Ejemplo n.º 1
0
//--------------------------------------------------------------------------------------------------
void overlayFrame(TString text, bool align)
{
  // Overlay a linear frame from user coordinates (0 - 1, 0 - 1) and put the frame text

  // Create new transparent pad for the text
  TPad *transPad = new TPad("transPad","Transparent Pad",0,0,1,1);
  transPad->SetFillStyle(4000);
  transPad->Draw();
  transPad->cd();

  // Overlay the text in a well defined frame
  TText *plotText = new TText();
  plotText->SetTextColor(kBlue);
  plotText->SetTextSize(0.04);
  plotText->SetNDC();

  // Draw text at top right
  if (align) {
    plotText->SetTextColor(kBlack);
    plotText->SetTextAlign(33);
    plotText->DrawText(0.92,0.95,text.Data());
  }
  // Draw text at bottom left
  else
    plotText->DrawText(0.01,0.01,text.Data());

  return;
}
Ejemplo n.º 2
0
void table(Float_t x1, Float_t x2, Float_t yrange, TText *t, 
   const char **symbol, Bool_t octal)
{
   Int_t i;
   Int_t n = 0;
   for (i=0;i<1000;i++) {
      if (!strcmp(symbol[i],"END")) break;
      n++;
   }
   Float_t y1  = 2.5;
   Float_t y2  = yrange - 0.5;
   Float_t dx  = (x2-x1)/5;
   Float_t dy  = (y2 - 1 -y1)/(n+1);
   Float_t y   = y2 - 1 - 0.7*dy;
   Float_t xc0 = x1  + 0.5*dx;
   Float_t xc1 = xc0 + dx;
   Float_t xc2 = xc1 + dx;
   Float_t xc3 = xc2 + dx;
   Float_t xc4 = xc3 + dx;
   TLine *line = new TLine();
   line->DrawLine(x1,y1,x1,y2);
   line->DrawLine(x1,y1,x2,y1);
   line->DrawLine(x1,y2,x2,y2);
   line->DrawLine(x2,y1,x2,y2);
   line->DrawLine(x1,y2-1,x2,y2-1);
   line->DrawLine(x1+  dx,y1,x1+  dx,y2);
   line->DrawLine(x1+2*dx,y1,x1+2*dx,y2);
   line->DrawLine(x1+3*dx,y1,x1+3*dx,y2);
   line->DrawLine(x1+4*dx,y1,x1+4*dx,y2);
   TText *tit = new TText(0,0,"a");
   tit->SetTextSize(0.015);
   tit->SetTextFont(72);
   tit->SetTextAlign(22);
   tit->DrawText(xc0,y2-0.6,"Input");
   tit->DrawText(xc1,y2-0.6,"Roman");
   tit->DrawText(xc2,y2-0.6,"Greek");
   tit->DrawText(xc3,y2-0.6,"Special");
   tit->DrawText(xc4,y2-0.6,"Zapf");
   char text[12];
   for (i=0;i<n;i++) {
      if (octal) {
         unsigned char value = *symbol[i];
         sprintf(text,"@\\ %3o",value);
      } else {
         strcpy(text,symbol[i]);
      }
      t->DrawText(xc0,y,text);
      sprintf(text,"%s",symbol[i]);
      t->DrawText(xc1,y,text);
      sprintf(text,"`%s",symbol[i]);
      t->DrawText(xc2,y,text);
      sprintf(text,"'%s",symbol[i]);
      t->DrawText(xc3,y,text);
      sprintf(text,"~%s",symbol[i]);
      t->DrawText(xc4,y,text);
      y -= dy;
   }
}
Ejemplo n.º 3
0
void SetupTowerDisplay(TH2F *hist)
{
  hist->SetStats(kFALSE);
  hist->SetXTitle("ieta");
  hist->SetYTitle("iphi");
  hist->GetXaxis()->CenterTitle();
  hist->GetYaxis()->CenterTitle();
  hist->GetXaxis()->SetNdivisions(65);
  hist->GetXaxis()->SetLabelColor(0);
  hist->GetXaxis()->SetTickLength(.78);
  hist->GetXaxis()->SetTitleOffset(0.95);
  hist->GetYaxis()->SetNdivisions(72);
  hist->GetYaxis()->SetLabelColor(0);
  hist->GetYaxis()->SetTitleOffset(0.85);
  TText *yLabel = new TText();
  TLine *pLine = new TLine();
  pLine->SetLineStyle(1);
  pLine->SetLineColor(1);
  pLine->SetLineWidth(1);
  yLabel->SetTextAlign(22);
  yLabel->SetTextSize(0.015);
  char phi_num[3];
  char eta_num[3];
  TText *xLabel = new TText();
  xLabel->SetTextSize(0.015);
  xLabel->SetTextAlign(22);
  for (Int_t i=1; i<73; ++i)
    {
      sprintf(phi_num,"%d",i);
      if(TMath::Abs(i%2)==1) {yLabel->DrawText(-33,0.5+i,phi_num);}
      else {yLabel->DrawText(-34.5,0.5+i,phi_num);}
      pLine->DrawLine(-32,i,33,i);
    }
  for (Int_t i=-32; i<33;++i)
    {
      sprintf(eta_num,"%d",i);
      if(TMath::Abs(i%2)==0) {xLabel->DrawText(0.5+i,-0.5,eta_num);}
      else {xLabel->DrawText(0.5+i,-2,eta_num);}
      pLine->DrawLine(i,1,i,72);
    }
}
Ejemplo n.º 4
0
void tree() {
   //
   // This macro displays the Tree data structures
   //Author: Rene Brun
   TCanvas* c1 = new TCanvas("c1","Tree Data Structure",200,10,750,940);
   c1->Range(0,-0.1,1,1.15);

   gBenchmark->Start("tree");

   Int_t branchcolor = 26;
   Int_t leafcolor   = 30;
   Int_t basketcolor = 42;
   Int_t offsetcolor = 43;
   TPaveLabel* title = new TPaveLabel(.3,1.05,.8,1.13,c1->GetTitle());
   title->SetFillColor(16);
   title->Draw();
   TPaveText* treePave = new TPaveText(.01,.75,.15,1.00);
   treePave->SetFillColor(18);
   treePave->SetTextAlign(12);
   TText *tnt = treePave->AddText("Tree");
   tnt->SetTextAlign(22);
   tnt->SetTextSize(0.030);
   treePave->AddText("fScanField");
   treePave->AddText("fMaxEventLoop");
   treePave->AddText("fMaxVirtualSize");
   treePave->AddText("fEntries");
   treePave->AddText("fDimension");
   treePave->AddText("fSelectedRows");
   treePave->Draw();
   TPavesText* farm = new TPavesText(.01,1.02,.15,1.1,9,"tr");
   TText *tfarm = farm->AddText("CHAIN");
   tfarm->SetTextSize(0.024);
   farm->AddText("Collection");
   farm->AddText("of Trees");
   farm->Draw();
   TLine* llink = new TLine(.15,.92,.80,.92);
   llink->SetLineWidth(2);
   llink->SetLineColor(1);
   llink->Draw();
   llink->DrawLine(.21,.87,.21,.275);
   llink->DrawLine(.23,.87,.23,.375);
   llink->DrawLine(.25,.87,.25,.775);
   llink->DrawLine(.41,.25,.41,-.025);
   llink->DrawLine(.43,.25,.43,.075);
   llink->DrawLine(.45,.25,.45,.175);
   TPaveLabel* branch0 = new TPaveLabel(.20,.87,.35,.97,"Branch 0");
   branch0->SetTextSize(0.35);
   branch0->SetFillColor(branchcolor);
   branch0->Draw();
   TPaveLabel* branch1 = new TPaveLabel(.40,.87,.55,.97,"Branch 1");
   branch1->SetTextSize(0.35);
   branch1->SetFillColor(branchcolor);
   branch1->Draw();
   TPaveLabel* branch2 = new TPaveLabel(.60,.87,.75,.97,"Branch 2");
   branch2->SetTextSize(0.35);
   branch2->SetFillColor(branchcolor);
   branch2->Draw();
   TPaveLabel* branch3 = new TPaveLabel(.80,.87,.95,.97,"Branch 3");
   branch3->SetTextSize(0.35);
   branch3->SetFillColor(branchcolor);
   branch3->Draw();
   TPaveLabel* leaf0 = new TPaveLabel(.4,.75,.5,.8,"Leaf 0");
   leaf0->SetFillColor(leafcolor);
   leaf0->Draw();
   TPaveLabel* leaf1 = new TPaveLabel(.6,.75,.7,.8,"Leaf 1");
   leaf1->SetFillColor(leafcolor);
   leaf1->Draw();
   TPaveLabel* leaf2 = new TPaveLabel(.8,.75,.9,.8,"Leaf 2");
   leaf2->SetFillColor(leafcolor);
   leaf2->Draw();
   TPaveText* firstevent = new TPaveText(.4,.35,.9,.4);
   firstevent->AddText("First event of each basket");
   firstevent->AddText("Array of fMaxBaskets Integers");
   firstevent->SetFillColor(basketcolor);
   firstevent->Draw();
   TPaveLabel* basket0 = new TPaveLabel(.4,.25,.5,.3,"Basket 0");
   basket0->SetFillColor(basketcolor);
   basket0->Draw();
   TPaveLabel* basket1 = new TPaveLabel(.6,.25,.7,.3,"Basket 1");
   basket1->SetFillColor(basketcolor);
   basket1->Draw();
   TPaveLabel* basket2 = new TPaveLabel(.8,.25,.9,.3,"Basket 2");
   basket2->SetFillColor(basketcolor);
   basket2->Draw();

   TPaveText* offset = new TPaveText(.55,.15,.9,.2);
   offset->AddText("Offset of events in fBuffer");
   offset->AddText("Array of fEventOffsetLen Integers");
   offset->AddText("(if variable length structure)");
   offset->SetFillColor(offsetcolor);
   offset->Draw();
   TPaveText* buffer = new TPaveText(.55,.05,.9,.1);
   buffer->AddText("Basket buffer");
   buffer->AddText("Array of fBasketSize chars");
   buffer->SetFillColor(offsetcolor);
   buffer->Draw();
   TPaveText* zipbuffer = new TPaveText(.55,-.05,.75,.0);
   zipbuffer->AddText("Basket compressed buffer");
   zipbuffer->AddText("(if compression)");
   zipbuffer->SetFillColor(offsetcolor);
   zipbuffer->Draw();
   TArrow* ar1 = new TArrow();
   ar1->SetLineWidth(2);
   ar1->SetLineColor(1);
   ar1->SetFillStyle(1001);
   ar1->SetFillColor(1);
   ar1->DrawArrow(.21,.275,.39,.275,0.015,"|>");
   ar1->DrawArrow(.23,.375,.39,.375,0.015,"|>");
   ar1->DrawArrow(.25,.775,.39,.775,0.015,"|>");
   ar1->DrawArrow(.50,.775,.59,.775,0.015,"|>");
   ar1->DrawArrow(.70,.775,.79,.775,0.015,"|>");
   ar1->DrawArrow(.50,.275,.59,.275,0.015,"|>");
   ar1->DrawArrow(.70,.275,.79,.275,0.015,"|>");
   ar1->DrawArrow(.45,.175,.54,.175,0.015,"|>");
   ar1->DrawArrow(.43,.075,.54,.075,0.015,"|>");
   ar1->DrawArrow(.41,-.025,.54,-.025,0.015,"|>");
   TLine* ldot = new TLine(.95,.92,.99,.92);
   ldot->SetLineStyle(3);
   ldot->Draw();
   ldot->DrawLine(.9,.775,.99,.775);
   ldot->DrawLine(.9,.275,.99,.275);
   ldot->DrawLine(.55,.05,.55,0);
   ldot->DrawLine(.9,.05,.75,0);
   TText* pname = new TText(.46,.21,"fEventOffset");
   pname->SetTextFont(72);
   pname->SetTextSize(0.018);
   pname->Draw();
   pname->DrawText(.44,.11,"fBuffer");
   pname->DrawText(.42,.01,"fZipBuffer");
   pname->DrawText(.26,.81,"fLeaves = TObjArray of TLeaf");
   pname->DrawText(.24,.40,"fBasketEvent");
   pname->DrawText(.22,.31,"fBaskets = TObjArray of TBasket");
   pname->DrawText(.20,1.0,"fBranches = TObjArray of TBranch");
   TPaveText* ntleaf = new TPaveText(0.30,.42,.62,.7);
   ntleaf->SetTextSize(0.014);
   ntleaf->SetFillColor(leafcolor);
   ntleaf->SetTextAlign(12);
   ntleaf->AddText("fLen: number of fixed elements");
   ntleaf->AddText("fLenType: number of bytes of data type");
   ntleaf->AddText("fOffset: relative to Leaf0-fAddress");
   ntleaf->AddText("fNbytesIO: number of bytes used for I/O");
   ntleaf->AddText("fIsPointer: True if pointer");
   ntleaf->AddText("fIsRange: True if leaf has a range");
   ntleaf->AddText("fIsUnsigned: True if unsigned");
   ntleaf->AddText("*fLeafCount: points to Leaf counter");
   ntleaf->AddText(" ");
   ntleaf->AddLine(0,0,0,0);
   ntleaf->AddText("fName = Leaf name");
   ntleaf->AddText("fTitle = Leaf type (see Type codes)");
   ntleaf->Draw();
   TPaveText* type = new TPaveText(.65,.42,.95,.7);
   type->SetTextAlign(12);
   type->SetFillColor(leafcolor);
   type->AddText(" ");
   type->AddText("C : a character string");
   type->AddText("B : an 8 bit signed integer");
   type->AddText("b : an 8 bit unsigned integer");
   type->AddText("S : a 16 bit signed short integer");
   type->AddText("s : a 16 bit unsigned short integer");
   type->AddText("I : a 32 bit signed integer");
   type->AddText("i : a 32 bit unsigned integer");
   type->AddText("F : a 32 bit floating point");
   type->AddText("D : a 64 bit floating point");
   type->AddText("TXXXX : a class name TXXXX");
   type->Draw();
   TPaveLabel* typecode = new TPaveLabel(.7,.68,.9,.72,"fType codes");
   typecode->SetFillColor(leafcolor);
   typecode->Draw();
   ldot->DrawLine(.4,.75,.30,.7);
   ldot->DrawLine(.5,.75,.62,.7);
   TPaveText* ntbasket = new TPaveText(0.02,-0.07,0.35,.25);
   ntbasket->SetFillColor(basketcolor);
   ntbasket->SetTextSize(0.014);
   ntbasket->SetTextAlign(12);
   ntbasket->AddText("fNbytes: Size of compressed Basket");
   ntbasket->AddText("fObjLen: Size of uncompressed Basket");
   ntbasket->AddText("fDatime: Date/Time when written to store");
   ntbasket->AddText("fKeylen: Number of bytes for the key");
   ntbasket->AddText("fCycle : Cycle number");
   ntbasket->AddText("fSeekKey: Pointer to Basket on file");
   ntbasket->AddText("fSeekPdir: Pointer to directory on file");
   ntbasket->AddText("fClassName: 'TBasket'");
   ntbasket->AddText("fName: Branch name");
   ntbasket->AddText("fTitle: TreePave name");
   ntbasket->AddText(" ");
   ntbasket->AddLine(0,0,0,0);
   ntbasket->AddText("fNevBuf: Number of events in Basket");
   ntbasket->AddText("fLast: pointer to last used byte in Basket");
   ntbasket->Draw();
   ldot->DrawLine(.4,.3,0.02,0.25);
   ldot->DrawLine(.5,.25,0.35,-.07);
   ldot->DrawLine(.5,.3,0.35,0.25);
   TPaveText* ntbranch = new TPaveText(0.02,0.40,0.18,0.68);
   ntbranch->SetFillColor(branchcolor);
   ntbranch->SetTextSize(0.015);
   ntbranch->SetTextAlign(12);
   ntbranch->AddText("fBasketSize");
   ntbranch->AddText("fEventOffsetLen");
   ntbranch->AddText("fMaxBaskets");
   ntbranch->AddText("fEntries");
   ntbranch->AddText("fAddress of Leaf0");
   ntbranch->AddText(" ");
   ntbranch->AddLine(0,0,0,0);
   ntbranch->AddText("fName: Branchname");
   ntbranch->AddText("fTitle: leaflist");
   ntbranch->Draw();
   ldot->DrawLine(.2,.97,.02,.68);
   ldot->DrawLine(.35,.97,.18,.68);
   ldot->DrawLine(.35,.87,.18,.40);
   TPavesText* basketstore = new TPavesText(.8,-0.088,0.952,-0.0035,7,"tr");
   basketstore->SetFillColor(28);
   basketstore->AddText("Baskets");
   basketstore->AddText("Stores");
   basketstore->Draw();
   c1->Update();

   gBenchmark->Show("treePave");
}
Ejemplo n.º 5
0
void archi() {
   TCanvas *c1 = new TCanvas("c1","Dictionary Architecture",20,10,750,930);
   c1->SetBorderSize(0);
   c1->Range(0,0,20.5,26);


   TPaveLabel *title = new TPaveLabel(4,24,16,25.5,c1->GetTitle());
   title->SetFillColor(46);
   title->Draw();

   TPavesText *dll = new TPavesText(0.5,19,4.5,23,5,"tr");
   dll->SetFillColor(39);
   dll->SetTextSize(0.023);
   dll->AddText(" ");
   dll->AddText("Dynamically");
   dll->AddText("Linked");
   dll->AddText("Libraries");
   dll->Draw();
   TPaveLabel *dlltitle = new TPaveLabel(1.5,22.6,3.5,23.3,"DLLs");
   dlltitle->SetFillColor(28);
   dlltitle->Draw();

   TPavesText *cpp = new TPavesText(5.5,19,9.5,23,5,"tr");
   cpp->SetTextSize(0.023);
   cpp->AddText(" ");
   cpp->AddText("Commented");
   cpp->AddText("Header");
   cpp->AddText("Files");
   cpp->Draw();
   TPaveLabel *cpptitle = new TPaveLabel(6.5,22.6,8.5,23.3,"C++");
   cpptitle->SetFillColor(28);
   cpptitle->Draw();

   TPavesText *odl = new TPavesText(10.5,19,14.5,23,5,"tr");
   odl->SetTextSize(0.023);
   odl->AddText(" ");
   odl->AddText("Objects");
   odl->AddText("Description");
   odl->AddText("Files");
   odl->Draw();
   TPaveLabel *odltitle = new TPaveLabel(11.5,22.6,13.5,23.3,"ODL");
   odltitle->SetFillColor(28);
   odltitle->Draw();

   TPavesText *idl = new TPavesText(15.5,19,19.5,23,5,"tr");
   idl->SetTextSize(0.023);
   idl->AddText(" ");
   idl->AddText("Interface");
   idl->AddText("Definition");
   idl->AddText("Language");
   idl->Draw();
   TPaveLabel *idltitle = new TPaveLabel(16.5,22.6,18.5,23.3,"IDL");
   idltitle->SetFillColor(28);
   idltitle->Draw();

   TWbox *p1 = new TWbox(7.8,10,13.2,17,11,12,1);
   p1->Draw();
   TText *pro1 = new TText(10.5,15.8,"Process 1");
   pro1->SetTextAlign(21);
   pro1->SetTextSize(0.03);
   pro1->Draw();
   TPaveText *p1dict = new TPaveText(8.8,13.8,12.2,15.6);
   p1dict->SetTextSize(0.023);
   p1dict->AddText("Dictionary");
   p1dict->AddText("in memory");
   p1dict->Draw();
   TPavesText *p1object = new TPavesText(8.6,10.6,12.1,13.0,5,"tr");
   p1object->SetTextSize(0.023);
   p1object->AddText("Objects");
   p1object->AddText("in memory");
   p1object->Draw();
   TWbox *p2 = new TWbox(15.5,10,20,17,11,12,1);
   p2->Draw();
   TText *pro2 = new TText(17.75,15.8,"Process 2");
   pro2->SetTextAlign(21);
   pro2->SetTextSize(0.03);
   pro2->Draw();
   TPaveText *p2dict = new TPaveText(16,13.8,19.5,15.6);
   p2dict->SetTextSize(0.023);
   p2dict->AddText("Dictionary");
   p2dict->AddText("in memory");
   p2dict->Draw();
   TPavesText *p2object = new TPavesText(16.25,10.6,19.25,13.0,5,"tr");
   p2object->SetTextSize(0.023);
   p2object->AddText("Objects");
   p2object->AddText("in memory");
   p2object->Draw();
   TWbox *stub1 = new TWbox(12.9,11.5,13.6,15.5,49,3,1);
   stub1->Draw();
   TText *tstub1 = new TText(13.25,13.5,"Stub1");
   tstub1->SetTextSize(0.025);
   tstub1->SetTextAlign(22);
   tstub1->SetTextAngle(90);
   tstub1->Draw();
   TWbox *stub2 = new TWbox(15.1,11.5,15.8,15.5,49,3,1);
   stub2->Draw();
   TText *tstub2 = new TText(15.45,13.5,"Stub2");
   tstub2->SetTextSize(0.025);
   tstub2->SetTextAlign(22);
   tstub2->SetTextAngle(-90);
   tstub2->Draw();
   TArrow *ar1 = new TArrow();
   ar1->SetLineWidth(6);
   ar1->SetLineColor(1);
   ar1->SetFillStyle(1001);
   ar1->SetFillColor(1);
   ar1->DrawArrow(13.5,14,15,14,0.012,"|>");
   ar1->DrawArrow(15.1,13,13.51,13,0.012,"|>");

   TPaveText *cint = new TPaveText(1.0,15.0,8.0,17.5);
   cint->SetFillColor(39);
   cint->SetBorderSize(1);
   cint->SetTextSize(0.023);
   cint->AddText("C++ Interpreter");
   cint->AddText("and program builder");
   cint->Draw();
   TPaveText *command = new TPaveText(2.5,13.4,8.0,14.5);
   command->SetTextSize(0.023);
   command->SetFillColor(39);
   command->SetBorderSize(1);
   command->AddText("Command Thread");
   command->Draw();
   TPavesText *view = new TPavesText(1.0,9.5,7.7,12.6,3,"tr");
   view->SetFillColor(39);
   view->SetBorderSize(2);
   view->SetTextSize(0.023);
   view->AddText("Viewer Thread(s)");
   view->AddText("Picking");
   view->AddText("Context Menus");
   view->AddText("Inspector/Browser");
   view->Draw();

   TPavesText *web = new TPavesText(0.5,5,6,8.5,5,"tr");
   web->SetTextSize(0.023);
   web->AddText(" ");
   web->AddText("generated");
   web->AddText("automatically");
   web->AddText("from dictionary");
   web->AddText("and source files");
   web->Draw();
   TPaveLabel *webtitle = new TPaveLabel(1.5,8.1,5.0,8.8,"HTML Files");
   webtitle->SetFillColor(28);
   webtitle->Draw();

   TPavesText *printed = new TPavesText(0.5,1.0,6,4,5,"tr");
   printed->SetTextSize(0.023);
   printed->AddText(" ");
   printed->AddText("generated");
   printed->AddText("automatically");
   printed->AddText("from HTML files");
   printed->Draw();
   TPaveLabel *printedtitle = new TPaveLabel(1.5,3.6,5.0,4.3,"Printed Docs");
   printedtitle->SetFillColor(28);
   printedtitle->Draw();

   TBox *box1 = new TBox(0.2,9.2,14.25,17.8);
   box1->SetFillStyle(0);
   box1->SetLineStyle(2);
   box1->Draw();

   TBox *box2 = new TBox(10.2,18.7,20.2,23.6);
   box2->SetFillStyle(0);
   box2->SetLineStyle(3);
   box2->Draw();

   ar1->DrawArrow(2.5,17.5,2.5,18.9,0.012,"|>");
   ar1->DrawArrow(5.5,9.2,5.5,8.7,0.012,"|>");
   ar1->DrawArrow(5.5,5,5.5,4.2,0.012,"|>");
   ar1->DrawArrow(8.5,9.2,8.5,8.2,0.012,"|>");
   ar1->DrawArrow(9.5,8.1,9.5,9.0,0.012,"|>");
   ar1->DrawArrow(6.5,19,6.5,17.6,0.012,"|>");
   ar1->DrawArrow(8.5,19,8.5,17.1,0.012,"|>");
   ar1->DrawArrow(11.5,19,11.5,17.1,0.012,"|>");


   TPaveLabel *ootitle = new TPaveLabel(10.5,7.8,17,8.8,"Objects Data Base");
   ootitle->SetFillColor(28);
   ootitle->Draw();

   TPad *pio = new TPad("pio","pio",0.37,0.02,0.95,0.31,49);
   pio->Range(0,0,12,8);
   pio->Draw();
   pio->cd();
   TPavesText *raw = new TPavesText(0.5,1,2.5,6,7,"tr");
   raw->Draw();
   TPavesText *dst1 = new TPavesText(4,1,5,3,7,"tr");
   dst1->Draw();
   TPavesText *dst2 = new TPavesText(6,1,7,3,7,"tr");
   dst2->Draw();
   TPavesText *dst3 = new TPavesText(4,4,5,6,7,"tr");
   dst3->Draw();
   TPavesText *dst4 = new TPavesText(6,4,7,6,7,"tr");
   dst4->Draw();
   Float_t xlow = 8.5;
   Float_t ylow = 1;
   Float_t dx   = 0.5;
   Float_t dy   = 0.5;
   for (Int_t j=1;j<9;j++) {
      Float_t y0 = ylow + (j-1)*0.7;
      Float_t y1 = y0 + dy;
      for (Int_t i=1;i<5;i++) {
         Float_t x0 = xlow +(i-1)*0.6;
         Float_t x1 = x0 + dx;
         TPavesText *anal = new TPavesText(x0,y0,x1,y1,7,"tr");
         anal->Draw();
      }
   }
   TText *daq = new TText();
   daq->SetTextSize(0.07);
   daq->SetTextAlign(22);
   daq->DrawText(1.5,7.3,"DAQ");
   daq->DrawText(6,7.3,"DST");
   daq->DrawText(10.,7.3,"Physics Analysis");
   daq->DrawText(1.5,0.7,"Events");
   daq->DrawText(1.5,0.3,"Containers");
   daq->DrawText(6,0.7,"Tracks/Hits");
   daq->DrawText(6,0.3,"Containers");
   daq->DrawText(10.,0.7,"Attributes");
   daq->DrawText(10.,0.3,"Containers");

   c1->cd();
}
Ejemplo n.º 6
0
Archivo: event.C Proyecto: Y--/root
void event(){
   TCanvas *c1 = new TCanvas("c1","ROOT Event description",700,500);
   c1->Range(0,0,14,15.5);
   TPaveText *event = new TPaveText(1,13,3,15);
   event->SetFillColor(11);
   event->Draw();
   event->AddText("Event");
   TLine *line = new TLine(1.1,13,1.1,1.5);
   line->SetLineWidth(2);
   line->Draw();
   line->DrawLine(1.3,13,1.3,3.5);
   line->DrawLine(1.5,13,1.5,5.5);
   line->DrawLine(1.7,13,1.7,7.5);
   line->DrawLine(1.9,13,1.9,9.5);
   line->DrawLine(2.1,13,2.1,11.5);
   TArrow *arrow = new TArrow(1.1,1.5,3.9,1.5,0.02,"|>");
   arrow->SetFillStyle(1001);
   arrow->SetFillColor(1);
   arrow->Draw();
   arrow->DrawArrow(1.3,3.5,3.9,3.5,0.02,"|>");
   arrow->DrawArrow(1.5,5.5,3.9,5.5,0.02,"|>");
   arrow->DrawArrow(1.7,7.5,3.9,7.5,0.02,"|>");
   arrow->DrawArrow(1.9,9.5,3.9,9.5,0.02,"|>");
   arrow->DrawArrow(2.1,11.5,3.9,11.5,0.02,"|>");
   TPaveText *p1 = new TPaveText(4,1,11,2);
   p1->SetTextAlign(12);
   p1->SetFillColor(42);
   p1->AddText("1 Mbyte");
   p1->Draw();
   TPaveText *p2 = new TPaveText(4,3,10,4);
   p2->SetTextAlign(12);
   p2->SetFillColor(42);
   p2->AddText("100 Kbytes");
   p2->Draw();
   TPaveText *p3 = new TPaveText(4,5,9,6);
   p3->SetTextAlign(12);
   p3->SetFillColor(42);
   p3->AddText("10 Kbytes");
   p3->Draw();
   TPaveText *p4 = new TPaveText(4,7,8,8);
   p4->SetTextAlign(12);
   p4->SetFillColor(42);
   p4->AddText("1 Kbytes");
   p4->Draw();
   TPaveText *p5 = new TPaveText(4,9,7,10);
   p5->SetTextAlign(12);
   p5->SetFillColor(42);
   p5->AddText("100 bytes");
   p5->Draw();
   TPaveText *p6 = new TPaveText(4,11,6,12);
   p6->SetTextAlign(12);
   p6->SetFillColor(42);
   p6->AddText("10 bytes");
   p6->Draw();
   TText *text = new TText();
   text->SetTextAlign(12);
   text->SetTextSize(0.04);
   text->SetTextFont(72);
   text->DrawText(6.2,11.5,"Header:Event_flag");
   text->DrawText(7.2,9.5,"Trigger_Info");
   text->DrawText(8.2,7.5,"Muon_Detector: TOF");
   text->DrawText(9.2,5.5,"Calorimeters");
   text->DrawText(10.2,3.5,"Forward_Detectors");
   text->DrawText(11.2,1.5,"TPCs");
}
Ejemplo n.º 7
0
void pstable()
{
// Display all possible types of ROOT/Postscript characters

   const char *symbol1[] =
      {"A","B","C","D","E","F","G","H","I","J","K","L","M","N",
       "O","P","Q","R","S","T","U","V","W","X","Y","Z",
       "0","1","2","3","4","5","6","7","8","9",
       ".",",","+","-","*","/","=","(",")","{","}","END"};

   const char *symbol2[] =
      {"a","b","c","d","e","f","g","h","i","j","k","l","m","n",
       "o","p","q","r","s","t","u","v","w","x","y","z",
       ":",";","@","\\","_","|","%",
       "@'","<",">","[","]","\42","@\43","@\136",
       "@\77","@\41","@&","$","@\176"," ","END"};

   const char *symbol3[] =
      {"\241","\242","\243","\244","\245","\246","\247","\250",
       "\251","\252","\253","\254","\255","\256","\257","\260",
       "\261","\262","\263","\264","\265","\266","\267","\270",
       "\271","\272","\273","\274","\275","\276","\277","\300",
       "\301","\302","\303","\304","\305","\306","\307","\310",
       "\311","\312","\313","\314","\315","\316","\317","END"};

   const char *symbol4[] =
      {"\321","\322","\323","\324","\325","\326","\327","\330",
       "\331","\332","\333","\334","\335","\336","\337","\340",
       "\341","\342","\343","\344","\345","\346","\347","\340",
       "\351","\352","\353","\354","\355","\356","\357","\360",
       "\361","\362","\363","\364","\365","\366","\367","\370",
       "\371","\372","\373","\374","\375","\376","\377","END"};

   const char *symbol5[] =
      {"\177","\200","\201","\202","\203","\204","\205","\206",
       "\207","\210","\211","\212","\213","\214","\215","\216",
       "\217","\220","\221","\222","\223","\224","\225","\226",
       "\227","\230","\231","\232","\233","\234","\235","\236",
       "\237","\240","END"};

   Float_t xrange = 18;
   Float_t yrange = 25;
   Int_t w = 650;
   Int_t h = w*yrange/xrange;
   
   TCanvas *c1 = new TCanvas("c1","c1",200,10,w,h);
   c1->Range(0,0,xrange,yrange);

   TText *t = new TText(0,0,"a");
   t->SetTextSize(0.02);
   t->SetTextFont(62);
   t->SetTextAlign(22);

   table(0.5,0.5*xrange-0.5,yrange,t,symbol1,0);
   table(0.5*xrange+0.5,xrange-0.5,yrange,t,symbol2,0);
   TText *tlabel = new TText(0,0,"a");
   tlabel->SetTextFont(72);
   tlabel->SetTextSize(0.018);
   tlabel->SetTextAlign(22);
   tlabel->DrawText(0.5*xrange,1.3,
      "Input characters are standard keyboard characters");
   c1->Modified();
   c1->Update();
   c1->Print("pstable1.ps");

   TCanvas *c2 = new TCanvas("c2","c2",220,20,w,h);
   c2->Range(0,0,xrange,yrange);

   table(0.5,0.5*xrange-0.5,yrange,t,symbol3,1);
   table(0.5*xrange+0.5,xrange-0.5,yrange,t,symbol4,1);
   tlabel->DrawText(0.5*xrange,1.3,
      "Input characters using backslash and octal numbers");
   c2->Modified();
   c2->Update();
   c2->Print("pstable2.ps");

   TCanvas *c3 = new TCanvas("c3","c3",240,20,w,h);
   c3->Range(0,0,xrange,yrange);

   table(0.5,0.5*xrange-0.5,yrange,t,symbol5,1);
   tlabel->DrawText(0.5*xrange,1.3,
      "Input characters using backslash and octal numbers");
   c3->Modified();
   c3->Update();
   c3->Print("pstable3.ps");
}
TCanvas* PlotHistograms(int nbJets, double usedCSVcut){

  TCanvas *cst = new TCanvas("cst","Histograms",10,10,1800,1000);
  TLine *line1 = new TLine(usedCSVcut,-0.1,usedCSVcut,1);
  TLine *line2 = new TLine(-0.1,usedCSVcut,1,usedCSVcut);
  line1->SetLineColor(kRed);
  line2->SetLineColor(kRed);

  TText *t = new TText();
  t->SetTextSize(0.03);

  int binx1, binx2, biny1, biny2;
  double perc_cutCSV[5], perc_cutCSV2[5];
  int TotEntries[5], TotEntries2[5];
  if(nbJets != 0){
    if(nbJets == 1){
      binx1 = h_2dCSV_[0]->GetXaxis()->FindBin( usedCSVcut );
      binx2 = h_2dCSV_[0]->GetXaxis()->FindBin(1);
      biny1 = h_2dCSV_[0]->GetYaxis()->GetFirst();
      biny2 = h_2dCSV_[0]->GetYaxis()->FindBin(1);
    } else {
      binx1 = h_2dCSV_[0]->GetXaxis()->FindBin( usedCSVcut );
      binx2 = h_2dCSV_[0]->GetXaxis()->FindBin(1);
      biny1 = h_2dCSV_[0]->GetYaxis()->FindBin( usedCSVcut );
      biny2 = h_2dCSV_[0]->GetYaxis()->FindBin(1);
    }

    for(int i = 0; i < 5; i++){
      TotEntries[i] = (int)h_2dCSV_[i]->GetEntries();
      TotEntries2[i] = (int)h_2dCSV2_[i]->GetEntries();
      perc_cutCSV[i] = 100.*h_2dCSV_[i]->Integral(binx1, binx2, biny1, biny2)/h_2dCSV_[i]->GetEntries();
      perc_cutCSV2[i] = 100.*h_2dCSV2_[i]->Integral(binx1, binx2, biny1, biny2)/h_2dCSV2_[i]->GetEntries();
    }
  }

  cst->Divide(5,2);
  gStyle->SetOptStat(0);
  for(int i = 0; i < 5; i++){
    cst->cd(i+1);
    h_2dCSV_[i]->Draw("COLZ");
    if(nbJets != 0){
      t->DrawText(.1,.75,Form("Percentage in CSV-cut = %f",perc_cutCSV[i]));
      t->DrawText(.1,.85,Form("Total entries = %d",TotEntries[i]));
      t->DrawText(.1,.8,Form("Entries in CSV-cut = %d",(int)h_2dCSV_[i]->Integral(binx1, binx2, biny1, biny2) ));
      line1->Draw();
      if(nbJets != 1) line2->Draw();
    }
  }
  for(int i = 0; i < 5; i++){
    cst->cd(i+6);
    h_2dCSV2_[i]->Draw("COLZ");
    if(nbJets != 0){
      t->DrawText(.1,.75,Form("Percentage in CSV-cut = %f",perc_cutCSV2[i]));
      t->DrawText(.1,.85,Form("Total entries = %d",TotEntries2[i]));
      t->DrawText(.1,.8,Form("Entries in CSV-cut = %d",(int)h_2dCSV2_[i]->Integral(binx1, binx2, biny1, biny2) ));
      line1->Draw();
      if(nbJets != 1) line2->Draw();
    }
  }

  cst->Update();
  return cst;
}
Ejemplo n.º 9
0
void Drawmethodcomp(){ 
 const int nDil = 8;
 const double centDil[nDil+1] = {1.0,0.7,0.6,0.5,0.4,0.3,0.2,0.1,0};
 double centDilbin[nDil];
for(int i=0;i<nDil;i++)
  centDilbin[i]=0.29+i+N-1-nDil;
 const double NpartDil[nDil] = {8.75,30.51,53.30,86.23,130.06,187.35,261.49,355.45};
 const double NpartDilerr[nDil] = {1.13,3.02,3.95,4.35,4.60,4.44,3.96,2.83};
 const double NcollDil[nDil] = {8.01,38.86,86.85,175.76,326.06,563.21,926.79,1484.49};
 const double NcollDilerr[nDil] = {1.41,6.41,12.48,21.13,34.27,52.66,81.37,120.0};
 TGraphErrors *graphNpartDil = new TGraphErrors(nDil,centDilbin,NpartDil,0,NpartDilerr);
 TGraphErrors *graphNcollDil = new TGraphErrors(nDil,centDilbin,NcollDil,0,NcollDilerr);
 TCanvas *c1 = new TCanvas("c1","c1",1,1,550,460);
 c1->SetLogy();
  c1->SetFillColor(10);
  c1->SetFrameFillColor(0);
  c1->SetFrameBorderSize(0);
  c1->SetFrameBorderMode(0);
  c1->SetLeftMargin(0.15);
  c1->SetBottomMargin(0.15);
  c1->SetTopMargin(0.02);
  c1->SetRightMargin(0.02);
  gStyle->SetOptStat(0);
  c1->SetTicks(-1);

	N=N-1;
 TString str="Ncoll";
 TH1D* hist = new TH1D("","",N,0,N);
 hist->GetXaxis()->SetNdivisions(502);
if(method==0)
 hist->SetXTitle("Centrality");
else
 hist->SetXTitle("HF #Sigma E_{T} |#eta|>3");
 hist->SetYTitle(Form("<%s> and systematic errors",str.Data()));
 hist->SetMinimum(1);
 hist->SetMaximum(3999.99);
 hist->GetXaxis()->CenterTitle(0);
 hist->GetYaxis()->CenterTitle(1);
 hist->GetYaxis()->SetTitleOffset(1.1);
 hist->GetXaxis()->SetTitleOffset(1.1);
 hist->GetXaxis()->SetTitleSize(0.056);
 hist->GetYaxis()->SetTitleSize(0.056);
 hist->GetXaxis()->SetLabelSize(0.05);
 hist->GetYaxis()->SetLabelSize(0.05);
hist->GetXaxis()->SetLabelOffset(99);
hist->Draw();
	
	TFile *f=TFile::Open(outG);
	TGraphErrors* graph = (TGraphErrors*)f->Get(Form("std/%s_graph",str.Data()));
//	TGraphErrors* Gri055_graph = (TGraphErrors*)f->Get(Form("Gri055/%s_graph",str.Data()));
//	TGraphErrors* Gri101_graph = (TGraphErrors*)f->Get(Form("Gri101/%s_graph",str.Data()));
        TVectorD *centbin = (TVectorD*)f->Get(Form("std/G0/centbin"));
        TVectorD *kpoint = (TVectorD*)f->Get(Form("std/G0/kpoint"));

	TFile *f1=TFile::Open(Form("../../OneComp/double_side/%s",outG.Data()));
	TGraphErrors* graph1 = (TGraphErrors*)f1->Get(Form("std/%s_graph",str.Data()));
//	TGraphErrors* Gri055_graph = (TGraphErrors*)f->Get(Form("Gri055/%s_graph",str.Data()));
//	TGraphErrors* Gri101_graph = (TGraphErrors*)f->Get(Form("Gri101/%s_graph",str.Data()));
        TVectorD *centbin1 = (TVectorD*)f1->Get(Form("std/G0/centbin"));
        TVectorD *kpoint1 = (TVectorD*)f1->Get(Form("std/G0/kpoint"));

graph->SetTitle("g1");
graph->SetMarkerStyle(20);
graph->SetMarkerColor(1);
graph->SetLineColor(1);
graph->SetLineWidth(2);
graph->SetMarkerSize(1.2);
graph->Draw("Psameez");

graph1->SetMarkerStyle(24);
graph1->SetMarkerColor(4);
graph1->SetLineColor(4);
graph1->SetLineWidth(2);
graph1->SetMarkerSize(1.2);
graph1->Draw("Psameez");
/*
Gri055_graph->SetTitle("g2");
Gri055_graph->SetMarkerStyle(33);
Gri055_graph->SetMarkerColor(2);
Gri055_graph->SetLineColor(2);
Gri055_graph->SetLineWidth(2);
Gri055_graph->SetMarkerSize(1.2);
Gri055_graph->Draw("Psameez");

Gri101_graph->SetTitle("g3");
Gri101_graph->SetMarkerStyle(34);
Gri101_graph->SetMarkerColor(4);
Gri101_graph->SetLineColor(4);
Gri101_graph->SetLineWidth(2);
Gri101_graph->SetMarkerSize(1.2);
Gri101_graph->Draw("Psameez");
*/
 graphNpartDil->SetMarkerSize(1.2);
 graphNpartDil->SetLineColor(2);
 graphNpartDil->SetLineWidth(2);
 graphNpartDil->SetMarkerStyle(33);
 graphNpartDil->SetMarkerColor(2);
 graphNcollDil->SetMarkerSize(1.2);
 graphNcollDil->SetLineColor(2);
 graphNcollDil->SetLineWidth(2);
 graphNcollDil->SetMarkerStyle(33);
 graphNcollDil->SetMarkerColor(2);
if(str=="Npart") graphNpartDil->Draw("Psame");
if(str=="Ncoll") graphNcollDil->Draw("Psame");
std::vector<TString> label(N);
for(int i=0;i<N;i++)
        if(method==0)label[i] = Form("%.2f-%.2f%%",(*centbin)[i]*100,(*centbin)[i+1]*100);
        else label[i] = Form("%.2f-%.2f",(*kpoint)[i],(*kpoint)[i+1]);

    TLatex *tex1= new TLatex(0.2,0.9,"CMS Preliminary PbPb #sqrt{s_{NN}} = 2.76 TeV");
    tex1->SetNDC();
    tex1->SetTextColor(1);
    tex1->SetTextFont(42);
    tex1->SetTextSize(0.05);
    tex1->Draw();

double y = gPad->GetUymin();
// - 0.2*h->GetYaxis()->GetBinWidth(1);
   TText t;
   t.SetTextAngle(45);
   t.SetTextSize(0.03);
   t.SetTextAlign(33);
   for (int i=0;i<N;i++) {
      double x = hist->GetXaxis()->GetBinCenter(i+1);
      t.DrawText(x,y,label[i]);
   }
TLegend *leg0 = new TLegend(0.18,0.70,0.50,0.85);
    leg0->SetFillColor(10);
    leg0->SetBorderSize(0);
    leg0->SetTextFont(42);
    leg0->SetTextSize(0.047);
    leg0->AddEntry(graph,"From Ancestor fitting","p");
    leg0->AddEntry(graph1,"From One Comp fitting","p");
//    leg0->AddEntry(Gri055_graph,"Gribov #Omega=0.55","p");
//    leg0->AddEntry(Gri101_graph,"Gribov #Omega=1.01","p");
 if(str=="Npart")   leg0->AddEntry(graphNpartDil,"Npart from run I","p");
 if(str=="Ncoll")   leg0->AddEntry(graphNcollDil,"Ncoll from run I","p");
	leg0->Draw();	
c1->SaveAs(Form("%sGri.png",str.Data()));
c1->SaveAs(Form("%sGri.pdf",str.Data()));


 TCanvas *c2 = new TCanvas("c2","c2",1,1,550,460);
  c2->SetFillColor(10);
  c2->SetFrameFillColor(0);
  c2->SetFrameBorderSize(0);
  c2->SetFrameBorderMode(0);
  c2->SetLeftMargin(0.15);
  c2->SetBottomMargin(0.15);
  c2->SetTopMargin(0.02);
  c2->SetRightMargin(0.02);
  c2->SetTicks(-1);
c2->cd();
TGraphErrors* fdvf1 = (TGraphErrors*)graph->Clone("fdvf1");
TGraphErrors* f1dvDil = (TGraphErrors*)graph->Clone("f1dvDil");
TGraphErrors* fdvDil = (TGraphErrors*)graph->Clone("fdvDil");
TGraphErrors* Dilsys = (TGraphErrors*)graph->Clone("Dilsys");
TGraphErrors* Dilsys2 = (TGraphErrors*)graph->Clone("Dilsys2");
for(int ip = 0;ip<fdvf1->GetN();ip++){
    double x = graph->GetX()[ip];
    double ey = graph->GetEY()[ip];
    double y = graph->GetY()[ip];
    double ey1 = graph1->GetEY()[ip];
    double y1 = graph1->GetY()[ip];
    double eyNcoll = graphNcollDil->GetEY()[ip];
    double yNcoll = graphNcollDil->GetY()[ip];
    double eyNpart = graphNpartDil->GetEY()[ip];
    double yNpart = graphNpartDil->GetY()[ip];
    if(y1!=0 && y!=0){
        fdvf1->SetPoint(ip,x,y/y1);
        fdvf1->SetPointError(ip,0,y/y1*sqrt((ey/y)**2+(ey1/y1)**2));
        if(str=="Ncoll"){
        fdvDil->SetPoint(ip,x,y/yNcoll);
        double yerr = y/yNcoll*sqrt((ey/y)**2+(eyNcoll/yNcoll)**2);
        fdvDil->SetPointError(ip,0,0);
        f1dvDil->SetPoint(ip,x,y1/yNcoll);
        double y1err = y1/yNcoll*sqrt((ey1/y1)**2+(eyNcoll/yNcoll)**2);
        f1dvDil->SetPointError(ip,0,0);
        Dilsys->SetPoint(ip,x,1.);
        Dilsys->SetPointError(ip,0,TMath::Max(fabs(y1/yNcoll-1),fabs(y/yNcoll-1)));
        Dilsys2->SetPoint(ip,x,1.);
        Dilsys2->SetPointError(ip,0,TMath::Max(yerr,y1err));
        }
        else if(str=="Npart"){
        fdvDil->SetPoint(ip,x,y/yNpart);
        double yerr = y/yNpart*sqrt((ey/y)**2+(eyNcoll/yNpart)**2);
        fdvDil->SetPointError(ip,0,0);
        f1dvDil->SetPoint(ip,x,y1/yNpart);
        double y1err = y1/yNpart*sqrt((ey1/y1)**2+(eyNcoll/yNcoll)**2);
        f1dvDil->SetPointError(ip,0,0);
        Dilsys->SetPoint(ip,x,1.);
        Dilsys->SetPointError(ip,0,TMath::Max(fabs(y1/yNpart-1),fabs(y/yNpart-1)));
        Dilsys2->SetPoint(ip,x,1.);
        Dilsys2->SetPointError(ip,0,TMath::Max(yerr,y1err));
        }
}
}
hist->SetMinimum(0.5);
hist->SetMaximum(1.5);
hist->SetYTitle(Form("<%s> ratio",str.Data()));
hist->Draw();
fdvf1->SetMarkerStyle(20);
fdvf1->SetMarkerColor(1);
fdvf1->SetLineColor(1);
fdvf1->SetLineWidth(2);
fdvf1->SetMarkerSize(1.4);
//fdvf1->Draw("Psameez");
f1dvDil->SetMarkerStyle(24);
f1dvDil->SetMarkerColor(2);
f1dvDil->SetLineColor(2);
f1dvDil->SetLineWidth(2);
f1dvDil->SetMarkerSize(1.4);
fdvDil->SetMarkerStyle(20);
fdvDil->SetMarkerColor(4);
fdvDil->SetLineColor(4);
fdvDil->SetLineWidth(2);
fdvDil->SetMarkerSize(1.4);
Dilsys->SetFillColor(kYellow+2);
Dilsys2->SetFillColor(kYellow+1);
//Dilsys2->Draw("e3same");
Dilsys->Draw("e3same");
fdvDil->Draw("Psameez");
f1dvDil->Draw("Psameez");
tex1->Draw();
TLine *l = new TLine(0,1,N,1);
l->SetLineStyle(2);
l->SetLineWidth(3);
l->Draw("same");
TLegend *leg1 = new TLegend(0.38,0.72,0.75,0.86);
    leg1->SetFillColor(10);
    leg1->SetBorderSize(0);
    leg1->SetTextFont(42);
    leg1->SetTextSize(0.04);
    //leg1->AddEntry(fdvf1,"Ancestor fitting/One Comp fitting","p");
    leg1->AddEntry(f1dvDil,"One Component fitting/Run I fitting","p");
    leg1->AddEntry(fdvDil,"Two Component fitting/Run I fitting","p");
    leg1->AddEntry(Dilsys,"RunI fitting systematics","f");
  //  leg1->AddEntry(Dilsys2,"RunI fitting ratio systematics","f");
    double y = gPad->GetUymin()+0.5;
   for (int i=0;i<N;i++) {
      double x = hist->GetXaxis()->GetBinCenter(i+1);
      t.DrawText(x,y,label[i]);
   }
   leg1->Draw();
c2->SaveAs(Form("%sGriratio.png",str.Data()));
c2->SaveAs(Form("%sGriratio.pdf",str.Data()));
}
Ejemplo n.º 10
0
void categories_sig() {

  gStyle->SetOptTitle(0);
  gStyle->SetOptStat(0);

  gStyle->SetCanvasColor(0);
  gStyle->SetFrameBorderMode(0);
  
  gStyle->SetPalette(1);

  TText *text = new TText();
  text->SetNDC();
  text->SetTextSize(0.05);

  TFile *file = TFile::Open("histograms_CMS-HGG_categories_sig.root");
  file->cd();

  TCanvas *c_bdtout = new TCanvas("c_bdtout","BDT output");

  bdtout_all_tot = (TH1*)bdtout_cat0_tot->Clone();
  bdtout_all_tot->Add(bdtout_cat1_tot);
  bdtout_all_tot->Add(bdtout_cat2_tot);
  bdtout_all_tot->Add(bdtout_cat3_tot);

  cout << bdtout_all_tot->Integral() << endl;
  cout << bdtout_all_tot->Integral(49,100)+bdtout_all_tot->GetBinContent(48)/2. << endl;
  cout << bdtout_all_tot->GetBinLowEdge(49) << endl;
  cout << bdtout_all_tot->GetBinLowEdge(48) << endl;
  cout << (bdtout_all_tot->Integral(49,100)+bdtout_all_tot->GetBinContent(48)/2.)/bdtout_all_tot->Integral() << endl;

  bdtout_passCiC_all_tot = (TH1*)bdtout_passCiC_cat0_tot->Clone();
  bdtout_passCiC_all_tot->Add(bdtout_passCiC_cat1_tot);
  bdtout_passCiC_all_tot->Add(bdtout_passCiC_cat2_tot);
  bdtout_passCiC_all_tot->Add(bdtout_passCiC_cat3_tot);

  bdtout_failpresel_cat0_tot->Rebin(2);
  bdtout_failpresel_cat1_tot->Rebin(2);
  bdtout_failpresel_cat2_tot->Rebin(2);
  bdtout_failpresel_cat3_tot->Rebin(2);

  bdtout_failpresel_all_tot = (TH1*)bdtout_failpresel_cat0_tot->Clone();
  bdtout_failpresel_all_tot->Add(bdtout_failpresel_cat1_tot);
  bdtout_failpresel_all_tot->Add(bdtout_failpresel_cat2_tot);
  bdtout_failpresel_all_tot->Add(bdtout_failpresel_cat3_tot);

  float nFail_m100180_bdtout005 = bdtout_all_tot->Integral(1,52) + bdtout_all_tot->GetBinContent(53)/2.;
  float nFail_m100180 = bdtout_all_tot->Integral(1,100);
  float frac_bdtout005 = nFail_m100180_bdtout005/nFail_m100180;
  float frac_bdtout005_err = frac_err(nFail_m100180_bdtout005,nFail_m100180);
  cout << bdtout_all_tot->Integral(1,52) << " " <<  bdtout_all_tot->GetBinContent(53)/2. << " " << bdtout_all_tot->Integral(1,100) << " " << bdtout_all_tot->GetBinLowEdge(53) << " " << frac_bdtout005 << " ± " << frac_bdtout005_err << endl;

  bdtout_all_tot->SetLineColor(1);
  bdtout_cat0_tot->SetLineColor(2);
  bdtout_cat1_tot->SetLineColor(3);
  bdtout_cat2_tot->SetLineColor(4);
  bdtout_cat3_tot->SetLineColor(6);

  bdtout_all_tot->SetLineWidth(2);
  bdtout_cat0_tot->SetLineWidth(2);
  bdtout_cat1_tot->SetLineWidth(2);
  bdtout_cat2_tot->SetLineWidth(2);
  bdtout_cat3_tot->SetLineWidth(2);

  bdtout_cat0_tot->SetMarkerColor(2);
  bdtout_cat1_tot->SetMarkerColor(3);
  bdtout_cat2_tot->SetMarkerColor(4);
  bdtout_cat3_tot->SetMarkerColor(6);

  bdtout_all_tot->SetMarkerStyle(20);
  bdtout_cat0_tot->SetMarkerStyle(20);
  bdtout_cat1_tot->SetMarkerStyle(20);
  bdtout_cat2_tot->SetMarkerStyle(20);
  bdtout_cat3_tot->SetMarkerStyle(20);

  bdtout_all_tot->SetMarkerSize(0.7);
  bdtout_cat0_tot->SetMarkerSize(0.7);
  bdtout_cat1_tot->SetMarkerSize(0.7);
  bdtout_cat2_tot->SetMarkerSize(0.7);
  bdtout_cat3_tot->SetMarkerSize(0.7);

  bdtout_passCiC_all_tot->SetLineColor(1);
  bdtout_passCiC_cat0_tot->SetLineColor(2);
  bdtout_passCiC_cat1_tot->SetLineColor(3);
  bdtout_passCiC_cat2_tot->SetLineColor(4);
  bdtout_passCiC_cat3_tot->SetLineColor(6);

  bdtout_passCiC_lowPt_cat0_tot->SetLineColor(2);
  bdtout_passCiC_lowPt_cat1_tot->SetLineColor(3);
  bdtout_passCiC_lowPt_cat2_tot->SetLineColor(4);
  bdtout_passCiC_lowPt_cat3_tot->SetLineColor(6);

  bdtout_passCiC_highPt_cat0_tot->SetLineColor(2);
  bdtout_passCiC_highPt_cat1_tot->SetLineColor(3);
  bdtout_passCiC_highPt_cat2_tot->SetLineColor(4);
  bdtout_passCiC_highPt_cat3_tot->SetLineColor(6);

  bdtout_failpresel_all_tot->SetLineColor(1);
  bdtout_failpresel_cat0_tot->SetLineColor(2);
  bdtout_failpresel_cat1_tot->SetLineColor(3);
  bdtout_failpresel_cat2_tot->SetLineColor(4);
  bdtout_failpresel_cat3_tot->SetLineColor(6);


  bdtout_all_tot->GetXaxis()->SetTitle("di-photon MVA output");

  float boundaries[4] = {-0.05,0.49,0.79,.91};
  float max = bdtout_all_tot->GetMaximum();

  TBox* box = new TBox(-1.,0.,boundaries[0],max*1.05);
  box->SetFillColor(38);
  box->SetFillStyle(3002);

  bdtout_all_tot->Draw("hist");
  box->Draw("hist,same");
  bdtout_all_tot->Draw("hist,same");
  bdtout_cat0_tot->Draw("hist,same");
  bdtout_cat1_tot->Draw("hist,same");
  bdtout_cat2_tot->Draw("hist,same");
  bdtout_cat3_tot->Draw("hist,same");

  TLegend *leg;
  leg = new TLegend(.14,.6,.46,.87);
  leg->SetBorderSize(0);
  leg->SetFillColor(10);
  leg->SetTextSize(.035);
  leg->AddEntry(bdtout_all_tot,"All");
  leg->AddEntry(bdtout_cat0_tot,"both EB, both R9>0.94");
  leg->AddEntry(bdtout_cat1_tot,"both EB, !both R9>0.94");
  leg->AddEntry(bdtout_cat2_tot,"!both EB, both R9>0.94");
  leg->AddEntry(bdtout_cat3_tot,"!both EB, !both R9>0.94");
  leg->Draw("hist");

  TLine* line[4];
  for (int i=0; i<4; i++) {
    line[i] = new TLine(boundaries[i],0.,boundaries[i],max*1.05);
    line[i]->SetLineColor(4);
    line[i]->SetLineWidth(2);
    line[i]->SetLineStyle(9);
    line[i]->Draw("hist");
  }

  gPad->RedrawAxis();

  c_bdtout->SaveAs("categories_sig.png");


  TCanvas *c_bdtout_passCiC = new TCanvas("c_bdtout_passCiC","BDT output, pass CiC");

  bdtout_passCiC_cat0_tot_clone = (TH1*)bdtout_passCiC_cat0_tot->Clone();
  bdtout_passCiC_cat1_tot_clone = (TH1*)bdtout_passCiC_cat1_tot->Clone();
  bdtout_passCiC_cat2_tot_clone = (TH1*)bdtout_passCiC_cat2_tot->Clone();
  bdtout_passCiC_cat3_tot_clone = (TH1*)bdtout_passCiC_cat3_tot->Clone();

  bdtout_passCiC_all_tot->SetLineWidth(2);
  bdtout_passCiC_cat0_tot_clone->SetLineWidth(2);
  bdtout_passCiC_cat1_tot_clone->SetLineWidth(2);
  bdtout_passCiC_cat2_tot_clone->SetLineWidth(2);
  bdtout_passCiC_cat3_tot_clone->SetLineWidth(2);

  bdtout_passCiC_all_tot->GetXaxis()->SetTitle("di-photon MVA output");

  max = bdtout_passCiC_all_tot->GetMaximum();
  TBox* box_passCiC = new TBox(-1.,0.,boundaries[0],max*1.05);
  box_passCiC->SetFillColor(38);
  box_passCiC->SetFillStyle(3002);

  bdtout_passCiC_all_tot->Draw("hist");
  box_passCiC->Draw("hist,same");
  bdtout_passCiC_all_tot->Draw("hist,same");
  bdtout_passCiC_cat0_tot_clone->Draw("hist,same");
  bdtout_passCiC_cat1_tot_clone->Draw("hist,same");
  bdtout_passCiC_cat2_tot_clone->Draw("hist,same");
  bdtout_passCiC_cat3_tot_clone->Draw("hist,same");

  leg->Draw("hist");

  TLine* line_passCiC[4];
  for (int i=0; i<4; i++) {
    line_passCiC[i] = new TLine(boundaries[i],0.,boundaries[i],max*1.05);
    line_passCiC[i]->SetLineColor(4);
    line_passCiC[i]->SetLineWidth(2);
    line_passCiC[i]->SetLineStyle(9);
    line_passCiC[i]->Draw("hist");
  }

  gPad->RedrawAxis();

  c_bdtout_passCiC->SaveAs("categories_passCiC_sig.png");

  /*
  TCanvas *c_bdtout_failpresel = new TCanvas("c_bdtout_failpresel","BDT output, pass CiC, fail presel");

  bdtout_failpresel_cat0_tot_clone = (TH1*)bdtout_failpresel_cat0_tot->Clone();
  bdtout_failpresel_cat1_tot_clone = (TH1*)bdtout_failpresel_cat1_tot->Clone();
  bdtout_failpresel_cat2_tot_clone = (TH1*)bdtout_failpresel_cat2_tot->Clone();
  bdtout_failpresel_cat3_tot_clone = (TH1*)bdtout_failpresel_cat3_tot->Clone();

  bdtout_failpresel_all_tot->SetLineWidth(2);
  bdtout_failpresel_cat0_tot_clone->SetLineWidth(2);
  bdtout_failpresel_cat1_tot_clone->SetLineWidth(2);
  bdtout_failpresel_cat2_tot_clone->SetLineWidth(2);
  bdtout_failpresel_cat3_tot_clone->SetLineWidth(2);

  bdtout_failpresel_all_tot->GetXaxis()->SetTitle("di-photon MVA output");

  max = bdtout_failpresel_all_tot->GetMaximum();
  TBox* box_failpresel = new TBox(-1.,0.,boundaries[0],max*1.05);
  box_failpresel->SetFillColor(38);
  box_failpresel->SetFillStyle(3002);

  bdtout_failpresel_all_tot->Draw("hist");
  box_failpresel->Draw("hist,same");
  bdtout_failpresel_all_tot->Draw("hist,same");
  bdtout_failpresel_cat0_tot_clone->Draw("hist,same");
  bdtout_failpresel_cat1_tot_clone->Draw("hist,same");
  bdtout_failpresel_cat2_tot_clone->Draw("hist,same");
  bdtout_failpresel_cat3_tot_clone->Draw("hist,same");

  leg->Draw("hist");

  TLine* line_failpresel[4];
  for (int i=0; i<4; i++) {
    line_failpresel[i] = new TLine(boundaries[i],0.,boundaries[i],max*1.05);
    line_failpresel[i]->SetLineColor(4);
    line_failpresel[i]->SetLineWidth(2);
    line_failpresel[i]->SetLineStyle(9);
    line_failpresel[i]->Draw("hist");
  }

  gPad->RedrawAxis();

  c_bdtout_failpresel->SaveAs("categories_failpresel_sig.png");
  */

  TCanvas *c_bdtout_compareCiC = new TCanvas("c_bdtout_compareCiC","BDT output: pass CiC supertight",1000,650);
  c_bdtout_compareCiC->Divide(2,2);

  bdtout_passCiC_cat0_tot->SetFillColor(2);
  bdtout_passCiC_cat1_tot->SetFillColor(3);
  bdtout_passCiC_cat2_tot->SetFillColor(4);
  bdtout_passCiC_cat3_tot->SetFillColor(6);

  bdtout_passCiC_cat0_tot->SetFillStyle(3002);
  bdtout_passCiC_cat1_tot->SetFillStyle(3002);
  bdtout_passCiC_cat2_tot->SetFillStyle(3002);
  bdtout_passCiC_cat3_tot->SetFillStyle(3002);

  bdtout_cat0_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_cat1_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_cat2_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_cat3_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_cat0_tot->GetXaxis()->SetTitleSize(0.05);
  bdtout_cat1_tot->GetXaxis()->SetTitleSize(0.05);
  bdtout_cat2_tot->GetXaxis()->SetTitleSize(0.05);
  bdtout_cat3_tot->GetXaxis()->SetTitleSize(0.05);

  c_bdtout_compareCiC->cd(1);

  box_passCiC_cat0 = (TBox*)box->Clone();
  box_passCiC_cat0->SetY2(bdtout_cat0_tot->GetMaximum()*1.05);

  bdtout_cat0_tot->Draw("hist");
  box_passCiC_cat0->Draw("hist,same");
  bdtout_cat0_tot->Draw("hist,same");
  bdtout_passCiC_cat0_tot->Draw("hist,same");

  TLine* line_passCiC_cat0[4];
  for (int i=0; i<4; i++) {
    line_passCiC_cat0[i] = (TLine*)line[i]->Clone();
    line_passCiC_cat0[i]->SetY2(bdtout_cat0_tot->GetMaximum()*1.05);
    line_passCiC_cat0[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"both EB, both R9>0.94");
  gPad->RedrawAxis();

  c_bdtout_compareCiC->cd(2);

  box_passCiC_cat1 = (TBox*)box->Clone();
  box_passCiC_cat1->SetY2(bdtout_cat1_tot->GetMaximum()*1.05);

  bdtout_cat1_tot->Draw("hist");
  box_passCiC_cat1->Draw("hist,same");
  bdtout_cat1_tot->Draw("hist,same");
  bdtout_passCiC_cat1_tot->Draw("hist,same");

  TLine* line_passCiC_cat1[4];
  for (int i=0; i<4; i++) {
    line_passCiC_cat1[i] = (TLine*)line[i]->Clone();
    line_passCiC_cat1[i]->SetY2(bdtout_cat1_tot->GetMaximum()*1.05);
    line_passCiC_cat1[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"both EB, !both R9>0.94");
  gPad->RedrawAxis();

  c_bdtout_compareCiC->cd(3);

  box_passCiC_cat2 = (TBox*)box->Clone();
  box_passCiC_cat2->SetY2(bdtout_cat2_tot->GetMaximum()*1.05);

  bdtout_cat2_tot->Draw("hist");
  box_passCiC_cat2->Draw("hist,same");
  bdtout_cat2_tot->Draw("hist,same");
  bdtout_passCiC_cat2_tot->Draw("hist,same");

  TLine* line_passCiC_cat2[4];
  for (int i=0; i<4; i++) {
    line_passCiC_cat2[i] = (TLine*)line[i]->Clone();
    line_passCiC_cat2[i]->SetY2(bdtout_cat2_tot->GetMaximum()*1.05);
    line_passCiC_cat2[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"!both EB, both R9>0.94");
  gPad->RedrawAxis();

  c_bdtout_compareCiC->cd(4);

  box_passCiC_cat3 = (TBox*)box->Clone();
  box_passCiC_cat3->SetY2(bdtout_cat3_tot->GetMaximum()*1.05);

  bdtout_cat3_tot->Draw("hist");
  box_passCiC_cat3->Draw("hist,same");
  bdtout_cat3_tot->Draw("hist,same");
  bdtout_passCiC_cat3_tot->Draw("hist,same");

  TLine* line_passCiC_cat3[4];
  for (int i=0; i<4; i++) {
    line_passCiC_cat3[i] = (TLine*)line[i]->Clone();
    line_passCiC_cat3[i]->SetY2(bdtout_cat3_tot->GetMaximum()*1.05);
    line_passCiC_cat3[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"!both EB, !both R9>0.94");
  gPad->RedrawAxis();

  c_bdtout_compareCiC->SaveAs("categories_compareCiC_sig.png");



  TCanvas *c_bdtout_lowPt = new TCanvas("c_bdtout_lowPt","BDT output: di-photon pT<40 GeV");

  bdtout_lowPt_all_tot = (TH1*)bdtout_lowPt_cat0_tot->Clone();
  bdtout_lowPt_all_tot->Add(bdtout_lowPt_cat1_tot);
  bdtout_lowPt_all_tot->Add(bdtout_lowPt_cat2_tot);
  bdtout_lowPt_all_tot->Add(bdtout_lowPt_cat3_tot);

  bdtout_lowPt_all_tot->SetLineColor(1);
  bdtout_lowPt_cat0_tot->SetLineColor(2);
  bdtout_lowPt_cat1_tot->SetLineColor(3);
  bdtout_lowPt_cat2_tot->SetLineColor(4);
  bdtout_lowPt_cat3_tot->SetLineColor(6);

  bdtout_lowPt_all_tot->SetLineWidth(2);
  bdtout_lowPt_cat0_tot->SetLineWidth(2);
  bdtout_lowPt_cat1_tot->SetLineWidth(2);
  bdtout_lowPt_cat2_tot->SetLineWidth(2);
  bdtout_lowPt_cat3_tot->SetLineWidth(2);

  bdtout_lowPt_all_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_lowPt_all_tot->GetYaxis()->SetTitle("Events/0.02");
  bdtout_lowPt_all_tot->GetXaxis()->SetTitleSize(0.05);
  bdtout_lowPt_all_tot->GetXaxis()->SetLabelSize(0.05);
  bdtout_lowPt_all_tot->GetYaxis()->SetTitleSize(0.05);
  bdtout_lowPt_all_tot->GetYaxis()->SetLabelSize(0.05);

  max = bdtout_lowPt_all_tot->GetMaximum();
  TBox* box_lowPt = new TBox(-1.,0.,boundaries[0],max*1.05);
  box_lowPt->SetFillColor(38);
  box_lowPt->SetFillStyle(3002);

  bdtout_lowPt_all_tot->Draw("hist");
  box_lowPt->Draw("hist,same");
  bdtout_lowPt_all_tot->Draw("hist,same");
  bdtout_lowPt_cat0_tot->Draw("hist,same");
  bdtout_lowPt_cat1_tot->Draw("hist,same");
  bdtout_lowPt_cat2_tot->Draw("hist,same");
  bdtout_lowPt_cat3_tot->Draw("hist,same");

  TLegend *leg_lowPt = (TLegend*)leg->Clone();
  leg_lowPt->Clear();
  leg_lowPt->AddEntry(bdtout_all_tot,"All (p_{T}(#gamma#gamma) < 40 GeV)");
  leg_lowPt->AddEntry(bdtout_cat0_tot,"both EB, both R9>0.94");
  leg_lowPt->AddEntry(bdtout_cat1_tot,"both EB, !both R9>0.94");
  leg_lowPt->AddEntry(bdtout_cat2_tot,"!both EB, both R9>0.94");
  leg_lowPt->AddEntry(bdtout_cat3_tot,"!both EB, !both R9>0.94");
  leg_lowPt->Draw("hist");

  TLine* line_lowPt[4];
  for (int i=0; i<4; i++) {
    line_lowPt[i] = new TLine(boundaries[i],0.,boundaries[i],max*1.05);
    line_lowPt[i]->SetLineColor(4);
    line_lowPt[i]->SetLineWidth(2);
    line_lowPt[i]->SetLineStyle(9);
    line_lowPt[i]->Draw("hist");
  }

  gPad->RedrawAxis();

  c_bdtout_lowPt->SaveAs("categories_lowPt_sig.png");


  TCanvas *c_bdtout_compareCiC_lowPt = new TCanvas("c_bdtout_compareCiC_lowPt","BDT output: di-photon pT<40 GeV, pass CiC supertight",1000,650);
  c_bdtout_compareCiC_lowPt->Divide(2,2);

  bdtout_passCiC_lowPt_cat0_tot->SetFillColor(2);
  bdtout_passCiC_lowPt_cat1_tot->SetFillColor(3);
  bdtout_passCiC_lowPt_cat2_tot->SetFillColor(4);
  bdtout_passCiC_lowPt_cat3_tot->SetFillColor(6);

  bdtout_passCiC_lowPt_cat0_tot->SetFillStyle(3002);
  bdtout_passCiC_lowPt_cat1_tot->SetFillStyle(3002);
  bdtout_passCiC_lowPt_cat2_tot->SetFillStyle(3002);
  bdtout_passCiC_lowPt_cat3_tot->SetFillStyle(3002);

  bdtout_lowPt_cat0_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_lowPt_cat1_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_lowPt_cat2_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_lowPt_cat3_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_lowPt_cat0_tot->GetXaxis()->SetTitleSize(0.05);
  bdtout_lowPt_cat1_tot->GetXaxis()->SetTitleSize(0.05);
  bdtout_lowPt_cat2_tot->GetXaxis()->SetTitleSize(0.05);
  bdtout_lowPt_cat3_tot->GetXaxis()->SetTitleSize(0.05);

  c_bdtout_compareCiC_lowPt->cd(1);

  box_passCiC_lowPt_cat0 = (TBox*)box->Clone();
  box_passCiC_lowPt_cat0->SetY2(bdtout_lowPt_cat0_tot->GetMaximum()*1.05);

  bdtout_lowPt_cat0_tot->Draw("hist");
  box_passCiC_lowPt_cat0->Draw("hist,same");
  bdtout_lowPt_cat0_tot->Draw("hist,same");
  bdtout_passCiC_lowPt_cat0_tot->Draw("hist,same");

  TLine* line_passCiC_lowPt_cat0[4];
  for (int i=0; i<4; i++) {
    line_passCiC_lowPt_cat0[i] = (TLine*)line[i]->Clone();
    line_passCiC_lowPt_cat0[i]->SetY2(bdtout_lowPt_cat0_tot->GetMaximum()*1.05);
    line_passCiC_lowPt_cat0[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"both EB, both R9>0.94");
  gPad->RedrawAxis();

  c_bdtout_compareCiC_lowPt->cd(2);

  box_passCiC_lowPt_cat1 = (TBox*)box->Clone();
  box_passCiC_lowPt_cat1->SetY2(bdtout_lowPt_cat1_tot->GetMaximum()*1.05);

  bdtout_lowPt_cat1_tot->Draw("hist");
  box_passCiC_lowPt_cat1->Draw("hist,same");
  bdtout_lowPt_cat1_tot->Draw("hist,same");
  bdtout_passCiC_lowPt_cat1_tot->Draw("hist,same");

  TLine* line_passCiC_lowPt_cat1[4];
  for (int i=0; i<4; i++) {
    line_passCiC_lowPt_cat1[i] = (TLine*)line[i]->Clone();
    line_passCiC_lowPt_cat1[i]->SetY2(bdtout_lowPt_cat1_tot->GetMaximum()*1.05);
    line_passCiC_lowPt_cat1[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"both EB, !both R9>0.94");
  gPad->RedrawAxis();

  c_bdtout_compareCiC_lowPt->cd(3);

  box_passCiC_lowPt_cat2 = (TBox*)box->Clone();
  box_passCiC_lowPt_cat2->SetY2(bdtout_lowPt_cat2_tot->GetMaximum()*1.05);

  bdtout_lowPt_cat2_tot->Draw("hist");
  box_passCiC_lowPt_cat2->Draw("hist,same");
  bdtout_lowPt_cat2_tot->Draw("hist,same");
  bdtout_passCiC_lowPt_cat2_tot->Draw("hist,same");

  TLine* line_passCiC_lowPt_cat2[4];
  for (int i=0; i<4; i++) {
    line_passCiC_lowPt_cat2[i] = (TLine*)line[i]->Clone();
    line_passCiC_lowPt_cat2[i]->SetY2(bdtout_lowPt_cat2_tot->GetMaximum()*1.05);
    line_passCiC_lowPt_cat2[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"!both EB, both R9>0.94");
  gPad->RedrawAxis();

  c_bdtout_compareCiC_lowPt->cd(4);

  box_passCiC_lowPt_cat3 = (TBox*)box->Clone();
  box_passCiC_lowPt_cat3->SetY2(bdtout_lowPt_cat3_tot->GetMaximum()*1.05);

  bdtout_lowPt_cat3_tot->Draw("hist");
  box_passCiC_lowPt_cat3->Draw("hist,same");
  bdtout_lowPt_cat3_tot->Draw("hist,same");
  bdtout_passCiC_lowPt_cat3_tot->Draw("hist,same");

  TLine* line_passCiC_lowPt_cat3[4];
  for (int i=0; i<4; i++) {
    line_passCiC_lowPt_cat3[i] = (TLine*)line[i]->Clone();
    line_passCiC_lowPt_cat3[i]->SetY2(bdtout_lowPt_cat3_tot->GetMaximum()*1.05);
    line_passCiC_lowPt_cat3[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"!both EB, !both R9>0.94");
  gPad->RedrawAxis();

  c_bdtout_compareCiC_lowPt->SaveAs("categories_compareCiC_lowPt_sig.png");


  TCanvas *c_bdtout_highPt = new TCanvas("c_bdtout_highPt","BDT output: di-photon pT>40 GeV");

  bdtout_highPt_all_tot = (TH1*)bdtout_highPt_cat0_tot->Clone();
  bdtout_highPt_all_tot->Add(bdtout_highPt_cat1_tot);
  bdtout_highPt_all_tot->Add(bdtout_highPt_cat2_tot);
  bdtout_highPt_all_tot->Add(bdtout_highPt_cat3_tot);

  bdtout_highPt_all_tot->SetLineColor(1);
  bdtout_highPt_cat0_tot->SetLineColor(2);
  bdtout_highPt_cat1_tot->SetLineColor(3);
  bdtout_highPt_cat2_tot->SetLineColor(4);
  bdtout_highPt_cat3_tot->SetLineColor(6);

  bdtout_highPt_all_tot->SetLineWidth(2);
  bdtout_highPt_cat0_tot->SetLineWidth(2);
  bdtout_highPt_cat1_tot->SetLineWidth(2);
  bdtout_highPt_cat2_tot->SetLineWidth(2);
  bdtout_highPt_cat3_tot->SetLineWidth(2);

  bdtout_highPt_all_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_highPt_all_tot->GetYaxis()->SetTitle("Events/0.02");
  bdtout_highPt_all_tot->GetXaxis()->SetTitleSize(0.05);
  bdtout_highPt_all_tot->GetXaxis()->SetLabelSize(0.05);
  bdtout_highPt_all_tot->GetYaxis()->SetTitleSize(0.05);
  bdtout_highPt_all_tot->GetYaxis()->SetLabelSize(0.05);

  max = 1.2*bdtout_highPt_all_tot->GetMaximum();
  bdtout_highPt_all_tot->SetMaximum(max);

  TBox* box_highPt = new TBox(-1.,0.,boundaries[0],max);
  box_highPt->SetFillColor(38);
  box_highPt->SetFillStyle(3002);

  bdtout_highPt_all_tot->Draw("hist");
  box_highPt->Draw("hist,same");
  bdtout_highPt_all_tot->Draw("hist,same");
  bdtout_highPt_cat0_tot->Draw("hist,same");
  bdtout_highPt_cat1_tot->Draw("hist,same");
  bdtout_highPt_cat2_tot->Draw("hist,same");
  bdtout_highPt_cat3_tot->Draw("hist,same");

  TLegend *leg_highPt = (TLegend*)leg->Clone();
  leg_highPt->Clear();
  leg_highPt->AddEntry(bdtout_all_tot,"All (p_{T}(#gamma#gamma) > 40 GeV)");
  leg_highPt->AddEntry(bdtout_cat0_tot,"both EB, both R9>0.94");
  leg_highPt->AddEntry(bdtout_cat1_tot,"both EB, !both R9>0.94");
  leg_highPt->AddEntry(bdtout_cat2_tot,"!both EB, both R9>0.94");
  leg_highPt->AddEntry(bdtout_cat3_tot,"!both EB, !both R9>0.94");
  leg_highPt->Draw("hist");

  TLine* line_highPt[4];
  for (int i=0; i<4; i++) {
    line_highPt[i] = new TLine(boundaries[i],0.,boundaries[i],max);
    line_highPt[i]->SetLineColor(4);
    line_highPt[i]->SetLineWidth(2);
    line_highPt[i]->SetLineStyle(9);
    line_highPt[i]->Draw("hist");
  }

  gPad->RedrawAxis();

  c_bdtout_highPt->SaveAs("categories_highPt_sig.png");



  TCanvas *c_bdtout_compareCiC_highPt = new TCanvas("c_bdtout_compareCiC_highPt","BDT output: di-photon pT>40 GeV, pass CiC supertight",1000,650);
  c_bdtout_compareCiC_highPt->Divide(2,2);

  bdtout_passCiC_highPt_cat0_tot->SetFillColor(2);
  bdtout_passCiC_highPt_cat1_tot->SetFillColor(3);
  bdtout_passCiC_highPt_cat2_tot->SetFillColor(4);
  bdtout_passCiC_highPt_cat3_tot->SetFillColor(6);

  bdtout_passCiC_highPt_cat0_tot->SetFillStyle(3002);
  bdtout_passCiC_highPt_cat1_tot->SetFillStyle(3002);
  bdtout_passCiC_highPt_cat2_tot->SetFillStyle(3002);
  bdtout_passCiC_highPt_cat3_tot->SetFillStyle(3002);

  bdtout_highPt_cat0_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_highPt_cat1_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_highPt_cat2_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_highPt_cat3_tot->GetXaxis()->SetTitle("di-photon MVA output");
  bdtout_highPt_cat0_tot->GetXaxis()->SetTitleSize(0.05);
  bdtout_highPt_cat1_tot->GetXaxis()->SetTitleSize(0.05);
  bdtout_highPt_cat2_tot->GetXaxis()->SetTitleSize(0.05);
  bdtout_highPt_cat3_tot->GetXaxis()->SetTitleSize(0.05);

  c_bdtout_compareCiC_highPt->cd(1);

  box_passCiC_highPt_cat0 = (TBox*)box->Clone();
  box_passCiC_highPt_cat0->SetY2(bdtout_highPt_cat0_tot->GetMaximum()*1.05);

  bdtout_highPt_cat0_tot->Draw("hist");
  box_passCiC_highPt_cat0->Draw("hist,same");
  bdtout_highPt_cat0_tot->Draw("hist,same");
  bdtout_passCiC_highPt_cat0_tot->Draw("hist,same");

  TLine* line_passCiC_highPt_cat0[4];
  for (int i=0; i<4; i++) {
    line_passCiC_highPt_cat0[i] = (TLine*)line[i]->Clone();
    line_passCiC_highPt_cat0[i]->SetY2(bdtout_highPt_cat0_tot->GetMaximum()*1.05);
    line_passCiC_highPt_cat0[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"both EB, both R9>0.94");
  gPad->RedrawAxis();

  c_bdtout_compareCiC_highPt->cd(2);

  box_passCiC_highPt_cat1 = (TBox*)box->Clone();
  box_passCiC_highPt_cat1->SetY2(bdtout_highPt_cat1_tot->GetMaximum()*1.05);

  bdtout_highPt_cat1_tot->Draw("hist");
  box_passCiC_highPt_cat1->Draw("hist,same");
  bdtout_highPt_cat1_tot->Draw("hist,same");
  bdtout_passCiC_highPt_cat1_tot->Draw("hist,same");

  TLine* line_passCiC_highPt_cat1[4];
  for (int i=0; i<4; i++) {
    line_passCiC_highPt_cat1[i] = (TLine*)line[i]->Clone();
    line_passCiC_highPt_cat1[i]->SetY2(bdtout_highPt_cat1_tot->GetMaximum()*1.05);
    line_passCiC_highPt_cat1[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"both EB, !both R9>0.94");
  gPad->RedrawAxis();

  c_bdtout_compareCiC_highPt->cd(3);

  box_passCiC_highPt_cat2 = (TBox*)box->Clone();
  box_passCiC_highPt_cat2->SetY2(bdtout_highPt_cat2_tot->GetMaximum()*1.05);

  bdtout_highPt_cat2_tot->Draw("hist");
  box_passCiC_highPt_cat2->Draw("hist,same");
  bdtout_highPt_cat2_tot->Draw("hist,same");
  bdtout_passCiC_highPt_cat2_tot->Draw("hist,same");

  TLine* line_passCiC_highPt_cat2[4];
  for (int i=0; i<4; i++) {
    line_passCiC_highPt_cat2[i] = (TLine*)line[i]->Clone();
    line_passCiC_highPt_cat2[i]->SetY2(bdtout_highPt_cat2_tot->GetMaximum()*1.05);
    line_passCiC_highPt_cat2[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"!both EB, both R9>0.94");
  gPad->RedrawAxis();

  c_bdtout_compareCiC_highPt->cd(4);

  box_passCiC_highPt_cat3 = (TBox*)box->Clone();
  box_passCiC_highPt_cat3->SetY2(bdtout_highPt_cat3_tot->GetMaximum()*1.05);

  bdtout_highPt_cat3_tot->Draw("hist");
  box_passCiC_highPt_cat3->Draw("hist,same");
  bdtout_highPt_cat3_tot->Draw("hist,same");
  bdtout_passCiC_highPt_cat3_tot->Draw("hist,same");

  TLine* line_passCiC_highPt_cat3[4];
  for (int i=0; i<4; i++) {
    line_passCiC_highPt_cat3[i] = (TLine*)line[i]->Clone();
    line_passCiC_highPt_cat3[i]->SetY2(bdtout_highPt_cat3_tot->GetMaximum()*1.05);
    line_passCiC_highPt_cat3[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"!both EB, !both R9>0.94");
  gPad->RedrawAxis();

  c_bdtout_compareCiC_highPt->SaveAs("categories_compareCiC_highPt_sig.png");


  TCanvas *c_ptVsBdtout = new TCanvas("c_ptVsBdtout","pT(#gamma#gamma) vs MVA output",1000,650);
  c_ptVsBdtout->Divide(2,2);

  pt_vs_bdtout_cat0_all = (TH2*)pt_vs_bdtout_cat0_ggh_m125_8TeV->Clone();
  pt_vs_bdtout_cat1_all = (TH2*)pt_vs_bdtout_cat1_ggh_m125_8TeV->Clone();
  pt_vs_bdtout_cat2_all = (TH2*)pt_vs_bdtout_cat2_ggh_m125_8TeV->Clone();
  pt_vs_bdtout_cat3_all = (TH2*)pt_vs_bdtout_cat3_ggh_m125_8TeV->Clone();
  pt_vs_bdtout_cat4_all = (TH2*)pt_vs_bdtout_cat4_ggh_m125_8TeV->Clone();

  pt_vs_bdtout_cat0_all->Add(pt_vs_bdtout_cat0_vbf_m125_8TeV);
  pt_vs_bdtout_cat1_all->Add(pt_vs_bdtout_cat1_vbf_m125_8TeV);
  pt_vs_bdtout_cat2_all->Add(pt_vs_bdtout_cat2_vbf_m125_8TeV);
  pt_vs_bdtout_cat3_all->Add(pt_vs_bdtout_cat3_vbf_m125_8TeV);
  pt_vs_bdtout_cat4_all->Add(pt_vs_bdtout_cat4_vbf_m125_8TeV);

  pt_vs_bdtout_cat0_all->Add(pt_vs_bdtout_cat0_wzh_m125_8TeV);
  pt_vs_bdtout_cat1_all->Add(pt_vs_bdtout_cat1_wzh_m125_8TeV);
  pt_vs_bdtout_cat2_all->Add(pt_vs_bdtout_cat2_wzh_m125_8TeV);
  pt_vs_bdtout_cat3_all->Add(pt_vs_bdtout_cat3_wzh_m125_8TeV);
  pt_vs_bdtout_cat4_all->Add(pt_vs_bdtout_cat4_wzh_m125_8TeV);

  pt_vs_bdtout_cat0_all->Add(pt_vs_bdtout_cat0_tth_m125_8TeV);
  pt_vs_bdtout_cat1_all->Add(pt_vs_bdtout_cat1_tth_m125_8TeV);
  pt_vs_bdtout_cat2_all->Add(pt_vs_bdtout_cat2_tth_m125_8TeV);
  pt_vs_bdtout_cat3_all->Add(pt_vs_bdtout_cat3_tth_m125_8TeV);
  pt_vs_bdtout_cat4_all->Add(pt_vs_bdtout_cat4_tth_m125_8TeV);

  pt_vs_bdtout_cat0_all->GetXaxis()->SetTitle("di-photon MVA output");
  pt_vs_bdtout_cat1_all->GetXaxis()->SetTitle("di-photon MVA output");
  pt_vs_bdtout_cat2_all->GetXaxis()->SetTitle("di-photon MVA output");
  pt_vs_bdtout_cat3_all->GetXaxis()->SetTitle("di-photon MVA output");
  pt_vs_bdtout_cat0_all->GetXaxis()->SetTitleSize(0.05);
  pt_vs_bdtout_cat1_all->GetXaxis()->SetTitleSize(0.05);
  pt_vs_bdtout_cat2_all->GetXaxis()->SetTitleSize(0.05);
  pt_vs_bdtout_cat3_all->GetXaxis()->SetTitleSize(0.05);
  pt_vs_bdtout_cat0_all->GetYaxis()->SetTitle("di-photon p_{T} (GeV)");
  pt_vs_bdtout_cat1_all->GetYaxis()->SetTitle("di-photon p_{T} (GeV)");
  pt_vs_bdtout_cat2_all->GetYaxis()->SetTitle("di-photon p_{T} (GeV)");
  pt_vs_bdtout_cat3_all->GetYaxis()->SetTitle("di-photon p_{T} (GeV)");
  pt_vs_bdtout_cat0_all->GetYaxis()->SetTitleSize(0.05);
  pt_vs_bdtout_cat1_all->GetYaxis()->SetTitleSize(0.05);
  pt_vs_bdtout_cat2_all->GetYaxis()->SetTitleSize(0.05);
  pt_vs_bdtout_cat3_all->GetYaxis()->SetTitleSize(0.05);

  c_ptVsBdtout->cd(1);
  pt_vs_bdtout_cat0_all->Draw("colz");
  box_ptVsBdtout = (TBox*)box->Clone();
  box_ptVsBdtout->SetY2(200.);
  box_ptVsBdtout->Draw("hist");
  pt_vs_bdtout_cat0_all->Draw("colz,same");
  TLine* line_ptVsBdtout[4];
  for (int i=0; i<4; i++) {
    line_ptVsBdtout[i] = (TLine*)line[i]->Clone();
    line_ptVsBdtout[i]->SetY2(200.);
    line_ptVsBdtout[i]->Draw("hist");
  }
  text->DrawText(0.15,0.75,"both EB, both R9>0.94");
  gPad->RedrawAxis();
  c_ptVsBdtout->cd(2);
  pt_vs_bdtout_cat1_all->Draw("colz");
  box_ptVsBdtout->Draw("hist");
  pt_vs_bdtout_cat1_all->Draw("colz,same");
  for (int i=0; i<4; i++) line_ptVsBdtout[i]->Draw("hist");
  text->DrawText(0.15,0.75,"both EB, !both R9>0.94");
  gPad->RedrawAxis();
  c_ptVsBdtout->cd(3);
  pt_vs_bdtout_cat2_all->Draw("colz");
  box_ptVsBdtout->Draw("hist");
  pt_vs_bdtout_cat2_all->Draw("colz,same");
  for (int i=0; i<4; i++) line_ptVsBdtout[i]->Draw("hist");
  text->DrawText(0.15,0.75,"!both EB, both R9>0.94");
  gPad->RedrawAxis();
  c_ptVsBdtout->cd(4);
  pt_vs_bdtout_cat3_all->Draw("colz");
  box_ptVsBdtout->Draw("hist");
  pt_vs_bdtout_cat3_all->Draw("colz,same");
  for (int i=0; i<4; i++) line_ptVsBdtout[i]->Draw("hist");
  text->DrawText(0.15,0.75,"!both EB, !both R9>0.94");
  gPad->RedrawAxis();

  c_ptVsBdtout->SaveAs("ptVsBdtout_sig.png");


  TCanvas *c_2D = new TCanvas("c_2D","min(R9) vs max(eta), sublead eta vs lead eta",1250,500);
  c_2D->Divide(4,2);

  minR9_vs_maxEta_cat2_all = (TH2*)minR9_vs_maxEta_cat2_ggh_m125_8TeV->Clone();
  minR9_vs_maxEta_cat3_all = (TH2*)minR9_vs_maxEta_cat3_ggh_m125_8TeV->Clone();
  minR9_vs_maxEta_cat4_all = (TH2*)minR9_vs_maxEta_cat4_ggh_m125_8TeV->Clone();
  minR9_vs_maxEta_cat5_all = (TH2*)minR9_vs_maxEta_cat5_ggh_m125_8TeV->Clone();
  minR9_vs_maxEta_cat6_all = (TH2*)minR9_vs_maxEta_cat6_ggh_m125_8TeV->Clone();

  minR9_vs_maxEta_cat2_all->Add(minR9_vs_maxEta_cat2_vbf_m125_8TeV);
  minR9_vs_maxEta_cat3_all->Add(minR9_vs_maxEta_cat3_vbf_m125_8TeV);
  minR9_vs_maxEta_cat4_all->Add(minR9_vs_maxEta_cat4_vbf_m125_8TeV);
  minR9_vs_maxEta_cat5_all->Add(minR9_vs_maxEta_cat5_vbf_m125_8TeV);
  minR9_vs_maxEta_cat6_all->Add(minR9_vs_maxEta_cat6_vbf_m125_8TeV);

  minR9_vs_maxEta_cat2_all->Add(minR9_vs_maxEta_cat2_wzh_m125_8TeV);
  minR9_vs_maxEta_cat3_all->Add(minR9_vs_maxEta_cat3_wzh_m125_8TeV);
  minR9_vs_maxEta_cat4_all->Add(minR9_vs_maxEta_cat4_wzh_m125_8TeV);
  minR9_vs_maxEta_cat5_all->Add(minR9_vs_maxEta_cat5_wzh_m125_8TeV);
  minR9_vs_maxEta_cat6_all->Add(minR9_vs_maxEta_cat6_wzh_m125_8TeV);

  minR9_vs_maxEta_cat2_all->Add(minR9_vs_maxEta_cat2_tth_m125_8TeV);
  minR9_vs_maxEta_cat3_all->Add(minR9_vs_maxEta_cat3_tth_m125_8TeV);
  minR9_vs_maxEta_cat4_all->Add(minR9_vs_maxEta_cat4_tth_m125_8TeV);
  minR9_vs_maxEta_cat5_all->Add(minR9_vs_maxEta_cat5_tth_m125_8TeV);
  minR9_vs_maxEta_cat6_all->Add(minR9_vs_maxEta_cat6_tth_m125_8TeV);

  eta2_vs_eta1_cat2_all = (TH2*)eta2_vs_eta1_cat2_ggh_m125_8TeV->Clone();
  eta2_vs_eta1_cat3_all = (TH2*)eta2_vs_eta1_cat3_ggh_m125_8TeV->Clone();
  eta2_vs_eta1_cat4_all = (TH2*)eta2_vs_eta1_cat4_ggh_m125_8TeV->Clone();
  eta2_vs_eta1_cat5_all = (TH2*)eta2_vs_eta1_cat5_ggh_m125_8TeV->Clone();
  eta2_vs_eta1_cat6_all = (TH2*)eta2_vs_eta1_cat6_ggh_m125_8TeV->Clone();

  eta2_vs_eta1_cat2_all->Add(eta2_vs_eta1_cat2_vbf_m125_8TeV);
  eta2_vs_eta1_cat3_all->Add(eta2_vs_eta1_cat3_vbf_m125_8TeV);
  eta2_vs_eta1_cat4_all->Add(eta2_vs_eta1_cat4_vbf_m125_8TeV);
  eta2_vs_eta1_cat5_all->Add(eta2_vs_eta1_cat5_vbf_m125_8TeV);
  eta2_vs_eta1_cat6_all->Add(eta2_vs_eta1_cat6_vbf_m125_8TeV);

  eta2_vs_eta1_cat2_all->Add(eta2_vs_eta1_cat2_wzh_m125_8TeV);
  eta2_vs_eta1_cat3_all->Add(eta2_vs_eta1_cat3_wzh_m125_8TeV);
  eta2_vs_eta1_cat4_all->Add(eta2_vs_eta1_cat4_wzh_m125_8TeV);
  eta2_vs_eta1_cat5_all->Add(eta2_vs_eta1_cat5_wzh_m125_8TeV);
  eta2_vs_eta1_cat6_all->Add(eta2_vs_eta1_cat6_wzh_m125_8TeV);

  eta2_vs_eta1_cat2_all->Add(eta2_vs_eta1_cat2_tth_m125_8TeV);
  eta2_vs_eta1_cat3_all->Add(eta2_vs_eta1_cat3_tth_m125_8TeV);
  eta2_vs_eta1_cat4_all->Add(eta2_vs_eta1_cat4_tth_m125_8TeV);
  eta2_vs_eta1_cat5_all->Add(eta2_vs_eta1_cat5_tth_m125_8TeV);
  eta2_vs_eta1_cat6_all->Add(eta2_vs_eta1_cat6_tth_m125_8TeV);

  minR9_vs_maxEta_cat2_all->GetXaxis()->SetTitle("max(#eta)");
  minR9_vs_maxEta_cat3_all->GetXaxis()->SetTitle("max(#eta)");
  minR9_vs_maxEta_cat4_all->GetXaxis()->SetTitle("max(#eta)");
  minR9_vs_maxEta_cat5_all->GetXaxis()->SetTitle("max(#eta)");
  minR9_vs_maxEta_cat6_all->GetXaxis()->SetTitle("max(#eta)");
  minR9_vs_maxEta_cat2_all->GetYaxis()->SetTitle("min(R9)");
  minR9_vs_maxEta_cat3_all->GetYaxis()->SetTitle("min(R9)");
  minR9_vs_maxEta_cat4_all->GetYaxis()->SetTitle("min(R9)");
  minR9_vs_maxEta_cat5_all->GetYaxis()->SetTitle("min(R9)");
  minR9_vs_maxEta_cat6_all->GetYaxis()->SetTitle("min(R9)");

  minR9_vs_maxEta_cat2_all->GetXaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat3_all->GetXaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat4_all->GetXaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat5_all->GetXaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat6_all->GetXaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat2_all->GetYaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat3_all->GetYaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat4_all->GetYaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat5_all->GetYaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat6_all->GetYaxis()->SetTitleSize(0.05);

  line_minr9 = new TLine(0.,0.94,2.5,0.94);
  line_maxeta = new TLine(1.479,0.5,1.479,1.);
  //line_minr9->SetLineColor(4);
  line_minr9->SetLineWidth(2);
  line_minr9->SetLineStyle(9);
  //line_maxeta->SetLineColor(4);
  line_maxeta->SetLineWidth(2);
  line_maxeta->SetLineStyle(9);

  c_2D->cd(1);
  minR9_vs_maxEta_cat2_all->Draw("colz");
  line_minr9->Draw("hist");
  line_maxeta->Draw("hist");
  c_2D->cd(2);
  minR9_vs_maxEta_cat3_all->Draw("colz");
  line_minr9->Draw("hist");
  line_maxeta->Draw("hist");
  c_2D->cd(3);
  minR9_vs_maxEta_cat4_all->Draw("colz");
  line_minr9->Draw("hist");
  line_maxeta->Draw("hist");
  c_2D->cd(4);
  minR9_vs_maxEta_cat5_all->Draw("colz");
  line_minr9->Draw("hist");
  line_maxeta->Draw("hist");
  //c_2D->cd(5);
  //minR9_vs_maxEta_cat6_all->Draw("colz");
  //line_minr9->Draw("hist");
  //line_maxeta->Draw("hist");

  eta2_vs_eta1_cat2_all->GetYaxis()->SetTitle("sublead #eta");
  eta2_vs_eta1_cat3_all->GetYaxis()->SetTitle("sublead #eta");
  eta2_vs_eta1_cat4_all->GetYaxis()->SetTitle("sublead #eta");
  eta2_vs_eta1_cat5_all->GetYaxis()->SetTitle("sublead #eta");
  eta2_vs_eta1_cat6_all->GetYaxis()->SetTitle("sublead #eta");
  eta2_vs_eta1_cat2_all->GetXaxis()->SetTitle("lead #eta");
  eta2_vs_eta1_cat3_all->GetXaxis()->SetTitle("lead #eta");
  eta2_vs_eta1_cat4_all->GetXaxis()->SetTitle("lead #eta");
  eta2_vs_eta1_cat5_all->GetXaxis()->SetTitle("lead #eta");
  eta2_vs_eta1_cat6_all->GetXaxis()->SetTitle("lead #eta");

  eta2_vs_eta1_cat2_all->GetXaxis()->SetTitleSize(0.05);
  eta2_vs_eta1_cat3_all->GetXaxis()->SetTitleSize(0.05);
  eta2_vs_eta1_cat4_all->GetXaxis()->SetTitleSize(0.05);
  eta2_vs_eta1_cat5_all->GetXaxis()->SetTitleSize(0.05);
  eta2_vs_eta1_cat6_all->GetXaxis()->SetTitleSize(0.05);
  eta2_vs_eta1_cat2_all->GetYaxis()->SetTitleSize(0.05);
  eta2_vs_eta1_cat3_all->GetYaxis()->SetTitleSize(0.05);
  eta2_vs_eta1_cat4_all->GetYaxis()->SetTitleSize(0.05);
  eta2_vs_eta1_cat5_all->GetYaxis()->SetTitleSize(0.05);
  eta2_vs_eta1_cat6_all->GetYaxis()->SetTitleSize(0.05);

  c_2D->cd(5);
  eta2_vs_eta1_cat2_all->Draw("colz");
  c_2D->cd(6);
  eta2_vs_eta1_cat3_all->Draw("colz");
  c_2D->cd(7);
  eta2_vs_eta1_cat4_all->Draw("colz");
  c_2D->cd(8);
  eta2_vs_eta1_cat5_all->Draw("colz");
  //c_2D->cd(10);
  //eta2_vs_eta1_cat6_all->Draw("colz");

  c_2D->SaveAs("categories_2D_sig.png");

  /*
  TCanvas *c_2D_v2 = new TCanvas("c_2D_v2","min(R9) vs max(eta), |lead eta| vs |deltaEeta|",1500,500);
  c_2D_v2->Divide(5,2);

  minR9_vs_maxEta_cat2_tot->GetXaxis()->SetTitle("max(#eta)");
  minR9_vs_maxEta_cat3_tot->GetXaxis()->SetTitle("max(#eta)");
  minR9_vs_maxEta_cat4_tot->GetXaxis()->SetTitle("max(#eta)");
  minR9_vs_maxEta_cat5_tot->GetXaxis()->SetTitle("max(#eta)");
  minR9_vs_maxEta_cat6_tot->GetXaxis()->SetTitle("max(#eta)");
  minR9_vs_maxEta_cat2_tot->GetYaxis()->SetTitle("min(R9)");
  minR9_vs_maxEta_cat3_tot->GetYaxis()->SetTitle("min(R9)");
  minR9_vs_maxEta_cat4_tot->GetYaxis()->SetTitle("min(R9)");
  minR9_vs_maxEta_cat5_tot->GetYaxis()->SetTitle("min(R9)");
  minR9_vs_maxEta_cat6_tot->GetYaxis()->SetTitle("min(R9)");

  minR9_vs_maxEta_cat2_tot->GetXaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat3_tot->GetXaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat4_tot->GetXaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat5_tot->GetXaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat6_tot->GetXaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat2_tot->GetYaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat3_tot->GetYaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat4_tot->GetYaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat5_tot->GetYaxis()->SetTitleSize(0.05);
  minR9_vs_maxEta_cat6_tot->GetYaxis()->SetTitleSize(0.05);

  c_2D_v2->cd(1);
  minR9_vs_maxEta_cat2_tot->Draw("colz");
  line_minr9->Draw("hist");
  line_maxeta->Draw("hist");
  c_2D_v2->cd(2);
  minR9_vs_maxEta_cat3_tot->Draw("colz");
  line_minr9->Draw("hist");
  line_maxeta->Draw("hist");
  c_2D_v2->cd(3);
  minR9_vs_maxEta_cat4_tot->Draw("colz");
  line_minr9->Draw("hist");
  line_maxeta->Draw("hist");
  c_2D_v2->cd(4);
  minR9_vs_maxEta_cat5_tot->Draw("colz");
  line_minr9->Draw("hist");
  line_maxeta->Draw("hist");
  c_2D_v2->cd(5);
  minR9_vs_maxEta_cat6_tot->Draw("colz");
  line_minr9->Draw("hist");
  line_maxeta->Draw("hist");

  eta1_vs_deltaEta_cat2_tot->GetYaxis()->SetTitle("|lead #eta|");
  eta1_vs_deltaEta_cat3_tot->GetYaxis()->SetTitle("|lead #eta|");
  eta1_vs_deltaEta_cat4_tot->GetYaxis()->SetTitle("|lead #eta|");
  eta1_vs_deltaEta_cat5_tot->GetYaxis()->SetTitle("|lead #eta|");
  eta1_vs_deltaEta_cat6_tot->GetYaxis()->SetTitle("|lead #eta|");
  eta1_vs_deltaEta_cat2_tot->GetXaxis()->SetTitle("|#Delta#eta|");
  eta1_vs_deltaEta_cat3_tot->GetXaxis()->SetTitle("|#Delta#eta|");
  eta1_vs_deltaEta_cat4_tot->GetXaxis()->SetTitle("|#Delta#eta|");
  eta1_vs_deltaEta_cat5_tot->GetXaxis()->SetTitle("|#Delta#eta|");
  eta1_vs_deltaEta_cat6_tot->GetXaxis()->SetTitle("|#Delta#eta|");

  eta1_vs_deltaEta_cat2_tot->GetXaxis()->SetTitleSize(0.05);
  eta1_vs_deltaEta_cat3_tot->GetXaxis()->SetTitleSize(0.05);
  eta1_vs_deltaEta_cat4_tot->GetXaxis()->SetTitleSize(0.05);
  eta1_vs_deltaEta_cat5_tot->GetXaxis()->SetTitleSize(0.05);
  eta1_vs_deltaEta_cat6_tot->GetXaxis()->SetTitleSize(0.05);
  eta1_vs_deltaEta_cat2_tot->GetYaxis()->SetTitleSize(0.05);
  eta1_vs_deltaEta_cat3_tot->GetYaxis()->SetTitleSize(0.05);
  eta1_vs_deltaEta_cat4_tot->GetYaxis()->SetTitleSize(0.05);
  eta1_vs_deltaEta_cat5_tot->GetYaxis()->SetTitleSize(0.05);
  eta1_vs_deltaEta_cat6_tot->GetYaxis()->SetTitleSize(0.05);

  c_2D_v2->cd(6);
  eta1_vs_deltaEta_cat2_tot->Draw("colz");
  c_2D_v2->cd(7);
  eta1_vs_deltaEta_cat3_tot->Draw("colz");
  c_2D_v2->cd(8);
  eta1_vs_deltaEta_cat4_tot->Draw("colz");
  c_2D_v2->cd(9);
  eta1_vs_deltaEta_cat5_tot->Draw("colz");
  c_2D_v2->cd(10);
  eta1_vs_deltaEta_cat6_tot->Draw("colz");

  c_2D_v2->SaveAs("categories_2D_v2_sig.png");
  */
}
Ejemplo n.º 11
0
void analyze() {
   TCanvas *c1 = new TCanvas("c1","Analyze.mac",620,790);
   c1->Range(-1,0,19,30);
   TPaveLabel *pl1 = new TPaveLabel(0,27,3.5,29,"Analyze");
   pl1->SetFillColor(42);
   pl1->Draw();
   TPaveText *pt1 = new TPaveText(0,22.8,4,25.2);
   TText *t1  = pt1->AddText("Parenthesis matching");
   TText *t2  = pt1->AddText("Remove unnecessary");
   TText *t2a = pt1->AddText("parenthesis");
   pt1->Draw();
   TPaveText *pt2 = new TPaveText(6,23,10,25);
   TText *t3 = pt2->AddText("break of");
   TText *t4 = pt2->AddText("Analyze");
   pt2->Draw();
   TPaveText *pt3 = new TPaveText(0,19,4,21);
   t4=pt3->AddText("look for simple");
   TText *t5 = pt3->AddText("operators");
   pt3->Draw();
   TPaveText *pt4 = new TPaveText(0,15,4,17);
   TText *t6 = pt4->AddText("look for an already");
   TText *t7 = pt4->AddText("defined expression");
   pt4->Draw();
   TPaveText *pt5 = new TPaveText(0,11,4,13);
   TText *t8 = pt5->AddText("look for usual");
   TText *t9 = pt5->AddText("functions :cos sin ..");
   pt5->Draw();
   TPaveText *pt6 = new TPaveText(0,7,4,9);
   TText *t10 = pt6->AddText("look for a");
   TText *t11 = pt6->AddText("numeric value");
   pt6->Draw();
   TPaveText *pt7 = new TPaveText(6,18.5,10,21.5);
   TText *t12 = pt7->AddText("Analyze left and");
   TText *t13 = pt7->AddText("right part of");
   TText *t14 = pt7->AddText("the expression");
   pt7->Draw();
   TPaveText *pt8 = new TPaveText(6,15,10,17);
   TText *t15 = pt8->AddText("Replace expression");
   pt8->Draw();
   TPaveText *pt9 = new TPaveText(6,11,10,13);
   TText *t16 = pt9->AddText("Analyze");
   pt9->SetFillColor(42);
   pt9->Draw();
   TPaveText *pt10 = new TPaveText(6,7,10,9);
   TText *t17 = pt10->AddText("Error");
   TText *t18 = pt10->AddText("Break of Analyze");
   pt10->Draw();
   TPaveText *pt11 = new TPaveText(14,22,17,24);
   pt11->SetFillColor(42);
   TText *t19  = pt11->AddText("Analyze");
   TText *t19a = pt11->AddText("Left");
   pt11->Draw();
   TPaveText *pt12 = new TPaveText(14,19,17,21);
   pt12->SetFillColor(42);
   TText *t20  = pt12->AddText("Analyze");
   TText *t20a = pt12->AddText("Right");
   pt12->Draw();
   TPaveText *pt13 = new TPaveText(14,15,18,18);
   TText *t21 = pt13->AddText("StackNumber++");
   TText *t22 = pt13->AddText("operator[StackNumber]");
   TText *t23 = pt13->AddText("= operator found");
   pt13->Draw();
   TPaveText *pt14 = new TPaveText(12,10.8,17,13.2);
   TText *t24 = pt14->AddText("StackNumber++");
   TText *t25 = pt14->AddText("operator[StackNumber]");
   TText *t26 = pt14->AddText("= function found");
   pt14->Draw();
   TPaveText *pt15 = new TPaveText(6,7,10,9);
   TText *t27 = pt15->AddText("Error");
   TText *t28 = pt15->AddText("break of Analyze");
   pt15->Draw();
   TPaveText *pt16 = new TPaveText(0,2,7,5);
   TText *t29 = pt16->AddText("StackNumber++");
   TText *t30 = pt16->AddText("operator[StackNumber] = 0");
   TText *t31 = pt16->AddText("value[StackNumber] = value found");
   pt16->Draw();
   TArrow *ar = new TArrow(2,27,2,25.4,0.012,"|>");
   ar->SetFillColor(1);
   ar->Draw();
   ar->DrawArrow(2,22.8,2,21.2,0.012,"|>");
   ar->DrawArrow(2,19,2,17.2,0.012,"|>");
   ar->DrawArrow(2,15,2,13.2,0.012,"|>");
   ar->DrawArrow(2,11,2, 9.2,0.012,"|>");
   ar->DrawArrow(2, 7,2, 5.2,0.012,"|>");
   ar->DrawArrow(4,24,6,24,0.012,"|>");
   ar->DrawArrow(4,20,6,20,0.012,"|>");
   ar->DrawArrow(4,16,6,16,0.012,"|>");
   ar->DrawArrow(4,12,6,12,0.012,"|>");
   ar->DrawArrow(4, 8,6, 8,0.012,"|>");
   ar->DrawArrow(10,20,14,20,0.012,"|>");
   ar->DrawArrow(12,23,14,23,0.012,"|>");
   ar->DrawArrow(12,16.5,14,16.5,0.012,"|>");
   ar->DrawArrow(10,12,12,12,0.012,"|>");
   TText *ta = new TText(2.2,22.2,"err = 0");
   ta->SetTextFont(71);
   ta->SetTextSize(0.015);
   ta->SetTextColor(4);
   ta->SetTextAlign(12);
   ta->Draw();
   ta->DrawText(2.2,18.2,"not found");
   ta->DrawText(2.2,6.2,"found");
   TText *tb = new TText(4.2,24.1,"err != 0");
   tb->SetTextFont(71);
   tb->SetTextSize(0.015);
   tb->SetTextColor(4);
   tb->SetTextAlign(11);
   tb->Draw();
   tb->DrawText(4.2,20.1,"found");
   tb->DrawText(4.2,16.1,"found");
   tb->DrawText(4.2,12.1,"found");
   tb->DrawText(4.2, 8.1,"not found");
   TLine *l1 = new TLine(12,16.5,12,23);
   l1->Draw();
}
Ejemplo n.º 12
0
void memstat(double update=0.01, const char* fname="*") {
   // Open the memstat data file, then call TTree::Draw to precompute
   // the arrays of positions and nbytes per entry.
   // update is the time interval in the data file  in seconds after which
   // the display is updated. For example is the job producing the memstat.root file
   // took 100s to execute, an update of 0.1s will generate 1000 time views of
   // the memory use.
   // if fname=="*" (default), the most recent file memstat*.root will be taken.
   
   TString s;
   if (!fname || strlen(fname) <5 || strstr(fname,"*")) {
      //take the most recent file memstat*.root
      s = gSystem->GetFromPipe("ls -lrt memstat*.root");
      Int_t ns = s.Length();
      fname = strstr(s.Data()+ns-25,"memstat");
   }
   printf("Analyzing file: %s\n",fname);
   f = TFile::Open(fname);
   if (!f) {
      printf("Cannot open file %s\n",fname);
      return;
   }
   T = (TTree*)f->Get("T");
   if (!T) {
      printf("cannot find the TMemStat TTree named T in file %s\n",fname);
      return;
   }
   if (update <= 0) {
      printf("Illegal update value %g, changed to 0.01\n",update);
      update = 0.01;
   }
   if (update < 0.001) printf("Warning update parameter is very small, processing may be slow\n");
   
   
   Long64_t nentries = T->GetEntries();
   T->SetEstimate(nentries+10);
   Long64_t nsel = T->Draw("pos:nbytes:time:btid","","goff");
   
   //now we compute the best binning for the histogram
   Int_t nbytes;
   Double_t pos;
   V1 = T->GetV1();
   V2 = T->GetV2();
   V3 = T->GetV3();
   V4 = T->GetV4();
   Long64_t imean = (Long64_t)TMath::Mean(nsel,V1);
   Long64_t irms  = (Long64_t)TMath::RMS(nsel,V1);
   //Long64_t bw = 10000;
   Long64_t bw = 1000;
   imean = imean - imean%bw;
   irms = irms -irms%bw;
   Int_t nbins = Int_t(4*irms/bw);
   Long64_t ivmin = imean -bw*nbins/2;
   Long64_t ivmax = ivmin+bw*nbins;
   if (ivmax > 2000000000 && ivmin <2000000000) {
      //the data set has been likely generated on a 32 bits machine
      //we are mostly interested by the small allocations, so we select
      //only values below 2 GBytes
      printf("memory locations above 2GBytes will be ignored\n");
      nsel = T->Draw("pos:nbytes:time:btid","pos <2e9","goff");
      V1 = T->GetV1();
      V2 = T->GetV2();
      V3 = T->GetV3();
      V4 = T->GetV4();
      imean = (Long64_t)TMath::Mean(nsel,V1);
      irms = (Long64_t)TMath::RMS(nsel,V1);
      bw = 10000;
      imean = imean - imean%bw;
      irms = irms -irms%bw;
      nbins = Int_t(4*irms/bw);
      ivmin = imean -bw*nbins/2;
      ivmax = ivmin+bw*nbins;
   } 
   update *= 0.0001*V3[nsel-1]; //convert time per cent in seconds
   Long64_t nvm = Long64_t(ivmax-ivmin+1);
   Long64_t *nbold = new Long64_t[nvm];
   Int_t *ientry  = new Int_t[nvm];
   memset(nbold,0,nvm*8);
   Double_t dv = (ivmax-ivmin)/nbins;
   h = new TH1D("h",Form("%s;pos;per cent of pages used",fname),nbins,ivmin,ivmax);
   TAxis *axis = h->GetXaxis();
   gStyle->SetOptStat("ie");
   h->SetFillColor(kRed);
   h->SetMinimum(0);
   h->SetMaximum(100);
   halloc = new TH1D("halloc",Form("%s;pos;number of mallocs",fname),nbins,ivmin,ivmax);
   hfree  = new TH1D("hfree", Form("%s;pos;number of frees",fname),nbins,ivmin,ivmax);
   //open a canvas and draw the empty histogram
   TCanvas *c1 = new TCanvas("c1","c1",1200,600);
   c1->SetFrameFillColor(kYellow-3);
   c1->SetGridx();
   c1->SetGridy();
   h->Draw();
   //create a TPaveText to show the summary results
   TPaveText *pvt = new TPaveText(.5,.9,.75,.99,"brNDC");
   pvt->Draw();
   //create a TPaveLabel to show the time
   TPaveLabel *ptime = new TPaveLabel(.905,.7,.995,.76,"time","brNDC");
   ptime->SetFillColor(kYellow-3);
   ptime->Draw();
   //draw producer identifier
   TNamed *named = (TNamed*)T->GetUserInfo()->FindObject("SysInfo");
   TText tmachine;
   tmachine.SetTextSize(0.02);
   tmachine.SetNDC();
   if (named) tmachine.DrawText(0.01,0.01,named->GetTitle());

   //start loop on selected rows
   Int_t bin,nb=0,j;
   Long64_t ipos;
   Double_t dbin,rest,time;
   Double_t updateLast = 0;
   Int_t nleaks = 0;
   Int_t i;
   for (i=0;i<nsel;i++) {
      pos    = V1[i];
      ipos = (Long64_t)(pos-ivmin);
      nbytes = (Int_t)V2[i];
      time = 0.0001*V3[i];
      bin = axis->FindBin(pos);
      if (bin<1 || bin>nbins) continue;
      dbin = axis->GetBinUpEdge(bin)-pos;
      if (nbytes > 0) {
         halloc->Fill(pos);
         if (dbin > nbytes) dbin = nbytes;
         //fill bytes in the first page
         h->AddBinContent(bin,100*dbin/dv);
	 //fill bytes in full following pages
         nb = Int_t((nbytes-dbin)/dv);
	 if (bin+nb >nbins) nb = nbins-bin;
         for (j=1;j<=nb;j++) h->AddBinContent(bin+j,100);
	 //fill the bytes remaining in last page
         rest = nbytes-nb*dv-dbin;
	 if (rest > 0) h->AddBinContent(bin+nb+1,100*rest/dv);
	 //we save nbytes at pos. This info will be used when we free this slot
         if (nbold[ipos] > 0) printf("reallocating %d bytes (was %lld) at %lld, entry=%d\n",nbytes,nbold[ipos],ipos,i);
         if (nbold[ipos] == 0) {
            nleaks++;            
            //save the Tree entry number where we made this allocation
            ientry[ipos] = i;
         }
         nbold[ipos] = nbytes;
      } else {
         hfree->Fill(pos);
         nbytes = nbold[ipos];
	 if (bin+nb >nbins) nb = nbins-bin;
	 nbold[ipos] = 0; nleaks--;
	 if (nbytes <= 0) continue;
         //fill bytes free in the first page
         if (dbin > nbytes) dbin = nbytes;
	 h->AddBinContent(bin,-100*dbin/dv);
	 //fill bytes free in full following pages
	 nb = Int_t((nbytes-dbin)/dv);
	 if (bin+nb >nbins) nb = nbins-bin;
         for (j=1;j<=nb;j++) h->AddBinContent(bin+j,-100);
	 //fill the bytes free in  in last page
	 rest = nbytes-nb*dv-dbin;
	 if (rest > 0) h->AddBinContent(bin+nb+1,-100*rest/dv);

      }
      if (time -updateLast > update) {
         //update canvas at regular intervals
	 updateLast = time;
         h->SetEntries(i);
	 c1->Modified();
         pvt->GetListOfLines()->Delete();
         Double_t mbytes = 0;
         Int_t nonEmpty = 0;
         Double_t w;
         for (Int_t k=1;k<nbins;k++) {
            w = h->GetBinContent(k);
            if (w > 0) {
               nonEmpty++;
               mbytes += 0.01*w*dv;
            }
         }
         Double_t occupancy = mbytes/(nonEmpty*0.01*dv);
         pvt->AddText(Form("memory used = %g Mbytes",mbytes*1e-6));
         pvt->AddText(Form("page occupancy = %f per cent",occupancy));
         pvt->AddText("(for non empty pages only)");
         ptime->SetLabel(Form("%g sec",time));
         
	 c1->Update();
         gSystem->ProcessEvents();
      }
   }
   h->SetEntries(nsel);
   Int_t nlmax = nleaks;
   nleaks += 1000;
   Int_t *lindex  = new Int_t[nleaks];
   Int_t *entry   = new Int_t[nleaks];
   Int_t *ileaks  = new Int_t[nleaks];

   nleaks =0;
   for (Int_t ii=0;ii<nvm;ii++) {
      if (nbold[ii] > 0) {
         ileaks[nleaks] = (Int_t)nbold[ii];
         entry[nleaks]  = ientry[ii];
         nleaks++;
         if (nleaks > nlmax) break;
      }
   }

   TMath::Sort(nleaks,ileaks,lindex);
   hentry = new TH1I("hentry","leak entry index",nleaks,0,nleaks);
   hleaks = new TH1I("hleaks","leaks;leak number;nbytes in leak",nleaks,0,nleaks);
   for (Int_t k=0;k<nleaks;k++) {
      Int_t kk = lindex[k];
      i = entry[kk];
      hentry->SetBinContent(k+1,i);
      hleaks->SetBinContent(k+1,ileaks[kk]);
   }
   hentry->SetEntries(nleaks);
   hleaks->SetEntries(nleaks);
   
   //open a second canvas and draw the histogram with leaks in decreasing order
   TCanvas *c2 = new TCanvas("c2","c2",1200,600);
   c2->SetFrameFillColor(kCyan-6);
   c2->SetGridx();
   c2->SetGridy();
   c2->SetLogy();
   hleaks->SetFillColor(kRed-3);
   if (nleaks > 1000) hleaks->GetXaxis()->SetRange(1,1000);
   hleaks->Draw();
   //draw producer identifier
   if (named) tmachine.DrawText(0.01,0.01,named->GetTitle());
   
   //construct the tooltip
   TRootCanvas *rc = (TRootCanvas *)c2->GetCanvasImp();
   TGMainFrame *frm = dynamic_cast<TGMainFrame *>(rc);
   // create the tooltip with a timeout of 250 ms
   if (!gTip) gTip = new TGToolTip(gClient->GetDefaultRoot(), frm, "", 250);
   c2->Connect("ProcessedEvent(Int_t, Int_t, Int_t, TObject*)",
               0, 0, "EventInfo(Int_t, Int_t, Int_t, TObject*)");

}
Ejemplo n.º 13
0
TH1F* AnalyzeDs1pToDstKs(TChain* fChain,TString DATAorMC,Int_t MatterOrAntiMatter,TString Mode,TString NtupleDir,Int_t WhichCuts){

  Int_t test;
  
  //
  Bool_t TruthMatch=false;
  if(DATAorMC=="MC")TruthMatch=true;
 
  // Declaration of leave types
  Float_t beamSX;
  Float_t beamSY;
  Float_t beamSZ;

  Int_t   nDs1p;
  Float_t Ds1pChi2[400];  
  Float_t Ds1pMass[400];  
  Float_t Ds1pcosth[400];  
  Float_t Ds1pcosthCM[400];  
  Float_t Ds1pp3CM[400];  
  Float_t Ds1pphiCM[400];  
  Int_t   Ds1pLund[400];  
  Int_t   Ds1pMCIdx[400];  
  Int_t   Ds1pd1Lund[400];  
  Int_t   Ds1pd1Idx[400];  
  Int_t   Ds1pd2Lund[400];  
  Int_t   Ds1pd2Idx[400];  
  Float_t Ds1pVtxx[500];  
  Float_t Ds1pVtxy[500];  
  Float_t Ds1pVtxz[500];     

  Int_t   nKs;
  Float_t KsMass[400]; 
  Float_t Ksp3CM[400]; 
  Int_t   KsLund[400]; 
  Int_t   Ksd1Lund[400]; 
  Int_t   Ksd1Idx[400]; 
  Int_t   Ksd2Lund[400]; 
  Int_t   Ksd2Idx[400];  
  Int_t   KsMCIdx[400];
  Float_t KsChi2[400];
  Int_t   KsnDof[400];
  Float_t KsVtxx[500]; 
  Float_t KsVtxy[500]; 
  Float_t KsVtxz[500]; 
  Float_t Kscosth[500]; 
  Float_t Ksphi[500]; 

  Int_t   nDstar;
  Float_t DstarMass[400];  
  Float_t DstarMassErr[400];  
  Float_t Dstarcosth[400];  
  Float_t Dstarp3[400];  
  Float_t Dstarp3CM[400];  
  Int_t   DstarLund[400];  
  Int_t   Dstard1Lund[400];  
  Int_t   Dstard1Idx[400];  
  Int_t   Dstard2Lund[400];  
  Int_t   Dstard2Idx[400];    
  Int_t   DstarMCIdx[400];
 
  Int_t   nD0;
  Float_t D0Mass[400];  
  Float_t D0MassErr[400];  
  Float_t D0p3CM[400];  
  Int_t   D0Lund[400];  
  Int_t   D0d1Lund[400];  
  Int_t   D0d1Idx[400];  
  Int_t   D0d2Lund[400];  
  Int_t   D0d2Idx[400];   
  Int_t   D0d3Lund[400];  
  Int_t   D0d3Idx[400];
  Int_t   D0d4Lund[400];     
  Int_t   D0d4Idx[400];
  Int_t   D0MCIdx[400];
  Float_t D0Chi2[400];
  Int_t   D0nDof[400];

  Int_t   nPi;
  Float_t Pip3[400];  
  Int_t   PiLund[400];   
  Int_t   PiMCIdx[400];
  Int_t   PiTrkIdx[400];
  Int_t   PiSelectorsMap[400];
  
  Int_t   nK;
  Float_t Kp3[400]; 
  Int_t   KLund[400]; 
  Int_t   KMCIdx[400];
  Int_t   KTrkIdx[400];

  Int_t   nPi0;
  Float_t Pi0Mass[400];
  Float_t Pi0p3[400];  
  Int_t   Pi0Lund[400];  
  Int_t   Pi0MCIdx[400];
  Int_t   Pi0d1Lund[400];
  Int_t   Pi0d1Idx[400];

  Float_t GammaECal[400];
  Int_t   GammaMCIdx[400];
  Int_t   GammaLund[400];

  Int_t TRKnSvt[400];
  Int_t TRKLund[400];
  

  ////MC block
  Int_t mcLen;
  Int_t mcLund[400];
  Int_t mothIdx[400];
  Int_t dauLen[400];
  Int_t dauIdx[400];
  Float_t mcmass[400]; 
  Float_t mccosth[400];
  Float_t mcp3[400];
  Float_t mccosthCM[400];
  Float_t mcp3CM[400]; 


 

  //////My derived variables
  Float_t D0Probab;
  Float_t KsProbab;
  Float_t KsCosine;  
  TVector3 Ksp3Direction;
  TVector3 KsFlightDirection;

  Int_t MCDs1pCounterPerEvent=0;
  Int_t MCDs1pCounterTotal=0;
  Int_t RecoDs1pCounterTotal=0;


  Int_t   Ds1pIdx;
  Int_t   DstarIdx;
  Int_t   KsIdx;
  Int_t   D0Idx;
  Int_t   PiIdx;
  Int_t   SlowPiIdx;
  Int_t   KIdx;
  Int_t   Pi0Idx;
  Int_t   GammaIdx;  
  Int_t   PitrkIdx;
  Int_t   SlowPitrkIdx;
  Int_t   KsPi1Idx;
  Int_t   KsPi2Idx;
  Int_t   KsPi1trkIdx;
  Int_t   KsPi2trkIdx;

  //TChain* fChain=DstToD0PiChain(firstfile,lastfile, DATAorMC,Mode, ModeSubDir);
  if(fChain==NULL){
    cout<<"No chain."<<endl;
    return NULL;
  }
  fChain->SetBranchAddress("beamSX",&beamSX);
  fChain->SetBranchAddress("beamSY",&beamSY);
  fChain->SetBranchAddress("beamSZ",&beamSZ);

  fChain->SetBranchAddress("nDs1p",&nDs1p);
  fChain->SetBranchAddress("Ds1pMass",Ds1pMass);
  fChain->SetBranchAddress("Ds1pcosthCM",Ds1pcosthCM);
  fChain->SetBranchAddress("Ds1pp3CM",Ds1pp3CM);
  fChain->SetBranchAddress("Ds1pLund",Ds1pLund); 
  fChain->SetBranchAddress("Ds1pd1Lund",Ds1pd1Lund);
  fChain->SetBranchAddress("Ds1pd1Idx",Ds1pd1Idx);
  fChain->SetBranchAddress("Ds1pd2Lund",Ds1pd2Lund);
  fChain->SetBranchAddress("Ds1pd2Idx",Ds1pd2Idx);
  fChain->SetBranchAddress("Ds1pVtxx",Ds1pVtxx);
  fChain->SetBranchAddress("Ds1pVtxy",Ds1pVtxy);
  fChain->SetBranchAddress("Ds1pVtxz",Ds1pVtxz);


  fChain->SetBranchAddress("nKs",&nKs);
  fChain->SetBranchAddress("KsMass",KsMass);
  fChain->SetBranchAddress("Ksp3CM",Ksp3CM);  
  fChain->SetBranchAddress("KsLund",KsLund);
  fChain->SetBranchAddress("Ksd1Lund",Ksd1Lund);
  fChain->SetBranchAddress("Ksd1Idx",Ksd1Idx);
  fChain->SetBranchAddress("Ksd2Lund",Ksd2Lund);
  fChain->SetBranchAddress("Ksd2Idx",Ksd2Idx);
  fChain->SetBranchAddress("KsChi2",KsChi2);
  fChain->SetBranchAddress("KsnDof",KsnDof);
  fChain->SetBranchAddress("KsMCIdx",KsMCIdx);
  fChain->SetBranchAddress("KsVtxx",KsVtxx);
  fChain->SetBranchAddress("KsVtxy",KsVtxy);
  fChain->SetBranchAddress("KsVtxz",KsVtxz);
  fChain->SetBranchAddress("Kscosth",Kscosth);
  fChain->SetBranchAddress("Ksphi",Ksphi);


  fChain->SetBranchAddress("nDstar",&nDstar);
  fChain->SetBranchAddress("DstarMass",DstarMass);
  fChain->SetBranchAddress("DstarLund",DstarLund);
  fChain->SetBranchAddress("Dstard1Lund",Dstard1Lund);
  fChain->SetBranchAddress("Dstard1Idx",Dstard1Idx);
  fChain->SetBranchAddress("Dstard2Lund",Dstard2Lund);
  fChain->SetBranchAddress("Dstard2Idx",Dstard2Idx);

  fChain->SetBranchAddress("nD0",&nD0);
  fChain->SetBranchAddress("D0Mass",D0Mass);
  fChain->SetBranchAddress("D0p3CM",D0p3CM);  
  fChain->SetBranchAddress("D0Lund",D0Lund);
  fChain->SetBranchAddress("D0d1Lund",D0d1Lund);
  fChain->SetBranchAddress("D0d1Idx",D0d1Idx);
  fChain->SetBranchAddress("D0d2Lund",D0d2Lund);
  fChain->SetBranchAddress("D0d2Idx",D0d2Idx);
  fChain->SetBranchAddress("D0Chi2",D0Chi2);
  fChain->SetBranchAddress("D0nDof",D0nDof);

  fChain->SetBranchAddress("nPi",&nPi);
  fChain->SetBranchAddress("Pip3",Pip3);
  fChain->SetBranchAddress("PiLund",PiLund);
  fChain->SetBranchAddress("PiTrkIdx",PiTrkIdx);

  fChain->SetBranchAddress("nK",&nK);
  fChain->SetBranchAddress("Kp3",Kp3);
  fChain->SetBranchAddress("KLund",KLund);
  fChain->SetBranchAddress("KTrkIdx",KTrkIdx);

  fChain->SetBranchAddress("TRKnSvt",TRKnSvt);
  fChain->SetBranchAddress("TRKLund",TRKLund);
  fChain->SetBranchAddress("piSelectorsMap",PiSelectorsMap);

 
  if(Mode=="D0ToKPiPi0"){
    fChain->SetBranchAddress("D0d3Lund",D0d3Lund);
    fChain->SetBranchAddress("D0d3Idx",D0d3Idx);
    fChain->SetBranchAddress("nPi0",&nPi0);
    fChain->SetBranchAddress("Pi0Mass",Pi0Mass);
    fChain->SetBranchAddress("Pi0p3",Pi0p3);
    fChain->SetBranchAddress("Pi0Lund",Pi0Lund);
    fChain->SetBranchAddress("Pi0d1Lund",Pi0d1Lund);
    fChain->SetBranchAddress("Pi0d1Idx",Pi0d1Idx);
    fChain->SetBranchAddress("GammaLund",GammaLund);
    fChain->SetBranchAddress("GammaECal",GammaECal);
 
    if(TruthMatch){
      fChain->SetBranchAddress("Pi0MCIdx",Pi0MCIdx);    
      fChain->SetBranchAddress("GammaMCIdx", GammaMCIdx);
   
    }

  }
  if(Mode=="D0ToK3Pi"){
    fChain->SetBranchAddress("D0d3Lund",D0d3Lund);
    fChain->SetBranchAddress("D0d3Idx",D0d3Idx);
    fChain->SetBranchAddress("D0d4Lund",D0d4Lund);
    fChain->SetBranchAddress("D0d4Idx",D0d4Idx);
  }

  if(TruthMatch){
    fChain->SetBranchAddress("Ds1pMCIdx",Ds1pMCIdx);
    fChain->SetBranchAddress("DstarMCIdx",DstarMCIdx);
    fChain->SetBranchAddress("D0MCIdx",D0MCIdx);
    fChain->SetBranchAddress("KMCIdx",KMCIdx);
    fChain->SetBranchAddress("PiMCIdx",PiMCIdx);
    fChain->SetBranchAddress("mcLund",mcLund);
    fChain->SetBranchAddress("mcLen",&mcLen);
    fChain->SetBranchAddress("mcp3",mcp3);
    fChain->SetBranchAddress("mccosth",mccosth);
    fChain->SetBranchAddress("mcp3CM",mcp3CM);
    fChain->SetBranchAddress("mccosthCM",mccosthCM); 
  }
  
 
  //Histosgrams
  Float_t DstarMassWindow=.090;  
  Float_t D0MassWindow=.090;
  Float_t KsMassWindow=.030;
  Int_t NMassBins=62;
  Float_t Ds1pMassLo=2.470;  
  Float_t Ds1pMassHi=2.600;  
  Int_t NDs1pMassBins=70;


  //////Cuts
  ///Loose
  Float_t D0p3CMCut=0.;
  Float_t D0ProbabCut=0.;
  Float_t KsProbabCut=0.;
  Float_t KsCosineCut=0.;

  ///Define Signal Region
  Float_t Ds1pMassCutLo=0.;
  Float_t Ds1pMassCutHi=0.;
  Float_t Ds1pMassResolution=0.;
  //////////////
  

  if(Mode=="D0ToKPi"){
    //loose
    if(WhichCuts==1){       
      D0p3CMCut=2.4; 
      D0ProbabCut=5e-3; 
      KsProbabCut=5e-3; 
      KsCosineCut=0; 
    }
    Ds1pMassResolution=.009;
    Ds1pMassCutLo=Ds1pPDGMass-4*Ds1pMassResolution;
    Ds1pMassCutHi=Ds1pPDGMass+4*Ds1pMassResolution;

  }
  if(Mode=="D0ToKPiPi0"){
    //loose
    if(WhichCuts==1){       
      D0p3CMCut=2.2; 
      D0ProbabCut=5e-3; 
      KsProbabCut=5e-3; 
      KsCosineCut=0; 
    }
    Ds1pMassResolution=.013;
    Ds1pMassCutLo=Ds1pPDGMass-4*Ds1pMassResolution;
    Ds1pMassCutHi=Ds1pPDGMass+4*Ds1pMassResolution;

  }

  if(Mode=="D0ToK3Pi"){
    //loose
    if(WhichCuts==1){       
      D0p3CMCut=2.2; 
      D0ProbabCut=5e-3; 
      KsProbabCut=5e-3; 
      KsCosineCut=0; 
    }
    Ds1pMassResolution=.006;
    Ds1pMassCutLo=Ds1pPDGMass-4*Ds1pMassResolution;
    Ds1pMassCutHi=Ds1pPDGMass+4*Ds1pMassResolution;

  }
  

  //////////////  
  //BeamPlots  
  TH1F HBeamRadius;
  SetHistoXY(&HBeamRadius,"Beam R",100,0,.5,"R (cm)","Entries/50#mu m");
  
  TH1F HBeamZ;
  SetHistoXY(&HBeamZ,"Beam Z",100,-4.,4.,"Z (cm)","Entries/1mm");
   
  ////Kaon
  TH1F HKMomentum;
  SetHistoXY(&HKMomentum,"K Momentum ",80,0,8,"p (GeV/c)","Entries/100MeV");

  TH1F HKMomentumTruthMatched;
  SetHistoXY(&HKMomentumTruthMatched,"K Momentum ",80,0,8,"p (GeV/c)","Entries/100MeV");
  
  /////pion 
  TH1F HPiMomentum;
  SetHistoXY(&HPiMomentum," Pion Momentum ",80,0,8,"p (GeV/c)","Entries/100MeV");

  TH1F HPiMomentumTruthMatched;
  SetHistoXY(&HPiMomentumTruthMatched," Pion Momentum ",80,0,8,"p (GeV/c)","Entries/100MeV");

  ///////////Mode dependent histos
  ////////////Mode=="D0ToKPiPi0"
  ////Gamma
  TH1F HGammaEnergy;
  SetHistoXY(&HGammaEnergy,"Gamma Energy",30,0,1.2,"calor. energy (GeV/c^{2})","Entries/40MeV");

  TH1F HGammaEnergyTruthMatched;
  SetHistoXY(&HGammaEnergyTruthMatched,"Gamma Energy",30,0,1.2,"calor. energy (GeV/c^{2})","Entries/40MeV");
  
  ////Pi0 
  TH1F HPi0MassPreCuts;
  SetHistoXY(&HPi0MassPreCuts,"Pi0 Mass After Cuts ",120,.075,.195," mass (GeV/c^{2})","Entries/1MeV");

  TH1F HPi0Mass;
  SetHistoXY(&HPi0Mass,"Pi0 Mass After Cuts ",120,.075,.195," mass (GeV/c^{2})","Entries/1MeV");

  TH1F HPi0MassTruthMatched;
  SetHistoXY(&HPi0MassTruthMatched,"Pi0 Mass After Cuts ",120,.075,.195," mass (GeV/c^{2})","Entries/1MeV");
  
 
  /////D0 
  TH1F HD0p3CM;
  SetHistoXY(&HD0p3CM,"D0 CM Momentum ",80,0,8,"p* (GeV/c)","Entries/100MeV");

  TH1F HD0MassPreCuts;
  SetHistoXY(&HD0MassPreCuts,"D0 Mass Before Cuts",NMassBins,D0PDGMass-D0MassWindow-.001,D0PDGMass+D0MassWindow+.001,"D0 Cand. Mass (GeV/c^{2})","Entries/1MeV");

  TH1F HD0Mass;
  SetHistoXY(&HD0Mass,"D0 Mass After Cuts ",NMassBins,D0PDGMass-D0MassWindow-.001,D0PDGMass+D0MassWindow+.001,"D0 Cand. Mass (GeV/c^{2})","Entries/1MeV");

  TH1F HD0MassTruthMatched;
  SetHistoXY(&HD0MassTruthMatched,"D0 Mass After Cuts ",NMassBins,D0PDGMass-D0MassWindow-.001,D0PDGMass+D0MassWindow+.001,"D0 Cand. Mass (GeV/c^{2})","Entries/1MeV");

  TH1F HD0Probab;
  SetHisto(&HD0Probab,"D0 Vtx Probab ",200,-8,0,"log(p(#chi^{2}))");


  //slow pion
  TH1F HSlowPiMomentum;
  SetHistoXY(&HSlowPiMomentum,"Slow Pion Momentum ",30,0,1.2,"p (GeV/c)","Entries/40MeV");

  TH1F HSlowPiMomentumTruthMatched;
  SetHistoXY(&HSlowPiMomentumTruthMatched,"Slow Pion Momentum ",30,0,1.2,"p (GeV/c)","Entries/40MeV");

  ////Dstar
  TH1F HDstarMassPreCuts;
  SetHistoXY(&HDstarMassPreCuts,"D* Mass Before Cuts",NMassBins,DstarPDGMass-DstarMassWindow-.001,DstarPDGMass+DstarMassWindow+.001,"D* Cand. Mass (GeV/c^{2})","Entries/1MeV");
  HDstarMassPreCuts.SetLineColor(1);

  TH1F HDstarMass;
  SetHistoXY(&HDstarMass,"D* Mass After Cuts",NMassBins,DstarPDGMass-DstarMassWindow-.001,DstarPDGMass+DstarMassWindow+.001,"D* Cand. Mass (GeV/c^{2})","Entries/1MeV");
  HDstarMass.SetLineColor(1);
  
  TH1F HDstarMassTruthMatched;
  SetHistoXY(&HDstarMassTruthMatched,"D* Mass After Cuts and Truth Matched",NMassBins,DstarPDGMass-DstarMassWindow-.001,DstarPDGMass+DstarMassWindow+.001,"D* Cand. Mass (GeV/c^{2})","Entries/1MeV");
  HDstarMassTruthMatched.SetLineColor(1);

  TH1F HMassDiff;
  SetHistoXY(&HMassDiff,"#Delta M After Cuts",300,.139,.160,"D* Cand. Mass - D0 Cand. Mass (GeV/c^{2})","Entries/.1MeV");  


  /////pion1 
  TH1F HPi1Momentum;
  SetHistoXY(&HPi1Momentum," Pion1 Momentum ",100,0,2,"p (GeV/c)","Entries/20MeV");

  TH1F HPi1MomentumTruthMatched;
  SetHistoXY(&HPi1MomentumTruthMatched," Pion1 Momentum ",100,0,2,"p (GeV/c)","Entries/20MeV");

  /////Ks 
  TH1F HKsp3CM;
  SetHistoXY(&HKsp3CM,"Ks CM Momentum ",80,0,8,"p* (GeV/c)","Entries/100MeV");

  TH1F HKsMassPreCuts;
  SetHistoXY(&HKsMassPreCuts,"Ks Mass Before Cuts",NMassBins,K0PDGMass-KsMassWindow-.001,K0PDGMass+KsMassWindow+.001,"Ks Cand. Mass (GeV/c^{2})","Entries/1MeV");

  TH1F HKsMass;
  SetHistoXY(&HKsMass,"Ks Mass After Cuts ",NMassBins,K0PDGMass-KsMassWindow-.001,K0PDGMass+KsMassWindow+.001,"Ks Cand. Mass (GeV/c^{2})","Entries/1MeV");

  TH1F HKsMassTruthMatched;
  SetHistoXY(&HKsMassTruthMatched,"Ks Mass After Cuts ",NMassBins,K0PDGMass-KsMassWindow-.001,K0PDGMass+KsMassWindow+.001,"Ks Cand. Mass (GeV/c^{2})","Entries/1MeV");

  TH1F HKsCosine;
  SetHistoXY(&HKsCosine,"Ks Direction",100,-1.00001,1.00001,"cos(#theta)","Entries/.02");

  TH1F HKsProbab;
  SetHisto(&HKsProbab,"Ks Vtx Probab ",200,-8,0,"log(p(#chi^{2}))");

 
  ////Ds1p
  TH1F HDs1pMassPreCuts;
  SetHistoXY(&HDs1pMassPreCuts,"D'_{s1} Mass Before Cuts",NDs1pMassBins,Ds1pMassLo,Ds1pMassHi,"Ds1p Cand. Mass (GeV/c^{2})","Entries/1MeV");
  HDs1pMassPreCuts.SetLineColor(1);

  TH1F HDs1pMassPID;
  SetHistoXY(&HDs1pMassPID,"D'_{s1} Mass After Cuts",NDs1pMassBins,Ds1pMassLo,Ds1pMassHi,"Ds1p Cand. Mass (GeV/c^{2})","Entries/1MeV");
  HDs1pMassPID.SetLineColor(1);

  TH1F HDs1pMass;
  SetHistoXY(&HDs1pMass,"D'_{s1} Mass After Cuts",NDs1pMassBins,Ds1pMassLo,Ds1pMassHi,"Ds1p Cand. Mass (GeV/c^{2})","Entries/1MeV");
  HDs1pMass.SetLineColor(1);
  
  TH1F HDs1pMassSignal;
  SetHistoXY(&HDs1pMassSignal,"D'_{s1} Mass After Cuts",NDs1pMassBins,Ds1pMassLo,Ds1pMassHi,"Ds1p Cand. Mass (GeV/c^{2})","Entries/1MeV");
  HDs1pMassSignal.SetLineColor(1);

  TH1F HDs1pMassTruthMatched;
  SetHistoXY(&HDs1pMassTruthMatched,"D'_{s1} Mass After Cuts and Truth Matched",NDs1pMassBins,Ds1pMassLo,Ds1pMassHi,"Ds1p Cand. Mass (GeV/c^{2})","Entries/1MeV");
  HDs1pMassTruthMatched.SetLineColor(1);

  
  Float_t Ds1pp3CMmax=8;
  Float_t Ds1pp3CMmin=0;
  Int_t Ds1pp3CMNbins=80;
  if(TruthMatch){
    Ds1pp3CMmax=5;
    Ds1pp3CMmin=0;
    Ds1pp3CMNbins=50;
  }
  
  TH1F HDs1pp3CMPreCuts;
  SetHistoXY(&HDs1pp3CMPreCuts,"D's1 CM Momentum ",Ds1pp3CMNbins,Ds1pp3CMmin,Ds1pp3CMmax,"p* (GeV/c)","Entries/100MeV");

  TH1F HDs1pp3CM;
  SetHistoXY(&HDs1pp3CM,"D's1 CM Momentum ",Ds1pp3CMNbins,Ds1pp3CMmin,Ds1pp3CMmax,"p* (GeV/c)","Entries/100MeV");

  TH1F HDs1pp3CMPIDCut;
  SetHistoXY(&HDs1pp3CMPIDCut,"D's1 CM Momentum ",Ds1pp3CMNbins,Ds1pp3CMmin,Ds1pp3CMmax,"p* (GeV/c)","Entries/100MeV");
  HDs1pp3CMPIDCut.SetLineColor(2);

  TH1F HDs1pp3CMPIDCutD0PCut;
  SetHistoXY(&HDs1pp3CMPIDCutD0PCut,"D's1 CM Momentum ",Ds1pp3CMNbins,Ds1pp3CMmin,Ds1pp3CMmax,"p* (GeV/c)","Entries/100MeV");
  HDs1pp3CMPIDCutD0PCut.SetLineColor(3);

  TH1F HDs1pp3CMPIDCutD0PCutDeltaMCut;
  SetHistoXY(&HDs1pp3CMPIDCutD0PCutDeltaMCut,"D's1 CM Momentum ",Ds1pp3CMNbins,Ds1pp3CMmin,Ds1pp3CMmax,"p* (GeV/c)","Entries/100MeV");
  HDs1pp3CMPIDCutD0PCutDeltaMCut.SetLineColor(4);

  TH1F HDs1pp3CMPIDCutD0PCutDeltaMCutD0Probab;
  SetHistoXY(&HDs1pp3CMPIDCutD0PCutDeltaMCutD0Probab,"D's1 CM Momentum ",Ds1pp3CMNbins,Ds1pp3CMmin,Ds1pp3CMmax,"p* (GeV/c)","Entries/100MeV");
  HDs1pp3CMPIDCutD0PCutDeltaMCutD0Probab.SetLineColor(6);    


  TH1F HDs1pcosthCMPreCuts;
  SetHistoXY(&HDs1pcosthCMPreCuts,"D's1 Angular Distribution  ",100,-1,1,"cos(#theta)*","Entries/.02");

  TH1F HDs1pcosthCM;
  SetHistoXY(&HDs1pcosthCM,"D's1 Angular Distribution  ",100,-1,1,"cos(#theta)*","Entries/.02");

  TH1F HDs1pcosthCMPIDCut;
  SetHistoXY(&HDs1pcosthCMPIDCut,"D's1 Angular Distribution  ",100,-1,1,"cos(#theta)*","Entries/.02");
  HDs1pcosthCMPIDCut.SetLineColor(2);

  TH1F HDs1pcosthCMPIDCutD0PCut;
  SetHistoXY(&HDs1pcosthCMPIDCutD0PCut,"D's1 Angular Distribution  ",100,-1,1,"cos(#theta)*","Entries/.02");
  HDs1pcosthCMPIDCutD0PCut.SetLineColor(3);

  TH1F HDs1pcosthCMPIDCutD0PCutDeltaMCut;
  SetHistoXY(&HDs1pcosthCMPIDCutD0PCutDeltaMCut,"D's1 Angular Distribution  ",100,-1,1,"cos(#theta)*","Entries/.02");
  HDs1pcosthCMPIDCutD0PCutDeltaMCut.SetLineColor(4);

  TH1F HDs1pcosthCMPIDCutD0PCutDeltaMCutD0Probab;
  SetHistoXY(&HDs1pcosthCMPIDCutD0PCutDeltaMCutD0Probab,"D's1 Angular Distribution  ",100,-1,1,"cos(#theta)*","Entries/.02");
  HDs1pcosthCMPIDCutD0PCutDeltaMCutD0Probab.SetLineColor(6);
    
  TH2F H2Ds1pCMPvsTheta;
  SetHisto2D(&H2Ds1pCMPvsTheta," #theta* vs  p* ",Ds1pp3CMNbins,Ds1pp3CMmin,Ds1pp3CMmax,"p* (GeV/c)",100,-1,1,"cos(#theta)*","entries/(.01x100MeV)");


  /////////MC 
  TH1F HMCDs1pMass;
  SetHistoXY(&HMCDs1pMass,"MC D's1 Mass",NDs1pMassBins,Ds1pMassLo,Ds1pMassHi,"Ds1p Cand. Mass (GeV/c^{2})","Entries/1MeV");

  TH1F HMCDs1pp3CM;
  SetHistoXY(&HMCDs1pp3CM,"MC D's1 Momentum ",Ds1pp3CMNbins,Ds1pp3CMmin,Ds1pp3CMmax,"p* (GeV/c)","Entries/100MeV");

  TH1F HMCDs1pcosthCM;
  SetHistoXY(&HMCDs1pcosthCM,"MC D's1 Angular Distribution ",100,-1,1,"cos(#theta)*","Entries/.02");
  
  TH2F H2MCDs1pCMPvsTheta;
  SetHisto2D(&H2MCDs1pCMPvsTheta,"MC  #theta* vs p* ",Ds1pp3CMNbins,Ds1pp3CMmin,Ds1pp3CMmax,"p* (GeV/c)",100,-1,1,"cos(#theta*)","entries/(.02x100MeV)");


  TH1F HMCNDs1p;
  SetHistoXY(&HMCNDs1p,"MC Number of D's1 Generated",10,-.5,10.5,"nDs1p/event","Counts");
 
  //check particle id 
  TH1F HLundCheck;SetHisto(&HLundCheck,"Lund Id Check",15,-.5,14.5,"ParticleLund - LundExp");

  ////////+++++++++Important
  // Dstard1=D0,Dstard2=Pi;D0d1=K;D0d2=Pi
  //Lunds:

    
  
  //Start the event loop;
  Int_t eventid=0;
  while(fChain->GetEntry(eventid,0)>0){   
    eventid++;
    if(eventid%5000==0)cout<<eventid<<" Events done."<<endl;    
           
    HBeamRadius.Fill(sqrt( beamSX*beamSX + beamSY*beamSY));
    HBeamZ.Fill(beamSZ);     
         
    if(nDs1p>400){cout<<"Too many cands at event"<<eventid<<endl;continue;}
    ///Loop over the reconstructed
    Ds1pIdx=-1;
    while( Ds1pIdx< nDs1p-1){
      Ds1pIdx++;

      ////For Monte Carlo decide to analyze matter or antimatter
      if(!(Ds1pLund[Ds1pIdx]==MatterOrAntiMatter*myDs1pLund || MatterOrAntiMatter==0))continue;

      //Check that Im using proper indexes
      if(Mode=="D0ToKPi"||Mode=="D0ToK3Pi"){
	KsIdx=Ds1pd2Idx[Ds1pIdx];  
	KsPi1Idx=Ksd1Idx[KsIdx];
	KsPi2Idx=Ksd2Idx[KsIdx];    
	DstarIdx=Ds1pd1Idx[Ds1pIdx];
	SlowPiIdx=Dstard2Idx[DstarIdx];
	D0Idx=Dstard1Idx[DstarIdx];
	PiIdx=D0d2Idx[D0Idx];
	KIdx=D0d1Idx[D0Idx];

	PitrkIdx=PiTrkIdx[PiIdx];
	SlowPitrkIdx=PiTrkIdx[SlowPiIdx];
	KsPi1trkIdx=PiTrkIdx[KsPi1Idx];
	KsPi2trkIdx=PiTrkIdx[KsPi2Idx];

	if(abs(Dstard1Lund[DstarIdx]-D0Lund[D0Idx])>0)HLundCheck.Fill(1);
	else if(abs(Dstard2Lund[DstarIdx]-PiLund[SlowPiIdx])>0)HLundCheck.Fill(2);
	else if(abs(D0d1Lund[D0Idx]-KLund[KIdx])>0)HLundCheck.Fill(3);
	else if(abs(D0d2Lund[D0Idx]-PiLund[PiIdx])>0)HLundCheck.Fill(4);
	else if(abs(TRKLund[SlowPitrkIdx]-PiLund[SlowPiIdx])>0)HLundCheck.Fill(5);
	else if(abs(TRKLund[PitrkIdx]-PiLund[PiIdx])>0)HLundCheck.Fill(6);
	else if(abs(Ds1pd1Lund[Ds1pIdx]-DstarLund[DstarIdx])>0)HLundCheck.Fill(7);
	else if(abs(Ds1pd2Lund[Ds1pIdx]-KsLund[KsIdx])>0)HLundCheck.Fill(8);
	else if(abs(TRKLund[KsPi1trkIdx]-PiLund[KsPi1Idx])>0)HLundCheck.Fill(9);
	else if(abs(TRKLund[KsPi2trkIdx]-PiLund[KsPi2Idx])>0)HLundCheck.Fill(10);
	else if(abs(Ksd1Lund[KsIdx]-PiLund[KsPi1Idx])>0)HLundCheck.Fill(11);
	else if(abs(Ksd2Lund[KsIdx]-PiLund[KsPi2Idx])>0)HLundCheck.Fill(12);	
	else HLundCheck.Fill(0);
      }      


      if(Mode=="D0ToKPiPi0"){
	KsIdx=Ds1pd2Idx[Ds1pIdx]; 
	KsPi1Idx=Ksd1Idx[KsIdx];
	KsPi2Idx=Ksd2Idx[KsIdx]; 
	DstarIdx=Ds1pd1Idx[Ds1pIdx];
   	SlowPiIdx=Dstard2Idx[DstarIdx];
	D0Idx=Dstard1Idx[DstarIdx];
	PiIdx=D0d2Idx[D0Idx];
	KIdx=D0d1Idx[D0Idx];
	Pi0Idx=D0d3Idx[D0Idx];
	GammaIdx=Pi0d1Idx[Pi0Idx];

	PitrkIdx=PiTrkIdx[PiIdx];
	SlowPitrkIdx=PiTrkIdx[SlowPiIdx];
	KsPi1trkIdx=PiTrkIdx[KsPi1Idx];
	KsPi2trkIdx=PiTrkIdx[KsPi2Idx];


	if(abs(Dstard1Lund[DstarIdx]-D0Lund[D0Idx])>0)HLundCheck.Fill(1);
	else if(abs(Dstard2Lund[DstarIdx]-PiLund[SlowPiIdx])>0)HLundCheck.Fill(2);
	else if(abs(D0d1Lund[D0Idx]-KLund[KIdx])>0)HLundCheck.Fill(3);
	else if(abs(D0d2Lund[D0Idx]-PiLund[PiIdx])>0)HLundCheck.Fill(4);
	else if(abs(TRKLund[SlowPitrkIdx]-PiLund[SlowPiIdx])>0)HLundCheck.Fill(5);
	else if(abs(TRKLund[PitrkIdx]-PiLund[PiIdx])>0)HLundCheck.Fill(6);
	else if(abs(Ds1pd1Lund[Ds1pIdx]-DstarLund[DstarIdx])>0)HLundCheck.Fill(7);
	else if(abs(Ds1pd2Lund[Ds1pIdx]-KsLund[KsIdx])>0)HLundCheck.Fill(8);
	else if(abs(TRKLund[KsPi1trkIdx]-PiLund[KsPi1Idx])>0)HLundCheck.Fill(9);
	else if(abs(TRKLund[KsPi2trkIdx]-PiLund[KsPi2Idx])>0)HLundCheck.Fill(10);
	else if(abs(Ksd1Lund[KsIdx]-PiLund[KsPi1Idx])>0)HLundCheck.Fill(11);
	else if(abs(Ksd2Lund[KsIdx]-PiLund[KsPi2Idx])>0)HLundCheck.Fill(12);
	else if(abs(D0d3Lund[D0Idx]-Pi0Lund[Pi0Idx])>0)HLundCheck.Fill(13);
	else if(abs(Pi0d1Lund[Pi0Idx]-GammaLund[GammaIdx])>0)HLundCheck.Fill(14);	
	else HLundCheck.Fill(0);

      }


      ///compute some quantities
      D0Probab=TMath::Prob(D0Chi2[D0Idx],D0nDof[D0Idx]);     
      KsProbab=TMath::Prob(KsChi2[D0Idx],KsnDof[D0Idx]);     
         
      Ksp3Direction.SetXYZ(sin(acos(Kscosth[KsIdx]))*cos(Ksphi[KIdx]),
			   sin(acos(Kscosth[KsIdx]))*sin(Ksphi[KIdx]),
			   Kscosth[KsIdx]); 
      KsFlightDirection.SetXYZ(KsVtxx[KsIdx]-Ds1pVtxx[Ds1pIdx],
			       KsVtxy[KsIdx]-Ds1pVtxy[Ds1pIdx],
			       KsVtxz[KsIdx]-Ds1pVtxz[Ds1pIdx]);
      KsCosine=Ksp3Direction*KsFlightDirection/KsFlightDirection.Mag();

      ///Fill Distributions  
      if(Mode=="D0ToKPiPi0"){        
	HPi0MassPreCuts.Fill(Pi0Mass[Pi0Idx]);  
      }

      HD0p3CM.Fill(D0p3CM[D0Idx]);
      HD0MassPreCuts.Fill(D0Mass[D0Idx]);
      HD0Probab.Fill(log(D0Probab));

      HDstarMassPreCuts.Fill(DstarMass[DstarIdx]);   

      HKsMassPreCuts.Fill(KsMass[KsIdx]);
      HKsProbab.Fill(log(KsProbab));
      HKsCosine.Fill(KsCosine);

      HDs1pMassPreCuts.Fill(Ds1pMass[Ds1pIdx]);  


      //Apply Cuts       
      //     if((PiSelectorsMap[KsPi1trkIdx] & (1<<4) ) != 0 && (PiSelectorsMap[KsPi2trkIdx] & (1<<4) ) != 0){
      //	HDs1pMassPID.Fill(Ds1pMass[Ds1pIdx]);

      if(D0p3CM[D0Idx] > D0p3CMCut){
	if(D0Probab > D0ProbabCut){
	  if(KsProbab > KsProbabCut && KsCosine>KsCosineCut){

	    HDs1pMass.Fill(Ds1pMass[Ds1pIdx]);

	    ///Fill histograms only for the signal region of Ds1p
	    if(Ds1pMassCutLo<Ds1pMass[Ds1pIdx]&&Ds1pMass[Ds1pIdx]<Ds1pMassCutHi){

	      HDs1pMassSignal.Fill(Ds1pMass[Ds1pIdx]);
	      if(Ds1pMCIdx[Ds1pIdx]>0){
		HDs1pMassTruthMatched.Fill(Ds1pMass[Ds1pIdx]); 	
		HDs1pp3CM.Fill(Ds1pp3CM[Ds1pIdx]); 
		HDs1pcosthCM.Fill(Ds1pcosthCM[Ds1pIdx]); 		  
		H2Ds1pCMPvsTheta.Fill(Ds1pp3CM[Ds1pIdx],Ds1pcosthCM[Ds1pIdx]);	
	      }	  
	  
	      HKsMass.Fill(KsMass[KsIdx]);	   
	      if(KsMCIdx[KsIdx]>0){
		HKsMassTruthMatched.Fill(KsMass[KsIdx]); 		
	      }
	  
	      HPi1Momentum.Fill(Pip3[KsPi1Idx]);
	      if(PiMCIdx[KsPi1Idx]>0)
		HPi1MomentumTruthMatched.Fill(Pip3[KsPi1Idx]);	

	      HDstarMass.Fill(DstarMass[DstarIdx]); 		  
	      if(DstarMCIdx[DstarIdx]>0){
		HDstarMassTruthMatched.Fill(DstarMass[DstarIdx]); 		
	      }	  
	      HMassDiff.Fill(DstarMass[DstarIdx]-D0Mass[D0Idx]);   

	  
	      HD0Mass.Fill(D0Mass[D0Idx]); 
	      if(D0MCIdx[D0Idx]>0)
		HD0MassTruthMatched.Fill(D0Mass[D0Idx]); 

	      HSlowPiMomentum.Fill(Pip3[SlowPiIdx]);	
	      if(PiMCIdx[SlowPiIdx]>0)
		HSlowPiMomentumTruthMatched.Fill(Pip3[SlowPiIdx]);	    

	      HKMomentum.Fill(Kp3[KIdx]);
	      if(KMCIdx[KIdx]>0)
		HKMomentumTruthMatched.Fill(Kp3[KIdx]);

	      HPiMomentum.Fill(Pip3[PiIdx]);
	      if(PiMCIdx[PiIdx]>0)
		HPiMomentumTruthMatched.Fill(Pip3[PiIdx]);	

	      if(Mode=="D0ToKPiPi0"){ 
		HGammaEnergy.Fill(GammaECal[GammaIdx]);
		if(GammaMCIdx[GammaIdx]>0)
		  HGammaEnergyTruthMatched.Fill(GammaECal[GammaIdx]);

		HPi0Mass.Fill(Pi0Mass[Pi0Idx]);
		if(Pi0MCIdx[Pi0Idx]>0)
		  HPi0MassTruthMatched.Fill(Pi0Mass[Pi0Idx]);
	      }
	 

	      RecoDs1pCounterTotal++;
	    }//signal region
	  }//Ks Cuts
	}//D0Probab Cut     
      }//D0 p* cut  
      
    }//Ds1p loop
	 

    //now loop over MC    
    MCDs1pCounterPerEvent=0; 
    Int_t mcid=-1;
    while(mcid<mcLen){
      mcid++;

      if(mcLund[mcid]==MatterOrAntiMatter*myDs1pLund){
	MCDs1pCounterPerEvent++; 
	MCDs1pCounterTotal++;
		
	HMCDs1pMass.Fill(mcmass[mcid]);
	HMCDs1pp3CM.Fill(mcp3CM[mcid]); 
	HMCDs1pcosthCM.Fill(mccosthCM[mcid]); 	
	H2MCDs1pCMPvsTheta.Fill(mcp3CM[mcid],mccosthCM[mcid]);
      }
    }
    HMCNDs1p.Fill(MCDs1pCounterPerEvent);
        
  }

  //print summary
  cout<<"--------Summary-------"<<endl;
  cout<<"Total events="<<eventid<<endl;
  cout<<"Total Generated="<<MCDs1pCounterTotal<<" Reconstructed="<<RecoDs1pCounterTotal<<endl;
  cout<<"--------End Summary---"<<endl;

 
  ////Save histograms
  TString filename;
  filename=NtupleDir+"/"+"Plots.ps";
  TCanvas Canvas(filename,filename);
  Canvas.Print(filename+"[");

  TLine cutline;
  cutline.SetLineColor(2);

  //beam
  Canvas.Clear();
  HBeamRadius.Draw();
  Canvas.Print(filename);
  Canvas.Clear();
  HBeamZ.Draw();
  Canvas.Print(filename);    

  ///The Kaon 
  Canvas.Clear();
  HKMomentum.Draw();
  Canvas.Print(filename);
  TH1F* HKMomentumTruthDifference=(TH1F*)HKMomentum.Clone();
  HKMomentumTruthDifference->Add(&HKMomentumTruthMatched,-1.);
  HKMomentumTruthDifference->SetTitle("Truth Difference");
  HKMomentumTruthDifference->Draw();
  Canvas.Print(filename);

  //ThePion
  Canvas.Clear();
  HPiMomentum.Draw();
  Canvas.Print(filename);
  Canvas.Clear();
  TH1F* HPiMomentumTruthDifference=(TH1F*)HPiMomentum.Clone();
  HPiMomentumTruthDifference->Add(&HPiMomentumTruthMatched,-1.);
  HPiMomentumTruthDifference->SetTitle("Truth Difference");
  HPiMomentumTruthDifference->Draw();
  Canvas.Print(filename);

  
  if(Mode=="D0ToKPiPi0"){ 
    ///Gamma
    Canvas.Clear();
    HGammaEnergy.Draw();
    Canvas.Print(filename);
    Canvas.Clear();
    TH1F* HGammaEnergyTruthDifference=(TH1F*)HGammaEnergy.Clone();
    HGammaEnergyTruthDifference->Add(&HGammaEnergyTruthMatched,-1.);
    HGammaEnergyTruthDifference->SetTitle("Truth Difference");
    HGammaEnergyTruthDifference->Draw();
    Canvas.Print(filename);

    //The Pi0
    Canvas.Clear();
    HPi0MassPreCuts.GetYaxis()->SetRangeUser(0,1.05*HPi0MassPreCuts.GetMaximum());
    HPi0MassPreCuts.Draw();
    HPi0Mass.Draw("same");
    Canvas.Print(filename);
    Canvas.Clear();
    TH1F* HPi0MassTruthDifference=(TH1F*)HPi0Mass.Clone();
    HPi0MassTruthDifference->Add(&HPi0MassTruthMatched,-1.);
    HPi0MassTruthDifference->SetTitle("Truth Difference");
    HPi0MassTruthDifference->Draw();
    Canvas.Print(filename);

  }

  //The D0 
  Canvas.Clear();
  HD0p3CM.Draw();
  cutline.DrawLine(D0p3CMCut,0,D0p3CMCut, HD0p3CM.GetMaximum());
  Canvas.Print(filename);
  Canvas.Clear();
  HD0MassPreCuts.GetYaxis()->SetRangeUser(0,1.05*HD0MassPreCuts.GetMaximum());
  HD0MassPreCuts.Draw();
  HD0Mass.Draw("same");
  Canvas.Print(filename);
  Canvas.Clear();
  TH1F* HD0MassTruthDifference=(TH1F*)HD0Mass.Clone();
  HD0MassTruthDifference->Add(&HD0MassTruthMatched,-1.);
  HD0MassTruthDifference->SetTitle("Truth Difference");
  HD0MassTruthDifference->Draw();
  Canvas.Print(filename);

  ///The Slow Pion
  Canvas.Clear();
  HSlowPiMomentum.Draw();
  Canvas.Print(filename);
  Canvas.Clear();
  TH1F* HSlowPiMomentumTruthDifference=(TH1F*)HSlowPiMomentum.Clone();
  HSlowPiMomentumTruthDifference->Add(&HSlowPiMomentumTruthMatched,-1.);
  HSlowPiMomentumTruthDifference->SetTitle("Truth Difference");
  HSlowPiMomentumTruthDifference->Draw();
  Canvas.Print(filename);


  ///The Dstar
  Canvas.Clear();
  HDstarMassPreCuts.GetYaxis()->SetRangeUser(0,1.05*HDstarMassPreCuts.GetMaximum());
  HDstarMassPreCuts.Draw();
  HDstarMass.Draw("same");
  //HDstarMassTruthMatched.Draw("same");
  Canvas.Print(filename); 
  Canvas.Clear();
  TH1F* HDstarMassTruthDifference=(TH1F*)HDstarMass.Clone();
  HDstarMassTruthDifference->Add(&HDstarMassTruthMatched,-1.);
  HDstarMassTruthDifference->SetTitle("Truth Difference");
  HDstarMassTruthDifference->Draw();
  Canvas.Print(filename);
  Canvas.Clear();
  HMassDiff.Draw();
  Canvas.Print(filename);


  //Pi1 and Pi2
  Canvas.Clear();
  HPi1Momentum.Draw();
  Canvas.Print(filename);
  Canvas.Clear();
  TH1F* HPi1MomentumTruthDifference=(TH1F*)HPi1Momentum.Clone();
  HPi1MomentumTruthDifference->Add(&HPi1MomentumTruthMatched,-1.);
  HPi1MomentumTruthDifference->SetTitle("Truth Difference");
  HPi1MomentumTruthDifference->Draw();
  Canvas.Print(filename);


  //Ks  
  Canvas.Clear();
  HKsProbab.Draw();
  Canvas.Print(filename); 
  Canvas.Clear();
  Canvas.SetLogy(1);
  HKsCosine.Draw();
  Canvas.Print(filename); 
  Canvas.SetLogy(0);
  Canvas.Clear();
  HKsMassPreCuts.GetYaxis()->SetRangeUser(0,1.05*HKsMassPreCuts.GetMaximum());
  HKsMassPreCuts.Draw();
  HKsMass.Draw("same");  
  //HKsMassTruthMatched.Draw("same");
  Canvas.Print(filename); 
  Canvas.Clear();
  TH1F* HKsMassTruthDifference=(TH1F*)HKsMass.Clone();
  HKsMassTruthDifference->Add(&HKsMassTruthMatched,-1.);
  HKsMassTruthDifference->SetTitle("Truth Difference");
  HKsMassTruthDifference->Draw();
  Canvas.Print(filename);


  //Ds1p
  Canvas.Clear();
  HDs1pMassPreCuts.GetYaxis()->SetRangeUser(0,1.05*HDs1pMassPreCuts.GetMaximum());
  HDs1pMassPreCuts.Draw();
  HDs1pMassPID.Draw("same");  
  HDs1pMass.Draw("same");
  cutline.DrawLine(Ds1pMassCutLo,0,Ds1pMassCutLo,HDs1pMass.GetMaximum());
  cutline.DrawLine(Ds1pMassCutHi,0,Ds1pMassCutHi,HDs1pMass.GetMaximum());  
  Canvas.Print(filename); 
  Canvas.Clear();
  Canvas.Divide(2,2);
  Canvas.cd(1);
  HDs1pMassSignal.Draw();
  HDs1pMassTruthMatched.Draw("same");
  Canvas.cd(2);
  TH1F* HDs1pMassTruthDifference=(TH1F*)HDs1pMassSignal.Clone();
  HDs1pMassTruthDifference->Add(&HDs1pMassTruthMatched,-1.);
  HDs1pMassTruthDifference->SetTitle("Truth Difference");
  HDs1pMassTruthDifference->Draw();
  Canvas.cd(3);
  TH1F* HDs1pMassTruthRatio=(TH1F*)HDs1pMassTruthMatched.Clone();
  HDs1pMassTruthRatio->Divide(&HDs1pMassSignal);
  HDs1pMassTruthRatio->SetTitle("Truth Ratio"); 
  HDs1pMassTruthRatio->GetYaxis()->SetTitle("TruthMatched/Reconstructed");
  HDs1pMassTruthRatio->Draw();
  Canvas.Print(filename);


  Canvas.Clear();
  if(TruthMatch){
    HMCDs1pp3CM.GetYaxis()->SetRangeUser(0,1.05*HMCDs1pp3CM.GetMaximum());
    HMCDs1pp3CM.Draw();  
    HDs1pp3CMPreCuts.Draw("same");
  }else {
    HDs1pp3CMPreCuts.GetYaxis()->SetRangeUser(1,1.05*HDs1pp3CMPreCuts.GetMaximum());
    HDs1pp3CMPreCuts.Draw();
  }       
  HDs1pp3CMPIDCut.Draw("same");
  HDs1pp3CMPIDCutD0PCut.Draw("same");
  HDs1pp3CMPIDCutD0PCutDeltaMCut.Draw("same");
  HDs1pp3CMPIDCutD0PCutDeltaMCutD0Probab.Draw("same");
  HDs1pp3CM.Draw("same");
  Canvas.Print(filename);

  //For bins were MC is less than 100 set efficiency to 0
  for(Int_t bin=0;bin<=HMCDs1pp3CM.GetNbinsX();bin++)
    if(HMCDs1pp3CM.GetBinContent(bin)<100)
      HMCDs1pp3CM.SetBinContent(bin,1e30);  

  Canvas.Clear();  
  TH1F HDs1pp3CMEfficiency0=*(TH1F*)HDs1pp3CMPreCuts.Clone();
  HDs1pp3CMEfficiency0.Divide(&HMCDs1pp3CM);
  HDs1pp3CMEfficiency0.SetTitle("CM Momentum Efficiency");
  HDs1pp3CMEfficiency0.GetYaxis()
    //->SetRangeUser(0,1.05*HDs1pp3CMEfficiency0.GetBinContent(HDs1pp3CMEfficiency0.GetMaximumBin()));
    ->SetRangeUser(0,1);
  HDs1pp3CMEfficiency0.Draw();
//   TH1F HDs1pp3CMEfficiency1=*(TH1F*)HDs1pp3CMPIDCut.Clone();
//   HDs1pp3CMEfficiency1.Divide(&HMCDs1pp3CM);
//   HDs1pp3CMEfficiency1.Draw("same");
//   TH1F HDs1pp3CMEfficiency2=*(TH1F*)HDs1pp3CMPIDCutD0PCut.Clone();
//   HDs1pp3CMEfficiency2.Divide(&HMCDs1pp3CM);
//   HDs1pp3CMEfficiency2.Draw("same");
//   TH1F HDs1pp3CMEfficiency3=*(TH1F*)HDs1pp3CMPIDCutD0PCutDeltaMCut.Clone();
//   HDs1pp3CMEfficiency3.Divide(&HMCDs1pp3CM);
//   HDs1pp3CMEfficiency3.Draw("same");
//   TH1F HDs1pp3CMEfficiency4=*(TH1F*)HDs1pp3CMPIDCutD0PCutDeltaMCutD0Probab.Clone();
//   HDs1pp3CMEfficiency4.Divide(&HMCDs1pp3CM);
//   HDs1pp3CMEfficiency4.Draw("same");  
  TH1F HDs1pp3CMEfficiencyFinal=*(TH1F*)HDs1pp3CM.Clone();
  HDs1pp3CMEfficiencyFinal.Divide(&HMCDs1pp3CM);  
  HDs1pp3CMEfficiencyFinal.Draw("same");
  Canvas.Print(filename);
  
  Canvas.Clear();
  if(TruthMatch){
    HMCDs1pcosthCM.GetYaxis()->SetRangeUser(0,1.05*HMCDs1pcosthCM.GetMaximum());
    HMCDs1pcosthCM.Draw();  
    HDs1pcosthCMPreCuts.Draw("same");
  }else {
    HDs1pcosthCMPreCuts.GetYaxis()->SetRangeUser(1,1.05*HDs1pcosthCMPreCuts.GetMaximum());
    HDs1pcosthCMPreCuts.Draw();
  }       
//   HDs1pcosthCMPIDCut.Draw("same");
//   HDs1pcosthCMPIDCutD0PCut.Draw("same");
//   HDs1pcosthCMPIDCutD0PCutDeltaMCut.Draw("same");
//   HDs1pcosthCMPIDCutD0PCutDeltaMCutD0Probab.Draw("same");
  HDs1pcosthCM.Draw("same");
  Canvas.Print(filename);
  
  Canvas.Clear();  
  TH1F HDs1pcosthCMEfficiency0=*(TH1F*)HDs1pcosthCMPreCuts.Clone();
  HDs1pcosthCMEfficiency0.Divide(&HMCDs1pcosthCM);
  HDs1pcosthCMEfficiency0.SetTitle("Angular Efficiency");
  HDs1pcosthCMEfficiency0.GetYaxis()
    //->SetRangeUser(0,1.05*HDs1pcosthCMEfficiency0.GetBinContent(HDs1pcosthCMEfficiency0.GetMaximumBin()));
    ->SetRangeUser(0,1);
  HDs1pcosthCMEfficiency0.Draw();
//   TH1F HDs1pcosthCMEfficiency1=*(TH1F*)HDs1pcosthCMPIDCut.Clone();
//   HDs1pcosthCMEfficiency1.Divide(&HMCDs1pcosthCM);
//   HDs1pcosthCMEfficiency1.Draw("same");
//   TH1F HDs1pcosthCMEfficiency2=*(TH1F*)HDs1pcosthCMPIDCutD0PCut.Clone();
//   HDs1pcosthCMEfficiency2.Divide(&HMCDs1pcosthCM);
//   HDs1pcosthCMEfficiency2.Draw("same");
//   TH1F HDs1pcosthCMEfficiency3=*(TH1F*)HDs1pcosthCMPIDCutD0PCutDeltaMCut.Clone();
//   HDs1pcosthCMEfficiency3.Divide(&HMCDs1pcosthCM);
//   HDs1pcosthCMEfficiency3.Draw("same");
//   TH1F HDs1pcosthCMEfficiency4=*(TH1F*)HDs1pcosthCMPIDCutD0PCutDeltaMCutD0Probab.Clone();
//   HDs1pcosthCMEfficiency4.Divide(&HMCDs1pcosthCM);
//   HDs1pcosthCMEfficiency4.Draw("same");  
  TH1F HDs1pcosthCMEfficiencyFinal=*(TH1F*)HDs1pcosthCM.Clone();
  HDs1pcosthCMEfficiencyFinal.Divide(&HMCDs1pcosthCM);  
  HDs1pcosthCMEfficiencyFinal.Draw("same");
  Canvas.Print(filename);

  Canvas.Clear();
  H2Ds1pCMPvsTheta.Draw("colz");
  Canvas.Print(filename);
  Canvas.Clear();
  H2MCDs1pCMPvsTheta.Draw("colz");
  Canvas.Print(filename);
  Canvas.Clear();
  //For bins were MC is less than 5 set efficiency to 0
  for(Int_t binx=0;binx<=H2MCDs1pCMPvsTheta.GetNbinsX();binx++)
    for(Int_t biny=0;biny<=H2MCDs1pCMPvsTheta.GetNbinsY();biny++)
      if(H2MCDs1pCMPvsTheta.GetBinContent(binx,biny)<20)
	H2MCDs1pCMPvsTheta.SetBinContent(binx,biny,1e30); 

  TH2F H2Ds1pPvsThetaEfficiency=*(TH2F*)H2Ds1pCMPvsTheta.Clone();
  H2Ds1pPvsThetaEfficiency.Divide(&H2MCDs1pCMPvsTheta);
  H2Ds1pPvsThetaEfficiency.SetTitle("D* Efficiency");
  H2Ds1pPvsThetaEfficiency.GetZaxis()->SetTitle("efficiency");
  H2Ds1pPvsThetaEfficiency.SetTitleOffset(.68,"Z");
  H2Ds1pPvsThetaEfficiency.SetStats(kFALSE);
  H2Ds1pPvsThetaEfficiency.Draw("colz");
  Canvas.Print(filename);





  ///Make plot of TruthMatched vs particle: 
  Float_t KTruthRatio=0;
  Float_t PiTruthRatio=0;
  Float_t GammaTruthRatio=0;
  Float_t Pi0TruthRatio=0;
  Float_t D0TruthRatio=0;
  Float_t SlowPiTruthRatio=0;
  Float_t DstarTruthRatio=0;
  Float_t Pi1TruthRatio=0;
  Float_t KsTruthRatio=0;
  Float_t Ds1pTruthRatio=0;

  if(HKMomentum.Integral()>0) KTruthRatio=HKMomentumTruthMatched.Integral()/HKMomentum.Integral();
  if(HPiMomentum.Integral()>0) PiTruthRatio=HPiMomentumTruthMatched.Integral()/HPiMomentum.Integral();
  if(HGammaEnergy.Integral()>0) GammaTruthRatio=HPiMomentumTruthMatched.Integral()/HPiMomentum.Integral();
  if(HPi0Mass.Integral()>0) Pi0TruthRatio=HPi0MassTruthMatched.Integral()/HPi0Mass.Integral();
  if(HD0Mass.Integral()>0) D0TruthRatio=HD0MassTruthMatched.Integral()/HD0Mass.Integral();
  if(HSlowPiMomentum.Integral()>0) SlowPiTruthRatio=HSlowPiMomentumTruthMatched.Integral()/HSlowPiMomentum.Integral();
  if(HDstarMass.Integral()>0) DstarTruthRatio=HDstarMassTruthMatched.Integral()/HDstarMass.Integral();
  if(HPi1Momentum.Integral()>0) Pi1TruthRatio=HPi1MomentumTruthMatched.Integral()/HPi1Momentum.Integral();
  if(HKsMass.Integral()>0) KsTruthRatio=HKsMassTruthMatched.Integral()/HKsMass.Integral();
  if(HDs1pMass.Integral()>0) Ds1pTruthRatio=HDs1pMassTruthMatched.Integral()/HDs1pMassSignal.Integral();
  

  TH1F HTruthRatioVsParticle;
  SetHistoXY(&HTruthRatioVsParticle,"Truth Match Ratios",10,.5,10.5,"Particle Type","TruthMatched/Reconstructed");
  HTruthRatioVsParticle.SetBinContent(1,KTruthRatio);
  HTruthRatioVsParticle.SetBinContent(2,PiTruthRatio);
  HTruthRatioVsParticle.SetBinContent(3,GammaTruthRatio);
  HTruthRatioVsParticle.SetBinContent(4,Pi0TruthRatio); 
  HTruthRatioVsParticle.SetBinContent(5,D0TruthRatio);
  HTruthRatioVsParticle.SetBinContent(6,SlowPiTruthRatio);
  HTruthRatioVsParticle.SetBinContent(7,DstarTruthRatio); 
  HTruthRatioVsParticle.SetBinContent(8,PiTruthRatio);   
  HTruthRatioVsParticle.SetBinContent(9,KsTruthRatio); 
  HTruthRatioVsParticle.SetBinContent(10,Ds1pTruthRatio); 
  HTruthRatioVsParticle.GetYaxis()->SetRangeUser(0,1);
  HTruthRatioVsParticle.SetStats(kFALSE);
  HTruthRatioVsParticle.SetBarWidth(.9);
  
  TText text;
  text.SetTextSize(.03);

  Canvas.Clear();
  HTruthRatioVsParticle.Draw("b");
  text.DrawText(1-.2,.1,"K");
  text.DrawText(2-.2,.1,"Pi");
  text.DrawText(3-.4,.1,"Gamma");
  text.DrawText(4-.2,.1,"Pi0");
  text.DrawText(5-.2,.1,"D0");
  text.DrawText(6-.4,.1,"SlowPi");
  text.DrawText(7-.2,.1,"D*");
  text.DrawText(8-.2,.1,"Pi1");
  text.DrawText(9-.2,.1,"Ks");
  text.DrawText(10-.2,.1,"Ds1");
  text.DrawText(1-.35,KTruthRatio*.9,TString("")+long(100*KTruthRatio)+"."+long(1000*KTruthRatio)%10+"%");
  text.DrawText(2-.35,PiTruthRatio*.9,TString("")+long(100*PiTruthRatio)+"."+long(1000*PiTruthRatio)%10+"%");
  text.DrawText(3-.35,GammaTruthRatio*.9,TString("")+long(100*GammaTruthRatio)+"."+long(1000*GammaTruthRatio)%10+"%");
  text.DrawText(4-.35,Pi0TruthRatio*.9,TString("")+long(100*Pi0TruthRatio)+"."+long(1000*Pi0TruthRatio)%10+"%");
  text.DrawText(5-.35,D0TruthRatio*.9,TString("")+long(100*D0TruthRatio)+"."+long(1000*D0TruthRatio)%10+"%");
  text.DrawText(6-.35,SlowPiTruthRatio*.9,TString("")+long(100*SlowPiTruthRatio)+"."+long(1000*SlowPiTruthRatio)%10+"%");
  text.DrawText(7-.35,DstarTruthRatio*.9,TString("")+long(100*DstarTruthRatio)+"."+long(1000*DstarTruthRatio)%10+"%");
  text.DrawText(8-.35,Pi1TruthRatio*.9,TString("")+long(100*Pi1TruthRatio)+"."+long(1000*Pi1TruthRatio)%10+"%");
  text.DrawText(9-.35,KsTruthRatio*.9,TString("")+long(100*KsTruthRatio)+"."+long(1000*KsTruthRatio)%10+"%");
  text.DrawText(10-.35,Ds1pTruthRatio*.9,TString("")+long(100*Ds1pTruthRatio)+"."+long(1000*Ds1pTruthRatio)%10+"%");
  Canvas.Print(filename);

  Canvas.Clear(); 
  HLundCheck.SetBarOffset(0);
  HLundCheck.SetBarWidth(.05);
  HLundCheck.Draw();
  Canvas.Print(filename);
   

  Canvas.Print(filename+"]");  
  return (TH1F*) HMassDiff.Clone(); 
}
Ejemplo n.º 14
0
void boostcontrolplots( TDirectory *boostdir ) {

   const Int_t nPlots = 4;

   Int_t width  = 900;
   Int_t height = 900;
   char cn[100];
   const TString titName = boostdir->GetName();
   sprintf( cn, "cv_%s", titName.Data() );
   TCanvas *c = new TCanvas( cn,  Form( "%s Control Plots", titName.Data() ),
                             width, height ); 
   c->Divide(2,3);


   const TString titName = boostdir->GetName();

   TString hname[nPlots]={"Booster_BoostWeight","Booster_MethodWeight","Booster_ErrFraction","Booster_OrigErrFraction"};

   for (Int_t i=0; i<nPlots; i++){
      Int_t color = 4; 
      TPad * cPad = (TPad*)c->cd(i+1);
      TH1 *h = (TH1*) boostdir->Get(hname[i]);
      TString plotname = h->GetName();
      h->SetMaximum(h->GetMaximum()*1.3);
      h->SetMinimum( 0 );
      h->SetMarkerColor(color);
      h->SetMarkerSize( 0.7 );
      h->SetMarkerStyle( 24 );
      h->SetLineWidth(2);
      h->SetLineColor(color);
      h->Draw();
      c->Update();
   }

   // draw combined ROC plots

   TString hname_roctest[2] ={"Booster_ROCIntegral_test",  "Booster_ROCIntegralBoosted_test"};
   TString hname_roctrain[2]={"Booster_ROCIntegral_train", "Booster_ROCIntegralBoosted_train"};
   TString htitle[2] = {"ROC integral of single classifier", "ROC integral of boosted method"}

   for (Int_t i=0; i<2; i++){
      Int_t color = 4; 
      TPad * cPad = (TPad*)c->cd(nPlots+i+1);
      TH1 *htest  = (TH1*) boostdir->Get(hname_roctest[i]);
      TH1 *htrain = (TH1*) boostdir->Get(hname_roctrain[i]);

      // check if filled 
      Bool_t histFilled = (htest->GetMaximum() > 0 || htrain->GetMaximum() > 0);

      htest->SetTitle(htitle[i]);
      htest->SetMaximum(1.0);
      htest->SetMinimum(0.0);
      htest->SetMarkerColor(color);
      htest->SetMarkerSize( 0.7 );
      htest->SetMarkerStyle( 24 );
      htest->SetLineWidth(2);
      htest->SetLineColor(color);
      htest->Draw();
      htrain->SetMaximum(1.0);
      htrain->SetMinimum(0.0);
      htrain->SetMarkerColor(color-2);
      htrain->SetMarkerSize( 0.7 );
      htrain->SetMarkerStyle( 24 );
      htrain->SetLineWidth(2);
      htrain->SetLineColor(color-2);
      htrain->Draw("same");

      if (histFilled) {
         TLegend *legend= new TLegend( cPad->GetLeftMargin(), 
                                       0.2 + cPad->GetBottomMargin(),
                                       cPad->GetLeftMargin() + 0.6, 
                                       cPad->GetBottomMargin() );
         legend->AddEntry(htest,  TString("testing sample"),  "L");
         legend->AddEntry(htrain, TString("training sample (orig. weights)"), "L");
         legend->SetFillStyle( 1 );
         legend->SetBorderSize(1);
         legend->SetMargin( 0.3 );
         legend->Draw("same");
      }
      else {
         TText* t = new TText();
         t->SetTextSize( 0.056 );
         t->SetTextColor( 2 );
         t->DrawText( 1, 0.6, "Use MethodBoost option: \"DetailedMonitoring\" " );        
         t->DrawText( 1, 0.51, "to fill this histograms" );        
      }

      c->Update();
   }

   // write to file
   TString fname = Form( "plots/%s_ControlPlots", titName.Data() );
   TMVAGlob::imgconv( c, fname );
   
}
Ejemplo n.º 15
0
Archivo: file.C Proyecto: MycrofD/root
void file(){

   TCanvas *c1 = new TCanvas("c1","ROOT File description",200,10,700,550);

   c1->Range(0,-0.25,21,14);
   TPaveLabel *title = new TPaveLabel(5,12,15,13.7,c1->GetTitle());
   title->SetFillColor(16);
   title->Draw();

   // horizonthal file layout
   TPave *file = new TPave(1,8.5,20,11);
   file->SetFillColor(11);
   file->Draw();
   TPave *fileh = new TPave(1,8.5,2.5,11);
   fileh->SetFillColor(44);
   fileh->Draw();
   TPave *lrh = new TPave(2.5,8.5,3.3,11,1);
   lrh->SetFillColor(33);
   lrh->Draw();
   lrh->DrawPave(6.9,8.5,7.7,11,1);
   lrh->DrawPave(10.5,8.5,11.3,11,1);
   lrh->DrawPave(14.5,8.5,15.3,11,1);
   TLine *ldot = new TLine(1,8.5,0.5,6.5);
   ldot->SetLineStyle(2);
   ldot->Draw();
   ldot->DrawLine(2.5, 8.5, 9.4, 6.5);
   ldot->DrawLine(10.5, 8.5, 10, 6.5);
   ldot->DrawLine(11.3, 8.5, 19.5, 6.5);
   TLine *line = new TLine(2.6,11,2.6,11.5);
   line->Draw();
   line->DrawLine(2.6,11.5,7,11.5);
   TArrow *arrow = new TArrow(7,11.5,7,11.1,0.01,"|>");
   arrow->SetFillStyle(1001);
   arrow->Draw();
   line->DrawLine( 7, 8.5, 7, 8.0);
   line->DrawLine( 7, 8.0, 10.6, 8);
   arrow->DrawArrow( 10.6,8, 10.6, 8.4,0.01,"|>");
   line->DrawLine( 10.6, 11, 10.6, 11.5);
   line->DrawLine( 10.6, 11.5, 14.6, 11.5);
   arrow->DrawArrow( 14.6,11.5, 14.6,11.1,0.01,"|>");
   line->DrawLine( 14.6, 8.5, 14.6, 8.0);
   line->DrawLine( 14.6, 8.0, 16, 8);
   ldot->DrawLine(16, 8, 19, 8);
   TText *vert = new TText(1.5,9.75,"File");
   vert->SetTextAlign(21);
   vert->SetTextAngle(90);
   vert->SetTextSize(0.025);
   vert->Draw();
   vert->DrawText(2.0, 9.75,"Header");
   vert->DrawText(2.9, 9.75,"Logical Record");
   vert->DrawText(3.2, 9.75,"Header");
   vert->DrawText(7.3, 9.75,"Logical Record");
   vert->DrawText(7.6, 9.75,"Header");
   vert->DrawText(10.9,9.75,"Logical Record");
   vert->DrawText(11.2,9.75,"Header");
   vert->DrawText(14.9,9.75,"Logical Record");
   vert->DrawText(15.2,9.75,"Header");
   TText *hori = new TText(4.75,10,"Object");
   hori->SetTextAlign(22);
   hori->SetTextSize(0.035);
   hori->Draw();
   hori->DrawText(4.75, 9.5,"Data");
   hori->DrawText(9.2, 10,"Deleted");
   hori->DrawText(9.2, 9.5,"Object");
   line->DrawLine( 6.9, 8.5, 10.5, 11);
   line->DrawLine( 6.9, 11, 10.5, 8.5);
   TText *tbig = new TText(17,9.75,"............");
   tbig->SetTextAlign(22);
   tbig->SetTextSize(0.03);
   tbig->Draw();
   tbig->DrawText(2.6, 7, "fBEGIN");
   tbig->DrawText(20., 7, "fEND");
   arrow->DrawArrow( 2.6,7, 2.6,8.4,0.01,"|>");
   arrow->DrawArrow( 20,7, 20,8.4,0.01,"|>");

   //file header
   TPaveText *header = new TPaveText(0.5,.2,9.4,6.5);
   header->SetFillColor(44);
   header->Draw();
   TText *fh=header->AddText("File Header");
   fh->SetTextAlign(22);
   fh->SetTextSize(0.04);
   header->SetTextSize(0.027);
   header->SetTextAlign(12);
   header->AddText(" ");
   header->AddLine(0,0,0,0);
   header->AddText("\"root\": Root File Identifier");
   header->AddText("fVersion: File version identifier");
   header->AddText("fBEGIN: Pointer to first data record");
   header->AddText("fEND: Pointer to first free word at EOF");
   header->AddText("fSeekFree: Pointer to FREE data record");
   header->AddText("fNbytesFree: Number of bytes in FREE");
   header->AddText("fNfree: Number of free data records");
   header->AddText("fNbytesName: Number of bytes in name/title");
   header->AddText("fUnits: Number of bytes for pointers");
   header->AddText("fCompress: Compression level");

   //logical record header
   TPaveText *lrecord = new TPaveText(10,0.2,19.5,6.5);
   lrecord->SetFillColor(33);
   lrecord->Draw();
   TText *tlrh=lrecord->AddText("Logical Record Header (TKEY)");
   tlrh->SetTextAlign(22);
   tlrh->SetTextSize(0.04);
   lrecord->SetTextSize(0.027);
   lrecord->SetTextAlign(12);
   lrecord->AddText(" ");
   lrecord->AddLine(0,0,0,0);
   lrecord->AddText("fNbytes: Length of compressed object");
   lrecord->AddText("fVersion: Key version identifier");
   lrecord->AddText("fObjLen: Length of uncompressed object");
   lrecord->AddText("fDatime: Date/Time when written to store");
   lrecord->AddText("fKeylen: Number of bytes for the key");
   lrecord->AddText("fCycle : Cycle number");
   lrecord->AddText("fSeekKey: Pointer to object on file");
   lrecord->AddText("fSeekPdir: Pointer to directory on file");
   lrecord->AddText("fClassName: class name of the object");
   lrecord->AddText("fName: name of the object");
   lrecord->AddText("fTitle: title of the object");

   c1->Update();
   c1->Print("file.png");
}