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.19 by buchmann, Mon Dec 3 16:01:11 2012 UTC vs.
Revision 1.23 by buchmann, Thu Jan 17 17:21:38 2013 UTC

# Line 53 | Line 53 | public:
53    TTree *events;
54    
55    sample(string m_filename,string m_samplename,long m_Nentries, float m_xs,bool is_data, bool m_is_signal, int m_groupindex, Color_t color);
56 +  string ExtractVersion(string FullVersionString);
57    void closeFile();
58   };
59  
# Line 62 | Line 63 | string write_mc_or_data(bool is_data)
63    return "MC";
64   }
65  
66 + string sample::ExtractVersion(string FullVersionString) {
67 +  string Result=FullVersionString.substr(FullVersionString.find(" ")+1,FullVersionString.length());
68 +  Result=Result.substr(0,Result.find(" "));
69 +  return Result;
70 + }
71 +  
72   sample::sample(string m_filename, string m_samplename, long m_Nentries, float m_xs,bool m_is_data, bool m_is_signal, int m_groupindex, Color_t mycolor)
73   {
74    this->filename=m_filename;
# Line 93 | Line 100 | sample::sample(string m_filename, string
100      TH1F *weight_histo = (TH1F*)(this->tfile)->Get("weight_histo");
101      float average_weight = 1.0;
102      if(weight_histo) {
103 <      average_weight = weight_histo->Integral()/weight_histo->GetEntries();
103 >      //average_weight = weight_histo->Integral()/weight_histo->GetEntries();
104        measured_nevents = (long)weight_histo->GetEntries();
105      } else {
106        measured_nevents=(this->events)->GetEntries();
# Line 123 | Line 130 | sample::sample(string m_filename, string
130          this->weightrenormalization=1;
131        }
132      }
133 +      
134    }
135    else {
136      this->is_active=false;
# Line 232 | Line 240 | void samplecollection::ListSamples()
240      dout << "MC sample(s): " << endl;
241      for (int isamp=0;isamp<(int)this->collection.size();isamp++)
242        {
243 <        if(!(this->collection)[isamp].is_data) dout << " - " << (this->collection)[isamp].samplename << " (" << (this->collection)[isamp].filename << ") xs=" << (this->collection)[isamp].xs << " pb, N(events)=" << (this->collection)[isamp].Nentries << " , RN = " << (this->collection)[isamp].weightrenormalization << endl;
243 >        if(!(this->collection)[isamp].is_data) dout << " - " << (this->collection)[isamp].samplename << " (" << (this->collection)[isamp].filename << ") xs=" << (this->collection)[isamp].xs << " pb, N(events)=" << (this->collection)[isamp].Nentries << endl;
244        }
245    }
246    dout << "---------------------------------------------------------------------------------------------------" << endl;
# Line 574 | Line 582 | TLegend* samplecollection::allbglegend(s
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+1;
588 >  }
589 >  
590 >  TH1F *fakehistos[maxIgroup];
591 >  bool donealready[maxIgroup];
592 >  
593 >  for(int i=0;i<maxIgroup;i++) donealready[i]=false;
594    for(int isample=0;isample<(int)(this->collection).size();isample++) {
595      if((this->collection)[isample].is_data||(this->collection)[isample].is_signal) continue;
596  
# Line 586 | Line 600 | TLegend* samplecollection::allbglegend(s
600      fakehistos[(this->collection)[isample].groupindex]->SetFillColor(this->GetColor(isample));
601      leg->AddEntry(fakehistos[(this->collection)[isample].groupindex],((this->collection)[isample].samplename).c_str(),"f");
602      donealready[(this->collection)[isample].groupindex]=true;
603 +    PlottingSetup::FakeHistoHeap.push_back(fakehistos[(this->collection)[isample].groupindex]);
604      }
605    }
606    DrawPrelim();
# Line 598 | Line 613 | TLegend* samplecollection::allbglegend(s
613   //   gErrorIgnoreLevel=5000;
614    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.
616 <  return this->allbglegend(title,blub,posx,posy);
616 >  TLegend *leg = this->allbglegend(title,blub,posx,posy);
617 >  delete blub;
618 >  return leg;
619   }
620  
621  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines