124 |
|
//******************************************************** |
125 |
|
|
126 |
|
TCut essentialcut("mll>0"); |
127 |
< |
// This will reweight all the events: use "weight" to correct MC for pileUP |
127 |
> |
// This will reweight all the events: use "weight" to correct MC for pileUP, "1.0" otherwise |
128 |
|
TCut cutWeight("weight"); |
129 |
|
|
130 |
|
void setessentialcut(TCut ess) { |
169 |
|
|
170 |
|
void PickUpFromThisFile(int isamp, string cut, vector<string> &output, vector<string> &pickupfile); |
171 |
|
void PickUpEvents(string cut); |
172 |
+ |
string find_units(string&); |
173 |
|
}; |
174 |
|
|
175 |
|
samplecollection::samplecollection(string m_name) |
286 |
|
(this->collection)[isample].events->Draw(drawthis.str().c_str(),(essentialcut&&Cut)*cutWeight);//this weight is based on PU etc. not XS |
287 |
|
if(addoverunderflowbins) { |
288 |
|
//now also adding the overflow & underflow bins: |
289 |
< |
tempdrawhisto->SetBinContent(tempdrawhisto->GetNbinsX(),tempdrawhisto->GetBinContent(tempdrawhisto->GetNbinsX()+1)); |
289 |
> |
tempdrawhisto->SetBinContent(tempdrawhisto->GetNbinsX(),tempdrawhisto->GetBinContent(tempdrawhisto->GetNbinsX()+1)+tempdrawhisto->GetBinContent(tempdrawhisto->GetNbinsX())); |
290 |
|
tempdrawhisto->SetBinError(tempdrawhisto->GetNbinsX(),TMath::Sqrt(tempdrawhisto->GetBinContent(tempdrawhisto->GetNbinsX()))); |
291 |
< |
tempdrawhisto->SetBinContent(1,tempdrawhisto->GetBinContent(0)); |
291 |
> |
tempdrawhisto->SetBinContent(1,tempdrawhisto->GetBinContent(0)+tempdrawhisto->GetBinContent(1)); |
292 |
|
tempdrawhisto->SetBinError(1,TMath::Sqrt(tempdrawhisto->GetBinContent(1))); |
293 |
|
} |
294 |
|
|
299 |
|
}//end of loop over isample |
300 |
|
if(Verbosity>0) dout << "Histo has been filled and now contains " << histo->Integral() << " points (integral)" << endl; |
301 |
|
histo->GetXaxis()->SetTitle(m_xlabel.c_str()); |
302 |
< |
histo->GetYaxis()->SetTitle(m_ylabel.c_str()); |
302 |
> |
// Try to add bin width information: look for units in m_xlabel |
303 |
> |
string units = find_units(m_xlabel); |
304 |
> |
if ( units.length()>0 ) { |
305 |
> |
stringstream ylabel; |
306 |
> |
ylabel << m_ylabel << " / " << histo->GetBinWidth(1) << " " << units; |
307 |
> |
histo->GetYaxis()->SetTitle( ylabel.str().c_str() ); |
308 |
> |
} else { |
309 |
> |
histo->GetYaxis()->SetTitle(m_ylabel.c_str()); |
310 |
> |
} |
311 |
|
histo->GetXaxis()->CenterTitle(); |
312 |
|
histo->GetYaxis()->CenterTitle(); |
313 |
|
if(do_only_selected_samples) histo->SetLineColor(this->GetColor(onlyindex[0])); |
359 |
|
(this->collection)[isample].events->Draw(drawthis.str().c_str(),(essentialcut&&Cut)*cutWeight);//this weight is based on PU etc. not XS |
360 |
|
if(addoverunderflowbins) { |
361 |
|
//now also adding the overflow & underflow bins: |
362 |
< |
tempdrawhisto->SetBinContent(tempdrawhisto->GetNbinsX(),tempdrawhisto->GetBinContent(tempdrawhisto->GetNbinsX()+1)); |
362 |
> |
tempdrawhisto->SetBinContent(tempdrawhisto->GetNbinsX(),tempdrawhisto->GetBinContent(tempdrawhisto->GetNbinsX()+1)+tempdrawhisto->GetBinContent(tempdrawhisto->GetNbinsX())); |
363 |
|
tempdrawhisto->SetBinError(tempdrawhisto->GetNbinsX(),TMath::Sqrt(tempdrawhisto->GetBinContent(tempdrawhisto->GetNbinsX()))); |
364 |
< |
tempdrawhisto->SetBinContent(1,tempdrawhisto->GetBinContent(0)); |
364 |
> |
tempdrawhisto->SetBinContent(1,tempdrawhisto->GetBinContent(0)+tempdrawhisto->GetBinContent(1)); |
365 |
|
tempdrawhisto->SetBinError(1,TMath::Sqrt(tempdrawhisto->GetBinContent(1))); |
366 |
|
} |
367 |
|
|
415 |
|
|
416 |
|
if(addoverunderflowbins) { |
417 |
|
//now also adding the overflow & underflow bins: |
418 |
< |
tempdrawhisto->SetBinContent(tempdrawhisto->GetNbinsX(),tempdrawhisto->GetBinContent(tempdrawhisto->GetNbinsX()+1)); |
419 |
< |
tempdrawhisto->SetBinError(tempdrawhisto->GetNbinsX(),TMath::Sqrt(tempdrawhisto->GetBinContent(tempdrawhisto->GetNbinsX()))); |
420 |
< |
tempdrawhisto->SetBinContent(1,tempdrawhisto->GetBinContent(0)); |
421 |
< |
tempdrawhisto->SetBinError(1,TMath::Sqrt(tempdrawhisto->GetBinContent(1))); |
418 |
> |
tempdrawhisto->SetBinContent(tempdrawhisto->GetNbinsX(),tempdrawhisto->GetBinContent(tempdrawhisto->GetNbinsX()+1)+tempdrawhisto->GetBinContent(tempdrawhisto->GetNbinsX())); |
419 |
> |
// tempdrawhisto->SetBinError(tempdrawhisto->GetNbinsX(),TMath::Sqrt(tempdrawhisto->GetBinContent(tempdrawhisto->GetNbinsX()))); // errors not necessary for stack! |
420 |
> |
tempdrawhisto->SetBinContent(1,tempdrawhisto->GetBinContent(0)+tempdrawhisto->GetBinContent(1)); |
421 |
> |
// tempdrawhisto->SetBinError(1,TMath::Sqrt(tempdrawhisto->GetBinContent(1))); // errors not necessary for stack! |
422 |
|
} |
423 |
|
|
424 |
|
if(!(this->collection)[isample].is_data) tempdrawhisto->Scale(luminosity*((this->collection)[isample].weight)); |
483 |
|
} |
484 |
|
if(hitcollection.size()==0) { |
485 |
|
hitcollection.push_back(-1); |
486 |
< |
write_warning(__FUNCTION__,"Couldn't find sample "+string(what)+": using sample collection \""+string(this->name)+"\""); |
486 |
> |
write_warning(__FUNCTION__,"Couldn't find sample "+string(what)+" using sample collection \""+string(this->name)+"\""); |
487 |
|
} |
488 |
|
return hitcollection; |
489 |
|
} |
603 |
|
//do something with output and of course the pickup file! |
604 |
|
} |
605 |
|
|
606 |
+ |
//________________________________________________________________________________________ |
607 |
+ |
// Find units from histogram x-label (looks for '[...]') |
608 |
+ |
string samplecollection::find_units(string& xlabel) { |
609 |
+ |
|
610 |
+ |
string units; |
611 |
+ |
size_t pos1 = xlabel.find("["); |
612 |
+ |
if ( pos1 != string::npos ) { |
613 |
+ |
size_t pos2 = xlabel.find("]"); |
614 |
+ |
units = xlabel.substr(pos1+1,pos2-pos1-1); |
615 |
+ |
}// else { |
616 |
+ |
// size_t pos1 = xlabel.find("("); |
617 |
+ |
// if ( pos1 != string::npos ) { |
618 |
+ |
// size_t pos2 = xlabel.find(")"); |
619 |
+ |
// units = xlabel.substr(pos1+1,pos2-pos1-1); |
620 |
+ |
// } |
621 |
+ |
// } |
622 |
+ |
return units; |
623 |
+ |
|
624 |
+ |
} |
625 |
|
|
626 |
|
void switch_overunderflow(bool newpos=false) { |
627 |
|
addoverunderflowbins=newpos; |
628 |
|
} |
629 |
+ |
|
630 |
+ |
|