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

Comparing UserCode/cbrown/AnalysisFramework/Plotting/Modules/SampleClass.C (file contents):
Revision 1.8 by buchmann, Wed Jul 20 08:51:33 2011 UTC vs.
Revision 1.13 by buchmann, Wed Aug 17 09:22:37 2011 UTC

# Line 124 | Line 124 | bool doesROOTFileExist(string filename)
124   //********************************************************
125  
126   TCut essentialcut("mll>0");
127 + // This will reweight all the events: use "weight" to correct MC for pileUP
128 + TCut cutWeight("weight");
129  
130   void setessentialcut(TCut ess) {
131    essentialcut=ess;
# Line 155 | Line 157 | public:
157    vector<float> get_optimal_binsize(string variable, TCut cut,int nbins, float low, float high);
158      
159    THStack DrawStack(string m_histoname,string m_var, int m_nbins, float m_minx, float m_maxx, string m_xlabel, string m_ylabel, TCut Cut, bool m_is_data, float luminosity, bool drawsignal);
160 +  THStack DrawStack(string m_histoname,string m_var, vector<float> binning, string m_xlabel, string m_ylabel, TCut Cut, bool m_is_data, float luminosity, bool drawsignal);
161    vector<int> FindSample(string what);
162    void ListSamples();
163    bool do_sample(int thissample, vector<int> &selected_samples);
# Line 279 | Line 282 | TH1F* samplecollection::Draw(string m_hi
282      tempdrawhisto->Sumw2();
283      if(use_this_sample) {
284        if(Verbosity>0) dout << "[samplecollection::Draw] : Added contribution from sample " << (this->collection)[isample].samplename << endl;
285 <      (this->collection)[isample].events->Draw(drawthis.str().c_str(),(essentialcut&&Cut)*"weight");//this weight is based on PU etc. not XS
285 >      (this->collection)[isample].events->Draw(drawthis.str().c_str(),(essentialcut&&Cut)*cutWeight);//this weight is based on PU etc. not XS
286        if(addoverunderflowbins) {
287          //now also adding the overflow & underflow bins:
288          tempdrawhisto->SetBinContent(tempdrawhisto->GetNbinsX(),tempdrawhisto->GetBinContent(tempdrawhisto->GetNbinsX()+1));
# Line 344 | Line 347 | TH2F* samplecollection::Draw(string m_hi
347      tempdrawhisto->Sumw2();
348      if(use_this_sample) {
349        if(Verbosity>0) dout << "[samplecollection::Draw] : Added contribution from sample " << (this->collection)[isample].samplename << endl;
350 <      (this->collection)[isample].events->Draw(drawthis.str().c_str(),(essentialcut&&Cut)*"weight");//this weight is based on PU etc. not XS
350 >      (this->collection)[isample].events->Draw(drawthis.str().c_str(),(essentialcut&&Cut)*cutWeight);//this weight is based on PU etc. not XS
351        if(addoverunderflowbins) {
352          //now also adding the overflow & underflow bins:
353          tempdrawhisto->SetBinContent(tempdrawhisto->GetNbinsX(),tempdrawhisto->GetBinContent(tempdrawhisto->GetNbinsX()+1));
# Line 379 | Line 382 | TH1F* samplecollection::Draw(string m_hi
382    TH1F *histo = this->Draw(m_histoname,m_var, binning, m_xlabel, m_ylabel, Cut, m_is_data, luminosity, onlyindex,drawsignal);
383    return histo;
384    }
385 < THStack samplecollection::DrawStack(string m_histoname,string m_var, int m_nbins, float m_minx, float m_maxx, string m_xlabel, string m_ylabel, TCut Cut, bool m_is_data, float luminosity, bool drawsignal=false)
386 < {
385 >
386 > THStack samplecollection::DrawStack(string m_histoname,string m_var, vector<float> binning, string m_xlabel, string m_ylabel, TCut Cut, bool m_is_data, float luminosity, bool drawsignal=false) {
387    stringstream h_histoname;
388    h_histoname<<"h_"<<m_histoname;
389    THStack thestack("thestack",m_histoname.c_str());
# Line 392 | Line 395 | THStack samplecollection::DrawStack(stri
395    int bookedhistos[this->ngroups+1];
396    for(int ih=0;ih<=this->ngroups;ih++) bookedhistos[ih]=0;
397    
398 +  float binningarray[binning.size()+1];
399 +  for(int i=0;i<binning.size();i++) {binningarray[i]=binning[i];}
400 +  
401    for (unsigned int isample=0;isample<(this->collection).size();isample++) {
402      if(!drawsignal&&(this->collection)[isample].is_signal) continue;
403      if((this->collection)[isample].is_active&&(this->collection)[isample].is_data==m_is_data) {//fills mc if we want mc, else fills data.
404 <      TH1F *tempdrawhisto = new TH1F("tempdrawhisto","",m_nbins,m_minx,m_maxx);
405 <      (this->collection)[isample].events->Draw(drawthis.str().c_str(),(essentialcut&&Cut)*"weight");
404 >      TH1F *tempdrawhisto = new TH1F("tempdrawhisto","",binning.size()-1,binningarray);
405 >      (this->collection)[isample].events->Draw(drawthis.str().c_str(),(essentialcut&&Cut)*cutWeight);
406        
407        if(addoverunderflowbins) {
408          //now also adding the overflow & underflow bins:
# Line 444 | Line 450 | THStack samplecollection::DrawStack(stri
450    return thestack;
451   }
452  
453 + THStack samplecollection::DrawStack(string m_histoname,string m_var, int m_nbins, float m_minx, float m_maxx, string m_xlabel, string m_ylabel, TCut Cut, bool m_is_data, float luminosity, bool
454 + drawsignal=false)
455 + {
456 +  vector<float> binning;
457 +  for(int i=0;i<=m_nbins;i++)
458 +  {
459 +    binning.push_back(((float)(m_maxx-m_minx)/((float)m_nbins))*i+m_minx);
460 +  }
461 +  return this->DrawStack(m_histoname,m_var, binning, m_xlabel, m_ylabel, Cut, m_is_data, luminosity, drawsignal);
462 +  }
463 +
464  
465   vector<int> samplecollection::FindSample(string what)
466   {
# Line 452 | Line 469 | vector<int> samplecollection::FindSample
469    {
470      if(((this->collection)[isam].filename).find(what)!=string::npos) {
471        hitcollection.push_back(isam);
472 +    } else {
473      }
456    else {
457    }
474    }
475 <  if(hitcollection.size()==0) hitcollection.push_back(-1);
475 >  if(hitcollection.size()==0) {
476 >    hitcollection.push_back(-1);
477 >    write_warning(__FUNCTION__,"Couldn't find sample "+string(what)+" using sample collection \""+string(this->name)+"\"");
478 >  }
479    return hitcollection;
480   }
481  
# Line 545 | Line 564 | void samplecollection::PickUpFromThisFil
564    (this->collection)[isamp].events->SetBranchAddress("eventNum",&eventNum);
565    (this->collection)[isamp].events->SetBranchAddress("lumi",&lumi);
566    (this->collection)[isamp].events->SetBranchAddress("runNum",&runNum);
567 +
568    
569    TTreeFormula *select = new TTreeFormula("select", cut.c_str()&&essentialcut, (this->collection)[isamp].events);
570    int npickedup=0;
# Line 577 | Line 597 | void samplecollection::PickUpEvents(stri
597  
598   void switch_overunderflow(bool newpos=false) {
599    addoverunderflowbins=newpos;
600 < }
600 > }

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines