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); |
216 |
> |
void PickUpEvents(string cut,string filename); |
217 |
|
string find_units(string&); |
218 |
|
|
219 |
|
void RemoveLastSample(); |
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; |
588 |
> |
} |
589 |
> |
maxIgroup++; |
590 |
> |
|
591 |
> |
TH1F *fakehistos[maxIgroup]; |
592 |
> |
bool donealready[maxIgroup]; |
593 |
> |
|
594 |
> |
for(int i=0;i<maxIgroup;i++) donealready[i]=false; |
595 |
> |
|
596 |
|
for(int isample=0;isample<(int)(this->collection).size();isample++) { |
597 |
|
if((this->collection)[isample].is_data||(this->collection)[isample].is_signal) continue; |
590 |
– |
|
598 |
|
if(!donealready[(this->collection)[isample].groupindex]) { |
599 |
+ |
assert((this->collection)[isample].groupindex<maxIgroup); |
600 |
|
fakehistos[(this->collection)[isample].groupindex] = new TH1F(GetNumericHistoName().c_str(),"",1,0,1); |
601 |
|
fakehistos[(this->collection)[isample].groupindex]->Fill(1); |
602 |
|
fakehistos[(this->collection)[isample].groupindex]->SetFillColor(this->GetColor(isample)); |
611 |
|
} |
612 |
|
|
613 |
|
TLegend* samplecollection::allbglegend(string title="",float posx=0.65, float posy=0.60) { |
606 |
– |
// Int_t currlevel=gErrorIgnoreLevel; |
607 |
– |
// gErrorIgnoreLevel=5000; |
614 |
|
TH1F *blub = new TH1F("nothing","nothing",1,0,1); |
609 |
– |
// gErrorIgnoreLevel=currlevel;//we know this possibly replaces a previous histo, but we don't care since it's fake anyway. |
615 |
|
TLegend *leg = this->allbglegend(title,blub,posx,posy); |
616 |
< |
delete blub; |
616 |
> |
PlottingSetup::FakeHistoHeap.push_back(blub); |
617 |
|
return leg; |
618 |
|
} |
619 |
|
|
649 |
|
} |
650 |
|
|
651 |
|
void samplecollection::PickUpFromThisFile(int isamp, string cut, vector<string> &output, vector<string> &pickupfile) { |
652 |
< |
int lumi,eventNum,runNum; |
652 |
> |
int lumi,runNum; |
653 |
> |
ULong64_t eventNum; |
654 |
> |
|
655 |
|
float jzb[30]; |
656 |
|
(this->collection)[isamp].events->SetBranchAddress("jzb",&jzb); |
657 |
|
(this->collection)[isamp].events->SetBranchAddress("lumi",&runNum); |
662 |
|
|
663 |
|
TTreeFormula *select = new TTreeFormula("select", cut.c_str()&&essentialcut, (this->collection)[isamp].events); |
664 |
|
int npickedup=0; |
665 |
+ |
stringstream filetext; |
666 |
|
for (Int_t entry = 0 ; entry < (this->collection)[isamp].events->GetEntries() ; entry++) { |
667 |
|
(this->collection)[isamp].events->LoadTree(entry); |
668 |
|
if (select->EvalInstance()) { |
669 |
|
(this->collection)[isamp].events->GetEntry(entry); |
670 |
|
dout << runNum << ":" << lumi << ":" << eventNum << endl; |
671 |
+ |
filetext.str(""); |
672 |
+ |
filetext << runNum << ":" << lumi << ":" << eventNum << endl; |
673 |
+ |
output.push_back(filetext.str()); |
674 |
|
npickedup++; |
675 |
|
} |
676 |
|
} |
679 |
|
|
680 |
|
|
681 |
|
|
682 |
< |
void samplecollection::PickUpEvents(string cut) { |
682 |
> |
void samplecollection::PickUpEvents(string cut, string filename) { |
683 |
|
vector<string> output; |
684 |
|
vector<string> pickupfile; |
685 |
< |
for (int isamp=0;isamp<(int)this->collection.size();isamp++) |
685 |
> |
for (unsigned int isamp=0;isamp<this->collection.size();isamp++) |
686 |
|
{ |
687 |
|
if((this->collection)[isamp].is_data) { |
688 |
|
//we have a data sample ! |
689 |
|
this->PickUpFromThisFile(isamp,cut,output,pickupfile); |
690 |
|
} |
691 |
|
} |
692 |
+ |
|
693 |
|
//do something with output and of course the pickup file! |
694 |
+ |
ofstream myfile(filename.c_str()); |
695 |
+ |
for(unsigned int ievent=0;ievent<output.size();ievent++) myfile << output[ievent]; |
696 |
+ |
myfile.close(); |
697 |
+ |
|
698 |
|
} |
699 |
|
|
700 |
|
//________________________________________________________________________________________ |