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.9 by buchmann, Fri Sep 7 13:40:44 2012 UTC vs.
Revision 1.13 by buchmann, Wed Jun 12 08:21:59 2013 UTC

# Line 1 | Line 1
1   #include <iostream>
2  
3 + #include <TVirtualIndex.h>
4 +
5   #include <RooRealVar.h>
6   #include <RooArgSet.h>
7   #include <RooDataSet.h>
# Line 69 | Line 71 | namespace EdgeFitter {
71    TCut cut;
72    
73    RooDataSet* AllData;
74 <  RooDataSet* eeSample;
75 <  RooDataSet* mmSample;
74 <  RooDataSet* emSample;
74 >  RooDataSet* SFSample;
75 >  RooDataSet* OFSample;
76    
77    bool MarcoDebug=true;
78 +  
79 +  float FixedMEdge=-1;
80 +  float FixedMEdgeChi2=-1;
81 +  
82   }
83  
84   TGraph* EdgeFitter::prepareLM(float mass, float nEv) {
# Line 93 | Line 98 | TGraph* EdgeFitter::prepareLM(float mass
98   }
99  
100   vector<RooDataSet> EdgeFitter::generateToys(RooWorkspace *ws, int nToys) {
101 +  ws->ls();
102    ws->var("nSig")->setVal(0.);
103    ws->var("nSig")->setConstant(true);
104    RooFitResult* fit = ws->pdf("combModel")->fitTo(*ws->data("data_obs"),RooFit::Save());
# Line 105 | Line 111 | vector<RooDataSet> EdgeFitter::generateT
111    RooMCStudy mcOSOF(*ws->pdf("combModel"),RooArgSet(*ws->var("inv")),RooFit::Slice(*ws->cat("cat"),"OSOF"));
112    mcOSOF.generate(nToys,44,true);
113    
114 <  RooRealVar mll("mll","mll",mllmin,mllmax,"GeV/c^{2}");
114 >  RooRealVar mll("m_{ll}","m_{ll}",mllmin,mllmax,"GeV/c^{2}");
115    RooRealVar id1("id1","id1",0,1,"GeV/c^{2}");
116    RooRealVar id2("id2","id2",0,1,"GeV/c^{2}");
117    RooRealVar jzb("jzb","jzb",-jzbmax,jzbmax,"GeV/c");
# Line 269 | Line 275 | TTree* SkimTree(int isample) {
275   //  int id1,id2;
276    
277    TTreeFormula *select = new TTreeFormula("select", EdgeFitter::cut, allsamples.collection[isample].events);
278 +  TTreeFormula *Weight = new TTreeFormula("Weight", cutWeight, allsamples.collection[isample].events);
279    float wgt=1.0;
280 <  allsamples.collection[isample].events->SetBranchAddress(cutWeight,&wgt);
280 > //  allsamples.collection[isample].events->SetBranchAddress(cutWeight,&wgt);
281    for (Int_t entry = 0 ; entry < allsamples.collection[isample].events->GetEntries() ; entry++) {
282     allsamples.collection[isample].events->LoadTree(entry);
283     if (select->EvalInstance()) {
284       allsamples.collection[isample].events->GetEntry(entry);
285 +     wgt=Weight->EvalInstance();
286       edgeWeight=wgt*xsweight;
287       newTree->Fill();
288     }
# Line 290 | Line 298 | void EdgeFitter::InitializeVariables(flo
298    jzbmax=_jzbmax;
299    cut=_cut;
300   }
301 <  
301 >
302 > TTree* MergeTrees(vector<TTree*> trees) {
303 >  TTree * newtree = (TTree*)trees[0]->CloneTree();
304 >  trees[0]->GetListOfClones()->Remove(newtree);
305 >  trees[0]->ResetBranchAddresses();
306 >  newtree->ResetBranchAddresses();
307 >  
308 >  for(int itree=1;itree<trees.size();itree++) {
309 >    newtree->CopyAddresses(trees[itree]);
310 >    Long64_t nentries = trees[itree]->GetEntries();
311 >    for (Long64_t iEntry=0;iEntry<nentries;iEntry++) {
312 >      trees[itree]->GetEntry(iEntry);
313 >      newtree->Fill();
314 >    }
315 >    trees[itree]->ResetBranchAddresses(); // Disconnect from new tree
316 >    if (newtree->GetTreeIndex()) {
317 >      newtree->GetTreeIndex()->Append(trees[itree]->GetTreeIndex(),kTRUE);
318 >    }
319 >    if (newtree && newtree->GetTreeIndex()) {
320 >      newtree->GetTreeIndex()->Append(0,kFALSE); // Force the sorting
321 >    }
322 >  }
323 >  return newtree;
324 > }
325 >    
326 >      
327 >
328   void EdgeFitter::PrepareDatasets(int is_data) {
295  TTree *completetree;
329    write_warning(__FUNCTION__,"Need to make this function ready for scans as well (use signal from scan samples)");
330 <  TList *treelist = new TList;
330 > //  TFile *tempout = new TFile("tempout.root","RECREATE");
331 >  vector<TTree*> SkimmedTrees;
332 >  TTree *SkimmedTree[(int)allsamples.collection.size()];
333    for(int isample=0;isample<(int)allsamples.collection.size();isample++) {
334      if(!allsamples.collection[isample].is_active) continue;
335      if(is_data==1&&allsamples.collection[isample].is_data==false) continue;//kick all samples that aren't data if we're looking for data.
# Line 302 | Line 337 | void EdgeFitter::PrepareDatasets(int is_
337      if(is_data!=1&&allsamples.collection[isample].is_data==true) continue;//kick all data samples when looking for MC
338      if(is_data!=2&&allsamples.collection[isample].is_signal==true) continue;//remove signal sample if we don't want it.
339      if(EdgeFitter::MarcoDebug) cout << "Considering : " << allsamples.collection[isample].samplename << endl;
340 <    treelist->Add(SkimTree(isample));
340 >    SkimmedTrees.push_back(SkimTree(isample));
341 > //      SkimmedTree[isample] = SkimTree(isample);
342 > //    tempout->cd();
343 > //    SkimmedTree[isample]->Write();
344 > //    treelist->Add(SkimmedTree[isample]);
345 >    //treelist->Add(SkimTree(isample));
346 > //    allsamples.collection[isample].tfile->Close();
347    }
348 <  completetree = TTree::MergeTrees(treelist);
348 >  
349 >  TTree *completetree  = MergeTrees(SkimmedTrees);
350 >  
351 > //  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;
356    
357 <  RooRealVar mll("mll","mll",mllmin,mllmax,"GeV/c^{2}");
357 >  RooRealVar mll("mll","m_{ll}",mllmin,mllmax,"GeV/c^{2}");
358    RooRealVar id1("id1","id1",0,1,"GeV/c^{2}");
359    RooRealVar id2("id2","id2",0,1,"GeV/c^{2}");
360    //RooRealVar jzb("jzb","jzb",-jzbmax,jzbmax,"GeV/c");
# Line 319 | Line 366 | void EdgeFitter::PrepareDatasets(int is_
366    RooDataSet LAllData("LAllData",title.c_str(),completetree,observables,"","edgeWeight");
367    completetree->Write();
368    delete completetree;
369 + //  tempout->Close();
370    
371 <  EdgeFitter::eeSample = (RooDataSet*)LAllData.reduce("id1==id2");
372 <  EdgeFitter::mmSample = (RooDataSet*)LAllData.reduce("id1==id2");
325 <  EdgeFitter::emSample = (RooDataSet*)LAllData.reduce("id1!=id2");
371 >  EdgeFitter::SFSample = (RooDataSet*)LAllData.reduce("id1==id2");
372 >  EdgeFitter::OFSample = (RooDataSet*)LAllData.reduce("id1!=id2");
373    EdgeFitter::AllData  = (RooDataSet*)LAllData.reduce("id1!=id2||id1==id2");
374    
375 <  eeSample->SetName("eeSample");
376 <  mmSample->SetName("mmSample");
330 <  emSample->SetName("emSample");
375 >  SFSample->SetName("SFSample");
376 >  OFSample->SetName("OFSample");
377    AllData->SetName("AllData");
378    
379    if(EdgeFitter::MarcoDebug) {
380      cout << "Number of events in data sample = " << AllData->numEntries() << endl;
381 <    cout << "Number of events in ee sample = " << eeSample->numEntries() << endl;
382 <    cout << "Number of events in mm sample = " << mmSample->numEntries() << endl;
337 <    cout << "Number of events in em sample = " << emSample->numEntries() << endl;
381 >    cout << "Number of events in eemm sample = " << SFSample->numEntries() << endl;
382 >    cout << "Number of events in em sample = " << OFSample->numEntries() << endl;
383    }
384    
385   }
386  
387 + string WriteWithError(float central, float error, int digits) {
388 +  float ref=central;
389 +  if(ref<0) ref=-central;
390 +  int HighestSigDigit = 0;
391 +  if(ref>1) HighestSigDigit = int(log(ref)/log(10))+1;
392 +  else HighestSigDigit = int(log(ref)/(log(10)));
393 +  
394 +  float divider=pow(10.0,(double(HighestSigDigit-digits)));
395 +  
396 +  stringstream result;
397 +  result << divider*int(central/divider+0.5) << " #pm " << divider*int(error/divider+0.5);
398 +  return result.str();
399 + }
400 +
401 +
402   string EdgeFitter::RandomStorageFile() {
403    TRandom3 *r = new TRandom3(0);
404    int rho = (int)r->Uniform(1,10000000);
# Line 361 | Line 421 | Yield EdgeFitter::Get_T_estimate(float j
421   }
422  
423   void EdgeFitter::DoFit(int is_data, float jzb_cut) {
424 <  RooRealVar mll("mll","mll",mllmin,mllmax,"GeV/c^{2}");
424 >  RooRealVar mll("mll","m_{ll}",mllmin,mllmax,"GeV/c^{2}");
425    RooRealVar edgeWeight("edgeWeight","edgeWeight",0,1000,"");
426    RooCategory sample("sample","sample") ;
427 <  sample.defineType("ee");
427 >  sample.defineType("SF");
428    //sample.defineType("mm");
429 <  sample.defineType("em");
429 >  sample.defineType("OF");
430    
431 <  //RooDataSet combData("combData","combined data",mll,Index(sample),Import("ee",*eeSample),Import("mm",*mmSample),Import("em",*emSample));
432 <  RooDataSet combData("combData","combined data",RooArgSet(mll,edgeWeight),RooFit::Index(sample),RooFit::Import("ee",*eeSample),RooFit::Import("em",*emSample),RooFit::WeightVar(edgeWeight));
431 >  //RooDataSet combData("combData","combined data",mll,Index(sample),Import("SF",*SFSample),Import("mm",*mmSample),Import("OF",*OFSample));
432 >  RooDataSet combData("combData","combined data",RooArgSet(mll,edgeWeight),RooFit::Index(sample),RooFit::Import("SF",*SFSample),RooFit::Import("OF",*OFSample),RooFit::WeightVar(edgeWeight));
433    
434    
435    //First we make a fit to opposite flavor
436 <  RooRealVar fttbarem("fttbarem", "fttbarem", 100, 0, 10000);
437 <  RooRealVar par1ttbarem("par1ttbarem", "par1ttbarem", 1.6, 0.01, 4.0);
438 <  RooRealVar par2ttbarem("par2ttbarem", "par2ttbarem", 1.0);
439 <  RooRealVar par3ttbarem("par3ttbarem", "par3ttbarem", 0.028, 0.001, 1.0);
440 <  RooRealVar par4ttbarem("par4ttbarem", "par4ttbarem", 2.0);
441 <  RooSUSYBkgPdf ttbarem("ttbarem","ttbarem", mll , par1ttbarem, par2ttbarem, par3ttbarem, par4ttbarem);
442 <  RooAddPdf model_em("model_em","model_em", ttbarem, fttbarem);
436 >  RooRealVar fttbarOF("fttbarOF", "fttbarOF", 100, 0, 10000);
437 >  RooRealVar par1ttbarOF("par1ttbarOF", "par1ttbarOF", 1.6, 0.01, 4.0);
438 >  RooRealVar par2ttbarOF("par2ttbarOF", "par2ttbarOF", 1.0);
439 >  RooRealVar par3ttbarOF("par3ttbarOF", "par3ttbarOF", 0.028, 0.001, 1.0);
440 >  RooRealVar par4ttbarOF("par4ttbarOF", "par4ttbarOF", 2.0);
441 >  RooSUSYBkgPdf ttbarOF("ttbarOF","ttbarOF", mll , par1ttbarOF, par2ttbarOF, par3ttbarOF, par4ttbarOF);
442 >  RooAddPdf model_OF("model_OF","model_OF", ttbarOF, fttbarOF);
443    RooSimultaneous simPdfOF("simPdfOF","simultaneous pdf", sample) ;
444 <  simPdfOF.addPdf(model_em,"em");
445 <  RooFitResult *resultOF = simPdfOF.fitTo(combData, RooFit::Save());
444 >  simPdfOF.addPdf(model_OF,"OF");
445 >  RooFitResult *resultOF = simPdfOF.fitTo(combData, RooFit::Save(),RooFit::Extended());
446    resultOF->Print();
447  
448 <  RooRealVar* resultOFpar1_ = (RooRealVar*) resultOF->floatParsFinal().find("par1ttbarem");
448 >  RooRealVar* resultOFpar1_ = (RooRealVar*) resultOF->floatParsFinal().find("par1ttbarOF");
449    float resultOFpar1 = resultOFpar1_->getVal();
450 <  //RooRealVar* resultOFpar2_ = (RooRealVar*) resultOF->floatParsFinal().find("par2ttbarem");
450 >  //RooRealVar* resultOFpar2_ = (RooRealVar*) resultOF->floatParsFinal().find("par2ttbarOF");
451    //float resultOFpar2 = resultOFpar2_->getVal();
452    //cout << "caca2.txt" << endl;
453  
454 <  RooRealVar* resultOFpar3_ = (RooRealVar*) resultOF->floatParsFinal().find("par3ttbarem");
454 >  RooRealVar* resultOFpar3_ = (RooRealVar*) resultOF->floatParsFinal().find("par3ttbarOF");
455    float resultOFpar3 = resultOFpar3_->getVal();
456  
457 <  //RooRealVar* resultOFpar4_ = (RooRealVar*) resultOF->floatParsFinal().find("par4ttbarem");
457 >  //RooRealVar* resultOFpar4_ = (RooRealVar*) resultOF->floatParsFinal().find("par4ttbarOF");
458    //float resultOFpar4 = resultOFpar4_->getVal();
459    //cout << "caca4.txt" << endl;
460 +  
461 +  float StartingMedge=70;
462 +  if(EdgeFitter::FixedMEdge>0) StartingMedge=EdgeFitter::FixedMEdge;
463  
464  
465    // Now same flavor  
466 <  RooRealVar fzee("fzee", "fzee", 5, 0, 100000);
467 <  RooRealVar meanzee("meanzee", "meanzee", 91.1876, 89, 95);
468 <  //RooRealVar sigmazee("sigmazee", "sigmazee", 0.5);
469 <  RooRealVar sigmazee("sigmazee", "sigmazee", 5, 0, 100);
470 <  RooRealVar widthzee("widthzee", "widthzee", 2.94);
471 <  
472 <  RooRealVar fttbaree("fttbaree", "fttbaree", 100, 0, 100000);
473 <  RooRealVar par1ttbaree("par1ttbaree", "par1ttbaree", resultOFpar1, 0, 100);
474 <  RooRealVar par2ttbaree("par2ttbaree", "par2ttbaree", 1.0);
475 <  RooRealVar par3ttbaree("par3ttbaree", "par3ttbaree", resultOFpar3, 0, 100);
476 <  RooRealVar par4ttbaree("par4ttbaree", "par4ttbaree", 2.0);
466 >  RooRealVar fzSF("fzSF", "fzSF", 5, 0, 100000);
467 >  RooRealVar meanzSF("meanzSF", "meanzSF", 91.1876, 89, 95);
468 >  //RooRealVar sigmazSF("sigmazSF", "sigmazSF", 0.5);
469 >  RooRealVar sigmazSF("sigmazSF", "sigmazSF", 5, 0.5, 5);
470 >  RooRealVar widthzSF("widthzSF", "widthzSF", 2.94);
471 >  
472 >  RooRealVar fttbarSF("fttbarSF", "fttbarSF", 100, 0, 100000);
473 >  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);
477  
478 <  RooRealVar fsignalee("fsignalee", "fsignalee", 10, 0, 400);
479 <  RooRealVar par1signalee("par1signalee", "par1signalee", 45, 20, 100);
480 <  RooRealVar par2signalee("par2signalee", "par2signalee", 2, 1, 10);
481 <  RooRealVar par3signalee("par3signalee", "par3signalee", 45, 0, 200);
478 >  RooRealVar fsignalSF("fsignalSF", "fsignalSF", 10, 0, 300);
479 >  RooRealVar par1signalSF("par1signalSF", "par1signalSF", 45, 20, 100);
480 >  RooRealVar par2signalSF("par2signalSF", "par2signalSF", 2, 1, 10);
481 >  RooRealVar par3signalSF("par3signalSF", "par3signalSF", StartingMedge, 0, 300);
482  
483 <  RooVoigtian zee("zee", "zee", mll, meanzee, widthzee, sigmazee);
483 >  RooVoigtian zSF("zSF", "zSF", mll, meanzSF, widthzSF, sigmazSF);
484  
485 +  if(EdgeFitter::FixedMEdge>0) par3signalSF.setConstant();
486 +  
487 +  RooSUSYBkgPdf ttbarSF("ttbarSF","ttbarSF", mll , par1ttbarSF, par2ttbarSF, par3ttbarSF, par4ttbarSF);
488 +  //RooSUSYTPdf signalSF("signalSF","signalSF", mll , par1signalSF, par2signalSF, par3signalSF);
489 +  RooSUSYTPdf signalSF("signalSF","signalSF", mll , par1signalSF, sigmazSF, par3signalSF);
490 +  
491 + /*  par1ttbarSF.setConstant(true);
492 +  par2ttbarSF.setConstant(true);
493 +  par3ttbarSF.setConstant(true);
494 +  par4ttbarSF.setConstant(true);*/
495    
423  RooSUSYBkgPdf ttbaree("ttbaree","ttbaree", mll , par1ttbaree, par2ttbaree, par3ttbaree, par4ttbaree);
424  //RooSUSYTPdf signalee("signalee","signalee", mll , par1signalee, par2signalee, par3signalee);
425  RooSUSYTPdf signalee("signalee","signalee", mll , par1signalee, sigmazee, par3signalee);
496  
497 <  //RooAddPdf model_ee("model_ee","model_ee", RooArgList(zee, ttbaree, signalee), RooArgList(fzee, fttbaree, fsignalee));
498 <  RooAddPdf model_ee("model_ee","model_ee", RooArgList(zee, ttbaree, signalee), RooArgList(fzee, fttbaree, fsignalee));
499 <  RooAddPdf model_emu("model_emu","model_emu", RooArgList(ttbaree), RooArgList(fttbaree));
497 >  //RooAddPdf model_SF("model_SF","model_SF", RooArgList(zSF, ttbarSF, signalSF), RooArgList(fzSF, fttbarSF, fsignalSF));
498 >  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  
501    
502    RooSimultaneous simPdf("simPdf","simultaneous pdf",sample) ;
503 <  simPdf.addPdf(model_ee,"ee") ;
504 <  simPdf.addPdf(model_emu,"em") ;
503 >  simPdf.addPdf(model_SF,"SF") ;
504 >  simPdf.addPdf(model_em,"em") ;
505  
506 <  RooFitResult *result = simPdf.fitTo(combData, RooFit::Save());
506 >  RooFitResult *result = simPdf.fitTo(combData, RooFit::Save(), RooFit::Extended());
507    result->Print();
508    
509 <  RooPlot* frame1 = mll.frame(RooFit::Bins(25),RooFit::Title("EE sample")) ;
510 <  combData.plotOn(frame1,RooFit::Cut("sample==sample::ee")) ;
511 <  simPdf.plotOn(frame1,RooFit::Slice(sample,"ee"),RooFit::ProjWData(sample,combData), RooFit::LineColor(kBlack)) ;
512 <  simPdf.plotOn(frame1,RooFit::Slice(sample,"ee"),RooFit::Components("ttbaree"),RooFit::ProjWData(sample,combData),RooFit::LineStyle(kDashed)) ;
513 <  simPdf.plotOn(frame1,RooFit::Slice(sample,"ee"),RooFit::Components("zee"), RooFit::ProjWData(sample, combData), RooFit::LineStyle(kDashed), RooFit::LineColor(kRed));
514 <  simPdf.plotOn(frame1,RooFit::Slice(sample,"ee"),RooFit::Components("signalee"), RooFit::ProjWData(sample, combData), RooFit::LineStyle(kDashed), RooFit::LineColor(kGreen));
515 <
516 <  RooPlot* frame2 = mll.frame(RooFit::Bins(25),RooFit::Title("MM sample")) ;
517 <  combData.plotOn(frame2,RooFit::Cut("sample==sample::mm")) ;
518 <  simPdf.plotOn(frame2,RooFit::Slice(sample,"mm"),RooFit::ProjWData(sample,combData), RooFit::LineColor(kBlack)) ;
449 <  simPdf.plotOn(frame2,RooFit::Slice(sample,"mm"),RooFit::Components("ttbarmm"),RooFit::ProjWData(sample,combData),RooFit::LineStyle(kDashed)) ;
450 <  simPdf.plotOn(frame2,RooFit::Slice(sample,"mm"),RooFit::Components("zmm"), RooFit::ProjWData(sample, combData), RooFit::LineStyle(kDashed), RooFit::LineColor(kRed));
451 <  simPdf.plotOn(frame2,RooFit::Slice(sample,"mm"),RooFit::Components("signalmm"), RooFit::ProjWData(sample, combData), RooFit::LineStyle(kDashed), RooFit::LineColor(kGreen));
452 <
509 >  RooPlot* frame1 = mll.frame(RooFit::Bins(int((mllmax-mllmin)/5.0)),RooFit::Title("EE sample")) ;
510 >  frame1->GetXaxis()->CenterTitle(1);
511 >  combData.plotOn(frame1,RooFit::Name("SFdata"),RooFit::Cut("sample==sample::SF")) ;
512 >  simPdf.plotOn(frame1,RooFit::Slice(sample,"SF"),RooFit::Name("FullFit"),RooFit::ProjWData(sample,combData), RooFit::LineColor(kBlack)) ;
513 >  simPdf.plotOn(frame1,RooFit::Slice(sample,"SF"),RooFit::Name("TTbarSFonly"),RooFit::Components("ttbarSF"),RooFit::ProjWData(sample,combData),RooFit::LineStyle(kDashed)) ;
514 >  simPdf.plotOn(frame1,RooFit::Slice(sample,"SF"),RooFit::Name("DYSFonly"),RooFit::Components("zSF"), RooFit::ProjWData(sample, combData), RooFit::LineStyle(kDashed), RooFit::LineColor(kRed));
515 >  simPdf.plotOn(frame1,RooFit::Slice(sample,"SF"),RooFit::Name("SignalSFonly"),RooFit::Components("signalSF"), RooFit::ProjWData(sample, combData), RooFit::LineStyle(kDashed), RooFit::LineColor(kGreen));
516 >  
517 >  EdgeFitter::FixedMEdgeChi2 = frame1->chiSquare("FullFit", "SFdata", 3);
518 >  
519    
520    cout << "Result   : " << endl;
521 <  cout << "f signal : " << fsignalee.getVal() << " +/- " << fsignalee.getError() << endl;
522 <  cout << "f ttbar  : " << fttbaree.getVal() << " +/- " << fttbaree.getError() << endl;
523 <  cout << "f tt em  : " << fttbarem.getVal() << " +/- " << fttbarem.getError() << endl;
524 <  cout << "f z ee   : " << fzee.getVal() << " +/- " << fzee.getError() << endl;
521 >  cout << "f signal : " << fsignalSF.getVal() << " +/- " << fsignalSF.getError() << endl;
522 >  cout << "f ttbar  : " << fttbarSF.getVal() << " +/- " << fttbarSF.getError() << endl;
523 >  cout << "f tt OF  : " << fttbarOF.getVal() << " +/- " << fttbarOF.getError() << endl;
524 >  cout << "f z SF   : " << fzSF.getVal() << " +/- " << fzSF.getError() << endl;
525 >  cout << "#Chi^{2}/NDF     : " << EdgeFitter::FixedMEdgeChi2 << endl;
526    
527    // The same plot for the cointrol sample slice
528 <  RooPlot* frame3 = mll.frame(RooFit::Bins(25),RooFit::Title("EM sample")) ;
529 <  combData.plotOn(frame3,RooFit::Cut("sample==sample::em")) ;
530 <  simPdfOF.plotOn(frame3,RooFit::Slice(sample,"em"),RooFit::ProjWData(sample,combData), RooFit::LineColor(kBlack)) ;
531 <  simPdfOF.plotOn(frame3,RooFit::Slice(sample,"em"),RooFit::Components("ttbarem"),RooFit::ProjWData(sample,combData),RooFit::LineStyle(kDashed)) ;
528 >  RooPlot* frame3 = mll.frame(RooFit::Bins(int((mllmax-mllmin)/5.0)),RooFit::Title("OF sample")) ;
529 >  frame3->GetXaxis()->CenterTitle(1);
530 >  frame3->SetMaximum(frame1->GetMaximum());
531 >  combData.plotOn(frame3,RooFit::Cut("sample==sample::OF")) ;
532 >  simPdfOF.plotOn(frame3,RooFit::Slice(sample,"OF"),RooFit::ProjWData(sample,combData), RooFit::LineColor(kBlack)) ;
533 >  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_";
# Line 479 | Line 549 | void EdgeFitter::DoFit(int is_data, floa
549    frame1->Draw();
550    if(is_data==data) DrawPrelim();
551    else DrawPrelim(PlottingSetup::luminosity,true);
552 <  CompleteSave(c,"Edge/"+prefix.str()+"eemm");
552 >  stringstream infotext;
553 >  infotext << "#splitline{Fit results (JZB>" << jzb_cut << "): }{#splitline{";
554 >  infotext << "N(Data) = " << EdgeFitter::SFSample->numEntries() << "}{#splitline{";
555 >  infotext << "N(Z+Jets) = " << WriteWithError(fzSF.getVal(),fzSF.getError(),3) << "}{#splitline{";
556 >  infotext << "N(t#bar{t}) = " << WriteWithError(fttbarSF.getVal(),fttbarSF.getError(),3) << "}{#splitline{";
557 >  infotext << "N(signal) = " << WriteWithError(fsignalSF.getVal(),fsignalSF.getError(),3) << "}{";
558 >  infotext << "m_{edge} = " << WriteWithError(par3signalSF.getVal(),par3signalSF.getError(),3) << "}}}}}";  
559 >
560 >  TLatex *infobox = new TLatex(0.57,0.75,infotext.str().c_str());
561 >  infobox->SetNDC();
562 >  infobox->SetTextSize(0.03);
563 >  infobox->Draw();
564 >  CompleteSave(c,"Edge/"+prefix.str()+"_SF__MEdgeFix_"+any2string(EdgeFitter::FixedMEdge),false,false);
565    delete c;
566    
485  TCanvas* d = new TCanvas("rf501_simultaneouspdf","rf403_simultaneouspdf") ;
486  d->cd() ;
487  gPad->SetLeftMargin(0.15);
488  frame2->GetYaxis()->SetTitleOffset(1.4);
489  frame2->Draw();
490  if(is_data==data) DrawPrelim();
491  else DrawPrelim(PlottingSetup::luminosity,true);
492  CompleteSave(d,"Edge/"+prefix.str()+"mm");
493  delete d;
494  //c->cd(2) ; gPad->SetLeftMargin(0.15) ; frame2->GetYaxis()->SetTitleOffset(1.4) ; frame2->Draw();
495  
567    TCanvas* e = new TCanvas("rf501_simultaneouspdfem","rf403_simultaneouspdfem") ;
568    e->cd();
569    gPad->SetLeftMargin(0.15);
# Line 500 | Line 571 | void EdgeFitter::DoFit(int is_data, floa
571    frame3->Draw();
572    if(is_data==data) DrawPrelim();
573    else DrawPrelim(PlottingSetup::luminosity,true);
574 <  CompleteSave(e,"Edge/"+prefix.str()+"emu");
574 >  CompleteSave(e,"Edge/"+prefix.str()+"_OF__MEdgeFix_"+any2string(EdgeFitter::FixedMEdge),false,false);
575    delete e;
576    
577    
# Line 513 | Line 584 | void EdgeFitter::DoFit(int is_data, floa
584    frame4->Draw();
585    if(is_data==data) DrawPrelim();
586    else DrawPrelim(PlottingSetup::luminosity,true);
587 <  CompleteSave(f,"Edge/"+prefix.str()+"eemm");
587 >  CompleteSave(f,"Edge/"+prefix.str()+"_SF");
588    delete f;*/
589  
590 < //  RooWorkspace* wspace = new RooWorkspace();
591 < //  stringstream mllvar;
592 < //  mllvar << "mll[" << (mllmax-mllmin)/2 << "," << mllmin << "," << mllmax;
593 < //  wspace->factory(mllvar.str().c_str());
594 < //  wspace->var("mll")->setBins(30);
595 < //  a lot of stuff missing here :-)
596 < //  we need to store data_obs, weight, and so on in this space.
597 < //  EdgeFitter::prepareLimits(wspace, true);
590 >
591 > /*
592 >  float maxZ=200;
593 >  RooWorkspace* wspace = new RooWorkspace();
594 >  stringstream mllvar;
595 >  mllvar << "mll[" << (mllmax-mllmin)/2 << "," << mllmin << "," << mllmax << "]";
596 >  wspace->factory(mllvar.str().c_str());
597 >  wspace->var("mll")->setBins(30);
598 >  wspace->factory("nSig[1.,0.,100.]");
599 >  wspace->factory(("nZ[0.04.,0.,"+any2string(maxZ)+"]").c_str());
600 >  wspace->factory("rME[1.12,1.05,1.19]");
601 >  wspace->factory("effUncert[1.]");
602 >  EdgeFitter::prepareLimits(wspace, true);
603 > */
604 >
605 > write_warning(__FUNCTION__," A lot missing here to calculate limits");
606 >
607   }
608  
609   void EdgeFitter::DoEdgeFit(string mcjzb, string datajzb, float DataPeakError, float MCPeakError, float jzb_cut, int icut, int is_data, TCut cut, TTree *signalevents=0) {
# Line 539 | Line 619 | void EdgeFitter::DoEdgeFit(string mcjzb,
619    RooFit::MsgLevel msglevel = RooMsgService::instance().globalKillBelow();
620    RooMsgService::instance().setGlobalKillBelow(RooFit::FATAL);
621    write_warning(__FUNCTION__,"Deactivated actual fitting procedure ATM");
622 +  
623 +  
624 +  bool ScanMassRange=true;
625 +  
626 +  
627 +  
628 +  if(ScanMassRange) {
629 +    TFile *fscan = new TFile("fscan.root","UPDATE");
630 +    TGraph *gr = new TGraph();
631 +    stringstream GrName;
632 +    GrName << "ScanGraphFor_JZB_" << jzb_cut;
633 +    gr->SetName(GrName.str().c_str());
634 +
635 +    int i=0;
636 +    for(float tempMedge=10;tempMedge<=300;tempMedge+=5.0) {
637 +      write_info(__FUNCTION__,"Now testing Medge="+any2string(tempMedge)+" for JZB>"+any2string(jzb_cut));
638 +      EdgeFitter::FixedMEdge=tempMedge;
639 +      EdgeFitter::DoFit(is_data, jzb_cut);
640 +      gr->SetPoint(i,tempMedge,EdgeFitter::FixedMEdgeChi2);
641 +      i++;
642 +    }
643 +    
644 +    TCanvas *ScanCan = new TCanvas("ScanCan","ScanCan",500,500);
645 +    gr->GetXaxis()->SetTitle("m_{edge}");
646 +    gr->GetXaxis()->CenterTitle();
647 +    gr->GetYaxis()->SetTitle("#Chi^{2} / NDF");
648 +    gr->GetYaxis()->CenterTitle();
649 +    gr->GetYaxis()->SetTitleOffset(0.95);
650 +    gr->GetXaxis()->SetTitleOffset(0.9);
651 +    gr->SetLineColor(kBlue);
652 +    gr->SetTitle("");
653 +    gr->Draw("AL");
654 +    stringstream ScanCanSave;
655 +    ScanCanSave << "Edge/MEdgeScan_JZB_" << jzb_cut;
656 +    if(is_data) DrawPrelim();
657 +    else DrawMCPrelim();
658 +    CompleteSave(ScanCan,ScanCanSave.str());
659 +    fscan->cd();
660 +    gr->Write();
661 +    delete ScanCan;
662 +    fscan->Close();
663 +  } else {
664 +    EdgeFitter::DoFit(is_data, jzb_cut);
665 +  }
666 +  
667 +      
668 +  
669 +  
670    EdgeFitter::DoFit(is_data, jzb_cut);
671    RooMsgService::instance().setGlobalKillBelow(msglevel);
672  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines