32 |
|
|
33 |
|
bool doesROOTFileExist(string filename); |
34 |
|
bool addoverunderflowbins=false; |
35 |
< |
string treename="PFevents"; |
35 |
> |
string treename="events"; |
36 |
|
|
37 |
|
class sample |
38 |
|
{ |
95 |
|
this->tfile = new TFile(m_filename.c_str()); |
96 |
|
// gErrorIgnoreLevel=currlevel; |
97 |
|
this->events=(TTree*)(this->tfile)->Get(treename.c_str()); |
98 |
+ |
// this->events->SetCacheSize(5000000);//only a 5 MB cache! |
99 |
|
if(Verbosity>0) dout << "The " << write_mc_or_data(is_data) << " file " << this->filename << " has been added successfully to the list of samples. " << endl; |
100 |
|
long long measured_nevents=(long)1; |
101 |
|
TH1F *weight_histo = (TH1F*)(this->tfile)->Get("weight_histo"); |
213 |
|
TLegend* allbglegend(string title,float x, float y); |
214 |
|
TLegend* allbglegend(string title, TH1F *data, float x, float y); |
215 |
|
|
216 |
< |
void PickUpFromThisFile(int isamp, string cut, vector<string> &output, vector<string> &pickupfile); |
217 |
< |
void PickUpEvents(string cut,string filename); |
216 |
> |
void PickUpFromThisFile(int isamp, string cut, vector<string> &output, vector<string> &pickupfile, bool QuietMode); |
217 |
> |
void PickUpEvents(string cut,string filename,bool QuietMode); |
218 |
|
string find_units(string&); |
219 |
|
|
220 |
|
void RemoveLastSample(); |
294 |
|
return histo; |
295 |
|
} |
296 |
|
|
297 |
+ |
|
298 |
|
TH1F* samplecollection::Draw(string m_histoname,string m_var, vector<float> binning, string m_xlabel, string m_ylabel, TCut Cut, bool m_is_data, float luminosity, vector<int> onlyindex, bool drawsignal=false) { |
299 |
|
if(Verbosity>0) dout << endl << endl; |
300 |
|
if(Verbosity>0) dout << "-------------------------------------------------------------------------------------" << endl; |
338 |
|
if(use_this_sample) { |
339 |
|
(this->collection)[isample].events->Draw(drawthis.str().c_str(),(essentialcut&&Cut)*cutWeight);//this weight is based on PU etc. not XS |
340 |
|
// cout << "\033[1;33m Drawing " << drawthis.str() << " with cut " << (const char*) (essentialcut&&Cut)*cutWeight << " for sample " << (this->collection)[isample].filename << "\033[0m (overflow: " << addoverunderflowbins << ")" << endl; |
341 |
+ |
// cout << "Drawing for : " << (this->collection)[isample].filename << endl; |
342 |
+ |
// for(int i=1;i<=tempdrawhisto->GetNbinsX();i++) cout << " Bin " << i << " [" << tempdrawhisto->GetBinLowEdge(i) << "," << tempdrawhisto->GetBinLowEdge(i)+tempdrawhisto->GetBinWidth(i) << "] : " << tempdrawhisto->GetBinContent(i) << " +/- " << tempdrawhisto->GetBinError(i) << endl; |
343 |
|
if(addoverunderflowbins) { |
344 |
|
//now also adding the overflow & underflow bins: |
345 |
|
tempdrawhisto->SetBinContent(tempdrawhisto->GetNbinsX(),tempdrawhisto->GetBinContent(tempdrawhisto->GetNbinsX()+1)+tempdrawhisto->GetBinContent(tempdrawhisto->GetNbinsX())); |
393 |
|
} |
394 |
|
stringstream h_histoname; |
395 |
|
h_histoname<<"h_"<<m_histoname; |
396 |
< |
float binningarray[binningx.size()+1]; |
393 |
< |
float binningyarray[binningy.size()+1]; |
394 |
< |
for(int i=0;i<(int)binningx.size();i++) {binningarray[i]=binningx[i];binningyarray[i]=binningy[i];} |
395 |
< |
TH2F *histo = new TH2F(m_histoname.c_str(),"",binningx.size()-1,binningarray,binningy.size()-1,binningyarray); |
396 |
> |
TH2F *histo = new TH2F(m_histoname.c_str(),"",binningx.size()-1,&binningx[0],binningy.size()-1,&binningy[0]); |
397 |
|
histo->Sumw2(); |
398 |
|
|
399 |
|
stringstream drawthis; |
409 |
|
if(do_only_selected_samples&&this->do_sample(isample,onlyindex)) { |
410 |
|
use_this_sample=true; |
411 |
|
} |
412 |
< |
TH2F *tempdrawhisto = new TH2F("tempdrawhisto","tempdrawhisto",binningx.size()-1,binningarray,binningy.size()-1,binningyarray); |
412 |
> |
TH2F *tempdrawhisto = new TH2F("tempdrawhisto","tempdrawhisto",binningx.size()-1,&binningx[0],binningy.size()-1,&binningy[0]); |
413 |
|
tempdrawhisto->Sumw2(); |
414 |
|
if(use_this_sample) { |
415 |
|
if(Verbosity>0) dout << "[samplecollection::Draw] : Added contribution from sample " << (this->collection)[isample].samplename << endl; |
471 |
|
TH1F *tempdrawhisto = new TH1F("tempdrawhisto","",binning.size()-1,binningarray); |
472 |
|
tempdrawhisto->Sumw2(); |
473 |
|
(this->collection)[isample].events->Draw(drawthis.str().c_str(),(essentialcut&&Cut)*cutWeight); |
474 |
< |
|
474 |
> |
// cout << "\033[1;33m Drawing " << drawthis.str() << " with cut " << (const char*) (essentialcut&&Cut)*cutWeight << " for sample " << (this->collection)[isample].filename << "\033[0m (overflow: " << addoverunderflowbins << ")" << endl; |
475 |
|
if(addoverunderflowbins) { |
476 |
|
//now also adding the overflow & underflow bins: |
477 |
|
tempdrawhisto->SetBinContent(tempdrawhisto->GetNbinsX(),tempdrawhisto->GetBinContent(tempdrawhisto->GetNbinsX()+1)+tempdrawhisto->GetBinContent(tempdrawhisto->GetNbinsX())); |
649 |
|
|
650 |
|
} |
651 |
|
|
652 |
< |
void samplecollection::PickUpFromThisFile(int isamp, string cut, vector<string> &output, vector<string> &pickupfile) { |
652 |
> |
void samplecollection::PickUpFromThisFile(int isamp, string cut, vector<string> &output, vector<string> &pickupfile, bool QuietMode) { |
653 |
|
int lumi,runNum; |
654 |
|
ULong64_t eventNum; |
655 |
|
|
668 |
|
(this->collection)[isamp].events->LoadTree(entry); |
669 |
|
if (select->EvalInstance()) { |
670 |
|
(this->collection)[isamp].events->GetEntry(entry); |
671 |
< |
dout << runNum << ":" << lumi << ":" << eventNum << endl; |
671 |
> |
if(!QuietMode) dout << runNum << ":" << lumi << ":" << eventNum << endl; |
672 |
|
filetext.str(""); |
673 |
|
filetext << runNum << ":" << lumi << ":" << eventNum << endl; |
674 |
|
output.push_back(filetext.str()); |
675 |
|
npickedup++; |
676 |
|
} |
677 |
|
} |
678 |
< |
dout << "Printed out a total of " << npickedup << " events" << endl; |
678 |
> |
if(!QuietMode) dout << "Printed out a total of " << npickedup << " events" << endl; |
679 |
|
} |
680 |
|
|
681 |
|
|
682 |
|
|
683 |
< |
void samplecollection::PickUpEvents(string cut, string filename) { |
683 |
> |
void samplecollection::PickUpEvents(string cut, string filename, bool QuietMode=false) { |
684 |
|
vector<string> output; |
685 |
|
vector<string> pickupfile; |
686 |
|
for (unsigned int isamp=0;isamp<this->collection.size();isamp++) |
687 |
|
{ |
688 |
|
if((this->collection)[isamp].is_data) { |
689 |
|
//we have a data sample ! |
690 |
< |
this->PickUpFromThisFile(isamp,cut,output,pickupfile); |
690 |
> |
this->PickUpFromThisFile(isamp,cut,output,pickupfile,QuietMode); |
691 |
|
} |
692 |
|
} |
693 |
|
|