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.12 by buchmann, Fri Aug 10 12:59:45 2012 UTC vs.
Revision 1.20 by buchmann, Wed Dec 5 09:46:45 2012 UTC

# Line 83 | Line 83 | sample::sample(string m_filename, string
83      
84    if(doesROOTFileExist(this->filename)) {
85      //suppressing  stupid 64/32 errors here (Warning in <TFile::ReadStreamerInfo>: /scratch/buchmann/MC_Spring11_PU_PF/TToBLNu_TuneZ2_t-channel_7TeV-madgraph.root: not a TStreamerInfo object)
86 <    Int_t currlevel=gErrorIgnoreLevel;
87 <    gErrorIgnoreLevel=5000;
86 > //    Int_t currlevel=gErrorIgnoreLevel;
87 > //     gErrorIgnoreLevel=5000;
88      this->tfile = new TFile(m_filename.c_str());
89 <    gErrorIgnoreLevel=currlevel;
89 > //     gErrorIgnoreLevel=currlevel;
90      this->events=(TTree*)(this->tfile)->Get(treename.c_str());
91      if(Verbosity>0) dout << "The " << write_mc_or_data(is_data) << " file " << this->filename << " has been added successfully to the list of samples. " << endl;
92      long long measured_nevents=(long)1;
93      TH1F *weight_histo = (TH1F*)(this->tfile)->Get("weight_histo");
94      float average_weight = 1.0;
95      if(weight_histo) {
96 <      average_weight = weight_histo->Integral()/weight_histo->GetEntries();
96 >      //average_weight = weight_histo->Integral()/weight_histo->GetEntries();
97        measured_nevents = (long)weight_histo->GetEntries();
98      } else {
99        measured_nevents=(this->events)->GetEntries();
# Line 144 | Line 144 | void sample::closeFile()
144   bool doesROOTFileExist(string filename)
145   {
146    //suppressing  stupid 64/32 errors here (Warning in <TFile::ReadStreamerInfo>: /scratch/buchmann/MC_Spring11_PU_PF/TToBLNu_TuneZ2_t-channel_7TeV-madgraph.root: not a TStreamerInfo object)
147 <  Int_t currlevel=gErrorIgnoreLevel;
148 <  gErrorIgnoreLevel=5000;
147 > //   Int_t currlevel=gErrorIgnoreLevel;
148 > //   gErrorIgnoreLevel=5000;
149    TFile *f = new TFile(filename.c_str());
150    
151    if (f->IsZombie()) {
# Line 153 | Line 153 | bool doesROOTFileExist(string filename)
153      return 0;
154    }
155    f->Close();
156 <  gErrorIgnoreLevel=currlevel;
156 > //   gErrorIgnoreLevel=currlevel;
157    return 1;
158   }
159   //********************************************************
# Line 241 | Line 241 | void samplecollection::ListSamples()
241   void samplecollection::AddSample(string m_filename,string m_samplename,long m_Nentries, float m_xs,bool is_data, bool m_is_signal, int groupindex, Color_t newcolor)
242   {
243    sample NewSample(m_filename,m_samplename,m_Nentries,m_xs,is_data,m_is_signal,groupindex,newcolor);
244 +  if (!NewSample.is_active) {
245 +    write_warning(__FUNCTION__,"Not adding this sample ("+m_filename+") as it has been declared inactive");
246 +    return;
247 +  }
248    (this->collection).push_back(NewSample);
249    if((this->collection).size()==1) {
250      this->nmcsamples=0;
# Line 323 | Line 327 | TH1F* samplecollection::Draw(string m_hi
327      tempdrawhisto->Sumw2();
328      if(use_this_sample) {
329        (this->collection)[isample].events->Draw(drawthis.str().c_str(),(essentialcut&&Cut)*cutWeight);//this weight is based on PU etc. not XS
330 < //cout << "Drawing " << drawthis.str() << "   with cut   " << (const char*) (essentialcut&&Cut)*cutWeight << endl;
330 > //        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;
331        if(addoverunderflowbins) {
332          //now also adding the overflow & underflow bins:
333          tempdrawhisto->SetBinContent(tempdrawhisto->GetNbinsX(),tempdrawhisto->GetBinContent(tempdrawhisto->GetNbinsX()+1)+tempdrawhisto->GetBinContent(tempdrawhisto->GetNbinsX()));
334          tempdrawhisto->SetBinError(tempdrawhisto->GetNbinsX(),TMath::Sqrt(tempdrawhisto->GetBinContent(tempdrawhisto->GetNbinsX())));
335 <        tempdrawhisto->SetBinContent(1,tempdrawhisto->GetBinContent(0)+tempdrawhisto->GetBinContent(1));
336 <        tempdrawhisto->SetBinError(1,TMath::Sqrt(tempdrawhisto->GetBinContent(1)));
335 > //      tempdrawhisto->SetBinContent(1,tempdrawhisto->GetBinContent(0)+tempdrawhisto->GetBinContent(1));
336 > //      tempdrawhisto->SetBinError(1,TMath::Sqrt(tempdrawhisto->GetBinContent(1)));
337 >        // Delete over- and under-flow bins
338 >        tempdrawhisto->SetBinContent(tempdrawhisto->GetNbinsX()+1,0);
339 > //        tempdrawhisto->SetBinContent(0,0);
340        }
341  
342        if(!(this->collection)[isample].is_data) tempdrawhisto->Scale(luminosity*((this->collection)[isample].weight));//weight applied here is XS & N(entries)
# Line 398 | Line 405 | TH2F* samplecollection::Draw(string m_hi
405      if(use_this_sample) {
406        if(Verbosity>0) dout << "[samplecollection::Draw] : Added contribution from sample " << (this->collection)[isample].samplename << endl;
407        (this->collection)[isample].events->Draw(drawthis.str().c_str(),(essentialcut&&Cut)*cutWeight);//this weight is based on PU etc. not XS
408 <      cout << "About to draw : " << drawthis.str() << "  with cut   " << (const char*) (essentialcut&&Cut)*cutWeight << endl;
408 > //       cout << "About to draw : " << drawthis.str() << "  with cut   " << (const char*) (essentialcut&&Cut)*cutWeight << endl;
409        if(addoverunderflowbins) {
410          //now also adding the overflow & underflow bins:
411          tempdrawhisto->SetBinContent(tempdrawhisto->GetNbinsX(),tempdrawhisto->GetBinContent(tempdrawhisto->GetNbinsX()+1)+tempdrawhisto->GetBinContent(tempdrawhisto->GetNbinsX()));
# Line 429 | Line 436 | TH1F* samplecollection::Draw(string m_hi
436    {
437      binning.push_back(((float)(m_maxx-m_minx)/((float)m_nbins))*i+m_minx);
438    }
439 <  
439 >
440    TH1F *histo = this->Draw(m_histoname,m_var, binning, m_xlabel, m_ylabel, Cut, m_is_data, luminosity, onlyindex,drawsignal);
441    return histo;
442    }
# Line 453 | Line 460 | THStack samplecollection::DrawStack(stri
460      if(!drawsignal&&(this->collection)[isample].is_signal) continue;
461      if((this->collection)[isample].is_active&&(this->collection)[isample].is_data==m_is_data) {//fills mc if we want mc, else fills data.
462        TH1F *tempdrawhisto = new TH1F("tempdrawhisto","",binning.size()-1,binningarray);
463 +      tempdrawhisto->Sumw2();
464        (this->collection)[isample].events->Draw(drawthis.str().c_str(),(essentialcut&&Cut)*cutWeight);
465        
466        if(addoverunderflowbins) {
# Line 561 | Line 569 | TLegend* samplecollection::allbglegend(s
569   //  TLegend *leg = new TLegend(0.65,0.60,0.89,0.77);
570    TLegend *leg = new TLegend(posx,posy,0.89,0.89);
571    if(title!="") leg->SetHeader(title.c_str());
572 <  if(data->GetName()!="nothing") leg->AddEntry(data,"Data","p");
572 >  if(data->GetName()!="nothing") leg->AddEntry(data,"Data","lp");
573    leg->SetFillColor(kWhite);
574    leg->SetBorderSize(0);
575    leg->SetLineColor(kWhite);
# Line 586 | Line 594 | TLegend* samplecollection::allbglegend(s
594   }
595  
596   TLegend* samplecollection::allbglegend(string title="",float posx=0.65, float posy=0.60) {
597 <  Int_t currlevel=gErrorIgnoreLevel;
598 <  gErrorIgnoreLevel=5000;
597 > //   Int_t currlevel=gErrorIgnoreLevel;
598 > //   gErrorIgnoreLevel=5000;
599    TH1F *blub = new TH1F("nothing","nothing",1,0,1);
600 <  gErrorIgnoreLevel=currlevel;//we know this possibly replaces a previous histo, but we don't care since it's fake anyway.
600 > //   gErrorIgnoreLevel=currlevel;//we know this possibly replaces a previous histo, but we don't care since it's fake anyway.
601    return this->allbglegend(title,blub,posx,posy);
602   }
603  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines