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.10 by buchmann, Mon Jun 25 11:57:35 2012 UTC vs.
Revision 1.11 by fronga, Fri Jul 20 16:38:32 2012 UTC

# Line 99 | Line 99 | sample::sample(string m_filename, string
99        measured_nevents=(this->events)->GetEntries();
100      }
101  
102 <    if(((this->Nentries>1)||(this->Nentries==0))&measured_nevents!=this->Nentries) {
102 >    if(((this->Nentries>1)||(this->Nentries==0))&&measured_nevents!=this->Nentries) {
103        //special cases: m_Nentries=1 : we want to give each event the full weight (->scans!)
104        //               m_Nentries=0: detect the number of events and set the nevents automatically
105 +      //               m_Nentries<0: set manually (see below)
106  
107        stringstream warning;
108        warning << "Detected incorrect number of events in sample initialization of sample " << m_filename << " (detected Nevents: " << measured_nevents << " , definition claims: " << this->Nentries << "; will use measured number of events. If you want to use this algorithm to set the number of events anyway, set the number of events to 0.";
109        if(m_Nentries>1) write_warning(__FUNCTION__,warning.str());
110        this->Nentries=measured_nevents;
111 +    } else if ( this->Nentries<0 ) {
112 +      this->Nentries = -this->Nentries;
113 +    }
114 +    if ( average_weight>0 ) {
115 +      this->weight=(xs/(float)Nentries)/average_weight;
116 +      this->weightrenormalization=(1.0/average_weight);
117 +    } else {
118 +      this->weight = (xs/(float)Nentries);
119 +      this->weightrenormalization=-1;
120      }
111    this->weight=(xs/(float)Nentries)/average_weight;
112    this->weightrenormalization=(1.0/average_weight);
121    }
122    else {
123      this->is_active=false;
# Line 148 | Line 156 | bool doesROOTFileExist(string filename)
156   TCut essentialcut("mll>0");
157   // The following cut (cutWeight) will reweight all the events: use "weight" to correct MC for pileUP, "1.0" otherwise
158   TCut cutWeight("weight");
159 + //TCut cutWeight("(weight*(((id1==id2&&id1==0)*1.2)+((id1==id2&&id1==1)/1.2)+(id1!=id2)))");
160  
161   void setessentialcut(TCut ess) {
162    essentialcut=ess;
# Line 308 | Line 317 | TH1F* samplecollection::Draw(string m_hi
317      TH1F *tempdrawhisto = new TH1F("tempdrawhisto","tempdrawhisto",binning.size()-1,binningarray);
318      tempdrawhisto->Sumw2();
319      if(use_this_sample) {
320 <      if(Verbosity>0) dout << "[samplecollection::Draw] : Added contribution from sample " << (this->collection)[isample].samplename << endl;
320 >      if ( (this->collection)[isample].weightrenormalization<0 ) cutWeight = "1.0"; // Quick fix for SMS samples
321        (this->collection)[isample].events->Draw(drawthis.str().c_str(),(essentialcut&&Cut)*cutWeight);//this weight is based on PU etc. not XS
322        if(addoverunderflowbins) {
323          //now also adding the overflow & underflow bins:
# Line 319 | Line 328 | TH1F* samplecollection::Draw(string m_hi
328        }
329  
330        if(!(this->collection)[isample].is_data) tempdrawhisto->Scale(luminosity*((this->collection)[isample].weight));//weight applied here is XS & N(entries)
331 +      if(Verbosity>0) dout << "[samplecollection::Draw] : Added contribution from sample " << (this->collection)[isample].samplename << ": " <<tempdrawhisto->Integral() << endl;
332        histo->Add(tempdrawhisto);
333      }
334      tempdrawhisto->Delete();

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines