212 |
|
TLegend* allbglegend(string title,float x, float y); |
213 |
|
TLegend* allbglegend(string title, TH1F *data, float x, float y); |
214 |
|
|
215 |
< |
void PickUpFromThisFile(int isamp, string cut, vector<string> &output, vector<string> &pickupfile); |
216 |
< |
void PickUpEvents(string cut); |
215 |
> |
void PickUpFromThisFile(int isamp, string cut, vector<string> &output, vector<string> &pickupfile, bool QuietMode); |
216 |
> |
void PickUpEvents(string cut,string filename,bool QuietMode); |
217 |
|
string find_units(string&); |
218 |
|
|
219 |
|
void RemoveLastSample(); |
389 |
|
} |
390 |
|
stringstream h_histoname; |
391 |
|
h_histoname<<"h_"<<m_histoname; |
392 |
< |
float binningarray[binningx.size()+1]; |
393 |
< |
float binningyarray[binningy.size()+1]; |
394 |
< |
for(int i=0;i<(int)binningx.size();i++) {binningarray[i]=binningx[i];binningyarray[i]=binningy[i];} |
395 |
< |
TH2F *histo = new TH2F(m_histoname.c_str(),"",binningx.size()-1,binningarray,binningy.size()-1,binningyarray); |
392 |
> |
TH2F *histo = new TH2F(m_histoname.c_str(),"",binningx.size()-1,&binningx[0],binningy.size()-1,&binningy[0]); |
393 |
|
histo->Sumw2(); |
394 |
|
|
395 |
|
stringstream drawthis; |
405 |
|
if(do_only_selected_samples&&this->do_sample(isample,onlyindex)) { |
406 |
|
use_this_sample=true; |
407 |
|
} |
408 |
< |
TH2F *tempdrawhisto = new TH2F("tempdrawhisto","tempdrawhisto",binningx.size()-1,binningarray,binningy.size()-1,binningyarray); |
408 |
> |
TH2F *tempdrawhisto = new TH2F("tempdrawhisto","tempdrawhisto",binningx.size()-1,&binningx[0],binningy.size()-1,&binningy[0]); |
409 |
|
tempdrawhisto->Sumw2(); |
410 |
|
if(use_this_sample) { |
411 |
|
if(Verbosity>0) dout << "[samplecollection::Draw] : Added contribution from sample " << (this->collection)[isample].samplename << endl; |
467 |
|
TH1F *tempdrawhisto = new TH1F("tempdrawhisto","",binning.size()-1,binningarray); |
468 |
|
tempdrawhisto->Sumw2(); |
469 |
|
(this->collection)[isample].events->Draw(drawthis.str().c_str(),(essentialcut&&Cut)*cutWeight); |
470 |
< |
|
470 |
> |
// 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; |
471 |
|
if(addoverunderflowbins) { |
472 |
|
//now also adding the overflow & underflow bins: |
473 |
|
tempdrawhisto->SetBinContent(tempdrawhisto->GetNbinsX(),tempdrawhisto->GetBinContent(tempdrawhisto->GetNbinsX()+1)+tempdrawhisto->GetBinContent(tempdrawhisto->GetNbinsX())); |
581 |
|
|
582 |
|
int maxIgroup=0; |
583 |
|
for(int isample=0;isample<(int)(this->collection).size();isample++) { |
584 |
< |
if((this->collection)[isample].groupindex>maxIgroup) maxIgroup=(this->collection)[isample].groupindex+1; |
584 |
> |
if((this->collection)[isample].groupindex>maxIgroup) maxIgroup=(this->collection)[isample].groupindex; |
585 |
|
} |
586 |
+ |
maxIgroup++; |
587 |
|
|
588 |
|
TH1F *fakehistos[maxIgroup]; |
589 |
|
bool donealready[maxIgroup]; |
590 |
|
|
591 |
|
for(int i=0;i<maxIgroup;i++) donealready[i]=false; |
592 |
+ |
|
593 |
|
for(int isample=0;isample<(int)(this->collection).size();isample++) { |
594 |
|
if((this->collection)[isample].is_data||(this->collection)[isample].is_signal) continue; |
596 |
– |
|
595 |
|
if(!donealready[(this->collection)[isample].groupindex]) { |
596 |
+ |
assert((this->collection)[isample].groupindex<maxIgroup); |
597 |
|
fakehistos[(this->collection)[isample].groupindex] = new TH1F(GetNumericHistoName().c_str(),"",1,0,1); |
598 |
|
fakehistos[(this->collection)[isample].groupindex]->Fill(1); |
599 |
|
fakehistos[(this->collection)[isample].groupindex]->SetFillColor(this->GetColor(isample)); |
608 |
|
} |
609 |
|
|
610 |
|
TLegend* samplecollection::allbglegend(string title="",float posx=0.65, float posy=0.60) { |
612 |
– |
// Int_t currlevel=gErrorIgnoreLevel; |
613 |
– |
// gErrorIgnoreLevel=5000; |
611 |
|
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. |
612 |
|
TLegend *leg = this->allbglegend(title,blub,posx,posy); |
613 |
< |
delete blub; |
613 |
> |
PlottingSetup::FakeHistoHeap.push_back(blub); |
614 |
|
return leg; |
615 |
|
} |
616 |
|
|
645 |
|
|
646 |
|
} |
647 |
|
|
648 |
< |
void samplecollection::PickUpFromThisFile(int isamp, string cut, vector<string> &output, vector<string> &pickupfile) { |
649 |
< |
int lumi,eventNum,runNum; |
648 |
> |
void samplecollection::PickUpFromThisFile(int isamp, string cut, vector<string> &output, vector<string> &pickupfile, bool QuietMode) { |
649 |
> |
int lumi,runNum; |
650 |
> |
ULong64_t eventNum; |
651 |
> |
|
652 |
|
float jzb[30]; |
653 |
|
(this->collection)[isamp].events->SetBranchAddress("jzb",&jzb); |
654 |
|
(this->collection)[isamp].events->SetBranchAddress("lumi",&runNum); |
659 |
|
|
660 |
|
TTreeFormula *select = new TTreeFormula("select", cut.c_str()&&essentialcut, (this->collection)[isamp].events); |
661 |
|
int npickedup=0; |
662 |
+ |
stringstream filetext; |
663 |
|
for (Int_t entry = 0 ; entry < (this->collection)[isamp].events->GetEntries() ; entry++) { |
664 |
|
(this->collection)[isamp].events->LoadTree(entry); |
665 |
|
if (select->EvalInstance()) { |
666 |
|
(this->collection)[isamp].events->GetEntry(entry); |
667 |
< |
dout << runNum << ":" << lumi << ":" << eventNum << endl; |
667 |
> |
if(!QuietMode) dout << runNum << ":" << lumi << ":" << eventNum << endl; |
668 |
> |
filetext.str(""); |
669 |
> |
filetext << runNum << ":" << lumi << ":" << eventNum << endl; |
670 |
> |
output.push_back(filetext.str()); |
671 |
|
npickedup++; |
672 |
|
} |
673 |
|
} |
674 |
< |
dout << "Printed out a total of " << npickedup << " events" << endl; |
674 |
> |
if(!QuietMode) dout << "Printed out a total of " << npickedup << " events" << endl; |
675 |
|
} |
676 |
|
|
677 |
|
|
678 |
|
|
679 |
< |
void samplecollection::PickUpEvents(string cut) { |
679 |
> |
void samplecollection::PickUpEvents(string cut, string filename, bool QuietMode=false) { |
680 |
|
vector<string> output; |
681 |
|
vector<string> pickupfile; |
682 |
< |
for (int isamp=0;isamp<(int)this->collection.size();isamp++) |
682 |
> |
for (unsigned int isamp=0;isamp<this->collection.size();isamp++) |
683 |
|
{ |
684 |
|
if((this->collection)[isamp].is_data) { |
685 |
|
//we have a data sample ! |
686 |
< |
this->PickUpFromThisFile(isamp,cut,output,pickupfile); |
686 |
> |
this->PickUpFromThisFile(isamp,cut,output,pickupfile,QuietMode); |
687 |
|
} |
688 |
|
} |
689 |
+ |
|
690 |
|
//do something with output and of course the pickup file! |
691 |
+ |
ofstream myfile(filename.c_str()); |
692 |
+ |
for(unsigned int ievent=0;ievent<output.size();ievent++) myfile << output[ievent]; |
693 |
+ |
myfile.close(); |
694 |
+ |
|
695 |
|
} |
696 |
|
|
697 |
|
//________________________________________________________________________________________ |