Main Page | Modules | Namespace List | Class Hierarchy | Class List | File List | Namespace Members | Class Members | File Members

BTagJetBrowsable.cpp

Go to the documentation of this file.
00001 
00002 
00003 
00004 
00005 
00006 #include "tmb_tree/BTagJetBrowsable.hpp"
00007 #include "tmb_tree/TMBJet.hpp"
00008 
00009 #include "TBranch.h"
00010 #include "TTree.h"
00011 #include "TBrowser.h"
00012 #include "TPad.h"
00013 
00014 #include <iostream>
00015 #include <sstream>
00016 ClassImp(BTagJetBrowsable)
00017 
00018 // Wrapper for the registration method. Needed against MSVC, which 
00019 // assigned different addr to the same method, depending on what
00020 // translation unit you're in...
00021 void BTagJetBrowsable::Register() {
00022   TVirtualBranchBrowsable::RegisterGenerator(GetBrowsables);
00023 }
00024 
00025 // Wrapper for the registration method. Needed against MSVC, which 
00026 // assigned different addr to the same method, depending on what
00027 // translation unit you're in...
00028 void BTagJetBrowsable::Unregister() {
00029   TVirtualBranchBrowsable::UnregisterGenerator(GetBrowsables);
00030 }
00031 
00037 Int_t BTagJetBrowsable::GetBrowsables(TList& li, const TBranch* branch,
00038                                                                           const TVirtualBranchBrowsable* parent)
00039 {
00044 
00045   TClass* clContained=0;
00046   TClass* clCollection=GetCollectionContainedType(branch, parent, clContained);
00047   if (!clCollection || !clContained) return 0;
00048 
00049   if (clContained != TMBJet::Class()) {
00050         return 0;
00051   }
00052 
00060 
00061   TString scope;
00062   if (parent) {
00063         parent->GetScope(scope);
00064         branch=parent->GetBranch();
00065   } else if (branch){
00066         scope=branch->GetName();
00067         scope+=".";
00068         const TBranch* mother=branch;
00069         while (mother != mother->GetMother() && (mother=mother->GetMother())) {
00070           TString nameMother(mother->GetName());
00071           if (!nameMother.EndsWith(".")) {
00072                 scope.Prepend(".");
00073                 scope.Prepend(nameMother);
00074           } else {
00075                 if (mother != mother->GetMother()) {
00076                   // If the mother is the top level mother
00077                   // and its ends ends with a ., the name is already
00078                   // embedded!
00079                   scope.Prepend(nameMother);
00080                 }
00081           }
00082         }
00083   } else {
00087 
00088         return 0;
00089   }
00090 
00091   // remove trailing delimiters
00092   if (scope.EndsWith(".")) scope.Remove(scope.Length()-1, 1);
00093   else if (scope.EndsWith("->")) scope.Remove(scope.Length()-2, 2);
00094 
00098 
00099   typedef std::vector<std::pair<std::string, std::string> > algs_to_do_type;
00100   algs_to_do_type algs_to_do;
00101   algs_to_do.push_back (std::make_pair ("SVT", "TIGHT"));
00102   algs_to_do.push_back (std::make_pair ("SVT", "MEDIUM"));
00103   algs_to_do.push_back (std::make_pair ("SVT", "LOOSE"));
00104   algs_to_do.push_back (std::make_pair ("JLIP", "TIGHT"));
00105   algs_to_do.push_back (std::make_pair ("JLIP", "MEDIUM"));
00106   algs_to_do.push_back (std::make_pair ("JLIP", "LOOSE"));
00107   algs_to_do.push_back (std::make_pair ("NN", "TIGHT"));
00108   algs_to_do.push_back (std::make_pair ("NN", "MEDIUM"));
00109   algs_to_do.push_back (std::make_pair ("NN", "LOOSE"));
00110 
00111   for (algs_to_do_type::const_iterator itr = algs_to_do.begin(); itr != algs_to_do.end(); itr++) {
00112         std::ostringstream thecall, thename, thetitle;
00113         thecall << scope.Data() << ".GetBTag("
00114           << "\"" << itr->first << "\","
00115           << "\"" << itr->second << "\")"
00116           << "->is_tagged()";
00117 
00118         thename << "@Tagged_" << itr->first << "_" << itr->second;
00119         thetitle << "Jet has a " << itr->first << " " << itr->second << " tag";
00120 
00121         BTagJetBrowsable *bb = new BTagJetBrowsable (thename.str().c_str(), thetitle.str().c_str(),
00122           thecall.str().c_str(), branch, parent);
00123         li.Add (bb);
00124   }
00125 
00126 
00127   return li.GetEntries();
00128 }
00129 
00137 void BTagJetBrowsable::Browse(TBrowser *b) {
00138   GetBranch()->GetTree()->Draw(GetDraw(), "", b ? b->GetDrawOption() : "");
00139   if (gPad) gPad->Update();
00140 }

Generated on Tue Mar 28 10:13:03 2006 for CAF by doxygen 1.3.4