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

Comparing UserCode/cbrown/Development/Plotting/Modules/EdgeLimit.C (file contents):
Revision 1.13 by buchmann, Wed Jun 12 08:21:59 2013 UTC vs.
Revision 1.18 by buchmann, Thu Jun 13 15:46:06 2013 UTC

# Line 56 | Line 56 | namespace EdgeFitter {
56    void getMedianLimit(RooWorkspace *ws,vector<RooDataSet> theToys,float &median,float &sigmaDown, float &sigmaUp, float &twoSigmaDown, float &twoSigmaUp);
57    void InitializeVariables(float _mllmin, float _mllmax, float _jzbmax, TCut _cut);
58    void PrepareDatasets(int);
59 +  void DrawDatasetContent(int);
60    void DoFit(int is_data, float jzb_cut);
61    string RandomStorageFile();
62    Yield Get_Z_estimate(float,int);
# Line 79 | Line 80 | namespace EdgeFitter {
80    float FixedMEdge=-1;
81    float FixedMEdgeChi2=-1;
82    
83 +  bool RejectPointIfNoConvergence=false;
84 +  
85 +  string Mode="UndefinedMode";
86 +  
87 + }
88 +
89 + TLatex* WriteAppleStudel() {
90 +  string sel="Apple Strudel Preliminary";
91 +  TLatex *sele = new TLatex(0.97,0.135,sel.c_str());
92 +  sele->SetNDC(true);
93 +  sele->SetTextColor(TColor::GetColor("#848484"));
94 +  sele->SetTextFont(42);
95 +  sele->SetTextAlign(32);
96 +  sele->SetTextSize(0.03);
97 +  sele->SetTextAngle(270);
98 +  return sele;
99   }
100  
101   TGraph* EdgeFitter::prepareLM(float mass, float nEv) {
# Line 150 | Line 167 | void EdgeFitter::getMedianLimit(RooWorks
167    sigmaDown = abs(yQ[1]-median);
168    sigmaUp = abs(yQ[2]-median);
169    twoSigmaUp = abs(yQ[3]-median);
170 <  cout << median * PlottingSetup::luminosity << " " << sigmaUp * PlottingSetup::luminosity << endl;
170 >  dout << median * PlottingSetup::luminosity << " " << sigmaUp * PlottingSetup::luminosity << endl;
171   }
172  
173   void EdgeFitter::prepareLimits(RooWorkspace *ws, bool ComputeBands) {
# Line 190 | Line 207 | void EdgeFitter::prepareLimits(RooWorksp
207      
208      for(int i=0;i<(int)theLimits.size();i++) {
209        if((theLimits[i]<2.0/PlottingSetup::luminosity)||(theLimits[i]>40.0/PlottingSetup::luminosity)) {
210 <        cout << i << " : " << theVals[i] << endl;
210 >        dout << i << " : " << theVals[i] << endl;
211          theLimits[i] = (theLimits[i+2]+theLimits[i-2])/2.0;
212          write_warning(__FUNCTION__,"Need to store limits");
213        }
# Line 254 | Line 271 | float EdgeFitter::calcExclusion(RooWorks
271    RooStats::HypoTestInverterResult* hcInt = hcInv.GetInterval();
272    float ulError = hcInt->UpperLimitEstimatedError();
273    theLimit = hcInt->UpperLimit();
274 <  cout << "Found upper limit : " << theLimit << "+/-" << ulError << endl;
274 >  dout << "Found upper limit : " << theLimit << "+/-" << ulError << endl;
275    
276    return theLimit/PlottingSetup::luminosity;
277    
278   }
279  
280   TTree* SkimTree(int isample) {
281 <  TTree* newTree = allsamples.collection[isample].events->CloneTree(0);
281 >  string TreeName = allsamples.collection[isample].filename;
282 >  TTree* newTree = new TTree("NanoTree",TreeName.c_str());
283 >  
284 >  float mll,edgeWeight;
285 >  int id1,id2;
286 >  
287 >  newTree->Branch("edgeWeight",&edgeWeight,"edgeWeight/F");
288 >  newTree->Branch("mll",&mll,"mll/F");
289 >  newTree->Branch("id1",&id1,"id1/I");
290 >  newTree->Branch("id2",&id2,"id2/I");
291 >  
292    float xsweight=1.0;
293    if(allsamples.collection[isample].is_data==false) xsweight=luminosity*allsamples.collection[isample].weight;
294    if(EdgeFitter::MarcoDebug) {
295 <    cout << "   Original tree contains " << allsamples.collection[isample].events->GetEntries() << endl;
296 <    cout << "   Going to reduce it with cut " << EdgeFitter::cut << endl;
295 >    dout << "   Original tree contains " << allsamples.collection[isample].events->GetEntries() << endl;
296 >    dout << "   Going to reduce it with cut " << EdgeFitter::cut << endl;
297    }
298 <  float edgeWeight;
272 <  newTree->Branch("edgeWeight",&edgeWeight,"edgeWeight/F");
298 >  
299    float tmll;
300 +  int tid1,tid2;
301    allsamples.collection[isample].events->SetBranchAddress("mll",&tmll);
302 < //  int id1,id2;
302 >  allsamples.collection[isample].events->SetBranchAddress("id1",&tid1);
303 >  allsamples.collection[isample].events->SetBranchAddress("id2",&tid2);
304    
305    TTreeFormula *select = new TTreeFormula("select", EdgeFitter::cut, allsamples.collection[isample].events);
306    TTreeFormula *Weight = new TTreeFormula("Weight", cutWeight, allsamples.collection[isample].events);
307 +  
308    float wgt=1.0;
280 //  allsamples.collection[isample].events->SetBranchAddress(cutWeight,&wgt);
309    for (Int_t entry = 0 ; entry < allsamples.collection[isample].events->GetEntries() ; entry++) {
310     allsamples.collection[isample].events->LoadTree(entry);
311     if (select->EvalInstance()) {
312       allsamples.collection[isample].events->GetEntry(entry);
313 +     mll=tmll;
314 +     id1=tid1;
315 +     id2=tid2;
316       wgt=Weight->EvalInstance();
317       edgeWeight=wgt*xsweight;
318       newTree->Fill();
319     }
320    }
321    
322 <  if(EdgeFitter::MarcoDebug) cout << "     Reduced tree contains " << newTree->GetEntries() << " entries " << endl;
322 >  if(EdgeFitter::MarcoDebug) dout << "     Reduced tree contains " << newTree->GetEntries() << " entries " << endl;
323    return newTree;
324   }
325  
# Line 300 | Line 331 | void EdgeFitter::InitializeVariables(flo
331   }
332  
333   TTree* MergeTrees(vector<TTree*> trees) {
334 <  TTree * newtree = (TTree*)trees[0]->CloneTree();
334 >  TTree * newtree = (TTree*)trees[0]->CloneTree(0);
335    trees[0]->GetListOfClones()->Remove(newtree);
336    trees[0]->ResetBranchAddresses();
337    newtree->ResetBranchAddresses();
338    
339 <  for(int itree=1;itree<trees.size();itree++) {
339 >  for(int itree=0;itree<trees.size();itree++) {
340      newtree->CopyAddresses(trees[itree]);
341      Long64_t nentries = trees[itree]->GetEntries();
342      for (Long64_t iEntry=0;iEntry<nentries;iEntry++) {
# Line 327 | Line 358 | TTree* MergeTrees(vector<TTree*> trees)
358  
359   void EdgeFitter::PrepareDatasets(int is_data) {
360    write_warning(__FUNCTION__,"Need to make this function ready for scans as well (use signal from scan samples)");
361 < //  TFile *tempout = new TFile("tempout.root","RECREATE");
361 >  TFile *tempout = new TFile("tempout.root","RECREATE");
362    vector<TTree*> SkimmedTrees;
363    TTree *SkimmedTree[(int)allsamples.collection.size()];
364    for(int isample=0;isample<(int)allsamples.collection.size();isample++) {
# Line 336 | Line 367 | void EdgeFitter::PrepareDatasets(int is_
367      if(is_data==1&&allsamples.collection[isample].is_data==false) continue;//kick all samples that aren't data if we're looking for data.
368      if(is_data!=1&&allsamples.collection[isample].is_data==true) continue;//kick all data samples when looking for MC
369      if(is_data!=2&&allsamples.collection[isample].is_signal==true) continue;//remove signal sample if we don't want it.
370 <    if(EdgeFitter::MarcoDebug) cout << "Considering : " << allsamples.collection[isample].samplename << endl;
371 <    SkimmedTrees.push_back(SkimTree(isample));
372 < //      SkimmedTree[isample] = SkimTree(isample);
373 < //    tempout->cd();
374 < //    SkimmedTree[isample]->Write();
344 < //    treelist->Add(SkimmedTree[isample]);
345 <    //treelist->Add(SkimTree(isample));
346 < //    allsamples.collection[isample].tfile->Close();
370 >    if(EdgeFitter::MarcoDebug) dout << "Considering : " << allsamples.collection[isample].samplename << endl;
371 >    SkimmedTree[isample] = SkimTree(isample);
372 >    tempout->cd();
373 >    SkimmedTree[isample]->Write();
374 >    SkimmedTrees.push_back(SkimmedTree[isample]);
375    }
376    
377    TTree *completetree  = MergeTrees(SkimmedTrees);
378    
379 < //  for(int isample=0;isample<(int)allsamples.collection.size();isample++) {
352 < //    if(SkimmedTree[isample]) SkimmedTree[isample]->Delete();
353 < //  }
354 <  
355 <  if(EdgeFitter::MarcoDebug) cout << "Complete tree now contains " << completetree->GetEntries() << " entries " << endl;
379 >  if(EdgeFitter::MarcoDebug) dout << "Complete tree now contains " << completetree->GetEntries() << " entries " << endl;
380    
381    RooRealVar mll("mll","m_{ll}",mllmin,mllmax,"GeV/c^{2}");
382    RooRealVar id1("id1","id1",0,1,"GeV/c^{2}");
383    RooRealVar id2("id2","id2",0,1,"GeV/c^{2}");
360  //RooRealVar jzb("jzb","jzb",-jzbmax,jzbmax,"GeV/c");
384    RooRealVar edgeWeight("edgeWeight","edgeWeight",0,1000,"");
385    RooArgSet observables(mll,id1,id2,edgeWeight);
386    
387    string title="CMS Data";
388    if(is_data!=1) title="CMS SIMULATION";
389    RooDataSet LAllData("LAllData",title.c_str(),completetree,observables,"","edgeWeight");
390 +  tempout->cd();
391    completetree->Write();
392 <  delete completetree;
393 < //  tempout->Close();
392 >  tempout->Close();
393 >
394    
395    EdgeFitter::SFSample = (RooDataSet*)LAllData.reduce("id1==id2");
396    EdgeFitter::OFSample = (RooDataSet*)LAllData.reduce("id1!=id2");
# Line 377 | Line 401 | void EdgeFitter::PrepareDatasets(int is_
401    AllData->SetName("AllData");
402    
403    if(EdgeFitter::MarcoDebug) {
404 <    cout << "Number of events in data sample = " << AllData->numEntries() << endl;
405 <    cout << "Number of events in eemm sample = " << SFSample->numEntries() << endl;
406 <    cout << "Number of events in em sample = " << OFSample->numEntries() << endl;
404 >    dout << "Number of events in data sample = " << AllData->sumEntries() << endl;
405 >    dout << "Number of events in eemm sample = " << SFSample->sumEntries() << endl;
406 >    dout << "Number of events in em sample = " << OFSample->sumEntries() << endl;
407    }
408    
409   }
410  
411 + void EdgeFitter::DrawDatasetContent(int is_data) {
412 +  RooRealVar mll("mll","m_{ll}",mllmin,mllmax,"GeV/c^{2}");
413 +  RooPlot* frame1 = mll.frame(RooFit::Bins(int((mllmax-mllmin)/5.0)),RooFit::Title("SF sample")) ;
414 +  frame1->GetXaxis()->CenterTitle(1);
415 +  frame1->GetYaxis()->CenterTitle(1);
416 +  SFSample->plotOn(frame1,RooFit::Name("SFdata")) ;
417 +  
418 +  RooPlot* frame2 = mll.frame(RooFit::Bins(int((mllmax-mllmin)/5.0)),RooFit::Title("OF sample")) ;
419 +  frame2->GetXaxis()->CenterTitle(1);
420 +  frame2->GetYaxis()->CenterTitle(1);
421 +  OFSample->plotOn(frame2,RooFit::Name("OFdata")) ;
422 +  
423 +  TCanvas* cSFdata = new TCanvas("cSFdata","cSFdata") ;
424 +  cSFdata->cd() ;
425 +  gPad->SetLeftMargin(0.15);
426 +  frame1->GetYaxis()->SetTitleOffset(1.4);
427 +  frame1->Draw();
428 +  if(is_data==data) DrawPrelim();
429 +  else DrawPrelim(PlottingSetup::luminosity,true);
430 +  CompleteSave(cSFdata,"Edge/SF_NoFit");
431 +  
432 +  TCanvas* cOFdata = new TCanvas("cOFdata","cOFdata") ;
433 +  cOFdata->cd() ;
434 +  gPad->SetLeftMargin(0.15);
435 +  frame2->SetMaximum(frame1->GetMaximum());
436 +  frame2->GetYaxis()->SetTitleOffset(1.4);
437 +  frame2->Draw();
438 +  if(is_data==data) DrawPrelim();
439 +  else DrawPrelim(PlottingSetup::luminosity,true);
440 +  CompleteSave(cOFdata,"Edge/OF_NoFit");
441 + }
442 +  
443   string WriteWithError(float central, float error, int digits) {
444    float ref=central;
445    if(ref<0) ref=-central;
# Line 421 | Line 477 | Yield EdgeFitter::Get_T_estimate(float j
477   }
478  
479   void EdgeFitter::DoFit(int is_data, float jzb_cut) {
480 +  
481 +  TLatex *ASP = WriteAppleStudel();
482 +  
483 +  stringstream prefix;
484 +  if(is_data==data) prefix << "data_";
485 +  if(is_data==mc) prefix << "mc_";
486 +  if(is_data==mcwithsignal) prefix << "mcwithS_";
487 +  
488 +  prefix << EdgeFitter::Mode << "_" << jzb_cut;
489 +  
490 +
491 +  
492    RooRealVar mll("mll","m_{ll}",mllmin,mllmax,"GeV/c^{2}");
493    RooRealVar edgeWeight("edgeWeight","edgeWeight",0,1000,"");
494    RooCategory sample("sample","sample") ;
# Line 442 | Line 510 | void EdgeFitter::DoFit(int is_data, floa
510    RooAddPdf model_OF("model_OF","model_OF", ttbarOF, fttbarOF);
511    RooSimultaneous simPdfOF("simPdfOF","simultaneous pdf", sample) ;
512    simPdfOF.addPdf(model_OF,"OF");
513 <  RooFitResult *resultOF = simPdfOF.fitTo(combData, RooFit::Save(),RooFit::Extended());
513 >  RooFitResult *resultOF = simPdfOF.fitTo(combData, RooFit::Save(),RooFit::Extended(),RooFit::Minos(true));
514 >  dout << "============================= < OF results > =============================" << endl;
515    resultOF->Print();
516 <
517 <  RooRealVar* resultOFpar1_ = (RooRealVar*) resultOF->floatParsFinal().find("par1ttbarOF");
518 <  float resultOFpar1 = resultOFpar1_->getVal();
519 <  //RooRealVar* resultOFpar2_ = (RooRealVar*) resultOF->floatParsFinal().find("par2ttbarOF");
520 <  //float resultOFpar2 = resultOFpar2_->getVal();
521 <  //cout << "caca2.txt" << endl;
522 <
523 <  RooRealVar* resultOFpar3_ = (RooRealVar*) resultOF->floatParsFinal().find("par3ttbarOF");
524 <  float resultOFpar3 = resultOFpar3_->getVal();
525 <
526 <  //RooRealVar* resultOFpar4_ = (RooRealVar*) resultOF->floatParsFinal().find("par4ttbarOF");
527 <  //float resultOFpar4 = resultOFpar4_->getVal();
528 <  //cout << "caca4.txt" << endl;
516 >  dout << "============================= < /OF results > =============================" << endl;
517 >  
518 >  
519 >  RooPlot* frameO = mll.frame(RooFit::Bins(int((mllmax-mllmin)/5.0)),RooFit::Title("OF sample"));
520 >  frameO->GetXaxis()->CenterTitle(1);
521 >  frameO->GetYaxis()->CenterTitle(1);
522 >  combData.plotOn(frameO,RooFit::Name("OFdata"),RooFit::Cut("sample==sample::OF")) ;
523 >  simPdfOF.plotOn(frameO,RooFit::Slice(sample,"OF"),RooFit::Name("FullFit"),RooFit::ProjWData(sample,combData), RooFit::LineColor(kBlack)) ;
524 >  simPdfOF.plotOn(frameO,RooFit::Slice(sample,"OF"),RooFit::Name("TTbarOFonly"),RooFit::Components("ttbarOF"),RooFit::ProjWData(sample,combData),RooFit::LineStyle(kDashed)) ;
525 >  
526 >  TCanvas* pof = new TCanvas("pof","pof") ;
527 >  pof->cd() ;
528 >  gPad->SetLeftMargin(0.15);
529 >  frameO->GetYaxis()->SetTitleOffset(1.4);
530 >  frameO->Draw();
531 >  if(is_data==data) DrawPrelim();
532 >  else DrawPrelim(PlottingSetup::luminosity,true);
533 >  ASP->Draw();
534 >  if(EdgeFitter::FixedMEdge>=0) CompleteSave(pof,"Edge/OF__OFFitonly_"+prefix.str()+"__MEdgeFix_"+any2string(EdgeFitter::FixedMEdge),false,false);
535 >  else CompleteSave(pof,"Edge/OF__OFFitonly_"+prefix.str(),false,false);
536 >  delete pof;
537 >    
538 >  if(resultOF->covQual()!=3) {
539 >    write_error(__FUNCTION__,"OF fit did not converge!!! Cannot continue!");
540 >    dout << "covQual is " << resultOF->covQual() << endl;
541 >    EdgeFitter::FixedMEdgeChi2=-1;
542 >    if(EdgeFitter::RejectPointIfNoConvergence) return;
543 >  } else {
544 >    write_info(__FUNCTION__,"OF fit converged");
545 >  }
546    
547    float StartingMedge=70;
548    if(EdgeFitter::FixedMEdge>0) StartingMedge=EdgeFitter::FixedMEdge;
549  
550  
551 +  RooDataSet *ZDataSet = (RooDataSet*)EdgeFitter::AllData->reduce("id1==id2 && abs(mll-91.2)<20");
552 +
553 +  float maxZ = ZDataSet->sumEntries();
554 +  dout << "maxZ was set to " << maxZ << endl;
555 +  delete ZDataSet;
556 +  
557 +  
558    // Now same flavor  
559 <  RooRealVar fzSF("fzSF", "fzSF", 5, 0, 100000);
559 >  RooRealVar fzSF("fzSF", "fzSF", 39, 39, maxZ);
560    RooRealVar meanzSF("meanzSF", "meanzSF", 91.1876, 89, 95);
561    //RooRealVar sigmazSF("sigmazSF", "sigmazSF", 0.5);
562    RooRealVar sigmazSF("sigmazSF", "sigmazSF", 5, 0.5, 5);
563    RooRealVar widthzSF("widthzSF", "widthzSF", 2.94);
564 +  widthzSF.setConstant();
565    
566    RooRealVar fttbarSF("fttbarSF", "fttbarSF", 100, 0, 100000);
567 <  RooRealVar par1ttbarSF("par1ttbarSF", "par1ttbarSF", resultOFpar1, 0, 100);
474 <  RooRealVar par2ttbarSF("par2ttbarSF", "par2ttbarSF", 1.0);
475 <  RooRealVar par3ttbarSF("par3ttbarSF", "par3ttbarSF", resultOFpar3, 0, 100);
476 <  RooRealVar par4ttbarSF("par4ttbarSF", "par4ttbarSF", 2.0);
567 >  RooRealVar par1ttbarSF("par1ttbarSF", "par1ttbarSF", 1.02*par1ttbarOF.getVal(), (1.02-0.07)*par1ttbarOF.getVal(), (1.02+0.07)*par1ttbarOF.getVal());
568  
569 <  RooRealVar fsignalSF("fsignalSF", "fsignalSF", 10, 0, 300);
569 >  RooRealVar fsignalSF("fsignalSF", "fsignalSF", 0, 0, 300);
570    RooRealVar par1signalSF("par1signalSF", "par1signalSF", 45, 20, 100);
571    RooRealVar par2signalSF("par2signalSF", "par2signalSF", 2, 1, 10);
572    RooRealVar par3signalSF("par3signalSF", "par3signalSF", StartingMedge, 0, 300);
# Line 484 | Line 575 | void EdgeFitter::DoFit(int is_data, floa
575  
576    if(EdgeFitter::FixedMEdge>0) par3signalSF.setConstant();
577    
578 <  RooSUSYBkgPdf ttbarSF("ttbarSF","ttbarSF", mll , par1ttbarSF, par2ttbarSF, par3ttbarSF, par4ttbarSF);
488 <  //RooSUSYTPdf signalSF("signalSF","signalSF", mll , par1signalSF, par2signalSF, par3signalSF);
578 >  RooSUSYBkgPdf ttbarSF("ttbarSF","ttbarSF", mll , par1ttbarSF, par2ttbarOF, par3ttbarOF, par4ttbarOF);
579    RooSUSYTPdf signalSF("signalSF","signalSF", mll , par1signalSF, sigmazSF, par3signalSF);
580    
491 /*  par1ttbarSF.setConstant(true);
492  par2ttbarSF.setConstant(true);
493  par3ttbarSF.setConstant(true);
494  par4ttbarSF.setConstant(true);*/
495  
496
497  //RooAddPdf model_SF("model_SF","model_SF", RooArgList(zSF, ttbarSF, signalSF), RooArgList(fzSF, fttbarSF, fsignalSF));
581    RooAddPdf model_SF("model_SF","model_SF", RooArgList(zSF, ttbarSF, signalSF), RooArgList(fzSF, fttbarSF, fsignalSF));
499  RooAddPdf model_em("model_em","model_em", RooArgList(ttbarSF), RooArgList(fttbarSF));
500
582    
583    RooSimultaneous simPdf("simPdf","simultaneous pdf",sample) ;
584    simPdf.addPdf(model_SF,"SF") ;
585 <  simPdf.addPdf(model_em,"em") ;
585 >  simPdf.addPdf(model_OF,"OF") ;
586 >
587 >  RooFitResult *result = simPdf.fitTo(combData, RooFit::Save(), RooFit::Extended(),RooFit::Minos(true));
588 >  
589 >  if(result->covQual()!=3) {
590 >    write_error(__FUNCTION__,"Full fit did not converge!!! Cannot continue!");
591 >    dout << "covQual is " << result->covQual() << endl;
592 >    EdgeFitter::FixedMEdgeChi2=-1;
593 >    if(EdgeFitter::RejectPointIfNoConvergence) return;
594 >  } else {
595 >    write_info(__FUNCTION__,"Full fit converged");
596 >  }
597  
598 <  RooFitResult *result = simPdf.fitTo(combData, RooFit::Save(), RooFit::Extended());
598 >  dout << "============================= < OF results > =============================" << endl;
599    result->Print();
600 +  dout << "============================= < /OF results > =============================" << endl;
601 +
602    
603    RooPlot* frame1 = mll.frame(RooFit::Bins(int((mllmax-mllmin)/5.0)),RooFit::Title("EE sample")) ;
604    frame1->GetXaxis()->CenterTitle(1);
605 +  frame1->GetYaxis()->CenterTitle(1);
606    combData.plotOn(frame1,RooFit::Name("SFdata"),RooFit::Cut("sample==sample::SF")) ;
607    simPdf.plotOn(frame1,RooFit::Slice(sample,"SF"),RooFit::Name("FullFit"),RooFit::ProjWData(sample,combData), RooFit::LineColor(kBlack)) ;
608    simPdf.plotOn(frame1,RooFit::Slice(sample,"SF"),RooFit::Name("TTbarSFonly"),RooFit::Components("ttbarSF"),RooFit::ProjWData(sample,combData),RooFit::LineStyle(kDashed)) ;
# Line 517 | Line 612 | void EdgeFitter::DoFit(int is_data, floa
612    EdgeFitter::FixedMEdgeChi2 = frame1->chiSquare("FullFit", "SFdata", 3);
613    
614    
615 <  cout << "Result   : " << endl;
616 <  cout << "f signal : " << fsignalSF.getVal() << " +/- " << fsignalSF.getError() << endl;
617 <  cout << "f ttbar  : " << fttbarSF.getVal() << " +/- " << fttbarSF.getError() << endl;
618 <  cout << "f tt OF  : " << fttbarOF.getVal() << " +/- " << fttbarOF.getError() << endl;
619 <  cout << "f z SF   : " << fzSF.getVal() << " +/- " << fzSF.getError() << endl;
620 <  cout << "#Chi^{2}/NDF     : " << EdgeFitter::FixedMEdgeChi2 << endl;
615 >  dout << "Result   : " << endl;
616 >  dout << "f signal : " << fsignalSF.getVal() << " +/- " << fsignalSF.getError() << endl;
617 >  dout << "f ttbar  : " << fttbarSF.getVal() << " +/- " << fttbarSF.getError() << endl;
618 >  dout << "f tt OF  : " << fttbarOF.getVal() << " +/- " << fttbarOF.getError() << endl;
619 >  dout << "f z SF   : " << fzSF.getVal() << " +/- " << fzSF.getError() << endl;
620 >  dout << "#Chi^{2}/NDF     : " << EdgeFitter::FixedMEdgeChi2 << endl;
621    
622    // The same plot for the cointrol sample slice
623    RooPlot* frame3 = mll.frame(RooFit::Bins(int((mllmax-mllmin)/5.0)),RooFit::Title("OF sample")) ;
624    frame3->GetXaxis()->CenterTitle(1);
625 +  frame3->GetYaxis()->CenterTitle(1);
626    frame3->SetMaximum(frame1->GetMaximum());
627    combData.plotOn(frame3,RooFit::Cut("sample==sample::OF")) ;
628 <  simPdfOF.plotOn(frame3,RooFit::Slice(sample,"OF"),RooFit::ProjWData(sample,combData), RooFit::LineColor(kBlack)) ;
629 <  simPdfOF.plotOn(frame3,RooFit::Slice(sample,"OF"),RooFit::Components("ttbarOF"),RooFit::ProjWData(sample,combData),RooFit::LineStyle(kDashed)) ;
534 <  
535 <  
536 <  stringstream prefix;
537 <  if(is_data==data) prefix << "data_";
538 <  if(is_data==mc) prefix << "mc_";
539 <  if(is_data==mcwithsignal) prefix << "mcwithS_";
540 <  
541 <  prefix << "JZB_" << jzb_cut;
542 <  
628 >  simPdf.plotOn(frame3,RooFit::Slice(sample,"OF"),RooFit::ProjWData(sample,combData), RooFit::LineColor(kBlack)) ;
629 >  simPdf.plotOn(frame3,RooFit::Slice(sample,"OF"),RooFit::Components("ttbarOF"),RooFit::ProjWData(sample,combData),RooFit::LineStyle(kDashed)) ;
630    
631    
632    TCanvas* c = new TCanvas("rf501_simultaneouspdf","rf403_simultaneouspdf") ;
# Line 550 | Line 637 | void EdgeFitter::DoFit(int is_data, floa
637    if(is_data==data) DrawPrelim();
638    else DrawPrelim(PlottingSetup::luminosity,true);
639    stringstream infotext;
640 <  infotext << "#splitline{Fit results (JZB>" << jzb_cut << "): }{#splitline{";
641 <  infotext << "N(Data) = " << EdgeFitter::SFSample->numEntries() << "}{#splitline{";
640 >  infotext << "#splitline{Fit results (" << EdgeFitter::Mode << ">" << jzb_cut << "): }{#splitline{";
641 >  infotext << "N(Data) = " << EdgeFitter::SFSample->sumEntries() << "}{#splitline{";
642    infotext << "N(Z+Jets) = " << WriteWithError(fzSF.getVal(),fzSF.getError(),3) << "}{#splitline{";
643    infotext << "N(t#bar{t}) = " << WriteWithError(fttbarSF.getVal(),fttbarSF.getError(),3) << "}{#splitline{";
644    infotext << "N(signal) = " << WriteWithError(fsignalSF.getVal(),fsignalSF.getError(),3) << "}{";
# Line 561 | Line 648 | void EdgeFitter::DoFit(int is_data, floa
648    infobox->SetNDC();
649    infobox->SetTextSize(0.03);
650    infobox->Draw();
651 <  CompleteSave(c,"Edge/"+prefix.str()+"_SF__MEdgeFix_"+any2string(EdgeFitter::FixedMEdge),false,false);
651 >  ASP->Draw();
652 >  if(EdgeFitter::FixedMEdge>=0) CompleteSave(c,"Edge/"+prefix.str()+"_SF__MEdgeFix_"+any2string(EdgeFitter::FixedMEdge),false,false);
653 >  else CompleteSave(c,"Edge/"+prefix.str()+"_SF",false,false);
654    delete c;
655    
656    TCanvas* e = new TCanvas("rf501_simultaneouspdfem","rf403_simultaneouspdfem") ;
# Line 571 | Line 660 | void EdgeFitter::DoFit(int is_data, floa
660    frame3->Draw();
661    if(is_data==data) DrawPrelim();
662    else DrawPrelim(PlottingSetup::luminosity,true);
663 <  CompleteSave(e,"Edge/"+prefix.str()+"_OF__MEdgeFix_"+any2string(EdgeFitter::FixedMEdge),false,false);
663 >  ASP->Draw();
664 >  if(EdgeFitter::FixedMEdge>=0) CompleteSave(e,"Edge/"+prefix.str()+"_OF__MEdgeFix_"+any2string(EdgeFitter::FixedMEdge),false,false);
665 >  else CompleteSave(e,"Edge/"+prefix.str()+"_OF",false,false);
666    delete e;
667    
668    
# Line 616 | Line 707 | void EdgeFitter::DoEdgeFit(string mcjzb,
707    
708    EdgeFitter::PrepareDatasets(is_data);
709    
710 +  EdgeFitter::DrawDatasetContent(is_data);
711 +  
712    RooFit::MsgLevel msglevel = RooMsgService::instance().globalKillBelow();
713    RooMsgService::instance().setGlobalKillBelow(RooFit::FATAL);
621  write_warning(__FUNCTION__,"Deactivated actual fitting procedure ATM");
714    
715    
716 <  bool ScanMassRange=true;
716 >  bool ScanMassRange=false;
717 >  float ScanSteps=5.0;//GeV
718    
719    
720    
# Line 629 | Line 722 | void EdgeFitter::DoEdgeFit(string mcjzb,
722      TFile *fscan = new TFile("fscan.root","UPDATE");
723      TGraph *gr = new TGraph();
724      stringstream GrName;
725 <    GrName << "ScanGraphFor_JZB_" << jzb_cut;
725 >    GrName << "ScanGraphFor_" << EdgeFitter::Mode << "_" << jzb_cut;
726      gr->SetName(GrName.str().c_str());
727  
728      int i=0;
729 <    for(float tempMedge=10;tempMedge<=300;tempMedge+=5.0) {
730 <      write_info(__FUNCTION__,"Now testing Medge="+any2string(tempMedge)+" for JZB>"+any2string(jzb_cut));
729 >    for(float tempMedge=10;tempMedge<=300;tempMedge+=ScanSteps) {
730 >      write_info(__FUNCTION__,"Now testing Medge="+any2string(tempMedge)+" for "+EdgeFitter::Mode+">"+any2string(jzb_cut));
731        EdgeFitter::FixedMEdge=tempMedge;
732        EdgeFitter::DoFit(is_data, jzb_cut);
733 +      if(EdgeFitter::FixedMEdgeChi2<0) continue;
734        gr->SetPoint(i,tempMedge,EdgeFitter::FixedMEdgeChi2);
735        i++;
736      }
# Line 652 | Line 746 | void EdgeFitter::DoEdgeFit(string mcjzb,
746      gr->SetTitle("");
747      gr->Draw("AL");
748      stringstream ScanCanSave;
749 <    ScanCanSave << "Edge/MEdgeScan_JZB_" << jzb_cut;
749 >    ScanCanSave << "Edge/MEdgeScan_"+EdgeFitter::Mode+"_" << jzb_cut;
750      if(is_data) DrawPrelim();
751      else DrawMCPrelim();
752      CompleteSave(ScanCan,ScanCanSave.str());
# Line 676 | Line 770 | void EdgeFitter::DoEdgeFit(string mcjzb,
770   }
771  
772   void DoEdgeFit(string mcjzb, string datajzb, float DataPeakError, float MCPeakError, vector<float> jzb_cut, int is_data, TCut cut, TTree *signalevents=0) {
773 +  
774 +  EdgeFitter::Mode="JZB";
775 +  if(mcjzb=="met[4]") EdgeFitter::Mode="MET";
776 +  
777    for(int icut=0;icut<(int)jzb_cut.size();icut++) {
778      stringstream addcut;
779      if(is_data==1) addcut << "(" << datajzb << ">" << jzb_cut[icut] << ")";

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines