53 |
|
TTree *events; |
54 |
|
|
55 |
|
sample(string m_filename,string m_samplename,long m_Nentries, float m_xs,bool is_data, bool m_is_signal, int m_groupindex, Color_t color); |
56 |
+ |
string ExtractVersion(string FullVersionString); |
57 |
|
void closeFile(); |
58 |
|
}; |
59 |
|
|
63 |
|
return "MC"; |
64 |
|
} |
65 |
|
|
66 |
+ |
string sample::ExtractVersion(string FullVersionString) { |
67 |
+ |
string Result=FullVersionString.substr(FullVersionString.find(" ")+1,FullVersionString.length()); |
68 |
+ |
Result=Result.substr(0,Result.find(" ")); |
69 |
+ |
return Result; |
70 |
+ |
} |
71 |
+ |
|
72 |
|
sample::sample(string m_filename, string m_samplename, long m_Nentries, float m_xs,bool m_is_data, bool m_is_signal, int m_groupindex, Color_t mycolor) |
73 |
|
{ |
74 |
|
this->filename=m_filename; |
100 |
|
TH1F *weight_histo = (TH1F*)(this->tfile)->Get("weight_histo"); |
101 |
|
float average_weight = 1.0; |
102 |
|
if(weight_histo) { |
103 |
< |
average_weight = weight_histo->Integral()/weight_histo->GetEntries(); |
103 |
> |
//average_weight = weight_histo->Integral()/weight_histo->GetEntries(); |
104 |
|
measured_nevents = (long)weight_histo->GetEntries(); |
105 |
|
} else { |
106 |
|
measured_nevents=(this->events)->GetEntries(); |
130 |
|
this->weightrenormalization=1; |
131 |
|
} |
132 |
|
} |
133 |
+ |
|
134 |
|
} |
135 |
|
else { |
136 |
|
this->is_active=false; |
240 |
|
dout << "MC sample(s): " << endl; |
241 |
|
for (int isamp=0;isamp<(int)this->collection.size();isamp++) |
242 |
|
{ |
243 |
< |
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 << " , RN = " << (this->collection)[isamp].weightrenormalization << endl; |
243 |
> |
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; |
244 |
|
} |
245 |
|
} |
246 |
|
dout << "---------------------------------------------------------------------------------------------------" << endl; |
335 |
|
tempdrawhisto->Sumw2(); |
336 |
|
if(use_this_sample) { |
337 |
|
(this->collection)[isample].events->Draw(drawthis.str().c_str(),(essentialcut&&Cut)*cutWeight);//this weight is based on PU etc. not XS |
338 |
< |
// 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; |
338 |
> |
// 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; |
339 |
|
if(addoverunderflowbins) { |
340 |
|
//now also adding the overflow & underflow bins: |
341 |
|
tempdrawhisto->SetBinContent(tempdrawhisto->GetNbinsX(),tempdrawhisto->GetBinContent(tempdrawhisto->GetNbinsX()+1)+tempdrawhisto->GetBinContent(tempdrawhisto->GetNbinsX())); |
468 |
|
if(!drawsignal&&(this->collection)[isample].is_signal) continue; |
469 |
|
if((this->collection)[isample].is_active&&(this->collection)[isample].is_data==m_is_data) {//fills mc if we want mc, else fills data. |
470 |
|
TH1F *tempdrawhisto = new TH1F("tempdrawhisto","",binning.size()-1,binningarray); |
471 |
+ |
tempdrawhisto->Sumw2(); |
472 |
|
(this->collection)[isample].events->Draw(drawthis.str().c_str(),(essentialcut&&Cut)*cutWeight); |
473 |
|
|
474 |
|
if(addoverunderflowbins) { |
582 |
|
leg->SetBorderSize(0); |
583 |
|
leg->SetLineColor(kWhite); |
584 |
|
|
585 |
< |
TH1F *fakehistos[(this->collection).size()]; |
586 |
< |
bool donealready[(this->collection).size()]; |
587 |
< |
for(int i=0;i<(int)(this->collection).size();i++) donealready[i]=false; |
585 |
> |
int maxIgroup=0; |
586 |
> |
for(int isample=0;isample<(int)(this->collection).size();isample++) { |
587 |
> |
if((this->collection)[isample].groupindex>maxIgroup) maxIgroup=(this->collection)[isample].groupindex+1; |
588 |
> |
} |
589 |
> |
|
590 |
> |
TH1F *fakehistos[maxIgroup]; |
591 |
> |
bool donealready[maxIgroup]; |
592 |
> |
|
593 |
> |
for(int i=0;i<maxIgroup;i++) donealready[i]=false; |
594 |
|
for(int isample=0;isample<(int)(this->collection).size();isample++) { |
595 |
|
if((this->collection)[isample].is_data||(this->collection)[isample].is_signal) continue; |
596 |
|
|
600 |
|
fakehistos[(this->collection)[isample].groupindex]->SetFillColor(this->GetColor(isample)); |
601 |
|
leg->AddEntry(fakehistos[(this->collection)[isample].groupindex],((this->collection)[isample].samplename).c_str(),"f"); |
602 |
|
donealready[(this->collection)[isample].groupindex]=true; |
603 |
+ |
PlottingSetup::FakeHistoHeap.push_back(fakehistos[(this->collection)[isample].groupindex]); |
604 |
|
} |
605 |
|
} |
606 |
|
DrawPrelim(); |
613 |
|
// gErrorIgnoreLevel=5000; |
614 |
|
TH1F *blub = new TH1F("nothing","nothing",1,0,1); |
615 |
|
// gErrorIgnoreLevel=currlevel;//we know this possibly replaces a previous histo, but we don't care since it's fake anyway. |
616 |
< |
return this->allbglegend(title,blub,posx,posy); |
616 |
> |
TLegend *leg = this->allbglegend(title,blub,posx,posy); |
617 |
> |
delete blub; |
618 |
> |
return leg; |
619 |
|
} |
620 |
|
|
621 |
|
|