Пример #1
0
void MakeSpinPlots::DrawIndFit(TString tag, TString mcName){
  TCanvas *cv = new TCanvas(Form("%s_%s",mcName.Data(),tag.Data()));
  
  if(ws->var( Form("Data_%s_INDFIT_%s_Nsig",mcName.Data(),tag.Data()) ) == 0) return;

  RooRealVar* mass = ws->var("mass");
  mass->setBins( (mass->getMax() - mass->getMin())/1.5 ); //enfore 1.5GeV bin width
  RooPlot* frame  = mass->frame();

  tPair lbl(mcName,tag);

  double Ns = ws->var( Form("Data_%s_INDFIT_%s_Nsig",mcName.Data(),tag.Data()) )->getVal();
  double Nb = ws->var( Form("Data_%s_INDFIT_%s_Nbkg",mcName.Data(),tag.Data()) )->getVal();

  double Nblind = ws->data("Data_Combined")->reduce("(mass>100 && mass<119) || (mass>135.5 && mass<170)")->sumEntries(TString("evtcat==evtcat::")+tag);
  double Ntot   = ws->data("Data_Combined")->sumEntries(TString("evtcat==evtcat::")+tag);

  RooFitResult* fitres = (RooFitResult*)ws->obj(Form("Data_%s_INDFIT_fitResult",mcName.Data())); 
  std::cout << fitres << std::endl;
    ws->data("Data_Combined")->reduce(TString("evtcat==evtcat::")+tag)->plotOn(frame,RooFit::LineColor(kWhite),RooFit::MarkerColor(kWhite));
  //Data_Hgg125_INDFIT_EB_0
  ws->pdf(Form("Data_%s_INDFIT_%s",mcName.Data(),tag.Data()))->plotOn(frame, RooFit::FillColor(kGreen),RooFit::VisualizeError(*fitres,2.0));
  ws->pdf(Form("Data_%s_INDFIT_%s",mcName.Data(),tag.Data()))->plotOn(frame, RooFit::FillColor(kYellow),RooFit::VisualizeError(*fitres,1.0));
  ws->pdf(Form("Data_%s_INDFIT_%s",mcName.Data(),tag.Data()))->plotOn(frame, RooFit::LineColor(kRed));
  std::cout << "1" << std::endl;
  ws->pdf(Form("Data_BKGFIT_%s_bkgModel",tag.Data()))->plotOn(frame, RooFit::Normalization(Nb/(Nb+Ns)),RooFit::LineColor(kRed),RooFit::LineStyle(kDashed));
  std::cout << "2" << std::endl;

  ws->data("Data_Combined")->reduce(TString("evtcat==evtcat::")+tag)->plotOn(frame);
  frame->Draw();

  //TLatex *prelim = new TLatex(250,x->GetXmax()-40.,"CMS Preliminary");
  TLatex *prelim = new TLatex(0.12,0.96,"CMS Preliminary");
  TLatex *lum = new TLatex(0.7,0.96,Form("#sqrt{s}=8 TeV  L = %0.1f fb^{-1}",lumi));
  prelim->SetNDC();
  lum->SetNDC();
  prelim->SetTextSize(0.045);
  prelim->SetTextColor(kBlack);
  lum->SetTextSize(0.045);
  lum->SetTextColor(kBlack);

  TLatex *owner = new TLatex(0.6,0.88,"Alex Mott (Nov. 13, 2012)");
  owner->SetNDC();
  owner->SetTextSize(0.045);
  owner->SetTextColor(kBlack);

  TLatex *mu = new TLatex(0.7,0.8,Form("#mu = %0.1f #pm %0.2f", fitMean[lbl].first,fitMean[lbl].second));
  mu->SetNDC();
  mu->SetTextSize(0.045);

  TLatex *sig = new TLatex(0.7,0.72,Form("#sigma_{eff} = %0.1f #pm %0.2f", fitSigEff[lbl].first,fitSigEff[lbl].second));
  sig->SetNDC();
  sig->SetTextSize(0.045);

  float nSig = ws->var( Form("Data_%s_INDFIT_%s_Nsig",mcName.Data(),tag.Data()) )->getVal();
  float nSigErr = ws->var( Form("Data_%s_INDFIT_%s_Nsig",mcName.Data(),tag.Data()) )->getError();

  TLatex *Nsig = new TLatex(0.7,0.64,Form("N_{sig}= %0.1f #pm %0.1f",nSig,nSigErr));
  Nsig->SetNDC();
  Nsig->SetTextSize(0.045);


  frame->addObject(prelim);
  frame->addObject(lum);
  //frame->addObject(owner);
  frame->addObject(mu);
  frame->addObject(sig);
  frame->addObject(Nsig);
  frame->Draw();
  cv->SaveAs( basePath+Form("/mgg-FloatedFraction-%s-%s-%s.png",outputTag.Data(),mcName.Data(),tag.Data()) );
  cv->SaveAs( basePath+Form("/C/mgg-FloatedFraction-%s-%s-%s.C",outputTag.Data(),mcName.Data(),tag.Data()) );
  cv->SaveAs( basePath+Form("/mgg-FloatedFraction-%s-%s-%s.pdf",outputTag.Data(),mcName.Data(),tag.Data()) );
  delete cv;
}
Пример #2
0
void mass4Chan(){
//=========Macro generated from canvas: ccc/
//=========  (Thu Mar  7 22:11:11 2013) by ROOT version5.34/03
   TCanvas *ccc = new TCanvas("ccc", "",0,0,600,600);
   gStyle->SetOptFit(1);
   gStyle->SetOptStat(0);
   gStyle->SetOptTitle(0);
   ccc->Range(86.5625,-1.875,92.8125,10.625);
   ccc->SetFillColor(0);
   ccc->SetBorderMode(0);
   ccc->SetBorderSize(2);
   ccc->SetLeftMargin(0.15);
   ccc->SetRightMargin(0.05);
   ccc->SetTopMargin(0.05);
   ccc->SetBottomMargin(0.15);
   ccc->SetFrameFillStyle(0);
   ccc->SetFrameBorderMode(0);
   ccc->SetFrameFillStyle(0);
   ccc->SetFrameBorderMode(0);
   
  

   
   TH2F *hframe = new TH2F("hframe","",100,85,96,100,0,10);
   hframe->SetLineStyle(0);
   hframe->SetMarkerStyle(20);
   hframe->GetXaxis()->SetTitle(" m_{Z} (GeV)");
   hframe->GetXaxis()->SetNdivisions(510);
   hframe->GetXaxis()->SetLabelFont(42);
   hframe->GetXaxis()->SetLabelOffset(0.01);
   hframe->GetXaxis()->SetLabelSize(0.05);
   hframe->GetXaxis()->SetTitleSize(0.05);
   hframe->GetXaxis()->SetTitleOffset(1.15);
   hframe->GetXaxis()->SetTitleFont(42);
   hframe->GetYaxis()->SetTitle(" -2#Delta ln L");
   hframe->GetYaxis()->SetLabelFont(42);
   hframe->GetYaxis()->SetLabelOffset(0.01);
   hframe->GetYaxis()->SetLabelSize(0.05);
   hframe->GetYaxis()->SetTitleSize(0.05);
   hframe->GetYaxis()->SetTitleOffset(1.4);
   hframe->GetYaxis()->SetTitleFont(42);
   hframe->GetZaxis()->SetLabelFont(42);
   hframe->GetZaxis()->SetLabelOffset(0.007);
   hframe->GetZaxis()->SetLabelSize(0.045);
   hframe->GetZaxis()->SetTitleSize(0.05);
   hframe->GetZaxis()->SetTitleFont(42);
   hframe->Draw("");
   
   //4e
   TGraph *graph = new TGraph(211);
   graph->SetName("Graph");
   graph->SetTitle("Graph");
   graph->SetLineColor(kGreen+1);
   graph->SetLineWidth(3);
   graph->SetMarkerStyle(20);
   graph->SetPoint(0,88.01999664,7.234320164);
   graph->SetPoint(1,88.05999756,7.121326923);
   graph->SetPoint(2,88.09999847,7.008939743);
   graph->SetPoint(3,88.13999939,6.897168636);
   graph->SetPoint(4,88.18000031,6.786022186);
   graph->SetPoint(5,88.22000122,6.67550993);
   graph->SetPoint(6,88.26000214,6.565642357);
   graph->SetPoint(7,88.30000305,6.456428051);
   graph->SetPoint(8,88.33999634,6.347877979);
   graph->SetPoint(9,88.37999725,6.240002632);
   graph->SetPoint(10,88.41999817,6.1328125);
   graph->SetPoint(11,88.45999908,6.026317596);
   graph->SetPoint(12,88.5,5.920529366);
   graph->SetPoint(13,88.54000092,5.815458775);
   graph->SetPoint(14,88.58000183,5.711116314);
   graph->SetPoint(15,88.62000275,5.607512951);
   graph->SetPoint(16,88.66000366,5.504659653);
   graph->SetPoint(17,88.69999695,5.402567387);
   graph->SetPoint(18,88.73999786,5.301246643);
   graph->SetPoint(19,88.77999878,5.200707436);
   graph->SetPoint(20,88.81999969,5.100960732);
   graph->SetPoint(21,88.81999969,5.100960732);
   graph->SetPoint(22,88.86000061,5.002016068);
   graph->SetPoint(23,88.90000153,4.903883457);
   graph->SetPoint(24,88.94000244,4.806572437);
   graph->SetPoint(25,88.98000336,4.710093021);
   graph->SetPoint(26,89.01999664,4.614454269);
   graph->SetPoint(27,89.05999756,4.519664764);
   graph->SetPoint(28,89.09999847,4.425733089);
   graph->SetPoint(29,89.13999939,4.332668304);
   graph->SetPoint(30,89.18000031,4.240478516);
   graph->SetPoint(31,89.22000122,4.149171829);
   graph->SetPoint(32,89.26000214,4.058755875);
   graph->SetPoint(33,89.30000305,3.969237804);
   graph->SetPoint(34,89.33999634,3.880625486);
   graph->SetPoint(35,89.37999725,3.792925596);
   graph->SetPoint(36,89.41999817,3.706145048);
   graph->SetPoint(37,89.45999908,3.620290518);
   graph->SetPoint(38,89.5,3.535368204);
   graph->SetPoint(39,89.54000092,3.451384068);
   graph->SetPoint(40,89.58000183,3.368344069);
   graph->SetPoint(41,89.62000275,3.286253691);
   graph->SetPoint(42,89.62000275,3.286253691);
   graph->SetPoint(43,89.66000366,3.205118656);
   graph->SetPoint(44,89.69999695,3.124943733);
   graph->SetPoint(45,89.73999786,3.045734167);
   graph->SetPoint(46,89.77999878,2.967494488);
   graph->SetPoint(47,89.81999969,2.890229225);
   graph->SetPoint(48,89.86000061,2.813942432);
   graph->SetPoint(49,89.90000153,2.738638639);
   graph->SetPoint(50,89.94000244,2.664321423);
   graph->SetPoint(51,89.98000336,2.590994596);
   graph->SetPoint(52,90.01999664,2.518661499);
   graph->SetPoint(53,90.05999756,2.447325468);
   graph->SetPoint(54,90.09999847,2.376989603);
   graph->SetPoint(55,90.13999939,2.307657003);
   graph->SetPoint(56,90.18000031,2.23933053);
   graph->SetPoint(57,90.22000122,2.172012329);
   graph->SetPoint(58,90.26000214,2.105705023);
   graph->SetPoint(59,90.30000305,2.040410995);
   graph->SetPoint(60,90.33999634,1.976132512);
   graph->SetPoint(61,90.37999725,1.912871242);
   graph->SetPoint(62,90.41999817,1.85062921);
   graph->SetPoint(63,90.41999817,1.85062921);
   graph->SetPoint(64,90.45999908,1.789408088);
   graph->SetPoint(65,90.5,1.729209423);
   graph->SetPoint(66,90.54000092,1.670034766);
   graph->SetPoint(67,90.58000183,1.611885428);
   graph->SetPoint(68,90.62000275,1.554762602);
   graph->SetPoint(69,90.66000366,1.498667479);
   graph->SetPoint(70,90.69999695,1.443601012);
   graph->SetPoint(71,90.73999786,1.389564157);
   graph->SetPoint(72,90.77999878,1.336557865);
   graph->SetPoint(73,90.81999969,1.284582734);
   graph->SetPoint(74,90.86000061,1.233639359);
   graph->SetPoint(75,90.90000153,1.183728576);
   graph->SetPoint(76,90.94000244,1.134850621);
   graph->SetPoint(77,90.98000336,1.087006092);
   graph->SetPoint(78,91.01999664,1.040195346);
   graph->SetPoint(79,91.05999756,0.9944185615);
   graph->SetPoint(80,91.09999847,0.9496760368);
   graph->SetPoint(81,91.13999939,0.9059679508);
   graph->SetPoint(82,91.18000031,0.8632944226);
   graph->SetPoint(83,91.22000122,0.8216554523);
   graph->SetPoint(84,91.22000122,0.8216554523);
   graph->SetPoint(85,91.26000214,0.7810510397);
   graph->SetPoint(86,91.30000305,0.7414811254);
   graph->SetPoint(87,91.33999634,0.70294559);
   graph->SetPoint(88,91.37999725,0.6654443145);
   graph->SetPoint(89,91.41999817,0.6289771199);
   graph->SetPoint(90,91.45999908,0.5935436487);
   graph->SetPoint(91,91.5,0.5591436625);
   graph->SetPoint(92,91.54000092,0.5257768631);
   graph->SetPoint(93,91.58000183,0.4934427738);
   graph->SetPoint(94,91.62000275,0.462141037);
   graph->SetPoint(95,91.66000366,0.431871146);
   graph->SetPoint(96,91.69999695,0.4026326835);
   graph->SetPoint(97,91.73999786,0.3744250238);
   graph->SetPoint(98,91.77999878,0.3472476304);
   graph->SetPoint(99,91.81999969,0.3210999072);
   graph->SetPoint(100,91.86000061,0.2959812582);
   graph->SetPoint(101,91.90000153,0.2718909979);
   graph->SetPoint(102,91.94000244,0.2488284409);
   graph->SetPoint(103,91.98000336,0.2267929316);
   graph->SetPoint(104,92.01999664,0.2057837248);
   graph->SetPoint(105,92.01999664,0.2057837248);
   graph->SetPoint(106,92.05999756,0.1858001053);
   graph->SetPoint(107,92.09999847,0.1668412983);
   graph->SetPoint(108,92.13999939,0.1489065737);
   graph->SetPoint(109,92.18000031,0.1319951713);
   graph->SetPoint(110,92.22000122,0.1161063388);
   graph->SetPoint(111,92.26000214,0.1012392938);
   graph->SetPoint(112,92.30000305,0.08739329875);
   graph->SetPoint(113,92.33999634,0.07456759363);
   graph->SetPoint(114,92.37999725,0.06276145577);
   graph->SetPoint(115,92.41999817,0.05197418481);
   graph->SetPoint(116,92.45999908,0.04220509902);
   graph->SetPoint(117,92.5,0.03345353901);
   graph->SetPoint(118,92.54000092,0.02571888082);
   graph->SetPoint(119,92.58000183,0.01900054142);
   graph->SetPoint(120,92.62000275,0.01329800207);
   graph->SetPoint(121,92.66000366,0.008610763587);
   graph->SetPoint(122,92.69999695,0.004938419908);
   graph->SetPoint(123,92.73999786,0.002280603396);
   graph->SetPoint(124,92.77999878,0.0006370125338);
   graph->SetPoint(125,92.81999969,7.419047051e-06);
   //graph->SetPoint(126,92.81999969,7.419047961e-06);
   graph->SetPoint(127,92.82485199,0);
   graph->SetPoint(128,92.82485199,0);
   graph->SetPoint(129,92.82485199,0);
   graph->SetPoint(130,92.82485199,0);
   graph->SetPoint(131,92.82485199,0);
   graph->SetPoint(132,92.82485199,0);
   graph->SetPoint(133,92.82485199,0);
   graph->SetPoint(134,93.05999756,0.01752127893);
   graph->SetPoint(135,93.09999847,0.02399016172);
   graph->SetPoint(136,93.13999939,0.0314742066);
   graph->SetPoint(137,93.18000031,0.03997394815);
   graph->SetPoint(138,93.22000122,0.04949002713);
   graph->SetPoint(139,93.26000214,0.06002314016);
   graph->SetPoint(140,93.30000305,0.07157406956);
   graph->SetPoint(141,93.33999634,0.08414366841);
   graph->SetPoint(142,93.37999725,0.09773286432);
   graph->SetPoint(143,93.41999817,0.1123426482);
   graph->SetPoint(144,93.45999908,0.1279740632);
   graph->SetPoint(145,93.5,0.144628197);
   graph->SetPoint(146,93.54000092,0.1623062044);
   graph->SetPoint(147,93.58000183,0.1810092628);
   graph->SetPoint(148,93.62000275,0.200738579);
   graph->SetPoint(149,93.62000275,0.200738579);
   graph->SetPoint(150,93.66000366,0.2214953899);
   graph->SetPoint(151,93.69999695,0.2432809174);
   graph->SetPoint(152,93.73999786,0.2660964429);
   graph->SetPoint(153,93.77999878,0.2899431586);
   graph->SetPoint(154,93.81999969,0.3148224056);
   graph->SetPoint(155,93.86000061,0.3407353461);
   graph->SetPoint(156,93.90000153,0.367683202);
   graph->SetPoint(157,93.94000244,0.3956672251);
   graph->SetPoint(158,93.98000336,0.4246885478);
   graph->SetPoint(159,94.01999664,0.4547482729);
   graph->SetPoint(160,94.05999756,0.4858476222);
   graph->SetPoint(161,94.09999847,0.5179876089);
   graph->SetPoint(162,94.13999939,0.5511692166);
   graph->SetPoint(163,94.18000031,0.585393548);
   graph->SetPoint(164,94.22000122,0.6206615567);
   graph->SetPoint(165,94.26000214,0.6569740772);
   graph->SetPoint(166,94.30000305,0.6943320632);
   graph->SetPoint(167,94.33999634,0.7327364087);
   graph->SetPoint(168,94.37999725,0.772187829);
   graph->SetPoint(169,94.41999817,0.8126871586);
   graph->SetPoint(170,94.41999817,0.8126871586);
   graph->SetPoint(171,94.45999908,0.8542351723);
   graph->SetPoint(172,94.5,0.8968324661);
   graph->SetPoint(173,94.54000092,0.940479815);
   graph->SetPoint(174,94.58000183,0.985177815);
   graph->SetPoint(175,94.62000275,1.030927062);
   graph->SetPoint(176,94.66000366,1.077728152);
   graph->SetPoint(177,94.69999695,1.125581622);
   graph->SetPoint(178,94.73999786,1.174487948);
   graph->SetPoint(179,94.77999878,1.224447489);
   graph->SetPoint(180,94.81999969,1.27546072);
   graph->SetPoint(181,94.86000061,1.327528);
   graph->SetPoint(182,94.90000153,1.380649686);
   graph->SetPoint(183,94.94000244,1.434825897);
   graph->SetPoint(184,94.98000336,1.490056992);
   graph->SetPoint(185,95.01999664,1.546342969);
   graph->SetPoint(186,95.05999756,1.603683949);
   graph->SetPoint(187,95.09999847,1.66207993);
   graph->SetPoint(188,95.13999939,1.721530676);
   graph->SetPoint(189,95.18000031,1.782036185);
   graph->SetPoint(190,95.22000122,1.843595982);
   graph->SetPoint(191,95.22000122,1.843595982);
   graph->SetPoint(192,95.26000214,1.906209826);
   graph->SetPoint(193,95.30000305,1.969877124);
   graph->SetPoint(194,95.33999634,2.034597158);
   graph->SetPoint(195,95.37999725,2.100369453);
   graph->SetPoint(196,95.41999817,2.167192936);
   graph->SetPoint(197,95.45999908,2.235066652);
   graph->SetPoint(198,95.5,2.30398941);
   graph->SetPoint(199,95.54000092,2.37395978);
   graph->SetPoint(200,95.58000183,2.44497633);
   graph->SetPoint(201,95.62000275,2.517037392);
   graph->SetPoint(202,95.66000366,2.590141296);
   graph->SetPoint(203,95.69999695,2.66428566);
   graph->SetPoint(204,95.73999786,2.739468575);
   graph->SetPoint(205,95.77999878,2.815687418);
   graph->SetPoint(206,95.81999969,2.892939568);
   graph->SetPoint(207,95.86000061,2.971222401);
   graph->SetPoint(208,95.90000153,3.050532341);
   graph->SetPoint(209,95.94000244,3.130866289);
   graph->SetPoint(210,95.98000336,3.212220907);


   graph->Sort();

   cout << "4e: " << graph->Eval(91.1876) << endl;


   //2e2mu
   TGraph *graph1 = new TGraph(211);
   graph1->SetName("Graph1");
   graph1->SetTitle("Graph1");
   graph1->SetFillColor(1);
   graph1->SetLineWidth(3);
   graph1->SetLineColor(kBlue);
   graph1->SetMarkerStyle(20);
   graph1->SetPoint(0,88.01999664,8.795412064);
   graph1->SetPoint(1,88.05999756,8.61370182);
   graph1->SetPoint(2,88.09999847,8.43285656);
   graph1->SetPoint(3,88.13999939,8.252916336);
   graph1->SetPoint(4,88.18000031,8.073918343);
   graph1->SetPoint(5,88.22000122,7.895903111);
   graph1->SetPoint(6,88.26000214,7.718908787);
   graph1->SetPoint(7,88.30000305,7.542974472);
   graph1->SetPoint(8,88.33999634,7.36813879);
   graph1->SetPoint(9,88.37999725,7.194441795);
   graph1->SetPoint(10,88.41999817,7.021921158);
   graph1->SetPoint(11,88.45999908,6.850616932);
   graph1->SetPoint(12,88.5,6.680567265);
   graph1->SetPoint(13,88.54000092,6.51181221);
   graph1->SetPoint(14,88.58000183,6.344389915);
   graph1->SetPoint(15,88.62000275,6.178339481);
   graph1->SetPoint(16,88.66000366,6.013700008);
   graph1->SetPoint(17,88.69999695,5.850510597);
   graph1->SetPoint(18,88.73999786,5.688809872);
   graph1->SetPoint(19,88.77999878,5.528635979);
   graph1->SetPoint(20,88.81999969,5.370028496);
   graph1->SetPoint(21,88.81999969,5.370028496);
   graph1->SetPoint(22,88.86000061,5.21302557);
   graph1->SetPoint(23,88.90000153,5.057665825);
   graph1->SetPoint(24,88.94000244,4.903987885);
   graph1->SetPoint(25,88.98000336,4.752028942);
   graph1->SetPoint(26,89.01999664,4.601828575);
   graph1->SetPoint(27,89.05999756,4.4534235);
   graph1->SetPoint(28,89.09999847,4.306852341);
   graph1->SetPoint(29,89.13999939,4.162151814);
   graph1->SetPoint(30,89.18000031,4.019360065);
   graph1->SetPoint(31,89.22000122,3.87851429);
   graph1->SetPoint(32,89.26000214,3.739651203);
   graph1->SetPoint(33,89.30000305,3.602807283);
   graph1->SetPoint(34,89.33999634,3.468019247);
   graph1->SetPoint(35,89.37999725,3.335323095);
   graph1->SetPoint(36,89.41999817,3.204754591);
   graph1->SetPoint(37,89.45999908,3.076349258);
   graph1->SetPoint(38,89.5,2.950142145);
   graph1->SetPoint(39,89.54000092,2.82616806);
   graph1->SetPoint(40,89.58000183,2.704461336);
   graph1->SetPoint(41,89.62000275,2.58505559);
   graph1->SetPoint(42,89.62000275,2.58505559);
   graph1->SetPoint(43,89.66000366,2.467984438);
   graph1->SetPoint(44,89.69999695,2.353280783);
   graph1->SetPoint(45,89.73999786,2.240977049);
   graph1->SetPoint(46,89.77999878,2.131105185);
   graph1->SetPoint(47,89.81999969,2.023696423);
   graph1->SetPoint(48,89.86000061,1.918781519);
   graph1->SetPoint(49,89.90000153,1.816390634);
   graph1->SetPoint(50,89.94000244,1.716553092);
   graph1->SetPoint(51,89.98000336,1.619297981);
   graph1->SetPoint(52,90.01999664,1.524653077);
   graph1->SetPoint(53,90.05999756,1.432646155);
   graph1->SetPoint(54,90.09999847,1.343303561);
   graph1->SetPoint(55,90.13999939,1.256651402);
   graph1->SetPoint(56,90.18000031,1.17271471);
   graph1->SetPoint(57,90.22000122,1.091517925);
   graph1->SetPoint(58,90.26000214,1.013084531);
   graph1->SetPoint(59,90.30000305,0.9374370575);
   graph1->SetPoint(60,90.33999634,0.864597559);
   graph1->SetPoint(61,90.37999725,0.7945868969);
   graph1->SetPoint(62,90.41999817,0.727425158);
   graph1->SetPoint(63,90.41999817,0.727425158);
   graph1->SetPoint(64,90.45999908,0.6631317139);
   graph1->SetPoint(65,90.5,0.6017247438);
   graph1->SetPoint(66,90.54000092,0.5432218313);
   graph1->SetPoint(67,90.58000183,0.4876395166);
   graph1->SetPoint(68,90.62000275,0.4349934459);
   graph1->SetPoint(69,90.66000366,0.3852983713);
   graph1->SetPoint(70,90.69999695,0.3385681808);
   graph1->SetPoint(71,90.73999786,0.2948157787);
   graph1->SetPoint(72,90.77999878,0.2540532351);
   graph1->SetPoint(73,90.81999969,0.2162916809);
   graph1->SetPoint(74,90.86000061,0.1815413088);
   graph1->SetPoint(75,90.90000153,0.1498114169);
   graph1->SetPoint(76,90.94000244,0.1211103573);
   graph1->SetPoint(77,90.98000336,0.09544557333);
   graph1->SetPoint(78,91.01999664,0.07282357663);
   graph1->SetPoint(79,91.05999756,0.05324992537);
   graph1->SetPoint(80,91.09999847,0.0367292501);
   graph1->SetPoint(81,91.13999939,0.02326522022);
   graph1->SetPoint(82,91.18000031,0.01286056917);
   graph1->SetPoint(83,91.22000122,0.005517064128);
   graph1->SetPoint(84,91.22000122,0.005517064128);
   graph1->SetPoint(85,91.26000214,0.001235519536);
   graph1->SetPoint(86,91.29593658,0);
   graph1->SetPoint(87,91.29593658,0);
   graph1->SetPoint(88,91.29593658,0);
   graph1->SetPoint(89,91.29593658,0);
   graph1->SetPoint(90,91.29593658,0);
   graph1->SetPoint(91,91.29593658,0);
   graph1->SetPoint(92,91.29593658,0);
   graph1->SetPoint(93,91.5,0.03977194428);
   graph1->SetPoint(94,91.54000092,0.05686627701);
   graph1->SetPoint(95,91.58000183,0.07699460536);
   graph1->SetPoint(96,91.62000275,0.1001491994);
   graph1->SetPoint(97,91.66000366,0.1263214052);
   graph1->SetPoint(98,91.69999695,0.1555016339);
   graph1->SetPoint(99,91.73999786,0.1876795292);
   graph1->SetPoint(100,91.77999878,0.2228437364);
   graph1->SetPoint(101,91.81999969,0.260982126);
   graph1->SetPoint(102,91.86000061,0.3020817041);
   graph1->SetPoint(103,91.90000153,0.3461286724);
   graph1->SetPoint(104,91.94000244,0.3931084573);
   graph1->SetPoint(105,91.98000336,0.443005681);
   graph1->SetPoint(106,92.01999664,0.4958042502);
   //graph1->SetPoint(107,92.01999664,0.4958042204);
   graph1->SetPoint(108,92.05999756,0.551487267);
   graph1->SetPoint(109,92.09999847,0.6100373268);
   graph1->SetPoint(110,92.13999939,0.671436131);
   graph1->SetPoint(111,92.18000031,0.7356648445);
   graph1->SetPoint(112,92.22000122,0.802703917);
   graph1->SetPoint(113,92.26000214,0.872533381);
   graph1->SetPoint(114,92.30000305,0.945132494);
   graph1->SetPoint(115,92.33999634,1.020480037);
   graph1->SetPoint(116,92.37999725,1.098554254);
   graph1->SetPoint(117,92.41999817,1.179333091);
   graph1->SetPoint(118,92.45999908,1.262793779);
   graph1->SetPoint(119,92.5,1.348913193);
   graph1->SetPoint(120,92.54000092,1.437667727);
   graph1->SetPoint(121,92.58000183,1.52903378);
   graph1->SetPoint(122,92.62000275,1.622986913);
   graph1->SetPoint(123,92.66000366,1.719502687);
   graph1->SetPoint(124,92.69999695,1.818556309);
   graph1->SetPoint(125,92.73999786,1.920122623);
   graph1->SetPoint(126,92.77999878,2.024176359);
   graph1->SetPoint(127,92.81999969,2.130692005);
   graph1->SetPoint(128,92.81999969,2.130692005);
   graph1->SetPoint(129,92.86000061,2.239643812);
   graph1->SetPoint(130,92.90000153,2.351006031);
   graph1->SetPoint(131,92.94000244,2.464752674);
   graph1->SetPoint(132,92.98000336,2.580857754);
   graph1->SetPoint(133,93.01999664,2.699294806);
   graph1->SetPoint(134,93.05999756,2.820037603);
   graph1->SetPoint(135,93.09999847,2.94306016);
   graph1->SetPoint(136,93.13999939,3.068335533);
   graph1->SetPoint(137,93.18000031,3.195837736);
   graph1->SetPoint(138,93.22000122,3.325540066);
   graph1->SetPoint(139,93.26000214,3.457416296);
   graph1->SetPoint(140,93.30000305,3.591439486);
   graph1->SetPoint(141,93.33999634,3.727583647);
   graph1->SetPoint(142,93.37999725,3.865821838);
   graph1->SetPoint(143,93.41999817,4.006127834);
   graph1->SetPoint(144,93.45999908,4.148474216);
   graph1->SetPoint(145,93.5,4.292835712);
   graph1->SetPoint(146,93.54000092,4.439184189);
   graph1->SetPoint(147,93.58000183,4.587494373);
   graph1->SetPoint(148,93.62000275,4.737738609);
   graph1->SetPoint(149,93.62000275,4.737738609);
   graph1->SetPoint(150,93.66000366,4.889890194);
   graph1->SetPoint(151,93.69999695,5.043922424);
   graph1->SetPoint(152,93.73999786,5.199808598);
   graph1->SetPoint(153,93.77999878,5.357521057);
   graph1->SetPoint(154,93.81999969,5.517033577);
   graph1->SetPoint(155,93.86000061,5.678318024);
   graph1->SetPoint(156,93.90000153,5.841347694);
   graph1->SetPoint(157,93.94000244,6.006094933);
   graph1->SetPoint(158,93.98000336,6.172532082);
   graph1->SetPoint(159,94.01999664,6.340631485);
   graph1->SetPoint(160,94.05999756,6.510365486);
   graph1->SetPoint(161,94.09999847,6.681705952);
   graph1->SetPoint(162,94.13999939,6.854624748);
   graph1->SetPoint(163,94.18000031,7.029093266);
   graph1->SetPoint(164,94.22000122,7.205083847);
   graph1->SetPoint(165,94.26000214,7.382567883);
   graph1->SetPoint(166,94.30000305,7.561516285);
   graph1->SetPoint(167,94.33999634,7.741900921);
   graph1->SetPoint(168,94.37999725,7.923692226);
   graph1->SetPoint(169,94.41999817,8.106862068);
   graph1->SetPoint(170,94.41999817,8.106862068);
   graph1->SetPoint(171,94.45999908,8.291379929);
   graph1->SetPoint(172,94.5,8.477218628);
   graph1->SetPoint(173,94.54000092,8.664347649);
   graph1->SetPoint(174,94.58000183,8.85273838);
   graph1->SetPoint(175,94.62000275,9.042361259);
   graph1->SetPoint(176,94.66000366,9.233187675);
   graph1->SetPoint(177,94.69999695,9.425187111);
   graph1->SetPoint(178,94.73999786,9.618330002);
   graph1->SetPoint(179,94.77999878,9.812587738);
   graph1->SetPoint(180,94.81999969,10.00793171);
   graph1->SetPoint(181,94.86000061,10.20433044);
   graph1->SetPoint(182,94.90000153,10.40175724);
   graph1->SetPoint(183,94.94000244,10.60017967);
   graph1->SetPoint(184,94.98000336,10.79957104);
   graph1->SetPoint(185,95.01999664,10.99990082);
   graph1->SetPoint(186,95.05999756,11.20113945);
   graph1->SetPoint(187,95.09999847,11.40325832);
   graph1->SetPoint(188,95.13999939,11.60622883);
   graph1->SetPoint(189,95.18000031,11.81002045);
   graph1->SetPoint(190,95.22000122,12.01460457);
   graph1->SetPoint(191,95.22000122,12.01460457);
   graph1->SetPoint(192,95.26000214,12.21995258);
   graph1->SetPoint(193,95.30000305,12.42603588);
   graph1->SetPoint(194,95.33999634,12.63282394);
   graph1->SetPoint(195,95.37999725,12.84028816);
   graph1->SetPoint(196,95.41999817,13.04840088);
   graph1->SetPoint(197,95.45999908,13.25713253);
   graph1->SetPoint(198,95.5,13.46645451);
   graph1->SetPoint(199,95.54000092,13.6763382);
   graph1->SetPoint(200,95.58000183,13.88675499);
   graph1->SetPoint(201,95.62000275,14.09767723);
   graph1->SetPoint(202,95.66000366,14.3090744);
   graph1->SetPoint(203,95.69999695,14.5209198);
   graph1->SetPoint(204,95.73999786,14.73318481);
   graph1->SetPoint(205,95.77999878,14.94584179);
   graph1->SetPoint(206,95.81999969,15.15886116);
   graph1->SetPoint(207,95.86000061,15.37221718);
   graph1->SetPoint(208,95.90000153,15.58588123);
   graph1->SetPoint(209,95.94000244,15.79982567);
   graph1->SetPoint(210,95.98000336,16.01402283);

   
   graph1->Sort();
   
   cout<< "2e2mu: " << graph1->Eval(91.1876) << endl;


   //4mu
   TGraph *graph2 = new TGraph(216);
   graph2->SetName("Graph2");
   graph2->SetTitle("Graph2");
   graph2->SetFillColor(1);
   graph2->SetLineWidth(3);
   graph2->SetLineColor(kRed);
   graph2->SetMarkerStyle(20);
   graph2->SetPoint(0,88.01999664,42.99673462);
   graph2->SetPoint(1,88.05999756,42.01807404);
   graph2->SetPoint(2,88.09999847,41.04578781);
   graph2->SetPoint(3,88.13999939,40.08004379);
   graph2->SetPoint(4,88.18000031,39.12101746);
   graph2->SetPoint(5,88.22000122,38.16888046);
   graph2->SetPoint(6,88.26000214,37.22380447);
   graph2->SetPoint(7,88.30000305,36.2859726);
   graph2->SetPoint(8,88.33999634,35.35555267);
   graph2->SetPoint(9,88.37999725,34.43272781);
   graph2->SetPoint(10,88.41999817,33.51767731);
   graph2->SetPoint(11,88.45999908,32.61057281);
   graph2->SetPoint(12,88.5,31.71160507);
   graph2->SetPoint(13,88.54000092,30.82094765);
   graph2->SetPoint(14,88.58000183,29.93878746);
   graph2->SetPoint(15,88.62000275,29.06530762);
   graph2->SetPoint(16,88.66000366,28.20069313);
   graph2->SetPoint(17,88.69999695,27.34512901);
   graph2->SetPoint(18,88.73999786,26.49880409);
   graph2->SetPoint(19,88.77999878,25.66190529);
   graph2->SetPoint(20,88.81999969,24.83462334);
   graph2->SetPoint(21,88.81999969,24.83462334);
   graph2->SetPoint(22,88.86000061,24.01715088);
   graph2->SetPoint(23,88.90000153,23.20967865);
   graph2->SetPoint(24,88.94000244,22.41239929);
   graph2->SetPoint(25,88.98000336,21.62551308);
   graph2->SetPoint(26,89.01999664,20.84921074);
   graph2->SetPoint(27,89.05999756,20.08369446);
   graph2->SetPoint(28,89.09999847,19.32916451);
   graph2->SetPoint(29,89.13999939,18.58581734);
   graph2->SetPoint(30,89.18000031,17.85385895);
   graph2->SetPoint(31,89.22000122,17.13349152);
   graph2->SetPoint(32,89.26000214,16.42491913);
   graph2->SetPoint(33,89.30000305,15.72835064);
   graph2->SetPoint(34,89.33999634,15.04399014);
   graph2->SetPoint(35,89.37999725,14.37204742);
   graph2->SetPoint(36,89.41999817,13.71273041);
   graph2->SetPoint(37,89.45999908,13.0662508);
   graph2->SetPoint(38,89.5,12.43281651);
   graph2->SetPoint(39,89.54000092,11.81264019);
   graph2->SetPoint(40,89.58000183,11.20593262);
   graph2->SetPoint(41,89.62000275,10.6129055);
   graph2->SetPoint(42,89.62000275,10.6129055);
   graph2->SetPoint(43,89.66000366,10.03376961);
   graph2->SetPoint(44,89.69999695,9.468736649);
   graph2->SetPoint(45,89.73999786,8.918016434);
   graph2->SetPoint(46,89.77999878,8.381820679);
   graph2->SetPoint(47,89.81999969,7.860357285);
   graph2->SetPoint(48,89.86000061,7.353835583);
   graph2->SetPoint(49,89.90000153,6.862462997);
   graph2->SetPoint(50,89.94000244,6.386445045);
   graph2->SetPoint(51,89.98000336,5.92598629);
   graph2->SetPoint(52,90.01999664,5.481288433);
   graph2->SetPoint(53,90.05999756,5.0525527);
   graph2->SetPoint(54,90.09999847,4.639976501);
   graph2->SetPoint(55,90.13999939,4.243755817);
   graph2->SetPoint(56,90.18000031,3.864083052);
   graph2->SetPoint(57,90.22000122,3.501147509);
   graph2->SetPoint(58,90.26000214,3.155135393);
   graph2->SetPoint(59,90.30000305,2.826228619);
   graph2->SetPoint(60,90.33999634,2.514605522);
   graph2->SetPoint(61,90.37999725,2.220438957);
   graph2->SetPoint(62,90.41999817,1.943897605);
   graph2->SetPoint(63,90.41999817,1.943897605);
   graph2->SetPoint(64,90.45999908,1.685144305);
   graph2->SetPoint(65,90.5,1.444335938);
   graph2->SetPoint(66,90.54000092,1.221622825);
   graph2->SetPoint(67,90.58000183,1.017148852);
   graph2->SetPoint(68,90.62000275,0.8310500383);
   graph2->SetPoint(69,90.66000366,0.663454473);
   graph2->SetPoint(70,90.69999695,0.5144816637);
   graph2->SetPoint(71,90.73999786,0.3842421472);
   graph2->SetPoint(72,90.77999878,0.2728365958);
   graph2->SetPoint(73,90.81999969,0.1803556085);
   graph2->SetPoint(74,90.86000061,0.1068789586);
   graph2->SetPoint(75,90.90000153,0.05247514695);
   graph2->SetPoint(76,90.94000244,0.01720083691);
   graph2->SetPoint(77,90.98000336,0.00110038009);
   graph2->SetPoint(78,90.9935379,0);
   graph2->SetPoint(79,90.9935379,0);
   graph2->SetPoint(80,90.9935379,0);
   graph2->SetPoint(81,90.9935379,0);
   graph2->SetPoint(82,90.9935379,0);
   graph2->SetPoint(83,90.9935379,0);
   graph2->SetPoint(84,90.9935379,0);
   graph2->SetPoint(85,91.01999664,0.004205350298);
   graph2->SetPoint(86,91.05999756,0.02653408609);
   graph2->SetPoint(87,91.09999847,0.06809128821);
   graph2->SetPoint(88,91.13999939,0.1288676411);
   graph2->SetPoint(89,91.18000031,0.208839491);
   graph2->SetPoint(90,91.22000122,0.3079685569);
   graph2->SetPoint(91,91.22000122,0.3079685569);
   graph2->SetPoint(92,91.26000214,0.4262017608);
   graph2->SetPoint(93,91.30000305,0.5634709001);
   graph2->SetPoint(94,91.33999634,0.7196927667);
   graph2->SetPoint(95,91.37999725,0.8947688341);
   graph2->SetPoint(96,91.41999817,1.088585615);
   graph2->SetPoint(97,91.45999908,1.301014304);
   graph2->SetPoint(98,91.5,1.531911612);
   graph2->SetPoint(99,91.54000092,1.781119347);
   graph2->SetPoint(100,91.58000183,2.048465252);
   graph2->SetPoint(101,91.62000275,2.333762884);
   graph2->SetPoint(102,91.66000366,2.636813402);
   graph2->SetPoint(103,91.69999695,2.957404137);
   graph2->SetPoint(104,91.73999786,3.295311213);
   graph2->SetPoint(105,91.77999878,3.650299788);
   graph2->SetPoint(106,91.81999969,4.022123814);
   graph2->SetPoint(107,91.86000061,4.410528183);
   graph2->SetPoint(108,91.90000153,4.815249443);
   graph2->SetPoint(109,91.94000244,5.23601675);
   graph2->SetPoint(110,91.98000336,5.672553062);
   graph2->SetPoint(111,92.01999664,6.124575138);
   graph2->SetPoint(112,92.01999664,6.124575138);
   graph2->SetPoint(113,92.05999756,6.591795921);
   graph2->SetPoint(114,92.09999847,7.073926449);
   graph2->SetPoint(115,92.13999939,7.570672989);
   graph2->SetPoint(116,92.18000031,8.08174324);
   graph2->SetPoint(117,92.22000122,8.606842995);
   graph2->SetPoint(118,92.26000214,9.145680428);
   graph2->SetPoint(119,92.30000305,9.697964668);
   graph2->SetPoint(120,92.33999634,10.26340675);
   graph2->SetPoint(121,92.37999725,10.84172058);
   graph2->SetPoint(122,92.41999817,11.43262482);
   graph2->SetPoint(123,92.45999908,12.03584099);
   graph2->SetPoint(124,92.5,12.65109539);
   graph2->SetPoint(125,92.54000092,13.27812099);
   graph2->SetPoint(126,92.58000183,13.91665268);
   graph2->SetPoint(127,92.62000275,14.56643105);
   graph2->SetPoint(128,92.66000366,15.22720337);
   graph2->SetPoint(129,92.69999695,15.89872169);
   graph2->SetPoint(130,92.73999786,16.58073997);
   graph2->SetPoint(131,92.77999878,17.2730217);
   graph2->SetPoint(132,92.81999969,17.97533035);
   graph2->SetPoint(133,92.81999969,17.97533035);
   graph2->SetPoint(134,92.86000061,18.68743896);
   graph2->SetPoint(135,92.90000153,19.40911865);
   graph2->SetPoint(136,92.94000244,20.14015007);
   graph2->SetPoint(137,92.98000336,20.88031387);
   graph2->SetPoint(138,93.01999664,21.62939453);
   graph2->SetPoint(139,93.05999756,22.38718414);
   graph2->SetPoint(140,93.09999847,23.15346909);
   graph2->SetPoint(141,93.13999939,23.92804527);
   graph2->SetPoint(142,93.18000031,24.71071243);
   graph2->SetPoint(143,93.22000122,25.50126266);
   graph2->SetPoint(144,93.26000214,26.29950333);
   graph2->SetPoint(145,93.30000305,27.10523224);
   graph2->SetPoint(146,93.33999634,27.91825485);
   graph2->SetPoint(147,93.37999725,28.73837852);
   graph2->SetPoint(148,93.41999817,29.56540871);
   graph2->SetPoint(149,93.45999908,30.39915657);
   graph2->SetPoint(150,93.5,31.23942947);
   graph2->SetPoint(151,93.54000092,32.0860405);
   graph2->SetPoint(152,93.58000183,32.93880081);
   graph2->SetPoint(153,93.62000275,33.79752731);
   graph2->SetPoint(154,93.62000275,33.79752731);
   graph2->SetPoint(155,93.66000366,34.66203308);
   graph2->SetPoint(156,93.69999695,35.53213501);
   graph2->SetPoint(157,93.73999786,36.40764999);
   graph2->SetPoint(158,93.77999878,37.28839874);
   graph2->SetPoint(159,93.81999969,38.17420197);
   graph2->SetPoint(160,93.86000061,39.06488037);
   graph2->SetPoint(161,93.90000153,39.96025848);
   graph2->SetPoint(162,93.94000244,40.86016464);
   graph2->SetPoint(163,93.98000336,41.76441956);
   graph2->SetPoint(164,94.01999664,42.67286301);
   graph2->SetPoint(165,94.05999756,43.5853157);
   graph2->SetPoint(166,94.09999847,44.50161362);
   graph2->SetPoint(167,94.13999939,45.42160034);
   graph2->SetPoint(168,94.18000031,46.34510422);
   graph2->SetPoint(169,94.22000122,47.27197266);
   graph2->SetPoint(170,94.26000214,48.20204544);
   graph2->SetPoint(171,94.30000305,49.13516998);
   graph2->SetPoint(172,94.33999634,50.07119751);
   graph2->SetPoint(173,94.37999725,51.00997925);
   graph2->SetPoint(174,94.41999817,51.95137024);
   graph2->SetPoint(175,94.41999817,51.95137024);
   graph2->SetPoint(176,94.45999908,52.89523315);
   graph2->SetPoint(177,94.5,53.84142303);
   graph2->SetPoint(178,94.54000092,54.789814);
   graph2->SetPoint(179,94.58000183,55.74026871);
   graph2->SetPoint(180,94.62000275,56.69266129);
   graph2->SetPoint(181,94.66000366,57.64687347);
   graph2->SetPoint(182,94.69999695,58.60277939);
   graph2->SetPoint(183,94.73999786,59.5602684);
   graph2->SetPoint(184,94.77999878,60.51922989);
   graph2->SetPoint(185,94.81999969,61.47954941);
   graph2->SetPoint(186,94.86000061,62.44112778);
   graph2->SetPoint(187,94.90000153,63.40386581);
   graph2->SetPoint(188,94.94000244,64.36766815);
   graph2->SetPoint(189,94.98000336,65.33243561);
   graph2->SetPoint(190,95.01999664,66.29808044);
   graph2->SetPoint(191,95.05999756,67.264534);
   graph2->SetPoint(192,95.09999847,68.23168945);
   graph2->SetPoint(193,95.13999939,69.19949341);
   graph2->SetPoint(194,95.18000031,70.16786194);
   graph2->SetPoint(195,95.22000122,71.13671875);
   graph2->SetPoint(196,95.22000122,71.13671875);
   graph2->SetPoint(197,95.26000214,72.10600281);
   graph2->SetPoint(198,95.30000305,73.07565308);
   graph2->SetPoint(199,95.33999634,74.04560852);
   graph2->SetPoint(200,95.37999725,75.01580811);
   graph2->SetPoint(201,95.41999817,75.98619843);
   graph2->SetPoint(202,95.45999908,76.95672607);
   graph2->SetPoint(203,95.5,77.92734528);
   graph2->SetPoint(204,95.54000092,78.89801788);
   graph2->SetPoint(205,95.58000183,79.86868286);
   graph2->SetPoint(206,95.62000275,80.83930969);
   graph2->SetPoint(207,95.66000366,81.80986023);
   graph2->SetPoint(208,95.69999695,82.7802887);
   graph2->SetPoint(209,95.73999786,83.7505722);
   graph2->SetPoint(210,95.77999878,84.72067261);
   graph2->SetPoint(211,95.81999969,85.69055176);
   graph2->SetPoint(212,95.86000061,86.6601944);
   graph2->SetPoint(213,95.90000153,87.62956238);
   graph2->SetPoint(214,95.94000244,88.59862518);
   graph2->SetPoint(215,95.98000336,89.56736755);



   cout<< "4mu: " << graph2->Eval(91.1876) << endl;


   //4l
   TGraph *graph3 = new TGraph(212);
   graph3->SetName("Graph3");
   graph3->SetTitle("Graph3");
   graph3->SetFillColor(1);
   graph3->SetLineWidth(3);
   graph3->SetMarkerStyle(20);
   graph3->SetPoint(0,88.01999664,57.33911514);
   graph3->SetPoint(1,88.05999756,56.08871841);
   graph3->SetPoint(2,88.09999847,54.84604263);
   graph3->SetPoint(3,88.13999939,53.61128998);
   graph3->SetPoint(4,88.18000031,52.38465881);
   graph3->SetPoint(5,88.22000122,51.1663475);
   graph3->SetPoint(6,88.26000214,49.95656586);
   graph3->SetPoint(7,88.30000305,48.75551605);
   graph3->SetPoint(8,88.33999634,47.56340408);
   graph3->SetPoint(9,88.37999725,46.38043976);
   graph3->SetPoint(10,88.41999817,45.20683289);
   graph3->SetPoint(11,88.45999908,44.04279709);
   graph3->SetPoint(12,88.5,42.88854218);
   graph3->SetPoint(13,88.54000092,41.74428558);
   graph3->SetPoint(14,88.58000183,40.61024094);
   graph3->SetPoint(15,88.62000275,39.48662186);
   graph3->SetPoint(16,88.66000366,38.37365723);
   graph3->SetPoint(17,88.69999695,37.27156067);
   graph3->SetPoint(18,88.73999786,36.18055725);
   graph3->SetPoint(19,88.77999878,35.10086823);
   graph3->SetPoint(20,88.81999969,34.03272247);
   graph3->SetPoint(21,88.81999969,34.03272247);
   graph3->SetPoint(22,88.86000061,32.97634506);
   graph3->SetPoint(23,88.90000153,31.93196487);
   graph3->SetPoint(24,88.94000244,30.89981461);
   graph3->SetPoint(25,88.98000336,29.88012505);
   graph3->SetPoint(26,89.01999664,28.87313271);
   graph3->SetPoint(27,89.05999756,27.87907028);
   graph3->SetPoint(28,89.09999847,26.8981781);
   graph3->SetPoint(29,89.13999939,25.93069649);
   graph3->SetPoint(30,89.18000031,24.97686577);
   graph3->SetPoint(31,89.22000122,24.03692818);
   graph3->SetPoint(32,89.26000214,23.11112785);
   graph3->SetPoint(33,89.30000305,22.19971466);
   graph3->SetPoint(34,89.33999634,21.30293083);
   graph3->SetPoint(35,89.37999725,20.42103004);
   graph3->SetPoint(36,89.41999817,19.55426025);
   graph3->SetPoint(37,89.45999908,18.70287132);
   graph3->SetPoint(38,89.5,17.86711502);
   graph3->SetPoint(39,89.54000092,17.04724693);
   graph3->SetPoint(40,89.58000183,16.24351692);
   graph3->SetPoint(41,89.62000275,15.45617962);
   graph3->SetPoint(42,89.62000275,15.45617962);
   graph3->SetPoint(43,89.66000366,14.6854887);
   graph3->SetPoint(44,89.69999695,13.93169785);
   graph3->SetPoint(45,89.73999786,13.19505882);
   graph3->SetPoint(46,89.77999878,12.47582531);
   graph3->SetPoint(47,89.81999969,11.77424908);
   graph3->SetPoint(48,89.86000061,11.09057903);
   graph3->SetPoint(49,89.90000153,10.4250679);
   graph3->SetPoint(50,89.94000244,9.777960777);
   graph3->SetPoint(51,89.98000336,9.149505615);
   graph3->SetPoint(52,90.01999664,8.539945602);
   graph3->SetPoint(53,90.05999756,7.949523926);
   graph3->SetPoint(54,90.09999847,7.378479958);
   graph3->SetPoint(55,90.13999939,6.827050209);
   graph3->SetPoint(56,90.18000031,6.295467854);
   graph3->SetPoint(57,90.22000122,5.783964634);
   graph3->SetPoint(58,90.26000214,5.292765617);
   graph3->SetPoint(59,90.30000305,4.82209301);
   graph3->SetPoint(60,90.33999634,4.37216568);
   graph3->SetPoint(61,90.37999725,3.943194866);
   graph3->SetPoint(62,90.41999817,3.535388231);
   graph3->SetPoint(63,90.41999817,3.535388231);
   graph3->SetPoint(64,90.45999908,3.148947239);
   graph3->SetPoint(65,90.5,2.784065962);
   graph3->SetPoint(66,90.54000092,2.440932035);
   graph3->SetPoint(67,90.58000183,2.119725466);
   graph3->SetPoint(68,90.62000275,1.820617914);
   graph3->SetPoint(69,90.66000366,1.543772101);
   graph3->SetPoint(70,90.69999695,1.28934145);
   graph3->SetPoint(71,90.73999786,1.057468891);
   graph3->SetPoint(72,90.77999878,0.8482871056);
   graph3->SetPoint(73,90.81999969,0.6619167924);
   graph3->SetPoint(74,90.86000061,0.4984668195);
   graph3->SetPoint(75,90.90000153,0.3580331504);
   graph3->SetPoint(76,90.94000244,0.240698427);
   graph3->SetPoint(77,90.98000336,0.1465311348);
   graph3->SetPoint(78,91.01999664,0.07558509707);
   graph3->SetPoint(79,91.05999756,0.02789884619);
   graph3->SetPoint(80,91.09999847,0.003495044075);
   graph3->SetPoint(81,91.12191772,0);
   graph3->SetPoint(82,91.12191772,0);
   graph3->SetPoint(83,91.12191772,0);
   graph3->SetPoint(84,91.12191772,0);
   graph3->SetPoint(85,91.12191772,0);
   graph3->SetPoint(86,91.12191772,0);
   graph3->SetPoint(87,91.12191772,0);
   graph3->SetPoint(88,91.26000214,0.1385737211);
   graph3->SetPoint(89,91.30000305,0.230332002);
   graph3->SetPoint(90,91.33999634,0.345148921);
   graph3->SetPoint(91,91.37999725,0.4829240143);
   graph3->SetPoint(92,91.41999817,0.643538177);
   graph3->SetPoint(93,91.45999908,0.8268537521);
   graph3->SetPoint(94,91.5,1.032714605);
   graph3->SetPoint(95,91.54000092,1.260946751);
   graph3->SetPoint(96,91.58000183,1.511358023);
   graph3->SetPoint(97,91.62000275,1.783738732);
   graph3->SetPoint(98,91.66000366,2.07786274);
   graph3->SetPoint(99,91.69999695,2.39348793);
   graph3->SetPoint(100,91.73999786,2.730356455);
   graph3->SetPoint(101,91.77999878,3.088196516);
   graph3->SetPoint(102,91.81999969,3.466723442);
   graph3->SetPoint(103,91.86000061,3.865639925);
   graph3->SetPoint(104,91.90000153,4.284637928);
   graph3->SetPoint(105,91.94000244,4.723400593);
   graph3->SetPoint(106,91.98000336,5.181601524);
   graph3->SetPoint(107,92.01999664,5.658910275);
   graph3->SetPoint(108,92.01999664,5.658910275);
   graph3->SetPoint(109,92.05999756,6.154988289);
   graph3->SetPoint(110,92.09999847,6.669495583);
   graph3->SetPoint(111,92.13999939,7.202087879);
   graph3->SetPoint(112,92.18000031,7.752422333);
   graph3->SetPoint(113,92.22000122,8.32015419);
   graph3->SetPoint(114,92.26000214,8.904941559);
   graph3->SetPoint(115,92.30000305,9.506444931);
   graph3->SetPoint(116,92.33999634,10.12432957);
   graph3->SetPoint(117,92.37999725,10.75826359);
   graph3->SetPoint(118,92.41999817,11.40792084);
   graph3->SetPoint(119,92.45999908,12.07298279);
   graph3->SetPoint(120,92.5,12.75313663);
   graph3->SetPoint(121,92.54000092,13.44807529);
   graph3->SetPoint(122,92.58000183,14.15750027);
   graph3->SetPoint(123,92.62000275,14.88112068);
   graph3->SetPoint(124,92.66000366,15.61865044);
   graph3->SetPoint(125,92.69999695,16.36981392);
   graph3->SetPoint(126,92.73999786,17.13433838);
   graph3->SetPoint(127,92.77999878,17.91196251);
   graph3->SetPoint(128,92.81999969,18.70242691);
   graph3->SetPoint(129,92.81999969,18.70242691);
   graph3->SetPoint(130,92.86000061,19.50548172);
   graph3->SetPoint(131,92.90000153,20.32088089);
   graph3->SetPoint(132,92.94000244,21.14838409);
   graph3->SetPoint(133,92.98000336,21.98775864);
   graph3->SetPoint(134,93.01999664,22.83877182);
   graph3->SetPoint(135,93.05999756,23.70119667);
   graph3->SetPoint(136,93.09999847,24.57481003);
   graph3->SetPoint(137,93.13999939,25.45939636);
   graph3->SetPoint(138,93.18000031,26.35473442);
   graph3->SetPoint(139,93.22000122,27.2606163);
   graph3->SetPoint(140,93.26000214,28.17682648);
   graph3->SetPoint(141,93.30000305,29.10315895);
   graph3->SetPoint(142,93.33999634,30.03940773);
   graph3->SetPoint(143,93.37999725,30.98536491);
   graph3->SetPoint(144,93.41999817,31.94083023);
   graph3->SetPoint(145,93.45999908,32.9056015);
   graph3->SetPoint(146,93.5,33.87947845);
   graph3->SetPoint(147,93.54000092,34.86225891);
   graph3->SetPoint(148,93.58000183,35.85375214);
   graph3->SetPoint(149,93.62000275,36.85375214);
   graph3->SetPoint(150,93.62000275,36.85375214);
   graph3->SetPoint(151,93.66000366,37.86207199);
   graph3->SetPoint(152,93.69999695,38.87851334);
   graph3->SetPoint(153,93.73999786,39.90288162);
   graph3->SetPoint(154,93.77999878,40.93498611);
   graph3->SetPoint(155,93.81999969,41.97463608);
   graph3->SetPoint(156,93.86000061,43.02164078);
   graph3->SetPoint(157,93.90000153,44.07581329);
   graph3->SetPoint(158,93.94000244,45.13696671);
   graph3->SetPoint(159,93.98000336,46.20491409);
   graph3->SetPoint(160,94.01999664,47.27947617);
   graph3->SetPoint(161,94.05999756,48.360466);
   graph3->SetPoint(162,94.09999847,49.44770813);
   graph3->SetPoint(163,94.13999939,50.54101944);
   graph3->SetPoint(164,94.18000031,51.64023209);
   graph3->SetPoint(165,94.22000122,52.74516296);
   graph3->SetPoint(166,94.26000214,53.85564804);
   graph3->SetPoint(167,94.30000305,54.97151947);
   graph3->SetPoint(168,94.33999634,56.09260941);
   graph3->SetPoint(169,94.37999725,57.21875763);
   graph3->SetPoint(170,94.41999817,58.34980011);
   graph3->SetPoint(171,94.41999817,58.34980011);
   graph3->SetPoint(172,94.45999908,59.48558426);
   graph3->SetPoint(173,94.5,60.62595749);
   graph3->SetPoint(174,94.54000092,61.77076721);
   graph3->SetPoint(175,94.58000183,62.91986847);
   graph3->SetPoint(176,94.62000275,64.07312012);
   graph3->SetPoint(177,94.66000366,65.2303772);
   graph3->SetPoint(178,94.69999695,66.39151001);
   graph3->SetPoint(179,94.73999786,67.55638123);
   graph3->SetPoint(180,94.77999878,68.72486877);
   graph3->SetPoint(181,94.81999969,69.89684296);
   graph3->SetPoint(182,94.86000061,71.07218933);
   graph3->SetPoint(183,94.90000153,72.25079346);
   graph3->SetPoint(184,94.94000244,73.43252563);
   graph3->SetPoint(185,94.98000336,74.61729431);
   graph3->SetPoint(186,95.01999664,75.80497742);
   graph3->SetPoint(187,95.05999756,76.99549103);
   graph3->SetPoint(188,95.09999847,78.18872833);
   graph3->SetPoint(189,95.13999939,79.38459015);
   graph3->SetPoint(190,95.18000031,80.58299255);
   graph3->SetPoint(191,95.22000122,81.78383636);
   graph3->SetPoint(192,95.22000122,81.78383636);
   graph3->SetPoint(193,95.26000214,82.98705292);
   graph3->SetPoint(194,95.30000305,84.19254303);
   graph3->SetPoint(195,95.33999634,85.40024567);
   graph3->SetPoint(196,95.37999725,86.61006927);
   graph3->SetPoint(197,95.41999817,87.82195282);
   graph3->SetPoint(198,95.45999908,89.03581238);
   graph3->SetPoint(199,95.5,90.25159454);
   graph3->SetPoint(200,95.54000092,91.46923065);
   graph3->SetPoint(201,95.58000183,92.68865204);
   graph3->SetPoint(202,95.62000275,93.90979767);
   graph3->SetPoint(203,95.66000366,95.13261414);
   graph3->SetPoint(204,95.69999695,96.35704803);
   graph3->SetPoint(205,95.73999786,97.58303833);
   graph3->SetPoint(206,95.77999878,98.81052399);
   graph3->SetPoint(207,95.81999969,100.0394745);
   graph3->SetPoint(208,95.86000061,101.2698212);
   graph3->SetPoint(209,95.90000153,102.5015259);
   graph3->SetPoint(210,95.94000244,103.7345352);
   graph3->SetPoint(211,95.98000336,104.9688034);



   TH1F *Graph_Graph1 = new TH1F("Graph_Graph1","Graph",212,84.03,95.97);
   Graph_Graph1->SetMinimum(0);
   Graph_Graph1->SetMaximum(57.47094);
   Graph_Graph1->SetDirectory(0);
   Graph_Graph1->SetStats(0);
   Graph_Graph1->SetLineStyle(0);
   Graph_Graph1->SetMarkerStyle(20);
   Graph_Graph1->GetXaxis()->SetLabelFont(42);
   Graph_Graph1->GetXaxis()->SetLabelOffset(0.01);
   Graph_Graph1->GetXaxis()->SetLabelSize(0.045);
   Graph_Graph1->GetXaxis()->SetTitleSize(0.055);
   Graph_Graph1->GetXaxis()->SetTitleOffset(0.9);
   Graph_Graph1->GetXaxis()->SetTitleFont(42);
   Graph_Graph1->GetYaxis()->SetLabelFont(42);
   Graph_Graph1->GetYaxis()->SetLabelOffset(0.01);
   Graph_Graph1->GetYaxis()->SetLabelSize(0.045);
   Graph_Graph1->GetYaxis()->SetTitleSize(0.055);
   Graph_Graph1->GetYaxis()->SetTitleOffset(1.25);
   Graph_Graph1->GetYaxis()->SetTitleFont(42);
   Graph_Graph1->GetZaxis()->SetLabelFont(42);
   Graph_Graph1->GetZaxis()->SetLabelOffset(0.01);
   Graph_Graph1->GetZaxis()->SetLabelSize(0.045);
   Graph_Graph1->GetZaxis()->SetTitleSize(0.055);
   Graph_Graph1->GetZaxis()->SetTitleFont(42);
   Graph_Graph1->GetXaxis()->SetNdivisions(510);
   
   graph->SetHistogram(Graph_Graph1);
   graph->Draw("cx");
   graph1->Draw("cx");
   graph2->Draw("cx");
   graph3->Draw("cx");

   TPaveText *pt = new TPaveText(0.1577181,0.95,0.9580537,0.99,"brNDC");
   pt->SetBorderSize(0);
   pt->SetFillStyle(0);
   pt->SetTextAlign(12);
   pt->SetTextFont(42);
   pt->SetTextSize(0.03);
   TText *text = pt->AddText(0.01,0.5,"CMS");
   text = pt->AddText(0.3,0.6,"#sqrt{s} = 7 TeV, L = 5.1 fb^{-1}  #sqrt{s} = 8 TeV, L = 19.7 fb^{-1}");
   pt->Draw();
   

   TLegend *leg = new TLegend(0.73,0.77,0.94,0.94);
   leg->SetTextSize(0.035);
   leg->SetTextFont(42);
   leg->SetFillColor(kWhite);
   //leg->SetBorderSize(0);
   //leg->SetFillStyle(0);

   leg->AddEntry(graph3,"Combined","L");
   leg->AddEntry(graph,"Z#rightarrow 4e","L");
   leg->AddEntry(graph2,"Z#rightarrow 4#mu","L");
   leg->AddEntry(graph1,"Z#rightarrow 2e2#mu","L");






   double yLow = 0.5;

   

   pt = new TPaveText(0.11,yLow,0.4,yLow+0.04,"brNDC");
   pt->SetBorderSize(0);
   pt->SetFillStyle(0);
   pt->SetTextAlign(12);
   pt->SetTextFont(42);
   pt->SetTextSize(0.03);
   pt->SetTextColor(kBlue);
   text = pt->AddText(0.2,0.2,"m_{2e2#mu} = 91.24 #pm 0.46 GeV");
   //text = pt->AddText(0.2,0.2,"m_{2e2#mu} = 91.24 #pm 0.40 #pm 0.16 GeV");
   //stat 91.4315 +0.405948-0.397679
   cout << "Syst 2e2mu: " << findSystErr(0.43,0.40) << endl;
   //pt->Draw();

   pt = new TPaveText(0.11,yLow+0.06,0.4,yLow+0.1,"brNDC");
   pt->SetBorderSize(0);
   pt->SetFillStyle(0);
   pt->SetTextAlign(12);
   pt->SetTextFont(42);
   pt->SetTextSize(0.03);
   pt->SetTextColor(kRed);
   text = pt->AddText(0.2,0.2,"m_{4#mu} = 91.00 #pm 0.26 GeV");
   //text = pt->AddText(0.2,0.2,"m_{4#mu} = 91.00 #pm 0.25 #pm 0.09 GeV");
   //stat 91.0078 +0.255715-0.25533
   cout << "Syst 4mu: " << findSystErr(0.27,0.255) << endl;
   //pt->Draw();

   pt = new TPaveText(0.11,yLow+0.12,0.4,yLow+0.16,"brNDC");
   pt->SetBorderSize(0);
   pt->SetFillStyle(0);
   pt->SetTextAlign(12);
   pt->SetTextFont(42);
   pt->SetTextSize(0.03);
   pt->SetTextColor(kGreen+1);
   text = pt->AddText(0.2,0.2,"m_{4e} = 93.67 #pm 1.08 GeV");
   //text = pt->AddText(0.2,0.2,"m_{4e} = 9 #pm 0.74 #pm 0.30 GeV");
   //stat 91.8026 +0.745333-0.740755
   cout << "Syst 4e: " << findSystErr(0.8,0.74) << endl;
   //pt->Draw();

   pt = new TPaveText(0.11,yLow+0.18,0.4,yLow+0.22,"brNDC");
   pt->SetBorderSize(0);
   pt->SetFillStyle(0);
   pt->SetTextAlign(12);
   pt->SetTextFont(42);
   pt->SetTextSize(0.03);
   text = pt->AddText(0.2,0.2,"m_{4l} = 91.15 #pm 0.23 GeV");
   //text = pt->AddText(0.2,0.2,"m_{4l} = 91.17 #pm 0.18 #pm 0.13 GeV");
   //stat  91.1724 +0.168014-0.204439
   cout << "Syst 4l: " << findSystErr(0.22,0.18) << endl;
   //pt->Draw();

   pt = new TPaveText(0.18,yLow+0.24,0.4,yLow+0.28,"brNDC");
   pt->SetBorderSize(0);
   pt->SetFillStyle(0);
   pt->SetTextAlign(12);
   pt->SetTextFont(42);
   pt->SetTextSize(0.035);
   text = pt->AddText(0.2,0.2,"#chi^{2}/ndof = 1.38/3");
   //pt->Draw();
   
   gPad->SetTicks(1,1);

   TLine *line95 = new TLine(88,3.84,96,3.84);
   line95->SetLineColor(kRed);
   line95->SetLineWidth(2);
   line95->Draw();

   TLine *line68 = new TLine(88,1,96,1);
   line68->SetLineColor(kRed);
   line68->SetLineWidth(3);
   line68->Draw();
   
   TLine *lineZ = new TLine(91.1876,0,91.1876,10);
   lineZ->SetLineColor(kGray+2);
   lineZ->SetLineStyle(7);
   lineZ->Draw();

   leg->Draw();
   hframe->GetXaxis()->SetRangeUser(88,96);
   ccc->Modified();
   ccc->cd();
   ccc->SetSelected(ccc);

   ccc->SaveAs("massZ4lScan_MZ2gt12_Legacy_split.eps");
   ccc->SaveAs("massZ4lScan_MZ2gt12_Legacy_split.png");
}
Пример #3
0
void PlotShapeSystematics2() {

  TFile *file = 0;
  TH1F *DefaultShape = 0;
  TH1F *UpShape = 0;
  TH1F *DownShape = 0;
  TCanvas *cv = 0;
  TLegend *legend = 0;

  //*********************************************************
  //0 Jet Bin - OF
  //*********************************************************

  file = new TFile("/data/smurf/sixie/data/Thesis/cards/120/hwwof_0j.input.root","READ");

  DefaultShape = (TH1F*)file->Get("histo_qqWW");
  UpShape = (TH1F*)file->Get("histo_qqWW_CMS_MVAWWNLOBounding_hwwUp");
  DownShape = (TH1F*)file->Get("histo_qqWW_CMS_MVAWWNLOBounding_hwwDown");

  assert(DefaultShape);
  assert(UpShape);
  assert(DownShape);

  NormalizeHist(DefaultShape);
  NormalizeHist(UpShape);
  NormalizeHist(DownShape);


  cv = new TCanvas("cv","cv",800,600);

  legend = new TLegend(0.2, 0.6, 0.5, 0.9);
  legend->SetTextSize(0.04);
  legend->SetBorderSize(0);
  legend->SetFillColor(kWhite);
  legend->AddEntry(DefaultShape, "Default Shape", "L");
  legend->AddEntry(UpShape, "Bounding Shape (Up)", "L");
  legend->AddEntry(DownShape, "Bounding Shape (Down)", "L");

  DefaultShape->SetLineColor(kBlack);
  UpShape->SetLineColor(kBlue);
  DownShape->SetLineColor(kRed);
  DefaultShape->SetLineWidth(2);
  UpShape->SetLineWidth(2);
  DownShape->SetLineWidth(2);
  DefaultShape->SetTitle("");
  DefaultShape->GetXaxis()->SetTitle("MVA discriminator");
  DefaultShape->GetYaxis()->SetTitle("Fraction of Events");
  DefaultShape->GetYaxis()->SetTitleOffset(1.4);
  DefaultShape->GetXaxis()->SetRangeUser(-1.0,1.0);
  DefaultShape->GetYaxis()->SetRangeUser(0.0,0.25);


  DefaultShape->Draw("hist");
  UpShape->Draw("same,hist");
  DownShape->Draw("same,hist");
  legend->Draw();

  cv->SaveAs("WWBkgShapeVariation_MCAtNLOScaleVariation_OF0Jet.png");
  cv->SaveAs("WWBkgShapeVariation_MCAtNLOScaleVariation_OF0Jet.eps");



  //*********************************************************
  //0 Jet Bin - SF
  //*********************************************************

  file = new TFile("/data/smurf/sixie/data/Thesis/cards/120/hwwsf_0j.input.root","READ");

  DefaultShape = (TH1F*)file->Get("histo_qqWW");
  UpShape = (TH1F*)file->Get("histo_qqWW_CMS_MVAWWNLOBounding_hwwUp");
  DownShape = (TH1F*)file->Get("histo_qqWW_CMS_MVAWWNLOBounding_hwwDown");

  assert(DefaultShape);
  assert(UpShape);
  assert(DownShape);

  NormalizeHist(DefaultShape);
  NormalizeHist(UpShape);
  NormalizeHist(DownShape);


  cv = new TCanvas("cv","cv",800,600);

  legend = new TLegend(0.2, 0.6, 0.5, 0.9);
  legend->SetTextSize(0.04);
  legend->SetBorderSize(0);
  legend->SetFillColor(kWhite);
  legend->AddEntry(DefaultShape, "Default Shape", "L");
  legend->AddEntry(UpShape, "Bounding Shape (Up)", "L");
  legend->AddEntry(DownShape, "Bounding Shape (Down)", "L");

  DefaultShape->SetLineColor(kBlack);
  UpShape->SetLineColor(kBlue);
  DownShape->SetLineColor(kRed);
  DefaultShape->SetLineWidth(2);
  UpShape->SetLineWidth(2);
  DownShape->SetLineWidth(2);
  DefaultShape->SetTitle("");
  DefaultShape->GetXaxis()->SetTitle("MVA discriminator");
  DefaultShape->GetYaxis()->SetTitle("Fraction of Events");
  DefaultShape->GetYaxis()->SetTitleOffset(1.4);
  DefaultShape->GetXaxis()->SetRangeUser(-1.0,1.0);
  DefaultShape->GetYaxis()->SetRangeUser(0.0,0.25);


  DefaultShape->Draw("hist");
  UpShape->Draw("same,hist");
  DownShape->Draw("same,hist");
  legend->Draw();

  cv->SaveAs("WWBkgShapeVariation_MCAtNLOScaleVariation_SF0Jet.png");
  cv->SaveAs("WWBkgShapeVariation_MCAtNLOScaleVariation_SF0Jet.eps");




  //*********************************************************
  //1 Jet Bin - OF
  //*********************************************************

  file = new TFile("/data/smurf/sixie/data/Thesis/cards/120/hwwof_1j.input.root","READ");

  DefaultShape = (TH1F*)file->Get("histo_qqWW");
  UpShape = (TH1F*)file->Get("histo_qqWW_CMS_MVAWWNLOBounding_hwwUp");
  DownShape = (TH1F*)file->Get("histo_qqWW_CMS_MVAWWNLOBounding_hwwDown");

  assert(DefaultShape);
  assert(UpShape);
  assert(DownShape);

  NormalizeHist(DefaultShape);
  NormalizeHist(UpShape);
  NormalizeHist(DownShape);


  cv = new TCanvas("cv","cv",800,600);

  legend = new TLegend(0.2, 0.6, 0.5, 0.9);
  legend->SetTextSize(0.04);
  legend->SetBorderSize(0);
  legend->SetFillColor(kWhite);
  legend->AddEntry(DefaultShape, "Default Shape", "L");
  legend->AddEntry(UpShape, "Bounding Shape (Up)", "L");
  legend->AddEntry(DownShape, "Bounding Shape (Down)", "L");

  DefaultShape->SetLineColor(kBlack);
  UpShape->SetLineColor(kBlue);
  DownShape->SetLineColor(kRed);
  DefaultShape->SetLineWidth(2);
  UpShape->SetLineWidth(2);
  DownShape->SetLineWidth(2);
  DefaultShape->SetTitle("");
  DefaultShape->GetXaxis()->SetTitle("MVA discriminator");
  DefaultShape->GetYaxis()->SetTitle("Fraction of Events");
  DefaultShape->GetYaxis()->SetTitleOffset(1.4);
  DefaultShape->GetXaxis()->SetRangeUser(-1.0,1.0);
  DefaultShape->GetYaxis()->SetRangeUser(0.0,0.4);


  DefaultShape->Draw("hist");
  UpShape->Draw("same,hist");
  DownShape->Draw("same,hist");
  legend->Draw();

  cv->SaveAs("WWBkgShapeVariation_MCAtNLOScaleVariation_OF1Jet.png");
  cv->SaveAs("WWBkgShapeVariation_MCAtNLOScaleVariation_OF1Jet.eps");



  //*********************************************************
  //1 Jet Bin - SF
  //*********************************************************

  file = new TFile("/data/smurf/sixie/data/Thesis/cards/120/hwwsf_1j.input.root","READ");

  DefaultShape = (TH1F*)file->Get("histo_qqWW");
  UpShape = (TH1F*)file->Get("histo_qqWW_CMS_MVAWWNLOBounding_hwwUp");
  DownShape = (TH1F*)file->Get("histo_qqWW_CMS_MVAWWNLOBounding_hwwDown");

  assert(DefaultShape);
  assert(UpShape);
  assert(DownShape);

  NormalizeHist(DefaultShape);
  NormalizeHist(UpShape);
  NormalizeHist(DownShape);


  cv = new TCanvas("cv","cv",800,600);

  legend = new TLegend(0.2, 0.6, 0.5, 0.9);
  legend->SetTextSize(0.04);
  legend->SetBorderSize(0);
  legend->SetFillColor(kWhite);
  legend->AddEntry(DefaultShape, "Default Shape", "L");
  legend->AddEntry(UpShape, "Bounding Shape (Up)", "L");
  legend->AddEntry(DownShape, "Bounding Shape (Down)", "L");

  DefaultShape->SetLineColor(kBlack);
  UpShape->SetLineColor(kBlue);
  DownShape->SetLineColor(kRed);
  DefaultShape->SetLineWidth(2);
  UpShape->SetLineWidth(2);
  DownShape->SetLineWidth(2);
  DefaultShape->SetTitle("");
  DefaultShape->GetXaxis()->SetTitle("MVA discriminator");
  DefaultShape->GetYaxis()->SetTitle("Fraction of Events");
  DefaultShape->GetYaxis()->SetTitleOffset(1.4);
  DefaultShape->GetXaxis()->SetRangeUser(-1.0,1.0);
  DefaultShape->GetYaxis()->SetRangeUser(0.0,0.4);


  DefaultShape->Draw("hist");
  UpShape->Draw("same,hist");
  DownShape->Draw("same,hist");
  legend->Draw();

  cv->SaveAs("WWBkgShapeVariation_MCAtNLOScaleVariation_SF1Jet.png");
  cv->SaveAs("WWBkgShapeVariation_MCAtNLOScaleVariation_SF1Jet.eps");












  //*********************************************************
  //0 Jet Bin - OF
  //*********************************************************

  file = new TFile("/data/smurf/sixie/data/Thesis/cards/120/hwwof_0j.input.root","READ");

  DefaultShape = (TH1F*)file->Get("histo_qqWW");
  UpShape = (TH1F*)file->Get("histo_qqWW_CMS_MVAWWBounding_hwwUp");
  DownShape = (TH1F*)file->Get("histo_qqWW_CMS_MVAWWBounding_hwwDown");

  assert(DefaultShape);
  assert(UpShape);
  assert(DownShape);

  NormalizeHist(DefaultShape);
  NormalizeHist(UpShape);
  NormalizeHist(DownShape);


  cv = new TCanvas("cv","cv",800,600);

  legend = new TLegend(0.2, 0.6, 0.5, 0.9);
  legend->SetTextSize(0.04);
  legend->SetBorderSize(0);
  legend->SetFillColor(kWhite);
  legend->AddEntry(DefaultShape, "Default Shape", "L");
  legend->AddEntry(UpShape, "Bounding Shape (Up)", "L");
  legend->AddEntry(DownShape, "Bounding Shape (Down)", "L");

  DefaultShape->SetLineColor(kBlack);
  UpShape->SetLineColor(kBlue);
  DownShape->SetLineColor(kRed);
  DefaultShape->SetLineWidth(2);
  UpShape->SetLineWidth(2);
  DownShape->SetLineWidth(2);
  DefaultShape->SetTitle("");
  DefaultShape->GetXaxis()->SetTitle("MVA discriminator");
  DefaultShape->GetYaxis()->SetTitle("Fraction of Events");
  DefaultShape->GetYaxis()->SetTitleOffset(1.4);
  DefaultShape->GetXaxis()->SetRangeUser(-1.0,1.0);
  DefaultShape->GetYaxis()->SetRangeUser(0.0,0.25);


  DefaultShape->Draw("hist");
  UpShape->Draw("same,hist");
  DownShape->Draw("same,hist");
  legend->Draw();

  cv->SaveAs("WWBkgShapeVariation_MadgraphVsMCAtNLO_OF0Jet.png");
  cv->SaveAs("WWBkgShapeVariation_MadgraphVsMCAtNLO_OF0Jet.eps");



  //*********************************************************
  //0 Jet Bin - SF
  //*********************************************************

  file = new TFile("/data/smurf/sixie/data/Thesis/cards/120/hwwsf_0j.input.root","READ");

  DefaultShape = (TH1F*)file->Get("histo_qqWW");
  UpShape = (TH1F*)file->Get("histo_qqWW_CMS_MVAWWBounding_hwwUp");
  DownShape = (TH1F*)file->Get("histo_qqWW_CMS_MVAWWBounding_hwwDown");

  assert(DefaultShape);
  assert(UpShape);
  assert(DownShape);

  NormalizeHist(DefaultShape);
  NormalizeHist(UpShape);
  NormalizeHist(DownShape);


  cv = new TCanvas("cv","cv",800,600);

  legend = new TLegend(0.2, 0.6, 0.5, 0.9);
  legend->SetTextSize(0.04);
  legend->SetBorderSize(0);
  legend->SetFillColor(kWhite);
  legend->AddEntry(DefaultShape, "Default Shape", "L");
  legend->AddEntry(UpShape, "Bounding Shape (Up)", "L");
  legend->AddEntry(DownShape, "Bounding Shape (Down)", "L");

  DefaultShape->SetLineColor(kBlack);
  UpShape->SetLineColor(kBlue);
  DownShape->SetLineColor(kRed);
  DefaultShape->SetLineWidth(2);
  UpShape->SetLineWidth(2);
  DownShape->SetLineWidth(2);
  DefaultShape->SetTitle("");
  DefaultShape->GetXaxis()->SetTitle("MVA discriminator");
  DefaultShape->GetYaxis()->SetTitle("Fraction of Events");
  DefaultShape->GetYaxis()->SetTitleOffset(1.4);
  DefaultShape->GetXaxis()->SetRangeUser(-1.0,1.0);
  DefaultShape->GetYaxis()->SetRangeUser(0.0,0.25);


  DefaultShape->Draw("hist");
  UpShape->Draw("same,hist");
  DownShape->Draw("same,hist");
  legend->Draw();

  cv->SaveAs("WWBkgShapeVariation_MadgraphVsMCAtNLO_SF0Jet.png");
  cv->SaveAs("WWBkgShapeVariation_MadgraphVsMCAtNLO_SF0Jet.eps");




  //*********************************************************
  //1 Jet Bin - OF
  //*********************************************************

  file = new TFile("/data/smurf/sixie/data/Thesis/cards/120/hwwof_1j.input.root","READ");

  DefaultShape = (TH1F*)file->Get("histo_qqWW");
  UpShape = (TH1F*)file->Get("histo_qqWW_CMS_MVAWWBounding_hwwUp");
  DownShape = (TH1F*)file->Get("histo_qqWW_CMS_MVAWWBounding_hwwDown");

  assert(DefaultShape);
  assert(UpShape);
  assert(DownShape);

  NormalizeHist(DefaultShape);
  NormalizeHist(UpShape);
  NormalizeHist(DownShape);


  cv = new TCanvas("cv","cv",800,600);

  legend = new TLegend(0.2, 0.6, 0.5, 0.9);
  legend->SetTextSize(0.04);
  legend->SetBorderSize(0);
  legend->SetFillColor(kWhite);
  legend->AddEntry(DefaultShape, "Default Shape", "L");
  legend->AddEntry(UpShape, "Bounding Shape (Up)", "L");
  legend->AddEntry(DownShape, "Bounding Shape (Down)", "L");

  DefaultShape->SetLineColor(kBlack);
  UpShape->SetLineColor(kBlue);
  DownShape->SetLineColor(kRed);
  DefaultShape->SetLineWidth(2);
  UpShape->SetLineWidth(2);
  DownShape->SetLineWidth(2);
  DefaultShape->SetTitle("");
  DefaultShape->GetXaxis()->SetTitle("MVA discriminator");
  DefaultShape->GetYaxis()->SetTitle("Fraction of Events");
  DefaultShape->GetYaxis()->SetTitleOffset(1.4);
  DefaultShape->GetXaxis()->SetRangeUser(-1.0,1.0);
  DefaultShape->GetYaxis()->SetRangeUser(0.0,0.4);


  DefaultShape->Draw("hist");
  UpShape->Draw("same,hist");
  DownShape->Draw("same,hist");
  legend->Draw();

  cv->SaveAs("WWBkgShapeVariation_MadgraphVsMCAtNLO_OF1Jet.png");
  cv->SaveAs("WWBkgShapeVariation_MadgraphVsMCAtNLO_OF1Jet.eps");



  //*********************************************************
  //1 Jet Bin - SF
  //*********************************************************

  file = new TFile("/data/smurf/sixie/data/Thesis/cards/120/hwwsf_1j.input.root","READ");

  DefaultShape = (TH1F*)file->Get("histo_qqWW");
  UpShape = (TH1F*)file->Get("histo_qqWW_CMS_MVAWWBounding_hwwUp");
  DownShape = (TH1F*)file->Get("histo_qqWW_CMS_MVAWWBounding_hwwDown");

  assert(DefaultShape);
  assert(UpShape);
  assert(DownShape);

  NormalizeHist(DefaultShape);
  NormalizeHist(UpShape);
  NormalizeHist(DownShape);


  cv = new TCanvas("cv","cv",800,600);

  legend = new TLegend(0.2, 0.6, 0.5, 0.9);
  legend->SetTextSize(0.04);
  legend->SetBorderSize(0);
  legend->SetFillColor(kWhite);
  legend->AddEntry(DefaultShape, "Default Shape", "L");
  legend->AddEntry(UpShape, "Bounding Shape (Up)", "L");
  legend->AddEntry(DownShape, "Bounding Shape (Down)", "L");

  DefaultShape->SetLineColor(kBlack);
  UpShape->SetLineColor(kBlue);
  DownShape->SetLineColor(kRed);
  DefaultShape->SetLineWidth(2);
  UpShape->SetLineWidth(2);
  DownShape->SetLineWidth(2);
  DefaultShape->SetTitle("");
  DefaultShape->GetXaxis()->SetTitle("MVA discriminator");
  DefaultShape->GetYaxis()->SetTitle("Fraction of Events");
  DefaultShape->GetYaxis()->SetTitleOffset(1.4);
  DefaultShape->GetXaxis()->SetRangeUser(-1.0,1.0);
  DefaultShape->GetYaxis()->SetRangeUser(0.0,0.4);


  DefaultShape->Draw("hist");
  UpShape->Draw("same,hist");
  DownShape->Draw("same,hist");
  legend->Draw();

  cv->SaveAs("WWBkgShapeVariation_MadgraphVsMCAtNLO_SF1Jet.png");
  cv->SaveAs("WWBkgShapeVariation_MadgraphVsMCAtNLO_SF1Jet.eps");





}
Пример #4
0
void plot_pll(TString fname="monoh_withsm_SRCR_bg11.7_bgslop-0.0_nsig0.0.root")
{
  SetAtlasStyle();



  TFile* file =  TFile::Open(fname);
  RooWorkspace* wspace = (RooWorkspace*) file->Get("wspace");

  cout << "\n\ncheck that eff and reco terms included in BSM component to make fiducial cross-section" <<endl;
  wspace->function("nsig")->Print();
  RooRealVar* reco = wspace->var("reco");
  if(  wspace->function("nsig")->dependsOn(*reco) ) {
    cout << "all good." <<endl;
  } else {
    cout << "need to rerun fit_withsm using DO_FIDUCIAL_LIMIT true" <<endl;
    return;
  }

  /*
  // DANGER
  // TEST WITH EXAGGERATED UNCERTAINTY
  wspace->var("unc_theory")->setMax(1);
  wspace->var("unc_theory")->setVal(1);
  wspace->var("unc_theory")->Print();
  */

  // this was for making plot about decoupling/recoupling approach
  TCanvas* tc = new TCanvas("tc","",400,400);
  RooPlot *frame = wspace->var("xsec_bsm")->frame();
  RooAbsPdf* pdfc = wspace->pdf("jointModeld");
  RooAbsData* data = wspace->data("data");
  RooAbsReal *nllJoint = pdfc->createNLL(*data, RooFit::Constrained()); // slice with fixed xsec_bsm
  RooAbsReal *profileJoint = nllJoint->createProfile(*wspace->var("xsec_bsm"));

  wspace->allVars().Print("v");
  pdfc->fitTo(*data);
  wspace->allVars().Print("v");
  wspace->var("xsec_bsm")->Print();
  double nllmin = 2*nllJoint->getVal();
  wspace->var("xsec_bsm")->setVal(0);
  double nll0 = 2*nllJoint->getVal();
  cout << Form("nllmin = %f, nll0 = %f, Z=%f", nllmin, nll0, sqrt(nll0-nllmin)) << endl;
  nllJoint->plotOn(frame, RooFit::LineColor(kGreen), RooFit::LineStyle(kDotted), RooFit::ShiftToZero(), RooFit::Name("nll_statonly")); // no error
  profileJoint->plotOn(frame,RooFit::Name("pll") );
  wspace->var("xsec_sm")->Print();
  wspace->var("theory")->Print();
  wspace->var("theory")->setConstant();
  profileJoint->plotOn(frame, RooFit::LineColor(kRed), RooFit::LineStyle(kDashed), RooFit::Name("pll_smfixed") );

  frame->GetXaxis()->SetTitle("#sigma_{BSM, fid} [fb]");
  frame->GetYaxis()->SetTitle("-log #lambda  ( #sigma_{BSM, fid} )");
  double temp = frame->GetYaxis()->GetTitleOffset();
  frame->GetYaxis()->SetTitleOffset( 1.1* temp );

  frame->SetMinimum(1e-7);
  frame->SetMaximum(4);


  // Legend
  double x1,y1,x2,y2;
  GetX1Y1X2Y2(tc,x1,y1,x2,y2);
  TLegend *legend_sr=FastLegend(x2-0.75,y2-0.3,x2-0.25,y2-0.5,0.045);
  legend_sr->AddEntry(frame->findObject("pll"),"with #sigma_{SM} uncertainty","L");
  legend_sr->AddEntry(frame->findObject("pll_smfixed"),"with #sigma_{SM} constant","L");
  legend_sr->AddEntry(frame->findObject("nll_statonly"),"no systematics","L");
  frame->Draw();
  legend_sr->Draw("SAME");



  // descriptive text
  vector<TString> pavetext11;
  pavetext11.push_back("#bf{#it{ATLAS Internal}}");
  pavetext11.push_back("#sqrt{#it{s}} = 8 TeV #scale[0.6]{#int}Ldt = 20.3 fb^{-1}");
  pavetext11.push_back("#it{H}+#it{E}_{T}^{miss} , #it{H #rightarrow #gamma#gamma}, #it{m}_{#it{H}} = 125.4 GeV");

  TPaveText* text11=CreatePaveText(x2-0.75,y2-0.25,x2-0.25,y2-0.05,pavetext11,0.045);
  text11->Draw();

  tc->SaveAs("pll.pdf");



  /*
  wspace->var("xsec_bsm")->setConstant(true);
  wspace->var("eff"     )->setConstant(true);
  wspace->var("mh"      )->setConstant(true);
  wspace->var("sigma_h" )->setConstant(true);
  wspace->var("lumi"    )->setConstant(true);
  wspace->var("xsec_sm" )->setVal(v_xsec_sm);
  wspace->var("eff"     )->setVal(1.0);
  wspace->var("lumi"    )->setVal(v_lumi);
  TH1* nllHist = profileJoint->createHistogram("xsec_bsm",100);
  TFile* out = new TFile("nllHist.root","REPLACE");
  nllHist->Write()
  out->Write();
  out->Close();
  */

}
Пример #5
0
void PlotEfficiencyMap(const string Label = "") 
{  
  gBenchmark->Start("HZZTemplate");
  string label = Label;
  if (Label != "") label = "_" + Label;

  //--------------------------------------------------------------------------------------------------------------
  // Settings 
  //==============================================================================================================

  //********************************************************
  // Create Arrays to store the map
  //********************************************************
   const UInt_t NPtBins = 15; 
   const UInt_t NEtaBins = 16;
   const UInt_t NPhiBins = 12;
   double ptBins[NPtBins+1] = { 5, 6, 7, 8, 9, 10, 12, 14, 16, 18, 20, 25, 30, 35, 40, 50};
   double etaBins[NEtaBins+1] = { 0.0, 0.2, 0.4, 0.6, 0.8, 1.0, 1.2, 1.4442, 1.566, 1.8, 2.0, 2.1, 2.2, 2.3, 2.4, 2.5, 2.6};
   double phiBins[NPhiBins+1] = { -3.2, -2.5, -2, -1.5, -1, -0.5, 0, 0.5, 1, 1.5,  2, 2.5, 3.2 };

   TH2F *ElectronEfficiencyMap = new TH2F("ElectronEfficiencyMap", ";p_{T} [GeV/c];#eta;Efficiency", 50, 0, 100, 50, 0, 2.5);
   TH2F *MuonEfficiencyMap = new TH2F("MuonEfficiencyMap", ";p_{T} [GeV/c];|#eta|;Efficiency", 50, 0, 100, 50, 0, 2.5);

   for (int i=0; i<ElectronEfficiencyMap->GetXaxis()->GetNbins()+1; ++i) {
     for (int j=0; j<ElectronEfficiencyMap->GetYaxis()->GetNbins()+1; ++j) {
       double x = ElectronEfficiencyMap->GetXaxis()->GetBinCenter(i);
       double y = ElectronEfficiencyMap->GetYaxis()->GetBinCenter(j);

       double weightModifier = 1.0;
       if (x < 8) weightModifier = 1.25;
       if (x>= 8 && x < 10) weightModifier = 1.03;
       if (x >= 10 &&  x < 16) weightModifier = 1.02;
       if (x >= 16 &&  x < 20) weightModifier = 1.01;
       if (x >= 20 &&  x < 40) weightModifier = 0.975;
       if (x >= 40 ) weightModifier = 0.97;

       ElectronEfficiencyMap->SetBinContent(i,j, weightModifier*GetElectronEfficiencyPtEta(x,y));
       //cout << x << " " << y << " : " << weightModifier*GetElectronEfficiencyPtEta(x,y) << "\n";

     }
   }

   for (int i=0; i<MuonEfficiencyMap->GetXaxis()->GetNbins()+1; ++i) {
     for (int j=0; j<MuonEfficiencyMap->GetYaxis()->GetNbins()+1; ++j) {
       double x = MuonEfficiencyMap->GetXaxis()->GetBinCenter(i);
       double y = MuonEfficiencyMap->GetYaxis()->GetBinCenter(j);

       double weightModifier = 1.0;
       if (x < 6) weightModifier *= 1.15;
       if (x >= 6 && x < 7) weightModifier *= 1.05;
       if (x >= 7 && x < 10) weightModifier *= 1.015;
       if (x >= 10 &&  x < 20) weightModifier *= 1.015;
       if (x >= 20 &&  x < 40) weightModifier *= 1.00;
       if (x >= 40 ) weightModifier *= 0.985;

       MuonEfficiencyMap->SetBinContent(i,j, weightModifier*GetMuonEfficiencyPtEta(x,y));
       //cout << x << " " << y << " : " << weightModifier*GetMuonEfficiencyPtEta(x,y) << "\n";

     }
   }


   TCanvas *cv = new TCanvas("cv","cv", 800, 600);
   cv->SetRightMargin(0.15);
   ElectronEfficiencyMap->SetMinimum(0.5);
   ElectronEfficiencyMap->Draw("colz");
   cv->SaveAs("ElectronEfficiencyMap.gif");


   cv = new TCanvas("cv","cv", 800, 600);
   cv->SetRightMargin(0.15);
   MuonEfficiencyMap->SetMinimum(0.5);
   MuonEfficiencyMap->Draw("colz");
   cv->SaveAs("MuonEfficiencyMap.gif");

} 
Пример #6
0
void v2ExpClose_pt(bool bSavePlots     = true,
                   float rangeYAxis    = 0.6,
                   float rangeXAxis    = 30,
                   bool  bDrawCh       = true,
                   const char* inputDir      = "../macro_v2/outRoot", // the place where the input root files, with the histograms are
                   const char* figNamePrefix="v2ExpClose_pt")
{
    gSystem->mkdir(Form("./figs/png"), kTRUE);
    gSystem->mkdir(Form("./figs/pdf"), kTRUE);
    setTDRStyle();

    // read CMS graphs
    TFile *pfV2Cms_cent   = new TFile(Form("%s/Prp_v2_pt_plotter.root",inputDir));

    TGraphAsymmErrors *pgV2Low  = (TGraphAsymmErrors *)pfV2Cms_cent->Get("pgV2_low");
    TGraphErrors *pgV2LowSyst   = (TGraphErrors *)pfV2Cms_cent->Get("pgV2_low_sys");
    TGraphErrors *pgV2LowP      = (TGraphErrors *)pfV2Cms_cent->Get("pgV2_low_cont");

    TGraphAsymmErrors *pgV2High = (TGraphAsymmErrors *)pfV2Cms_cent->Get("pgV2");
    TGraphErrors *pgV2HighSyst  = (TGraphErrors *)pfV2Cms_cent->Get("pgV2_sys");
    TGraphErrors *pgV2HighP     = (TGraphErrors *)pfV2Cms_cent->Get("pgV2_cont");

    pgV2Low->SetName("pgV2Low");
    pgV2LowSyst->SetFillColorAlpha(kViolet-9,0.5);
    pgV2High->SetName("pgV2High");
    pgV2HighSyst->SetFillColorAlpha(kRed-9,0.5);

    // -----------------------------------------------------------------------------------------
    // ----- charged hadrons
    TGraphErrors *gChar    = new TGraphErrors(19, pTChar, v2Char, chxerr, v2CharSt);
    TGraphErrors *gChar2   = new TGraphErrors(19, pTChar, v2Char, chxerr, v2CharSt2);
    TGraphErrors *gCharSys = new TGraphErrors(19, pTChar, v2Char, chxerr2, v2CharSys);

    gChar->SetName("gChar");
    gChar->SetMarkerStyle(20);
    gChar->SetMarkerColor(kTeal+3);
    gChar->SetLineColor(kTeal+3);
    gChar->SetMarkerSize(1.3);
    gChar2->SetMarkerStyle(24);
    gChar2->SetMarkerColor(kTeal+4);
    gChar2->SetLineColor(kTeal+4);
    gChar2->SetMarkerSize(1.3);

    gCharSys->SetFillColor(kTeal-9);

    //----------- D from ALICE
    TGraphErrors *pgAlice          = new TGraphErrors(6, v2AliceX_pt, v2Alice_pt, v2AliceXl, v2AliceStat_pt);
    TGraphErrors *pgAliceSys       = new TGraphErrors(6, v2AliceX_pt, v2Alice_pt, v2AliceXl, v2AliceSyst_pt);
    TGraphAsymmErrors *pgAliceSysB = new TGraphAsymmErrors(6, v2AliceX_pt, v2Alice_pt, v2AliceXl2, v2AliceXl2, v2AliceSystBLow_pt, v2AliceSystBHigh_pt);


    pgAlice->SetName("pgAlice");
    pgAlice->SetMarkerStyle(kOpenSquare);
    pgAlice->SetMarkerColor(kGray+2);
    pgAlice->SetLineColor(kGray+2);
    pgAlice->SetMarkerSize(1.0);

    pgAliceSys->SetFillStyle(0);
    pgAliceSys->SetMarkerColor(kGray+2);
    pgAliceSys->SetLineColor(kGray+2);
    pgAliceSys->SetMarkerSize(1.7);

    pgAliceSysB->SetFillColor(kGray);

    // drawing
    //------------------------------------------------------------------------
    // put everything on one plot
    TH1D *phAxis_v2 = new TH1D("phAxis_v2",";p_{T} (GeV/c);v_{2}",1,0,rangeXAxis);
    phAxis_v2->SetDirectory(0);
    phAxis_v2->GetXaxis()->CenterTitle(true);
    phAxis_v2->GetXaxis()->LabelsOption("h");
    phAxis_v2->GetYaxis()->SetRangeUser(0,rangeYAxis);
    phAxis_v2->GetYaxis()->SetTitleOffset(1.25);

    TCanvas *pcCombi = new TCanvas("pcCombi","pcCombi");
    phAxis_v2->Draw();
    CMS_lumi(pcCombi,12001000,0);

    pgAliceSysB->Draw("2");
    pgAliceSys->Draw("2");
    pgAlice->Draw("pz");

    if (bDrawCh) {
        gCharSys->Draw("2");
        gChar->Draw("pz");
        gChar2->Draw("p");
    }

    pgV2LowSyst->Draw("2");
    pgV2Low->Draw("PZ");
    pgV2LowP->Draw("P");

    pgV2HighSyst->Draw("2");
    pgV2High->Draw("PZ");
    pgV2HighP->Draw("P");

    // --------- legends ----
    TLegend *leg = new TLegend(0.2,0.77,0.7,0.89,NULL,"brNDC"); // at top center
    leg->SetBorderSize(0);
    leg->SetTextFont(132);
    leg->SetTextSize(0.03);
    leg->SetLineColor(1);
    leg->SetLineStyle(1);
    leg->SetLineWidth(1);
    leg->SetFillColor(19);
    leg->SetFillStyle(0);

    TLegendEntry *entry, *entry11;
    entry=leg->AddEntry("cmspr","Hidden charm: prompt J/#psi","");
    entry->SetTextFont(132);
    entry->SetTextSize(ltxSetTextSize3);

    entry=leg->AddEntry("pgV2Low", "1.6 < |y| < 2.4","p");
    entry->SetTextFont(42);
    entry->SetTextSize(entrySize);

    entry=leg->AddEntry("pgV2High", "|y| < 2.4","P");
    entry->SetTextFont(42);
    entry->SetTextSize(entrySize);

    TLegend *leg1 = new TLegend(0.2,0.685,0.7,0.765,NULL,"brNDC");
    leg1->SetBorderSize(0);
    leg1->SetTextFont(132);
    leg1->SetTextSize(ltxSetTextSize3);

    if (bDrawCh) {
        TLegendEntry *entry1;
        entry1=leg1->AddEntry("hpm","Charged hadron","");
        entry1->SetTextFont(132);
        entry1->SetTextSize(ltxSetTextSize3);
        entry1=leg1->AddEntry("gChar","|#eta| < 0.8","P");
        entry1->SetTextFont(42);
        entry1->SetTextSize(entrySize);
    }

    //---------------------------
    TLegend *leg_alice;
    if (bDrawCh) {
        leg_alice = new TLegend(0.2,0.60,0.7,0.68,NULL,"brNDC");
    } else {
        leg_alice = new TLegend(0.2,0.685,0.7,0.765,NULL,"brNDC");
    }
    leg_alice->SetBorderSize(0);
    leg_alice->SetTextFont(132);
    leg_alice->SetLineColor(1);
    leg_alice->SetLineStyle(1);
    leg_alice->SetLineWidth(1);
    leg_alice->SetFillColor(19);
    leg_alice->SetFillStyle(0);

    TLegendEntry *entry_alice=leg_alice->AddEntry("pgAlice","Open charm: prompt D (ALICE)","");
    entry_alice->SetTextFont(132);
    entry_alice->SetTextSize(ltxSetTextSize3);
    entry_alice=leg_alice->AddEntry("pgAlice","|y| < 0.8, Cent. 30-50\%","P");
    entry_alice->SetTextFont(42);
    entry_alice->SetTextSize(entrySize);

    TLatex *lat = new TLatex();
    lat->SetNDC();
    lat->SetTextFont(42);
    lat->SetTextSize(ltxSetTextSize2);
    if (bDrawCh) lat->DrawLatex(0.63,0.52,"Cent. 10-60%");
    else lat->DrawLatex(0.63,0.58,"Cent. 10-60%");

    leg->Draw();
    if (bDrawCh) leg1->Draw();
    leg_alice->Draw();

    gPad->RedrawAxis();

    if(bSavePlots)
    {
        pcCombi->SaveAs(Form("figs/pdf/%s_RaaCh%d.pdf",figNamePrefix,bDrawCh));
        pcCombi->SaveAs(Form("figs/png/%s_RaaCh%d.png",figNamePrefix,bDrawCh));
    }


    return;
}
Пример #7
0
int main(int ac, char *av[]) {
  gROOT->SetStyle("Plain");

  try {
    typedef funct::FunctExpression Expr;
    typedef fit::HistoChiSquare<funct::FunctExpression> ExprChi2;
    typedef fit::MultiHistoChiSquare<ExprChi2, ExprChi2, ExprChi2, ExprChi2, ExprChi2> ChiSquared;
    double fMin, fMax;
    string ext;
    po::options_description desc("Allowed options");
    desc.add_options()
      ("help,h", "produce help message")
      ("input-file,i", po::value< vector<string> >(), "input file")
      ("min,m", po::value<double>(&fMin)->default_value(60), "minimum value for fit range")
      ("max,M", po::value<double>(&fMax)->default_value(120), "maximum value for fit range")
      ("plot-format,p", po::value<string>(&ext)->default_value("eps"), 
       "output plot format");
    
    po::positional_options_description p;
    p.add("input-file", -1);
    
    po::variables_map vm;
    po::store(po::command_line_parser(ac, av).
	    options(desc).positional(p).run(), vm);
    po::notify(vm);
    
    if (vm.count("help")) {
      cout << "Usage: options_description [options]\n";
      cout << desc;
      return 0;
    }
    
    fit::RootMinuitCommands<ChiSquared> commands("zFitToyMc.txt");

    cout << "minuit command file completed" << endl;
    const unsigned int rebinMuMuNoIso = 2,rebinMuMu = 1, rebinMuMu1HLT = 1, rebinMuMu2HLT = 1, rebinMuTk = 2, rebinMuSa = 10;
    // assume that the bin size is 1 GeV!!!
    funct::Constant rebinMuMuNoIsoConst(rebinMuMuNoIso), rebinMuMuConst(rebinMuMu), 
      rebinMuMu1HLTConst(rebinMuMu1HLT), rebinMuMu2HLTConst(rebinMuMu2HLT), 
      rebinMuTkConst(rebinMuTk), rebinMuSaConst(rebinMuSa);

    if (vm.count("input-file")) {
      cout << "Input files are: " 
	   << vm["input-file"].as< vector<string> >() << "\n";
      vector<string> v_file = vm["input-file"].as< vector<string> >();
      for(vector<string>::const_iterator it = v_file.begin(); 
	  it != v_file.end(); ++it) {
	TFile * root_file = new TFile(it->c_str(), "read");
	TH1 * histoZMuMuNoIso = getHisto(root_file, "nonIsolatedZToMuMuPlots/zMass_noIso",rebinMuMuNoIso);
	TH1 * histoZMuMu = getHisto(root_file, "goodZToMuMuPlots/zMass_golden",rebinMuMu);
	TH1 * histoZMuMu1HLT = getHisto(root_file, "goodZToMuMu1HLTPlots/zMass_1hlt", rebinMuMu1HLT);
	TH1 * histoZMuMu2HLT = getHisto(root_file, "goodZToMuMu2HLTPlots/zMass_2hlt", rebinMuMu2HLT);
	TH1 * histoZMuTk = getHisto(root_file, "goodZToMuMuOneTrackPlots/zMass_tk", rebinMuTk);
	TH1 * histoZMuSa = getHisto(root_file, "goodZToMuMuOneStandAloneMuonPlots/zMass_sa", rebinMuSa);
	TH1 * histoZMuSaFromMuMu = getHisto(root_file, "zmumuSaMassHistogram/zMass_safromGolden", rebinMuSa);


	cout << ">>> histogram loaded\n";
	string f_string = *it;
	replace(f_string.begin(), f_string.end(), '.', '_');
	replace(f_string.begin(), f_string.end(), '/', '_');
	string plot_string = f_string + "." + ext;
	cout << ">>> Input files loaded\n";
	
	const char * kYieldZMuMu = "YieldZMuMu";
	const char * kEfficiencyTk = "EfficiencyTk";
	const char * kEfficiencySa = "EfficiencySa";
	const char * kEfficiencyIso = "EfficiencyIso";
	const char * kEfficiencyHLT = "EfficiencyHLT"; 
	const char * kYieldBkgZMuTk = "YieldBkgZMuTk"; 
	const char * kYieldBkgZMuSa = "YieldBkgZMuSa"; 
	const char * kYieldBkgZMuMuNotIso = "YieldBkgZMuMuNotIso";
	const char * kAlpha = "Alpha";
	const char * kBeta = "Beta";
	const char * kLambda = "Lambda";
	const char * kA0 = "A0"; 
	const char * kA1 = "A1"; 
	const char * kA2 = "A2"; 
	const char * kB0 = "B0"; 
	const char * kB1 = "B1"; 
	const char * kB2 = "B2"; 
	
	funct::Parameter yieldZMuMu(kYieldZMuMu, commands.par(kYieldZMuMu));
	funct::Parameter effTk(kEfficiencyTk, commands.par(kEfficiencyTk)); 
	funct::Parameter effSa(kEfficiencySa, commands.par(kEfficiencySa)); 
	funct::Parameter effIso(kEfficiencyIso, commands.par(kEfficiencyIso)); 
	funct::Parameter effHLT(kEfficiencyHLT, commands.par(kEfficiencyHLT)); 
	funct::Parameter yieldBkgZMuTk(kYieldBkgZMuTk, commands.par(kYieldBkgZMuTk));
	funct::Parameter yieldBkgZMuSa(kYieldBkgZMuSa, commands.par(kYieldBkgZMuSa));
	funct::Parameter yieldBkgZMuMuNotIso(kYieldBkgZMuMuNotIso, commands.par(kYieldBkgZMuMuNotIso));
	funct::Parameter alpha(kAlpha, commands.par(kAlpha));
	funct::Parameter beta(kBeta, commands.par(kBeta));
	funct::Parameter lambda(kLambda, commands.par(kLambda));
	funct::Parameter a0(kA0, commands.par(kA0));
	funct::Parameter a1(kA1, commands.par(kA1));
	funct::Parameter a2(kA2, commands.par(kA2));
	funct::Parameter b0(kB0, commands.par(kB0));
	funct::Parameter b1(kB1, commands.par(kB1));
	funct::Parameter b2(kB2, commands.par(kB2));
	funct::Constant cFMin(fMin), cFMax(fMax);

	// count ZMuMu Yield
	double nZMuMu = 0, nZMuMu1HLT = 0, nZMuMu2HLT = 0;
	{
	  unsigned int nBins = histoZMuMu->GetNbinsX();
	  double xMin = histoZMuMu->GetXaxis()->GetXmin();
	  double xMax = histoZMuMu->GetXaxis()->GetXmax();
	  double deltaX =(xMax - xMin) / nBins;
	  for(unsigned int i = 0; i < nBins; ++i) { 
	    double x = xMin + (i +.5) * deltaX;
	    if(x > fMin && x < fMax){
	      nZMuMu += histoZMuMu->GetBinContent(i+1);
	      nZMuMu1HLT += histoZMuMu1HLT->GetBinContent(i+1);
	      nZMuMu2HLT += histoZMuMu2HLT->GetBinContent(i+1);
	    }
	  }
	}
	// aggiungi 1HLT 2HLT
	cout << ">>> count of ZMuMu yield in the range [" << fMin << ", " << fMax << "]: " << nZMuMu << endl;
	cout << ">>> count of ZMuMu (1HLT) yield in the range [" << fMin << ", " << fMax << "]: "  << nZMuMu1HLT << endl;
	cout << ">>> count of ZMuMu (2HLT) yield in the range [" << fMin << ", " << fMax << "]: "  << nZMuMu2HLT << endl;
	funct::RootHistoPdf zPdfMuMuNonIso(*histoZMuMu, fMin, fMax);//imposto le pdf a quella di ZMuMu
	funct::RootHistoPdf zPdfMuTk = zPdfMuMuNonIso;
	funct::RootHistoPdf zPdfMuMu1HLT = zPdfMuMuNonIso;
	funct::RootHistoPdf zPdfMuMu2HLT = zPdfMuMuNonIso;
	funct::RootHistoPdf zPdfMuSa(*histoZMuSaFromMuMu, fMin, fMax);
	zPdfMuMuNonIso.rebin(rebinMuMuNoIso/rebinMuMu);
	zPdfMuTk.rebin(rebinMuTk/rebinMuMu);
	zPdfMuMu1HLT.rebin(rebinMuMu1HLT/rebinMuMu);
	zPdfMuMu2HLT.rebin(rebinMuMu2HLT/rebinMuMu);

	funct::Numerical<2> _2;
	funct::Numerical<1> _1;

	//Efficiency term
	Expr zMuMuEff1HLTTerm = _2 * (effTk ^ _2) *  (effSa ^ _2) * (effIso ^ _2) * effHLT * (_1 - effHLT); 
	Expr zMuMuEff2HLTTerm = (effTk ^ _2) *  (effSa ^ _2) * (effIso ^ _2) * (effHLT ^ _2) ; 
	Expr zMuMuNoIsoEffTerm = (effTk ^ _2) * (effSa ^ _2) * (_1 - (effIso ^ _2)) * (_1 - ((_1 - effHLT)^_2));
	Expr zMuTkEffTerm = _2 * (effTk ^ _2) * effSa * (_1 - effSa) * (effIso ^ _2) * effHLT;
	Expr zMuSaEffTerm = _2 * (effSa ^ _2) * effTk * (_1 - effTk) * (effIso ^ _2) * effHLT;

	Expr zMuMu1HLT = rebinMuMu1HLTConst * zMuMuEff1HLTTerm * yieldZMuMu;
	Expr zMuMu2HLT = rebinMuMu2HLTConst * zMuMuEff2HLTTerm * yieldZMuMu;

	Expr zMuTkBkg = yieldBkgZMuTk * funct::Exponential(lambda)* funct::Polynomial<2>(a0, a1, a2);
	Expr zMuTkBkgScaled = rebinMuTkConst * zMuTkBkg;
	Expr zMuTk = rebinMuTkConst * (zMuTkEffTerm * yieldZMuMu * zPdfMuTk + zMuTkBkg);

	Expr zMuMuNoIsoBkg = yieldBkgZMuMuNotIso * funct::Exponential(alpha)* funct::Polynomial<2>(b0, b1, b2);
	Expr zMuMuNoIsoBkgScaled = rebinMuMuNoIsoConst * zMuMuNoIsoBkg;
	Expr zMuMuNoIso = rebinMuMuNoIsoConst * (zMuMuNoIsoEffTerm * yieldZMuMu * zPdfMuMuNonIso + zMuMuNoIsoBkg);

	Expr zMuSa = rebinMuSaConst * (zMuSaEffTerm * yieldZMuMu * zPdfMuSa); // + (yieldBkgZMuSa * funct::Exponential(beta) )); 

	TH1D histoZCount1HLT("histoZCount1HLT", "", 1, fMin, fMax);
	histoZCount1HLT.Fill(100, nZMuMu1HLT);
	TH1D histoZCount2HLT("histoZCount2HLT", "", 1, fMin, fMax);
	histoZCount2HLT.Fill(100, nZMuMu2HLT);
				       
	ChiSquared chi2(zMuMu1HLT, & histoZCount1HLT,
			zMuMu2HLT, & histoZCount2HLT,
			zMuTk, histoZMuTk, 
			zMuSa, histoZMuSa, 
			zMuMuNoIso,histoZMuMuNoIso,
			fMin, fMax);
	fit::RootMinuit<ChiSquared> minuit(chi2, true);
	commands.add(minuit, yieldZMuMu);
	commands.add(minuit, effTk);
	commands.add(minuit, effSa);
	commands.add(minuit, effIso);
	commands.add(minuit, effHLT);
	commands.add(minuit, yieldBkgZMuTk);
	commands.add(minuit, yieldBkgZMuSa);
	commands.add(minuit, yieldBkgZMuMuNotIso);
	commands.add(minuit, lambda);
	commands.add(minuit, alpha);
	commands.add(minuit, beta);
	commands.add(minuit, a0);
	commands.add(minuit, a1);
	commands.add(minuit, a2);
	commands.add(minuit, b0);
	commands.add(minuit, b1);
	commands.add(minuit, b2);
	commands.run(minuit);
	const unsigned int nPar = 17;//WARNIG: this must be updated manually for now
	ROOT::Math::SMatrix<double, nPar, nPar, ROOT::Math::MatRepSym<double, nPar> > err;
	minuit.getErrorMatrix(err);

	std::cout << "error matrix:" << std::endl;
	for(unsigned int i = 0; i < nPar; ++i) {
	  for(unsigned int j = 0; j < nPar; ++j) {
	    std::cout << err(i, j) << "\t";
	  }
	  std::cout << std::endl;
	} 
	minuit.printFitResults();
	ofstream myfile;
	myfile.open ("fitResult.txt", ios::out | ios::app);
	myfile<<"\n";
        double Y =  minuit.getParameterError("YieldZMuMu");
        double dY = minuit.getParameterError("YieldZMuMu", Y);
        double tk_eff =  minuit.getParameterError("EfficiencyTk");
        double dtk_eff = minuit.getParameterError("EfficiencyTk", tk_eff);
        double sa_eff =  minuit.getParameterError("EfficiencySa");
        double dsa_eff = minuit.getParameterError("EfficiencySa", sa_eff);
        double iso_eff =  minuit.getParameterError("EfficiencyIso");
        double diso_eff = minuit.getParameterError("EfficiencyIso", iso_eff);
        double hlt_eff =  minuit.getParameterError("EfficiencyHLT");
        double dhlt_eff = minuit.getParameterError("EfficiencyHLT",hlt_eff);
	myfile<< Y <<" "<< dY <<" "<< tk_eff <<" "<< dtk_eff <<" "<< sa_eff << " " << dsa_eff << " " << iso_eff <<" " << diso_eff<< " " << hlt_eff << " " << dhlt_eff << " " <<chi2()/(chi2.numberOfBins()- minuit.numberOfFreeParameters());

	myfile.close();

	//Plot
	double s;
	s = 0;
	for(int i = 1; i <= histoZMuMuNoIso->GetNbinsX(); ++i)
	  s += histoZMuMuNoIso->GetBinContent(i);
	histoZMuMuNoIso->SetEntries(s);
	s = 0;
	for(int i = 1; i <= histoZMuMu->GetNbinsX(); ++i)
	  s += histoZMuMu->GetBinContent(i);
	histoZMuMu->SetEntries(s);
	s = 0;
	for(int i = 1; i <= histoZMuMu1HLT->GetNbinsX(); ++i)
	  s += histoZMuMu1HLT->GetBinContent(i);
	histoZMuMu1HLT->SetEntries(s);
	s = 0;
	for(int i = 1; i <= histoZMuMu2HLT->GetNbinsX(); ++i)
	  s += histoZMuMu2HLT->GetBinContent(i);
	histoZMuMu2HLT->SetEntries(s);
	s = 0;
	for(int i = 1; i <= histoZMuTk->GetNbinsX(); ++i)
	  s += histoZMuTk->GetBinContent(i);
	histoZMuTk->SetEntries(s);
	s = 0;
	for(int i = 1; i <= histoZMuSa->GetNbinsX(); ++i)
	  s += histoZMuSa->GetBinContent(i);
	histoZMuSa->SetEntries(s);

	string ZMuMu1HLTPlot = "ZMuMu1HLTFit_" + plot_string;
	root::plot<Expr>(ZMuMu1HLTPlot.c_str(), *histoZMuMu1HLT, zMuMu1HLT, fMin, fMax, 
			  effTk, effSa, effIso, effHLT, yieldZMuMu, 
			  kRed, 2, kDashed, 100, 
			  "Z -> #mu #mu mass", "#mu #mu invariant mass (GeV/c^{2})", 
			  "Events");

	string ZMuMu2HLTPlot = "ZMuMu2HLTFit_" + plot_string;
	root::plot<Expr>(ZMuMu2HLTPlot.c_str(), *histoZMuMu2HLT, zMuMu2HLT, fMin, fMax, 
			  effTk, effSa, effIso, effHLT, yieldZMuMu, 
			  kRed, 2, kDashed, 100, 
			  "Z -> #mu #mu mass", "#mu #mu invariant mass (GeV/c^{2})", 
			  "Events");

	
	string ZMuMuNoIsoPlot = "ZMuMuNoIsoFit_" + plot_string;
	root::plot<Expr>(ZMuMuNoIsoPlot.c_str(), *histoZMuMuNoIso, zMuMuNoIso, fMin, fMax, 
			 effTk, effSa, effIso, effHLT, yieldZMuMu,
			 kRed, 2, kDashed, 100, 
			 "Z -> #mu #mu Not Iso mass", "#mu #mu invariant mass (GeV/c^{2})", 
			 "Events");	
	
	string ZMuTkPlot = "ZMuTkFit_X_" + plot_string;
	root::plot<Expr>(ZMuTkPlot.c_str(), *histoZMuTk, zMuTk, fMin, fMax,
			 effTk, effSa, effIso, effHLT, yieldZMuMu,
			 yieldBkgZMuTk, lambda, a0, a1, a2,
			 kRed, 2, kDashed, 100,
                         "Z -> #mu + (unmatched) track mass", "#mu #mu invariant mass (GeV/c^{2})",
                         "Events");
	ZMuTkPlot = "ZMuTkFit_" + plot_string;
	TF1 funZMuTk = root::tf1_t<sig_tag, Expr>("ZMuTkFunction", zMuTk, fMin, fMax, 
						  effTk, effSa, effIso, effHLT, yieldZMuMu, 
						  yieldBkgZMuTk, lambda, a0, a1, a2);
	funZMuTk.SetLineColor(kRed);
	funZMuTk.SetLineWidth(2);
	funZMuTk.SetLineStyle(kDashed);
	funZMuTk.SetNpx(10000);
	TF1 funZMuTkBkg = root::tf1_t<bkg_tag, Expr>("ZMuTkBack", zMuTkBkgScaled, fMin, fMax, 
						     yieldBkgZMuTk, lambda, a0, a1, a2);
	funZMuTkBkg.SetLineColor(kGreen);
	funZMuTkBkg.SetLineWidth(2);
	funZMuTkBkg.SetLineStyle(kDashed);
	funZMuTkBkg.SetNpx(10000);
	histoZMuTk->SetTitle("Z -> #mu + (unmatched) track mass");
	histoZMuTk->SetXTitle("#mu + (unmatched) track invariant mass (GeV/c^{2})");
	histoZMuTk->SetYTitle("Events");
	TCanvas *canvas = new TCanvas("canvas");
	histoZMuTk->Draw("e");
	funZMuTkBkg.Draw("same");
	funZMuTk.Draw("same");
	canvas->SaveAs(ZMuTkPlot.c_str());
	canvas->SetLogy();
	string logZMuTkPlot = "log_" + ZMuTkPlot;
	canvas->SaveAs(logZMuTkPlot.c_str());
	string ZMuSaPlot = "ZMuSaFit_" + plot_string;
	root::plot<Expr>(ZMuSaPlot.c_str(), *histoZMuSa, zMuSa, fMin, fMax, 
			 effSa, effTk, effIso,
			 yieldZMuMu, yieldBkgZMuSa, 
			 kRed, 2, kDashed, 10000, 
			 "Z -> #mu + (unmatched) standalone mass", 
			 "#mu + (unmatched) standalone invariant mass (GeV/c^{2})", 
			 "Events");
      }
    }
  }
  catch(std::exception& e) {
    cerr << "error: " << e.what() << "\n";
    return 1;
  }
  catch(...) {
    cerr << "Exception of unknown type!\n";
  }

  return 0;
}
void plotScaleFactor(string label) {

  TFile *inf = new TFile(Form("data/ScaleFactors/RazorMADD2015/RazorScaleFactors_%s.root",label.c_str()),"READ");
  inf->ls();
  TH2Poly *ttbarNominal = (TH2Poly*)inf->Get("TTJetsScaleFactors");
  TH2Poly *ttbarUp = (TH2Poly*)inf->Get("TTJetsScaleFactorsUp");
  TH2Poly *ttbarDown = (TH2Poly*)inf->Get("TTJetsScaleFactorsDown");
  TH2Poly *wNominal = (TH2Poly*)inf->Get("WJetsScaleFactors");
  TH2Poly *wUp = (TH2Poly*)inf->Get("WJetsScaleFactorsUp");
  TH2Poly *wDown = (TH2Poly*)inf->Get("WJetsScaleFactorsDown");
  TH2Poly *wInvNominal = (TH2Poly*)inf->Get("WJetsInvScaleFactors");
  TH2Poly *wInvUp = (TH2Poly*)inf->Get("WJetsInvScaleFactorsUp");
  TH2Poly *wInvDown = (TH2Poly*)inf->Get("WJetsInvScaleFactorsDown");
  TH2Poly *GJetInvNominal = (TH2Poly*)inf->Get("GJetsInvScaleFactors");

  TCanvas *cv = 0;
  gStyle->SetPaintTextFormat("4.2f");

  //****************************************************
  //Plot GJetsInv Scale Factors
  //****************************************************
  cv = new TCanvas("cv","cv", 800,600);
  cv->cd();
  gStyle->SetPalette(53);
  GJetInvNominal->Draw("colztexte1");
  cv->SetLogx();
  cv->SetLogy();
  cv->SetRightMargin(0.175);
  cv->SetBottomMargin(0.12);
  GJetInvNominal->GetXaxis()->SetRangeUser(400,4000);
  GJetInvNominal->GetYaxis()->SetRangeUser(0.25,1.5);
  GJetInvNominal->GetZaxis()->SetTitle("Data to MC Correction Factor");
  GJetInvNominal->GetXaxis()->SetTitle("M_{R} [GeV/c^{2}]");
  GJetInvNominal->GetYaxis()->SetTitle("R^{2}");
  GJetInvNominal->SetTitle("");
  GJetInvNominal->GetZaxis()->SetLabelSize(0.05);
  GJetInvNominal->GetZaxis()->SetTitleSize(0.05);
  GJetInvNominal->GetXaxis()->SetLabelSize(0.05);
  GJetInvNominal->GetXaxis()->SetTitleSize(0.05);
  GJetInvNominal->GetXaxis()->SetTitleOffset(0.8);
  GJetInvNominal->GetYaxis()->SetLabelSize(0.05);
  GJetInvNominal->GetYaxis()->SetTitleSize(0.05);
  GJetInvNominal->GetYaxis()->SetTitleOffset(0.8);
  GJetInvNominal->SetStats(false);
  GJetInvNominal->SetMaximum(1.8);
  GJetInvNominal->SetMinimum(0.35);

  lumi_13TeV = "35.9 fb^{-1}";
  writeExtraText = true;
  relPosX = 0.13;
  lumiTextSize = 0.5;
  cmsTextSize = 0.6;
  extraOverCmsTextSize = 0.85;
  CMS_lumi(cv,4,0);
  cv->SaveAs(Form("GJetsInvScaleFactor_CorrectedToMultiJet_%s.png",label.c_str()));
  cv->SaveAs(Form("GJetsInvScaleFactor_CorrectedToMultiJet_%s.pdf",label.c_str()));

  TH2Poly *GJetInvUncertainties = (TH2Poly*)GJetInvNominal->Clone("GJetInvUncertainties");
  for (int i=1; i<GJetInvUncertainties->GetNumberOfBins()+1; ++i) {
    GJetInvUncertainties->SetBinContent(i,100*GJetInvNominal->GetBinError(i) / GJetInvNominal->GetBinContent(i));
    cout << i << " : " << GJetInvNominal->GetBinError(i) << " " << GJetInvNominal->GetBinContent(i) << " : " << GJetInvNominal->GetBinError(i) / GJetInvNominal->GetBinContent(i) << "\n";
  }

  cv = new TCanvas("cv","cv", 800,600);
  gStyle->SetPalette(1);
  gStyle->SetPaintTextFormat("4.0f");
  GJetInvUncertainties->Draw("colztext");
  cv->SetLogx();
  cv->SetLogy();
  cv->SetRightMargin(0.175);
  cv->SetBottomMargin(0.12);
  GJetInvUncertainties->SetMarkerSize(2.0);
  GJetInvUncertainties->SetTitle("");
  GJetInvUncertainties->GetXaxis()->SetTitle("M_{R} [GeV/c^{2}]");
  GJetInvUncertainties->GetYaxis()->SetTitle("R^{2}");
  GJetInvUncertainties->GetXaxis()->SetRangeUser(400,4000);
  GJetInvUncertainties->GetYaxis()->SetRangeUser(0.25,1.5);
  GJetInvUncertainties->GetZaxis()->SetTitle("Systematic Uncertainty (%)");
  GJetInvUncertainties->GetZaxis()->SetLabelSize(0.05);
  GJetInvUncertainties->GetZaxis()->SetTitleSize(0.05);
  GJetInvUncertainties->GetXaxis()->SetLabelSize(0.05);
  GJetInvUncertainties->GetXaxis()->SetTitleSize(0.05);
  GJetInvUncertainties->GetXaxis()->SetTitleOffset(0.8);
  GJetInvUncertainties->GetYaxis()->SetLabelSize(0.05);
  GJetInvUncertainties->GetYaxis()->SetTitleSize(0.05);
  GJetInvUncertainties->GetYaxis()->SetTitleOffset(0.8);
  GJetInvUncertainties->SetStats(false);
  GJetInvUncertainties->SetMaximum(50);
  GJetInvUncertainties->SetMinimum(0.0);
  lumi_13TeV = "35.9 fb^{-1}";
  writeExtraText = true;
  relPosX = 0.13;
  lumiTextSize = 0.5;
  cmsTextSize = 0.6;
  extraOverCmsTextSize = 0.85;
  CMS_lumi(cv,4,0);
  cv->SaveAs(Form("GJetsInvScaleFactorUncertainty_%s.png",label.c_str()));
  cv->SaveAs(Form("GJetsInvScaleFactorUncertainty_%s.pdf",label.c_str()));



  //****************************************************
  //Plot WJetsInv Scale Factors
  //****************************************************
  cv = new TCanvas("cv","cv", 800,600);
  gStyle->SetPalette(53);
  gStyle->SetPaintTextFormat("4.2f");
  wInvNominal->Draw("colztexte1");
  cv->SetLogx();
  cv->SetLogy();
  cv->SetRightMargin(0.175);
  cv->SetBottomMargin(0.12);
  wInvNominal->GetXaxis()->SetRangeUser(300,4000);
  wInvNominal->GetYaxis()->SetRangeUser(0.15,1.5);
  wInvNominal->GetZaxis()->SetTitle("Data to MC Correction Factor");
  wInvNominal->GetZaxis()->SetLabelSize(0.05);
  wInvNominal->GetZaxis()->SetTitleSize(0.05);
  wInvNominal->GetXaxis()->SetLabelSize(0.05);
  wInvNominal->GetXaxis()->SetTitleSize(0.05);
  wInvNominal->GetXaxis()->SetTitleOffset(0.8);
  wInvNominal->GetYaxis()->SetLabelSize(0.05);
  wInvNominal->GetYaxis()->SetTitleSize(0.05);
  wInvNominal->GetYaxis()->SetTitleOffset(0.8);
  wInvNominal->SetStats(false);
  wInvNominal->SetMaximum(1.8);
  wInvNominal->SetMinimum(0.0);


  lumi_13TeV = "35.9 fb^{-1}";
  writeExtraText = true;
  relPosX = 0.13;
  lumiTextSize = 0.5;
  cmsTextSize = 0.6;
  extraOverCmsTextSize = 0.85;
  CMS_lumi(cv,4,0);
  cv->SaveAs(Form("WJetsInvScaleFactor_CorrectedToMultiJet_%s.png",label.c_str()));
  cv->SaveAs(Form("WJetsInvScaleFactor_CorrectedToMultiJet_%s.pdf",label.c_str()));




 //****************************************************
  //Plot WJets Scale Factors
  //****************************************************
  cv = new TCanvas("cv","cv", 800,600);
  gStyle->SetPalette(53);
  wNominal->Draw("colztexte1");
  cv->SetLogx();
  cv->SetLogy();
  cv->SetRightMargin(0.175);
  cv->SetBottomMargin(0.12);
  wNominal->GetXaxis()->SetRangeUser(300,4000);
  wNominal->GetYaxis()->SetRangeUser(0.15,1.5);
  wNominal->GetZaxis()->SetTitle("Data to MC Correction Factor");
  wNominal->GetZaxis()->SetLabelSize(0.05);
  wNominal->GetZaxis()->SetTitleSize(0.05);
  wNominal->GetXaxis()->SetLabelSize(0.05);
  wNominal->GetXaxis()->SetTitleSize(0.05);
  wNominal->GetXaxis()->SetTitleOffset(0.8);
  wNominal->GetYaxis()->SetLabelSize(0.05);
  wNominal->GetYaxis()->SetTitleSize(0.05);
  wNominal->GetYaxis()->SetTitleOffset(0.8);
  wNominal->SetStats(false);
  wNominal->SetMaximum(1.8);
  wNominal->SetMinimum(0.35);

  lumi_13TeV = "35.9 fb^{-1}";
  writeExtraText = true;
  relPosX = 0.13;
  lumiTextSize = 0.5;
  cmsTextSize = 0.6;
  extraOverCmsTextSize = 0.85;
  CMS_lumi(cv,4,0);
  cv->SaveAs(Form("WJetsScaleFactor_CorrectedToMultiJet_%s.png",label.c_str()));
  cv->SaveAs(Form("WJetsScaleFactor_CorrectedToMultiJet_%s.pdf",label.c_str()));




  TH2Poly *WJetsUncertainties = (TH2Poly*)wNominal->Clone("WJetsUncertainties");
  for (int i=1; i<WJetsUncertainties->GetNumberOfBins()+1; ++i) {
    WJetsUncertainties->SetBinContent(i,100*wNominal->GetBinError(i) / wNominal->GetBinContent(i));
  }

  cv = new TCanvas("cv","cv", 800,600);
  gStyle->SetPalette(1);
  gStyle->SetPaintTextFormat("4.0f");
  WJetsUncertainties->Draw("colztext");
  cv->SetLogx();
  cv->SetLogy();
  cv->SetRightMargin(0.175);
  cv->SetBottomMargin(0.12);
  WJetsUncertainties->SetMarkerSize(2.0);
  WJetsUncertainties->SetTitle("");
  WJetsUncertainties->GetXaxis()->SetTitle("M_{R} [GeV/c^{2}]");
  WJetsUncertainties->GetYaxis()->SetTitle("R^{2}");
  WJetsUncertainties->GetXaxis()->SetRangeUser(300,4000);
  WJetsUncertainties->GetYaxis()->SetRangeUser(0.15,1.5);
  WJetsUncertainties->GetZaxis()->SetTitle("Systematic Uncertainty (%)");
  WJetsUncertainties->GetZaxis()->SetLabelSize(0.05);
  WJetsUncertainties->GetZaxis()->SetTitleSize(0.05);
  WJetsUncertainties->GetXaxis()->SetLabelSize(0.05);
  WJetsUncertainties->GetXaxis()->SetTitleSize(0.05);
  WJetsUncertainties->GetXaxis()->SetTitleOffset(0.8);
  WJetsUncertainties->GetYaxis()->SetLabelSize(0.05);
  WJetsUncertainties->GetYaxis()->SetTitleSize(0.05);
  WJetsUncertainties->GetYaxis()->SetTitleOffset(0.8);
  WJetsUncertainties->SetStats(false);
  WJetsUncertainties->SetMaximum(50);
  WJetsUncertainties->SetMinimum(0.0);
  lumi_13TeV = "35.9 fb^{-1}";
  writeExtraText = true;
  relPosX = 0.13;
  lumiTextSize = 0.5;
  cmsTextSize = 0.6;
  extraOverCmsTextSize = 0.85;
  CMS_lumi(cv,4,0);
  cv->SaveAs(Form("WJetsScaleFactorUncertainty_%s.png",label.c_str()));
  cv->SaveAs(Form("WJetsScaleFactorUncertainty_%s.pdf",label.c_str()));




 //****************************************************
  //Plot TTBar Scale Factors
  //****************************************************
  cv = new TCanvas("cv","cv", 800,600);
  gStyle->SetPalette(53);
  gStyle->SetPaintTextFormat("4.2f");
  ttbarNominal->Draw("colztexte1");
  cv->SetLogx();
  cv->SetLogy();
  cv->SetRightMargin(0.175);
  cv->SetBottomMargin(0.12);
  ttbarNominal->GetXaxis()->SetRangeUser(400,4000);
  ttbarNominal->GetYaxis()->SetRangeUser(0.25,1.5);
  ttbarNominal->GetZaxis()->SetTitle("Data to MC Correction Factor");
  ttbarNominal->GetZaxis()->SetLabelSize(0.05);
  ttbarNominal->GetZaxis()->SetTitleSize(0.05);
  ttbarNominal->GetXaxis()->SetLabelSize(0.05);
  ttbarNominal->GetXaxis()->SetTitleSize(0.05);
  ttbarNominal->GetXaxis()->SetTitleOffset(0.8);
  ttbarNominal->GetYaxis()->SetLabelSize(0.05);
  ttbarNominal->GetYaxis()->SetTitleSize(0.05);
  ttbarNominal->GetYaxis()->SetTitleOffset(0.8);
  ttbarNominal->SetStats(false);
  // ttbarNominal->SetMaximum(10000);
  // ttbarNominal->SetMinimum(0.0);
  ttbarNominal->SetMaximum(1.8);
  ttbarNominal->SetMinimum(0.35);

  lumi_13TeV = "35.9 fb^{-1}";
  writeExtraText = true;
  relPosX = 0.13;
  lumiTextSize = 0.5;
  cmsTextSize = 0.6;
  extraOverCmsTextSize = 0.85;
  CMS_lumi(cv,4,0);
  cv->SaveAs(Form("TTBarScaleFactor_CorrectedToMultiJet_%s.png",label.c_str()));
  cv->SaveAs(Form("TTBarScaleFactor_CorrectedToMultiJet_%s.pdf",label.c_str()));





  TH2Poly *TTBarUncertainties = (TH2Poly*)ttbarNominal->Clone("TTBarUncertainties");
  for (int i=1; i<TTBarUncertainties->GetNumberOfBins()+1; ++i) {
    TTBarUncertainties->SetBinContent(i,100*ttbarNominal->GetBinError(i) / ttbarNominal->GetBinContent(i));
  }

  cv = new TCanvas("cv","cv", 800,600);
  gStyle->SetPalette(1);
  gStyle->SetPaintTextFormat("4.0f");
  TTBarUncertainties->Draw("colztext");
  cv->SetLogx();
  cv->SetLogy();
  cv->SetRightMargin(0.175);
  cv->SetBottomMargin(0.12);
  TTBarUncertainties->SetMarkerSize(2.0);
  TTBarUncertainties->SetTitle("");
  TTBarUncertainties->GetXaxis()->SetTitle("M_{R} [GeV/c^{2}]");
  TTBarUncertainties->GetYaxis()->SetTitle("R^{2}");
  TTBarUncertainties->GetXaxis()->SetRangeUser(300,4000);
  TTBarUncertainties->GetYaxis()->SetRangeUser(0.15,1.5);
  TTBarUncertainties->GetZaxis()->SetTitle("Systematic Uncertainty (%)");
  TTBarUncertainties->GetZaxis()->SetLabelSize(0.05);
  TTBarUncertainties->GetZaxis()->SetTitleSize(0.05);
  TTBarUncertainties->GetXaxis()->SetLabelSize(0.05);
  TTBarUncertainties->GetXaxis()->SetTitleSize(0.05);
  TTBarUncertainties->GetXaxis()->SetTitleOffset(0.8);
  TTBarUncertainties->GetYaxis()->SetLabelSize(0.05);
  TTBarUncertainties->GetYaxis()->SetTitleSize(0.05);
  TTBarUncertainties->GetYaxis()->SetTitleOffset(0.8);
  TTBarUncertainties->SetStats(false);
  TTBarUncertainties->SetMaximum(50);
  TTBarUncertainties->SetMinimum(0.0);
  lumi_13TeV = "35.9 fb^{-1}";
  writeExtraText = true;
  relPosX = 0.13;
  lumiTextSize = 0.5;
  cmsTextSize = 0.6;
  extraOverCmsTextSize = 0.85;
  CMS_lumi(cv,4,0);
  cv->SaveAs(Form("TTBarScaleFactorUncertainty_%s.png",label.c_str()));
  cv->SaveAs(Form("TTBarScaleFactorUncertainty_%s.pdf",label.c_str()));



  


}
void plotGJetsScaleFactorSystematics(string label) {

  TFile *inf = new TFile(Form("data/ScaleFactors/RazorMADD2015/RazorScaleFactors_%s.root",label.c_str()),"READ");

  TH2Poly *ttbarNominal = (TH2Poly*)inf->Get("TTJetsScaleFactors");
  TH2Poly *ttbarUp = (TH2Poly*)inf->Get("TTJetsScaleFactorsUp");
  TH2Poly *ttbarDown = (TH2Poly*)inf->Get("TTJetsScaleFactorsDown");
  TH2Poly *wNominal = (TH2Poly*)inf->Get("WJetsScaleFactors");
  TH2Poly *wUp = (TH2Poly*)inf->Get("WJetsScaleFactorsUp");
  TH2Poly *wDown = (TH2Poly*)inf->Get("WJetsScaleFactorsDown");
  TH2Poly *wInvNominal = (TH2Poly*)inf->Get("WJetsInvScaleFactors");
  TH2Poly *wInvUp = (TH2Poly*)inf->Get("WJetsInvScaleFactorsUp");
  TH2Poly *wInvDown = (TH2Poly*)inf->Get("WJetsInvScaleFactorsDown");
  TH2Poly *GJetInvNominal = (TH2Poly*)inf->Get("GJetsInvScaleFactors");

  TCanvas *cv = 0;
  gStyle->SetPaintTextFormat("4.2f");

  //****************************************************
  //Systematic Uncertainty and GJets Down SF Histogram
  //****************************************************
  TH2Poly *GJetsSystematicUnc = (TH2Poly*)GJetInvNominal->Clone("GJetsSystematicUnc");
  TH2Poly *GJetsScaleFactor_Down = (TH2Poly*)GJetInvNominal->Clone("GJetsInvScaleFactors_Down");

  //Get bins of each histogram
  TList *wInvBins = wInvNominal->GetBins();
  TList *gInvBins = GJetInvNominal->GetBins();

  //Loop over GJets bins
  TH2PolyBin *gBin, *wBin; //temp variables to hold bin info
  for (int i = 1; i < GJetsSystematicUnc->GetNumberOfBins()+1; ++i) {

      //Get GJets bin
      gBin = (TH2PolyBin*)gInvBins->At(i-1);

      cout << "In bin " << i << " of GJets histogram" << endl;
      //cout << gBin->GetXMin() << " " << gBin->GetXMax() << " " << gBin->GetYMin() << " " << gBin->GetYMax() << endl;

      //Find out which WJets bin we are in
      int wBinNum = -1;
      for (int j = 1; j < wInvNominal->GetNumberOfBins()+1; ++j) {

          //Get WJets bin
          wBin = (TH2PolyBin*)wInvBins->At(j-1);

          //cout << "In bin " << j << " of WJets histogram" << endl;
          //cout << wBin->GetXMin() << " " << wBin->GetXMax() << " " << wBin->GetYMin() << " " << wBin->GetYMax() << endl;

          //Check if this GJets bin is inside this WJets bin
          if ( gBin->GetXMin() >= wBin->GetXMin() &&
               gBin->GetXMax() <= wBin->GetXMax() &&
               gBin->GetYMin() >= wBin->GetYMin() &&
               gBin->GetYMax() <= wBin->GetYMax() ) {
              cout << "This GJets bin is inside bin " << j << " of WJets histogram" << endl;
              wBinNum = j;
              break;
          }
      }

      double gjet = GJetInvNominal->GetBinContent(i);
      double wjet = wInvNominal->GetBinContent(wBinNum);

      //Set bin content of each histogram
      GJetsSystematicUnc->SetBinContent(i, (gjet - wjet)/gjet );
      GJetsScaleFactor_Down->SetBinContent(i, gjet - (wjet - gjet) );

      cout << "Bin " << i << " : " << gjet << " , " << wjet << " , " <<  gjet - (wjet - gjet) << "\n";
  }

  cv = new TCanvas("cv","cv", 800,600);
  gStyle->SetPalette(1);
  GJetsSystematicUnc->Draw("colztext");
  cv->SetLogx();
  cv->SetLogy();
  cv->SetRightMargin(0.175);
  cv->SetBottomMargin(0.12);
  GJetsSystematicUnc->GetXaxis()->SetRangeUser(400,4000);
  GJetsSystematicUnc->GetYaxis()->SetRangeUser(0.25,1.5);
  GJetsSystematicUnc->GetZaxis()->SetTitle("Systematic Uncertainty");
  GJetsSystematicUnc->GetXaxis()->SetTitle("M_{R} [GeV/c^{2}]");
  GJetsSystematicUnc->GetYaxis()->SetTitle("R^{2}");
  GJetsSystematicUnc->SetTitle("");
  GJetsSystematicUnc->GetZaxis()->SetLabelSize(0.05);
  GJetsSystematicUnc->GetZaxis()->SetTitleSize(0.05);
  GJetsSystematicUnc->GetXaxis()->SetLabelSize(0.05);
  GJetsSystematicUnc->GetXaxis()->SetTitleSize(0.05);
  GJetsSystematicUnc->GetXaxis()->SetTitleOffset(0.8);
  GJetsSystematicUnc->GetYaxis()->SetLabelSize(0.05);
  GJetsSystematicUnc->GetYaxis()->SetTitleSize(0.05);
  GJetsSystematicUnc->GetYaxis()->SetTitleOffset(0.8);
  GJetsSystematicUnc->SetStats(false);
  GJetsSystematicUnc->SetMaximum(1.0);
  GJetsSystematicUnc->SetMinimum(-1.0);

  lumi_13TeV = "35.9 fb^{-1}";
  writeExtraText = true;
  relPosX = 0.13;
  lumiTextSize = 0.5;
  cmsTextSize = 0.6;
  extraOverCmsTextSize = 0.85;
  CMS_lumi(cv,4,0);
  cv->SaveAs(Form("GJetsVsWJetsSystematic_%s.png",label.c_str()));
  cv->SaveAs(Form("GJetsVsWJetsSystematic_%s.pdf",label.c_str()));

  TFile *outf = new TFile(Form("data/ScaleFactors/RazorMADD2015/RazorScaleFactors_%s.root",label.c_str()),"UPDATE");
  outf->WriteTObject(GJetsScaleFactor_Down, GJetsScaleFactor_Down->GetName(), "WRITEDELETE");
  outf->Close();

}
Пример #10
0
void Unfold2(int algo= 3,bool useSpectraFromFile=0, bool useMatrixFromFile=0, int doToy = 0, int isMC = 0,char *spectraFileName = (char*)"pbpb_spectra_akPu3PF.root",double recoJetPtCut = 60,double trackMaxPtCut = 0, int nBayesianIter = 4, int doBjets=0) // algo 2 =akpu2 ; 3 =akpu3 ; 4 =akpu4 ;1 = icpu5
{
  
  gStyle->SetErrorX(0.5);
  gStyle->SetPaintTextFormat("3.2f");
  gStyle->SetOptLogz(1);
  gStyle->SetPadRightMargin(0.13);	
  gStyle->SetOptTitle(0);

	const float pplumi=5.3e9;
        const bool SavePlot=kTRUE;

  TH1::SetDefaultSumw2();
  TH2::SetDefaultSumw2();
  
  // input files
  char *fileNamePP_data = (char*)"/net/hidsk0001/d00/scratch/maoyx/pPb/Btag/CodeMatt/NewFormatV4_bFractionMCTemplate_pppp1_SSVHEat2.0FixCL0_bin_0_40_eta_0_2.root";
  char *fileNamePbPb_data = (char*)"/net/hidsk0001/d00/scratch/maoyx/pPb/Btag/CodeMatt/AltBinningV6_bFractionMCTemplate_ppPbPb1_SSVHEat2.0FixCL0_bin_0_40_eta_0_2.root";
  char *fileNamePP_mc = NULL;
  if(doBjets) fileNamePP_mc = (char*)"/net/hidsk0001/d00/scratch/kjung/histos/ppMC_ppReco_ak3PF_BjetTrig_noIPupperCut.root";
  else fileNamePP_mc = (char*)"/net/hidsk0001/d00/scratch/kjung/histos//ppMC_ppReco_ak3PF_QCDjetTrig_noIPupperCut.root";
  char *fileNamePbPb_mc = NULL;
  if(doBjets)fileNamePbPb_mc = (char*) "/net/hisrv0001/home/mnguyen/scratch/bTaggingOutput/ntuples/PbPbBMC_pt30by3_ipHICalibCentWeight_noTrig.root";
  else fileNamePbPb_mc = (char*) "/net/hisrv0001/home/mnguyen/scratch/bTaggingOutput/ntuples/PbPbQCDMC_pt30by3_ipHICalibCentWeight_noTrig.root";

  // grab ntuples
  TFile *infPbPb_mc = new TFile(fileNamePbPb_mc);
  TFile *infPP_mc = new TFile(fileNamePP_mc);


  // Output file
  TFile *pbpb_Unfo;
  if (isMC) pbpb_Unfo = new TFile(Form("pbpb_Unfo_%s_MC.root",algoName[algo]),"RECREATE");
  else pbpb_Unfo  = new TFile(Form("pbpb_Unfo_%s_jtpt%.0f_trk%.0f.root",algoName[algo],recoJetPtCut,trackMaxPtCut),"RECREATE");
  // Histograms used by RooUnfold
  UnfoldingHistos *uhist[nbins_cent+1];
		
  // Initialize Histograms   
	
  for (int i=0;i<=nbins_cent;i++) uhist[i] = new UnfoldingHistos(i);
	
  // Initialize reweighting functions
  
  TCut dataSelection;
  TCut dataSelectionPP;
  TCut TriggerSelectionPP;
  TCut TriggerSelectionPbPb80;

  if(doBjets)dataSelection = "weight*(abs(refparton_flavorForB)==5&&abs(jteta)<2)";
  else dataSelection = "weight*(abs(jteta)<2)";
  

  if (isMC) cout<<"This is a MC closure test"<<endl;
  else cout<< "This is a data analysis"<<endl;    		     
	     	
  // Setup jet data branches, basically the jet tree branches are assigned to this object when we loop over the events
	
  JetDataPbPb *dataPbPb   = new JetDataPbPb(fileNamePbPb_mc,(char*)"nt"); // PbPb data	
  JetDataPP *dataPP = new JetDataPP(fileNamePP_mc,(char*)"nt");	// pp data
	
  TFile *fSpectra(0);		
  if (useSpectraFromFile||useMatrixFromFile){
    fSpectra = new TFile(spectraFileName,"read");
  }
  
  // Come back to the output file dir
  pbpb_Unfo->cd();

  // Get Jet spectra from data file
  cout <<"Reading data..."<<endl;

  // This doesn't seem to be relevant for the moment -Matt
  /*	

  TTree *tPbPbJet = (TTree*)infPbPb_mc->Get("nt");
  TTree *tPPJet  = (TTree*)infPP_mc->Get("nt");


  TCanvas * cInput = new TCanvas("cInput","Input",800,400);
  cInput->Divide(2,1);
		
  cout <<"Spectra..."<<endl;	
	
  for (int i=0;i<=nbins_cent;i++){
    cout <<nbins_cent<<endl;
    TCut centCut = Form("bin<%.0f&&bin>=%.0f",boundaries_cent[i+1],boundaries_cent[i]);
    if (useSpectraFromFile) {
      uhist[i]->hMeas = (TH1F*)fSpectra->Get(Form("hMeas_cent%d",i));
    } else {
      if (!isMC) {
	tPbPbJet->Project(Form("hMeas_cent%d",i),"jtptB", dataSelection&&centCut&&TriggerSelectionPbPb80);
      }   
    }
		
    if (useMatrixFromFile) {
      cout <<"Matrix"<<endl;
      uhist[i]->hMatrixFit = (TH2F*) fSpectra->Get(Form("hMatrixFit_cent%d",i));
      uhist[i]->hMeasMatch = (TH1F*)((TH2F*) fSpectra->Get(Form("hMatrixFit_cent%d",i)))->ProjectionY();
      uhist[i]->hMeasMatch->Divide(uhist[i]->hMeas);
    } else {
      uhist[i]->hMeasMatch = 0;
    }
    uhist[i]->hMeas->Draw();
  }

  if (!isMC) tPPJet->Project(Form("hMeas_cent%d",nbins_cent),"jtpt",dataSelectionPP&&TriggerSelectionPP);
  */
  cout <<"MC..."<<endl;	
  
  TH1F *hCent = new TH1F("hCent","",nbins_cent,boundaries_cent);
 
		
  // Fill PbPb MC   
  if (!useMatrixFromFile) {
    for (Long64_t jentry2=0; jentry2<dataPbPb->tJet->GetEntries();jentry2++) {
      dataPbPb->tJet->GetEntry(jentry2);
      
      // change when we switch to centrality binning
      int cBin = 0;
      
      //int cBin = hCent->FindBin(dataPbPb->bin)-1;
      /*
	if (cBin>=nbins_cent) continue;
	if (cBin==-1) continue;
      */
      
      if ( dataPbPb->refpt  < 0. ) continue;
      if ( dataPbPb->jteta  > 2. || dataPbPb->jteta < -2. ) continue;
      if ( dataPbPb->refpt<0) dataPbPb->refpt=0;
      if (doBjets && fabs(dataPbPb->refparton_flavorForB)!=5) continue;
      if (doBjets&& dataPbPb->discr_ssvHighEff<2) continue;
      if (doBjets && dataPbPb->jtptB < recoJetPtCut) continue;
      if (!doBjets && dataPbPb->jtptA < recoJetPtCut) continue;
      //if ( dataPbPb->isTrig <1) continue;
      
      if(!doBjets)if(dataPbPb->refpt < 50 && dataPbPb->jtptA>120) continue;
      if(doBjets)if(dataPbPb->refpt < 50 && dataPbPb->jtptB>120) continue;

      if (!isMC||jentry2 % 2 == 1) {
	if(doBjets)uhist[cBin]-> hMatrix->Fill(dataPbPb->refpt,dataPbPb->jtptB,dataPbPb->weight);
	else uhist[cBin]-> hMatrix->Fill(dataPbPb->refpt,dataPbPb->jtptA,dataPbPb->weight);
      }	  
      if (jentry2 % 2 == 0) {
	uhist[cBin]-> hGen->Fill(dataPbPb->refpt,dataPbPb->weight);   
	if(doBjets)uhist[cBin]-> hMeas->Fill(dataPbPb->jtptB,dataPbPb->weight);  	 
	else uhist[cBin]-> hMeas->Fill(dataPbPb->jtptA,dataPbPb->weight);  	 
	//uhist[cBin]-> hMeasJECSys->Fill(dataPbPb->jtpt*(1.+0.02/nbins_cent*(nbins_cent-i)),dataPbPb->weight); 
	// FIXME!!!!!!  i is supposed to be a loop over centrality !!!!
	if(doBjets)uhist[cBin]-> hMeasJECSys->Fill(dataPbPb->jtptB*(1.+0.02/nbins_cent*(nbins_cent-0)),dataPbPb->weight); 
	else uhist[cBin]-> hMeasJECSys->Fill(dataPbPb->jtptA*(1.+0.02/nbins_cent*(nbins_cent-0)),dataPbPb->weight); 
      }
    }

    //pp will just fill the last index of the centrality array

    // fill pp MC
    for (Long64_t jentry2=0; jentry2<dataPP->tJet->GetEntries();jentry2++) {
      dataPP->tJet->GetEntry(jentry2);
      
      if ( dataPP->refpt<0) continue;
      if ( dataPP->jteta  > 2. || dataPP->jteta < -2. ) continue;
      if ( dataPP->refpt<0) dataPP->refpt=0;
      if ( doBjets && fabs(dataPP->refparton_flavorForB)!=5) continue;
      if ( doBjets && dataPP->discr_ssvHighEff<2) continue;
      if ( dataPP->jtpt < recoJetPtCut) continue;
      
      if (!isMC||jentry2 % 2 == 1) {
	uhist[nbins_cent]-> hMatrix->Fill(dataPP->refpt,dataPP->jtpt,dataPP->weight);
      }	  
      if (jentry2 % 2 == 0) {
	uhist[nbins_cent]-> hGen->Fill(dataPP->refpt,dataPP->weight);   
	uhist[nbins_cent]-> hMeas->Fill(dataPP->jtpt,dataPP->weight); 
      }           
    }
  }

	

  cout <<"Response Matrix..."<<endl;
	
  TCanvas * cMatrix = new TCanvas("cMatrix","Matrix",800,400);
  cMatrix->Divide(2,1);

  for (int i=0;i<=nbins_cent;i++){
    cMatrix->cd(i+1);
    if (!useMatrixFromFile) {
      TF1 *f = new TF1("f","[0]*pow(x+[2],[1])");
      f->SetParameters(1e10,-8.8,40);
      for (int y=1;y<=uhist[i]->hMatrix->GetNbinsY();y++) {
	double sum=0;
	for (int x=1;x<=uhist[i]->hMatrix->GetNbinsX();x++) {
	  if (uhist[i]->hMatrix->GetBinContent(x,y)<=1*uhist[i]->hMatrix->GetBinError(x,y)) {
	    uhist[i]->hMatrix->SetBinContent(x,y,0);
	    uhist[i]->hMatrix->SetBinError(x,y,0);
	  }
	  sum+=uhist[i]->hMatrix->GetBinContent(x,y);
	}
				
	for (int x=1;x<=uhist[i]->hMatrix->GetNbinsX();x++) {	   
	  double ratio = 1;
	  uhist[i]->hMatrix->SetBinContent(x,y,uhist[i]->hMatrix->GetBinContent(x,y)*ratio);
	  uhist[i]->hMatrix->SetBinError(x,y,uhist[i]->hMatrix->GetBinError(x,y)*ratio);
	}
      }
    }
    uhist[i]->hResponse = (TH2F*)uhist[i]->hMatrix->Clone(Form("hResponse_cent%d",i));
    for (int y=1;y<=uhist[i]->hResponse->GetNbinsY();y++) {
      double sum=0;
      for (int x=1;x<=uhist[i]->hResponse->GetNbinsX();x++) {
	if (uhist[i]->hResponse->GetBinContent(x,y)<=0*uhist[i]->hResponse->GetBinError(x,y)) {
	  uhist[i]->hResponse->SetBinContent(x,y,0);
	  uhist[i]->hResponse->SetBinError(x,y,0);
	}
	sum+=uhist[i]->hResponse->GetBinContent(x,y);
      }
			
      for (int x=1;x<=uhist[i]->hResponse->GetNbinsX();x++) {  	
	if (sum==0) continue;
	double ratio = uhist[i]->hMeas->GetBinContent(y)/sum;
	if (uhist[i]->hMeas->GetBinContent(y)==0) ratio = 1e-100/sum;
      }
    }
		
    uhist[i]->hResponseNorm = (TH2F*)uhist[i]->hMatrix->Clone(Form("hResponseNorm_cent%d",i));
    for (int x=1;x<=uhist[i]->hResponseNorm->GetNbinsX();x++) {
      double sum=0;
      for (int y=1;y<=uhist[i]->hResponseNorm->GetNbinsY();y++) {
	if (uhist[i]->hResponseNorm->GetBinContent(x,y)<=0*uhist[i]->hResponseNorm->GetBinError(x,y)) {
	  uhist[i]->hResponseNorm->SetBinContent(x,y,0);
	  uhist[i]->hResponseNorm->SetBinError(x,y,0);
	}
	sum+=uhist[i]->hResponseNorm->GetBinContent(x,y);
      }
			
      for (int y=1;y<=uhist[i]->hResponseNorm->GetNbinsY();y++) {  	
	if (sum==0) continue;
	double ratio = 1./sum;
	uhist[i]->hResponseNorm->SetBinContent(x,y,uhist[i]->hResponseNorm->GetBinContent(x,y)*ratio);
	uhist[i]->hResponseNorm->SetBinError(x,y,uhist[i]->hResponseNorm->GetBinError(x,y)*ratio);
      }
    }
		
    uhist[i]->hResponse->Draw("col");
		
    if (!useMatrixFromFile) uhist[i]->hMatrixFit = uhist[i]->hMatrix;
    uhist[i]->hMatrixFit->SetName(Form("hMatrixFit_cent%d",i));
  }

   cMatrix->Update();
  if (isMC==0) {
    // Use measured histogram from Matt & Kurt's file
	   
    // PbPb file:

    TFile *infMatt = new TFile(fileNamePbPb_data);
    TH1F *hMattPbPb = NULL;
    if(doBjets) hMattPbPb = (TH1F*) infMatt->Get("hRawBData");
    else hMattPbPb = (TH1F*) infMatt->Get("hIncJetsData");
    divideBinWidth(hMattPbPb);
           
    // Need to match the binning carefully, please double check whenever you change the binning
    for (int i=1;i<=hMattPbPb->GetNbinsX();i++)
      {
	uhist[0]->hMeas->SetBinContent(i+uhist[0]->hMeas->FindBin(61)-1,hMattPbPb->GetBinContent(i));  
	uhist[0]->hMeas->SetBinError(i+uhist[0]->hMeas->FindBin(61)-1,hMattPbPb->GetBinError(i));  
      }

    // pp file:
    // The file name needs to be updated!!!!!
    TFile *infMattPP = new TFile(fileNamePP_data);
    TH1F *hMattPP = NULL;
    if(doBjets)hMattPP = (TH1F*) infMattPP->Get("hRawBData");
    else hMattPP = (TH1F*) infMattPP->Get("hIncJetsData");
    divideBinWidth(hMattPP);
	   
    // Need to match the binning carefully, please double check whenever you change the binning
    for (int i=1;i<=hMattPP->GetNbinsX();i++)
      {
	uhist[nbins_cent]->hMeas->SetBinContent(i+uhist[nbins_cent]->hMeas->FindBin(61)-1,hMattPP->GetBinContent(i));  
	uhist[nbins_cent]->hMeas->SetBinError(i+uhist[nbins_cent]->hMeas->FindBin(61)-1,hMattPP->GetBinError(i));  
      }

  }

 
  pbpb_Unfo->cd();
	
  cout << "==================================== UNFOLD ===================================" << endl;
	
  //char chmet[100]; 
	
  // ======================= Reconstructed pp and PbPb spectra =========================================================
  TCanvas * cPbPb = new TCanvas("cPbPb","Comparison",1200,600);
  cPbPb->Divide(2,1); 
  cPbPb->cd(1);
	
	
  for (int i=0;i<=nbins_cent;i++) {
    cPbPb->cd(i+1)->SetLogy();   
    // Do Bin-by-bin
    TH1F *hBinByBinCorRaw = (TH1F*)uhist[i]->hResponse->ProjectionY(); 
    TH1F *hMCGen           = (TH1F*)uhist[i]->hResponse->ProjectionX(); // gen
    hBinByBinCorRaw->Divide(hMCGen);
    TF1 *f = new TF1("f","[0]+[1]*x");
    hBinByBinCorRaw->Fit("f","LL ","",90,300);
    TH1F* hBinByBinCor = (TH1F*)hBinByBinCorRaw->Clone();//functionHist(f,hBinByBinCorRaw,Form("hBinByBinCor_cent%d",i));
    delete hBinByBinCorRaw;
    delete hMCGen;
    uhist[i]->hRecoBinByBin = (TH1F*) uhist[i]->hMeas->Clone(Form("hRecoBinByBin_cent%d",i));
    uhist[i]->hRecoBinByBin->Divide(hBinByBinCor);
		
    // Do unfolding
    //if (isMC) uhist[i]->hMeas = (TH1F*)uhist[i]->hMatrix->ProjectionY()->Clone(Form("hMeas_cent%d",i));
    prior myPrior(uhist[i]->hMatrixFit,uhist[i]->hMeas,0);
  //  myPrior.unfold(uhist[i]->hMeas,1);
    myPrior.unfold(uhist[i]->hMeas,nBayesianIter);
    TH1F *hPrior;//=(TH1F*) functionHist(fPow,uhist[i]->hMeas,Form("hPrior_cent%d",i));
    hPrior = (TH1F*)uhist[i]->hGen->Clone("hPrior");//(TH1F*)uhist[i]->hMeas->Clone(Form("hPrior_cent%d",i));
    removeZero(hPrior);
		
    bayesianUnfold myUnfoldingJECSys(uhist[i]->hMatrixFit,hPrior,0);
    myUnfoldingJECSys.unfold(uhist[i]->hMeasJECSys,nBayesianIter);
    bayesianUnfold myUnfoldingSmearSys(uhist[i]->hMatrixFit,hPrior,0);
    myUnfoldingSmearSys.unfold(uhist[i]->hMeasSmearSys,nBayesianIter);
    bayesianUnfold myUnfolding(uhist[i]->hMatrixFit,myPrior.hPrior,0);
    myUnfolding.unfold(uhist[i]->hMeas,nBayesianIter);
    cout <<"Unfolding bin "<<i<<endl;

    // Iteration Systematics
    for (int j=2;j<=40;j++)
      {
	bayesianUnfold myUnfoldingSys(uhist[i]->hMatrixFit,hPrior,0);
	myUnfoldingSys.unfold(uhist[i]->hMeas,j);
	uhist[i]->hRecoIterSys[j]  = (TH1F*) myUnfoldingSys.hPrior->Clone(Form("hRecoRAA_IterSys%d_cent%d",j,i));
      }
		
		
    uhist[i]->hReco         = (TH1F*) uhist[i]->hRecoIterSys[nBayesianIter]->Clone(Form("Unfolded_cent%i",i));
    uhist[i]->hRecoJECSys   = (TH1F*) myUnfoldingJECSys.hPrior->Clone(Form("UnfoldedJeCSys_cent%i",i));
    uhist[i]->hRecoSmearSys   = (TH1F*) myUnfoldingSmearSys.hPrior->Clone(Form("UnfoldedSmearSys_cent%i",i));
    uhist[i]->hRecoBinByBin->SetName(Form("UnfoldedBinByBin_cent%i",i));
		
    if (doToy) {
      TCanvas *cToy = new TCanvas("cToy","toy",600,600);
      cToy->cd();
      int nExp=1000;
      TH1F *hTmp[nbins_truth+1];
      TH1F *hTmp2[nbins_truth+1];
      for (int j=1;j<=nbins_truth;j++) {
	hTmp[j] = new TH1F(Form("hTmp%d",j),"",200,0,10.+uhist[i]->hReco->GetBinContent(j)*2);
	hTmp2[j] = new TH1F(Form("hTmp2%d",j),"",200,0,10.+uhist[i]->hRecoBinByBin->GetBinContent(j)*2);
      }
      for (int exp =0; exp<nExp; exp++) {
	TH1F *hToy = (TH1F*)uhist[i]->hMeas->Clone();   
	TH2F *hMatrixToy = (TH2F*)uhist[i]->hMatrixFit->Clone();
	hToy->SetName("hToy");
	if (exp%100==0) cout <<"Pseudo-experiment "<<exp<<endl;
	for (int j=1;j<=hToy->GetNbinsX();j++) {
	  double value = gRandom->Poisson(uhist[i]->hMeas->GetBinContent(j));
	  hToy->SetBinContent(j,value);
	}
				
	for (int j=1;j<=hMatrixToy->GetNbinsX();j++) {
	  for (int k=1;k<=hMatrixToy->GetNbinsY();k++) {
	    double value = gRandom->Gaus(uhist[i]->hMatrixFit->GetBinContent(j,k),uhist[i]->hMatrixFit->GetBinError(j,k));
	    hMatrixToy->SetBinContent(j,k,value);
	  }
	}

	prior myPriorToy(hMatrixToy,hToy,0.0);
	myPriorToy.unfold(hToy,1);
	bayesianUnfold myUnfoldingToy(hMatrixToy,myPriorToy.hPrior,0.0);
	myUnfoldingToy.unfold(hToy,nBayesianIter);
	TH1F *hRecoTmp = (TH1F*) myUnfoldingToy.hPrior->Clone();
				
	for (int j=1;j<=hRecoTmp->GetNbinsX();j++) {
	  hTmp[j]->Fill(hRecoTmp->GetBinContent(j));
	}
	delete hToy;
	delete hRecoTmp;
	delete hMatrixToy;
      }
      TF1 *fGaus = new TF1("fGaus","[0]*TMath::Gaus(x,[1],[2])");
      for (int j=1;j<=nbins_truth;j++)
	{
	  f->SetParameters(hTmp[j]->GetMaximum(),hTmp[j]->GetMean(),hTmp[j]->GetRMS());
				
	  if (hTmp[j]->GetMean()>0) {
	    hTmp[j]->Fit(fGaus,"LL Q ");
	    hTmp[j]->Fit(fGaus,"LL Q ");
	    uhist[i]->hReco->SetBinError(j,f->GetParameter(2));
	  }	       
	  f->SetParameters(hTmp2[j]->GetMaximum(),hTmp2[j]->GetMean(),hTmp2[j]->GetRMS());
	  if (hTmp2[j]->GetMean()>0) {
	    hTmp2[j]->Fit(fGaus,"LL Q ");
	    hTmp2[j]->Fit(fGaus,"LL Q ");
	    uhist[i]->hRecoBinByBin->SetBinError(j,f->GetParameter(2));
	  }	       
	  delete hTmp[j];
	  delete hTmp2[j];
	}
      cPbPb->cd(i+1);
    }

    uhist[i]->hMeas->SetMarkerStyle(20);
    uhist[i]->hMeas->SetMarkerColor(1);
    uhist[i]->hReco->SetMarkerStyle(24);
    uhist[i]->hReco->SetMarkerColor(2);
    uhist[i]->hReco->SetLineColor(2);
    uhist[i]->hReco->SetName(Form("hReco_cent%d",i));
    uhist[i]->hReco->Draw("");    
    makeHistTitle(uhist[i]->hReco,"","Jet p_{T} (GeV/c)","dN_{jets} / dp_{T}");
    uhist[i]->hReco->GetYaxis()->SetTitleOffset(1.3);
    uhist[i]->hReco->GetXaxis()->SetTitleOffset(1.2);
    uhist[i]->hGen->SetLineWidth(1);
    uhist[i]->hGen->SetLineColor(1);
    if(isMC)uhist[i]->hGen->Draw("hist same");
    uhist[i]->hReco->Draw("same");    
    uhist[i]->hRecoBinByBin->SetMarkerStyle(28);
    uhist[i]->hRecoBinByBin->SetMarkerColor(4);
    uhist[i]->hRecoBinByBin->SetLineColor(4);
    uhist[i]->hRecoBinByBin->Draw("same");    
    uhist[i]->hReco->SetAxisRange(60,300);
    TH1F *hReproduced = (TH1F*)myUnfolding.hReproduced->Clone(Form("hReproduced_cent%d",i));
    hReproduced->SetMarkerColor(4);
    hReproduced->SetMarkerStyle(24);
    uhist[i]->hMeas->Draw("same");    
		
    TLegend *leg = new TLegend(0.5,0.5,0.9,0.9);
    leg->SetBorderSize(0);
    leg->SetFillStyle(0);
    leg->AddEntry(uhist[i]->hMeas,"Measured","pl");
    leg->AddEntry(uhist[i]->hReco,"Bayesian unfolded","pl");
    leg->AddEntry(uhist[i]->hRecoBinByBin,"Bin-by-bin unfolded","pl");
    if(isMC)leg->AddEntry(uhist[i]->hGen,"Generator level truth","l");
    leg->Draw();
  }	     
  
  cPbPb->Update();

 // ======================= Unfolding closure in MC =========================================================
  TCanvas * cRatio = new TCanvas("cRatio","Ratio",1200,600);
    TH1F * hReco[nbins_cent+1];
    TH1F * hRecoBinByBin[nbins_cent+1];
    TH1F * hMeas[nbins_cent+1];
    TH1F * hGen[nbins_cent+1];
    TLegend *leg[nbins_cent+1];
  TLine *line = new TLine(60,1,250,1);
	line->SetLineStyle(2);
	line->SetLineWidth(2);
 
    for (int i=0;i<=nbins_cent;i++) {
        hReco[i]          = (TH1F*)uhist[i]->hReco->Clone(Form("hReco_Cen%d", i));
        hRecoBinByBin[i]          = (TH1F*)uhist[i]->hRecoBinByBin->Clone(Form("hRecoBinByBin_Cen%d", i));
        hMeas[i]          = (TH1F*)uhist[i]->hMeas->Clone(Form("hMeas_Cen%d", i));
        if(isMC) hGen[i]          = (TH1F*)uhist[i]->hGen->Clone(Form("hGen_Cen%d", i));
    }
    
  if(isMC){
    cRatio->Divide(2,1);
      for (int i=0;i<=nbins_cent;i++) {
          
          hMeas[i]->Divide(hGen[i]);
          hRecoBinByBin[i]->Divide(hGen[i]);
          hReco[i]->Divide(hGen[i]);
          cRatio->cd(i+1);

		//hRecoPP->SetAxisRange(90,300,"X");
		hReco[i]->SetAxisRange(0,2,"Y");
		hReco[i]->SetMarkerStyle(24);
		hReco[i] ->SetLineColor(2);
		hReco[i] ->SetMarkerColor(2);
		hMeas[i]->SetMarkerStyle(20);
		hMeas[i]->SetLineColor(1);
		hMeas[i]->SetMarkerColor(1);
		hRecoBinByBin[i]->SetMarkerStyle(28);
		hRecoBinByBin[i]->SetLineColor(4);
		hRecoBinByBin[i]->SetMarkerColor(4);
		
		makeHistTitle(hReco[i],"","Jet p_{T} (GeV/c)","Reco / Truth");
		hReco[i]->GetYaxis()->SetTitleOffset(1.4);
		hReco[i]->GetXaxis()->SetTitleOffset(1.2);
		hReco[i]->Draw("");
		hRecoBinByBin[i]->Draw("same");
		hMeas[i]->Draw("same");
		line->Draw();
		
		leg[i] = myLegend(0.52,0.65,0.85,0.9);
		leg[i]->AddEntry(hReco[i],"Bayesian","pl");
		leg[i]->AddEntry(hRecoBinByBin[i],"Bin-by-bin","pl");
		leg[i]->AddEntry(hMeas[i],"no unfolding","pl");
		leg[i]->Draw();
		putCMSPrel(0.2,0.83,0.06);
		drawText("Anti-k_{T} Particle Flow Jets   R = 0.3",0.2,0.23,20);
		drawText("CMS Simulation",0.6,0.4,22);
		drawText("| #eta | <2 ",0.6,0.31,22);
      }
  }
  else {
      hMeas[nbins_cent]->Scale(1./CorFac[6]/5.3e9);
      hRecoBinByBin[nbins_cent]->Scale(1./CorFac[6]/5.3e9);
      hReco[nbins_cent]->Scale(1./CorFac[6]/5.3e9);
      cRatio->cd(1);
      
      for (int i=0;i<nbins_cent;i++) {
          hMeas[i]            ->Scale(1./CorFac[i]/1.0908e9/TAA[i]);
          hRecoBinByBin[i]            ->Scale(1./CorFac[i]/1.0908e9/TAA[i]);
          hReco[i]            ->Scale(1./CorFac[i]/1.0908e9/TAA[i]);
          
          hMeas[i]->Divide(hMeas[nbins_cent]);
          hRecoBinByBin[i]->Divide(hRecoBinByBin[nbins_cent]);
          hReco[i]->Divide(hReco[nbins_cent]);
          
          hReco[i]->SetAxisRange(0,2,"Y");
          hReco[i]->SetMarkerStyle(24);
          hReco[i] ->SetLineColor(2);
          hReco[i] ->SetMarkerColor(2);
          hMeas[i]->SetMarkerStyle(20);
          hMeas[i]->SetLineColor(1);
          hMeas[i]->SetMarkerColor(1);
          hRecoBinByBin[i]->SetMarkerStyle(28);
          hRecoBinByBin[i]->SetLineColor(4);
          hRecoBinByBin[i]->SetMarkerColor(4);
         // if(i==0){
          makeHistTitle(hReco[i],"","Jet p_{T} (GeV/c)","Spectra Ratio");
          hReco[i]->GetYaxis()->SetTitleOffset(1.4);
          hReco[i]->GetXaxis()->SetTitleOffset(1.2);
          hReco[i]->Draw("");
              leg[i] = myLegend(0.52,0.65,0.85,0.9);
              leg[i]->AddEntry(hReco[i],"Bayesian","pl");
              leg[i]->AddEntry(hRecoBinByBin[i],"Bin-by-bin","pl");
              leg[i]->AddEntry(hMeas[i],"no unfolding","pl");
              leg[i]->Draw();

       //   }
       //   else {
          hReco[i]->Draw("same");
          hRecoBinByBin[i]->Draw("same");
          hMeas[i]->Draw("same");
      //    }
       } 
         line->Draw();
          
          putCMSPrel(0.2,0.83,0.06);
          drawText(Form("#intL dt = %.f #mub^{-1}",150.),0.2,0.78,22);
          drawText("Anti-k_{T} Particle Flow Jets   R = 0.3",0.2,0.73,20);
          drawText("| #eta | <2 ",0.6,0.69,22);
  
  }
    cRatio->Update();

  pbpb_Unfo->Write();

  SysData systematics;

  // Iteration systematics
  TCanvas *cIterSys = new TCanvas("cIterSys","IterSys",1200,600);
  cIterSys->Divide(2,1);
  cIterSys->cd(2);
  TH1F *hRecoIterSysPP[100];
  TH1F *hRebinPP_tmp         = rebin(uhist[nbins_cent]->hReco, (char*)"hRebinPP_tmp");
  TLegend *legBayesianIterPP = myLegend(0.4,0.7,0.9,0.9);
  legBayesianIterPP->AddEntry("","PP","");
         
  for (int j=2;j<7;j++) {
    hRecoIterSysPP[j] = rebin(uhist[nbins_cent]->hRecoIterSys[j],Form("hRecoIterSysPP_IterSys%d",j));
    hRecoIterSysPP[j]->SetLineColor(colorCode[j-2]);
    hRecoIterSysPP[j]->SetMarkerColor(colorCode[j-2]);
    hRecoIterSysPP[j]->Divide(hRebinPP_tmp);
    if (j==2){
    //  makeHistTitle(hRecoIterSysPP[j],(char*)"",(char*)"Jet p_{T} (GeV/c)",(char*)"Ratio (Unfolded / Nominal)");
      makeHistTitle(hRecoIterSysPP[j],"","Jet p_{T} (GeV/c)","Ratio (Unfolded / Nominal)");
      hRecoIterSysPP[j]->SetTitleOffset(1.3,"Y");
      hRecoIterSysPP[j]->SetTitleOffset(1.2,"X");
      hRecoIterSysPP[j]->SetAxisRange(0,2,"Y");
      hRecoIterSysPP[j]->Draw(); 
    } else {
      hRecoIterSysPP[j]->Draw("same");
    }
         
    checkMaximumSys(systematics.hSysIter[nbins_cent],hRecoIterSysPP[j],0,1.1);
    legBayesianIterPP->AddEntry(hRecoIterSysPP[j],Form("Iteration %d",j),"pl");     
  }
      
  legBayesianIterPP->Draw();
  line->Draw();
  drawEnvelope(systematics.hSysIter[nbins_cent],(char*)"hist same");


  cIterSys->cd(1);
  TH1F *hRecoIterSysPbPb[100];
  TH1F *hRebinPbPb_tmp         = rebin(uhist[0]->hReco, (char*)"hRebinPbPb_tmp");
  TLegend *legBayesianIterPbPb = myLegend(0.4,0.7,0.9,0.9);
  legBayesianIterPbPb->AddEntry("","PbPb","");
  for (int j=2;j<7;j++) {
    hRecoIterSysPbPb[j] = rebin(uhist[0]->hRecoIterSys[j],Form("hRecoIterSysPbPb_IterSys%d",j));
    hRecoIterSysPbPb[j]->SetLineColor(colorCode[j-2]);
    hRecoIterSysPbPb[j]->SetMarkerColor(colorCode[j-2]);
    hRecoIterSysPbPb[j]->Divide(hRebinPbPb_tmp);
    if (j==2){
    //  makeHistTitle(hRecoIterSysPbPb[j],(char*)"",(char*)"Jet p_{T} (GeV/c)",(char*)"Ratio (Unfolded / Nominal)");
      makeHistTitle(hRecoIterSysPbPb[j],"","Jet p_{T} (GeV/c)","Ratio (Unfolded / Nominal)");
      hRecoIterSysPbPb[j]->SetTitleOffset(1.3,"Y");
      hRecoIterSysPbPb[j]->SetTitleOffset(1.2,"X");
      hRecoIterSysPbPb[j]->SetAxisRange(0,2,"Y");
      hRecoIterSysPbPb[j]->Draw(); 
    } else {
      hRecoIterSysPbPb[j]->Draw("same");
    }
         
    checkMaximumSys(systematics.hSysIter[0],hRecoIterSysPbPb[j],0,1.1);
    legBayesianIterPbPb->AddEntry(hRecoIterSysPbPb[j],Form("Iteration %d",j),"pl");     
  }
  legBayesianIterPbPb->Draw();
  line->Draw();
  drawEnvelope(systematics.hSysIter[0],(char*)"hist same");
  
  cIterSys->Update();
  
  TString data ;
  if(isMC) data="MC";
  else data="Data";
 TString anaType ;
  if(doBjets) anaType="Bjet";
  else anaType="Inclusive";
  
  if(SavePlot){
    cMatrix->SaveAs(Form("plots/%s%s%sResponseMatrix.gif", data.Data(), anaType.Data(), algoName[algo]));
    cPbPb->SaveAs(Form("plots/%s%s%sJetSpectra.gif",  data.Data(), anaType.Data(), algoName[algo]));
    cRatio->SaveAs(Form("plots/%s%s%sJetRatio.gif",  data.Data(), anaType.Data(), algoName[algo]));
    cIterSys->SaveAs(Form("plots/%s%s%sIterationSys.gif",  data.Data(), anaType.Data(), algoName[algo]));
}
}
Пример #11
0
void Draw(const char* pairName, const char* canvasName, std::vector<CorrelationFunction> &plots, bool isIdentical)
{
	unsigned int i, k;
	int canvasNumber1 = -1, canvasNumber2 = 0;
	TLegend *hHKMlegend, *EPOSlegend;
	TCanvas *canv = new TCanvas(canvasName, canvasName, 1300, 2000);
	if(isIdentical)
		canv->Divide(2,4);
	else
		canv->Divide(2,5);

	// 
	// hHKM
	//
	hHKMlegend = new TLegend(legendX1, legendY1, legendX2, legendY2);

	k = 0;
	canv->cd(++++canvasNumber1);
	for(i = 0 ; i < plots.size(); ++i)
		if(plots[i].model.compare("hHKM") == 0)
		{
			DrawSinglePlot(plots[i].cf1D, (std::string(pairName) + std::string(" - hHKM - 1D;q_{inv} (GeV/c);C(q_{inv})")).c_str(), k);
			SetRanges(plots[i].cf1D, canvasName, "1D");
			hHKMlegend->AddEntry(plots[i].cf1D, plots[i].centrality.c_str(),"P");
		}
	if(plots.size() > 0)
	{
		hHKMlegend->Draw();
		hHKMlegend->SetFillColor(0);
	}
			
	k = 0;
	canv->cd(++++canvasNumber1);
	for(i = 0 ; i < plots.size(); ++i)
		if(plots[i].model.compare("hHKM") == 0)
		{
			DrawSinglePlot(plots[i].cfSH00, (std::string(pairName) + std::string(" - hHKM - Spherical Harmonics;k* (GeV/c);#RgothicC^{0}_{0}")).c_str(), k);
			SetRanges(plots[i].cfSH00, canvasName, "SH00");
		}

	if(!isIdentical)
	{
		k = 0;
		canv->cd(++++canvasNumber1);
		for(i = 0 ; i < plots.size(); ++i)
			if(plots[i].model.compare("hHKM") == 0)
			{
				DrawSinglePlot(plots[i].cfSH11, (std::string(pairName) + std::string(" - hHKM - Spherical Harmonics;k* (GeV/c);#RgothicC^{1}_{1}")).c_str(), k);
				SetRanges(plots[i].cfSH11, canvasName, "SH11");
			}
	}

	k = 0;
	canv->cd(++++canvasNumber1);
	for(i = 0 ; i < plots.size(); ++i)
		if(plots[i].model.compare("hHKM") == 0)
		{
			DrawSinglePlot(plots[i].cfSH20, (std::string(pairName) + std::string(" - hHKM - Spherical Harmonics;k* (GeV/c);#RgothicC^{0}_{2}")).c_str(), k);
			SetRanges(plots[i].cfSH20, canvasName, "SH20");
		}

	k = 0;
	canv->cd(++++canvasNumber1);
	for(i = 0 ; i < plots.size(); ++i)
		if(plots[i].model.compare("hHKM") == 0)
		{
			DrawSinglePlot(plots[i].cfSH22, (std::string(pairName) + std::string(" - hHKM - Spherical Harmonics;k* (GeV/c);#RgothicC^{2}_{2}")).c_str(), k);
			SetRanges(plots[i].cfSH22, canvasName, "SH22");
		}

	//
	// EPOS
	//
	EPOSlegend = new TLegend(legendX1, legendY1, legendX2, legendY2);

	k = 0;
	canv->cd(++++canvasNumber2);
	for(i = 0 ; i < plots.size(); ++i)
		if(plots[i].model.compare("EPOS") == 0)
		{
			DrawSinglePlot(plots[i].cf1D, (std::string(pairName) + std::string(" - EPOS - 1D;q_{inv} (GeV/c);C(q_{inv})")).c_str(), k);
			SetRanges(plots[i].cf1D, canvasName, "1D");
			EPOSlegend->AddEntry(plots[i].cf1D, plots[i].centrality.c_str(),"P");
		}
	if(plots.size() > 0)
	{
		EPOSlegend->Draw();
		EPOSlegend->SetFillColor(0);
	}
		
	k = 0;
	canv->cd(++++canvasNumber2);
	for(i = 0 ; i < plots.size(); ++i)
		if(plots[i].model.compare("EPOS") == 0)
		{
			DrawSinglePlot(plots[i].cfSH00, (std::string(pairName) + std::string(" - EPOS - Spherical Harmonics;k* (GeV/c);#RgothicC^{0}_{0}")).c_str(), k);
			SetRanges(plots[i].cfSH00, canvasName, "SH00");
		}

	if(!isIdentical)
	{
		k = 0;
		canv->cd(++++canvasNumber2);
		for(i = 0 ; i < plots.size(); ++i)
			if(plots[i].model.compare("EPOS") == 0)
			{
				DrawSinglePlot(plots[i].cfSH11, (std::string(pairName) + std::string(" - EPOS - Spherical Harmonics;k* (GeV/c);#RgothicC^{1}_{1}")).c_str(), k);
				SetRanges(plots[i].cfSH11, canvasName, "SH11");
			}
	}

	k = 0;
	canv->cd(++++canvasNumber2);
	for(i = 0 ; i < plots.size(); ++i)
		if(plots[i].model.compare("EPOS") == 0)
		{
			DrawSinglePlot(plots[i].cfSH20, (std::string(pairName) + std::string(" - EPOS - Spherical Harmonics;k* (GeV/c);#RgothicC^{0}_{2}")).c_str(), k);
			SetRanges(plots[i].cfSH20, canvasName, "SH20");
		}

	k = 0;
	canv->cd(++++canvasNumber2);
	for(i = 0 ; i < plots.size(); ++i)
		if(plots[i].model.compare("EPOS") == 0)
		{
			DrawSinglePlot(plots[i].cfSH22, (std::string(pairName) + std::string(" - EPOS - Spherical Harmonics;k* (GeV/c);#RgothicC^{2}_{2}")).c_str(), k);
			SetRanges(plots[i].cfSH22, canvasName, "SH22");
		}

	canv->SaveAs((std::string(canvasName)+std::string(".eps")).c_str());
	canv->SaveAs((std::string(canvasName)+std::string(".png")).c_str());
	canv->SaveAs((std::string(canvasName)+std::string(".root")).c_str());
}
void pythia6_gammagamma_leptons( int Nevts = 25000, double sqrts = 90, int MSTP14_val=10) 
{

  //Luminosity and bunches definitions according to FCC-ee project specifications
  Double_t Luminosity=1;
  Double_t Luminosity_c=1; //with opt crab waist
  Double_t FCC_Circumference = 100000; // meters
  Double_t speed_of_light = 299792458; // m/s
  Int_t N_bunch = 1; //number of bunches per beam
  Int_t N_bunch_c= 1;//with opt Crab waist

  if (sqrts==90){
    N_bunch = 16700;
    Luminosity = 0.28; //pb^-1 s^-1
    N_bunch_c = 59581;
    Luminosity_c = 2.15;
  }
  else if (sqrts==160){
    N_bunch = 4490;
    Luminosity = 0.12; //pb^-1 s^-1
    N_bunch_c =3143;
    Luminosity_c =0.38;
  }
  else if (sqrts==240){
    N_bunch = 1360;
    Luminosity =  0.06; //pb^-1 s^-1
    N_bunch_c = 625;
    Luminosity_c = 0.087;
  }
  else if (sqrts==350){
    N_bunch = 98;
    Luminosity = 0.0018; //pb^-1 s^-1
    N_bunch_c = 68;
    Luminosity_c = 0.021;
  }
  
  // Instance of the Pythia event generator

  TPythia6* pythia = new TPythia6();

  PDG = TDatabasePDG::Instance(); // TDataBasePDG contains info on all particle properties

  // Random seeding
  int seed = (int)(time(NULL)/3);
  if( (seed>=0) && (seed<=900000000) ) {
    pythia->SetMRPY(1,seed); // set seed
    pythia->SetMRPY(2,0); // use new seed
    cout << endl << "<I> Random Seed : " << seed << endl; 
  } 
  else{
    cout << endl << "<I> Default random seed ... "<< seed << endl; 
  } 

  //____________________________________________________________________
  //
  // PYTHIA GENERATION SETTINGS
  //____________________________________________________________________
  

  // *******************************************************************
  // PHYSICS PROCESS SELECTION
  
  pythia->SetMSEL(0); // we choose the process by hand below 
  pythia->SetMSTP(81, 1); // Multiple parton interactions for resolved gamma-gamma colls.


  // *******************************************************************
  // Final-state:

  pythia->SetMSTJ(22,2);      //! Decay those unstable particles',
  pythia->SetPARJ(71,10.);    //! for which ctau < 10 mm',


  // *******************************************************************
  // Detailed process selection 


  pythia->SetMSTP(14,MSTP14_val);  // gamma gamma -> hadrons (30=FULL)
  //pythia->SetMSEL(2); // min-bias QCD
  pythia->SetMSEL(1); //less accuracy in hadronic simulation but faster(usefull if intereted in leptonic)


  // ******************************************************************


  book_histos();

  // ******************************************************************
  //  Initialise it to run e+/e- --> gamma gamma --> X

  pythia->Initialize("cms", "gamma/e+", "gamma/e-", sqrts);
  //pythia->Initialize("cms", "e+", "e-", sqrts);
  cout << "SYSTEM: e+e- at sqrt(s)=" << sqrts << " GeV" << endl; 

  TClonesArray* particlesArray = 0;

  // ******************************************************************
  // EVENT LOOP
  
  int exclEvts = 0;

  std::ofstream myfile;
  myfile.open("_txt/generation_time.txt");
  int execution_time[Nevts/1000];

  Int_t n_lepton_total=0; //counter for the total number of charged leptons (sum on the events)

  for (int ievt = 0; ievt < Nevts; ievt++) {

    if (ievt ==0) cout << "Generating event #: " << flush;
    if (ievt % 1000 == 0) {
      cout << ievt << " " << flush;
      execution_time[ievt/1000]=time(NULL);
      if (ievt !=0)
	myfile << execution_time[ievt/1000] << "\t" << ievt << "\t" << 1000/(float)(execution_time[ievt/1000]-execution_time[ievt/1000 -1])<< endl;
    }

    // ******************************************************************
    // Generate event

    pythia->GenerateEvent();
    
    // ***********************************************************************************************
    // Check if event passes trigger selection
    // 
    //  if (debug) cout << "############ EVENT " << ievt << " #############" << endl;
    //	dumpEvent( pythia );

    if ( passEvtSelection(pythia)==false ) { ///Cut on W!!!!!!!!!!!!!!!
      exclEvts++;
      continue;
    }

    // Loop over particles and fill histos

    particlesArray = (TClonesArray*)pythia->GetListOfParticles();
    int N = particlesArray->GetEntriesFast();
    //cout << "<I> PYTHIA particles in event: " << N << " " << flush;

    TMCParticle *part;
    TParticle *partic;

    Int_t n_leptons = 0;

    for (int ip = 0; ip < N; ip++ ) {

      part = (TMCParticle*)particlesArray->At(ip);
      int status = part->GetKS();
      if (status!=1) continue; // Only consider final-state particles

      int pdg = part->GetKF();
      double charge = PDG->GetParticle(pdg)->Charge();
      if(charge==0) continue; // only charged particles

      if ( abs(pdg)!=11 && abs(pdg)!=13 && abs(pdg)!=15) continue;// only leptons
      

      partic = (TParticle*)TMCParticle2TParticle(part);
      double ptPartic = partic->Pt();
      double etaPartic = partic->Eta();
      //phiPartic = partic->Phi();

      //if ( ptPartic<0.15 ) continue; //cut on Pt!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
      //if (abs(etaPartic)>1.5) continue; //Fill only if |eta|<1.5!!!!!!!!!!!!!!!!!!!!!   


      // Histo filling
      h_id_part->Fill(abs(pdg));
      hdsigmadeta->Fill(etaPartic);
      
      hdsigmadpT->Fill(ptPartic);

      n_leptons++; //Count the total number of charged hadrons in this event
      delete partic;
      // if (TMath::Abs(etaPartic)<1.) Nch++;
    } // End loop over all particles in event

    h_lep_per_ev->Fill(n_leptons);

    n_lepton_total += n_leptons;
    
    
  } // END EVENT GENERATION LOOP

  myfile.close();

  
  
  // **********************************************************************************  
  // FINAL GENERATION MESSAGES:
  
  pythia->Pystat(1);
  
  double xsection = pythia->GetPARI(1) * 1e9;//conversion form mb to pb
  int    ntrials  = pythia->GetMSTI(5);
  double sigmaweight = xsection/ntrials;
  double total_lepton_xsection = sigmaweight*n_lepton_total;

    
  cout << endl << "#######################" << endl 
       << endl << "<I> Event summary: " << Nevts << " generated." << endl ;

  
  //double evts = hdsigmadeta->Integral(); 
  double triggEff = (Nevts-exclEvts)/(float)Nevts;
  cout << "<I> Num. of total valid events = " << Nevts-exclEvts << " (Effic="<< triggEff*100. << "%)" << endl;

  cout << "<I> Pythia cross section: " << xsection << " mb || number of trials: " << ntrials << " || sigmaweight = "<< sigmaweight <<endl;

  cout << endl << "Hadrons per events: " << endl << "Mean = " << h_lep_per_ev->GetMean() << endl << "Max = " << h_lep_per_ev->GetMaximumBin() <<endl;

  cout << endl << endl << endl <<  "Total number of leptons = " << n_lepton_total << endl;
  cout << "Cross section = " << total_lepton_xsection << "pb  in e+e- --> gamma gamma --> X at sqrt(s) = " << sqrts << " GeV " << endl << endl << endl;

  Double_t N_rate = total_lepton_xsection*Luminosity;
  Double_t Pileup = (N_rate*FCC_Circumference)/(N_bunch*speed_of_light);
  Double_t N_rate_c = total_lepton_xsection*Luminosity_c;
  Double_t Pileup_c = (N_rate_c*FCC_Circumference)/(N_bunch_c*speed_of_light);

  ofstream file_out;
  char file_out_name[150];
  sprintf(file_out_name, "_txt/pythia6_gammagamma_leptons_%iGeV_seed%d_Nevts%d_output.txt",(int)TMath::Ceil(sqrts),seed,Nevts);
  file_out.open(file_out_name);

  file_out << Nevts-exclEvts << " //   Total event generated" << endl;
  file_out << xsection << " //   [pb] Pythia6 total cross section" << endl;
  file_out << total_lepton_xsection << " //   [pb] Cross section for e+e- --> gamma gamma --> l"<< endl;
  file_out << sqrts << " //   [GeV] sqrt(s)" << endl;
  file_out << n_lepton_total <<" //   Total Lepton produced" << endl;
  file_out << N_rate << " //   [Hz] Production Rate (Sigma*Lum)" << endl;
  file_out << N_rate_c << " //   [Hz] Production Rate (Sigma*Lum) (Crab waist)" << endl << endl << endl;
  
  file_out << Pileup << " //   Interactions e/gamma e/gamma -> l per bunch" << endl;
  file_out << Pileup_c << " //   Interactions e/gamma e/gamma -> l per bunch (Crab Waist)" << endl;

  
  file_out.close();



  // double dNchdeta = hdsigmadeta->GetBinContent(11)/ntrials; 
  // cout << "<I> dN_ch/deta|_{eta=0} = " << dNchdeta << " in e+e- --> gamma gamma --> X at sqrt(s) = " << sqrts << " GeV " << endl ;

  // **********************************************************************************  
  // Normalize histos by weighted cross-section, pseudorapidity range, and the pT bin size

  hdNdeta=(TH1F*)hdsigmadeta->Clone("hdNdeta");
  hdNdeta->Scale(1./(float)Nevts);
  hdNdeta->SetTitle("hdNdeta");
  hdNdeta->SetXTitle("|#eta|");
  hdNdeta->SetYTitle("dN/d|#eta| (nb)");

  double etabinsize = 20/20; // eta binning: 20 within -10<eta<10
  hdsigmadeta->Scale(1e-3*sigmaweight/etabinsize);
  //hdsigmadeta->Scale(1/Nevts);
  double ptbinsize = (pt_max-pt_min)/n_bin_pt;
  hdsigmadpT->Scale(sigmaweight/ptbinsize);
    
  //hdsigmadetaTruth->Scale(sigmaweight*0.01); // eta binning: 2000 in -10<eta<10
  //hEdsigmadpT->Scale(ptbinsize/ntrials);
  //ntFFdsigmadeta->SetWeight(sigmaweight);


  // **********************************************************************************  
  // Plot distributions for cross-check


  char title[300];
    sprintf(title, "cinvdsigmadpT_%iGeV",(int)sqrts);
    TCanvas *cinvdsigmadpT = new TCanvas(title,title,700,600);
    cinvdsigmadpT->SetLogy();
    cinvdsigmadpT->SetLogx();
    cinvdsigmadpT->cd();
    hdsigmadpT->Draw();
    cinvdsigmadpT->SaveAs("_png/histo_hdsigmadpT.png");   
    

    sprintf(title, "cinvdsigmadeta_%iGeV",(int)sqrts);
    TCanvas *cinvdsigmadeta = new TCanvas(title,title,700,600);
    cinvdsigmadeta->cd();
    hdsigmadeta->Draw();
    cinvdsigmadeta->SaveAs("_png/histo_hdsigmadeta.png");

    sprintf(title, "cinvdNdeta_%iGeV",(int)sqrts);
    TCanvas *cinvdNdeta = new TCanvas(title,title,700,600);
    cinvdNdeta->cd();
    hdNdeta->Draw();
    cinvdNdeta->SaveAs("_png/histo_hdNdeta.png");


    // sprintf(title, "cinvW_%iGeV",(int)sqrts);
    // TCanvas *cinvW = new TCanvas(title,title,700,600);
    // cinvW->cd();
    // hW->Draw();
    // cinvW->SaveAs("_png/histo_hW.png");

    sprintf(title, "cinvn_had_%iGeV",(int)sqrts);
    TCanvas *cinvn_had = new TCanvas(title,title,700,600);
    cinvn_had->cd();
    h_lep_per_ev->Draw();
    cinvn_had->SaveAs("_png/histo_charged_leptons_per_ev.png");

    // sprintf(title, "cinvp_id_%iGeV",(int)sqrts);
    // TCanvas *cinvp_id = new TCanvas(title,title,700,600);
    // cinvp_id->cd();
    // cinvp_id->SetLogy();
    // h_id_part->Draw();
    // cinvp_id->SaveAs("_png/histo_particle_id.png");

    

  // **********************************************************************************  
  // Open  output file and Close file
    
  char filename[200];
  sprintf(filename, "_root/pythia6_gammagamma_leptons_%iGeV_seed%d_Nevts%d.root",(int)TMath::Ceil(sqrts),seed,Nevts);

  TFile* file = TFile::Open(filename, "RECREATE");
  if (!file || !file->IsOpen()) {
    Error("pythia6_gammagamma_leptons", "Couldn;t open file %s", filename);
    return;
  }

  file->cd();
  hdsigmadeta->Write();
  hdsigmadpT->Write();
  hdNdeta->Write();
  h_lep_per_ev->Write();
  hW->Write();
  h_id_part->Write();
  file->Close();
  cout << endl << "#######<I> File " << filename << " created. Take a look ... ##############" << endl << endl;

  file = TFile::Open(filename);
  file->ls();
  file->Close();
}
Пример #13
0
int main(){

  /*Toy Model with following True parameters
    Guess 20 events in Lb->pketa' (1)
    and 15 events in Lb->pketa'->pipieta (2)
    Lb Efficiencies=0.0002637
    B+ Efficiency=0.000411 (3)
    B(eta'->pi pi g)=0.291
    B(eta'->pi pi eta)=0.16
    fd/fL= 2.5
   */
  
  int GenRare=40;
  int GenRare2=30;
  int GenControl=11000;
  
  RooRealVar Mode2EfficiencyRatio("Mode2EfficiencyRatio","Mode2EfficiencyRatio",1.558589);
  RooRealVar ModeEfficiencyRatio("ModeEfficiencyRatio","ModeEfficiencyRatio",1.558589);
  RooRealVar SubBRRatio("SubBRRatio","SubBRRatio",0.645);
  RooRealVar fdFl("fdFl","fdFl",2.5);
  RooRealVar YieldRatio("YieldRatio","YieldRatio",0.1,0.000001,1.0);
  RooRealVar YieldRatio2("YieldRatio2","YieldRatio2",0.1,0.000001,1.0);


  //RooFormulaVar ObservableBFRatio("ObservableBFRatio","ObservableBFRatio","((@0*@1)+(@2*@3))*@4*@5",RooArgSet(YieldRatio,ModeEfficiencyRatio,YieldRatio2,Mode2EfficiencyRatio,SubBRRatio,fdFl));
  RooRealVar ObservableBFRatio("ObservableBFRatio","ObservableBFRatio",0.5,0.00000001,10.0);
  
  //  RooRealVar ControlYield("ControlYield","ControlYield",10000.0,0.0,20000.0);
  //RooRealVar RareYield("RareYield","RareYield",30.0,0.0,1100.0);

  
  //RooFormulaVar RareArg("RareArg","RareArg","@1*@2",RooArgSet(ControlYield,YieldRatio));
  RooRealVar ControlMean("ControlMean","ControlMean",5279.0,5200.0,5350.0);
  RooRealVar SigmaCorrection("SigmaCorrection","SigmaCorrection",1.1,0.9,1.8);
  RooRealVar LambdaMass("LambdaMass","LambdaMass",5000,6200.0);
  //  RooRealVar RareMean("RareMean","RareMean",5619.0,5600.0,5650.0);
  RooFormulaVar RareMean("RareMean","RareMean","@0+339.72",RooArgSet(ControlMean));
  RooRealVar MCRareSigma("MCRareSigma","MCRareSigma",25.0);
  //  RooRealVar RareSigma("RareSigma","RareSigma",29.0,20.0,40.0);
  RooFormulaVar RareSigma("RareSigma","RareSigma","@0*@1",RooArgSet(MCRareSigma,SigmaCorrection));
  RooGaussian RareMode("RareMode","RareMode",LambdaMass,RareMean,RareSigma);

  RooRealVar K("K","K",-0.003,-0.010,-0.001);
  RooExponential RareBkg("RareBkg","RareBkg",LambdaMass,K);
  
  RooRealVar RareBkgYield("RareBkgYield","RareBkgYield",1000.0,0.0,2000.0);
  RooExtendPdf ExtRareBkg("ExtRareBkg","ExtRareBkg",RareBkg,RareBkgYield);
  
  //  RooFormulaVar RareYield("RareYield","RareYield","@0*@1",RooArgSet(ControlYield,YieldRatio));
  RooRealVar RareYield("RareYield","RareYield",1.0,0.0,600.0);
  RooExtendPdf ExtRareSig("ExtRareSig","ExtRareSig",RareMode,RareYield);

  RooAddPdf ExtRare("ExtRare","ExtRare",RooArgSet(ExtRareSig,ExtRareBkg));

  RooDataSet* RareSigData=RareMode.generate(RooArgSet(LambdaMass),GenRare);
  RooDataSet* RareBkgData=RareBkg.generate(RooArgSet(LambdaMass),500);
  RooDataSet* RareData= new RooDataSet(*RareSigData,"RareData");
  RareData->append(*RareBkgData);
  
  RooRealVar MCRare2Sigma("MCRare2Sigma","MCRare2Sigma",17.0);
  //RooRealVar Rare2Sigma("Rare2Sigma","Rare2Sigma",20.0,10.0,30.0);
  RooFormulaVar Rare2Sigma("Rare2Sigma","Rare2Sigma","@0*@1",RooArgSet(MCRare2Sigma,SigmaCorrection));
  RooGaussian RareMode2("RareMode2","RareMode2",LambdaMass,RareMean,Rare2Sigma);
  RooDataSet* RareData2=RareMode2.generate(RooArgSet(LambdaMass),GenRare2);
  
  
  //RooFormulaVar RareYield2("RareYield2","RareYield2","@0*@1",RooArgSet(ControlYield,YieldRatio2));
  //RooFormulaVar RareYield2("RareYield2","RareYield2","(ControlYield*(1/Mode2EfficiencyRatio))*((ObservableBFRatio/(SubBRRatio*fdFl))-(YieldRatio*ModeEfficiencyRatio))",RooArgSet(ControlYield,Mode2EfficiencyRatio,ObservableBFRatio,SubBRRatio,fdFl,YieldRatio,ModeEfficiencyRatio));
  RooRealVar RareYield2("RareYield2","RareYield2",1.0,0.0,100.0);
  RooExtendPdf ExtRare2("ExtRare2","ExtRare2",RareMode2,RareYield2);
  
  RooRealVar BMass("BMass","BMass",5000.0,5500.0);					
  
  //  RooFormulaVar ControlMean("ControlMean","ControlMean","@0-339.72",RooArgSet(RareMean));
  RooRealVar MCControlSigma("MCControlSigma","MCControlSigma",17.0);
  RooFormulaVar ControlSigma("ControlSigma","ControlSigma","@0*@1",RooArgSet(MCControlSigma,SigmaCorrection));
  //RooRealVar ControlSigma("ControlSigma","ControlSigma",20.0,10.0,40.0);
  RooGaussian ControlMode("ControlMode","ControlMode",BMass,ControlMean,ControlSigma);
  RooFormulaVar ControlYield("ControlYield","ControlYield","(1/ObservableBFRatio)*((ModeEfficiencyRatio*RareYield)+(Mode2EfficiencyRatio*RareYield2))*SubBRRatio*fdFl",RooArgSet(ObservableBFRatio,ModeEfficiencyRatio,RareYield,Mode2EfficiencyRatio,RareYield2,SubBRRatio,fdFl));
  RooExtendPdf ExtControl("ExtControl","ExtControl",ControlMode,ControlYield);

    
  RooDataSet* ControlData=ControlMode.generate(RooArgSet(BMass),GenControl);
  
  RooCategory Mode("Mode","Mode");
  Mode.defineType("Rare");
  Mode.defineType("Rare2");
  Mode.defineType("Control");

  RooDataSet CombData("CombData","CombData",RooArgSet(BMass,LambdaMass),Index(Mode),Import("Rare2",*RareData2),Import("Rare",*RareData),Import("Control",*ControlData));

  RooSimultaneous SimPdf("SimPdf","SimPdf",Mode);
  SimPdf.addPdf(ExtRare,"Rare");
  SimPdf.addPdf(ExtRare2,"Rare2");
  SimPdf.addPdf(ExtControl,"Control");

  RooFitResult* SimResult=SimPdf.fitTo(CombData,Save(kTRUE),Minos(kTRUE));
  /*  double FreeYield=-1*SimResult->minNll();
  std::cout<<"With free yield = "<<SimResult->minNll()<<std::endl;
  RareYield.setVal(0);
  RareYield.setConstant(kTRUE);
  RooFitResult* Rare1Fixed=SimPdf.fitTo(CombData,Save(kTRUE),Minos(kTRUE));
  double NullYield=-1*Rare1Fixed->minNll();
  std::cout<<"With not free yield = "<<Rare1Fixed->minNll()<<std::endl;

  double DeltaLogLikelihood=NullYield-FreeYield;
  std::cout<<"DeltaNll= "<<DeltaLogLikelihood<<std::endl;
  double Significance=TMath::Sqrt(-2*DeltaLogLikelihood); 
  std::cout<<"Significance= "<<Significance<<std::endl;
  SimPdf.fitTo(CombData,Save(kTRUE),Minos(kTRUE));*/

  
  RooPlot* BFrame= BMass.frame(Bins(50),Title("B Mass"),Range(5200.0,5400.0));
  ControlData->plotOn(BFrame);
  ControlMode.plotOn(BFrame);

  RooPlot* LambdaFrame = LambdaMass.frame(Bins(50),Title("Lambda mass"),Range(5200.0,6100.0));
  RareData->plotOn(LambdaFrame);
  ExtRare.plotOn(LambdaFrame);

  RooPlot* LambdaFrame2 = LambdaMass.frame(Bins(50),Title("Lambda mass"),Range(5200.0,6100.0));
  RareData2->plotOn(LambdaFrame2);
  RareMode2.plotOn(LambdaFrame2);
  
  TCanvas BCanvas;
  BFrame->Draw();
  BCanvas.SaveAs("BCanvas.pdf");

  TCanvas LambdaCanvas;
  LambdaFrame->Draw();
  LambdaCanvas.SaveAs("LambdaCanvas.pdf");

  TCanvas LambdaCanvas2;
  LambdaFrame2->Draw();
  LambdaCanvas2.SaveAs("LambdaCanvas2.pdf");
  

  SimResult->Print("v");

  // S imPdf.graphVizTree("model.dot");
  std::cout<<"Real Ratio = "<<GenRare/(double)GenControl<<std::endl;
  ObservableBFRatio.Print("v");
  

  std::cout<<"Lb BF = "<<ObservableBFRatio.getVal()*7.06E-5<<" + "<<ObservableBFRatio.getErrorHi()*7.06E-5<<" - "<<ObservableBFRatio.getErrorLo()*7.06E-5<<std::endl;
  

  //________________________________________________ATTEMPT TO SWEIGHT____________________________________________
  
  RooStats::SPlot* sDataMass = new RooStats::SPlot("sData","An SPlot",*RareData,&ExtRare,RooArgList(RareYield,RareBkgYield));
  std::cout << std::endl <<  "Yield of signal is " << RareYield.getVal() << ".  From sWeights it is " << sDataMass->GetYieldFromSWeight("RareYield") << std::endl;
  std::cout << "Yield of background is " << RareBkgYield.getVal() << ".  From sWeights it is " << sDataMass->GetYieldFromSWeight("RareBkgYield") << std::endl << std::endl;

  RooAbsReal* nll = SimPdf.createNLL(CombData);
  RooMinuit(*nll).migrad();
  
  RooPlot* LLFrame=ObservableBFRatio.frame(Title("Some Title"),Range(0.005,0.03));
  nll->plotOn(LLFrame,ShiftToZero());
  LLFrame->GetYaxis()->SetRangeUser(0.0,1000.0);

  TCanvas LLCanvas;
  LLFrame->Draw();
  LLCanvas.SaveAs("LLCanvas.pdf");
}
Пример #14
0
void ElectronTagAndProbeMC(const string dataInputFilename, const string Label, 
                           Int_t ChargeSelection = 0) {   

  gBenchmark->Start("ElectronTagAndProbe");

  //--------------------------------------------------------------------------------------------------------------
  // Settings 
  //==============================================================================================================
  string label = Label;
  if (Label != "") label = "_" + label;

  Double_t lumi;              // luminosity (pb^-1)
    

  //********************************************************
  // Define Bins
  //********************************************************
  vector<string> ptbinLabel;
  vector<Double_t> ptbinLowEdge;
  vector<Double_t> ptbinUpEdge;
   ptbinLabel.push_back("Pt20ToInf"); ptbinLowEdge.push_back(20.0); ptbinUpEdge.push_back(14000.0);
//   ptbinLabel.push_back("Pt10To15"); ptbinLowEdge.push_back(10.0); ptbinUpEdge.push_back(15.0);
//   ptbinLabel.push_back("Pt15To20"); ptbinLowEdge.push_back(15.0); ptbinUpEdge.push_back(20.0);
//   ptbinLabel.push_back("Pt20To30"); ptbinLowEdge.push_back(20.0); ptbinUpEdge.push_back(30.0);
//   ptbinLabel.push_back("Pt30To40"); ptbinLowEdge.push_back(30.0); ptbinUpEdge.push_back(40.0);
//   ptbinLabel.push_back("Pt40To50"); ptbinLowEdge.push_back(40.0); ptbinUpEdge.push_back(50.0);
//   ptbinLabel.push_back("Pt50ToInf"); ptbinLowEdge.push_back(50.0); ptbinUpEdge.push_back(14000.0);
  vector<string> etabinLabel;
  vector<Double_t> etabinLowEdge;
  vector<Double_t> etabinUpEdge;
  etabinLabel.push_back("EE"); etabinLowEdge.push_back(1.5); etabinUpEdge.push_back(2.5);
  etabinLabel.push_back("EB"); etabinLowEdge.push_back(0); etabinUpEdge.push_back(1.5);
  vector<string> chargebinLabel;
  vector<Double_t> chargeSelection;
  chargebinLabel.push_back("All");  chargeSelection.push_back(0);
  chargebinLabel.push_back("Plus"); chargeSelection.push_back(1);
  chargebinLabel.push_back("Minus"); chargeSelection.push_back(-1);
  vector<vector<vector<Double_t> > > EventCount_TagPlusRecoFailWWTightIdIso_binned;
  vector<vector<vector<Double_t> > > EventCount_TagPlusRecoPassWWTightIdIso_binned;
  vector<vector<vector<Double_t> > > EventCount_TagPlusWWTightIdIsoPassHLT_binned;
  vector<vector<vector<Double_t> > > EventCount_TagPlusWWTightIdIsoFailHLT_binned;
  for (int k=0; k < chargebinLabel.size(); ++k) {
    vector<vector<Double_t> > tmp_tmp_EventCount_TagPlusRecoFailWWTightIdIso_binned;
    vector<vector<Double_t> > tmp_tmp_EventCount_TagPlusRecoPassWWTightIdIso_binned;
    vector<vector<Double_t> > tmp_tmp_EventCount_TagPlusWWTightIdIsoPassHLT_binned;
    vector<vector<Double_t> > tmp_tmp_EventCount_TagPlusWWTightIdIsoFailHLT_binned;    
    
    for (int i=0; i < etabinLabel.size(); ++i) {
      vector<Double_t> tmp_EventCount_TagPlusRecoFailWWTightIdIso_binned;
      vector<Double_t> tmp_EventCount_TagPlusRecoPassWWTightIdIso_binned;
      vector<Double_t> tmp_EventCount_TagPlusWWTightIdIsoPassHLT_binned;
      vector<Double_t> tmp_EventCount_TagPlusWWTightIdIsoFailHLT_binned;    
      
      for (int j=0; j < ptbinLabel.size(); ++j) {
        Double_t tmp_EventCount_TagPlusRecoFailWWTightIdIso = 0;
        tmp_EventCount_TagPlusRecoFailWWTightIdIso_binned.push_back(tmp_EventCount_TagPlusRecoFailWWTightIdIso);
        
        Double_t tmp_EventCount_TagPlusRecoPassWWTightIdIso = 0;
        tmp_EventCount_TagPlusRecoPassWWTightIdIso_binned.push_back(tmp_EventCount_TagPlusRecoPassWWTightIdIso);
        
        Double_t tmp_EventCount_TagPlusWWTightIdIsoFailHLT = 0;
        tmp_EventCount_TagPlusWWTightIdIsoFailHLT_binned.push_back(tmp_EventCount_TagPlusWWTightIdIsoFailHLT);
        
        Double_t tmp_EventCount_TagPlusWWTightIdIsoPassHLT = 0;
        tmp_EventCount_TagPlusWWTightIdIsoPassHLT_binned.push_back(tmp_EventCount_TagPlusWWTightIdIsoPassHLT);
        
        cout << "make bins : " << k << " " << i << " " << j << " " << endl;
        
      }
      
      tmp_tmp_EventCount_TagPlusRecoFailWWTightIdIso_binned.push_back(tmp_EventCount_TagPlusRecoFailWWTightIdIso_binned);
      tmp_tmp_EventCount_TagPlusRecoPassWWTightIdIso_binned.push_back(tmp_EventCount_TagPlusRecoPassWWTightIdIso_binned);
      tmp_tmp_EventCount_TagPlusWWTightIdIsoPassHLT_binned.push_back(tmp_EventCount_TagPlusWWTightIdIsoPassHLT_binned);
      tmp_tmp_EventCount_TagPlusWWTightIdIsoFailHLT_binned.push_back(tmp_EventCount_TagPlusWWTightIdIsoFailHLT_binned);
      
    }

    EventCount_TagPlusRecoFailWWTightIdIso_binned.push_back(tmp_tmp_EventCount_TagPlusRecoFailWWTightIdIso_binned);
    EventCount_TagPlusRecoPassWWTightIdIso_binned.push_back(tmp_tmp_EventCount_TagPlusRecoPassWWTightIdIso_binned);
    EventCount_TagPlusWWTightIdIsoPassHLT_binned.push_back(tmp_tmp_EventCount_TagPlusWWTightIdIsoPassHLT_binned);
    EventCount_TagPlusWWTightIdIsoFailHLT_binned.push_back(tmp_tmp_EventCount_TagPlusWWTightIdIsoFailHLT_binned);
    
  }

  //--------------------------------------------------------------------------------------------------------------
  // Histograms
  //==============================================================================================================  
  Double_t EventCount_TagPlusRecoFailWWTightIdIso = 0;
  Double_t EventCount_TagPlusRecoPassWWTightIdIso = 0;
  Double_t EventCount_TagPlusWWTightIdIsoFailHLT = 0;
  Double_t EventCount_TagPlusWWTightIdIsoPassHLT = 0;

  Int_t nbins = 20;
  TH1F *histogram = new TH1F ("histogram", "; xaxis; yaxis; ", 100, 0 , 200);
  TH1F *ProbePt = new TH1F ("ProbePt", "; xaxis; yaxis; ", 100, 0 , 200);
  TH1F *TagPt = new TH1F ("TagPt", "; xaxis; yaxis; ", 100, 0 , 200);
  TH1F *TagPlusRecoFailWWTightIdIso = new TH1F ("TagPlusRecoFailWWTightIdIso", "; xaxis; yaxis; ", nbins, 60 , 120);
  TH1F *TagPlusRecoPassWWTightIdIso = new TH1F ("TagPlusRecoPassWWTightIdIso", "; xaxis; yaxis; ", nbins, 60 , 120);
  TH1F *TagPlusWWTightIdIsoFailHLT = new TH1F ("TagPlusWWTightIdIsoFailHLT", "; xaxis; yaxis; ", nbins, 60 , 120);
  TH1F *TagPlusWWTightIdIsoPassHLT = new TH1F ("TagPlusWWTightIdIsoPassHLT", "; xaxis; yaxis; ", nbins, 60 , 120);


  //--------------------------------------------------------------------------------------------------------------
  // Main analysis code 
  //==============================================================================================================  
  
  //
  // Access samples and fill histograms
  //  
  TFile *infile=0;
  TTree *eventTree=0;  
  
  // Data structures to store info from TTrees
  mithep::TEventInfo *info    = new mithep::TEventInfo();
  TClonesArray *electronArr = new TClonesArray("mithep::TElectron");
  

  //********************************************************
  // Get Tree
  //********************************************************
  eventTree = getTreeFromFile(dataInputFilename.c_str(),"Events");
  
  // Set branch address to structures that will store the info  
  eventTree->SetBranchAddress("Info",       &info);          TBranch *infoBr       = eventTree->GetBranch("Info");
  eventTree->SetBranchAddress("Electron", &electronArr); TBranch *electronBr = eventTree->GetBranch("Electron");
  

  //*****************************************************************************************
  //Loop over Data Tree
  //*****************************************************************************************
  Double_t nsel=0, nselvar=0;
  for(UInt_t ientry=0; ientry<eventTree->GetEntries(); ientry++) {       	
    infoBr->GetEntry(ientry);
	
    if (ientry % 100000 == 0) cout << "Event " << ientry << endl;

    //********************************************************
    // Load the branches
    //********************************************************
    electronArr->Clear();    
    electronBr->GetEntry(ientry);
 

    //********************************************************
    // TcMet
    //********************************************************
    TVector3 met;        
    if(info->tcMEx!=0 || info->tcMEy!=0) {       
      met.SetXYZ(info->tcMEx, info->tcMEy, 0);
    }

    //******************************************************************************
    //dilepton preselection
    //******************************************************************************
    if (electronArr->GetEntries() < 2) continue;


    //******************************************************************************
    //loop over electron pairs
    //******************************************************************************
    for(Int_t i=0; i<electronArr->GetEntries(); i++) {
      const mithep::TElectron *tag = (mithep::TElectron*)((*electronArr)[i]);
      if ( !(
             fabs(tag->eta) < 2.5
             && 
             tag->pt > 20.0
             &&
             passElectronTagCuts(tag)
             )
        ) continue;
      

      for(Int_t j=0; j<electronArr->GetEntries(); j++) {
        if (i==j) continue;

        const mithep::TElectron *probe = (mithep::TElectron*)((*electronArr)[j]);
        if ( !(
               fabs(probe->eta) < 2.5
               && probe->pt > 10.0
               && probe->isEcalDriven
               )
          ) continue;
        
        mithep::FourVectorM tagVector;
        mithep::FourVectorM probeVector;
        tagVector.SetCoordinates(tag->pt, tag->eta, tag->phi, 0.51099892e-3 );
        probeVector.SetCoordinates(probe->pt, probe->eta, probe->phi, 0.51099892e-3 );
        mithep::FourVectorM dilepton = tagVector+probeVector;
 
        if (dilepton.M() > 60 && dilepton.M() < 120
            
          ) {
          
          //For binned efficiencies
          for (int q=0; q < chargebinLabel.size(); ++q) {
            for (int e=0; e < etabinLabel.size(); ++e) {
              for (int p=0; p < ptbinLabel.size(); ++p) {
                
                //Require the probe is in the right pt and eta bin
                if ( 		  
                (probe->pt >= ptbinLowEdge[p] && probe->pt < ptbinUpEdge[p])
                &&
                (fabs(probe->eta) >= etabinLowEdge[e] && fabs(probe->eta) < etabinUpEdge[e]) 
                && 
                (probe->q == chargeSelection[q] || chargeSelection[q] == 0)
//                 &&
//                 met.Pt() < 20.0
                  ) {
                  
                  //*****************************************************************************************************
                  //Reco -> WWTight
                  //*****************************************************************************************************	    
                
                  if (passElectronCuts(probe)) {	 
                    EventCount_TagPlusRecoPassWWTightIdIso_binned[q][e][p]++;                  
                  } else {
                  EventCount_TagPlusRecoFailWWTightIdIso_binned[q][e][p]++;
                  }
                  
                  //*****************************************************************************************************
                  //WWTight -> HLT
                  //*****************************************************************************************************	    
                  if (passElectronCuts(probe)) {
                    if (passHLT(probe, info->runNum)) {	 		     
                      EventCount_TagPlusWWTightIdIsoPassHLT_binned[q][e][p]++;
                    } else {
                      EventCount_TagPlusWWTightIdIsoFailHLT_binned[q][e][p]++;
                    }
                  }	    	    	
                }
              }
            }
          }            

          //*****************************************************************************************************
          //Reco -> WWTight
          //*****************************************************************************************************	    
          if (passElectronCuts(probe)) {	 
            EventCount_TagPlusRecoPassWWTightIdIso++;
            TagPlusRecoPassWWTightIdIso->Fill(dilepton.M());	      		  	      
          } else {
            EventCount_TagPlusRecoFailWWTightIdIso++;
            TagPlusRecoFailWWTightIdIso->Fill(dilepton.M());	   
          }
	    
          //*****************************************************************************************************
          //WWTight -> HLT
          //*****************************************************************************************************	    
          if (passElectronCuts(probe)) {
            if (passHLT(probe, info->runNum)) {	 
              EventCount_TagPlusWWTightIdIsoPassHLT++;
              TagPlusWWTightIdIsoPassHLT->Fill(dilepton.M());	
              ProbePt->Fill(probe->pt);
            } else {
              EventCount_TagPlusWWTightIdIsoFailHLT++;
              TagPlusWWTightIdIsoPassHLT->Fill(dilepton.M());			
            }
          }

        } //passes T&P selection

              
      } //loop over probes
    } //loop over tags


  } //end loop over data     

  delete info;
  delete electronArr;


  //--------------------------------------------------------------------------------------------------------------
  // Make plots
  //==============================================================================================================
  TCanvas *cv = new TCanvas("cv","cv", 800,600);
  TagPlusRecoPassWWTightIdIso->Draw();
  cv->SaveAs("TagPlusRecoPassWWTightIdIso.gif");
  TagPlusRecoFailWWTightIdIso->Draw();
  cv->SaveAs("TagPlusRecoFailWWTightIdIso.gif");
  TagPlusWWTightIdIsoPassHLT->Draw();
  cv->SaveAs("TagPlusWWTightIdIsoPassHLT.gif");
  TagPlusWWTightIdIsoFailHLT->Draw();
  cv->SaveAs("TagPlusWWTightIdIsoFailHLT.gif");

  ProbePt->Draw();
  cv->SaveAs("ProbePt.gif");
  TagPt->Draw();
  cv->SaveAs("TagPt.gif");

  //*****************************************************************************************
  //Summarize Efficiencies
  //*****************************************************************************************
  cout << "**********************************************************************\n";
  cout << "Summarize MC Efficiencies\n";
  TFile *file = new TFile("Efficiencies.root", "UPDATE");

  for (int q=0; q < chargebinLabel.size(); ++q) {    
    for (int e=0; e < etabinLabel.size(); ++e) {
      vector<Double_t> efficiency_RecoToWWTight;
      vector<Double_t> efficiency_RecoToWWTight_lowErr;
      vector<Double_t> efficiency_RecoToWWTight_highErr;
      vector<Double_t> efficiency_WWTightToHLT;
      vector<Double_t> efficiency_WWTightToHLT_lowErr;
      vector<Double_t> efficiency_WWTightToHLT_highErr;
      
      for (int p=0; p < ptbinLabel.size(); ++p) {
    
        cout << etabinLabel[e] << "  " << ptbinLabel[p] << "  Charge = " << chargeSelection[q] << endl;
        cout << endl;

        Int_t errorType = 2; //Clopper Pearson intervals
        Double_t ratio;
        Double_t errLow;
        Double_t errHigh;     
        Double_t n1;
        Double_t n2;

        n1 = TMath::Nint(EventCount_TagPlusRecoPassWWTightIdIso_binned[q][e][p]);
        n2 = TMath::Nint(EventCount_TagPlusRecoPassWWTightIdIso_binned[q][e][p] + EventCount_TagPlusRecoFailWWTightIdIso_binned[q][e][p]);
        if (n1 > n2) n1 = n2;
        mithep::MathUtils::CalcRatio(n1 , n2, ratio, errLow, errHigh, errorType);      
        cout << "Reco -> WWTight  Efficiency (MC) : " << n1 << " / " << n2 << " = " << ratio << " + " << errHigh << " - " << errLow << endl;
        cout << "\n";
        efficiency_RecoToWWTight.push_back(ratio);
        efficiency_RecoToWWTight_lowErr.push_back(errLow);
        efficiency_RecoToWWTight_highErr.push_back(errHigh);


        n1 = TMath::Nint(EventCount_TagPlusWWTightIdIsoPassHLT_binned[q][e][p]);
        n2 = TMath::Nint(EventCount_TagPlusWWTightIdIsoPassHLT_binned[q][e][p] + EventCount_TagPlusWWTightIdIsoFailHLT_binned[q][e][p]);
        if (n1 > n2) n1 = n2;
        mithep::MathUtils::CalcRatio(n1 , n2, ratio, errLow, errHigh, errorType);      
        cout << "WWTight  -> HLT : " << n1 << " / " << n2 << " = " << ratio << " + " << errHigh << " - " << errLow << endl;
        cout << "\n";

        efficiency_WWTightToHLT.push_back(ratio);
        efficiency_WWTightToHLT_lowErr.push_back(errLow);
        efficiency_WWTightToHLT_highErr.push_back(errHigh);

  
        cout << "\n\n\n";
      }

    //Make Efficiency Graphs
    const Int_t nbins = efficiency_RecoToWWTight.size();
    Double_t x[nbins];
    Double_t y[nbins];
    Double_t xErr[nbins];
    Double_t yErrLow[nbins];
    Double_t yErrHigh[nbins];

    //***********************************************************
    //Reco -> WW Tight    
    //***********************************************************
    for (int b=0; b< efficiency_RecoToWWTight.size(); ++b) {
      x[b] = (ptbinUpEdge[b] + ptbinLowEdge[b]) / 2;
      xErr[b] = fabs(ptbinUpEdge[b] - ptbinLowEdge[b]) / 2;
      if (b==efficiency_RecoToWWTight.size() - 1) {
        x[b] = (100 + ptbinLowEdge[b]) / 2;
        xErr[b] = fabs(100 - ptbinLowEdge[b]) / 2;
      }
      y[b] = efficiency_RecoToWWTight[b];
      yErrLow[b] = fabs(efficiency_RecoToWWTight_lowErr[b]);
      yErrHigh[b] = efficiency_RecoToWWTight_highErr[b];
    }
   
    TGraphAsymmErrors *efficiencyGraph_RecoToWWTight = new TGraphAsymmErrors(nbins, x, y, xErr, xErr, yErrLow,yErrHigh );
    efficiencyGraph_RecoToWWTight->SetName(("MCEfficiency_RecoToWWTight_" + chargebinLabel[q] + "_" + etabinLabel[e]).c_str());
    efficiencyGraph_RecoToWWTight->SetTitle("");
    efficiencyGraph_RecoToWWTight->GetXaxis()->SetTitle("p_{T} [GeV/c]");
    efficiencyGraph_RecoToWWTight->GetYaxis()->SetTitle("Efficiency");
    efficiencyGraph_RecoToWWTight->SetMaximum(1.0);
    efficiencyGraph_RecoToWWTight->SetMinimum(0.0);
    efficiencyGraph_RecoToWWTight->SetMarkerSize(1);
    efficiencyGraph_RecoToWWTight->SetLineWidth(2);
    efficiencyGraph_RecoToWWTight->GetXaxis()->SetRangeUser(0,100);

    file->WriteTObject(efficiencyGraph_RecoToWWTight, efficiencyGraph_RecoToWWTight->GetName(), "WriteDelete");


    //***********************************************************
    //WW Tight -> HLT
    //***********************************************************
    for (int b=0; b< efficiency_WWTightToHLT.size(); ++b) {
      x[b] = (ptbinUpEdge[b] + ptbinLowEdge[b]) / 2;
      xErr[b] = fabs(ptbinUpEdge[b] - ptbinLowEdge[b]) / 2;
      if (b==efficiency_RecoToWWTight.size() - 1) {
        x[b] = (100 + ptbinLowEdge[b]) / 2;
        xErr[b] = fabs(100 - ptbinLowEdge[b]) / 2;
      }
      y[b] = efficiency_WWTightToHLT[b];
      yErrLow[b] = fabs(efficiency_WWTightToHLT_lowErr[b]);
      yErrHigh[b] = efficiency_WWTightToHLT_highErr[b];
    }      
    TGraphAsymmErrors *efficiencyGraph_WWTightToHLT = new TGraphAsymmErrors(nbins, x, y, xErr, xErr, yErrLow,yErrHigh );
    efficiencyGraph_WWTightToHLT->SetName(("MCEfficiency_WWTightToHLT_" + chargebinLabel[q] + "_" + etabinLabel[e]).c_str());
    efficiencyGraph_WWTightToHLT->SetTitle("");
    efficiencyGraph_WWTightToHLT->GetXaxis()->SetTitle("p_{T} [GeV/c]");
    efficiencyGraph_WWTightToHLT->GetYaxis()->SetTitle("Efficiency");
    efficiencyGraph_WWTightToHLT->SetMaximum(1.0);
    efficiencyGraph_WWTightToHLT->SetMinimum(0.0);
    efficiencyGraph_WWTightToHLT->SetMarkerSize(1);
    efficiencyGraph_WWTightToHLT->SetLineWidth(2);
    efficiencyGraph_WWTightToHLT->GetXaxis()->SetRangeUser(0,100);

    file->WriteTObject(efficiencyGraph_WWTightToHLT, efficiencyGraph_WWTightToHLT->GetName(), "WriteDelete");

    } //end for loop over eta bins
  } //end for loop over charge bins

  file->Close();

  Int_t errorType = 2; //Clopper Pearson intervals
  Double_t ratio;
  Double_t errLow;
  Double_t errHigh;     
  Double_t n1;
  Double_t n2;


  n1 = TMath::Nint(EventCount_TagPlusRecoPassWWTightIdIso);
  n2 = TMath::Nint(EventCount_TagPlusRecoPassWWTightIdIso + EventCount_TagPlusRecoFailWWTightIdIso);
  if (n1 > n2) n1 = n2;
  mithep::MathUtils::CalcRatio(n1 , n2, ratio, errLow, errHigh, errorType);      
  cout << "Reco -> WWTight  Efficiency (MC) : " << n1 << " / " << n2 << " = " << ratio << " + " << errHigh << " - " << errLow << endl;
  cout << "\n";



  n1 = TMath::Nint(EventCount_TagPlusWWTightIdIsoPassHLT);
  n2 = TMath::Nint(EventCount_TagPlusWWTightIdIsoPassHLT + EventCount_TagPlusWWTightIdIsoFailHLT);
  if (n1 > n2) n1 = n2;
  mithep::MathUtils::CalcRatio(n1 , n2, ratio, errLow, errHigh, errorType);      
  cout << "WWTight  -> HLT : " << n1 << " / " << n2 << " = " << ratio << " + " << errHigh << " - " << errLow << endl;
  cout << "\n";

  

  cout << "**********************************************************************\n";

      
  gBenchmark->Show("ElectronTagAndProbe");       


} 
Пример #15
0
void kees_gen() {
  gROOT->SetStyle("HALLA");
  TCanvas *cn = new TCanvas("cn");
  cn->Draw();
  cn->UseCurrentStyle();
  TH1F *frm = new TH1F("frm","",100,0.,10.);
  frm->GetXaxis()->SetTitle("Q^{2}  [GeV^{2}]");
  frm->GetYaxis()->SetTitle("G_{E}^{n}");
  frm->SetMinimum(-.02);
  frm->SetMaximum(0.1);
  frm->UseCurrentStyle();
  frm->Draw();
  frm->SetAxisRange(0.,5.,"X");

  TF1 *genf = new TF1("genf",genff,1.,10.,1);
  genf->SetLineColor(2);
  genf->SetLineStyle(2);
  genf->SetParameter(0,1.);
  genf->SetParameter(1,.3);
  genf->SetParameter(0,-0.632);
  // match to Madey point just below 1.5
  //  genf->SetParameter(0,.0411/genf->Eval(1.45));
  
  TMultiGraph* mgrDta = new TMultiGraph("Data","G_{E}^{n}");
  TLegend *legDta = new TLegend(.54,.6,.875,.90,"","brNDC");

  TMultiGraph* wgr = mgrDta;
  TLegend *wlg = legDta;

   // the data
  legDta->SetBorderSize(0); // turn off border
  legDta->SetFillStyle(0);
  
  datafile_t *f = datafiles;
  TGraph* gr=0;
  while ( f && f->filename ) {
    gr=OneGraph(f);
    if (gr) {
      if (f->lnpt) {
	mgrDta->Add(gr,f->lnpt);
	legDta->AddEntry(gr,f->label,f->lnpt);
      }
      else if (gr->GetMarkerStyle()>=20) {
	mgrDta->Add(gr,"p");
	legDta->AddEntry(gr,f->label,"p");
      }	
      else {
	mgrDta->Add(gr,"l");
	legDta->AddEntry(gr,f->label,"l");
      }
    }
    f++;
  }
    

  mgrDta->Draw("p");
  //  legDta->Draw();   don't draw the data legend
  
  TMultiGraph* mgrThry = new TMultiGraph("Theory","G_{E}^{n}");
  TLegend *legThry = new TLegend(.54,.6,.875,.9,"","brNDC");

  wgr = mgrThry;
  wlg = legThry;

  // the theory
  wlg->SetBorderSize(0); // turn off border
  wlg->SetFillStyle(0);
  
  f = theoryfiles1;
  gr=0;
  while ( f && f->filename ) {
    gr=OneGraph(f);
    if (gr) {
      TGraphAsymmErrors *egr = dynamic_cast<TGraphAsymmErrors*>(gr);
      if (egr && egr->GetN()>1 && egr->GetEYhigh() && egr->GetEYhigh()[1]>0) {
	gr = toerror_band(egr);
	gr->SetFillStyle(3000+f->style);
      }
      if (f->lnpt) {
	wgr->Add(gr,f->lnpt);
	wlg->AddEntry(gr,f->label,f->lnpt);
      }
      else if (gr->GetMarkerStyle()>=20) {
	wgr->Add(gr,"p");
	wlg->AddEntry(gr,f->label,"p");
      }	
      else {
	wgr->Add(gr,"l");
	wlg->AddEntry(gr,f->label,"l");
      }
    }
    f++;
  }

  genf->Draw("same");
  mgrThry->Draw("c");
  legThry->AddEntry(genf,"F_{2}/F_{1} #propto ln^{2}(Q^{2}/#Lambda^{2})/Q^{2}","l");
  legThry->Draw();

  // draw a line at 1
  cn->Modified();

  cn->Update();
  cn->SaveAs(Form("%s.eps",psfile));
  cn->SaveAs(Form("%s.root",psfile));
  gSystem->Exec(Form("./replace_symbols.pl %s.eps",psfile));
  // now an overlay, hopefully matching dimensions

  // remove everything but the graph
  cn->Update();
  TList *clist = cn->GetListOfPrimitives();
  TFrame* frame = cn->GetFrame();
  for (int i=0; i<clist->GetSize(); ) {
    if (clist->At(i) != frame) {
      clist->RemoveAt(i);
    } else i++;
  }
  // draw markers in the corners
  TMarker *mkr = new TMarker(frame->GetX1(),frame->GetY1(),2);
  mkr->Draw();
  mkr = new TMarker(frame->GetX2(),frame->GetY1(),2);
  mkr->Draw();
  mkr = new TMarker(frame->GetX1(),frame->GetY2(),2);
  mkr->Draw();
  mkr = new TMarker(frame->GetX2(),frame->GetY2(),2);
  mkr->Draw();
  frame->SetLineColor(10);
  cn->Update();

  datafile_t miller = { "figure_input/Miller/lattice.GEn.rtf","Miller",
			"[0]","[1]","[1]-[3]","[2]-[1]",0,0,1,3,"F" };

  gr = OneGraph(&miller);
  TGraphAsymmErrors* egr = dynamic_cast<TGraphAsymmErrors*>(gr);
  if (egr && egr->GetEYhigh() && egr->GetEYhigh()[egr->GetN()/2]>0) {
    gr = toerror_band(egr);
    gr->SetLineStyle(1);
    gr->SetFillColor(gr->GetLineColor());
    gr->SetFillStyle(3000+miller.style);
  }
  
  gr->Draw("F");

  cn->Update();
  cn->SaveAs("gen_Miller_Overlay.eps");
  cn->SaveAs("gen_Miller_Overlay.root");
  
}
Пример #16
0
TCanvas* NAtRatio(){

  TGraphErrors *NatSig = new TGraphErrors(6);
  TGraphErrors *NatCtrl = new TGraphErrors(6); 


 TH1D *Sig0 = ((TH1D*)Sig->Get("kinplot/AlphaT_0"))->Clone();
 TH1D *Ctrl0= ((TH1D*)Bkgd->Get("kinplot/AlphaT_0"))->Clone();

 TH1D *Sig50 = ((TH1D*)Sig->Get("kinplot_afterHT_50/AlphaT_0"))->Clone();
 TH1D *Ctrl50= ((TH1D*)Bkgd->Get("kinplot_afterHT_50/AlphaT_0"))->Clone();

 TH1D *Sig100 = ((TH1D*)Sig->Get("kinplot_afterHT_100/AlphaT_0"))->Clone();
 TH1D *Ctrl100= ((TH1D*)Bkgd->Get("kinplot_afterHT_100/AlphaT_0"))->Clone();

 TH1D *Sig150 = ((TH1D*)Sig->Get("kinplot_afterHT_150/AlphaT_0"))->Clone();
 TH1D *Ctrl150= ((TH1D*)Bkgd->Get("kinplot_afterHT_150/AlphaT_0"))->Clone();

 TH1D *Sig200 = ((TH1D*)Sig->Get("kinplot_afterHT_200/AlphaT_0"))->Clone();
 TH1D *Ctrl200= ((TH1D*)Bkgd->Get("kinplot_afterHT_200/AlphaT_0"))->Clone();

 TH1D *Sig250 = ((TH1D*)Sig->Get("kinplot_afterHT_250/AlphaT_0"))->Clone();
 TH1D *Ctrl250= ((TH1D*)Bkgd->Get("kinplot_afterHT_250/AlphaT_0"))->Clone();



 NatSig->SetPoint(0,0.,(Sig0->Integral(55,300)/Sig0->Integral(0,54)));
 NatSig->SetPoint(1,50.,(Sig50->Integral(55,300)/Sig50->Integral(0,54)));
 NatSig->SetPoint(2,100.,(Sig100->Integral(55,300)/Sig100->Integral(0,54)));
 NatSig->SetPoint(3,150.,(Sig150->Integral(55,300)/Sig150->Integral(0,54)));
 NatSig->SetPoint(4,200.,(Sig200->Integral(55,300)/Sig200->Integral(0,54)));
 NatSig->SetPoint(5,250.,(Sig250->Integral(55,300)/Sig250->Integral(0,54)));



 NatSig->SetPointError(0,1.,sqrt(Sig0->Integral(55,300)/Sig0->Integral(0,54)));
 NatSig->SetPointError(1,1.,sqrt(Sig50->Integral(55,300)/Sig50->Integral(0,54)));
 NatSig->SetPointError(2,1.,sqrt(Sig100->Integral(55,300)/Sig100->Integral(0,54)));
 NatSig->SetPointError(3,1.,sqrt(Sig150->Integral(55,300)/Sig150->Integral(0,54)));
 NatSig->SetPointError(4,1.,sqrt(Sig200->Integral(55,300)/Sig200->Integral(0,54)));
 NatSig->SetPointError(5,1.,sqrt(Sig250->Integral(55,300)/Sig250->Integral(0,54)));

 NatCtrl->SetPoint(0,0.,(Ctrl0->Integral(55,300)/Ctrl0->Integral(0,54)));
 NatCtrl->SetPoint(1,50.,(Ctrl50->Integral(55,300)/Ctrl50->Integral(0,54)));
 NatCtrl->SetPoint(2,100.,(Ctrl100->Integral(55,300)/Ctrl100->Integral(0,54)));
 NatCtrl->SetPoint(3,150.,(Ctrl150->Integral(55,300)/Ctrl150->Integral(0,54)));
 NatCtrl->SetPoint(4,200.,(Ctrl200->Integral(55,300)/Ctrl200->Integral(0,54)));
 NatCtrl->SetPoint(5,250.,(Ctrl250->Integral(55,300)/Ctrl250->Integral(0,54)));



 NatCtrl->SetPointError(0,1.,sqrt(Ctrl0->Integral(55,300)/Ctrl0->Integral(0,54)));
 NatCtrl->SetPointError(1,1.,sqrt(Ctrl50->Integral(55,300)/Ctrl50->Integral(0,54)));
 NatCtrl->SetPointError(2,1.,sqrt(Ctrl100->Integral(55,300)/Ctrl100->Integral(0,54)));
 NatCtrl->SetPointError(3,1.,sqrt(Ctrl150->Integral(55,300)/Ctrl150->Integral(0,54)));
 NatCtrl->SetPointError(4,1.,sqrt(Ctrl200->Integral(55,300)/Ctrl200->Integral(0,54)));
 NatCtrl->SetPointError(5,1.,sqrt(Ctrl250->Integral(55,300)/Ctrl250->Integral(0,54)));




  gROOT->SetStyle("Plain");


TCanvas* c = new TCanvas("NalphaT_Ratio","NAlphaT_Ratio");
 c->SetLogy();
 TLegend *leg = new TLegend(0.5,0.8,0.99,0.99);
 leg->SetFillColor(0);
 leg->AddEntry(NatSig,"Selected Events","P");
 leg->AddEntry(NatCtrl,"Anti-selected events","P");
 NatSig->SetMarkerColor(kRed);
 NatSig->SetMarkerStyle(kFullCircle);
 NatSig->SetLineColor(kRed);
 NatSig->SetLineWidth(2);
 NatCtrl->SetMarkerColor(kBlue);
 NatCtrl->SetMarkerStyle(kFullCircle);
 NatCtrl->SetLineColor(kBlue);
 NatCtrl->SetLineWidth(2);
 NatCtrl->Draw("APX");
 NatSig->Draw("PX");



 //NatSig->Fit("pol1");
 NatCtrl->GetXaxis()->SetTitle("HT Cut [GeV]");
 NatCtrl->GetYaxis()->SetTitle("#frac{N(#alpha_{T}>0.55)}{N(#alpha_{T}<0.55)}");

 NatCtrl->GetXaxis()->SetTitle("HT Cut [GeV]");
 NatCtrl->GetYaxis()->SetRangeUser(0.0005,0.5);
 NatCtrl->SetTitle();
 leg->Draw("SAME");

 c->Update();
 c->SaveAs(saving+"NAlphaTRatio_plot.png");
 return c;
}
Пример #17
0
void PlotPedestalsvsTime(Int_t year=2011, Int_t firstRun=141820, 
		   Int_t lastRun=146900, Int_t ipedGainChain=0)
{


  TGrid::Connect("alien:",0,0,"t");
  gSystem->Exec(Form("gbbox find \"/alice/data/%d/OCDB/ZDC/Calib/Pedestals/\" \"Run*.root\" > calibAlienFiles.txt",year));
  FILE* listruns=fopen("calibAlienFiles.txt","r");
  
  const int kNchannels=24;
  TGraphErrors* graph[24];
  for(Int_t i=0; i<kNchannels; i++){
     graph[i] = new TGraphErrors(0);
     char name[50], title[50];
     sprintf(name,"graph%d",i); sprintf(title,"Pedestal ch.%d vs. run#",i);
     graph[i]->SetName("graph");  graph[i]->SetTitle("title");
  }

  Char_t filnam[200], filnamalien[200];
  Int_t iPoint=0;
  Int_t nrun, nrun2, nv, ns;

  while(!feof(listruns)){
    int st = fscanf(listruns,"%s\n",filnam);    
    Char_t directory[100];
    sprintf(directory,"/alice/data/%d",year);
    if(!strstr(filnam,directory)) continue;
    sscanf(filnam,"/alice/data/%d/OCDB/ZDC/Calib/Pedestals/Run%d_%d_v%d_s%d.root",&year,&nrun,&nrun2,&nv,&ns);
    if(nrun<firstRun) continue;
    if(nrun>lastRun) continue;
    sprintf(filnamalien,"alien://%s",filnam);
    printf("Opening file: %s\n",filnam);
    TFile *f = TFile::Open(filnamalien);  
    AliCDBEntry *entry = (AliCDBEntry*)f->Get("AliCDBEntry");
    AliZDCPedestals *calibdata = dynamic_cast<AliZDCPedestals*>  (entry->GetObject());
    
    for(int i=0; i<kNchannels; i++){
      if(ipedGainChain==0){
        graph[i]->SetPoint(iPoint, (Double_t)nrun, calibdata->GetMeanPed(i));
        graph[i]->SetPointError(iPoint, 0., calibdata->GetMeanPedWidth(i));
      }
      else{
        graph[i]->SetPoint(iPoint, (Double_t)nrun, calibdata->GetMeanPed(i+kNchannels));
        graph[i]->SetPointError(iPoint, 0., calibdata->GetMeanPedWidth(i+kNchannels));
      }
    }
    iPoint++;
    f->Close();
 }

 TFile *outfile=new TFile(Form("PedCalib%dVsTime.root",year),"recreate");
 outfile->cd();
 for(int i=0; i<kNchannels; i++) graph[i]->Write();
 outfile->Close();

 //***********************************************************
 // #### ROOT initialization
 gROOT->Reset();
 gStyle->SetCanvasColor(10);
 gStyle->SetFrameFillColor(10);
 gStyle->SetOptTitle(0);
 gStyle->SetOptStat(1111);
 gStyle->SetOptFit(0);
 gStyle->SetTitleTextColor(4);
 gStyle->SetStatTextColor(4);
 gStyle->SetStatX(0.92);
 gStyle->SetStatY(0.92);
 gStyle->SetLineColor(1);
 gStyle->SetPalette(1);
 gStyle->SetPadTopMargin(0.05);
 gStyle->SetPadRightMargin(0.05);
 gStyle->SetPadBottomMargin(0.09);
 gStyle->SetPadLeftMargin(0.09); 
 gStyle->SetTitleOffset(1.1,"Y");  
 // *************************************************************

 TCanvas *cHadPeds = new TCanvas("cHadPeds","Hadronic ZDC pedestals",0,0,1000,800);
 cHadPeds->Divide(5,4);
 for(int ic=0; ic<5; ic++){
   // *** ZNC pedestals
   cHadPeds->cd(ic+1);
   //
   TH1F *haxis1=0;
   if(ipedGainChain==0){
     if(ic==0) haxis1 = gPad->DrawFrame(firstRun-100, 80, lastRun+100, 100);
     else  haxis1 = gPad->DrawFrame(firstRun-100, 50, lastRun+100, 70);
   }
   else{
     if(ic==0) haxis1 = gPad->DrawFrame(firstRun-100, 500, lastRun+100, 800);
     else  haxis1 = gPad->DrawFrame(firstRun-100, 300, lastRun+100, 600);
   }
   haxis1->GetXaxis()->SetNoExponent();
   haxis1->SetXTitle("RUN no.");
   haxis1->SetYTitle("ZNC pedestals");
   //
   graph[ic]->SetMarkerStyle(20);
   graph[ic]->SetMarkerColor(kBlue);
   graph[ic]->Draw("P, SAME");
   // *** ZPC pedestals
   cHadPeds->cd(ic+6);
   //
   TH1F *haxis2=0;
   if(ipedGainChain==0) haxis2= gPad->DrawFrame(firstRun-100, 55, lastRun+100, 85);
   else  haxis2 = gPad->DrawFrame(firstRun-100, 400, lastRun+100, 700);
   haxis2->GetXaxis()->SetNoExponent();
   haxis2->SetXTitle("RUN no.");
   haxis2->SetYTitle("ZPC pedestals");
   //
   graph[ic+5]->SetMarkerStyle(21);
   graph[ic+5]->SetMarkerColor(kBlue+3);
   graph[ic+5]->Draw("P, SAME");
   // *** ZNA pedestals
   cHadPeds->cd(ic+11);
   //
   TH1F *haxis3=0;
   if(ipedGainChain==0) haxis3 = gPad->DrawFrame(firstRun-100, 35, lastRun+100, 85);
   else  haxis3 = gPad->DrawFrame(firstRun-100, 300, lastRun+100, 700);
   haxis3->GetXaxis()->SetNoExponent();
   haxis3->SetXTitle("RUN no.");
   haxis3->SetYTitle("ZNA pedestals");
   //
   graph[ic+12]->SetMarkerStyle(20);
   graph[ic+12]->SetMarkerColor(kRed);
   graph[ic+12]->Draw("P, SAME");
   // *** ZPA pedestals
   cHadPeds->cd(ic+16);
   //
   TH1F *haxis4=0;
   if(ipedGainChain==0) haxis4 = gPad->DrawFrame(firstRun-100, 40, lastRun+100, 80);
   else  haxis4 = gPad->DrawFrame(firstRun-100, 300, lastRun+100, 600);
   haxis4->GetXaxis()->SetNoExponent();
   haxis4->SetXTitle("RUN no.");
   haxis4->SetYTitle("ZPA pedestals");
   //
   graph[ic+17]->SetMarkerStyle(21);
   graph[ic+17]->SetMarkerColor(kRed+1);
   graph[ic+17]->Draw("P, SAME");
 }
 cHadPeds->SaveAs("ZDCPedvsTime1.gif");
 cHadPeds->SaveAs("ZDCPedvsTime1.C");

 TCanvas *cothPeds = new TCanvas("cothPeds","ZEM + Ref. pedestals",800,0,600,600);
 cothPeds->Divide(2,2);
 for(int ic=0; ic<2; ic++){
    // *** ZEM pedestals
    cothPeds->cd(ic+1);
    //
    TH1F *haxis5=0;
    if(ipedGainChain==0) haxis5 = gPad->DrawFrame(firstRun-100, 30, lastRun+20, 70);
    else  haxis5 = gPad->DrawFrame(firstRun-100, 250, lastRun+100, 550);
    haxis5->GetXaxis()->SetNoExponent();
    haxis5->SetXTitle("RUN no.");
    haxis5->SetYTitle("ZEM pedestals");
    //
    graph[ic+10]->SetMarkerStyle(22);
    graph[ic+10]->SetMarkerColor(kGreen+1);
    graph[ic+10]->Draw("P, SAME");
    // *** Ref. pedestals
    cothPeds->cd(ic+3);
    //
    TH1F *haxis6=0; 
    if(ipedGainChain==0) haxis6 = gPad->DrawFrame(firstRun-100, 50, lastRun+100, 90);
    else  haxis6 = gPad->DrawFrame(firstRun-100, 400, lastRun+100, 700);
    haxis6->GetXaxis()->SetNoExponent();
    haxis6->SetXTitle("RUN no.");
    haxis6->SetYTitle("PMRef. pedestals");
    //
    graph[ic+22]->SetMarkerStyle(23);
    graph[ic+22]->SetMarkerColor(kGreen+4);
    graph[ic+22]->Draw("P, SAME");
 }
 cothPeds->SaveAs("ZDCPedvsTime2.gif");
 cothPeds->SaveAs("ZDCPedvsTime2.C");
 
}
Пример #18
0
fitResult getPurity(TString fname, sampleType collision, TCut evtSeltCut, TCut sbEvtCut, TString canvasName, float photonPtThr, float photonPtThrUp) {
  double purity(0);
  
  multiTreeUtil* tgj = new multiTreeUtil();
  multiTreeUtil* tgjMC = new multiTreeUtil();
  cout << " Calculating Purity....." << endl;           
  tgj->addFile(fname,  "tgj",  "",  1);         //  tgj->AddFriend("yTrk");
  if   (collision==kPPDATA) { 
    tgjMC->addFile(fnamePPMC_AllQcdPho30to50,    "tgj", "", wPPMC_AllQcdPho30to50 ); 
    tgjMC->addFile(fnamePPMC_AllQcdPho50to80,    "tgj", "", wPPMC_AllQcdPho50to80 ); 
    tgjMC->addFile(fnamePPMC_AllQcdPho80to120,   "tgj", "", wPPMC_AllQcdPho80to120); 
    tgjMC->addFile(fnamePPMC_AllQcdPho120to9999, "tgj", "", wPPMC_AllQcdPho120to9999); 
  }
  else if (collision==kPADATA)     {
    tgjMC->addFile(fnamePAMC_AllQcdPho30to50,     "tgj","", wPAMC_AllQcdPho30to50);
    tgjMC->addFile(fnamePAMC_AllQcdPho50to80,     "tgj","", wPAMC_AllQcdPho50to80);
    tgjMC->addFile(fnamePAMC_AllQcdPho80to120,    "tgj","", wPAMC_AllQcdPho80to120);
    tgjMC->addFile(fnamePAMC_AllQcdPho120to9999,  "tgj","", wPAMC_AllQcdPho120to9999);
  }
  else if (collision==kHIDATA)  {
     /*    tgjMC->addFile(fnameHIMC_AllQcdPho30to50,     "tgj", "",wHIMC_AllQcdPho30to50);
	   tgjMC->addFile(fnameHIMC_AllQcdPho50to80,     "tgj", "",wHIMC_AllQcdPho50to80);
	   tgjMC->addFile(fnameHIMC_AllQcdPho80to9999,   "tgj", "",wHIMC_AllQcdPho80to9999);       */
     tgjMC->addFile(fnameHIMC_AllQcdPho30to9999,   "tgj", "",wHIMC_AllQcdPho80to9999);
  }   
  else { 
    cout << " Error: getPurity.  check the type of the collision!  " << endl;
    fitResult fitr0;
    return fitr0;
  }
  
  TH1D* hCand = new TH1D("cand","",25,0,0.025);
  TH1D* hBkg = (TH1D*)hCand->Clone("bkg");  TH1D* hSig = (TH1D*)hCand->Clone("sig");
  
  tgj->Draw2(   hCand, "sigmaIetaIeta", evtSeltCut , "");
  tgj->Draw2(   hBkg, "sigmaIetaIeta", sbEvtCut , "");
  tgjMC->Draw2( hSig, "sigmaIetaIeta", evtSeltCut && "genIso<5 && abs(genMomId)<=22", "");

  handsomeTH1(hCand,1);
  handsomeTH1(hSig,2);
  handsomeTH1(hBkg,4);
  
  hCand->Draw();
  hSig->Draw("same");
  hBkg->Draw("same hist");

  TCanvas* cPurity = new TCanvas("cpurity","",500,500);
  fitResult  fitr = doFit ( hSig, hBkg, hCand, 0.005, 0.025);
  drawText(Form("Purity : %.2f", (float)fitr.purity010), 0.5680963,0.429118);
  drawText(Form("p_{T}^{#gamma}: %d-%d GeV", (int)photonPtThr, (int)photonPtThrUp), 0.568,0.529118);
  cPurity->SaveAs( Form("%s.pdf",canvasName.Data() ) );
  //  gPad->SetLogy();   cPurity->SaveAs( Form("%s_logScale.pdf",canvasName.Data() ) );
   
  TCanvas* c1 = new TCanvas("c1","",100,100);
  
  
  delete tgj;
  delete tgjMC;
  delete hSig;
  delete hBkg;
  delete hCand;
  
  return fitr;
  
  
}
Пример #19
0
TCanvas *plotmean(TString selecter)
{
 TCanvas *cWork = NULL; 
 if( selecter == "L" )
 {
   cWork = new TCanvas("cWork", "plots",200,10,700,500);
   cWork->Divide(2,2);
   plotmean(cWork, 1, "JP", selecter);
   plotmean(cWork, 2, "JBP", selecter);
   plotmean(cWork, 3, "CSV", selecter);
   plotmean(cWork, 4, "TCHE", selecter);
 }
 else if( selecter == "M" )
 {
   cWork = new TCanvas("cWork", "plots",200,10,700,750);
   cWork->Divide(2,3);
   plotmean(cWork, 1, "JP", selecter);
   plotmean(cWork, 2, "JBP", selecter);
   plotmean(cWork, 3, "CSV", selecter);
   plotmean(cWork, 4, "TCHE", selecter);
   plotmean(cWork, 5, "TCHP", selecter);
   plotmean(cWork, 6, "SSVHE", selecter);
 }
 else if( selecter == "T" )
 {
   cWork = new TCanvas("cWork", "plots",200,10,700,750);
   cWork->Divide(2,3);
   plotmean(cWork, 1, "JP", selecter);
   plotmean(cWork, 2, "JBP", selecter);
   plotmean(cWork, 3, "CSV", selecter);
   //plotmean(cWork, 4, "TCHE", selecter);
   plotmean(cWork, 5, "TCHP", selecter);
   plotmean(cWork, 6, "SSVHP", selecter);
 }
 else if( selecter == "TCHE" )
 {
   cWork = new TCanvas("cWork", "plots",200,10,700,500);
   cWork->Divide(1,2);
   plotmean(cWork, 1, selecter, "L");
   plotmean(cWork, 2, selecter, "M");
 }
 else if( selecter == "TCHP" )
 {
   cWork = new TCanvas("cWork", "plots",200,10,700,500);
   cWork->Divide(1,2);
   plotmean(cWork, 1, selecter, "M");
   plotmean(cWork, 2, selecter, "T");
 }
 else if( selecter == "SSVHE" )
 {
   cWork = new TCanvas("cWork", "plots",200,10,700,250);
   plotmean(cWork, 0, selecter, "M");
 }
 else if( selecter == "SSVHP" )
 {
   cWork = new TCanvas("cWork", "plots",200,10,700,250);
   plotmean(cWork, 0, selecter, "T");
 }
 else
 {
   cWork = new TCanvas("cWork", "plots",200,10,700,750);
   cWork->Divide(1,3);
   plotmean(cWork, 1, selecter, "L");
   plotmean(cWork, 2, selecter, "M");
   plotmean(cWork, 3, selecter, "T");
 }

 cWork->WaitPrimitive();
 cWork->SaveAs("MistagFunc_"+selecter+".pdf");
 return cWork;
}
Пример #20
0
void PlotGluonFusionHiggsShapeSystematics() {


  TFile *file = new TFile("/data/blue/sixie/Thesis/Limits/MVAIDIsoCombinedDetIsoSameSigWP/130/hww130_of_0j.input.root","READ");
  TH1F *DefaultShape;
  TH1F *UpShape;
  TH1F *DownShape;
  TCanvas *cv ;
  TLegend *legend;



  //*************************
  //ggH signal - DF 0Jet
  //*************************

  DefaultShape = (TH1F*)file->Get("histo_ggH");
  UpShape = (TH1F*)file->Get("histo_ggH_CMS_MVAggHBoundingUp");
  DownShape = (TH1F*)file->Get("histo_ggH_CMS_MVAggHBoundingDown");

  assert(DefaultShape);
  assert(UpShape);
  assert(DownShape);


  //Make relative histograms
  UpShapeRelative = MakeRelative(UpShape,DefaultShape);
  DownShapeRelative = MakeRelative(DownShape,DefaultShape);


  cv = new TCanvas("cv","cv",800,600);

  pad1 = new TPad("pad1","pad1", 0,0.2,1,1);
  pad1->SetBottomMargin(0.125);
  pad1->Draw();
  pad1->cd();

  legend = new TLegend(0.2, 0.6, 0.5, 0.9);
  legend->SetTextSize(0.04);
  legend->SetBorderSize(0);
  legend->SetFillColor(kWhite);
  legend->AddEntry(DefaultShape, "Default Shape", "L");
  legend->AddEntry(UpShape, "Systematics Shape (Up)", "L");
  legend->AddEntry(DownShape, "Systematics Shape (Down)", "L");

  DefaultShape->SetLineColor(kBlack);
  UpShape->SetLineColor(kBlue);
  DownShape->SetLineColor(kRed);
  DefaultShape->SetLineWidth(2);
  UpShape->SetLineWidth(2);
  DownShape->SetLineWidth(2);
  DefaultShape->SetTitle("");
  DefaultShape->GetXaxis()->SetTitle("MVA discriminator");
  DefaultShape->GetYaxis()->SetTitle("Number of Events");
  DefaultShape->GetYaxis()->SetTitleOffset(1.1);
  DefaultShape->GetXaxis()->SetTitleOffset(1.05);
  DefaultShape->GetXaxis()->SetRangeUser(-1.0,1.0);
  DefaultShape->GetYaxis()->SetRangeUser(0.0,13);

  DefaultShape->Draw("hist");
  UpShape->Draw("same,hist");
  DownShape->Draw("same,hist");
  legend->Draw();

  cv->cd();
  pad2 = new TPad("pad2","pad2", 0,0,1,0.2);
  pad1->SetTopMargin(0.01);
  pad2->Draw();
  pad2->cd();

  UpShapeRelative->GetYaxis()->SetTitle("% Difference");
  UpShapeRelative->GetYaxis()->SetTitleSize(0.15);
  UpShapeRelative->GetYaxis()->SetTitleOffset(0.3);
  UpShapeRelative->GetYaxis()->SetRangeUser(-3,3);
  UpShapeRelative->GetYaxis()->SetLabelSize(0.15);
  UpShapeRelative->GetXaxis()->SetLabelSize(0.0);
  UpShapeRelative->SetLineColor(kBlue);
  UpShapeRelative->SetMarkerColor(kBlue);
  UpShapeRelative->Draw("hist");
  DownShapeRelative->SetLineColor(kRed);
  DownShapeRelative->SetMarkerColor(kRed);
  DownShapeRelative->Draw("hist,same");


  cv->SaveAs("ggHShapeVariation_ggH_0Jet_DF.png");
  cv->SaveAs("ggHShapeVariation_ggH_0Jet_DF.eps");

  //*************************
  //ggH signal - SF 0Jet
  //*************************
  file = new TFile("/data/blue/sixie/Thesis/Limits/MVAIDIsoCombinedDetIsoSameSigWP/130/hww130_sf_0j.input.root","READ");

  DefaultShape = (TH1F*)file->Get("histo_ggH");
  UpShape = (TH1F*)file->Get("histo_ggH_CMS_MVAggHBoundingUp");
  DownShape = (TH1F*)file->Get("histo_ggH_CMS_MVAggHBoundingDown");

  assert(DefaultShape);
  assert(UpShape);
  assert(DownShape);


  //Make relative histograms
  UpShapeRelative = MakeRelative(UpShape,DefaultShape);
  DownShapeRelative = MakeRelative(DownShape,DefaultShape);


  cv = new TCanvas("cv","cv",800,600);

  pad1 = new TPad("pad1","pad1", 0,0.2,1,1);
  pad1->SetBottomMargin(0.125);
  pad1->Draw();
  pad1->cd();

  legend = new TLegend(0.2, 0.6, 0.5, 0.9);
  legend->SetTextSize(0.04);
  legend->SetBorderSize(0);
  legend->SetFillColor(kWhite);
  legend->AddEntry(DefaultShape, "Default Shape", "L");
  legend->AddEntry(UpShape, "Systematics Shape (Up)", "L");
  legend->AddEntry(DownShape, "Systematics Shape (Down)", "L");

  DefaultShape->SetLineColor(kBlack);
  UpShape->SetLineColor(kBlue);
  DownShape->SetLineColor(kRed);
  DefaultShape->SetLineWidth(2);
  UpShape->SetLineWidth(2);
  DownShape->SetLineWidth(2);
  DefaultShape->SetTitle("");
  DefaultShape->GetXaxis()->SetTitle("MVA discriminator");
  DefaultShape->GetYaxis()->SetTitle("Number of Events");
  DefaultShape->GetYaxis()->SetTitleOffset(1.1);
  DefaultShape->GetXaxis()->SetTitleOffset(1.05);
  DefaultShape->GetXaxis()->SetRangeUser(-1.0,1.0);
  DefaultShape->GetYaxis()->SetRangeUser(0.0,5.5);

  DefaultShape->Draw("hist");
  UpShape->Draw("same,hist");
  DownShape->Draw("same,hist");
  legend->Draw();

  cv->cd();
  pad2 = new TPad("pad2","pad2", 0,0,1,0.2);
  pad1->SetTopMargin(0.01);
  pad2->Draw();
  pad2->cd();

  UpShapeRelative->GetYaxis()->SetTitle("% Difference");
  UpShapeRelative->GetYaxis()->SetTitleSize(0.15);
  UpShapeRelative->GetYaxis()->SetTitleOffset(0.3);
  UpShapeRelative->GetYaxis()->SetRangeUser(-3,3);
  UpShapeRelative->GetYaxis()->SetLabelSize(0.15);
  UpShapeRelative->GetXaxis()->SetLabelSize(0.0);
  UpShapeRelative->SetLineColor(kBlue);
  UpShapeRelative->SetMarkerColor(kBlue);
  UpShapeRelative->Draw("hist");
  DownShapeRelative->SetLineColor(kRed);
  DownShapeRelative->SetMarkerColor(kRed);
  DownShapeRelative->Draw("hist,same");


  cv->SaveAs("ggHShapeVariation_ggH_0Jet_SF.png");
  cv->SaveAs("ggHShapeVariation_ggH_0Jet_SF.eps");



}
Пример #21
0
TF1* fit(Double_t ptmin, Double_t ptmax)
{
  TCanvas* c = new TCanvas(Form("c_%.0f_%.0f",ptmin,ptmax),"",600,600);
  TFile* infile = new TFile(Form("%s_%s_%.0f_%.0f.root",infname.Data(),collisionsystem.Data(),ptmin,ptmax));
  TH1D* h = (TH1D*)infile->Get("h");                    h->SetName(Form("h_%.0f_%.0f",ptmin,ptmax));
  TH1D* hMCSignal = (TH1D*)infile->Get("hMCSignal");    hMCSignal->SetName(Form("hMCSignal_%.0f_%.0f",ptmin,ptmax));
  TH1D* hMCSwapped = (TH1D*)infile->Get("hMCSwapped");  hMCSwapped->SetName(Form("hMCSwapped_%.0f_%.0f",ptmin,ptmax));
  TF1* f = new TF1(Form("f_%.0f_%.0f",ptmin,ptmax),"[0]*([7]*([9]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2])+(1-[9])*Gaus(x,[1],[10])/(sqrt(2*3.14159)*[10]))+(1-[7])*Gaus(x,[1],[8])/(sqrt(2*3.14159)*[8]))+[3]*exp([4]*x)", 1.7, 2.0);

  f->SetParLimits(10,0.001,0.05);
  f->SetParLimits(2,0.01,0.1);
  f->SetParLimits(8,0.02,0.2);
  f->SetParLimits(7,0,1);
  f->SetParLimits(9,0,1);
  
  f->SetParameter(0,setparam0);
  f->SetParameter(1,setparam1);
  f->SetParameter(2,setparam2);
  f->SetParameter(10,setparam10);
  f->SetParameter(9,setparam9);

  f->FixParameter(8,setparam8);
  f->FixParameter(7,1);
  f->FixParameter(1,fixparam1);
  f->FixParameter(3,0);
  f->FixParameter(4,0);
  h->GetEntries();
  
  hMCSignal->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"q","",minhisto,maxhisto);
  hMCSignal->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"q","",minhisto,maxhisto);
  f->ReleaseParameter(1);
  hMCSignal->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto);
  hMCSignal->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto);
  hMCSignal->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L m","",minhisto,maxhisto);
  
  f->FixParameter(1,f->GetParameter(1));
  f->FixParameter(2,f->GetParameter(2));
  f->FixParameter(10,f->GetParameter(10));
  f->FixParameter(9,f->GetParameter(9));
  f->FixParameter(7,0);
  f->ReleaseParameter(8);
  f->SetParameter(8,setparam8);
  
  hMCSwapped->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto);
  hMCSwapped->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto);
  hMCSwapped->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto);
  hMCSwapped->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L m","",minhisto,maxhisto);
  
  f->SetParLimits(0,0,1.e+6);
  f->FixParameter(7,hMCSignal->Integral(0,1000)/(hMCSwapped->Integral(0,1000)+hMCSignal->Integral(0,1000)));
  f->FixParameter(8,f->GetParameter(8));
  f->ReleaseParameter(3);
  f->ReleaseParameter(4);
  f->SetParLimits(3,0,1.e+10);
  f->SetParameter(3,1.e+3);

  f->SetLineColor(kRed);
  
  h->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"q","",minhisto,maxhisto);
  h->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"q","",minhisto,maxhisto);
  f->ReleaseParameter(1);
  f->SetParLimits(1,1.85,1.90);
  //f->ReleaseParameter(2);                                     // you need to release these two parameters if you want to perform studies on the sigma shape
  //f->ReleaseParameter(10);                                   // you need to release these two parameters if you want to perform studies on the sigma shape
  h->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto);
  h->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto);
  h->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L q","",minhisto,maxhisto);
  h->Fit(Form("f_%.0f_%.0f",ptmin,ptmax),"L m","",minhisto,maxhisto);
  
  TF1* background = new TF1(Form("background_%.0f_%.0f",ptmin,ptmax),"[0]*exp([1]*x)");
  background->SetParameter(0,f->GetParameter(3));
  background->SetParameter(1,f->GetParameter(4));
  background->SetLineColor(4);
  background->SetRange(minhisto,maxhisto);
  background->SetLineStyle(2);
  
  TF1* mass = new TF1(Form("fmass_%.0f_%.0f",ptmin,ptmax),"[0]*([3]*([4]*Gaus(x,[1],[2])/(sqrt(2*3.14159)*[2])+(1-[4])*Gaus(x,[1],[5])/(sqrt(2*3.14159)*[5])))");
  mass->SetParameters(f->GetParameter(0),f->GetParameter(1),f->GetParameter(2),f->GetParameter(7),f->GetParameter(9),f->GetParameter(10));
  mass->SetParError(0,f->GetParError(0));
  mass->SetParError(1,f->GetParError(1));
  mass->SetParError(2,f->GetParError(2));
  mass->SetParError(3,f->GetParError(7));
  mass->SetParError(4,f->GetParError(9));
  mass->SetParError(5,f->GetParError(10));
  mass->SetFillColor(kOrange-3);
  mass->SetFillStyle(3002);
  mass->SetLineColor(kOrange-3);
  mass->SetLineWidth(3);
  mass->SetLineStyle(2);
  
  TF1* massSwap = new TF1(Form("fmassSwap_%.0f_%.0f",ptmin,ptmax),"[0]*(1-[2])*Gaus(x,[1],[3])/(sqrt(2*3.14159)*[3])");
  massSwap->SetParameters(f->GetParameter(0),f->GetParameter(1),f->GetParameter(7),f->GetParameter(8));
  massSwap->SetParError(0,f->GetParError(0));
  massSwap->SetParError(1,f->GetParError(1));
  massSwap->SetParError(2,f->GetParError(7));
  massSwap->SetParError(3,f->GetParError(8));
  massSwap->SetFillColor(kGreen+4);
  massSwap->SetFillStyle(3005);
  massSwap->SetLineColor(kGreen+4);
  massSwap->SetLineWidth(3);
  massSwap->SetLineStyle(1);
  
  h->SetXTitle("m_{#piK} (GeV/c^{2})");
  h->SetYTitle("Entries / (5 MeV/c^{2})");
  h->GetXaxis()->CenterTitle();
  h->GetYaxis()->CenterTitle();
  h->SetAxisRange(0,h->GetMaximum()*1.4*1.2,"Y");
  h->GetXaxis()->SetTitleOffset(1.3);
  h->GetYaxis()->SetTitleOffset(1.8);
  h->GetXaxis()->SetLabelOffset(0.007);
  h->GetYaxis()->SetLabelOffset(0.007);
  h->GetXaxis()->SetTitleSize(0.045);
  h->GetYaxis()->SetTitleSize(0.045);
  h->GetXaxis()->SetTitleFont(42);
  h->GetYaxis()->SetTitleFont(42);
  h->GetXaxis()->SetLabelFont(42);
  h->GetYaxis()->SetLabelFont(42);
  h->GetXaxis()->SetLabelSize(0.04);
  h->GetYaxis()->SetLabelSize(0.04);
  h->SetMarkerSize(0.8);
  h->SetMarkerStyle(20);
  h->SetStats(0);
  h->Draw("e");

  background->Draw("same");   
  mass->SetRange(minhisto,maxhisto);	
  mass->Draw("same");
  massSwap->SetRange(minhisto,maxhisto);
  massSwap->Draw("same");
  f->Draw("same");
  
  Double_t yield = mass->Integral(minhisto,maxhisto)/binwidthmass;
  Double_t yieldErr = mass->Integral(minhisto,maxhisto)/binwidthmass*mass->GetParError(0)/mass->GetParameter(0);
  
  std::cout<<"YIELD="<<yield<<std::endl;

  TLegend* leg = new TLegend(0.65,0.58,0.82,0.88,NULL,"brNDC");
  leg->SetBorderSize(0);
  leg->SetTextSize(0.04);
  leg->SetTextFont(42);
  leg->SetFillStyle(0);
  leg->AddEntry(h,"Data","pl");
  leg->AddEntry(f,"Fit","l");
  leg->AddEntry(mass,"D^{0}+#bar{D^{#lower[0.2]{0}}} Signal","f");
  leg->AddEntry(massSwap,"K-#pi swapped","f");
  leg->AddEntry(background,"Combinatorial","l");
  leg->Draw("same");

  TLatex* texCms = new TLatex(0.18,0.93, "#scale[1.25]{CMS} Preliminary");
  texCms->SetNDC();
  texCms->SetTextAlign(12);
  texCms->SetTextSize(0.04);
  texCms->SetTextFont(42);
  texCms->Draw();

  TLatex* texCol = new TLatex(0.96,0.93, Form("%s #sqrt{s_{NN}} = 5.02 TeV",collisionsystem.Data()));
  texCol->SetNDC();
  texCol->SetTextAlign(32);
  texCol->SetTextSize(0.04);
  texCol->SetTextFont(42);
  texCol->Draw();

  TLatex* texPt = new TLatex(0.22,0.78,Form("%.1f < p_{T} < %.1f GeV/c",ptmin,ptmax));
  texPt->SetNDC();
  texPt->SetTextFont(42);
  texPt->SetTextSize(0.04);
  texPt->SetLineWidth(2);
  texPt->Draw();

  TLatex* texY = new TLatex(0.22,0.83,"|y| < 1.0");
  texY->SetNDC();
  texY->SetTextFont(42);
  texY->SetTextSize(0.04);
  texY->SetLineWidth(2);
  texY->Draw();

  TLatex* texYield = new TLatex(0.22,0.73,Form("N_{D} = %.0f #pm %.0f",yield,yieldErr));
  texYield->SetNDC();
  texYield->SetTextFont(42);
  texYield->SetTextSize(0.04);
  texYield->SetLineWidth(2);
  texYield->Draw();

  c->SaveAs(Form("plotFits/DMass_expo_%s_%.0f_%.0f.pdf",collisionsystem.Data(),ptmin,ptmax));
  
  TCanvas* cPull = new TCanvas(Form("cPull_%.0f_%.0f",ptmin,ptmax),"",600,700);
  TH1D* hPull = (TH1D*)h->Clone("hPull");
  for(int i=0;i<h->GetNbinsX();i++)
    {
      Double_t nfit = f->Integral(h->GetBinLowEdge(i+1),h->GetBinLowEdge(i+1)+h->GetBinWidth(i+1))/h->GetBinWidth(i+1);
      hPull->SetBinContent(i+1,(h->GetBinContent(i+1)-nfit)/h->GetBinError(i+1));
      hPull->SetBinError(i+1,0);
    }
  hPull->SetMinimum(-4.);
  hPull->SetMaximum(4.);
  hPull->SetYTitle("Pull");
  hPull->GetXaxis()->SetTitleOffset(1.);
  hPull->GetYaxis()->SetTitleOffset(0.65);
  hPull->GetXaxis()->SetLabelOffset(0.007);
  hPull->GetYaxis()->SetLabelOffset(0.007);
  hPull->GetXaxis()->SetTitleSize(0.12);
  hPull->GetYaxis()->SetTitleSize(0.12);
  hPull->GetXaxis()->SetLabelSize(0.1);
  hPull->GetYaxis()->SetLabelSize(0.1);
  hPull->GetYaxis()->SetNdivisions(504);
  TLine* lPull = new TLine(1.7, 0, 2., 0);
  lPull->SetLineWidth(1);
  lPull->SetLineStyle(7);
  lPull->SetLineColor(1);
  TPad* pFit = new TPad("pFit","",0,0.3,1,1);
  pFit->SetBottomMargin(0);
  pFit->Draw();
  pFit->cd();
  h->Draw("e");
  background->Draw("same");
  mass->Draw("same");
  massSwap->Draw("same");
  f->Draw("same");
  leg->Draw("same");
  texCms->Draw();
  texCol->Draw();
  texPt->Draw();
  texY->Draw();
  texYield->Draw();
  cPull->cd();
  TPad* pPull = new TPad("pPull","",0,0,1,0.3);
  pPull->SetTopMargin(0);
  pPull->SetBottomMargin(0.3);
  pPull->Draw();
  pPull->cd();
  hPull->Draw("p");
  lPull->Draw();
  cPull->cd();
  cPull->SaveAs(Form("plotFits/DMass_expo_%s_%.0f_%.0f_Pull.pdf",collisionsystem.Data(),ptmin,ptmax));

  return mass;
}
Пример #22
0
void drawingEff_TnPToyStudy::loadHisto(vector<string> *outname) {
  if (!finput) cout << "Cannot open input file!\n" << endl;

  TFile *foutput = new TFile(Form("%s_toySFToy.root",outname->at(1).c_str()),"recreate");

  setTDRStyle();
  gStyle->SetEndErrorSize(3);

  TLatex *lat = new TLatex(); lat->SetNDC(); lat->SetTextSize(0.035);
  TCanvas *can = new TCanvas("can","can",600,600);
  TLegend *leg = new TLegend(0.55,0.60,0.94,0.88);
  SetLegendStyle(leg);
 
  cout << "\n\t" << outname->at(0) << " " << outname->at(1) << endl;

  // Load denominator, numerators
  ///// Eff vs centrality in 4+1 |y| regions (6.5-50 GeV/c), forward & low pT region
  TObjArray *hnum = (TObjArray*)finput->Get("hnum_cent_rap0024");
  TObjArray *hden = (TObjArray*)finput->Get("hden_cent_rap0024");
  bool dofixcent = true; // True: Only if it is centrality drawing (no matter if it's pp or pbpb)
  TProfile *tp_cent_rap[5];
  tp_cent_rap[0] = simpleEff(hnum, hden, dofixcent);
  tp_cent_rap[0]->SetName("tnpSFToy_cent_rap0024");
  
  TH1F *haxes = new TH1F("haxes",";;Efficiency",1,0,100);
  haxes->GetXaxis()->SetTitle("Centrality [%]");
  haxes->Draw();

  tp_cent_rap[0]->Draw("same");
  leg->AddEntry(tp_cent_rap[0],"|y|: 0-2.4, 6.5-50 GeV/c","p");
  leg->Draw();
  lat->DrawLatex(0.2,0.85,outname->at(0).c_str());
  can->SaveAs(Form("%s_cent_rap_0.png",outname->at(1).c_str()));
  can->SaveAs(Form("%s_cent_rap_0.pdf",outname->at(1).c_str()));

  vector<TH1*> tps;
  vector<string> yname;
 
  yname.push_back("$|y|<2.4$");
  tps.push_back(tp_cent_rap[0]);
  TString texname = outname->at(1) + "_cent.tex";
  inittex(texname.Data(), "Centrality [\\%]", yname);
  printHist(tps, texname.Data());
  closetex(texname.Data());
  tps.clear();
  yname.clear();

  delete can;
  delete leg;

  for (int i=0; i<nbins_4rap; i++) {
    TObjArray *hnum1 = (TObjArray*)finput->Get( Form("hnum_cent_rap%02.0f%02.0f",bins_4rap[i]*10,bins_4rap[i+1]*10) );
    TObjArray *hden1 = (TObjArray*)finput->Get( Form("hden_cent_rap%02.0f%02.0f",bins_4rap[i]*10,bins_4rap[i+1]*10) );
    tp_cent_rap[i+1] = simpleEff(hnum1, hden1, dofixcent);
    tp_cent_rap[i+1]->SetName( Form("tnpSFToy_cent_rap%02.0f%02.0f",bins_4rap[i]*10,bins_4rap[i+1]*10) );
    
    can = new TCanvas("can","can",600,600);
    leg = new TLegend(0.55,0.60,0.94,0.88);
    SetLegendStyle(leg);
    haxes->Draw();
    tp_cent_rap[i+1]->Draw("same");
    leg->AddEntry(tp_cent_rap[i+1],Form("|y|: %.1f-%.1f, 6.5-50 GeV/c",bins_4rap[i],bins_4rap[i+1]),"p");
    leg->Draw();
    lat->DrawLatex(0.2,0.85,outname->at(0).c_str());
    can->SaveAs(Form("%s_cent_rap_%d.png",outname->at(1).c_str(),i+1));
    can->SaveAs(Form("%s_cent_rap_%d.pdf",outname->at(1).c_str(),i+1));
    
    yname.push_back(Form("$%0.1f<|y|<%0.1f$",bins_4rap[i],bins_4rap[i+1]));
    tps.push_back(tp_cent_rap[i+1]);

    delete can;
    delete leg;
  }
  texname = outname->at(1) + "_cent_pt65500.tex";
  inittex(texname.Data(), "Centrality [\\%]", yname);
  printHist(tps, texname.Data());
  closetex(texname.Data());
  tps.clear();
  yname.clear();


  hnum = (TObjArray*)finput->Get("hnum_cent_rap1824_pt3065");
  hden = (TObjArray*)finput->Get("hden_cent_rap1824_pt3065");
  tp_cent_rap[4] = simpleEff(hnum, hden, dofixcent);
  tp_cent_rap[4]->SetName("tnpSFToy_cent_rap1824_pt3065");
  
  can = new TCanvas("can","can",600,600);
  leg = new TLegend(0.55,0.60,0.94,0.88);
  SetLegendStyle(leg);
  haxes->Draw();
  tp_cent_rap[4]->Draw("same");
  leg->AddEntry(tp_cent_rap[4],Form("|y|: %.1f-%.1f, 3-6.5 GeV/c",bins_4rap[nbins_4rap-1],bins_4rap[nbins_4rap]),"p");
  leg->Draw();
  lat->DrawLatex(0.2,0.85,outname->at(0).c_str());
  can->SaveAs(Form("%s_cent_rap_%d.png",outname->at(1).c_str(),nbins_4rap));
  can->SaveAs(Form("%s_cent_rap_%d.pdf",outname->at(1).c_str(),nbins_4rap));
  
  yname.push_back(Form("$%0.1f<|y|<%0.1f$, $3<p_{T}<6.5$ GeV/c",bins_4rap[nbins_4rap-1],bins_4rap[nbins_4rap]));
  tps.push_back(tp_cent_rap[4]);

  texname = outname->at(1) + "_cent_pt30500.tex";
  inittex(texname.Data(), "Centrality [\\%]", yname);
  printHist(tps, texname.Data());
  closetex(texname.Data());
  tps.clear();
  yname.clear();

  delete can;
  delete leg;  

  ///// Eff vs pT in 4+1 |y| regions
  hnum = (TObjArray*)finput->Get("hnum_pt_rap0024");
  hden = (TObjArray*)finput->Get("hden_pt_rap0024");
  dofixcent = false;
  TProfile *tp_pt_rap[5];
  tp_pt_rap[0] = simpleEff(hnum, hden, dofixcent);
  tp_pt_rap[0]->SetName("tnpSFToy_pt_rap0024");

  haxes->GetXaxis()->SetTitle("p_{T} [GeV/c]");
  haxes->SetBins(1,0,50);
  
  can = new TCanvas("can","can",600,600);
  leg = new TLegend(0.6,0.68,0.9,0.88);
  SetLegendStyle(leg);
  haxes->Draw();
  tp_pt_rap[0]->Draw("same");
  if (ispbpb) leg->AddEntry(tp_pt_rap[0],"|y|: 0-2.4, 0-100%","p");
  else leg->AddEntry(tp_pt_rap[0],"|y|: 0-2.4","p");
  leg->Draw();
  lat->DrawLatex(0.2,0.85,outname->at(0).c_str());
  can->SaveAs(Form("%s_pt_rap_0.png",outname->at(1).c_str()));
  can->SaveAs(Form("%s_pt_rap_0.pdf",outname->at(1).c_str()));

  yname.push_back("$|y|<2.4$");
  tps.push_back(tp_pt_rap[0]);
  
  // |y| ranges have different number of pT bins -> create separate tex files
  texname = outname->at(1) + "_pt_rap__rap0024.tex";
  inittex(texname.Data(), "$p_{T}$ $\\mathrm{[GeV/c]}$", yname);
  printHist(tps, texname.Data());
  closetex(texname.Data());
  tps.clear();
  yname.clear();

  delete can;
  delete leg;

  for (int i=0; i<nbins_4rap-1; i++) {
    TObjArray *hnum1 = (TObjArray*)finput->Get( Form("hnum_pt_rap%02.0f%02.0f",bins_4rap[i]*10,bins_4rap[i+1]*10) );
    TObjArray *hden1 = (TObjArray*)finput->Get( Form("hden_pt_rap%02.0f%02.0f",bins_4rap[i]*10,bins_4rap[i+1]*10) );
    tp_pt_rap[i+1] = simpleEff(hnum1, hden1, dofixcent);
    tp_pt_rap[i+1]->SetName( Form("tnpSFToy_pt_rap%02.0f%02.0f",bins_4rap[i]*10,bins_4rap[i+1]*10) );
    
    can = new TCanvas("can","can",600,600);
    leg = new TLegend(0.6,0.68,0.9,0.88);
    SetLegendStyle(leg);
    haxes->Draw();
    tp_pt_rap[i+1]->Draw("same");
    if (ispbpb) leg->AddEntry(tp_pt_rap[i+1],Form("|y|: %.1f-%.1f, 0-100%%",bins_4rap[i],bins_4rap[i+1]),"p");
    else leg->AddEntry(tp_pt_rap[i+1],Form("|y|: %.1f-%.1f",bins_4rap[i],bins_4rap[i+1]),"p");
    leg->Draw();
    lat->DrawLatex(0.2,0.85,outname->at(0).c_str());
    can->SaveAs(Form("%s_pt_rap_%d.png",outname->at(1).c_str(),i+1));
    can->SaveAs(Form("%s_pt_rap_%d.pdf",outname->at(1).c_str(),i+1));

    yname.push_back(Form("$%0.1f<|y|<%0.1f$",bins_4rap[i],bins_4rap[i+1]));
    tps.push_back(tp_pt_rap[i+1]);

    delete can;
    delete leg;
  }
  texname = outname->at(1) + "_pt_rap__pt65500.tex";
  inittex(texname.Data(), "$p_{T}$ $\\mathrm{[GeV/c]}$", yname);
  printHist(tps, texname.Data());
  closetex(texname.Data());
  tps.clear();
  yname.clear();

  for (int i=nbins_4rap-1; i<nbins_4rap; i++) {
    TObjArray *hnum1 = (TObjArray*)finput->Get( Form("hnum_pt_rap%02.0f%02.0f",bins_4rap[i]*10,bins_4rap[i+1]*10) );
    TObjArray *hden1 = (TObjArray*)finput->Get( Form("hden_pt_rap%02.0f%02.0f",bins_4rap[i]*10,bins_4rap[i+1]*10) );
    tp_pt_rap[i+1] = simpleEff(hnum1, hden1, dofixcent);
    tp_pt_rap[i+1]->SetName( Form("tnpSFToy_cent_rap%02.0f%02.0f",bins_4rap[i]*10,bins_4rap[i+1]*10) );
    
    can = new TCanvas("can","can",600,600);
    leg = new TLegend(0.6,0.68,0.9,0.88);
    SetLegendStyle(leg);
    haxes->Draw();
    tp_pt_rap[i+1]->Draw("same");
    if (ispbpb) leg->AddEntry(tp_pt_rap[i+1],Form("|y|: %.1f-%.1f, 0-100%%",bins_4rap[i],bins_4rap[i+1]),"p");
    else leg->AddEntry(tp_pt_rap[i+1],Form("|y|: %.1f-%.1f",bins_4rap[i],bins_4rap[i+1]),"p");
    leg->Draw();
    lat->DrawLatex(0.2,0.85,outname->at(0).c_str());
    can->SaveAs(Form("%s_pt_rap_%d.png",outname->at(1).c_str(),i+1));
    can->SaveAs(Form("%s_pt_rap_%d.pdf",outname->at(1).c_str(),i+1));

    yname.push_back(Form("$%0.1f<|y|<%0.1f$",bins_4rap[i],bins_4rap[i+1]));
    tps.push_back(tp_pt_rap[i+1]);

    delete can;
    delete leg;
  }
  texname = outname->at(1) + "_pt_rap__pt30500.tex";
  inittex(texname.Data(), "$p_{T}$ $\\mathrm{[GeV/c]}$", yname);
  printHist(tps, texname.Data());
  closetex(texname.Data());
  tps.clear();
  yname.clear();

  ///// Eff vs pT in 3 centrality regions
  TProfile *tp_pt_cent[nbins_3cent];
  for (int i=0; i<(ispbpb?nbins_3cent-1:1); i++) { // for pp, only the 1st bin is necessary
    TObjArray *hnum1 = (TObjArray*)finput->Get( Form("hnum_pt_cent%02.0f%02.0f",bins_3cent[i],bins_3cent[i+1]) );
    TObjArray *hden1 = (TObjArray*)finput->Get( Form("hden_pt_cent%02.0f%02.0f",bins_3cent[i],bins_3cent[i+1]) );
    tp_pt_cent[i] = simpleEff(hnum1, hden1, dofixcent);
    tp_pt_cent[i]->SetName( Form("tnpSFToy_pt_cent%02.0f%02.0f",bins_3cent[i],bins_3cent[i+1]) );
    
    haxes->GetXaxis()->SetTitle("p_{T} [GeV/c]");
    haxes->SetBins(1,0,50);
    
    can = new TCanvas("can","can",600,600);
    leg = new TLegend(0.67,0.68,0.9,0.88);
    SetLegendStyle(leg);
    haxes->Draw();
    tp_pt_cent[i]->Draw("same");
    if (ispbpb) {
      leg->AddEntry(tp_pt_cent[i],Form("%.0f-%.0f%%",bins_3cent[i],bins_3cent[i+1]),"p");
      leg->Draw();
    }
    lat->DrawLatex(0.2,0.85,outname->at(0).c_str());
    lat->DrawLatex(0.2,0.80,"|y| < 2.4");
    can->SaveAs(Form("%s_pt_cent_%d.png",outname->at(1).c_str(),i));
    can->SaveAs(Form("%s_pt_cent_%d.pdf",outname->at(1).c_str(),i));

    yname.push_back(Form("$%0.1f-%0.1f$\\%%",bins_3cent[i],bins_3cent[i+1]));
    tps.push_back(tp_pt_cent[i]);

    delete can;
    delete leg;
  }
  if (ispbpb) {
    hnum = (TObjArray*)finput->Get( Form("hnum_pt_cent%02.0f%03.0f",bins_3cent[nbins_3cent-1],bins_3cent[nbins_3cent]) );
    hden = (TObjArray*)finput->Get( Form("hden_pt_cent%02.0f%03.0f",bins_3cent[nbins_3cent-1],bins_3cent[nbins_3cent]) );
    tp_pt_cent[nbins_3cent-1] = simpleEff(hnum, hden, dofixcent);
    tp_pt_cent[nbins_3cent-1]->SetName( Form("tnpSFToy_pt_cent%02.0f%03.0f",bins_3cent[nbins_3cent-1],bins_3cent[nbins_3cent]) );
    
    haxes->GetXaxis()->SetTitle("p_{T} [GeV/c]");
    haxes->SetBins(1,0,50);
    
    can = new TCanvas("can","can",600,600);
    leg = new TLegend(0.67,0.68,0.9,0.88);
    SetLegendStyle(leg);
    haxes->Draw();
    tp_pt_cent[nbins_3cent-1]->Draw("same");
    leg->AddEntry(tp_pt_cent[nbins_3cent-1],Form("%.0f-%.0f%%",bins_3cent[nbins_3cent-1],bins_3cent[nbins_3cent]),"p");
    leg->Draw();
    lat->DrawLatex(0.2,0.85,outname->at(0).c_str());
    lat->DrawLatex(0.2,0.80,"|y| < 2.4");
    can->SaveAs(Form("%s_pt_cent_%d.png",outname->at(1).c_str(),nbins_3cent));
    can->SaveAs(Form("%s_pt_cent_%d.pdf",outname->at(1).c_str(),nbins_3cent));

    yname.push_back(Form("$%0.1f-%0.1f$\\%%",bins_3cent[nbins_3cent-1],bins_3cent[nbins_3cent]));
    tps.push_back(tp_pt_cent[nbins_3cent-1]);
    
    delete can;
    delete leg;
  }

  texname = outname->at(1) + "_pt_cent.tex";
  inittex(texname.Data(), "$p_{T}$ $\\mathrm{[GeV/c]}$", yname);
  printHist(tps, texname.Data());
  closetex(texname.Data());
  tps.clear();
  yname.clear();

  ///// Eff vs rap integrated
  hnum = (TObjArray*)finput->Get("hnum_rap");
  hden = (TObjArray*)finput->Get("hden_rap");
  TProfile *tp_rap = simpleEff(hnum, hden, dofixcent);
  tp_rap->SetName("tnpSFToy_rap");

  haxes->GetXaxis()->SetTitle("|y|");
  haxes->SetBins(1,0,2.4);
    
  can = new TCanvas("can","can",600,600);
  haxes->Draw();
  tp_rap->Draw("same");
  lat->DrawLatex(0.2,0.85,outname->at(0).c_str());
  lat->DrawLatex(0.2,0.80,"6.5-50 GeV/c");
  if (ispbpb) lat->DrawLatex(0.2,0.75,"0-100%");
  can->SaveAs(Form("%s_rap.png",outname->at(1).c_str()));
  can->SaveAs(Form("%s_rap.pdf",outname->at(1).c_str()));

  yname.push_back("$6.5<p_{T}<50$ GeV/c, 0-100%");
  tps.push_back(tp_rap);

  texname = outname->at(1) + "_rap.tex";
  inittex(texname.Data(), "|y|", yname);
  printHist(tps, texname.Data());
  closetex(texname.Data());
  tps.clear();
  yname.clear();

  delete can;
  delete lat;


  ///// Write TProfiles into .root file
  foutput->cd();
  for (int i=0; i<5; i++)
    tp_cent_rap[i]->Write();
  for (int i=0; i<nbins_4rap+1; i++) 
    tp_pt_rap[i]->Write();
  for (int i=0; i<(ispbpb?nbins_3cent:1); i++) 
    tp_pt_cent[i]->Write();
  tp_rap->Write(); 
  

  // Clean up memory
  for (int i=0; i<5; i++)
    delete tp_cent_rap[i];
  for (int i=0; i<nbins_4rap+1; i++) 
    delete tp_pt_rap[i];
  for (int i=0; i<(ispbpb?nbins_3cent:1); i++) 
    delete tp_pt_cent[i];
  delete tp_rap;
}
Пример #23
0
void plotLimit(string outputDir="./", TString inputs="", TString inputs_blinded="", TString inputXSec="", bool strengthLimit=true, bool blind=false, double energy=7, double luminosity=5.035, TString legendName="ee and #mu#mu channels")
{
   setTDRStyle();  
   gStyle->SetPadTopMargin   (0.05);
   gStyle->SetPadBottomMargin(0.12);
   gStyle->SetPadRightMargin (0.16);
   gStyle->SetPadLeftMargin  (0.14);
   gStyle->SetTitleSize(0.04, "XYZ");
   gStyle->SetTitleXOffset(1.1);
   gStyle->SetTitleYOffset(1.45);
   gStyle->SetPalette(1);
   gStyle->SetNdivisions(505);
  
  //get the limits from the tree
  TFile* file = TFile::Open(inputs);
  printf("Looping on %s\n",inputs.Data());
  if(!file) return;
  if(file->IsZombie()) return;
  TFile* file_blinded = TFile::Open(inputs_blinded);
  printf("Looping on %s\n",inputs_blinded.Data());
  if(!file_blinded) return;
  if(file_blinded->IsZombie()) return;
  TTree* tree_blinded = (TTree*)file_blinded->Get("limit");
  tree_blinded->GetBranch("mh"              )->SetAddress(&Tmh      );
  tree_blinded->GetBranch("limit"           )->SetAddress(&Tlimit   );
  tree_blinded->GetBranch("limitErr"        )->SetAddress(&TlimitErr);
  tree_blinded->GetBranch("quantileExpected")->SetAddress(&TquantExp);
  TGraph* ExpLimitm2 = getLimitGraph(tree_blinded,0.025);
  TGraph* ExpLimitm1 = getLimitGraph(tree_blinded,0.160);
  TGraph* ExpLimit   = getLimitGraph(tree_blinded,0.500);
  TGraph* ExpLimitp1 = getLimitGraph(tree_blinded,0.840);
  TGraph* ExpLimitp2 = getLimitGraph(tree_blinded,0.975);
  file_blinded->Close(); 
  TTree* tree = (TTree*)file->Get("limit");
  tree->GetBranch("mh"              )->SetAddress(&Tmh      );
  tree->GetBranch("limit"           )->SetAddress(&Tlimit   );
  tree->GetBranch("limitErr"        )->SetAddress(&TlimitErr);
  tree->GetBranch("quantileExpected")->SetAddress(&TquantExp);
  TGraph* ObsLimit   = getLimitGraph(tree,-1   ); 
  file->Close(); 

  FILE* pFileSStrenght = fopen((outputDir+"SignalStrenght").c_str(),"w");
  std::cout << "Printing Signal Strenght" << std::endl;
  for(int i=0;i<ExpLimit->GetN();i++){
     double M = ExpLimit->GetX()[i];
     std::cout << "Mass: " << M << "; ExpLimit: " << ExpLimit->Eval(M) << std::endl; 
     printf("$%8.6E$ & $%8.6E$ & $[%8.6E,%8.6E]$ & $[%8.6E,%8.6E]$ \\\\\\hline\n",M, ExpLimit->Eval(M), ExpLimitm1->Eval(M), ExpLimitp1->Eval(M), ExpLimitm2->Eval(M),  ExpLimitp2->Eval(M));
     fprintf(pFileSStrenght, "$%8.6E$ & $%8.6E$ & $[%8.6E,%8.6E]$ & $[%8.6E,%8.6E]$ & $%8.6E$ \\\\\\hline\n",M, ExpLimit->Eval(M), ExpLimitm1->Eval(M), ExpLimitp1->Eval(M), ExpLimitm2->Eval(M),  ExpLimitp2->Eval(M), ObsLimit->Eval(M));
    if(int(ExpLimit->GetX()[i])%50!=0)continue; //printf("%f ",ObsLimit->Eval(M));
  }printf("\n");
  fclose(pFileSStrenght); 
 

  //get the pValue
  inputs = inputs.ReplaceAll("/LimitTree", "/PValueTree");
  file = TFile::Open(inputs);
  
  printf("Looping on %s\n",inputs.Data());
  if(!file) return;
  if(file->IsZombie()) return;
  
  tree = (TTree*)file->Get("limit");
  
  tree->GetBranch("limit"           )->SetAddress(&Tlimit   );
  
  TGraph* pValue     = getLimitGraph(tree,-1);
  
  file->Close();

  
  //make TH Cross-sections
   string suffix = outputDir;
   TGraph* THXSec   = Hxswg::utils::getXSec(outputDir); 
   scaleGraph(THXSec, 1000);  //convert cross-section to fb
   double cprime=1.0; double  brnew=0.0;
   double XSecScaleFactor = 1.0;
   if(suffix.find("_cp")!=string::npos){
     sscanf(suffix.c_str()+suffix.find("_cp"), "_cp%lf_brn%lf", &cprime, &brnew);
     XSecScaleFactor = pow(cprime,2) * (1-brnew);
   }
  //XSecScaleFactor = 0.001; //pb to fb
  scaleGraph(THXSec, XSecScaleFactor);


  string prod = "pp_SM";
  if(outputDir.find("ggH")!=std::string::npos)prod="gg";
  if(outputDir.find("qqH")!=std::string::npos)prod="qq";
  if(outputDir.find("ppH")!=std::string::npos)prod="pp";

  
  strengthLimit = false;
  if(prod=="pp_SM")strengthLimit=true;
 
  //TGraph *XSecMELA = Hxswg::utils::getXSecMELA(cprime);

  //Hxswg::utils::multiplyGraph(   ObsLimit, XSecMELA);
  //Hxswg::utils::multiplyGraph( ExpLimitm2, XSecMELA);
  //Hxswg::utils::multiplyGraph( ExpLimitm1, XSecMELA);
  //Hxswg::utils::multiplyGraph(   ExpLimit, XSecMELA);
  //Hxswg::utils::multiplyGraph( ExpLimitp1, XSecMELA);
  //Hxswg::utils::multiplyGraph( ExpLimitp2, XSecMELA);
 
  //Scale exclusion XSec in fb
  scaleGraph(ObsLimit  , 0.001); //pb to fb
  scaleGraph(ExpLimitm2, 0.001); //pb to fb
  scaleGraph(ExpLimitm1, 0.001); //pb to fb
  scaleGraph(ExpLimit  , 0.001); //pb to fb
  scaleGraph(ExpLimitp1, 0.001); //pb to fb
  scaleGraph(ExpLimitp2, 0.001); //pb to fb

  //scal eTH cross-section and limits according to scale factor 
  //this only apply to NarrowResonnance case
  if(strengthLimit){
     Hxswg::utils::divideGraph(ObsLimit   , THXSec);
     Hxswg::utils::divideGraph(ExpLimitm2 , THXSec);
     Hxswg::utils::divideGraph(ExpLimitm1 , THXSec);
     Hxswg::utils::divideGraph(ExpLimit   , THXSec);
     Hxswg::utils::divideGraph(ExpLimitp1 , THXSec);
     Hxswg::utils::divideGraph(ExpLimitp2 , THXSec);
     Hxswg::utils::divideGraph(THXSec     , THXSec);
  }


  //limits in terms of signal strength
  TCanvas* c = new TCanvas("c", "c",800,800);
  c->SetGridx();
  c->SetGridy();
  TH1F* framework = new TH1F("Graph","Graph",1,strengthLimit?199:199,2500); //3000);
  framework->SetStats(false);
  framework->SetTitle("");
  framework->GetXaxis()->SetTitle("M_{H} [GeV]");
  framework->GetYaxis()->SetTitleOffset(1.70);
  if(strengthLimit){
  framework->GetYaxis()->SetTitle("#mu = #sigma_{95%} / #sigma_{th}");
  framework->GetYaxis()->SetRangeUser(1E-4,1E3);
  c->SetLogy(true);
  }else{
  framework->GetYaxis()->SetTitle((string("#sigma_{95%} (") + prod +" #rightarrow H #rightarrow ZZ) (pb)").c_str());
  framework->GetYaxis()->SetRangeUser(1E-3,1E3);
  c->SetLogy(true);
  }
  framework->GetXaxis()->SetLabelOffset(0.007);
  framework->GetXaxis()->SetLabelSize(0.03);
  framework->GetXaxis()->SetTitleOffset(1.0);
  framework->GetXaxis()->SetTitleFont(42);
  framework->GetXaxis()->SetTitleSize(0.035);
  framework->GetYaxis()->SetLabelFont(42);
  framework->GetYaxis()->SetLabelOffset(0.007);
  framework->GetYaxis()->SetLabelSize(0.03);
  framework->GetYaxis()->SetTitleOffset(1.3);
  framework->GetYaxis()->SetTitleFont(42);
  framework->GetYaxis()->SetTitleSize(0.035);
  framework->Draw();

  
  TGraph* TGObsLimit   = ObsLimit;  TGObsLimit->SetLineWidth(2);
  TGraph* TGExpLimit   = ExpLimit;  TGExpLimit->SetLineWidth(2); TGExpLimit->SetLineStyle(2);
  TCutG* TGExpLimit1S  = GetErrorBand("1S", ExpLimitm1, ExpLimitp1);  
  TCutG* TGExpLimit2S  = GetErrorBand("2S", ExpLimitm2, ExpLimitp2);  TGExpLimit2S->SetFillColor(5);
  THXSec->SetLineWidth(2); THXSec->SetLineStyle(1); THXSec->SetLineColor(4);

  TGExpLimit->SetLineColor(1);  TGExpLimit->SetLineStyle(2);
  TGObsLimit->SetLineWidth(2);  TGObsLimit->SetMarkerStyle(20);
  TGExpLimit2S->Draw("fc same");
  TGExpLimit1S->Draw("fc same");
  if(!blind) TGObsLimit->Draw("same P");
  TGExpLimit->Draw("same c");

  
  /*if(strengthLimit){
     TLine* SMLine = new TLine(framework->GetXaxis()->GetXmin(),1.0,framework->GetXaxis()->GetXmax(),1.0);
     SMLine->SetLineWidth(2); SMLine->SetLineStyle(1); SMLine->SetLineColor(4);      
     SMLine->Draw("same C");
  }else{
     THXSec->Draw("same C");
  }*/

  utils::root::DrawPreliminary(luminosity, energy, c);

  
  TLegend* LEG = new TLegend(0.55,0.75,0.85,0.95);
  LEG->SetHeader("");
  LEG->SetFillColor(0);
  LEG->SetFillStyle(0);
  LEG->SetTextFont(42);
  LEG->SetBorderSize(0);
  //LEG->AddEntry(THXSec  , "Th prediction"  ,"L");
  LEG->AddEntry(TGExpLimit  , "median expected"  ,"L");
  LEG->AddEntry(TGExpLimit1S  , "expected #pm 1#sigma"  ,"F");
  LEG->AddEntry(TGExpLimit2S  , "expected #pm 2#sigma"  ,"F");
  if(!blind) LEG->AddEntry(TGObsLimit  , "observed"  ,"LP");
  LEG->Draw();
  c->RedrawAxis();
  c->SaveAs((outputDir+"Limit.png").c_str());
  c->SaveAs((outputDir+"Limit.C").c_str());
  c->SaveAs((outputDir+"Limit.pdf").c_str()); 

  
  //save a summary of the limits
  FILE* pFileSum = fopen((outputDir+"LimitSummary").c_str(),"w");
  for(int i=0;i<TGExpLimit->GetN();i++){
     double M = ExpLimit->GetX()[i];
     fprintf(pFileSum, "$%8.6E$ & $%8.6E$ & $[%8.6E,%8.6E]$ & $[%8.6E,%8.6E]$ & $%8.6E$ & Th=$%8.6E$ & pValue=$%8.6E$\\\\\\hline\n",M, ExpLimit->Eval(M), ExpLimitm1->Eval(M), ExpLimitp1->Eval(M), ExpLimitm2->Eval(M),  ExpLimitp2->Eval(M), ObsLimit->Eval(M), (THXSec!=NULL)?THXSec->Eval(M):-1, pValue->Eval(M));
    if(int(ExpLimit->GetX()[i])%50!=0)continue; printf("%f ",ObsLimit->Eval(M));
  }printf("\n");
  fclose(pFileSum);

  pFileSum = fopen((outputDir+"LimitRange").c_str(),"w");
  fprintf(pFileSum, "EXPECTED LIMIT --> ");                   printLimits(pFileSum,TGExpLimit, TGExpLimit->GetX()[0], TGExpLimit->GetX()[TGExpLimit->GetN()-1]);
  if(!blind) fprintf(pFileSum, "OBSERVED LIMIT --> ");        printLimits(pFileSum,TGObsLimit, TGObsLimit->GetX()[0], TGObsLimit->GetX()[TGObsLimit->GetN()-1]);
  fprintf(pFileSum, "Exp Limits for Model are: ");              for(int i=0;i<TGExpLimit->GetN();i++){if(int(TGExpLimit->GetX()[i])%50==0) fprintf(pFileSum, "%f+-%f ",TGExpLimit->GetY()[i], (ExpLimitp1->GetY()[i]-ExpLimitm1->GetY()[i])/2.0);}fprintf(pFileSum,"\n");
  if(!blind) { fprintf(pFileSum, "Obs Limits for Model are: "); for(int i=0;i<TGObsLimit->GetN();i++){if(int(TGObsLimit->GetX()[i])%50==0) fprintf(pFileSum, "%f ",TGObsLimit->GetY()[i]);}fprintf(pFileSum,"\n"); }
  fclose(pFileSum); 
}
Пример #24
0
//------------------------------------------------------------------------------
// DrawHistogram
//------------------------------------------------------------------------------
void DrawHistogram(TString  hname,
		   TString  xtitle,
		   Int_t    ngroup       = -1,
		   Int_t    precision    = 1,
		   TString  units        = "NULL",
		   Double_t xmin         = -999,
		   Double_t xmax         =  999,
		   Bool_t   moveOverflow = true)
{
  //TCanvas* canvas = new TCanvas(hname, hname, 550, 720);
  TCanvas* canvas = new TCanvas(hname, hname, 800, 800);

  TPad* pad1 = new TPad("pad1", "pad1", 0, 0.3, 1, 1.0);
  TPad* pad2 = new TPad("pad2", "pad2", 0, 0.0, 1, 0.3); 

  pad1->SetTopMargin   (0.08);
  pad1->SetBottomMargin(0.02);
  pad1->Draw();
      
  pad2->SetTopMargin   (0.08);
  pad2->SetBottomMargin(0.35);
  pad2->Draw();


  //----------------------------------------------------------------------------
  // pad1
  //----------------------------------------------------------------------------
  pad1->cd();

  pad1->SetLogy(_setLogy);

  THStack* hstack = new THStack(hname, hname);

  TH1F* hist[nProcesses];

  //Save histograms to root file
  TFile* outfile;
  //TString fname = Form("files/%s_%djet.root", hname.Data(),_njet);
  TString fname = "files/0jet_"+hname+".root";
  if(_njet==1) fname = "files/1jet_"+hname+".root";
  outfile = new TFile(fname, "create");
  
  TH1F* data;
  TH1F* top;
  TH1F* tW;
  TH1F* WW;
  TH1F* WZ;
  TH1F* ZZ;
  TH1F* Wg;
  TH1F* WgSMu;
  TH1F* WgSEl;
  TH1F* Wjets;
  TH1F* Zjets;
  TH1F* DYtau;
  TH1F* Zgamma;
  TH1F* ggH;



  
  for (UInt_t ip=0; ip<nProcesses; ip++) {

    hist[ip] = (TH1F*)input[ip]->Get(hname);
    hist[ip]->SetName(hname + process[ip]);
    hist[ip]->SetTitle("");

    if(ip == iData)   data   = (TH1F*)hist[iData]->Clone("Data");     //data   -> Sumw2();
    if(ip == itt)     top    = (TH1F*)hist[itt]->Clone("top");        //top    -> Sumw2();
    if(ip == itW)     tW     = (TH1F*)hist[itW]->Clone("tW");         //tW     -> Sumw2();
    if(ip == iWW)     WW     = (TH1F*)hist[iWW]->Clone("WW");         //WW     -> Sumw2();
    if(ip == iWZ)     WZ     = (TH1F*)hist[iWZ]->Clone("WZ");   //VV     -> Sumw2();
    if(ip == iZZ)     ZZ     = (TH1F*)hist[iZZ]->Clone("ZZ");         //ZZ     -> Sumw2();
    if(ip == iWg)     Wg     = (TH1F*)hist[iWg]->Clone("Wg");         //Wg     -> Sumw2();
    if(ip == iWgSMu){
      WgSMu  = (TH1F*)hist[iWgSMu]->Clone("WgSMu");         //WgSMu     -> Sumw2();
      hist[iWgSMu]->Scale(1.5);
    }
    if(ip == iWgSEl){
      WgSEl  = (TH1F*)hist[iWgSEl]->Clone("WgSEl");         //WgSel     -> Sumw2();
      hist[iWgSEl]->Scale(1.5);         //WgSel     -> Sumw2();
    }
    if(ip == iWj)     Wjets  = (TH1F*)hist[iWj]->Clone("W+jets");     //Wjets  -> Sumw2();
    if(ip == iDY)     Zjets  = (TH1F*)hist[iDY]->Clone("Z+jets");     //Zjets  -> Sumw2();
    if(ip == iDYtau)  DYtau  = (TH1F*)hist[iDYtau]->Clone("DYtau");   //DYtau  -> Sumw2();
    if(ip == iZgamma) Zgamma = (TH1F*)hist[iZgamma]->Clone("Zgamma"); //Zgamma -> Sumw2();
    if(ip == iH125)   ggH    = (TH1F*)hist[iH125]->Clone("ggH");      //ggH    -> Sumw2();
    
    if (moveOverflow) MoveOverflowBins  (hist[ip], xmin, xmax);
    else              ZeroOutOfRangeBins(hist[ip], xmin, xmax);

    if (ngroup > 0) hist[ip]->Rebin(ngroup);

    if (ip == iWg) {
      //hist[ip]->Scale(0.01);
    }
    
    if (ip == iData) {
      hist[ip]->SetMarkerStyle(kFullCircle);
    }
    else {
      hist[ip]->SetFillColor(color[ip]);
      hist[ip]->SetFillStyle(1001);
      hist[ip]->SetLineColor(color[ip]);

      if (_dataDriven && ip == itt)    hist[ip]->Scale(ttScale[_njet]);
      if (_dataDriven && ip == itW)    hist[ip]->Scale(tWScale[_njet]);
      if (_dataDriven && ip == iWW)    hist[ip]->Scale(WWScale[_njet]);
      if (_dataDriven && ip == iDY)    hist[ip]->Scale(ZjScale[_njet]);
      if (_dataDriven && ip == iDYtau) hist[ip]->Scale(ZjScale[_njet]);

      if( ip != iZZ ) hstack->Add(hist[ip]);//TODO something wrong with ZZ
      
    }
  }

  if (_dataDriven)
  {
    top->Scale(ttScale[_njet]);
    tW->Scale(tWScale[_njet]);
    WW->Scale(WWScale[_njet]);
    Zjets->Scale(ZjScale[_njet]);
    DYtau->Scale(ZjScale[_njet]);
  }
  
  top  ->Add(tW);
  //VV   ->Add(ZZ);
  //VV   ->Add(Wg);  
  //Zjets->Add(DYtau);
  //Zjets->Add(Zgamma);

  data  -> Write();
  top   -> Write();
  WW    -> Write();
  //VV    -> Write();
  //Wjets -> Write();
  //Zjets -> Write();
  ggH   -> Write();
  
  outfile->Close();


  // All MC
  //----------------------------------------------------------------------------
  TH1F* allmc = (TH1F*)hist[iData]->Clone("allmc");

  allmc->SetFillColor  (kGray+2);
  allmc->SetFillStyle  (   3345);
  allmc->SetLineColor  (kGray+2);
  allmc->SetMarkerColor(kGray+2);
  allmc->SetMarkerSize (      0);

  for (UInt_t ibin=1; ibin<=allmc->GetNbinsX(); ibin++) {

    Double_t binValue = 0;
    Double_t binError = 0;

    for (UInt_t ip=0; ip<nProcesses; ip++) {

      if (ip == iData) continue;
      if (ip == iZZ) continue;

      Double_t binContent = hist[ip]->GetBinContent(ibin);
      
      binValue += binContent;
      binError += (hist[ip]->GetBinError(ibin) * hist[ip]->GetBinError(ibin));

      //We need to calculate systematic uncertainty for ggH case
//      if (_dataDriven)
//	binError += (systError[ip]*binContent * systError[ip]*binContent);
    }
    
    binError = sqrt(binError);

    allmc->SetBinContent(ibin, binValue);
    allmc->SetBinError  (ibin, binError);
  }


  // Axis labels
  //------------------------------------------------------------------
  TAxis* xaxis = hist[iData]->GetXaxis();
  TAxis* yaxis = hist[iData]->GetYaxis();

  TString ytitle = Form("entries / %s.%df", "%", precision);

  xaxis->SetTitle(xtitle);
  yaxis->SetTitle(Form(ytitle.Data(), hist[iData]->GetBinWidth(0)));
  yaxis->SetTitleOffset(1.6);

  if (!units.Contains("NULL")) {
    
    xaxis->SetTitle(Form("%s [%s]", xaxis->GetTitle(), units.Data()));
    yaxis->SetTitle(Form("%s %s",   yaxis->GetTitle(), units.Data()));
  }


  // Draw
  //--------------------------------------------------------------------
  xaxis->SetRangeUser(xmin, xmax);

  hist[iData]->Draw("ep");
  hstack     ->Draw("hist,same");
  allmc      ->Draw("e2,same");
  hist[iData]->Draw("ep,same");

  // Adjust scale
  //----------------------------------------------------------------------------
  Float_t theMax   = GetMaximumIncludingErrors(hist[iData], xmin, xmax);
  Float_t theMaxMC = GetMaximumIncludingErrors(allmc,       xmin, xmax);

  if (theMaxMC > theMax) theMax = theMaxMC;

  if (pad1->GetLogy()) {

    theMax = TMath::Power(10, TMath::Log10(theMax) + 2.7);

    hist[iData]->SetMinimum(0.05);
  }
  else theMax *= 1.55;

  hist[iData]->SetMaximum(theMax);


  // Legend
  //----------------------------------------------------------------------
  Double_t x0      = 0.720; 
  Double_t y0      = 0.834; 
  Double_t yoffset = 0.048;
  Double_t delta   = yoffset + 0.001;
  Double_t ndelta  = 0;

  Double_t YieldTop   = Yield(hist[itt]) + Yield(hist[itW]);
  Double_t YieldWZ    = Yield(hist[iWZ]);
  Double_t YieldVV    = Yield(hist[iWZ]) + Yield(hist[iZZ]) + Yield(hist[iWg]);
  //Double_t YieldZJets = Yield(hist[iDY]) + Yield(hist[iDYtau]);
  Double_t YieldZJets = Yield(hist[iDY]) + Yield(hist[iDYtau]) + Yield(hist[iZgamma]);

  DrawLegend(x0 - 0.49, y0 - ndelta, hist[iData],  Form(" data (%.0f)", Yield(hist[iData])), "lp", 0.03, 0.2, yoffset); ndelta += delta;
  //DrawLegend(x0 - 0.23, y0 - ndelta, hist[itt],    Form(" tt (%.0f)",  Yield(hist[itt])),   "f",  0.03, 0.2, yoffset); ndelta += delta;
  //DrawLegend(x0 - 0.23, y0 - ndelta, hist[itW],    Form(" tW (%.0f)",  Yield(hist[itW])),   "f",  0.03, 0.2, yoffset); ndelta += delta;
  //DrawLegend(x0 - 0.49, y0 - ndelta, allmc,        Form(" all (%.0f)",  Yield(allmc)),       "f",  0.03, 0.2, yoffset); ndelta += delta;
  DrawLegend(x0 - 0.49, y0 - ndelta, hist[iWW],    Form(" WW (%.0f)",   Yield(hist[iWW])),   "f",  0.03, 0.2, yoffset); ndelta += delta;
  DrawLegend(x0 - 0.49, y0 - ndelta, hist[iWZ],    Form(" WZ (%.0f)",   Yield(hist[iWZ])),  "f",  0.03, 0.2, yoffset); ndelta += delta;
  DrawLegend(x0 - 0.49, y0 - ndelta, hist[iWg],    Form(" Wg (%.0f)",    Yield(hist[iWg])),   "f",  0.03, 0.2, yoffset); ndelta += delta;
  DrawLegend(x0 - 0.49, y0 - ndelta, hist[iWgSMu], Form(" Wg*Mu (%.0f)",    Yield(hist[iWgSMu])),   "f",  0.03, 0.2, yoffset); ndelta += delta;
  DrawLegend(x0 - 0.49, y0 - ndelta, hist[iWgSEl], Form(" Wg*El (%.0f)",    Yield(hist[iWgSEl])),   "f",  0.03, 0.2, yoffset); ndelta += delta;
  DrawLegend(x0 - 0.49, y0 - ndelta, hist[iWj],    Form(" W+jets (%.0f)",Yield(hist[iWj])),   "f",  0.03, 0.2, yoffset); ndelta += delta;
  DrawLegend(x0 - 0.49, y0 - ndelta, hist[iZZ],    Form(" ZZ (%.0f)",    Yield(hist[iZZ])),   "f",  0.03, 0.2, yoffset); ndelta += delta;


  ndelta = 0;
  DrawLegend(x0 - 0.23, y0 - ndelta, hist[iDY],    Form(" DY (%.0f)",    Yield(hist[iDY])),   "f",  0.03, 0.2, yoffset); ndelta += delta;
  DrawLegend(x0 - 0.23, y0 - ndelta, hist[iDYtau], Form(" DYtau (%.0f)", Yield(hist[iDYtau])),"f",  0.03, 0.2, yoffset); ndelta += delta;
  DrawLegend(x0 - 0.23, y0 - ndelta, hist[iZgamma],Form(" Zg (%.0f)",   Yield(hist[iZgamma])),"f",  0.03, 0.2, yoffset); ndelta += delta;
  //DrawLegend(x0 - 0.23, y0 - ndelta, hist[iDY],   Form(" Z+jets (%.0f)", YieldZJets),         "f",  0.03, 0.2, yoffset); ndelta += delta;
  //DrawLegend(x0 - 0.23, y0 - ndelta, hist[iH125], Form(" Higgs (%.0f)",  Yield(hist[iH125])), "f",  0.03, 0.2, yoffset); ndelta += delta;
  DrawLegend(x0 - 0.23, y0 - ndelta, hist[iH125],  Form(" ggH (%.0f)",  Yield(hist[iH125])), "f",  0.03, 0.2, yoffset); ndelta += delta;
  DrawLegend(x0 - 0.23, y0 - ndelta, hist[itt],  Form(" tt (%.0f)",  Yield(hist[itt])), "f",  0.03, 0.2, yoffset); ndelta += delta;
  DrawLegend(x0 - 0.23, y0 - ndelta, hist[itW],  Form(" tW (%.0f)",  Yield(hist[itW])), "f",  0.03, 0.2, yoffset); ndelta += delta;


  // Additional titles
  //----------------------------------------------------------------------------
  //TString channelLabel = "ee/#mu#mu/e#mu/#mue";
  TString channelLabel = "";

  //if (_channel == "EE")   channelLabel = "ee";
  //if (_channel == "MuMu") channelLabel = "#mu#mu";
  //if (_channel == "EMu")  channelLabel = "e#mu";
  //if (_channel == "MuE")  channelLabel = "#mue";
  //if (_channel == "SF")   channelLabel = "ee/#mu#mu";
  //if (_channel == "OF")   channelLabel = "e#mu/#mue";

  channelLabel += Form(" %d", _njet);

  if (_njet == 0) channelLabel += "-jets";
  if (_njet == 1) channelLabel += "-jet";
  if (_njet >= 2) channelLabel += "-jets";

  double nBin;
  double binWidth;
  nBin = allmc->GetSize();
  nBin -=2;
  binWidth = allmc->GetBinWidth(2);

  int Z1bin=70/binWidth;
  int Z2bin=110/binWidth;

  cout<<"number of bin: "<<nBin<<endl;
  cout<<"Z bin1: "<<Z1bin<<" Z bin2: "<<Z2bin<<endl;
  double nMcZ, nDataZ;
  nMcZ   = allmc->Integral(Z1bin,Z2bin);
  nDataZ = hist[iData]->Integral(Z1bin,Z2bin);
  double effiCorr;
  effiCorr=nDataZ/nMcZ;
  cout<<"efficiency correction factor: "<<effiCorr<<endl;
  double nMcGstar, nDataGstar, nMcGamma;
  nMcGstar   = hist[iWgSMu]->Integral(1,2);
  nMcGamma   = hist[iWg]->Integral(1,2);
  //nMcGstar   = allmc->Integral(1,2);
  nMcGstar *= effiCorr;
  nMcGamma *= effiCorr;
  nDataGstar = hist[iData]->Integral(1,2);
  double Kfactor;
  double KfactorErr;
  nDataGstar -= nMcGamma;
  Kfactor = nDataGstar/nMcGstar;
  KfactorErr =Kfactor* TMath::Sqrt(nDataGstar/nDataGstar/nDataGstar + nMcGstar/nMcGstar/nMcGstar);
  KfactorErr += 0.1;
  cout<<"Kfactor: "<<Kfactor<<"+"<<KfactorErr<<endl;

  //DrawTLatex(0.185, 0.975, 0.05, 13, channelLabel.Data(),"");
  DrawTLatex(0.940, 0.983, 0.05, 33, Form("L = %.1f fb^{-1}", _luminosity/1e3),"");
  DrawTLatex(0.45, 0.48, 0.04, 13, Form("K factor (Data/Wg*) = %.2f #pm %.2f", Kfactor, KfactorErr ),"");
  DrawTLatex(0.45, 0.43, 0.04, 13, Form("0< InvM(#mu^{+}#mu^{-}) <4 GeV"),"");

  //----------------------------------------------------------------------------
  // pad2
  //----------------------------------------------------------------------------
  pad2->cd();
    
  TH1F* ratio       = (TH1F*)hist[iData]->Clone("ratio");
  TH1F* uncertainty = (TH1F*)allmc->Clone("uncertainty");
    
  for (UInt_t ibin=1; ibin<=ratio->GetNbinsX(); ibin++) {

    Double_t mcValue = allmc->GetBinContent(ibin);
    Double_t mcError = allmc->GetBinError  (ibin);
    
    Double_t dtValue = ratio->GetBinContent(ibin);
    Double_t dtError = ratio->GetBinError  (ibin);

    Double_t ratioValue       = (mcValue > 0) ? dtValue/mcValue : 0.0;
    Double_t ratioError       = (mcValue > 0) ? dtError/mcValue : 0.0;
    Double_t uncertaintyError = (mcValue > 0) ? mcError/mcValue : 0.0;

    ratio->SetBinContent(ibin, ratioValue);
    ratio->SetBinError  (ibin, ratioError);

    uncertainty->SetBinContent(ibin, 1.0);
    uncertainty->SetBinError  (ibin, uncertaintyError);
  }


  TAxis* uaxis = (TAxis*)uncertainty->GetXaxis();
    
  uaxis->SetRangeUser(xmin, xmax);
    
    
  uncertainty->Draw("e2");
  ratio      ->Draw("ep,same");

  uncertainty->GetYaxis()->SetRangeUser(0, 2.5);


  // Save
  //----------------------------------------------------------------------
  pad2->cd(); SetAxis(uncertainty, hist[iData]->GetXaxis()->GetTitle(), "data / prediction", 0.10, 0.8);
  pad1->cd(); SetAxis(hist[iData], "", hist[iData]->GetYaxis()->GetTitle(),                  0.05, 1.6);

  canvas->cd();

  TString suffixLogy = (_setLogy) ? "_Log" : "_Lin";

  canvas->SaveAs(Form("%s/%s%s.%s",
		      _output.Data(),
		      hname.Data(),
		      suffixLogy.Data(),
		      _format.Data()));
}
void embeddedToysWithBackgDetEffects_1DKD(int nEvts=600, int nToys=3000,
					  sample mySample = kScalar_fa3p5, 
					  bool bkg, bool sigFloating, int counter){
  
  RooRealVar* kd = new RooRealVar("psMELA","psMELA",0,1);
  kd->setBins(1000);
  RooPlot* kdframe1 = kd->frame();
  
  // 0- template
  TFile f1("KDdistribution_ps_analytical_detEff.root", "READ"); 
  TH1F *h_KD_ps = (TH1F*)f1.Get("h_KD");
  h_KD_ps->SetName("h_KD_ps");
  RooDataHist rdh_KD_ps("rdh_KD_ps","rdh_KD_ps",RooArgList(*kd),h_KD_ps);
  RooHistPdf pdf_KD_ps("pdf_KD_ps","pdf_KD_ps",RooArgList(*kd),rdh_KD_ps); 

  // 0+ template
  TFile f2("KDdistribution_sm_analytical_detEff.root", "READ"); 
  TH1F *h_KD_sm = (TH1F*)f2.Get("h_KD");
  h_KD_sm->SetName("h_KD_sm");
  RooDataHist rdh_KD_sm("rdh_KD_sm","rdh_KD_sm",RooArgList(*kd),h_KD_sm);
  RooHistPdf pdf_KD_sm("pdf_KD_sm","pdf_KD_sm",RooArgList(*kd),rdh_KD_sm); 

  // backg template
  TFile f3("KDdistribution_bkg_analytical_detEff.root", "READ"); 
  TH1F *h_KD_bkg = (TH1F*)f3.Get("h_KD");
  h_KD_bkg->SetName("h_KD_bkg");
  RooDataHist rdh_KD_bkg("rdh_KD_bkg","rdh_KD_bkg",RooArgList(*kd),h_KD_bkg);
  RooHistPdf pdf_KD_bkg("pdf_KD_bkg","pdf_KD_bkg",RooArgList(*kd),rdh_KD_bkg); 

  //Define signal model with 0+, 0- mixture
  RooRealVar rrv_fa3("fa3","fa3",0.5,0.,1.);  //free parameter of the model
  RooFormulaVar rfv_fa3Obs("fa3obs","1/ (1 + (1/@0 - 1)*0.99433)",RooArgList(rrv_fa3));
  RooAddPdf modelSignal("modelSignal","ps+sm",pdf_KD_ps,pdf_KD_sm,rfv_fa3Obs);  
  rrv_fa3.setConstant(kFALSE);
  
  //Define signal+bakground model
  RooRealVar rrv_BoverTOT("BoverTOT","BoverTOT",1/(3.75+1),0.,10.);  
  RooAddPdf model("model","background+modelSignal",pdf_KD_bkg,modelSignal,rrv_BoverTOT);  
  if(sigFloating)
    rrv_BoverTOT.setConstant(kFALSE);
  else
    rrv_BoverTOT.setConstant(kTRUE);

  //Set the values of free parameters to compute pulls
  double fa3Val=-99;
  if (mySample == kScalar_fa3p0)
    fa3Val=0.;
  else if (mySample == kScalar_fa3p1)
    fa3Val=0.1;
  else if (mySample == kScalar_fa3p5 || mySample == kScalar_fa3p5phia390)
    fa3Val=0.5;
  else if (mySample == kScalar_fa3p25)
    fa3Val=0.25;
  else{
    cout<<"fa3Val not correct!"<<endl;
      return 0;
  }
  double sigFracVal=1 - 1/(3.75+1);

  //Plot the models
  TCanvas* c = new TCanvas("modelPlot_detBkg","modelPlot_detBkg",400,400);
  rdh_KD_ps.plotOn(kdframe1,LineColor(kBlack),MarkerColor(kBlack));
  pdf_KD_ps.plotOn(kdframe1,LineColor(kBlack),RooFit::Name("pseudo"));
  //rdh_KD_sm.plotOn(kdframe1,LineColor(kBlue),MarkColor(kBlue));
  pdf_KD_sm.plotOn(kdframe1,LineColor(kBlue),RooFit::Name("SM"));
  //rdh_KD_bkg.plotOn(kdframe1,LineColor(kGreen),LineColor(kGreen));
  pdf_KD_bkg.plotOn(kdframe1,LineColor(kGreen),RooFit::Name("bkg"));
  modelSignal.plotOn(kdframe1,LineColor(kRed),RooFit::Name("signal_fa3p5"));
  model.plotOn(kdframe1,LineColor(kOrange),RooFit::Name("signal+background"));
  TLegend *leg = new TLegend (0.7,0.6,0.95,0.8);
  leg->AddEntry(kdframe1->findObject("pseudo"),"0-","L");
  leg->AddEntry(kdframe1->findObject("SM"),"0+","L");
  leg->AddEntry(kdframe1->findObject("bkg"),"bkg","L");
  leg->AddEntry(kdframe1->findObject("signal_fa3p5"),"signal fa3=0.5","L");
  leg->AddEntry(kdframe1->findObject("signal+background"),"signal + bkg","L");
  kdframe1->Draw();
  leg->SetFillColor(kWhite);
  leg->Draw("same");
  c->SaveAs("modelPlot_detBkg.eps");
  c->SaveAs("modelPlot_detBkg.png");

  
  //Load the trees into the datasets
  TChain* myChain = new TChain("SelectedTree");
  myChain->Add(inputFileNames[mySample]);
  if(!myChain || myChain->GetEntries()<=0) {
    cout<<"error in the tree"<<endl;
    return 0;
  }
  RooDataSet* data = new RooDataSet("data","data",myChain,RooArgSet(*kd),"");

  TChain* myChain_bkg = new TChain("SelectedTree");
  myChain_bkg->Add("samples/analyticalpsMELA/withResolution/pwgevents_mllCut10_smeared_withDiscriminants_2e2mu_cutDetector.root");
  myChain_bkg->Add("samples/analyticalpsMELA/withResolution/pwgevents_mllCut4_wResolution_withDiscriminants_cutDetector.root");
  if(!myChain_bkg || myChain_bkg->GetEntries()<=0) {
    cout<<"error in the tree"<<endl;
    return 0;
  }
  RooDataSet* data_bkg = new RooDataSet("data_bkg","data_bkg",myChain_bkg,RooArgSet(*kd),"");

  cout << "Number of events in data sig: " << data->numEntries() << endl;
  cout << "Number of events in data bkg: " << data_bkg->numEntries() << endl;
  
  // Initialize tree to save toys to 
  TTree* results = new TTree("results","toy results");
  
  double fa3,fa3Error, fa3Pull;
  double sigFrac,sigFracError, sigFracPull;
  double significance;

  results->Branch("fa3",&fa3,"fa3/D");
  results->Branch("fa3Error",&fa3Error,"fa3Error/D");
  results->Branch("fa3Pull",&fa3Pull,"fa3Pull/D");
  results->Branch("sigFrac",&sigFrac,"sigFrac/D");
  results->Branch("sigFracError",&sigFracError,"sigFracError/D");
  results->Branch("sigFracPull",&sigFracPull,"sigFracPull/D");
  results->Branch("significance",&significance,"significance/D");

  //---------------------------------

  RooDataSet* toyData;
  RooDataSet* toyData_bkgOnly;
  int embedTracker=nEvts*counter;
  int embedTracker_bkg=TMath::Ceil(nEvts/3.75*counter);
  RooArgSet *tempEvent;

  RooFitResult *toyfitresults;
  RooFitResult *toyfitresults_sigBkg;
  RooFitResult *toyfitresults_bkgOnly;
  RooRealVar *r_fa3;
  RooRealVar *r_sigFrac;

  for(int i = 0 ; i<nToys ; i++){
    cout <<i<<"<-----------------------------"<<endl;
    //if(toyData) delete toyData;
    toyData = new RooDataSet("toyData","toyData",RooArgSet(*kd));
    toyData_bkgOnly = new RooDataSet("toyData_bkgOnly","toyData_bkgOnly",RooArgSet(*kd));

    if(nEvts+embedTracker > data->sumEntries()){
      cout << "Playground::generate() - ERROR!!! Playground::data does not have enough events to fill toy!!!!  bye :) " << endl;
      toyData = NULL;
      abort();
      return 0;
    }
    if(nEvts+embedTracker_bkg > data_bkg->sumEntries()){
      cout << "Playground::generate() - ERROR!!! Playground::data does not have enough events to fill toy!!!!  bye :) " << endl;
      toyData = NULL;
      abort();
      return 0;
    }

    for(int iEvent=0; iEvent<nEvts; iEvent++){
      if(iEvent==1)
	cout << "generating event: " << iEvent << " embedTracker: " << embedTracker << endl;
      tempEvent = (RooArgSet*) data->get(embedTracker);
      toyData->add(*tempEvent);
      embedTracker++;
    }
    if(bkg){
      for(int iEvent=0; iEvent<nEvts/3.75; iEvent++){
	if(iEvent==1)
	  cout << "generating bkg event: " << iEvent << " embedTracker bkg: " << embedTracker_bkg << endl;
	tempEvent = (RooArgSet*) data_bkg->get(embedTracker_bkg);
	toyData->add(*tempEvent);
	toyData_bkgOnly->add(*tempEvent);
	embedTracker_bkg++;
      }
    }

    if(bkg)
      toyfitresults =model.fitTo(*toyData,Save());
    else
      toyfitresults =modelSignal.fitTo(*toyData,Save());

    //cout<<toyfitresults<<endl;
    r_fa3 = (RooRealVar *) toyfitresults->floatParsFinal().find("fa3");

    fa3 = r_fa3->getVal();
    fa3Error = r_fa3->getError();
    fa3Pull = (r_fa3->getVal() - fa3Val) / r_fa3->getError();
    if(sigFloating){
      r_sigFrac = (RooRealVar *) toyfitresults->floatParsFinal().find("BoverTOT");
      sigFrac = 1-r_sigFrac->getVal();
      sigFracError = r_sigFrac->getError();
      sigFracPull = (1-r_sigFrac->getVal() - sigFracVal) / r_sigFrac->getError();
    }
    // fill TTree
    results->Fill();
  }

  char nEvtsString[100];
  sprintf(nEvtsString,"_%iEvts_%iiter",nEvts, counter);

  // write tree to output file (ouputFileName set at top)
  TFile *outputFile = new TFile("embeddedToys1DKD_fa3Corr_WithBackgDetEffects_"+sampleName[mySample]+nEvtsString+".root","RECREATE");
  results->Write();
  outputFile->Close();

}
Пример #26
0
//------------------------------------------------------------------------------
//Subtraction 
//------------------------------------------------------------------------------
void Subtraction(TString  hname,
		   TString  xtitle,
		   Int_t    ngroup       = -1,
		   Int_t    precision    = 1,
		   TString  units        = "NULL",
		   Double_t xmin         = -999,
		   Double_t xmax         =  999,
		   Bool_t   moveOverflow = true)
{
  TCanvas* canvas = new TCanvas(hname, hname, 800, 800);

  TPad* pad1 = new TPad("pad1", "pad1", 0, 0.0, 1, 1.0);

  pad1->SetTopMargin   (0.08);
  //pad1->SetBottomMargin(0.02);
  pad1->Draw();
      

  //----------------------------------------------------------------------------
  // pad1
  //----------------------------------------------------------------------------
  pad1->cd();

  pad1->SetLogy(_setLogy);

  TH1F* hist[nProcesses];

  for (UInt_t ip=0; ip<nProcesses; ip++) {

    hist[ip] = (TH1F*)input[ip]->Get(hname);
    hist[ip]->SetName(hname + process[ip]);

    if (moveOverflow) MoveOverflowBins  (hist[ip], xmin, xmax);
    else              ZeroOutOfRangeBins(hist[ip], xmin, xmax);

	if (ngroup > 0) hist[ip]->Rebin(ngroup);

	if (_dataDriven && ip == iWW)    hist[ip]->Scale(WWScale[_njet]);
	if (_dataDriven && ip == iDY)    hist[ip]->Scale(ZjScale[_njet]);
	if (_dataDriven && ip == iDYtau) hist[ip]->Scale(ZjScale[_njet]);

  }

  // Data subtraction for Top background estimation
  //----------------------------------------------------------------------------
  TH1F* subData = (TH1F*)hist[iData]->Clone("subData");
  for (UInt_t ip=0; ip<nProcesses; ip++) {
	  if (ip == itt) continue;
	  if (ip == itW) continue;
	  if (ip == iData ) continue;
	  subData->Add(hist[ip],-1);
  }
  subData->SetLineColor(kRed+1);
  Double_t subData_Yield = subData->Integral();
  //subData->SetLineColor();

  // Top background
  //----------------------------------------------------------------------------
  TH1F* Top = (TH1F*)hist[itt]->Clone("Top");
  Top->Add(hist[itW]);
  Top->SetLineColor(kBlue+1);
  Double_t Top_Yield = Top->Integral();

  // Axis labels
  //----------------------------------------------------------------------------
  TAxis* xaxis = subData->GetXaxis();
  TAxis* yaxis = subData->GetYaxis();

  TString ytitle = Form("entries / %s.%df", "%", precision);

  xaxis->SetTitle(xtitle);
  yaxis->SetTitle(Form(ytitle.Data(), subData->GetBinWidth(0)));
  yaxis->SetTitleOffset(1.6);

  if (!units.Contains("NULL")) {
    
    xaxis->SetTitle(Form("%s [%s]", xaxis->GetTitle(), units.Data()));
    yaxis->SetTitle(Form("%s %s",   yaxis->GetTitle(), units.Data()));
  }


  // Draw
  //----------------------------------------------------------------------------
  xaxis->SetRangeUser(xmin, xmax);

  subData->Draw("hist");
  Top->Draw("hist same");

  // Adjust scale
  //----------------------------------------------------------------------------
  subData->SetMinimum(0.0);
  
  Float_t theMax   = GetMaximumIncludingErrors(subData, xmin, xmax);
  Float_t theMaxMC = GetMaximumIncludingErrors(Top,       xmin, xmax);

  if (theMaxMC > theMax) theMax = theMaxMC;

  if (pad1->GetLogy()) {

    theMax = TMath::Power(10, TMath::Log10(theMax) + 2.7);

    subData->SetMinimum(0.05);
  }
  else theMax *= 1.55;

  subData->SetMaximum(theMax);

  // Legend
  //----------------------------------------------------------------------------
  Double_t x0      = 0.720; 
  Double_t y0      = 0.834; 
  Double_t yoffset = 0.048;
  Double_t delta   = yoffset + 0.001;
  Double_t ndelta  = 0;

  DrawLegend(x0 - 0.49, y0 - ndelta, subData, Form(" Data Subtraction (MC without Top) (%.0f)", Yield(subData)), "l", 0.03, 0.2, yoffset); ndelta += delta;
  DrawLegend(x0 - 0.49, y0 - ndelta, Top,     Form(" Top (%.0f)",  Yield(Top)),     "l", 0.03, 0.2, yoffset); ndelta += delta;

  // Additional titles
  //----------------------------------------------------------------------------
  //TString channelLabel = "ee/#mu#mu/e#mu/#mue";
  TString channelLabel = "";

  //if (_channel == "EE")   channelLabel = "ee";
  //if (_channel == "MuMu") channelLabel = "#mu#mu";
  //if (_channel == "EMu")  channelLabel = "e#mu";
  //if (_channel == "MuE")  channelLabel = "#mue";
  //if (_channel == "SF")   channelLabel = "ee/#mu#mu";
  //if (_channel == "OF")   channelLabel = "e#mu/#mue";

  channelLabel += Form(" %d", _njet);

  if (_njet == 0) channelLabel += "-jets";
  if (_njet == 1) channelLabel += "-jet";
  if (_njet >= 2) channelLabel += "-jets";

  DrawTLatex(0.185, 0.975, 0.05, 13, channelLabel.Data(),"");
  DrawTLatex(0.940, 0.983, 0.05, 33, Form("L = %.1f fb^{-1}", _luminosity/1e3),"");
  
  if (Top_Yield!=0){ 
	  cout << "subData_Yield = "<<subData_Yield<<", Top_Yield = "<<Top_Yield<<", Ratio = "<< subData_Yield/Top_Yield <<endl;
	  TLatex *tex3 = new TLatex(0.250, 0.75, "Scale Factor");
	  tex3->SetNDC();
	  tex3->SetTextSize(0.035);
	  tex3->Draw();
	  TLatex *tex4 = new TLatex(0.250, 0.7, Form("%.0f / %.0f = %3.3f",subData_Yield ,Top_Yield ,subData_Yield/Top_Yield));
	  tex4->SetNDC();
	  tex4->SetTextSize(0.035);
	  tex4->Draw();
  }


  // Save
  //----------------------------------------------------------------------------
  pad1->cd(); 
  //SetAxis(subData, "", subData->GetYaxis()->GetTitle(),                  0.05, 1.6);

  canvas->cd();

  TString suffixLogy = (_setLogy) ? "_Log" : "_Lin";

  canvas->SaveAs(Form("%s/%s%s_sub.%s",
		      _output.Data(),
		      hname.Data(),
		      suffixLogy.Data(),
		      _format.Data()));
  
}
void makejpsifit(string inputFilename, string outFilename, 
		 Int_t ptBin, Int_t etaBin,
		 double minMass, double maxMass, 
		 double mean_bw, double gamma_bw, double cutoff_cb, double power_cb, 
		 const char* plotOpt, const int nbins, Int_t isMC) {

  TStyle *mystyle = RooHZZStyle("ZZ");
  mystyle->cd();

  //Create Data Set
  RooRealVar mass("zmass","m(e^{+}e^{-})",minMass,maxMass,"GeV/c^{2}");

  // Reading everything from root tree instead
  TFile *tfile = TFile::Open(inputFilename.c_str());
  TTree *ttree = (TTree*)tfile->Get("zeetree/probe_tree");
  hzztree *zeeTree = new hzztree(ttree);

  RooArgSet zMassArgSet(mass);
  RooDataSet* data = new RooDataSet("data", "ntuple parameters", zMassArgSet);

  for (int i = 0; i < zeeTree->fChain->GetEntries(); i++) {
    if(i%100000==0) cout << "Processing Event " << i << endl;
    zeeTree->fChain->GetEntry(i);

    //*************************************************************************
    //Electron Selection
    //*************************************************************************
    // already passed for this tree

    //*************************************************************************
    //Compute electron four vector;
    //*************************************************************************
    double ele1pt = zeeTree->l1pt;
    double ele2pt = zeeTree->l2pt;

    double ELECTRONMASS = 0.51e-3;
    TLorentzVector ele1FourVector;
    ele1FourVector.SetPtEtaPhiM(zeeTree->l1pt, zeeTree->l1eta, zeeTree->l1phi, ELECTRONMASS);
    TLorentzVector ele2FourVector;
    ele2FourVector.SetPtEtaPhiM(zeeTree->l2pt, zeeTree->l2eta, zeeTree->l2phi, ELECTRONMASS);

    
    //*************************************************************************
    //pt and eta cuts on electron
    //*************************************************************************
    if (! (ele1pt > 7 && ele2pt > 7
           && fabs( zeeTree->l1eta) < 2.5 
           && fabs( zeeTree->l2eta) < 2.5 )) continue;

    //*************************************************************************
    //pt bins and eta bins
    //*************************************************************************
    Int_t Ele1PtBin = -1;
    Int_t Ele1EtaBin = -1;
    Int_t Ele2PtBin = -1;
    Int_t Ele2EtaBin = -1;
    if (ele1pt > 7 && ele1pt < 10) Ele1PtBin = 0;
    else if (ele1pt < 20) Ele1PtBin = 1;
    else Ele1PtBin = 2;
    if (ele2pt > 7 && ele2pt < 10) Ele2PtBin = 0;
    else if (ele2pt < 20) Ele2PtBin = 1;
    else Ele2PtBin = 2;
    if (fabs(zeeTree->l1sceta) < 1.479) Ele1EtaBin = 0;
    else Ele1EtaBin = 1;
    if (fabs(zeeTree->l2sceta) < 1.479) Ele2EtaBin = 0;
    else Ele2EtaBin = 1;

    if (!(Ele1PtBin == ptBin || Ele2PtBin == ptBin)) continue; 
    if (!(Ele1EtaBin == etaBin && Ele2EtaBin == etaBin)) continue; 
    
    //*************************************************************************
    // restrict range of mass
    //*************************************************************************
    double zMass = (ele1FourVector+ele2FourVector).M();
    if (zMass < minMass || zMass > maxMass) continue;

    //*************************************************************************
    //set mass variable
    //*************************************************************************
    zMassArgSet.setRealValue("zmass", zMass);    

    data->add(zMassArgSet);
  }

  // do binned fit to gain time...
  mass.setBins(nbins);
  RooDataHist *bdata = new RooDataHist("data_binned","data_binned", zMassArgSet, *data);

  cout << "dataset size: " << data->numEntries() << endl;

//   // Closing file
//   treeFile->Close();
  //====================== Parameters===========================

  //Crystal Ball parameters
//   RooRealVar cbBias ("#Deltam_{CB}", "CB Bias", -.01, -10, 10, "GeV/c^{2}");
//   RooRealVar cbSigma("sigma_{CB}", "CB Width", 1.7, 0.8, 5.0, "GeV/c^{2}");
//   RooRealVar cbCut  ("a_{CB}","CB Cut", 1.05, 1.0, 3.0);
//   RooRealVar cbPower("n_{CB}","CB Order", 2.45, 0.1, 20.0);
  RooRealVar cbBias ("#Deltam_{CB}", "CB Bias", -.01, -10, 10, "GeV/c^{2}");
  RooRealVar cbSigma("#sigma_{CB}", "CB Width", 1.5, 0.01, 5.0, "GeV/c^{2}");
  RooRealVar cbCut  ("a_{CB}","CB Cut", 1.0, 1.0, 3.0);
  RooRealVar cbPower("n_{CB}","CB Order", 2.5, 0.1, 20.0);
  cbCut.setVal(cutoff_cb);
  cbPower.setVal(power_cb);

  // Just checking
  //cbCut.Print();
  //cbPower.Print();

  //Breit_Wigner parameters
  RooRealVar bwMean("m_{JPsi}","BW Mean", 3.096916, "GeV/c^{2}");
  bwMean.setVal(mean_bw);
  RooRealVar bwWidth("#Gamma_{JPsi}", "BW Width", 92.9e-6, "GeV/c^{2}");
  bwWidth.setVal(gamma_bw);

  // Fix the Breit-Wigner parameters to PDG values
  bwMean.setConstant(kTRUE);
  bwWidth.setConstant(kTRUE);

  // Exponential Background parameters
  RooRealVar expRate("#lambda_{exp}", "Exponential Rate", -0.064, -1, 1);
  RooRealVar c0("c_{0}", "c0", 1., 0., 50.);

  //Number of Signal and Background events
  RooRealVar nsig("N_{S}", "# signal events", 524, 0.1, 10000000000.);
  RooRealVar nbkg("N_{B}", "# background events", 43, 1., 10000000.);

  //============================ P.D.F.s=============================

  // Mass signal for two decay electrons p.d.f.
  RooBreitWigner bw("bw", "bw", mass, bwMean, bwWidth);
  RooCBShape  cball("cball", "Crystal Ball", mass, cbBias, cbSigma, cbCut, cbPower);
  RooFFTConvPdf BWxCB("BWxCB", "bw X crystal ball", mass, bw, cball);

  // Mass background p.d.f.
  RooExponential bg("bg", "exp. background", mass, expRate);

  // Mass model for signal electrons p.d.f.
  RooAddPdf model("model", "signal", RooArgList(BWxCB), RooArgList(nsig));

  TStopwatch t ;
  t.Start() ;
  double fitmin, fitmax;
  if(isMC) {
    fitmin = (etaBin==0) ? 3.00 : 2.7;
    fitmax = (etaBin==0) ? 3.20 : 3.4;
  } else {
    fitmin = (etaBin==0) ? ( (ptBin>=2) ? 3.01 : 3.02 ) : 2.7;
    fitmax = (etaBin==0) ? ( (ptBin==3) ? 3.23 : 3.22 ) : 3.4;
  }
  RooFitResult *fitres = model.fitTo(*bdata,Range(fitmin,fitmax),Hesse(1),Minos(1),Timer(1),Save(1));
  fitres->SetName("fitres");
  t.Print() ;

  TCanvas* c = new TCanvas("c","Unbinned Invariant Mass Fit", 0,0,800,600);

  //========================== Plotting  ============================
  //Create a frame
  RooPlot* plot = mass.frame(Range(minMass,maxMass),Bins(nbins));
  // Add data and model to canvas
  int col = (isMC ? kAzure+4 : kGreen+1);
  data->plotOn(plot);
  model.plotOn(plot,LineColor(col));
  data->plotOn(plot);
  model.paramOn(plot, Format(plotOpt, AutoPrecision(1)), Parameters(RooArgSet(cbBias, cbSigma, cbCut, cbPower, bwMean, bwWidth, expRate, nsig, nbkg)), Layout(0.15,0.45,0.80));
  plot->getAttText()->SetTextSize(.03);
  plot->SetTitle("");
  plot->Draw();

  // Print Fit Values
  TLatex *tex = new TLatex();
  tex->SetNDC();
  tex->SetTextSize(.1);
  tex->SetTextFont(132);
  //  tex->Draw();
  tex->SetTextSize(0.057);
  if(isMC) tex->DrawLatex(0.65, 0.75, "J/#psi #rightarrow e^{+}e^{-} MC");
  else tex->DrawLatex(0.65, 0.75, "J/#psi #rightarrow e^{+}e^{-} data");
  tex->SetTextSize(0.030);
  tex->DrawLatex(0.645, 0.65, Form("BW Mean = %.2f GeV/c^{2}", bwMean.getVal()));
  tex->DrawLatex(0.645, 0.60, Form("BW #sigma = %.2f GeV/c^{2}", bwWidth.getVal()));
  c->Update();
  c->SaveAs((outFilename + ".pdf").c_str());
  c->SaveAs((outFilename + ".png").c_str());

  // tablefile << Form(Outfile + "& $ %f $ & $ %f $ & $ %f $\\ \hline",cbBias.getVal(), cbSigma.getVal(), cbCut.getVal());
  // Output workspace with model and data

  RooWorkspace *w = new RooWorkspace("JPsieeMassScaleAndResolutionFit");
  w->import(model);
  w->import(*bdata);
  w->writeToFile((outFilename + ".root").c_str());  

  TFile *tfileo = TFile::Open((outFilename + ".root").c_str(),"update");
  fitres->Write();
  tfileo->Close();

}
Пример #28
0
// -----------------------------------------------------------------------------
//
TCanvas* createPlot( TDirectory* output_file,
		     std::string output_canvas, 
		     std::vector<std::string> input_files, 
		     std::vector<std::string> input_histos, 
		     std::vector<std::string> input_legend, 
 		     std::vector<int> marker_style, 
 		     std::vector<int> marker_colour, 
 		     std::vector<float> marker_size, 
 		     std::vector<float> lumis, 
		     double lumi,
		     int rebin, 
		     bool norm, 
		     bool log,
		     double min = -1.,
		     double max = -1. )
{

  // SetSomeStyles();
  
  // Create legend
  TLegend* legend = new TLegend( 0.6, 0.5, 0.9, 0.7,  NULL, "brNDC" );
  legend->SetFillColor(0);
  legend->SetLineColor(0); 
  
  // Create canvas
  TCanvas* aCanvas = createCanvas( output_canvas, output_file, log );
  
  TPaveText* stats = new TPaveText( 0.6, 0.3, 0.9, 0.45, "brNDC" );
  stats->SetFillColor(0);
  stats->SetLineColor(0);

  TLatex* prelim = new TLatex( 0.55, 0.8, "#scale[0.8]{CMS preliminary 2011}" );
  prelim->SetTextSize(0.04);
  prelim->SetNDC();
  std::stringstream ssl; ssl << "#scale[0.8]{#int L dt = " << lumi << "pb^{-1}, #sqrt{s} = 7 TeV}";
  TLatex* lumistxt = new TLatex( 0.51, 0.87, ssl.str().c_str() );
  lumistxt->SetTextSize(0.04);
  lumistxt->SetNDC();
    
  // First histo be drawn
  bool first = true;
  
  // Loop through histogram names
  std::vector<TH1D*> his;
  for ( uint ihis = 0; ihis < input_histos.size(); ++ihis ) {
    his.push_back( (TH1D*)getHisto( input_files[ihis], input_histos[ihis], "QcdBkgdEst", rebin ) );
  }

  // For Ted
  bool print_ted = true;
  std::stringstream ted;
  if ( print_ted ) { ted << "self._htMeans = ("; }

  // Loop through histograms
  double aMax = 0.;
  double aMin = 1.e12;
  for ( uint ihis = 0; ihis < his.size(); ++ihis ) {
    if ( !his[ihis] ) { continue; }
    
    // Line colour and fill
    his[ihis]->Scale(lumis[ihis]/100.);
    his[ihis]->SetMarkerStyle(marker_style[ihis]);
    his[ihis]->SetMarkerColor(marker_colour[ihis]);
    his[ihis]->SetMarkerSize(marker_size[ihis]);
    his[ihis]->SetLineColor(marker_colour[ihis]);
    his[ihis]->SetLineStyle(0);
    his[ihis]->SetLineWidth(0);
    
    // Populate legend
    if ( input_legend.size() > ihis ) { legend->AddEntry( his[ihis], input_legend[ihis].c_str(), "EPL" ); }
    else                              { legend->AddEntry( his[ihis], input_histos[ihis].c_str(), "EPL" ); }

    // Populate stats box
    std::stringstream ss;
    ss << "Mean=" << int(his[ihis]->GetMean()*100.)/100. << ", RMS=" << int(his[ihis]->GetRMS()*100.)/100.;
    TText* text = stats->AddText(ss.str().c_str());
    text->SetTextAlign(11);
    text->SetTextSize(0.03);
    text->SetTextColor(marker_colour[ihis]);

    // For Ted
    if ( print_ted ) ted << std::setw(9) << std::scientific << std::setprecision(3) << his[ihis]->GetMean() << ", ";
    
    // Calc min/max number of entries
    if ( his[ihis]->GetMaximum() > aMax ) { aMax = his[ihis]->GetMaximum(); }
    if ( his[ihis]->GetMinimum(1.e-12) < aMin ) { aMin = his[ihis]->GetMinimum(1.e-12); }

  }

  // For Ted
  if ( print_ted ) { 
    ted << ")" << std::endl;
    std::cout << ted.str() << std::endl;
  }

  if ( !his.empty() ) {
    if ( his[0] ) his[0]->GetYaxis()->SetTitleOffset(1.43);
    if ( his[0] ) his[0]->GetYaxis()->SetTitleSize(0.06);
    if ( his[0] ) his[0]->GetXaxis()->SetTitleSize(0.06);
    if ( his[0] ) his[0]->GetXaxis()->SetTitleOffset(0.9);
  }

  for ( uint ihis = 0; ihis < his.size(); ++ihis ) {

    if ( !his[ihis] ) { continue; }
    
    //his[ihis]->GetYaxis()->SetTitle("a.u.");
    
    if ( log ) {
      his[ihis]->SetMaximum( aMax * 10. );
      his[ihis]->SetMinimum( aMin * 0.1 );
    } else {
      his[ihis]->SetMaximum( aMax * 1.1 );
      his[ihis]->SetMinimum( aMin * 0.9 );
    }

    if ( min > 0. ) his[ihis]->SetMinimum( min );
    if ( max > 0. ) his[ihis]->SetMaximum( max );
    
    if ( norm ) {
      std::string options = "";
      if ( first ) { options = "Ehist"; first = false; }
      else { options = "hsame"; }
      if ( his[ihis]->GetEntries() > 0. ) { his[ihis]->DrawNormalized(options.c_str()); }
    } else {
      std::string options = "";
      if ( first ) { options = "h"; first = false; }
      else { options = "hsame"; }
      his[ihis]->Draw(options.c_str());
    }
    
  } // Loop through histos

  output_file->cd();
  legend->Draw("same");
  stats->Draw("same");
  prelim->Draw("same");
  lumistxt->Draw("same");
  aCanvas->Modified();
  //aCanvas->SaveAs( std::string(output_canvas+".png").c_str() );
  aCanvas->SaveAs( std::string(output_canvas+".pdf").c_str() );
  aCanvas->SaveAs( std::string(output_canvas+".C").c_str() );
  aCanvas->Write();
  return aCanvas;

}
Пример #29
0
void plot_CL_chi2_roofit(char * filename, double min, double max, double initial, double ndof_min, double ndof_max, char * plot, char * var = "chi2")
{

	//gStyle->SetOptStat(0);
	//gStyle->SetOptFit(1);
	//gStyle->SetStatFontSize(0.02);
	TFile * _file0 = TFile::Open(filename);
	TTree * t = (TTree*)_file0->Get("tuple");

	RooRealVar * chi2 = new RooRealVar(var, "#chi^{2}", min, max);
	RooRealVar * ndof = new RooRealVar("ndof", "ndof", initial, ndof_min, ndof_max);
	RooChiSquarePdf * pdf = new RooChiSquarePdf("pdf", "pdf", *chi2, *ndof);

	RooDataSet * data = new RooDataSet("data", "data", RooArgSet(*chi2), RooFit::Import(*t));

	pdf->fitTo(*data);

	char formula[30];
	sprintf(formula, "TMath::Prob(%s,ndof)", var);

	RooFormulaVar * CL_ndof_eff_formula = new RooFormulaVar("CL","CL(#chi^{2})",formula, RooArgList(*chi2, *ndof));
	RooRealVar * CL_ndof_eff = (RooRealVar*) data->addColumn(*CL_ndof_eff_formula);
	CL_ndof_eff->setRange(0, 1);
	RooUniform * uniform = new RooUniform("uniform", "uniform", *CL_ndof_eff);
	uniform->fitTo(*data);

	//RooFormulaVar * CL_ndof_min_formula = new RooFormulaVar("CL","CL(#chi^{2})","TMath::Prob(chi2,39)", RooArgList(*chi2));
	//RooRealVar * CL_ndof_min = (RooRealVar*) data->addColumn(*CL_ndof_min_formula);
	//CL_ndof_min->setRange(0, 1);

	RooPlot * frame0 = chi2->frame(RooFit::Bins(25));
	data->plotOn(frame0);
	pdf->plotOn(frame0);
	pdf->paramOn(frame0, RooFit::Format("NELU", RooFit::AutoPrecision(2)), RooFit::Layout(0.6,0.95,0.75)); 
	data->statOn(frame0, RooFit::Format("NELU", RooFit::AutoPrecision(2)), RooFit::Layout(0.6,0.95,0.95));

	RooPlot * frame1 = CL_ndof_eff->frame(RooFit::Bins(10));
	data->plotOn(frame1);
	uniform->plotOn(frame1);	

        TCanvas * c = new TCanvas("c","c",1200, 600);
        c->Divide(2,1);
        c->cd(1);
	frame0->Draw();
        c->cd(2);
	frame1->Draw();

/*
        char buf[30];
        sprintf(buf, "TMath::Prob(chi2,%f)>>h1", f1->GetParameter(0));
        cout << buf << endl;
        c->Modified();
        c->Update();

        c->cd(2);
        t->Draw("TMath::Prob(chi2,ndof-8)>>h0");
        t->Draw(buf);
        h1->Draw();
        h1->Fit("pol0");
        h0->Draw("same");
        h1->GetXaxis()->SetTitle("CL(#chi^{2})");
        h1->GetYaxis()->SetTitle("Number of toys / 0.1");
        h1->SetMinimum(0);
        h1->SetMaximum(2*t->GetEntries()/nbins);
*/
        c->SaveAs(plot);



}
Пример #30
0
void MakeSpinPlots::DrawBlindFit(TString tag, TString mcName,TString cosThetaBin){
  TString fitTag="FULLFIT";
  TString cat = "evtcat";
  if(cosThetaBin!=""){
    tag+="_"+cosThetaBin;
    fitTag="FULLCOSTFIT";
    cat = "evtcat_cosT";
  }
  TString dataTag = "_Combined";
  if(cosThetaBin!="") dataTag+="_CosTBin";

  TCanvas *cv = new TCanvas(Form("%s_%s",mcName.Data(),tag.Data()));

  
  RooRealVar* mass = ws->var("mass");
  mass->setBins( (mass->getMax() - mass->getMin())/1.5 ); //enfore 1.5GeV bin width
  RooPlot* frame  = mass->frame();
  double Nb = ws->var(Form("Data_BKGFIT_%s_Nbkg",tag.Data()))->getVal();
  cout << Nb << endl;
  RooDataSet *blind = (RooDataSet*)ws->data("Data"+dataTag)->reduce(TString("((mass<119) || (mass>135.5)) && ")+cat+"=="+cat+"::"+tag);
  blind->plotOn(frame);

  tPair lbl(mcName,tag);
  double nBkg = ws->data("Data"+dataTag)->sumEntries(cat+"=="+cat+"::"+tag);

  ws->pdf( Form("Data_BKGFIT_%s_bkgModel",tag.Data()) )->plotOn(frame,RooFit::Range("all"),RooFit::Normalization(nBkg/blind->sumEntries()),
									       RooFit::LineColor(kRed));

  //TLatex *prelim = new TLatex(250,x->GetXmax()-40.,"CMS Preliminary");
  TLatex *prelim = new TLatex(0.12,0.96,"CMS Preliminary");
  TLatex *lum = new TLatex(0.7,0.96,Form("#sqrt{s}=8 TeV  L = %0.1f fb^{-1}",lumi));
  prelim->SetNDC();
  lum->SetNDC();
  prelim->SetTextSize(0.045);
  prelim->SetTextColor(kBlack);
  lum->SetTextSize(0.045);
  lum->SetTextColor(kBlack);

  TLatex *owner = new TLatex(0.6,0.88,"Caltech-CMS Preliminary");
  owner->SetNDC();
  owner->SetTextSize(0.045);
  owner->SetTextColor(kBlack);

  TLatex *Nbkg = new TLatex(0.7,0.8,Form("N_{bkg}= %0.1f #pm %0.1f",nBackground[lbl].first,nBackground[lbl].second));
  Nbkg->SetNDC();
  Nbkg->SetTextSize(0.045);

  TLatex *sig = new TLatex(0.7,0.72,Form("#sigma_{eff} = %0.1f #pm %0.2f",fitSigEff[lbl].first,fitSigEff[lbl].second));
  sig->SetNDC();
  sig->SetTextSize(0.045);

  TLatex *expBkg = new TLatex(0.7,0.64,Form("B @ 125 = %0.1f",fitBkg1Sigma[lbl].first));
  expBkg->SetNDC();
  expBkg->SetTextSize(0.045);


  frame->addObject(prelim);
  frame->addObject(lum);
  //frame->addObject(owner);
  frame->addObject(Nbkg);
  frame->addObject(sig);
  frame->addObject(expBkg);
  frame->Draw();
  cv->SaveAs( basePath+Form("/mgg-%s-%s-%s_BLIND.png",outputTag.Data(),mcName.Data(),tag.Data()) );
  cv->SaveAs( basePath+Form("/C/mgg-%s-%s-%s_BLIND.C",outputTag.Data(),mcName.Data(),tag.Data()) );
  cv->SaveAs( basePath+Form("/mgg-%s-%s-%s_BLIND.pdf",outputTag.Data(),mcName.Data(),tag.Data()) );
  delete cv;
}