Example #1
0
void drawLabels(){

  // "Hadron Gas"
  TLatex *xHad1 = new TLatex(0.11, 0.13, "Hadron");
  TLatex *xHad2 = new TLatex(0.15, 0.085, "Gas");
  xHad1->SetTextSize(0.04);
  xHad2->SetTextSize(0.04);
  if(iColor)xHad1->SetTextColor(4);
  if(iColor)xHad2->SetTextColor(4);
  xHad1->Draw();
  xHad2->Draw();

  //"Quark Gloun Plasma"
  TLatex *xQGP1 = new TLatex(0.55, 0.8, "Quark Gluon");
  TLatex *xQGP2 = new TLatex(0.62, 0.755, "Plasma");
  xQGP1->SetTextSize(0.04);
  xQGP2->SetTextSize(0.04);
  if(iColor)xQGP1->SetTextColor(4);
  if(iColor)xQGP2->SetTextColor(4);
  xQGP1->Draw();
  xQGP2->Draw();

  //"Early Universe"
  TArrow *aUniv = new TArrow(.025, 0.95,.025, 0.45,0.03,"|>");
  aUniv->SetLineWidth(2);
  if(iColor)aUniv->SetLineColor(2);
  if(iColor)aUniv->SetFillColor(2);
  aUniv->Draw();
  TLatex *xUniv = new TLatex(0.075, 0.58, "Early Universe");
  xUniv->SetTextSize(0.04);
  xUniv->SetTextAngle(90);
  if(iColor)xUniv->SetTextColor(2);
  xUniv->Draw();
  
  //"Neutron Stars"
  TArrow *aNeut = new TArrow(.65, .05 ,.99, 0.075,0.03,"|>");
  aNeut->SetLineWidth(2);
  if(iColor)aNeut->SetLineColor(8);
  if(iColor)aNeut->SetFillColor(8);
  aNeut->Draw();
  TLatex *xNeut = new TLatex(0.735, 0.08, "Neutron Stars");
  xNeut->SetTextSize(0.04);
  xNeut->SetTextAngle(5);
  if(iColor)xNeut->SetTextColor(8);
  xNeut->Draw();

  //"Critical Point"
  TLatex *xCrit1 = new TLatex(0.2, 0.585, "Critical");
  TLatex *xCrit2 = new TLatex(0.225, 0.54, "Point");
  xCrit1->SetTextSize(0.04);
  xCrit2->SetTextSize(0.04);
  xCrit1->Draw();
  xCrit2->Draw();
}
Example #2
0
void drawAxis()
{
  TArrow *arr = new TArrow(0,0,1,0,0.03,"|>");
  arr->SetFillColor(1);
  arr->SetLineWidth(2);
  arr->Draw();
  
  arr = new TArrow(0,0,0,1,0.03,"|>");
  arr->SetFillColor(1);
  arr->SetLineWidth(2);
  arr->Draw();
}
Example #3
0
void drawArrow(Double_t u, Double_t v, Double_t du, Double_t due, Double_t dv, Double_t dve){

  if ( du+dv ){ 

    Double_t arrowLengthSqr = du*du+dv*dv;
    Double_t relErrorOnArrowLength = sqrt(du*du*due*due+dv*dv*dve*dve)/arrowLengthSqr;
    
    Int_t color = 0; //-10, -9, -7, -4, 0
    Int_t lwid = 2;
    if ( relErrorOnArrowLength>0.5 ) color=kBlue-9;
    if ( relErrorOnArrowLength<0.4 ) color=kBlue-7;
    if ( relErrorOnArrowLength<0.3 ) color=kBlue-4;
    if ( relErrorOnArrowLength<0.2 ) color=kBlue;
    //    if ( relErrorOnArrowLength<0.1 ) color=kBlue;
    if ( relErrorOnArrowLength<0.1 ) {
      color=kBlue;
      lwid = 3;
    }
   if ( relErrorOnArrowLength<0.05 ) {
      color=kBlue;
      lwid = 4;
    }
   
   Double_t arrowSize = 0.006;

    TArrow * ar = new TArrow(u-0.5*du,v-0.5*dv,u+0.5*du,v+0.5*dv,arrowSize,"|>");
    ar->SetLineWidth(lwid);
    ar->SetFillColor(color);
    ar->SetLineColor(color);
    ar->Draw();
  }

}
Example #4
0
void arrow (Double_t x1, Double_t y1, Double_t x2, Double_t y2, Int_t ls)
{
   TArrow *arr = new TArrow(x1,y1,x2,y2,0.025,"|>");
   arr->SetFillColor(1);
   arr->SetFillStyle(1001);
   arr->SetLineStyle(ls);
   arr->SetAngle(19);
   arr->Draw();
}
Example #5
0
void
HHV4Vector::Draw(Int_t color, Int_t style) const
{  // draw particle for event display in x-y view
  TArrow *Ar = new TArrow(0, 0, Px(), Py(), 0.001, "|>");
  Ar->SetLineColor(color);
  Ar->SetFillColor(color);
  Ar->SetLineWidth(3);
  Ar->SetLineStyle(style);
  Ar->Draw();
}
void draw_synapse(Double_t cx1, Double_t cy1, Double_t cx2, Double_t cy2,
                  Double_t  rad1, Double_t rad2, Double_t weightNormed)
{
   const Double_t TIP_SIZE   = 0.01;
   const Double_t MAX_WEIGHT = 8;
   const Double_t MAX_COLOR  = 100;  // red
   const Double_t MIN_COLOR  = 60;   // blue

   if (weightNormed == 0) return;

   //   gStyle->SetPalette(100, NULL);

   TArrow *arrow = new TArrow(cx1+rad1, cy1, cx2-rad2, cy2, TIP_SIZE, ">");
   arrow->SetFillColor(1);
   arrow->SetFillStyle(1001);
   arrow->SetLineWidth((Int_t)(TMath::Abs(weightNormed)*MAX_WEIGHT+0.5));
   arrow->SetLineColor((Int_t)((weightNormed+1.0)/2.0*(MAX_COLOR-MIN_COLOR)+MIN_COLOR+0.5));
   arrow->Draw();
}
void RoutePlot(){
gStyle->SetTitleX(0.21);
gStyle->SetTitleY(0.98);

  const int minIteration=0;
  const int Iteration=10;
  int nParticles=20;
  
  TGraph* emptygraph = new TGraph(1);
  emptygraph->SetPoint(0,1000,0.005);
  
  std::vector< std::vector<TGraph*> > graphs;
  std::vector<TPolyLine*> lines;
  std::vector<TGraph*> FirstPoints;
  std::vector<TGraph*> LastPoints;
  std::vector< std::vector<TArrow*> > arrows;
  

  //get max an min ROC
  Int_t bestPartIteration[Iteration];
  Double_t bestROCIteration[Iteration];
  for(int o=0;o<Iteration;o++){bestROCIteration[o]=0.0;}
  Double_t maxROC=0.0;
  Double_t minROC=1.0;
  Double_t bestROCGlobal=0.0;
  for(int i=0;i<nParticles;i++){
//      if(!(i==1 or i==13 or i==5 or i==6 or i==8 or i==4 or i==14 or i==18))continue;

//     std::cout<<i<<std::endl;
    std::string buffer="";
    std::stringstream buffer2;
    buffer2<<i;
//     std::cout<<buffer2.str()<<" "<<buffer2.str()<<std::endl;
//     buffer2>>buffer;
    std::string filename="../Particles_long/Particle";
    filename+=buffer2.str();
    filename+="/ParticleRoute.txt";
//     std::cout<<filename.c_str()<<std::endl;
    std::ifstream inputfile(filename.c_str());
//     std::ifstream inputfile("Particles_long/Particle1/ParticleRoute.txt");

    int k=0;
    double nTrees=0.0;
    double shrinkage=0.0;
    double bagging=0.0;
    double cuts=0.0;
    double ROC=0.0;
    double KS=0.0;
    double depth=0.0;
    bool readline=true;
    while(readline){
      inputfile>>ROC;
      inputfile>>KS;
      inputfile>>nTrees;
      inputfile>>shrinkage;
      inputfile>>bagging;
      inputfile>>cuts;
//       inputfile>>depth;
      std::string dump="";
      int j=0;
      do{
        inputfile>>dump;
//         std::cout<<dump<<std::endl;
        j++;
//         if(dump=="--Next--")std::cout<<"here"<<std::endl;
//         if(dump=="--Next--\n")std::cout<<"too"<<std::endl;
//         if(dump=="")std::cout<<"never"<<std::endl;

      }while(dump!="--Next--" and dump!="--Next--\n" and dump!="");
//       std::cout<<"Data "<<nTrees<<" "<<shrinkage<<" "<<ROC<<std::endl;
      if(dump!="" and k>=minIteration){
        if(ROC>maxROC)maxROC=ROC;
        if(ROC<minROC and ROC!=0)minROC=ROC;
      
      }
      k++;
//      inputfile>>dump;
      if(inputfile.eof() or dump=="" or k==Iteration)readline=false;
    }

    inputfile.close();
    std::cout<<"NPoints: "<<k<<std::endl;
  }
  std::cout<<"ROC range "<<minROC<<"  "<<maxROC<<std::endl;
  
  //get marker scaling;
  Double_t maxSize=2.4;
  Double_t minSize=0.3;
  minROC=0.74;
  Double_t m = (maxSize-minSize)/(maxROC-minROC);
  Double_t abschnitt = maxSize-m*maxROC;
  std::cout<<m<<" "<<abschnitt<<std::endl;
  std::cout<<minSize<<" "<<maxSize<<std::endl;

      
  //read points
  for(int i=0;i<nParticles;i++){
      if(!(i==1 or i==2 or i==4 or i==10 or i==13 or i==14 or i==17))continue;

    std::cout<<i<<std::endl;
    std::string buffer="";
    std::stringstream buffer2;
    buffer2<<i;
//     std::cout<<buffer2.str()<<" "<<buffer2.str()<<std::endl;
//     buffer2>>buffer;
    std::string filename="../Particles_long/Particle";
    filename+=buffer2.str();
    filename+="/ParticleRoute.txt";
    std::cout<<filename.c_str()<<std::endl;
    std::ifstream inputfile(filename.c_str());
//     std::ifstream inputfile("Particles_long/Particle1/ParticleRoute.txt");

    std::vector< TGraph*> buffgraph;
    graphs.push_back( buffgraph);
    lines.push_back(new TPolyLine);
    FirstPoints.push_back(new TGraph);
    LastPoints.push_back(new TGraph);
    std::vector< TArrow*> buffarrow;
    arrows.push_back(buffarrow);


    int k=0;
    int kk=0;
    double nTrees=0.0;
    double shrinkage=0.0;
    double bagging=0.0;
    double cuts=0.0;
    double ROC=0.0;
    double KS=0.0;
    double depth=0.0;
    
    bool readline=true;
    while(readline){
      inputfile>>ROC;
      inputfile>>KS;
      inputfile>>nTrees;
      inputfile>>shrinkage;
      inputfile>>bagging;
      inputfile>>cuts;
//       inputfile>>depth;
      std::string dump="";
      int j=0;
      do{
        inputfile>>dump;
//         std::cout<<dump<<std::endl;
        j++;
//         if(dump=="--Next--")std::cout<<"here"<<std::endl;
//         if(dump=="--Next--\n")std::cout<<"too"<<std::endl;
//         if(dump=="")std::cout<<"never"<<std::endl;

      }while(dump!="--Next--" and dump!="--Next--\n" and dump!="");
//       std::cout<<"Data "<<nTrees<<" "<<shrinkage<<" "<<ROC<<std::endl;
      if(dump!="" and k>=minIteration){
        kk++;
        graphs.back().push_back(new TGraph);
        graphs.back().back()->SetPoint(0,nTrees,shrinkage);
        if(ROC==0)graphs.back().back()->SetMarkerStyle(3);
        else{
          graphs.back().back()->SetMarkerStyle(8);
//           std::cout<<TMath::Exp(ROC)<<std::endl;
          Double_t size=m*ROC+abschnitt;
          graphs.back().back()->SetMarkerSize(size); 
          std::cout<<j<<" "<<ROC<<" "<<size<<std::endl;

        }
        if(k==minIteration)graphs.back().back()->SetMarkerStyle(34);
        if(k>=minIteration)lines.back()->SetPoint(kk-1,nTrees,shrinkage);
        
        
           
          
          //if(k==0)FirstPoints.back()->SetPoint(0,nTrees,shrinkage);
      
      }
      if(ROC>=bestROCIteration[k]){
      bestROCIteration[k]=ROC;
      bestPartIteration[k]=i;
//       if(ROC>=bestROCGlobal)bestROCGlobal=ROC;
//       if(bestROCGlobal>=bestROCIteration[k])bestROCIteration[k]=bestROCGlobal;
      }
      
      k++;
//      inputfile>>dump;
      if(inputfile.eof() or dump=="" or k==Iteration)readline=false;
    }
    
//     LastPoints.back()->SetPoint(0,nTrees,bagging);

    inputfile.close();
    std::cout<<"NPoints: "<<k<<std::endl;
    
    //get velocities
    for(size_t l=1;l<graphs.back().size()-1;l++){
//       std::cout<<graphs.size()<<std::endl;
      Double_t PrevTrees=0.001;
      Double_t PrevShrinkage=0.001;
      graphs.back().at(l-1)->GetPoint(0,PrevTrees,PrevShrinkage);
//       std::cout<<PrevTrees<<" "<<PrevShrinkage<<std::endl;
      Double_t CurrTrees;
      Double_t CurrShrinkage;
      graphs.back().at(l)->GetPoint(0,CurrTrees,CurrShrinkage);
      Double_t NextTrees;
      Double_t NextShrinkage;
      graphs.back().at(l+1)->GetPoint(0,NextTrees,NextShrinkage);
      Double_t velTree=CurrTrees-PrevTrees;
      Double_t velShrinkage=CurrShrinkage-PrevShrinkage;
      Double_t nvelTree=NextTrees-CurrTrees;
      Double_t nvelShrinkage=NextShrinkage-CurrShrinkage;
      Double_t forceTrees=nvelTree-0.73*velTree;
      Double_t forceShrinkage=nvelShrinkage-0.73*velShrinkage;
      arrows.back().push_back(new TArrow(CurrTrees,CurrShrinkage,CurrTrees+forceTrees,CurrShrinkage+forceShrinkage,0.02,">"));
      
    }
    
  }//end input loop
    
    //Get velocities
    
    
    TCanvas* c = new TCanvas("c","c",1024,768);
    TLegend* leg= new TLegend(0.5,0.75,0.7,0.95);
    leg->SetFillColor(0);
    leg->SetTextFont(42);
    std::vector<TGraph*> leggraphs;

    for(size_t i=0;i<graphs.size();i++){
      leggraphs.push_back(new TGraph);
      leggraphs.back()->SetMarkerColor(1+i);
      leggraphs.back()->SetMarkerStyle(8);
      leggraphs.back()->SetMarkerSize(1);
      if(i==2)leggraphs.back()->SetMarkerColor(9);
      leg->AddEntry(leggraphs.back(), Form("particle %i",i+1),"p");
    }
    TLegend* legMarker= new TLegend(0.7,0.65,0.9,0.95);
    legMarker->SetFillColor(0);
    legMarker->SetFillStyle(0);
    legMarker->SetTextFont(42);
    TLegend* legCMS= new TLegend(0.07,0.85,0.39,0.95);
    legCMS->SetFillColor(0);
    legCMS->SetFillStyle(0);
    legCMS->SetBorderSize(0);
    legCMS->SetTextFont(42);
    legCMS->AddEntry((TObject*)0,"CMS private work","");
    TPaveText* legExplain= new TPaveText(0.23,0.84,0.73,0.94,"NDC");
    legExplain->SetFillColor(3);
    legExplain->SetFillStyle(0);
    legExplain->SetBorderSize(0);
    legExplain->AddText("BDTs trained and tested with t#bar{t}H, H#rightarrowb#bar{b} and t#bar{t} MC-Samples");
    legExplain->SetTextFont(42);
    
    TGraph* initMarker = new TGraph();
    initMarker->SetMarkerStyle(34);
    initMarker->SetMarkerSize(1.5);
    TGraph* zeroKSMarker = new TGraph();
    zeroKSMarker->SetMarkerStyle(3);
    zeroKSMarker->SetMarkerSize(1.5);
    legMarker->AddEntry(initMarker,"init. pos.","p");
    
    TArrow* legArrow = new TArrow(100,0.01,200,0.02,0.02,">");
    TArrow* legArrow2 = new TArrow(1270,0.0453,1320,0.0453,0.02,">");
    
    legArrow->SetLineColor(0);
    legArrow->SetFillColor(0);
    legArrow2->SetLineWidth(2);
    legArrow2->SetAngle(40);
    legMarker->AddEntry(legArrow,"#Delta#vec{v}","");
//         legMarker->AddEntry((TObject*)0,"","");
    legMarker->AddEntry(zeroKSMarker,"KS < min KS","p");

    TGraph* sizegraph1 = new TGraph();
    sizegraph1->SetMarkerStyle(8);
    Double_t size2=m*0.74+abschnitt;
    sizegraph1->SetMarkerSize(size2);
    legMarker->AddEntry(sizegraph1, "A_{ROC} = 0.74","p");
    TGraph* sizegraph2 = new TGraph();
    sizegraph2->SetMarkerStyle(8);
    size2=m*0.76+abschnitt;
    sizegraph2->SetMarkerSize(size2);
    legMarker->AddEntry(sizegraph2, "A_{ROC} = 0.76","p");
    TGraph* sizegraph3 = new TGraph();
    sizegraph3->SetMarkerStyle(8);
    size2=m*0.78+abschnitt;
    sizegraph3->SetMarkerSize(size2);
    legMarker->AddEntry(sizegraph3, "A_{ROC} = 0.78","p");
    
    
    
    for(size_t i=0;i<graphs.size();i++){

      if(i==0){
        c->cd();
        
        
        emptygraph->Draw("AP");
        c->Update();
        emptygraph->GetXaxis()->SetLimits(200,1600);
        emptygraph->GetXaxis()->SetRangeUser(200,1600);

        emptygraph->GetYaxis()->SetLimits(0.0,0.05);
        emptygraph->GetYaxis()->SetRangeUser(0.0,0.05);
        //emptygraph->SetTitle("particle paths in the n_{Trees} - shrinkage plane");
        emptygraph->SetTitle("");
        emptygraph->GetXaxis()->SetTitle("n_{Trees}");
        emptygraph->GetYaxis()->SetTitle("shrinkage");
        emptygraph->GetYaxis()->SetTitleOffset(1.5);
        emptygraph->GetXaxis()->SetTitleOffset(1.2);
       std::cout<<emptygraph->GetXaxis()->GetTitleFont()<<std::endl;

	c->SetTopMargin(0.05);
        c->Update();
        for(size_t j=0;j<graphs.at(i).size();j++){
//           graphs.at(i).at(j)->SetMarkerStyle(3);
          graphs.at(i).at(j)->SetMarkerColor(1+i);
          graphs.at(i).at(j)->SetLineColor(1+i);
//         graphs.at(i)->GetXaxis()->SetLimits(200.0,2500.0);
//         graphs.at(i)->GetYaxis()->SetLimits(0.1,0.9);
//         graphs.at(i)->GetZaxis()->SetRangeUser(0.0,1.0);
          graphs.at(i).at(j)->Draw("P SAME");
        c->Update();
        }
        for(size_t j=0;j<arrows.at(i).size();j++){
          arrows.at(i).at(j)->SetLineColor(1+i);
          arrows.at(i).at(j)->SetFillColor(1+i);
          arrows.at(i).at(j)->SetAngle(40);
          arrows.at(i).at(j)->SetLineWidth(1.9);
          arrows.at(i).at(j)->Draw("");
          c->Update();
        }
        lines.at(i)->SetLineColor(1+i);
        lines.at(i)->SetLineStyle(7);
        lines.at(i)->Draw();
        c->Update();
        
//         FirstPoints.at(i)->SetMarkerStyle(20);
//         FirstPoints.at(i)->SetMarkerColor(1+i);
//         FirstPoints.at(i)->Draw("P SAME");
//         LastPoints.at(i)->SetMarkerStyle(21);
//         LastPoints.at(i)->SetMarkerColor(1+i);
//         LastPoints.at(i)->Draw("P SAME");
//         c->Update();
//         LastPoints.at(i)->GetXaxis()->SetRangeUser(200.0,2500.0);
//         LastPoints.at(i)->GetYaxis()->SetRangeUser(0.0001,0.05);
//         LastPoints.at(i)->GetZaxis()->SetRangeUser(0.0,1.0);
//         LastPoints.at(i)->Draw("P SAME");

//         graphs.at(i)->Draw("P SAME");
        c->Update();
//         TObject* view = c->GetView3D();
//         TAxis3D *axis = TAxis3D::GetPadAxis();
//         std::cout<<view<<std::endl;
//         TAxis3D::ToggleRulers();     // To pop axice down
//         axis->SetLabelColor(kBlue); // Paint the axice labels with blue color
//         axis->SetAxisColor(kRed);   // Paint the axice itself with blue color
//         TAxis3D::ToggleRulers(); 
//         axis->Paint();// To pop axice up
//         c->Update();
        
      }
      else{
        c->cd();
        for(size_t j=0;j<graphs.at(i).size();j++){
//           graphs.at(i).at(j)->SetMarkerStyle(3);
          graphs.at(i).at(j)->SetMarkerColor(1+i);
          graphs.at(i).at(j)->SetLineColor(1+i);
          if(i==2){
          graphs.at(i).at(j)->SetMarkerColor(9);
          graphs.at(i).at(j)->SetLineColor(9);
          }
//         graphs.at(i)->GetXaxis()->SetRangeUser(200.0,2500.0);
//         graphs.at(i)->GetYaxis()->SetRangeUser(0.0001,0.05);
//         graphs.at(i)->GetZaxis()->SetRangeUser(0.0,1.0);
          graphs.at(i).at(j)->Draw("SAME P");
        c->Update();
        }
        for(size_t j=0;j<arrows.at(i).size();j++){
        arrows.at(i).at(j)->SetLineColor(1+i);
        arrows.at(i).at(j)->SetFillColor(1+i);
        if(i==2){
        arrows.at(i).at(j)->SetLineColor(9);
        arrows.at(i).at(j)->SetFillColor(9);
        }
        arrows.at(i).at(j)->SetAngle(40);
        arrows.at(i).at(j)->SetLineWidth(1.9);


        arrows.at(i).at(j)->Draw("");
        c->Update();
        }
        lines.at(i)->SetLineColor(1+i);
        lines.at(i)->SetLineStyle(7);
        if(i==2)lines.at(i)->SetLineColor(9);

        lines.at(i)->Draw();
        c->Update();
        
// d        FirstPoints.at(i)->SetMarkerStyle(20);
//     d    FirstPoints.at(i)->SetMarkerColor(1+i);
//         FirstPoints.at(i)->Draw("P Same");
//         LastPoints.at(i)->SetMarkerStyle(21);
//         LastPoints.at(i)->SetMarkerColor(1+i);
//         LastPoints.at(i)->Draw("P Same");
        c->Update();
      }
      
    }
    legArrow2->Draw("");
    leg->Draw();
    legMarker->Draw();
    legCMS->Draw();
    //legExplain->Draw();
    c->Update();
    TString outfile="ParticleRoute_";
    outfile+=Iteration;
    outfile+="eng.eps";
    c->SaveAs(outfile);
    
    
    for(int p=0;p<Iteration;p++){
    if(p>0 and bestROCIteration[p-1]>bestROCIteration[p])bestROCIteration[p]=bestROCIteration[p-1];

    std::cout<<p<<" "<<bestROCIteration[p]<<" "<<bestPartIteration[p]<<std::endl;
    
    }
}
void determineWorkingPoint(TString algo="csv",TString baseURL="~/scratch0/top-nosyst/plotter.root")
{
  float workPoint(0.244);
  float sfb(1.020),    sfberr(0.04);      //from BTV-11-003
  float sflight(1.08), sflighterr(0.13);  //from BTV-11-002
  //  float sfb(0.99),        sfberr(0.099);      //from BTV-11-001
  //  float sflight(1.07882), sflighterr(0.244);  //from BTV-11-001
  if(algo=="tche")
    {
      workPoint=1.7;
      sfb=0.95; sfberr=0.095;
      sflight=1.08018; sflighterr=0.1125;
    }

  TObjArray bjets=getDistributionFromPlotter(algo+"b",baseURL);
  TObjArray lightjets=getDistributionFromPlotter(algo+"light",baseURL);
  
  TH1F *bDisc=(TH1F *) bjets.At(1);
  TH1F *lightDisc=(TH1F *) lightjets.At(1);
  
  setStyle();
  gStyle->SetOptFit(0);

  TCanvas *cnv = getNewCanvas("c","c",false);
  cnv->Clear();
  cnv->SetCanvasSize(1200,1200);
  cnv->SetWindowSize(1200,1200);
  cnv->Divide(2,2);

  //draw the discriminator
  TPad *p = (TPad *)cnv->cd(1); 
  bDisc->SetTitle("b");
  bDisc->SetLineColor(1);
  bDisc->SetMarkerColor(1);
  bDisc->SetMarkerStyle(20);
  bDisc->SetFillStyle(0);
  bDisc->DrawNormalized("histe1");
  lightDisc->SetLineColor(1);
  lightDisc->SetMarkerColor(1);
  lightDisc->SetMarkerStyle(24);
  lightDisc->SetFillStyle(0);
  lightDisc->SetTitle("udcsg");
  lightDisc->DrawNormalized("histe1same");
  TLegend *leg=p->BuildLegend();
  formatForCmsPublic(p,leg,"CMS simulation",2);

  //draw the b/light efficiencies
  p=(TPad *)cnv->cd(2);
  p->SetLogy();
  TGraphAsymmErrors *bEff     = getEfficiencyFrom(bDisc);
  TGraphAsymmErrors *lightEff = getEfficiencyFrom(lightDisc);
  bEff->SetMarkerStyle(20);
  bEff->SetFillStyle(0);
  bEff->Draw("ap");
  bEff->GetXaxis()->SetTitle(bDisc->GetXaxis()->GetTitle());
  bEff->GetYaxis()->SetTitle("Efficiency");
  lightEff->SetMarkerStyle(24);
  lightEff->SetFillStyle(0);
  lightEff->Draw("p");

  //draw relatively to a given working point
  p=(TPad *)cnv->cd(3);
  Double_t baseBEff=bEff->Eval(workPoint);
  TGraphAsymmErrors *relBEff=new TGraphAsymmErrors;
  relBEff->SetMarkerStyle(20);
  relBEff->SetFillStyle(0);
  Double_t baseLightEff=lightEff->Eval(workPoint);
  TGraphAsymmErrors *relLightEff=new TGraphAsymmErrors;
  relLightEff->SetMarkerStyle(24);
  relLightEff->SetFillStyle(0);
  for(int ip=0; ip<bEff->GetN(); ip++)
    {
      Double_t cut, y,ey; 
      bEff->GetPoint(ip,cut,y);     ey = bEff->GetErrorY(ip);
      Double_t relEff(y/baseBEff);
      if(relEff<sfb+2*sfberr && relEff>sfb-2*sfberr)
	{
	  int ipt=relBEff->GetN();
	  relBEff->SetPoint(ipt,cut,relEff);
	  relBEff->SetPointError(ipt,0,0,ey/baseBEff,ey/baseBEff);
	}

      lightEff->GetPoint(ip,cut,y);     ey = lightEff->GetErrorY(ip);
      relEff=y/baseLightEff;
      //      if(relEff<sflight+7*sflighterr && relEff>sflight-7*sflighterr)
      if(relEff<sflight+3*sflighterr && relEff>sflight-3*sflighterr)
	{
	  int ipt=relLightEff->GetN();
	  relLightEff->SetPoint(ipt,cut,relEff);
	  relLightEff->SetPointError(ipt,0,0,ey/baseLightEff,ey/baseLightEff);
	}
    }

  relLightEff->Draw("ap");
  relLightEff->GetXaxis()->SetTitle( bDisc->GetXaxis()->GetTitle() );
  relLightEff->GetYaxis()->SetTitle( "#varepsilon/#varepsilon_{0}" );
  relLightEff->Fit("expo","Q+");
  TF1 *ffunc=relLightEff->GetFunction("expo");
  float newLightCut=(TMath::Log(sflight)-ffunc->GetParameter(0))/ffunc->GetParameter(1);
  float newLightCutErrPlus=(TMath::Log(sflight+sflighterr)-ffunc->GetParameter(0))/ffunc->GetParameter(1)-newLightCut;
  float newLightCutErrMinus=(TMath::Log(sflight-sflighterr)-ffunc->GetParameter(0))/ffunc->GetParameter(1)-newLightCut;
  TArrow *lightArrow = new TArrow(newLightCut, sflight-3*sflighterr, newLightCut, sflight-3*sflighterr*0.8, 0.02, "<|");
  lightArrow->SetLineColor(kGray+2);
  lightArrow->SetFillColor(kGray+2);
  lightArrow->Draw("SAME <|");

  relBEff->Draw("p");
  relBEff->Fit("expo","Q+");
  ffunc=relBEff->GetFunction("expo");
  float newBCut=(TMath::Log(sfb)-ffunc->GetParameter(0))/ffunc->GetParameter(1);
  float newBCutErrPlus=(TMath::Log(sfb+sfberr)-ffunc->GetParameter(0))/ffunc->GetParameter(1)-newBCut;
  float newBCutErrMinus=(TMath::Log(sfb-sfberr)-ffunc->GetParameter(0))/ffunc->GetParameter(1)-newBCut;
  cout <<  sfb << " " << sfb+sfberr << " " << sfb-sfberr << endl;
  TArrow *bArrow    = new TArrow(newBCut, sflight-3*sflighterr, newBCut, sflight-3*sflighterr*0.8, 0.02, "<|");
  bArrow->Draw("SAME <|");

  //draw epsilon_b vs epsilon_q
  p=(TPad *)cnv->cd(4);
  p->SetLogy();

  TGraphAsymmErrors *perf=new TGraphAsymmErrors;
  perf->SetName("algoperformance");
  perf->SetMarkerStyle(20);
  perf->SetFillStyle(0);
  for(int ip=0; ip<bEff->GetN(); ip++)
    {
      Double_t cut;
      Double_t x,ex; bEff->GetPoint(ip,cut,x);     ex = bEff->GetErrorY(ip);
      Double_t y,ey; lightEff->GetPoint(ip,cut,y); ey = lightEff->GetErrorY(ip);
      perf->SetPoint(ip,x,y);
      perf->SetPointError(ip,ex,ex,ey,ey);
    }
  perf->Draw("ap");
  perf->GetXaxis()->SetTitle( bEff->GetTitle() );
  perf->GetYaxis()->SetTitle( lightEff->GetTitle() );

  //new performance expected after applying the new cuts
  TGraphAsymmErrors *newperf=new TGraphAsymmErrors;
  newperf->SetName("newalgoperformance");
  newperf->SetMarkerStyle(24);
  newperf->SetFillStyle(0);
  newperf->SetLineWidth(2);
  newperf->SetLineColor(kRed);
  newperf->SetLineColor(kRed);
  newperf->SetPoint(0,baseBEff*sfb,baseLightEff*sflight);
  newperf->SetPointError(0,baseBEff*sfberr,baseBEff*sfberr,baseLightEff*sflighterr,baseLightEff*sflighterr);
  newperf->Draw("p");

  cnv->Modified();
  cnv->Update();
  cnv->SaveAs("discFlavor.C");  
  cnv->SaveAs("discFlavor.png");  


  cout << "[determineWorkingPoint]" << endl
       << "To emulate the measured scale-factors you can use the following new cuts per jet flavor" << endl
       << "SF-b : "     << newBCut << " +" << newBCutErrPlus << " " << newBCutErrMinus << endl
       << "SF-light : " << newLightCut << " +" << newLightCutErrPlus << " " << newLightCutErrMinus << endl;
}
Example #9
0
File: event.C Project: 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");
}
Example #10
0
/// \file
/// \ingroup tutorial_tree
/// \notebook
/// Playing with a Tree containing variables of type character
/// \macro_image
/// \macro_code
/// \author Rene Brun
void cernstaff () {
   TString dir = gROOT->GetTutorialsDir();
   dir.Append("/tree/cernstaff.C");
   if (gSystem->AccessPathName("cernstaff.root")) {
      gROOT->SetMacroPath(dir);
      gROOT->ProcessLine(".x cernbuild.C");
   }
   TFile *f = new TFile("cernstaff.root");
   TTree *T = (TTree*)f->Get("T");
   TCanvas *c1 = new TCanvas("c1","CERN staff",10,10,1000,750);
   c1->Divide(2,2);
   // make table of number of people per Nation & Division
   c1->cd(1); gPad->SetGrid();
   T->Draw("Nation:Division>>hN","","text");
   TH2F *hN = (TH2F*)gDirectory->Get("hN");
   hN->SetMarkerSize(1.6);
   hN->SetStats(0);

   //make profile of Average cost per Nation
   c1->cd(2); gPad->SetGrid();
   gPad->SetLeftMargin(0.12);
   T->Draw("Cost:Nation>>hNation","","prof,goff");
   TH1F *hNation = (TH1F*)gDirectory->Get("hNation");
   hNation->SetTitle("Average Cost per Nation");
   hNation->LabelsOption(">"); //sort by decreasing bin contents
   hNation->SetMaximum(13000);
   hNation->SetMinimum(7000);
   hNation->SetStats(0);
   hNation->SetMarkerStyle(21);
   hNation->Draw();

   //make stacked plot of Nations versus Grade
   c1->cd(3); gPad->SetGrid();
   THStack *hGrades = new THStack("hGrades","Nations versus Grade");
   TH1F *hFR = new TH1F("hFR","FR",12,3,15);
    hFR->SetFillColor(kCyan);
    hGrades->Add(hFR);
    T->Draw("Grade>>hFR","Nation==\"FR\"");
   TH1F *hCH = new TH1F("hCH","CH",12,3,15);
    hCH->SetFillColor(kRed);
    hGrades->Add(hCH);
    T->Draw("Grade>>hCH","Nation==\"CH\"");
   TH1F *hIT = new TH1F("hIT","IT",12,3,15);
    hIT->SetFillColor(kGreen);
    hGrades->Add(hIT);
    T->Draw("Grade>>hIT","Nation==\"IT\"");
   TH1F *hDE = new TH1F("hDE","DE",12,3,15);
    hDE->SetFillColor(kYellow);
    hGrades->Add(hDE);
    T->Draw("Grade>>hDE","Nation==\"DE\"");
   TH1F *hGB = new TH1F("hGB","GB",12,3,15);
    hGB->SetFillColor(kBlue);
    hGrades->Add(hGB);
    T->Draw("Grade>>hGB","Nation==\"GB\"");
   hGrades->Draw();
   TLegend *legend = new TLegend(0.7,0.65,0.86,0.88);
   legend->AddEntry(hGB,"GB","f");
   legend->AddEntry(hDE,"DE","f");
   legend->AddEntry(hIT,"IT","f");
   legend->AddEntry(hCH,"CH","f");
   legend->AddEntry(hFR,"FR","f");
   legend->Draw();

   //make histogram of age distribution
   c1->cd(4); gPad->SetGrid();
   T->Draw("Age");
   T->Draw("Age>>hRetired","Age>(65-2002+1988)","same");
   TH1F *hRetired = (TH1F*)gDirectory->Get("hRetired");
   hRetired->SetFillColor(kRed);
   hRetired->SetFillStyle(3010);

   TArrow *arrow = new TArrow(32,169,55,74,0.03,"|>");
   arrow->SetFillColor(1);
   arrow->SetFillStyle(1001);
   arrow->Draw();

   TPaveText *pt = new TPaveText(0.12,0.8,0.55,0.88,"brNDC");
   pt->SetFillColor(kWhite);
   pt->AddText("People at CERN in 1988");
   pt->AddText("and retired in 2002");
   pt->Draw();

   c1->cd();
}
Example #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();
}
Example #12
0
int
main (int argc, char *argv[])
{
  if (argc != 2)
    {
      cout << "Usage: " << argv[0] << " INPUT_FILE" << endl;
      cout << "  or:  " << argv[0] << " INPUT_LIST" << endl;
      cout << "" << endl;
      cout << endl;

      return 0;
    }
  string inputFile = argv[1], upperInputFile;
  upperInputFile.resize (inputFile.length ());
  transform (inputFile.begin (), inputFile.end (), upperInputFile.begin (), ::toupper);

  // so canvases don't appear on the screen when being created
  // very useful when running on the OSU T3 from CERN
  gROOT->SetBatch();
  gStyle->SetPadTopMargin(0.1);
  gStyle->SetPadBottomMargin(0.1);
  gStyle->SetPadLeftMargin(0.03);
  gStyle->SetPadRightMargin(0.08);

  //Create chain of root trees
  TChain chain("Delphes");

  if (upperInputFile.length () < 5 || upperInputFile.substr (upperInputFile.length () - 5, 5) != ".ROOT")
  {
    ifstream fin (inputFile);
    string line;
    while(getline(fin, line))
      {
        chain.Add(line.c_str());
      }
    fin.close();
  }
  else
    chain.Add(inputFile.c_str());

  // Create object of class ExRootTreeReader
  ExRootTreeReader *treeReader = new ExRootTreeReader(&chain);

  // Get pointers to branches used in this analysis
  TClonesArray *branchTrack = treeReader->UseBranch("Track");
  TClonesArray *branchCluster = treeReader->UseBranch("Cluster"); 
  TClonesArray *branchNPU = treeReader->UseBranch("NPU");

  //gStyle->SetOptStat(10011);
  //actually, let's turn this off for now
  gStyle->SetOptStat(0);


  TH2D *hist[LEN];
  signal (SIGINT, signalHandler);
  //Loop over a LEN Events
  for (int event = 0; event < LEN && !interrupted; event++) {

    //Load Branches
    treeReader->ReadEntry(event);

    // N.B. this is a hack put in by Andrew using the ScalarHT class                                                                                                                                    
    // it's the number of pileup interactions, it's not actually the HT                                                                                                                                 
    unsigned nInteractions = (unsigned) ((ScalarHT *) branchNPU->At(0))->HT + 1;
    int nClusters = branchCluster->GetEntries();


    // create and format the histogram for this event
    TString name = "TrackPtVsTrackZ_" + TString(Form("%d",event+1));
    TCanvas *can = new TCanvas(name,name,1600,500);

    TString title = "Event " + TString(Form("%d",event+1)) + ": ";
    title += TString(Form("%d",nInteractions)) + " Interactions, ";
    title += TString(Form("%d",nClusters)) + " Clusters";

    hist[event] = new TH2D(name, title, X_BIN, X_MIN, X_MAX, Y_BIN, Y_MIN, Y_MAX);
    hist[event]->GetXaxis()->SetTitle("track z [mm]");
    hist[event]->GetXaxis()->SetLabelOffset(0.02);
    hist[event]->GetXaxis()->SetTitleOffset(1.2);
    hist[event]->GetYaxis()->SetTitle("track p_{T} [GeV]");
    hist[event]->GetYaxis()->SetTitleOffset(0.35);


    
    TArrow *genPVArrow = new TArrow(0,0,0,0.01,0.01,"|>");
    genPVArrow->SetLineColor(3);
    genPVArrow->SetFillColor(3);
    genPVArrow->SetLineWidth(0.1);
    genPVArrow->SetAngle(40);

    vector<float> interactionPositions;
    vector<TLine *> clusterLineVector;
    Cluster *recoPV = (Cluster *) branchCluster->At(0);
    TLine *highELine = new TLine(recoPV->Z,0,recoPV->Z,Y_MAX);
    highELine->SetLineColor(1);
    highELine->SetLineWidth(0.8);
    highELine->SetLineStyle(3);

    // Draw cluster lines
    // Skip first cluster since we've already drawn it (start from 1)
    for(int iCluster = 1; iCluster < branchCluster->GetEntries(); iCluster++) {
	Cluster *cluster = (Cluster *) branchCluster->At(iCluster);
	TLine *clusterLine = new TLine(cluster->Z,0,cluster->Z,Y_MAX);
	clusterLine->SetLineWidth(0.5);
	clusterLineVector.push_back(clusterLine);
    }
   
    for(int iTrack = 0; iTrack < branchTrack->GetEntries(); iTrack++) {
        Track *track = (Track *) branchTrack->At(iTrack);
	if (track->PT < Y_MAX) hist[event]->Fill(track->Z, track->PT);
	else hist[event]->Fill(track->Z, Y_MAX-0.01); // if entry would be off the y-scale, draw it in the last bin

        if(track->IsPU==0) { // track comes from primary interaction
//           genPVArrow->SetX1(track->TrueZ);  FIXME
//           genPVArrow->SetX2(track->TrueZ); FIXME
	}
//	else if (find(interactionPositions.begin(), interactionPositions.end(), track->TrueZ) == interactionPositions.end()){ FIXME
//	  interactionPositions.push_back(track->TrueZ); FIXME
//	} FIXME
    }

    //create arrows for all the generated pileup interactions
    vector<TArrow *> interactionArrowVector;
    for(uint iInteraction = 0; iInteraction < interactionPositions.size() ; iInteraction++) {
      TArrow *interactionArrow = new TArrow(interactionPositions.at(iInteraction),0,interactionPositions.at(iInteraction),0.01,0.01,"|>");
      interactionArrow->SetLineWidth(0.1);
      interactionArrow->SetAngle(20);
      interactionArrow->SetLineColor(2);
      interactionArrow->SetFillColor(2);
      interactionArrowVector.push_back(interactionArrow);
    }
  
    //Draw and save images
    hist[event]->Draw("contz");
    for(uint iCluster = 0; iCluster < clusterLineVector.size(); iCluster++) {
      clusterLineVector.at(iCluster)->Draw();
    } 
    for(uint iInteraction = 0; iInteraction < interactionArrowVector.size(); iInteraction++) {
      interactionArrowVector.at(iInteraction)->Draw();
    } 
    highELine->Draw();
    genPVArrow->Draw();

    TLegend *leg = new TLegend(0.07,0.6,0.25,0.89);
    leg->SetBorderSize(0);
    leg->SetFillColor(0);
    leg->SetFillStyle(0);
    leg->AddEntry(genPVArrow, "Primary Gen. Interaction", "");
    if (interactionArrowVector.size() > 0) leg->AddEntry(interactionArrowVector.at(0), "Pileup Interactions", "");
    leg->AddEntry(highELine, "Highest #Sigmap_{T}^{2} Cluster", "l");
    if (clusterLineVector.size() > 0) leg->AddEntry(clusterLineVector.at(0), "Other Clusters", "l");
    leg->Draw();


    //hack to get the triangles to draw in the legend
    double x_left = X_MIN + (X_MAX-X_MIN)/13;
    double x_right = X_MIN + (X_MAX-X_MIN)/13;

    if (interactionArrowVector.size() > 0){
      TArrow *interactionArrowLabel = new TArrow(x_left,Y_MAX*0.86,x_right,Y_MAX*0.86,0.02,"|>");
      interactionArrowLabel->SetLineWidth(1);
      interactionArrowLabel->SetAngle(20);
      interactionArrowLabel->SetLineColor(2);
      interactionArrowLabel->SetFillColor(2);
      interactionArrowLabel->Draw();
    }
    TArrow *genPVArrowLabel = new TArrow(x_left,Y_MAX*0.94,x_right,Y_MAX*0.94,0.02,"|>");
    genPVArrowLabel->SetLineWidth(1);
    genPVArrowLabel->SetAngle(40);
    genPVArrowLabel->SetLineColor(3);
    genPVArrowLabel->SetFillColor(3);
    genPVArrowLabel->Draw();
    
    can->SaveAs("output/" + name + ".pdf");
    //can->Write();

  }
}
Example #13
0
void ClassTree()
{

   TCanvas *ClassTree = new TCanvas("ClassTree", "",186,135,594,449);
   ClassTree->SetHighLightColor(2);
   ClassTree->Range(0,5,20,20);
   ClassTree->SetFillColor(33);
   ClassTree->SetBorderSize(2);
   TLine *line = new TLine(0.5,18.15,4.4,18.15);
   line->Draw();
   line = new TLine(4.4,17.725,4.4,18.575);
   line->Draw();
   
   TPaveLabel *pl = new TPaveLabel(1,17.895,4.205,18.405,"TArray","br");
   pl->SetFillColor(30);
   pl->SetTextSize(0.9);
   pl->Draw();
   line = new TLine(0.5,16.875,1,16.875);
   line->Draw();
   
   pl = new TPaveLabel(1,16.62,4.205,17.13,"TAttFill","br");
   pl->SetFillColor(30);
   pl->SetTextSize(0.9);
   pl->Draw();
   line = new TLine(0.5,16.025,1,16.025);
   line->Draw();
   
   pl = new TPaveLabel(1,15.77,4.205,16.28,"TAttLine","br");
   pl->SetFillColor(30);
   pl->SetTextSize(0.9);
   pl->Draw();
   line = new TLine(0.5,15.175,1,15.175);
   line->Draw();
   
   pl = new TPaveLabel(1,14.92,4.205,15.43,"TAttMarker","br");
   pl->SetFillColor(30);
   pl->SetTextSize(0.9);
   pl->Draw();
   line = new TLine(0.5,9.775,4.4,9.775);
   line->Draw();
   line = new TLine(4.4,7.65,4.4,12.325);
   line->Draw();
   
   pl = new TPaveLabel(1,9.52,4.205,10.03,"TObject","br");
   pl->SetFillColor(5);
   pl->SetTextSize(0.9);
   pl->Draw();
   line = new TLine(4.4,12.325,4.9,12.325);
   line->Draw();
   
   pl = new TPaveLabel(4.9,12.07,8.105,12.58,"AliArrayI","br");
   pl->SetFillColor(18);
   pl->SetTextSize(0.9);
   pl->Draw();
   line = new TLine(4.4,11.475,4.9,11.475);
   line->Draw();
   
   pl = new TPaveLabel(4.9,11.22,8.105,11.73,"AliArrayS","br");
   pl->SetFillColor(18);
   pl->SetTextSize(0.9);
   pl->Draw();
   line = new TLine(4.4,18.575,4.9,18.575);
   line->Draw();
   
   pl = new TPaveLabel(4.9,18.32,8.105,18.83,"TArrayI","br");
   pl->SetFillColor(30);
   pl->SetTextSize(0.9);
   pl->Draw();
   line = new TLine(4.4,17.725,4.9,17.725);
   line->Draw();
   
   pl = new TPaveLabel(4.9,17.47,8.105,17.98,"TArrayS","br");
   pl->SetFillColor(30);
   pl->SetTextSize(0.9);
   pl->Draw();
   line = new TLine(4.4,10.2,8.3,10.2);
   line->Draw();
   
   pl = new TPaveLabel(4.9,9.945,8.105,10.455,"TCollection","br");
   pl->SetFillColor(18);
   pl->SetTextSize(0.9);
   pl->Draw();
   line = new TLine(4.4,7.65,8.3,7.65);
   line->Draw();
   line = new TLine(8.3,6.8,8.3,8.075);
   line->Draw();
   
   pl = new TPaveLabel(4.9,7.395,8.105,7.905,"TNamed","br");
   pl->SetFillColor(18);
   pl->SetTextSize(0.9);
   pl->Draw();
   line = new TLine(8.3,8.075,12.2,8.075);
   line->Draw();
   
   pl = new TPaveLabel(8.8,7.82,12.005,8.33,"AliSegmentArray","br");
   pl->SetFillColor(18);
   pl->SetTextSize(0.9);
   pl->Draw();
   line = new TLine(8.3,10.2,12.2,10.2);
   line->Draw();
   
   pl = new TPaveLabel(8.8,9.945,12.005,10.455,"TSeqCollection","br");
   pl->SetFillColor(18);
   pl->SetTextSize(0.9);
   pl->Draw();
   line = new TLine(8.3,6.8,8.8,6.8);
   line->Draw();
   
   pl = new TPaveLabel(8.8,6.545,12.005,7.055,"TTree","br");
   pl->SetFillColor(18);
   pl->SetTextSize(0.9);
   pl->Draw();
   line = new TLine(12.2,8.075,12.7,8.075);
   line->Draw();
   
   pl = new TPaveLabel(12.7,7.82,15.905,8.33,"AliTPCClustersArray","br");
   pl->SetFillColor(18);
   pl->SetTextSize(0.9);
   pl->Draw();
   line = new TLine(12.2,10.2,16.1,10.2);
   line->Draw();
   
   pl = new TPaveLabel(12.7,9.945,15.905,10.455,"TObjArray","br");
   pl->SetFillColor(18);
   pl->SetTextSize(0.9);
   pl->Draw();
   line = new TLine(16.1,10.2,16.6,10.2);
   line->Draw();
   
   pl = new TPaveLabel(16.6,9.945,19.805,10.455,"TClonesArray","br");
   pl->SetFillColor(18);
   pl->SetTextSize(0.9);
   pl->Draw();
   
   pl = new TPaveLabel(0.1,19.1,18.2,19.9,"*AliSegmet:*AliSegmentArray:*AliArrayI:*AliArrayS:TTree:*TObjArray","br");
   pl->SetFillColor(42);
   pl->SetTextSize(0.7);
   pl->Draw();
   line = new TLine(11.4041,6.8,14.3025,10.2);
   line->SetLineColor(6);
   line->SetLineStyle(3);
   line->Draw();
   line = new TLine(11.4842,6.8,14.3025,10.2);
   line->SetLineColor(6);
   line->SetLineStyle(3);
   line->Draw();
   line = new TLine(6.5025,12.325,6.5025,18.575);
   line->SetLineColor(4);
   line->SetLineStyle(2);
   line->Draw();
   line = new TLine(6.5025,11.475,6.5025,17.725);
   line->SetLineColor(4);
   line->SetLineStyle(2);
   line->Draw();
   line = new TLine(10.4025,6.8,2.6025,16.025);
   line->SetLineColor(4);
   line->SetLineStyle(2);
   line->Draw();
   line = new TLine(10.4025,6.8,2.6025,16.875);
   line->SetLineColor(4);
   line->SetLineStyle(2);
   line->Draw();
   line = new TLine(10.4025,6.8,2.6025,15.175);
   line->SetLineColor(4);
   line->SetLineStyle(2);
   line->Draw();
   TArrow *arrow = new TArrow(5.43417,10.2,6.5025,10.2,0.008,"|>");
   arrow->SetFillColor(2);
   arrow->SetFillStyle(1001);
   arrow->SetLineColor(2);
   arrow->Draw();
   arrow = new TArrow(6.85861,10.2,2.6025,9.775,0.008,"|>");
   arrow->SetFillColor(2);
   arrow->SetFillStyle(1001);
   arrow->SetLineColor(2);
   arrow->Draw();
   arrow = new TArrow(9.60125,8.075,14.3025,10.2,0.008,"|>");
   arrow->SetFillColor(2);
   arrow->SetFillStyle(1001);
   arrow->SetLineColor(2);
   arrow->Draw();
   arrow = new TArrow(10.1354,8.075,6.5025,12.325,0.008,"|>");
   arrow->SetFillColor(2);
   arrow->SetFillStyle(1001);
   arrow->SetLineColor(2);
   arrow->Draw();
   arrow = new TArrow(11.2037,8.075,10.4025,6.8,0.008,"|>");
   arrow->SetFillColor(2);
   arrow->SetFillStyle(1001);
   arrow->SetLineColor(2);
   arrow->Draw();
   arrow = new TArrow(13.9019,10.2,2.6025,9.775,0.008,"|>");
   arrow->SetFillColor(2);
   arrow->SetFillStyle(1001);
   arrow->SetLineColor(2);
   arrow->Draw();
   arrow = new TArrow(19.2708,10.2,14.3025,10.2,0.008,"|>");
   arrow->SetFillColor(2);
   arrow->SetFillStyle(1001);
   arrow->SetLineColor(2);
   arrow->Draw();
   ClassTree->Modified();
   ClassTree->cd();
}
Example #14
0
void rf106_plotdecoration()
{

  // S e t u p   m o d e l 
  // ---------------------

  // Create observables
  RooRealVar x("x","x",-10,10) ;

  // Create Gaussian
  RooRealVar sigma("sigma","sigma",1,0.1,10) ;
  RooRealVar mean("mean","mean",-3,-10,10) ;
  RooGaussian gauss("gauss","gauss",x,mean,sigma) ;

  // Generate a sample of 1000 events with sigma=3
  RooDataSet* data = gauss.generate(x,1000) ;

  // Fit pdf to data
  gauss.fitTo(*data) ;


  // P l o t   p . d . f   a n d   d a t a 
  // -------------------------------------

  // Overlay projection of gauss on data
  RooPlot* frame = x.frame(Name("xframe"),Title("RooPlot with decorations"),Bins(40)) ;
  data->plotOn(frame) ;
  gauss.plotOn(frame) ;


  // A d d   b o x   w i t h   p d f   p a r a m e t e r s 
  // -----------------------------------------------------

  // Left edge of box starts at 55% of Xaxis)
  gauss.paramOn(frame,Layout(0.55)) ;


  // A d d   b o x   w i t h   d a t a   s t a t i s t i c s
  // -------------------------------------------------------  

  // X size of box is from 55% to 99% of Xaxis range, top of box is at 80% of Yaxis range)
  data->statOn(frame,Layout(0.55,0.99,0.8)) ;


  // A d d   t e x t   a n d   a r r o w 
  // -----------------------------------

  // Add text to frame
  TText* txt = new TText(2,100,"Signal") ;
  txt->SetTextSize(0.04) ;
  txt->SetTextColor(kRed) ;
  frame->addObject(txt) ;

  // Add arrow to frame
  TArrow* arrow = new TArrow(2,100,-1,50,0.01,"|>") ;
  arrow->SetLineColor(kRed) ;
  arrow->SetFillColor(kRed) ;
  arrow->SetLineWidth(3) ;
  frame->addObject(arrow) ;


  // P e r s i s t   f r a m e   w i t h   a l l   d e c o r a t i o n s   i n   R O O T   f i l e
  // ---------------------------------------------------------------------------------------------

  TFile f("rf106_plotdecoration.root","RECREATE") ;
  frame->Write() ;
  f.Close() ;

  // To read back and plot frame with all decorations in clean root session do
  // root> TFile f("rf106_plotdecoration.root") ;
  // root>  xframe->Draw() ;

  new TCanvas("rf106_plotdecoration","rf106_plotdecoration",600,600) ;
  gPad->SetLeftMargin(0.15) ; frame->GetYaxis()->SetTitleOffset(1.6) ; frame->Draw() ;
  
}
Example #15
0
void EvtSel_Q2Pmiss(){

  Styles style2; style2.setPadsStyle(2); style2.applyStyle();

  TString NameTrees[3] = {"AWG82/ntuples/small/RAll_RunAll.root", 
			  "AWG82/ntuples/small/uds_RunAll.root", "AWG82/ntuples/small/ccbar_RunAll.root"};
  TChain gen("ntp1"), cont("ntp1");
  gen.Add(NameTrees[0]);
  for(int t=1; t<3; t++) cont.Add(NameTrees[t]);
  double totMCB = 0, totuds = 0, totccbar = 0, totdata = 0, totOffdata = 0;
  getNumberB(NameTrees[0], "All", totMCB, totdata, totuds, totccbar, totOffdata);
  double wuds = totMCB/totuds*2.09/1.05;     

  TH1F *hCount = new TH1F("hCount","",100,-4,12);
  gen.Draw("candM2>>hCount","weight");
  double nTotal = hCount->Integral();
  cont.Draw("candM2>>hCount","weight");
  nTotal += hCount->Integral()*wuds;

  TLine line; line.SetLineStyle(2); line.SetLineColor(28); line.SetLineWidth(2);
  TArrow arrow; arrow.SetLineColor(28); arrow.SetFillColor(28); arrow.SetLineWidth(2);
  TCanvas can("can","Pmiss and q2 cuts");
  can.Divide(2,1); TPad *cPad = (TPad *)can.cd(1);
  int bins[] = {42,40}, colors[2][4] = {{8,4,1,3},{8,2,4,1}};
  double xrange[2][2] = {{0,4.2},{-3,13}}, yield[2][4], maxi[] = {-99,-99};
  TString Variable[] = {"candPMiss","candQ2"};
  TString labels[2][4] = {{"Signal (", "Normaliz. (","Had. bkg. (",""},
 			  {"Signal (", "D l #nu (", "D* l #nu (", "Bkg. ("}};
//   TString labels[2][4] = {{"Signal", "Normaliz.","Had. Bkg.",""},
// 			  {"Signal", "D l #nu", "D* l #nu", "Bkg."}};
  TString cuts[2][4] = {{"(candType<3&&MCType>4&&MCType<7||candType>2&&MCType>10&&MCType<13)*weight",
			 "(candType<3&&MCType>0&&MCType<5||candType>2&&MCType>6&&MCType<11)*weight",
			 "(MCType==0&&MCCombmode==12)*weight", ""},
			{"(candType<3&&MCType>4&&MCType<7||candType>2&&MCType>10&&MCType<13)*weight",
			 "(candType<3&&(MCType==1||MCType==3)||candType>2&&(MCType==7||MCType==9))*weight",
			 "(candType<3&&(MCType==2||MCType==4)||candType>2&&(MCType==8||MCType==10))*weight",
			 "(!(candType<3&&MCType>0&&MCType<7||candType>2&&MCType>6&&MCType<13))*weight"}};
  double legW = 0.4, legH = 0.225;
  double legX = 1-style2.PadRightMargin-0.02, legY = 1-style2.PadTopMargin-0.02;
  TLegend *leg[2];
  leg[0] = new TLegend(legX-legW, legY-legH, legX, legY);
  legW = 0.24; legH = 0.285; legX = 0.47;
  leg[1] = new TLegend(legX-legW, legY-legH, legX, legY);
  TH1F* h[2][4];
  for(int pad=0; pad<2; pad++){
    leg[pad]->SetTextSize(style2.LabelSize); leg[pad]->SetFillColor(0); 
    leg[pad]->SetTextFont(style2.nFont);  leg[pad]->SetBorderSize(0);
    for(int i=0; i<4; i++) {
      if(pad==0 && i==3) continue;
      TString hname = "h"; hname += pad; hname += i;
      h[pad][i] = new TH1F(hname,"",bins[pad],xrange[pad][0],xrange[pad][1]);
      h[pad][i]->SetLineWidth(2);  h[pad][i]->SetLineColor(colors[pad][i]);
      TString vari = Variable[pad]; vari += ">>"; vari += hname;
      gen.Draw(vari,cuts[pad][i]);
      if(i==3){
	hname = "hCont"; hname += pad; hname += i;
	TH1F *hCont = new TH1F(hname,"",bins[pad],xrange[pad][0],xrange[pad][1]);
	TString vari = Variable[pad]; vari += ">>"; vari += hname;
	cont.Draw(vari,cuts[pad][i]);
	hCont->Scale(wuds);
	h[pad][i]->Add(hCont);
	hCont->Delete();
      }
      yield[pad][i] = h[pad][i]->Integral();
      h[pad][i]->Scale(1000/h[pad][i]->Integral());
      if(h[pad][i]->GetMaximum()>maxi[pad]) maxi[pad] = h[pad][i]->GetMaximum();
      labels[pad][i] += RoundNumber(yield[pad][i]*100,0,nTotal); labels[pad][i] += "%)";
      leg[pad]->AddEntry(h[pad][i],labels[pad][i]);
    }
    h[pad][0]->SetMaximum(maxi[pad]*1.22);
  }
  h[0][0]->Draw();
  style2.fixYAxis(h[0][0],cPad);
  style2.setTitles(h[0][0],"|p_{miss}| (GeV)","Entries/(100 MeV)","a)");
  h[0][1]->Draw("same");h[0][2]->Draw("same");
  leg[0]->Draw();
  line.DrawLine(0.2,h[0][0]->GetMinimum(), 0.2,maxi[0]/1.45);
  arrow.DrawArrow(0.2,maxi[0]/1.65,0.5,maxi[0]/1.65,0.01,"|>");


  cPad = (TPad *)can.cd(2);
  h[1][0]->Draw();
  style2.fixYAxis(h[1][0],cPad);
  style2.setTitles(h[1][0],"q^{2} (GeV^{2})","Entries/(0.4 GeV^{2})","b)");
  h[1][1]->Draw("same"); h[1][2]->Draw("same"); h[1][3]->Draw("same");
  leg[1]->Draw();
  line.DrawLine(4,h[1][0]->GetMinimum(), 4,maxi[1]/1.45);
  arrow.DrawArrow(4,maxi[1]/1.65,5.4,maxi[1]/1.65,0.01,"|>");

  TString pName = "public_html/EvtSel_Q2Pmiss.eps"; 
  can.SaveAs(pName);
  for(int pad=0; pad<2; pad++){
    leg[pad]->Delete();
    for(int i=0; i<4; i++){
      if(pad==0 && i==3) continue;
      h[pad][i]->Delete();
    }
  }
  hCount->Delete();
}