87 |
|
this->tfile = new TFile(m_filename.c_str()); |
88 |
|
gErrorIgnoreLevel=currlevel; |
89 |
|
this->events=(TTree*)(this->tfile)->Get(treename.c_str()); |
90 |
< |
if(Verbosity>0) cout << "The " << write_mc_or_data(is_data) << " file " << this->filename << " has been added successfully to the list of samples. " << endl; |
90 |
> |
if(Verbosity>0) dout << "The " << write_mc_or_data(is_data) << " file " << this->filename << " has been added successfully to the list of samples. " << endl; |
91 |
|
} |
92 |
|
else { |
93 |
|
this->is_active=false; |
101 |
|
(this->tfile)->Close(); |
102 |
|
} |
103 |
|
else { |
104 |
< |
cout << "SAMPLE " << this->samplename << " cannot be closed as the underlying file (" << this->filename << ") does not exist!" << endl; |
104 |
> |
dout << "SAMPLE " << this->samplename << " cannot be closed as the underlying file (" << this->filename << ") does not exist!" << endl; |
105 |
|
this->is_active=false; |
106 |
|
} |
107 |
|
} |
114 |
|
TFile *f = new TFile(filename.c_str()); |
115 |
|
|
116 |
|
if (f->IsZombie()) { |
117 |
< |
cout << "Error opening file" << filename << endl; |
117 |
> |
dout << "Error opening file" << filename << endl; |
118 |
|
return 0; |
119 |
|
} |
120 |
|
f->Close(); |
171 |
|
samplecollection::samplecollection(string m_name) |
172 |
|
{ |
173 |
|
this->name=m_name; |
174 |
< |
if(Verbosity>0) cout << "Initiated sample collection " << this->name << " " << endl; |
174 |
> |
if(Verbosity>0) dout << "Initiated sample collection " << this->name << " " << endl; |
175 |
|
} |
176 |
|
|
177 |
|
void samplecollection::ListSamples() |
178 |
|
{ |
179 |
< |
cout << "---------------------------------------------------------------------------------------------------" << endl; |
180 |
< |
cout << "Listing all " << this->nsamples << " sample(s) of the sample collection called " << this->name << " : " << endl; |
179 |
> |
dout << "---------------------------------------------------------------------------------------------------" << endl; |
180 |
> |
dout << "Listing all " << this->nsamples << " sample(s) of the sample collection called " << this->name << " : " << endl; |
181 |
|
if(this->ndatasamples>0) { |
182 |
< |
cout << "Data sample(s): " << endl; |
182 |
> |
dout << "Data sample(s): " << endl; |
183 |
|
for (int isamp=0;isamp<this->collection.size();isamp++) |
184 |
|
{ |
185 |
< |
if((this->collection)[isamp].is_data) cout << " - " << (this->collection)[isamp].samplename << " from " << (this->collection)[isamp].filename << endl; |
185 |
> |
if((this->collection)[isamp].is_data) dout << " - " << (this->collection)[isamp].samplename << " from " << (this->collection)[isamp].filename << endl; |
186 |
|
} |
187 |
|
} |
188 |
|
if(this->nmcsamples>0) { |
189 |
< |
cout << "MC sample(s): " << endl; |
189 |
> |
dout << "MC sample(s): " << endl; |
190 |
|
for (int isamp=0;isamp<this->collection.size();isamp++) |
191 |
|
{ |
192 |
< |
if(!(this->collection)[isamp].is_data) cout << " - " << (this->collection)[isamp].samplename << " from " << (this->collection)[isamp].filename << endl; |
192 |
> |
if(!(this->collection)[isamp].is_data) dout << " - " << (this->collection)[isamp].samplename << " from " << (this->collection)[isamp].filename << endl; |
193 |
|
} |
194 |
|
} |
195 |
< |
cout << "---------------------------------------------------------------------------------------------------" << endl; |
195 |
> |
dout << "---------------------------------------------------------------------------------------------------" << endl; |
196 |
|
} |
197 |
|
|
198 |
|
void samplecollection::AddSample(string m_filename,string m_samplename,int m_Nentries, float m_xs,bool is_data, bool m_is_signal, int groupindex, Color_t newcolor) |
239 |
|
} |
240 |
|
|
241 |
|
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) { |
242 |
< |
if(Verbosity>0) cout << endl << endl; |
243 |
< |
if(Verbosity>0) cout << "-------------------------------------------------------------------------------------" << endl; |
244 |
< |
if(Verbosity>0) cout << "histoname : " << m_histoname << " , m_var = " << m_var << ", m_xlabel=" << m_xlabel << " m_ylabel=" << m_ylabel << " m_is_data = " << m_is_data << " lumi = " << luminosity << " onlyindex size: " << onlyindex.size() << endl; |
245 |
< |
if(HUSH==0) cout << "Drawing histo called " << m_histoname << "... " << endl; |
242 |
> |
if(Verbosity>0) dout << endl << endl; |
243 |
> |
if(Verbosity>0) dout << "-------------------------------------------------------------------------------------" << endl; |
244 |
> |
if(Verbosity>0) dout << "histoname : " << m_histoname << " , m_var = " << m_var << ", m_xlabel=" << m_xlabel << " m_ylabel=" << m_ylabel << " m_is_data = " << m_is_data << " lumi = " << luminosity << " onlyindex size: " << onlyindex.size() << endl; |
245 |
> |
if(HUSH==0) dout << "Drawing histo called " << m_histoname << "... " << endl; |
246 |
|
bool do_only_selected_samples=false; |
247 |
|
if(onlyindex.size()>0&&onlyindex[0]!=-1) { |
248 |
< |
if(Verbosity>0) {cout << "Requested to only draw sample corresponding to the following sample(s) : " << endl;} |
248 |
> |
if(Verbosity>0) {dout << "Requested to only draw sample corresponding to the following sample(s) : " << endl;} |
249 |
|
for(int is=0;is<onlyindex.size();is++) { |
250 |
< |
if(Verbosity>0) cout << " - " << (this->collection)[onlyindex[is]].filename << " (sample index: " << onlyindex[is] << ")" << endl; |
250 |
> |
if(Verbosity>0) dout << " - " << (this->collection)[onlyindex[is]].filename << " (sample index: " << onlyindex[is] << ")" << endl; |
251 |
|
} |
252 |
|
do_only_selected_samples=true; |
253 |
|
} |
278 |
|
TH1F *tempdrawhisto = new TH1F("tempdrawhisto","tempdrawhisto",binning.size()-1,binningarray); |
279 |
|
tempdrawhisto->Sumw2(); |
280 |
|
if(use_this_sample) { |
281 |
< |
if(Verbosity>0) cout << "[samplecollection::Draw] : Added contribution from sample " << (this->collection)[isample].samplename << endl; |
281 |
> |
if(Verbosity>0) dout << "[samplecollection::Draw] : Added contribution from sample " << (this->collection)[isample].samplename << endl; |
282 |
|
(this->collection)[isample].events->Draw(drawthis.str().c_str(),(essentialcut&&Cut)*"weight");//this weight is based on PU etc. not XS |
283 |
|
if(addoverunderflowbins) { |
284 |
|
//now also adding the overflow & underflow bins: |
293 |
|
} |
294 |
|
tempdrawhisto->Delete(); |
295 |
|
}//end of loop over isample |
296 |
< |
if(Verbosity>0) cout << "Histo has been filled and now contains " << histo->Integral() << " points (integral)" << endl; |
296 |
> |
if(Verbosity>0) dout << "Histo has been filled and now contains " << histo->Integral() << " points (integral)" << endl; |
297 |
|
histo->GetXaxis()->SetTitle(m_xlabel.c_str()); |
298 |
|
histo->GetYaxis()->SetTitle(m_ylabel.c_str()); |
299 |
|
histo->GetXaxis()->CenterTitle(); |
303 |
|
} |
304 |
|
|
305 |
|
TH2F* samplecollection::Draw(string m_histoname,string m_var, vector<float> binningx, vector<float> binningy, string m_xlabel, string m_ylabel, TCut Cut, bool m_is_data, float luminosity, vector<int> onlyindex, bool drawsignal=false) { |
306 |
< |
if(Verbosity>0) cout << endl << endl; |
307 |
< |
if(Verbosity>0) cout << "-------------------------------------------------------------------------------------" << endl; |
308 |
< |
if(Verbosity>0) cout << "histoname : " << m_histoname << " , m_var = " << m_var << ", m_xlabel=" << m_xlabel << " m_ylabel=" << m_ylabel << " m_is_data = " << m_is_data << " lumi = " << luminosity << " onlyindex size: " << onlyindex.size() << endl; |
309 |
< |
if(HUSH==0) cout << "Drawing histo called " << m_histoname << "... " << endl; |
306 |
> |
if(Verbosity>0) dout << endl << endl; |
307 |
> |
if(Verbosity>0) dout << "-------------------------------------------------------------------------------------" << endl; |
308 |
> |
if(Verbosity>0) dout << "histoname : " << m_histoname << " , m_var = " << m_var << ", m_xlabel=" << m_xlabel << " m_ylabel=" << m_ylabel << " m_is_data = " << m_is_data << " lumi = " << luminosity << " onlyindex size: " << onlyindex.size() << endl; |
309 |
> |
if(HUSH==0) dout << "Drawing histo called " << m_histoname << "... " << endl; |
310 |
|
bool do_only_selected_samples=false; |
311 |
|
if(onlyindex.size()>0&&onlyindex[0]!=-1) { |
312 |
< |
if(Verbosity>0) {cout << "Requested to only draw sample corresponding to the following sample(s) : " << endl;} |
312 |
> |
if(Verbosity>0) {dout << "Requested to only draw sample corresponding to the following sample(s) : " << endl;} |
313 |
|
for(int is=0;is<onlyindex.size();is++) { |
314 |
< |
if(Verbosity>0) cout << " - " << (this->collection)[onlyindex[is]].filename << " (sample index: " << onlyindex[is] << ")" << endl; |
314 |
> |
if(Verbosity>0) dout << " - " << (this->collection)[onlyindex[is]].filename << " (sample index: " << onlyindex[is] << ")" << endl; |
315 |
|
} |
316 |
|
do_only_selected_samples=true; |
317 |
|
} |
343 |
|
TH2F *tempdrawhisto = new TH2F("tempdrawhisto","tempdrawhisto",binningx.size()-1,binningarray,binningy.size()-1,binningyarray); |
344 |
|
tempdrawhisto->Sumw2(); |
345 |
|
if(use_this_sample) { |
346 |
< |
if(Verbosity>0) cout << "[samplecollection::Draw] : Added contribution from sample " << (this->collection)[isample].samplename << endl; |
346 |
> |
if(Verbosity>0) dout << "[samplecollection::Draw] : Added contribution from sample " << (this->collection)[isample].samplename << endl; |
347 |
|
(this->collection)[isample].events->Draw(drawthis.str().c_str(),(essentialcut&&Cut)*"weight");//this weight is based on PU etc. not XS |
348 |
|
if(addoverunderflowbins) { |
349 |
|
//now also adding the overflow & underflow bins: |
358 |
|
} |
359 |
|
tempdrawhisto->Delete(); |
360 |
|
}//end of loop over isample |
361 |
< |
if(Verbosity>0) cout << "Histo has been filled and now contains " << histo->Integral() << " points (integral)" << endl; |
361 |
> |
if(Verbosity>0) dout << "Histo has been filled and now contains " << histo->Integral() << " points (integral)" << endl; |
362 |
|
histo->GetXaxis()->SetTitle(m_xlabel.c_str()); |
363 |
|
histo->GetYaxis()->SetTitle(m_ylabel.c_str()); |
364 |
|
histo->GetXaxis()->CenterTitle(); |
508 |
|
|
509 |
|
|
510 |
|
void set_treename(string treen="events") { |
511 |
< |
cout << "Treename has been set to " << treen << endl; |
511 |
> |
dout << "Treename has been set to " << treen << endl; |
512 |
|
if(treen=="PFevents"||treen=="events") treename=treen; |
513 |
|
else write_error("sample::set_treename","Setting the treename failed as you provided an invalid tree name."); |
514 |
|
} |
552 |
|
(this->collection)[isamp].events->LoadTree(entry); |
553 |
|
if (select->EvalInstance()) { |
554 |
|
(this->collection)[isamp].events->GetEntry(entry); |
555 |
< |
cout << runNum << ":" << lumi << ":" << eventNum << endl; |
555 |
> |
dout << runNum << ":" << lumi << ":" << eventNum << endl; |
556 |
|
npickedup++; |
557 |
|
} |
558 |
|
} |
559 |
< |
cout << "Printed out a total of " << npickedup << " events" << endl; |
559 |
> |
dout << "Printed out a total of " << npickedup << " events" << endl; |
560 |
|
} |
561 |
|
|
562 |
|
|