ViewVC Help
View File | Revision Log | Show Annotations | Root Listing
root/cvsroot/UserCode/cbrown/Development/Plotting/Modules/SampleClass.C
(Generate patch)

Comparing UserCode/cbrown/Development/Plotting/Modules/SampleClass.C (file contents):
Revision 1.23 by buchmann, Thu Jan 17 17:21:38 2013 UTC vs.
Revision 1.27 by buchmann, Fri Apr 5 16:17:49 2013 UTC

# Line 212 | Line 212 | public:
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();
# Line 389 | Line 389 | TH2F* samplecollection::Draw(string m_hi
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;
# Line 408 | Line 405 | TH2F* samplecollection::Draw(string m_hi
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;
# Line 470 | Line 467 | THStack samplecollection::DrawStack(stri
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()));
# Line 584 | Line 581 | TLegend* samplecollection::allbglegend(s
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));
# Line 609 | Line 608 | TLegend* samplecollection::allbglegend(s
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  
# Line 649 | Line 645 | vector<float> samplecollection::get_opti
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);
# Line 661 | Line 659 | void samplecollection::PickUpFromThisFil
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   //________________________________________________________________________________________

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines