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

Comparing UserCode/cbrown/AnalysisFramework/Plotting/Modules/Systematics.C (file contents):
Revision 1.22 by buchmann, Wed Aug 31 06:53:52 2011 UTC vs.
Revision 1.23 by pablom, Wed Aug 31 10:21:17 2011 UTC

# Line 157 | Line 157 | TH1F* plotEff(TTree* events, TCut kbase,
157  
158  
159   //________________________________________________________________________________________
160 + // Master Formula
161 + void master_formula(std::vector<float> eff, float &errHi, float &errLo) {
162 +
163 +  float x0 = eff[0];
164 +  float deltaPos = 0, deltaNeg = 0;
165 +  for(int k = 0; k < (eff.size()-1)/2; k++) {
166 +    float xneg = eff[2*k+2];
167 +    float xpos = eff[2*k+1];
168 +    if(xpos-x0>0 || xneg-x0>0) {
169 +      if(xpos-x0 > xneg-x0) {
170 +        deltaPos += (xpos-x0)*(xpos-x0);
171 +      } else {
172 +        deltaPos += (xneg-x0)*(xneg-x0);
173 +      }
174 +    }
175 +    if(x0-xpos>0 || x0-xneg>0) {
176 +      if(x0-xpos > x0-xneg) {
177 +        deltaNeg += (xpos-x0)*(xpos-x0);
178 +      } else {
179 +        deltaNeg += (xneg-x0)*(xneg-x0);
180 +      }
181 +    }
182 +  }
183 +  errHi = sqrt(deltaPos);
184 +  errLo = sqrt(deltaNeg);
185 +
186 + }
187 +
188 +
189 + //________________________________________________________________________________________
190 + // Get normalization factor for the PDFs
191 + float get_norm_pdf_factor(TTree *events, int k) {
192 +
193 +  TH1F *haux = new TH1F("haux", "", 1000, 0, 15);
194 +  char nameVar[20];
195 +  sprintf(nameVar, "pdfW[%d]", k);
196 +  events->Project("haux", nameVar);
197 +  float factor = haux->Integral();
198 +
199 +  delete haux;
200 +
201 +  return factor;
202 +
203 + }
204 +
205 +
206 +
207 + //________________________________________________________________________________________
208   // Pile-up efficiency
209   float pileup(TTree *events, bool requireZ, string informalname, string addcut="",Float_t myJzbMax = 140. ) {
210          nBins = 16;
# Line 224 | Line 272 | void PeakError(TTree *events,float &resu
272  
273   //____________________________________________________________________________________
274   // Total selection efficiency (MC)
275 < void MCefficiency(TTree *events,float &result, float &resulterr,string mcjzb,bool requireZ,int Neventsinfile, string addcut="") {
275 > void MCefficiency(TTree *events,float &result, float &resulterr,string mcjzb,bool requireZ,int Neventsinfile, string addcut="", int k = 0) {
276          
277          char jzbSelStr[256]; sprintf(jzbSelStr,"%f",jzbSel);
278          // All acceptance cuts at gen. level
# Line 235 | Line 283 | void MCefficiency(TTree *events,float &r
283          // Corresponding reco. cuts
284          TCut ksel("pfJetGoodNum>2&&abs(mll-91.2)<20&&id1==id2&&"+TString(mcjzb)+geq_or_leq()+TString(jzbSelStr));
285          TCut ksel2("pfJetGoodNum>2&&abs(mll-91.2)<20&&id1==id2&&"+TString(mcjzb)+ngeq_or_leq()+TString("-")+TString(jzbSelStr));
286 <        events->Draw(mcjzbexpression.c_str(),kbase&&ksel,"goff");
286 >        TCut posSide = kbase&&ksel;
287 >        TCut negSide = kbase&&ksel2;
288 >        string sposSide(posSide);
289 >        string snegSide(negSide);
290 >        char var[20];
291 >        sprintf(var, "pdfW[%d]", k);
292 >        string svar(var);
293 >        string newPosSide = "(" + sposSide + ")*" + svar;
294 >        string newNegSide = "(" + snegSide + ")*" + svar;
295 >
296 >        events->Draw(mcjzbexpression.c_str(), newPosSide.c_str(),"goff");
297          Float_t sel = events->GetSelectedRows();
298          Float_t nsel=0;
299          if(ConsiderSignalContaminationForLimits) {
300 <          events->Draw(mcjzbexpression.c_str(),kbase&&ksel2,"goff");
300 >          events->Draw(mcjzbexpression.c_str(), newNegSide.c_str(),"goff");
301            nsel = events->GetSelectedRows();
302          }
303 +        //Corrections due to normalization in the PDF. This has to be applied as well to the number of events in a file if the definition changes at some point.
304 +        float normFactor = get_norm_pdf_factor(events, k);
305 +        sel = sel/normFactor;
306 +        nsel = nsel/normFactor;
307 +
308   //      events->Draw(mcjzbexpression.c_str(),kbase,"goff");
309   //      Float_t tot = events->GetSelectedRows();
310          Float_t tot = Neventsinfile;
# Line 357 | Line 420 | void JZBresponse(TTree *events, bool req
420   }
421  
422  
423 + //________________________________________________________________________________________
424 + // PDF uncertainty  
425 + float get_pdf_uncertainty(TTree *events, string mcjzb, bool requireZ, int Neventsinfile, string addcut="") {
426 +
427 +  int numberOfPDFs = 44;
428 +  std::vector<float> efficiency;
429 +  for(int k = 1; k < numberOfPDFs; k++) {
430 +    float result, resulterr;
431 +    MCefficiency(events, result, resulterr, mcjzb, requireZ, Neventsinfile, addcut, k);  
432 +    efficiency.push_back(result);
433 +  }
434 +  float errHi, errLow;
435 +  master_formula(efficiency, errHi, errLow);
436 +  if(errHi>errLow) return errHi;
437 +  return errLow;
438 +
439 + }
440 +
441 +
442 +
443   void do_systematics_for_one_file(TTree *events,int Neventsinfile,string informalname, vector<vector<float> > &results,string mcjzb,string datajzb,float peakerror,bool requireZ=false, string addcut="", bool ismSUGRA=false) {
444    
445    float JetEnergyScaleUncert=0.1;
# Line 391 | Line 474 | void do_systematics_for_one_file(TTree *
474  
475    if(!automatized) dout << "Pileup: " << std::endl;
476    float resolution=pileup(events,requireZ,informalname,addcut);
477 <  
477 >
478    float PDFuncert=0;
479 <  if(ismSUGRA) PDFuncert=999;//Pablo will complete this
480 <  
479 >  if(ismSUGRA) PDFuncert = get_pdf_uncertainty(events, mcjzb, requireZ, Neventsinfile, addcut);
480 >
481    dout << "_______________________________________________" << endl;
482    dout << "                 SUMMARY FOR " << informalname << " with JZB>" << jzbSel << "  (all in %) ";
483    if(addcut!="") dout << "With additional cut: " << addcut;

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines