Example #1
0
void start(const char *basename, const double offset = 0.0)
{

  TFile *file1 = TFile::Open(Form("Data/ROOT/%s_VMIN_SIPM1_meanHistSub_projections.root",basename));
  TFile *file2 = TFile::Open(Form("Data/ROOT/%s_VMIN_SIPM2_meanHistSub_projections.root",basename));

  if(file1==NULL) {cout<<"cannot find file1"<<endl;return;}
  if(file2==NULL) {cout<<"cannot find file2"<<endl;return;}

  calc(file1,file2,basename,0);
  calc(file1,file2,basename,1);
  calc(file1,file2,basename,2);
  calc(file1,file2,basename,3);
  calc(file1,file2,basename,4);
  calc(file1,file2,basename,5);
  calc(file1,file2,basename,6);
  calc(file1,file2,basename,7);
  calc(file1,file2,basename,8);

  ofstream fout(Form("Data/Text/%s_Asymmetries.txt"));
  double pn[9];
  for(int i=0; i<9; i++)
    {
      fout<<frac1[i]<<" "
	  <<frac2[i]<<" "
	  <<fracAv[i]<<" "
	  <<fracAs[i]<<" "
	  <<endl;
      //pn[i] = i+0.5; // projection number
      pn[i] = -2.0 + i/2.0; // distance
      pn[i] += offset;
    }

  TGraph *tg1 = new TGraph(9,pn,frac1);
  TGraph *tg2 = new TGraph(9,pn,frac2);
  TGraph *tgAv = new TGraph(9,pn,fracAv);
  TGraph *tgAs = new TGraph(9,pn,fracAs);
  tg1->SetMarkerStyle(kFullCircle);
  tg2->SetMarkerStyle(kFullCircle);
  tgAv->SetMarkerStyle(kOpenCircle);
  tgAs->SetMarkerStyle(kFullSquare);
  tg1->SetMarkerColor(kBlue);
  tg2->SetMarkerColor(kRed);
  tgAv->SetMarkerColor(kBlack);
  tgAs->SetMarkerColor(kBlack);
  TMultiGraph *tmg = new TMultiGraph();
  tmg->Add(tgAs);
  tmg->Add(tg1);
  tmg->Add(tg2);
  tmg->Add(tgAv);
  tmg->Draw("ap");
  tmg->SetMaximum(1.0);
  tmg->SetMinimum(0.0);
  tmg->GetXaxis()->SetLimits(-2.25+offset,2.25+offset);
  //tmg->GetXaxis()->SetLimits(0.0,9.0); // projection number
  tmg->GetXaxis()->SetTitle("Distance from fiber (cm)");
  tmg->GetYaxis()->SetTitle("f_{core} from different methods");
  TLegend *leg1 = new TLegend(0.18,0.18,0.28,0.38);
  leg1->AddEntry(tg1,"SiPM1","p");
  leg1->AddEntry(tg2,"SiPM2","p");
  leg1->AddEntry(tgAv,"Average SiPM1+SiPM2","p");
  leg1->AddEntry(tgAs,"Asymmetry","p");
  leg1->SetFillStyle(0);
  leg1->SetTextSize(0.05);
  leg1->Draw();

  c1->Print(Form("Figures/%s_AsymmetryComparison.png",basename));
  c1->Print(Form("Figures/%s_AsymmetryComparison.pdf",basename));

}
Example #2
0
void plot( TString stream = "eleTau", TString variable = "diTauVisMass", Float_t xMax = 50){

  TCanvas *c1 = new TCanvas("c1","",5,30,650,600);
  c1->SetGrid(0,0);
  c1->SetFillStyle(4000);
  c1->SetFillColor(10);
  c1->SetTicky();
  c1->SetObjectStat(0);
  
  TLegend* leg = new TLegend(0.14,0.60,0.41,0.85,NULL,"brNDC");
  leg->SetBorderSize(0);
  leg->SetTextSize(0.03);
  leg->SetFillColor(0);

  ifstream is;

  
  is.open("submit/grid/results_"+stream+"_SM_"+variable+".txt");  
  int nMassPoints = 0;
  char* c0 = new char[100];
  while (is.good())     
    {
      is.getline(c0,100,'\n');
      printf("%s\n",c0);
      nMassPoints++;
    }
  is.close();
  nMassPoints -= 1;
  cout << "Using " << nMassPoints << " mass points" << endl;

  if(nMassPoints!=8){
    cout << "Check the mass points!" << endl;
    return;
  }


  Float_t obsX[]          = {0.,0.,0.,0.,0.,0.,0.,0.};
  float obsY[]            = {0.,0.,0.,0.,0.,0.,0.,0.};

  float X[]               = {0.,0.,0.,0.,0.,0.,0.,0.};
  float Y[]               = {0.,0.,0.,0.,0.,0.,0.,0.};

  float eX1sL[]           = {0.,0.,0.,0.,0.,0.,0.,0.};
  float eY1sL[]           = {0.,0.,0.,0.,0.,0.,0.,0.};
  float eX1sH[]           = {0.,0.,0.,0.,0.,0.,0.,0.};
  float eY1sH[]           = {0.,0.,0.,0.,0.,0.,0.,0.};

  float eX2sL[]           = {0.,0.,0.,0.,0.,0.,0.,0.};
  float eY2sL[]           = {0.,0.,0.,0.,0.,0.,0.,0.};
  float eX2sH[]           = {0.,0.,0.,0.,0.,0.,0.,0.};
  float eY2sH[]           = {0.,0.,0.,0.,0.,0.,0.,0.};

  char* c = new char[100];
  is.open("submit/grid/results_"+stream+"_SM_"+variable+".txt");

  int countMass = 0;

  while (is.good())     
    {
      is.getline(c,100,'\n');
      if (is.good()){

	cout << "Now doing mass point number " << countMass << endl;

	eX1sL[countMass] = 0.;
	eX1sH[countMass] = 0.;
	eX2sL[countMass] = 0.;
	eX2sH[countMass] = 0.;

	string line(c);
	char* cSplit = strtok ( c ," ");

	int counter = 0;
	while (cSplit != NULL)
	  {
	    cout << "Parsing the " << counter << "th number in line " << countMass << endl;
	    //cout << atof(cSplit) << endl;
	    if(counter==0){
	      X[countMass]           = atof(cSplit);
	      obsX[countMass]        = atof(cSplit);
	    }
	    if(counter==1) Y[countMass]       = atof(cSplit);
 
	    if(counter==2) eY1sH[countMass]   = atof(cSplit);
	    if(counter==3) eY2sH[countMass]   = atof(cSplit);

	    if(counter==4) eY1sL[countMass]   = atof(cSplit);
	    if(counter==5) eY2sL[countMass]   = atof(cSplit);

	    if(counter==6) obsY[countMass]    = atof(cSplit);

	    counter++;
	    cSplit = strtok ( NULL ," ");
	  }

	countMass++;

      }
    }
  

  for(int i = 0 ; i < nMassPoints ; i++){
    cout << "Mass " << X[i] << endl;
    cout << "Exp  " << Y[i] << endl;
    cout << "Obs  " << obsY[i] << endl;

    eY1sH[i] = eY1sH[i]-Y[i];
    eY1sL[i] = fabs(eY1sL[i]-Y[i]);
    eY2sH[i] = eY2sH[i]-Y[i];
    eY2sL[i] = TMath::Max( TMath::Abs(eY2sL[i]-Y[i]), eY1sL[i] );

    if((string(stream.Data())).find("mu")!=string::npos && (string(variable.Data())).find("diTauVisMass")!=string::npos &&
       (i==1 || i==4) ){
      eY1sH[i] = eY1sH[i-1];
      eY2sH[i] = eY2sH[i-1];
    }

    if((string(stream.Data())).find("mu")!=string::npos && (string(variable.Data())).find("diTauNSVfitMass")!=string::npos &&
       i==4 )
      eY2sH[i] = eY2sH[i-1];

    if((string(stream.Data())).find("ele")!=string::npos && (string(variable.Data())).find("diTauVisMass")!=string::npos &&
       i==6 )
      eY2sH[i] = eY2sH[7]-Y[7];

    cout << "1s Up   " << eY1sH[i] << endl;
    cout << "1s Down " << eY1sL[i] << endl;
  }

  TMultiGraph *mg = new TMultiGraph();
  mg->SetTitle("");

  TGraphAsymmErrors* expected = new TGraphAsymmErrors(nMassPoints, X, Y, eX1sL ,eX1sL , eX1sL, eX1sL);
  TGraphAsymmErrors* oneSigma = new TGraphAsymmErrors(nMassPoints, X, Y, eX1sL, eX1sL, eY1sL, eY1sH);
  TGraphAsymmErrors* twoSigma = new TGraphAsymmErrors(nMassPoints, X, Y, eX2sL, eX2sL, eY2sL, eY2sH);
  TGraphAsymmErrors* observed = new TGraphAsymmErrors(nMassPoints, X, obsY, eX1sL ,eX1sL , eX1sL, eX1sL);

 
  oneSigma->SetMarkerColor(kBlack);
  oneSigma->SetMarkerStyle(kFullCircle);
  oneSigma->SetFillColor(kGreen);
  oneSigma->SetFillStyle(1001);

  twoSigma->SetMarkerColor(kBlack);
  twoSigma->SetMarkerStyle(kFullCircle);
  twoSigma->SetFillColor(kYellow);
  twoSigma->SetFillStyle(1001);

  expected->SetMarkerColor(kBlack);
  expected->SetMarkerStyle(kFullCircle);
  expected->SetMarkerSize(1.5);
  expected->SetLineColor(kBlack);
  expected->SetLineWidth(2);

  observed->SetMarkerColor(kBlue);
  observed->SetMarkerStyle(1);
  observed->SetLineColor(kBlue);
  observed->SetLineWidth(4);

  mg->Add(twoSigma);
  mg->Add(oneSigma);
  mg->Add(expected);
  mg->Add(observed);

  mg->Draw("ALP3");

  c1->cd();
  gPad->Modified();
  mg->GetXaxis()->SetLimits(105,140);
  mg->GetYaxis()->SetTitleOffset(0.97);
  mg->SetMinimum(0.);
  mg->SetMaximum(xMax);
  mg->GetXaxis()->SetTitle("m_{H} (GeV)");
  mg->GetYaxis()->SetTitle("#sigma X BR(H#rightarrow#tau#tau)_{95% CLs}/#sigma_{SM}");

  if((string(stream.Data())).find("ele")!=string::npos )
    leg->SetHeader("#splitline{CMS Preliminary}{#sqrt{s}=7 TeV, 1.9 fb^{-1}, #tau_{e}#tau_{had}}");
  else if((string(stream.Data())).find("mu")!=string::npos )
    leg->SetHeader("#splitline{CMS Preliminary}{#sqrt{s}=7 TeV, 1.9 fb^{-1}, #tau_{#mu}#tau_{had}}");

  leg->AddEntry(expected,"Expected CLs limit","P");
  leg->AddEntry(observed,"Observed CLs limit","L");

  leg->Draw();

  TF1 *line = new TF1("line","1",100,150);
  line->SetLineColor(kRed);
  line->SetLineWidth(2);

  line->Draw("SAME");

  gPad->SaveAs("submit/grid/limits_"+stream+"_"+variable+".png");

}
Example #3
0
void plotExclusion() {
  //CMSstyle();
  setTDRStyle();
  gROOT->ForceStyle();
  //gStyle->SetOptStat(0);

  TMultiGraph *mg = new TMultiGraph("mg", ";M_{W'} (GeV);W'#rightarrowWZ Coupling");
  TCanvas* c1 = new TCanvas("c1");
  c1->SetLogy(1);

   float masses[15];
   masses[0] = 200;
   masses[1] = 250;
   masses[2] = 300;
   masses[3] = 400;
   masses[4] = 500;
   masses[5] = 600;
   masses[6] = 700;
   masses[7] = 800;
   masses[8] = 900;
   masses[9] = 1000;
   masses[10] = 1100;
   masses[11] = 1200;
   masses[12] = 1300;
   masses[13] = 1400;
   masses[14] = 1500;

   float masses2D[30];
   masses2D[0] = 200;
   masses2D[29] = 200;
   masses2D[1] = 250;
   masses2D[28] = 250;
   masses2D[2] = 300;
   masses2D[27] = 300;
   masses2D[3] = 400;
   masses2D[26] = 400;
   masses2D[4] = 500;
   masses2D[25] = 500;
   masses2D[5] = 600;
   masses2D[24] = 600;
   masses2D[6] = 700;
   masses2D[23] = 700;
   masses2D[7] = 800;
   masses2D[22] = 800;
   masses2D[8] = 900;
   masses2D[21] = 900;
   masses2D[9] = 1000;
   masses2D[20] = 1000;
   masses2D[10] = 1100;
   masses2D[19] = 1100;
   masses2D[11] = 1200;
   masses2D[18] = 1200;
   masses2D[12] = 1300;
   masses2D[17] = 1300;
   masses2D[13] = 1400;
   masses2D[16] = 1400;
   masses2D[14] = 1500;
   masses2D[15] = 1500;
   float exp[15];
   float obs[15];
   float exp1[30];
   float exp2[30];
   exp[0] = 0.258951497072;
   obs[0] = 0.264236507723;
   exp1[0] = 0.302958978755;
   exp1[29] = 0.221380623691;
   exp2[0] = 0.361484816545;
   exp2[29] = 0.134881244455;
   exp[1] = 0.238074875871;
   obs[1] = 0.262501951025;
   exp1[1] = 0.271489954939;
   exp1[28] = 0.212149800065;
   exp2[1] = 0.31212926296;
   exp2[28] = 0.188396377283;
   exp[2] = 0.203941984681;
   obs[2] = 0.195862072551;
   exp1[2] = 0.228775587519;
   exp1[27] = 0.15388234499;
   exp2[2] = 0.258549678245;
   exp2[27] = 0.0761613633144;
   exp[3] = 0.221149265622;
   obs[3] = 0.197161298736;
   exp1[3] = 0.25146417874;
   exp1[26] = 0.195849275574;
   exp2[3] = 0.302745675541;
   exp2[26] = 0.102178773493;
   exp[4] = 0.265859426326;
   obs[4] = 0.281814245586;
   exp1[4] = 0.316136059804;
   exp1[25] = 0.241393072817;
   exp2[4] = 0.39001755547;
   exp2[25] = 0.221096337301;
   exp[5] = 0.318011210571;
   obs[5] = 0.27969609314;
   exp1[5] = 0.37957804241;
   exp1[24] = 0.276992405418;
   exp2[5] = 0.447262299127;
   exp2[24] = 0.222377913436;
   exp[6] = 0.398436976666;
   obs[6] = 0.42176421485;
   exp1[6] = 0.459808375625;
   exp1[23] = 0.364154826684;
   exp2[6] = 0.537189459921;
   exp2[23] = 0.357480425803;
   exp[7] = 0.46411170267;
   obs[7] = 0.481806072966;
   exp1[7] = 0.565467804363;
   exp1[22] = 0.425115372019;
   exp2[7] = 0.672064509509;
   exp2[22] = 0.4120593318;
   exp[8] = 0.563947415859;
   obs[8] = 0.536922403468;
   exp1[8] = 0.672650081221;
   exp1[21] = 0.534487182571;
   exp2[8] = 0.808457381294;
   exp2[21] = 0.514649041607;
   exp[9] = 0.700579859433;
   obs[9] = 0.676280384249;
   exp1[9] = 0.798482092783;
   exp1[20] = 0.674378686191;
   exp2[9] = 1.0120004248;
   exp2[20] = 0.663954563503;
   exp[10] = 0.918970653344;
   obs[10] = 0.889845853577;
   exp1[10] = 1.04923440155;
   exp1[19] = 0.858375432352;
   exp2[10] = 1.24717913491;
   exp2[19] = 0.746731022724;
   exp[11] = 1.19793401961;
   obs[11] = 1.17653186674;
   exp1[11] = 1.39512272299;
   exp1[18] = 1.16185610477;
   exp2[11] = 1.62812001722;
   exp2[18] = 1.01020656441;
   exp[12] = 1.58254134376;
   obs[12] = 1.56834374153;
   exp1[12] = 1.84607923047;
   exp1[17] = 1.51628586669;
   exp2[12] = 2.18103685499;
   exp2[17] = 1.31304946585;
   exp[13] = 2.30981854338;
   obs[13] = 2.30117260535;
   exp1[13] = 2.42189837009;
   exp1[16] = 2.13395645197;
   exp2[13] = 2.92307163497;
   exp2[16] = 2.04337780276;
   exp[14] = 3.19375101546;
   obs[14] = 3.16458908761;
   exp1[14] = 3.28113723449;
   exp1[15] = 2.99139611866;
   exp2[14] = 4.07139223438;
   exp2[15] = 2.84407249777;

  TGraph* grExp = new TGraph(15, masses, exp);
  TGraph* grObs = new TGraph(15, masses, obs);
  TGraph* grExp1 = new TGraph(30, masses2D, exp1);
  TGraph* grExp2 = new TGraph(30, masses2D, exp2);

  grExp->SetLineColor(kBlack);
  grExp->SetMarkerColor(kBlack);
  grExp->SetLineStyle(kDashed);
  grObs->SetLineColor(kBlack);
  grObs->SetMarkerColor(kBlack);
  grObs->SetMarkerStyle(20);
  grExp1->SetFillStyle(1001);
  grExp1->SetFillColor(kGreen);
  grExp2->SetFillStyle(1001);
  grExp2->SetFillColor(kYellow);

  mg->Add(grExp2, "F");
  mg->Add(grExp1, "F");
  mg->Add(grExp,  "L");
  mg->Add(grObs,  "P");
  mg->SetMinimum(0.1);
  mg->SetMaximum(10.);
  mg->Draw("a");

  TLine* line = new TLine(200, 1, 1500, 1);
  line->Draw();

  TLegend* leg = new TLegend(0.2, 0.62, 0.58, 0.92);
  leg->SetTextSize(0.05);
  leg->SetTextFont(42);
  leg->AddEntry(grObs, "Obs. Limit", "p");
  leg->AddEntry(grExp, "Exp. Limit", "l");
  leg->AddEntry(grExp1, "Exp. #pm 1#sigma", "f");
  leg->AddEntry(grExp2, "Exp. #pm 2#sigma", "f");
  leg->AddEntry(line, "W'_{SSM}#rightarrowWZ Coupling", "l");
  leg->SetBorderSize(0);
  leg->SetFillColor(0);
  leg->Draw();

  TLatex latexLabel;
  latexLabel.SetNDC();
  latexLabel.SetTextSize(0.05);
  latexLabel.SetTextFont(42);
  latexLabel.DrawLatex(0.33, 0.96, "CMS Preliminary 2011");
  latexLabel.DrawLatex(0.67, 0.38, "#sqrt{s} = 7 TeV");
  latexLabel.DrawLatex(0.62, 0.25, Form("#intL dt = %.2f fb^{-1}",4.98));


  c1->RedrawAxis();
  c1->Print("wprimewz_limits.C");
  c1->Print("wprimewz_limits.pdf");
  c1->Print("wprimewz_limits.png");
}
Example #4
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// drawFigure7
//
//    parameter = "dg0"
//    parameter = "lam0"
//    parameter = "dk0"
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void drawFigure7(TString parameter = "dk0")
{
  gInterpreter->ExecuteMacro("WZPaperStyle.C");

  gSystem->mkdir("pdf", kTRUE);
  gSystem->mkdir("png", kTRUE);


  // Individual settings
  //----------------------------------------------------------------------------
  if (parameter.Contains("dg0"))
    {
      xtitle = "#Delta#kappa^{Z}";
      ytitle = "#lambda";
      xmin   = -0.5;
      xmax   =  0.5;
      ymin   = -0.039;
      ymax   =  0.053;
    }
  else if (parameter.Contains("lam0"))
    {
      xtitle = "#Delta#kappa^{Z}";
      ytitle = "#Deltag^{Z}_{1}";
      xmin   = -0.53;
      xmax   =  0.53;
      ymin   = -0.05;
      ymax   =  0.09;
    }
  else if (parameter.Contains("dk0"))
    {
      xtitle = "#Deltag^{Z}_{1}";
      ytitle = "#lambda";
      xmin   = -0.059;
      xmax   =  0.059;
      ymin   = -0.037;
      ymax   =  0.052;
    }


  // Read the input file
  //----------------------------------------------------------------------------
  TFile* file = new TFile("rootfiles/contours_" + parameter + "_2Dpol2.root", "read");

  TGraph* cont_exp_68 = (TGraph*)file->Get("cont_exp_68");
  TGraph* cont_exp_95 = (TGraph*)file->Get("cont_exp_95");
  TGraph* cont_exp_99 = (TGraph*)file->Get("cont_exp_99");
  TGraph* cont_obs_95 = (TGraph*)file->Get("cont_obs_95");
  TGraph* bestFit     = (TGraph*)file->Get("bestFit");

  bestFit->SetMarkerSize(1.5);
  bestFit->SetMarkerStyle(34);

  TGraph* g_large = new TGraph(2);

  g_large->SetPoint(0, -1.0, 1.0);
  g_large->SetPoint(1,  1.0, 1.0);


  // Draw
  //----------------------------------------------------------------------------
  TCanvas* canvas = new TCanvas("canvas", "canvas");

  TMultiGraph* mg = new TMultiGraph();

  mg->Add(cont_exp_68);
  mg->Add(cont_exp_95);
  mg->Add(cont_exp_99);
  mg->Add(cont_obs_95);
  mg->Add(bestFit, "p");
  mg->Add(g_large);

  mg->Draw("ac");

  mg->SetMinimum(ymin);
  mg->SetMaximum(ymax);


  // Axis labels
  //----------------------------------------------------------------------------
  TAxis* xaxis = mg->GetXaxis();
  TAxis* yaxis = mg->GetYaxis();
  
  xaxis->SetLabelFont  (    42);
  xaxis->SetLabelOffset(  0.01);
  xaxis->SetLabelSize  (  0.05);
  xaxis->SetNdivisions (   505);
  xaxis->SetTitle      (xtitle);
  xaxis->SetTitleFont  (    42);
  xaxis->SetTitleOffset(   1.2);
  xaxis->SetTitleSize  (  0.05);

  xaxis->SetLimits(xmin, xmax);

  yaxis->SetLabelFont  (    42);
  yaxis->SetLabelOffset(  0.01);
  yaxis->SetLabelSize  (  0.05);
  yaxis->SetNdivisions (   505);
  yaxis->SetTitle      (ytitle);
  yaxis->SetTitleFont  (    42);
  yaxis->SetTitleOffset(   1.6);
  yaxis->SetTitleSize  (  0.05);

  canvas->Modified();


  // Legend
  //----------------------------------------------------------------------------
  Double_t x0 = 0.580;
  Double_t y0 = 0.755;

  DrawTLegend(x0 - 0.36, y0 + 2.*(_yoffset+0.001), (TH1F*)cont_exp_68, " Expected 68% CL", "l");
  DrawTLegend(x0 - 0.36, y0 + 1.*(_yoffset+0.001), (TH1F*)cont_exp_95, " Expected 95% CL", "l");
  DrawTLegend(x0,        y0 + 2.*(_yoffset+0.001), (TH1F*)cont_exp_99, " Expected 99% CL", "l");
  DrawTLegend(x0,        y0 + 1.*(_yoffset+0.001), (TH1F*)cont_obs_95, " Observed 95% CL", "l");
  DrawTLegend(x0,        y0,                       (TH1F*)bestFit,     " Best fit",          "p");


  // Finish it
  //----------------------------------------------------------------------------
  DrawTLatex(_cmsTextFont,   0.190, 0.94, 0.055, 11, "CMS");
  //  DrawTLatex(_extraTextFont, 0.315, 0.94, 0.030, 11, "Preliminary");
  DrawTLatex(_lumiTextFont,  0.940, 0.94, 0.040, 31, "19.6 fb^{-1} (8 TeV)");

  canvas->SaveAs("pdf/lZ_dkg_2dlimit_" + parameter + "_2Dpol2_deltaNLL.pdf");
  canvas->SaveAs("png/lZ_dkg_2dlimit_" + parameter + "_2Dpol2_deltaNLL.png");
}
Example #5
0
int main(int argc, char** argv)
{

  std::string plot_type = argv[1];
    //"HVScan";
  //    std::string plot_type = "AngScanHigh";
  //  std::string plot_type = "scanX0_HVLow_50";
  //  std::string plot_type = "scanX0_HVLow_20";
  std::cout<<plot_type<<std::endl;

  TFile* inF_GaAsEm;
  //TFile* inF_GaAsEm_OFF;
  TFile* inF_MultiAlkEm;
  //TFile* inF_MultiAlkEm_OFF;
  TFile* inF_Double9090;
  TFile* inF_Double9040;
  TFile* inF_Double9090b;
  TFile* inF_Double9040b;

  TMultiGraph *mg = new TMultiGraph();

  TLegend *legC;

  if(plot_type == "HV12"){
    legC = new TLegend(0.12,0.62,0.30,0.87,NULL,"brNDC");

	//plot name MCPName_ScanType_HVScanScanType_MCPName
    inF_MultiAlkEm = TFile::Open("plots/efficiency_studies/MultiAlkEm_HV12_HVScan12_MultiAlkEm.root");
    inF_GaAsEm = TFile::Open("plots/efficiency_studies/GaAsEm_HV12_HVScan12_GaAsEm.root");
    //inF_GaAsEm_OFF = TFile::Open("plots/efficiency_studies/GaAsEm_HV_HVScan7.root");
    inF_Double9090 = TFile::Open("plots/efficiency_studies/Double9090_HV12_HVScan12_Double9090.root");
    inF_Double9040 = TFile::Open("plots/efficiency_studies/Double9040_HV12_HVScan12_Double9040.root");    
    TGraphErrors* eff_GaAsEm = (TGraphErrors*)inF_GaAsEm->Get("eff");
    TGraphErrors* eff_MultiAlkEm = (TGraphErrors*)inF_MultiAlkEm->Get("eff");
    TGraphErrors* eff_Double9040 = (TGraphErrors*)inF_Double9040->Get("eff");
    TGraphErrors* eff_Double9090 = (TGraphErrors*)inF_Double9090->Get("eff");

    //settings
    eff_GaAsEm->SetMarkerColor(kGreen+1);
    eff_GaAsEm->SetLineColor(kGreen+1);
    //eff_GaAsEm_OFF->SetMarkerColor(kGreen+1);
    //eff_GaAsEm_OFF->SetLineColor(kGreen+1);
    eff_Double9040->SetMarkerColor(kBlue);
    eff_Double9040->SetLineColor(kBlue);
    eff_Double9090->SetMarkerColor(kRed);
    eff_Double9090->SetLineColor(kRed);
    eff_MultiAlkEm->SetMarkerColor(1);
    eff_MultiAlkEm->SetLineColor(1);
  //
    eff_GaAsEm->SetMarkerStyle(20);
    eff_GaAsEm->SetLineWidth(2);
    eff_GaAsEm->SetMarkerSize(0.9);
//    eff_GaAsEm_OFF->SetMarkerStyle(22);
//    eff_GaAsEm_OFF->SetLineWidth(2);
    eff_Double9040->SetMarkerStyle(20);
    eff_Double9040->SetLineWidth(2);
    eff_Double9040->SetMarkerSize(0.9);
    eff_Double9090->SetMarkerStyle(20);
    eff_Double9090->SetLineWidth(2);
    eff_Double9090->SetMarkerSize(0.9);
    eff_MultiAlkEm->SetMarkerStyle(22);
    eff_MultiAlkEm->SetLineWidth(2);

    legC->SetTextFont(42);
    legC->SetTextSize(0.034);
    legC->SetFillColor(kWhite);
    legC->SetLineColor(kWhite);
    legC->SetShadowColor(kWhite);
    legC->AddEntry(eff_MultiAlkEm, "MultiAlk. emitt. ON: #DeltaV_{12} = 300 V", "p");
    legC->AddEntry(eff_GaAsEm, "GaAs emitt. ON: #DeltaV_{12} = 300 V", "p");
//    legC->AddEntry(eff_GaAsEm_OFF, "GaAs emitt. - iMCP mode", "p");
    legC->AddEntry(eff_Double9040, "Double9040 HV_{1} = HV_{2}", "p");
    legC->AddEntry(eff_Double9090, "Double9090 HV_{1} = HV_{2}", "p");
  
    mg->Add(eff_GaAsEm);
//    mg->Add(eff_GaAsEm_OFF);
    mg->Add(eff_Double9090);
    mg->Add(eff_Double9040);
    mg->Add(eff_MultiAlkEm);

    //    TCanvas* c = new TCanvas("cEff","cEff",400,800);
    TCanvas* c = new TCanvas();
    gPad->SetTicks();
    char plot_name[100];
    std::string command = "if [ ! -e final_plots/ ] ; then mkdir final_plots ; fi";
    system(command.c_str());
    sprintf(plot_name, "final_plots/efficiency_%s.pdf", plot_type.c_str());

    mg->Draw("APL");
    mg->SetTitle("Electron Beam 450 MeV");
    mg->GetXaxis()->SetRangeUser(1200,4000);
    mg->GetXaxis()->SetTitle("HV_{1} (V)");
    mg->GetXaxis()->SetTitleSize(0.05);
    mg->GetYaxis()->SetTitle("Efficiency");
    mg->GetYaxis()->SetTitleSize(0.05);
    mg->SetMaximum(1);
    mg->SetMinimum(0);
    mg->Draw("APL");  
    legC->Draw("same");
    banner4Plot();
    c->Update();

    c->Print(plot_name, "pdf");
    sprintf(plot_name, "final_plots/efficiency_%s.png", plot_type.c_str());
    c->Print(plot_name, "png");

    sprintf(plot_name, "final_plots/efficiency_%s.root", plot_type.c_str());
    c->SaveAs(plot_name, "root");
    sprintf(plot_name, "final_plots/efficiency_%s.C", plot_type.c_str());
    c->SaveAs(plot_name, "C");
  }

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

if(plot_type == "HV1"){
    legC = new TLegend(0.52,0.58,0.80,0.83,NULL,"brNDC");

	//plot name MCPName_ScanType_HVScanScanType_MCPName
    inF_GaAsEm = TFile::Open("plots/efficiency_studies/GaAsEm_HV1_HVScan1_GaAsEm.root");
    //inF_GaAsEm_OFF = TFile::Open("plots/efficiency_studies/GaAsEm_HV_HVScan7.root");
    inF_MultiAlkEm = TFile::Open("plots/efficiency_studies/MultiAlkEm_HV1_HVScan1_MultiAlkEm.root");
    inF_Double9090 = TFile::Open("plots/efficiency_studies/Double9090_HV1_HVScan1_Double9090.root");
    inF_Double9040 = TFile::Open("plots/efficiency_studies/Double9040_HV1_HVScan1_Double9040.root");    
    TGraphErrors* eff_GaAsEm = (TGraphErrors*)inF_GaAsEm->Get("eff");
    TGraphErrors* eff_Double9090 = (TGraphErrors*)inF_Double9090->Get("eff");
    TGraphErrors* eff_MultiAlkEm = (TGraphErrors*)inF_MultiAlkEm->Get("eff");
    TGraphErrors* eff_Double9040 = (TGraphErrors*)inF_Double9040->Get("eff");

    //settings
    eff_GaAsEm->SetMarkerColor(kGreen+1);
    eff_GaAsEm->SetLineColor(kGreen+1);
    //eff_GaAsEm_OFF->SetMarkerColor(kGreen+1);
    //eff_GaAsEm_OFF->SetLineColor(kGreen+1);
    eff_Double9040->SetMarkerColor(kBlue);
    eff_Double9040->SetLineColor(kBlue);
    eff_Double9090->SetMarkerColor(kRed);
    eff_Double9090->SetLineColor(kRed);
    eff_MultiAlkEm->SetMarkerColor(1);
    eff_MultiAlkEm->SetLineColor(1);
  //
    eff_GaAsEm->SetMarkerStyle(20);
    eff_GaAsEm->SetLineWidth(2);
    eff_GaAsEm->SetMarkerSize(0.9);
//    eff_GaAsEm_OFF->SetMarkerStyle(22);
//    eff_GaAsEm_OFF->SetLineWidth(2);
    eff_Double9040->SetMarkerStyle(20);
    eff_Double9040->SetLineWidth(2);
    eff_Double9040->SetMarkerSize(0.9);
    eff_Double9090->SetMarkerStyle(20);
    eff_Double9090->SetLineWidth(2);
    eff_Double9090->SetMarkerSize(0.9);
    eff_MultiAlkEm->SetMarkerStyle(22);
    eff_MultiAlkEm->SetLineWidth(2);

    legC->SetTextFont(42);
    legC->SetTextSize(0.034);
    legC->SetFillColor(kWhite);
    legC->SetLineColor(kWhite);
    legC->SetShadowColor(kWhite);
    legC->AddEntry(eff_MultiAlkEm, "MultiAlk emitt. HV_{2} = 3100 (V)", "p");
    legC->AddEntry(eff_GaAsEm, "GaAs emitt. HV_{2} = 3100 (V)", "p");
//    legC->AddEntry(eff_GaAsEm_OFF, "GaAs emitt. - iMCP mode", "p");
//    legC->AddEntry(eff_Double9040, "Double9040 HV_{2} = 2700 (V)", "p");
//    legC->AddEntry(eff_Double9090, "Double9090 HV_{2} = 2700 (V)", "p");
  
    mg->Add(eff_GaAsEm);
//    mg->Add(eff_GaAsEm_OFF);
    //  mg->Add(eff_Double9090);
    //    mg->Add(eff_Double9040);
    mg->Add(eff_MultiAlkEm);

    //    TCanvas* c = new TCanvas("cEff","cEff",400,800);
    TCanvas* c = new TCanvas();
    gPad->SetTicks();
    char plot_name[100];
    std::string command = "if [ ! -e final_plots/ ] ; then mkdir final_plots ; fi";
    system(command.c_str());
    sprintf(plot_name, "final_plots/efficiency_%s.pdf", plot_type.c_str());

    mg->Draw("APL");
    mg->SetTitle("Electron Beam 450 MeV");
    mg->GetXaxis()->SetRangeUser(1200,4000);
    mg->GetXaxis()->SetTitle("HV_{1} (V)");
    mg->GetXaxis()->SetTitleSize(0.05);
    mg->GetYaxis()->SetTitle("Efficiency");
    mg->GetYaxis()->SetTitleSize(0.05);
    mg->SetMaximum(1);
    mg->SetMinimum(0);
    mg->Draw("APL");  
    legC->Draw("same");
    banner4Plot();
    c->Update();

    c->Print(plot_name, "pdf");
    sprintf(plot_name, "final_plots/efficiency_%s.png", plot_type.c_str());
    c->Print(plot_name, "png");

    sprintf(plot_name, "final_plots/efficiency_%s.root", plot_type.c_str());
    c->SaveAs(plot_name, "root");
    sprintf(plot_name, "final_plots/efficiency_%s.C", plot_type.c_str());
    c->SaveAs(plot_name, "C");
  }

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

if(plot_type == "HV2"){
    legC = new TLegend(0.12,0.62,0.40,0.87,NULL,"brNDC");

	//plot name MCPName_ScanType_HVScanScanType_MCPName
    //    inF_GaAsEm = TFile::Open("plots/efficiency_studies/GaAsEm_HV1_HVScan1_GaAsEm.root");
    //inF_GaAsEm_OFF = TFile::Open("plots/efficiency_studies/GaAsEm_HV_HVScan7.root");
    //inF_MultiAlkEm = TFile::Open("plots/efficiency_studies/MultiAlkEm_HV1_HVScan1_MultiAlkEm.root");
    inF_Double9090 = TFile::Open("plots/efficiency_studies/Double9090_HV2_HVScan2_Double9090.root");
    inF_Double9040 = TFile::Open("plots/efficiency_studies/Double9040_HV2_HVScan2_Double9040.root");    
    inF_Double9090b = TFile::Open("plots/efficiency_studies/Double9090_HV1_HVScan1_Double9090.root");
    inF_Double9040b = TFile::Open("plots/efficiency_studies/Double9040_HV1_HVScan1_Double9040.root");    
    //TGraphErrors* eff_GaAsEm = (TGraphErrors*)inF_GaAsEm->Get("eff");
    TGraphErrors* eff_Double9090 = (TGraphErrors*)inF_Double9090->Get("eff");
    TGraphErrors* eff_Double9040 = (TGraphErrors*)inF_Double9040->Get("eff");
    TGraphErrors* eff_Double9090b = (TGraphErrors*)inF_Double9090b->Get("eff");
    TGraphErrors* eff_Double9040b = (TGraphErrors*)inF_Double9040b->Get("eff");

    //settings
    eff_Double9040->SetMarkerColor(kBlue);
    eff_Double9040->SetLineColor(kBlue);
    eff_Double9090->SetMarkerColor(kRed);
    eff_Double9090->SetLineColor(kRed);
  //
    eff_Double9040->SetMarkerStyle(20);
    eff_Double9040->SetLineWidth(2);
    eff_Double9040->SetMarkerSize(0.9);
    eff_Double9090->SetMarkerStyle(20);
    eff_Double9090->SetLineWidth(2);
    eff_Double9090->SetMarkerSize(0.9);


    eff_Double9040b->SetMarkerColor(kBlue);
    eff_Double9040b->SetLineColor(kBlue);
    eff_Double9090b->SetMarkerColor(kRed);
    eff_Double9090b->SetLineColor(kRed);
  //
    eff_Double9040b->SetMarkerStyle(22);
    eff_Double9040b->SetLineWidth(2);
    eff_Double9040b->SetMarkerSize(0.9);
    eff_Double9090b->SetMarkerStyle(22);
    eff_Double9090b->SetLineWidth(2);
    eff_Double9090b->SetMarkerSize(0.9);

    legC->SetTextFont(42);
    legC->SetTextSize(0.034);
    legC->SetFillColor(kWhite);
    legC->SetLineColor(kWhite);
    legC->SetShadowColor(kWhite);
    legC->AddEntry(eff_Double9040, "Double9040 HV_{1} = 2700 (V), scan on HV_{2}", "p");
    legC->AddEntry(eff_Double9090, "Double9090 HV_{1} = 2700 (V), scan on HV_{2}", "p");

    legC->AddEntry(eff_Double9040b, "Double9040 HV_{2} = 2700 (V), scan on HV_{1}", "p");
    legC->AddEntry(eff_Double9090b, "Double9090 HV_{2} = 2700 (V), scan on HV_{1}", "p");
  
    mg->Add(eff_Double9090);
    mg->Add(eff_Double9040);
    mg->Add(eff_Double9090b);
    mg->Add(eff_Double9040b);

    //    TCanvas* c = new TCanvas("cEff","cEff",400,800);
    TCanvas* c = new TCanvas();
    gPad->SetTicks();
    char plot_name[100];
    std::string command = "if [ ! -e final_plots/ ] ; then mkdir final_plots ; fi";
    system(command.c_str());
    sprintf(plot_name, "final_plots/efficiency_%s.pdf", plot_type.c_str());

    mg->Draw("APL");
    mg->SetTitle("Electron Beam 450 MeV");
    mg->GetXaxis()->SetRangeUser(1200,4000);
    mg->GetXaxis()->SetTitle("HV_{1} or HV_{2} (V)");
    mg->GetXaxis()->SetTitleSize(0.05);
    mg->GetYaxis()->SetTitle("Efficiency");
    mg->GetYaxis()->SetTitleSize(0.05);
    mg->SetMaximum(1);
    mg->SetMinimum(0);
    mg->Draw("APL");  
    legC->Draw("same");
    banner4Plot();
    c->Update();

    c->Print(plot_name, "pdf");
    sprintf(plot_name, "final_plots/efficiency_%s.png", plot_type.c_str());
    c->Print(plot_name, "png");

    sprintf(plot_name, "final_plots/efficiency_%s.root", plot_type.c_str());
    c->SaveAs(plot_name, "root");
    sprintf(plot_name, "final_plots/efficiency_%s.C", plot_type.c_str());
    c->SaveAs(plot_name, "C");
  }

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

if(plot_type == "Extreme"){
    legC = new TLegend(0.12,0.72,0.30,0.87,NULL,"brNDC");

	//plot name MCPName_ScanType_HVScanScanType_MCPName
    //    inF_GaAsEm = TFile::Open("plots/efficiency_studies/GaAsEm_HV1_HVScan1_GaAsEm.root");
    //inF_GaAsEm_OFF = TFile::Open("plots/efficiency_studies/GaAsEm_HV_HVScan7.root");
    //inF_MultiAlkEm = TFile::Open("plots/efficiency_studies/MultiAlkEm_HV1_HVScan1_MultiAlkEm.root");
    inF_Double9090 = TFile::Open("plots/efficiency_studies/Double9090_HV1_HVScanExt_Double9090.root");
    inF_Double9040 = TFile::Open("plots/efficiency_studies/Double9040_HV1_HVScanExt_Double9040.root");    
    //TGraphErrors* eff_GaAsEm = (TGraphErrors*)inF_GaAsEm->Get("eff");
    TGraphErrors* eff_Double9090 = (TGraphErrors*)inF_Double9090->Get("eff");
    //TGraphErrors* eff_MultiAlkEm = (TGraphErrors*)inF_MultiAlkEm->Get("eff");
    TGraphErrors* eff_Double9040 = (TGraphErrors*)inF_Double9040->Get("eff");

    //settings
    eff_Double9040->SetMarkerColor(kBlue);
    eff_Double9040->SetLineColor(kBlue);
    eff_Double9090->SetMarkerColor(kRed);
    eff_Double9090->SetLineColor(kRed);
  //
    eff_Double9040->SetMarkerStyle(20);
    eff_Double9040->SetLineWidth(2);
    eff_Double9040->SetMarkerSize(0.9);
    eff_Double9090->SetMarkerStyle(20);
    eff_Double9090->SetLineWidth(2);
    eff_Double9090->SetMarkerSize(0.9);

    legC->SetTextFont(42);
    legC->SetTextSize(0.034);
    legC->SetFillColor(kWhite);
    legC->SetLineColor(kWhite);
    legC->SetShadowColor(kWhite);
    legC->AddEntry(eff_Double9040, "Double9040 HV_{2} = 3000 (V)", "p");
    legC->AddEntry(eff_Double9090, "Double9090 HV_{2} = 3000 (V)", "p");
  
    mg->Add(eff_Double9090);
    mg->Add(eff_Double9040);

    //    TCanvas* c = new TCanvas("cEff","cEff",400,800);
    TCanvas* c = new TCanvas();
    gPad->SetTicks();
    char plot_name[100];
    std::string command = "if [ ! -e final_plots/ ] ; then mkdir final_plots ; fi";
    system(command.c_str());
    sprintf(plot_name, "final_plots/efficiency_%s.pdf", plot_type.c_str());

    mg->Draw("APL");
    mg->SetTitle("Electron Beam 450 MeV");
    mg->GetXaxis()->SetRangeUser(2200,4000);
    mg->GetXaxis()->SetTitle("HV_{1} (V)");
    mg->GetXaxis()->SetTitleSize(0.05);
    mg->GetYaxis()->SetTitle("Efficiency");
    mg->GetYaxis()->SetTitleSize(0.05);
    mg->SetMaximum(1);
    mg->SetMinimum(0);
    mg->Draw("APL");  
    legC->Draw("same");
    banner4Plot();
    c->Update();

    c->Print(plot_name, "pdf");
    sprintf(plot_name, "final_plots/efficiency_%s.png", plot_type.c_str());
    c->Print(plot_name, "png");

    sprintf(plot_name, "final_plots/efficiency_%s.root", plot_type.c_str());
    c->SaveAs(plot_name, "root");
    sprintf(plot_name, "final_plots/efficiency_%s.C", plot_type.c_str());
    c->SaveAs(plot_name, "C");
  }

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

if(plot_type == "Ang"){
    legC = new TLegend(0.12,0.62,0.40,0.87,NULL,"brNDC");

	//plot name MCPName_ScanType_HVScanScanType_MCPName
    inF_Double9040 = TFile::Open("plots/efficiency_studies/Double9040_Ang_AngScan_Double9040.root");    
    TGraphErrors* eff_Double9040 = (TGraphErrors*)inF_Double9040->Get("eff");

    //settings
    eff_Double9040->SetMarkerColor(kBlue);
    eff_Double9040->SetLineColor(kBlue);
  //
    eff_Double9040->SetMarkerStyle(20);
    eff_Double9040->SetLineWidth(2);
    eff_Double9040->SetMarkerSize(0.9);

    legC->SetTextFont(42);
    legC->SetTextSize(0.034);
    legC->SetFillColor(kWhite);
    legC->SetLineColor(kWhite);
    legC->SetShadowColor(kWhite);
    legC->AddEntry(eff_Double9040, "Double9040 HV_{1} = 2700 V, HV_{2} = 2700 V", "p");
  
    mg->Add(eff_Double9040);

    //    TCanvas* c = new TCanvas("cEff","cEff",400,800);
    TCanvas* c = new TCanvas();
    gPad->SetTicks();
    char plot_name[100];
    std::string command = "if [ ! -e final_plots/ ] ; then mkdir final_plots ; fi";
    system(command.c_str());
    sprintf(plot_name, "final_plots/efficiency_%s.pdf", plot_type.c_str());

    mg->Draw("APL");
    mg->SetTitle("Electron Beam 450 MeV");
    mg->GetXaxis()->SetRangeUser(-1,50);
    mg->GetXaxis()->SetTitle("Angle (degrees)");
    mg->GetXaxis()->SetTitleSize(0.05);
    mg->GetYaxis()->SetTitle("Efficiency");
    mg->GetYaxis()->SetTitleSize(0.05);
    mg->SetMaximum(0.9);
    mg->SetMinimum(0.5);
    mg->Draw("APL");  
    legC->Draw("same");
    banner4Plot();
    c->Update();

    c->Print(plot_name, "pdf");
    sprintf(plot_name, "final_plots/efficiency_%s.png", plot_type.c_str());
    c->Print(plot_name, "png");

    sprintf(plot_name, "final_plots/efficiency_%s.root", plot_type.c_str());
    c->SaveAs(plot_name, "root");
    sprintf(plot_name, "final_plots/efficiency_%s.C", plot_type.c_str());
    c->SaveAs(plot_name, "C");
  }

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


 if(plot_type == "X0_12"){
    legC = new TLegend(0.15,0.15,0.45,0.32,NULL,"brNDC");

    inF_GaAsEm = TFile::Open("plots/efficiency_studies/GaAsEm_X0_X0Scan12_GaAsEm.root");
    //inF_GaAsEm_OFF = TFile::Open("plots/efficiency_studies/GaAsEm_HV_HVScan7.root");
    inF_MultiAlkEm = TFile::Open("plots/efficiency_studies/MultiAlkEm_X0_X0Scan12_MultiAlkEm.root");
    inF_Double9090 = TFile::Open("plots/efficiency_studies/Double9090_X0_X0Scan12_Double9090.root");
    inF_Double9040 = TFile::Open("plots/efficiency_studies/Double9040_X0_X0Scan12_Double9040.root");    

    TGraphErrors* eff_GaAsEm;
    TGraphErrors* eff_MultiAlkEm;
    TGraphErrors* eff_Double9090;
    TGraphErrors* eff_Double9040;
    
    
    eff_GaAsEm = (TGraphErrors*)inF_GaAsEm->Get("eff");
    eff_MultiAlkEm = (TGraphErrors*)inF_MultiAlkEm->Get("eff");
    eff_Double9090 = (TGraphErrors*)inF_Double9090->Get("eff");
    eff_Double9040 = (TGraphErrors*)inF_Double9040->Get("eff");
    
    //settings
    eff_GaAsEm->SetMarkerColor(kGreen+1);
    eff_GaAsEm->SetLineColor(kGreen+1);
    eff_Double9040->SetMarkerColor(kBlue);
    eff_Double9040->SetLineColor(kBlue);
    eff_Double9090->SetMarkerColor(kRed);
    eff_Double9090->SetLineColor(kRed);
    eff_MultiAlkEm->SetMarkerColor(1);
    eff_MultiAlkEm->SetLineColor(1);
    eff_GaAsEm->SetMarkerStyle(20);
    eff_GaAsEm->SetLineWidth(2);
    eff_GaAsEm->SetMarkerSize(0.9);  
    eff_Double9040->SetMarkerStyle(20);
    eff_Double9040->SetLineWidth(2);
    eff_Double9040->SetMarkerSize(0.9);
    eff_Double9090->SetMarkerStyle(20);
    eff_Double9090->SetLineWidth(2);
    eff_Double9090->SetMarkerSize(0.9);
    eff_MultiAlkEm->SetMarkerStyle(20);
    eff_MultiAlkEm->SetLineWidth(2);
    eff_MultiAlkEm->SetMarkerSize(0.9);
    
    legC->SetTextFont(42);
    legC->SetTextSize(0.037);
    legC->SetFillColor(kWhite);
    legC->SetLineColor(kWhite);
    legC->SetShadowColor(kWhite);

    mg->Add(eff_GaAsEm);
    mg->Add(eff_Double9090);
    mg->Add(eff_MultiAlkEm);
    mg->Add(eff_Double9040);

    TCanvas* c = new TCanvas();
    gPad->SetTicks();
    char plot_name[100];
    std::string command = "if [ ! -e final_plots/ ] ; then mkdir final_plots ; fi";
    system(command.c_str());
    sprintf(plot_name, "final_plots/efficiency_%s.pdf", plot_type.c_str());

    mg->Draw("ALP");
    mg->SetTitle("Electron Beam 450 MeV");
    mg->GetXaxis()->SetRangeUser(-0.1,7.2);
    mg->GetXaxis()->SetTitle("Number of X_{0}");
    mg->GetXaxis()->SetTitleSize(0.046);
    mg->GetYaxis()->SetTitle("Efficiency");
    mg->GetYaxis()->SetTitleSize(0.046);
    mg->SetMaximum(1.05);
    mg->SetMinimum(0);
     
    legC->AddEntry(eff_MultiAlkEm, "MultiAlk emitt (ON) HV_{1} = -3800 HV_{2} = -3500 (V)", "p"); 
    legC->AddEntry(eff_GaAsEm, "GaAs emitt. (ON) HV_{1} = -3400 (V) HV_{2} = -3100 (V)", "p"); 
    //legC->AddEntry(eff_GaAsEm_OFF, "GaAs emitt. - iMCP mode", "p");
    legC->AddEntry(eff_Double9040, "Double9040 HV_{1} = -2700 (V), HV_{2} = 2700 (V)", "p");
    legC->AddEntry(eff_Double9090, "Double9090 HV_{1} = -2700 (V), HV_{2} = 2700 (V)", "p");

    mg->Draw("ALP");  
    legC->Draw("same");
    banner4Plot();
    c->Update();

    c->Print(plot_name, "pdf");
    sprintf(plot_name, "final_plots/efficiency_%s.png", plot_type.c_str());
    c->Print(plot_name, "png");

    sprintf(plot_name, "final_plots/efficiency_%s.root", plot_type.c_str());
    c->Print(plot_name, "root");
    sprintf(plot_name, "final_plots/efficiency_%s.C", plot_type.c_str());
    c->SaveAs(plot_name, "C");
 }


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


 if(plot_type == "X0_1"){
    legC = new TLegend(0.15,0.15,0.45,0.32,NULL,"brNDC");

    inF_GaAsEm = TFile::Open("plots/efficiency_studies/GaAsEm_X0_X0Scan1_GaAsEm.root");
    //inF_GaAsEm_OFF = TFile::Open("plots/efficiency_studies/GaAsEm_HV_HVScan7.root");
    inF_MultiAlkEm = TFile::Open("plots/efficiency_studies/MultiAlkEm_X0_X0Scan1_MultiAlkEm.root");
    inF_Double9090 = TFile::Open("plots/efficiency_studies/Double9090_X0_X0Scan1_Double9090.root");
    inF_Double9040 = TFile::Open("plots/efficiency_studies/Double9040_X0_X0Scan1_Double9040.root");    

    TGraphErrors* eff_GaAsEm;
    TGraphErrors* eff_MultiAlkEm;
    TGraphErrors* eff_Double9090;
    TGraphErrors* eff_Double9040;
    
    
    eff_GaAsEm = (TGraphErrors*)inF_GaAsEm->Get("eff");
    eff_MultiAlkEm = (TGraphErrors*)inF_MultiAlkEm->Get("eff");
    eff_Double9090 = (TGraphErrors*)inF_Double9090->Get("eff");
    eff_Double9040 = (TGraphErrors*)inF_Double9040->Get("eff");
    
    //settings
    eff_GaAsEm->SetMarkerColor(kGreen+1);
    eff_GaAsEm->SetLineColor(kGreen+1);
    eff_Double9040->SetMarkerColor(kBlue);
    eff_Double9040->SetLineColor(kBlue);
    eff_Double9090->SetMarkerColor(kRed);
    eff_Double9090->SetLineColor(kRed);
    eff_MultiAlkEm->SetMarkerColor(1);
    eff_MultiAlkEm->SetLineColor(1);
    eff_GaAsEm->SetMarkerStyle(20);
    eff_GaAsEm->SetLineWidth(2);
    eff_GaAsEm->SetMarkerSize(0.9);  
    eff_Double9040->SetMarkerStyle(20);
    eff_Double9040->SetLineWidth(2);
    eff_Double9040->SetMarkerSize(0.9);
    eff_Double9090->SetMarkerStyle(20);
    eff_Double9090->SetLineWidth(2);
    eff_Double9090->SetMarkerSize(0.9);
    eff_MultiAlkEm->SetMarkerStyle(20);
    eff_MultiAlkEm->SetLineWidth(2);
    eff_MultiAlkEm->SetMarkerSize(0.9);
    
    legC->SetTextFont(42);
    legC->SetTextSize(0.037);
    legC->SetFillColor(kWhite);
    legC->SetLineColor(kWhite);
    legC->SetShadowColor(kWhite);

    mg->Add(eff_GaAsEm);
    mg->Add(eff_Double9090);
    mg->Add(eff_MultiAlkEm);
    mg->Add(eff_Double9040);

    TCanvas* c = new TCanvas();
    gPad->SetTicks();
    char plot_name[100];
    std::string command = "if [ ! -e final_plots/ ] ; then mkdir final_plots ; fi";
    system(command.c_str());
    sprintf(plot_name, "final_plots/efficiency_%s.pdf", plot_type.c_str());

    mg->Draw("ALP");
    mg->SetTitle("Electron Beam 450 MeV");
    mg->GetXaxis()->SetRangeUser(-0.1,7.2);
    mg->GetXaxis()->SetTitle("Number of X_{0}");
    mg->GetXaxis()->SetTitleSize(0.046);
    mg->GetYaxis()->SetTitle("Efficiency");
    mg->GetYaxis()->SetTitleSize(0.046);
    mg->SetMaximum(1.05);
    mg->SetMinimum(0);
     
    legC->AddEntry(eff_MultiAlkEm, "MultiAlk emitt (OFF) HV_{1} = -3450 HV_{2} = -3500 (V)", "p"); 
    legC->AddEntry(eff_GaAsEm, "GaAs emitt. (OFF) HV_{1} = -3050 (V) HV_{2} = -3100 (V)", "p"); 
    //legC->AddEntry(eff_GaAsEm_OFF, "GaAs emitt. - iMCP mode", "p");
    legC->AddEntry(eff_Double9040, "Double9040 HV_{1} = -2400 (V), HV_{2} = 2700 (V)", "p");
    legC->AddEntry(eff_Double9090, "Double9090 HV_{1} = -2400 (V), HV_{2} = 2700 (V)", "p");

    mg->Draw("ALP");  
    legC->Draw("same");
    banner4Plot();
    c->Update();

    c->Print(plot_name, "pdf");
    sprintf(plot_name, "final_plots/efficiency_%s.png", plot_type.c_str());
    c->Print(plot_name, "png");

    sprintf(plot_name, "final_plots/efficiency_%s.root", plot_type.c_str());
    c->Print(plot_name, "root");
    sprintf(plot_name, "final_plots/efficiency_%s.C", plot_type.c_str());
    c->SaveAs(plot_name, "C");
 }


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

 if(plot_type == "multiplicity1"){
    legC = new TLegend(0.15,0.15,0.45,0.32,NULL,"brNDC");

    inF_GaAsEm = TFile::Open("plots/efficiency_studies/GaAsEm_multiplicity1_LongScan0X0_GaAsEm_1.root");
    //inF_GaAsEm_OFF = TFile::Open("plots/efficiency_studies/GaAsEm_HV_HVScan7.root");
    inF_MultiAlkEm = TFile::Open("plots/efficiency_studies/MultiAlkEm_multiplicity1_LongScan0X0_MultiAlkEm_1.root");
    inF_Double9090 = TFile::Open("plots/efficiency_studies/Double9090_multiplicity1_LongScan0X0_Double9090_1.root");
    inF_Double9040 = TFile::Open("plots/efficiency_studies/Double9040_multiplicity1_LongScan0X0_Double9040_1.root");    

    TGraphErrors* eff_GaAsEm;
    TGraphErrors* eff_MultiAlkEm;
    TGraphErrors* eff_Double9090;
    TGraphErrors* eff_Double9040;
    
    
    eff_GaAsEm = (TGraphErrors*)inF_GaAsEm->Get("eff");
    eff_MultiAlkEm = (TGraphErrors*)inF_MultiAlkEm->Get("eff");
    eff_Double9090 = (TGraphErrors*)inF_Double9090->Get("eff");
    eff_Double9040 = (TGraphErrors*)inF_Double9040->Get("eff");
    
    //settings
    eff_GaAsEm->SetMarkerColor(kGreen+1);
    eff_GaAsEm->SetLineColor(kGreen+1);
    eff_Double9040->SetMarkerColor(kBlue);
    eff_Double9040->SetLineColor(kBlue);
    eff_Double9090->SetMarkerColor(kRed);
    eff_Double9090->SetLineColor(kRed);
    eff_MultiAlkEm->SetMarkerColor(1);
    eff_MultiAlkEm->SetLineColor(1);
    eff_GaAsEm->SetMarkerStyle(20);
    eff_GaAsEm->SetLineWidth(2);
    eff_GaAsEm->SetMarkerSize(0.9);  
    eff_Double9040->SetMarkerStyle(20);
    eff_Double9040->SetLineWidth(2);
    eff_Double9040->SetMarkerSize(0.9);
    eff_Double9090->SetMarkerStyle(20);
    eff_Double9090->SetLineWidth(2);
    eff_Double9090->SetMarkerSize(0.9);
    eff_MultiAlkEm->SetMarkerStyle(20);
    eff_MultiAlkEm->SetLineWidth(2);
    eff_MultiAlkEm->SetMarkerSize(0.9);
    
    legC->SetTextFont(42);
    legC->SetTextSize(0.037);
    legC->SetFillColor(kWhite);
    legC->SetLineColor(kWhite);
    legC->SetShadowColor(kWhite);

    mg->Add(eff_GaAsEm);
    mg->Add(eff_Double9090);
    mg->Add(eff_MultiAlkEm);
    mg->Add(eff_Double9040);

    TCanvas* c = new TCanvas();
    gPad->SetTicks();
    char plot_name[100];
    std::string command = "if [ ! -e final_plots/ ] ; then mkdir final_plots ; fi";
    system(command.c_str());
    sprintf(plot_name, "final_plots/efficiency_%s.pdf", plot_type.c_str());

    mg->Draw("ALP");
    mg->SetTitle("Electron Beam 450 MeV");
    mg->GetXaxis()->SetRangeUser(-0.1,7.2);
    mg->GetXaxis()->SetTitle("multiplicity");
    mg->GetXaxis()->SetTitleSize(0.046);
    mg->GetYaxis()->SetTitle("Efficiency");
    mg->GetYaxis()->SetTitleSize(0.046);
    mg->SetMaximum(1.05);
    mg->SetMinimum(0);
     
    legC->AddEntry(eff_MultiAlkEm, "MultiAlk emitt (ON) HV_{1} = -3800 HV_{2} = -3500 (V)", "p"); 
    legC->AddEntry(eff_GaAsEm, "GaAs emitt. (ON) HV_{1} = -3400 (V) HV_{2} = -3100 (V)", "p"); 
    //legC->AddEntry(eff_GaAsEm_OFF, "GaAs emitt. - iMCP mode", "p");
    legC->AddEntry(eff_Double9040, "Double9040 HV_{1} = -2700 (V), HV_{2} = 2700 (V)", "p");
    legC->AddEntry(eff_Double9090, "Double9090 HV_{1} = -2700 (V), HV_{2} = 2700 (V)", "p");

    mg->Draw("ALP");  
    legC->Draw("same");
    banner4Plot();
    c->Update();

    c->Print(plot_name, "pdf");
    sprintf(plot_name, "final_plots/efficiency_%s.png", plot_type.c_str());
    c->Print(plot_name, "png");

    sprintf(plot_name, "final_plots/efficiency_%s.root", plot_type.c_str());
    c->Print(plot_name, "root");
    sprintf(plot_name, "final_plots/efficiency_%s.C", plot_type.c_str());
    c->SaveAs(plot_name, "C");
 }


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


 if(plot_type == "multiplicity2"){
    legC = new TLegend(0.15,0.15,0.45,0.32,NULL,"brNDC");

    inF_GaAsEm = TFile::Open("plots/efficiency_studies/GaAsEm_multiplicity2_LongScan0X0_GaAsEm_2.root");
    //inF_GaAsEm_OFF = TFile::Open("plots/efficiency_studies/GaAsEm_multiplicity2_HVScan7.root");
    inF_MultiAlkEm = TFile::Open("plots/efficiency_studies/MultiAlkEm_multiplicity2_LongScan0X0_MultiAlkEm_2.root");
    inF_Double9090 = TFile::Open("plots/efficiency_studies/Double9090_multiplicity2_LongScan0X0_Double9090_2.root");
    inF_Double9040 = TFile::Open("plots/efficiency_studies/Double9040_multiplicity2_LongScan0X0_Double9040_2.root");    

    TGraphErrors* eff_GaAsEm;
    TGraphErrors* eff_MultiAlkEm;
    TGraphErrors* eff_Double9090;
    TGraphErrors* eff_Double9040;
    
    
    eff_GaAsEm = (TGraphErrors*)inF_GaAsEm->Get("eff");
    eff_MultiAlkEm = (TGraphErrors*)inF_MultiAlkEm->Get("eff");
    eff_Double9090 = (TGraphErrors*)inF_Double9090->Get("eff");
    eff_Double9040 = (TGraphErrors*)inF_Double9040->Get("eff");
    
    //settings
    eff_GaAsEm->SetMarkerColor(kGreen+1);
    eff_GaAsEm->SetLineColor(kGreen+1);
    eff_Double9040->SetMarkerColor(kBlue);
    eff_Double9040->SetLineColor(kBlue);
    eff_Double9090->SetMarkerColor(kRed);
    eff_Double9090->SetLineColor(kRed);
    eff_MultiAlkEm->SetMarkerColor(1);
    eff_MultiAlkEm->SetLineColor(1);
    eff_GaAsEm->SetMarkerStyle(20);
    eff_GaAsEm->SetLineWidth(2);
    eff_GaAsEm->SetMarkerSize(0.9);  
    eff_Double9040->SetMarkerStyle(20);
    eff_Double9040->SetLineWidth(2);
    eff_Double9040->SetMarkerSize(0.9);
    eff_Double9090->SetMarkerStyle(20);
    eff_Double9090->SetLineWidth(2);
    eff_Double9090->SetMarkerSize(0.9);
    eff_MultiAlkEm->SetMarkerStyle(20);
    eff_MultiAlkEm->SetLineWidth(2);
    eff_MultiAlkEm->SetMarkerSize(0.9);
    
    legC->SetTextFont(42);
    legC->SetTextSize(0.037);
    legC->SetFillColor(kWhite);
    legC->SetLineColor(kWhite);
    legC->SetShadowColor(kWhite);

    mg->Add(eff_GaAsEm);
    mg->Add(eff_Double9090);
    mg->Add(eff_MultiAlkEm);
    mg->Add(eff_Double9040);

    TCanvas* c = new TCanvas();
    gPad->SetTicks();
    char plot_name[100];
    std::string command = "if [ ! -e final_plots/ ] ; then mkdir final_plots ; fi";
    system(command.c_str());
    sprintf(plot_name, "final_plots/efficiency_%s.pdf", plot_type.c_str());

    mg->Draw("ALP");
    mg->SetTitle("Electron Beam 450 MeV");
    mg->GetXaxis()->SetRangeUser(-0.1,7.2);
    mg->GetXaxis()->SetTitle("multiplicity");
    mg->GetXaxis()->SetTitleSize(0.046);
    mg->GetYaxis()->SetTitle("Efficiency");
    mg->GetYaxis()->SetTitleSize(0.046);
    mg->SetMaximum(1.05);
    mg->SetMinimum(0);

    legC->AddEntry(eff_MultiAlkEm, "MultiAlk emitt (OFF) HV_{1} = -3450 HV_{2} = -3500 (V)", "p"); 
    legC->AddEntry(eff_GaAsEm, "GaAs emitt. (OFF) HV_{1} = -3050 (V) HV_{2} = -3100 (V)", "p"); 
    //legC->AddEntry(eff_GaAsEm_OFF, "GaAs emitt. - iMCP mode", "p");
    legC->AddEntry(eff_Double9040, "Double9040 HV_{1} = -2400 (V), HV_{2} = 2700 (V)", "p");
    legC->AddEntry(eff_Double9090, "Double9090 HV_{1} = -2400 (V), HV_{2} = 2700 (V)", "p");

    mg->Draw("ALP");  
    legC->Draw("same");
    banner4Plot();
    c->Update();

    c->Print(plot_name, "pdf");
    sprintf(plot_name, "final_plots/efficiency_%s.png", plot_type.c_str());
    c->Print(plot_name, "png");

    sprintf(plot_name, "final_plots/efficiency_%s.root", plot_type.c_str());
    c->Print(plot_name, "root");
    sprintf(plot_name, "final_plots/efficiency_%s.C", plot_type.c_str());
    c->SaveAs(plot_name, "C");
 }


/////----------------------------------------------------------------------------//////////////
  
 if(plot_type == "LongScan2X0"){
    legC = new TLegend(0.15,0.15,0.45,0.32,NULL,"brNDC");

    inF_GaAsEm = TFile::Open("plots/efficiency_studies/GaAsEm_HV1_LongScan2X0_GaAsEm.root");
    //inF_GaAsEm_OFF = TFile::Open("plots/efficiency_studies/GaAsEm_multiplicity2_HVScan7.root");
    inF_MultiAlkEm = TFile::Open("plots/efficiency_studies/MultiAlkEm_HV1_LongScan2X0_MultiAlkEm.root");
    inF_Double9090 = TFile::Open("plots/efficiency_studies/Double9090_HV1_LongScan2X0_Double9090.root");
    inF_Double9040 = TFile::Open("plots/efficiency_studies/Double9040_HV1_LongScan2X0_Double9040.root");    

    TGraphErrors* eff_GaAsEm;
    TGraphErrors* eff_MultiAlkEm;
    TGraphErrors* eff_Double9090;
    TGraphErrors* eff_Double9040;
    
    
    eff_GaAsEm = (TGraphErrors*)inF_GaAsEm->Get("eff");
    eff_MultiAlkEm = (TGraphErrors*)inF_MultiAlkEm->Get("eff");
    eff_Double9090 = (TGraphErrors*)inF_Double9090->Get("eff");
    eff_Double9040 = (TGraphErrors*)inF_Double9040->Get("eff");
    
    //settings
    eff_GaAsEm->SetMarkerColor(kGreen+1);
    eff_GaAsEm->SetLineColor(kGreen+1);
    eff_Double9040->SetMarkerColor(kBlue);
    eff_Double9040->SetLineColor(kBlue);
    eff_Double9090->SetMarkerColor(kRed);
    eff_Double9090->SetLineColor(kRed);
    eff_MultiAlkEm->SetMarkerColor(1);
    eff_MultiAlkEm->SetLineColor(1);
    eff_GaAsEm->SetMarkerStyle(20);
    eff_GaAsEm->SetLineWidth(2);
    eff_GaAsEm->SetMarkerSize(0.9);  
    eff_Double9040->SetMarkerStyle(20);
    eff_Double9040->SetLineWidth(2);
    eff_Double9040->SetMarkerSize(0.9);
    eff_Double9090->SetMarkerStyle(20);
    eff_Double9090->SetLineWidth(2);
    eff_Double9090->SetMarkerSize(0.9);
    eff_MultiAlkEm->SetMarkerStyle(20);
    eff_MultiAlkEm->SetLineWidth(2);
    eff_MultiAlkEm->SetMarkerSize(0.9);
    
    legC->SetTextFont(42);
    legC->SetTextSize(0.037);
    legC->SetFillColor(kWhite);
    legC->SetLineColor(kWhite);
    legC->SetShadowColor(kWhite);

    mg->Add(eff_GaAsEm);
    mg->Add(eff_Double9090);
    mg->Add(eff_MultiAlkEm);
    mg->Add(eff_Double9040);

    TCanvas* c = new TCanvas();
    gPad->SetTicks();
    char plot_name[100];
    std::string command = "if [ ! -e final_plots/ ] ; then mkdir final_plots ; fi";
    system(command.c_str());
    sprintf(plot_name, "final_plots/efficiency_%s.pdf", plot_type.c_str());

    mg->Draw("ALP");
    mg->SetTitle("Electron Beam 450 MeV");
    mg->GetXaxis()->SetRangeUser(1400,3800);
    mg->GetXaxis()->SetTitle("HV_{2} (V)");
    mg->GetXaxis()->SetTitleSize(0.046);
    mg->GetYaxis()->SetTitle("Efficiency");
    mg->GetYaxis()->SetTitleSize(0.046);
    mg->SetMaximum(1.05);
    mg->SetMinimum(0);

    legC->AddEntry(eff_MultiAlkEm, "MultiAlk emitt. HV_{2} = 3500 (V)", "p");
    legC->AddEntry(eff_GaAsEm, "GaAs emitt. HV_{2} = 3100 (V)", "p");
//    legC->AddEntry(eff_GaAsEm_OFF, "GaAs emitt. - iMCP mode", "p");
    legC->AddEntry(eff_Double9040, "Double9040 HV_{2} = 2700 (V)", "p");
    legC->AddEntry(eff_Double9090, "Double9090 HV_{2} = 2700 (V)", "p");

    mg->Draw("ALP");  
    legC->Draw("same");
    banner4Plot();
    c->Update();

    c->Print(plot_name, "pdf");
    sprintf(plot_name, "final_plots/efficiency_%s.png", plot_type.c_str());
    c->Print(plot_name, "png");

    sprintf(plot_name, "final_plots/efficiency_%s.root", plot_type.c_str());
    c->Print(plot_name, "root");
    sprintf(plot_name, "final_plots/efficiency_%s.C", plot_type.c_str());
    c->SaveAs(plot_name, "C");
 }


 return 0;
}
Example #6
0
/**
The purpose of this function is to conveniently plot an event. Each event is plotted on a TCanvas. Divided into as many pads as there are panels. Each pad is a TMultiGraph with a TLegend, and shows the channels of the digitizer connected to the lines of that panel. The grouping into pads must not necessarily be according to panels, but in any other prefered way.

@param a_channels - a vector of a vector of samples, containing all 32 channels
@ param a_channelsToPadsAssociation - a map from std::string, which is the name of the panel (or group of channels) to be assigned to each pad to a vector if integers, which is the list of channels indices corresponding to indices of channels in the paramater a_channels to associate to a pad
@param sEventTitle - a string containing the title of the event (for example, the time stamp)
*/
void RangePlotter::PlotRanges(Channels_t& a_channels, Range_t& a_channelsToPadsAssociation, std::string sEventTitle)
{	
//	printf("Plotting\n");
	//m_pCanvas->Clear();
	m_pCanvas->SetTitle(sEventTitle.c_str());
	
	
	int iPadCounter = 0;
	if(0 == m_vpMultiGraph.size())
	{
		MakePads(a_channelsToPadsAssociation.size());	
		for (auto& rangeIt: a_channelsToPadsAssociation)
		{	
			TMultiGraph* pMg = new TMultiGraph();	
			m_vpMultiGraph.push_back(std::unique_ptr<TMultiGraph>(pMg));

	//		m_pCanvas->cd(iPadCounter + 1);
			ChangePad(iPadCounter);
			int i = 0;

			auto legend = new TLegend(0.8,0.8,1,1, "Channels");
			m_vpLegends.push_back(std::unique_ptr<TLegend>(legend));
			printf("printing panel %s\n", rangeIt.first.c_str());
			for (auto& chanIt: rangeIt.second)
			{
				int iNumOfSamples = a_channels[chanIt].size();
				TGraph* pGr = new TGraph(iNumOfSamples);
				std::vector<float> vTimeSeq = CommonUtils::GenerateTimeSequence(iNumOfSamples, m_fSamplingFreqGHz);
				for (int counter = 0; counter < iNumOfSamples; counter++)
				{
					pGr->SetPoint(counter, vTimeSeq[counter], TransformToVoltage(a_channels[chanIt][counter]));
				}

				m_vpGraph[chanIt] = pGr;
				pGr->SetLineColor(m_colors[i%(sizeof(m_colors)/sizeof(int))]);
				pGr->SetName((m_sInstanceName + std::string("Pan_") + rangeIt.first + std::string("chan_") + std::to_string(chanIt)).c_str());
				std::string sGraphTitle = std::string("Channel ") + std::to_string(chanIt);
				pGr->SetTitle(sGraphTitle.c_str());
				legend->AddEntry(pGr,std::to_string(chanIt).c_str(), "l");
		
				pMg->Add(pGr);
				i++;
			}

			if(Configuration::Instance().ShowTriggerInWaveformsStep())
			{
				int iNumOfSamples = a_channels[a_channels.size() - 1].size();
				m_vpGraphPrecisionTrigger = new TGraph(iNumOfSamples);
				std::vector<float> vTimeSeq = CommonUtils::GenerateTimeSequence(iNumOfSamples, m_fSamplingFreqGHz);
				for (int counter = 0; counter < iNumOfSamples; counter++)
				{
					m_vpGraphPrecisionTrigger->SetPoint(counter, vTimeSeq[counter], TransformToVoltage(a_channels[a_channels.size() - 1][counter]));
				}
				
				m_vpGraphPrecisionTrigger->SetName((m_sInstanceName + std::string("Pan_") + rangeIt.first + "_Trig").c_str());	
				m_vpGraphPrecisionTrigger->SetTitle("Trigger");
				legend->AddEntry(m_vpGraphPrecisionTrigger,"Trigger", "l");
				pMg->Add(m_vpGraphPrecisionTrigger);
			}
			
			std::string sMultiGraphTitle = std::string("Panel ") + rangeIt.first;
			pMg->SetTitle(sMultiGraphTitle.c_str());

			pMg->Draw("AL");
			pMg->GetXaxis()->SetTitle("Time [nanoseconds]");
			pMg->GetXaxis()->CenterTitle();
			pMg->GetYaxis()->SetTitle("Voltage [volts]");
			pMg->GetYaxis()->CenterTitle();

			gPad->Modified();

			pMg->SetMinimum(m_fMinVoltage);
			pMg->SetMaximum(m_fMaxVoltage);
			legend->Draw();
			iPadCounter++;
		}
		m_pCanvas->Update();
	}
	else
	{
//		printf("Plottin again\n");
		for (auto& rangeIt: a_channelsToPadsAssociation)
		{
			printf("Panel %s\n", rangeIt.first.c_str());
			m_pCanvas->cd(iPadCounter + 1);
			for (auto& chanIt: rangeIt.second)
			{
//				printf("Chanenl %d\n", chanIt);
				//TODO: num of samples is constant per run at least!
				m_vpGraph[chanIt]->SetLineWidth(1);
				int iNumOfSamples = a_channels[chanIt].size();	
				std::vector<float> vTimeSeq = CommonUtils::GenerateTimeSequence(iNumOfSamples, m_fSamplingFreqGHz);	
				for (int counter = 0; counter < iNumOfSamples; counter++)
				{
					(m_vpGraph[chanIt]->GetY())[counter] = TransformToVoltage(a_channels[chanIt][counter]);
				}

				for (int counter = 0; counter < iNumOfSamples; counter++)
				{
					(m_vpGraphPrecisionTrigger->GetY())[counter] = TransformToVoltage(a_channels[a_channels.size() - 1][counter]);
				}
	
				gPad->Modified();
			}

			m_vpMultiGraph[iPadCounter]->Draw("AC");
			m_vpLegends[iPadCounter]->Draw();
			iPadCounter++;
		}
		printf("Updating\n");
		m_pCanvas->Update();
		printf("After updating\n");
	}
	printf("done\n");
}
int main(int argc, char *argv[])
{
  ApplyLHCbStyle();
  double maxrate;
  switch(argc)
  {
    case 2:
      maxrate=-1;
      break;
    case 3:
      if(atoi(argv[2]))
        maxrate=atoi(argv[2]);
      else
      {
        cout << "Argument not a number" << endl;
        return 1;
      }
      break;
    default:
      cout << "Usage: " << argv[0] << " <Filename> [<Max rate>]" << endl;
      return 1;
  }
  if(system("[ -a figs ]") != 0)
  {
    cout << "Directory ./figs/ does not exist" << endl;
    const int mkdirerr = system("mkdir figs");
    if(mkdirerr != 0)
    {
      cout << "Error code " << mkdirerr << " while creating ./figs/" << endl;
    }
    else
    {
      cout << "Directory ./figs/ created" << endl;
    }
  }
  TFile* file = new TFile(argv[1]);
  if(!file->IsOpen())
  {
    cout << "Exiting" << endl;
    return 1;
  }
  TTree* tree = (TTree*)file->Get("metatree");
  int iHV; tree->SetBranchAddress("HV", &iHV);
  vector<int> HVs;
  string HV;
  int n = tree->GetEntries();
  TCanvas* mapscan, * histcan, * graphcan, * indivgraphcan[4];
  TPad* mapspad[4], * histpad[4];
  TH1D* hist;
  TH2D* map;
  string title[4] = {"JB", "JT", "ST", "SB"};
//  string title[4] = {"FA0026", "DA0024", "FA0019", "FA0006"};
  TGraphErrors* graph[4];
  TMultiGraph* mg;
  TLegend* lg;
  float xlo, xhi, ylo, yhi;
//  rainbowgradient();
  heatmapgradient();
//  DarkBodyRadiator();
//  DarkBodyRadiator2();
//  redbluegradient();
//  heatmapRB();
  string plotname;
  stringstream plotnamestream;
  double* x[4], * y[4], * xe[4], * ye[4];
  for(int j = 0; j < 4; j++)
  {
    x[j]  = new double[n];
    y[j]  = new double[n];
    xe[j] = new double[n];
    ye[j] = new double[n];
  }

  Double_t maxima[4];
  cout << "Entering loop of " << n << " events." << endl;
  for(int i = 0; i < n; i++)
  {
    tree->GetEntry(i);
    HVs.push_back(iHV);
    HV = itoa(iHV);
    for(int j = 0; j < 4; j++)
    {
      map = (TH2D*)file->Get(("DarkMap"+HV+"V"+itoa(j)).c_str());
      maxima[j] = map->GetMaximum();
    }
  }
  sort(HVs.begin(), HVs.end());
  if(maxrate==-1)
  {
    for(int i = 1; i < 4; i++)
    {
      maxrate = TMath::Max(maxima[i-1], maxima[i]);
      maxima[i]=maxrate;
    }
  }
//  cout << "Plotting with a maximum rate of " << maxrate << endl;
  for(int i = 0; i < n; i++)
  {
    HV = itoa(HVs[i]);
    plotnamestream << "DarkRate" << setfill('0') << setw(4) << HVs[i];
    plotnamestream >> plotname;
    histcan = new TCanvas(plotname.c_str(), "", 800, 800);
    plotnamestream.clear();
    histcan->Draw();
    plotnamestream << "DarkMap" << setfill('0') << setw(4) << HVs[i];
    plotnamestream >> plotname;
    mapscan = new TCanvas(plotname.c_str(), "", 800, 800);
    plotnamestream.clear();
    mapscan->Draw();
    for(int j = 0; j < 4; j++)
    {
      // Set limits
      xlo = 0.5*((j/2)%2);
      xhi = xlo+0.5;
      ylo = 0.5*((j+((j/2)%2))%2);
      yhi = ylo+0.5;
      // 2D maps
      mapscan->cd();
      mapspad[j] = new TPad("", "", xlo, ylo, xhi, yhi);
      mapspad[j]->SetLeftMargin(  0.05);
      mapspad[j]->SetRightMargin( 0.15);
      mapspad[j]->SetTopMargin(   0.05);
      mapspad[j]->SetBottomMargin(0.05);
      mapspad[j]->Draw();
      mapspad[j]->cd();
      map = (TH2D*)file->Get(("DarkMap"+HV+"V"+itoa(j)).c_str());
      map->SetTitle("");
      map->SetMaximum(maxrate);
      map->SetMinimum(0);
      map->Draw("COLZ");
      // 1D histogram
      histcan->cd();
      histpad[j] = new TPad("", "", xlo, ylo, xhi, yhi);
      histpad[j]->SetLeftMargin(  0.05);
      histpad[j]->SetRightMargin( 0.15);
      histpad[j]->SetTopMargin(   0.05);
      histpad[j]->SetBottomMargin(0.05);
      histpad[j]->Draw();
      histpad[j]->SetLogy();
      histpad[j]->cd();
      hist = new TH1D(("hist"+itoa(i)+itoa(j)).c_str(), title[j].c_str(), 100, 0, maxrate);
      tree->Draw(("rate"+itoa(j)+">>"+hist->GetName()).c_str(), "", "", 1, i);
      // Graph
      x[j][i]  = HVs[i];
      xe[j][i] = 0;
      y[j][i]  = 0;
      ye[j][i] = 0;
      double yval = 0, yerr = 0;
      double npix = 0;
      for(int k = 0; k < 64; k++)
      {
        yval = map->GetBinContent((k/8)+1, (k%8)+1);
        yerr = map->GetBinError((k/8)+1, (k%8)+1);
        if(yval<0) continue;
        y[j][i]  += yval;
        ye[j][i] += yerr*yerr;
        npix++;
      }
      y[j][i]  /= npix;
      ye[j][i] = sqrt(ye[j][i])/npix;
      cout << npix << "\t" <<  y[j][i] << "±" << ye[j][i] << endl;
    }
    gStyle->SetOptStat("m");
    histcan->SaveAs(("./figs/"+(string)histcan->GetName()+".pdf").c_str());
    histcan->SaveAs(("./figs/"+(string)histcan->GetName()+".png").c_str());
    mapscan->SaveAs(("./figs/"+(string)mapscan->GetName()+".pdf").c_str());
    mapscan->SaveAs(("./figs/"+(string)mapscan->GetName()+".png").c_str());
  }
  mg = new TMultiGraph();
  lg = new TLegend(0.17,0.6,0.45,0.82);
  lg->SetFillStyle(0);
  lg->SetLineWidth(0);
  int linecolour[4] = {kBlue,kRed+1,kGreen+1,kViolet};
  int linestyle[4]  = {2,9,3,5};
  int index[4] = {1, 0, 2, 3}; // More sensible order
  for(int k = 0; k < 4; k++)
  {
    int j = index[k];
    graph[j] = new TGraphErrors(n, x[j], y[j], xe[j], ye[j]);
    graph[j]->SetTitle(title[j].c_str());
    graph[j]->SetLineWidth(2);
    indivgraphcan[j] = new TCanvas((title[j]+"graph").c_str(),"",1000,900);
    indivgraphcan[j]->Draw();
    graph[j]->GetXaxis()->SetTitle("High Voltage [V]");
    graph[j]->GetYaxis()->SetTitle("Dark count rate [Hz]");
    graph[j]->GetYaxis()->SetTitleOffset(1.25);
    graph[j]->SetMinimum(0);
    graph[j]->Draw("APL");
    indivgraphcan[j]->SaveAs(("./figs/graph"+title[j]+".pdf").c_str());
    graph[j]->SetLineColor(linecolour[j]);
    graph[j]->Fit("pol1");
    graph[j]->GetFunction("pol1")->SetLineColor(graph[j]->GetLineColor());
    graph[j]->GetFunction("pol1")->SetLineStyle(linestyle[j]);
    lg->AddEntry(graph[j]->GetFunction("pol1"),title[j].c_str(),"L");
    mg->Add(graph[j], "P");
  }
  graphcan = new TCanvas("graph", "", 900, 900);
  graphcan->cd();
  graphcan->Draw();
  mg->SetMinimum(0);
  mg->Draw("APL");
  mg->GetXaxis()->SetTitle("High Voltage [V]");
  mg->GetYaxis()->SetTitle("Dark count rate [Hz]");
  mg->GetXaxis()->SetTitleOffset(1.2);
  mg->GetYaxis()->SetTitleOffset(1.2);
  GetLHCbName()->Draw();
  lg->Draw();
  graphcan->SaveAs("figs/graph.pdf");

  cout << "\\hline" << endl << "Voltage";
  for(int j = 0; j < 4; j++)
  {
    cout << " & " << title[j];
  }
  cout << "\\\\\\hline" << endl;
  for(int i = 0; i < n; i++)
  {
    cout << HVs[i];
    for(int j = 0; j < 4; j++)
    {
      cout << setprecision(3) << " & " << y[j][i];
    }
    cout << "\\\\\\hline" << endl;
  }
  return 0;
}
Example #8
0
void Overlap_1and3Pixel(){		// name of file

using namespace std;

int i=0;			// used to name the TGraphs
int j=0;

TCanvas *c1 = new TCanvas("c1","c1", 600, 400);
TPad *pad1 = new TPad("pad1","",0,0,1,1);
TLegend *leg = new TLegend(.80,.70,.85,.87);

TGraph *gr[15];			// defines array to number of TGraphs

TMultiGraph *mg = new TMultiGraph();		// create multigraph

for (double bias=10;bias<=60;bias+=10){		// loop to create of graph for select bias values

	TString str =TString::Format("/afs/cern.ch/user/m/mbucklan/TCAD_Analysis/SimpleCMOS_2d/1pixel/CC_Simple_Pixel_bias=%.0f_500.txt",bias);		// does some magic, creates string with name of file
	
	if (i==4){
	
	i++;
	
	}

	gr[i] = new TGraph(str,"%lE %lE");		// creates graph called gr and reads file
	
	TString str1 =TString::Format("1 pixel %.0fV",bias);		// creates string with bias value
	gr[i]->SetTitle(str1);			// sets title to string
	gr[i]->SetLineColor(i+1);		// sets line colour, changes for each graph
	gr[i]->SetLineWidth(1);

	mg->Add(gr[i]);				// adds graph to multigraph
	
	leg->AddEntry(gr[i],str1,"l");
	
	i++;
	
	
}

for (double bias=10;bias<=60;bias+=10){		// loop to create of graph for select bias values

	TString str3 =TString::Format("/afs/cern.ch/user/m/mbucklan/TCAD_Analysis/SimpleCMOS_2d/3pixel/CC_3pixel_bias=%.1f_200.txt",bias);		// does some magic, creates string with name of file
	
	if (j==4){
	
	j++;
	
	}

	gr[i] = new TGraph(str3,"%lE %lE");		// creates graph called gr and reads file
	
	TString str4 =TString::Format("3 pixel %.0fV",bias);		// creates string with bias value
	gr[i]->SetTitle(str4);			// sets title to string
	gr[i]->SetLineColor(j+1);		// sets line colour, changes for each graph
	gr[i]->SetLineWidth(1);
	gr[i]->SetLineStyle(2);
	
	mg->Add(gr[i]);				// adds graph to multigraph
	
	leg->AddEntry(gr[i],str4,"l");
	
	i++;
	j++;
	
}

pad1->Draw();
pad1->cd();
pad1->SetTickx(1);		//draws ticks on top side x axis
pad1->SetTicky(1);		//draws ticks on right hand side y axis

gPad->Update();

mg->Draw("AC");		// draws graph

// Make the graph look fancy...ish
mg->GetXaxis()->SetTitle("Time (s)");
mg->GetYaxis()->SetTitle("Collected Charge (C)");
mg->GetHistogram()->SetTitle("Collected Charge for 1 and 3 Pixel 100#mum Thick Sensor, Resistivity=100#Omegacm");
mg->SetMinimum(0);

//mg->GetXaxis()->SetLimits(1.0e-8,11.5e-8);

leg->SetTextSize(0.03);
leg->SetBorderSize(0);		// no border
leg->Draw();


}
Example #9
0
void EffVsMass(string inName, int applyAnalysisCuts){

  gErrorIgnoreLevel = kWarning;
  CMSstyle();
  gStyle->SetOptStat(0);

  TFile *fin = TFile::Open(inName.c_str(), "read"); assert(fin);
  TGraphAsymmErrors* g[4];
  for(int ch=0; ch<4; ++ch){
    g[ch] = new TGraphAsymmErrors();
  }

  int ipoint = 0;
  for(int mass=200; mass <= 2000; mass += 100){
    string name = Form("WprimeToWZTo3LNu_M-%i",mass);
    
    float sample_tot(0), sample_pass(0);
    
    TH1F* hInfo = (TH1F*) fin->Get(Form("%s/hFileInfo", name.c_str()));
    if(!hInfo) continue;  
    float sample_weight = GetSampleInfo(hInfo, "Sample Weight");
    sample_tot = GetSampleInfo(hInfo, "Number of Events Produced");
    sample_tot *= (4./9.); //remove tau contribution from denom
    
    //get tree from file
    TTree* t = getTree(fin, name, "tEvts_MET"); assert(t);
    string analysisCuts = applyAnalysisCuts ? (applyAnalysisCuts == 1 ? Form("Lt > %.0f", LtCut(mass)) : AnalysisCuts(mass)) : "1";

    for(int ch=0; ch<4; ++ch){
      float tot = sample_tot / 4;
      float pass = 0;

      float pass_alt = t->Draw("WZMass", Form("weight*(EvtType == %i)*(%s)",ch, analysisCuts.c_str()), "goff");
      int n = t->GetSelectedRows();
      for(int ientry=0; ientry<n; ++ientry){
        float weight = t->GetW()[ientry];
        pass += weight;
      }
      pass /= sample_weight;
      sample_pass += pass;
      
      float mean    = tot>0 ? pass / tot : 0.;
      float errUp   = TEfficiency::ClopperPearson(tot, pass, 0.68, true) - mean;
      float errDown = mean - TEfficiency::ClopperPearson(tot, pass, 0.68, false);
      
      errDown = std::max(errDown, (float) 0.);
      float err = (errUp + errDown)/2;
      printf(" %s %ie%i\\mu &  %4.2f & %4.2f or %4.2f & %.2f \\pm %.2f\\%% \\\\\n", name.c_str(), 3-ch, ch, tot, pass, pass_alt, mean*100, err*100);

      g[ch]->SetPoint(ipoint, mass, mean);
      g[ch]->SetPointError(ipoint, 0., 0., errDown, errUp);
    }
    ipoint++;
  }

  TCanvas* c1 = new TCanvas();
  TMultiGraph* mg = new TMultiGraph("mg", ";M_{W'} (GeV); #varepsilon");
  TLegend *legend = new TLegend(0.4,0.2,0.51,0.4,"");
  prepLegend(legend);
  for(int ch=0; ch<4; ++ch){
    g[ch]->SetMarkerColor(ch+2);
    g[ch]->SetLineColor(ch+2);
    legend->AddEntry(g[ch], Form("%ie%i#mu", 3-ch, ch), "PE");
    mg->Add(g[ch]);
  }
  mg->SetMaximum(1.1);
  mg->SetMinimum(0. );
  mg->Draw("AP");
  legend->Draw();

  TLatex latexLabel;
  latexLabel.SetNDC();
  latexLabel.SetTextSize(0.05);
  latexLabel.SetTextFont(42);
  latexLabel.DrawLatex(0.33, 0.96, "CMS Simulation 2012");
  latexLabel.DrawLatex(0.21, 0.85, "#sqrt{s} = 8 TeV");

  string outName = applyAnalysisCuts ? (applyAnalysisCuts==1 ? "EffVsMass_LtCut.png" : "EffVsMass_AnalysisCuts.png") : "EffVsMass.png";
  c1->SaveAs(outName.c_str());
}
Example #10
0
// define the generator's information across different ctau models
void Limit_lambda() {

   gROOT->LoadMacro("CMS_lumi.C");

   string hfolder  = "Limit1/" ;

   string ctau = "2000" ;
   string names[4] = {  "1935", "2060", "1945", "2195"  } ;
   const int sz = 4;

   string ld_Str[4] = { "120", "140", "160", "180" } ;
   float x[4] = { 120, 140, 160, 180, } ;
   float Xsec[4] = { 0.133, 0.0574, 0.0277, 0.0145 }  ;

   /*
   string ctau = "6000" ;
   string names[6] = { "6000", "5985", "6000", "5875", "5980", "6000"  } ;
   const int sz = 6;

   string ld_Str[6] = { "100", "120", "140", "160", "180", "220" } ;
   float x[6] = { 100, 120, 140, 160, 180, 220 } ;
   float Xsec[6] = { 0.368, 0.133, 0.0574, 0.0277, 0.0145, 0.0048}  ;

   string ctau = "1000" ;
   string names[4] = {  "1030", "975", "1100", "1000"  } ;
   const int sz = 4;

   string ld_Str[4] = { "140", "160", "180", "220" } ;
   float x[4] = { 140, 160, 180, 220 } ;
   float Xsec[4] = { 0.0574, 0.0277, 0.0145, 0.0048}  ;

   string ctau = "10000" ;
   string names[6] = { "10000", "10000", "10000", "10000", "10000", "10000" } ;
   const int sz = 6;

   string ld_Str[6] = { "100", "120", "140", "160", "180", "220" } ;
   float x[6] = { 100, 120, 140, 160, 180, 220 } ;
   float Xsec[6] = { 0.368, 0.133, 0.0574, 0.0277, 0.0145, 0.0048}  ;

   string ctau = "500" ;
   string names[4] = { "425", "515", "490", "500" } ;
   const int sz = 4;

   string ld_Str[4] = { "100", "140", "160", "220" } ;
   float x[4] = { 100, 140, 160, 220 } ;
   float Xsec[4] = { 0.368, 0.0574, 0.0277, 0.0048}  ;
   */

   /*
   string Lambda = "160" ;
   float Xsec = 0.0277 ;
   string names[7] = { "490", "975", "1945", "2930", "3910", "5875", "10000"  } ;
   const int sz = 7;

   string Lambda = "180" ;
   float Xsec = 0.0145 ;
   string names[8] = { "185", "365", "730", "1100", "2195", "3950", "5980", "10000"  } ;
   const int sz = 8;

   string Lambda = "220" ;
   float Xsec = 0.0048 ;
   string names[5] = { "500", "1000", "3000", "6000", "10000"  } ;
   const int sz = 5;

   string Lambda = "100" ;
   float Xsec = 0.368 ;
   string names[7] = { "215", "425", "1700", "3400", "5100", "6000", "10000"  } ;
   const int sz = 7;

   string Lambda = "120" ;
   float Xsec = 0.133 ;
   string names[8] = { "325", "645", "1290", "1935", "2955", "3870", "5985", "10000"  } ;
   const int sz = 8;

   string Lambda = "140" ;
   float Xsec = 0.0574 ;
   string names[8] = { "130", "515", "1030", "2060", "2920", "3985", "6000", "10000"  } ;
   const int sz = 8;
   */

   TString legTitle = "#tilde{#chi}^{0}_{1} #rightarrow #gamma #tilde{G}, c#tau ="+ ctau + " mm" ;
   string limitPlotName = "limit_ct"+ ctau + ".png" ;

   float yMax = 30. * Xsec[0] ;
   float yMin = 0.1 * Xsec[sz-1] ; 

   char s1[8],s2[8],s3[8],s4[8],s5[8],s6[8],s7[8] ;
   float f1,f2 ;
   int r1 ;
   float md[sz], u1[sz], u2[sz], d1[sz], d2[sz], ob[sz], x[sz], th[sz] ;
   float ex[sz] = { 0. } ;
   FILE* logf ; 

   // Get signal strength
   for (int i=0; i< sz; i++ ) {
       string fileName = hfolder +  "log_" + ld_Str[i] + "_" + names[i] + ".txt"  ;
       printf(" filename : %s \n", fileName.c_str() ) ;
       logf = fopen( fileName.c_str() ,"r");
       th[i] = Xsec[i] ;

       for (int j=0; j< 6; j++ ) {
           r1 = fscanf( logf, "%s %s %s %f %s %f %s %s %s", s1,s2,s3,&f1,s4,&f2,s5,s6,s7  );
	   printf("[%.0f] %s %s %s %f %s %f %s %s %s \n", x[i], s1,s2,s3, f1, s4, f2, s5,s6,s7 ) ;
           if ( j == 0 ) ob[i] = f1 * Xsec[i] ;
           if ( j == 1 ) u2[i] = f1 * Xsec[i] ;
           if ( j == 2 ) u1[i] = f1 * Xsec[i] ;
           if ( j == 3 ) md[i] = f1 * Xsec[i] ;
           if ( j == 4 ) d1[i] = f1 * Xsec[i] ;
           if ( j == 5 ) d2[i] = f1 * Xsec[i] ;
       } 
       u2[i] = u2[i] - md[i] ;
       u1[i] = u1[i] - md[i] ;
       d1[i] = md[i] - d1[i] ;
       d2[i] = md[i] - d2[i] ;

       printf(" -- \n") ;
       fclose( logf ) ;
   }


   // For the frame:
   gStyle->SetFrameBorderMode(0);
   gStyle->SetFrameBorderSize(1);
   gStyle->SetFrameFillColor(0);
   gStyle->SetFrameFillStyle(0);
   gStyle->SetFrameLineColor(1);
   gStyle->SetFrameLineStyle(1);
   gStyle->SetFrameLineWidth(1);

   gStyle->SetLabelOffset(0.007, "XYZ");
   gStyle->SetLabelSize(0.04, "XYZ");

   TCanvas *c1a = new TCanvas("c1a","c1a" ,800,800);
   //c1a->SetGridy() ;
   c1a->SetTopMargin(0.1);
   c1a->SetBottomMargin(0.13);
   c1a->SetLeftMargin(0.16);
   c1a->SetRightMargin(0.05);

   c1a->SetLogy() ;
   TMultiGraph *mg = new TMultiGraph();
   //gStyle->SetTitleW(0.85);
   //mg->SetTitle( "   CMS 19.1 fb^{-1}                                                   #sqrt{s} = 8 TeV" );

   // SetFillStyle ref: http://root.cern.ch/root/html/TAttFill.html
   TGraphAsymmErrors* gbe = new TGraphAsymmErrors(sz, x, md, ex, ex, d2, u2);
   gbe->SetFillStyle(1001);
   gbe->SetFillColor(kYellow);
   //gbe->GetXaxis()->SetLimits(240.,6100.) ;

   TGraphAsymmErrors* gae = new TGraphAsymmErrors(sz, x, md, ex, ex, d1, u1);
   gae->SetFillStyle(1001);
   //gae->SetFillColor(kSpring);
   gae->SetFillColor(kGreen);
   //gae->GetXaxis()->SetRangeUser(1.,5.) ;
   //gae->GetXaxis()->SetLimits(1.,5.) ;

   mg->Add( gbe ) ;
   mg->Add( gae ) ;
   mg->Draw("a3") ;

   // this modify the x-axis range, must set after Draw() ...stupid ROOT 
   gPad->Modified();
   mg->GetXaxis()->SetLimits( x[0] - 1, x[sz-1]+1 ) ;
   mg->SetMaximum( yMax );
   mg->SetMinimum( yMin );
   mg->GetXaxis()->SetTitleOffset(1.1);
   mg->GetYaxis()->SetTitleOffset(1.3);
   mg->GetXaxis()->SetTitleFont(42);
   mg->GetYaxis()->SetTitleFont(42);
   mg->GetXaxis()->SetTitleSize(0.04);
   mg->GetYaxis()->SetTitleSize(0.04);
   mg->GetXaxis()->SetTitle( "SUSY breaking scale (TeV)"  ) ;
   //mg->GetXaxis()->SetTitle( "MET Cut (GeV)" ) ;
   mg->GetYaxis()->SetTitle(" #sigma_{Upper Limit} (pb) at 95% CL") ;

   // expected
   TGraph*  g1  = new TGraph(sz, x, md ) ;
   g1->SetLineColor(2) ;
   g1->SetLineWidth(2) ;
   g1->SetLineStyle(1) ;
   //g1->GetXaxis()->SetLimits(1.,5.) ;
   g1->Draw("LP") ;
   c1a->Update() ;

   // observation
   TGraph*  g0  = new TGraph(sz, x, ob ) ;
   g0->SetLineColor(1) ;
   g0->SetLineWidth(2) ;
   g0->SetLineStyle(1) ;
   //g0->GetXaxis()->SetLimits(1.,5.) ;
   //g0->SetMarkerStyle(20) ;
   g0->Draw("LP") ;
   c1a->Update() ;


   // theoratical suggestion
   TGraph*  gth = new TGraph(sz, x, th ) ;
   gth->SetLineColor(4) ;
   gth->SetLineWidth(2) ;
   gth->SetLineStyle(1) ;
   gth->GetXaxis()->SetLimits( x[0], x[sz-1] ) ;
   gth->Draw("L") ;
   
   TLegend* leg1  = new TLegend(.4, .6, .90, .88 );
   //TLegend* leg1  = new TLegend(.4, .15, .90, .40 );
   leg1->SetHeader( legTitle ); 
   leg1->SetFillStyle(0); 
   leg1->SetBorderSize(0);
   leg1->SetFillColor(0);
   leg1 ->SetTextFont(22);

   leg1->SetFillColor(10) ;
   leg1->SetTextSize(0.030) ;
   leg1->AddEntry( gbe, "#pm 2#sigma Expected" ,  "F");
   leg1->AddEntry( gae, "#pm 1#sigma Expected" ,  "F");
   leg1->AddEntry( g1,  "Expected 95% CL upper limit" , "L");
   leg1->AddEntry( gth, "Theoretical LO cross-section", "L");
   leg1->AddEntry( g0,  "Observed" , "L");
   leg1->Draw("same") ;

   CMS_lumi( c1a, 2, 11 ) ;
   c1a->Update();

   TString gPlotname = hfolder +  limitPlotName  ;
   c1a->Print( gPlotname ) ;
   delete c1a ;

   /*
    // *************************
    // ***  Drawing setup    ***
    // *************************
    gStyle->SetOptStat("");

    gStyle->SetOptStat(kFALSE);
    //gStyle->SetOptFit(111);
    gStyle->SetOptTitle(0);
    //gStyle->SetTitleFontSize(0.05);
 
    // Plots
    TCanvas* c0 = new TCanvas("c0","", 800, 700);
    c0->SetFillColor(10);
    c0->SetFillColor(10);

    c0->SetTopMargin(0.1);
    c0->SetBottomMargin(0.13);
    c0->SetLeftMargin(0.16);
    c0->SetRightMargin(0.05);
    c0->SetLogy();

    //gPad->SetGridx();
    //gPad->SetGridy();
    c0->cd();

    TGraphAsymmErrors* eff[nModel] ;
    leg1->Clear() ;
    for ( int i=0; i< nModel; i++ ) {

        eff[i]= new TGraphAsymmErrors();

        D_ctbgT[i]->Rebin( rbin ) ;
        N_ctbgT[i]->Rebin( rbin ) ;

        eff[i]->Divide( N_ctbgT[i], D_ctbgT[i] );    

        eff[i]->SetMarkerColor( color[i] );
        eff[i]->SetLineColor( color[i] );
        leg1->AddEntry( eff[i], names[i]+" TeV" ,  "L");

        if ( i ==0 ) {
           c0->cd();
           c0->SetLogy(0);

           eff[i]->SetMaximum( ymax );
           eff[i]->SetMinimum( 0.0 );
           eff[i]->SetMarkerStyle(22);
           eff[i]->SetMarkerSize(1);
           eff[i]->SetLineWidth(2);

           eff[i]->GetXaxis()->SetTitleOffset(0.9);
           eff[i]->GetYaxis()->SetTitleOffset(1.25);
	   eff[i]->GetXaxis()->SetTitleSize(0.06);
	   eff[i]->GetYaxis()->SetTitleSize(0.06);
         
           eff[i]->GetXaxis()->SetTitle("Number of Vertices") ;
           eff[i]->GetYaxis()->SetTitle("Efficiency ") ;
           eff[i]->GetXaxis()->SetRangeUser(0, xmax ) ;
           eff[i]->Draw("AP");
        } else {
           eff[i]->Draw("SAMEPS");
        }
    }
    leg1->Draw("sames") ;
    c0->Update();

    CMS_lumi( c0, 2, 11 ) ;
    c0->Update();

    c0->Print( hfolder + plotname );


    delete c0 ;
    */
}
Example #11
0
int main(int argc, char** argv)
{

  std::string plot_type = argv[1];
    //"EffAll";
  //    std::string plot_type = "AngScanHigh";
  //  std::string plot_type = "scanX0_HVLow_50";
  //  std::string plot_type = "scanX0_HVLow_20";
  std::cout<<plot_type<<std::endl;

  TFile* inF_MiB3_ON;
  TFile* inF_MiB3_OFF;
  TFile* inF_enSEE;
  TFile* inF_ZStack1_ON;
  TFile* inF_ZStack1_OFF;
  TFile* inF_ZStack2_ON;
  TFile* inF_ZStack2_OFF;

  TFile* inF_MiB3;
  TFile* inF_ZStack1;
  TFile* inF_ZStack2;

  TMultiGraph *mg = new TMultiGraph();

  TLegend *legC;

  if(plot_type == "EffAll"){
    legC = new TLegend(0.15,0.65,0.35,0.85,NULL,"brNDC");

    inF_MiB3_ON = TFile::Open("plots/efficiency_studies/MiB3_HV_HVScan2.root");
    inF_MiB3_OFF = TFile::Open("plots/efficiency_studies/MiB3_HV_HVScan7.root");
    inF_enSEE = TFile::Open("plots/efficiency_studies/enSEE_HV_HVScan5.root");
    inF_ZStack1_ON = TFile::Open("plots/efficiency_studies/ZStack1_HV_HVScan1.root");
    inF_ZStack1_OFF = TFile::Open("plots/efficiency_studies/ZStack1_HV_HVScan8.root");
    inF_ZStack2_ON = TFile::Open("plots/efficiency_studies/ZStack2_HV_HVScan2.root");
    inF_ZStack2_OFF = TFile::Open("plots/efficiency_studies/ZStack2_HV_HVScan6.root");

    TGraphErrors* eff_MiB3_ON = (TGraphErrors*)inF_MiB3_ON->Get("frac_saturated");
    TGraphErrors* eff_MiB3_OFF = (TGraphErrors*)inF_MiB3_OFF->Get("frac_saturated");
    TGraphErrors* eff_enSEE = (TGraphErrors*)inF_enSEE->Get("frac_saturated");
    TGraphErrors* eff_ZStack1_ON = (TGraphErrors*)inF_ZStack1_ON->Get("frac_saturated");
    TGraphErrors* eff_ZStack1_OFF = (TGraphErrors*)inF_ZStack1_OFF->Get("frac_saturated");
    TGraphErrors* eff_ZStack2_ON = (TGraphErrors*)inF_ZStack2_ON->Get("frac_saturated");
    TGraphErrors* eff_ZStack2_OFF = (TGraphErrors*)inF_ZStack2_OFF->Get("frac_saturated");

    //settings
    eff_MiB3_ON->SetMarkerColor(kGreen+1);
    eff_MiB3_ON->SetLineColor(kGreen+1);
    eff_MiB3_OFF->SetMarkerColor(kGreen+1);
    eff_MiB3_OFF->SetLineColor(kGreen+1);
    eff_ZStack2_ON->SetMarkerColor(kBlue);
    eff_ZStack2_ON->SetLineColor(kBlue);
    eff_ZStack1_ON->SetMarkerColor(kRed);
    eff_ZStack1_ON->SetLineColor(kRed);
    eff_ZStack2_OFF->SetMarkerColor(kBlue);
    eff_ZStack2_OFF->SetLineColor(kBlue);
    eff_ZStack1_OFF->SetMarkerColor(kRed);
    eff_ZStack1_OFF->SetLineColor(kRed);
    eff_enSEE->SetMarkerColor(1);
    eff_enSEE->SetLineColor(1);
  //
    eff_MiB3_ON->SetMarkerStyle(20);
    eff_MiB3_ON->SetLineWidth(2);
    eff_MiB3_ON->SetMarkerSize(0.7);
    eff_MiB3_OFF->SetMarkerStyle(22);
    eff_MiB3_OFF->SetLineWidth(2);
    eff_ZStack2_ON->SetMarkerStyle(20);
    eff_ZStack2_ON->SetLineWidth(2);
    eff_ZStack2_ON->SetMarkerSize(0.7);
    eff_ZStack1_ON->SetMarkerStyle(20);
    eff_ZStack1_ON->SetLineWidth(2);
    eff_ZStack1_ON->SetMarkerSize(0.7);
    eff_ZStack2_OFF->SetMarkerStyle(22);
    eff_ZStack2_OFF->SetLineWidth(2);
    eff_ZStack1_OFF->SetMarkerStyle(22);
    eff_ZStack1_OFF->SetLineWidth(2);
    eff_enSEE->SetMarkerStyle(22);
    eff_enSEE->SetLineWidth(2);


    legC->SetTextFont(42);
    legC->SetTextSize(0.03);
    legC->SetFillColor(kWhite);
    legC->SetLineColor(kWhite);
    legC->SetShadowColor(kWhite);

    legC->AddEntry(eff_MiB3_ON, "MiB3 chevron-ON", "p");
    legC->AddEntry(eff_MiB3_OFF, "MiB3 chevron-OFF", "p");
    legC->AddEntry(eff_ZStack2_ON, "ZStack2 ON", "p");
    legC->AddEntry(eff_ZStack2_OFF, "ZStack2 OFF", "p");
    legC->AddEntry(eff_ZStack1_ON, "ZStack1 ON", "p");
    legC->AddEntry(eff_ZStack1_OFF, "ZStack1 OFF", "p");
    legC->AddEntry(eff_enSEE, "SEE OFF", "p");
  
    mg->Add(eff_MiB3_ON);
    mg->Add(eff_MiB3_OFF);
    mg->Add(eff_ZStack1_ON);
    mg->Add(eff_ZStack1_OFF);
    mg->Add(eff_ZStack2_OFF);
    mg->Add(eff_ZStack2_ON);
    mg->Add(eff_ZStack2_OFF);
    mg->Add(eff_enSEE);

    TCanvas* c = new TCanvas();
    gPad->SetTicks();
    char plot_name[100];
    std::string command = "if [ ! -e final_plots/ ] ; then mkdir final_plots ; fi";
    system(command.c_str());
    sprintf(plot_name, "final_plots/saturatedFrac_%s.pdf", plot_type.c_str());

    mg->Draw("AP");
    mg->GetXaxis()->SetRangeUser(-0.1,5.1);
    mg->GetXaxis()->SetTitle("HV (V)");
    mg->GetYaxis()->SetTitle("SaturatedFrac");
    mg->SetMaximum(100);
    mg->SetMinimum(0);
    mg->Draw("AP");  
    legC->Draw("same");

    c->Print(plot_name, "pdf");
    sprintf(plot_name, "final_plots/saturatedFrac_%s.png", plot_type.c_str());
    c->Print(plot_name, "png");

  }

  else {

    legC = new TLegend(0.15,0.70,0.3,0.85,NULL,"brNDC");

    TGraphErrors* eff_MiB3;
    TGraphErrors* eff_enSEE;
    TGraphErrors* eff_ZStack1;
    TGraphErrors* eff_ZStack2;

    if(plot_type == "AngScanHigh"){
      inF_MiB3 = TFile::Open("plots/efficiency_studies/MiB3_X0_AngScan_HVHigh.root");
      inF_enSEE = TFile::Open("plots/efficiency_studies/enSEE_X0_AngScan_HVHigh.root");
      inF_ZStack1 = TFile::Open("plots/efficiency_studies/ZStack1_X0_AngScan_HVHigh.root");
    }
    if(plot_type == "AngScanLow"){
      inF_MiB3 = TFile::Open("plots/efficiency_studies/MiB3_X0_AngScan_HVLow.root");
      inF_enSEE = TFile::Open("plots/efficiency_studies/enSEE_X0_AngScan_HVLow.root");
      inF_ZStack1 = TFile::Open("plots/efficiency_studies/ZStack1_X0_AngScan_HVLow.root");
    }
    
    if(plot_type == "scanX0_HVHigh_50"){
      inF_MiB3 = TFile::Open("plots/efficiency_studies/MiB3_X0_scanX0_HVHigh50GeV.root");
      inF_enSEE = TFile::Open("plots/efficiency_studies/enSEE_X0_scanX0_HVHigh50GeV.root");
      inF_ZStack2 = TFile::Open("plots/efficiency_studies/ZStack2_X0_scanX0_HVHigh50GeV.root");
      inF_ZStack1 = TFile::Open("plots/efficiency_studies/ZStack1_X0_scanX0_HVHigh50GeV.root");
    }
    if(plot_type == "scanX0_HVHigh_20"){
      inF_MiB3 = TFile::Open("plots/efficiency_studies/MiB3_X0_scanX0_HVHigh20GeV.root");
      inF_enSEE = TFile::Open("plots/efficiency_studies/enSEE_X0_scanX0_HVHigh20GeV.root");
      inF_ZStack2 = TFile::Open("plots/efficiency_studies/ZStack2_X0_scanX0_HVHigh20GeV.root");
      inF_ZStack1 = TFile::Open("plots/efficiency_studies/ZStack1_X0_scanX0_HVHigh20GeV.root");
    }
    if(plot_type == "scanX0_HVLow_50"){
      inF_MiB3 = TFile::Open("plots/efficiency_studies/MiB3_X0_scanX0_HVLow50GeV.root");
      inF_enSEE = TFile::Open("plots/efficiency_studies/enSEE_X0_scanX0_HVLow50GeV.root");
      inF_ZStack2 = TFile::Open("plots/efficiency_studies/ZStack2_X0_scanX0_HVLow50GeV.root");
      inF_ZStack1 = TFile::Open("plots/efficiency_studies/ZStack1_X0_scanX0_HVLow50GeV.root");
    }
    if(plot_type == "scanX0_HVLow_20"){
      inF_MiB3 = TFile::Open("plots/efficiency_studies/MiB3_X0_scanX0_HVLow20GeV.root");
      inF_enSEE = TFile::Open("plots/efficiency_studies/enSEE_X0_scanX0_HVLow20GeV.root");
      inF_ZStack2 = TFile::Open("plots/efficiency_studies/ZStack2_X0_scanX0_HVLow20GeV.root");
      inF_ZStack1 = TFile::Open("plots/efficiency_studies/ZStack1_X0_scanX0_HVLow20GeV.root");
    }
    
    
    eff_MiB3 = (TGraphErrors*)inF_MiB3->Get("frac_saturated");
    eff_enSEE = (TGraphErrors*)inF_enSEE->Get("frac_saturated");
    eff_ZStack1 = (TGraphErrors*)inF_ZStack1->Get("frac_saturated");
    if (plot_type=="scanX0_HVLow_20" || plot_type=="scanX0_HVHigh_20" || plot_type=="scanX0_HVHigh_50" || plot_type=="scanX0_HVLow_50") 
      eff_ZStack2 = (TGraphErrors*)inF_ZStack2->Get("frac_saturated");
    
    //settings
    eff_MiB3->SetMarkerColor(kGreen+1);
    eff_MiB3->SetLineColor(kGreen+1);
    if (plot_type=="scanX0_HVLow_20" || plot_type=="scanX0_HVHigh_20" || plot_type=="scanX0_HVHigh_50" || plot_type=="scanX0_HVLow_50") {
      eff_ZStack2->SetMarkerColor(kBlue);
      eff_ZStack2->SetLineColor(kBlue);
    }
    eff_ZStack1->SetMarkerColor(kRed);
    eff_ZStack1->SetLineColor(kRed);
    eff_enSEE->SetMarkerColor(1);
    eff_enSEE->SetLineColor(1);
    //
    eff_MiB3->SetMarkerStyle(20);
    eff_MiB3->SetLineWidth(2);
    eff_MiB3->SetMarkerSize(0.7);
    if (plot_type=="scanX0_HVLow_20" || plot_type=="scanX0_HVHigh_20" || plot_type=="scanX0_HVHigh_50" || plot_type=="scanX0_HVLow_50") {
      eff_ZStack2->SetMarkerStyle(20);
      eff_ZStack2->SetLineWidth(2);
      eff_ZStack2->SetMarkerSize(0.7);
    }
    eff_ZStack1->SetMarkerStyle(20);
    eff_ZStack1->SetLineWidth(2);
    eff_ZStack1->SetMarkerSize(0.7);
    eff_enSEE->SetMarkerStyle(20);
    eff_enSEE->SetLineWidth(2);
    eff_enSEE->SetMarkerSize(0.7);
    
    legC->SetTextFont(42);
    legC->SetTextSize(0.03);
    legC->SetFillColor(kWhite);
    legC->SetLineColor(kWhite);
    legC->SetShadowColor(kWhite);
        
    if(plot_type == "AngScanLow"){
      legC->AddEntry(eff_MiB3, "MiB3 chevron-OFF HV 3000", "p");
      legC->AddEntry(eff_ZStack1, "ZStack1 OFF HV 3000", "p");
      legC->AddEntry(eff_enSEE, "SEE OFF HV 1900", "p");
    }
    if(plot_type == "AngScanHigh"){
      legC->AddEntry(eff_MiB3, "MiB3 chevron-OFF HV 3200", "p");
      legC->AddEntry(eff_ZStack1, "ZStack1 OFF HV 3200", "p");
      legC->AddEntry(eff_enSEE, "SEE OFF HV 2200", "p");
    }

    if(plot_type == "scanX0_HVHigh_50" || plot_type == "scanX0_HVHigh_20"){
      legC->AddEntry(eff_MiB3, "MiB3 chevron-OFF HV 3200", "p");
      legC->AddEntry(eff_ZStack1, "ZStack1 OFF HV 3200", "p");
      legC->AddEntry(eff_ZStack2, "ZStack2 OFF HV 3200", "p");
      legC->AddEntry(eff_enSEE, "SEE OFF  HV 2200", "p");
    }

    if(plot_type == "scanX0_HVLow_50" || plot_type == "scanX0_HVLow_20"){
      legC->AddEntry(eff_MiB3, "MiB3 chevron-OFF HV 3000", "p");
      legC->AddEntry(eff_ZStack1, "ZStack1 OFF HV 3000", "p");
      legC->AddEntry(eff_ZStack2, "ZStack2 OFF HV 3000", "p");
      legC->AddEntry(eff_enSEE, "SEE OFF  HV 1900", "p");
    }

    mg->Add(eff_MiB3);
    mg->Add(eff_ZStack1);
    mg->Add(eff_enSEE);
    if (plot_type=="scanX0_HVLow_20" || plot_type=="scanX0_HVHigh_20" || plot_type=="scanX0_HVHigh_50" || plot_type=="scanX0_HVLow_50") 
      mg->Add(eff_ZStack2);

    TCanvas* c = new TCanvas();
    gPad->SetTicks();
    char plot_name[100];
    std::string command = "if [ ! -e final_plots/ ] ; then mkdir final_plots ; fi";
    system(command.c_str());
    sprintf(plot_name, "final_plots/saturatedFrac_%s.pdf", plot_type.c_str());

    mg->Draw("AP");
    if (plot_type=="scanX0_HVLow_20" || plot_type=="scanX0_HVHigh_20" || plot_type=="scanX0_HVHigh_50" || plot_type=="scanX0_HVLow_50") 
      {
	mg->GetXaxis()->SetRangeUser(-0.1,5.1);
	mg->GetXaxis()->SetTitle("X0");
	mg->GetYaxis()->SetTitle("SaturatedFrac");
	mg->SetTitle(plot_type.c_str());
      }
    else
      {
	mg->GetXaxis()->SetRangeUser(-0.1, 50);
	mg->GetXaxis()->SetTitle("Angle (degrees)");
	mg->GetYaxis()->SetTitle("SaturatedFrac");
	mg->SetTitle(plot_type.c_str());
      }

    mg->SetMaximum(100);
    mg->SetMinimum(0);
    mg->Draw("AP");  
    legC->Draw("same");

    c->Print(plot_name, "pdf");
    sprintf(plot_name, "final_plots/saturatedFrac_%s.png", plot_type.c_str());
    c->Print(plot_name, "png");
  }


  return 0;
}
Example #12
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// DY
//
// channel = SF, MuMu, EE
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void DY(Double_t &yield,
        Double_t &statError,
        Double_t &systError,
        Double_t &scaleFactor,
        Int_t     njet,
        TString   channel,
        TString   directory,
        Bool_t    useDataDriven,
        Int_t     printLevel,
        Bool_t    drawR = false)
{
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //
    // Input files
    //
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    TString path = Form("%s/%djet/%s/", directory.Data(), njet, channel.Data());

    TFile* inputDYSF   = new TFile(path + "DY.root");
    TFile* inputZZSF   = new TFile(path + "ZZ.root");
    TFile* inputWZSF   = new TFile(path + "WZ.root");
    TFile* inputDataSF = new TFile(path + "DataRun2012_Total.root");
    TFile* inputDataOF = new TFile(Form("%s/%djet/OF/DataRun2012_Total.root", directory.Data(), njet));


    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //
    // Input histograms
    //
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    TH1F* hNinDYSF  [numberMetCuts];
    TH1F* hNinWZSF  [numberMetCuts];
    TH1F* hNinZZSF  [numberMetCuts];
    TH1F* hNinDataSF[numberMetCuts];
    TH1F* hNinDataOF[numberMetCuts];

    TH1F* hNoutDYSF  [numberMetCuts];
    TH1F* hNoutWZSF  [numberMetCuts];
    TH1F* hNoutZZSF  [numberMetCuts];
    TH1F* hNoutDataSF[numberMetCuts];
    TH1F* hNoutDataOF[numberMetCuts];

    for (UInt_t nC=0; nC<numberMetCuts; nC++) {
        hNinDYSF  [nC] = (TH1F*)inputDYSF  ->Get(Form("hNinZevents%.2f", MetCuts[nC]));
        hNinWZSF  [nC] = (TH1F*)inputWZSF  ->Get(Form("hNinZevents%.2f", MetCuts[nC]));
        hNinZZSF  [nC] = (TH1F*)inputZZSF  ->Get(Form("hNinZevents%.2f", MetCuts[nC]));
        hNinDataSF[nC] = (TH1F*)inputDataSF->Get(Form("hNinZevents%.2f", MetCuts[nC]));
        hNinDataOF[nC] = (TH1F*)inputDataOF->Get(Form("hNinZevents%.2f", MetCuts[nC]));

        hNoutDYSF  [nC] = (TH1F*)inputDYSF  ->Get(Form("hNoutZevents%.2f", MetCuts[nC]));
        hNoutWZSF  [nC] = (TH1F*)inputWZSF  ->Get(Form("hNoutZevents%.2f", MetCuts[nC]));
        hNoutZZSF  [nC] = (TH1F*)inputZZSF  ->Get(Form("hNoutZevents%.2f", MetCuts[nC]));
        hNoutDataSF[nC] = (TH1F*)inputDataSF->Get(Form("hNoutZevents%.2f", MetCuts[nC]));
        hNoutDataOF[nC] = (TH1F*)inputDataOF->Get(Form("hNoutZevents%.2f", MetCuts[nC]));
    }


    // Histogram at analysis level
    //----------------------------------------------------------------------------
    TH1F* hExpectedDYSF = (TH1F*)inputDYSF->Get("hWTopTagging");


    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //
    // k estimation
    //
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    TFile* inputDYmumu = new TFile(Form("%s/%djet/MuMu/DY.root", directory.Data(), njet));
    TFile* inputDYee   = new TFile(Form("%s/%djet/EE/DY.root",   directory.Data(), njet));

    TH1F* hNinDYmumu = (TH1F*)inputDYmumu->Get("hNinLooseZevents20.00");
    TH1F* hNinDYee   = (TH1F*)inputDYee  ->Get("hNinLooseZevents20.00");

    Double_t NinDYmumu = hNinDYmumu->GetBinContent(2);
    Double_t NinDYee   = hNinDYee  ->GetBinContent(2);

    Double_t k    = 0.5 * (sqrt(NinDYmumu / NinDYee) + sqrt(NinDYee / NinDYmumu));
    Double_t errk = errkSF(NinDYmumu, NinDYee);

    if (channel == "MuMu") {
        k    = 0.5 * sqrt(NinDYmumu / NinDYee);
        errk = errkFunction(NinDYmumu, NinDYee);
    }
    else if (channel == "EE") {
        k    = 0.5 * sqrt(NinDYee / NinDYmumu);
        errk = errkFunction(NinDYee, NinDYmumu);
    }


    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //
    // Counters
    //
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Double_t NinDYSF  [numberMetCuts];
    Double_t NinWZSF  [numberMetCuts];
    Double_t NinZZSF  [numberMetCuts];
    Double_t NinDataSF[numberMetCuts];
    Double_t NinDataOF[numberMetCuts];

    Double_t NoutDYSF  [numberMetCuts];
    Double_t NoutWZSF  [numberMetCuts];  // Not used for now
    Double_t NoutZZSF  [numberMetCuts];  // Not used for now
    Double_t NoutDataSF[numberMetCuts];
    Double_t NoutDataOF[numberMetCuts];

    for (UInt_t nC=0; nC<numberMetCuts-1; nC++) {
        NinDYSF   [nC] = hNinDYSF   [nC]->GetBinContent(2);
        NinWZSF   [nC] = hNinWZSF   [nC]->GetBinContent(2);
        NinZZSF   [nC] = hNinZZSF   [nC]->GetBinContent(2);
        NinDataSF [nC] = hNinDataSF [nC]->GetBinContent(2);
        NinDataOF [nC] = hNinDataOF [nC]->GetBinContent(2);

        NoutDYSF  [nC] = hNoutDYSF  [nC]->GetBinContent(2);
        NoutWZSF  [nC] = hNoutWZSF  [nC]->GetBinContent(2);
        NoutZZSF  [nC] = hNoutZZSF  [nC]->GetBinContent(2);
        NoutDataSF[nC] = hNoutDataSF[nC]->GetBinContent(2);
        NoutDataOF[nC] = hNoutDataOF[nC]->GetBinContent(2);
    }


    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    //
    // R estimation
    //
    //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    Double_t R       [numberMetCuts];
    Double_t RData   [numberMetCuts];
    Double_t errR    [numberMetCuts];
    Double_t errRData[numberMetCuts];


    // Loop over the met cuts
    //----------------------------------------------------------------------------
    for (UInt_t nC=0; nC<numberMetCuts-1; nC++) {

        R   [nC] = NoutDYSF[nC] / NinDYSF[nC];
        errR[nC] = errRFunction(NoutDYSF[nC], NinDYSF[nC]);

        RData   [nC] = RDataFunction   (NoutDataSF[nC], NoutDataOF[nC], NinDataSF[nC], NinDataOF[nC], k);
        errRData[nC] = errRDataFunction(NoutDataSF[nC], NoutDataOF[nC], NinDataSF[nC], NinDataOF[nC], k, errk);


        if (printLevel > 2) {
            printf("\n %.0f < mpmet < %.0f GeV\n", MetCuts[nC], MetCuts[nC+1]);
            printf(" -------------------------------------------------\n");
            printf("         N^{MC}_{out,SF}   = %6.1f\n", NoutDYSF[nC]);
            printf("         N^{MC}_{in, SF}   = %6.1f\n", NinDYSF[nC]);
            printf("         N^{data}_{out,SF} = %4.0f\n", NoutDataSF[nC]);
            printf("         N^{data}_{out,OF} = %4.0f\n", NoutDataOF[nC]);
            printf("         N^{data}_{in, SF} = %4.0f\n", NinDataSF[nC]);
            printf("         N^{data}_{in, OF} = %4.0f\n", NinDataOF[nC]);
            printf("         k                 = % 5.3f +- %5.3f\n", k,         errk);
            printf("         R^{MC}            = % 5.3f +- %5.3f\n", R[nC],     errR[nC]);
            printf("         R^{data}          = % 5.3f +- %5.3f\n", RData[nC], errRData[nC]);
        }
    }


    // Estimate the R systematic as the difference between R[2] and R[3]
    //----------------------------------------------------------------------------
    Int_t iMaxR = 0;
    Int_t iMinR = 0;

    for (UInt_t nC=0; nC<numberMetCuts-1; nC++) {

        if (R[nC] > 0 && R[nC] > R[iMaxR]) iMaxR = nC;
        if (R[nC] > 0 && R[nC] < R[iMinR]) iMinR = nC;
    }

    Int_t theR = 2;
    Int_t sysR = 3;

    Double_t RelDiffR = (R[theR] > 0) ? fabs(R[theR] - R[sysR]) / R[theR] : -999;


    if (printLevel > 0) {
        printf("\n [%s] R systematic uncertainty\n", channel.Data());
        printf(" -------------------------------------------------\n");
        printf("         min R              = %5.3f\n",     R[iMinR]);
        printf("         max R              = %5.3f\n",     R[iMaxR]);
        printf("         R[%d]               = %5.3f\n",    theR, R[theR]);
        printf("         R[%d]               = %5.3f\n",    sysR, R[sysR]);
        printf("         |R[%d]-R[%d]| / R[%d] = %.1f%s\n", theR, sysR, theR, 1e2*RelDiffR, "%");
        printf("\n");
    }


    // Estimate Nout
    //----------------------------------------------------------------------------
    Double_t NinCountedSFWZ   = NinWZSF  [sysR];
    Double_t NinCountedSFZZ   = NinZZSF  [sysR];
    Double_t NinCountedSFData = NinDataSF[sysR];
    Double_t NinCountedOFData = NinDataOF[sysR];

    Double_t NinEstSFFinal    = NinCountedSFData - k*NinCountedOFData;
    Double_t errNinEstSFFinal = errNinEstFunction(NinCountedSFData, NinCountedOFData, k, errk);

    Double_t NestSFFinal    = R[theR] * NinEstSFFinal;
    Double_t errNestSFFinal = errNestFunction(NestSFFinal, R[theR], errR[theR], NinEstSFFinal, errNinEstSFFinal);

    Double_t NinEstSFNoDibosonFinal    = NinEstSFFinal - NinCountedSFWZ - NinCountedSFZZ;
    Double_t errNinEstSFNoDibosonFinal = errNinEstNoDibosonFunction(NinCountedSFData, k, errk, NinCountedOFData, NinCountedSFWZ, NinCountedSFZZ);

    Double_t NestSFNoDibosonFinal    = R[theR] * NinEstSFNoDibosonFinal;
    Double_t errNestSFNoDibosonFinal = errNestFunction(NestSFNoDibosonFinal, R[theR], errR[theR], NinEstSFNoDibosonFinal, errNinEstSFNoDibosonFinal);
    Double_t totalError              = sqrt(errNestSFNoDibosonFinal*errNestSFNoDibosonFinal + (RelDiffR*NestSFNoDibosonFinal)*(RelDiffR*NestSFNoDibosonFinal));


    Double_t SFsf = NestSFNoDibosonFinal / hExpectedDYSF->GetBinContent(2);


    if (printLevel > 1) {
        printf("\n Analysis results\n");
        printf(" -------------------------------------------------\n");
        printf("         N^{data}_{in,SF} = %4.0f\n", NinCountedSFData);
        printf("         N^{data}_{in,OF} = %4.0f\n", NinCountedOFData);
        printf("         k                = %5.3f +- %5.3f\n", k, errk);
        printf("         R[%d]             = %5.3f +- %5.3f\n", theR, R[theR], errR[theR]);
        printf("         N^{WZ}_{in,SF}   = %7.2f +- %6.2f (stat.) +- %6.2f (syst.)\n",
               NinCountedSFWZ, sqrt(NinCountedSFWZ), 0.1*NinCountedSFWZ);
        printf("         N^{ZZ}_{in,SF}   = %7.2f +- %6.2f (stat.) +- %6.2f (syst.)\n",
               NinCountedSFZZ, sqrt(NinCountedSFZZ), 0.1*NinCountedSFZZ);
        printf("         N^{est}_{in, SF} = %7.2f +- %6.2f\n", NinEstSFFinal, errNinEstSFFinal);
        printf("         N^{est}_{out,SF} = %7.2f +- %6.2f (stat.) +- %6.2f (syst.)\n",
               NestSFFinal, errNestSFFinal, RelDiffR*NestSFFinal);
        printf(" -------------------------------------------------\n");
        printf(" [no VZ] N^{est}_{out,SF} = %7.2f +- %6.2f (stat.) +- %6.2f (syst.) = %7.2f +- %6.2f (stat. + syst.)\n",
               NestSFNoDibosonFinal, errNestSFNoDibosonFinal, RelDiffR*NestSFNoDibosonFinal,
               NestSFNoDibosonFinal, totalError);
        printf("         N^{MC}_{out,SF}  = %7.2f +- %6.2f\n",
               hExpectedDYSF->GetBinContent(2), hExpectedDYSF->GetBinError(2));
        printf("     *** scale factor     = %.3f\n\n", SFsf);
    }


    // Save the result
    //----------------------------------------------------------------------------
    yield       = (useDataDriven) ? NestSFNoDibosonFinal : hExpectedDYSF->GetBinContent(2);
    statError   = errNestSFNoDibosonFinal;
    systError   = RelDiffR*NestSFNoDibosonFinal;
    scaleFactor = yield / hExpectedDYSF->GetBinContent(2);


    // For the note
    //----------------------------------------------------------------------------
    if (printLevel > 0) {
        printf("\n [%s] DY values for the note\n", channel.Data());
        printf(" -------------------------------------------------\n");
        printf(" final state   &             R_{MC}  &  N^{control,data}  &     N_{DY}^{data}  &       N_{DY}^{MC}  &  data/MC\n");
        printf(" same flavour  &  %5.3f $\\pm$ %5.3f  &              %4.0f  &  %5.1f $\\pm$ %4.1f  &  %5.1f $\\pm$ %4.1f  &     %4.1f\n\n",
               R[theR],
               errR[theR],
               NinCountedSFData,
               yield,
               statError,
               hExpectedDYSF->GetBinContent(2),
               hExpectedDYSF->GetBinError(2),
               scaleFactor);
        printf("\n [%s] DY relative systematic uncertainties\n", channel.Data());
        printf(" -------------------------------------------------\n");
        printf(" DY normalisation = %.0f (stat.) $\\bigoplus$ %.0f (syst.)\n\n",
               1e2*statError/yield, 1e2*systError/yield);
    }


    // Check
    //----------------------------------------------------------------------------
    Double_t check = hExpectedDYSF->GetBinContent(2) - NoutDYSF[sysR];
    if (check != 0) printf(" WARNING: DY yields do not much by %f\n\n", check);


    // Draw histograms
    //----------------------------------------------------------------------------
    if (drawR) {

        Double_t absoluteMin = 999;

        TGraphErrors* gR     = new TGraphErrors(numberMetCuts-1);
        TGraphErrors* gRdata = new TGraphErrors(numberMetCuts-1);

        for (UInt_t i=0; i<numberMetCuts-1; i++) {

            gR->SetPoint     (i, 0.5 * (MetDraw[i+1] + MetDraw[i]),    R[i]);
            gR->SetPointError(i, 0.5 * (MetDraw[i+1] - MetDraw[i]), errR[i]);

            gRdata->SetPoint     (i, 0.5 * (MetDraw[i+1] + MetDraw[i]),    RData[i]);
            gRdata->SetPointError(i, 0.5 * (MetDraw[i+1] - MetDraw[i]), errRData[i]);

            if (absoluteMin > (R[i]     - errR[i]))     absoluteMin = R[i]     - errR[i];
            if (absoluteMin > (RData[i] - errRData[i])) absoluteMin = RData[i] - errRData[i];
        }

        if (absoluteMin > 0) absoluteMin = 0;


        // Cosmetics
        //--------------------------------------------------------------------------
        gR->SetMarkerSize (0.9);
        gR->SetMarkerStyle(kFullCircle);

        gRdata->SetLineColor  (kRed+1);
        gRdata->SetMarkerColor(kRed+1);
        gRdata->SetMarkerSize (0.9);
        gRdata->SetMarkerStyle(kFullCircle);


        // Draw
        //--------------------------------------------------------------------------
        canvas = new TCanvas();

        TMultiGraph *mgR = new TMultiGraph();
        mgR->Add(gRdata);
        mgR->Add(gR);

        mgR->Draw("ap");

        mgR->GetYaxis()->SetTitle("R^{out/in}");
        mgR->GetXaxis()->SetTitle("mpmet (GeV)");

        mgR->SetMinimum(absoluteMin - 0.1);
        mgR->SetMaximum(1.0);


        // Legend
        //--------------------------------------------------------------------------
        TLegend* lmgR = new TLegend(0.72, 0.68, 0.92, 0.88);

        lmgR->AddEntry(gR,    " DY MC", "lp");
        lmgR->AddEntry(gRdata," data",  "lp");

        lmgR->SetFillColor(0);
        lmgR->SetTextAlign(12);
        lmgR->SetTextFont (42);
        lmgR->SetTextSize (0.04);

        if      (channel == "SF")   lmgR->SetHeader("ee + #mu#mu");
        else if (channel == "EE")   lmgR->SetHeader("ee");
        else if (channel == "MuMu") lmgR->SetHeader("#mu#mu");

        lmgR->Draw("same");


        // Line at zero
        //--------------------------------------------------------------------------
        TLine* zeroLine = new TLine(canvas->GetUxmin(), 0.0, canvas->GetUxmax(), 0.0);
        zeroLine->SetLineStyle(3);
        zeroLine->SetLineWidth(2);
        zeroLine->Draw("same");
        mgR->Draw("p,same");


        // Save
        //--------------------------------------------------------------------------
        canvas->SaveAs("R_" + channel + ".png");
    }
}
Example #13
0
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// DY
//
// channel = SF, MuMu, EE
//
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void doDY(char jetbin,
	  TString channel,
	  TString ID = "MediumIDTighterIP",
	  TString bunch = "50ns",
	  Bool_t  useDataDriven = true,
	  Int_t   printLevel = 100,
	  Bool_t  drawR = true)
{
  cout<<"nJet = "<<jetbin<<endl;
  cout<<"Channel = "<<channel<<endl;

  Double_t yield;                                                                                                                      
  Double_t statError;
  Double_t systError;                                                                                                                    
  Double_t scaleFactor;
  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  //
  // Input files
  //
  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  TString path   = "../rootFiles/" + channel + "/" + ID + "/" + bunch + "/"; 
  TString pathOF = "../rootFiles/OF/" + ID + "/" + bunch + "/"; 

  TFile* inputDYSF   = new TFile(path + "DY.root");
  TFile* inputVVSF   = new TFile(path + "VV.root");
  TFile* inputDataSF = new TFile(path + "Data2015.root");
  TFile* inputDataOF = new TFile(pathOF + "Data2015.root");

  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  //
  // Input histograms
  //
  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  TH1F* hNinDYSF  [numberMetCuts];
  TH1F* hNinVVSF  [numberMetCuts];
  TH1F* hNinDataSF[numberMetCuts];
  TH1F* hNinDataOF[numberMetCuts];

  TH1F* hNoutDYSF  [numberMetCuts];
  TH1F* hNoutVVSF  [numberMetCuts];
  TH1F* hNoutDataSF[numberMetCuts];
  TH1F* hNoutDataOF[numberMetCuts];

  for (UInt_t nC=0; nC<numberMetCuts; nC++) {
    hNinDYSF  [nC] = (TH1F*)inputDYSF  ->Get(Form("hNinZevents%.i%.c", MetCuts[nC],jetbin));
    cout<<Form("hNinZevents%.i%.c", MetCuts[nC],jetbin)<<endl;
    hNinVVSF  [nC] = (TH1F*)inputVVSF  ->Get(Form("hNinZevents%.i%.c", MetCuts[nC],jetbin));
    hNinDataSF[nC] = (TH1F*)inputDataSF->Get(Form("hNinZevents%.i%.c", MetCuts[nC],jetbin));
    hNinDataOF[nC] = (TH1F*)inputDataOF->Get(Form("hNinZevents%.i%.c", MetCuts[nC],jetbin));

    hNoutDYSF  [nC] = (TH1F*)inputDYSF  ->Get(Form("hNoutZevents%.i%.c", MetCuts[nC],jetbin));     
    hNoutVVSF  [nC] = (TH1F*)inputVVSF  ->Get(Form("hNoutZevents%.i%.c", MetCuts[nC],jetbin));     
    hNoutDataSF[nC] = (TH1F*)inputDataSF->Get(Form("hNoutZevents%.i%.c", MetCuts[nC],jetbin));
    hNoutDataOF[nC] = (TH1F*)inputDataOF->Get(Form("hNoutZevents%.i%.c", MetCuts[nC],jetbin));
  }


  // Histogram at analysis level
  //----------------------------------------
  TH1F* hExpectedDYSF = (TH1F*)inputDYSF->Get(Form("hPtLepton1WWLevel%.c", jetbin));//("hWTopTagging");

  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  //
  // k estimation
  //
  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  TFile* inputDYmumu = new TFile("../rootFiles/MuMu/" + ID + "/" + bunch + "/DY.root");
  TFile* inputDYee   = new TFile("../rootFiles/EE/"   + ID + "/" + bunch + "/DY.root");

  TH1F* hNinDYmumu = (TH1F*)inputDYmumu->Get(Form("hNinLooseZevents20%.c", jetbin));
  TH1F* hNinDYee   = (TH1F*)inputDYee  ->Get(Form("hNinLooseZevents20%.c", jetbin));

  Double_t NinDYmumu = hNinDYmumu -> GetBinContent(2);
  Double_t NinDYee   = hNinDYee   -> GetBinContent(2);

  Double_t k    = 0.5 * (sqrt(NinDYmumu / NinDYee) + sqrt(NinDYee / NinDYmumu));
  Double_t errk = errkSF(NinDYmumu, NinDYee);

  if (channel == "MuMu") {
    k    = 0.5 * sqrt(NinDYmumu / NinDYee);
    errk = errkFunction(NinDYmumu, NinDYee);
  }
  else if (channel == "EE") {
    k    = 0.5 * sqrt(NinDYee / NinDYmumu);
    errk = errkFunction(NinDYee, NinDYmumu);
  }


  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  //
  // Counters
  //
  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Double_t NinDYSF  [numberMetCuts];
  Double_t NinVVSF  [numberMetCuts];
  Double_t NinDataSF[numberMetCuts];
  Double_t NinDataOF[numberMetCuts];

  Double_t NoutDYSF  [numberMetCuts];
  Double_t NoutVVSF  [numberMetCuts];  // Not used for now
  Double_t NoutDataSF[numberMetCuts];
  Double_t NoutDataOF[numberMetCuts];

  for (UInt_t nC=0; nC<numberMetCuts-1; nC++) {
    NinDYSF   [nC] = hNinDYSF   [nC]->GetBinContent(2);
    NinVVSF   [nC] = hNinVVSF   [nC]->GetBinContent(2);
    NinDataSF [nC] = hNinDataSF [nC]->GetBinContent(2);    
    NinDataOF [nC] = hNinDataOF [nC]->GetBinContent(2);

    NoutDYSF  [nC] = hNoutDYSF  [nC]->GetBinContent(2);
    NoutVVSF  [nC] = hNoutVVSF  [nC]->GetBinContent(2);
    NoutDataSF[nC] = hNoutDataSF[nC]->GetBinContent(2);    
    NoutDataOF[nC] = hNoutDataOF[nC]->GetBinContent(2);
  }

  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  //
  // R estimation
  //
  //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  Double_t R       [numberMetCuts];
  Double_t RData   [numberMetCuts];
  Double_t errR    [numberMetCuts];
  Double_t errRData[numberMetCuts];


  // Loop over the met cuts
  //----------------------------------------------------------------------------
  for (UInt_t nC=0; nC<numberMetCuts-1; nC++) {

    R   [nC] = NoutDYSF[nC] / NinDYSF[nC]; 
    errR[nC] = errRFunction(NoutDYSF[nC], NinDYSF[nC]);

    RData   [nC] = RDataFunction   (NoutDataSF[nC], NoutDataOF[nC], NinDataSF[nC], NinDataOF[nC], k);
    errRData[nC] = errRDataFunction(NoutDataSF[nC], NoutDataOF[nC], NinDataSF[nC], NinDataOF[nC], k, errk);

    if (printLevel > 2) {
      printf("\n %.0f < mpmet < %.0f GeV\n", MetCuts[nC], MetCuts[nC+1]);
      printf(" -------------------------------------------------\n");
      printf("         N^{MC}_{out,SF}   = %6.1f\n", NoutDYSF[nC]);
      printf("         N^{MC}_{in, SF}   = %6.1f\n", NinDYSF[nC]);
      printf("         N^{data}_{out,SF} = %4.0f\n", NoutDataSF[nC]);
      printf("         N^{data}_{out,OF} = %4.0f\n", NoutDataOF[nC]);
      printf("         N^{data}_{in, SF} = %4.0f\n", NinDataSF[nC]);
      printf("         N^{data}_{in, OF} = %4.0f\n", NinDataOF[nC]);
      printf("         k                 = % 5.3f +- %5.3f\n", k,         errk);
      printf("         R^{MC}            = % 5.3f +- %5.3f\n", R[nC],     errR[nC]);
      printf("         R^{data}          = % 5.3f +- %5.3f\n", RData[nC], errRData[nC]);
    }
  }

  // Estimate the R systematic as the difference between R[2] and R[3]
  //----------------------------------------------------------------------------
  Int_t iMaxR = 0; 
  Int_t iMinR = 0; 

  for (UInt_t nC=0; nC<numberMetCuts-1; nC++) {

    if (R[nC] > 0 && R[nC] > R[iMaxR]) iMaxR = nC;
    if (R[nC] > 0 && R[nC] < R[iMinR]) iMinR = nC;
  }

  Int_t theR = 2;
  Int_t sysR = 3;

  Double_t RelDiffR = (R[theR] > 0) ? fabs(R[theR] - R[sysR]) / R[theR] : -999;


  if (printLevel > 0) {
    printf("\n [%s] R systematic uncertainty\n", channel.Data());
    printf(" -------------------------------------------------\n");
    printf("         min R               = %5.3f\n",     R[iMinR]);
    printf("         max R               = %5.3f\n",     R[iMaxR]);
    printf("         R[%d]               = %5.3f\n",    theR, R[theR]);
    printf("         R[%d]               = %5.3f\n",    sysR, R[sysR]);
    printf("         |R[%d]-R[%d]| / R[%d] = %.1f%s\n", theR, sysR, theR, 1e2*RelDiffR, "%");
    printf("\n");
  }


  // Estimate Nout
  //----------------------------------------------------------------------------
  Double_t NinCountedSFVV   = NinVVSF  [sysR];
  Double_t NinCountedSFData = NinDataSF[sysR];
  Double_t NinCountedOFData = NinDataOF[sysR];

  Double_t NinEstSFFinal    = NinCountedSFData - k*NinCountedOFData;
  Double_t errNinEstSFFinal = errNinEstFunction(NinCountedSFData, NinCountedOFData, k, errk);

  Double_t NestSFFinal    = R[theR] * NinEstSFFinal;
  Double_t errNestSFFinal = errNestFunction(NestSFFinal, R[theR], errR[theR], NinEstSFFinal, errNinEstSFFinal);

  Double_t NinEstSFNoDibosonFinal    = NinEstSFFinal - NinCountedSFVV;
  Double_t errNinEstSFNoDibosonFinal = errNinEstNoDibosonFunction(NinCountedSFData, k, errk, NinCountedOFData, NinCountedSFVV);

  Double_t NestSFNoDibosonFinal    = R[theR] * NinEstSFNoDibosonFinal;
  Double_t errNestSFNoDibosonFinal = errNestFunction(NestSFNoDibosonFinal, R[theR], errR[theR], NinEstSFNoDibosonFinal, errNinEstSFNoDibosonFinal);
  Double_t totalError              = sqrt(errNestSFNoDibosonFinal*errNestSFNoDibosonFinal + (RelDiffR*NestSFNoDibosonFinal)*(RelDiffR*NestSFNoDibosonFinal));


  Double_t SFsf = NestSFNoDibosonFinal / hExpectedDYSF->Integral();


  if (printLevel > 1) {
    printf("\n Analysis results\n");
    printf(" -------------------------------------------------\n");
    printf("         N^{data}_{in,SF} = %4.0f\n", NinCountedSFData);
    printf("         N^{data}_{in,OF} = %4.0f\n", NinCountedOFData);
    printf("         k                = %5.3f +- %5.3f\n", k, errk);
    printf("         R[%d]             = %5.3f +- %5.3f\n", theR, R[theR], errR[theR]);
    printf("         N^{VV}_{in,SF}   = %7.2f +- %6.2f (stat.) +- %6.2f (syst.)\n",
	   NinCountedSFVV, sqrt(NinCountedSFVV), 0.1*NinCountedSFVV);
    printf("         N^{est}_{in, SF} = %7.2f +- %6.2f\n", NinEstSFFinal, errNinEstSFFinal);
    printf("         N^{est}_{out,SF} = %7.2f +- %6.2f (stat.) +- %6.2f (syst.)\n",
	   NestSFFinal, errNestSFFinal, RelDiffR*NestSFFinal);
    printf(" -------------------------------------------------\n");
    printf(" [no VZ] N^{est}_{out,SF} = %7.2f +- %6.2f (stat.) +- %6.2f (syst.) = %7.2f +- %6.2f (stat. + syst.)\n",
	   NestSFNoDibosonFinal, errNestSFNoDibosonFinal, RelDiffR*NestSFNoDibosonFinal,
	   NestSFNoDibosonFinal, totalError);
    printf("         N^{MC}_{out,SF}  = %7.2f +- %6.2f\n",
	   hExpectedDYSF->Integral(), sqrt(hExpectedDYSF->Integral()));
    printf("     *** scale factor     = %.3f\n\n", SFsf);
  }


  // Save the result
  //----------------------------------------------------------------------------
  yield       = (useDataDriven) ? NestSFNoDibosonFinal : hExpectedDYSF->Integral();
  statError   = errNestSFNoDibosonFinal;
  systError   = RelDiffR*NestSFNoDibosonFinal;
  scaleFactor = yield / hExpectedDYSF->Integral();


  // For the note
  //----------------------------------------------------------------------------
  if (printLevel > 0) {
    printf("\n [%s] DY values for the note\n", channel.Data());
    printf(" -------------------------------------------------\n");
    printf(" final state   &             R_{MC}  &  N^{control,data}  &     N_{DY}^{data}  &       N_{DY}^{MC}  &  data/MC\n");
    printf(" same flavour  &  %5.3f $\\pm$ %5.3f  &              %4.0f  &  %5.1f $\\pm$ %4.1f  &  %5.1f $\\pm$ %4.1f  &     %4.1f\n\n",
	   R[theR],
	   errR[theR],
	   NinCountedSFData,
	   yield,
	   statError,
	   hExpectedDYSF->Integral(),
	   sqrt(hExpectedDYSF->Integral()),
	   scaleFactor);
    printf("\n [%s] DY relative systematic uncertainties\n", channel.Data());
    printf(" -------------------------------------------------\n");
    printf(" DY normalisation = %.0f (stat.) $\\bigoplus$ %.0f (syst.)\n\n",
	   1e2*statError/yield, 1e2*systError/yield);
  }


  // Check
  //----------------------------------------------------------------------------
  Double_t check = hExpectedDYSF->Integral() - NoutDYSF[sysR];
  if (check != 0) printf(" WARNING: DY yields do not much by %f\n\n", check);


  // Draw histograms
  //----------------------------------------------------------------------------
  if (drawR) {

    Double_t absoluteMin = 999;

    TGraphErrors* gR     = new TGraphErrors(numberMetCuts-1);
    TGraphErrors* gRdata = new TGraphErrors(numberMetCuts-1);

    for (UInt_t i=0; i<numberMetCuts-1; i++) {

      gR->SetPoint     (i, 0.5 * (MetDraw[i+1] + MetDraw[i]),    R[i]);
      gR->SetPointError(i, 0.5 * (MetDraw[i+1] - MetDraw[i]), errR[i]);

      gRdata->SetPoint     (i, 0.5 * (MetDraw[i+1] + MetDraw[i]),    RData[i]);
      gRdata->SetPointError(i, 0.5 * (MetDraw[i+1] - MetDraw[i]), errRData[i]);

      if (absoluteMin > (R[i]     - errR[i]))     absoluteMin = R[i]     - errR[i];
      if (absoluteMin > (RData[i] - errRData[i])) absoluteMin = RData[i] - errRData[i];
    }
    
    if (absoluteMin > 0) absoluteMin = 0;

    // Cosmetics
    //--------------------------------------------------------------------------
    gR->SetMarkerSize (0.9);
    gR->SetMarkerStyle(kFullCircle);

    gRdata->SetLineColor  (kRed+1);
    gRdata->SetMarkerColor(kRed+1);
    gRdata->SetMarkerSize (0.9);
    gRdata->SetMarkerStyle(kFullCircle);


    // Draw
    //--------------------------------------------------------------------------
    canvas = new TCanvas();

    TMultiGraph *mgR = new TMultiGraph();
    mgR->Add(gRdata);
    mgR->Add(gR);

    mgR->Draw("ap");

    mgR->GetYaxis()->SetTitle("R^{out/in}");
    mgR->GetXaxis()->SetTitle("mpmet (GeV)");

    mgR->SetMinimum(absoluteMin - 0.1);
    mgR->SetMaximum(1.0);


    // Legend
    //--------------------------------------------------------------------------
    TLegend* lmgR = new TLegend(0.62, 0.68, 0.86, 0.88);

    lmgR->AddEntry(gR,    " DY MC", "lp");
    lmgR->AddEntry(gRdata," data",  "lp");

    lmgR->SetFillColor(0);
    lmgR->SetLineColor(kWhite);
    lmgR->SetTextAlign(12);
    lmgR->SetTextFont (42);
    lmgR->SetTextSize (0.04);

    if      (channel == "SF")   lmgR->SetHeader("ee + #mu#mu");
    else if (channel == "EE")   lmgR->SetHeader("ee");
    else if (channel == "MuMu") lmgR->SetHeader("#mu#mu");

    lmgR->Draw();

    // Line at zero
    //--------------------------------------------------------------------------
    TLine* zeroLine = new TLine(canvas->GetUxmin(), 0.0, canvas->GetUxmax(), 0.0);
    zeroLine->SetLineStyle(3);
    zeroLine->SetLineWidth(2);
    zeroLine->Draw("same");
    mgR->Draw("p,same");
  

    // Save
    //--------------------------------------------------------------------------
    lmgR->Draw("same");

    if (jetbin == '3'){
      DrawTLatex(0.725, 0.65, 0.04,  "Inclusive");
      canvas->SaveAs("R_" + channel + "_Inclusive.png");
      canvas->SaveAs("R_" + channel + "_Inclusive.pdf");
    }
    else{                                                   //Inclusive 
      if      (jetbin == '0') DrawTLatex(0.725, 0.65, 0.04,  "0 Jet    ");
      else if (jetbin == '1') DrawTLatex(0.725, 0.65, 0.04,  "1 Jet    ");
      else if (jetbin == '2') DrawTLatex(0.725, 0.65, 0.04,  "2+ Jets  ");
      canvas->SaveAs("R_" + channel + "_" + jetbin + "jet.png");
      canvas->SaveAs("R_" + channel + "_" + jetbin + "jet.pdf");
    }
  }
}
void EnergyDependentCorrections() {

  gStyle->SetOptStat(0);
  gStyle->SetTitleSize(0.08,"t");
  gStyle->SetPadLeftMargin(0.15);
  //gStyle->SetPadRightMargin(0.15);
  gStyle->SetPadBottomMargin(0.15);
  gStyle->SetTitleYSize(0.05);
  gStyle->SetTitleYOffset(1.4);
  gStyle->SetTitleXSize(0.05);
  gStyle->SetTitleXOffset(1.2);
  gStyle->SetTitleSize(0.04,"Z");
  gStyle->SetTitleOffset(1.6,"Z");
  gStyle->SetLabelSize(0.04,"xyz");
  gStyle->SetLegendBorderSize(0);
  gStyle->SetFillStyle(0);

  // read in the corrections and plot their deltaA/A for each bin
  // This can be done for both theory and MC

  //Int_t octmin = year==2011?0:60;
  //Int_t octmax = year==2011?59:121;

  std::vector <Double_t> energy;
  std::vector <Double_t> UnCorr2011;
  std::vector <Double_t> TheoryCorr2011;
  std::vector <Double_t> AllCorr2011;

  std::vector <Double_t> UnCorr2012;
  std::vector <Double_t> TheoryCorr2012;
  std::vector <Double_t> AllCorr2012;

  Double_t en, val, err;
  
  std::ifstream infile(TString::Format("%s/Asymmetries/UnCorr_OctetAsymmetries_AnaChC_Octets_%i-%i_BinByBin.txt",getenv("ANALYSIS_RESULTS"),0,59));
  
  while (infile >> en >> val >> err ) {
    energy.push_back(en);
    UnCorr2011.push_back(val);
  }

  infile.close();

  infile.open(TString::Format("%s/Asymmetries/DeltaTheoryOnly_OctetAsymmetries_AnaChC_Octets_%i-%i_BinByBin.txt",getenv("ANALYSIS_RESULTS"),0,59));
  
  while (infile >> en >> val >> err) {
    TheoryCorr2011.push_back(val);
  }

  infile.close();

  infile.open(TString::Format("%s/Asymmetries/AllCorr_OctetAsymmetries_AnaChC_Octets_%i-%i_BinByBin.txt",getenv("ANALYSIS_RESULTS"),0,59));
  
  while (infile >> en >> val >> err) {
    AllCorr2011.push_back(val);
  }

  infile.close();
    
  infile.open(TString::Format("%s/Asymmetries/UnCorr_OctetAsymmetries_AnaChC_Octets_%i-%i_BinByBin.txt",getenv("ANALYSIS_RESULTS"),60,121));
  
  while (infile >> en >> val >> err ) {
    energy.push_back(en);
    UnCorr2012.push_back(val);
  }

  infile.close();

  infile.open(TString::Format("%s/Asymmetries/DeltaTheoryOnly_OctetAsymmetries_AnaChC_Octets_%i-%i_BinByBin.txt",getenv("ANALYSIS_RESULTS"),60,121));
  
  while (infile >> en >> val >> err) {
    TheoryCorr2012.push_back(val);
  }

  infile.close();

  infile.open(TString::Format("%s/Asymmetries/AllCorr_OctetAsymmetries_AnaChC_Octets_%i-%i_BinByBin.txt",getenv("ANALYSIS_RESULTS"),60,121));
  
  while (infile >> en >> val >> err) {
    AllCorr2012.push_back(val);
  }

  infile.close();


  
  
  
  

  std::vector <Double_t> en_Th;
  std::vector <Double_t> corr_Th;
  std::vector <Double_t> en_MC2011;
  std::vector <Double_t> corr_MC2011;
  std::vector <Double_t> en_MC2012;
  std::vector <Double_t> corr_MC2012;
  
  
  for (int i=2;i<80;++i) {

    if (UnCorr2011[i]!=0.) en_Th.push_back(energy[i]), corr_Th.push_back(100.*(TheoryCorr2011[i]/UnCorr2011[i]-1.));
    if (TheoryCorr2011[i]!=0.) en_MC2011.push_back(energy[i]), corr_MC2011.push_back(100.*(AllCorr2011[i]/TheoryCorr2011[i]-1.));
    if (TheoryCorr2012[i]!=0.) en_MC2012.push_back(energy[i]), corr_MC2012.push_back(100.*(AllCorr2012[i]/TheoryCorr2012[i]-1.));
  }

  

  TCanvas *c2 = new TCanvas("c2","c2",1200,800);
  c2->Divide(2,1);

  c2->cd(1);

  TGraph *gTheory = new TGraph(en_Th.size(),&en_Th[0],&corr_Th[0]);
  gTheory->SetTitle("Theory Corrections vs. Energy");
  gTheory->SetMarkerStyle(kFullCircle);
  gTheory->SetMinimum(-5.);
  gTheory->SetMaximum(0.);
  gTheory->SetLineWidth(3);
  gTheory->SetLineColor(kBlack);
  gTheory->GetYaxis()->SetTitle("#DeltaA/A (%)");
  gTheory->GetYaxis()->CenterTitle();
  gTheory->GetXaxis()->SetTitle("Energy (keV)");
  gTheory->GetXaxis()->CenterTitle();
  gTheory->Draw("AL");
  
  c2->cd(2);

  TMultiGraph *mg = new TMultiGraph();
  mg->SetTitle("MC Corrections vs. Energy");
  
  TGraph *gMC2011 = new TGraph(en_MC2011.size(),&en_MC2011[0],&corr_MC2011[0]);
  gMC2011->SetMarkerStyle(kFullCircle);
  //gMC2011->SetMinimum(-10.);
  //gMC2011->SetMaximum(6.);
  gMC2011->SetLineWidth(3);
  gMC2011->SetLineColor(kBlue);
  gMC2011->GetYaxis()->SetTitle("#DeltaA/A (%)");
  gMC2011->GetYaxis()->CenterTitle();
  gMC2011->GetXaxis()->SetTitle("Energy (keV)");
  gMC2011->GetXaxis()->CenterTitle();
  //gMC2011->Draw("AC");

  TGraph *gMC2012 = new TGraph(en_MC2012.size(),&en_MC2012[0],&corr_MC2012[0]);
  gMC2012->SetMarkerStyle(kFullCircle);
  //gMC2012->SetMinimum(-10.);
  //gMC2012->SetMaximum(6.);
  gMC2012->SetLineWidth(3);
  gMC2012->SetLineColor(kGreen);
  //gMC2012->GetYaxis()->SetTitle("#DeltaA/A (%)");
  //gMC2012->GetYaxis()->CenterTitle();
  //gMC2012->GetXaxis()->SetTitle("Energy (keV)");
  //gMC2012->GetXaxis()->CenterTitle();
  //gMC2012->Draw("AC");
  
  mg->Add(gMC2011);
  mg->Add(gMC2012);
  mg->SetMinimum(-8.);
  mg->SetMaximum(6.);
  
  mg->Draw("AC");
  mg->GetYaxis()->SetTitle("#DeltaA/A (%)");
  mg->GetYaxis()->CenterTitle();
  mg->GetXaxis()->SetTitle("Energy (keV)");
  mg->GetXaxis()->CenterTitle();
  gPad->Modified();

  TLegend *leg = new TLegend(0.55,0.75,0.85,0.85);
  leg->AddEntry(gMC2011,"2011-2012","l");
  leg->AddEntry(gMC2012,"2012-2013","l");
  leg->SetTextSize(0.05);
  leg->Draw("SAME");
}
// =================================================
void plotter::plotEffOnOneCanvas( string extension )
{
	yAxisLabel_ = "Efficiency";
	xAxisLabel_ = "Electron p_{T} (GeV)";
	
	x_[6] = 125;
	xRange_[6] = 75;
	
	setExtension( extension );
   setOutFilexPrefix( "eff" );
	setUpCanvas();
	
	TMultiGraph *mg = new TMultiGraph();
	
   for( int j = 0; j < max_-1; j++)
	{
		// Read Data input
      input.readDataEff( inputDataPath_, files1_.at(j) );
		eff1_ = input.getDataEff().first;
		eff_error1_ = input.getDataEff().second;
		
      TGraphAsymmErrors *tgaeEffData = new TGraphAsymmErrors( numOfPoints_, x_, eff1_, xRange_, xRange_, eff_error1_, eff_error1_);
      tgaeEffData->SetTitle("TGraphAsymmErrors for Data efficiencies");
      tgaeEffData->SetMarkerSize(1);
      if (j == 0) tgaeEffData->SetMarkerStyle(20);
		else if (j == 1) tgaeEffData->SetMarkerStyle(24);
      else if (j == 2) tgaeEffData->SetMarkerStyle(21);
      else tgaeEffData->SetMarkerStyle(25);
		
		tgaeEffData->SetMarkerColor(kAzure - 2*j);
      tgaeEffData->SetLineColor(kAzure - 2*j);
		
		legend_->SetX1(.60);
		legend_->SetX2(.87);
		legend_->AddEntry(tgaeEffData, etaRegionLegend_.at(j), "p");
		
		mg->Add(tgaeEffData,"p");
   } // end for j
	
	canvas->SetLogx();
	
	mg->SetMinimum(0.4);
	mg->SetMaximum(1);
	mg->Draw("A");
	mg->GetXaxis()->SetMoreLogLabels();
	mg->GetXaxis()->SetTitle( xAxisLabel_ );
   mg->GetYaxis()->SetTitle( yAxisLabel_ );
	mg->GetXaxis()->SetTitleOffset(1.3);
	mg->GetYaxis()->SetTitleOffset(1.25);
	
	legend_->Draw();
	pt_->Draw();
	texZee_->Draw();
//	texCMS_->Draw();
//	texLumi_->Draw();
	
	cout << "--------------------------------------------------------------------------------" << endl;
	TString fileName = "eff_04";
	if ( extension_ == "all" )
	{
		canvas->SaveAs( outPlotsDir_ + fileName + ".pdf" );
		canvas->SaveAs( outPlotsDir_ + fileName + ".png" );
		canvas->SaveAs( outPlotsDir_ + fileName + ".eps" );
//		canvas->SaveAs( outPlotsDir_ + fileName + ".ps"  );
		canvas->SaveAs( outPlotsDir_ + fileName + ".C"   );
		canvas->SaveAs( outPlotsDir_ + fileName + ".root");
	}
	else
		canvas->SaveAs( outPlotsDir_ + fileName + extension_ );
	cout << "--------------------------------------------------------------------------------" << endl;
	
	canvas->Destructor();
	legend_->Clear();
	
	// Clear out files vector
   outFiles_.clear();
	
} // end plotEffOnOneCanvas
Example #16
0
void plot( TString stream  = "MuTau", 
	   TString channel = "SM0",
	   TString legend  = "#tau_{#mu}#tau_{h}",
	   Float_t xMax_   = 50){

  TCanvas *c1 = new TCanvas("c1","",5,30,650,600);
  c1->SetGrid(0,0);
  c1->SetFillStyle(4000);
  c1->SetFillColor(10);
  c1->SetTicky();
  c1->SetObjectStat(0);
  
  TLegend* leg = new TLegend(0.14,0.60,0.41,0.85,NULL,"brNDC");
  leg->SetBorderSize(0);
  leg->SetTextSize(0.03);
  leg->SetFillColor(0);


  float X[]        = {110,115,120,125,130,135,140,145};

  float obsY[]     = {0.,0.,0.,0.,0.,0.,0.,0.};
  float expY[]     = {0.,0.,0.,0.,0.,0.,0.,0.};

  float expX1sL[]  = {0.,0.,0.,0.,0.,0.,0.,0.};
  float expX1sH[]  = {0.,0.,0.,0.,0.,0.,0.,0.};
  float expY1sL[]  = {0.,0.,0.,0.,0.,0.,0.,0.};
  float expY1sH[]  = {0.,0.,0.,0.,0.,0.,0.,0.};

  float expX2sL[]  = {0.,0.,0.,0.,0.,0.,0.,0.};
  float expX2sH[]  = {0.,0.,0.,0.,0.,0.,0.,0.};
  float expY2sL[]  = {0.,0.,0.,0.,0.,0.,0.,0.};
  float expY2sH[]  = {0.,0.,0.,0.,0.,0.,0.,0.};

  int nMassPoints = 8;

  for(unsigned int i = 0 ; i < nMassPoints; i++){

    TFile f(Form("higgsCombine%s%s.Asymptotic.mH%.0f.root",stream.Data(),channel.Data(),X[i]),"READ");
    if(f.IsZombie()){
      cout << "Cannot open file for " << string(channel.Data()) << " and mass " << X[i] << endl;
      continue;
    }

    Double_t r;
    TTree* limit = (TTree*)f.Get("limit");
    limit->SetBranchAddress("limit",&r);

    for(int k = 0 ; k< limit->GetEntries() ; k++){
      limit->GetEntry(k);
      if(k==0) expY2sL[i] = r;
      if(k==1) expY1sL[i] = r;
      if(k==2) expY[i]    = r;
      if(k==3) expY1sH[i] = r;
      if(k==4) expY2sH[i] = r;
      if(k==5) obsY[i]    = r;
    }

  }
 


  for(int i = 0 ; i < nMassPoints ; i++){
    expY1sH[i] = TMath::Abs(expY1sH[i]-expY[i]);
    expY1sL[i] = TMath::Abs(expY1sL[i]-expY[i]);
    expY2sH[i] = TMath::Abs(expY2sH[i]-expY[i]);
    expY2sL[i] = TMath::Abs(expY2sL[i]-expY[i]);

    cout << "Mass " << X[i] << " => " << expY2sL[i] << ", " << expY1sL[i] << ", " << expY1sH[i] << ", "
	 << expY2sH[i] << ", " << endl;
  }

  TMultiGraph *mg = new TMultiGraph();
  mg->SetTitle("");

  TGraphAsymmErrors* expected = new TGraphAsymmErrors(nMassPoints, X, expY, expX1sL ,expX1sL , expX1sL, expX1sL);
  TGraphAsymmErrors* oneSigma = new TGraphAsymmErrors(nMassPoints, X, expY, expX1sL, expX1sL,  expY1sL, expY1sH);
  TGraphAsymmErrors* twoSigma = new TGraphAsymmErrors(nMassPoints, X, expY, expX2sL, expX2sL,  expY2sL, expY2sH);
  TGraphAsymmErrors* observed = new TGraphAsymmErrors(nMassPoints, X, obsY, expX1sL ,expX1sL , expX1sL, expX1sL);

 
  oneSigma->SetMarkerColor(kBlack);
  oneSigma->SetMarkerStyle(kFullCircle);
  oneSigma->SetFillColor(kGreen);
  oneSigma->SetFillStyle(1001);

  twoSigma->SetMarkerColor(kBlack);
  twoSigma->SetMarkerStyle(kFullCircle);
  twoSigma->SetFillColor(kYellow);
  twoSigma->SetFillStyle(1001);

  expected->SetMarkerColor(kBlack);
  expected->SetMarkerStyle(kFullCircle);
  expected->SetMarkerSize(1.5);
  expected->SetLineColor(kBlack);
  expected->SetLineWidth(2);

  observed->SetMarkerColor(kBlue);
  observed->SetMarkerStyle(1);
  observed->SetLineColor(kBlue);
  observed->SetLineWidth(4);

  mg->Add(twoSigma);
  mg->Add(oneSigma);
  mg->Add(expected);
  mg->Add(observed);

  mg->Draw("ALP3");

  c1->cd();
  gPad->Modified();
  mg->GetXaxis()->SetLimits(110,145);
  mg->GetYaxis()->SetTitleOffset(0.97);
  mg->SetMinimum(0.);
  mg->SetMaximum(xMax_);
  mg->GetXaxis()->SetTitle("m_{H} (GeV)");
  mg->GetYaxis()->SetTitle("#sigma X BR(H#rightarrow#tau#tau)_{95% CLs}/#sigma_{SM}");

  leg->SetHeader(Form("#splitline{CMS Preliminary #sqrt{s}=7 TeV}{4.6 fb^{-1}, %s}",legend.Data()));

  leg->AddEntry(expected,"Expected","P");
  leg->AddEntry(observed,"Observed","L");

  leg->Draw();

  TF1 *line = new TF1("line","1",100,150);
  line->SetLineColor(kRed);
  line->SetLineWidth(2);

  line->Draw("SAME");

  gPad->SaveAs(Form("limit_%s_%s.png",stream.Data(), channel.Data()));
  gPad->SaveAs(Form("limit_%s_%s.pdf",stream.Data(), channel.Data()));

}
Example #17
0
void Eff_Doping(){		// name of file

using namespace std;

double bias=30;
int i=0;			// used to name the TGraphs

TCanvas *c1 = new TCanvas("c1","c1",600,400);
TPad *pad1 = new TPad("pad1","",0,0,1,1);
TLegend *leg = new TLegend(.80,.70,.85,.87);

TGraph *gr[4];			// defines array to number of TGraphs

TMultiGraph *mg = new TMultiGraph();		// create multigraph

for (double fluence=13;fluence<=15;fluence+=1){		// loop to create multigraph for select bias values

	TString str =TString::Format("/afs/cern.ch/work/m/mbucklan/TCAD/SimpleCMOS/DepletionSimRemesh_3pixels_Rad/Neffextraction_3pixel_yCut_bias=%.1f_pitch=15.0_Fluence=1e+%.0f.txt",bias,fluence);		// does some magic, creates string with name of file
		
	if (i==4){
	
	i++;
	
	}

	gr[i] = new TGraph(str,"%lg %lg");		// creates graph called gr and reads file
	
	
	TString str1 =TString::Format("1e%.0f n_{eq} cm^{-2}",fluence);		// creates string with bias value
	
	gr[i]->SetTitle(str1);			// sets title to string
	gr[i]->SetLineColor(i+1);		// sets line colour, changes for each graph
	
	mg->Add(gr[i]);				// adds graph to multigraph
	leg->AddEntry(gr[i],str1,"l");
	
	i++;
	
}
	
pad1->Draw();
pad1->cd();
pad1->SetTickx(1);		//draws ticks on top side x axis
pad1->SetTicky(1);		//draws ticks on right hand side y axis

gPad->Update();
	
mg->Draw("AL");		// draws multigraph

// Make the graph look fancy...ish
mg->GetXaxis()->SetTitle("Depth (#mum)");
mg->GetYaxis()->SetTitle("Effective Doping Concentration (cm^{-3})");

TString str2 =TString::Format("Effective Doping Concentration for 3 Pixel 100#mum Thick Sensor at %.0fV, Resistivity=100#Omegacm",bias);		// does some magic, creates string with name of file

mg->GetHistogram()->SetTitle(str2);

mg->SetMinimum(-2e12);

leg->SetTextSize(0.03);
leg->Draw();

}
void GE11sEfficiencyPlots_3Sector_DividerCurrent()
{
   
   // Input Files 
   ifstream File1, File2, File3, File4;

    File1.open("EfficiencyData_R1592_R1646_Lat17_GE11_IV.txt");
    File2.open("SWAPHV_EfficiencyData_R2065_R2123_Lat17_GE11_IV.txt");
    File3.open("SWAP_EfficiencyData_R1868_R1906_Lat18_GE11_IV.txt");
    File4.open("EfficiencyData_R1313_R1397_Lat17_GE11_IV_GIF.txt");

   // Name of Detector
   const char*  Detector1 = "#left(i#eta,i#phi#right)=#left(5,2#right); #sigma_{eff} #times 4";
   const char*  Detector2 = "#left(i#eta,i#phi#right)=#left(1,2#right); #sigma_{eff} #times 4";
   const char*  Detector3 = "#left(i#eta,i#phi#right)=#left(8,2#right); #sigma_{eff} #times 4";
   const char*  Detector4 = "#left(i#eta,i#phi#right)=#left(5,2#right); #sigma_{eff} #times 4";

   const char* RunRange = "Threshold = 1.2 fC";	// 15 VFAT units";
   const char* BeamType = "Beam: Muon";
   const char* MSPL = "";
   const char* Threshold = "";
   const char* GasUsed = "";
   const char* ClockMode = "";
   const char* EtaPhiSector = "";

   const char* CanvasName   = "Efficiency_wrt_DividerCurrent";
   const char* pdfFile	    = "EfficiencyPlot_wrt_DividerCurrent_wError4times_2gas.pdf";
   const char* pngFile	    = "EfficiencyPlot_wrt_DividerCurrent_wError4times_2gas.png";
   TFile *f = new   TFile(    "Efficiency_wrt_DividerCurrent_2gas_3Sector.root","RECREATE");

   TGaxis::SetMaxDigits(3);

   //const char* GraphTitle = "Efficiency For Run Range 306 To 407: 2014H2B";
   const char* GraphTitle = "";


   // Set TDR Style
   setTDRStyle();
   gStyle->SetOptFit(0);

   writeExtraText = true;       // if extra text
   extraText  = "#italic{Preliminary}";  // default extra text is "Preliminary"
   int iPeriod = 0;    // 1=7TeV, 2=8TeV, 3=7+8TeV, 7=7+8+13TeV, 0=free form (uses lumi_sqrtS)

   TNtuple *NT_Detector1 = new TNtuple("EtaPhi52_ArCO2CF4","Efficiency Vs Divider Current","Divider_Current:Efficiency:Efficiency_Error");
   TNtuple *NT_Detector2 = new TNtuple("EtaPhi12_ArCO2CF4","Efficiency Vs Divider Current","Divider_Current:Efficiency:Efficiency_Error");
   TNtuple *NT_Detector3 = new TNtuple("EtaPhi82_ArCO2CF4","Efficiency Vs Divider Current","Divider_Current:Efficiency:Efficiency_Error");
   TNtuple *NT_Detector4 = new TNtuple("EtaPhi52_ArCO2",   "Efficiency Vs Divider Current","Divider_Current:Efficiency:Efficiency_Error");

   Int_t nlines = 0;

   vector<double> NT_Detector1_HV,NT_Detector1_Eff,NT_Detector1_EffErr,NT_Detector2_HV,NT_Detector2_Eff,NT_Detector2_EffErr,NT_Detector3_HV,NT_Detector3_Eff,NT_Detector3_EffErr, NT_Detector1_Gain, NT_Detector2_Gain, NT_Detector3_Gain, NT_Detector4_Gain, NT_Detector4_HV,NT_Detector4_Eff,NT_Detector4_EffErr;
   double current, eff, efferr;
   while (1) 
   {
     File1 >> current >> eff >> efferr;
     cout<<"1==> "<<current<<"\t"<<eff<<"\t"<<efferr<<endl;
	if (!File1.good()) break;

	NT_Detector1_HV.push_back(current);
	NT_Detector1_Eff.push_back(eff);
        NT_Detector1_EffErr.push_back(efferr);

	NT_Detector1->Fill(current,eff,efferr);
	nlines++;
   }
   while (1) 
   {
     File2 >> current >> eff >> efferr;
     cout<<"2==> "<<current<<"\t"<<eff<<"\t"<<efferr<<endl;
	if (!File2.good()) break;

	NT_Detector2_HV.push_back(current);
	NT_Detector2_Eff.push_back(eff);
        NT_Detector2_EffErr.push_back(efferr);

	NT_Detector2->Fill(current,eff,efferr);
	nlines++;
   }
   while (1) 
   {
     File3 >> current >> eff >> efferr;
     cout<<"3==> "<<current<<"\t"<<eff<<"\t"<<efferr<<endl;
	if (!File3.good()) break;

	NT_Detector3_HV.push_back(current);
	NT_Detector3_Eff.push_back(eff);
        NT_Detector3_EffErr.push_back(efferr);

	NT_Detector3->Fill(current,eff,efferr);
	nlines++;
   }
   while (1) 
   {
     File4 >> current >> eff >> efferr;
     cout<<"4==> "<<current<<"\t"<<eff<<"\t"<<efferr<<endl;
	if (!File4.good()) break;

	NT_Detector4_HV.push_back(current);
	NT_Detector4_Eff.push_back(eff);
        NT_Detector4_EffErr.push_back(efferr);

	NT_Detector4->Fill(current,eff,efferr);
	nlines++;
   }

   File1.close();
   File2.close();
   File3.close();
   File4.close();
   
   TCanvas* c1 = new TCanvas("c1","",1);
   c1->Range(0,0,1,1);
   TPad *pad = new TPad("pad","",0,0,1,1);
   pad->SetGrid();
   pad->Draw();
   pad->cd();


   TF1 *f1 = new TF1("f1","[0]+(0.989)/([1]+exp(-[2]*(x-697.3)))",650,815);
   TF1 *f2 = new TF1("f2","(0.968)/([1]+exp(-[2]*(x-713)))",650,815);
   TF1 *f3 = new TF1("f3","(0.973)/([1]+exp(-[2]*(x-725)))",650,820);
   TF1 *f4 = new TF1("f4","(0.985)/([1]+exp(-[2]*(x-614)))",565,720);

//   f3->SetParameters(1.,1.,1.);

      // create first graph
   TGraphErrors *gr1 = new TGraphErrors(NT_Detector1_HV.size());
   for(unsigned int i=0;i<NT_Detector1_HV.size();i++)
   {
       gr1->SetPoint(i,NT_Detector1_HV[i],NT_Detector1_Eff[i]);
       gr1->SetPointError(i,0,4*NT_Detector1_EffErr[i]);
   }
   gr1->SetMarkerColor(kGreen+3);
   gr1->SetLineColor(kGreen+3);
   gr1->SetMarkerStyle(21);
   gr1->GetXaxis()->SetTitle("Current Supplied To HV Divider (#mu A)");
   gr1->GetYaxis()->SetTitle("Efficiency");
   gr1->SetTitle(GraphTitle);
   f1->SetLineColor(kGreen+3);
   gr1->Fit("f1","R");

      // create first graph
   TGraphErrors *gr5 = new TGraphErrors(NT_Detector2_HV.size());
   for(unsigned int i=0;i<NT_Detector2_HV.size();i++)
   {
       gr5->SetPoint(i,NT_Detector2_HV[i],NT_Detector2_Eff[i]);
       gr5->SetPointError(i,0,4*NT_Detector2_EffErr[i]);
   }
   gr5->SetMarkerColor(kBlack);
   gr5->SetLineColor(kBlack);
   gr5->SetMarkerStyle(22);
   gr5->GetXaxis()->SetTitle("Current Supplied To HV Divider (#mu A)");
   gr5->GetYaxis()->SetTitle("Efficiency");
   f2->SetLineColor(kBlack);
   gr5->Fit("f2","R");

      // create first graph
   TGraphErrors *gr8 = new TGraphErrors(NT_Detector3_HV.size());
   for(unsigned int i=0;i<NT_Detector3_HV.size();i++)
   {
       gr8->SetPoint(i,NT_Detector3_HV[i],NT_Detector3_Eff[i]);
       gr8->SetPointError(i,0,4*NT_Detector3_EffErr[i]);
   }
   gr8->SetMarkerColor(kBlue);
   gr8->SetLineColor(kBlue);
   gr8->SetMarkerStyle(24);
   gr8->GetXaxis()->SetTitle("Current Supplied To HV Divider (uA)");
   gr8->GetYaxis()->SetTitle("Efficiency");
   gr8->SetTitle(GraphTitle);
   f3->SetLineColor(kBlue);
   gr8->Fit("f3","R");

      // create first graph
   TGraphErrors *gr9 = new TGraphErrors(NT_Detector4_HV.size());
   for(unsigned int i=0;i<NT_Detector4_HV.size();i++)
   {
       gr9->SetPoint(i,NT_Detector4_HV[i],NT_Detector4_Eff[i]);
       gr9->SetPointError(i,0,4*NT_Detector4_EffErr[i]);
   }
   gr9->SetMarkerColor(kMagenta+2);
   gr9->SetLineColor(kMagenta+2);
   gr9->SetMarkerStyle(20);
   gr9->GetXaxis()->SetTitle("Current Supplied To HV Divider (uA)");
   gr9->GetYaxis()->SetTitle("Efficiency");
   f4->SetLineColor(kMagenta+2);
   gr9->Fit("f4","R");

TMultiGraph *mg = new TMultiGraph("mg",";Current Supplied to HV Divider (#mu A);Efficiency");
mg->Add(gr1);
mg->Add(gr5);
mg->Add(gr8);
mg->Add(gr9);
mg->SetMaximum(1.01);
mg->SetMinimum(0.0);
//mg->GetYaxis()->SetRangeUser(570.,820.);
mg->Draw("AP");
mg->GetXaxis()->SetLimits(560,890);
mg->GetYaxis()->SetDecimals(1);


   

   //Draw the Legend 
   TLegend *leg = new TLegend(0.55,0.400,0.80,0.50);
   TLegend *leg2 = new TLegend(0.55,0.150,0.80,0.30);
   leg2->SetTextSize(0.05);
   leg2->SetTextFont(42);
   leg->SetTextSize(0.05);
   leg->SetTextFont(42);
   //leg->AddEntry(gr1,"(i#eta,i#phi)=(1,2)","LPE");
   //leg->AddEntry(gr5,"(i#eta,i#phi)=(5,2)","LPE");
   //leg->AddEntry(gr8,"(i#eta,i#phi)=(8.2)","LPE");
   leg->AddEntry(gr9,Detector4,"PE");
   leg2->AddEntry(gr5,Detector2,"PE");
   leg2->AddEntry(gr1,Detector1,"PE");
   leg2->AddEntry(gr8,Detector3,"PE");

   leg->Draw("same");
   leg2->Draw("same");

   TLatex *text1 = new TLatex(750,0.74,RunRange);
   TLatex *text2 = new TLatex(750,0.66,BeamType);
   TLatex *text5 = new TLatex(750,0.58,"Gap Config: 3/1/2/1 mm");
   TLatex *text3 = new TLatex(750,0.48,"Gas: Ar/CO2 (70/30)");
   TLatex *text4 = new TLatex(750,0.28,"Gas: Ar/CO2/CF4 (45/15/40)");
//   TLatex *text5 = new TLatex(81050,0.64,ClockMode);
   TLatex *text6 = new TLatex(3150,0.56,EtaPhiSector);
   TLatex *text7 = new TLatex(3250,0.48,GasUsed);
   text1->SetTextFont(42);
   text2->SetTextFont(42);
   text3->SetTextFont(42);
   text5->SetTextFont(42);
   //text3->SetTextAngle(50);
   //text4->SetTextAngle(50);
//   text3->SetTextColor(kMagenta);
   text4->SetTextFont(42);
   text1->SetTextSize(0.04);
   text2->SetTextSize(0.04);
   text3->SetTextSize(0.04);
   text4->SetTextSize(0.04);
   text5->SetTextSize(0.04);
   TLatex *cmsprem = new TLatex(560,1.015,"CMS #it{Preliminary}");
   //TLatex *cmsprem = new TLatex(58.5,1.03,"#it{Preliminary}");
   //TLatex *cmsprem = new TLatex(58.5,1.03,"CMS #it{Preliminary}");
   TLatex *gen = new TLatex(855,1.015,"GE1/1");
//   cmsprem->SetTextFont(42);
//   cmsprem->SetTextSize(0.05);
//   gen->SetTextFont(42);
//   gen->SetTextSize(0.05);
//   cmsprem->SetTextSize(0.04);
   text1->Draw("same");
   text2->Draw("same");
   text3->Draw("same");
   text4->Draw("same");
   text5->Draw("same");
   text6->Draw("same");
   text7->Draw("same");
   cmsprem->Draw("same");
   gen->Draw("same");
//
////   CMS_lumi( c1, iPeriod, 0 );
//   

//   Float_t rightmax = 1.1*gr1->GetMaximum();

   //draw an axis on the right side
//   TGaxis *axis = new TGaxis(gPad->GetUxmin(),gPad->GetUymin(),
//	   gPad->GetUxmax(), gPad->GetUymax(),0,rightmax,510,"+L");
//   TGaxis *axis = new TGaxis(104,1.01,23211,1.01,3370,4252,15,"-");
//   cout<<"GetUxmax = "<<gPad->GetUxmin()<<"\tGetUymin = "<<gPad->GetUxmax()<<endl;
//   cout<<"GetUxmax = "<<gPad->GetUymin()<<"\tGetUymin = "<<gPad->GetUymax()<<endl;
//   axis->SetTitle("V_Drift (volts)");
// //  axis->SetTitleSize(2.5);
//  axis->SetTitleFont(42);
//  axis->SetTitleColor(1);
//  //axis->SetTitleFontSize(0.05);
//   axis->SetLineColor(kBlack);
//   axis->SetLabelColor(kBlack);
//   axis->Draw("sames");

   c1->Update();
   c1->SaveAs(pdfFile);
   c1->SaveAs(pngFile);
   //c1->SaveAs();

   c1->Write();
   f->Write();

}
Example #19
0
void plotS11Baby() {

   const int numFiles=8;
   char filename[180];
   int antFiles[numFiles][2]={{1,17},{1,18},{1,28},{1,27},{2,7},{2,8},{5,8},{5,9}};
   int whichOpen[numFiles]={1,1,2,2,5,5,6,6};
   int plotThis[numFiles]={1,1,1,1,2,2,2,2};
   char *graphDesc[numFiles]={"Office (1)","Office (2)","Outside (1)","Outside (2)","Salt Day I (1)","Salt Day I (2)","Salt Day III (1)","Salt Day III (2)"};
   TGraph *grOpen[NUM_OPENS]; 
   TGraph *grOpenPower[NUM_OPENS];
   for(int i=0;i<NUM_OPENS;i++) {
      grOpen[i]=getOpenWave(i); 
      //      grOpenPower[i]=FFTtools::makePowerSpectrumVoltsSecondsPadded(grOpen[i],8);
      grOpenPower[i]=FFTtools::makePSVSBartlettPaddedOverlap(grOpen[i],32,1024);
      Double_t *freq=grOpenPower[i]->GetX();
      //      cout << i << "\t" << grOpenPower[i]->GetN() << "\t" <<  freq[1]-freq[0] << "\n";
   }
   
   TGraph *grAnt[numFiles];
   TGraph *grAntPower[numFiles];
   TGraph *grAntRatio[numFiles];
   TGraph *grAntTrans[numFiles];
   for(int i=0;i<numFiles;i++) {
       sprintf(filename,"/home/rjn/saltStuff/hockley2009/disk_%d/TEK%05d.txt",antFiles[i][0],antFiles[i][1]);
       grAnt[i]=getWaveFromTxt(filename);
       grAnt[i]=cropLikeOpen(grAnt[i],whichOpen[i]);
       if(i<3) {
	 //	  grAntPower[i]=FFTtools::makePowerSpectrumVoltsSecondsPadded(grAnt[i],8);
	  grAntPower[i]=FFTtools::makePSVSBartlettPaddedOverlap(grAnt[i],32,1024);
       }
       else {
	  grAntPower[i]=FFTtools::makePSVSBartlettPaddedOverlap(grAnt[i],32,1024);
	  //	  TGraph *grTemp=FFTtools::makePowerSpectrumVoltsSecondsPadded(grAnt[i],8);
	  //	  grAntPower[i]=FFTtools::smoothFFT(grTemp,2);
       }
       grAntRatio[i]=FFTtools::dbGraphs(grAntPower[i],grOpenPower[whichOpen[i]]);
       grAntTrans[i]=FFTtools::ratioSubtractOneGraphs(grAntPower[i],grOpenPower[whichOpen[i]]);
       //       Double_t *freq=grAntPower[i]->GetX();
       //       cout << i << "\t" << freq[1]-freq[0] << "\n";
       //       cout << i << "\t" << grAntPower[i]->GetN() << "\t" <<  freq[1]-freq[0] << "\n";
       //       cout << grAntRatio[i] << "\t" << grAntTrans[i] << endl;
   }


  TCanvas *canWave = new TCanvas("canBabyWave","canBabyWave",800,800);
  canWave->Divide(1,numFiles);
  for(int i=0;i<numFiles;i++) {
     canWave->cd(i+1);
     grAnt[i]->SetLineColor(getNiceColour(i));     
     grAnt[i]->Draw("al");
     grAnt[i]->SetTitle(graphDesc[i]);
     grAnt[i]->GetXaxis()->SetTitle("Time (s)");
     grAnt[i]->GetYaxis()->SetTitle("Voltage (V)");

  }

  TCanvas *can = new TCanvas("canBaby","canBaby",900,600);
  can->Divide(1,2);
  for(int subPad=1;subPad<=2;subPad++) {
    can->cd(subPad);
    TMultiGraph *mg = new TMultiGraph();
    
    TLegend *leggy = new TLegend(0.2,0.2,0.4,0.5);
    leggy->SetBorderSize(0);
    leggy->SetFillColor(0);
    leggy->SetFillStyle(0);  
    for(int i=0;i<numFiles;i++) {
      if(plotThis[i]!=subPad) continue;
      grAntRatio[i]->SetLineColor(getNiceColour(i));
      grAntRatio[i]->SetLineWidth(2);
      mg->Add(grAntRatio[i],"l");
      leggy->AddEntry(grAntRatio[i],graphDesc[i],"l");
    }
    mg->Draw("al");
    mg->SetTitle("S11 Measurements Baby");
    mg->SetMaximum(0);
    mg->SetMinimum(-20);
    mg->GetXaxis()->SetRangeUser(0,1000);
    mg->GetXaxis()->SetTitle("Frequency (MHz)");
    mg->GetYaxis()->SetTitle("Reflected Power (dB)");
    leggy->Draw();
  }


  TCanvas *canTrans = new TCanvas("canTransBaby","canTransBaby",900,600);
  canTrans->Divide(1,2);
  for(int subPad=1;subPad<=2;subPad++) {
    canTrans->cd(subPad);
    TMultiGraph *mg = new TMultiGraph();
    TLegend *leggy2 = new TLegend(0.2,0.55,0.4,0.85);
    leggy2->SetBorderSize(0);
    leggy2->SetFillColor(0);
    leggy2->SetFillStyle(0);  
    for(int i=0;i<numFiles;i++) {
      if(plotThis[i]!=subPad) continue;
      grAntTrans[i]->SetLineColor(getNiceColour(i));
      grAntTrans[i]->SetLineWidth(2);
      mg->Add(grAntTrans[i],"l");
      leggy2->AddEntry(grAntTrans[i],graphDesc[i],"l");
    }
    mg->Draw("al");
    mg->SetTitle("S11 Measurements Baby");
    mg->SetMaximum(1);
    mg->SetMinimum(0);
    mg->GetXaxis()->SetRangeUser(0,1000);
    mg->GetXaxis()->SetTitle("Frequency (MHz)");
    mg->GetYaxis()->SetTitle("Transmission (Ratio)");    
    leggy2->Draw();
  }


}
Example #20
0
void Pulse_shape_int_v3(){		// name of file

using namespace std;

int i=0;			// used to name the TGraphs

int bins = 500;
double total_time = 1e-8;
double bin_width = total_time/bins;

double raw_data[bins+1][2];			// data from TCAD, current cleaned file
double adapted_data[bins+1][2];			// data with leakage current subtracted, adapted array file
double int_data[bins+1][2];			// integrated data i.e. the charge, CC file

TCanvas *c1 = new TCanvas("c1","c1", 600, 400);
TPad *pad1 = new TPad("pad1","",0,0,1,1);
TLegend *leg = new TLegend(.80,.70,.85,.87);

TGraph *gr1[7];			// defines array to number of TGraphs

TMultiGraph *mg = new TMultiGraph();		// create multigraph

for (double bias=10;bias<=60;bias+=10){		// loop to create of graph for select bias values

	TString str =TString::Format("/afs/cern.ch/work/m/mbucklan/TCAD/SimpleCMOS/DepletionSimRemesh_Particle_v10/Current_Cleaned_bias=%.0f_500.txt",bias);		// does some magic, creates string with name of file
	
	TString str1 =TString::Format("%.0fV",bias);		// creates string with bias value
	
	int a=0;			// a by b array for raw_data
	int b=0;
	
	memset(raw_data, 0, sizeof(raw_data));			//set all array elements to 0
	
	// read current data from file and store in array
	ifstream infile (str);   
 	if (infile.is_open()){		
	
       		for (int c=0;c<=bins;c++){ 
       
       			infile >> raw_data[a][b] >> raw_data[a][b+1];
			a++;
			b=0;
		
      		}
      
     	}
	
	int x=0;		// x by y array for adapted_data
	int y=0;
	memset(adapted_data, 0, sizeof(adapted_data));			//set all array elements to 0
	
	for (int e=0;e<=bins;e++){ 
       			
			adapted_data[x][0]= raw_data[x][0];
       			adapted_data[x][1]= raw_data[x][1] - raw_data[0][1];
			x++;

      	}
	
	TString str2 =TString::Format("/afs/cern.ch/work/m/mbucklan/TCAD_Analysis/SimpleCMOS_2d/1pixel/Adapted_array_Simple_Pixel_bias=%.0f_500.txt",bias);		// does some magic, creates string with name of file
	
	// write adapted_data array to text file
	ofstream adapted_file (str2);
	if (adapted_file.is_open()) {

    		for (int f = 0; f <= bins; f++) {
	
			for (int g = 0; g < 2; g++) {
		
				adapted_file << adapted_data[0+f][0+g] << " ";
			
			}
			
			adapted_file << endl;	
		
 	 	}
	
	}
	
	int n=0;			// n by m array for int_data
	int m=0;
	
	
	memset(int_data, 0, sizeof(int_data));			//set all array elements to 0

	for (int h=1;h<=bins+1;h++){		// loop that finds area under curve at increasing time points using trap rule and stores to array
		
		double sum=0;
		
		for (int d=1;d<=h-1;d++){			// loop for last term in trap rule formula, sum of midpoints
		
			sum+=adapted_data[d][1];
			
		}
		
		int_data[n][m]= adapted_data[n][0];
		m++;
		int_data[n][m]= 0.5*bin_width*(adapted_data[0][1] + adapted_data[h][1] + 2*(sum));
		n++;
		m=0;
		
		
	}
	
	TString str3 =TString::Format("/afs/cern.ch/work/m/mbucklan/TCAD_Analysis/SimpleCMOS_2d/1pixel/CC_Simple_Pixel_bias=%.0f_500.txt",bias);		// does some magic, creates string with name of file
	
	// write data array to text file
	ofstream myfile (str3);
	if (myfile.is_open()) {

    		for (int k = 0; k <= bins; k++) {
	
			for (int l = 0; l < 2; l++) {
		
				myfile << int_data[0+k][0+l] << " ";
			
			}
			
			myfile << endl;	
		
 	 	}
	
	}
	
	
	if (i==4){
	
	i++;
	
	}
	
	gr1[i] = new TGraph(str3,"%lE %lE");		// creates graph and reads file
	
		
	gr1[i]->SetTitle(str1);			// sets title to string
	gr1[i]->SetLineColor(i+1);		// sets line colour, changes for each graph
		
	mg->Add(gr1[i]);			// adds graph to multigraph
	
	leg->AddEntry(gr1[i],str1,"l");
	
	i++;

}
	
	


pad1->Draw();
pad1->cd();
pad1->SetTickx(1);		//draws ticks on top side x axis
pad1->SetTicky(1);		//draws ticks on right hand side y axis

gPad->Update();

mg->Draw("AL");		// draws graph

// Make the graph look fancy...ish
mg->GetXaxis()->SetTitle("Time (s)");
mg->GetYaxis()->SetTitle("Collected Charge (C)");
//mg->GetYaxis()->SetTitleOffset(1.2);
mg->GetHistogram()->SetTitle("Colled Charge for 1 Pixel 100#mum Thick Sensor, Resistivity=100#Omegacm");
mg->SetMinimum(0);

leg->SetTextSize(0.03);
//leg->SetBorderSize(0);		// no border
leg->Draw();


}