87 |
|
gErrorIgnoreLevel=currlevel; |
88 |
|
this->events=(TTree*)(this->tfile)->Get(treename.c_str()); |
89 |
|
if(Verbosity>0) dout << "The " << write_mc_or_data(is_data) << " file " << this->filename << " has been added successfully to the list of samples. " << endl; |
90 |
< |
long long measured_nevents=(this->events)->GetEntries(); |
90 |
> |
long long measured_nevents=(long)1; |
91 |
> |
TH1F *weight_histo = (TH1F*)(this->tfile)->Get("weight_histo"); |
92 |
> |
float average_weight = 1.0; |
93 |
> |
if(weight_histo) { |
94 |
> |
average_weight = weight_histo->Integral()/weight_histo->GetEntries(); |
95 |
> |
measured_nevents = (long)weight_histo->GetEntries(); |
96 |
> |
} else { |
97 |
> |
measured_nevents=(this->events)->GetEntries(); |
98 |
> |
} |
99 |
> |
|
100 |
|
if(((this->Nentries>1)||(this->Nentries==0))&measured_nevents!=this->Nentries) { |
101 |
|
//special cases: m_Nentries=1 : we want to give each event the full weight (->scans!) |
102 |
|
// m_Nentries=0: detect the number of events and set the nevents automatically |
107 |
|
this->Nentries=measured_nevents; |
108 |
|
} |
109 |
|
this->weight=(xs/(float)Nentries); |
110 |
+ |
TH1F *weight_histo = (TH1F*)(this->tfile)->Get("weight_histo"); |
111 |
+ |
this->weight/=average_weight; |
112 |
|
} |
113 |
|
else { |
114 |
|
this->is_active=false; |
208 |
|
dout << "Listing all " << this->nsamples << " sample(s) of the sample collection called " << this->name << " : " << endl; |
209 |
|
if(this->ndatasamples>0) { |
210 |
|
dout << "Data sample(s): " << endl; |
211 |
< |
for (int isamp=0;isamp<this->collection.size();isamp++) |
211 |
> |
for (int isamp=0;isamp<(int)this->collection.size();isamp++) |
212 |
|
{ |
213 |
|
if((this->collection)[isamp].is_data) dout << " - " << (this->collection)[isamp].samplename << " from " << (this->collection)[isamp].filename << endl; |
214 |
|
} |
215 |
|
} |
216 |
|
if(this->nmcsamples>0) { |
217 |
|
dout << "MC sample(s): " << endl; |
218 |
< |
for (int isamp=0;isamp<this->collection.size();isamp++) |
218 |
> |
for (int isamp=0;isamp<(int)this->collection.size();isamp++) |
219 |
|
{ |
220 |
|
if(!(this->collection)[isamp].is_data) dout << " - " << (this->collection)[isamp].samplename << " (" << (this->collection)[isamp].filename << ") xs=" << (this->collection)[isamp].xs << " pb, N(events)=" << (this->collection)[isamp].Nentries << endl; |
221 |
|
} |
242 |
|
bool samplecollection::do_sample(int thissample, vector<int> &selected_samples) |
243 |
|
{ |
244 |
|
bool drawit=false; |
245 |
< |
for(int isel=0;isel<selected_samples.size();isel++) |
245 |
> |
for(int isel=0;isel<(int)selected_samples.size();isel++) |
246 |
|
{ |
247 |
|
if(selected_samples[isel]==thissample) { |
248 |
|
drawit=true; |
274 |
|
bool do_only_selected_samples=false; |
275 |
|
if(onlyindex.size()>0&&onlyindex[0]!=-1) { |
276 |
|
if(Verbosity>0) {dout << "Requested to only draw sample corresponding to the following sample(s) : " << endl;} |
277 |
< |
for(int is=0;is<onlyindex.size();is++) { |
277 |
> |
for(int is=0;is<(int)onlyindex.size();is++) { |
278 |
|
if(Verbosity>0) dout << " - " << (this->collection)[onlyindex[is]].filename << " (sample index: " << onlyindex[is] << ")" << endl; |
279 |
|
} |
280 |
|
do_only_selected_samples=true; |
286 |
|
stringstream h_histoname; |
287 |
|
h_histoname<<"h_"<<m_histoname; |
288 |
|
float binningarray[binning.size()+1]; |
289 |
< |
for(int i=0;i<binning.size();i++) {binningarray[i]=binning[i];} |
289 |
> |
for(int i=0;i<(int)binning.size();i++) {binningarray[i]=binning[i];} |
290 |
|
TH1F *histo = new TH1F(m_histoname.c_str(),"",binning.size()-1,binningarray); |
291 |
|
histo->Sumw2(); |
292 |
|
|
346 |
|
bool do_only_selected_samples=false; |
347 |
|
if(onlyindex.size()>0&&onlyindex[0]!=-1) { |
348 |
|
if(Verbosity>0) {dout << "Requested to only draw sample corresponding to the following sample(s) : " << endl;} |
349 |
< |
for(int is=0;is<onlyindex.size();is++) { |
349 |
> |
for(int is=0;is<(int)onlyindex.size();is++) { |
350 |
|
if(Verbosity>0) dout << " - " << (this->collection)[onlyindex[is]].filename << " (sample index: " << onlyindex[is] << ")" << endl; |
351 |
|
} |
352 |
|
do_only_selected_samples=true; |
359 |
|
h_histoname<<"h_"<<m_histoname; |
360 |
|
float binningarray[binningx.size()+1]; |
361 |
|
float binningyarray[binningy.size()+1]; |
362 |
< |
for(int i=0;i<binningx.size();i++) {binningarray[i]=binningx[i];binningyarray[i]=binningy[i];} |
362 |
> |
for(int i=0;i<(int)binningx.size();i++) {binningarray[i]=binningx[i];binningyarray[i]=binningy[i];} |
363 |
|
TH2F *histo = new TH2F(m_histoname.c_str(),"",binningx.size()-1,binningarray,binningy.size(),binningyarray); |
364 |
|
histo->Sumw2(); |
365 |
|
|
429 |
|
for(int ih=0;ih<=this->ngroups;ih++) bookedhistos[ih]=0; |
430 |
|
|
431 |
|
float binningarray[binning.size()+1]; |
432 |
< |
for(int i=0;i<binning.size();i++) {binningarray[i]=binning[i];} |
432 |
> |
for(int i=0;i<(int)binning.size();i++) {binningarray[i]=binning[i];} |
433 |
|
|
434 |
|
for (unsigned int isample=0;isample<(this->collection).size();isample++) { |
435 |
|
if(!drawsignal&&(this->collection)[isample].is_signal) continue; |
448 |
|
if(!(this->collection)[isample].is_data) tempdrawhisto->Scale(luminosity*((this->collection)[isample].weight)); |
449 |
|
tempdrawhisto->SetFillColor(this->GetColor(isample)); |
450 |
|
if(bookedhistos[(this->collection)[isample].groupindex]==0) { |
451 |
< |
tempdrawhisto->SetName(GetNumericHistoName().c_str()); |
451 |
> |
tempdrawhisto->SetName((removefunnystring((this->collection)[isample].samplename)+"__"+GetNumericHistoName()).c_str()); |
452 |
|
histogroups[(this->collection)[isample].groupindex]=(TH1F*)tempdrawhisto->Clone(); |
453 |
|
bookedhistos[(this->collection)[isample].groupindex]=1; |
454 |
|
} |
477 |
|
thestack.Add(histogroups[ordered_indices[index]]); |
478 |
|
} |
479 |
|
*/ |
480 |
< |
for(int index=0;index<ordered_indices.size();index++) { |
480 |
> |
for(int index=0;index<(int)ordered_indices.size();index++) { |
481 |
|
thestack.Add(histogroups[ordered_indices[index]]); |
482 |
|
} |
483 |
|
return thestack; |
550 |
|
|
551 |
|
TH1F *fakehistos[(this->collection).size()]; |
552 |
|
bool donealready[(this->collection).size()]; |
553 |
< |
for(int i=0;i<(this->collection).size();i++) donealready[i]=false; |
554 |
< |
for(int isample=0;isample<(this->collection).size();isample++) { |
553 |
> |
for(int i=0;i<(int)(this->collection).size();i++) donealready[i]=false; |
554 |
> |
for(int isample=0;isample<(int)(this->collection).size();isample++) { |
555 |
|
if((this->collection)[isample].is_data||(this->collection)[isample].is_signal) continue; |
556 |
|
|
557 |
|
if(!donealready[(this->collection)[isample].groupindex]) { |
634 |
|
void samplecollection::PickUpEvents(string cut) { |
635 |
|
vector<string> output; |
636 |
|
vector<string> pickupfile; |
637 |
< |
for (int isamp=0;isamp<this->collection.size();isamp++) |
637 |
> |
for (int isamp=0;isamp<(int)this->collection.size();isamp++) |
638 |
|
{ |
639 |
|
if((this->collection)[isamp].is_data) { |
640 |
|
//we have a data sample ! |