void makePlots_hlt_eventbyevent_comparison( std::string inputFile_="input.root", std::string target_label_="Target", std::string outputSuffix_="_out" ) {

  TFile *file = new TFile(inputFile_.c_str());

  std::string dirprefix = "Images" + outputSuffix_;
  struct stat st;
  if( stat(dirprefix.c_str(),&st) != 0 )  mkdir(dirprefix.c_str(),0777);

  std::string label_ref = "Reference";
  std::string label_tgt = target_label_;

  TH1D* h_ref = (TH1D*)file->Get("eventbyevent/HLT_Ref");
  TH1D* h_tgt = (TH1D*)file->Get("eventbyevent/HLT_Tgt");
  TH1D* h_tgt_sep = (TH1D*)file->Get("eventbyevent/HLT_Tgt_sep");

  std::map<std::string, int> hlt_counts_per_path_ref_;
  std::map<std::string, int> hlt_counts_per_path_tgt_;
  std::map<double, std::string> hlt_counts_per_path_diff_;

  std::vector<std::string> hlt_common_paths;

  TAxis * axis = h_ref->GetXaxis();

  // loop over target paths
  for( int iPath=0; iPath<h_tgt_sep->GetNbinsX(); iPath++ ){
    std::string name(h_tgt_sep->GetXaxis()->GetBinLabel(iPath+1));
    
    int bin = axis->FindBin(name.c_str());

    if( bin<1 ) continue;

    double cnt_ref = h_ref->GetBinContent(bin);
    double cnt_tgt = h_tgt->GetBinContent(bin);

    int diff = int( cnt_ref - cnt_tgt );
    double rel_diff = double(diff);

    if( cnt_ref>0 )      rel_diff = fabs(cnt_tgt - cnt_ref)/cnt_ref;
    else if( cnt_tgt>0 ) rel_diff = fabs(cnt_tgt - cnt_ref)/cnt_tgt;
    else                 rel_diff = 0.;

    // printf("%s\t %d\t %d\t %d\t %.3f \n",
    // 	   name.c_str(), int(cnt_ref), int(cnt_tgt), diff, rel_diff ); 

    hlt_counts_per_path_ref_[name] = int(cnt_ref);
    hlt_counts_per_path_tgt_[name] = int(cnt_tgt);

    hlt_counts_per_path_diff_[rel_diff] = name;

    if( rel_diff>0.15 ) hlt_common_paths.push_back(name);
  }


  std::map<double, std::string>::reverse_iterator rit;
  for( rit=hlt_counts_per_path_diff_.rbegin(); rit!=hlt_counts_per_path_diff_.rend(); ++rit )
    std::cout << "path: " << rit->second << "\t" << rit->first << "\t" << hlt_counts_per_path_ref_[rit->second] << "\t" << hlt_counts_per_path_tgt_[rit->second] << std::endl;


  int numPaths = int( hlt_counts_per_path_ref_.size() );
  TH1D* h_hlt_ref = new TH1D("h_hlt_ref",";HLT path", numPaths, 0, numPaths );
  TH1D* h_hlt_tgt = new TH1D("h_hlt_tgt",";HLT path", numPaths, 0, numPaths );
  TH1D* h_hlt_diff = new TH1D("h_hlt_diff",";HLT path", numPaths, 0, numPaths );

  int iHLT=0;
  for( std::map<std::string, int>::iterator it=hlt_counts_per_path_ref_.begin(); it!=hlt_counts_per_path_ref_.end(); ++it ){
    iHLT++;
    std::string name = it->first;

    double cnt_ref = double(hlt_counts_per_path_ref_[name]);
    double cnt_tgt = double(hlt_counts_per_path_tgt_[name]);

    double rel_diff = 1.0;
    if( cnt_ref>0 )      rel_diff = (cnt_tgt - cnt_ref)/cnt_ref;
    else if( cnt_tgt>0 ) rel_diff = (cnt_tgt - cnt_ref)/cnt_tgt;
    else                 rel_diff = 0.;

    h_hlt_ref->SetBinContent(iHLT,cnt_ref);
    h_hlt_tgt->SetBinContent(iHLT,cnt_tgt);
    h_hlt_diff->SetBinContent(iHLT,rel_diff);

    h_hlt_ref->GetXaxis()->SetBinLabel(iHLT,name.c_str());
    h_hlt_diff->GetXaxis()->SetBinLabel(iHLT,name.c_str());
  }


  h_hlt_ref->SetStats(0);

  h_hlt_ref->SetLineColor(kBlue);
  h_hlt_tgt->SetLineColor(kRed);

  if( true ){
    // TLegend *legend = new TLegend(0.255,0.78,0.92,0.89);
    TLegend *legend = new TLegend(0.255,0.92,0.92,0.99);

    legend->SetFillColor(kWhite);
    legend->SetLineColor(kWhite);
    legend->SetShadowColor(kWhite);
    legend->SetTextFont(42);
    legend->SetTextSize(0.035);

    legend->SetNColumns(2);

    legend->AddEntry(h_hlt_ref,label_ref.c_str(),"l");
    legend->AddEntry(h_hlt_tgt,label_tgt.c_str(),"l");


    //// Original
    // double ratioMin = -1.2;
    // double ratioMax = 1.2;
    double ratioMin = -0.6;
    double ratioMax = 0.6;

    //Hack to get it plotted with ratio plot
    TCanvas* myC = new TCanvas("myC", "myC", 1200,700);

    gStyle->SetPadBorderMode(0);
    gStyle->SetFrameBorderMode(0);
    Float_t small = 1.e-5;
    myC->Divide(1,2,small,small);
    const float padding=1e-5; const float ydivide=0.3;
    myC->GetPad(1)->SetPad( padding, ydivide + padding , 1-padding, 1-padding);
    myC->GetPad(2)->SetPad( padding, padding, 1-padding, ydivide-padding);
    myC->GetPad(1)->SetLeftMargin(.11);
    myC->GetPad(2)->SetLeftMargin(.11);
    myC->GetPad(1)->SetRightMargin(.05);
    myC->GetPad(2)->SetRightMargin(.05);
    myC->GetPad(1)->SetBottomMargin(.3);
    myC->GetPad(2)->SetBottomMargin(.3);
    myC->GetPad(1)->Modified();
    myC->GetPad(2)->Modified();
    myC->cd(1);
    gPad->SetBottomMargin(small);
    gPad->Modified();



    TH1D* myRatio = (TH1D*)h_hlt_diff->Clone("myRatio");

    myRatio->SetStats(0);
    myRatio->Sumw2();
    myRatio->SetLineColor(kBlack);
    myRatio->SetMarkerColor(kBlack);

    myRatio->SetMinimum(ratioMin);
    myRatio->SetMaximum(ratioMax);
    //myRatio->GetYaxis()->SetNdivisions(50000+404);
    myRatio->GetYaxis()->SetNdivisions(20000+505);
    myRatio->GetYaxis()->SetLabelSize(0.1); //make y label bigger
    myRatio->GetXaxis()->SetLabelSize(0.1); //make y label bigger
    myRatio->GetXaxis()->SetTitleOffset(1.1);
    myRatio->GetXaxis()->SetTitle(h_hlt_diff->GetXaxis()->GetTitle()); //make y label bigger
    myRatio->GetXaxis()->SetLabelSize(0.12);
    myRatio->GetXaxis()->SetLabelOffset(0.04);
    myRatio->GetXaxis()->SetTitleSize(0.12);
    // myRatio->GetYaxis()->SetTitle("Data/MC");
    myRatio->GetYaxis()->SetTitle("New - Old / Old");
    myRatio->GetYaxis()->SetTitleSize(0.1);
    myRatio->GetYaxis()->SetTitleOffset(.45);
    myC->cd(2);
    gPad->SetTopMargin(small);
    gPad->SetTickx();
    gPad->Modified();

    myC->cd(1);

    h_hlt_ref->GetYaxis()->SetTitle("Number of Events");
    h_hlt_ref->GetYaxis()->SetTitleSize(0.05);
    h_hlt_ref->GetYaxis()->SetTitleOffset(.95);

    h_hlt_ref->Draw();
    h_hlt_tgt->Draw("same");

    legend->Draw();

    double xmin = h_hlt_ref->GetBinLowEdge(1);
    double xmax = h_hlt_ref->GetBinLowEdge(h_hlt_ref->GetNbinsX()) + h_hlt_ref->GetBinWidth(h_hlt_ref->GetNbinsX());

    myC->cd(2);

    myRatio->SetLineWidth(2);

    myRatio->Draw("hist");

    TLine* myLine;
    myLine = new TLine(xmin, 0, xmax, 0);
    myLine->Draw();

    std::string outputFile = dirprefix + "/hlt_path_comparison" + outputSuffix_ + ".pdf";
    myC->Print(outputFile.c_str());

    delete legend;
    delete myC;
    delete myLine;
  }


  if( true ){
    int numCommonPaths = int(hlt_common_paths.size());

    for( int iPath=0; iPath<numCommonPaths; iPath++ ){
      std::cout << " ====================== " << std::endl;
      std::string name = hlt_common_paths[iPath];
      std::string pathName_ref = "eventbyevent/h_path_ref_" + name;
      std::string pathName_tgt = "eventbyevent/h_path_tgt_" + name;

      std::string diffname = "h_path_diff_" + name;

      //std::cout << " path is " << pathName_ref << std::endl;

      if( name=="HLT_LogMonitor" ) continue;

      TH1D* h_hlt_filt_ref = (TH1D*)file->Get(pathName_ref.c_str());
      TH1D* h_hlt_filt_tgt = (TH1D*)file->Get(pathName_tgt.c_str());
      TH1D* h_hlt_filt_diff = (TH1D*)h_hlt_filt_ref->Clone(diffname.c_str());

      bool printOut = true;
      for( int iBin=0; iBin<h_hlt_filt_tgt->GetNbinsX(); iBin++ ){
	double cnt_ref = h_hlt_filt_ref->GetBinContent(iBin+1);
	double cnt_tgt = h_hlt_filt_tgt->GetBinContent(iBin+1);

	double rel_diff = 1.0;
	if( cnt_ref>0 )      rel_diff = (cnt_tgt - cnt_ref)/cnt_ref;
	else if( cnt_tgt>0 ) rel_diff = (cnt_tgt - cnt_ref)/cnt_tgt;
	else                 rel_diff = 0.;

	h_hlt_filt_diff->SetBinContent(iBin+1,rel_diff);

	//if( fabs(rel_diff)>0.0002 ) printOut = true;
      }

      if( printOut ){
	double cnt_ref = double(hlt_counts_per_path_ref_[name]);
	double cnt_tgt = double(hlt_counts_per_path_tgt_[name]);

	double rel_diff = 1.0;
	if( cnt_ref>0 )      rel_diff = (cnt_tgt - cnt_ref)/cnt_ref;
	else if( cnt_tgt>0 ) rel_diff = (cnt_tgt - cnt_ref)/cnt_tgt;
	else                 rel_diff = 0.;

	printf("%s: relative difference = %.3f,\t reference = %d,\t target = %d \n",
	       name.c_str(), rel_diff, hlt_counts_per_path_ref_[name], hlt_counts_per_path_tgt_[name]);

	for( int iBin=0; iBin<h_hlt_filt_tgt->GetNbinsX(); iBin++ ){
	  double my_cnt_ref = h_hlt_filt_ref->GetBinContent(iBin+1);
	  double my_cnt_tgt = h_hlt_filt_tgt->GetBinContent(iBin+1);

	  double my_rel_diff = 1.0;
	  if( my_cnt_ref>0 )      my_rel_diff = (my_cnt_tgt - my_cnt_ref)/my_cnt_ref;
	  else if( my_cnt_tgt>0 ) my_rel_diff = (my_cnt_tgt - my_cnt_ref)/my_cnt_tgt;
	  else                   my_rel_diff = 0.;

	  printf("\t %s \t %.3f \t %.0f \t %.0f \n",
		 h_hlt_filt_ref->GetXaxis()->GetBinLabel(iBin+1), my_rel_diff, my_cnt_ref, my_cnt_tgt);
	}
      }

      h_hlt_filt_ref->SetStats(0);

      h_hlt_filt_ref->SetLineColor(kBlue);
      h_hlt_filt_tgt->SetLineColor(kRed);

      //TLegend *legend = new TLegend(0.255,0.78,0.92,0.89);
      TLegend *legend = new TLegend(0.255,0.92,0.92,0.99);

      legend->SetFillColor(kWhite);
      legend->SetLineColor(kWhite);
      legend->SetShadowColor(kWhite);
      legend->SetTextFont(42);
      legend->SetTextSize(0.035);

      legend->SetNColumns(2);

      legend->AddEntry(h_hlt_filt_ref,label_ref.c_str(),"l");
      legend->AddEntry(h_hlt_filt_tgt,label_tgt.c_str(),"l");


      double ratioMin = -1.2;
      double ratioMax = 1.2;

      //Hack to get it plotted with ratio plot
      TCanvas* myC = new TCanvas("myC", "myC", 600,700);

      gStyle->SetPadBorderMode(0);
      gStyle->SetFrameBorderMode(0);
      Float_t small = 1.e-5;
      myC->Divide(1,2,small,small);
      const float padding=1e-5; const float ydivide=0.3;
      myC->GetPad(1)->SetPad( padding, ydivide + padding , 1-padding, 1-padding);
      myC->GetPad(2)->SetPad( padding, padding, 1-padding, ydivide-padding);
      myC->GetPad(1)->SetLeftMargin(.11);
      myC->GetPad(2)->SetLeftMargin(.11);
      myC->GetPad(1)->SetRightMargin(.05);
      myC->GetPad(2)->SetRightMargin(.05);
      myC->GetPad(1)->SetBottomMargin(.3);
      myC->GetPad(2)->SetBottomMargin(.3);
      myC->GetPad(1)->Modified();
      myC->GetPad(2)->Modified();
      myC->cd(1);
      gPad->SetBottomMargin(small);
      gPad->Modified();



      TH1D* myRatio = (TH1D*)h_hlt_filt_diff->Clone();

      myRatio->SetStats(0);
      myRatio->Sumw2();
      myRatio->SetLineColor(kBlack);
      myRatio->SetMarkerColor(kBlack);

      myRatio->SetMinimum(ratioMin);
      myRatio->SetMaximum(ratioMax);
      myRatio->GetYaxis()->SetNdivisions(50000+404);
      myRatio->GetYaxis()->SetLabelSize(0.1); //make y label bigger
      myRatio->GetXaxis()->SetLabelSize(0.1); //make y label bigger
      myRatio->GetXaxis()->SetTitleOffset(1.1);
      myRatio->GetXaxis()->SetTitle(h_hlt_diff->GetXaxis()->GetTitle()); //make y label bigger
      myRatio->GetXaxis()->SetLabelSize(0.12);
      myRatio->GetXaxis()->SetLabelOffset(0.04);
      myRatio->GetXaxis()->SetTitleSize(0.12);
      // myRatio->GetYaxis()->SetTitle("Data/MC");
      myRatio->GetYaxis()->SetTitle("New - Old / Old");
      myRatio->GetYaxis()->SetTitleSize(0.1);
      myRatio->GetYaxis()->SetTitleOffset(.45);
      myC->cd(2);
      gPad->SetTopMargin(small);
      gPad->SetTickx();
      gPad->Modified();

      myC->cd(1);

      h_hlt_filt_ref->GetYaxis()->SetTitle("Number of Events");
      h_hlt_filt_ref->GetYaxis()->SetTitleSize(0.05);
      h_hlt_filt_ref->GetYaxis()->SetTitleOffset(.95);

      h_hlt_filt_ref->Draw();
      h_hlt_filt_tgt->Draw("same");

      legend->Draw();

      double xmin = h_hlt_filt_ref->GetBinLowEdge(1);
      double xmax = h_hlt_filt_ref->GetBinLowEdge(h_hlt_filt_ref->GetNbinsX()) + h_hlt_filt_ref->GetBinWidth(h_hlt_filt_ref->GetNbinsX());

      myC->cd(2);

      myRatio->SetLineWidth(2);

      myRatio->Draw("hist");

      TLine* myLine;
      myLine = new TLine(xmin, 0, xmax, 0);
      myLine->Draw();

      std::string outputFile = dirprefix + "/hlt_path_" + name + outputSuffix_ + ".pdf";
      myC->Print(outputFile.c_str());

      delete legend;
      delete myC;
      delete myLine;
    }
    std::cout << " ====================== " << std::endl;

  }

  // close file
  file->Close();

}
コード例 #2
0
ファイル: ProofEventProc.C プロジェクト: adevress/root-1
//_____________________________________________________________________________
void ProofEventProc::Terminate()
{
   // The Terminate() function is the last function to be called during
   // a query. It always runs on the client, it can be used to present
   // the results graphically or save the results to file.

   // Check ranges
   CheckRanges();

   if (gROOT->IsBatch()) return;
   
   TCanvas* canvas = new TCanvas("event","event",800,10,700,780);
   canvas->Divide(2,2);
   TPad *pad1 = (TPad *) canvas->GetPad(1);
   TPad *pad2 = (TPad *) canvas->GetPad(2);
   TPad *pad3 = (TPad *) canvas->GetPad(3);
   TPad *pad4 = (TPad *) canvas->GetPad(4);

   // The number of tracks
   pad1->cd();
   pad1->SetLogy();
   TH1F *hi = dynamic_cast<TH1F*>(fOutput->FindObject("pz_dist"));
   if (hi) {
      hi->SetFillColor(30);
      hi->SetLineColor(9);
      hi->SetLineWidth(2);
      hi->DrawCopy();
   } else { Warning("Terminate", "no pz dist found"); }

   // The Pt distribution
   pad2->cd();
   pad2->SetLogy();
   TH1F *hf = dynamic_cast<TH1F*>(fOutput->FindObject("pt_dist"));
   if (hf) {
      hf->SetFillColor(30);
      hf->SetLineColor(9);
      hf->SetLineWidth(2);
      hf->DrawCopy();
   } else { Warning("Terminate", "no pt dist found"); }

   // The Px,Py distribution, color surface
   TH2F *h2f = dynamic_cast<TH2F*>(fOutput->FindObject("px_py"));
   if (h2f) {
      // Color surface
      pad3->cd();
      h2f->DrawCopy("SURF1 ");
      // Lego
      pad4->cd();
      h2f->DrawCopy("CONT2COL");
   } else {
      Warning("Terminate", "no px py found");
   }

   // Final update
   canvas->cd();
   canvas->Update();
}
コード例 #3
0
ファイル: CheckTagger.C プロジェクト: zahmed9/acqu
CheckTagger() {
    Char_t* hname[] = {
        "FPD_Nhits", "FPD_NhitsPrompt", "FPD_NhitsRand",
        "FPD_Hits", "FPD_ScalerCurr", "FPD_ScalerAcc",
        "FPD_EnergyOR","FPD_TimeOR","TAGG_PhotonEnergy",
        "FPD_Hits_v_EnergyOR",
        "FPD_Hits_v_TimeOR",
        "TAGG_Micro_Hits_v_FPD_Hits",
    };
    Int_t log[] = { 0,0,0,0,1,1,0,0,0 };
    Int_t col[] = { 2,2,2,4,5,5,3,3,3 };
    Char_t* xname[] = {
        "Number of Tagger Hits per Event",
        "Number of Prompt Tagger Hits per Event",
        "Number of Random Tagger Hits per Event",
        "Tagger Hits distribution",
        "Tagger Current Scaler Read",
        "Tagger Accumulated Scalers",
        "Tagger Pulse-Height (MeV)",
        "Tagger Time (ns)",
        "Tagger Photon Energy",
        "Tagger Pulse-Height vs Hits",
        "Tagger Time vs Hits",
        "Microscope Hits vs Tagger Hits",
    };
    TH1F* h1;
    TCanvas* canv;
    //
    canv = new TCanvas("Tagger-Spectra","Tagger-Online",240,180,1240,890);
    canv->SetFillStyle(4000);
    canv->Divide(3,4,0.01,0.01);
    for( Int_t i=0; i<9; i++ ) {
        h1 = (TH1F*)(gROOT->FindObject(hname[i]));
        if( !h1 ) {
            printf("No root histogram %s\n",hname[i]);
            continue;
        }
        h1->SetLineColor( 1 );
        h1->SetFillColor( col[i] );
        canv->cd(i+1);
        if( log[i] ) canv->GetPad(i+1)->SetLogy();
        h1->GetXaxis()->SetTitle(xname[i]);
        h1->Draw();
    }
    //  return;
    TH2F* h2;
    for( Int_t i=9; i<12; i++ ) {
        h2 = (TH2F*)(gROOT->FindObject(hname[i]));
        if( !h2 ) {
            printf("No root histogram %s\n",hname[i]);
            continue;
        }
        canv->cd(i+1);
        h2->GetXaxis()->SetTitle(xname[i]);
        h2->Draw("COLZ");
    }
    return;
}
コード例 #4
0
ファイル: PlotFromMillepedeRes.C プロジェクト: ANSH0712/cmssw
void PlotParValVsLabelWithErr(TFile* f, TTree* tr, TString strMillepedeRes, TString strOutdir)
{
 
  f->cd();
  TString canvName="c_";
  canvName+=strMillepedeRes;
  canvName+="_";
  canvName+=StrPlotType(PARSwithERRvsLABEL);
  canvName.ReplaceAll(".res","");

  TCanvas* canv = new TCanvas(canvName,canvName,900,600);
  canv->Divide(3,2);

  for (int ind=1; ind<=6; ind++){
    canv->cd(ind);
    TPad* pad = (TPad*)canv->GetPad(ind);
    TString strCut="((label%20-1)%9+1)==";
    strCut+=ind;
    int n = tr->Draw("label%700000:10000*parVal:10000*parErr:0.01*(label%700000)",strCut,"goff");
    TGraphErrors *gr = new TGraphErrors(n,tr->GetV1(),tr->GetV2(),tr->GetV4(),tr->GetV3());
    gr->SetMarkerStyle(20);
    gr->SetLineWidth(2);
    for (int i=0; i<n; i++){
      std::cout<<tr->GetV1()[i]<<" "<<tr->GetV2()[i]<<"+-"<<tr->GetV3()[i]<<std::endl;
    }
    gr->SetTitle(StrPar(ind)+TString(", 10000*(par+-err)"));
    gr->GetXaxis()->SetTitle("label%700000");
    gr->Draw("AP");
  }// end of loop over ind
  canvName+=".png";
  TString saveName=strOutdir+canvName;
  canv->SaveAs(saveName);
  saveName.ReplaceAll(".png",".pdf");
  canv->SaveAs(saveName);

}// end of PlotParValVsLabelWithErr
コード例 #5
0
ファイル: DrawKinvarPlot.C プロジェクト: c-dilks/spinlong
void DrawKinvarPlot(TString filename="kinvarset/FMSOR_Pt_vs_run.root",
                    TString classname="pi0") {
  TFile * infile = new TFile(filename.Data(),"READ");

  char trig[32];
  char typ[32];
  char tmp[128];
  TString tmpstr = filename;
  tmpstr.ReplaceAll("_"," ");
  TRegexp re("^.*\/");
  tmpstr(re) = "";
  cout << tmpstr << endl;
  sscanf(tmpstr.Data(),"%s %s",trig,typ);
  printf("%s %s\n",trig,typ);

  TString hname = "h2_"+classname;
  TH2D * h = (TH2D*)infile->Get(hname.Data());
  TString gname = "g_"+classname;
  TGraphErrors * g = (TGraphErrors*)infile->Get(gname.Data());
  TString gtname = "gt_"+classname;
  TGraphErrors * gt;
  if(!strcmp(typ,"Pt")) gt = (TGraphErrors*)infile->Get(gtname.Data());
  
  char htitle[256];
  char hnewtitle[512];
  strcpy(htitle,h->GetTitle());
  sprintf(hnewtitle,"%s -- %s triggers",htitle,trig);
  h->SetTitle(hnewtitle);

  h->SetMinimum(0.001);

  if(!strcmp(typ,"Pt")) {
    gt->SetLineWidth(2);
    gt->SetLineColor(kBlack);
  };

  // temporary hack to cut out fluctuations of pt_thresh vs. run to 0
  Double_t xx,yy;
  Int_t gtn = gt->GetN();
  for(int ii=0; ii<gtn; ii++) {
    gt->GetPoint(ii,xx,yy);
    printf("xx=%f yy=%f\n",xx,yy);
    if(yy<0.001) gt->RemovePoint(ii);
  };
   
  // drawing range
  Float_t xmin = h->GetXaxis()->GetXmin();
  Float_t xmax = h->GetXaxis()->GetXmax();
  xmax = 515;
  if(xmax<gtn) { 
    fprintf(stderr,"\nWARNING: xmax < gt->GetN(); graphs will be cut off!\n\n");
  };
  
  TCanvas * c = new TCanvas("c","c",1500,700);
  c->Divide(1,2);
  gStyle->SetOptStat(0);
  for(int x=1; x<=2; x++) c->GetPad(x)->SetGrid(1,1);
  c->cd(1);
  c->GetPad(1)->SetLogz();
  h->GetXaxis()->SetRangeUser(xmin,xmax);
  h->Draw("colz");
  if(!strcmp(typ,"Pt")) gt->Draw("LX");
  c->cd(2);
  g->SetFillColor(kGray);
  printf("%f %f\n",xmin,xmax);
  g->GetXaxis()->SetLimits(xmin,xmax);
  g->GetXaxis()->SetRangeUser(xmin,xmax);
  /*
  g->Draw("A3");
  g->Draw("PLX");
  */
  g->Draw("APLX");
  
  TString outname = filename.ReplaceAll(".root"," "+classname);
  outname = outname+".png";
  c->Print(outname.Data(),"png");
};
コード例 #6
0
ファイル: mvas.C プロジェクト: aocampor/UGentSUSY
// input: - Input file (result from TMVA)
//        - use of TMVA plotting TStyle
void mvas( TString fin = "TMVA.root", HistType htype = MVAType, Bool_t useTMVAStyle = kTRUE )
{
   // set style and remove existing canvas'
   TMVAGlob::Initialize( useTMVAStyle );

   // switches
   const Bool_t Save_Images     = kTRUE;

   // checks if file with name "fin" is already open, and if not opens one
   TFile* file = TMVAGlob::OpenFile( fin );  

   // define Canvas layout here!
   Int_t xPad = 1; // no of plots in x
   Int_t yPad = 1; // no of plots in y
   Int_t noPad = xPad * yPad ; 
   const Int_t width = 600;   // size of canvas

   // this defines how many canvases we need
   TCanvas *c = 0;

   // counter variables
   Int_t countCanvas = 0;

   // search for the right histograms in full list of keys
   TIter next(file->GetListOfKeys());
   TKey *key(0);   
   while ((key = (TKey*)next())) {

      if (!TString(key->GetName()).BeginsWith("Method_")) continue;
      if( ! gROOT->GetClass(key->GetClassName())->InheritsFrom("TDirectory") ) continue;

      TString methodName;
      TMVAGlob::GetMethodName(methodName,key);

      TDirectory* mDir = (TDirectory*)key->ReadObj();

      TIter keyIt(mDir->GetListOfKeys());
      TKey *titkey;
      while ((titkey = (TKey*)keyIt())) {
         if (!gROOT->GetClass(titkey->GetClassName())->InheritsFrom("TDirectory")) continue;

         TDirectory *titDir = (TDirectory *)titkey->ReadObj();
         TString methodTitle;
         TMVAGlob::GetMethodTitle(methodTitle,titDir);

         cout << "--- Found directory for method: " << methodName << "::" << methodTitle << flush;
         TString hname = "MVA_" + methodTitle;
         if      (htype == ProbaType  ) hname += "_Proba";
         else if (htype == RarityType ) hname += "_Rarity";
         TH1* sig = dynamic_cast<TH1*>(titDir->Get( hname + "_S" ));
         TH1* bgd = dynamic_cast<TH1*>(titDir->Get( hname + "_B" ));

         if (sig==0 || bgd==0) {
            if     (htype == MVAType)     
               cout << "mva distribution not available (this is normal for Cut classifier)" << endl;
            else if(htype == ProbaType)   
               cout << "probability distribution not available (this is normal for Cut classifier)" << endl;
            else if(htype == RarityType)  
               cout << "rarity distribution not available (this is normal for Cut classifier)" << endl;
            else if(htype == CompareType) 
               cout << "overtraining check not available (this is normal for Cut classifier)" << endl;
            else cout << endl;
         } 
         else {
            cout << endl;
            // chop off useless stuff
            sig->SetTitle( Form("TMVA response for classifier: %s", methodTitle.Data()) );
            if      (htype == ProbaType) 
               sig->SetTitle( Form("TMVA probability for classifier: %s", methodTitle.Data()) );
            else if (htype == RarityType) 
               sig->SetTitle( Form("TMVA Rarity for classifier: %s", methodTitle.Data()) );
            else if (htype == CompareType) 
               sig->SetTitle( Form("TMVA overtraining check for classifier: %s", methodTitle.Data()) );
         
            // create new canvas
            TString ctitle = ((htype == MVAType) ? 
                              Form("TMVA response %s",methodTitle.Data()) : 
                              (htype == ProbaType) ? 
                              Form("TMVA probability %s",methodTitle.Data()) :
                              (htype == CompareType) ? 
                              Form("TMVA comparison %s",methodTitle.Data()) :
                              Form("TMVA Rarity %s",methodTitle.Data()));
         
            TString cname = ((htype == MVAType) ? 
                             Form("output_%s",methodTitle.Data()) : 
                             (htype == ProbaType) ? 
                             Form("probability_%s",methodTitle.Data()) :
                             (htype == CompareType) ? 
                             Form("comparison_%s",methodTitle.Data()) :
                             Form("rarity_%s",methodTitle.Data()));

            c = new TCanvas( Form("canvas%d", countCanvas+1), ctitle, 
                             countCanvas*50+200, countCanvas*20, width, (Int_t)width*0.78 ); 
    
            // set the histogram style
            TMVAGlob::SetSignalAndBackgroundStyle( sig, bgd );
   
            // normalise both signal and background
            TMVAGlob::NormalizeHists( sig, bgd );
   
            // frame limits (choose judicuous x range)
            Float_t nrms = 4;
            cout << "--- Mean and RMS (S): " << sig->GetMean() << ", " << sig->GetRMS() << endl;
            cout << "--- Mean and RMS (B): " << bgd->GetMean() << ", " << bgd->GetRMS() << endl;
            Float_t xmin = TMath::Max( TMath::Min(sig->GetMean() - nrms*sig->GetRMS(), 
                                                  bgd->GetMean() - nrms*bgd->GetRMS() ),
                                       sig->GetXaxis()->GetXmin() );
            Float_t xmax = TMath::Min( TMath::Max(sig->GetMean() + nrms*sig->GetRMS(), 
                                                  bgd->GetMean() + nrms*bgd->GetRMS() ),
                                       sig->GetXaxis()->GetXmax() );
            Float_t ymin = 0;
            Float_t maxMult = (htype == CompareType) ? 1.3 : 1.2;
            Float_t ymax = TMath::Max( sig->GetMaximum(), bgd->GetMaximum() )*maxMult;
   
            // build a frame
            Int_t nb = 500;
            TString hFrameName(TString("frame") + methodTitle);
            TObject *o = gROOT->FindObject(hFrameName);
            if(o) delete o;
            TH2F* frame = new TH2F( hFrameName, sig->GetTitle(), 
                                    nb, xmin, xmax, nb, ymin, ymax );
            frame->GetXaxis()->SetTitle( methodTitle + ((htype == MVAType || htype == CompareType) ? " response" : "") );
            if      (htype == ProbaType  ) frame->GetXaxis()->SetTitle( "Signal probability" );
            else if (htype == RarityType ) frame->GetXaxis()->SetTitle( "Signal rarity" );
            frame->GetYaxis()->SetTitle("Normalized");
            TMVAGlob::SetFrameStyle( frame );
   
            // eventually: draw the frame
            frame->Draw();  
    
            c->GetPad(0)->SetLeftMargin( 0.105 );
            frame->GetYaxis()->SetTitleOffset( 1.2 );

            // Draw legend               
            TLegend *legend= new TLegend( c->GetLeftMargin(), 1 - c->GetTopMargin() - 0.12, 
                                          c->GetLeftMargin() + (htype == CompareType ? 0.40 : 0.3), 1 - c->GetTopMargin() );
            legend->SetFillStyle( 1 );
            legend->AddEntry(sig,TString("Signal")     + ((htype == CompareType) ? " (test sample)" : ""), "F");
            legend->AddEntry(bgd,TString("Background") + ((htype == CompareType) ? " (test sample)" : ""), "F");
            legend->SetBorderSize(1);
            legend->SetMargin( (htype == CompareType ? 0.2 : 0.3) );
            legend->Draw("same");

            // overlay signal and background histograms
            sig->Draw("samehist");
            bgd->Draw("samehist");
   
            if (htype == CompareType) {
               // if overtraining check, load additional histograms
               TH1* sigOv = 0;
               TH1* bgdOv = 0;

               TString ovname = hname += "_Train";
               sigOv = dynamic_cast<TH1*>(titDir->Get( ovname + "_S" ));
               bgdOv = dynamic_cast<TH1*>(titDir->Get( ovname + "_B" ));
      
               if (sigOv == 0 || bgdOv == 0) {
                  cout << "+++ Problem in \"mvas.C\": overtraining check histograms do not exist" << endl;
               }
               else {
                  cout << "--- Found comparison histograms for overtraining check" << endl;

                  TLegend *legend2= new TLegend( 1 - c->GetRightMargin() - 0.42, 1 - c->GetTopMargin() - 0.12,
                                                 1 - c->GetRightMargin(), 1 - c->GetTopMargin() );
                  legend2->SetFillStyle( 1 );
                  legend2->SetBorderSize(1);
                  legend2->AddEntry(sigOv,"Signal (training sample)","P");
                  legend2->AddEntry(bgdOv,"Background (training sample)","P");
                  legend2->SetMargin( 0.1 );
                  legend2->Draw("same");
               }
               Int_t col = sig->GetLineColor();
               sigOv->SetMarkerColor( col );
               sigOv->SetMarkerSize( 0.7 );
               sigOv->SetMarkerStyle( 20 );
               sigOv->SetLineWidth( 1 );
               sigOv->SetLineColor( col );
               sigOv->Draw("e1same");
      
               col = bgd->GetLineColor();
               bgdOv->SetMarkerColor( col );
               bgdOv->SetMarkerSize( 0.7 );
               bgdOv->SetMarkerStyle( 20 );
               bgdOv->SetLineWidth( 1 );
               bgdOv->SetLineColor( col );
               bgdOv->Draw("e1same");

               ymax = TMath::Max( ymax, TMath::Max( sigOv->GetMaximum(), bgdOv->GetMaximum() )*maxMult );
               frame->GetYaxis()->SetLimits( 0, ymax );
      
               // for better visibility, plot thinner lines
               sig->SetLineWidth( 1 );
               bgd->SetLineWidth( 1 );

               // perform K-S test
               cout << "--- Perform Kolmogorov-Smirnov tests" << endl;
               Double_t kolS = sig->KolmogorovTest( sigOv );
               Double_t kolB = bgd->KolmogorovTest( bgdOv );
               cout << "--- Goodness of signal (background) consistency: " << kolS << " (" << kolB << ")" << endl;

               TString probatext = Form( "Kolmogorov-Smirnov test: signal (background) probability = %5.3g (%5.3g)", kolS, kolB );
               TText* tt = new TText( 0.12, 0.74, probatext );
               tt->SetNDC(); tt->SetTextSize( 0.032 ); tt->AppendPad(); 
            }

            // redraw axes
            frame->Draw("sameaxis");

            // text for overflows
            Int_t    nbin = sig->GetNbinsX();
            Double_t dxu  = sig->GetBinWidth(0);
            Double_t dxo  = sig->GetBinWidth(nbin+1);
            TString uoflow = Form( "U/O-flow (S,B): (%.1f, %.1f)%% / (%.1f, %.1f)%%", 
                                   sig->GetBinContent(0)*dxu*100, bgd->GetBinContent(0)*dxu*100,
                                   sig->GetBinContent(nbin+1)*dxo*100, bgd->GetBinContent(nbin+1)*dxo*100 );
            TText* t = new TText( 0.975, 0.115, uoflow );
            t->SetNDC();
            t->SetTextSize( 0.030 );
            t->SetTextAngle( 90 );
            t->AppendPad();    
   
            // update canvas
            c->Update();

            // save canvas to file

            TMVAGlob::plot_logo(1.058);
            if (Save_Images) {
               if      (htype == MVAType)     TMVAGlob::imgconv( c, Form("plots/mva_%s",     methodTitle.Data()) );
               else if (htype == ProbaType)   TMVAGlob::imgconv( c, Form("plots/proba_%s",   methodTitle.Data()) ); 
               else if (htype == CompareType) TMVAGlob::imgconv( c, Form("plots/overtrain_%s", methodTitle.Data()) ); 
               else                           TMVAGlob::imgconv( c, Form("plots/rarity_%s",  methodTitle.Data()) ); 
            }
            countCanvas++;
         }
      }
   }
}
コード例 #7
0
void L1q1trigger(){
  const TString l1_input = "~/scratch1/DiHadronCorrelations/L1UpgradeAnalyzer.root";

  TFile *lFile = TFile::Open(l1_input);
  Int_t l1Up_evt, l1Up_run, l1Up_et, l1Up_q2;
  TTree *l1UpTree = (TTree*)lFile->Get("L1UpgradeAnalyzer/L1UpgradeTree");

  l1UpTree->SetBranchStatus("*",0);
  l1UpTree->SetBranchStatus("event",1);
  l1UpTree->SetBranchStatus("run",1);
  l1UpTree->SetBranchStatus("centrality_hwPt",1);
  l1UpTree->SetBranchStatus("v2_hwPt",1);

  l1UpTree->SetBranchAddress("event",&l1Up_evt);
  l1UpTree->SetBranchAddress("run",&l1Up_run);
  l1UpTree->SetBranchAddress("centrality_hwPt",&l1Up_et);
  l1UpTree->SetBranchAddress("v2_hwPt",&l1Up_q2);

  const TString forest_input = "~/scratch1/DiHadronCorrelations/outputs_312/HIData_Minbias_2760GeV/ebyeflow_promptreco_pt009.root";
  TFile *fFile = TFile::Open(forest_input);
  TTree *fTree = (TTree*)fFile->Get("ebyeflow_ana_HI/q2ntuple");

  Float_t f_evt, f_run, f_lumi, hiBin;
  float hiHF,q2hf;

  fTree->SetBranchStatus("*",0);
  fTree->SetBranchStatus("evtnum",1);
  fTree->SetBranchStatus("run",1);
  fTree->SetBranchStatus("lumi",1);
  fTree->SetBranchStatus("cent",1);
  fTree->SetBranchStatus("q2hf",1);
  fTree->SetBranchStatus("hf",1);

  fTree->SetBranchAddress("evtnum",&f_evt);
  fTree->SetBranchAddress("run",&f_run);
  fTree->SetBranchAddress("lumi",&f_lumi);
  fTree->SetBranchAddress("cent",&hiBin);
  fTree->SetBranchAddress("hf",&hiHF);
  fTree->SetBranchAddress("q2hf",&q2hf);

  map<long, int> kmap;
  map<long, int> kmapcal;
  
  cout << "Filling the map..." << endl;
  int l1up_entries = l1UpTree->GetEntries();
  //int l_entries = lEvtTree->GetEntries();
  for(long j = 0; j < l1up_entries; ++j){
    if(j % 10000 == 0) printf("%ld / %d\n",j,l1up_entries);
    l1UpTree->GetEntry(j);
    long key = makeKey(l1Up_run, l1Up_evt);

    pair<long,int> p(key,j);
    kmap.insert(p);
    kmapcal.insert(p);
  }
  cout << "map filled!!!" << endl;

//q2 histos
  TH2D* q2CorrHist = new TH2D("q2CorrHist",";offline q_{2};online q_{2}",1000,0.,1.0,1000,0.0,1.0);
  TH2D* HFCorrHist = new TH2D("HFCorrHist",";offline HF E_{T} sum (GeV); online HF E_{T} sum (GeV)",100,0.,8000.0,100,0.0,8000.0);
  TH2D* q2HFCorrHist = new TH2D("q2HFCorrHist",";online HF*q^{2}_{2} (GeV); online HF E_{T} sum (GeV)",300,0.,30000.0,100,0.0,8000.0);

  Float_t q2On   = 0.0; 

  int entries = fTree->GetEntries();
  for(long int j = 1; j < entries; ++j){
    if(j % 10000 == 0) printf("%ld / %d \n",j,entries);
    fTree->GetEntry(j);
    long keycal = makeKey(f_run, f_evt);
    
    map<long,int>::const_iterator gotcal = kmapcal.find(keycal);

    if(gotcal == kmapcal.end()){
      continue;      
    }
    else {
      l1UpTree->GetEntry(gotcal->second);
      kmapcal.erase(keycal);

      if(l1Up_et == 0) continue; 
      //q2 part
                
      q2On = sqrt(l1Up_q2)/l1Up_et;

//      if(l1Up_run<182060 && l1Up_run>182050 & l1Up_et<2839 && l1Up_et>1198)
    //  if(l1Up_et<2839 && l1Up_et>1198)
      {
        q2CorrHist->Fill(q2hf,q2On);
        HFCorrHist->Fill(hiHF,l1Up_et);
        q2HFCorrHist->Fill(l1Up_q2,l1Up_et);
      }
      q2On   = 0.0; 
    }  
  }  

  TCanvas* c = new TCanvas("c","c",800,400);
  c->Divide(2,1);
  c->cd(1);
  c->GetPad(1)->SetLogz();
  q2CorrHist->Rebin2D(2,2);
  q2CorrHist->Draw("colz");
  TProfile* hprof = q2CorrHist->ProfileX("prof",-1,-1,"e");
  hprof->Draw("PEsame");
  c->cd(2);
  c->GetPad(2)->SetLogz();
  HFCorrHist->Draw("colz");

  TCanvas* c1 = new TCanvas("c1","c1",500,500);
  q2HFCorrHist->Draw("colz");
}
コード例 #8
0
void RDK2AnalysisPlotter::makeEPPlot(CoDet detType)
{
    gROOT->cd();
    TCanvas* theCanvas;
    TPad* mainPad;
    TPad* titlePad;
    TPad* pTPad;
    TPad* eEPad;
    TPad* pEPad;
    TPad* pTPadSubs[3];
    TPad* eEPadSubs[3];
    TPad* pEPadSubs[3];


    int numTitleLines=getTitleBoxLines( detType);
    int canvasNumPixelsYPlot=600;
    int canvasNumPixelsYPlots=3*canvasNumPixelsYPlot;
    int canvasNumPixelsYTitle=40*numTitleLines;
    int canvasNumPixelsY=canvasNumPixelsYPlots+canvasNumPixelsYTitle;

    theCanvas = new TCanvas("EPExpMCAnalysisComparisonPlot","EPExpMCAnalysisComparisonPlot",10,10,1200,canvasNumPixelsY);
     mainPad=(TPad*) theCanvas->GetPad(0);


    double ylow,yhigh;

    yhigh=1;
    ylow=1.-canvasNumPixelsYTitle/(double)canvasNumPixelsY;
    titlePad=new TPad("titlePad", "titlePad", 0., ylow, 1., yhigh, -1, 1, 1);

    yhigh=1.-canvasNumPixelsYTitle/(double)canvasNumPixelsY;
    ylow=1.-canvasNumPixelsYTitle/(double)canvasNumPixelsY-canvasNumPixelsYPlot/(double)canvasNumPixelsY;
    pTPad=new TPad("pTPad", "pTPad", 0., ylow, 1., yhigh, -1, 1, 1);

    yhigh=1.-canvasNumPixelsYTitle/(double)canvasNumPixelsY-canvasNumPixelsYPlot/(double)canvasNumPixelsY;
    ylow=1.-canvasNumPixelsYTitle/(double)canvasNumPixelsY- 2*canvasNumPixelsYPlot/(double)canvasNumPixelsY;
    eEPad=new TPad("eEPad", "eEPad", 0., ylow, 1., yhigh, -1, 1, 1);

    yhigh=1.-canvasNumPixelsYTitle/(double)canvasNumPixelsY-2*canvasNumPixelsYPlot/(double)canvasNumPixelsY;
    ylow=0;
    pEPad=new TPad("pEPad", "pEPad", 0., ylow, 1., yhigh, -1, 1, 1);

    titlePad->Draw();
    pTPad->Draw();
    eEPad->Draw();
    pEPad->Draw();



//    titlePad=(TPad*) theCanvas->GetPad(1);
//    pTPad=(TPad*) theCanvas->GetPad(2);
//    eEPad=(TPad*) theCanvas->GetPad(3);
//    pEPad=(TPad*) theCanvas->GetPad(4);

    titlePad->SetMargin(0.05,0.0,0.0,0.0);
    pTPad->SetMargin(0.05,0.0,0.0,0.05);
    pEPad->SetMargin(0.05,0.0,0.0,0.05);
    eEPad->SetMargin(0.05,0.0,0.0,0.05);


    if(numExp+numMC >1)
    {
        pTPad->Divide(2);
        eEPad->Divide(2);
        pEPad->Divide(2);

        pTPadSubs[0]=(TPad*) pTPad->GetPad(1);
        eEPadSubs[0]=(TPad*) eEPad->GetPad(1);
        pEPadSubs[0]=(TPad*) pEPad->GetPad(1);

        TPad* tempPad;
        tempPad=(TPad*) pTPad->GetPad(2);
        tempPad->Divide(1,2);
        pTPadSubs[1]=(TPad*) tempPad->GetPad(1);
        pTPadSubs[2]=(TPad*) tempPad->GetPad(2);

        tempPad=(TPad*) pEPad->GetPad(2);
        tempPad->Divide(1,2);
        pEPadSubs[1]=(TPad*) tempPad->GetPad(1);
        pEPadSubs[2]=(TPad*) tempPad->GetPad(2);

        tempPad=(TPad*) eEPad->GetPad(2);
        tempPad->Divide(1,2);
        eEPadSubs[1]=(TPad*) tempPad->GetPad(1);
        eEPadSubs[2]=(TPad*) tempPad->GetPad(2);

        TPad* allBasePads[10]={titlePad,pTPadSubs[0],pTPadSubs[1],pTPadSubs[2],eEPadSubs[0],eEPadSubs[1],eEPadSubs[2],pEPadSubs[0],pEPadSubs[1],pEPadSubs[2]};
        for (int i = 1;i< 10;i++)
        {
            allBasePads[i]->SetGrid(1,1);
            allBasePads[i]->SetTickx(1);
            allBasePads[i]->SetTicky(1);
        }
        pTPadSubs[0]->SetMargin(0.13,0.1,.1,0.1);
        pEPadSubs[0]->SetMargin(0.13,0.1,.1,0.1);
        eEPadSubs[0]->SetMargin(0.13,0.1,.1,0.1);

        pTPadSubs[1]->SetMargin(0.1,0.1,.1,0.1);
        pEPadSubs[1]->SetMargin(0.1,0.1,.1,0.1);
        eEPadSubs[1]->SetMargin(0.1,0.1,.1,0.1);

        pTPadSubs[2]->SetMargin(0.1,0.1,.1,0.1);
        pEPadSubs[2]->SetMargin(0.1,0.1,.1,0.1);
        eEPadSubs[2]->SetMargin(0.1,0.1,.1,0.1);
        //Plot pT

        pTPadSubs[0]->cd(); drawPlot(detType, PLOTVAR_PT,PLOT_COMP);
        pTPadSubs[1]->cd(); drawPlot(detType, PLOTVAR_PT,PLOT_RESID);
        pTPadSubs[2]->cd(); drawPlot(detType, PLOTVAR_PT,PLOT_NORMRESID);


        //Plot eE
        eEPadSubs[0]->cd(); drawPlot(detType, PLOTVAR_EE,PLOT_COMP);
        eEPadSubs[1]->cd(); drawPlot(detType, PLOTVAR_EE,PLOT_RESID);
        eEPadSubs[2]->cd(); drawPlot(detType, PLOTVAR_EE,PLOT_NORMRESID);

        //Plot pE
        pEPadSubs[0]->cd(); drawPlot(detType, PLOTVAR_PE,PLOT_COMP);
        pEPadSubs[1]->cd(); drawPlot(detType, PLOTVAR_PE,PLOT_RESID);
        pEPadSubs[2]->cd(); drawPlot(detType, PLOTVAR_PE,PLOT_NORMRESID);
    }
    else
    {
        TPad* allBasePads[4]={titlePad,pTPad,eEPad,pEPad};
        for (int i = 1;i< 4;i++)
        {
            allBasePads[i]->SetGrid(1,1);
            allBasePads[i]->SetTickx(1);
            allBasePads[i]->SetTicky(1);
        }
        pTPad->SetMargin(0.13,0.1,.1,0.1);
        pEPad->SetMargin(0.13,0.1,.1,0.1);
        eEPad->SetMargin(0.13,0.1,.1,0.1);
        pTPad->cd(); drawPlot(detType, PLOTVAR_PT,PLOT_COMP);
        eEPad->cd(); drawPlot(detType, PLOTVAR_EE,PLOT_COMP);
        pEPad->cd(); drawPlot(detType, PLOTVAR_PE,PLOT_COMP);

    }
    mainPad->SetFillColor(kGray);

    ///Make Title box
    titlePad->cd();
    titlePad->SetFillColor(kGray);
    TPaveText* titleBox = makeTitleBox( detType);
    titleBox->Draw();





    TString coTypeString;
    if(detType==DET_EP)
    {
        coTypeString="EP";
    }
    else if(detType==DET_EPG)
    {
        coTypeString="EPG";
    }
    else if(detType==DET_EPBG)
    {
        coTypeString="EPBG";
    }
     TString imagePath=GRAPHS_DIR;
    imagePath+="layouts/PlotLayout";
    if(numMC>0) imagePath+="_MC";
    for (int i = 0;i< numMC;i++)
    {
        imagePath+=TString("_")+mc[i]->GetName();
    }
    if(numExp>0) imagePath+="_Exp";
    for (int i = 0;i< numExp;i++)
    {
        imagePath+=TString("_")+exp[i]->GetName();
    }

    imagePath+="_"+coTypeString+"_EPPlots.pdf";
    theCanvas->SaveAs(imagePath);

    delete theCanvas;
    clearPlotHists();

}
コード例 #9
0
void makePlot(const std::string& inputFilePath, const std::string& canvasName, const std::string& sample, int massPoint, const std::string& channel, double k, 
	      const std::string& inputFileName, const std::string& outputFilePath, const std::string& outputFileName)
{
  std::string inputFileName_full = Form("%s%s", inputFilePath.data(), inputFileName.data());
  TFile* inputFile = new TFile(inputFileName_full.data());
  if ( !inputFile ) {
    std::cerr << "Failed to open input file = " << inputFileName_full << " !!" << std::endl;
    assert(0);
  }

  inputFile->ls();

  TCanvas* canvas = dynamic_cast<TCanvas*>(inputFile->Get(canvasName.data()));
  if ( !canvas ) {
    std::cerr << "Failed to load canvas = " << canvasName << " !!" << std::endl;
    assert(0);
  }

  int idxPad = -1;
  if ( massPoint ==  90 ) idxPad = 1;
  if ( massPoint == 125 ) idxPad = 2;
  if ( massPoint == 200 ) idxPad = 3;
  if ( massPoint == 300 ) idxPad = 4;
  if ( massPoint == 500 ) idxPad = 5;
  if ( massPoint == 800 ) idxPad = 6;  
  if ( !(idxPad >= 1 && idxPad <= 6) ) {
    std::cerr << "Invalid sample = " << sample << " !!" << std::endl;
    assert(0);
  }
  TVirtualPad* pad = canvas->GetPad(idxPad);
  std::cout << "pad = " << pad << ": ClassName = " << pad->ClassName() << std::endl;

  TCanvas* canvas_new = new TCanvas("canvas_new", "canvas_new", 900, 800);
  canvas_new->SetFillColor(10);
  canvas_new->SetBorderSize(2);
  canvas_new->SetTopMargin(0.065);
  canvas_new->SetLeftMargin(0.17);
  canvas_new->SetBottomMargin(0.165);
  canvas_new->SetRightMargin(0.015);
  canvas_new->SetLogx(true);
  canvas_new->SetLogy(true);
  canvas_new->Draw();
  canvas_new->cd();

  //TList* pad_primitives = canvas->GetListOfPrimitives();
  TList* pad_primitives = pad->GetListOfPrimitives();

  TH1* histogramCA            = 0;
  TH1* histogramSVfit         = 0;
  TH1* histogramSVfitMEMkEq0  = 0;
  TH1* histogramSVfitMEMkNeq0 = 0;

  TIter pad_nextObj(pad_primitives);
  while ( TObject* obj = pad_nextObj() ) {
    std::string objName = "";
    if ( dynamic_cast<TNamed*>(obj) ) objName = (dynamic_cast<TNamed*>(obj))->GetName();    
    std::cout << "obj = " << obj << ": name = " << objName << ", type = " << obj->ClassName() << std::endl;

    TH1* tmpHistogram = dynamic_cast<TH1*>(obj);
    if ( tmpHistogram ) {
      std::cout << "tmpHistogram:" 
		<< " fillColor = " << tmpHistogram->GetFillColor() << ", fillStyle = " << tmpHistogram->GetFillStyle() << ","
		<< " lineColor = " << tmpHistogram->GetLineColor() << ", lineStyle = " << tmpHistogram->GetLineStyle() << ", lineWidth = " << tmpHistogram->GetLineWidth() << ","
		<< " markerColor = " << tmpHistogram->GetMarkerColor() << ", markerStyle = " << tmpHistogram->GetMarkerStyle() << ", markerSize = " << tmpHistogram->GetMarkerSize() << ","
		<< " integral = " << tmpHistogram->Integral() << std::endl;
      std::cout << "(mean = " << tmpHistogram->GetMean() << ", rms = " << tmpHistogram->GetRMS() << ": rms/mean = " << (tmpHistogram->GetRMS()/tmpHistogram->GetMean()) << ")" << std::endl;
      if ( tmpHistogram->GetLineColor() == 416 ) histogramCA            = tmpHistogram;
      if ( tmpHistogram->GetLineColor() == 600 ) histogramSVfit         = tmpHistogram;
      if ( tmpHistogram->GetLineColor() == 616 ) histogramSVfitMEMkEq0  = tmpHistogram;
      if ( tmpHistogram->GetLineColor() == 632 ) histogramSVfitMEMkNeq0 = tmpHistogram;
    }
  }

  if ( !(histogramCA && histogramSVfit && histogramSVfitMEMkEq0 && histogramSVfitMEMkNeq0) ) {
    std::cerr << "Failed to load histograms !!" << std::endl;
    assert(0);
  }

  //gStyle->SetLineStyleString(2,"40 10 10 10 10 10 10 10");
  //gStyle->SetLineStyleString(3,"25 15");
  //gStyle->SetLineStyleString(4,"60 25");

  //int colors[4] = { kBlack, kGreen - 6, kBlue - 7, kMagenta - 7  };
  int colors[4] = { 28, kGreen - 6, kBlue - 7, kBlack };
  //int lineStyles[4] = { 2, 3, 4, 1 };
  int lineStyles[4] = { 7, 1, 1, 1 };
  //int lineWidths[4] = { 3, 3, 4, 3 };
  int lineWidths[4] = { 3, 3, 1, 1 };
  int markerStyles[4] = { 20, 25, 21, 24 };
  int markerSizes[4] = { 2, 2, 2, 2 };

  histogramCA->SetFillColor(0);
  histogramCA->SetFillStyle(0);
  histogramCA->SetLineColor(colors[0]);
  histogramCA->SetLineStyle(lineStyles[0]);
  histogramCA->SetLineWidth(lineWidths[0]);
  histogramCA->SetMarkerColor(colors[0]);
  histogramCA->SetMarkerStyle(markerStyles[0]);
  histogramCA->SetMarkerSize(markerSizes[0]);

  histogramSVfit->SetFillColor(0);
  histogramSVfit->SetFillStyle(0);
  histogramSVfit->SetLineColor(colors[1]);
  histogramSVfit->SetLineStyle(lineStyles[1]);
  histogramSVfit->SetLineWidth(lineWidths[1]);
  histogramSVfit->SetMarkerColor(colors[1]);
  histogramSVfit->SetMarkerStyle(markerStyles[1]);
  histogramSVfit->SetMarkerSize(markerSizes[1]);

  histogramSVfitMEMkEq0->SetFillColor(0);
  histogramSVfitMEMkEq0->SetFillStyle(0);
  histogramSVfitMEMkEq0->SetLineColor(colors[2]);
  histogramSVfitMEMkEq0->SetLineStyle(lineStyles[2]);
  histogramSVfitMEMkEq0->SetLineWidth(lineWidths[2]);
  histogramSVfitMEMkEq0->SetMarkerColor(colors[2]);
  histogramSVfitMEMkEq0->SetMarkerStyle(markerStyles[2]);
  histogramSVfitMEMkEq0->SetMarkerSize(markerSizes[2]);
  // CV: fix pathological bins at high mass for which dN/dm increases
  int numBins = histogramSVfitMEMkEq0->GetNbinsX();
  for ( int idxBin = 1; idxBin <= numBins; ++idxBin ) {
    double binCenter = histogramSVfitMEMkEq0->GetBinCenter(idxBin);
    if ( (channel == "#tau_{h}#tau_{h}" && massPoint == 500 && binCenter > 1500.) ||
	 (channel == "#tau_{h}#tau_{h}" && massPoint == 800 && binCenter > 2000.) ||
	 (channel == "#mu#tau_{h}"      && massPoint == 500 && binCenter > 1500.) ||
	 (channel == "#mu#tau_{h}"      && massPoint == 800 && binCenter > 2500.) ) {
      histogramSVfitMEMkEq0->SetBinContent(idxBin, 0.);
    }
  }

  histogramSVfitMEMkNeq0->SetFillColor(0);
  histogramSVfitMEMkNeq0->SetFillStyle(0);
  histogramSVfitMEMkNeq0->SetLineColor(colors[3]);
  histogramSVfitMEMkNeq0->SetLineStyle(lineStyles[3]);
  histogramSVfitMEMkNeq0->SetLineWidth(lineWidths[3]);
  histogramSVfitMEMkNeq0->SetMarkerColor(colors[3]);
  histogramSVfitMEMkNeq0->SetMarkerStyle(markerStyles[3]);
  histogramSVfitMEMkNeq0->SetMarkerSize(markerSizes[3]);

  TAxis* xAxis = histogramCA->GetXaxis();
  xAxis->SetTitle("m_{#tau#tau} [GeV]");
  xAxis->SetTitleOffset(1.15);
  xAxis->SetTitleSize(0.070);
  xAxis->SetTitleFont(42);
  xAxis->SetLabelOffset(0.010);
  xAxis->SetLabelSize(0.055);
  xAxis->SetLabelFont(42);
  xAxis->SetTickLength(0.040);
  xAxis->SetNdivisions(510);

  //double xMin = 20.;
  //double xMax = xAxis->GetXmax();
  //xAxis->SetRangeUser(xMin, xMax);

  TAxis* yAxis = histogramCA->GetYaxis();
  yAxis->SetTitle("dN/dm_{#tau#tau} [1/GeV]");
  yAxis->SetTitleOffset(1.20);
  yAxis->SetTitleSize(0.070);
  yAxis->SetTitleFont(42);
  yAxis->SetLabelOffset(0.010);
  yAxis->SetLabelSize(0.055);
  yAxis->SetLabelFont(42);
  yAxis->SetTickLength(0.040);  
  yAxis->SetNdivisions(505);

  double massPoint_double = 0.;
  if ( massPoint == 90 ) massPoint_double = 91.2;
  else massPoint_double = massPoint;
  double dLog = (TMath::Log(5.*massPoint_double) - TMath::Log(50.))/25.; // xMin = 50, xMax = 5*massPoint, numBins = 25
  double binWidth = TMath::Exp(TMath::Log(massPoint_double) + 0.5*dLog) - TMath::Exp(TMath::Log(massPoint_double) - 0.5*dLog);
  double sf_binWidth = 1./binWidth;
  std::cout << "massPoint = " << massPoint << ": sf_binWidth = " << sf_binWidth << std::endl;

  histogramCA->SetTitle("");
  histogramCA->SetStats(false);
  histogramCA->SetMaximum(sf_binWidth*0.79);
  histogramCA->SetMinimum(sf_binWidth*1.1e-4);
  histogramCA->Draw("hist");
  histogramSVfit->Draw("histsame");
  //histogramSVfitMEMkEq0->Draw("histsame");
  histogramSVfitMEMkEq0->Draw("epsame");
  //histogramSVfitMEMkNeq0->Draw("histsame");
  histogramSVfitMEMkNeq0->Draw("epsame");
  histogramCA->Draw("axissame");

  //TPaveText* label_sample = new TPaveText(0.21, 0.86, 0.46, 0.94, "NDC");
  TPaveText* label_sample = new TPaveText(0.1700, 0.9475, 0.4600, 1.0375, "NDC");
  label_sample->SetFillStyle(0);
  label_sample->SetBorderSize(0);
  label_sample->AddText(sample.data());
  label_sample->SetTextFont(42);
  label_sample->SetTextSize(0.055);
  label_sample->SetTextColor(1);
  label_sample->SetTextAlign(13);
  label_sample->Draw();

  //TLegend* legend_new = new TLegend(0.225, 0.52, 0.41, 0.82, NULL, "brNDC");
  TLegend* legend_new = new TLegend(0.30, 0.30, 0.80, 0.80, NULL, "brNDC");
  legend_new->SetFillColor(10);
  legend_new->SetFillStyle(0);
  legend_new->SetBorderSize(0);
  legend_new->SetTextFont(42);
  legend_new->SetTextSize(0.055);
  legend_new->SetTextColor(1);
  legend_new->SetMargin(0.20);
  legend_new->AddEntry(histogramCA, "CA", "l");
  legend_new->AddEntry(histogramSVfit, "SVfit", "l");
  //legend_new->AddEntry(histogramSVfitMEMkEq0, "SVfitMEM (k=0)", "l");
  legend_new->AddEntry(histogramSVfitMEMkEq0, "SVfitMEM (k=0)", "p");
  //legend_new->AddEntry(histogramSVfitMEMkNeq0, Form("SVfitMEM(k=%1.0f)", k), "l");
  legend_new->AddEntry(histogramSVfitMEMkNeq0, Form("SVfitMEM (k=%1.0f)", k), "p");
  //legend_new->Draw();

  double label_channel_y0;
  if      ( channel == "e#mu"             ) label_channel_y0 = 0.9275;
  else if ( channel == "#mu#tau_{h}"      ) label_channel_y0 = 0.9400;
  else if ( channel == "#tau_{h}#tau_{h}" ) label_channel_y0 = 0.9350;
  else {
    std::cerr << "Invalid channel = " << channel << " !!" << std::endl;
    assert(0);
  }
  TPaveText* label_channel = new TPaveText(0.895, label_channel_y0, 0.975, label_channel_y0 + 0.055, "NDC");
  label_channel->SetFillStyle(0);
  label_channel->SetBorderSize(0);
  label_channel->AddText(channel.data());
  label_channel->SetTextFont(62);
  label_channel->SetTextSize(0.055);
  label_channel->SetTextColor(1);
  label_channel->SetTextAlign(31);
  label_channel->Draw();

  canvas_new->Update();

  std::string outputFileName_full = Form("%s%s", outputFilePath.data(), outputFileName.data());
  size_t idx = outputFileName_full.find_last_of('.');
  std::string outputFileName_plot = std::string(outputFileName_full, 0, idx);
  canvas_new->Print(std::string(outputFileName_plot).append(".pdf").data());
  canvas_new->Print(std::string(outputFileName_plot).append(".root").data());

  std::string channel_string;
  if      ( channel == "e#mu"             ) channel_string = "emu";
  else if ( channel == "#mu#tau_{h}"      ) channel_string = "muhad";
  else if ( channel == "#tau_{h}#tau_{h}" ) channel_string = "hadhad";
  else {
    std::cerr << "Invalid channel = " << channel << " !!" << std::endl;
    assert(0);
  }
  std::string outputFileName_legend = Form("makeSVfitMEM_PerformancePlots_legend_%s.pdf", channel_string.data());
  makePlot_legend(legend_new, outputFilePath, outputFileName_legend);

  delete label_sample;
  delete legend_new;
  delete label_channel;
  delete canvas_new;

  delete inputFile;
}
コード例 #10
0
ファイル: CheckPhysics.C プロジェクト: LightninGreen/acqu
void CheckPhysics(){
  Char_t* hname[] = {
    "1",  "EtaM_Nphoton",   "log",  "",
    "2",  "EtaM_Nproton",   "log",  "",
    //    "3",  "EtaM_Nneutron",  "log",  "",
    "3",  "EtaM_Npi0",      "log",  "",
    //    "5",  "EtaM_Npiplus",   "log",  "",
    "4",  "EtaM_Neta",      "log",  "",
    "5",  "EtaM_M2g",      "log",  "",
    "6",  "EtaM_M6g",      "lin",  "",
    "7",  "EtaM_EmEtaP",   "lin",  "",
    "7",  "EtaM_EmEtaR",   "lin",  "Same",
    "8",  "EtaM_EmEtapP",   "lin",  "",
    "8",  "EtaM_EmEtapR",   "lin",  "Same",
    //    "8",  "EtaM_EmComptonpP",   "lin",  "",
    //    "8",  "EtaM_EmComptonpR",   "lin",  "Same",
    "9",  "EtaM_M2gCBTAPS","lin",  "",
    "10", "EtaM_M2g_v_CB_NaI_ClNhitsOR",        "log",  "CONTZ",
    "11", "EtaM_M2g_v_TAGG_FPD_HitsPrompt",     "log",  "COLZ",
    "12", "EtaM_M6g_v_TAGG_FPD_HitsPrompt",       "log",  "COLZ",
  };
  Int_t col[] = { 2,2,2,2, 3,3,3,5,3,5,3,2,2,2,1,1 };
  Int_t xxx;
  Char_t* xname[] = {
    "Number Reconstructed #gamma per event",
    "Number Reconstructed p per event",
    //    "Number Reconstructed n per event",
    "Number Reconstructed #pi^{0} per event",
    //    "Number Reconstructed #pi^{+} per event",
    "Number Reconstructed #eta per event",
    "2-#gamma Invariant Mass",
    "6-#gamma Invariant Mass",
    "Missing Mass if QF #eta (Gr-prompt, Yell-rand) ",
    "",
    "Missing Energy if QF #eta-p (Gr-prompt, Yell-rand)",
    "",
    "2-#gamma Invariant Mass (1-#gamma CB, 1-#gamma TAPS)",
    "2-#gamma Invariant Mass vs CB Cluster Size",
    "2-#gamma Invariant Mass vs Prompt Tagger Hits",
    "6-#gamma Invariant Mass vs Prompt Tagger Hits",
  };
  Char_t* cloneName[] = {"rand1", "rand2", "rand3", "rand4"};
  TH1F* h1r;
  TH1F** ph1r[4];
  for( Int_t i=0; i<2; i++ ){
    h1r = (TH1F*)gROOT->FindObject(cloneName[i]);
    if( !h1r ) h1r = new TH1F("cloneName[i]","Photo-Hist",1000,0,1000);
    ph1r[i] = h1r;
  }
  //
  TH1F* h1;
  TH2F* h2;
  //  TH1F* h3 = new TH1F("h3x","Photo-Hist",10000,-5000,5000);
  //  TH1F* h4 = new TH1F("h4x","Photo-Hist",10000,-5000,5000);
  //  TH1F* h5 = new TH1F("h5x","Photo-Hist",10000,-5000,5000);
  TCanvas* canv = new TCanvas("Physics-Spectra","Physics-Online",240,180,1240,890);
  canv->Divide(4,3);
  Int_t i = 0;
  Int_t k = 0;
  Int_t j;
  Int_t pad_no;
  for( j=0; j<44; j+=4){
    sscanf(hname[j], "%d", &pad_no);           // pad_no is 1st arg.
    canv->cd(pad_no);
    //    printf("%d %d %d %s %s %s %s\n",pad_no,j,i,hname[j],hname[j+1],hname[j+2],hname[j+3]);
    h1 = (TH1F*)gROOT->FindObjectAny(hname[j+1]); // name is 2nd argument
    if( !h1 ){
      printf("No object named '%s' was found.\n Check your macro!\n", hname[j+1]);
    }
    else{
      if(strcmp(hname[j+3], "Same") == 0){
	h1r = ph1r[k];
	h1->Copy(*h1r);
	*h1r = *h1r * 0.5;
	h1 = h1r;
	k++;
      }
      if(strcmp(hname[j+2], "log") == 0)         // lin/log 3rd argument
	canv->GetPad(pad_no)->SetLogy();
      h1->GetXaxis()->SetTitle(xname[i]);
      h1->SetLineColor( 1 );
      h1->SetFillColor( col[i] );
      h1->Draw(hname[j+3]);               // parameter 4th arg.
      gPad->RedrawAxis();
    }
    i++;
  }
  for( j=44; j<56; j+=4){
    sscanf(hname[j], "%d", &pad_no);           // pad_no is 1st arg.
    canv->cd(pad_no);
    //    printf("%d %d %d\n",pad_no,j,i);
    h2 = (TH2F*)gROOT->FindObjectAny(hname[j+1]); // name is 2nd argument
    if( !h2 ){
      printf("No object named '%s' was found.\n Check your macro!\n", hname[j+1]);
    }
    else{
      if(strcmp(hname[j+2], "log") == 0)         // lin/log 3rd argument
	canv->GetPad(pad_no)->SetLogz();
      h2->GetXaxis()->SetTitle(xname[i]);
      h2->Draw(hname[j+3]);               // parameter 4th arg.
      gPad->RedrawAxis();
    }
    i++;
  }
  return;
}
コード例 #11
0
void vn_spectra_trackHF()
{
   TString filename = Form("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/HIData_Minbias_2760GeV/merged/HIData_Minbias_2760GeV_UCC2011_INCLv1HF_nmin-1_nmax-1_etatrg-5.0--3.0_etaass3.0-5.0_centmin110_centmax1000.root");
   TFile* fdiff = new TFile(filename.Data());

  TH1D* hpt_ref;
  TH2D* hsignal_ref;
  TH2D* hbackground_ref;
  TH1D* hsignal_ref_1D;
  TH1D* hbackground_ref_1D;
  TH1D* hcorr_ref_1D;

  TH1D* hpt[20];
  TH2D* hsignal[20];
  TH2D* hbackground[20];
  TH1D* hsignal_1D[20];
  TH1D* hbackground_1D[20];
  TH1D* hcorr_1D[20];

  TGraphErrors* gr[20];
  TGraphErrors* gr_corr[20];
  for(int i=0;i<20;i++)
  {
    if(i>=5)
    {
      gr[i] = new TGraphErrors(11);
      gr_corr[i] = new TGraphErrors(11);
    }
    else
    {
      gr[i] = new TGraphErrors(13);
      gr_corr[i] = new TGraphErrors(13);
    }
    gr[i]->SetName(Form("vnpt_%d",i));
    gr_corr[i]->SetName(Form("vnpt_corr_%d",i));
  }

  double factor[20]={1.,1.3,1.0,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8,0.8};
  double factor_err[20]={0.,0.1,0.4,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6,0.6};
  double VnArray[20][20],Vn0[20],vn0[20],vn0err[20],vn01[20],vn01err[20],vn0_corr[20],vn0_corr_up[20],vn0_corr_down[20],vn0_corr_sys[28],vn0err_corr[20],vn0_ratio[20],vn0err_ratio[20];
  hsignal_ref = (TH2D*)fdiff->Get("signalcosn_trg0_ass0");
  hbackground_ref = (TH2D*)fdiff->Get("backgroundcosn_trg0_ass0");
  hsignal_ref_1D = (TH1D*)hsignal_ref->ProfileY("signal_1D_trg0_ass0_ref",1,-1,"e");
  hbackground_ref_1D = (TH1D*)hbackground_ref->ProfileY("background_1D_trg0_ass0_ref",1,-1,"e");
  hcorr_ref_1D = new TH1D("Vn_1D_trg0_ass0_ref",";n;V_{n#Delta}",15,0.5,15.5);
  for(int n=1;n<=hcorr_ref_1D->GetNbinsX();n++)
  {
    double Vn=hsignal_ref_1D->GetBinContent(n)-hbackground_ref_1D->GetBinContent(n);
    double VnError=sqrt(hsignal_ref_1D->GetBinError(n)*hsignal_ref_1D->GetBinError(n)+hbackground_ref_1D->GetBinError(n)*hbackground_ref_1D->GetBinError(n));
    hcorr_ref_1D->SetBinContent(n,Vn);
    hcorr_ref_1D->SetBinError(n,VnError);
    Vn0[n] = Vn;
    vn0[n] = sqrt(fabs(Vn));
    vn0err[n] = fabs(VnError/Vn)*vn0[n];
  }

  TFile* fpt = new TFile(Form("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/outputs_312/HIData_Minbias_2760GeV/merged/HIData_Minbias_2760GeV_UCC2011_INCLv1TrackHF_nmin-1_nmax-1_etatrg-2.4-0.0_etaass3.0-5.0_centmin110_centmax1000.root"));
  TH1D* hptcorr = (TH1D*)fpt->Get("ptcorrall_trg");

  double merit[20]={0};
  double merit_err[20]={0};
  double total[20]={0};
  double merit_corr[20]={0};
  double merit_corr_up[20]={0};
  double merit_corr_down[20]={0};
  double merit_corr_err[20]={0};
  double total_corr[20]={0};
  for(int i=13;i>=0;i--)
  {
    hpt[i] = (TH1D*)fdiff1->Get(Form("ptcorr_trg_%d",i+1));
    if(i>2)
    {
      hsignal[i] = (TH2D*)fdiff->Get(Form("signalcosn_trg%d_ass0",i+1));
      hbackground[i] = (TH2D*)fdiff->Get(Form("backgroundcosn_trg%d_ass0",i+1));
    }
    else
    {
      hsignal[i] = (TH2D*)fdiff1->Get(Form("signalcosn_trg%d_ass0",i+1));
      hbackground[i] = (TH2D*)fdiff1->Get(Form("backgroundcosn_trg%d_ass0",i+1));
    }
    hsignal_1D[i] = (TH1D*)hsignal[i]->ProfileY(Form("signal_1D_trg%d_ass0",i+1),1,-1,"e");
    hbackground_1D[i] = (TH1D*)hbackground[i]->ProfileY(Form("background_1D_trg%d_ass0",i+1),1,-1,"e");
    hcorr_1D[i] = new TH1D(Form("Vn_1D_trg%d_ass0",i+1),";n;V_{n#Delta}",15,0.5,15.5);

    for(int n=1;n<=hcorr_1D[i]->GetNbinsX();n++)
    {
      if(n>=6 && hpt[i]->GetMean()>5.0) continue;
      if(n==5 && hpt[i]->GetMean()>8.0) continue;
      if(n==4 && hpt[i]->GetMean()>10.0) continue;

      double Vn=hsignal_1D[i]->GetBinContent(n)-hbackground_1D[i]->GetBinContent(n);
      double VnError=sqrt(hsignal_1D[i]->GetBinError(n)*hsignal_1D[i]->GetBinError(n)+hbackground_1D[i]->GetBinError(n)*hbackground_1D[i]->GetBinError(n));

      VnArray[n][i] = Vn;
      hcorr_1D[i]->SetBinContent(n,Vn);
      hcorr_1D[i]->SetBinError(n,VnError);
      
      double vn=Vn/vn0[n];
      if(i<=2) vn=Vn/vn01[n];
      double vnerr=vn*sqrt((VnError/Vn)*(VnError/Vn)+vn0err[n]*vn0err[n]);
      if(i<=2) vnerr=vn*sqrt((VnError/Vn)*(VnError/Vn)+vn01err[n]*vn01err[n]);
      gr[n-1]->SetPoint(i,hpt[i]->GetMean(),vn);
      gr[n-1]->SetPointError(i,0,vnerr);

/*
      double integral = hpt[i]->Integral();
      if(i==0) integral = hpt[1]->Integral();
      if(hpt[i]->GetMean()>3.0) continue;
      merit[n-1] =  merit[n-1] + integral/1000.*vn;
      merit_err[n-1] =  merit_err[n-1] + integral/1000.*vnerr;
      total[n-1] =  total[n-1] + integral/1000.;
      gr_merit[n-1]->SetPoint(i,hpt[i]->GetMean(),merit[n-1]/sqrt(total[n-1]));
if(n==2) cout<<"n="<<n<<" i="<<i<<" "<<merit[n-1]/sqrt(total[n-1])<<endl;
*/
      double integral = hptcorr->GetBinContent(hptcorr->FindBin(hpt[i]->GetMean()))*hptcorr->GetBinWidth(hptcorr->FindBin(hpt[i]->GetMean()));
      if(hpt[i]->GetMean()>3.0) continue;
      merit[n-1] =  merit[n-1] + integral/1000.*vn;
      merit_err[n-1] =  merit_err[n-1] + integral/1000.*vnerr;
      total[n-1] =  total[n-1] + integral/1000.;
      gr_merit[n-1]->SetPoint(i,hpt[i]->GetMean(),merit[n-1]/sqrt(total[n-1]));
if(n==2) cout<<"n="<<n<<" i="<<i<<" "<<merit[n-1]/sqrt(total[n-1])<<endl;
    }
  }

  TH1D* h1corr = (TH1D*)Get1DCFdPhiv3(filename.Data(),0,0,1.9,4.0);
  TH1D* h2corr = (TH1D*)Get1DCFdPhiv3(filename.Data(),11,0,1.9,4.0);
  TCanvas* ccorr = new TCanvas("ccorr","ccorr",900,400);
  ccorr->Divide(2,1);
  ccorr->cd(1);
  ccorr->GetPad(1)->SetLeftMargin(0.23);
  h1corr->SetAxisRange(50.9,52.,"Y");
  h1corr->GetYaxis()->SetTitleOffset(1.2);
  h1corr->GetXaxis()->SetLabelSize(h1corr->GetXaxis()->GetLabelSize()*0.98);
  h1corr->GetYaxis()->SetLabelSize(h1corr->GetXaxis()->GetLabelSize()*0.98);
  h1corr->GetXaxis()->SetTitleSize(h1corr->GetXaxis()->GetTitleSize()*0.98);
  h1corr->GetYaxis()->SetTitleSize(h1corr->GetXaxis()->GetTitleSize()*0.98);
  h1corr->GetYaxis()->SetTitleOffset(h1corr->GetYaxis()->GetTitleOffset()*1.4);
  h1corr->GetXaxis()->CenterTitle();
  h1corr->GetYaxis()->CenterTitle();
  h1corr->Draw("PE");
  ccorr->cd(2);
  ccorr->GetPad(2)->SetLeftMargin(0.23);
  h2corr->SetAxisRange(50.8,52.4,"Y");
  h2corr->GetYaxis()->SetTitleOffset(1.2);
  h2corr->GetXaxis()->SetLabelSize(h2corr->GetXaxis()->GetLabelSize()*0.98);
  h2corr->GetYaxis()->SetLabelSize(h2corr->GetXaxis()->GetLabelSize()*0.98);
  h2corr->GetXaxis()->SetTitleSize(h2corr->GetXaxis()->GetTitleSize()*0.98);
  h2corr->GetYaxis()->SetTitleSize(h2corr->GetXaxis()->GetTitleSize()*0.98);
  h2corr->GetYaxis()->SetTitleOffset(h2corr->GetYaxis()->GetTitleOffset()*1.4);
  h2corr->GetXaxis()->CenterTitle();
  h2corr->GetYaxis()->CenterTitle();
  h2corr->Draw("PE");  

  TF1* fitfunc1 = FitVnFunc(h1corr);
  TF1* fitfunc2 = FitVnFunc(h2corr);
  fitfunc1->SetLineStyle(4);
  fitfunc2->SetLineStyle(4);
  fitfunc1->SetParameters(fitfunc1->GetParameter(0),Vn0[1],Vn0[2],Vn0[3],Vn0[4],Vn0[5],Vn0[6],Vn0[7],Vn0[8],Vn0[9],Vn0[10]);
  fitfunc2->SetParameters(fitfunc2->GetParameter(0),VnArray[1][10],VnArray[2][10],VnArray[3][10],VnArray[4][10],VnArray[5][10],VnArray[6][10],VnArray[7][10],VnArray[8][10],VnArray[9][10],VnArray[10][10]);
  ccorr->cd(1);
  fitfunc1->Draw("Lsame");
  ccorr->cd(2);
  fitfunc2->Draw("Lsame");
  TF1* fitfuns1[6];
  TF1* fitfuns2[6];
  for(int i=0;i<6;i++)
  {
    fitfuns1[i] = (TF1*)fitfunc1->Clone(Form("fitfuncs1_%d",i));
    fitfuns2[i] = (TF1*)fitfunc2->Clone(Form("fitfuncs2_%d",i));
    fitfuns1[i]->SetLineColor(i+1);
    fitfuns2[i]->SetLineColor(i+1);
    fitfuns1[i]->SetLineWidth(1);
    fitfuns2[i]->SetLineWidth(1);
    fitfuns1[i]->SetLineStyle(1);
    fitfuns2[i]->SetLineStyle(1);
  }
  fitfuns1[0]->SetLineColor(1);
  fitfuns1[1]->SetLineColor(2);
  fitfuns1[2]->SetLineColor(9);
  fitfuns1[3]->SetLineColor(4);
  fitfuns1[4]->SetLineColor(8);
  fitfuns1[5]->SetLineColor(6);
  fitfuns2[0]->SetLineColor(1);
  fitfuns2[1]->SetLineColor(2);
  fitfuns2[2]->SetLineColor(9);
  fitfuns2[3]->SetLineColor(4);
  fitfuns2[4]->SetLineColor(8);
  fitfuns2[5]->SetLineColor(6);

  fitfuns1[0]->SetParameters(fitfuns1[0]->GetParameter(0),fitfuns1[0]->GetParameter(1),0,0,0,0,0,0,0,0,0);
  fitfuns1[1]->SetParameters(fitfuns1[1]->GetParameter(0),0,fitfuns1[1]->GetParameter(2),0,0,0,0,0,0,0,0);
  fitfuns1[2]->SetParameters(fitfuns1[2]->GetParameter(0),0,0,fitfuns1[2]->GetParameter(3),0,0,0,0,0,0,0);
  fitfuns1[3]->SetParameters(fitfuns1[3]->GetParameter(0),0,0,0,fitfuns1[3]->GetParameter(4),0,0,0,0,0,0);
  fitfuns1[4]->SetParameters(fitfuns1[4]->GetParameter(0),0,0,0,0,fitfuns1[4]->GetParameter(5),0,0,0,0,0);
  fitfuns1[5]->SetParameters(fitfuns1[5]->GetParameter(0),0,0,0,0,0,fitfuns1[5]->GetParameter(6),0,0,0,0);
  fitfuns2[0]->SetParameters(fitfuns2[0]->GetParameter(0),fitfuns2[0]->GetParameter(1),0,0,0,0,0,0,0,0,0);
  fitfuns2[1]->SetParameters(fitfuns2[1]->GetParameter(0),0,fitfuns2[1]->GetParameter(2),0,0,0,0,0,0,0,0);
  fitfuns2[2]->SetParameters(fitfuns2[2]->GetParameter(0),0,0,fitfuns2[2]->GetParameter(3),0,0,0,0,0,0,0);
  fitfuns2[3]->SetParameters(fitfuns2[3]->GetParameter(0),0,0,0,fitfuns2[3]->GetParameter(4),0,0,0,0,0,0);
  fitfuns2[4]->SetParameters(fitfuns2[4]->GetParameter(0),0,0,0,0,fitfuns2[4]->GetParameter(5),0,0,0,0,0);
  fitfuns2[5]->SetParameters(fitfuns2[5]->GetParameter(0),0,0,0,0,0,fitfuns2[5]->GetParameter(6),0,0,0,0);
  
  ccorr->cd(1);
  fitfuns1[0]->Draw("Lsame");
  fitfuns1[1]->Draw("Lsame");
  fitfuns1[2]->Draw("Lsame");
  fitfuns1[3]->Draw("Lsame");
  fitfuns1[4]->Draw("Lsame");
  fitfuns1[5]->Draw("Lsame");
  ccorr->cd(2);
  fitfuns2[0]->Draw("Lsame");
  fitfuns2[1]->Draw("Lsame");
  fitfuns2[2]->Draw("Lsame");
  fitfuns2[3]->Draw("Lsame");
  fitfuns2[4]->Draw("Lsame");
  fitfuns2[5]->Draw("Lsame");

  TLegend* legend_corr = new TLegend(0.28,0.63,0.7,0.92);
  legend_corr->SetFillStyle(0);
  legend_corr->SetTextFont(42);
  legend_corr->AddEntry(fitfunc1,"Sum","L");
  legend_corr->AddEntry(fitfuns1[0],"n = 1","L");
  legend_corr->AddEntry(fitfuns1[1],"n = 2","L");
  legend_corr->AddEntry(fitfuns1[2],"n = 3","L");
  legend_corr->AddEntry(fitfuns1[3],"n = 4","L");
  legend_corr->AddEntry(fitfuns1[4],"n = 5","L");  
  legend_corr->AddEntry(fitfuns1[5],"n = 6","L");
  ccorr->cd(1);
  legend_corr->Draw("same");
  ccorr->cd(2);
  legend_corr->Draw("same");

  ccorr->cd(1);
  TLatex* latex_corr = new TLatex();
  latex_corr->SetNDC(1);
  latex_corr->SetTextSize(latex_corr->GetTextSize()*0.8);
  latex_corr->DrawLatex(0.47,0.88,"CMS PbPb  #sqrt{s_{NN}} = 2.76 TeV");
  latex_corr->DrawLatex(0.63,0.82,centtag.Data());
  latex_corr->DrawLatex(0.76,0.76,"|#Delta#eta| > 2");
  ccorr->cd(2);
  TLatex* latex1_corr = new TLatex();
  latex1_corr->SetNDC(1);
  latex1_corr->SetTextSize(latex1_corr->GetTextSize()*0.8);
  latex1_corr->DrawLatex(0.47,0.88,"CMS PbPb  #sqrt{s_{NN}} = 2.76 TeV");
  latex1_corr->DrawLatex(0.63,0.82,centtag.Data());
  latex1_corr->DrawLatex(0.76,0.76,"|#Delta#eta| > 2");  
  ccorr->cd(1);
  TLatex* latex_trg1 = new TLatex();
  latex_trg1->SetNDC(1);
  latex_trg1->SetTextSize(latex_trg1->GetTextSize()*0.8);
  latex_trg1->DrawLatex(0.59,0.635,"1 < p_{T}^{trig} < 3 GeV/c");
  latex_trg1->DrawLatex(0.59,0.57,"1 < p_{T}^{assoc} < 3 GeV/c");
  ccorr->cd(2);
  TLatex* latex_trg2 = new TLatex();
  latex_trg2->SetNDC(1);
  latex_trg2->SetTextSize(latex_trg2->GetTextSize()*0.8);
  latex_trg2->DrawLatex(0.59,0.635,"4 < p_{T}^{trig} < 5 GeV/c");
  latex_trg2->DrawLatex(0.59,0.57,"1 < p_{T}^{assoc} < 3 GeV/c");

  SaveCanvas(ccorr,"HI/UCC",Form("corr1Dfit_%s_centmin%d_centmax%d",tag.Data(),centmin,centmax));
/*
  TCanvas* ccc = new TCanvas("ccc","ccc",900,400);
  ccc->Divide(2,1);
  ccc->cd(1);
  ccc->GetPad(1)->SetLeftMargin(0.3);
  hsignal_ref_1D->GetYaxis()->SetTitleOffset(2.0);
  hsignal_ref_1D->GetYaxis()->CenterTitle();
  hsignal_ref_1D->SetAxisRange(1.5,10.5,"X");
  hsignal_ref_1D->SetAxisRange(-0.00025,0.0019,"Y");
  hsignal_ref_1D->SetYTitle("<cos(n#Delta#phi)>");
  hsignal_ref_1D->Draw("PE");
  hbackground_ref_1D->SetMarkerStyle(24);
  hbackground_ref_1D->Draw("PESAME");
  TLegend* legend = new TLegend(0.5,0.75,0.9,0.9);
  legend->SetFillStyle(0);
  legend->SetTextFont(42);
  legend->AddEntry(hsignal_ref_1D,"Signal","P");
  legend->AddEntry(hbackground_ref_1D,"Background","P");
  legend->Draw("same");
  ccc->cd(2);
  ccc->GetPad(2)->SetLeftMargin(0.3);
  hcorr_ref_1D->GetYaxis()->SetTitleOffset(2.0);
  hcorr_ref_1D->GetYaxis()->CenterTitle();
  hcorr_ref_1D->SetAxisRange(1.5,10.5,"X");
  hcorr_ref_1D->Draw("PE");

  SaveCanvas(ccc,"HI/UCC",Form("sigbak_%s_centmin%d_centmax%d",tag.Data(),centmin,centmax));
*/
  for(int n=1;n<=hcorr_ref_1D->GetNbinsX();n++)
  {  
    vn0[n] = merit[n-1]/total[n-1];
    vn0err[n] = merit_err[n-1]/total[n-1];
  }    

  TFile* ffake = new TFile("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/efficiency/fake_hiGoodTightMerged_ucc_new.root");
  TH1D* hfake = (TH1D*)ffake->Get("hFake");

//  TFile* ffake1 = new TFile("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/efficiency/fake_hiGoodTight_ucc_new.root");
//  TH1D* hfake1 = (TH1D*)ffake1->Get("hFake");

  TFile* ffake1 = new TFile("/net/hisrv0001/home/davidlw/scratch1/DiHadronCorrelations/efficiency/fake_hiGoodTightMerged_ucc_new.root");
  TH1D* hfake1 = (TH1D*)ffake1->Get("hFake");

  for(int n=1;n<=hcorr_ref_1D->GetNbinsX();n++)
  {
cout<<"n="<<n<<endl;
    for(i=0;i<13;i++) 
    {
      double x,y,xerr,yerr;
      gr[n-1]->GetPoint(i,x,y);
      xerr=gr[n-1]->GetErrorX(i);
      yerr=gr[n-1]->GetErrorY(i);

      if(n>=6 && i>10) continue;

      double fake = 0;
      if(x>1.0) fake = hfake1->GetBinContent(hfake1->FindBin(x));
      if(x<1.0) fake = hfake->GetBinContent(hfake->FindBin(x));
      double vn_corr = (y-fake*factor[n-1]*vn0[n])/(1-fake);
      gr_corr[n-1]->SetPoint(i,x,vn_corr);
      gr_corr[n-1]->SetPointError(i,0,yerr);
cout<<x<<" "<<vn_corr<<" "<<yerr<<endl;
      double vn_corr_up = (y-fake*(factor[n-1]-factor_err[n-1])*vn0[n])/(1-fake)+y*0.02;
      double vn_corr_down = (y-fake*(factor[n-1]+factor_err[n-1])*vn0[n])/(1-fake)-y*0.02;
// temporarily add additional systematics due to EP comparison
/*
      if(n==2 && i==8)
      {
        vn_corr_up = (y-fake*(factor[n-1]-factor_err[n-1])*vn0[n])/(1-fake)+y*0.08;
        vn_corr_down = (y-fake*(factor[n-1]+factor_err[n-1])*vn0[n])/(1-fake)-y*0.08;
      }
      if(n==2 && i==9)
      {
        vn_corr_up = (y-fake*(factor[n-1]-factor_err[n-1])*vn0[n])/(1-fake)+y*0.10;
        vn_corr_down = (y-fake*(factor[n-1]+factor_err[n-1])*vn0[n])/(1-fake)-y*0.10;
      }
      if(n==2 && i==10)
      {
        vn_corr_up = (y-fake*(factor[n-1]-factor_err[n-1])*vn0[n])/(1-fake)+y*0.17;
        vn_corr_down = (y-fake*(factor[n-1]+factor_err[n-1])*vn0[n])/(1-fake)-y*0.17;
      }
      if(n==2 && i>10)
      {
        vn_corr_up = (y-fake*(factor[n-1]-factor_err[n-1])*vn0[n])/(1-fake)+y*0.17;
        vn_corr_down = (y-fake*(factor[n-1]+factor_err[n-1])*vn0[n])/(1-fake)-y*0.17;
      }

      if(n==3 && i>=8)
      {
        vn_corr_up = (y-fake*(factor[n-1]-factor_err[n-1])*vn0[n])/(1-fake)+y*0.04;
        vn_corr_down = (y-fake*(factor[n-1]+factor_err[n-1])*vn0[n])/(1-fake)-y*0.04;
      }
      if(n==5)
      {
        vn_corr_up = (y-fake*(factor[n-1]-factor_err[n-1])*vn0[n])/(1-fake)+y*0.04;
        vn_corr_down = (y-fake*(factor[n-1]+factor_err[n-1])*vn0[n])/(1-fake)-y*0.04;
      }
      if(n>5)
      {
        vn_corr_up = (y-fake*(factor[n-1]-factor_err[n-1])*vn0[n])/(1-fake)+y*0.08;
        vn_corr_down = (y-fake*(factor[n-1]+factor_err[n-1])*vn0[n])/(1-fake)-y*0.08;
      }
*/
      if(n>=6)
      {
        gr_syst[n-1]->SetPoint(i,x,vn_corr_up);
        gr_syst[n-1]->SetPoint(21-i,x,vn_corr_down);
      }
      else 
      {
        gr_syst[n-1]->SetPoint(i,x,vn_corr_up);
        gr_syst[n-1]->SetPoint(25-i,x,vn_corr_down);
      }

      gr_ratio[n-1]->SetPoint(i,x,vn_corr/y);
      gr_ratio[n-1]->SetPointError(i,0,0);

//      double integral = hpt[i]->Integral();
//      if(i==0) integral = hpt[1]->Integral();
      double integral = hptcorr->GetBinContent(hptcorr->FindBin(hpt[i]->GetMean()))*hptcorr->GetBinWidth(hptcorr->FindBin(hpt[i]->GetMean()));
      merit_corr[n-1] =  merit_corr[n-1] + integral/1000.*vn_corr;
      merit_corr_up[n-1] =  merit_corr_up[n-1] + integral/1000.*vn_corr_up;
      merit_corr_down[n-1] =  merit_corr_down[n-1] + integral/1000.*vn_corr_down;
      merit_corr_err[n-1] =  merit_corr_err[n-1] + integral/1000.*yerr;
      total_corr[n-1] =  total_corr[n-1] + integral/1000.;
    }
  }

  for(int n=2;n<=15;n++)
  {
    vn0_corr[n] = merit_corr[n-1]/total_corr[n-1];
cout<<n<<" "<<vn0_corr[n]<<endl;
    vn0_corr_up[n] = merit_corr_up[n-1]/total_corr[n-1];
    vn0_corr_down[n] = merit_corr_down[n-1]/total_corr[n-1];
    vn0_corr_sys[n-2] = vn0_corr_up[n];
    vn0_corr_sys[29-n] = vn0_corr_down[n];
    if(n>=5)
    {
      vn0_corr_sys[n-2] = vn0_corr[n]+0.0004;
      vn0_corr_sys[29-n] = vn0_corr[n]-0.0004;
    }
    vn0err_corr[n] = merit_corr_err[n-1]/total_corr[n-1];
    vn0_ratio[n] = vn0_corr[n]/vn0[n];
    vn0err_ratio[n] = 0;
  }

  double vn_hydro_ideal[4] = {0.21,0.1875,0.1,0.0375};
  double vn_hydro_004[4] = {0.195,0.167,0.08,0.025};
  double vn_hydro_008[4] = {0.18,0.15,0.0625,0.0167};
  double vn_hydro_012[4] = {0.167,0.14,0.05,0.0084};
  double vn_hydro_016[4] = {0.15,0.128,0.04,0.001};
  double etas[4] = {2,3,4,5};

  for(int i=3;i>=0;i--)
  {
    vn_hydro_ideal[i] = vn_hydro_ideal[i]/vn_hydro_ideal[0]*vn0[2];
    vn_hydro_004[i] = vn_hydro_004[i]/vn_hydro_004[0]*vn0[2];
    vn_hydro_008[i] = vn_hydro_008[i]/vn_hydro_008[0]*vn0[2];
    vn_hydro_012[i] = vn_hydro_012[i]/vn_hydro_012[0]*vn0[2];
    vn_hydro_016[i] = vn_hydro_016[i]/vn_hydro_016[0]*vn0[2];
  }

  TGraph* gr_ideal = new TGraph(4,etas,vn_hydro_ideal);
  TGraph* gr_004 = new TGraph(4,etas,vn_hydro_004);
  TGraph* gr_008 = new TGraph(4,etas,vn_hydro_008);
  TGraph* gr_012 = new TGraph(4,etas,vn_hydro_012);
  TGraph* gr_016 = new TGraph(4,etas,vn_hydro_016);
  gr_004->SetLineColor(kRed);
  gr_008->SetLineColor(kBlue);
  gr_012->SetLineColor(kGreen);
  gr_016->SetLineColor(6);
  gr_ideal->SetLineStyle(9);
  gr_ideal->SetLineWidth(2);
  gr_004->SetLineWidth(2);
  gr_008->SetLineWidth(2);
  gr_012->SetLineWidth(2);
  gr_016->SetLineWidth(2);

  double narray[15] = {0,1,2,3,4,5,6,7,8,9,10,11,12,13,14};
  double narray2[28] = {2,3,4,5,6,7,8,9,10,11,12,13,14,15,15,14,13,12,11,10,9,8,7,6,5,4,3,2};

  double narrayerr[15] = {0};
  TGraphErrors* gr_vn0 = new TGraphErrors(15,narray,vn0,narrayerr,vn0err);
  gr_vn0->SetName("vnn");
  TCanvas* c1 = new TCanvas("c1","",580,500);
  c1->SetLeftMargin(0.16);
  TH2D* htmp1 = new TH2D("htmp1",";n;v_{n}",100,0.5,7.9+5,100,0.00003-0.01,0.04);
  htmp1->GetXaxis()->CenterTitle();
  htmp1->GetYaxis()->CenterTitle();
  htmp1->GetXaxis()->SetLabelSize(0.8*htmp1->GetXaxis()->GetLabelSize());
  htmp1->GetYaxis()->SetLabelSize(0.8*htmp1->GetYaxis()->GetLabelSize());
  htmp1->GetYaxis()->SetTitleOffset(0.96*htmp1->GetYaxis()->GetTitleOffset());
  htmp1->GetXaxis()->SetTitleOffset(1.02*htmp1->GetXaxis()->GetTitleOffset());
  htmp1->GetYaxis()->SetTitleSize(1.1*htmp1->GetYaxis()->GetTitleSize());
  htmp1->GetXaxis()->SetTitleSize(0.9*htmp1->GetXaxis()->GetTitleSize());
//  c1->SetLogy();
  htmp1->Draw("");
  gr_vn0->Draw("PESAME");

  gr_ideal->Draw("LSAME");
  gr_004->Draw("LSAME");
  gr_008->Draw("LSAME");
  gr_012->Draw("LSAME");
  gr_016->Draw("LSAME");

  TLine* line1 = new TLine(0.5,0.0,7.9+5,0.0);
  line1->SetLineStyle(9);
  line1->Draw("lsame");

  TLatex* latex1 = new TLatex();
  latex1->SetNDC(1);
  latex1->SetTextSize(latex1->GetTextSize()*1.0);
  latex1->DrawLatex(0.65,0.87,"CMS Preliminary");
  latex1->DrawLatex(0.65,0.80,"PbPb  #sqrt{s_{NN}} = 2.76 TeV");
  latex1->DrawLatex(0.65,0.74,centtag.Data());
  latex1->DrawLatex(0.25,0.34,"0.3<p_{T}<3 GeV/c");

  TLegend* legend = new TLegend(0.2,0.45,0.45,0.7);
  legend->SetFillStyle(0);
  legend->SetTextFont(42);
  legend->AddEntry(gr_ideal,"Ideal Hydro","L");
  legend->AddEntry(gr_004,"#eta/s=0.04","L");
  legend->AddEntry(gr_008,"#eta/s=0.08","L");
  legend->AddEntry(gr_012,"#eta/s=0.12","L");
  legend->AddEntry(gr_016,"#eta/s=0.16","L");
//  legend->Draw("same");

  SaveCanvas(c1,"HI/UCC",Form("vnn_%s_centmin%d_centmax%d",tag.Data(),centmin,centmax));

  TGraphErrors* gr_corr_vn0 = new TGraphErrors(15,narray,vn0_corr,narrayerr,vn0err_corr);
  gr_corr_vn0->SetName("vnn_corr");
  TGraph* gr_corr_vn0_sys = new TGraph(28,narray2,vn0_corr_sys);
  gr_corr_vn0_sys->SetName("vnn_corr_sys");

  TCanvas* c1_corr = new TCanvas("c1_corr","",580,500);
  c1_corr->SetLeftMargin(0.16);
  htmp1->Draw("");
  gr_corr_vn0_sys->SetFillColor(17);
  gr_corr_vn0_sys->Draw("Fsame");
  gr_corr_vn0->Draw("PESAME");

  gr_ideal->Draw("LSAME");
  gr_004->Draw("LSAME");
  gr_008->Draw("LSAME");
  gr_012->Draw("LSAME");
  gr_016->Draw("LSAME");

  line1->Draw("lsame");
  latex1->Draw("same");
//  legend->Draw("same");

  SaveCanvas(c1_corr,"HI/UCC",Form("vnn_%s_centmin%d_centmax%d_corr",tag.Data(),centmin,centmax));

  TGraphErrors* gr_ratio_vn0 = new TGraphErrors(15,narray,vn0_ratio,narrayerr,vn0err_ratio);
  gr_ratio_vn0->SetName("vnn_ratio");
  TCanvas* c1_ratio = new TCanvas("c1_ratio","",580,500);
  c1_ratio->SetLeftMargin(0.16);
  TH2D* htmp1_ratio = new TH2D("htmp1_ratio",";n;v_{n}",100,0.5,7.9+5,100,0.5,1.5);
  htmp1_ratio->GetXaxis()->CenterTitle();
  htmp1_ratio->GetYaxis()->CenterTitle();
  htmp1_ratio->GetXaxis()->SetLabelSize(0.8*htmp1_ratio->GetXaxis()->GetLabelSize());
  htmp1_ratio->GetYaxis()->SetLabelSize(0.8*htmp1_ratio->GetYaxis()->GetLabelSize());
  htmp1_ratio->GetYaxis()->SetTitleOffset(0.96*htmp1_ratio->GetYaxis()->GetTitleOffset());
  htmp1_ratio->GetXaxis()->SetTitleOffset(1.02*htmp1_ratio->GetXaxis()->GetTitleOffset());
  htmp1_ratio->GetYaxis()->SetTitleSize(1.1*htmp1_ratio->GetYaxis()->GetTitleSize());
  htmp1_ratio->GetXaxis()->SetTitleSize(0.9*htmp1_ratio->GetXaxis()->GetTitleSize());
//  c1->SetLogy();
  htmp1_ratio->Draw("");
  gr_ratio_vn0->Draw("PESAME");
  latex1->Draw("same");
  TLine* line1_ratio = new TLine(0.5,1.0,7.9+5,1.0);
  line1_ratio->SetLineStyle(9);
  line1_ratio->Draw("lsame");

  SaveCanvas(c1_ratio,"HI/UCC",Form("vnn_%s_centmin%d_centmax%d_ratio",tag.Data(),centmin,centmax));

  TCanvas* c2 = new TCanvas("c2","",580,500);
  c2->SetLeftMargin(0.18);
  TH2D* htmp = new TH2D("htmp",";p_{T}(GeV/c);v_{n}{2part, |#Delta#eta| > 2}",100,-0.001,7.3,100,-0.005,0.099);  
  htmp->GetXaxis()->CenterTitle();
  htmp->GetYaxis()->CenterTitle();
  htmp->GetXaxis()->SetLabelSize(htmp->GetXaxis()->GetLabelSize());
  htmp->GetYaxis()->SetLabelSize(htmp->GetYaxis()->GetLabelSize());
  htmp->GetYaxis()->SetTitleOffset(0.8*htmp->GetYaxis()->GetTitleOffset());
  htmp->GetXaxis()->SetTitleOffset(0.7*htmp->GetXaxis()->GetTitleOffset());
  htmp->GetYaxis()->SetTitleSize(1.5*htmp->GetYaxis()->GetTitleSize());
  htmp->GetXaxis()->SetTitleSize(1.4*htmp->GetXaxis()->GetTitleSize());
  htmp->Draw();
  TLine* line = new TLine(0.001,0,7.3,0.0);
  line->SetLineStyle(9);
  line->Draw("lsame");
//  gr[0]->SetMarkerColor(6);
  gr[1]->SetMarkerColor(1);
  gr[2]->SetMarkerColor(2);
  gr[3]->SetMarkerColor(3);
  gr[4]->SetMarkerColor(4);
  gr[5]->SetMarkerColor(6);
  gr[1]->SetMarkerStyle(20);
  gr[2]->SetMarkerStyle(22);
  gr[3]->SetMarkerStyle(21);
  gr[4]->SetMarkerStyle(29);
  gr[5]->SetMarkerStyle(3);
  gr[2]->SetMarkerSize(1.1*gr[2]->GetMarkerSize());
  gr[3]->SetMarkerSize(0.8*gr[3]->GetMarkerSize());
  gr[4]->SetMarkerSize(1.3*gr[4]->GetMarkerSize());
  gr[5]->SetMarkerSize(1.3*gr[5]->GetMarkerSize());
  gr[1]->Draw("PESAME");
  gr[2]->Draw("PESAME");
  gr[3]->Draw("PESAME");
  gr[4]->Draw("PESAME");
  gr[5]->Draw("PESAME");

  TLegend* legend = new TLegend(0.18,0.6,0.47,0.9);
  legend->SetFillStyle(0);
  legend->SetTextFont(42);
  legend->AddEntry(gr[1],"n = 2","P");
  legend->AddEntry(gr[2],"n = 3","P");
  legend->AddEntry(gr[3],"n = 4","P");
  legend->AddEntry(gr[4],"n = 5","P");
  legend->AddEntry(gr[5],"n = 6","P");
  legend->Draw("same");

  TLatex* latex = new TLatex();
  latex->SetNDC(1);
  latex->SetTextSize(latex->GetTextSize()*1.0);
  latex->DrawLatex(0.66,0.86,"CMS Preliminary");
  latex->DrawLatex(0.64,0.80,"PbPb  #sqrt{s_{NN}} = 2.76 TeV");
  latex->DrawLatex(0.66,0.74,centtag.Data());

  SaveCanvas(c2,"HI/UCC",Form("vn_pt_%s_centmin%d_centmax%d",tag.Data(),centmin,centmax));

  TCanvas* c2_corr = new TCanvas("c2corr","",600,500);
  c2_corr->SetBottomMargin(0.12);
  c2_corr->SetLeftMargin(0.15);
  htmp->Draw();
  line->Draw("lsame");
  gr_corr[1]->SetMarkerColor(1);
  gr_corr[2]->SetMarkerColor(2);
  gr_corr[3]->SetMarkerColor(3);
  gr_corr[4]->SetMarkerColor(4);
  gr_corr[5]->SetMarkerColor(6);
  gr_corr[1]->SetMarkerStyle(20);
  gr_corr[2]->SetMarkerStyle(22);
  gr_corr[3]->SetMarkerStyle(21);
  gr_corr[4]->SetMarkerStyle(29);
  gr_corr[5]->SetMarkerStyle(3);
  gr_corr[2]->SetMarkerSize(1.3*gr_corr[2]->GetMarkerSize());
  gr_corr[3]->SetMarkerSize(1.0*gr_corr[3]->GetMarkerSize());
  gr_corr[4]->SetMarkerSize(1.5*gr_corr[4]->GetMarkerSize());
  gr_corr[5]->SetMarkerSize(1.3*gr_corr[5]->GetMarkerSize());

  gr_syst[1]->Draw("FSAME");
  gr_syst[2]->Draw("FSAME");
  gr_syst[3]->Draw("FSAME");
  gr_syst[4]->Draw("FSAME");
  gr_syst[5]->Draw("FSAME");

  gr_corr[1]->Draw("PESAME");
  gr_corr[2]->Draw("PESAME");
  gr_corr[3]->Draw("PESAME");
  gr_corr[4]->Draw("PESAME");
  gr_corr[5]->Draw("PESAME");
  legend->Draw("same");

  TLatex* latex_corr = new TLatex();
  latex_corr->SetNDC(1);
  latex_corr->SetTextSize(latex_corr->GetTextSize()*0.8);
//  latex_corr->DrawLatex(0.63,0.88,"CMS Preliminary");
  latex_corr->DrawLatex(0.54,0.875,"CMS PbPb  #sqrt{s_{NN}} = 2.76 TeV");
  latex_corr->DrawLatex(0.68,0.815,centtag.Data());
  latex_corr->DrawLatex(0.68,0.755,"1 < p_{T}^{ref} < 3 GeV/c");

  SaveCanvas(c2_corr,"HI/UCC",Form("vn_pt_%s_centmin%d_centmax%d_corr",tag.Data(),centmin,centmax));

  TCanvas* c2_ratio = new TCanvas("c2_ratio","",580,500);
  c2_ratio->SetLeftMargin(0.16);
  TH2D* htmp_ratio = new TH2D("htmp_ratio",";p_{T}(GeV/c);v^{corr}_{n}/v^{raw}_{n}",100,0.001,7.3,100,0.5,1.5);
  htmp_ratio->GetXaxis()->CenterTitle();
  htmp_ratio->GetYaxis()->CenterTitle();
  htmp_ratio->GetXaxis()->SetLabelSize(0.8*htmp_ratio->GetXaxis()->GetLabelSize());
  htmp_ratio->GetYaxis()->SetLabelSize(0.8*htmp_ratio->GetYaxis()->GetLabelSize());
  htmp_ratio->GetYaxis()->SetTitleOffset(0.98*htmp_ratio->GetYaxis()->GetTitleOffset());
  htmp_ratio->GetXaxis()->SetTitleOffset(1.02*htmp_ratio->GetXaxis()->GetTitleOffset());
  htmp_ratio->GetYaxis()->SetTitleSize(1.1*htmp_ratio->GetYaxis()->GetTitleSize());
  htmp_ratio->GetXaxis()->SetTitleSize(0.9*htmp_ratio->GetXaxis()->GetTitleSize());
  htmp_ratio->Draw();
  TLine* line_ratio = new TLine(0.001,1.0,7.3,1.0);
  line_ratio->SetLineStyle(9);
  line_ratio->Draw("lsame");
  gr_ratio[1]->SetMarkerColor(1);
  gr_ratio[2]->SetMarkerColor(2);
  gr_ratio[3]->SetMarkerColor(3);
  gr_ratio[4]->SetMarkerColor(4);
  gr_ratio[5]->SetMarkerColor(6);
  gr_ratio[1]->SetMarkerStyle(20);
  gr_ratio[2]->SetMarkerStyle(22);
  gr_ratio[3]->SetMarkerStyle(21);
  gr_ratio[4]->SetMarkerStyle(29);
  gr_ratio[5]->SetMarkerStyle(3);
  gr_ratio[2]->SetMarkerSize(1.1*gr_ratio[2]->GetMarkerSize());
  gr_ratio[3]->SetMarkerSize(0.8*gr_ratio[3]->GetMarkerSize());
  gr_ratio[4]->SetMarkerSize(1.3*gr_ratio[4]->GetMarkerSize());
  gr_ratio[5]->SetMarkerSize(1.3*gr_ratio[5]->GetMarkerSize());
  gr_ratio[1]->Draw("PESAME");
  gr_ratio[2]->Draw("PESAME");
  gr_ratio[3]->Draw("PESAME");
  gr_ratio[4]->Draw("PESAME");
  gr_ratio[5]->Draw("PESAME");
  legend->Draw("same");

  TLatex* latex_ratio = new TLatex();
  latex_ratio->SetNDC(1);
  latex_ratio->SetTextSize(latex_ratio->GetTextSize()*1.0);
  latex_ratio->DrawLatex(0.65,0.87,"CMS Preliminary");
  latex_ratio->DrawLatex(0.65,0.80,"PbPb  #sqrt{s_{NN}} = 2.76 TeV");
  latex_ratio->DrawLatex(0.65,0.74,centtag.Data());

  SaveCanvas(c2_ratio,"HI/UCC",Form("vn_pt_%s_centmin%d_centmax%d_ratio",tag.Data(),centmin,centmax));

//  gr[0]->Draw("PESAME");
/*
  c2->Print("/net/hisrv0001/home/davidlw/scratch1/UCCPileUp/pics/vnpt_data_UCC020.gif");
  c2->Print("/net/hisrv0001/home/davidlw/scratch1/UCCPileUp/pics/vnpt_data_UCC020.pdf");
  c2->Print("/net/hisrv0001/home/davidlw/scratch1/UCCPileUp/pics/vnpt_data_UCC020.eps");
  c2->Print("/net/hisrv0001/home/davidlw/scratch1/UCCPileUp/pics/vnpt_data_UCC020.C");
*/
/*
  TCanvas* c0 = new TCanvas("c0","",500,500);
  hsignal_1D[3]->Draw("PE");
  hbackground_1D[3]->SetMarkerStyle(24);
  hbackground_1D[3]->Draw("PESAME");

  TCanvas* c = new TCanvas("c","",500,500);
  hcorr_1D[3]->SetAxisRange(-0.001,0.006,"Y");
  hcorr_1D[3]->SetMarkerColor(1);
  hcorr_1D[3]->Draw("PE");
*/
return;
  TFile* fout = new TFile(Form("gr_%s_centmin%d_centmax%d.root",tag.Data(),centmin,centmax),"recreate");
  gr_vn0->SetName("vnn");
  gr_vn0->Write();
  gr_corr_vn0->SetName("vnn_corr");
  gr_corr_vn0->Write();
  gr_corr_vn0_sys->SetName("vnn_corr_sys");
  gr_corr_vn0_sys->Write();
  gr_ratio_vn0->SetName("vnn_ratio");
  gr_ratio_vn0->Write();
  for(int i=0;i<6;i++) 
  {
    gr[i]->SetName(Form("v%dpt",i+1));
    gr[i]->Write();
    gr_corr[i]->SetName(Form("v%dpt_corr",i+1));
    gr_corr[i]->Write();
    gr_ratio[i]->SetName(Form("v%dpt_ratio",i+1));
    gr_ratio[i]->Write();
    gr_syst[i]->SetName(Form("v%dpt_syst",i+1));
    gr_syst[i]->Write();
  }
}
コード例 #12
0
ファイル: hv_scan.C プロジェクト: c-dilks/run16
void hv_scan()
{
  gStyle->SetOptFit(1);

  // ====================================================================
 
  // curves for bad fits. A fit is considered bad if alpha is far from
  // it's expected value. In this case, alpha is fixed to this expected
  // value, and the scale factor is then fit for
  const Double_t expect_alpha_large = 12.23;
  const Double_t expect_alpha_russian = 3.93;
  const Double_t expect_alpha_yale = 7.80;
  // alpha from fit must be within range expect_alpha +/- range_alpha
  const Double_t range_alpha_large = 4;
  const Double_t range_alpha_russian = 2;
  const Double_t range_alpha_yale = 2;

  // ====================================================================

  // runnum <--> HV settings
  /*
  // MAGNET OFF
  const Int_t NUM = 1;
  Int_t runnum[NUM];
  Double_t largehv[NUM]; // in kV
  Int_t smallrdac[NUM]; // software value {0x00-0xFF} (maps to voltage value)
  runnum[0]=15353003; largehv[0]=1.2; smallrdac[0]=0xA0; // not necessarily correct, only NSTB 2&4 were on
  */
  /*
  // MAGNET OFF
  const Int_t NUM = 5;
  Int_t runnum[NUM];
  Double_t largehv[NUM]; // in kV
  Int_t smallrdac[NUM]; // software value {0x00-0xFF} (maps to voltage value)
  runnum[0]=16017058; largehv[0]=1.1; smallrdac[0]=0x90;
  runnum[1]=16017054; largehv[1]=1.2; smallrdac[1]=0xA0;
  runnum[2]=16017055; largehv[2]=1.3; smallrdac[2]=0xB0;
  runnum[3]=16017056; largehv[3]=1.4; smallrdac[3]=0xC0;
  runnum[4]=16017057; largehv[4]=1.5; smallrdac[4]=0xD0;
  */
  /*
  // MAGNET OFF
  const Int_t NUM = 13;
  Int_t runnum[NUM];
  Double_t largehv[NUM]; // in kV
  Int_t smallrdac[NUM]; // software value {0x00-0xFF} (maps to voltage value)
  runnum[0]=16020005; largehv[0]=1.10; smallrdac[0]=0xA0;
  runnum[1]=16020006; largehv[1]=1.15; smallrdac[1]=0xA8;
  runnum[2]=16020004; largehv[2]=1.20; smallrdac[2]=0xB0;
  runnum[3]=16020007; largehv[3]=1.25; smallrdac[3]=0xB8;
  runnum[4]=16020008; largehv[4]=1.30; smallrdac[4]=0xC0;
  runnum[5]=16020009; largehv[5]=1.35; smallrdac[5]=0xC8;
  runnum[6]=16020010; largehv[6]=1.40; smallrdac[6]=0xD0;
  runnum[7]=16020011; largehv[7]=1.45; smallrdac[7]=0xD8;
  runnum[8]=16020012; largehv[8]=1.50; smallrdac[8]=0xE0;    // DISREGARD NSTB==4 // (lost communication)
  runnum[9]=16020013; largehv[9]=1.55; smallrdac[9]=0xE8;    // DISREGARD NSTB==4 // (lost communication)
  runnum[10]=16020014; largehv[10]=1.60; smallrdac[10]=0xF0; // DISREGARD NSTB==4 // (lost communication)
  runnum[11]=16020015; largehv[11]=1.60; smallrdac[11]=0xF8; // DISREGARD NSTB==4 // (lost communication)
  runnum[12]=16020016; largehv[12]=1.60; smallrdac[12]=0xFF; // DISREGARD NSTB==4 // (lost communication)
  */
  /*
  // MAGNET ON
  const Int_t NUM = 13;
  Int_t runnum[NUM];
  Double_t largehv[NUM]; // in kV
  Int_t smallrdac[NUM]; // software value {0x00-0xFF} (maps to voltage value)
  runnum[0]=16021065; largehv[0]=1.10; smallrdac[0]=0xA0;
  runnum[1]=16021066; largehv[1]=1.15; smallrdac[1]=0xA8;
  runnum[2]=16021067; largehv[2]=1.20; smallrdac[2]=0xB0; //
  runnum[3]=16021068; largehv[3]=1.25; smallrdac[3]=0xB8;
  runnum[4]=16021069; largehv[4]=1.30; smallrdac[4]=0xC0;
  runnum[5]=16021070; largehv[5]=1.35; smallrdac[5]=0xC8; //
  runnum[6]=16021071; largehv[6]=1.40; smallrdac[6]=0xD0;
  runnum[7]=16021072; largehv[7]=1.45; smallrdac[7]=0xD8;
  runnum[8]=16021073; largehv[8]=1.50; smallrdac[8]=0xE0; //
  runnum[9]=16021074; largehv[9]=1.55; smallrdac[9]=0xE8;
  runnum[10]=16021075; largehv[10]=1.60; smallrdac[10]=0xF0;
  runnum[11]=16021076; largehv[11]=1.65; smallrdac[11]=0xF8; //
  runnum[12]=16021077; largehv[12]=1.70; smallrdac[12]=0xFF;
  */
  /*
  // MAGNET OFF
  const Int_t NUM = 1;
  Int_t runnum[NUM];
  Double_t largehv[NUM]; // in kV
  Int_t smallrdac[NUM]; // software value {0x00-0xFF} (maps to voltage value)
  runnum[0]=16037091; largehv[0]=1.30; smallrdac[0]=0xA0;
  */
  /*
  // MAGNET ON
  const Int_t NUM = 1;
  Int_t runnum[NUM];
  Double_t largehv[NUM]; // in kV
  Int_t smallrdac[NUM]; // software value {0x00-0xFF} (maps to voltage value)
  runnum[0]=16042057; largehv[0]=1.30; smallrdac[0]=0xA0;
  */
  /*
  // MAGNET ON
  const Int_t NUM = 16;
  Int_t runnum[NUM];
  Double_t largehv[NUM]; // in kV
  Int_t smallrdac[NUM]; // software value {0x00-0xFF} (maps to voltage value)
  runnum[0]=16041163; largehv[0]=1.750; smallrdac[0]=0xF0;
  runnum[1]=16041164; largehv[1]=1.700; smallrdac[1]=0xFF;
  runnum[2]=16041165; largehv[2]=1.650; smallrdac[2]=0xF8;
  runnum[3]=16041166; largehv[3]=1.600; smallrdac[3]=0xF0;
  runnum[4]=16041167; largehv[4]=1.550; smallrdac[4]=0xE8;
  runnum[5]=16041168; largehv[5]=1.500; smallrdac[5]=0xE0;
  runnum[6]=16041169; largehv[6]=1.450; smallrdac[6]=0xD8;
  runnum[7]=16041170; largehv[7]=1.400; smallrdac[7]=0xD0;
  runnum[8]=16041171; largehv[8]=1.350; smallrdac[8]=0xC8;
  runnum[9]=16041172; largehv[9]=1.300; smallrdac[9]=0xC0;
  runnum[10]=16041173; largehv[10]=1.250; smallrdac[10]=0xB8;
  runnum[11]=16041174; largehv[11]=1.200; smallrdac[11]=0xB0;
  runnum[12]=16041175; largehv[12]=1.150; smallrdac[12]=0xA8;
  runnum[13]=16041176; largehv[13]=1.100; smallrdac[13]=0xA0;
  runnum[14]=16041177; largehv[14]=1.050; smallrdac[14]=0x98;
  runnum[15]=16041178; largehv[15]=1.000; smallrdac[15]=0x90;
  */
  /*
  // MAGNET ON
  const Int_t NUM = 1;
  Int_t runnum[NUM];
  Double_t largehv[NUM]; // in kV
  Int_t smallrdac[NUM]; // software value {0x00-0xFF} (maps to voltage value)
  runnum[0]=16062061; largehv[0]=1.40; smallrdac[0]=0xA0;
  */
  /*
  // MAGNET ON
  const Int_t NUM = 1;
  Int_t runnum[NUM];
  Double_t largehv[NUM]; // in kV
  Int_t smallrdac[NUM]; // software value {0x00-0xFF} (maps to voltage value)
  runnum[0]=16112024; largehv[0]=1.40; smallrdac[0]=0xA0; // (@ iteration values)
  */
  ///*
  // MAGNET OFF
  const Int_t NUM = 1;
  Int_t runnum[NUM];
  Double_t largehv[NUM]; // in kV
  Int_t smallrdac[NUM]; // software value {0x00-0xFF} (maps to voltage value)
  runnum[0]=16133072; largehv[0]=1.40; smallrdac[0]=0xA0; // (@ iteration values)
  //*/
  
  /*
  // MAGNET ON
  const Int_t NUM = 1;
  Int_t runnum[NUM];
  Double_t largehv[NUM]; // in kV
  Int_t smallrdac[NUM]; // software value {0x00-0xFF} (maps to voltage value)
  runnum[0]=16125028; largehv[0]=1.40; smallrdac[0]=0xA0; // (@ iteration values)
  */
  
  // ====================================================================

  // convert small cell rdac value to HV setpoint (in kV)
  gROOT->LoadMacro("small_cell_LUT.C");
  Double_t smallhv[NUM]; // small cell HV setpoint [kV]
  for(Int_t i=0; i<NUM; i++) smallhv[i]=(small_cell_LUT(smallrdac[i]))/1000.;


  // open adc trees
  TFile * adcfile[NUM];
  char adcfile_n[NUM][64];
  TTree * adctr[NUM];
  for(Int_t r=0; r<NUM; r++)
  {
    sprintf(adcfile_n[r],"%d.1/adcTr.root",runnum[r]);
    adcfile[r] = new TFile(adcfile_n[r],"READ");
    adctr[r] = (TTree*) adcfile[r]->Get("Tr_adc");
    printf("run=%d largehv=-%.2fkV smallrdac=%X smallhv=%.3f entries=%d\n",
      runnum[r],largehv[r],smallrdac[r],smallhv[r],adctr[r]->GetEntries());
  };


  // open geotr
  TFile * geofile = new TFile("geotr.root","READ");
  TTree * geotr = (TTree*) geofile->Get("geotr");
  Int_t nstb,row,col,chan;
  char cell_type[32];
  geotr->SetBranchAddress("row",&row);
  geotr->SetBranchAddress("col",&col);
  geotr->SetBranchAddress("nstb",&nstb);
  geotr->SetBranchAddress("chan",&chan);
  geotr->SetBranchAddress("cell_type",cell_type);


  // define output file & tree
  TFile * outfile = new TFile("hvtr.root","RECREATE");
  TTree * hvtr = new TTree("hvtr","hvtr");
  Double_t alpha,scale,chisq,ndf;
  Double_t alpha_arr[3];
  Double_t scale_arr[3];
  Double_t chisq_arr[3];
  Double_t ndf_arr[3];
  Int_t choice;
  Float_t Lhv,Shv;
  Double_t gaus_const,gaus_mean,gaus_sigma,gaus_chisq,gaus_ndf;
  Double_t dist_mean,dist_sigma;
  hvtr->Branch("nstb",&nstb,"nstb/I");
  hvtr->Branch("row",&row,"row/I");
  hvtr->Branch("col",&col,"col/I");
  hvtr->Branch("cell_type",cell_type,"cell_type/C");
  hvtr->Branch("scale",&scale,"scale/D"); // gain curve fit: ADC = scale*V^alpha
  hvtr->Branch("alpha",&alpha,"alpha/D");
  hvtr->Branch("chisq",&chisq,"chisq/D");
  hvtr->Branch("ndf",&ndf,"ndf/D");
  TTree * adcdisttr = new TTree("adcdisttr","adcdisttr");
  adcdisttr->Branch("nstb",&nstb,"nstb/I");
  adcdisttr->Branch("row",&row,"row/I");
  adcdisttr->Branch("col",&col,"col/I");
  adcdisttr->Branch("cell_type",cell_type,"cell_type/C");
  adcdisttr->Branch("Lhv",&Lhv,"Lhv/F"); // large cell voltage setpoint
  adcdisttr->Branch("Shv",&Shv,"Shv/F"); // small cell voltage setpoint
  adcdisttr->Branch("dist_mean",&dist_mean,"dist_mean/D"); // distribution mean
  adcdisttr->Branch("dist_sigma",&dist_sigma,"dist_sigma/D"); // distribution rms
  adcdisttr->Branch("gaus_const",&gaus_const,"gaus_const/D"); // height of gaussian fit
  adcdisttr->Branch("gaus_mean",&gaus_mean,"gaus_mean/D"); // mean of gaussian fit
  adcdisttr->Branch("gaus_sigma",&gaus_sigma,"gaus_sigma/D"); // sigma of gaussian fit
  adcdisttr->Branch("gaus_chisq",&gaus_chisq,"gaus_chisq/D"); // chisq of gaussian fit
  adcdisttr->Branch("gaus_ndf",&gaus_ndf,"gaus_ndf/D"); // ndf of gaussian fit


  // loop through FMS cells
  Int_t sf=3;
  Int_t factor;
  TCanvas * adccanv = new TCanvas("adccanv","adccanv",sf*NUM*200,sf*200);
  TCanvas * gaincanv = new TCanvas("gaincanv","gaincanv",1000,1000);
  TCanvas * fitcanv = new TCanvas("fitcanv","fitanv",500,500); // for fitting
  Int_t cdno;
  Int_t canv_row=1;
  Int_t page=1;
  TH1D * adcdist[4][34][17][NUM];
  char adcdist_n[4][34][17][NUM][64];
  char cellcut[256];
  TGraphErrors * gaingr[4][34][17];
  TF1 * gaingr_fit[4][34][17];
  TF1 * gaingr_fitL[4][34][17]; // left half fit
  TF1 * gaingr_fitA[4][34][17]; // all points
  TF1 * gaingr_fitR[4][34][17]; // right half fit
  char gaingr_fit_n[4][34][17][128];
  char gaingr_fitL_n[4][34][17][128];
  char gaingr_fitA_n[4][34][17][128];
  char gaingr_fitR_n[4][34][17][128];
  char gaingr_n[4][34][17][64];
  Int_t gaingr_i[4][34][17];
  Double_t hv,hv_low,hv_high,hv_low_small,hv_low_large,hv_high_small,hv_high_large;
  Double_t hv_mid,hv_midcalc_low,hv_midcalc_high;
  Int_t ent = geotr->GetEntries();
  char printname[64];
  Double_t distmaxloc,distrms;
  Double_t expect_alpha,range_alpha;
  Int_t distmaxbin;
  char fit_param_txt[4][34][17][256];
  char better_str[16];
  char titlemod[256];
  TLatex * choice_tex[4][34][17];
  Color_t choice_color[3] = {kRed,kGreen+1,kBlue};
  hv_low_small = 3000;
  hv_low_large = 3000;
  hv_high_small = 0;
  hv_high_large = 0;
  for(Int_t i=0; i<NUM; i++)
  {
    hv_low_small = (smallhv[i] < hv_low_small) ? smallhv[i]:hv_low_small;
    hv_low_large = (largehv[i] < hv_low_large) ? largehv[i]:hv_low_large;
    hv_high_small = (smallhv[i] > hv_high_small) ? smallhv[i]:hv_high_small;
    hv_high_large = (largehv[i] > hv_high_large) ? largehv[i]:hv_high_large;
  };

  // -------------- FMS CHANNEL LOOP -------------------- //
  for(Int_t i=0; i<ent; i++)
  {
    // -- DEBUG --
    /*
      if(i==0) i=370;
      if(i==390) i=400;
      if(i==420) i=800;
      if(i==820) i=1100;
      if(i==1120) i=1263;
    */
    // -- END DEBUG --
    geotr->GetEntry(i);
    printf("%d %d %d [%d]\n",nstb,row,col,chan);

    // set alpha expected values based on cell type
    // (only caring about large cells, small russian cells, small yale cells
    if(nstb==1 || nstb==2)
    {
      expect_alpha = expect_alpha_large;
      range_alpha = range_alpha_large;
    }
    else
    {
      if(!strcmp(cell_type,"small_russian"))
      {
        expect_alpha = expect_alpha_russian;
        range_alpha = range_alpha_russian;
      }
      else if(!strcmp(cell_type,"small_yale"))
      {
        expect_alpha = expect_alpha_yale;
        range_alpha = range_alpha_yale;
      };
    };

    // define ADC vs. V plots 
    if(nstb==1||nstb==2) factor=17;
    else factor=12;
    sprintf(gaingr_n[nstb-1][row][col],"ADC_vs_V_n%d_ch%d_r%d_c%d (fit: ADC=cV^{#alpha})",
      nstb,col+row*factor+1,row,col);
    gaingr[nstb-1][row][col] = new TGraphErrors();
    gaingr[nstb-1][row][col]->SetName(gaingr_n[nstb-1][row][col]);
    gaingr[nstb-1][row][col]->SetTitle(gaingr_n[nstb-1][row][col]);
    gaingr[nstb-1][row][col]->SetMarkerStyle(kFullCircle);
    sprintf(gaingr_fit_n[nstb-1][row][col],"gaingr_fit_n%d_ch%d_r%d_c%d",
      nstb,col+row*factor+1,row,col);
    sprintf(gaingr_fitL_n[nstb-1][row][col],"gaingr_fitL_n%d_ch%d_r%d_c%d",
      nstb,col+row*factor+1,row,col);
    sprintf(gaingr_fitA_n[nstb-1][row][col],"gaingr_fitA_n%d_ch%d_r%d_c%d",
      nstb,col+row*factor+1,row,col);
    sprintf(gaingr_fitR_n[nstb-1][row][col],"gaingr_fitR_n%d_ch%d_r%d_c%d",
      nstb,col+row*factor+1,row,col);
    if(nstb==1||nstb==2) { hv_low=hv_low_large-0.1; hv_high=hv_high_large+0.1; }
    else {hv_low=hv_low_small-0.1; hv_high=hv_high_small+0.1; };
    hv_midcalc_low=hv_high;
    hv_midcalc_high=hv_low;
    
    // ================== GAIN CURVE FIT FUNCTIONS =================== //

    // power law fit
    gaingr_fit[nstb-1][row][col] = new TF1(gaingr_fit_n[nstb-1][row][col],"[0]*x^[1]",hv_low,hv_high);
    gaingr_fitL[nstb-1][row][col] = new TF1(gaingr_fitL_n[nstb-1][row][col],"[0]*x^[1]",hv_low,hv_high);
    gaingr_fitA[nstb-1][row][col] = new TF1(gaingr_fitA_n[nstb-1][row][col],"[0]*x^[1]",hv_low,hv_high);
    gaingr_fitR[nstb-1][row][col] = new TF1(gaingr_fitR_n[nstb-1][row][col],"[0]*x^[1]",hv_low,hv_high);
    if(nstb==1||nstb==2)  
    {
      gaingr_fit[nstb-1][row][col]->SetParameters(1,8);
      gaingr_fitL[nstb-1][row][col]->SetParameters(1,8);
      gaingr_fitA[nstb-1][row][col]->SetParameters(1,8);
      gaingr_fitR[nstb-1][row][col]->SetParameters(1,8);
    }
    else 
    {
      gaingr_fit[nstb-1][row][col]->SetParameters(1,4);
      gaingr_fitL[nstb-1][row][col]->SetParameters(1,4);
      gaingr_fitA[nstb-1][row][col]->SetParameters(1,4);
      gaingr_fitR[nstb-1][row][col]->SetParameters(1,4);
    };

    gaingr_fit[nstb-1][row][col]->SetParLimits(1,1,30);
    gaingr_fitL[nstb-1][row][col]->SetParLimits(1,1,30);
    gaingr_fitA[nstb-1][row][col]->SetParLimits(1,1,30);
    gaingr_fitR[nstb-1][row][col]->SetParLimits(1,1,30);

    gaingr_fit[nstb-1][row][col]->SetParName(0,"c");
    gaingr_fit[nstb-1][row][col]->SetParName(1,"#alpha");
    gaingr_fitL[nstb-1][row][col]->SetParName(0,"c_{L}");
    gaingr_fitL[nstb-1][row][col]->SetParName(1,"#alpha_{L}");
    gaingr_fitA[nstb-1][row][col]->SetParName(0,"c_{A}");
    gaingr_fitA[nstb-1][row][col]->SetParName(1,"#alpha_{A}");
    gaingr_fitR[nstb-1][row][col]->SetParName(0,"c_{R}");
    gaingr_fitR[nstb-1][row][col]->SetParName(1,"#alpha_{R}");

    
    // e^quadratic fit -- DEPRECATED
    /*
    gaingr_fit[nstb-1][row][col] =
      new TF1(gaingr_fit_n[nstb-1][row][col],"exp([0]*[1]*x+[2]*x^2)",hv_low,hv_high);
    gaingr_fit[nstb-1][row][col]->SetParameters(3.,0.01,0.00005);
    gaingr_fit[nstb-1][row][col]->SetParLimits(0,1e-10,100);
    gaingr_fit[nstb-1][row][col]->SetParLimits(1,1e-10,100);
    gaingr_fit[nstb-1][row][col]->SetParLimits(2,1e-10,100);
    */

    // =============================================================== //


    // loop through HV settings
    gaingr_i[nstb-1][row][col] = 0;
    for(Int_t r=0; r<NUM; r++)
    {
      // project ADC distribution and fit to Gaussian
      printf(" %.2f 0x%X\n",largehv[r],smallrdac[r]);
      sprintf(adcdist_n[nstb-1][row][col][r],"adcdist_n%d_ch%d_r%d_c%d_hv%d%X",
        nstb,col+row*factor+1,row,col,(Int_t)1000*largehv[r],smallrdac[r]);
      adcdist[nstb-1][row][col][r] = new TH1D(adcdist_n[nstb-1][row][col][r],
        adcdist_n[nstb-1][row][col][r],4096,0,4096);
      sprintf(cellcut,"nstbADC==%d&&rowADC==%d&&colADC==%d",nstb,row,col);
      adctr[r]->Project(adcdist_n[nstb-1][row][col][r],"ADC",cellcut);
      fitcanv->Clear();
      fitcanv->cd();
      Lhv=largehv[r];
      Shv=smallrdac[r];
      if(adcdist[nstb-1][row][col][r]->GetEntries())
      {
        //adcdist[nstb-1][row][col][r]->Fit("gaus","Q","",0,4096);
        distmaxbin = adcdist[nstb-1][row][col][r]->GetMaximumBin();
        distmaxloc = adcdist[nstb-1][row][col][r]->GetBinCenter(distmaxbin);
        distrms = adcdist[nstb-1][row][col][r]->GetRMS();
        adcdist[nstb-1][row][col][r]->Fit("gaus","Q","",distmaxloc-4*distrms,distmaxloc+4*distrms);
        gaus_const = adcdist[nstb-1][row][col][r]->GetFunction("gaus")->GetParameter(0);
        gaus_mean = adcdist[nstb-1][row][col][r]->GetFunction("gaus")->GetParameter(1);
        gaus_sigma = adcdist[nstb-1][row][col][r]->GetFunction("gaus")->GetParameter(2);
        gaus_chisq = adcdist[nstb-1][row][col][r]->GetFunction("gaus")->GetChisquare();
        gaus_ndf = adcdist[nstb-1][row][col][r]->GetFunction("gaus")->GetNDF();
        dist_mean = adcdist[nstb-1][row][col][r]->GetMean();
        dist_sigma = distrms;
        adcdisttr->Fill();
      };

      // add point to ADC vs. HV gain curve graph
      if(adcdist[nstb-1][row][col][r]->GetFunction("gaus"))
      {
        // points are added to gain curves given the following constraints:
        // -- upper limit is in place to remove saturated ADC counts from fit
        // -- lower limit is in place to remove low gain junk
        // -- mean error must be less than mean
        if(adcdist[nstb-1][row][col][r]->GetFunction("gaus")->GetParameter(1) > 10 &&
           adcdist[nstb-1][row][col][r]->GetFunction("gaus")->GetParameter(1) <= 3800 &&
           adcdist[nstb-1][row][col][r]->GetFunction("gaus")->GetParameter(1) >
           adcdist[nstb-1][row][col][r]->GetFunction("gaus")->GetParError(1)) 
        {
          if(nstb==1||nstb==2) hv=largehv[r];
          else hv=smallhv[r];

          // NSTB==4 LOST COMMUNICATION RUNS 020012-16; THIS FILTERS IT OUT (FILTER DISABLED)
          // to enable filter, place the following if statement:
          // if(!(r>=8 && nstb==4)) { around SetPoint & SetPointError & gaingr_i++ lines }
          
          gaingr[nstb-1][row][col]->SetPoint(gaingr_i[nstb-1][row][col],hv,
            adcdist[nstb-1][row][col][r]->GetFunction("gaus")->GetParameter(1));
          gaingr[nstb-1][row][col]->SetPointError(gaingr_i[nstb-1][row][col],0,
            adcdist[nstb-1][row][col][r]->GetFunction("gaus")->GetParError(1));
          (gaingr_i[nstb-1][row][col])++;

          hv_midcalc_low = (hv < hv_midcalc_low) ? hv:hv_midcalc_low;
          hv_midcalc_high = (hv > hv_midcalc_high) ? hv:hv_midcalc_high;
        };
      };

      // draw ADC dists to canvas
      cdno=(canv_row-1)*NUM+r+canv_row;
      if(cdno==1) 
      {
        adccanv->Clear();
        adccanv->Divide(NUM,1);
      };
      //printf("--- %d %d %d %d %d %p\n",cdno,nstb-1,row,col,r,(void*)(adccanv->GetPad(cdno)));
      adccanv->GetPad(cdno)->SetLogx();
      adccanv->GetPad(cdno)->SetLogy();
      adccanv->GetPad(cdno)->cd();
      adcdist[nstb-1][row][col][r]->Draw();
      //adcdist[nstb-1][row][col][r]->Write();
    };
    hv_mid = (hv_midcalc_low+hv_midcalc_high)/2.0;

    // fit ADC vs. HV gain curves and fill hvtr tree
    gaincanv->cd();
    gaincanv->SetLogy();
    gaincanv->SetGrid(1,1);

    // fit left half & right half of HV range separately, and choose the one with the
    // better chisq to be the gain curve; this technique helps to avoid the cases where
    // an outlier point draws the fit away from the trending data points
    if(gaingr_i[nstb-1][row][col])
    {
      // fit left half (L), right half (R) and all points (A)
      gaingr[nstb-1][row][col]->Fit(gaingr_fitL[nstb-1][row][col],"MQN","",hv_low,hv_mid); 
      gaingr[nstb-1][row][col]->Fit(gaingr_fitA[nstb-1][row][col],"MQN","",hv_low,hv_high); 
      gaingr[nstb-1][row][col]->Fit(gaingr_fitR[nstb-1][row][col],"MQN","",hv_mid,hv_high); 

      // parameter, chisq, and ndf "array", where array index is
      //  0 for L (left half fit)
      //  1 for A (all points fit)
      //  2 for R (right half fit)
      scale_arr[0] = gaingr_fitL[nstb-1][row][col]->GetParameter(0);
      alpha_arr[0] = gaingr_fitL[nstb-1][row][col]->GetParameter(1);
      chisq_arr[0] = gaingr_fitL[nstb-1][row][col]->GetChisquare();
      ndf_arr[0] = gaingr_fitL[nstb-1][row][col]->GetNDF();
      scale_arr[1] = gaingr_fitA[nstb-1][row][col]->GetParameter(0);
      alpha_arr[1] = gaingr_fitA[nstb-1][row][col]->GetParameter(1);
      chisq_arr[1] = gaingr_fitA[nstb-1][row][col]->GetChisquare();
      ndf_arr[1] = gaingr_fitA[nstb-1][row][col]->GetNDF();
      scale_arr[2] = gaingr_fitR[nstb-1][row][col]->GetParameter(0);
      alpha_arr[2] = gaingr_fitR[nstb-1][row][col]->GetParameter(1);
      chisq_arr[2] = gaingr_fitR[nstb-1][row][col]->GetChisquare();
      ndf_arr[2] = gaingr_fitR[nstb-1][row][col]->GetNDF();

      // choose lowest chisq, but only if
      // - all points fit chisq is bad
      // - best chosen must be chisq>1
      // ==> Int_t choice is then the chosen array index; this is the "choice number"
      if(chisq_arr[1]>3000)
      {
        if(!(chisq_arr[0]>1) && !(chisq_arr[2]>1)) choice=1;
        else if(!(chisq_arr[0]>1)) choice=2;
        else if(!(chisq_arr[2]>1)) choice=0;
        else choice = (chisq_arr[0]/ndf_arr[0] < chisq_arr[2]/ndf_arr[2]) ? 0:2;
        choice = (chisq_arr[1]/ndf_arr[1] < chisq_arr[choice]/ndf_arr[choice]) ? 1:choice;
        //printf("----------- %.2f %.2f %.2f ---- choose %d\n",chisq_arr[0],chisq_arr[1],chisq_arr[2],choice);
      }
      else
      {
        choice=1;
        //printf("----------- %.2f %.2f %.2f ---- choose %d, since full chisq ok\n",chisq_arr[0],chisq_arr[1],chisq_arr[2],choice);
      };

      // set tree branch variables to the chosen values according to "choice number"
      scale = scale_arr[choice];
      alpha = alpha_arr[choice];
      chisq = chisq_arr[choice];
      ndf = ndf_arr[choice];

      // set gaingr limits & titles
      gaingr[nstb-1][row][col]->GetHistogram()->SetMaximum(1e5);
      gaingr[nstb-1][row][col]->GetHistogram()->SetMinimum(1e-1);
      gaingr[nstb-1][row][col]->GetXaxis()->SetLimits(hv_low,hv_high);
      gaingr[nstb-1][row][col]->GetXaxis()->SetTitle("voltage set point (kV)");
      gaingr[nstb-1][row][col]->GetYaxis()->SetTitle("mean ADC counts");

      // set TF1 colors
      gaingr_fitL[nstb-1][row][col]->SetLineColor(choice_color[0]);
      gaingr_fitA[nstb-1][row][col]->SetLineColor(choice_color[1]);
      gaingr_fitR[nstb-1][row][col]->SetLineColor(choice_color[2]);

      // now that we've chosen which gain curve to use, we fix the parameters for
      // gaingr_fit to the chosen parameters, and run TGraph::Fit with these
      // fixed parameters so they show up when the TGraph is drawn later
      gaingr_fit[nstb-1][row][col]->FixParameter(0,scale);
      gaingr_fit[nstb-1][row][col]->FixParameter(1,alpha);
      gaingr_fit[nstb-1][row][col]->SetLineColor(choice_color[choice]);
      gaingr[nstb-1][row][col]->Fit(gaingr_fit[nstb-1][row][col],"MQ","",hv_low,hv_high); 

      // draw the TGraph first so chosen fit parameters are drawn, then draw
      // the other three TF1's over the TGraph
      gaingr[nstb-1][row][col]->Draw("APE");
      gaingr_fitL[nstb-1][row][col]->Draw("same");
      gaingr_fitA[nstb-1][row][col]->Draw("same");
      gaingr_fitR[nstb-1][row][col]->Draw("same");

      choice_tex[nstb-1][row][col] = new TLatex(0.12,0.83,"#bullet");
      choice_tex[nstb-1][row][col]->SetNDC();
      choice_tex[nstb-1][row][col]->SetTextColor(choice_color[choice]);
      choice_tex[nstb-1][row][col]->Draw();
      
      // when either the left half fit or right half fit was chosen,
      // we change the x-axis title to be three floats: 
      // chisq/ndf for left half, all points, right half fits, respectively
      // --> this is for diagnosing why the all points fit wasn't chosen
      if(choice!=1)
      {
        sprintf(titlemod,"%.2f %.2f %.2f",chisq_arr[0]/ndf_arr[0],chisq_arr[1]/ndf_arr[1],chisq_arr[2]/ndf_arr[2]);
        gaingr[nstb-1][row][col]->GetXaxis()->SetTitle(titlemod);
      };
    }
    else
    {
      // set parameters to expected values for completely data-less channels
      gaincanv->Clear();
      alpha = expect_alpha;
      scale = 1;
      chisq = 0; 
      ndf = 0;
    };
    hvtr->Fill();

    //if(cdno==NUM*(NUM+1) || i+1==ent)

    if(cdno==NUM)
    {
      //if(page==1) adccanv->Print("gain_curves.pdf(","pdf");
      //else if(i+1==ent) adccanv->Print("gain_curves.pdf)","pdf");
      //else adccanv->Print("gain_curves.pdf","pdf");
      if(nstb==1||nstb==2) factor=17;
      else factor=12;
      sprintf(printname,"adc_dists/n%d_ch%d_r%d_c%d.png",nstb,col+row*factor+1,row,col);
      adccanv->Print(printname,"png");
      sprintf(printname,"gain_curves/n%d_ch%d_r%d_c%d.png",nstb,col+row*factor+1,row,col);
      gaincanv->Print(printname,"png");
      page++;
      canv_row=1;
    }
    else canv_row++;
  }; // end cell loop


  // write output
  hvtr->Write("hvtr");
  adcdisttr->Write("adcdisttr");
};
コード例 #13
0
ファイル: anaJesFF.C プロジェクト: CmsHI/CVS_SavedFMa
void anaJesFF(int doMC=0,
    TString SrcName = "HCPR-MB",
    TString AnaVersion = "a1123",
    TString CmpVersion = "c0",
    TString modName = "djcalo",
    Double_t NrJEtMin = 0,
    Double_t NrJEtMax = 200,
    TString DJCutType = "Ana",
    TString fragVar = "lppt[0]/nljet",
    TString fragVarTag = "LzJet",
    TString fragVarTitle = "E_{T}^{Tower1}/E_{T}^{Jet}",
    Double_t fragVarMin = 0,
    Double_t fragVarMax = 0.6,
    //TString fragVar = "nlrjet",
    //TString fragVarTag = "RefJEt",
    //TString fragVarTitle = "E_{T}^{RefJet}",
    //Double_t fragVarMin = 0,
    //Double_t fragVarMax = 250,
    TString jextraCut = "",//"(ljcpt[0]-ljcptbg[0])/nlrjet>0.5",
    const char * inFile0Name="dj_HCPR-MB-151020to151076_trigana1116.root",
    TString header = "HICore-MB",
    TString AnaType = "dj")
{
  // Define Inputs
  TString outdir="out/"+SrcName+"/compare/"+AnaVersion+CmpVersion;
  cout << "======= Inputs: ========" << endl;
  cout << inFile0Name << endl;
  cout << "Analyze: " << modName << endl;
  TChain * djTree = new TChain(modName+"/djTree","dijet Tree");
  djTree->Add(inFile0Name);
  aliases_dijet(djTree,doMC);

  // === Declare selection ===
  selectionCut anaSel(SrcName,doMC,"S1",NrJEtMin,NrJEtMax,NrJEtMin,2.5);
  anaSel.DJCutType = DJCutType;
  anaSel.TrkCutType = "Ana";
  anaSel.LJExtraCut = jextraCut;
  anaSel.AJExtraCut = anaSel.Nr2Aw(jextraCut);
  anaSel.Tag2+=TString("_"+modName);
  anaSel.SetCut();
  anaSel.Print(1);
  anaSel.PreviewCuts(djTree,2);

  // === Define Output ===
  CPlot::sOutDir = outdir;
  gSystem->mkdir(outdir.Data(),kTRUE);

  // === ana ===
  // frag var
  Int_t numFragVarBins=40;
  AnaFrag anaFragVarNr(fragVarTag,"Nr",djTree,anaSel.FinLJCut(),"",fragVar,"","",numFragVarBins,fragVarMin,fragVarMax);
  AnaFrag anaFragVarAw(fragVarTag,"Aw",djTree,anaSel.FinAJCut(),"",anaSel.Nr2Aw(fragVar),"","",numFragVarBins,fragVarMin,fragVarMax);

  cout << "=== Correlation Analysis ===" << endl;
  // correlations
  AnaFrag anaFragVar_AnaJEt(fragVarTag,"JEt",djTree,numFragVarBins,fragVarMin,fragVarMax);
  anaFragVar_AnaJEt.xtitle = "E_{t}^{Jet}";
  anaFragVar_AnaJEt.ytitle = fragVarTitle;
  anaFragVar_AnaJEt.PlotCorrelations(anaSel,fragVar,"nljet",anaSel.numJEtBins,anaSel.hisJEtMin,anaSel.hisJEtMax);

  AnaFrag anaFragVar_LzJEt(fragVarTag,"LzJEt",djTree,numFragVarBins,fragVarMin,fragVarMax);
  anaFragVar_LzJEt.xtitle = "z^{lead} = p_{T}^{trk}/E_{T}^{Jet}";
  anaFragVar_LzJEt.ytitle = fragVarTitle;
  anaFragVar_LzJEt.PlotCorrelations(anaSel,fragVar,"lppt[0]/nljet",numFragVarBins,0,1.5);

  AnaFrag anaFragVar_JCPtDivJEt(fragVarTag,"JCPtDivJEt",djTree,numFragVarBins,fragVarMin,fragVarMax);
  anaFragVar_JCPtDivJEt.xtitle = "#Sigma_{jet cone} p_{T}^{Trk}/E_{t}^{Jet}";
  anaFragVar_JCPtDivJEt.ytitle = fragVarTitle;
  anaFragVar_JCPtDivJEt.PlotCorrelations(anaSel,fragVar,"(ljcpt[0]-ljcptbg[0])/nljet",numFragVarBins,0,2);

  AnaFrag anaFragVar_JCRAvePtW(fragVarTag,"JCRAvePtW",djTree,numFragVarBins,fragVarMin,fragVarMax);
  anaFragVar_JCRAvePtW.xtitle = "#LT dr(trk,jet) #GT_{p_{T}}";
  anaFragVar_JCRAvePtW.ytitle = fragVarTitle;
  anaFragVar_JCRAvePtW.PlotCorrelations(anaSel,fragVar,"ljcptr[0]/ljcpt[0]",numFragVarBins,0,0.8);

  if (doMC==0) return;

  AnaFrag anaFragVar_RefJEt(fragVarTag,"RefJEt",djTree,numFragVarBins,fragVarMin,fragVarMax);
  anaFragVar_RefJEt.xtitle = "E_{t}^{RefJet}";
  anaFragVar_RefJEt.ytitle = fragVarTitle;
  anaFragVar_RefJEt.PlotCorrelations(anaSel,fragVar,"nlrjet",anaSel.numJEtBins,anaSel.hisJEtMin,anaSel.hisJEtMax);

  AnaFrag anaFragVar_LzRefJEt(fragVarTag,"LzRefJEt",djTree,numFragVarBins,fragVarMin,fragVarMax);
  anaFragVar_LzRefJEt.xtitle = "z^{lead} = p_{T}^{trk}/E_{T}^{RefJet}";
  anaFragVar_LzRefJEt.ytitle = fragVarTitle;
  anaFragVar_LzRefJEt.PlotCorrelations(anaSel,fragVar,"lppt[0]/nlrjet",numFragVarBins,0,1.5);

  AnaFrag anaFragVar_JCPtDivRefJEt(fragVarTag,"JCPtDivRefJEt",djTree,numFragVarBins,fragVarMin,fragVarMax);
  anaFragVar_JCPtDivRefJEt.xtitle = "#Sigma_{jet cone} p_{T}^{Trk}/E_{t}^{RefJet}";
  anaFragVar_JCPtDivRefJEt.ytitle = fragVarTitle;
  anaFragVar_JCPtDivRefJEt.PlotCorrelations(anaSel,fragVar,"(ljcpt[0]-ljcptbg[0])/nlrjet",numFragVarBins,0,2);

  AnaFrag anaFragVar_JResp("JResp",fragVarTag,djTree,numFragVarBins,0,2);
  anaFragVar_JResp.xtitle = fragVarTitle;
  anaFragVar_JResp.ytitle = "E_{T}^{RecoJet}/E_{t}^{RefJet}";
  anaFragVar_JResp.PlotCorrelations(anaSel,"nljet/nlrjet",fragVar,numFragVarBins,fragVarMin,fragVarMax);

  // -- plot frag var--
  TCanvas * cFragVar = new TCanvas("c"+fragVarTag,"c"+fragVarTag,1000,500);
  cFragVar->Divide(2,1);
  CPlot cpFragVar(fragVarTag+anaSel.Tag2,fragVarTag,fragVarTitle,"unit normalization");
  cpFragVar.SetLogy();
  cpFragVar.AddHist1D(anaFragVarNr.hRaw,"Leading Jet","E",kRed,kOpenCircle);
  cpFragVar.AddHist1D(anaFragVarAw.hRaw,"Away Jet","E",kBlue,kOpenSquare);
  cFragVar->cd(1); cpFragVar.Draw((TPad*)cFragVar->GetPad(1),false);
  CPlot cpJRespFragVar(fragVarTag+"_JResp"+anaSel.Tag2,fragVarTag,fragVarTitle,"unit normalization");
  cpJRespFragVar.AddHist1D(anaFragVar_JResp.hCorrelProfNr,"Leading Jet","E",kRed,kOpenCircle);
  cpJRespFragVar.AddHist1D(anaFragVar_JResp.hCorrelProfAw,"Away Jet","E",kBlue,kOpenSquare);
  cFragVar->cd(2); cpJRespFragVar.Draw((TPad*)cFragVar->GetPad(2),false);
  cFragVar->Print(CPlot::sOutDir+"/"+fragVarTag+anaSel.Tag2+".gif");
}
コード例 #14
0
ファイル: ExclusionPlot.C プロジェクト: wa01/usercode
void CommandMSUGRA(TString plotName,Int_t tanBeta_, Bool_t plotLO_, Bool_t tb40_plotExpected) {
  
  gStyle->SetOptTitle(0);
  gStyle->SetOptStat(0);
  gStyle->SetPalette(1); 
  gStyle->SetTextFont(42);
  gStyle->SetFrameBorderMode(0);

  //convert tanb value to string
  std::stringstream tmp;
  tmp << tanBeta_;
  TString tanb( tmp.str() );
  
  
  // Output file
  std::cout << " create " << plotName << std::endl;
  TFile* output = new TFile( plotName, "RECREATE" );
  if ( !output || output->IsZombie() ) { std::cout << " zombie alarm output is a zombie " << std::endl; }
  

  //set old exclusion Limits
  TGraph* LEP_ch = set_lep_ch(tanBeta_);
  TGraph* LEP_sl = set_lep_sl(tanBeta_);//slepton curve
  TGraph* TEV_sg_cdf = set_tev_sg_cdf(tanBeta_);//squark gluino cdf
  TGraph* TEV_sg_d0 = set_tev_sg_d0(tanBeta_);//squark gluino d0
  //  TGraph* TEV_tlp_cdf = set_tev_tlp_cdf(tanBeta_);//trilepton cdf
  //  TGraph* TEV_tlp_d0 = set_tev_tlp_d0(tanBeta_);//trilepton d0
  TGraph* stau   = set_tev_stau(tanBeta_);//stau 
  TGraph* NoEWSB = set_NoEWSB(tanBeta_); 

  TGraph* TEV_sn_d0_1 = set_sneutrino_d0_1(tanBeta_);
  TGraph* TEV_sn_d0_2 = set_sneutrino_d0_2(tanBeta_);

  //some tan beta 40 stuff (load the squark and gluino mass lines)
  TGraph2D* squarkMasses=0;
  TGraph2D* gluinoMasses=0;
  if (tanBeta_==40) {
    const int nPoints = nSusyGridPoints();
    double m0[nPoints],m12[nPoints],squarkMass[nPoints],gluinoMass[nPoints];
    
    susyGrid(m0,m12,squarkMass,gluinoMass);
    
    squarkMasses = new TGraph2D("squarkMasses","",nPoints,m0,m12,squarkMass);
    gluinoMasses = new TGraph2D("gluinoMasses","",nPoints,m0,m12,gluinoMass);
    
    gluinoMasses->GetHistogram();
    squarkMasses->GetHistogram();
  }
  // end of tan beta 40 stuff

  //constant squark and gluino lines
  TF1* lnsq[10];
  TF1* lngl[10];
  TLatex* sq_text[10];
  TLatex* gl_text[10];

  //versions for tan beta 40
  TGraph* lnsq_40[15];
  TGraph* lngl_40[15];
  TLatex* sq_40_text[15];
  TLatex* gl_40_text[15];

  int loopmax = 6;
  if (tanBeta_==40) loopmax=15;
  for(int i = 0; i < loopmax; i++){
    if (tanBeta_==10) {
      lnsq[i] = constant_squark(tanBeta_,i);
      sq_text[i] = constant_squark_text(i,*lnsq[i],tanBeta_);
      lngl[i] = constant_gluino(tanBeta_,i);
      gl_text[i] = constant_gluino_text(i,*lngl[i]);
    }
    else if (tanBeta_==40) {
      lnsq_40[i] = constant_mass(i*250,squarkMasses);
      lngl_40[i] = constant_mass(i*250,gluinoMasses);
      sq_40_text[i] = constant_squark_text_tanBeta40(i*250,lnsq_40[i]);
      gl_40_text[i] = constant_gluino_text_tanBeta40(i*250,lngl_40[i]);;
    }
  }
  

  //Legends
  TLegend* legst  = makeStauLegend(0.05,tanBeta_);
//   TLegend* legNoEWSB  = makeNoEWSBLegend(0.05,tanBeta_);
  TLegend* legexp = makeExpLegend( *TEV_sg_cdf,*TEV_sg_d0,*LEP_ch,*LEP_sl,*TEV_sn_d0_1,0.035,tanBeta_);
  
 
  //make Canvas
  TCanvas* cvsSys = new TCanvas("cvsnm","cvsnm",0,0,800,600);
  gStyle->SetOptTitle(0);
  cvsSys->SetFillColor(0);
  cvsSys->GetPad(0)->SetRightMargin(0.07);
  cvsSys->Range(-120.5298,26.16437,736.0927,750);
  //  cvsSys->Range(-50.5298,26.16437,736.0927,500);
  cvsSys->SetFillColor(0);
  cvsSys->SetBorderMode(0);
  cvsSys->GetPad(0)->SetBorderMode(0);
  cvsSys->GetPad(0)->SetBorderSize(2);
  cvsSys->GetPad(0)->SetLeftMargin(0.1407035);
  cvsSys->GetPad(0)->SetTopMargin(0.08);
  cvsSys->GetPad(0)->SetBottomMargin(0.13);

  cvsSys->SetTitle("tan#beta="+tanb);
 
  output->cd();
  
  TDirectory* curDir = gDirectory;
//   TFile* f = new TFile("limits_binc_ht1000_met350-contours.root");
//   TFile* f = new TFile("limits_msugraNLO_multibtag_ht1000_met250_m12_0-550_HN_comb-contours.root");
  TFile* f = ContourFile;
  TGraph* ra4VieObs = (TGraph*)f->Get("gObs");
  TGraph* ra4VieExpM2 = (TGraph*)f->Get("gExpMinus2");
  TGraph* ra4VieExpM1 = (TGraph*)f->Get("gExpMinus1");
  TGraph* ra4VieExp = (TGraph*)f->Get("gExpMedian");
  TGraph* ra4VieExpP1 = (TGraph*)f->Get("gExpPlus1");
  TGraph* ra4VieExpP2 = (TGraph*)f->Get("gExpPlus2");
  TGraph* ra4VieExpArea(0);

  TGraph* ra4VieObsThM(0);
  TGraph* ra4VieExpThM(0);
  if ( ContourFileM ) {
    ra4VieObsThM = (TGraph*)ContourFileM->Get("gObs");
    ra4VieExpThM = (TGraph*)ContourFileM->Get("gExpMedian");
  }
  TGraph* ra4VieObsThP(0);
  TGraph* ra4VieExpThP(0);
  if ( ContourFileP ) {
    ra4VieObsThP = (TGraph*)ContourFileP->Get("gObs");
    ra4VieExpThP = (TGraph*)ContourFileP->Get("gExpMedian");
  }

  curDir->cd();


  double m0min = 0;
  double m0max=1600;
//   double m0max=1800;
  double xscale = m0max-m0min;
  if (tanBeta_ == 50) m0min=200;
  if (tanBeta_ == 40) {m0min=400;  m0max=2000;}
  xscale = (m0max-m0min)/xscale;
  TH2D* hist = new TH2D("h","h",100,m0min,m0max,100,120,700);
  hist->Draw();  
  hist->GetXaxis()->SetTitle("m_{0} (GeV/c^{2})");
  hist->GetYaxis()->SetTitle("m_{1/2} (GeV/c^{2})");
  hist->GetXaxis()->SetTitleOffset(.9);
  hist->GetXaxis()->SetTitleSize(0.06);
  hist->GetYaxis()->SetTitleOffset(1.0);
  hist->GetYaxis()->SetTitleSize(0.06);

  hist->GetXaxis()->SetNdivisions(506);
  //  if (tanBeta_ == 50)  hist->GetXaxis()->SetNdivisions(504);
  hist->GetYaxis()->SetNdivisions(506);

  int col[]={2,3,4};

  TSpline3 *sRA4_LP =0;
  TSpline3 *sRA1 = 0;
  TSpline3 *sRA2 = 0;
  TSpline3 *sRA4_old =0;
  TSpline3 *sRAZ =0;

  if (tanBeta_==10) {
    ra4VieObs->SetLineWidth(3);
    ra4VieObs->SetLineColor(2);
    ra4VieExp->SetLineWidth(3);
//     ra4VieExp->SetLineStyle(2);
    ra4VieExp->SetLineColor(4);
//     ra4VieObs->RemovePoint(0);
//     ra4VieObs->RemovePoint(0);
//     double x,y;
//     ra4VieObs->GetPoint(36,x,y);
//     std::cout << x << " " << y << std::endl;
//     ra4VieObs->RemovePoint(37);
//     ra4VieObs->RemovePoint(37);
//     ra4VieObs->RemovePoint(37);
    if ( ra4VieExpM1 && ra4VieExpP1 ) {
      ra4VieExpArea = new TGraph();
      int np(0);
      double* xExp = ra4VieExpM1->GetX();
      double* yExp = ra4VieExpM1->GetY();
      for ( int i=0; i<ra4VieExpM1->GetN(); ++i ) 
	ra4VieExpArea->SetPoint(np++,xExp[i],yExp[i]);
      xExp = ra4VieExpP1->GetX();
      yExp = ra4VieExpP1->GetY();
      for ( int i=ra4VieExpP1->GetN()-1; i>=0; --i ) 
	ra4VieExpArea->SetPoint(np++,xExp[i],yExp[i]);
      ra4VieExpArea->SetLineColor(7);
      ra4VieExpArea->SetFillColor(7);
      ra4VieExpArea->Draw("F");
      ra4VieExpM1->SetLineWidth(1);
      ra4VieExpM1->SetLineStyle(3);
      ra4VieExpM1->SetLineColor(4);
      ra4VieExpP1->SetLineWidth(1);
      ra4VieExpP1->SetLineStyle(3);
      ra4VieExpP1->SetLineColor(4);
      ra4VieExpM1->Draw();
      ra4VieExpP1->Draw();
    }
    if ( ra4VieObsThM && ra4VieObsThP ) {
      ra4VieObsThM->SetLineWidth(2);
      ra4VieObsThM->SetLineColor(2);
      ra4VieObsThM->SetLineStyle(2);
      ra4VieObsThM->Draw();
      ra4VieObsThP->SetLineWidth(2);
      ra4VieObsThP->SetLineColor(2);
      ra4VieObsThP->SetLineStyle(2);
      ra4VieObsThP->Draw();
      
      ra4VieExpThM->SetLineWidth(2);
      ra4VieExpThM->SetLineColor(4);
      ra4VieExpThM->SetLineStyle(2);
      ra4VieExpThM->Draw();
      ra4VieExpThP->SetLineWidth(2);
      ra4VieExpThP->SetLineColor(4);
      ra4VieExpThP->SetLineStyle(2);
      ra4VieExpThP->Draw();
      
    }
    ra4VieExp->Draw();
    ra4VieObs->Draw();
//     if ( ra4VieExpM2 && ra4VieExpP2 ) {
//       ra4VieExpM2->SetLineWidth(2);
//       ra4VieExpM2->SetLineStyle(3);
//       ra4VieExpM2->SetLineColor(4);
//       ra4VieExpP2->SetLineWidth(2);
//       ra4VieExpP2->SetLineStyle(3);
//       ra4VieExpP2->SetLineColor(4);
//       ra4VieExpM2->Draw();
//       ra4VieExpP2->Draw();
//     }
  }
  else if (tanBeta_==40 ) {

  }
  
  TLegend* myleg;

  float leg_x1=0.39+0.23;
  float leg_y1=0.65+0.05;
  float leg_x2= 0.55+0.25;
  float leg_y2= 0.84+0.05;

  if( plotLO_ ) {
    if ( ContourFileM && ContourFileP )
      myleg = new TLegend(0.3,0.55,0.6,0.7,NULL,"brNDC");
//       myleg = new TLegend(0.3,0.55,0.6,0.8,NULL,"brNDC");
    else
      myleg = new TLegend(0.3,0.65,0.6,0.7,NULL,"brNDC");
  }
  else if (tb40_plotExpected) myleg = new TLegend(0.25,0.76,0.44,0.91,NULL,"brNDC"); // copied from else block below
  else if (tanBeta_==40) myleg = new TLegend(leg_x1,leg_y1,leg_x2,leg_y2,NULL,"brNDC");
  else          myleg = new TLegend(0.25,0.76,0.44,0.91,NULL,"brNDC");


  myleg->SetFillColor(0); 
  myleg->SetShadowColor(0);
  myleg->SetTextSize(0.03);
  myleg->SetBorderSize(0);

  TLegendEntry *entry=0;

  if (tanBeta_ == 10 ) {
//     myleg->SetHeader("RA4Tmpl, (NLO, exp. unc.)");
    myleg->SetHeader("95% CL exclusion limits");
    myleg->AddEntry(ra4VieObs,"observed","l");
    myleg->AddEntry(ra4VieExp,"median expected","l");
    if ( ra4VieExpM1 && ra4VieExpP1 ) {
//       myleg->AddEntry(ra4VieExpP1,"exp #pm 1#sigma","l");
      myleg->AddEntry(ra4VieExpArea,"expected #pm 1#sigma exp.","f");
    }
    if ( ra4VieObsThM && ra4VieObsThP ) {
      myleg->AddEntry(ra4VieObsThM,"observed / sig.cont.","l");
      myleg->AddEntry(ra4VieExpThM,"expected / sig.cont.","l");
//       myleg->AddEntry(ra4VieObsThM,"observed #pm 1#sigma theor.","l");
//       myleg->AddEntry(ra4VieExpThM,"expected #pm 1#sigma theor.","l");
    }
    //     entry=myleg->AddEntry("RA1","2011 Limits","l");
    //     entry->SetLineColor(1);
    //     entry->SetLineStyle(1);
    //     entry->SetLineWidth(3);
    
    //     entry=myleg->AddEntry("sRA1","2010 Limits","l");
    //     entry->SetLineColor(1);
    //     entry->SetLineStyle(2);
    //     entry->SetLineWidth(3);
  }
  else if (tanBeta_==40) {

    //     entry=myleg->AddEntry("obs","Observed Limit","l");
    //     entry->SetLineColor(1);
    //     entry->SetLineStyle(1);
    //     entry->SetLineWidth(3);
    //     entry->SetTextColor(1);

    //     entry=myleg->AddEntry("exp","Expected Limit #pm 1#sigma","lf");
    //     entry->SetFillColor(kGray);
    //     entry->SetTextColor(1);
    //     entry->SetLineColor(1);
    //     entry->SetLineStyle(7);
    //     entry->SetLineWidth(3);
    //     entry->SetFillStyle(3002);


  }
  
  //constant squark and gluino mass contours
  if (tanBeta_==10) {
    for (int it=0;it<5;it++) {   
      lngl[it]->Draw("same");   
      lnsq[it]->Draw("same");
      sq_text[it]->Draw();
      gl_text[it]->Draw();
    }
  }
  else if (tanBeta_==40) {
    for (int it=2;it<9;it++) {  
      if(it<7){
	if(lngl_40[it]!=0)lngl_40[it]->Draw("samec");   
	if(gl_40_text[it]!=0)gl_40_text[it]->Draw();
      }
      if(lnsq_40[it]!=0)lnsq_40[it]->Draw("samec");
      if(it<6){
	if(sq_40_text[it]!=0)sq_40_text[it]->Draw();
      }
    }
  }

  if (tanBeta_==10) {
    //     SSdilep->Draw("samec");
    //     OSdilep->Draw("samec");
    //     Multilep->Draw("samec");
    //     RA1->Draw("samec");
    //     RA2->Draw("samec");
    //     MT2->Draw("samec");
    //     sRA4_LP->Draw("samec");
    // 	RAZ->Draw("samec");
    
    //     sRA1->Draw("same"); 
    //     sRA2->Draw("same"); 
    //     sRA4_old->Draw("samec");
    // 	sRAZ->Draw("samec");
    //     RA5_old->Draw("c same");
    //     RA6_old->Draw("c same");
  }
  else if (tanBeta_==40) {

    //     //expected curves and errors bands
    //     if ( tb40_plotExpected) {
    //       //not drawing the expected curves for better legibility
    // //       RA1_tb40_exp_p->Draw("samel");
    // //       RA1_tb40_exp_m->Draw("samel");
    // //       RA2b_1b_tight_exp_p->Draw("samel");
    // //       RA2b_1b_tight_exp_m->Draw("samel");
    // //keep the expected +/-1 sigma band
    //       RA1_tb40_exp_band->Draw("f") ;
    //       RA2b_1b_tight_exp_band->Draw("f") ;

    //       //important to draw lines after fill
    //       RA1_tb40_exp->Draw("samel");
    //       RA2b_1b_tight_exp->Draw("samel") ;

  }

  //     RA2b_1b_tight->Draw("samel");
  //     RA1_tb40->Draw("samel");

  // }
  
  TLegend* leg2=0;
  if (tanBeta_==10) {
    //     TLatex* RA1label = new TLatex(670,370.,"#alpha_{T}");
    //     RA1label->SetTextFont(42);
    //     RA1label->SetTextSize(0.05);
    //     RA1label->SetTextColor(kRed+2);
    //     RA1label->Draw("same");
    
    //     TLatex* RA2label = new TLatex(640,465.,"Jets+MHT");
    //     RA2label->SetTextFont(42);
    //     RA2label->SetTextSize(0.04);
    //     RA2label->SetTextColor(kBlue+2);
    //     RA2label->Draw("same");
	  
    //     TLatex* RAZlabel = new TLatex(740,415.,"Razor (0.8 fb^{-1})");
    //     RAZlabel->SetTextFont(42);
    //     RAZlabel->SetTextSize(0.04);
    //     RAZlabel->SetTextColor(kMagenta+1);
    //     RAZlabel->Draw("same");
    
    //     TLatex* RA5label = new TLatex(300,350.,"SS Dilepton");
    //     RA5label->SetTextFont(42);
    //     //RA5label->SetTextAngle(-10);
    //     RA5label->SetTextSize(0.04);
    //     RA5label->SetTextColor(kGreen+2);
    //     RA5label->Draw("same");
    
    //     //TLatex* RA6label = new TLatex(400,280.,"OS Dilepton");
    //     TLatex* RA6label = new TLatex(355,285.,"OS Dilepton");
    //     RA6label->SetTextFont(42);
    //     //RA6label->SetTextAngle(-15);
    //     RA6label->SetTextSize(0.04);
    //     RA6label->SetTextColor(kCyan+2);
    //     RA6label->Draw("same");

    //     TLatex* RA7label = new TLatex(338,215.,"Multi-Lepton");
    //     RA7label->SetTextFont(42);
    //     RA7label->SetTextSize(0.04);
    //     RA7label->SetTextColor(kYellow+2);
    //     RA7label->Draw("same");
    //     TLatex* RA7lumi = new TLatex(450,185.,"(2.1 fb^{-1})");
    //     RA7lumi->SetTextFont(42);
    //     RA7lumi->SetTextSize(0.04);
    //     RA7lumi->SetTextColor(kYellow+2);
    //     RA7lumi->Draw("same");

    
    //     TLatex* MT2label = new TLatex(400,440.,"MT2");
    //     MT2label->SetTextFont(42);
    //     MT2label->SetTextSize(0.04);
    //     MT2label->SetTextColor(kRed);
    //     MT2label->Draw("same");
    
    //     TLatex* RA4label = new TLatex(250,400.,"1 Lepton");
    //     RA4label->SetTextFont(42);
    //     RA4label->SetTextSize(0.04);
    //     RA4label->SetTextColor(kBlue);
    //     RA4label->Draw("same");
  }
  else if (tanBeta_==40  && !tb40_plotExpected) {
    //     int xposRA1 = 480;
    //     int yposRA1 = 510;

    //     int xposRA2b=450;
    //     int yposRA2b=275;

    //     TLatex* RA1label = new TLatex(xposRA1,yposRA1,"#alpha_{T}");
    //     RA1label->SetTextFont(42);
    //     RA1label->SetTextSize(0.05);
    //     RA1label->SetTextColor(kRed+2);
    //     RA1label->Draw("same");

    //     TLatex* RA2blabel = new TLatex(xposRA2b,yposRA2b,"Jets+MET+b");
    //     RA2blabel->SetTextFont(42);
    //     RA2blabel->SetTextSize(0.05);
    //     RA2blabel->SetTextColor(kBlue+1);
    //     RA2blabel->Draw("same");
    //   }
    //   else if (tanBeta_==40 && tb40_plotExpected) {

    //     leg2 = new TLegend(0.63,0.76,0.94,0.91,NULL,"brNDC");
    //     leg2->SetFillColor(0); 
    //     leg2->SetShadowColor(0);
    //     leg2->SetTextSize(0.04);
    //     leg2->SetBorderSize(0);
    
    //     entry=leg2->AddEntry("RA1_tb40","#alpha_{T}","l");
    //     entry->SetLineColor(kRed+2);
    //     entry->SetLineStyle(1);
    //     entry->SetLineWidth(3);
    //     entry->SetTextColor(kRed+2);

    //     entry=leg2->AddEntry("RA2b_1btight","Jets+MET+b","l");
    //     entry->SetLineColor(kBlue+1);
    //     entry->SetLineStyle(1);
    //     entry->SetLineWidth(3);
    //     entry->SetTextColor(kBlue+1);

  }

  //exclusion limits previous experiments
  if(tanBeta_ == 3){
    TEV_sn_d0_1->Draw("fsame");
    TEV_sn_d0_2->Draw("fsame");
  }
  if (tanBeta_==10)   LEP_ch->Draw("fsame");
  if (tanBeta_ != 50 && tanBeta_!=40) LEP_sl->Draw("fsame");

//   //remove CDF/D0 excluded regions
//   if (tanBeta_==10) {
//     TEV_sg_cdf->Draw("fsame");
//     TEV_sg_d0->Draw("same");  
//     TEV_sg_d0->Draw("fsame");
//   }

  //other labels
  Double_t xpos = 0;
  Double_t xposi = 0;
  Double_t ypos = 0;
  if(tanBeta_ == 50) xposi = 100;
  if(tanBeta_ == 50) xpos = 200;
  if(tanBeta_ == 50) ypos = -10;

  if(tanBeta_ == 40) xposi = 180+160;
  if(tanBeta_ == 40) xpos = 400;//240;
  if(tanBeta_ == 40) ypos = 100;

 
  //TLatex* lumilabel = new TLatex(750 +xposi + 100,767.-154,"#sqrt{s} = 7 TeV, #scale[0.65]{#int}Ldt = 0.98 fb^{-1}");
  TLatex* lumilabel = new TLatex(450*xscale+xpos,767.-154+100,"#sqrt{s} = 7 TeV,   Ldt 4.98 fb^{ -1}");
  TLatex* integral_symbol = new TLatex((577+100)*xscale+xpos,767.-145+100,"#int");

  lumilabel->SetTextSize(0.03);
  integral_symbol->SetTextSize(0.015);
  lumilabel->Draw("same");
  integral_symbol->Draw("same");

  TLatex* cmslabel = new TLatex(10.+xpos,767.-154+100,"CMS Preliminary");
  cmslabel->SetTextSize(0.03);
  cmslabel->Draw("same");

  TString text_tanBeta;
  TString a0str="0";
  if (tanBeta_==40) a0str = "-500 GeV";
  text_tanBeta =  "tan#beta = "+tanb+",  A_{0} = "+a0str+",  #mu > 0";
  int anotherOffset = (tb40_plotExpected && tanBeta_==40) ? -100 : 0;
//   TLatex* cmssmpars = new TLatex(/*530.+xpos,690.+ypos-130*/120+xpos,555+ypos+anotherOffset,text_tanBeta);
//   TLatex* cmssmpars = new TLatex(0.61,0.60,text_tanBeta);
  TLatex* cmssmpars = new TLatex(0.61,0.70,text_tanBeta);
  cmssmpars->SetNDC(1);

  cmssmpars->SetTextSize(0.04);
  cmssmpars->Draw("same");

  TLatex* lep_chargino = new TLatex(250,135,"LEP2 #tilde{#chi}_{1}^{#pm}");
  lep_chargino->SetTextSize(0.03);
  lep_chargino->SetTextFont(42);
  //  lep_chargino->Draw("same");

  TLatex* lep_slepton = new TLatex(26,190,"LEP2 #tilde{#font[12]{l}}^{#pm}");
  lep_slepton->SetTextSize(0.03);
  lep_slepton->SetTextAngle(-83);
  lep_slepton->SetTextFont(42);
  //  lep_slepton->Draw("same");



  //LM points
  TMarker* LM0 = new TMarker(200.,160.,20);
  TMarker* LM1 = new TMarker(60.,250.,20);
  TMarker* LM3 = new TMarker(330.,240.,20);
  TMarker* LM6 = new TMarker(80.,400.,20);
    
  LM0->SetMarkerSize(1.2);
  LM1->SetMarkerSize(1.2);
    
  TLatex* tLM0 = new TLatex(205.,160.," LM0");
  tLM0->SetTextSize(0.035);
    
  TLatex* tLM1 = new TLatex(80.,245.,"LM1");
  tLM1->SetTextSize(0.035);
  
  //TLatex* tLM3 = new TLatex(350.,235.,"LM3 (tan#beta=20)");
  TLatex* tLM3 = new TLatex(350.,235.,"LM3");
  tLM3->SetTextSize(0.035);
  
  TLatex* tLM6 = new TLatex(100.,395.,"LM6");
  tLM6->SetTextSize(0.035);
  
  //  if (tanBeta_ != 50){
  //  LM0->Draw("same");   
  //  tLM0->Draw("same");
  //  LM1->Draw("same");   
  //  tLM1->Draw("same");
  // }

  /*
    if (tanBeta_ == 10){ 
    LM1->Draw("same");
    tLM1->Draw("same");
    LM3->Draw("same");
    tLM3->Draw("same");
    LM6->Draw("same");
    tLM6->Draw("same");
    }
  */



  //stau=LSP contour
  if (tanBeta_==10) {
    stau->Draw("fsame");
//     NoEWSB->Draw("fsame");
    
    //legends
    legexp->Draw();
    legst->Draw();
    //legNoEWSB->Draw();
  }
  if (tanBeta_!=40 || tb40_plotExpected)  myleg->Draw();
  if (tanBeta_==40 && tb40_plotExpected) leg2->Draw();

  hist->Draw("sameaxis");
  cvsSys->RedrawAxis();
  cvsSys->Update();
  cvsSys->Write();
  
  if( plotLO_ ){
    cvsSys->SaveAs("ExclusionLimit_tanb"+tanb+"_LO.pdf");
    cvsSys->SaveAs("ExclusionLimit_tanb"+tanb+"_LO.png");
  }else{
    cvsSys->SaveAs("ExclusionLimit_tanb"+tanb+".eps");
    cvsSys->SaveAs("ExclusionLimit_tanb"+tanb+".ps");
    cvsSys->SaveAs("ExclusionLimit_tanb"+tanb+".pdf");
    cvsSys->SaveAs("ExclusionLimit_tanb"+tanb+".png");
  }
  
  output->Write();

  //output->Close();
  //delete output; 

}
コード例 #15
0
ファイル: checkTrkInputs.C プロジェクト: CmsHI/CVS_SavedFMa
void checkTrkInputs(
    TString infrec="nt_djhp_HyUQ110v0_djcalo.root",
    TString infgen="nt_djhp_HyUQ110v0_djcalo_genp.root",
    TCut evtCut="cent<30")
{
  //TH1::SetDefaultSumw2();
  TChain * trec = new TChain("tjttrk");
  trec->Add(infrec);
  setupAlias(trec);
  TChain * tgen = new TChain("tjttrk");
  tgen->Add(infgen);
  cout << infrec << " cut " << TString(evtCut) << ": " << trec->GetEntries() << endl;
  cout << infgen << " cut " << TString(evtCut) << ": " << tgen->GetEntries() << endl;
   
  // Correction Histograms
  TFile * fTrkCorr = new TFile("djtrkhist_hydjetBassv2_djuq110.root");
  TString corrModule = "hitrkEffAnalyzer";
  TH2F * hrec = (TH2F*)fTrkCorr->Get(Form("%s/hrec",corrModule.Data()));
  TH1D * hrec_pt = (TH1D*)hrec->ProjectionY();
  TH2F * hsim = (TH2F*)fTrkCorr->Get(Form("%s/hsim",corrModule.Data()));
  TH1D * hsim_pt = (TH1D*)hsim->ProjectionY();
  
  // Frag Histograms
  //TH1D * hPPtRecRaw = new TH1D("hPPtRecRaw",";p_{T} (GeV/c); count;");
  TH1D * hPPtRecRaw = (TH1D*)hrec_pt->Clone("hPPtRecRaw");
  hPPtRecRaw->Reset();
  TH1D * hPPtGen = (TH1D*)hrec_pt->Clone("hPPtGen");
  hPPtGen->Reset();
  trec->Project("hPPtRecRaw","ppt","");
  tgen->Project("hPPtGen","ppt","");
  TH1D * hRecSimRat_pt = (TH1D*)hrec_pt->Clone("hRecSimRat_pt");
  hRecSimRat_pt->Sumw2();
  hRecSimRat_pt->Divide(hrec_pt,hsim_pt);
  TH1D * hPPtRat = (TH1D*)hrec_pt->Clone("hPPtRat");
  hPPtRat->Sumw2();
  hPPtRat->Divide(hPPtRecRaw,hPPtGen);

  // Normalize
  normHist(hsim_pt,0,true,1);
  normHist(hrec_pt,0,true,1);
  normHist(hPPtGen,0,true,1);
  normHist(hPPtRecRaw,0,true,1);

  // Plot
  hsim_pt->SetAxisRange(0,100,"X");
  hsim_pt->SetTitle(";p_{T} (GeV/c); count");
  hRecSimRat_pt->SetTitle(";p_{T} (GeV/c); reco/gen ratio");
  hsim_pt->SetLineColor(kRed);
  hPPtGen->SetMarkerColor(kRed);
  hPPtGen->SetLineColor(kRed);
  hRecSimRat_pt->SetAxisRange(0,100,"X");
  hRecSimRat_pt->SetAxisRange(-0.2,1.2,"Y");
  hRecSimRat_pt->SetLineColor(kRed);
  TCanvas *cRec = new TCanvas("cRec","Rec",500,900);
  cRec->Divide(1,2);
  cRec->cd(1);
  cRec->GetPad(1)->SetLogy();
  hsim_pt->Draw("hist");
  hPPtGen->Draw("sameE");
  hrec_pt->Draw("hist same");
  hPPtRecRaw->Draw("sameE");
  cRec->cd(2);
  hRecSimRat_pt->Draw("hist");
  hPPtRat->Draw("sameE");

  // ====================
  TLegend *leg = new TLegend(0.61,0.78,0.91,0.91);
  leg->SetFillStyle(0);
  leg->SetBorderSize(0);
  leg->SetTextSize(0.035);
}
コード例 #16
0
ファイル: MovieMaker.C プロジェクト: CMSAachen3B/RWTH3b
void DrawMLPoutputMovie( TFile* file, const TString& methodType, const TString& methodTitle )
{
   gROOT->SetBatch( 1 );

   // define Canvas layout here!
   const Int_t width = 600;   // size of canvas

   // this defines how many canvases we need
   TCanvas* c = 0;

   Float_t nrms = 4;
   Float_t xmin = -1.2;
   Float_t xmax = 1.2;
   Float_t ymin = 0;
   Float_t ymax = 0;
   Float_t maxMult = 6.0;
   Int_t   countCanvas = 0;
   Bool_t  first = kTRUE;
            
   TString     dirname  = methodType + "/" + methodTitle + "/" + "EpochMonitoring";
   TDirectory *epochDir = (TDirectory*)file->Get( dirname );
   if (!epochDir) {
      cout << "Big troubles: could not find directory \"" << dirname << "\"" << endl;
      exit(1);
   }

   // now read all evolution histograms
   TIter keyItTit(epochDir->GetListOfKeys());
   TKey *titkeyTit;
   while ((titkeyTit = (TKey*)keyItTit())) {
      
      if (!gROOT->GetClass(titkeyTit->GetClassName())->InheritsFrom("TH1F")) continue;
      TString name = titkeyTit->GetName();
      
      if (!name.BeginsWith("convergencetest___")) continue;
      if (!name.Contains("_train_"))              continue; // only for training so far
      if (name.EndsWith( "_B"))                   continue;
      
      // must be signal histogram
      if (!name.EndsWith( "_S")) {
         cout << "Big troubles with histogram: " << name << " -> should end with _S" << endl;
         exit(1);
      }
      
      // create canvas
      countCanvas++;
      TString ctitle = Form("TMVA response %s",methodTitle.Data());
      c = new TCanvas( Form("canvas%d", countCanvas), ctitle, 0, 0, width, (Int_t)width*0.78 ); 
      
      TH1F* sig = (TH1F*)titkeyTit->ReadObj();
      sig->SetTitle( Form("TMVA response for classifier: %s", methodTitle.Data()) );
      
      TString dataType = (name.Contains("_train_") ? "(training sample)" : "(test sample)");
      
      // find background
      TString nbn = sig->GetName(); nbn[nbn.Length()-1] = 'B';            
      TH1F* bgd = dynamic_cast<TH1F*>(epochDir->Get( nbn ));
      if (bgd == 0) {
         cout << "Big troubles with histogram: " << bgd << " -> cannot find!" << endl;
         exit(1);
      }
      
      cout << "sig = " << sig->GetName() << endl;
      cout << "bgd = " << bgd->GetName() << endl;
      
      // set the histogram style
      TMVAGlob::SetSignalAndBackgroundStyle( sig, bgd );
      
      // normalise both signal and background
      TMVAGlob::NormalizeHists( sig, bgd );
      
      // set only first time, then same for all plots
      if (first) {
         if (xmin == 0 && xmax == 0) {
            xmin = TMath::Max( TMath::Min(sig->GetMean() - nrms*sig->GetRMS(), 
                                          bgd->GetMean() - nrms*bgd->GetRMS() ),
                               sig->GetXaxis()->GetXmin() );
            xmax = TMath::Min( TMath::Max(sig->GetMean() + nrms*sig->GetRMS(), 
                                          bgd->GetMean() + nrms*bgd->GetRMS() ),
                               sig->GetXaxis()->GetXmax() );
         }
         ymin = 0;
         ymax = TMath::Max( sig->GetMaximum(), bgd->GetMaximum() )*maxMult;
         first = kFALSE;
      }
      
      // build a frame
      Int_t nb = 100;
      TString hFrameName(TString("frame") + methodTitle);
      TObject *o = gROOT->FindObject(hFrameName);
      if(o) delete o;
      TH2F* frame = new TH2F( hFrameName, sig->GetTitle(), 
                              nb, xmin, xmax, nb, ymin, ymax );
      frame->GetXaxis()->SetTitle( methodTitle + " response" );
      frame->GetYaxis()->SetTitle("(1/N) dN^{ }/^{ }dx");
      TMVAGlob::SetFrameStyle( frame );
      
      // find epoch number (4th token)
      TObjArray* tokens = name.Tokenize("_");
      TString es = ((TObjString*)tokens->At(4))->GetString();
      if (!es.IsFloat()) {
         cout << "Big troubles in epoch parsing: \"" << es << "\" is not float" << endl;
         exit(1);
      }
      Int_t epoch = es.Atoi();
      
      // eventually: draw the frame
      frame->Draw();  
      
      c->GetPad(0)->SetLeftMargin( 0.105 );
      frame->GetYaxis()->SetTitleOffset( 1.2 );
      
      // Draw legend               
      TLegend *legend= new TLegend( c->GetLeftMargin(), 1 - c->GetTopMargin() - 0.12, 
                                    c->GetLeftMargin() + 0.5, 1 - c->GetTopMargin() );
      legend->SetFillStyle( 1 );
      legend->AddEntry(sig,TString("Signal ")     + dataType, "F");
      legend->AddEntry(bgd,TString("Background ") + dataType, "F");
      legend->SetBorderSize(1);
      legend->SetMargin( 0.15 );
      legend->Draw("same");
      
      TText* t = new TText();            
      t->SetTextSize( 0.04 );
      t->SetTextColor( 1 );
      t->SetTextAlign( 31 );
      t->DrawTextNDC( 1 - c->GetRightMargin(), 1 - c->GetTopMargin() + 0.015, Form( "Epoch: %i", epoch) );
      
      // overlay signal and background histograms
      sig->Draw("samehist");
      bgd->Draw("samehist");
      
      // save to file
      TString dirname  = "movieplots";
      TString foutname = dirname + "/" + name;
      foutname.Resize( foutname.Length()-2 );
      foutname.ReplaceAll("convergencetest___","");
      foutname += ".gif";
      
      cout << "storing file: " << foutname << endl;
      
      c->Update();
      c->Print(foutname);            
   }
}
コード例 #17
0
ファイル: ExclusionPlot.C プロジェクト: hooberman/UserCode
void CommandMSUGRA(TString plotName_,Int_t tanBeta_, Bool_t plotLO_){
  
  gStyle->SetOptTitle(0);
  gStyle->SetOptStat(0);
  gStyle->SetPalette(1); 
  gStyle->SetTextFont(42);
  
  //convert tanb value to string
  std::stringstream tmp;
  tmp << tanBeta_;
  TString tanb( tmp.str() );
  
  // Output file
  cout << " create " << plotName_ << endl;
  TFile* output = new TFile( plotName_, "RECREATE" );
  if ( !output || output->IsZombie() ) { std::cout << " zombie alarm output is a zombie " << std::endl; }
  
  //-----------------------------------
  //set old exclusion Limits
  //-----------------------------------

  TGraph* LEP_ch = set_lep_ch(tanBeta_);
  TGraph* LEP_sl = set_lep_sl(tanBeta_);             //slepton curve
  TGraph* TEV_sg_cdf = set_tev_sg_cdf(tanBeta_);     //squark gluino cdf
  TGraph* TEV_sg_d0 = set_tev_sg_d0(tanBeta_);       //squark gluino d0
  //TGraph* TEV_tlp_cdf = set_tev_tlp_cdf(tanBeta_); //trilepton cdf
  //TGraph* TEV_tlp_d0 = set_tev_tlp_d0(tanBeta_);   //trilepton d0
  TGraph* stau = set_tev_stau(tanBeta_);             //stau 
  //TGraph* NoEWSB = set_NoEWSB(tanBeta_); 

  TGraph* TEV_sn_d0_1 = set_sneutrino_d0_1(tanBeta_);
  TGraph* TEV_sn_d0_2 = set_sneutrino_d0_2(tanBeta_);

  //-----------------------------------
  // constant sqquark and gluino lines
  //-----------------------------------

  const unsigned int nlines = 4;

  TF1* lnsq[nlines];
  TF1* lngl[nlines];
  
  TLatex* sq_text[nlines];
  TLatex* gl_text[nlines];

  for(unsigned int i = 0; i < nlines; i++){
    lnsq[i]    = constant_squark(tanBeta_,i);
    sq_text[i] = constant_squark_text(i,*lnsq[i],tanBeta_);
    lngl[i]    = constant_gluino(tanBeta_,i);
    gl_text[i] = constant_gluino_text(i,*lngl[i]);
  }

  //-----------------------------------
  // Legends
  //-----------------------------------

  TLegend* legst     = makeStauLegend(0.05,tanBeta_);
  TLegend* legexp    = makeExpLegend( *TEV_sg_cdf,*TEV_sg_d0,*LEP_ch,*LEP_sl,*TEV_sn_d0_1,0.035,tanBeta_);
  //TLegend* legNoEWSB = makeNoEWSBLegend(0.05,tanBeta_);

  //-----------------------------------
  // make Canvas
  //-----------------------------------

  TCanvas* cvsSys = new TCanvas("cvsnm","cvsnm",0,0,800,600);
  gStyle->SetOptTitle(0);
  cvsSys->SetFillColor(0);
  cvsSys->GetPad(0)->SetRightMargin(0.07);
  cvsSys->Range(-120.5298,26.16437,736.0927,500);
  //cvsSys->Range(-50.5298,26.16437,736.0927,500);
  cvsSys->SetFillColor(0);
  cvsSys->SetBorderMode(0);
  cvsSys->GetPad(0)->SetBorderSize(2);
  cvsSys->GetPad(0)->SetLeftMargin(0.1407035);
  cvsSys->GetPad(0)->SetTopMargin(0.08);
  cvsSys->GetPad(0)->SetBottomMargin(0.13);
  cvsSys->SetTitle("tan#beta="+tanb);
 
  output->cd();
  
  //and now
  //the exclusion limits
  TGraphErrors* First ;
  //TGraphErrors* FirstDummy ;
  TGraphErrors* Second;
  TGraphErrors* Third;
  TGraphErrors* Second_up;
  TGraphErrors* Second_low;
  TGraphErrors* expband;
  TGraphErrors* obs2010;

  if (tanBeta_		== 3) {
    //First		= getObserved_NLOunc();
    //FirstDummy	= getObserved_NLOunc();
  } else {
    //First		= getNLOobsTanbeta10();
    //First		= getNLOobsTanbeta10_smooth();
    //First		= getNLOobsTanbeta10_funky();
    First		= getNLOobsTanbeta10();
    //FirstDummy	= getObserved_NLOunc();
    //Second		= getNLOexpTanbeta10();
    Second		= getNLOexpTanbeta10();
    Second_up		= getNLOexpUpTanbeta10();
    Second_low		= getNLOexpDownTanbeta10();
    Third		= getNLOexpTanbeta10();
    expband		= getNLOexpTanbeta10_band();
    obs2010		= getNLOobsTanbeta10_2010();
    //Second_up		= getExpected_NLO_tanBeta3_up();
    //Second_low	= getExpected_NLO_tanBeta3_low();
  }
  //Third		= getExpected_NLOunc();//getLO_jetMultis();
  //Second		= getLO_signalCont();

  TGraph *grObserved3p5_shape = getObserved3p5_shape();
  TGraph *grExpected3p5_shape = getExpected3p5_shape();

//   First->SetMarkerColor(kWhite);
//   First->GetXaxis()->SetRangeUser(2.,500.);
//   First->GetYaxis()->SetRangeUser(80,500);
//   if(tanBeta_ == 50) First->GetXaxis()->SetRangeUser(200,500);
//   First->GetXaxis()->SetTitle("m_{0} (GeV)");
//   First->GetYaxis()->SetTitle("m_{1/2} (GeV)");
//   First->GetYaxis()->SetTitleOffset(0.8);

  double m0min = 0;
  if (tanBeta_ == 50) m0min=200;
  TH2D* hist = new TH2D("h","h",100,m0min,m0max,100,120,m12max);
  hist->Draw();  
  hist->GetXaxis()->SetTitle("m_{0} (GeV/c^{2})");
  hist->GetYaxis()->SetTitle("m_{1/2} (GeV/c^{2})");
  hist->GetYaxis()->SetTitleOffset(1.);
  hist->GetXaxis()->SetNdivisions(506);
  //  if (tanBeta_ == 50)  hist->GetXaxis()->SetNdivisions(504);
  hist->GetYaxis()->SetNdivisions(506);

  //int col[]={2,3,4};

  
  //TFile *f = TFile::Open("exclusion_Spring11_CLs.root");        
  //TFile *f = TFile::Open("exclusion_Fall10_tcmet_JPT.root"); 
  //TFile *f = TFile::Open("exclusion_Fall10_pfmet_pfjets.root"); 
  //TFile *f = new TFile("exclusion_Fall10_pfmet_pfjets_CLs.root");
  
  //TH2F* h = (TH2F*) f->Get("hexcl_NLO_obs");
  //TH2F* h = (TH2F*) f->Get("hexcl_NLO_exp");
  //TH2F* h = (TH2F*) f->Get("hexcl_NLO_expp1");
  //TH2F* h = (TH2F*) f->Get("hexcl_NLO_expm1");

  //h->SetMaximum(3);
  //h->Draw("samecolz");
  
  TSpline3 *sFirst = new TSpline3("sFirst",First);
  sFirst->SetLineColor(kRed);
  sFirst->SetLineWidth(3);
  First->SetLineColor(kRed);
  First->SetLineWidth(3);

  TSpline3 *sSecond = new TSpline3("sSecond",Second);
  sSecond->SetLineColor(kBlue);
  sSecond->SetLineStyle(2);
  sSecond->SetLineWidth(3);
  Second->SetLineColor(kBlue);
  Second->SetLineStyle(2);
  Second->SetLineWidth(3);

  TSpline3 *sSecond_up = new TSpline3("sSecond_up",Second_up);
  sSecond_up->SetLineColor(kCyan);
  sSecond_up->SetLineStyle(1);
  sSecond_up->SetLineWidth(3);
  Second_up->SetLineColor(kBlue);
  //Second_up->SetLineColor(1);
  Second_up->SetLineWidth(2);

  TSpline3 *sSecond_low = new TSpline3("sSecond_low",Second_low);
  sSecond_low->SetLineColor(kCyan);
  sSecond_low->SetLineStyle(1);
  sSecond_low->SetLineWidth(3);
  Second_low->SetLineColor(kBlue);
  //Second_low->SetLineColor(1);
  Second_low->SetLineWidth(2);

  Third->SetLineColor(kCyan);
  Third->SetLineWidth(30);

  
  // TSpline3 *sThird = new TSpline3("sThird",Third);
  // sThird->SetLineColor(kGreen+2);
  // sThird->SetLineStyle(4);
  // sThird->SetLineWidth(3);
  // Third->SetLineColor(kGreen+2);
  // Third->SetLineStyle(4);
  // Third->SetLineWidth(3);

  //  First->Draw("AP");
  
  /*
 for(vector<TH1F*>::iterator at = exclusionPlots.begin();at != exclusionPlots.end();++at){
      (*at)->SetContour(2);
      if(n == 0){
      	(*at)->DrawCopy();
	(*at)->SetTitle("tan#beta="+tanBeta_);
      }
      cout << " n " << n << endl;
     (*at)->DrawCopy("same");
      //  (*it)->Write();
      cout << " here " << endl;
      n++;
      }*/

  
  TLegend* myleg;

  if( plotLO_ ) myleg = new TLegend(0.3,0.75,0.54,0.9,NULL,"brNDC");
  else          myleg = new TLegend(0.25,0.75,0.54,0.9,NULL,"brNDC");



  myleg->SetFillColor(0); 
  myleg->SetShadowColor(0);
  myleg->SetTextSize(0.03);
  myleg->SetBorderSize(0);
  
  TH1F* hdummy = new TH1F();
  hdummy->SetLineColor(4);
  hdummy->SetFillColor(4);
  hdummy->SetFillStyle(3002);
  hdummy->SetLineWidth(2);
  hdummy->SetLineStyle(2);

  //  myleg->AddEntry(sSecond,"NLO Expected Limit","L");
  if (tanBeta_ == 3 && plotLO_) {
    myleg->AddEntry(sSecond,"LO Observed Limit","L");
    myleg->AddEntry(sFirst,"NLO Observed Limit","L"); 
  } else {
    //myleg->AddEntry(sFirst,"CMS OS Dilepton Limit","L"); 
    myleg->AddEntry(sFirst,"NLO observed limit","L"); 
    //myleg->AddEntry(hdummy,"NLO expected limit","LF"); 
    myleg->AddEntry(hdummy,"NLO expected limit","L"); 
    //myleg->AddEntry(sSecond,"NLO expected limit","L"); 
    //myleg->AddEntry(sSecond_up,"NLO expected limit (+/-1#sigma)","L"); 
    myleg->AddEntry(obs2010,"2010 NLO observed limit","L"); 
  }
  
  //sSecond_up->Draw("h same");
  //sSecond_low->Draw("h same");
      
 
  //constant squark and gluino mass contours
  for (unsigned int it=1;it<nlines;it++) {   
    lngl[it]->Draw("same");   
    lnsq[it]->Draw("same");
    sq_text[it]->Draw();
    gl_text[it]->Draw();
  }

  sSecond_up->SetFillStyle(4010);
  sSecond_up->SetFillColor(kCyan-10);

  sSecond_low->SetFillStyle(1001);
  sSecond_low->SetFillColor(10);

  //expected and observed (LO & NLO) contours
  //sFirst->Draw("same");    
  //sSecond->Draw("same");   
  //sThird->Draw("same");
  //Third->Draw("samec");

  //expband->Draw("samecf"); // summer11 expected band
  //First->Draw("samec");    // summer11 observed exclusion
  
  //First->SetMarkerColor(1);
  //First->Draw("samep");
  //Second->Draw("samec");   // summer11 expected limit
  obs2010->Draw("samec");
  //Second_up->Draw("samec");
  //Second_low->Draw("samec");

  grObserved3p5_shape->SetLineColor(2);
  grExpected3p5_shape->SetLineColor(4);
  grExpected3p5_shape->SetLineStyle(2);
  grObserved3p5_shape->Draw("same");
  grExpected3p5_shape->Draw("same");

  // if (tanBeta_ == 3) Third->Draw("samec");
  //if (tanBeta_ == 3 && plotLO_) Second->Draw("samec");

   
    
  //exclusion limits previous experiments
  if(tanBeta_ == 3){
    TEV_sn_d0_1->Draw("fsame");
    TEV_sn_d0_2->Draw("fsame");
  }
  LEP_ch->Draw("fsame");
  if (tanBeta_ != 50) LEP_sl->Draw("fsame");

  //remove CDF/D0 excluded regions
  TEV_sg_cdf->Draw("fsame");
  TEV_sg_d0->Draw("same");  
  TEV_sg_d0->Draw("fsame");


  //other labels
  Double_t xpos = 0;
  Double_t xposi = 0;
  Double_t ypos = 0;
  if(tanBeta_ == 50) xposi = 100;
  if(tanBeta_ == 50) xpos = 200;
  if(tanBeta_ == 50) ypos = -10;
  
  //TLatex* lumilabel = new TLatex(135.+xposi,510.,"L_{int} = 34 pb^{-1}, #sqrt{s} = 7 TeV");
  //TLatex* lumilabel = new TLatex(305.+xposi + 100,510.,"L_{int} = 976 pb^{-1}, #sqrt{s} = 7 TeV");
  TLatex* lumilabel = new TLatex(490,m12max+15,"#sqrt{s} = 7 TeV, #scale[0.6]{#int} L dt = 3.5 fb^{-1}");

  lumilabel->SetTextSize(0.05);
  lumilabel->Draw("same");

  TLatex* cmslabel = new TLatex(10.,m12max+15,"CMS Preliminary");
  cmslabel->SetTextSize(0.05);
  cmslabel->Draw("same");

  TString text_tanBeta;
  //text_tanBeta =  "tan#beta = "+tanb+", A_{0} = 0, sign(#mu) > 0";
  text_tanBeta =  "tan#beta = "+tanb+",  A_{0} = 0,  #mu > 0";
  //TLatex* cmssmpars = new TLatex(70.+xpos,340.+ypos,text_tanBeta);
 
  TLatex* cmssmpars = new TLatex(120,540,text_tanBeta);
  //TLatex* cmssmpars = new TLatex(200,370,text_tanBeta);
  cmssmpars->SetTextSize(0.045);

  cmssmpars->Draw("same");

  //LM points
  TMarker* LM0 = new TMarker(200.,160.,20);
  TMarker* LM1 = new TMarker(60.,250.,20);
  TMarker* LM3 = new TMarker(330.,240.,20);
  TMarker* LM6 = new TMarker(80.,400.,20);
    
  LM0->SetMarkerSize(1.2);
  LM1->SetMarkerSize(1.2);
    
  TLatex* tLM0 = new TLatex(205.,160.," LM0");
  tLM0->SetTextSize(0.035);
    
  TLatex* tLM1 = new TLatex(80.,245.,"LM1");
  tLM1->SetTextSize(0.035);
  
  //TLatex* tLM3 = new TLatex(350.,235.,"LM3 (tan#beta=20)");
  TLatex* tLM3 = new TLatex(350.,235.,"LM3");
  tLM3->SetTextSize(0.035);
  
  TLatex* tLM6 = new TLatex(100.,395.,"LM6");
  tLM6->SetTextSize(0.035);
  
  //  if (tanBeta_ != 50){
  //  LM0->Draw("same");   
  //  tLM0->Draw("same");
  //  LM1->Draw("same");   
  //  tLM1->Draw("same");
  // }
  if (tanBeta_ == 10){ 
    LM1->Draw("same");
    tLM1->Draw("same");
    LM3->Draw("same");
    tLM3->Draw("same");
    LM6->Draw("same");
    tLM6->Draw("same");
  }

    /*
   Int_t n = 0;
    for(vector<TH1F*>::iterator at = exclusionPlots.begin();at != exclusionPlots.end();++at){
      (*at)->SetContour(2);
      if(n == 0){
      	(*at)->DrawCopy("same");
	(*at)->SetTitle("tan#beta=3");
      }
      cout << " n " << n << endl;
     (*at)->DrawCopy("same");
      //  (*it)->Write();
      cout << " here " << endl;
      n++;
      }
  
    */



  //stau=LSP contour
  stau->Draw("fsame");
  //NoEWSB->Draw("fsame");

  //legends
  legexp->Draw();
  legst->Draw();
  myleg->Draw();
  //legNoEWSB->Draw();

  //First->Draw("samec");
  // if (tanBeta_ == 3) Third->Draw("samec");
  //if (tanBeta_ == 3 && plotLO_) Second->Draw("samec");
  
  hist->Draw("sameaxis");
  cvsSys->RedrawAxis();
  cvsSys->Update();
  cvsSys->Write();
  
  if( plotLO_ ){
    cvsSys->SaveAs("RA6_ExclusionLimit_tanb"+tanb+"_LO.pdf");
    cvsSys->SaveAs("RA6_ExclusionLimit_tanb"+tanb+"_LO.png");
  }else{
    cvsSys->SaveAs("RA6_ExclusionLimit_tanb"+tanb+".eps");
    cvsSys->SaveAs("RA6_ExclusionLimit_tanb"+tanb+".pdf");
    cvsSys->SaveAs("RA6_ExclusionLimit_tanb"+tanb+".png");
  }
  
  output->Write();
  //output->Close();
  //delete output; 
  
}
コード例 #18
0
ファイル: mk_tree.C プロジェクト: c-dilks/run16
void mk_tree(const char * filename="master", Int_t month0=2, Int_t day0=20, 
              Int_t timecut_low=0, Int_t timecut_high=0)
{
  // list of channels to not plot in summary.pdf (so scales get set properly)
  const Int_t N_MASK = 10;
  Int_t mask[N_MASK][3]; // [count] [crate,slot,chan]
  Int_t ii=0;
  mask[ii][0]=7005; mask[ii][1]=13; mask[ii++][2]=0;  // not stacked
  mask[ii][0]=7005; mask[ii][1]=14; mask[ii++][2]=2;  // not stacked
  mask[ii][0]=7005; mask[ii][1]=15; mask[ii++][2]=1;  // not stacked
  mask[ii][0]=7006; mask[ii][1]=15; mask[ii++][2]=2;  // suppressed to 0 V
  mask[ii][0]=7007; mask[ii][1]=1;  mask[ii++][2]=15; // unused channel: setpoint=900V, but readback=~1V
  mask[ii][0]=7008; mask[ii][1]=4;  mask[ii++][2]=13; // suppressed to 0 V
  mask[ii][0]=7005; mask[ii][1]=12;  mask[ii++][2]=4;
  mask[ii][0]=7007; mask[ii][1]=0;  mask[ii++][2]=15;
  mask[ii][0]=7007; mask[ii][1]=7;  mask[ii++][2]=2;
  mask[ii][0]=7007; mask[ii][1]=7;  mask[ii++][2]=7;



  // make tree after daily log file
  char outfilename[128];
  sprintf(outfilename,"rootfile.2015.%d.%d.root",month0,day0);
  TFile * outfile = new TFile(outfilename,"RECREATE");
  TTree * tr = new TTree();
  tr->ReadFile(filename,"crate/I:date/C:time/C:slot/I:chan/I:setpoint/I:readback/F");
  tr->Write("tr");
  Int_t crate,slot,chan,setpoint;
  Int_t year,month,day,hour,minute,second;
  Int_t c;
  Float_t readback;
  char date[32];
  char time[32];
  Color_t color[4] = {kRed,kGreen+1,kBlue,kMagenta};

  tr->SetBranchAddress("crate",&crate);
  tr->SetBranchAddress("date",date);
  tr->SetBranchAddress("time",time);
  tr->SetBranchAddress("slot",&slot);
  tr->SetBranchAddress("chan",&chan);
  tr->SetBranchAddress("setpoint",&setpoint);
  tr->SetBranchAddress("readback",&readback);


  // read list of unused channels
  TTree * ul = new TTree(); // list of unused channels
  ul->ReadFile("unused_list.txt","crate/I:slot/I:chan/I");
  Int_t ucrate,uslot,uchan;
  ul->SetBranchAddress("crate",&ucrate);
  ul->SetBranchAddress("slot",&uslot);
  ul->SetBranchAddress("chan",&uchan);


  // initalise (x) vs. time plots
  TGraph * stability_gr[4][16][16]; // [crate] [slot] [chan] // V_set-V_read vs. HHMM time
  TGraph * readback_gr[4][16][16]; // [crate] [slot] [chan] // V_read vs. HHMM time
  TGraph * setpoint_gr[4][16][16]; // [crate] [slot] [chan] // V_set vs. HHMM time
  Int_t gr_i[4][16][16];
  for(Int_t c=0; c<4; c++)
  {
    for(Int_t sl=0; sl<16; sl++)
    {
      for(Int_t ch=0; ch<16; ch++)
      {
        stability_gr[c][sl][ch] = new TGraph();
        readback_gr[c][sl][ch] = new TGraph();
        setpoint_gr[c][sl][ch] = new TGraph();
        gr_i[c][sl][ch] = 0;
        stability_gr[c][sl][ch]->SetMarkerStyle(kFullCircle);
        readback_gr[c][sl][ch]->SetMarkerStyle(kFullCircle);
        setpoint_gr[c][sl][ch]->SetMarkerStyle(kFullCircle);
        stability_gr[c][sl][ch]->SetMarkerColor(color[c]);
        readback_gr[c][sl][ch]->SetMarkerColor(color[c]);
        setpoint_gr[c][sl][ch]->SetMarkerColor(color[c]);
      };
    };
  };
  

  // fill (x) vs. time plots
  for(Int_t i=0; i<tr->GetEntries(); i++)
  {
    tr->GetEntry(i);
    sscanf(date,"%d.%d.%d",&year,&month,&day);
    if(month==month0 && day==day0)
    {
      sscanf(time,"%d.%d.%d",&hour,&minute,&second);
      c = CrateToIndex(crate);
      if(100*hour+minute>=timecut_low && (timecut_high==0 || 100*hour+minute<=timecut_high))
      {
        stability_gr[c][slot][chan]->SetPoint(
          gr_i[c][slot][chan],
          100*hour+minute,
          setpoint-readback);
        readback_gr[c][slot][chan]->SetPoint(
          gr_i[c][slot][chan],
          100*hour+minute,
          readback);
        setpoint_gr[c][slot][chan]->SetPoint(
          gr_i[c][slot][chan],
          100*hour+minute,
          setpoint);
        gr_i[c][slot][chan]++;
      };
    };
  };


  // define legend for voltage difference vs. time plots
  TLatex * color_leg[4];
  char color_leg_txt[4][8];
  for(Int_t c=0; c<4; c++)
  {
    sprintf(color_leg_txt[c],"%d",IndexToCrate(c));
    color_leg[c] = new TLatex(0.0,0.9-c*0.1,color_leg_txt[c]);
    color_leg[c]->SetNDC();
    color_leg[c]->SetTextColor(color[c]);
    color_leg[c]->SetTextSize(0.08);
  };

  
  // draw pdf for voltage difference vs. time plots
  gStyle->SetTitleH(0.1);
  gStyle->SetTitleW(0.7);
  TMultiGraph * multi_stability[16][16]; // [slot] [chan]
  char multi_stability_t[16][16][512];
  char unused_lab[32];
  char unused_str[40];
  TCanvas * canv = new TCanvas("canv","canv",700,1200);
  canv->Divide(1,8);
  Int_t padnum=1;
  Int_t pagenum=1;
  char pdfname[64];
  char pdfnameL[64];
  char pdfnameR[64];
  char canv_writename[64];
  sprintf(pdfname,"monitor.%d.%d.%d.pdf",year,month,day);
  sprintf(pdfnameL,"%s(",pdfname);
  sprintf(pdfnameR,"%s)",pdfname);
  for(Int_t sl=0; sl<16; sl++)
  {
    for(Int_t ch=0; ch<16; ch++)
    {
      strcpy(unused_str,"");
      strcpy(unused_lab,"");
      for(Int_t ent=0; ent<ul->GetEntries(); ent++)
      {
        ul->GetEntry(ent);
        if(sl==uslot && ch==uchan) 
        {
          strcpy(unused_lab," -- unused chan in");
          sprintf(unused_str,"%s %d",unused_str,ucrate);
        };
      };
      if((sl==13 && ch==0) ||
         (sl==14 && ch==2) ||
         (sl==15 && ch==1))
      {
        strcpy(unused_lab," -- unused chan in");
        sprintf(unused_str,"%s 7005[not_stacked]",unused_str);
      };
      sprintf(multi_stability_t[sl][ch],
        "V_{set}-V_{read} vs. time (%d,%d) on %d-%d-%d%s%s",
        sl,ch,year,month,day,unused_lab,unused_str);
      multi_stability[sl][ch] = new TMultiGraph();
      multi_stability[sl][ch]->SetTitle(multi_stability_t[sl][ch]);
      for(Int_t c=0; c<4; c++)
      {
        if(stability_gr[c][sl][ch]!=NULL && gr_i[c][sl][ch]>0)
        {
          multi_stability[sl][ch]->Add(stability_gr[c][sl][ch]);
        };
      };
      canv->cd(padnum);
      canv->GetPad(padnum)->SetGrid(1,1);
      multi_stability[sl][ch]->Draw("AP");
      multi_stability[sl][ch]->GetXaxis()->SetLabelSize(0.08);
      multi_stability[sl][ch]->GetYaxis()->SetLabelSize(0.08);
      for(Int_t c=0; c<4; c++) color_leg[c]->Draw();
      //printf("%d %d\n",pagenum,padnum);
      padnum++;
      if(padnum>8)
      {
        if(pagenum==1) canv->Print(pdfnameL,"PDF");
        else if(pagenum==32) canv->Print(pdfnameR,"PDF");
        else canv->Print(pdfname,"PDF");
        sprintf(canv_writename,"stability_slot%d_ch%d-%d",sl,
          (pagenum%2)?0:8,(pagenum%2)?7:15);
        canv->Write(canv_writename);
        pagenum++;
        padnum=1;
      };
    };
  };




  // summary plots
  TH2F * rms_plot[4]; // rms of V_set-V_read
  char rms_plot_t[4][64];
  char rms_plot_n[4][32];
  TH2F * ave_plot[4]; // abs value of average V_set-V_read
  char ave_plot_t[4][64];
  char ave_plot_n[4][32];
  TH2F * set_plot[4]; // abs value of average V_set
  char set_plot_t[4][64];
  char set_plot_n[4][32];
  TH2F * rdb_plot[4]; // abs value of average V_read
  char rdb_plot_t[4][64];
  char rdb_plot_n[4][32];
  Int_t binn;
  TGraph * unused_gr[4]; // unused channel markers
  Int_t unused_gr_i[4]; 
  TGraph * masked_gr[4]; // masked channel markers
  Int_t masked_gr_i[4]; 
  Bool_t plot_summary_point;
  for(Int_t c=0; c<4; c++) 
  {
    unused_gr[c] = new TGraph();
    unused_gr_i[c]=0;
    unused_gr[c]->SetMarkerStyle(28);
    unused_gr[c]->SetMarkerSize(3);
    unused_gr[c]->SetMarkerColor(kBlack);
    masked_gr[c] = new TGraph();
    masked_gr_i[c]=0;
    masked_gr[c]->SetMarkerStyle(8);
    masked_gr[c]->SetMarkerSize(1.5);
    masked_gr[c]->SetMarkerColor(kBlack);
  };
  for(Int_t c=0; c<4; c++)
  {
    sprintf(rms_plot_t[c],"RMS(V_{set}-V_{read}) vs. slot,channel [%d];slot;channel",IndexToCrate(c));
    sprintf(rms_plot_n[c],"rms_plot_%d",IndexToCrate(c));
    rms_plot[c] = new TH2F(rms_plot_n[c],rms_plot_t[c],16,-0.5,15.5,16,-0.5,15.5);
    sprintf(ave_plot_t[c],"|<V_{set}-V_{read}>| vs. slot,channel [%d];slot;channel",IndexToCrate(c));
    sprintf(ave_plot_n[c],"ave_plot_%d",IndexToCrate(c));
    ave_plot[c] = new TH2F(ave_plot_n[c],ave_plot_t[c],16,-0.5,15.5,16,-0.5,15.5);
    sprintf(set_plot_t[c],"|<V_{set}>| vs. slot,channel [%d];slot;channel",IndexToCrate(c));
    sprintf(set_plot_n[c],"set_plot_%d",IndexToCrate(c));
    set_plot[c] = new TH2F(set_plot_n[c],set_plot_t[c],16,-0.5,15.5,16,-0.5,15.5);
    sprintf(rdb_plot_t[c],"|<V_{read}>| vs. slot,channel [%d];slot;channel",IndexToCrate(c));
    sprintf(rdb_plot_n[c],"rdb_plot_%d",IndexToCrate(c));
    rdb_plot[c] = new TH2F(rdb_plot_n[c],rdb_plot_t[c],16,-0.5,15.5,16,-0.5,15.5);

    for(Int_t sl=0; sl<16; sl++)
    {
      for(Int_t ch=0; ch<16; ch++)
      {
        if(gr_i[c][sl][ch])
        {
          plot_summary_point=true;
          for(Int_t kk=0; kk<N_MASK; kk++)
          {
            if(IndexToCrate(c)==mask[kk][0] &&
               sl==mask[kk][1] &&
               ch==mask[kk][2]) plot_summary_point=false;
          };
          if(plot_summary_point) 
          {
            binn = rms_plot[c]->FindBin(sl,ch);
            rms_plot[c]->SetBinContent(binn,stability_gr[c][sl][ch]->GetRMS(2));
            ave_plot[c]->SetBinContent(binn,fabs(stability_gr[c][sl][ch]->GetMean(2)));
            set_plot[c]->SetBinContent(binn,fabs(setpoint_gr[c][sl][ch]->GetMean(2)));
            rdb_plot[c]->SetBinContent(binn,fabs(readback_gr[c][sl][ch]->GetMean(2)));
          };
        };
        for(Int_t ent=0; ent<ul->GetEntries(); ent++)
        {
          ul->GetEntry(ent);
          // filters not_stacked cells and unused channels
          if(sl==uslot && ch==uchan && IndexToCrate(c)==ucrate)
          {
            unused_gr[c]->SetPoint(unused_gr_i[c],sl,ch);
            unused_gr_i[c]++;
          };
          if(!plot_summary_point)
          {
            masked_gr[c]->SetPoint(masked_gr_i[c],sl,ch);
            masked_gr_i[c]++;
          };
        };
      };
    };
  };


  // draw summary plots
  gStyle->SetOptStat(0);
  gStyle->SetPaintTextFormat("5.2f");

  char summarypdfL[64];
  char summarypdf[64];
  char summarypdfR[64];
  sprintf(summarypdf,"summary.%d.%d.%d.pdf",year,month,day);
  sprintf(summarypdfL,"%s(",summarypdf);
  sprintf(summarypdfR,"%s)",summarypdf);

  TCanvas * rms_canv = new TCanvas("rms_canv","rms_canv",1700,1000);
  rms_canv->Divide(2,2);
  char draw_style[16];
  strcpy(draw_style,"colztext");
  //for(Int_t c=1; c<5; c++) rms_canv->GetPad(c)->SetLogz();
  for(Int_t p=0; p<4; p++)
  {
    rms_canv->cd(p+1);
    rms_plot[p]->Draw(draw_style);
    if(unused_gr_i[p]) unused_gr[p]->Draw("P");
    if(masked_gr_i[p]) masked_gr[p]->Draw("P");
  };
  rms_canv->Write();
  rms_canv->Print(summarypdfL,"pdf");

  TCanvas * ave_canv = new TCanvas("ave_canv","ave_canv",1700,1000);
  ave_canv->Divide(2,2);
  char draw_style[16];
  strcpy(draw_style,"colztext");
  //for(Int_t c=1; c<5; c++) ave_canv->GetPad(c)->SetLogz();
  for(Int_t p=0; p<4; p++)
  {
    ave_canv->cd(p+1);
    ave_plot[p]->Draw(draw_style);
    if(unused_gr_i[p]) unused_gr[p]->Draw("P");
    if(masked_gr_i[p]) masked_gr[p]->Draw("P");
  };
  ave_canv->Write();
  ave_canv->Print(summarypdf,"pdf");

  TCanvas * rdb_canv = new TCanvas("rdb_canv","rdb_canv",1700,1000);
  rdb_canv->Divide(2,2);
  char draw_style[16];
  strcpy(draw_style,"colztext");
  //for(Int_t c=1; c<5; c++) rdb_canv->GetPad(c)->SetLogz();
  for(Int_t p=0; p<4; p++)
  {
    rdb_canv->cd(p+1);
    rdb_plot[p]->Draw(draw_style);
    if(unused_gr_i[p]) unused_gr[p]->Draw("P");
    if(masked_gr_i[p]) masked_gr[p]->Draw("P");
  };
  rdb_canv->Write();
  rdb_canv->Print(summarypdf,"pdf");

  TCanvas * set_canv = new TCanvas("set_canv","set_canv",1700,1000);
  set_canv->Divide(2,2);
  char draw_style[16];
  strcpy(draw_style,"colztext");
  //for(Int_t c=1; c<5; c++) set_canv->GetPad(c)->SetLogz();
  for(Int_t p=0; p<4; p++)
  {
    set_canv->cd(p+1);
    set_plot[p]->Draw(draw_style);
    if(unused_gr_i[p]) unused_gr[p]->Draw("P");
    if(masked_gr_i[p]) masked_gr[p]->Draw("P");
  };
  set_canv->Write();
  set_canv->Print(summarypdfR,"pdf");


  printf("\n");
  printf("%s created (V_set-V_read vs. HHMM time)\n",pdfname);
  printf("%s created (summary diagnostics)\n",summarypdf);
  printf("%s created\n",outfilename);
}
コード例 #19
0
void PostFitCombine(TString Plots = "fit_s", TString InpDir = "FitResults_DataCardFixbtagSysVisPhSp_hSF-PreApp-v0_Tree_LepJets_NewJEC-OldKinFit_v8-0-6_Spring16-80X_36814pb-1_2btag", TString FitDir = "OBSERVED"){

  TString PlotsFileName;
  if(FitDir == "OBSERVED") PlotsFileName = "obs";
  if(FitDir == "EXPECTED") PlotsFileName = "exp";
 
  TString inputfile = "CombineResults/" + InpDir + "/" + FitDir + "/fitDiagnostics" + PlotsFileName + "MLF.root";
  
 
  setTDRStyle();

  gROOT->SetStyle("Plain");
  gStyle->SetOptFit(1000);
  gStyle->SetOptStat("emruo");
  gStyle->SetOptStat(kFALSE);
  gStyle->SetPadTickY(1);
  gStyle->SetPadTickX(1);
  
  int col_ttbb = TColor::GetColor("#660000");
  int col_ttb  = TColor::GetColor("#ffcc00");
  int col_ttcc = TColor::GetColor("#cc6600");
  int col_ttc  = TColor::GetColor("#cc6600");
  int col_ttLF = TColor::GetColor("#ff0000");
  int col_tt   = TColor::GetColor("#FF7F7F");

  int col_ttbarBkg  = TColor::GetColor("#ff6565");
  int col_SingleTop = TColor::GetColor("#ff00ff");
  int col_WJets     = TColor::GetColor("#33cc33");
  int col_ZJets     = TColor::GetColor("#3366ff");
  int col_QCD       = TColor::GetColor("#ffff00");
  int col_ttbarV    = TColor::GetColor("#e75c8d");
  int col_ttbarH    = TColor::GetColor("#e5c4f4");
  int col_VV        = TColor::GetColor("#ffffff");
 
  TFile *hfile = NULL;
  hfile = TFile::Open(inputfile);
  cout << "file loaded: " << inputfile << endl;

  std::vector<TString> hNamefile;
  std::vector<int> hColor;
  hNamefile.push_back("ttbar_LepJetsPowhegPythiattbb"); // 0
  hColor.push_back(TColor::GetColor("#660000"));
  hNamefile.push_back("ttbar_LepJetsPowhegPythiattbj"); // 1 
  hColor.push_back(TColor::GetColor("#ffcc00"));
  hNamefile.push_back("ttbar_LepJetsPowhegPythiattcc"); // 2
  hColor.push_back(TColor::GetColor("#cc6600"));
  hNamefile.push_back("ttbar_LepJetsPowhegPythiattLF"); // 3
  hColor.push_back(TColor::GetColor("#ff0000"));
  hNamefile.push_back("ttbar_PowhegPythiaBkgtt");
  hColor.push_back(TColor::GetColor("#FF7F7F"));
  hNamefile.push_back("ttHbb_PowhegPythia");
  hColor.push_back(TColor::GetColor("#e5c4f4"));
  hNamefile.push_back("ttV_Madgraph");
  hColor.push_back(TColor::GetColor("#e75c8d"));
  hNamefile.push_back("WJets_aMCatNLO");
  hColor.push_back(TColor::GetColor("#33cc33"));
  hNamefile.push_back("QCD");
  hColor.push_back(TColor::GetColor("#ffff00"));
  hNamefile.push_back("SingleTop");
  hColor.push_back(TColor::GetColor("#ff00ff"));
  hNamefile.push_back("VV");
  hColor.push_back(TColor::GetColor("#ffffff"));
  hNamefile.push_back("ZJets_aMCatNLO");
  hColor.push_back(TColor::GetColor("#3366ff"));
  hNamefile.push_back("total");
  hColor.push_back(1);
  hNamefile.push_back("total_signal");
  hColor.push_back(1);
  hNamefile.push_back("total_background");
  hColor.push_back(1);



  //TString dirname[2]     = {"Name1","Name2"};     //{mu,e}
  TString dirname[2]     = {"ch1","ch2"};     //{mu,e}
  TString titlechname[2] = {"#mu+Jets","e+Jets"}; 
  TString chname[2]      = {"mujets","ejets"};    

  std::vector<TH1D*> hInput[2];
  TH1D    *hData[2], *hData_reg[2][20];
  THStack *AllMC[2], *AllMC_reg[2][20];
  
  THStack *AllMC_CSV1[2], *AllMC_CSV2[2];

  // THStack Initialization
  for(int ich=0;ich<2;ich++){
    AllMC[ich] = new THStack("PostFit_"+chname[ich], "CSV Distribution Post-Fit ("+titlechname[ich]+")");  
    for(int ireg=0;ireg<20;ireg++){
      TString RegNum;
      RegNum.Form("%i",ireg); 
      AllMC_reg[ich][ireg] = new THStack("PostFit_"+chname[ich]+RegNum, "CSV Distribution Post-Fit ("+titlechname[ich]+") for "+RegNum);        
    } // for(ireg)
  } // for(ich)
 
  cout << "Loading histograms... " << endl;

  // MC Profiles
  for(int ich=0;ich<2;ich++){

    for(int ih=0;ih<hNamefile.size();ih++){      
      cout << "shapes_"+Plots+"/"+dirname[ich]+"/" + hNamefile.at(ih) << endl;
      TH1D *htemp = (TH1D*) hfile->Get("shapes_"+Plots+"/"+dirname[ich]+"/" + hNamefile.at(ih))->Clone("c" + hNamefile.at(ih));
      htemp->SetFillColor(hColor.at(ih));
      htemp->SetLineColor(1);
      hInput[ich].push_back(htemp);
      cout << hNamefile.at(ih) << " = " << htemp->Integral()  << endl;
      if(ih==0) AllMC[ich]->SetHistogram((TH1D*)htemp->Clone("FirstStack"));
      if (!hNamefile.at(ih).Contains("total")) AllMC[ich] -> Add(htemp);
      // Data
      // Clone Histo Structure only once
      if(ih==0){
	hData[ich] = (TH1D *) htemp->Clone("data_"+dirname[ich]);
	hData[ich]->Reset();
      }
    } // for(ih)

    // Data TGraph
    TGraphAsymmErrors *DataFull = (TGraphAsymmErrors *) hfile->Get("shapes_"+Plots+"/"+dirname[ich]+"/data")->Clone("data_"+dirname[ich]);
    for(int ibin=1;ibin<=hData[ich]->GetNbinsX();ibin++){ 
      double igb, EvtBinData, EvtErrBinData;
      DataFull->GetPoint((ibin-1),igb,EvtBinData); 
      hData[ich]->SetBinContent(ibin,EvtBinData);
      EvtErrBinData = DataFull->GetErrorY((ibin-1));
      hData[ich]->SetBinError(ibin,EvtErrBinData);
    }
    
    // Histograms for each region
    for(int ih=0;ih<hNamefile.size();ih++){

      TH1D *htemp = (TH1D*) hfile->Get("shapes_"+Plots+"/"+dirname[ich]+"/" + hNamefile.at(ih))->Clone("c_reg" + hNamefile.at(ih));
      
      for(int ireg=0;ireg<20;ireg++){
	TH1D *htempreg = new TH1D ("","",20,0,20);       
    	for(int ibin=1;ibin<=20;ibin++){
	  //if ( (ibin+20*ireg) == 181) cout << hNamefile.at(ih) << " " << ibin+20*ireg << " : " << htemp->GetBinContent(ibin+20*ireg) << " ; " << htemp->GetBinError(ibin+20*ireg) << endl;
    	  htempreg->SetBinContent(ibin,htemp->GetBinContent(ibin+20*ireg));	  
    	  htempreg->SetBinError(ibin,htemp->GetBinError(ibin+20*ireg));	  
	  htempreg->SetFillColor(hColor.at(ih));
    	} // for(ibin)
	if(ih==0) AllMC_reg[ich][ireg]->SetHistogram((TH1D*)htempreg->Clone("FirstStack"));
	if (!hNamefile.at(ih).Contains("total")) AllMC_reg[ich][ireg] -> Add(htempreg);
      } // for(ireg)
    } // for(ih)

    // Data
    for(int ireg=0;ireg<20;ireg++){
      TString RegNum;
      RegNum.Form("%i",ireg);
      hData_reg[ich][ireg] = new TH1D ("hData_"+chname[ich]+RegNum,"Data Histogram "+titlechname[ich]+" for "+RegNum,20,0,20);       

      // Data
      for(int ibin=1;ibin<=20;ibin++){ 
	double igb, EvtBinData, EvtErrBinData;
	DataFull->GetPoint(((ibin-1)+(20*ireg)),igb,EvtBinData); 
	hData_reg[ich][ireg]->SetBinContent(ibin,EvtBinData);	  
	EvtErrBinData = DataFull->GetErrorY((ibin-1));
	hData_reg[ich][ireg]->SetBinError(ibin,EvtErrBinData);

	hData_reg[ich][ireg]->SetMarkerStyle(20);
	hData_reg[ich][ireg]->SetMarkerSize(0.5);
      } // for(ibin)
    } // for(ireg)


    // Recover basic CSV plots
    // -- MC
    TH1D *GlobalCSVJet[12][2]; // 12 components
    AllMC_CSV1[ich] = new THStack("CSV1_"+chname[ich], "CSV-AddJet1 Distribution Post-Fit ("+titlechname[ich]+")");
    AllMC_CSV2[ich] = new THStack("CSV2_"+chname[ich], "CSV-AddJet2 Distribution Post-Fit ("+titlechname[ich]+")");

    for(int ih=0;ih<12;ih++){
      GlobalCSVJet[ih][0] = new TH1D("GlobalCSVJet1_" + hNamefile.at(ih), "CSV distribution for AddJet-1", 20, 0.0, 1.0);
      GlobalCSVJet[ih][1] = new TH1D("GlobalCSVJet2_" + hNamefile.at(ih), "CSV distribution for AddJet-2", 20, 0.0, 1.0);
      RecoverCSVHisto (hInput[ich].at(ih), GlobalCSVJet[ih][0], GlobalCSVJet[ih][1]);
      GlobalCSVJet[ih][0]->SetFillColor(hColor.at(ih));
      GlobalCSVJet[ih][1]->SetFillColor(hColor.at(ih));
      
      if(ih==0) AllMC_CSV1[ich]->SetHistogram((TH1D*)GlobalCSVJet[ih][0]->Clone("FirstStack"));
      if(ih==0) AllMC_CSV2[ich]->SetHistogram((TH1D*)GlobalCSVJet[ih][1]->Clone("FirstStack"));
      AllMC_CSV1[ich] -> Add(GlobalCSVJet[ih][0]);
      AllMC_CSV2[ich] -> Add(GlobalCSVJet[ih][1]);
    }

    // -- Data
    TH1D *GlobalCSVJet_Data[2]; // 12 components
    GlobalCSVJet_Data[0] = new TH1D("GlobalCSVJet1_Data", "CSV distribution for AddJet-1", 20, 0.0, 1.0);
    GlobalCSVJet_Data[1] = new TH1D("GlobalCSVJet2_Data", "CSV distribution for AddJet-2", 20, 0.0, 1.0);
    RecoverCSVHisto (hData[ich], GlobalCSVJet_Data[0], GlobalCSVJet_Data[1]);
    
    // -----------
    // Plotting
    // -----------

    TH1D *hstyle = new TH1D ("","",
			     hData[ich]->GetNbinsX(),
			     hData[ich]->GetBinLowEdge (1),
			     hData[ich]->GetBinLowEdge (hData[ich]->GetNbinsX()+1));
    
    hstyle -> SetMaximum(1.1*hInput[ich].at(12)->GetMaximum());
    hstyle -> GetYaxis()->SetTitleFont(42);
    hstyle -> GetYaxis()->SetTitleOffset(0.7);
    hstyle -> GetYaxis()->SetTitleSize(0.05);
    hstyle -> GetYaxis()->SetLabelFont(42);
    hstyle -> GetYaxis()->SetLabelSize(0.045);
    hstyle -> GetYaxis()->SetNdivisions(607);
    hstyle -> GetYaxis()->SetTitle("Events / unit"); 
    
    
    hData[ich] -> SetMarkerStyle(20); 
    hData[ich] -> SetMarkerSize(0.4); 
    hData[ich] -> SetLineWidth(1); 
    hData[ich] -> SetTitle(""); 
    
    
    TCanvas *cPlots;//histos
    cPlots = new TCanvas("cPlots"+dirname[ich] ,"Plots");
    cPlots->Divide(1,2);
    TPad    *pad[4], *glpad[2];
    // Global Pad
    glpad[0] = (TPad*)cPlots->GetPad(1);
    glpad[0]->Divide(1,2);
    glpad[1] = (TPad*)cPlots->GetPad(2);
    glpad[1]->Divide(1,2);

    //Plot Pad
    pad[0] = (TPad*)glpad[0]->GetPad(1);
    pad[0]->SetPad(0.01, 0.23, 0.99, 0.99);
    pad[0]->SetTopMargin(0.1);
    pad[0]->SetRightMargin(0.04);
    
    //Ratio Pad
    pad[1] = (TPad*)glpad[0]->GetPad(2);
    pad[1]->SetPad(0.01, 0.02, 0.99, 0.3);
    gStyle->SetGridWidth(1);
    gStyle->SetGridColor(14);
    pad[1]->SetGridx();
    pad[1]->SetGridy();
    pad[1]->SetTopMargin(0.05);
    pad[1]->SetBottomMargin(0.4);
    pad[1]->SetRightMargin(0.04);

    //Plot Pad
    pad[2] = (TPad*)glpad[1]->GetPad(1);
    pad[2]->SetPad(0.01, 0.23, 0.99, 0.99);
    pad[2]->SetTopMargin(0.1);
    pad[2]->SetRightMargin(0.04);
    
    //Ratio Pad
    pad[3] = (TPad*)glpad[1]->GetPad(2);
    pad[3]->SetPad(0.01, 0.02, 0.99, 0.3);
    gStyle->SetGridWidth(1);
    gStyle->SetGridColor(14);
    pad[3]->SetGridx();
    pad[3]->SetGridy();
    pad[3]->SetTopMargin(0.05);
    pad[3]->SetBottomMargin(0.4);
    pad[3]->SetRightMargin(0.04);
    
    pad[0]->cd();

    hstyle->Draw();
    AllMC[ich] -> Draw("HISTSAME"); 
    hData[ich] -> Draw("PSAME"); 
    
    TH1D *RatioFull = HistoRatio (hData[ich] , (TH1D*) AllMC[ich]->GetStack()->Last());
    TGraphErrors *gRatioFull = new TGraphErrors(RatioFull);
    gRatioFull->SetFillStyle(1001);
    gRatioFull->SetFillColor(chatch);
    gRatioFull->SetName("gRatioFull");


    TLegend *leg;
    float legPos[4] = {0.70,  // x_o
		       0.40,  // y_o
		       0.94,  // x_f
		       0.87}; // y_f
 
    leg = new TLegend(legPos[0],legPos[1],legPos[2],legPos[3]);
    leg->SetFillColor(0);
    leg->SetLineColor(0);
    leg->SetLineWidth(0.0);
    leg->SetTextFont(62);
    leg->SetTextSize(0.03);
    leg->SetNColumns(2);
  
    leg->AddEntry(hData[ich],         "Data","PL");
    leg->AddEntry(hInput[ich].at(11), "Z+Jets","F");
    leg->AddEntry(hInput[ich].at(10), "VV","F");
    leg->AddEntry(hInput[ich].at(9),  "Single t","F");
    leg->AddEntry(hInput[ich].at(8),  "QCD","F");
    leg->AddEntry(hInput[ich].at(7),  "W+Jets","F");
    leg->AddEntry(hInput[ich].at(6),  "t#bar{t}+V","F");
    leg->AddEntry(hInput[ich].at(5),  "t#bar{t}+H","F");
    leg->AddEntry(hInput[ich].at(4),  "t#bar{t}+other","F");
    leg->AddEntry(hInput[ich].at(3),  "t#bar{t}+LF","F");
    leg->AddEntry(hInput[ich].at(2),  "t#bar{t}+cc","F");
    leg->AddEntry(hInput[ich].at(1),  "t#bar{t}+bj","F");
    leg->AddEntry(hInput[ich].at(0),  "t#bar{t}+bb","F");
    leg->AddEntry(gRatioFull,         "Stat. Unc.","F");

    leg->Draw("SAME");
    
    TLatex *titlePr;      
    titlePr  = new TLatex(-20.,50.,"35.9 fb^{-1} (13TeV)");
    titlePr->SetNDC();
    titlePr->SetTextAlign(12);
    titlePr->SetX(0.78);
    titlePr->SetY(0.935);
    titlePr->SetTextFont(42);
    titlePr->SetTextSize(0.05);
    titlePr->SetTextSizePixels(24);
    titlePr->Draw("SAME");
    
    TLatex *title;
    //title  = new TLatex(-20.,50.,"CMS(2016) #sqrt{s} = 13TeV, L = 35.9 fb^{-1}");
    title  = new TLatex(-20.,50.,"CMS");
    title->SetNDC();
    title->SetTextAlign(12);
    title->SetX(0.13);
    title->SetY(0.84);
    title->SetTextFont(61);
    title->SetTextSize(0.06);
    title->SetTextSizePixels(24);
    title->Draw("SAME");
  
    TLatex *chtitle;
    chtitle  = new TLatex(-20.,50.,titlechname[ich]+"");
    chtitle->SetNDC();
    chtitle->SetTextAlign(12);
    chtitle->SetX(0.14);
    chtitle->SetY(0.74);
    chtitle->SetTextFont(42);
    chtitle->SetTextSize(0.05);
    chtitle->SetTextSizePixels(24);
    chtitle->Draw("SAME");

    pad[2]->cd();
    pad[2]->cd()->SetLogy();
    
    TH1D *hstyleLog = (TH1D *)hstyle->Clone();
    hstyleLog -> SetMaximum(10.0*hInput[ich].at(12)->GetMaximum());
    hstyleLog -> SetMinimum(0.8);
    hstyleLog -> Draw();
    
    AllMC[ich] -> Draw("HISTSAME"); 
    hData[ich] -> Draw("PSAME"); 
    titlePr->Draw("SAME");
    title->Draw("SAME");
    chtitle->Draw("SAME");

    pad[1]->cd();
    RatioFull ->Draw("HIST");
    gRatioFull->Draw("e2");
    RatioFull ->Draw("HISTSAME");

    pad[3]->cd();
    RatioFull ->Draw("HIST");
    gRatioFull->Draw("e2");
    RatioFull ->Draw("HISTSAME");

    TString dirfigname_pdf = "CombineResults/Figures_" + InpDir + Plots + FitDir + "/";
    // make a dir if it does not exist!!
    gSystem->mkdir(dirfigname_pdf, kTRUE);

    cPlots->SaveAs(dirfigname_pdf + "FullHisto_" + dirname[ich] + "_NormLog.pdf");

    // -----------------------------------------------------------------------------
    // Only Log Plots
    // -----------------------------------------------------------------------------

    TCanvas *cPlotsLog;//histos                                                                                                                                                                   
    cPlotsLog = new TCanvas("cPlotsLog"+dirname[ich] ,"Plots");
    cPlotsLog->Divide(1,2);
    TPad    *padLog[2];

    //Plot Pad
    padLog[0] = (TPad*)cPlotsLog->GetPad(1);
    padLog[0]->SetPad(0.01, 0.23, 0.99, 0.99);
    padLog[0]->SetTopMargin(0.1);
    padLog[0]->SetRightMargin(0.04);
    
    //Ratio Pad
    padLog[1] = (TPad*)cPlotsLog->GetPad(2);;
    padLog[1]->SetPad(0.01, 0.02, 0.99, 0.3);
    gStyle->SetGridWidth(1);
    gStyle->SetGridColor(14);
    padLog[1]->SetGridx();
    padLog[1]->SetGridy();
    padLog[1]->SetTopMargin(0.05);
    padLog[1]->SetBottomMargin(0.4);
    padLog[1]->SetRightMargin(0.04);

    padLog[0]->cd();
    padLog[0]->cd()->SetLogy();
    
    hstyleLog -> Draw();
    
    AllMC[ich] -> Draw("HISTSAME"); 
    hData[ich] -> Draw("PSAME"); 
    titlePr->Draw("SAME");
    title->Draw("SAME");
    chtitle->Draw("SAME");

    TLegend *legLog;
    legLog = new TLegend(0.70,0.60,0.94,0.87);
    legLog->SetFillColor(0);
    legLog->SetLineColor(0);
    legLog->SetLineWidth(0.0);
    legLog->SetTextFont(62);
    legLog->SetTextSize(0.03);
    legLog->SetNColumns(2);
  
    legLog->AddEntry(hData[ich],         "Data","PL");
    legLog->AddEntry(hInput[ich].at(11), "Z+Jets","F");
    legLog->AddEntry(hInput[ich].at(10), "VV","F");
    legLog->AddEntry(hInput[ich].at(9),  "Single t","F");
    legLog->AddEntry(hInput[ich].at(8),  "QCD","F");
    legLog->AddEntry(hInput[ich].at(7),  "W+Jets","F");
    legLog->AddEntry(hInput[ich].at(6),  "t#bar{t}+V","F");
    legLog->AddEntry(hInput[ich].at(5),  "t#bar{t}+H","F");
    legLog->AddEntry(hInput[ich].at(4),  "t#bar{t}+other","F");
    legLog->AddEntry(hInput[ich].at(3),  "t#bar{t}+LF","F");
    legLog->AddEntry(hInput[ich].at(2),  "t#bar{t}+cc","F");
    legLog->AddEntry(hInput[ich].at(1),  "t#bar{t}+bj","F");
    legLog->AddEntry(hInput[ich].at(0),  "t#bar{t}+bb","F");
    legLog->AddEntry(gRatioFull,         "Stat. Unc.","F");
    legLog->Draw("SAME");

    padLog[1]->cd();
    RatioFull ->Draw("HIST");
    gRatioFull->Draw("e2");
    RatioFull ->Draw("HISTSAME");

    cPlotsLog->SaveAs(dirfigname_pdf + "FullHisto_" + dirname[ich] + "_OnlyLog.pdf");
    
    // -----------------------------------------------------------------------------
    // -----------------------------------------------------------------------------
    // -----------------------------------------------------------------------------
    // Plots by Regions
    // -----------------------------------------------------------------------------
    // -----------------------------------------------------------------------------
    // -----------------------------------------------------------------------------
    int ireg = 0;
    for(int ican=0;ican<5;ican++){

      TString CanNum;
      CanNum.Form("%i",ican); 
      TCanvas *cPlots_reg;//histos
      cPlots_reg = new TCanvas("cPlots_reg" + CanNum + dirname[ich] ,"Plots By regions");
      cPlots_reg->Divide(2,2);
      
      for(int icr=1;icr<=4;icr++){

        //cPlots_reg->cd(icr);

	TPad *glpad_reg = (TPad*)cPlots_reg->cd(icr);
	glpad_reg->Divide(2,1);
	TPad *pad_reg[2];
	//Plot Pad
	pad_reg[0] = (TPad*)glpad_reg->GetPad(1);
	pad_reg[0]->SetPad(0.01, 0.23, 0.99, 0.99);
	pad_reg[0]->SetTopMargin(0.1);
	pad_reg[0]->SetRightMargin(0.04);	
	//Ratio Pad
	pad_reg[1] = (TPad*)glpad_reg->GetPad(2);
	pad_reg[1]->SetPad(0.01, 0.02, 0.99, 0.3);
	gStyle->SetGridWidth(1);
	gStyle->SetGridColor(14);
	pad_reg[1]->SetGridx();
	pad_reg[1]->SetGridy();
	pad_reg[1]->SetTopMargin(0.05);
	pad_reg[1]->SetBottomMargin(0.4);
	pad_reg[1]->SetRightMargin(0.04);

	pad_reg[0]->cd();
	pad_reg[0]->SetLogy();
	TH1D *hstyle_reg = (TH1D*)AllMC_reg[ich][ireg]->GetHistogram(); 
	hstyle_reg -> Reset();
	hstyle_reg -> SetMaximum(10.0*hData_reg[ich][ireg]->GetMaximum());
	hstyle_reg -> SetMinimum(0.7);
	hstyle_reg -> GetYaxis()->SetTitleOffset(0.9);
	hstyle_reg -> GetYaxis()->SetTitleSize(0.05);
	hstyle_reg -> GetYaxis()->SetLabelSize(0.05);
	hstyle_reg -> GetYaxis()->SetTitle("Events"); 

	pad_reg[0]->cd();
	hstyle_reg->Draw();
	AllMC_reg[ich][ireg] -> Draw("HISTSAME"); 
	hData_reg[ich][ireg] -> Draw("E1SAME"); 
	titlePr->Draw("SAME");
	title->Draw("SAME");
	chtitle->Draw("SAME");	

	TH1D *RatioFull_reg = HistoRatio (hData_reg[ich][ireg] , (TH1D*) AllMC_reg[ich][ireg]->GetStack()->Last());
	TGraphErrors *gRatioFull_reg = new TGraphErrors(RatioFull_reg);
	gRatioFull_reg->SetFillStyle(1001);
	gRatioFull_reg->SetFillColor(chatch);
	gRatioFull_reg->SetName("gRatioFull");
	
	pad_reg[1]->cd();
	RatioFull_reg->GetYaxis()->SetTitleOffset(0.25);	
	RatioFull_reg->Draw("HIST");
	gRatioFull_reg->Draw("e2");
	RatioFull_reg->Draw("HISTSAME");
	
	ireg++;
      } // for(ireg) 

      cPlots_reg->SaveAs(dirfigname_pdf + "RegionHisto_" + CanNum + "_" + dirname[ich] + "_NormLog.pdf");
    } // for(ican) 


    TCanvas *cPlotsI;
    cPlotsI = new TCanvas("cPlotsI"+dirname[ich] ,"Plots");
    cPlotsI->Divide(1,2);

    TPad    *padI[4];
    //Plot Pad
    padI[0] = (TPad*)cPlotsI->GetPad(1);
    padI[0]->SetPad(0.01, 0.23, 0.99, 0.99);
    padI[0]->SetTopMargin(0.1);
    padI[0]->SetRightMargin(0.04);
    
    //Ratio Pad
    padI[1] = (TPad*)cPlotsI->GetPad(2);
    padI[1]->SetPad(0.01, 0.02, 0.99, 0.3);
    gStyle->SetGridWidth(1);
    gStyle->SetGridColor(14);
    padI[1]->SetGridx();
    padI[1]->SetGridy();
    padI[1]->SetTopMargin(0.05);
    padI[1]->SetBottomMargin(0.4);
    padI[1]->SetRightMargin(0.04);

    TCanvas *cPlotsII;
    cPlotsII = new TCanvas("cPlotsII"+dirname[ich] ,"Plots");
    cPlotsII->Divide(1,2);
    //Plot Pad
    padI[2] = (TPad*)cPlotsII->GetPad(1);
    padI[2]->SetPad(0.01, 0.23, 0.99, 0.99);
    padI[2]->SetTopMargin(0.1);
    padI[2]->SetRightMargin(0.04);
    
    //Ratio Pad
    padI[3] = (TPad*)cPlotsII->GetPad(2);
    padI[3]->SetPad(0.01, 0.02, 0.99, 0.3);
    gStyle->SetGridWidth(1);
    gStyle->SetGridColor(14);
    padI[3]->SetGridx();
    padI[3]->SetGridy();
    padI[3]->SetTopMargin(0.05);
    padI[3]->SetBottomMargin(0.4);
    padI[3]->SetRightMargin(0.04);
    


    TH1D *hstyleI = new TH1D ("hstyleI","",
			      GlobalCSVJet_Data[1]->GetNbinsX(),
			      GlobalCSVJet_Data[1]->GetBinLowEdge (1),
			      GlobalCSVJet_Data[1]->GetBinLowEdge (GlobalCSVJet_Data[1]->GetNbinsX()+1));
    
    hstyleI -> SetMaximum(1.1*GlobalCSVJet_Data[1]->GetMaximum());
    hstyleI -> GetYaxis()->SetTitleOffset(0.8);
    hstyleI -> GetYaxis()->SetTitleSize(0.05);
    hstyleI -> GetYaxis()->SetLabelSize(0.05);
    hstyleI -> GetYaxis()->SetTitle("Events"); 
    
    GlobalCSVJet_Data[0] -> SetMarkerStyle(20); 
    GlobalCSVJet_Data[0] -> SetMarkerSize(0.4); 
    GlobalCSVJet_Data[0] -> SetLineWidth(1); 
    GlobalCSVJet_Data[0] -> SetTitle(""); 


    padI[0]->cd();
    padI[0]->cd()->SetLogy();
    
    hstyleI -> SetMaximum(100.0*GlobalCSVJet_Data[0]->GetMaximum());
    hstyleI -> SetMinimum(0.7);
    hstyleI -> Draw();

    AllMC_CSV1[ich] -> Draw("HISTSAME");

    GlobalCSVJet_Data[0] -> SetMarkerStyle(20); 
    GlobalCSVJet_Data[0] -> SetMarkerSize(0.6); 
    GlobalCSVJet_Data[0] -> SetLineWidth(1); 
    GlobalCSVJet_Data[0] -> SetTitle(""); 
    GlobalCSVJet_Data[0] -> Draw("SAME");

    titlePr->Draw("SAME");
    title->Draw("SAME");
    chtitle->Draw("SAME");	

    TLegend *legI;
    legI = new TLegend(0.70,0.64,0.93,0.87);
    legI->SetFillColor(0);
    legI->SetLineColor(0);
    legI->SetLineWidth(0.0);
    legI->SetTextFont(62);
    legI->SetTextSize(0.03);
    legI->SetNColumns(2);
  
    legI->AddEntry(hData[ich],         "Data","PL");
    legI->AddEntry(hInput[ich].at(11), "Z+Jets","F");
    legI->AddEntry(hInput[ich].at(10), "VV","F");
    legI->AddEntry(hInput[ich].at(9),  "Single t","F");
    legI->AddEntry(hInput[ich].at(8),  "QCD","F");
    legI->AddEntry(hInput[ich].at(7),  "W+Jets","F");
    legI->AddEntry(hInput[ich].at(6),  "t#bar{t}+V","F");
    legI->AddEntry(hInput[ich].at(5),  "t#bar{t}+H","F");
    legI->AddEntry(hInput[ich].at(4),  "t#bar{t}+other","F");
    legI->AddEntry(hInput[ich].at(3),  "t#bar{t}+LF","F");
    legI->AddEntry(hInput[ich].at(2),  "t#bar{t}+cc","F");
    legI->AddEntry(hInput[ich].at(1),  "t#bar{t}+bj","F");
    legI->AddEntry(hInput[ich].at(0),  "t#bar{t}+bb","F");
    legI->AddEntry(gRatioFull,         "Stat. Unc.","F");

    legI->Draw("SAME");

    TH1D *RatioFullJet1 = HistoRatio (GlobalCSVJet_Data[0] , (TH1D*) AllMC_CSV1[ich]->GetStack()->Last());
    TGraphErrors *gRatioFullJet1 = new TGraphErrors(RatioFullJet1);
    gRatioFullJet1->SetFillStyle(1001);
    gRatioFullJet1->SetFillColor(chatch);
    gRatioFullJet1->SetName("gRatioFullJet2");

    padI[1]->cd();
    RatioFullJet1 ->GetYaxis()->SetTitleOffset(0.25);
    RatioFullJet1 ->GetXaxis()->SetTitle("CSVv2");
    RatioFullJet1 ->Draw("HIST");
    gRatioFullJet1->Draw("e2");
    RatioFullJet1 ->Draw("HISTSAME");

    padI[2]->cd();
    padI[2]->cd()->SetLogy();
    // No Log
    TH1D *hstyleII = (TH1D *)hstyleI -> Clone("StyleII"); 
    hstyleII -> SetMaximum(100.0*GlobalCSVJet_Data[1]->GetMaximum());
    hstyleII -> SetMinimum(0.7);

    hstyleII -> Draw();
    AllMC_CSV2[ich] -> Draw("HISTSAME");

    GlobalCSVJet_Data[1] -> SetMarkerStyle(20); 
    GlobalCSVJet_Data[1] -> SetMarkerSize(0.5); 
    GlobalCSVJet_Data[1] -> SetLineWidth(1); 
    GlobalCSVJet_Data[1] -> SetTitle(""); 
    GlobalCSVJet_Data[1] -> Draw("SAME");

    titlePr->Draw("SAME");
    title->Draw("SAME");
    chtitle->Draw("SAME");	

    legI->Draw("SAME");

    TH1D *RatioFullJet2 = HistoRatio (GlobalCSVJet_Data[1] , (TH1D*) AllMC_CSV2[ich]->GetStack()->Last());
    TGraphErrors *gRatioFullJet2 = new TGraphErrors(RatioFullJet2);
    gRatioFullJet2->SetFillStyle(1001);
    gRatioFullJet2->SetFillColor(chatch);
    gRatioFullJet2->SetName("gRatioFullJet2");

    padI[3]->cd();
    RatioFullJet2 ->GetYaxis()->SetTitleOffset(0.25);
    RatioFullJet2 ->GetXaxis()->SetTitle("CSVv2");
    RatioFullJet2 ->Draw("HIST");
    gRatioFullJet2->Draw("e2");
    RatioFullJet2 ->Draw("HISTSAME");


    cPlotsI ->SaveAs(dirfigname_pdf + "CSVHistosJet1_" + dirname[ich] + "_Log.pdf");
    cPlotsII->SaveAs(dirfigname_pdf + "CSVHistosJet2_" + dirname[ich] + "_Log.pdf");

    // ttbb Shape

    


  }// for(ich)
  

}
コード例 #20
0
ファイル: ExclusionPlot.C プロジェクト: SusyRa2b/NtupleTools
void CommandMSUGRA(TString plotName_,Int_t tanBeta_, Bool_t plotLO_){
  gROOT->SetStyle("CMS");//jmt specific
  gROOT->ForceStyle();

  gStyle->SetOptTitle(0);
  gStyle->SetOptStat(0);
  gStyle->SetPalette(1); 
  gStyle->SetTextFont(42);
  gStyle->SetFrameBorderMode(0);

  //convert tanb value to string
  std::stringstream tmp;
  tmp << tanBeta_;
  TString tanb( tmp.str() );
  
  
  // Output file
  std::cout << " create " << plotName_ << std::endl;
  TFile* output = new TFile( plotName_, "RECREATE" );
  if ( !output || output->IsZombie() ) { std::cout << " zombie alarm output is a zombie " << std::endl; }
  

  //set old exclusion Limits
  TGraph* LEP_ch = set_lep_ch(tanBeta_);
  TGraph* LEP_sl = set_lep_sl(tanBeta_);//slepton curve
  TGraph* TEV_sg_cdf = set_tev_sg_cdf(tanBeta_);//squark gluino cdf
  TGraph* TEV_sg_d0 = set_tev_sg_d0(tanBeta_);//squark gluino d0
  //  TGraph* TEV_tlp_cdf = set_tev_tlp_cdf(tanBeta_);//trilepton cdf
  //  TGraph* TEV_tlp_d0 = set_tev_tlp_d0(tanBeta_);//trilepton d0
  TGraph* stau   = set_tev_stau(tanBeta_);//stau 
  TGraph* NoEWSB = set_NoEWSB(tanBeta_); 

  TGraph* TEV_sn_d0_1 = set_sneutrino_d0_1(tanBeta_);
  TGraph* TEV_sn_d0_2 = set_sneutrino_d0_2(tanBeta_);

  int nPoints = nSusyGridPoints();
  double m0[nPoints],m12[nPoints],squarkMass[nPoints],gluinoMass[nPoints];

  susyGrid(m0,m12,squarkMass,gluinoMass);

  TGraph2D* squarkMasses = new TGraph2D("squarkMasses","",nPoints,m0,m12,squarkMass);
  TGraph2D* gluinoMasses = new TGraph2D("gluinoMasses","",nPoints,m0,m12,gluinoMass);

  TH2D* gluinoMassPlot = gluinoMasses->GetHistogram();
  TH2D* squarkMassPlot = squarkMasses->GetHistogram();

  //constant ssqquark and gluino lines
  TF1* lnsq[15];
  TF1* lngl[15];

  TGraph* lnsq_40[15];
  TGraph* lngl_40[15];
  
  TLatex* sq_text[15];
  TLatex* gl_text[15];

  TLatex* sq_40_text[15];
  TLatex* gl_40_text[15];

  for(int i = 1; i < 15; i++){
    //lnsq[i] = constant_squark(tanBeta_,i);
    //sq_text[i] = constant_squark_text(i,*lnsq[i],tanBeta_);
    //lngl[i] = constant_gluino(tanBeta_,i);
    //gl_text[i] = constant_gluino_text(i,*lngl[i]);
    lnsq_40[i] = constant_mass(i*250,squarkMasses);
    lngl_40[i] = constant_mass(i*250,gluinoMasses);
    sq_40_text[i] = constant_squark_text_tanBeta40(i*250,lnsq_40[i]);
    gl_40_text[i] = constant_gluino_text_tanBeta40(i*250,lngl_40[i]);;
  }


  //Legends
  TLegend* legst  = makeStauLegend(0.05,tanBeta_);
  TLegend* legNoEWSB  = makeNoEWSBLegend(0.05,tanBeta_);
  TLegend* legexp = makeExpLegend( *TEV_sg_cdf,*TEV_sg_d0,*LEP_ch,*LEP_sl,*TEV_sn_d0_1,0.035,tanBeta_);
  
 
  //make Canvas
  TCanvas* cvsSys = new TCanvas("cvsnm","cvsnm",0,0,800,600);
  gStyle->SetOptTitle(0);
  cvsSys->SetFillColor(0);
  cvsSys->GetPad(0)->SetRightMargin(0.07);
  cvsSys->Range(-120.5298,26.16437,736.0927,750);
  //  cvsSys->Range(-50.5298,26.16437,736.0927,500);
  cvsSys->SetFillColor(0);
  cvsSys->SetBorderMode(0);
  cvsSys->GetPad(0)->SetBorderMode(0);
  cvsSys->GetPad(0)->SetBorderSize(2);
  cvsSys->GetPad(0)->SetLeftMargin(0.1407035);
  cvsSys->GetPad(0)->SetTopMargin(0.08);
  cvsSys->GetPad(0)->SetBottomMargin(0.13);

  cvsSys->SetTitle("tan#beta="+tanb);
 
  output->cd();
  
//and now  the exclusion limits


  TGraph* SSdilep;
  TGraphErrors* OSdilep;
  TGraphErrors* RA1;

  TGraphErrors* RA1_old;
  TGraphErrors* RA5_old;
  TGraphErrors* RA6_old;

  TGraph* RA2b_1b_loose;
  TGraph* RA2b_1b_tight;
  TGraph* RA2b_2b_loose;
  TGraph* RA2b_2b_tight;

  TGraph* RA2b_1b_loose_exp;
  TGraph* RA2b_1b_tight_exp;
  TGraph* RA2b_2b_loose_exp;
  TGraph* RA2b_2b_tight_exp;

  TGraph* RA2b_1b_loose_exp_p;
  TGraph* RA2b_1b_tight_exp_p;
  TGraph* RA2b_2b_loose_exp_p;
  TGraph* RA2b_2b_tight_exp_p;

  TGraph* RA2b_1b_loose_exp_m;
  TGraph* RA2b_1b_tight_exp_m;
  TGraph* RA2b_2b_loose_exp_m;
  TGraph* RA2b_2b_tight_exp_m;

  TGraph* RA2b_1b_loose_shade;
  TGraph* RA2b_1b_tight_shade;
  TGraph* RA2b_2b_loose_shade;
  TGraph* RA2b_2b_tight_shade;

  TSpline3* RA1_tb40 =getCLs1080ObsNLOtb40();

  if (tanBeta_ == 10) {
    SSdilep = SSdilep_NLO();
    OSdilep = OSdilep_NLO();
    RA1 = RA1_NLO();

    RA1_old = getRA1Observed_NLO_tanBeta10();
    RA5_old = getRA5Observed_NLO_tanBeta10();
    RA6_old = getRA6Observed_NLO_tanBeta10();

  }
  if(tanBeta_ == 40)
    {
//       RA2b_1b_loose = RA2b_limit("an-scanplot-unblind-tb40-withcontam-ge1b-loose.root", "hsusyscanExcluded");
//       RA2b_2b_loose = RA2b_limit("an-scanplot-unblind-tb40-withcontam-ge2b-loose.root", "hsusyscanExcluded");
//       RA2b_1b_tight = RA2b_limit("an-scanplot-unblind-tb40-withcontam-ge1b-tight.root", "hsusyscanExcluded");
//       RA2b_2b_tight = RA2b_limit("an-scanplot-unblind-tb40-withcontam-ge2b-tight.root", "hsusyscanExcluded");
//       RA2b_1b_loose = RA2b_limit("/afs/cern.ch/user/o/owen/public/RA2b/clsplots-tb40-ge1bloose.root", "hcls");
//       RA2b_2b_loose = RA2b_limit("/afs/cern.ch/user/o/owen/public/RA2b/clsplots-tb40-ge2bloose.root", "hcls");
//       RA2b_1b_tight = RA2b_limit("/afs/cern.ch/user/o/owen/public/RA2b/clsplots-tb40-ge1btight.root", "hcls");
//       RA2b_2b_tight = RA2b_limit("/afs/cern.ch/user/o/owen/public/RA2b/clsplots-tb40-ge2btight.root", "hcls");

/* 
     TString ra2bfile= "RA2b_tb40_exclusion.25Sep.root";
      RA2b_1b_loose = RA2b_limit(ra2bfile,"curve4_ge1bloose");
      RA2b_1b_tight = RA2b_limit(ra2bfile,"curve4_ge1btight");
      RA2b_2b_loose = RA2b_limit(ra2bfile,"curve4_ge2bloose");
      RA2b_2b_tight = RA2b_limit(ra2bfile,"curve4_ge2btight");

      RA2b_1b_loose_exp = RA2b_limit(ra2bfile,"curve4_1bloose_exp");
      RA2b_1b_tight_exp = RA2b_limit(ra2bfile,"curve4_1btight_exp");
      RA2b_2b_loose_exp = RA2b_limit(ra2bfile,"curve4_2bloose_exp");
      RA2b_2b_tight_exp = RA2b_limit(ra2bfile,"curve4_2btight_exp");

      RA2b_1b_loose_exp_p = RA2b_limit(ra2bfile,"curve4_1bloose_exp_plus");
      RA2b_1b_tight_exp_p = RA2b_limit(ra2bfile,"curve4_1btight_exp_plus");
      RA2b_2b_loose_exp_p = RA2b_limit(ra2bfile,"curve4_2bloose_exp_plus");
      RA2b_2b_tight_exp_p = RA2b_limit(ra2bfile,"curve4_2btight_exp_plus");

      RA2b_1b_loose_exp_m = RA2b_limit(ra2bfile,"curve4_1bloose_exp_minus");
      RA2b_1b_tight_exp_m = RA2b_limit(ra2bfile,"curve4_1btight_exp_minus");
      RA2b_2b_loose_exp_m = RA2b_limit(ra2bfile,"curve4_2bloose_exp_minus");
      RA2b_2b_tight_exp_m = RA2b_limit(ra2bfile,"curve4_2btight_exp_minus");
*/
      RA2b_1b_loose = get_RA2b_1bloose();
      RA2b_1b_tight = get_RA2b_1btight();
      RA2b_2b_loose = get_RA2b_2bloose();
      RA2b_2b_tight = get_RA2b_2btight();

      RA2b_1b_loose_exp = get_RA2b_1bloose_exp();
      RA2b_1b_tight_exp = get_RA2b_1btight_exp();
      RA2b_2b_loose_exp = get_RA2b_2bloose_exp();
      RA2b_2b_tight_exp = get_RA2b_2btight_exp();
    
      RA2b_1b_loose_exp_p = get_RA2b_1bloose_exp_p();
      RA2b_1b_tight_exp_p = get_RA2b_1btight_exp_p();
      RA2b_2b_loose_exp_p = get_RA2b_2bloose_exp_p();
      RA2b_2b_tight_exp_p = get_RA2b_2btight_exp_p();

      RA2b_1b_loose_exp_m = get_RA2b_1bloose_exp_m();
      RA2b_1b_tight_exp_m = get_RA2b_1btight_exp_m();
      RA2b_2b_loose_exp_m = get_RA2b_2bloose_exp_m();
      RA2b_2b_tight_exp_m = get_RA2b_2btight_exp_m();
   
      cout<<"Getting the shaded regions"<<endl;
      RA2b_1b_loose_shade = getShadedRegion(RA2b_1b_loose_exp_p,RA2b_1b_loose_exp_m);
      RA2b_1b_tight_shade = getShadedRegion(RA2b_1b_tight_exp_p,RA2b_1b_tight_exp_m);
      RA2b_2b_loose_shade = getShadedRegion(RA2b_2b_loose_exp_p,RA2b_2b_loose_exp_m);
      RA2b_2b_tight_shade = getShadedRegion(RA2b_2b_tight_exp_p,RA2b_2b_tight_exp_m);
      cout<<"DONE Getting the shaded regions"<<endl;
    }



  double m0min = 0;
  if (tanBeta_ == 40) m0min=400; 
  TH2D* hist = new TH2D("h","h",100,m0min,2000,100,120,700);
  hist->Draw();  
  hist->GetXaxis()->SetTitle("m_{0} [GeV]");
  hist->GetYaxis()->SetTitle("m_{1/2} [GeV]");
  hist->GetXaxis()->SetTitleOffset(.9);
  hist->GetXaxis()->SetTitleSize(0.06);
  hist->GetYaxis()->SetTitleOffset(1.0);
  hist->GetYaxis()->SetTitleSize(0.06);

  hist->GetXaxis()->SetNdivisions(506);
  //  if (tanBeta_ == 50)  hist->GetXaxis()->SetNdivisions(504);
  hist->GetYaxis()->SetNdivisions(506);

  int col[]={2,3,4};

  //SSdilep->SetLineColor(kGreen+2);
  //SSdilep->SetLineStyle(1);
  //SSdilep->SetLineWidth(3);
  //
  //OSdilep->SetLineColor(kCyan+2);
  //OSdilep->SetLineStyle(1);
  //OSdilep->SetLineWidth(3);
  //
  //RA1->SetLineColor(kRed+2);
  //RA1->SetLineStyle(1);
  //RA1->SetLineWidth(3);
  RA1_tb40->SetLineColor(kBlack);
  RA1_tb40->SetLineStyle(7);
  RA1_tb40->SetLineWidth(3);
  RA1_tb40->SetName("RA1_tb40");
  //
  //TSpline3 *sRA1 = new TSpline3("sRA1",RA1_old);
  //sRA1->SetLineColor(kRed+2);
  ////sRA1->SetLineStyle(5);
  //sRA1->SetLineStyle(2);
  //sRA1->SetLineWidth(3);
  //
  //RA5_old->SetLineColor(kGreen+2);
  ////RA5_old->SetLineStyle(5);
  //RA5_old->SetLineStyle(2);
  //RA5_old->SetLineWidth(3);
  //
  //RA6_old->SetLineColor(kCyan+2);
  ////RA6_old->SetLineStyle(1);
  //RA6_old->SetLineStyle(2);
  //RA6_old->SetLineWidth(3);

  if (RA2bmode.Contains("all")) {
  RA2b_1b_loose->SetLineColor(kRed+2);
  RA2b_1b_loose->SetLineStyle(2);
  RA2b_1b_loose->SetLineWidth(3);
         
  RA2b_1b_tight->SetLineColor(kRed+2);
  RA2b_1b_tight->SetLineStyle(1);
  RA2b_1b_tight->SetLineWidth(3);
         
  RA2b_2b_loose->SetLineColor(kGreen+2);
  RA2b_2b_loose->SetLineStyle(2);
  RA2b_2b_loose->SetLineWidth(3);
         
  RA2b_2b_tight->SetLineColor(kGreen+2);
  RA2b_2b_tight->SetLineStyle(1);
  RA2b_2b_tight->SetLineWidth(3);
  }
  else {
  RA2b_1b_loose->SetLineColor(kRed);
  RA2b_1b_loose->SetLineStyle(1);
  RA2b_1b_loose->SetLineWidth(3);
         
  RA2b_1b_tight->SetLineColor(kRed);
  RA2b_1b_tight->SetLineStyle(1);
  RA2b_1b_tight->SetLineWidth(3);
         
  RA2b_2b_loose->SetLineColor(kRed);
  RA2b_2b_loose->SetLineStyle(1);
  RA2b_2b_loose->SetLineWidth(3);
         
  RA2b_2b_tight->SetLineColor(kRed);
  RA2b_2b_tight->SetLineStyle(1);
  RA2b_2b_tight->SetLineWidth(3);

  RA2b_1b_loose_exp->SetLineColor(kBlue);
  RA2b_2b_loose_exp->SetLineColor(kBlue);
  RA2b_1b_tight_exp->SetLineColor(kBlue);
  RA2b_2b_tight_exp->SetLineColor(kBlue);

  RA2b_1b_loose_exp->SetLineStyle(5);
  RA2b_2b_loose_exp->SetLineStyle(5);
  RA2b_1b_tight_exp->SetLineStyle(5);
  RA2b_2b_tight_exp->SetLineStyle(5);

  RA2b_1b_loose_exp->SetLineWidth(3);
  RA2b_2b_loose_exp->SetLineWidth(3);
  RA2b_1b_tight_exp->SetLineWidth(3);
  RA2b_2b_tight_exp->SetLineWidth(3);

  int acolor=kCyan+2;
  RA2b_1b_loose_exp_p->SetLineColor(acolor);
  RA2b_2b_loose_exp_p->SetLineColor(acolor);
  RA2b_1b_tight_exp_p->SetLineColor(acolor);
  RA2b_2b_tight_exp_p->SetLineColor(acolor);

  RA2b_1b_loose_exp_p->SetLineStyle(1);
  RA2b_2b_loose_exp_p->SetLineStyle(1);
  RA2b_1b_tight_exp_p->SetLineStyle(1);
  RA2b_2b_tight_exp_p->SetLineStyle(1);

  RA2b_1b_loose_exp_p->SetLineWidth(3);
  RA2b_2b_loose_exp_p->SetLineWidth(3);
  RA2b_1b_tight_exp_p->SetLineWidth(3);
  RA2b_2b_tight_exp_p->SetLineWidth(3);

  RA2b_1b_loose_exp_m->SetLineColor(acolor);
  RA2b_2b_loose_exp_m->SetLineColor(acolor);
  RA2b_1b_tight_exp_m->SetLineColor(acolor);
  RA2b_2b_tight_exp_m->SetLineColor(acolor);

  RA2b_1b_loose_exp_m->SetLineStyle(1);
  RA2b_2b_loose_exp_m->SetLineStyle(1);
  RA2b_1b_tight_exp_m->SetLineStyle(1);
  RA2b_2b_tight_exp_m->SetLineStyle(1);

  RA2b_1b_loose_exp_m->SetLineWidth(3);
  RA2b_2b_loose_exp_m->SetLineWidth(3);
  RA2b_1b_tight_exp_m->SetLineWidth(3);
  RA2b_2b_tight_exp_m->SetLineWidth(3);

  RA2b_1b_tight_shade->SetFillStyle(fillstyle);
  RA2b_1b_tight_shade->SetFillColor(acolor);

  RA2b_1b_loose_shade->SetFillStyle(fillstyle);
  RA2b_1b_loose_shade->SetFillColor(acolor);

  RA2b_2b_tight_shade->SetFillStyle(fillstyle);
  RA2b_2b_tight_shade->SetFillColor(acolor);

  RA2b_2b_loose_shade->SetFillStyle(fillstyle);
  RA2b_2b_loose_shade->SetFillColor(acolor);

  }
  
  TLegend* myleg;

  float leg_x1=0.39+0.23;
  float leg_y1=0.65+0.05;
  float leg_x2= 0.55+0.25;
  float leg_y2= 0.84+0.05;

  if (RA2bmode.Contains("all")) {
    leg_y1 -= 0.1;
  }

  if( plotLO_ ) myleg = new TLegend(0.3,0.65,0.65,0.8,NULL,"brNDC");
  else          myleg = new TLegend(leg_x1,leg_y1,leg_x2,leg_y2,NULL,"brNDC");


  myleg->SetFillColor(0); 
  myleg->SetShadowColor(0);
  myleg->SetTextSize(0.04);
  myleg->SetBorderSize(0);

  TLegendEntry *entry=0;
//   entry= myleg->AddEntry("ge1bLoose","LEP2 #tilde{#chi}_{1}^{#pm}","f");

//   entry->SetFillColor(3);
//   entry->SetLineColor(3);
//   entry->SetFillStyle(1001);


  if (RA2bmode.Contains("all")) {
    entry= myleg->AddEntry("ge1bLoose","#geq 1b Loose","l");
    entry->SetLineColor(1);
    entry->SetLineStyle(2);
    entry->SetLineWidth(3);
    entry->SetLineColor(kRed+2);
    entry->SetTextColor(kRed+2);
    
    entry=myleg->AddEntry("ge2bLoose","#geq 2b Loose","l");
    entry->SetLineColor(1);
    entry->SetLineStyle(2);
    entry->SetLineWidth(3);
    entry->SetLineColor(kGreen+2);
    entry->SetTextColor(kGreen+2);
    
    entry=myleg->AddEntry("ge1bTight","#geq 1b Tight","l");
    entry->SetLineColor(1);
    entry->SetLineStyle(1);
    entry->SetLineWidth(3);
    entry->SetLineColor(kRed+2);
    entry->SetTextColor(kRed+2);
    
    entry=myleg->AddEntry("ge2bTight","#geq 2b Tight","l");
    entry->SetLineColor(1);
    entry->SetLineStyle(1);
    entry->SetLineWidth(3);
    entry->SetLineColor(kGreen+2);
    entry->SetTextColor(kGreen+2);
  }
  else if (RA2bmode.Contains("ge")) {
    entry=myleg->AddEntry("ge1bTight","Observed Limit","l");
    entry->SetLineStyle(1);
    entry->SetLineWidth(3);
    entry->SetLineColor(kRed);
    entry->SetTextColor(kBlack);

    entry=myleg->AddEntry("ge1bTight_exp","Expected Limit #pm 1#sigma","lf");
    entry->SetFillStyle (fillstyle);
    entry->SetFillColor (kCyan+2);
    entry->SetLineStyle(5);
    entry->SetLineWidth(3);
    entry->SetLineColor(kBlue);
    entry->SetTextColor(kBlack);


  }
  
   if (RA2bmode=="allPlusRA1") {
    entry=myleg->AddEntry("RA1_tb40","CMS #alpha_{T}","l");
    entry->SetLineColor(kBlack);
    entry->SetLineStyle(7);
    entry->SetLineWidth(3);
    entry->SetTextColor(kBlack);
   }  

  //constant squark and gluino mass contours
  for (int it=2;it<9;it++) {  
    if(it<7){
      if(lngl_40[it]!=0)lngl_40[it]->Draw("samec");   
      if(gl_40_text[it]!=0)gl_40_text[it]->Draw();
    }
      if(lnsq_40[it]!=0)lnsq_40[it]->Draw("samec");
    if(it<6){
      if(sq_40_text[it]!=0)sq_40_text[it]->Draw();
    }
  }
  //SSdilep->Draw("samec");
  //OSdilep->Draw("samec");
  //RA1->Draw("samec");
  //
  //sRA1->Draw("same"); 
  //RA5_old->Draw("c same");
  //RA6_old->Draw("c same");
  TString drawopt="samel"; //default choice
  if (RA2bmode.Contains("all"))  RA2b_1b_loose->Draw(drawopt);
  if (RA2bmode.Contains("all")) RA2b_2b_loose->Draw(drawopt);
  if (RA2bmode.Contains("all")) RA2b_1b_tight->Draw(drawopt);
  if (RA2bmode.Contains("all")) RA2b_2b_tight->Draw(drawopt);
  if (RA2bmode=="allPlusRA1") RA1_tb40->Draw(drawopt);

  if (RA2bmode=="ge1btight") {
    RA2b_1b_tight_shade->Draw("f");
    RA2b_1b_tight_exp_p->Draw(drawopt);
    RA2b_1b_tight_exp_m->Draw(drawopt);
    RA2b_1b_tight_exp->Draw(drawopt);
    RA2b_1b_tight->Draw(drawopt);
  }
  else if (RA2bmode=="ge1bloose") {
    RA2b_1b_loose_shade->Draw("f");
    RA2b_1b_loose_exp_p->Draw(drawopt);
    RA2b_1b_loose_exp_m->Draw(drawopt);
    RA2b_1b_loose_exp->Draw(drawopt);
    RA2b_1b_loose->Draw(drawopt);
  }
  else if (RA2bmode=="ge2bloose") {
    RA2b_2b_loose_shade->Draw("f");
    RA2b_2b_loose_exp_p->Draw(drawopt);
    RA2b_2b_loose_exp_m->Draw(drawopt);
    RA2b_2b_loose_exp->Draw(drawopt);
    RA2b_2b_loose->Draw(drawopt);
  }
  else if (RA2bmode=="ge2btight") {
    RA2b_2b_tight_shade->Draw("f");
    RA2b_2b_tight_exp_p->Draw(drawopt);
    RA2b_2b_tight_exp_m->Draw(drawopt);
    RA2b_2b_tight_exp->Draw(drawopt);
    RA2b_2b_tight->Draw(drawopt);
  }
  //
  //
  //TLatex* RA1label = new TLatex(670,430.,"#alpha_{T}");
  ////TLatex* RA1label = new TLatex(80,288.,"#alpha_{T}");
  //RA1label->SetTextFont(42);
  //RA1label->SetTextSize(0.05);
  //RA1label->SetTextColor(kRed+2);
  //RA1label->Draw("same");

  TLatex* RA2blabel_2b=0;
  TLatex* RA2blabel_1b=0;
  if (false) {
    RA2blabel_2b = new TLatex(1150,330.,"#geq 2 b-tags");
    RA2blabel_2b->SetTextFont(42);
    RA2blabel_2b->SetTextSize(0.05);
    RA2blabel_2b->SetTextColor(kGreen+2);
    RA2blabel_2b->Draw("same");
    
    RA2blabel_1b = new TLatex(1150,430.,"#geq 1 b-tags");
    RA2blabel_1b->SetTextFont(42);
    RA2blabel_1b->SetTextSize(0.05);
    RA2blabel_1b->SetTextColor(kRed+2);
    RA2blabel_1b->Draw("same");
  }
  //
  //TLatex* RA5label = new TLatex(400,370.,"SS Dilepton");
  //RA5label->SetTextFont(42);
  ////RA5label->SetTextAngle(20);
  //RA5label->SetTextSize(0.04);
  //RA5label->SetTextColor(kGreen+2);
  //RA5label->Draw("same");
  //
  //TLatex* RA6label = new TLatex(650,215.,"OS Dilepton");
  //RA6label->SetTextFont(42);
  ////RA6label->SetTextAngle(8);
  //RA6label->SetTextSize(0.04);
  //RA6label->SetTextColor(kCyan+2);
  //RA6label->Draw("same");
  
  
  //exclusion limits previous experiments
  if(tanBeta_ == 3){
    TEV_sn_d0_1->Draw("fsame");
    TEV_sn_d0_2->Draw("fsame");
  }
  //  LEP_ch->Draw("fsame");
  if (tanBeta_ != 40) LEP_sl->Draw("fsame");

  //remove CDF/D0 excluded regions
  //  TEV_sg_cdf->Draw("fsame");
  //  TEV_sg_d0->Draw("same");  
  //  TEV_sg_d0->Draw("fsame");


  //other labels
  Double_t xpos = 0;
  Double_t xposi = 0;
  Double_t ypos = 0;
  if(tanBeta_ == 40) xposi = 180+160;
  if(tanBeta_ == 40) xpos = 400;//240;
  if(tanBeta_ == 40) ypos = -10;
  
  //TLatex* lumilabel = new TLatex(750 +xposi + 100,767.-154,"#sqrt{s} = 7 TeV, #scale[0.65]{#int}Ldt = 0.98 fb^{-1}");
  TLatex* lumilabel = new TLatex(925+xpos-50,767.-154+105,"#sqrt{s} = 7 TeV, L_{int} = 1.1 fb^{-1}");
  TLatex* integral_symbol = new TLatex(1287 +xposi + 100-85,767.-145+95,"#int");

  lumilabel->SetTextSize(0.05);
  integral_symbol->SetTextSize(0.03);
  lumilabel->Draw("same");
  //  integral_symbol->Draw("same");

  TLatex* cmslabel = new TLatex(10.+xpos,767.-154+105,"CMS Preliminary");
  cmslabel->SetTextSize(0.05);
  cmslabel->Draw("same");

  TString text_tanBeta;
  text_tanBeta =  "tan#beta = "+tanb+",  A_{0} = -500 GeV,  #mu > 0";
  TLatex* cmssmpars = new TLatex(/*530.+xpos,690.+ypos-130*/150+xpos,660,text_tanBeta);

  cmssmpars->SetTextSize(0.04);
  cmssmpars->Draw("same");

  TLatex* lep_chargino = new TLatex(250,135,"LEP2 #tilde{#chi}_{1}^{#pm}");
  lep_chargino->SetTextSize(0.03);
  lep_chargino->SetTextFont(42);
  //    lep_chargino->Draw("same");

  TLatex* lep_slepton = new TLatex(26,190,"LEP2 #tilde{#font[12]{l}}^{#pm}");
  lep_slepton->SetTextSize(0.03);
  lep_slepton->SetTextAngle(-83);
  lep_slepton->SetTextFont(42);
  //  lep_slepton->Draw("same");



  //LM points
  TMarker* LM0 = new TMarker(200.,160.,20);
  TMarker* LM1 = new TMarker(60.,250.,20);
  TMarker* LM3 = new TMarker(330.,240.,20);
  TMarker* LM6 = new TMarker(80.,400.,20);
    
  LM0->SetMarkerSize(1.2);
  LM1->SetMarkerSize(1.2);
    
  TLatex* tLM0 = new TLatex(205.,160.," LM0");
  tLM0->SetTextSize(0.035);
    
  TLatex* tLM1 = new TLatex(80.,245.,"LM1");
  tLM1->SetTextSize(0.035);
  
  //TLatex* tLM3 = new TLatex(350.,235.,"LM3 (tan#beta=20)");
  TLatex* tLM3 = new TLatex(350.,235.,"LM3");
  tLM3->SetTextSize(0.035);
  
  TLatex* tLM6 = new TLatex(100.,395.,"LM6");
  tLM6->SetTextSize(0.035);
  
  //  if (tanBeta_ != 50){
  //  LM0->Draw("same");   
  //  tLM0->Draw("same");
  //  LM1->Draw("same");   
  //  tLM1->Draw("same");
  // }

  /*
  if (tanBeta_ == 10){ 
    LM1->Draw("same");
    tLM1->Draw("same");
    LM3->Draw("same");
    tLM3->Draw("same");
    LM6->Draw("same");
    tLM6->Draw("same");
  }
  */



  //stau=LSP contour
  stau->Draw("fsame");
  //  NoEWSB->Draw("fsame");
 
  //legends
  //  legexp->Draw();
  //  legst->Draw();
  //legNoEWSB->Draw();
    myleg->Draw();

  hist->Draw("sameaxis");
  cvsSys->RedrawAxis();
  cvsSys->Update();
  cvsSys->Write();
  
  if( plotLO_ ){
    cvsSys->SaveAs("ExclusionLimit_tanb"+tanb+"_LO.pdf");
    cvsSys->SaveAs("ExclusionLimit_tanb"+tanb+"_LO.png");
  }else{
    cvsSys->SaveAs("ExclusionLimit_tanb"+tanb+"_"+RA2bmode+".eps");
    cvsSys->SaveAs("ExclusionLimit_tanb"+tanb+"_"+RA2bmode+".pdf");
    cvsSys->SaveAs("ExclusionLimit_tanb"+tanb+"_"+RA2bmode+".png");
  }
  
  output->Write();
  //output->Close();
  //delete output; 
  
}
コード例 #21
0
ファイル: DeltaPhiPhoMETMax.C プロジェクト: camendola/macro
void DeltaPhiPhoMETMax(double pt1_cutIN,double pt2_cutIN,double MET_cutIN, double DPHI_cutIN){
  cout<<"#### Max[DeltaPhi(MET,pho1),DeltaPhi(MET,pho2)] #####"<<endl;


 

  gStyle->SetPadTickY(1);
  gStyle->SetPadTickX(1);
  TLegend* leg = new TLegend(0.13,0.55,0.68,0.87);
  leg->SetNColumns(2);
  leg->SetBorderSize(0);
  leg->SetFillStyle(0);
  TLegend* leg_norm = new TLegend(0.13,0.5,0.7,0.87);
  leg_norm->SetNColumns(2);
  leg_norm->SetBorderSize(0);
  leg_norm->SetFillStyle(0);


  TCanvas *canvas = new TCanvas("c1n","",1100,500);
  canvas->Divide(2,1);
  canvas->cd(1);

  TCut mggmax = "mgg<180";
  TCut mggmin = "mgg>100";
  TCut mggblind = "((mgg<115)||(mgg>135))";
  TCut eveto1 = "eleveto1 == 1";
  TCut eveto2 = "eleveto2 == 1";
  TCut eveto = eveto1 && eveto2;
  TCut genmatch = "((genmatch1==1 && genmatch2==0)||(genmatch1==0 && genmatch2==1)||(genmatch1==0 && genmatch2==0))";  
  TCut metF = "((metF_GV==1) && (metF_HBHENoise==1) && (metF_HBHENoiseIso==1) && (metF_CSC==1) && (metF_eeBadSC==1))";  
  TCut pt1cut = Form("pt1/mgg>%lf",pt1_cutIN);
  TCut pt2cut = Form("pt2/mgg>%lf",pt2_cutIN);  
  TCut METcut = Form("t1pfmet>%lf",MET_cutIN);  
  TCut DPHIcut = Form("FDelta(pt1,eta1,phi1,0.,pt2,eta2,phi2,0.,t1pfmetPhi)>%lf",DPHI_cutIN);  
  TCut NegWeight = "weight>0.";
  
 

  TFile *data = TFile::Open("./25ns_2246inv_v3/DoubleEG.root","READ");  
  TFile *sig1 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP600.root","READ");
  TFile *sig2 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP800.root","READ");
  TFile *sig3 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1000.root","READ");
  TFile *sig4 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1200.root","READ");
  TFile *sig5 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1400.root","READ");  
  TFile *sig6 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP1700.root","READ");  
  TFile *sig7 = TFile::Open("./25ns_2246inv_v3/2HDM_mZP2500.root","READ");  

 
  TFile *bkg1 =  TFile::Open("./25ns_2246inv_v3/DiPhoton.root","READ");  
  TFile *bkg2 =  TFile::Open("./25ns_2246inv_v3/DYJetsToLL.root","READ");  
  TFile *bkg3 =  TFile::Open("./25ns_2246inv_v3/GJets.root","READ");  
  TFile *bkg4 =  TFile::Open("./25ns_2246inv_v3/GluGluHToGG.root","READ");  
  TFile *bkg5 =  TFile::Open("./25ns_2246inv_v3/QCD.root","READ");  
  TFile *bkg6 =  TFile::Open("./25ns_2246inv_v3/VH.root","READ");  
  TFile *bkg7 =  TFile::Open("./25ns_2246inv_v3/ttHJetToGG.root","READ");
  TFile *bkg8 =  TFile::Open("./25ns_2246inv_v3/VBFHToGG.root","READ");
  TFile *bkg9 =  TFile::Open("./25ns_2246inv_v3/TGJets.root","READ");
  TFile *bkg10 =  TFile::Open("./25ns_2246inv_v3/TTGJets.root","READ");
  TFile *bkg11 =  TFile::Open("./25ns_2246inv_v3/WGToLNuG.root","READ");
  TFile *bkg12 =  TFile::Open("./25ns_2246inv_v3/ZGTo2LG.root","READ");
  
  
  TTree *tree_data = (TTree*) data->Get("DiPhotonTree");
  
  TTree *tree_sig1 = (TTree*) sig1->Get("DiPhotonTree");
  TTree *tree_sig2 = (TTree*) sig2->Get("DiPhotonTree");
  TTree *tree_sig3 = (TTree*) sig3->Get("DiPhotonTree");
  TTree *tree_sig4 = (TTree*) sig4->Get("DiPhotonTree");
  TTree *tree_sig5 = (TTree*) sig5->Get("DiPhotonTree");
  TTree *tree_sig6 = (TTree*) sig6->Get("DiPhotonTree");
  TTree *tree_sig7 = (TTree*) sig7->Get("DiPhotonTree");
  
  
  TTree *tree_bkg1 = (TTree*) bkg1->Get("DiPhotonTree");
  TTree *tree_bkg2 = (TTree*) bkg2->Get("DiPhotonTree");
  TTree *tree_bkg3 = (TTree*) bkg3->Get("DiPhotonTree");
  TTree *tree_bkg4 = (TTree*) bkg4->Get("DiPhotonTree");
  TTree *tree_bkg5 = (TTree*) bkg5->Get("DiPhotonTree");
  TTree *tree_bkg6 = (TTree*) bkg6->Get("DiPhotonTree");
  TTree *tree_bkg7 = (TTree*) bkg7->Get("DiPhotonTree");
  TTree *tree_bkg8 = (TTree*) bkg8->Get("DiPhotonTree");
  TTree *tree_bkg9 = (TTree*) bkg9->Get("DiPhotonTree");
  TTree *tree_bkg10 = (TTree*) bkg10->Get("DiPhotonTree");
  TTree *tree_bkg11 = (TTree*) bkg11->Get("DiPhotonTree");
  TTree *tree_bkg12 = (TTree*) bkg12->Get("DiPhotonTree");

  
  tree_data->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hdata(25,0,3.5)",(mggblind && mggmax && mggmin && metF && eveto && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *hdata =(TH1F*)gPad->GetPrimitive("hdata");
  hdata->SetMarkerColor(kBlack);
  hdata->SetMarkerStyle(20);
  hdata->SetLineColor(kBlack);
    
 
 
  
  tree_sig1->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h1(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *h1 =(TH1F*)gPad->GetPrimitive("h1");
  tree_sig2->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h2(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *h2 =(TH1F*)gPad->GetPrimitive("h2");
  tree_sig3->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h3(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *h3 =(TH1F*)gPad->GetPrimitive("h3");
  tree_sig4->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h4(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *h4 =(TH1F*)gPad->GetPrimitive("h4");
  tree_sig5->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h5(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *h5 =(TH1F*)gPad->GetPrimitive("h5");
  tree_sig6->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h6(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *h6 =(TH1F*)gPad->GetPrimitive("h6");
  tree_sig7->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h7(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *h7 =(TH1F*)gPad->GetPrimitive("h7");
 
  tree_bkg1->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg1(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *hbkg1 =(TH1F*)gPad->GetPrimitive("hbkg1");
  tree_bkg2->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg2(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));  
  TH1F *hbkg2 =(TH1F*)gPad->GetPrimitive("hbkg2");
  tree_bkg3->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg3(25,0,3.5)","weight"*(mggmax && mggmin && eveto && genmatch && pt1cut && pt2cut && METcut&& DPHIcut));  
  TH1F *hbkg3 =(TH1F*)gPad->GetPrimitive("hbkg3");
  tree_bkg4->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg4(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples
  TH1F *hbkg4 =(TH1F*)gPad->GetPrimitive("hbkg4");
  tree_bkg5->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg5(25,0,3.5)","weight"*(mggmax && mggmin && eveto && genmatch && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *hbkg5 =(TH1F*)gPad->GetPrimitive("hbkg5");
  tree_bkg6->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg6(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));   //weight also on BR = 0.002 if using 50ns samples
  TH1F *hbkg6 =(TH1F*)gPad->GetPrimitive("hbkg6");
  tree_bkg7->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg7(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));  //weight also on BR = 0.002 if using 50ns samples   
   TH1F *hbkg7 =(TH1F*)gPad->GetPrimitive("hbkg7");
    tree_bkg8->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg8(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));  //weight also on BR = 0.002 if using 50ns samples  
   TH1F *hbkg8 =(TH1F*)gPad->GetPrimitive("hbkg8");

    tree_bkg9->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg9(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut && NegWeight));  //weight also on BR = 0.002 if using 50ns samples  
   TH1F *hbkg9 =(TH1F*)gPad->GetPrimitive("hbkg9");
    tree_bkg10->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg10(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));  //weight also on BR = 0.002 if using 50ns samples  
   TH1F *hbkg10 =(TH1F*)gPad->GetPrimitive("hbkg10");
    tree_bkg11->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg11(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));  //weight also on BR = 0.002 if using 50ns samples  
   TH1F *hbkg11 =(TH1F*)gPad->GetPrimitive("hbkg11");
    tree_bkg12->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg12(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));  //weight also on BR = 0.002 if using 50ns samples  
   TH1F *hbkg12 =(TH1F*)gPad->GetPrimitive("hbkg12");

 
 


  /*  h1->Scale(0.00009338);
  h2->Scale(0.00010348);
  h3->Scale(0.00008394);
  h4->Scale(0.00006352);
  h5->Scale(0.00004712);
  h6->Scale(0.00003020);
  h7->Scale(0.00000972);
  */


  h1->SetLineColor(kRed+3);
  h2->SetLineColor(kRed+1);
  h3->SetLineColor(kRed);
  h4->SetLineColor(kPink+2);
  h5->SetLineColor(kPink+4); //only for 25ns samples
  h6->SetLineColor(kPink+7); //only for 25ns samples
  h7->SetLineColor(kMagenta+2); //only for 25ns samples
  h1->SetLineWidth(2);
  h2->SetLineWidth(2);
  h3->SetLineWidth(2);
  h4->SetLineWidth(2);
  h5->SetLineWidth(2); //only for 25ns samples
  h6->SetLineWidth(2); //only for 25ns samples
  h7->SetLineWidth(2); //only for 25ns samples
  
  





  
  
   THStack *hs=new THStack("hs","");
 
   hbkg7->SetFillColor(kGreen+2);
   hbkg6->SetFillColor(kGreen);
   hbkg8->SetFillColor(kYellow);
   hbkg4->SetFillColor(kOrange);
   hbkg9->SetFillColor(kOrange+7);
   hbkg10->SetFillColor(kOrange+4);
   hbkg11->SetFillColor(kCyan);
   hbkg12->SetFillColor(kCyan+1);
   hbkg5->SetFillColor(kBlue+3);
   hbkg2->SetFillColor(kBlue);
   hbkg3->SetFillColor(kMagenta-2);
   hbkg1->SetFillColor(kViolet);





  hbkg1->SetLineColor(kBlack);
  hbkg2->SetLineColor(kBlack);
  hbkg3->SetLineColor(kBlack);
  hbkg4->SetLineColor(kBlack);
  hbkg5->SetLineColor(kBlack);
  hbkg6->SetLineColor(kBlack);
  hbkg7->SetLineColor(kBlack);
  hbkg8->SetLineColor(kBlack);
  hbkg9->SetLineColor(kBlack);
  hbkg10->SetLineColor(kBlack);
  hbkg11->SetLineColor(kBlack);
  hbkg12->SetLineColor(kBlack);
 
  hs->Add(hbkg7);
  hs->Add(hbkg6);
  hs->Add(hbkg8);
  hs->Add(hbkg4);
  hs->Add(hbkg9);
  hs->Add(hbkg10);
  hs->Add(hbkg11);
  hs->Add(hbkg12);
  hs->Add(hbkg2);
  hs->Add(hbkg5);
  hs->Add(hbkg3);
  hs->Add(hbkg1);
  
  
  
  
  TH1F *hsum = (TH1F*)hbkg1->Clone("hsum"); 
  hsum->Add(hbkg2);
  hsum->Add(hbkg3);
  hsum->Add(hbkg4);
  hsum->Add(hbkg5);
  hsum->Add(hbkg6);
  hsum->Add(hbkg7);
  hsum->Add(hbkg8);
  hsum->Add(hbkg9);
  hsum->Add(hbkg10);
  hsum->Add(hbkg11);
  hsum->Add(hbkg12);  
//  hs->SetMaximum(700);
  // hs->SetMinimum(0.0001);
  hdata->SetTitle("");
  hdata->Draw("e1"); 

  hsum->SetMarkerStyle(1);
  hsum->SetFillColor(kGray+3);
  hsum->SetFillStyle(3001);
  
  hs->Draw("same hist");
  hsum->Draw("same e2");
  h2->Draw("same hist");
  h3->Draw("same hist"); 
  h4->Draw("same hist");
  h1->Draw("same hist");
  h5->Draw("same hist"); //only for 25ns samples
  h6->Draw("same hist"); //only for 25ns samples
  h7->Draw("same hist"); //only for 25ns samples
  hdata->Draw("same e1");  
  
  hdata->GetXaxis()->SetTitle("max[|#Delta#phi(#gamma_{1},MET)|,|#Delta#phi(#gamma_{2},MET)|]");
  hdata->GetYaxis()->SetTitleOffset(1.2);
  hdata->GetYaxis()->SetTitle("Events/0.1 GeV");  
  gPad->Modified();
  
  

  /*leg->AddEntry(h1,"m_{#chi} = 1 GeV","l");
    leg->AddEntry(h2,"m_{#chi} = 10 GeV","l");
    leg->AddEntry(h3,"m_{#chi} = 100 GeV","l");      
    leg->AddEntry(h4,"m_{#chi} = 1000 GeV","l");*/
  leg->AddEntry(hdata,"Data","elp"); 
  leg->AddEntry(h1,"m_{Z'} = 600 GeV","l");
  leg->AddEntry(hbkg1,"#gamma #gamma","f");         
  leg->AddEntry(h2,"m_{Z'} = 800 GeV","l");
  leg->AddEntry(hbkg2,"Drell Yann","f");       
  leg->AddEntry(h3,"m_{Z'} = 1000 GeV","l");      
  leg->AddEntry(hbkg3,"#gamma + Jets","f");      
  leg->AddEntry(h4,"m_{Z'} = 1200 GeV","l");     
  leg->AddEntry(hbkg5,"QCD","f");    
  leg->AddEntry(h5,"m_{Z'} = 1400 GeV","l"); //only for 25ns samples    
  leg->AddEntry(hbkg4,"ggH","f");      
  leg->AddEntry(h6,"m_{Z'} = 1700 GeV","l"); //only for 25ns samples    
  leg->AddEntry(hbkg6,"VH","f");  
  leg->AddEntry(h7,"m_{Z'} = 2500 GeV","l"); //only for 25ns samples      
  leg->AddEntry(hbkg7,"ttH","f");  
  leg->AddEntry(hbkg8,"VBF H","f");
  leg->AddEntry(hbkg9,"t + #gamma + Jets","f");
  leg->AddEntry(hbkg10,"tt + #gamma +Jets","f");
  leg->AddEntry(hbkg11,"#gamma+W","f");
  leg->AddEntry(hbkg12,"#gamma+Z","f");
  leg->AddEntry(hsum,"Bkg uncertainty","f");
  leg->Draw("same");
  
  gStyle->SetOptStat(0);  
  

  tree_data->Scan("event:lumi:run:t1pfmet",(mggblind && METcut && metF && pt1cut && pt2cut)*"max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>2.5");


  canvas->cd(2);
  
  

  tree_sig1->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h1_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *h1_norm =(TH1F*)gPad->GetPrimitive("h1_norm");
  tree_sig2->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h2_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *h2_norm =(TH1F*)gPad->GetPrimitive("h2_norm");
  tree_sig3->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h3_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *h3_norm =(TH1F*)gPad->GetPrimitive("h3_norm");
  tree_sig4->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h4_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *h4_norm =(TH1F*)gPad->GetPrimitive("h4_norm");
  tree_sig5->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h5_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *h5_norm =(TH1F*)gPad->GetPrimitive("h5_norm");
  tree_sig6->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h6_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *h6_norm =(TH1F*)gPad->GetPrimitive("h6_norm");
  tree_sig7->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>h7_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *h7_norm =(TH1F*)gPad->GetPrimitive("h7_norm");
  




  tree_bkg1->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg1_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *hbkg1_norm =(TH1F*)gPad->GetPrimitive("hbkg1_norm");
  tree_bkg2->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg2_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));  
  TH1F *hbkg2_norm =(TH1F*)gPad->GetPrimitive("hbkg2_norm");
  tree_bkg3->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg3_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && genmatch && pt1cut && pt2cut && METcut&& DPHIcut));  
  TH1F *hbkg3_norm =(TH1F*)gPad->GetPrimitive("hbkg3_norm");
  tree_bkg4->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg4_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut)); //weight also on BR = 0.002 if using 50ns samples
  TH1F *hbkg4_norm =(TH1F*)gPad->GetPrimitive("hbkg4_norm");
  tree_bkg5->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg5_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && genmatch && pt1cut && pt2cut && METcut&& DPHIcut));
  TH1F *hbkg5_norm =(TH1F*)gPad->GetPrimitive("hbkg5_norm");
  tree_bkg6->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg6_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));   //weight also on BR = 0.002 if using 50ns samples
  TH1F *hbkg6_norm =(TH1F*)gPad->GetPrimitive("hbkg6_norm");
  tree_bkg7->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg7_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));  //weight also on BR = 0.002 if using 50ns samples   
   TH1F *hbkg7_norm =(TH1F*)gPad->GetPrimitive("hbkg7_norm");
    tree_bkg8->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg8_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));  //weight also on BR = 0.002 if using 50ns samples  
   TH1F *hbkg8_norm =(TH1F*)gPad->GetPrimitive("hbkg8_norm");
    tree_bkg9->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg9_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut && NegWeight));  //weight also on BR = 0.002 if using 50ns samples  
   TH1F *hbkg9_norm =(TH1F*)gPad->GetPrimitive("hbkg9_norm");
    tree_bkg10->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg10_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));  //weight also on BR = 0.002 if using 50ns samples  
   TH1F *hbkg10_norm =(TH1F*)gPad->GetPrimitive("hbkg10_norm");
    tree_bkg11->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg11_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));  //weight also on BR = 0.002 if using 50ns samples  
   TH1F *hbkg11_norm =(TH1F*)gPad->GetPrimitive("hbkg11_norm");
    tree_bkg12->Draw("max(FDelta(pt1,eta1,phi1,0.,0.,0.,0.,0.,t1pfmetPhi),FDelta(0.,0.,0.,0.,pt2,eta2,phi2,0.,t1pfmetPhi))>>hbkg12_norm(25,0,3.5)","weight"*(mggmax && mggmin && eveto && pt1cut && pt2cut && METcut&& DPHIcut));  //weight also on BR = 0.002 if using 50ns samples  
   TH1F *hbkg12_norm =(TH1F*)gPad->GetPrimitive("hbkg12_norm");



  double norm = 1./h1_norm->Integral();
  h1_norm->Scale(norm);
  norm = 1./h2_norm->Integral();
  h2_norm->Scale(norm);
  norm = 1./h3_norm->Integral();
  h3_norm->Scale(norm);
  norm = 1./h4_norm->Integral();
  h4_norm->Scale(norm);  
  norm = 1./h5_norm->Integral(); //only for 50ns samples
  h5_norm->Scale(norm);  //only for 50ns samples
  norm = 1./h6_norm->Integral(); //only for 50ns samples
  h6_norm->Scale(norm);  //only for 50ns samples
  norm = 1./h7_norm->Integral(); //only for 50ns samples
  h7_norm->Scale(norm);  //only for 50ns samples
  


  norm = 1./hbkg1_norm->Integral();
  hbkg1_norm->Scale(norm);  
  norm = 1./hbkg2_norm->Integral();
  hbkg2_norm->Scale(norm);  
  norm = 1./hbkg3_norm->Integral();
  hbkg3_norm->Scale(norm);  
  norm = 1./hbkg4_norm->Integral();
  hbkg4_norm->Scale(norm);  
  norm = 1./hbkg5_norm->Integral();
  hbkg5_norm->Scale(norm);  
  norm = 1./hbkg6_norm->Integral();
  hbkg6_norm->Scale(norm);  
   norm = 1./hbkg7_norm->Integral();
  hbkg7_norm->Scale(norm);  
    norm = 1./hbkg8_norm->Integral();
  hbkg8_norm->Scale(norm);  
  norm = 1./hbkg9_norm->Integral();
  hbkg9_norm->Scale(norm);
  norm = 1./hbkg10_norm->Integral();
  hbkg10_norm->Scale(norm);
  norm = 1./hbkg11_norm->Integral();
  hbkg11_norm->Scale(norm);
  norm = 1./hbkg12_norm->Integral();
  hbkg12_norm->Scale(norm);
  
  h1_norm->SetLineColor(kRed+3);
  h2_norm->SetLineColor(kRed+1);
  h3_norm->SetLineColor(kRed);
  h4_norm->SetLineColor(kPink+2);
  h5_norm->SetLineColor(kPink+4); //only for 25ns samples
  h6_norm->SetLineColor(kPink+7); //only for 25ns samples
  h7_norm->SetLineColor(kMagenta+2); //only for 25ns samples
  h1_norm->SetLineWidth(2);
  h2_norm->SetLineWidth(2);
  h3_norm->SetLineWidth(2);
  h4_norm->SetLineWidth(2);
  h5_norm->SetLineWidth(2); //only for 25ns samples
  h6_norm->SetLineWidth(2); //only for 25ns samples
  h7_norm->SetLineWidth(2); //only for 25ns samples

 


  hbkg7_norm->SetLineColor(kGreen+2);
  hbkg6_norm->SetLineColor(kGreen);
  hbkg8_norm->SetLineColor(kYellow);
  hbkg4_norm->SetLineColor(kOrange);
  hbkg9_norm->SetLineColor(kOrange+7);
  hbkg10_norm->SetLineColor(kOrange+4);
  hbkg11_norm->SetLineColor(kCyan);
  hbkg12_norm->SetLineColor(kCyan+1);
  hbkg5_norm->SetLineColor(kBlue+3);
  hbkg2_norm->SetLineColor(kBlue);
  hbkg3_norm->SetLineColor(kMagenta-2);
  hbkg1_norm->SetLineColor(kViolet);
  
  hbkg1_norm->SetFillStyle(0);
  hbkg2_norm->SetFillStyle(0);
  hbkg3_norm->SetFillStyle(0);
  hbkg4_norm->SetFillStyle(0);
  hbkg5_norm->SetFillStyle(0);
  hbkg6_norm->SetFillStyle(0);
   hbkg7_norm->SetFillStyle(0); 
  hbkg8_norm->SetFillStyle(0);
  hbkg9_norm->SetFillStyle(0);
  hbkg10_norm->SetFillStyle(0);
  hbkg11_norm->SetFillStyle(0);
  hbkg12_norm->SetFillStyle(0); 
 
  
  h1_norm->SetTitle("");

  h1_norm->SetMaximum(1);  
  h1_norm->SetMinimum(0.001);  
  h1_norm->Draw("HIST"); 
  
  hbkg1_norm->Draw("same HIST");  
  hbkg2_norm->Draw("same HIST"); 
  hbkg3_norm->Draw("same HIST"); 
  hbkg5_norm->Draw("same HIST"); 
  hbkg4_norm->Draw("same HIST"); 
  hbkg6_norm->Draw("same HIST"); 
  hbkg7_norm->Draw("same HIST"); 
  hbkg8_norm->Draw("same HIST"); 
  hbkg9_norm->Draw("same HIST");
  hbkg10_norm->Draw("same HIST");
  hbkg11_norm->Draw("same HIST");
  hbkg12_norm->Draw("same HIST"); 
  h1_norm->Draw("same hist"); 
  h2_norm->Draw("same hist");
  h3_norm->Draw("same hist"); 
  h4_norm->Draw("same hist");
  h5_norm->Draw("same hist");
  h6_norm->Draw("same hist");
  h7_norm->Draw("same hist");

  h1_norm->GetXaxis()->SetTitle("max[|#Delta#phi(#gamma_{1},MET)|,|#Delta#phi(#gamma_{2},MET)|]");
  h1_norm->GetYaxis()->SetTitle("Normalized events");  
  h1_norm->GetYaxis()->SetTitleOffset(1.2);  
  gPad->Modified();
  gStyle->SetOptStat(0);
  
  
  
  
  leg_norm->AddEntry(h1_norm,"m_{Z'} = 600 GeV","l");
  leg_norm->AddEntry(hbkg1_norm,"#gamma #gamma","l");      
  leg_norm->AddEntry(h2_norm,"m_{Z'} = 800 GeV","l");
  leg_norm->AddEntry(hbkg2_norm,"Drell Yann","l");      
  leg_norm->AddEntry(h3_norm,"m_{Z'} = 1000 GeV","l");      
  leg_norm->AddEntry(hbkg3_norm,"#gamma + Jets","l");      
  leg_norm->AddEntry(h4_norm,"m_{Z'} = 1200 GeV","l");    
  leg_norm->AddEntry(hbkg5_norm,"QCD","l");     
  leg_norm->AddEntry(h5_norm,"m_{Z'} = 1400 GeV","l"); //only for 25ns samples    
  leg_norm->AddEntry(hbkg4_norm,"ggH","l");      
  leg_norm->AddEntry(h6_norm,"m_{Z'} = 1700 GeV","l"); //only for 25ns samples    
  leg_norm->AddEntry(hbkg6_norm,"VH","l");   
  leg_norm->AddEntry(h7_norm,"m_{Z'} = 2500 GeV","l"); //only for 25ns samples      
    leg_norm->AddEntry(hbkg7_norm,"ttH","l");  
    leg_norm->AddEntry(hbkg8_norm,"VBF H","l");   
    leg_norm->AddEntry(hbkg9_norm,"t + #gamma + Jets","l");
    leg_norm->AddEntry(hbkg10_norm,"tt + #gamma +Jets","l");
    leg_norm->AddEntry(hbkg11_norm,"#gamma+W","l");
    leg_norm->AddEntry(hbkg12_norm,"#gamma+Z","l");
  leg_norm->Draw("same");
  
  TPad *p1 = ((TPad*)(canvas->GetPad(1)));
  TPad *p2 = ((TPad*)(canvas->GetPad(2)));

  // int iPos =0;
  // CMS_lumi(p1,true,iPos,true);
  //CMS_lumi(p2,true,iPos,true);

  if(pt1_cutIN==0 && pt2_cutIN == 0 && MET_cutIN == 0){
    canvas->SaveAs("./25ns_2246inv_v3/plots/kinematics/DeltaPhiMax_Pho_MET.png");
    canvas->SaveAs("./25ns_2246inv_v3/plots/kinematics/DeltaPhiMax_Pho_MET.pdf");
  }
  if(pt1_cutIN==0.65 && pt2_cutIN == 0.25){
    canvas->SaveAs(Form("./25ns_2246inv_v3/plots/kinematics/DeltaPhiMax_Pho_MET_optcuts_MET%.0lf.png",MET_cutIN));
    canvas->SaveAs(Form("./25ns_2246inv_v3/plots/kinematics/DeltaPhiMax_Pho_MET_optcuts_MET%.0lf.pdf",MET_cutIN));
  }
  


 
}
コード例 #22
0
void makePlot(const std::string& inputFilePath, const std::string& canvasName, const std::string& histogram, const std::string& channel, const std::string& xAxisTitle, const std::string& yAxisTitle,
	      const std::string& inputFileName, const std::string& outputFilePath, const std::string& outputFileName)
{
  std::string inputFileName_full = Form("%s%s", inputFilePath.data(), inputFileName.data());
  TFile* inputFile = new TFile(inputFileName_full.data());
  if ( !inputFile ) {
    std::cerr << "Failed to open input file = " << inputFileName_full << " !!" << std::endl;
    assert(0);
  }

  inputFile->ls();

  TCanvas* canvas = dynamic_cast<TCanvas*>(inputFile->Get(canvasName.data()));
  if ( !canvas ) {
    std::cerr << "Failed to load canvas = " << canvasName << " !!" << std::endl;
    assert(0);
  }

  int idxPad = -1;
  if ( histogram == "mVis"    ) idxPad = 1;
  if ( histogram == "mTauTau" ) idxPad = 2;
  if ( !(idxPad >= 1 && idxPad <= 2) ) {
    std::cerr << "Invalid histogram = " << histogram << " !!" << std::endl;
    assert(0);
  }
  TVirtualPad* pad = canvas->GetPad(idxPad);
  std::cout << "pad = " << pad << ": ClassName = " << pad->ClassName() << std::endl;

  TCanvas* canvas_new = new TCanvas("canvas_new", "canvas_new", 900, 850);
  canvas_new->SetFillColor(10);
  canvas_new->SetBorderSize(2);
  canvas_new->SetTopMargin(0.065);
  canvas_new->SetLeftMargin(0.17);
  canvas_new->SetBottomMargin(0.155);
  canvas_new->SetRightMargin(0.045);
  canvas_new->SetLogx(false);
  canvas_new->SetLogy(false);
  canvas_new->Draw();
  canvas_new->cd();

  //TList* pad_primitives = canvas->GetListOfPrimitives();
  TList* pad_primitives = pad->GetListOfPrimitives();

  TH1* histogramDYJets   = 0;
  TH1* histogramHiggs125 = 0;
  TH1* histogramHiggs200 = 0;
  TH1* histogramHiggs300 = 0;

  TIter pad_nextObj(pad_primitives);
  while ( TObject* obj = pad_nextObj() ) {
    std::string objName = "";
    if ( dynamic_cast<TNamed*>(obj) ) objName = (dynamic_cast<TNamed*>(obj))->GetName();    
    std::cout << "obj = " << obj << ": name = " << objName << ", type = " << obj->ClassName() << std::endl;

    TH1* tmpHistogram = dynamic_cast<TH1*>(obj);
    if ( tmpHistogram ) {
      std::cout << "tmpHistogram:" 
		<< " fillColor = " << tmpHistogram->GetFillColor() << ", fillStyle = " << tmpHistogram->GetFillStyle() << ","
		<< " lineColor = " << tmpHistogram->GetLineColor() << ", lineStyle = " << tmpHistogram->GetLineStyle() << ", lineWidth = " << tmpHistogram->GetLineWidth() << ","
		<< " markerColor = " << tmpHistogram->GetMarkerColor() << ", markerStyle = " << tmpHistogram->GetMarkerStyle() << ", markerSize = " << tmpHistogram->GetMarkerSize() << ","
		<< " integral = " << tmpHistogram->Integral() << std::endl;
      if ( tmpHistogram->GetFillColor() ==   0 ) histogramDYJets   = tmpHistogram;
      if ( tmpHistogram->GetFillColor() == 632 ) histogramHiggs125 = tmpHistogram;
      if ( tmpHistogram->GetFillColor() == 616 ) histogramHiggs200 = tmpHistogram;
      if ( tmpHistogram->GetFillColor() == 600 ) histogramHiggs300 = tmpHistogram;
    }
  }

  if ( !(histogramDYJets && histogramHiggs125 && histogramHiggs200 && histogramHiggs300) ) {
    std::cerr << "Failed to load histograms !!" << std::endl;
    assert(0);
  }

  int lineColors[4] = { 1, 2, 6, 4 };
  int lineStyles[4] = { 1, 1, 1, 1 };
  int lineWidths[4] = { 2, 2, 2, 2 };
  int fillColors[4] = { 10, 2, 6, 4 };
  int fillStyles[4] = { 0, 3002, 3004, 3005 };

  histogramDYJets->SetFillColor(fillColors[0]);
  histogramDYJets->SetFillStyle(fillStyles[0]);
  histogramDYJets->SetLineColor(lineColors[0]);
  histogramDYJets->SetLineStyle(lineStyles[0]);
  histogramDYJets->SetLineWidth(lineWidths[0]);

  histogramHiggs125->SetFillColor(fillColors[1]);
  histogramHiggs125->SetFillStyle(fillStyles[1]);
  histogramHiggs125->SetLineColor(lineColors[1]);
  histogramHiggs125->SetLineStyle(lineStyles[1]);
  histogramHiggs125->SetLineWidth(lineWidths[1]);

  histogramHiggs200->SetFillColor(fillColors[2]);
  histogramHiggs200->SetFillStyle(fillStyles[2]);
  histogramHiggs200->SetLineColor(lineColors[2]);
  histogramHiggs200->SetLineStyle(lineStyles[2]);
  histogramHiggs200->SetLineWidth(lineWidths[2]);

  histogramHiggs300->SetFillColor(fillColors[3]);
  histogramHiggs300->SetFillStyle(fillStyles[3]);
  histogramHiggs300->SetLineColor(lineColors[3]);
  histogramHiggs300->SetLineStyle(lineStyles[3]);
  histogramHiggs300->SetLineWidth(lineWidths[3]);

  TAxis* xAxis = histogramHiggs300->GetXaxis();
  if ( histogram == "mVis"    ) xAxis->SetRangeUser(0,350);
  else xAxis->SetRangeUser(0,450);
  xAxis->SetTitle(xAxisTitle.data());
  xAxis->SetTitleOffset(1.00);
  xAxis->SetTitleSize(0.070);
  xAxis->SetTitleFont(42);
  xAxis->SetLabelOffset(0.010);
  xAxis->SetLabelSize(0.050);
  xAxis->SetLabelFont(42);
  xAxis->SetTickLength(0.040);
  xAxis->SetNdivisions(505);

  //double xMin = 20.;
  //double xMax = xAxis->GetXmax();
  //xAxis->SetRangeUser(xMin, xMax);

  TAxis* yAxis = histogramHiggs300->GetYaxis();
  yAxis->SetTitle(yAxisTitle.data());
  yAxis->SetTitleOffset(1.20);
  yAxis->SetTitleSize(0.070);
  yAxis->SetTitleFont(42);
  yAxis->SetLabelOffset(0.010);
  yAxis->SetLabelSize(0.055);
  yAxis->SetLabelFont(42);
  yAxis->SetTickLength(0.040);  
  yAxis->SetNdivisions(505);

  histogramHiggs300->SetTitle("");
  histogramHiggs300->SetStats(false);
  histogramHiggs300->SetMaximum(1.2*histogramDYJets->GetMaximum());
  histogramHiggs300->SetMinimum(0.);
  histogramHiggs300->Draw("hist");
  histogramHiggs200->Draw("histsame");
  histogramHiggs125->Draw("histsame");
  histogramDYJets->Draw("histsame");
  histogramHiggs300->Draw("axissame");

  TLegend* legend_new = new TLegend(0.50, 0.62, 0.87, 0.92, NULL, "brNDC");
  legend_new->SetFillColor(10);
  legend_new->SetFillStyle(0);
  legend_new->SetBorderSize(0);
  legend_new->SetTextFont(42);
  legend_new->SetTextSize(0.055);
  legend_new->SetTextColor(1);
  legend_new->SetMargin(0.20);
  legend_new->AddEntry(histogramDYJets, "Z/#gamma* #rightarrow #tau#tau", "f");
  legend_new->AddEntry(histogramHiggs125, "H(125 GeV) #rightarrow #tau#tau", "f");
  legend_new->AddEntry(histogramHiggs200, "H(200 GeV) #rightarrow #tau#tau", "f");
  legend_new->AddEntry(histogramHiggs300, "H(300 GeV) #rightarrow #tau#tau", "f");
  legend_new->Draw();

  double label_channel_y0;
  if      ( channel == "e#mu"             ) label_channel_y0 = 0.9275;
  else if ( channel == "#mu#tau_{h}"      ) label_channel_y0 = 0.9400;
  else if ( channel == "#tau_{h}#tau_{h}" ) label_channel_y0 = 0.9350;
  else {
    std::cerr << "Invalid channel = " << channel << " !!" << std::endl;
    assert(0);
  }
  TPaveText* label_channel = new TPaveText(0.855, label_channel_y0, 0.945, label_channel_y0 + 0.055, "NDC");
  label_channel->SetFillStyle(0);
  label_channel->SetBorderSize(0);
  label_channel->AddText(channel.data());
  label_channel->SetTextFont(62);
  label_channel->SetTextSize(0.055);
  label_channel->SetTextColor(1);
  label_channel->SetTextAlign(31);
  label_channel->Draw();

  canvas_new->Update();

  std::string outputFileName_full = Form("%s%s", outputFilePath.data(), outputFileName.data());
  size_t idx = outputFileName_full.find_last_of('.');
  std::string outputFileName_plot = std::string(outputFileName_full, 0, idx);
  canvas_new->Print(std::string(outputFileName_plot).append(".pdf").data());
  //canvas_new->Print(std::string(outputFileName_plot).append(".root").data());

  delete legend_new;
  delete label_channel;
  delete canvas_new;

  delete inputFile;
}
コード例 #23
0
ファイル: Plots.C プロジェクト: brochero/TopCodeljets
void Plots(TString plots="4Jets", TString sys="", bool EvtNorm=false){
  
  /****************
        Style
  ****************/
  gROOT->SetStyle("Plain");
  gStyle->SetOptFit(1000);
  gStyle->SetOptStat("emruo");
  gStyle->SetOptStat(kFALSE);
  gStyle->SetPadTickY(1);
  gStyle->SetPadTickX(1);
  
  gROOT->ProcessLine(".L /home/brochero/ttbar/TopCodeljets/tdrStyle.C");
  setTDRStyle();
  
  Int_t chatch = 1756;
  TColor *color = new TColor(chatch, 0.3, 0.5, 0.5, "", 0.45); // alpha = 0.5
  TString files  = dirnameIn + fl;  
  
  /****************
       Channel
  ****************/
  TString channel[3];
  channel[0] = "mujets";
  channel[1] = "ejets";  
  channel[2] = "lepjet"; 
  
 
  /****************
        Data
  ****************/ 
  std::vector<histos> DataMu;
  DataMu = loadhistograms(plots, files + "_DataSingleMu");
  std::vector<histos> DataEG;
  DataEG = loadhistograms(plots, files + "_DataSingleEG");
  std::vector<histos> Data;
  Data = addhistograms(DataMu, DataEG);
  setuphistograms(Data, kBlack);

  /****************
    ttbar Signal
  ****************/ 
  std::vector<histos> ttbar_0;
  ttbar_0 = loadhistograms(plots, files + "_ttbar-PowhegPythia");
  setuphistograms(ttbar_0, kRed+1);

  std::vector<histos> ttbar_1;
  ttbar_1 = loadhistograms(plots, files + "_ttbar-MCatNLO");
  setuphistograms(ttbar_1, kRed+2);

  std::vector<histos> ttbar_2;
  ttbar_2 = loadhistograms(plots, files + "_ttbar-Madgraph");
  setuphistograms(ttbar_2, kRed+3);

  /****************
       Z+Jets
  ****************/ 
  std::vector<histos> ZJets;
  ZJets = loadhistograms(plots, files + "_ZJets");
  setuphistograms(ZJets, kAzure-2);

  /****************
         VV
  ****************/ 
  std::vector<histos> WW;
  WW = loadhistograms(plots, files + "_WW");
  std::vector<histos> WZ;
  WZ = loadhistograms(plots, files + "_WZ");
  std::vector<histos> ZZ;
  ZZ = loadhistograms(plots, files + "_ZZ");
  std::vector<histos> VV;
  VV = addhistograms(WW, WZ);
  VV = addhistograms(VV, ZZ);
  setuphistograms(VV, kYellow-3);

  /****************
     Single Top
  ****************/ 
  std::vector<histos> tW;
  tW = loadhistograms(plots, files + "_tW");
  std::vector<histos> tbarW;
  tbarW = loadhistograms(plots, files + "_tbarW");
  std::vector<histos> t_tch;
  t_tch = loadhistograms(plots, files + "_t-tchannel");
  std::vector<histos> tbar_tch;
  tbar_tch = loadhistograms(plots, files + "_tbar-tchannel");
  std::vector<histos> Single_top;
  Single_top = addhistograms(tW, tbarW);
  Single_top = addhistograms(Single_top, t_tch);
  Single_top = addhistograms(Single_top, tbar_tch);
  setuphistograms(Single_top, kPink-3);

  /****************
       W+Jets
  ****************/ 
  std::vector<histos> WJets;
  WJets = loadhistograms(plots, files + "_WJets");
  setuphistograms(WJets, kGreen-3);

  /****************
     ttbar Bkg
  ****************/ 
  std::vector<histos> ttbar_bkg;
  ttbar_bkg = loadhistograms(plots, files + "_ttbar-PowhegPythiaBkg");
  setuphistograms(ttbar_bkg, kViolet-3);

  /****************
        QCD
  ****************/ 
  std::vector<histos> QCD;
  QCD = loadhistograms(plots, files + "_QCD-MuEnr");
  setuphistograms(QCD, kOrange-3);

  /****************
       Stacks
  ****************/ 
  std::vector<histos> Stack_bkg;
  std::vector<histos> Stack;
  histos st_bkg;
  histos st;
  for(unsigned int h=0; h<WJets.size(); h++){
    TString variable;
    for(int ch=0; ch<3; ch++){
      st.mc[ch]     = new THStack(variable, "");
      st_bkg.mc[ch] = new THStack(variable, "");
      st.mc[ch]->SetHistogram( (TH1F*)WJets[h].hist[ch]->Clone());
      st_bkg.mc[ch]->SetHistogram( (TH1F*)WJets[h].hist[ch]->Clone());
    }
    Stack.push_back(st);
    Stack_bkg.push_back(st_bkg);
  }
  
  //-------------------------------------------------------
  // Background Stack
  Stack_bkg = addstack(Stack_bkg, WJets);
  Stack_bkg = addstack(Stack_bkg, QCD);
  Stack_bkg = addstack(Stack_bkg, Single_top);
  Stack_bkg = addstack(Stack_bkg, VV);
  Stack_bkg = addstack(Stack_bkg, ttbar_bkg);
  Stack_bkg = addstack(Stack_bkg, ZJets);

  //-------------------------------------------------------
  // Stack
  Stack = addstack(Stack, WJets);
  Stack = addstack(Stack, QCD);
  Stack = addstack(Stack, Single_top);
  Stack = addstack(Stack, VV);
  Stack = addstack(Stack, ttbar_bkg);
  Stack = addstack(Stack, ZJets);
  Stack = addstack(Stack, ttbar_0);

  //-------------------------------------------------------
  // other ttbar Generators
  ttbar_1 = addhistograms(ttbar_1, Stack_bkg);
  ttbar_2 = addhistograms(ttbar_2, Stack_bkg);

  
  /****************
     Draw Histos
  ****************/ 
  TCanvas *histocanvas;
  histocanvas = new TCanvas("plots", "Plots");
  
  for(unsigned int h=0; h<WJets.size(); h++){
    for(int ch=0; ch<3; ch++){
      
      histocanvas->Divide(1,2);
      
      TPad    *pad[2];
      //Plot Pad
      pad[0] = (TPad*)histocanvas->GetPad(1);
      pad[0]->SetPad(0.01, 0.23, 0.99, 0.99);
      pad[0]->SetTopMargin(0.1);
      pad[0]->SetRightMargin(0.04);
      
      //Ratio Pad
      pad[1] = (TPad*)histocanvas->GetPad(2);
      pad[1]->SetPad(0.01, 0.02, 0.99, 0.3);
      gStyle->SetGridWidth(0.5);
      gStyle->SetGridColor(14);
      pad[1]->SetGridx();
      pad[1]->SetGridy();
      pad[1]->SetTopMargin(0.05);
      pad[1]->SetBottomMargin(0.4);
      pad[1]->SetRightMargin(0.04);
      
      //-------------------------------------------------------
      // Stack
      pad[0]->cd();

      Stack[h].mc[ch]->Draw("hist");

      Stack[h].mc[ch]->GetYaxis()->SetTitle("Events");
      Stack[h].mc[ch]->GetYaxis()->SetTitleOffset(1.2);
      Stack[h].mc[ch]->GetYaxis()->SetTitleSize(0.07);
      Stack[h].mc[ch]->GetYaxis()->SetLabelSize(0.055);
      Stack[h].mc[ch]->GetYaxis()->SetNdivisions(607);
      //Stack[h].mc[ch]->GetYaxis()->SetLabelSize(0.05);
      TGaxis *hYaxis = (TGaxis*)Stack[h].mc[ch]->GetYaxis();
      //hYaxis->SetMaxDigits(3);
      Stack[h].mc[ch]->GetXaxis()->SetLabelSize(0.0);
      Stack[h].mc[ch]->GetXaxis()->SetTitle("");

      float maxh = Data[h].hist[ch]->GetMaximum();
      if(maxh < Stack[h].mc[ch]->GetMaximum()) maxh = Stack[h].mc[ch]->GetMaximum();
      Stack[h].mc[ch]->SetMaximum(1.7*maxh);
      
      //-------------------------------------------------------
      // Band error
      TGraphErrors *thegraph = new TGraphErrors(Stack[h].hist[ch]);
      thegraph->SetName("thegraph");
      thegraph->SetFillStyle(1001);
      thegraph->SetFillColor(chatch);
      thegraph->SetLineColor(chatch);

      thegraph->Draw("e2SAME");

      //-------------------------------------------------------
      // Other ttbar generators
      ttbar_1[h].hist[ch]->SetLineColor(6);
      ttbar_1[h].hist[ch]->SetLineStyle(2);
      ttbar_1[h].hist[ch]->SetFillColor(0);
      ttbar_1[h].hist[ch]->Draw("histoSAME");

      ttbar_2[h].hist[ch]->SetLineColor(8);
      ttbar_2[h].hist[ch]->SetLineStyle(4);
      ttbar_2[h].hist[ch]->SetFillColor(0);
      ttbar_2[h].hist[ch]->Draw("histoSAME");
      //-------------------------------------------------------
      // Data Histogram
      Data[h].hist[ch]->SetMarkerStyle(20);
      Data[h].hist[ch]->SetMarkerSize(0.7);

      Data[h].hist[ch]->Draw("SAME");

      /***********************
             Legends
      ***********************/
      TLegend *leg;
      float legx1=0.76;
      float legy1=0.54;
      float legx2=0.90;
      float legy2=0.87;
      leg = new TLegend(legx1,legy1,legx2,legy2);
      leg->SetFillColor(0);
      leg->SetLineColor(1);
      leg->SetTextFont(62);
      leg->SetTextSize(0.03);

      leg->AddEntry(Data[h].hist[ch],"Data","PL");
      leg->AddEntry(ttbar_0[h].hist[ch],"t#bar{t} Signal","F");
      leg->AddEntry(ZJets[h].hist[ch],"Z+Jets","F");
      leg->AddEntry(ttbar_bkg[h].hist[ch],"t#bar{t} Bkg","F");
      leg->AddEntry(VV[h].hist[ch],"VV","F");
      leg->AddEntry(Single_top[h].hist[ch],"Single t","F");
      leg->AddEntry(QCD[h].hist[ch],"QCD","F");
      leg->AddEntry(WJets[h].hist[ch],"W+Jets","F");
      leg->AddEntry("thegraph","Uncertainty","F");
      leg->AddEntry((TObject*)0,"","");
      leg->AddEntry(ttbar_1[h].hist[ch],"MC@NLO","L");
      leg->AddEntry(ttbar_2[h].hist[ch],"Madgraph","L");

      leg->Draw("SAME");
      //-------------------------------------------------------
      // CMS
      TString htitleCMSChannel[3];
      htitleCMSChannel[0] = "#mu^{#pm}+jets channel";
      htitleCMSChannel[1] = "e^{#pm}+jets channel";
      htitleCMSChannel[2] = "l^{#pm}+jets channel";
      
      titlePr  = new TLatex(-20.,50.,"Preliminary");
      titlePr->SetNDC();
      titlePr->SetTextAlign(12);
      titlePr->SetX(0.25);
      titlePr->SetY(0.93);
      titlePr->SetTextColor(2);
      titlePr->SetTextFont(42);
      titlePr->SetTextSize(0.05);
      titlePr->SetTextSizePixels(24);
      titlePr->Draw("SAME");
      
      title  = new TLatex(-20.,50.,"CMS #sqrt{s} = 13TeV, L = 42 pb^{-1}(50ns)");
      title->SetNDC();
      title->SetTextAlign(12);
      title->SetX(0.20);
      title->SetY(0.83);
      title->SetTextFont(42);
      title->SetTextSize(0.05);
      title->SetTextSizePixels(24);
      title->Draw("SAME");
      
      chtitle  = new TLatex(-20.,50.,htitleCMSChannel[ch]);
      chtitle->SetNDC();
      chtitle->SetTextAlign(12);
      chtitle->SetX(0.20);
      chtitle->SetY(0.75);
      chtitle->SetTextFont(42);
      chtitle->SetTextSize(0.05);
      chtitle->SetTextSizePixels(24);
      chtitle->Draw("SAME");

      /***********************
               Ratio
      ***********************/    
      pad[1]->cd();
      
      //-------------------------------------------------------
      //Graph Ratio Clone
      TH1F *Ratio;
      Ratio = (TH1F*)Data[h].hist[ch]->Clone();
      Ratio->Divide(Stack[h].hist[ch]);

      TH1F *RatioSyst;
      RatioSyst = (TH1F*)Data[h].hist[ch]->Clone();
      RatioSyst->Divide(Stack[h].hist[ch]); // Should be the histogram with the Total Syst. Unc.
      std::vector<double> ratioContent;
      for(unsigned int b_r = 1; b_r <= RatioSyst->GetNbinsX(); b_r++){
	RatioSyst->SetBinContent(b_r,1.0);
	//RatioSyst->SetBinError(b_r,0.15); // Tempotal!!!
      }      

      Ratio->SetMarkerStyle(20);
      Ratio->SetMarkerSize(0.5);
      Ratio->SetMarkerColor(1);
      Ratio->SetLineColor(1);
      Ratio->SetLineWidth(1);
      Ratio->SetMaximum(2);
      Ratio->SetMinimum(0);
      Ratio->SetTitle("");
      
      Ratio->GetYaxis()->SetTitle("Obs/Exp");
      Ratio->GetYaxis()->CenterTitle();
      Ratio->GetYaxis()->SetTitleOffset(0.45);
      Ratio->GetYaxis()->SetTitleSize(0.16);
      Ratio->GetYaxis()->SetLabelSize(0.15);
      Ratio->GetYaxis()->SetNdivisions(402);
      Ratio->GetXaxis()->SetNdivisions(509);
      Ratio->GetXaxis()->SetTitleOffset(1.1);
      Ratio->GetXaxis()->SetLabelSize(0.20);
      Ratio->GetXaxis()->SetTitleSize(0.16);
      
      Ratio->SetMinimum(0.6);
      Ratio->SetMaximum(1.4);
      
      TGraphErrors *thegraphRatioSyst = new TGraphErrors(RatioSyst);
      thegraphRatioSyst->SetFillStyle(1001);
      thegraphRatioSyst->SetFillColor(chatch);
      thegraphRatioSyst->SetName("thegraphRatioSyst");
      
      //-------------------------------------------------------
      //Graph Ratio other ttbar generators
      TH1F *Ratio_1;
      Ratio_1 = (TH1F*)Data[h].hist[ch]->Clone();
      Ratio_1->Divide(ttbar_1[h].hist[ch]);
      Ratio_1->SetLineColor(6);
      Ratio_1->SetLineStyle(2);
      Ratio_1->SetLineWidth(2);
      Ratio_1->SetFillColor(0);

      TH1F *Ratio_2;
      Ratio_2 = (TH1F*)Data[h].hist[ch]->Clone();
      Ratio_2->Divide(ttbar_2[h].hist[ch]);
      Ratio_2->SetLineColor(8);
      Ratio_2->SetLineStyle(4);
      Ratio_2->SetLineWidth(2);
      Ratio_2->SetFillColor(0);

      //-------------------------------------------------------
      // Draw Ratios
      Ratio->Draw();
      thegraphRatioSyst->Draw("e2");
      Ratio->Draw("histpSAME");
      Ratio_1->Draw("histSAME");
      Ratio_2->Draw("histSAME");
            
      /***********************
            Save Histos
      ***********************/    
      TString dirfigname_pdf=dirnameIn + "figures_" + fl + "/pdf/";
      // make a dir if it does not exist!!
      gSystem->mkdir(dirfigname_pdf,       kTRUE);
      histocanvas->SaveAs(dirfigname_pdf + WJets[h].hist[ch]->GetName() + ".pdf");
      
      // clear Canvas
      histocanvas->Clear();    

    }
  }
  
} //end Plots.C
コード例 #24
0
/*
EXAMPLE
root
.L particleDrawer.C++
particleDrawer("../test/test.root",11,2)
 */
void particleDrawer(TString filename, int entry = 0, int PVAssoc = 2, bool debug = false) {

   cout << "particleDrawer::Setting the TDR style ... ";
   setTDRStyle();
   cout << "DONE" << endl;

   cout << "particleDrawer::Drawing the default (TDR) frame ... " << endl;
   TH1D* frame = new TH1D();
   frame->GetXaxis()->SetLimits(-5,5);
   frame->GetXaxis()->SetTitle("#eta");
   frame->GetYaxis()->SetRangeUser(-TMath::Pi(),TMath::Pi());
   frame->GetYaxis()->SetTitle("#phi");
   TCanvas* c = tdrCanvas("particleBasedEvent",frame,4,0,true);
   c->GetPad(0)->SetLogz();
   cout << "\r\r\r\r\r\r" << flush;
   cout << setw(52) << " " << "DONE" << endl << endl;

   cout << "particleDrawer::Opening the input file (" << filename << " ) ... ";
   TFile* inFile = TFile::Open(filename,"READ");
   assert(inFile!=NULL);
   cout << "DONE" << endl;

   cout << "particleDrawer::Getting the input trees ... ";
   TTree* puppiTree = (TTree*)inFile->Get("puppiReader/puppiTree");
   assert(puppiTree!=NULL);
   TTree* jetTree = (TTree*)inFile->Get("nt_AK4PFchs/t");
   assert(jetTree!=NULL);
   cout << "DONE" << endl;

   cout << "particleDrawer::Making the ntuples ... ";
   puppiNtuple*     pNtuple = new puppiNtuple(puppiTree);
   validatorNtuple* jNtuple = new validatorNtuple(jetTree);
   cout << "DONE" << endl;

   cout << "particleDrawer::Getting entry " << entry << " for puppiTree ... ";
   puppiTree->GetEntry(entry);
   cout << "DONE" << endl;

   cout << "particleDrawer::Filling the histograms ... ";
   TH2F* hPU = new TH2F("hPU","hPU",50,-5,5,60,-TMath::Pi(),TMath::Pi());
   TH2F* hHard = new TH2F("hHard","hHard",50,-5,5,60,-TMath::Pi(),TMath::Pi());

   for(unsigned int iparticle=0; iparticle<(*pNtuple->px).size(); iparticle++) {
      TLorentzVector tempVect((*pNtuple->px)[iparticle],(*pNtuple->py)[iparticle],
                              (*pNtuple->pz)[iparticle],(*pNtuple->e)[iparticle]);

      if((*pNtuple->fromPV)[iparticle]<PVAssoc) {
         if(debug) cout << "Filling PU::fromPV = " << (*pNtuple->fromPV)[iparticle] << endl;
         hPU->Fill(tempVect.Eta(),tempVect.Phi(),tempVect.Pt());
      }
      else {
         if(debug) cout << "Filling hard-scatter:: fromPV = " << (*pNtuple->fromPV)[iparticle] << endl;
         hHard->Fill(tempVect.Eta(),tempVect.Phi(),tempVect.Pt());
      }
   }
   if(debug) {
      cout << "hPU->GetEntries() = " << hPU->GetEntries() << endl;
      cout << "hHard->GetEntries() = " << hHard->GetEntries() << endl;
   }
   else
      cout << "DONE" << endl;

   cout << "particleDrawer::Drawing the histograms ... ";
   //tdrDraw(hPU,"BOX",kFullSquare,kNone,kSolid,kGray,kNone,kNone);
   //tdrDraw(hHard,"colz");
   THStack* stack = new THStack("stack","stack");
   hPU->SetLineStyle(kSolid);
   hPU->SetLineColor(kGray);
   hPU->SetFillStyle(1001);
   hPU->SetFillColor(kNone);
   hPU->SetMarkerStyle(kFullSquare);
   hPU->SetMarkerColor(kNone);
   if(hHard->GetEntries()>0)
      stack->Add(hHard,"colz");
   if(hPU->GetEntries()>0)
      stack->Add(hPU,"BOX");
   tdrDraw(stack,"nostack");

   set_plot_style();
   c->Update();
   c->RedrawAxis();
   cout << "DONE" << endl;

   cout << "particleDrawer::Getting entry " << entry << " for jetTree ... ";
   jetTree->GetEntry(entry);
   cout << "DONE" << endl;

   cout << "particleDrawer::Drawing the jets ... " << endl;
   vector<JetCircle> jets;
   for(unsigned int ijet=0; ijet<jNtuple->nref; ijet++) {
      if((*jNtuple->jtpt)[ijet]<20) continue;
      double RJet = TMath::Sqrt((*jNtuple->jtarea)[ijet]/TMath::Pi());
      jets.push_back(JetCircle((*jNtuple->jteta)[ijet],(*jNtuple->jtphi)[ijet],RJet,(*jNtuple->jtpt)[ijet]));
   }
   for(unsigned int ijet=0; ijet<jets.size(); ijet++) {
      for(unsigned int jjet=ijet+1; jjet<jets.size(); jjet++) {
         if(check_overlap(jets[ijet].getX(),jets[ijet].getY(),jets[ijet].getRadius(),
                          jets[jjet].getX(),jets[jjet].getY(),jets[jjet].getRadius())) {
            cout << "Jet " << ijet << " overlaps with jet " << jjet << endl;
            if(jets[ijet].getPt()>jets[jjet].getPt()) {
               //find angle for jjet;
               jets[jjet].findAngles(jets[ijet]);               
            }
            else if(jets[ijet].getPt()<jets[jjet].getPt()) {
               //find angle for ijet
               jets[ijet].findAngles(jets[jjet]);
            }
            else {
               //must find angle for both jets
               //then must draw a straight line between the two intersection points
               jets[jjet].findAngles(jets[ijet]);
               jets[ijet].findAngles(jets[jjet]);
               //NEED TO COMPLETE THIS FUNCTION. CURRENTLY DOESNOT DRAW LINE BETWEEN THE JETS.
            }
            cout << "Jet " << ijet << ": \n" << jets[ijet] << endl;
            cout << "Jet " << jjet << ": \n" << jets[jjet] << endl;
         }
      }
   }
   for(unsigned int ijet=0; ijet<jets.size(); ijet++) {
      loadbar2(ijet+1, jets.size());
      TEllipse* cJet = new TEllipse(jets[ijet].getX(),jets[ijet].getY(),
                                    jets[ijet].getRadius(),jets[ijet].getRadius(),
                                    jets[ijet].getStartAngle(),jets[ijet].getEndAngle());
      cJet->SetFillStyle(0);
      cJet->SetFillColor(kNone);
      cJet->SetLineStyle(kSolid);
      cJet->SetLineColor(kRed);
      cJet->SetLineWidth(3);
      cJet->Draw("only same");
   }
   //cout << "\r\r\r\r" << flush;
   //cout << setw(37) << " " << "DONE" << endl << endl;

   cout << "particleDrawer::Saving the canvas ... ";
   TString name = Form("particleMap_entry%i_PVAssoc%i",entry,PVAssoc);
   c->SaveAs(name+".png");
   c->SaveAs(name+".pdf");
   c->SaveAs(name+".C");
   cout << "DONE" << endl;
}
コード例 #25
0
void RDK2AnalysisPlotter::makeEPGPlot(CoDet detType)
{
     gROOT->cd();
    TCanvas* theCanvas;
    TPad* mainPad;
    TPad* titlePad;
    TPad* gEPad;
    TPad* detPad;
    TPad* gEPadSubs[3];


    int numTitleLines=getTitleBoxLines( detType);
    int canvasNumPixelsYPlot=600;
    int canvasNumPixelsYPlots=2*canvasNumPixelsYPlot;
    int canvasNumPixelsYTitle=40*numTitleLines;
    int canvasNumPixelsY=canvasNumPixelsYPlots+canvasNumPixelsYTitle;

    theCanvas = new TCanvas("EPGExpMCAnalysisComparisonPlot","EPGExpMCAnalysisComparisonPlot",10,10,1200,canvasNumPixelsY);
     mainPad=(TPad*) theCanvas->GetPad(0);


    double ylow,yhigh;

    yhigh=1;
    ylow=1.-canvasNumPixelsYTitle/(double)canvasNumPixelsY;
    titlePad=new TPad("titlePad", "titlePad", 0., ylow, 1., yhigh, -1, 1, 1);

    yhigh=ylow;
    ylow=ylow-canvasNumPixelsYPlot/(double)canvasNumPixelsY;
    gEPad=new TPad("gEPad", "gEPad", 0., ylow, 1., yhigh, -1, 1, 1);

    yhigh=ylow;
    ylow=0;
    detPad=new TPad("detPad", "detPad", 0., ylow, 1., yhigh, -1, 1, 1);

    titlePad->Draw();
    gEPad->Draw();
    detPad->Draw();



//    titlePad=(TPad*) theCanvas->GetPad(1);
//    gEPad=(TPad*) theCanvas->GetPad(2);
//    detPad=(TPad*) theCanvas->GetPad(3);
//    egTPad=(TPad*) theCanvas->GetPad(4);

    titlePad->SetMargin(0.05,0.0,0.0,0.0);
    gEPad->SetMargin(0.05,0.0,0.0,0.05);

    if(numExp>1 && numMC>1)
    {
        gEPad->Divide(2);

        gEPadSubs[0]=(TPad*) gEPad->GetPad(1);

        TPad* tempPad;
        tempPad=(TPad*) gEPad->GetPad(2);
        tempPad->Divide(1,2);
        gEPadSubs[1]=(TPad*) tempPad->GetPad(1);
        gEPadSubs[2]=(TPad*) tempPad->GetPad(2);


        TPad* allBasePads[5]={titlePad,gEPadSubs[0],gEPadSubs[1],gEPadSubs[2],detPad};
         for (int i = 1;i< 5;i++)
        {
            allBasePads[i]->SetGrid(1,1);
            allBasePads[i]->SetTickx(1);
            allBasePads[i]->SetTicky(1);
        }

        gEPadSubs[2]->SetLogx();

        gEPadSubs[0]->SetMargin(0.15,0.1,.1,0.1);
        gEPadSubs[1]->SetMargin(0.1,0.1,.1,0.1);
        gEPadSubs[2]->SetMargin(0.1,0.1,.1,0.1);

        //Plot gE

        gEPadSubs[0]->cd(); drawPlot(detType, PLOTVAR_GE,PLOT_COMP);
        gEPadSubs[1]->cd(); drawPlot(detType, PLOTVAR_GE,PLOT_RESID);
        gEPadSubs[2]->cd(); drawPlot(detType, PLOTVAR_GEVAR,PLOT_NORMRESID);

    }
    else
    {

        TPad* allBasePads[3]={titlePad,gEPad,detPad};
        for (int i = 1;i< 3;i++)
        {
            allBasePads[i]->SetGrid(1,1);
            allBasePads[i]->SetTickx(1);
            allBasePads[i]->SetTicky(1);
        }

        gEPad->SetMargin(0.13,0.1,.1,0.1);


        //Plot gE

        gEPad->cd(); drawPlot(detType, PLOTVAR_GE,PLOT_COMP);
    }
    mainPad->SetFillColor(kGray);

    ///Make Title box
    titlePad->cd();
    titlePad->SetFillColor(kGray);
    TPaveText* titleBox = makeTitleBox( detType);
    titleBox->Draw();

    detPad->SetMargin(0.1,0.05,.1,0.1);

    //Plot det
     detPad->cd(); drawPlot(detType, PLOTVAR_GE,PLOT_DETS);

    TString coTypeString;
    if(detType==DET_EP)
    {
        coTypeString="EP";
    }
    else if(detType==DET_EPG)
    {
        coTypeString="EPG";
    }
    else if(detType==DET_EPBG)
    {
        coTypeString="EPBG";
    }
    TString imagePath=GRAPHS_DIR;
    imagePath+="layouts/PlotLayout";
    if(numMC) imagePath+="_MC";
    for (int i = 0;i< numMC;i++)
    {
        imagePath+=TString("_")+mc[i]->GetName();
    }
    if(numExp) imagePath+="_Exp";
    for (int i = 0;i< numExp;i++)
    {
        imagePath+=TString("_")+exp[i]->GetName();
    }

    imagePath+="_"+coTypeString+"_EPGPlots.pdf";
    theCanvas->SaveAs(imagePath);

    delete theCanvas;
    clearPlotHists();

}
コード例 #26
0
TCanvas* CommandMSUGRA(TString plotName_X,Int_t tanBeta_, Bool_t plotLO_){
  
  gStyle->SetOptTitle(0);
  gStyle->SetOptStat(0);
  gStyle->SetPalette(1); 
  gStyle->SetTextFont(42);
  gStyle->SetFrameBorderMode(0);

  //convert tanb value to string
  std::stringstream tmp;
  tmp << tanBeta_;
  std::cout << "my tan beta is " << tanBeta_ << std::endl;
  TString tanb( tmp.str() );
  
  
  // Output file
  //std::cout << " create " << plotName_X << std::endl;
  //TFile* output = new TFile( plotName_X, "RECREATE" );
  //if ( !output || output->IsZombie() ) { std::cout << " zombie alarm output is a zombie " << std::endl; }
  

  //set old exclusion Limits
  TGraph* LEP_ch = set_lep_ch(tanBeta_);
  TGraph* LEP_sl = set_lep_sl(tanBeta_);//slepton curve
  TGraph* TEV_sg_cdf = set_tev_sg_cdf(tanBeta_);//squark gluino cdf
  TGraph* TEV_sg_d0 = set_tev_sg_d0(tanBeta_);//squark gluino d0
  //  TGraph* TEV_tlp_cdf = set_tev_tlp_cdf(tanBeta_);//trilepton cdf
  //  TGraph* TEV_tlp_d0 = set_tev_tlp_d0(tanBeta_);//trilepton d0
  TGraph* stau   = set_tev_stau(tanBeta_);//stau 
  TGraph* NoEWSB = set_NoEWSB(tanBeta_); 

  TGraph* TEV_sn_d0_1 = set_sneutrino_d0_1(tanBeta_);
  TGraph* TEV_sn_d0_2 = set_sneutrino_d0_2(tanBeta_);

  //constant ssqquark and gluino lines
  TF1* lnsq[10];
  TF1* lngl[10];
  
  TLatex* sq_text[10];
  TLatex* gl_text[10];

  
  for(int i = 0; i < 6; i++){
    lnsq[i] = constant_squark(tanBeta_,i);
    sq_text[i] = constant_squark_text(i,*lnsq[i],tanBeta_);
    lngl[i] = constant_gluino(tanBeta_,i);
    gl_text[i] = constant_gluino_text(i,*lngl[i]);
  }
  

  //Legends
  TLegend* legst  = makeStauLegend(0.05,tanBeta_);
  TLegend* legNoEWSB  = makeNoEWSBLegend(0.05,tanBeta_);
  TLegend* legexp = makeExpLegend( *TEV_sg_cdf,*TEV_sg_d0,*LEP_ch,*LEP_sl,*TEV_sn_d0_1,0.035,tanBeta_);
  
 
  //make Canvas
  TCanvas* cvsSys = new TCanvas("cvsnm","cvsnm",0,0,800,600);
  gStyle->SetOptTitle(0);
  cvsSys->SetFillColor(0);
  cvsSys->GetPad(0)->SetRightMargin(0.07);
  cvsSys->Range(-120.5298,26.16437,736.0927,750);
  //  cvsSys->Range(-50.5298,26.16437,736.0927,500);
  cvsSys->SetFillColor(0);
  cvsSys->SetBorderMode(0);
  cvsSys->GetPad(0)->SetBorderMode(0);
  cvsSys->GetPad(0)->SetBorderSize(2);
  cvsSys->GetPad(0)->SetLeftMargin(0.1407035);
  cvsSys->GetPad(0)->SetTopMargin(0.08);
  cvsSys->GetPad(0)->SetBottomMargin(0.13);

  cvsSys->SetTitle("tan#beta="+tanb);
 
  //output->cd();
  
//and now  the exclusion limits


  TGraph* SSdilep;
  TGraphErrors* OSdilep;
  TGraphErrors* RA1;

  TGraphErrors* RA1_old;
  TGraphErrors* RA5_old;
  TGraphErrors* RA6_old;


  
  if (tanBeta_ == 10) {
    std::cout << "tanb ==10" << std::endl;
    //SSdilep = SSdilep_NLO();
    //OSdilep = OSdilep_NLO();
    //RA1 = RA1_NLO();

    //RA1_old = getRA1Observed_NLO_tanBeta10();
    //RA5_old = getRA5Observed_NLO_tanBeta10();
    //RA6_old = getRA6Observed_NLO_tanBeta10();

  }



  double m0min = 0;
  if (tanBeta_ == 50) m0min=200;
  //TH2D* hist = new TH2D("h","h",100,m0min,1000,100,120,700);
  TH2D* hist = new TH2D("h","h",100,m0min,2000,100,120,700);
  hist->Draw();  
  hist->GetXaxis()->SetTitle("m_{0} (GeV)");
  hist->GetYaxis()->SetTitle("m_{1/2} (GeV)");
  hist->GetXaxis()->SetTitleOffset(.9);
  hist->GetXaxis()->SetTitleSize(0.06);
  hist->GetYaxis()->SetTitleOffset(1.0);
  hist->GetYaxis()->SetTitleSize(0.06);

  hist->GetXaxis()->SetNdivisions(506);
  //  if (tanBeta_ == 50)  hist->GetXaxis()->SetNdivisions(504);
  hist->GetYaxis()->SetNdivisions(506);

  int col[]={2,3,4};



  //TLegend* myleg;

  //if( plotLO_ ) myleg = new TLegend(0.3,0.65,0.65,0.8,NULL,"brNDC");
  //else          myleg = new TLegend(0.25,0.76,0.44,0.91,NULL,"brNDC");


  //myleg->SetFillColor(0); 
  //myleg->SetShadowColor(0);
  //myleg->SetTextSize(0.04);
  //myleg->SetBorderSize(0);

  //TLegendEntry *entry=myleg->AddEntry("RA1","2011 Limits","l");
  //entry->SetLineColor(1);
  //entry->SetLineStyle(1);
  //entry->SetLineWidth(3);

  //entry=myleg->AddEntry("sRA1","2010 Limits","l");
  //entry->SetLineColor(1);
  //entry->SetLineStyle(2);
  //entry->SetLineWidth(3);

  
  //constant squark and gluino mass contours
  for (int it=0;it<5;it++) {   
    lngl[it]->Draw("same");   
    lnsq[it]->Draw("same");
    sq_text[it]->Draw();
    gl_text[it]->Draw();
  }
  

  //exclusion limits previous experiments
  if(tanBeta_ == 3){
    TEV_sn_d0_1->Draw("fsame");
    TEV_sn_d0_2->Draw("fsame");
  }
  LEP_ch->Draw("fsame");
  if (tanBeta_ != 50) LEP_sl->Draw("fsame");

  //remove CDF/D0 excluded regions
  TEV_sg_cdf->Draw("fsame");
  TEV_sg_d0->Draw("same");  
  TEV_sg_d0->Draw("fsame");


  //other labels
  Double_t xpos = 0;
  Double_t xposi = 0;
  Double_t ypos = 0;
  if(tanBeta_ == 50) xposi = 100;
  if(tanBeta_ == 50) xpos = 200;
  if(tanBeta_ == 50) ypos = -10;
  
  //TLatex* lumilabel = new TLatex(750 +xposi + 100,767.-154,"#sqrt{s} = 7 TeV, #scale[0.65]{#int}Ldt = 0.98 fb^{-1}");
  //TLatex* lumilabel = new TLatex(450,767.-154+100,"#sqrt{s} = 7 TeV,   Ldt = 1 fb^{-1}");
  TLatex* lumilabel = new TLatex(0,720.,"3.2 fb^{-1}, #sqrt{s} = 7 TeV");
  //TLatex* integral_symbol = new TLatex(577 +xposi + 100,767.-145+100,"#int");

  lumilabel->SetTextSize(0.05);
  //integral_symbol->SetTextSize(0.03);
  lumilabel->Draw("same");
  //integral_symbol->Draw("same");

  //TLatex* cmslabel = new TLatex(10.,767.-154+100,"               ");
  //TLatex* cmslabel = new TLatex(10.,767.-154+100,"CMS Preliminary");
  //cmslabel->SetTextSize(0.05);
  //cmslabel->Draw("same");

  TString text_tanBeta;
  text_tanBeta =  "tan#beta = "+tanb+",  A_{0} = 0,  #mu > 0";
  TLatex* cmssmpars = new TLatex(200,650,text_tanBeta);

  cmssmpars->SetTextSize(0.04);
  cmssmpars->Draw("same");

  TLatex* lep_chargino = new TLatex(250,135,"LEP2 #tilde{#chi}_{1}^{#pm}");
  lep_chargino->SetTextSize(0.03);
  lep_chargino->SetTextFont(42);
  //  lep_chargino->Draw("same");

  TLatex* lep_slepton = new TLatex(26,190,"LEP2 #tilde{#font[12]{l}}^{#pm}");
  lep_slepton->SetTextSize(0.03);
  lep_slepton->SetTextAngle(-83);
  lep_slepton->SetTextFont(42);
  //  lep_slepton->Draw("same");



  //LM points
  TMarker* LM0 = new TMarker(200.,160.,20);
  TMarker* LM1 = new TMarker(60.,250.,20);
  TMarker* LM3 = new TMarker(330.,240.,20);
  TMarker* LM6 = new TMarker(80.,400.,20);
    
  LM0->SetMarkerSize(1.2);
  LM1->SetMarkerSize(1.2);
    
  TLatex* tLM0 = new TLatex(205.,160.," LM0");
  tLM0->SetTextSize(0.035);
    
  TLatex* tLM1 = new TLatex(80.,245.,"LM1");
  tLM1->SetTextSize(0.035);
  
  //TLatex* tLM3 = new TLatex(350.,235.,"LM3 (tan#beta=20)");
  TLatex* tLM3 = new TLatex(350.,235.,"LM3");
  tLM3->SetTextSize(0.035);
  
  TLatex* tLM6 = new TLatex(100.,395.,"LM6");
  tLM6->SetTextSize(0.035);
  
  //  if (tanBeta_ != 50){
  //  LM0->Draw("same");   
  //  tLM0->Draw("same");
  //  LM1->Draw("same");   
  //  tLM1->Draw("same");
  // }

  /*
  if (tanBeta_ == 10){ 
    LM1->Draw("same");
    tLM1->Draw("same");
    LM3->Draw("same");
    tLM3->Draw("same");
    LM6->Draw("same");
    tLM6->Draw("same");
  }
  */



  //stau=LSP contour
  stau->Draw("fsame");
  NoEWSB->Draw("fsame");
 
  //legends
  legexp->Draw();
  legst->Draw();
  //legNoEWSB->Draw();
  //myleg->Draw();

  hist->Draw("sameaxis");
  cvsSys->RedrawAxis();
  cvsSys->Update();
  //cvsSys->Write();
  
  // plots are made here
  //if( plotLO_ ){
  //  cvsSys->SaveAs("ExclusionLimit_tanb"+tanb+"_LO.pdf");
  //  cvsSys->SaveAs("ExclusionLimit_tanb"+tanb+"_LO.png");
  //}else{
  //  cvsSys->SaveAs("ExclusionLimit_tanb"+tanb+".eps");
  //  cvsSys->SaveAs("ExclusionLimit_tanb"+tanb+".pdf");
  //  cvsSys->SaveAs("ExclusionLimit_tanb"+tanb+".png");
  //}                 
  
  return cvsSys;
  //output->Write();
  //output->Close();
  //delete output; 
  
}
コード例 #27
0
ファイル: CheckTrigger.C プロジェクト: LightninGreen/acqu
CheckTrigger(){
  Char_t* hname[] = {
    "Trigger",
    "MAMIHelicity",
    "Multiplicity",
    "Multiplicity_NHits",
    "ScInt4",
    "ScFC",
    "ScG175",
    "ScFarady",
    "ScP2Faraday",
    "ScP2Tagger",
    "ScCBEsum",
    "ScTAPSM1",
    "ScTAPSM2",
    "ScCher",
    "ScTAPSPed",
 };
  Char_t* xname[] = {
    "L1 (0-16) & L2 (16-24) CB Trigger Pattern",
    "Beam Helicity (0-4)",
    "Hits in multiplicity circuit",
    "Number multiplicity hits",
    "Interrupt rate (Hz)",
    "Fast Clear (Hz)",
    "Tagger G175 Rate (kHz)",
    "Faraday Cup rate (Hz)",
    "P2/Faraday-Cup Ratio",
    "P2/Tagger-G175 Ratio",
    "CB Energy Sum-low Rate",
    "TAPS M1 Rate",
    "TAPS M2 Rate",
    "Cherenkov Rate",
    "TAPS Pedestal Rate"
};
  Char_t* hname2[] = {
    "TwoD2000v1400",
    //    "TwoD20401v2005M0",
  };
  Char_t* xname2[] = {
    " CB-Tagger Synch = Straight Line",
    //    " CB - TAPS Synchronised = Small Dot",
  };
  Int_t log[] = { 1,1,1,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0 };
  Int_t col[] = { 4,4,4,4,2,2,2,2,5,5,5,5,3,3,3,3,2,2,2,2,5,5,5 };
 //
  TH1F* h1;
  TCanvas* canv;
  canv = new TCanvas("Scaler-Spectra","Scaler Spectra & Synchronisation",240,180,1240,890);
  canv->SetFillStyle(4000);
  canv->Divide(4,4,0.01,0.01);
  for( Int_t i=0; i<15; i++ ){
      h1 = (TH1F*)(gROOT->FindObject(hname[i]));
      if( !h1 ){ printf("No root histogram %s\n",hname[i]); continue; }
      h1->SetLineColor( 1 );
      h1->SetFillColor( col[i] );
      canv->cd(i+1);
      if( log[i]==1 ) canv->GetPad(i+1)->SetLogy();
      h1->GetXaxis()->SetTitle(xname[i]);
      h1->Draw();
  }
  TH2F* h2;
  for( Int_t i=0; i<1; i++ ){
    h2 = (TH2F*)(gROOT->FindObject(hname2[i]));
    if( !h2 ){ printf("No root histogram %s\n",hname[i]); continue; }
    canv->cd(i+16);
    if( log[i] ) canv->GetPad(i+1)->SetLogz();
    h2->GetXaxis()->SetTitle(xname2[i]);
    h2->Draw("COLZ");
  }
}
コード例 #28
0
ファイル: TTMnS2.C プロジェクト: Hosein47/usercode
void TTMnS2 () {
  
  const int nbins=400;
  
  TFile * QCD[8];     
  QCD[0] = new TFile("./root/TagMassVsTagNTrk_EXTRA_QCD_30-50_plots.root");
  QCD[1] = new TFile("./root/TagMassVsTagNTrk_EXTRA_QCD_50-80_plots.root");
  QCD[2] = new TFile("./root/TagMassVsTagNTrk_EXTRA_QCD_80-120_plots.root");
  QCD[3] = new TFile("./root/TagMassVsTagNTrk_EXTRA_QCD_120-170_plots.root");
  QCD[4] = new TFile("./root/TagMassVsTagNTrk_EXTRA_QCD_170-230_plots.root");
  QCD[5] = new TFile("./root/TagMassVsTagNTrk_EXTRA_QCD_230-300_plots.root");
  QCD[6] = new TFile("./root/TagMassVsTagNTrk_EXTRA_QCD_300-380_plots.root");
  QCD[7] = new TFile("./root/TagMassVsTagNTrk_EXTRA_QCD_380-incl_plots.root");
  double QCDxs[8] = { 155929000., 20938850., 2949713., 499656., 100995.,  23855., 6391., 2821.};
  // For extra QCD:
  double NQCD[8] = { 130000., 133096., 281096, 164000., 436000., 346000., 418000., 406000. };
  // For normal QCD:
  // double NQCD[8] = { 86000., 78000., 104000., 96000., 100000., 102000., 112000., 102000.};
  
  double Lumfactor = 100000; // 100/fb of luminosity assumed in histograms
  
  TH1D * H = dynamic_cast<TH1D*> (QCD[0]->Get("MTS2_0"));

  double minx=H->GetBinLowEdge(1);
  double maxx=nbins*H->GetBinWidth(1)+minx;
  TH1D * MT[8]; 
  TH1D * MN[8]; 
  for ( int i=0; i<8; i++ ) {
    char Ename[20];
    char Pname[20];
    sprintf ( Ename, "MTS2_%d", i );
    sprintf ( Pname, "MNS2_%d", i );
    MT[i] = new TH1D ( Ename, Ename, nbins, minx, maxx );
    MN[i] = new TH1D ( Pname, Pname, nbins, minx, maxx );
  }

  for ( int iN=0; iN<8; iN++ ) {
    char nameT[20];
    char nameN[20];
    sprintf ( nameT, "MTS2_%d", iN );
    sprintf ( nameN, "MNS2_%d", iN );
    double tot1[nbins]={0.};
    double s2_tot1[nbins]={0.};
    double tot2[nbins]={0.};
    double s2_tot2[nbins]={0.};
    for ( int i=0; i<8; i++ ) {
      MTtmp = dynamic_cast<TH1D*>(QCD[i]->Get(nameT));
      MNtmp = dynamic_cast<TH1D*>(QCD[i]->Get(nameN));
      cout << "Got histogram " << iN << endl;
      for ( int ibin=1; ibin<=nbins; ibin++ ) {
	double t1=MTtmp->GetBinContent(ibin);
	tot1[ibin-1]+=t1*QCDxs[i]/NQCD[i]*Lumfactor;
	s2_tot1[ibin-1]+=t1*pow(QCDxs[i]/NQCD[i]*Lumfactor,2);
	double t2=MNtmp->GetBinContent(ibin);
	tot2[ibin-1]+=t2*QCDxs[i]/NQCD[i]*Lumfactor;
	s2_tot2[ibin-1]+=t2*pow(QCDxs[i]/NQCD[i]*Lumfactor,2);
      }
    }
    if ( iN==7 ) {  // Fix split histogram for Nt=9 && >9
      sprintf ( nameT, "MTS2_%d", iN+1 );
      sprintf ( nameN, "MNS2_%d", iN+1);
      for ( int i=0; i<8; i++ ) {
	MTtmp = dynamic_cast<TH1D*>(QCD[i]->Get(nameT));
	MNtmp = dynamic_cast<TH1D*>(QCD[i]->Get(nameN));
	for ( int ibin=1; ibin<=nbins; ibin++ ) {
	  double t1=MTtmp->GetBinContent(ibin);
	  tot1[ibin-1]+=t1*QCDxs[i]/NQCD[i]*Lumfactor;
	  s2_tot1[ibin-1]+=t1*pow(QCDxs[i]/NQCD[i]*Lumfactor,2);
	  double t2=MNtmp->GetBinContent(ibin);
	  tot2[ibin-1]+=t2*QCDxs[i]/NQCD[i]*Lumfactor;
	  s2_tot2[ibin-1]+=t2*pow(QCDxs[i]/NQCD[i]*Lumfactor,2);
	}
      }
    }
    // Now renormalize histograms
    // --------------------------
    double i1=0.;
    double i2=0.;
    for ( int ibin=1; ibin<=nbins; ibin++ ) {
      i1+=tot1[ibin-1];
      i2+=tot2[ibin-1];
    }
    for ( int ibin=1; ibin<=nbins; ibin++ ) {
      MT[iN]->SetBinContent(ibin,tot1[ibin-1]/i1);
      MT[iN]->SetBinError(ibin,sqrt(s2_tot1[ibin-1])/i1);
      MN[iN]->SetBinContent(ibin,tot2[ibin-1]/i2);
      MN[iN]->SetBinError(ibin,sqrt(s2_tot2[ibin-1])/i2);
    }
  } // iN
  
  TCanvas * b = new TCanvas ("b", "Total Tag masses", 700, 700 );
  b->Divide(2,2);
  
  b->cd(1);
  b->GetPad(1)->SetLogy();
  MT[0]->SetMarkerStyle(20);
  MT[0]->SetMarkerSize(0.4);
  MT[0]->SetMarkerColor(kBlue);
  MT[0]->SetLineColor(kBlue);
  MT[0]->DrawCopy("PE");
  MT[1]->SetMarkerStyle(21);
  MT[1]->SetMarkerSize(0.4);
  MT[1]->SetMarkerColor(kRed);
  MT[1]->SetLineColor(kRed);
  MT[1]->DrawCopy("PESAME");
  MT[2]->SetMarkerStyle(24);
  MT[2]->SetMarkerSize(0.4);
  MT[2]->SetMarkerColor(kBlack);
  MT[2]->SetLineColor(kBlack);
  MT[2]->DrawCopy("PESAME");
  MT[3]->SetMarkerStyle(25);
  MT[3]->SetMarkerSize(0.4);
  MT[3]->SetMarkerColor(kGreen);
  MT[3]->SetLineColor(kGreen);
  MT[3]->DrawCopy("PESAME");
  b->cd(2);
  b->GetPad(2)->SetLogy();
  MT[4]->SetMarkerStyle(20);
  MT[4]->SetMarkerSize(0.4);
  MT[4]->SetMarkerColor(kBlue);
  MT[4]->SetLineColor(kBlue);
  MT[4]->DrawCopy("PE");
  MT[5]->SetMarkerStyle(21);
  MT[5]->SetMarkerSize(0.4);
  MT[5]->SetMarkerColor(kRed);
  MT[5]->SetLineColor(kRed);
  MT[5]->DrawCopy("PESAME");
  MT[6]->SetMarkerStyle(24);
  MT[6]->SetMarkerSize(0.4);
  MT[6]->SetMarkerColor(kBlack);
  MT[6]->SetLineColor(kBlack);
  MT[6]->DrawCopy("PESAME");
  MT[7]->SetMarkerStyle(25);
  MT[7]->SetMarkerSize(0.4);
  MT[7]->SetMarkerColor(kGreen);
  MT[7]->SetLineColor(kGreen);
  MT[7]->DrawCopy("PESAME");
  b->cd(3);
  b->GetPad(3)->SetLogy();
  MN[0]->SetMarkerStyle(20);
  MN[0]->SetMarkerSize(0.4);
  MN[0]->SetMarkerColor(kBlue);
  MN[0]->SetLineColor(kBlue);
  MN[0]->DrawCopy("PE");
  MN[1]->SetMarkerStyle(21);
  MN[1]->SetMarkerSize(0.4);
  MN[1]->SetMarkerColor(kRed);
  MN[1]->SetLineColor(kRed);
  MN[1]->DrawCopy("PESAME");
  MN[2]->SetMarkerStyle(24);
  MN[2]->SetMarkerSize(0.4);
  MN[2]->SetMarkerColor(kBlack);
  MN[2]->SetLineColor(kBlack);
  MN[2]->DrawCopy("PESAME");
  MN[3]->SetMarkerStyle(25);
  MN[3]->SetMarkerSize(0.4);
  MN[3]->SetMarkerColor(kGreen);
  MN[3]->SetLineColor(kGreen);
  MN[3]->DrawCopy("PESAME");
  b->cd(4);
  b->GetPad(4)->SetLogy();
  MN[4]->SetMarkerStyle(20);
  MN[4]->SetMarkerSize(0.4);
  MN[4]->SetMarkerColor(kBlue);
  MN[4]->SetLineColor(kBlue);
  MN[4]->DrawCopy("PE");
  MN[5]->SetMarkerStyle(21);
  MN[5]->SetMarkerSize(0.4);
  MN[5]->SetMarkerColor(kRed);
  MN[5]->SetLineColor(kRed);
  MN[5]->DrawCopy("PESAME");
  MN[6]->SetMarkerStyle(24);
  MN[6]->SetMarkerSize(0.4);
  MN[6]->SetMarkerColor(kBlack);
  MN[6]->SetLineColor(kBlack);
  MN[6]->DrawCopy("PESAME");
  MN[7]->SetMarkerStyle(25);
  MN[7]->SetMarkerSize(0.4);
  MN[7]->SetMarkerColor(kGreen);
  MN[7]->SetLineColor(kGreen);
  MN[7]->DrawCopy("PESAME");
  b->Print("./ps/TTMnS2.ps");
  
  // Close files
  // -----------
  TFile * File = new TFile ("TTMnS2.root","RECREATE");
  File->cd();
  for ( int i=0; i<8; i++ ) {
    MT[i]->Write();
    MN[i]->Write();
  }
  File->Close();
  
}
コード例 #29
0
void Draw_BDiJetImbalance()
{
  gStyle->SetOptStat(0);
  gStyle->SetOptTitle(0);

  //==========================================================================//
  // SET RUNNING CONDITIONS
  //==========================================================================//
  bool print_plots = true;

  bool is_pp = false;

  // const char* inFile = "HFtag_bjet.root";
  // const char* inFile = "HFtag_bjet_pp.root";
  // const char* inFile = "/phenix/plhf/dcm07e/sPHENIX/bjetsims/test.root";
  // if (!is_pp)
  //   const char* inFile = "HFtag_bjet_AuAu0-10.root";

  const char* inDir = "/phenix/plhf/dcm07e/sPHENIX/bjetsims/ana";

  // // desired nn integrated luminosity [pb^{-1}]
  // double lumiDesired = 175;
  // if ( !is_pp )
  //   lumiDesired = 229; // AuAu 0-10% central (10B events)
  // desired nn integrated luminosity [pb^{-1}]
  double lumiDesired = 200;
  TString scol("p + p #sqrt{s_{_{NN}}} = 200 GeV");
  TString slumi(Form("#int L dt = %.0f pb^{-1} |z| < 10 cm", lumiDesired));
  if ( !is_pp )
  {
    // equivelant nn luminosity:
    // N_{evt}^{NN} / sigma_NN = N_{evt}^{AA}*Ncoll / sigma_NN
    // = 10e9 * 962 / 42e9 pb = 229 pb^-1
    double evntDesired = 24e9; // AuAu 0-10% central
    lumiDesired = evntDesired * 962 / 42e9; // AuAu 0-10% central
    scol = "0-10% Au + Au #sqrt{s_{_{NN}}}=200 GeV";
    slumi = Form("%.0fB events |z| < 10 cm", evntDesired / 1.e9);
  }

  // luminosity per file generated [pb^{-1}]
  double lumiPerFile = 99405 / (4.641e-06 * 1e12);
  double lumiRead = 0;

  double pT1min = 20;
  double pT2min = 10;
  // double etamax = 1.0;
  double etamax = 0.7;

  // double bJetEff = 0.5; // b-jet tagging efficiency
  double bJetEff = 0.60; // p+p b-jet tagging efficiency
  if ( !is_pp )
    bJetEff = 0.40;

  double bJetPur = 0.40; // b-jet tagging purity

  double RAA = 1.0;
  if (!is_pp)
    RAA = 0.6;

  const int NETACUT = 3;
  double etacut[] = {1.3, 1.0, 0.7};
  double etaColor[] = {kBlue, kRed, kBlack};

  const int PTCUT = 3;
  double ptcut[] = {10, 20, 40};
  double ptColor[] = {kBlue, kRed, kBlack};

  //==========================================================================//
  // DECLARE VARIABLES
  //==========================================================================//

  //-- tree variables
  TChain *ttree;
  Int_t           event;
  Int_t           truthjet_n;
  Int_t           truthjet_parton_flavor[100];
  Int_t           truthjet_hadron_flavor[100];
  Float_t         truthjet_pt[100];
  Float_t         truthjet_eta[100];
  Float_t         truthjet_phi[100];

  //-- histograms

  TH1D* hjet_pT = new TH1D("hjet_pT", ";p_{T}^{jet} [GeV/c]", 20, 0, 100);
  TH1D* hjet_eta = new TH1D("hjet_eta", ";#eta^{jet}", 40, -2., 2.);
  TH1D* hjet_phi = new TH1D("hjet_phi", ";#phi^{jet}", 40, -4, 4);

  TH1D* hdijet_pT1 = new TH1D("hdijet_pT1", ";p_{T,1}^{jet} [GeV/c]", 20, 0, 100);
  TH1D* hdijet_pT2 = new TH1D("hdijet_pT2", ";p_{T,2}^{jet} [GeV/c]", 20, 0, 100);
  TH1D* hdijet_xj = new TH1D("hdijet_xj", ";x_{j} = p_{T,2} / p_{T,1}; event fraction", 10, 0, 1);
  TH1D* hdijet_dphi = new TH1D("hdijet_dphi", ";|#Delta#phi_{12}|; event fraction", 10, 0, TMath::Pi());

  TH1D* hdijet_sing_pT1 = new TH1D("hdijet_sing_pT1",
                                   ";p_{T,1} [GeV/c];Fraction of Dijet / Single Accepted",
                                   20, 00, 100);
  TH1D* hdijet_sing_eta2 = new TH1D("hdijet_sing_eta2",
                                    ";#eta_{2};Fraction of Dijet / Single Accepted",
                                    15, -1.5, 1.5);
  TH1D* hdijet_eff_pT1[3];
  TH1D* hdijet_eff_eta2[3];
  for (int i = 0; i < NETACUT; i++)
  {
    hdijet_eff_pT1[i] = new TH1D(Form("hdijet_eff_pT1_%i", i),
                                 ";p_{T,1} [GeV/c];Fraction of Dijet / Single Accepted",
                                 20, 00, 100);
    hdijet_eff_pT1[i]->SetLineColor(etaColor[i]);
    hdijet_eff_pT1[i]->SetLineWidth(2);
  } // i
  for (int i = 0; i < PTCUT; i++)
  {
    hdijet_eff_eta2[i] = new TH1D(Form("hdijet_eff_eta2_%i", i),
                                  ";#eta;Fraction of Dijet / Single Accepted",
                                  15, -1.5, 1.5);
    hdijet_eff_eta2[i]->SetLineColor(etaColor[i]);
    hdijet_eff_eta2[i]->SetLineWidth(2);
  } // i

  hjet_pT->Sumw2();
  hjet_eta->Sumw2();
  hjet_phi->Sumw2();

  hdijet_pT1->Sumw2();
  hdijet_pT2->Sumw2();
  hdijet_dphi->Sumw2();
  hdijet_xj->Sumw2();

  // for fixing the uncertainties
  TH1D* hdijet_xj_fix;

  //-- other
  TRandom3 *rand = new TRandom3();

  bool acc[100];

  //==========================================================================//
  // LOAD TTREE
  //==========================================================================//
  // cout << endl;
  // cout << "--> Reading data from " << inFile << endl;

  // TFile *fin = TFile::Open(inFile);
  // if (!fin)
  // {
  //   cout << "ERROR!! Unable to open " << inFile << endl;
  //   return;
  // }

  // ttree = (TTree*) fin->Get("ttree");
  // if (!ttree)
  // {
  //   cout << "ERROR!! Unable to find ttree in " << inFile << endl;
  //   return;
  // }

  cout << endl;
  cout << "--> Reading data from dir: " << inDir << endl;

  // calculate the number of files necessary for the desired luminosity
  int nfiles = (int)(lumiDesired / lumiPerFile);
  cout << "  desired luminosity : " << lumiDesired << endl;
  cout << "  luminosity per file: " << lumiPerFile << endl;
  cout << "  N files needed     : " << nfiles << endl;


  // check the number of files found in the directory
  int nfound = (gSystem->GetFromPipe(Form("ls %s/*.root | wc -l", inDir))).Atoi();
  cout << "  N files found      : " << nfound << endl;

  if (nfound < nfiles)
  {
    cout << "WARNING!! There are not enough files for the desired luminosity." << endl;
    cout << "          Will scale the statistical uncertainties accordingly." << endl;
    // return;
  }

  // chain the desired files
  ttree = new TChain("ttree");
  int nread = 0;

  TString fileList = gSystem->GetFromPipe(Form("ls %s/*.root", inDir));

  int spos = fileList.First("\n");
  while (spos > 0 && nread < nfiles)
  {
    TString tfile = fileList(0, spos);
    // cout << tsub << endl;

    ttree->Add(tfile.Data());


    // chop off the file
    fileList = fileList(spos + 1, fileList.Length());
    spos = fileList.First("\n");
    nread++;
  }

  cout << " successfully read in " << nread << " files" << endl;
  lumiRead = lumiPerFile * nread;


  ttree->SetBranchAddress("event", &event);
  ttree->SetBranchAddress("truthjet_n", &truthjet_n);
  ttree->SetBranchAddress("truthjet_parton_flavor", truthjet_parton_flavor);
  ttree->SetBranchAddress("truthjet_hadron_flavor", truthjet_hadron_flavor);
  ttree->SetBranchAddress("truthjet_pt", truthjet_pt);
  ttree->SetBranchAddress("truthjet_eta", truthjet_eta);
  ttree->SetBranchAddress("truthjet_phi", truthjet_phi);

  Long64_t nentries = ttree->GetEntries();


  //==========================================================================//
  // GET MOMENTUM IMBALANCE
  //==========================================================================//
  cout << endl;
  cout << "--> Running over " << nentries << endl;

  int iprint = 0;
  for (Long64_t ientry = 0; ientry < nentries; ientry++)
  {
    ttree->GetEntry(ientry);

    if (ientry % 100000 == 0) cout << "----> Processing event " << ientry << endl;

    //-- apply acceptance to each jet
    for (int i = 0; i < truthjet_n; i++)
      acc[i] = (rand->Uniform() < bJetEff);
      // acc[i] = (rand->Uniform() < bJetEff) && (rand->Uniform() < RAA);

    //-- get kinematics for all b-jets
    for (int i = 0; i < truthjet_n; i++)
    {
      if (TMath::Abs(truthjet_parton_flavor[i]) != 5)
        continue;

      // single b-jet kinematics
      hjet_pT->Fill(truthjet_pt[i]);
      hjet_eta->Fill(truthjet_eta[i]);
      hjet_phi->Fill(truthjet_phi[i]);

      for (int j = i + 1; j < truthjet_n; j++)
      {
        if (TMath::Abs(truthjet_parton_flavor[j]) != 5)
          continue;


        // find the leading and subleading jets
        int i1, i2;
        double pT1, pT2;
        double phi1, phi2;
        double eta1, eta2;
        bool acc1, acc2;

        if (truthjet_pt[i] > truthjet_pt[j])
        {
          i1 = i;
          i2 = j;
        }
        else
        {
          i1 = j;
          i2 = i;
        }

        pT1 = truthjet_pt[i1];
        phi1 = truthjet_phi[i1];
        eta1 = truthjet_eta[i1];
        acc1 = acc[i1];

        pT2 = truthjet_pt[i2];
        phi2 = truthjet_phi[i2];
        eta2 = truthjet_eta[i2];
        acc2 = acc[i2];



        if (iprint < 20)
        {
          cout << " ientry: " << ientry << endl
               << "        i1:" << i1 << " pT1:" << pT1 << " eta1:" << eta1 << " acc1:" << acc1 << endl
               << "        i2:" << i2 << " pT2:" << pT2 << " eta2:" << eta2 << " acc2:" << acc2 << endl;
          iprint++;
        }



        // check if we accept the leading jet
        // only take RAA hit once
        if ( pT1 < pT1min || TMath::Abs(eta1) > etamax || !acc1  || rand->Uniform() > RAA)
          continue;

        // calculate the delta phi
        double dphi = TMath::Abs(TMath::ATan2(TMath::Sin(phi1 - phi2), TMath::Cos(phi1 - phi2)));
        if (dphi > TMath::Pi())
          cout << " " << truthjet_phi[i] << " " << truthjet_phi[j] << " " << dphi << endl;

        // calculate efficiency for finding the dijet
        hdijet_sing_pT1->Fill(pT1);

        // cut on the subleading jet
        if ( pT2 < pT2min || TMath::Abs(eta2) > etamax || !acc2 )
          continue;

        hdijet_sing_eta2->Fill(eta2);


        // fill efficiency for finding the dijet
        for (int k = 0; k < NETACUT; k++)
        {
          if ( TMath::Abs(eta2) < etacut[k])
            hdijet_eff_pT1[k]->Fill(pT1);
        }
        for (int k = 0; k < PTCUT; k++)
        {
          if (pT2 > ptcut[k])
            hdijet_eff_eta2[k]->Fill(eta2);
        }

        hdijet_dphi->Fill(dphi);

        if ( dphi < 2.*TMath::Pi() / 3)
          continue;


        // fill diagnostic histograms

        hdijet_pT1->Fill(pT1);
        hdijet_pT2->Fill(pT2);
        hdijet_xj->Fill(pT2 / pT1);

      } // j
    } // i

  } // ientry

  // first get some statistics
  cout << " N b dijets: " << hdijet_dphi->Integral() << endl;
  cout << " N b dijets w / dphi cut: " << hdijet_xj->Integral() << endl;

  // calculate efficiencies
  for (int i = 0; i < NETACUT; i++)
  {
    hdijet_eff_pT1[i]->Divide(hdijet_sing_pT1);
    cout << " i: " << hdijet_eff_pT1[i]->GetMaximum() << endl;
  }
  for (int i = 0; i < PTCUT; i++)
  {
    hdijet_eff_eta2[i]->Divide(hdijet_sing_eta2);
  }

  //-- normalize to integral 1
  hdijet_dphi->Scale(1. / hdijet_dphi->Integral());
  hdijet_xj->Scale(1. / hdijet_xj->Integral());

  //-- scale statistical uncertainties if not enough simulated events
  if ( lumiRead < lumiDesired )
  {
    cout << endl;
    cout << "-- Scaling statistical uncertainties by:" << endl;
    cout << "  sqrt(" << lumiRead << "/" << lumiDesired << ") = "
         << TMath::Sqrt(lumiRead / lumiDesired) << endl;
    for (int ix = 1; ix <= hdijet_xj->GetNbinsX(); ix++)
    {
      double be = hdijet_xj->GetBinError(ix);
      be = be * TMath::Sqrt(lumiRead / lumiDesired);
      hdijet_xj->SetBinError(ix, be);
    } // ix
  }

  //-- fix statistical uncertainties for purity
  hdijet_xj_fix = (TH1D*) hdijet_xj->Clone("hdijet_xj_fix");
  hdijet_xj_fix->SetLineColor(kRed);
  hdijet_xj_fix->SetMarkerColor(kRed);
  for (int ix = 1; ix <= hdijet_xj->GetNbinsX(); ix++)
  {
    double bc = hdijet_xj->GetBinContent(ix);
    double be = hdijet_xj->GetBinError(ix);

    // increase the bin error due to the purity
    // need to square it, once for each bjet
    be = be / TMath::Sqrt(bJetPur * bJetPur);
    hdijet_xj_fix->SetBinError(ix, be);
  } // ix



  //==========================================================================//
  // <x_j>
  //==========================================================================//
  cout << endl;
  cout << "--> Calculating <x_j>" << endl;

  double sum = 0;
  double w = 0;
  double err = 0;
  for (int i = 1; i <= hdijet_xj->GetNbinsX(); i++)
  {
    double c = hdijet_xj->GetBinContent(i);
    if (c > 0)
    {
      sum += c * hdijet_xj->GetBinCenter(i);
      w += c;
      err += TMath::Power(c * hdijet_xj->GetBinError(i), 2);
    }
  }
  double mean = sum / w;
  err = TMath::Sqrt(err) / w;

  cout << "  <x_j>=" << mean << " +/- " << err << endl;

  //==========================================================================//
  // PLOT OBJECTS
  //==========================================================================//
  cout << endl;
  cout << "-- > Plotting" << endl;

  hdijet_xj->SetMarkerStyle(kFullCircle);
  hdijet_xj->SetMarkerColor(kBlack);
  hdijet_xj->SetLineColor(kBlack);
  // hdijet_xj->GetYaxis()->SetTitleFont(63);
  // hdijet_xj->GetYaxis()->SetTitleSize(24);
  // hdijet_xj->GetYaxis()->SetTitleOffset(1.4);
  // hdijet_xj->GetYaxis()->SetLabelFont(63);
  // hdijet_xj->GetYaxis()->SetLabelSize(20);
  // hdijet_xj->GetXaxis()->SetTitleFont(63);
  // hdijet_xj->GetXaxis()->SetTitleSize(24);
  // hdijet_xj->GetXaxis()->SetTitleOffset(1.0);
  // hdijet_xj->GetXaxis()->SetLabelFont(63);
  // hdijet_xj->GetXaxis()->SetLabelSize(20);

  hdijet_xj_fix->SetMarkerStyle(kFullCircle);
  hdijet_xj_fix->SetMarkerColor(kBlack);
  hdijet_xj_fix->SetLineColor(kBlack);

  hdijet_dphi->SetMarkerStyle(kFullCircle);
  hdijet_dphi->SetMarkerColor(kBlack);
  hdijet_dphi->SetLineColor(kBlack);
  hdijet_dphi->GetYaxis()->SetTitleFont(63);
  hdijet_dphi->GetYaxis()->SetTitleSize(24);
  hdijet_dphi->GetYaxis()->SetTitleOffset(1.4);
  hdijet_dphi->GetYaxis()->SetLabelFont(63);
  hdijet_dphi->GetYaxis()->SetLabelSize(20);
  hdijet_dphi->GetXaxis()->SetTitleFont(63);
  hdijet_dphi->GetXaxis()->SetTitleSize(24);
  hdijet_dphi->GetXaxis()->SetTitleOffset(1.0);
  hdijet_dphi->GetXaxis()->SetLabelFont(63);
  hdijet_dphi->GetXaxis()->SetLabelSize(20);

  hdijet_pT1->SetLineColor(kBlue);
  hdijet_pT2->SetLineColor(kRed);

  TH1D* heff_axis_pt = new TH1D("heff_axis_pt",
                                "; p_{T, 1} [GeV / c]; Fraction of Dijet / Single Accepted",
                                20, 00, 100);
  heff_axis_pt->SetMinimum(0);
  heff_axis_pt->SetMaximum(1.);
  heff_axis_pt->GetYaxis()->SetTitleFont(63);
  heff_axis_pt->GetYaxis()->SetTitleSize(24);
  heff_axis_pt->GetYaxis()->SetTitleOffset(1.4);
  heff_axis_pt->GetYaxis()->SetLabelFont(63);
  heff_axis_pt->GetYaxis()->SetLabelSize(20);
  heff_axis_pt->GetXaxis()->SetTitleFont(63);
  heff_axis_pt->GetXaxis()->SetTitleSize(24);
  heff_axis_pt->GetXaxis()->SetTitleOffset(1.0);
  heff_axis_pt->GetXaxis()->SetLabelFont(63);
  heff_axis_pt->GetXaxis()->SetLabelSize(20);

  TH1D* heff_axis_eta = new TH1D("heff_axis_eta",
                                 "; #eta_{2}; Fraction of Dijet / Single Accepted",
                                 150, -1.5, 1.5);
  heff_axis_eta->SetMinimum(0);
  heff_axis_eta->SetMaximum(1.);
  heff_axis_eta->GetYaxis()->SetTitleFont(63);
  heff_axis_eta->GetYaxis()->SetTitleSize(24);
  heff_axis_eta->GetYaxis()->SetTitleOffset(1.4);
  heff_axis_eta->GetYaxis()->SetLabelFont(63);
  heff_axis_eta->GetYaxis()->SetLabelSize(20);
  heff_axis_eta->GetXaxis()->SetTitleFont(63);
  heff_axis_eta->GetXaxis()->SetTitleSize(24);
  heff_axis_eta->GetXaxis()->SetTitleOffset(1.0);
  heff_axis_eta->GetXaxis()->SetLabelFont(63);
  heff_axis_eta->GetXaxis()->SetLabelSize(20);

  for (int i = 0; i < NETACUT; i++)
    hdijet_eff_pT1[i]->SetLineColor(etaColor[i]);

//-- legends
  TLegend *leg_jetpt = new TLegend(0.6, 0.5, 0.95, 0.95);
  leg_jetpt->SetFillStyle(0);
  leg_jetpt->SetBorderSize(0);
  leg_jetpt->SetTextFont(63);
  leg_jetpt->SetTextSize(12);
  leg_jetpt->AddEntry(hjet_pT, "Inclusive b - jet", "L");
  leg_jetpt->AddEntry(hdijet_pT1, "leading b - jet", "L");
  leg_jetpt->AddEntry(hdijet_pT2, "subleading b - jet", "L");


//-- other
  TLatex ltxt;
  ltxt.SetNDC();
  ltxt.SetTextFont(63);
  ltxt.SetTextSize(20);

//==========================================================================//
// PLOT
//==========================================================================//

// plot b-jet kinematics
  TCanvas *cjet = new TCanvas("cjet", "b - jet", 1200, 400);
  cjet->SetMargin(0, 0, 0, 0);
  cjet->Divide(3, 1);

  cjet->GetPad(1)->SetMargin(0.12, 0.02, 0.12, 0.02);
  cjet->GetPad(2)->SetMargin(0.12, 0.02, 0.12, 0.02);
  cjet->GetPad(3)->SetMargin(0.12, 0.02, 0.12, 0.02);

  cjet->cd(1);
  gPad->SetLogy();
  hjet_pT->GetYaxis()->SetRangeUser(0.5, 1.5 * hjet_pT->GetMaximum());
  hjet_pT->GetXaxis()->SetRangeUser(0, 50);
  hjet_pT->Draw();
  // hdijet_pT1->Draw("same");
  // hdijet_pT2->Draw("same");

  // leg_jetpt->Draw("same");

  cjet->cd(2);
  hjet_eta->Draw("HIST");

  cjet->cd(3);
  hjet_phi->Draw("HIST");


// plot dijet eff
  TCanvas *ceff = new TCanvas("ceff", "eff", 1200, 600);
  ceff->Divide(2, 1);
  ceff->GetPad(1)->SetMargin(0.12, 0.02, 0.12, 0.02);
  ceff->GetPad(1)->SetTicks(1, 1);
  ceff->GetPad(2)->SetMargin(0.12, 0.02, 0.12, 0.02);
  ceff->GetPad(2)->SetTicks(1, 1);

  ceff->cd(1);

  heff_axis_pt->Draw();

  for (int i = 0; i < NETACUT; i++)
    hdijet_eff_pT1[i]->Draw("L same");

  ceff->cd(2);

  heff_axis_eta->Draw();

  for (int i = 0; i < NETACUT; i++)
    hdijet_eff_eta2[i]->Draw("L same");

// plot dijet checks
  TCanvas *cdijet2 = new TCanvas("cdijet2", "dijet", 1200, 600);
  cdijet2->SetMargin(0, 0, 0, 0);
  cdijet2->Divide(2, 1);

  cdijet2->GetPad(1)->SetMargin(0.12, 0.02, 0.12, 0.02);
  cdijet2->GetPad(2)->SetMargin(0.12, 0.02, 0.12, 0.02);

  cdijet2->cd(1);
  hdijet_xj->Draw();

  ltxt.DrawLatex(0.2, 0.92, "Di b-jets (Pythia8)");
  ltxt.DrawLatex(0.2, 0.86, "p + p #sqrt{s_{_{NN}}}=200 GeV");
  ltxt.DrawLatex(0.2, 0.80, "anti - k_ {T}, R = 0.4");
  ltxt.DrawLatex(0.2, 0.74, Form("p_{T, 1} > % .0f GeV", pT1min));
  ltxt.DrawLatex(0.2, 0.68, Form("p_{T, 2} > % .0f GeV", pT2min));
  ltxt.DrawLatex(0.2, 0.62, Form(" | #Delta#phi_{12}| > 2#pi/3"));

  cdijet2->cd(2);
  hdijet_dphi->Draw();






  // make this one consistent with sPHENIX style
  TCanvas *cdijet = new TCanvas("cdijet", "dijet", 600, 600);
  // cdijet->SetMargin(0.12, 0.02, 0.12, 0.02);
  // cdijet->SetTicks(1, 1);
  cdijet->cd();
  hdijet_xj_fix->GetYaxis()->SetRangeUser(0, 0.3);
  hdijet_xj_fix->Draw();
  // hdijet_xj->Draw("same");


  TLegend *legsphenix = new TLegend(0.15, 0.5, 0.5, 0.9);
  legsphenix->SetFillStyle(0);
  legsphenix->SetBorderSize(0);
  legsphenix->AddEntry("", "#it{#bf{sPHENIX}} Simulation", "");
  legsphenix->AddEntry("", "Di b-jets (Pythia8, CTEQ6L)", "");
  // if (is_pp)
  // {
  //   legsphenix->AddEntry("", "p + p #sqrt{s_{_{NN}}} = 200 GeV", "");
  //   legsphenix->AddEntry("", Form("#int L dt = %.0f pb^{-1} |z| < 10 cm", lumiDesired), "");
  // }
  // else
  // {
  //   legsphenix->AddEntry("", "0-10% Au + Au #sqrt{s_{_{NN}}}=200 GeV", "");
  //   legsphenix->AddEntry("", "10B events |z| < 10 cm", "");
  // }
  legsphenix->AddEntry("", scol.Data(), "");
  legsphenix->AddEntry("", slumi.Data(), "");
  legsphenix->AddEntry("", "anti-k_{T}, R = 0.4", "");
  legsphenix->AddEntry("", Form(" |#eta| < %.1f", etamax), "");
  legsphenix->AddEntry("", Form(" |#Delta#phi_{12}| > 2#pi/3"), "");
  legsphenix->AddEntry("", Form("p_{T, 1} > % .0f GeV", pT1min), "");
  legsphenix->AddEntry("", Form("p_{T, 2} > % .0f GeV", pT2min), "");
  legsphenix->AddEntry("", Form("%.0f%% b-jet Eff, %.0f%% b-jet Pur.", bJetEff * 100., bJetPur * 100.), "");
  legsphenix->Draw("same");

  // ltxt.DrawLatex(0.2, 0.92, "Di b-jets (Pythia8)");
  // if (is_pp)
  // {
  //   ltxt.DrawLatex(0.2, 0.86, "p + p #sqrt{s_{_{NN}}} = 200 GeV");
  //   ltxt.DrawLatex(0.2, 0.80, "#int L dt = 175 pb^{-1} |z| < 10 cm");
  // }
  // else
  // {
  //   ltxt.DrawLatex(0.2, 0.86, "0-10% Au + Au #sqrt{s_{_{NN}}}=200 GeV");
  //   ltxt.DrawLatex(0.2, 0.80, "10B events |z| < 10 cm");
  // }
  // ltxt.DrawLatex(0.2, 0.74, "anti-k_{T}, R = 0.4");
  // ltxt.DrawLatex(0.2, 0.68, Form("p_{T, 1} > % .0f GeV", pT1min));
  // ltxt.DrawLatex(0.2, 0.62, Form("p_{T, 2} > % .0f GeV", pT2min));
  // ltxt.DrawLatex(0.2, 0.56, Form(" |#eta| < %.0f", etamax));
  // ltxt.DrawLatex(0.2, 0.50, Form(" |#Delta#phi_{12}| > 2#pi/3"));


  //==========================================================================//
  // PRINT PLOTS
  //==========================================================================//
  if (print_plots)
  {
    if (is_pp)
    {
      // cjet->Print("bjet_kinematics_pp.pdf");
      // cdijet2->Print("dibjet_2panel_pp.pdf");
      cdijet->Print("dibjet_imbalance_pp.pdf");
      cdijet->Print("dibjet_imbalance_pp.C");
      cdijet->Print("dibjet_imbalance_pp.root");

      TFile *fout = new TFile("dibjet_imbalance_histos_pp.root","RECREATE");
      fout->cd();
      hdijet_xj->Write();
      hdijet_xj_fix->Write();
      fout->Close();
      delete fout;

    }
    else
    {
      cdijet->Print("dibjet_imbalance_AuAu0-10.pdf");
      cdijet->Print("dibjet_imbalance_AuAu0-10.C");
      cdijet->Print("dibjet_imbalance_AuAu0-10.root");

      TFile *fout = new TFile("dibjet_imbalance_histos_AuAu0-10.root","RECREATE");
      fout->cd();
      hdijet_xj->Write();
      hdijet_xj_fix->Write();
      fout->Close();
      delete fout;
    }
  }

}
コード例 #30
0
ファイル: makeEfficiency.C プロジェクト: echapon/UserCode
// const char* infilePairStd="/tmp/camelia/tuple_jpsi_v11_minbias_ptSignal03_pnSimRecoPairType1.root",
// 		    const char* infilePairRegit="/tmp/camelia/tuple_jpsi_v11_minbias_ptSignal03_pnSimRecoPairType2.root",
// 		    const char* infileTrkStd="/tmp/camelia/tuple_jpsi_v11_minbias_ptSignal03_pnSimRecoTrkType1.root",
// 		    const char* infileTrkRegit="/tmp/camelia/tuple_jpsi_v11_minbias_ptSignal03_pnSimRecoTrkType2.root",
//____________________________________________________________________________________
void makeEfficiency(const char* pTuplePairStd="mcmatchanalysis/pnSimRecoPairType1",
		    const char* pTuplePairRegit="mcmatchanalysis/pnSimRecoPairType2",
		    const char* pTupleTrkStd="mcmatchanalysis/pnSimRecoTrkType1",
		    const char* pTupleTrkRegit="mcmatchanalysis/pnSimRecoTrkType2",
		    const char* pOutFilePath="outputfigs",
		    const char* pOutFileName="effs_bjpsi",
		    Bool_t bSavePlots=true)
{
  gROOT->Macro("/afs/cern.ch/user/m/mironov/utilities/setStyle.C+");
  gStyle->SetPalette(1);
  const char* aInFileLocation[4] = {"",
				    // "/tmp/camelia/tuple_jpsi_v11_minbias"
				    "/afs/cern.ch/user/e/echapon/workspace/private/jpsi_PbPb_5_3_17/CMSSW_5_3_17/src/RegitStudy/McAnalyzer/test/ntuples_bjpsi/ntuples_pp",
				    "/afs/cern.ch/user/e/echapon/workspace/private/jpsi_PbPb_5_3_17/CMSSW_5_3_17/src/RegitStudy/McAnalyzer/test/ntuples_bjpsi/ntuples_regit",
				    "/afs/cern.ch/user/e/echapon/workspace/private/jpsi_PbPb_5_3_17/CMSSW_5_3_17/src/RegitStudy/McAnalyzer/test/ntuples_bjpsi/ntuples_regit_3LastRegitStepsAsPp"
				   };
  const int nPtBins = 2;
  const char* aPtSignalBins[nPtBins] = {"",
               ""
					//	"_ptSignal03_",
					//	"_ptSignal36_",
               // "_ptSignal69_",
					//"_ptSignal1215_",
					//	"_ptSignal1530_"
  };
  bool bDoSinglePlots =  true;
  bool bDo2D          = true;
  bool bDoPairPlots   =  true;
  float ptPairMin = 0;
  float ptPairMax = 20;
  int nPtPairBins = 10;

  float ptTrkMin = 0;
  float ptTrkMax = 20;
  int nPtTrkBins = 10;

  TCut pairGenSelection("smuacc(pt1,eta1)&&smuacc(pt2,eta2) &&npixelhits1>2&&npixelhits2>2 &&nmuonhits1>0&&nmuonhits2>0");
  TCut pairRecoSelection("smuacc(ptreco1,etareco1)&&smuacc(ptreco2,etareco2) &&nvalidpixelhitsreco1>2&&nvalidpixelhitsreco2>2 &&nvalidmuonhitsreco1>0&&nvalidmuonhitsreco2>0 &&minvreco>2.6&&minvreco<3.5&&chi2ndofreco1<4&&chi2ndofreco2<4");

  TCut trkGenSelection("TMath::Abs(eta)<2.4&&(abs(idparent)<550&&abs(idparent)>442) &&npixelhits>2&&nmuonhits>0");
  TCut trkRecoSelection("TMath::Abs(eta)<2.4&&(abs(idparent)<550&&abs(idparent)>442) &&nvalidpixelhitsreco>2&&nvalidmuonhitsreco>0 &&nmatch>0&&chi2ndofreco<4");

  // TCut pairGenSelection("TMath::Abs(eta1)<2.4&&TMath::Abs(eta2)<2.4&&npixelhits1>1&&npixelhits2>1&&nmuonhits1>0&&nmuonhits2>0");
//   TCut pairRecoSelection("nmuonhits1>0&&nmuonhits2>0&&minvreco>2.6&&minvreco<3.5");
//   TCut trkGenSelection("TMath::Abs(eta)<2.4&&idparent==443&&npixelhits>1&&nmuonhits>0");
//   TCut trkRecoSelection("nvalidmuonhitsreco>0");
  
  // axis pair
  TH1F *phPtTmp = new TH1F("phPtTmp",";p_{T}^{#mu#mu}[GeV/c];Efficiency",1,ptPairMin,ptPairMax);
  TH1F *phYTmp  = new TH1F("phYTmp",";y^{#mu#mu};Efficiency",1,-2.4,2.4);
  phPtTmp->SetMinimum(0.005);
  phYTmp->SetMinimum(0.005);
  phPtTmp->SetMaximum(1.);
  phYTmp->SetMaximum(1.);
  TH2F *phPtYTmp = new TH2F("phPtYTmp",";y;p_{T}^{#mu#mu}[GeV/c]",1,-2.4,2.4,1,ptPairMin,ptPairMax);
 

  // axis single
  TH1F *phPtTmp2 = new TH1F("phPtTmp2",";p_{T}^{#mu}[GeV/c];Efficiency",1,ptTrkMin,ptTrkMax);
  phPtTmp2->SetMinimum(0.005);
  phPtTmp2->SetMaximum(1.);
    
  TH1F *phEtaTmp  = new TH1F("phEtaTmp",";#eta^{#mu};Efficiency",1,-2.4,2.4);
  phEtaTmp->SetMinimum(0.005);
  phEtaTmp->SetMaximum(1.);
  TH2F *phPtEtaTmp = new TH2F("phPtEtaTmp",";#eta;p_{T}^{#mu}[GeV/c]",1,-2.4,2.4,1,ptTrkMin,ptTrkMax);
  // TH2F *phPtEtaTmp = new TH2F("phPtEtaTmp",";#eta;p_{T}^{#mu}[GeV/c]",1,-2.4,2.4,1,ptTrkMin,5);

  if(bDoPairPlots)
    {
      TChain *ptPairPp   = new TChain(Form("%s",pTuplePairStd));
      TChain *ptPairStd   = new TChain(Form("%s",pTuplePairStd));
      TChain *ptPairRegit = new TChain(Form("%s",pTuplePairRegit));
      for(int iptbin=1; iptbin<nPtBins; iptbin++)
	{
	  const char* infilePairPp   = Form("%s%s.root",aInFileLocation[1],aPtSignalBins[iptbin]);
	  ptPairPp->Add(infilePairPp);
	  const char* infilePairStd = Form("%s%s.root",aInFileLocation[2],aPtSignalBins[iptbin]);
	  ptPairStd->Add(infilePairStd);
	  const char* infilePairRegit = Form("%s%s.root",aInFileLocation[3],aPtSignalBins[iptbin]);
	  ptPairRegit->Add(infilePairRegit);
	}
   
  
      // ########## pair plots!!!
      TH1D *phPtGenRecoPair_pp = new TH1D("phPtGenRecoPair_pp","phPtGenRecoPair_pp",nPtPairBins,ptPairMin,ptPairMax);
      TH1D *phPtGenPair_pp     = new TH1D("phPtGenPair_pp","phPtGenPair_pp",nPtPairBins,ptPairMin,ptPairMax);
      TH1D *phYGenRecoPair_pp  = new TH1D("phYGenRecoPair_pp","phYGenRecoPair_pp",12,-2.4,2.4);
      TH1D *phYGenPair_pp      = new TH1D("phYGenPair_pp","phYGenPair_pp",12,-2.4,2.4);

      phPtGenRecoPair_pp->Sumw2();
      phPtGenPair_pp->Sumw2();
      phYGenRecoPair_pp->Sumw2();
      phYGenPair_pp->Sumw2();
      
      TH1D *phPtGenRecoPair_std = new TH1D("phPtGenRecoPair_std","phPtGenRecoPair_std",nPtPairBins,ptPairMin,ptPairMax);
      TH1D *phPtGenPair_std     = new TH1D("phPtGenPair_std","phPtGenPair_std",nPtPairBins,ptPairMin,ptPairMax);
      TH1D *phYGenRecoPair_std  = new TH1D("phYGenRecoPair_std","phYGenRecoPair_std",12,-2.4,2.4);
      TH1D *phYGenPair_std      = new TH1D("phYGenPair_std","phYGenPair_std",12,-2.4,2.4);

      phPtGenRecoPair_std->Sumw2();
      phPtGenPair_std->Sumw2();
      phYGenRecoPair_std->Sumw2();
      phYGenPair_std->Sumw2();
      
      TH1D *phPtGenRecoPair_regit = new TH1D("phPtGenRecoPair_regit","phPtGenRecoPair_regit",nPtPairBins,ptPairMin,ptPairMax);
      TH1D *phPtGenPair_regit     = new TH1D("phPtGenPair_regit","phPtGenPair_regit",nPtPairBins,ptPairMin,ptPairMax);
      TH1D *phYGenRecoPair_regit  = new TH1D("phYGenRecoPair_regit","phYGenRecoPair_regit",12,-2.4,2.4);
      TH1D *phYGenPair_regit      = new TH1D("phYGenPair_regit","phYGenPair_regit",12,-2.4,2.4);
      phPtGenRecoPair_regit->Sumw2();
      phPtGenPair_regit->Sumw2();
      phYGenRecoPair_regit->Sumw2();
      phYGenPair_regit->Sumw2();
      
      // 2d histos
      TH2F *phPtYGenRecoPair_pp  = new TH2F("phPtYGenRecoPair_pp",";y;p_{T}^{#mu#mu}[GeV/c]",48,-2.4,2.4,nPtPairBins,ptPairMin,ptPairMax);
      TH2F *phPtYGenPair_pp      = new TH2F("phPtYGenPair_pp",";y;p_{T}^{#mu#mu}[GeV/c]",48,-2.4,2.4,nPtPairBins,ptPairMin,ptPairMax);
      TH2F *phPtYGenRecoPair_std  = new TH2F("phPtYGenRecoPair_std",";y;p_{T}^{#mu#mu}[GeV/c]",48,-2.4,2.4,nPtPairBins,ptPairMin,ptPairMax);
      TH2F *phPtYGenPair_std      = new TH2F("phPtYGenPair_std",";y;p_{T}^{#mu#mu}[GeV/c]",48,-2.4,2.4,nPtPairBins,ptPairMin,ptPairMax);
      TH2F *phPtYGenRecoPair_regit = new TH2F("phPtYGenRecoPair_regit",";y;p_{T}^{#mu#mu}[GeV/c]",48,-2.4,2.4,nPtPairBins,ptPairMin,ptPairMax);
      TH2F *phPtYGenPair_regit     = new TH2F("phPtYGenPair_regit",";y;p_{T}^{#mu#mu}[GeV/c]",48,-2.4,2.4,nPtPairBins,ptPairMin,ptPairMax);
      
      TCanvas *pcTemp = new TCanvas("pcTemp","pcTemp", 900, 400);
      pcTemp->Divide(3,1);
      pcTemp->cd(1);
      ptPairPp->Draw("pt>>phPtGenPair_pp","","E");
      ptPairPp->Draw("pt>>phPtGenPair_pp",pairGenSelection,"E");
      ptPairPp->Draw("ptreco>>phPtGenRecoPair_pp",pairRecoSelection,"Esame");
   
      pcTemp->cd(2);
      ptPairPp->Draw("y>>phYGenPair_pp",pairGenSelection,"E");
      ptPairPp->Draw("yreco>>phYGenRecoPair_pp",pairRecoSelection,"Esame");
      
      pcTemp->cd(1);
      ptPairStd->Draw("pt>>phPtGenPair_std",pairGenSelection,"Esame");
      ptPairStd->Draw("ptreco>>phPtGenRecoPair_std",pairRecoSelection,"Esame");
   
      pcTemp->cd(2);
      ptPairStd->Draw("y>>phYGenPair_std",pairGenSelection,"Esame");
      ptPairStd->Draw("yreco>>phYGenRecoPair_std",pairRecoSelection,"Esame");
      
      pcTemp->cd(1);
      ptPairRegit->Draw("pt>>phPtGenPair_regit",pairGenSelection,"Esame");
      ptPairRegit->Draw("ptreco>>phPtGenRecoPair_regit",pairRecoSelection,"Esame");
      pcTemp->cd(2);
      ptPairRegit->Draw("y>>phYGenPair_regit",pairGenSelection,"Esame");
      ptPairRegit->Draw("yreco>>phYGenRecoPair_regit",pairRecoSelection,"Esame");
      
      ptPairPp->Draw("pt:y>>phPtYGenPair_pp",pairGenSelection,"colz");
      ptPairPp->Draw("ptreco:yreco>>phPtYGenRecoPair_pp",pairRecoSelection,"colz");
      ptPairStd->Draw("pt:y>>phPtYGenPair_std",pairGenSelection,"colz");
      ptPairStd->Draw("ptreco:yreco>>phPtYGenRecoPair_std",pairRecoSelection,"colz");
      ptPairRegit->Draw("pt:y>>phPtYGenPair_regit",pairGenSelection,"colz");
      ptPairRegit->Draw("ptreco:yreco>>phPtYGenRecoPair_regit",pairRecoSelection,"colz");
      
      TH1D *pgPtEff_pp = new TH1D("pgPtEff_pp","pgPtEff_pp",nPtPairBins,ptPairMin,ptPairMax);
      TH1D *pgYEff_pp  = new TH1D("pgYEff_pp","pgYEff_pp",12,-2.4,2.4);
      pgPtEff_pp->Sumw2();
      pgYEff_pp->Sumw2();
      TH1D *pgPtEff_std = new TH1D("pgPtEff_std","pgPtEff_std",nPtPairBins,ptPairMin,ptPairMax);
      TH1D *pgYEff_std  = new TH1D("pgYEff_std","pgYEff_std",12,-2.4,2.4);
      pgPtEff_std->Sumw2();
      pgYEff_std->Sumw2();
      TH1D *pgPtEff_regit =  new TH1D("pgPtEff_regit","pgPtEff_regit",nPtPairBins,ptPairMin,ptPairMax);
      TH1D *pgYEff_regit  =  new TH1D("pgYEff_regit","pgYEff_regit",12,-2.4,2.4);
      pgPtEff_regit->Sumw2();
      pgYEff_regit->Sumw2();

      pgPtEff_pp->Divide(phPtGenRecoPair_pp,phPtGenPair_pp,1,1,"b");
      pgYEff_pp->Divide(phYGenRecoPair_pp,phYGenPair_pp,1,1,"b");
      pgPtEff_std->Divide(phPtGenRecoPair_std,phPtGenPair_std,1,1,"b");
      pgYEff_std->Divide(phYGenRecoPair_std,phYGenPair_std,1,1,"b");
      pgPtEff_regit->Divide(phPtGenRecoPair_regit,phPtGenPair_regit,1,1,"b");
      pgYEff_regit->Divide(phYGenRecoPair_regit,phYGenPair_regit,1,1,"b");

      // 2d histos
      TH2D *pgPtYEff_pp   = new TH2D("pgPtYEff_pp","pgPtYEff_pp",48,-2.4,2.4,nPtPairBins,ptPairMin,ptPairMax);
      TH2D *pgPtYEff_std   = new TH2D("pgPtYEff_std","pgPtYEff_std",48,-2.4,2.4,nPtPairBins,ptPairMin,ptPairMax);
      TH2D *pgPtYEff_regit = new TH2D("pgPtYEff_regit","pgPtYEff_regit",48,-2.4,2.4,nPtPairBins,ptPairMin,ptPairMax);
      pgPtYEff_pp->Divide(phPtYGenRecoPair_pp,phPtYGenPair_pp,1,1,"b");
      pgPtYEff_std->Divide(phPtYGenRecoPair_std,phPtYGenPair_std,1,1,"b");
      pgPtYEff_regit->Divide(phPtYGenRecoPair_regit,phPtYGenPair_regit,1,1,"b");

      // drawing
      pgPtEff_pp->SetLineColor(3);
      pgPtEff_pp->SetMarkerColor(3);
      pgPtEff_pp->SetMarkerStyle(3);
      
      pgYEff_pp->SetLineColor(3);
      pgYEff_pp->SetMarkerColor(3);
      pgYEff_pp->SetMarkerStyle(3);
      
      pgPtEff_std->SetLineColor(4);
      pgPtEff_std->SetMarkerColor(4);
      pgPtEff_std->SetMarkerStyle(4);
      
      pgYEff_std->SetLineColor(4);
      pgYEff_std->SetMarkerColor(4);
      pgYEff_std->SetMarkerStyle(4);
      
      pgPtEff_regit->SetLineColor(2);
      pgPtEff_regit->SetMarkerColor(2);
      pgPtEff_regit->SetMarkerStyle(25);
      
      pgYEff_regit->SetLineColor(2);
      pgYEff_regit->SetMarkerColor(2);
      pgYEff_regit->SetMarkerStyle(25);
      
      TCanvas *pcPairEff = new TCanvas("pcPairEff","pcPairEff",900,500);
      pcPairEff->Divide(2,1);
      pcPairEff->cd(1);// gPad->SetLogy();
      phPtTmp->Draw();
      pgPtEff_pp->Draw("pl same");
      pgPtEff_std->Draw("pl same");
      pgPtEff_regit->Draw("pl same");
      
      pcPairEff->cd(2); //gPad->SetLogy();
      phYTmp->Draw();
      pgYEff_pp->Draw("pl same");
      pgYEff_std->Draw("pl same");
      pgYEff_regit->Draw("pl same");
      
      TLegend *t = new TLegend(0.34,0.78,0.94,0.91);
      t->SetBorderSize(0);
      t->SetFillStyle(0);
      t->AddEntry(pgPtEff_pp,"Pp_reco","pl");
      t->AddEntry(pgPtEff_std,"Std_reco","pl");
      t->AddEntry(pgPtEff_regit,"Regit_reco","pl");
      t->Draw();

      //2D histo
      if(bDo2D)
	{
	  TLatex lx;
	  TCanvas *pcPtYPairEff = new TCanvas("pcPtYPairEff","pcPtYPairEff",1500,600);
	  pcPtYPairEff->Divide(3,1);
	  pcPtYPairEff->cd(1);      
	  pcPtYPairEff->GetPad(1)->SetLeftMargin(0.16);
	  pcPtYPairEff->GetPad(1)->SetRightMargin(0.15);
	  phPtYTmp->Draw();
	  pgPtYEff_pp->GetZaxis()->SetRangeUser(0.0,1.0);
	  pgPtYEff_pp->Draw("colz same");
	  lx.DrawLatex(0.,2.,"Pp_reco");
	  gPad->Update();

	  pcPtYPairEff->cd(2);      
	  pcPtYPairEff->GetPad(2)->SetLeftMargin(0.16);
	  pcPtYPairEff->GetPad(2)->SetRightMargin(0.15);
	  phPtYTmp->Draw();
	  pgPtYEff_std->GetZaxis()->SetRangeUser(0.0,1.0);
	  pgPtYEff_std->Draw("colz same");
	  lx.DrawLatex(0.,2.,"Std_reco");
	  gPad->Update();
	  
	  pcPtYPairEff->cd(3);  
	  pcPtYPairEff->GetPad(3)->SetLeftMargin(0.16);
	  pcPtYPairEff->GetPad(3)->SetRightMargin(0.15);    
	  phPtYTmp->Draw();
	  pgPtYEff_regit->GetZaxis()->SetRangeUser(0.0,1.0);
	  pgPtYEff_regit->Draw("colz same");
	  lx.DrawLatex(0.,2,"Regit_reco");

	  if(bSavePlots)
	    {
	      TString outFileBase1(Form("%s/%s_%s",pOutFilePath,pcPtYPairEff->GetTitle(),pOutFileName));
	      TString outFileGif1 = outFileBase1+".gif";
	      pcPtYPairEff->Print(outFileGif1.Data(),"gifLandscape");
	      TString outFilePdf1 = outFileBase1+".pdf";
	      pcPtYPairEff->SaveAs(outFilePdf1.Data());
	      
	    }
	  
	}

      if(bSavePlots)
	{
	  TString outFileBase(Form("%s/%s_%s",pOutFilePath,pcPairEff->GetTitle(),pOutFileName));
	  TString outFileGif = outFileBase+".gif";
	  pcPairEff->Print(outFileGif.Data(),"gifLandscape");
	  TString outFilePdf = outFileBase+".pdf";
	  pcPairEff->SaveAs(outFilePdf.Data());
	  
	}
    }
  
  // ##########--------------------- single plots!!!
  if(bDoSinglePlots)
    {
      TChain *ptTrkPp   = new TChain(Form("%s",pTupleTrkStd));
      TChain *ptTrkStd   = new TChain(Form("%s",pTupleTrkStd));
      TChain *ptTrkRegit = new TChain(Form("%s",pTupleTrkRegit));
      //nPtBins
      for(int iptbin=1; iptbin<nPtBins; iptbin++)
	{
	  const char* infileTrkPp   = Form("%s%s.root",aInFileLocation[1],aPtSignalBins[iptbin]);
	  ptTrkPp->Add(infileTrkPp);
	  const char* infileTrkStd = Form("%s%s.root",aInFileLocation[2],aPtSignalBins[iptbin]);
	  ptTrkStd->Add(infileTrkStd);
	  const char* infileTrkRegit = Form("%s%s.root",aInFileLocation[3],aPtSignalBins[iptbin]);
	  ptTrkRegit->Add(infileTrkRegit);
	}
      
     
      TH1D *phPtGenRecoTrk_pp   = new TH1D("phPtGenRecoTrk_pp","phPtGenRecoTrk_pp",nPtTrkBins,ptTrkMin,ptTrkMax);
      TH1D *phPtGenTrk_pp       = new TH1D("phPtGenTrk_pp","phPtGenTrk_pp",nPtTrkBins,ptTrkMin,ptTrkMax);
      TH1D *phEtaGenRecoTrk_pp  = new TH1D("phEtaGenRecoTrk_pp","phEtaGenRecoTrk_pp",12,-2.4,2.4);
      TH1D *phEtaGenTrk_pp      = new TH1D("phEtaGenTrk_pp","phEtaGenTrk_pp",12,-2.4,2.4);
      phPtGenRecoTrk_pp->Sumw2();
      phPtGenTrk_pp->Sumw2();
      phEtaGenRecoTrk_pp->Sumw2();
      phEtaGenTrk_pp->Sumw2();
     
      TH1D *phPtGenRecoTrk_std   = new TH1D("phPtGenRecoTrk_std","phPtGenRecoTrk_std",nPtTrkBins,ptTrkMin,ptTrkMax);
      TH1D *phPtGenTrk_std       = new TH1D("phPtGenTrk_std","phPtGenTrk_std",nPtTrkBins,ptTrkMin,ptTrkMax);
      TH1D *phEtaGenRecoTrk_std  = new TH1D("phEtaGenRecoTrk_std","phEtaGenRecoTrk_std",12,-2.4,2.4);
      TH1D *phEtaGenTrk_std      = new TH1D("phEtaGenTrk_std","phEtaGenTrk_std",12,-2.4,2.4);
      phPtGenRecoTrk_std->Sumw2();
      phPtGenTrk_std->Sumw2();
      phEtaGenRecoTrk_std->Sumw2();
      phEtaGenTrk_std->Sumw2();

      TH1D *phPtGenRecoTrk_regit = new TH1D("phPtGenRecoTrk_regit","phPtGenRecoTrk_regit",nPtTrkBins,ptTrkMin,ptTrkMax);
      TH1D *phPtGenTrk_regit     = new TH1D("phPtGenTrk_regit","phPtGenTrk_regit",nPtTrkBins,ptTrkMin,ptTrkMax);
      TH1D *phEtaGenRecoTrk_regit= new TH1D("phEtaGenRecoTrk_regit","phEtaGenRecoTrk_regit",12,-2.4,2.4);
      TH1D *phEtaGenTrk_regit    = new TH1D("phEtaGenTrk_regit","phEtaGenTrk_regit",12,-2.4,2.4);
      phPtGenRecoTrk_regit->Sumw2();
      phPtGenTrk_regit->Sumw2();
      phEtaGenRecoTrk_regit->Sumw2();
      phEtaGenTrk_regit->Sumw2();
  
      TCanvas *pcTemp2 = new TCanvas("pcTemp2","pcTemp2", 900, 400);
      pcTemp2->Divide(2,1);
      pcTemp2->cd(1);
      pcTemp2->cd(1);
      ptTrkPp->Draw("pt>>phPtGenTrk_pp",trkGenSelection,"E");
      ptTrkPp->Draw("ptreco>>phPtGenRecoTrk_pp",trkRecoSelection,"Esame");
      pcTemp2->cd(2);
      ptTrkPp->Draw("eta>>phEtaGenTrk_pp",trkGenSelection,"E");
      ptTrkPp->Draw("etareco>>phEtaGenRecoTrk_pp",trkRecoSelection,"Esame");
      
      ptTrkStd->Draw("pt>>phPtGenTrk_std",trkGenSelection,"Esame");
      ptTrkStd->Draw("ptreco>>phPtGenRecoTrk_std",trkRecoSelection,"Esame");
      pcTemp2->cd(2);
      ptTrkStd->Draw("eta>>phEtaGenTrk_std",trkGenSelection,"Esame");
      ptTrkStd->Draw("etareco>>phEtaGenRecoTrk_std",trkRecoSelection,"Esame");
      
      pcTemp2->cd(1);
      ptTrkRegit->Draw("pt>>phPtGenTrk_regit",trkGenSelection,"Esame");
      ptTrkRegit->Draw("ptreco>>phPtGenRecoTrk_regit",trkRecoSelection,"Esame");
      pcTemp2->cd(2);
      ptTrkRegit->Draw("eta>>phEtaGenTrk_regit",trkGenSelection,"Esame");
      ptTrkRegit->Draw("etareco>>phEtaGenRecoTrk_regit",trkRecoSelection,"Esame");

      TH1D *pgPtTrkEff_pp = new TH1D("pgPtTrkEff_pp","pgPtTrkEff_pp",nPtTrkBins,ptTrkMin,ptTrkMax);
      TH1D *pgEtaTrkEff_pp  = new TH1D("pgEtaTrkEff_pp","pgEtaTrkEff_pp",12,-2.4,2.4);
      pgPtTrkEff_pp->Sumw2();
      pgEtaTrkEff_pp->Sumw2();
      TH1D *pgPtTrkEff_std = new TH1D("pgPtTrkEff_std","pgPtTrkEff_std",nPtTrkBins,ptTrkMin,ptTrkMax);
      TH1D *pgEtaTrkEff_std  = new TH1D("pgEtaTrkEff_std","pgEtaTrkEff_std",12,-2.4,2.4);
      pgPtTrkEff_std->Sumw2();
      pgEtaTrkEff_std->Sumw2();
      TH1D *pgPtTrkEff_regit =  new TH1D("pgPtTrkEff_regit","pgPtTrkEff_regit",nPtTrkBins,ptTrkMin,ptTrkMax);
      TH1D *pgEtaTrkEff_regit  =  new TH1D("pgEtaTrkEff_regit","pgEtaTrkEff_regit",12,-2.4,2.4);
      pgPtTrkEff_regit->Sumw2();
      pgEtaTrkEff_regit->Sumw2();

      pgPtTrkEff_pp->Divide(phPtGenRecoTrk_pp,phPtGenTrk_pp,1,1,"b");
      pgEtaTrkEff_pp->Divide(phEtaGenRecoTrk_pp,phEtaGenTrk_pp,1,1,"b");
      pgPtTrkEff_std->Divide(phPtGenRecoTrk_std,phPtGenTrk_std,1,1,"b");
      pgEtaTrkEff_std->Divide(phEtaGenRecoTrk_std,phEtaGenTrk_std,1,1,"b");
      pgPtTrkEff_regit->Divide(phPtGenRecoTrk_regit,phPtGenTrk_regit,1,1,"b");
      pgEtaTrkEff_regit->Divide(phEtaGenRecoTrk_regit,phEtaGenTrk_regit,1,1,"b");
  
      // 2D stuff
      TH2F *phPtEtaGenRecoTrk_pp  = new TH2F("phPtEtaGenRecoTrk_pp",";#eta;p_{T}^{#mu}[GeV/c]",48,-2.4,2.4,nPtTrkBins,ptTrkMin,ptTrkMax);
      TH2F *phPtEtaGenTrk_pp      = new TH2F("phPtEtaGenTrk_pp",";#eta;p_{T}^{#mu}[GeV/c]",48,-2.4,2.4,nPtTrkBins,ptTrkMin,ptTrkMax);
      ptTrkPp->Draw("pt:eta>>phPtEtaGenTrk_pp",trkGenSelection,"colz");
      ptTrkPp->Draw("ptreco:etareco>>phPtEtaGenRecoTrk_pp",trkRecoSelection,"colz");
      TH2F *phPtEtaGenRecoTrk_std  = new TH2F("phPtEtaGenRecoTrk_std",";#eta;p_{T}^{#mu}[GeV/c]",48,-2.4,2.4,nPtTrkBins,ptTrkMin,ptTrkMax);
      TH2F *phPtEtaGenTrk_std      = new TH2F("phPtEtaGenTrk_std",";#eta;p_{T}^{#mu}[GeV/c]",48,-2.4,2.4,nPtTrkBins,ptTrkMin,ptTrkMax);
      ptTrkStd->Draw("pt:eta>>phPtEtaGenTrk_std",trkGenSelection,"colz");
      ptTrkStd->Draw("ptreco:etareco>>phPtEtaGenRecoTrk_std",trkRecoSelection,"colz");
      TH2F *phPtEtaGenRecoTrk_regit= new TH2F("phPtEtaGenRecoTrk_regit",";#eta;p_{T}^{#mu#mu}[GeV/c]",48,-2.4,2.4,nPtTrkBins,ptTrkMin,ptTrkMax);
      TH2F *phPtEtaGenTrk_regit    = new TH2F("phPtEtaGenTrk_regit",";#eta;p_{T}^{#mu#mu}[GeV/c]",48,-2.4,2.4,nPtTrkBins,ptTrkMin,ptTrkMax);
      ptTrkRegit->Draw("pt:eta>>phPtEtaGenTrk_regit",trkGenSelection,"colz");
      ptTrkRegit->Draw("ptreco:etareco>>phPtEtaGenRecoTrk_regit",trkRecoSelection,"colz");

      TH2D *pgPtEtaEff_pp   = new TH2D("pgPtEtaEff_pp",";#eta;p_{T}^{#mu}[GeV/c]",48,-2.4,2.4,nPtTrkBins,ptTrkMin,ptTrkMax);
      TH2D *pgPtEtaEff_std   = new TH2D("pgPtEtaEff_std",";#eta;p_{T}^{#mu}[GeV/c]",48,-2.4,2.4,nPtTrkBins,ptTrkMin,ptTrkMax);
      TH2D *pgPtEtaEff_regit = new TH2D("pgPtEtaEff_regit",";#eta;p_{T}^{#mu}[GeV/c]",48,-2.4,2.4,nPtTrkBins,ptTrkMin,ptTrkMax);
      pgPtEtaEff_pp->Divide(phPtEtaGenRecoTrk_pp,phPtEtaGenTrk_pp,1,1,"b");
      pgPtEtaEff_std->Divide(phPtEtaGenRecoTrk_std,phPtEtaGenTrk_std,1,1,"b");
      pgPtEtaEff_regit->Divide(phPtEtaGenRecoTrk_regit,phPtEtaGenTrk_regit,1,1,"b");


      // drawing
      pgPtTrkEff_pp->SetLineColor(3);
      pgPtTrkEff_pp->SetMarkerColor(3);
      pgPtTrkEff_pp->SetMarkerStyle(3);
      
      pgEtaTrkEff_pp->SetLineColor(3);
      pgEtaTrkEff_pp->SetMarkerColor(3);
      pgEtaTrkEff_pp->SetMarkerStyle(3);
      
      pgPtTrkEff_std->SetLineColor(4);
      pgPtTrkEff_std->SetMarkerColor(4);
      pgPtTrkEff_std->SetMarkerStyle(4);
      
      pgEtaTrkEff_std->SetLineColor(4);
      pgEtaTrkEff_std->SetMarkerColor(4);
      pgEtaTrkEff_std->SetMarkerStyle(4);
      
      pgPtTrkEff_regit->SetLineColor(2);
      pgPtTrkEff_regit->SetMarkerColor(2);
      pgPtTrkEff_regit->SetMarkerStyle(25);
      
      pgEtaTrkEff_regit->SetLineColor(2);
      pgEtaTrkEff_regit->SetMarkerColor(2);
      pgEtaTrkEff_regit->SetMarkerStyle(25);
      
      TCanvas *pcTrkEff = new TCanvas("pcTrkEff","pcTrkEff",1000,600);
      pcTrkEff->Divide(2,1);
      pcTrkEff->cd(1); //gPad->SetLogy();
      phPtTmp2->Draw();
      pgPtTrkEff_pp->Draw("pl same");
      pgPtTrkEff_std->Draw("pl same");
      pgPtTrkEff_regit->Draw("pl same");
      
      pcTrkEff->cd(2); //gPad->SetLogy();
      phEtaTmp->Draw();
      pgEtaTrkEff_pp->Draw("pl same");
      pgEtaTrkEff_std->Draw("pl same");
      pgEtaTrkEff_regit->Draw("pl same");
      
      TLegend *t2 = new TLegend(0.34,0.78,0.94,0.91);
      t2->SetBorderSize(0);
      t2->SetFillStyle(0);
      t2->AddEntry(pgPtTrkEff_pp,"Pp_reco","pl");
      t2->AddEntry(pgPtTrkEff_std,"Std_reco","pl");
      t2->AddEntry(pgPtTrkEff_regit,"Regit_reco","pl");
      t2->Draw();
      
      // 2d plots
      //2D histo
      if(bDo2D)
	{
	  TLatex lx2;
	  TCanvas *pcPtEtaTrkEff = new TCanvas("pcPtEtaTrkEff","pcPtEtaTrkEff",1300,500);
	  pcPtEtaTrkEff->Divide(3,1);
	  pcPtEtaTrkEff->cd(1);      
	  pcPtEtaTrkEff->GetPad(1)->SetLeftMargin(0.16);
	  pcPtEtaTrkEff->GetPad(1)->SetRightMargin(0.15); 
	  phPtEtaTmp->Draw();
	  pgPtEtaEff_pp->GetZaxis()->SetRangeUser(0.0,1.0);
	  pgPtEtaEff_pp->Draw("COLZ same");
	  lx2.DrawLatex(-0.2,2,"Pp_reco");
	  
	  
	  pcPtEtaTrkEff->cd(2);      
	  pcPtEtaTrkEff->GetPad(2)->SetLeftMargin(0.16);
	  pcPtEtaTrkEff->GetPad(2)->SetRightMargin(0.15); 
	  phPtEtaTmp->Draw();
	  pgPtEtaEff_std->GetZaxis()->SetRangeUser(0.0,1.0);
	  pgPtEtaEff_std->Draw("COLZ same");
	  lx2.DrawLatex(-0.2,2,"Std_reco");
	  
	  pcPtEtaTrkEff->cd(3);
	  pcPtEtaTrkEff->GetPad(3)->SetLeftMargin(0.16);
	  pcPtEtaTrkEff->GetPad(3)->SetRightMargin(0.15);       
	  phPtEtaTmp->Draw();
	  pgPtEtaEff_regit->GetZaxis()->SetRangeUser(0.0,1.0);
	  pgPtEtaEff_regit->Draw("colz same");
	  lx2.DrawLatex(-0.2,2,"Regit_reco");

     if(bSavePlots)
     {
        TString outFileBase2(Form("%s/%s_%s",pOutFilePath,pcPtEtaTrkEff->GetTitle(),pOutFileName));
        TString outFileGif2 = outFileBase2+".gif";
        pcPtEtaTrkEff->Print(outFileGif2.Data(),"gifLandscape");
        TString outFilePdf2 = outFileBase2+".pdf";
        pcPtEtaTrkEff->SaveAs(outFilePdf2.Data());
     }

   }
      if(bSavePlots)
      {
         TString outFileBase(Form("%s/%s_%s",pOutFilePath,pcTrkEff->GetTitle(),pOutFileName));
         TString outFileGif = outFileBase+".gif";
         pcTrkEff->Print(outFileGif.Data(),"gifLandscape");
         TString outFilePdf2 = outFileBase+".pdf";
         pcTrkEff->SaveAs(outFilePdf2.Data());
      }
    }


}