99 |
|
measured_nevents=(this->events)->GetEntries(); |
100 |
|
} |
101 |
|
|
102 |
< |
if(((this->Nentries>1)||(this->Nentries==0))&measured_nevents!=this->Nentries) { |
102 |
> |
if(((this->Nentries>1)||(this->Nentries==0))&&measured_nevents!=this->Nentries) { |
103 |
|
//special cases: m_Nentries=1 : we want to give each event the full weight (->scans!) |
104 |
|
// m_Nentries=0: detect the number of events and set the nevents automatically |
105 |
+ |
// m_Nentries<0: set manually (see below) |
106 |
|
|
107 |
|
stringstream warning; |
108 |
|
warning << "Detected incorrect number of events in sample initialization of sample " << m_filename << " (detected Nevents: " << measured_nevents << " , definition claims: " << this->Nentries << "; will use measured number of events. If you want to use this algorithm to set the number of events anyway, set the number of events to 0."; |
109 |
|
if(m_Nentries>1) write_warning(__FUNCTION__,warning.str()); |
110 |
|
this->Nentries=measured_nevents; |
111 |
+ |
} else if ( this->Nentries<0 ) { |
112 |
+ |
this->Nentries = -this->Nentries; |
113 |
+ |
} |
114 |
+ |
if ( average_weight>0 ) { |
115 |
+ |
this->weight=(xs/(float)Nentries)/average_weight; |
116 |
+ |
this->weightrenormalization=(1.0/average_weight); |
117 |
+ |
} else { |
118 |
+ |
if(average_weight>0) { |
119 |
+ |
this->weight=(xs/(float)Nentries)/average_weight; |
120 |
+ |
this->weightrenormalization=(1.0/average_weight); |
121 |
+ |
} else { |
122 |
+ |
this->weight = (xs/(float)Nentries); |
123 |
+ |
this->weightrenormalization=1; |
124 |
+ |
} |
125 |
|
} |
111 |
– |
this->weight=(xs/(float)Nentries)/average_weight; |
112 |
– |
this->weightrenormalization=(1.0/average_weight); |
126 |
|
} |
127 |
|
else { |
128 |
|
this->is_active=false; |
161 |
|
TCut essentialcut("mll>0"); |
162 |
|
// The following cut (cutWeight) will reweight all the events: use "weight" to correct MC for pileUP, "1.0" otherwise |
163 |
|
TCut cutWeight("weight"); |
164 |
+ |
//TCut cutWeight("(weight*(((id1==id2&&id1==0)*1.2)+((id1==id2&&id1==1)/1.2)+(id1!=id2)))"); |
165 |
|
|
166 |
|
void setessentialcut(TCut ess) { |
167 |
|
essentialcut=ess; |
322 |
|
TH1F *tempdrawhisto = new TH1F("tempdrawhisto","tempdrawhisto",binning.size()-1,binningarray); |
323 |
|
tempdrawhisto->Sumw2(); |
324 |
|
if(use_this_sample) { |
311 |
– |
if(Verbosity>0) dout << "[samplecollection::Draw] : Added contribution from sample " << (this->collection)[isample].samplename << endl; |
325 |
|
(this->collection)[isample].events->Draw(drawthis.str().c_str(),(essentialcut&&Cut)*cutWeight);//this weight is based on PU etc. not XS |
326 |
+ |
// 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; |
327 |
|
if(addoverunderflowbins) { |
328 |
|
//now also adding the overflow & underflow bins: |
329 |
|
tempdrawhisto->SetBinContent(tempdrawhisto->GetNbinsX(),tempdrawhisto->GetBinContent(tempdrawhisto->GetNbinsX()+1)+tempdrawhisto->GetBinContent(tempdrawhisto->GetNbinsX())); |
330 |
|
tempdrawhisto->SetBinError(tempdrawhisto->GetNbinsX(),TMath::Sqrt(tempdrawhisto->GetBinContent(tempdrawhisto->GetNbinsX()))); |
331 |
< |
tempdrawhisto->SetBinContent(1,tempdrawhisto->GetBinContent(0)+tempdrawhisto->GetBinContent(1)); |
332 |
< |
tempdrawhisto->SetBinError(1,TMath::Sqrt(tempdrawhisto->GetBinContent(1))); |
331 |
> |
// tempdrawhisto->SetBinContent(1,tempdrawhisto->GetBinContent(0)+tempdrawhisto->GetBinContent(1)); |
332 |
> |
// tempdrawhisto->SetBinError(1,TMath::Sqrt(tempdrawhisto->GetBinContent(1))); |
333 |
> |
// Delete over- and under-flow bins |
334 |
> |
tempdrawhisto->SetBinContent(tempdrawhisto->GetNbinsX()+1,0); |
335 |
> |
// tempdrawhisto->SetBinContent(0,0); |
336 |
|
} |
337 |
|
|
338 |
|
if(!(this->collection)[isample].is_data) tempdrawhisto->Scale(luminosity*((this->collection)[isample].weight));//weight applied here is XS & N(entries) |
339 |
+ |
if(Verbosity>0) dout << "[samplecollection::Draw] : Added contribution from sample " << (this->collection)[isample].samplename << ": " <<tempdrawhisto->Integral() << endl; |
340 |
|
histo->Add(tempdrawhisto); |
341 |
|
} |
342 |
|
tempdrawhisto->Delete(); |
401 |
|
if(use_this_sample) { |
402 |
|
if(Verbosity>0) dout << "[samplecollection::Draw] : Added contribution from sample " << (this->collection)[isample].samplename << endl; |
403 |
|
(this->collection)[isample].events->Draw(drawthis.str().c_str(),(essentialcut&&Cut)*cutWeight);//this weight is based on PU etc. not XS |
404 |
+ |
// cout << "About to draw : " << drawthis.str() << " with cut " << (const char*) (essentialcut&&Cut)*cutWeight << endl; |
405 |
|
if(addoverunderflowbins) { |
406 |
|
//now also adding the overflow & underflow bins: |
407 |
|
tempdrawhisto->SetBinContent(tempdrawhisto->GetNbinsX(),tempdrawhisto->GetBinContent(tempdrawhisto->GetNbinsX()+1)+tempdrawhisto->GetBinContent(tempdrawhisto->GetNbinsX())); |
432 |
|
{ |
433 |
|
binning.push_back(((float)(m_maxx-m_minx)/((float)m_nbins))*i+m_minx); |
434 |
|
} |
435 |
< |
|
435 |
> |
|
436 |
|
TH1F *histo = this->Draw(m_histoname,m_var, binning, m_xlabel, m_ylabel, Cut, m_is_data, luminosity, onlyindex,drawsignal); |
437 |
|
return histo; |
438 |
|
} |
564 |
|
// TLegend *leg = new TLegend(0.65,0.60,0.89,0.77); |
565 |
|
TLegend *leg = new TLegend(posx,posy,0.89,0.89); |
566 |
|
if(title!="") leg->SetHeader(title.c_str()); |
567 |
< |
if(data->GetName()!="nothing") leg->AddEntry(data,"Data","p"); |
567 |
> |
if(data->GetName()!="nothing") leg->AddEntry(data,"Data","lp"); |
568 |
|
leg->SetFillColor(kWhite); |
569 |
|
leg->SetBorderSize(0); |
570 |
|
leg->SetLineColor(kWhite); |