2 #include "boost/program_options.hpp" 3 #include "boost/algorithm/string.hpp" 31 TH1::SetDefaultSumw2();
33 exe_ = std::string(argv[0]);
43 config_ = std::make_shared<Config>(argc,argv);
47 if (
config_->outputRoot() !=
"" )
49 hout_= std::make_shared<TFile>(
config_->outputRoot().c_str(),
"recreate",Form(
"%s %s %s",argv[0],argv[1],argv[2]));
56 h1_[
"cutflow"] = std::make_shared<TH1F>(
"workflow",Form(
"Workflow #%d",
config_->workflow()), 100,0,100);
59 isMC_ = analysis_->isMC();
66 if ( analysis_ -> crossSections(
config_->crossSectionTree()) == 0 )
69 if (
config_->pileupWeights() !=
"" )
76 puw_label_ =
"*** missing *** assuming puweight = 1";
90 if (
config_->btagEfficiencies() !=
"" )
92 TFile
f(
config_->btagEfficiencies().c_str(),
"old");
93 auto list =
f.GetListOfKeys();
94 for (
int i = 0; i < list -> GetSize(); ++i)
96 TString item(list -> At(i) -> GetName());
97 if ( ! item.BeginsWith(
"eff_"))
continue;
99 btageff_[item.Data()] = std::shared_ptr<TGraphAsymmErrors>((TGraphAsymmErrors*)
f.Get((
"eff_"+item).Data()));
108 std::cout << std::endl;
111 for (
int i = 1; i <=
h1_[
"cutflow"] ->GetNbinsX(); ++i )
113 std::string label = std::string(
h1_[
"cutflow"]->GetXaxis()->GetBinLabel(i));
120 float fevts =
h1_[
"cutflow"] -> GetBinContent(lastbin);
123 bool doscale =
false;
140 if ( std::string(
h1_[
"cutflow"] -> GetXaxis()-> GetBinLabel(lastbin+1)) ==
"" )
142 h1_[
"cutflow"] -> GetXaxis()-> SetBinLabel(lastbin+1,Form(
"Number of events after scaling to %10.5f",scale));
144 h1_[
"cutflow"] -> Fill(lastbin,fevts*scale);
150 if (
h.first ==
"cutflow" ||
h.first ==
"pileup" ||
h.first ==
"pileup_w" )
continue;
151 if ( doscale )
h.second -> Scale(scale);
152 bool is_empty = (
h.second -> GetEntries() != 0 ||
h.second -> GetSumOfWeights() != 0 );
159 if ( doscale )
h.second -> Scale(scale);
160 bool is_empty = (
h.second -> GetEntries() != 0 ||
h.second -> GetSumOfWeights() != 0 );
161 if ( is_empty )
continue;
174 system(Form(
"Workflow %s",
config_->outputRoot().c_str()));
178 std::cout <<
"Problems with Workflow macro or the output file, no summary printed" << std::endl;
182 std::cout << std::endl;
183 std::cout <<
exe_ <<
" finished!" << std::endl;
184 printf(
"%s\n", std::string(100,
'_').c_str());
185 std::cout << std::endl;
187 std::ofstream finished;
188 finished.open(
"finished.txt");
189 finished <<
exe_ <<
"\n";
215 int maxevt =
config_->nEventsMax();
222 if (
h1_.find(hname) ==
h1_.end() )
224 std::cout <<
"-e- BaseAnalyser::H1F(const string & hname) -> no histogram with hname = " << hname << std::endl;
296 if ( !
config_->isMC() )
return -1;
303 if ( !
config_->isMC() )
return;
321 h1_[
"pileup_w"] = std::make_shared<TH1F>(
"pileup_w" ,
"weighted pileup" ,
config_->n() ,
config_->min() ,
config_->max() );
325 h1_[
"pileup"] = std::make_shared<TH1F>(
"pileup" ,
"pileup" , 100 , 0 , 100 );
326 h1_[
"pileup_w"] = std::make_shared<TH1F>(
"pileup_w" ,
"weighted pileup" , 100 , 0 , 100 );
350 if ( std::string(
h1_[
"cutflow"] -> GetXaxis()-> GetBinLabel(
cutflow_+1)) ==
"" )
352 h1_[
"cutflow"] -> GetXaxis()-> SetBinLabel(
cutflow_+1,label.c_str());
366 std::vector<std::string> paths;
369 boost::split(paths, name, boost::is_any_of(
"/"));
385 if ( !
config_->isMC() )
return;
388 if (
config_->fullGenWeight() )
394 float sign = (weight > 0) ? 1 : ((weight < 0) ? -1 : 0);
403 std::vector<TriggerObject> new_objects;
406 if ( name !=
"l1tJets" && name !=
"l1tMuons" )
410 for (
int i = 0 ; i < objects->size() ; ++i )
413 if ( obj.
pt() >= ptmin && fabs(obj.
eta()) <= etamax )
415 new_objects.push_back(obj);
421 if ( name ==
"l1tJets" )
425 for (
int i = 0 ; i < l1tjets->size() ; ++i )
427 L1TJet l1tjet = l1tjets -> at(i);
428 float pt = l1tjet.
pt();
429 float eta = l1tjet.
eta();
430 float phi = l1tjet.
phi();
431 float e = l1tjet.
e();
433 if ( obj.
pt() >= ptmin && fabs(obj.
eta()) <= etamax )
435 new_objects.push_back(obj);
440 if ( name ==
"l1tMuons" )
444 for (
int i = 0 ; i < l1tmuons->size() ; ++i )
446 L1TMuon l1tmuon = l1tmuons -> at(i);
447 float pt = l1tmuon.
pt();
448 float eta = l1tmuon.
eta();
449 float phi = l1tmuon.
phi();
450 float e = l1tmuon.
e();
452 if ( obj.
pt() >= ptmin && fabs(obj.
eta()) <= etamax )
454 new_objects.push_back(obj);
459 trg_emul_[newname] = ( (
int)new_objects.size() >= nmin );
462 analysis_->addCollection(new_collection);