Exemplo n.º 1
0
void HistogramPlotter::makePlot(std::map<std::string, TH1F*> plotMap, std::string plotName, std::vector<std::string> xAxisLabels){
  makePlot(plotMap,plotName,"",xAxisLabels);
}
Exemplo n.º 2
0
void HistogramPlotter::makePlot(std::map<std::string, TH1F*> plotMap, std::string plotName, std::string subLabel){
  std::vector<std::string> blankLabels;
  makePlot(plotMap,plotName,subLabel,blankLabels);
}  
Exemplo n.º 3
0
//Main function
void readData(
		char* filename = "./output/LM2_out", //input file name
		int filenum = 1100, 					//file number
		Double_t entriesN = 0,					//number of entries for prcessing
		int nsleep = 0							//sleep time between 2 processed entries, helpful for viewing traces
		)
{
	nbins = 1024;
	entries = entriesN;
	sleep = nsleep;

	// input file
    char fname[100]=0;
    sprintf(fname,"%s_0%i.root",filename,filenum);

    // TChain fill
	t = new TChain("tree");
	t->Add(fname);
	//t->Add("./output/LM2_out_01092.root");
	//t->Add("./output/LM2_out_01093.root");
	//t->Add("./output/LM2_out_01094.root");
	//t->Add("./output/LM2_out_01096.root");
	//t->Add("./output/LM2_out_01097.root");
	//t->Add("./output/LM2_out_01098.root");
	//t->Add("./output/LM2_out_01100.root");
	t->Add("./output/LM2_out_01101.root");
	t->Add("./output/LM2_out_01102.root");
	t->Add("./output/LM2_out_01103.root");
	t->Add("./output/LM2_out_01104.root");
	t->Add("./output/LM2_out_01105.root");
	t->Add("./output/LM2_out_01106.root");
	t->Add("./output/LM2_out_01107.root");
/*
	//gSystem->Setenv("LOCAL_FILES",(char*)gSystem->GetListOfFileHandlers ());
	if(gSystem->Getenv("LOCAL_FILES")!=NULL) {
		TString ftemp(gSystem->Getenv("LOCAL_FILES"));
		cout<<"ftemp=" <<ftemp<<endl;;
		TObjArray* foa = ftemp.Tokenize(" ");
		for(int i=0; i<foa->GetEntries(); i++) {
		  t->AddFile(((TObjString*) foa->At(i))->String().Data(),
					  TChain::kBigNumber);
		}
	}
*/
	//function that make plots
	makePlot("LM2");

	entries = entriesN;

	delete t;
	t = new TChain("tree");
	t1 = new TChain("ntuple");
	//t->Add("./output/LM1_out_01091.root");
	//t->Add("./output/LM1_out_01092.root");
	//t->Add("./output/LM1_out_01093.root");
	//t->Add("./output/LM1_out_01094.root");
	//t->Add("./output/LM1_out_01096.root");
	//t->Add("./output/LM1_out_01097.root");
	//t->Add("./output/LM1_out_01098.root");
	t->Add("./output/LM1_out_01100.root");
	t->Add("./output/LM1_out_01101.root");
	t->Add("./output/LM1_out_01102.root");
	t->Add("./output/LM1_out_01103.root");
	t->Add("./output/LM1_out_01104.root");
	t->Add("./output/LM1_out_01105.root");
	t->Add("./output/LM1_out_01106.root");
	t->Add("./output/LM1_out_01107.root");
	t1->Add("160229_160307_PTU.root");

	clearTree();

	//function that make plots
	makePlot("LM1");
}
Exemplo n.º 4
0
// ----------------------------------------------------------------------
void moduleSummary(const char *dirName = "", const char *module_type) 
{

  printf("\nmoduleSummary> Starting ...\n");

  nChips = 16;
  startChip = 0;
	
  if ( !strcmp(module_type,"a") ) {
    
    nChips = 8; 
    startChip = 0; 
  }
  
  if ( !strcmp(module_type,"b") ) {
    
    nChips = 8; 
    startChip = 8; 
  }

  sprintf(fname, "%s/%s", dirName, fileName);
  inputFile = fopen(fname, "r");
  if (!inputFile) { 

    printf("\nmoduleSummary> ----> COULD NOT FIND %s IN DIRECTORY %s\n", fileName, dirName);
    printf("moduleSummary> ----> Aborting execution of moduleSummaryPage.C ... \n\n", fileName, dirName);   
    break; 
  }

  
  sprintf(fname, "%s/%s", dirName, adFileName);
  inputFile = fopen(fname, "r");
  if (!inputFile) {
    
    sprintf(adFileName,"%s", fileName); 
  }
  else {
    
    printf("moduleSummary> ----> found separate address decoding file: %s\n", adFileName); 
    fclose (inputFile); 
  }
  
  sprintf(fname, "%s/../../macros/criteria.dat", dirName);
  if ( !readCriteria(fname) ) {  
    
    printf("\nmoduleSummary> ----> COULD NOT READ GRADING CRITERIA !!!\n");
    printf("moduleSummary> ----> Aborting execution of moduleSummaryPage.C ... \n\n", fileName, dirName);  
    break;
  }

  TFile *f = new TFile(Form("%s/%s", dirName, fileName));

  gROOT->SetStyle("Plain");
  
  gStyle->SetPalette(1);
  gStyle->SetOptStat(0);
  gStyle->SetTitle(0);

  gStyle->SetStatFont(132);
  gStyle->SetTextFont(132);
  gStyle->SetLabelFont(132, "X");
  gStyle->SetLabelFont(132, "Y");
  gStyle->SetLabelSize(0.08, "X");
  gStyle->SetLabelSize(0.08, "Y");
  gStyle->SetTitleSize(0.08, "X");
  gStyle->SetTitleSize(0.08, "Y");
  gStyle->SetNdivisions(10, "X");
  gStyle->SetNdivisions(8, "Y");
  gStyle->SetTitleFont(132);
    
  gROOT->ForceStyle();
  
  tl = new TLatex;
  tl->SetNDC(kTRUE);
  tl->SetTextSize(0.1);
  
  ts = new TLatex;
  ts->SetNDC(kTRUE);
  ts->SetTextSize(0.09);

  line = new TLine;
  line->SetLineColor(kRed);
  line->SetLineStyle(kDashed);

  box = new TBox;
  box->SetFillColor(3);
  box->SetFillStyle(3004);

  c1 = new TCanvas("c1", "", 900, 700);
  c1->Clear();
  c1->Divide(1,4);
    
  int EColor[6]        = { 4, 8, 6, 1 };  
  int EMarkerStyle[10] = { 4, 25, 26, 23, 21, 27, 28, 20, 30, 29 };

  TH2D *mThreshold = new TH2D("mThreshold", "", 416, 0., 416., 160, 0., 160.);
  TH2D *mBumps     = new TH2D("mBumps",     "", 416, 0., 416., 160, 0., 160.);
  TH2D *mAddr      = new TH2D("mAddr",      "", 416, 0., 416., 160, 0., 160.);  

  double mThresholdmin(0.), mThresholdmax(255.);


  const int nfit = 4;  
  TString fitNames[] = {TString("Noise"), TString("Vcal Thr. Width"), TString("Rel. Gain Width"), TString("Pedestal Spread")};

  float limitB[] = { noiseB, trimmingB, gainB, pedestalB };   // limit for grading
  float limitC[] = { noiseC, trimmingC, gainC, pedestalC };   // limit for grading
  float max[]   = { noiseB + 100., trimmingB + 100., gainB + 0.05, pedestalB + 1000. };    // scaling of histogram

  TH1D *fit[nfit];
  TH1D *fitEntries[nfit];

  for(int ifit = 0; ifit < nfit; ++ifit) {

    fit[ifit] = new TH1D(Form("%s", fitNames[ifit].Data()),"", nChips, float(startChip), float(startChip+nChips));
    fitEntries[ifit] = new TH1D(Form("n%s", fitNames[ifit].Data()),"", nChips, float(startChip), float(startChip+nChips));

    fit[ifit]->SetLineColor(EColor[ifit]);
    fit[ifit]->SetMarkerColor(EColor[ifit]);
    fit[ifit]->SetMarkerStyle(EMarkerStyle[ifit]);
    fit[ifit]->SetMarkerSize(0.5);
  }
 
  for (int i = startChip; i < startChip+nChips; i++) { addVcalThreshold(dirName, i, mThreshold); }
  for (int i = startChip; i < startChip+nChips; i++) { addChip("vcals_xtalk", i, mBumps); }

  TFile *f1 = new TFile(Form("%s/%s", dirName, adFileName));
  for (int i = startChip; i < startChip+nChips; i++) { addChip("AddressDecoding", i, mAddr);}

  if ( nChips < 16 && startChip == 0 ) { 
    for (int i = 8; i < nChips+8; i++) { removeChip(i, mThreshold, -99); }
    for (int i = 8; i < nChips+8; i++) { removeChip(i, mBumps, -99); }
    for (int i = 8; i < nChips+8; i++) { removeChip(i, mAddr, -99); }
  }

  if ( nChips < 16 && startChip == 8 ) { 
    for (int i = 0; i < nChips; i++) { removeChip(i, mThreshold, -99); }
    for (int i = 0; i < nChips; i++) { removeChip(i, mBumps, -99); }
    for (int i = 0; i < nChips; i++) { removeChip(i, mAddr, -99); }
  }

  TString noslash(dirName);
  noslash.ReplaceAll("/", "");
  noslash.ReplaceAll("..", "");
  
  c1->cd(1);

  if ( mThreshold->GetMaximum() < mThresholdmax ) { 
    mThresholdmax = mThreshold->GetMaximum();
  }
  if ( mThreshold->GetMinimum() > mThresholdmin ) {
    mThresholdmin = mThreshold->GetMinimum();
  }
  mThreshold->GetZaxis()->SetRangeUser(mThresholdmin,mThresholdmax);
  mThreshold->DrawCopy("colz");
  tl->DrawLatex(0.1, 0.92, "Vcal threshold");
  tl->DrawLatex(0.75, 0.92, Form("%s",noslash.Data()));

  if ( nChips < 16 && startChip == 0 ) { 
   
    box->SetFillColor(29);
    box->DrawBox( 0, 0,  416,  80);
  }

  if ( nChips < 16  && startChip == 8 ) { 
   
    box->SetFillColor(29);
    box->DrawBox( 0, 80,  416,  160);
  }



  c1->cd(2);
  mBumps->SetMaximum(2.);
  mBumps->SetMinimum(-2.);  
  mBumps->DrawCopy("colz");
  tl->DrawLatex(0.1, 0.92, "Bump bonding map");

  if ( nChips < 16 && startChip == 0 ) { 
   
    box->SetFillColor(29);
    box->DrawBox( 0, 0,  416,  80);
  }

  if ( nChips < 16 && startChip == 8 ) { 
   
    box->SetFillColor(29);
    box->DrawBox( 0, 80,  416,  160);
  }
  
  c1_3->Divide(3,1);
  c1_3->cd(1);
  gPad->SetBottomMargin(0.2);
  gPad->SetLogy(1);
  gPad->SetLeftMargin(0.20);
  gPad->SetRightMargin(0.01);
  
  float V, A;
  float x_V[250], y_A[250];
  int i(0); 
  float iv100(0.);
  float iv150(0.);
  float iv150_17(0.);
  float iv100_17(0.);
  float variation(0.);
  float variation_17(0.);
  
  FILE *ivFile, *sumWrite, *sumRead, *gradWrite; 
    
  sprintf(fname, "%s/iv.dat", dirName);
  ivFile = fopen(fname, "r");
  
  if (!ivFile)
  {
    printf("moduleSummary> !!!!!!!!!  ----> Could not open file %s to read data\n", fname);
  }
  
  else {
  
    fclose(ivFile);
    ifstream is(fname);
    
    char  buffer[200];
    
    while (is.getline(buffer, 200, '\n')) {
      
      // check that line starts with a number
      if (buffer[0] != '1' && buffer[0] != '2' && buffer[0] != '3' && buffer[0] != '4' && 
	  buffer[0] != '5' && buffer[0] != '6' && buffer[0] != '7' && buffer[0] != '8' && buffer[0] != '9'  )  {continue;} 
      
      sscanf(buffer, "%e %e", &V, &A);
      
      x_V[i] = V;
      y_A[i] = 1e6*A;
      
      if ( i > 0 ) {
	
        // check that voltage is increasing & find current at 150 V 
        if ( x_V[i] < x_V[i-1] ) { continue; }
	if ( x_V[i] >= 100. && x_V[i-1] <= 100. ) { iv100 = y_A[i-1] + (100. - x_V[i-1])*(y_A[i] - y_A[i-1])/(x_V[i] - x_V[i-1]); }
	if ( x_V[i] >= 150. && x_V[i-1] <= 150. ) { iv150 = y_A[i-1] + (150. - x_V[i-1])*(y_A[i] - y_A[i-1])/(x_V[i] - x_V[i-1]); }
	
      }
      
      i++;
      
    }
 
 
    if ( iv100 != 0. ) { variation = iv150/iv100; }
    else               { variation = 0; }

    if ( i > 0 ) {
    
      TGraph *g1 = new TGraph(i,x_V,y_A);

      g1->Draw("aC");
      g1->SetTitle("");
      g1->SetLineColor(4);
      g1->SetLineWidth(2);
    
      g1->GetXaxis()->SetTitle("Voltage [V]");
      g1->GetYaxis()->SetTitle("Current [#muA]");
      g1->GetYaxis()->SetDecimals();
      g1->GetYaxis()->SetTitleOffset(1.2);
      g1->GetYaxis()->CenterTitle();
  
      tl->DrawLatex(0.2, 0.92, "I-V-Curve");
      ts->DrawLatex(0.25, 0.78, Form("I(150 V) = %.2f #muA", iv150));
      ts->DrawLatex(0.25, 0.65, Form("I_{150}/I_{100} =  %.2f ", variation));

    }   
  }
    
  char mod[20] = noslash.Data(), waf[20] = "",  test[20] = "",tmon[20], trim[20], ph[20], cycl[20];
  int tday;
  int dp(0), dm(0), db(0), dt(0), da(0);
  int root(0), a(0), b(0), c(0); 
  int badRocs[3] = {0, 0, 0};
  char iv;
  float voltage, current; 
  float temp, tempSigma, sollTemp;
  float cyclMean, cyclSigma;
  char  string[1000];
  
  c1_3->cd(2);
  
  sprintf(fname, "%s/summaryTest.txt", dirName);
  sumRead = fopen(fname, "r");

  if (!sumRead)
  {
    printf("\nmoduleSummary> !!!!!!!!!  ----> File %s does not exist yet...\n", fname);
    printf("moduleSummary> !!!!!!!!!  ----> Module summary not complete!\n\n");
  }
  else
  {
    fgets(string, 200, sumRead);
    //   fscanf(sumRead, "%s %s", string, mod);
    fscanf(sumRead, "%s %s %s %s", string, string, waf, test);
    fscanf(sumRead, "%s %i %i %i %i %i", string, &dp, &dm, &db, &dt, &da);
    fscanf(sumRead, "%s %s %s %s %s %i %i %i", string, string, string, string, string, &a, &b, &c);
    badRocs[0]=a;  badRocs[1]=b;  badRocs[2]=c;
    fscanf(sumRead, "%s %s %i", string, string, &root);
    fscanf(sumRead, "%s %s %s %s %s %i %s %s", string, string, string, string, tmon, &tday, string, string);

    fgets(string, 200, sumRead);
    fscanf(sumRead, "%s %s", string, trim);
    fgets(string, 200, sumRead); 
    fscanf(sumRead, "%s %s", string, ph);
    fgets(string, 200, sumRead);
    
    fscanf(sumRead, "%s %f %f %s %f", string, &temp, &tempSigma, string, &sollTemp); 

    fscanf(sumRead, "%s %s %s %f %f", string, string, cycl, &cyclMean, &cyclSigma);

    fclose(sumRead);
    
    tl->SetTextSize(0.09);
    tl->SetTextFont(22);
    double y = 0.92;
    tl->DrawLatex(0.01, y, Form("Test Summary of %s     %s", waf, test));
    tl->SetTextFont(132); 
    tl->SetTextSize(0.09);

    y -= 0.16;
    tl->DrawLatex(0.01, y, "ROCs > 1% defects: ");
    tl->DrawLatex(0.5, y, Form("%i", badRocs[0]));
    
    y -= 0.12;
    tl->DrawLatex(0.01, y, Form("Dead Pixel: "));
    tl->DrawLatex(0.5, y, Form("%i", dp));

    y -= 0.11;
    tl->DrawLatex(0.01, y, "Mask Defects: ");
    tl->DrawLatex(0.5, y, Form("%i", dm));

    y -= 0.11;
    tl->DrawLatex(0.01, y, "Dead Bumps: ");
    tl->DrawLatex(0.5, y, Form("%i", db));

    y -= 0.11;
    tl->DrawLatex(0.01, y, "Dead Trimbits: ");
    tl->DrawLatex(0.5, y, Form("%i", dt));

    y -= 0.11;
    tl->DrawLatex(0.01, y, "Address Probl: ");
    tl->DrawLatex(0.5, y, Form("%i", da));

    y = 0.76;
    tl->DrawLatex(0.72, y, Form("Tested on:"));
    y -= 0.11;
    tl->DrawLatex(0.72, y, "Temp. [^{o}C]:  ");
    y -= 0.11;
    tl->DrawLatex(0.72, y, "Trim / phCal: ");
    y -= 0.11;
    tl->DrawLatex(0.72, y, "Therm. cycl.: ");
    y -= 0.11;
    tl->DrawLatex(0.72, y, "TBM1: ");
    y -= 0.11;
    tl->DrawLatex(0.72, y, "TBM2: ");

    c1_3->cd(3);
    y = 0.76;
    tl->DrawLatex(0.01, y, Form("%s %i", tmon, tday));
    
    y -= 0.11;
    tl->DrawLatex(0.01, y, Form("%.1f +- %.1f", temp, tempSigma));
              
    y -= 0.11;
    tl->DrawLatex(0.01, y, Form("%s / %s", trim, ph));

    y -= 0.11;
    tl->DrawLatex(0.01, y, Form("%s", cycl));

  }

  int result;
  int tbm1(1), tbm2(1);
  TParameter<int>* par;
  
  y -= 0.11;
  par = (TParameter<int>*)f->Get("TBM1");
  if (par)
  {
  	tbm1 = par->GetVal();
  	if (tbm1 == 0) tl->DrawLatex(0.01, y, "ok");   
  	else tl->DrawLatex(0.01, y, Form("Err%i", tbm1));   
  }

  y -= 0.11;
  par = (TParameter<int>*)f->Get("TBM2");
  if (par)
  {
	tbm2 = par->GetVal();
	if (tbm2 == 0) tl->DrawLatex(0.01, y, "ok");   
	else tl->DrawLatex(0.01, y, Form("Err%i", tbm2));   
  }


  // Convert current to currents at room temperature
  double Tk = 273.15;
  double egap = 1.12;
  double kB = 8.617343E-5;
  double tTest;
  // tTest = temp;  // --> averaged temperature
  tTest = sollTemp;
  
  double expnt  = egap*(1/(Tk+tTest) - 1/(Tk+17))/(2*kB);
  double fctr   = (Tk+17)*(Tk+17)/((Tk+tTest)*(Tk+tTest));
  
  iv150_17 = iv150*fctr*TMath::Exp(expnt);
  iv100_17 = iv100*fctr*TMath::Exp(expnt);
  if ( iv100_17 != 0 ) variation_17 = iv150_17/iv100_17;
    
  printf("\nmoduleSummary> converted I(150 V, %.0f C)    = %.4f       to  I(150 V, 17 C)    = %.4f \n", tTest, iv150, iv150_17);
  printf("moduleSummary> converted I(100 V, %.0f C)    = %.4f       to  I(100 V, 17 C)    = %.4f \n\n", tTest, iv100, iv100_17);
  
  if ( iv150_17 != 0 ) {
    c1_3->cd(3);
    y = 0.32;
    tl->DrawLatex(0.25, y, "I(150 V) [T = 17 ^{o}C]");
    tl->DrawLatex(0.72, y, Form("%.2f #muA", iv150_17));
    c1_3->cd(2);
    
  }

  if ( iv100_17 != 0 ) {
    c1_3->cd(3);
    y = 0.21;
    tl->DrawLatex(0.25, y, "I_{150}/I_{100}   [T = 17 ^{o}C]");
    tl->DrawLatex(0.72, y, Form("%.2f", variation_17));
    c1_3->cd(2);
  }

  sprintf(fname, "%s/summaryTest.txt", dirName);
  sumWrite = fopen(fname, "a");
  fputs(Form("TBM1 %i\n", tbm1), sumWrite);
  fputs(Form("TBM2 %i\n", tbm2), sumWrite);
  fputs(Form("I 150 %f \n", iv150_17), sumWrite);
  fputs(Form("I150/I100 %f \n", variation_17), sumWrite);
  fputs(Form("iv datapoints %i \n", i), sumWrite);

//   c1->cd(4);
//   mAddr->DrawCopy("colz");
//   mAddr->SetMaximum(1.);
//   mAddr->SetMinimum(0.);
//   tl->DrawLatex(0.1, 0.92, "Address decoding map");



  c1_4->Divide(4,1);
  qualification(dirName, fit, fitEntries);
  

  for (int i = 0; i < 4; i++) {

  // makePlot(TH1 *h, const char *title, int pad, double Ymin, double Ymax, double Ylimit)
    makePlot(fit[i], fitNames[i].Data(), i+1, 0, max[i], limitB[i], limitC[i]); 
  
  }

  int grad(0);

  FILE *missingData; 
  sprintf(fname, "%s/comment_3.txt", dirName);
  missingData = fopen(fname, "r");

  if ( missingData ) {

    printf("\nmoduleSummary> !!!!!!!!!  ----> Found file for missing data: comment_3.txt => GRADE C!\n\n");
    grad = 3;
    fclose(missingData);

  } else {
  
    grad = grading(badRocs, iv150_17, variation_17, fit, fitEntries, limitB, limitC, test);
  }
  
  c1_3->cd(3);    
  tl->SetTextSize(0.09);
  tl->SetTextFont(22);
 
  if (grad == 1) {  tl->DrawLatex(0.6, 0.92, "GRADE:  A");  fputs("Grade A\n", sumWrite); }
  if (grad == 2) {  tl->DrawLatex(0.6, 0.92, "GRADE:  B");  fputs("Grade B\n", sumWrite); }
  if (grad == 3) {  tl->DrawLatex(0.6, 0.92, "GRADE:  C");  fputs("Grade C\n", sumWrite); }  


  sprintf(fname, "%s/gradingTest.txt", dirName);
  gradWrite = fopen(fname, "a");
 
  if (!gradWrite)
  {
    printf("\nmoduleSummary> !!!!!!!!!  ----> File %s does not exist yet...\n", fname);
    printf("moduleSummary> !!!!!!!!!  ----> Grading data could not be written to file!\n\n");
  }
  else
  {

    fputs(Form("Noise %i %i\n", fitsProblemB[0], fitsProblemC[0]), gradWrite);
    fputs(Form("VcalThrWidth %i %i\n", fitsProblemB[1], fitsProblemC[1]), gradWrite);
    fputs(Form("RelGainWidth %i %i\n", fitsProblemB[2], fitsProblemC[2]), gradWrite);
    fputs(Form("PedSpread %i %i\n", fitsProblemB[3], fitsProblemC[3]), gradWrite);
    fputs(Form("I150V %i %i\n", currentProblemB, currentProblemC), gradWrite);
    fputs(Form("Iratio %i 0\n",  slopeProblemB), gradWrite);
  }
  
  c1->SaveAs(Form("%s/moduleSummary_%s%s.ps", dirName, waf, test));
  c1->SaveAs(Form("%s/%s%s.gif", dirName, waf, test));

  printf("\nmoduleSummary> ................................................ finished\n");
}
void makeSVfitMEM_massPlots_from13()
{
  gROOT->SetBatch(true);

  TH1::AddDirectory(false);

  std::vector<int> massPoints;
  massPoints.push_back(90);
  massPoints.push_back(125);
  massPoints.push_back(200);
  massPoints.push_back(300);
  massPoints.push_back(500);
  massPoints.push_back(800);
  
  std::vector<std::string> histograms;
  histograms.push_back("mVis");
  histograms.push_back("mTauTau");

  std::map<std::string, std::string> xAxisTitles; // key = histogram
  xAxisTitles["mVis"]    = "m_{vis} [GeV]";
  xAxisTitles["mTauTau"] = "m_{#tau#tau} [GeV]";

  std::map<std::string, std::string> yAxisTitles; // key = histogram
  yAxisTitles["mVis"]    = "dN/dm_{vis} [1/GeV]";
  yAxisTitles["mTauTau"] = "dN/dm_{#tau#tau} [1/GeV]";
  
  std::string inputFilePath = "/home/lucia/SVfitPerformanceStudiesII/CMSSW_7_6_3/src/TauAnalysis/SVfitPerformanceStudies/test/plot/";
  std::map<std::string, std::string> inputFileNames_emu; // key = histogram
  inputFileNames_emu["mVis"]       = "plot_13_lin_emu_smeared.root";
  inputFileNames_emu["mTauTau"]    = "plot_13_lin_emu_smeared.root";
  std::map<std::string, std::string> inputFileNames_muhad; // key = histogram
  inputFileNames_muhad["mVis"]     = "plot_13_lin_muhad_smeared.root";
  inputFileNames_muhad["mTauTau"]  = "plot_13_lin_muhad_smeared.root";
  std::map<std::string, std::string> inputFileNames_hadhad; // key = mhistogram
  inputFileNames_hadhad["mVis"]    = "plot_13_lin_hadhad_smeared.root";
  inputFileNames_hadhad["mTauTau"] = "plot_13_lin_hadhad_smeared.root";

  std::string outputFilePath = "/home/lucia/SVfitPerformanceStudiesII/CMSSW_7_6_3/src/TauAnalysis/SVfitPerformanceStudies/test/plot/finalplots/";
  std::map<std::string, std::string> outputFileNames_emu; // key = histogram
  outputFileNames_emu["mVis"]       = "svFitPerformance_emu_visMass.pdf";
  outputFileNames_emu["mTauTau"]    = "svFitPerformance_emu_svFitMass.pdf";
  std::map<std::string, std::string> outputFileNames_muhad; // key = histogram
  outputFileNames_muhad["mVis"]     = "svFitPerformance_muhad_visMass.pdf";
  outputFileNames_muhad["mTauTau"]  = "svFitPerformance_muhad_svFitMass.pdf";
  std::map<std::string, std::string> outputFileNames_hadhad; // key = histogram
  outputFileNames_hadhad["mVis"]    = "svFitPerformance_hadhad_visMass.pdf";
  outputFileNames_hadhad["mTauTau"] = "svFitPerformance_hadhad_svFitMass.pdf";
  
  for ( std::vector<std::string>::const_iterator histogram = histograms.begin();
	histogram != histograms.end(); ++histogram ) {
    std::string xAxisTitle_emu        = xAxisTitles[*histogram];
    std::string yAxisTitle_emu        = yAxisTitles[*histogram];
    std::string inputFileName_emu     = inputFileNames_emu[*histogram];
    std::string outputFileName_emu    = outputFileNames_emu[*histogram];
    makePlot(inputFilePath, "emu_smeared", *histogram, "e#mu", xAxisTitle_emu, yAxisTitle_emu, inputFileName_emu, outputFilePath, outputFileName_emu);
    std::string xAxisTitle_muhad      = xAxisTitles[*histogram];
    std::string yAxisTitle_muhad      = yAxisTitles[*histogram];
    std::string inputFileName_muhad   = inputFileNames_muhad[*histogram];
    std::string outputFileName_muhad  = outputFileNames_muhad[*histogram];
    makePlot(inputFilePath, "muhad_smeared", *histogram, "#mu#tau_{h}", xAxisTitle_muhad, yAxisTitle_muhad, inputFileName_muhad, outputFilePath, outputFileName_muhad);
    std::string xAxisTitle_hadhad     = xAxisTitles[*histogram];
    std::string yAxisTitle_hadhad     = yAxisTitles[*histogram];
    std::string inputFileName_hadhad  = inputFileNames_hadhad[*histogram];
    std::string outputFileName_hadhad = outputFileNames_hadhad[*histogram];
    makePlot(inputFilePath, "hadhad_smeared", *histogram, "#tau_{h}#tau_{h}", xAxisTitle_hadhad, yAxisTitle_hadhad, inputFileName_hadhad, outputFilePath, outputFileName_hadhad);
  }
}
void makePostFitPlots_1l_2tau()
{
  gROOT->SetBatch(true);

  TH1::AddDirectory(false);

  std::vector<std::string> categories;
  categories.push_back("ttH_1l_2tau_prefit");
  categories.push_back("ttH_1l_2tau_postfit");

  std::string inputFilePath = string(getenv("CMSSW_BASE")) + "/src/CombineHarvester/ttH_htt/";
  std::map<std::string, std::string> inputFileNames; // key = category
  inputFileNames["ttH_1l_2tau_prefit"]  = "ttH_1l_2tau_shapes.root";
  inputFileNames["ttH_1l_2tau_postfit"] = "ttH_1l_2tau_shapes.root";
  
  for ( std::vector<std::string>::const_iterator category = categories.begin();
	category != categories.end(); ++category ) {
    std::string inputFileName_full = Form("%s%s", inputFilePath.data(), inputFileNames[*category].data());
    TFile* inputFile = new TFile(inputFileName_full.data());
    if ( !inputFile ) {
      std::cerr << "Failed to open input file = " << inputFileName_full << " !!" << std::endl;
      assert(0);
    }

    TH1* histogramTTH_hww = loadHistogram(inputFile, *category, "ttH_hww");
    TH1* histogramTTH_hzz = loadHistogram(inputFile, *category, "ttH_hzz");
    TH1* histogramTTH_htt = loadHistogram(inputFile, *category, "ttH_htt");
    TString histogramNameTTH = TString(histogramTTH_hww->GetName()).ReplaceAll("_hww", "_sum");
    TH1* histogramTTH = (TH1*)histogramTTH_hww->Clone(histogramNameTTH.Data());
    histogramTTH->Add(histogramTTH_hzz);
    histogramTTH->Add(histogramTTH_htt);

    TH1* histogramData = loadHistogram(inputFile, *category, "data_obs");

    TH1* histogramTT = loadHistogram(inputFile, *category, "TT");

    TH1* histogramTTW = loadHistogram(inputFile, *category, "TTW");
    TH1* histogramTTZ = loadHistogram(inputFile, *category, "TTZ");
    TString histogramNameTTV = "TTV";
    TH1* histogramTTV = (TH1*)histogramTTW->Clone(histogramNameTTV.Data());
    histogramTTV->Add(histogramTTZ);

    TH1* histogramEWK = loadHistogram(inputFile, *category, "EWK");

    TH1* histogramRares = loadHistogram(inputFile, *category, "Rares");

    TH1* histogramBgrSum = loadHistogram(inputFile, *category, "TotalBkg");
    TH1* histogramBgrUncertainty = (TH1*)histogramBgrSum->Clone("TotalBkgErr");

    std::string outputFileName = Form("plots/makePostFitPlots_%s.pdf", category->data());
    makePlot(800, 900,
	     histogramTTH,
	     histogramData, 
	     histogramTT,
	     histogramTTV,
	     histogramEWK,
	     histogramRares,
	     histogramBgrSum,
	     histogramBgrUncertainty,	
	     "m_{#tau#tau}^{vis}", 0.9,
	     true, 3.e-4, 3.e0, "Events", 0.9,
	     outputFileName);

    delete histogramTTH;
    delete histogramTTV;
    delete histogramBgrUncertainty;

    delete inputFile;
  }
}
void wikiPlot()
/* wikiPlot - Quick plots of maps vs. each other. */
{
boolean gotDir = cgiVarExists("contigDir");
double step;

contigDir = cgiUsualString("contigDir", contigDir);
mapX = cgiUsualString("mapX", mapX);
mapY = cgiUsualString("mapY", mapY);
pix = cgiUsualInt("pix", pix);
xOff = cgiUsualDouble("xOff", xOff);
yOff = cgiUsualDouble("yOff", yOff);
zoom = cgiUsualDouble("zoom", zoom);
step = 0.1 * 1/zoom;

if (cgiVarExists("boxOut"))
    {
    double invZoom = 1.0/zoom;
    double xCen = xOff + invZoom*0.5;
    double yCen = yOff + invZoom*0.5;
    zoom /= 2;
    invZoom = 1.0/zoom;
    xOff = xCen - invZoom*0.5;
    yOff = yCen - invZoom*0.5;
    }
else if (cgiVarExists("boxUp"))
    yOff -= step;
else if (cgiVarExists("boxDown"))
    yOff += step;
else if (cgiVarExists("boxLeft"))
    xOff -= step;
else if (cgiVarExists("boxRight"))
    xOff += step;
else if (cgiVarExists("boxUpLeft"))
    {
    yOff -= step;
    xOff -= step;
    }
else if (cgiVarExists("boxUpRight"))
    {
    yOff -= step;
    xOff += step;
    }
else if (cgiVarExists("boxDownLeft"))
    {
    yOff += step;
    xOff -= step;
    }
else if (cgiVarExists("boxDownRight"))
    {
    yOff += step;
    xOff += step;
    }
else if (cgiVarExists("unzoom"))
    {
    xOff = yOff = -0.05;
    zoom = 0.9;
    }

printf("<FORM ACTION=\"../cgi-bin/wikiPlot\" METHOD=\"GET\">\n");
printf("<TABLE BORDER=0 WIDTH=\"100%%\">\n");
printf("<TR>\n");
printf("<TD WIDTH=\"78%%\">\n");
printf("<B>Wiki Plotter</B><BR>\n");
printf("<B>Contig: </B>");
cgiMakeTextVar("contigDir", contigDir, 0);
if (gotDir)
    {
    cgiMakeButton("refresh", "refresh");
    }
else
    cgiMakeButton("submit", "submit");
printf("<BR>\n");
printf("<B>Map X: </B>");
cgiMakeTextVar("mapX", mapX, 12);
printf("<B>Map Y: </B>");
cgiMakeTextVar("mapY", mapY, 12);
printf("<B>Pixels: </B>");
cgiMakeIntVar("pix", pix, 4);
printf("</TD>\n");
printf("<TD WIDTH=\"22%%\">\n");
if (gotDir)
    printBox();
printf("</TD>\n");
printf("</TR>\n");
printf("</TABLE>\n");

if (gotDir)
    {
    char xFile[512], yFile[512];
    struct hash *xHash = NULL, *yHash = NULL;
    struct clonePos *xList = NULL, *yList = NULL;
    sprintf(xFile, "%s/%s", contigDir, mapX);
    sprintf(yFile, "%s/%s", contigDir, mapY);
    loadMaps(xFile, yFile, &xList, &yList, &xHash, &yHash);
    makePlot(xList, yList, yHash);
    }

/* Save hidden vars. */
    {
    char buf[256];
    sprintf(buf, "%f", zoom);
    cgiMakeHiddenVar("zoom", buf);
    sprintf(buf, "%f", xOff);
    cgiMakeHiddenVar("xOff", buf);
    sprintf(buf, "%f", yOff);
    cgiMakeHiddenVar("yOff", buf);
    }
printf("</FORM>\n");
}
void makePostFitPlots_3l_1tau()
{
  gROOT->SetBatch(true);

  TH1::AddDirectory(false);

  std::vector<std::string> categories;
  categories.push_back("ttH_3l_1tau_prefit");
  categories.push_back("ttH_3l_1tau_postfit");

  std::string inputFilePath = string(getenv("CMSSW_BASE")) + "/src/CombineHarvester/ttH_htt/limits/";
  std::map<std::string, std::string> inputFileNames; // key = category
  inputFileNames["ttH_3l_1tau_prefit"]  = "ttH_3l_1tau_mvaDiscr_3l_2016_shapes.root";
  inputFileNames["ttH_3l_1tau_postfit"] = "ttH_3l_1tau_mvaDiscr_3l_2016_shapes.root";
  
  bool doKeepBlinded = true;
  //bool doKeepBlinded = false;

  for ( std::vector<std::string>::const_iterator category = categories.begin();
	category != categories.end(); ++category ) {
    std::string inputFileName_full = Form("%s%s", inputFilePath.data(), inputFileNames[*category].data());
    TFile* inputFile = new TFile(inputFileName_full.data());
    if ( !inputFile ) {
      std::cerr << "Failed to open input file = " << inputFileName_full << " !!" << std::endl;
      assert(0);
    }

    TH1* histogram_data = loadHistogram(inputFile, *category, "data_obs");
    std::cout << "histogram_data = " << histogram_data << ":" << std::endl;
    if ( !doKeepBlinded ) {
      dumpHistogram(histogram_data);
    }


    TH1* histogram_ttH_htt = loadHistogram(inputFile, *category, "ttH_htt");
    TH1* histogram_ttH_hww = loadHistogram(inputFile, *category, "ttH_hww");
    TH1* histogram_ttH_hzz = loadHistogram(inputFile, *category, "ttH_hzz");
    std::cout << "histogram_ttH: htt = " << histogram_ttH_htt << ", hww = " << histogram_ttH_hww << ", hzz = " << histogram_ttH_hzz << std::endl;
    TString histogramName_ttH = TString(histogram_ttH_htt->GetName()).ReplaceAll("_htt", "_sum");
    TH1* histogram_ttH = (TH1*)histogram_ttH_htt->Clone(histogramName_ttH.Data());
    histogram_ttH->Add(histogram_ttH_hww);
    histogram_ttH->Add(histogram_ttH_hzz);
    makeBinContentsPositive(histogram_ttH);
    std::cout << "histogram_ttH = " << histogram_ttH << ":" << std::endl;
    dumpHistogram(histogram_ttH);

    TH1* histogram_ttZ = loadHistogram(inputFile, *category, "TTZ");
    std::cout << "histogram_ttZ = " << histogram_ttZ << std::endl;
    makeBinContentsPositive(histogram_ttZ);
    dumpHistogram(histogram_ttZ);
    
    TH1* histogram_ttW = loadHistogram(inputFile, *category, "TTW");
    std::cout << "histogram_ttW = " << histogram_ttW << std::endl;
    makeBinContentsPositive(histogram_ttW);
    dumpHistogram(histogram_ttW);
    
    TH1* histogram_EWK = loadHistogram(inputFile, *category, "EWK");    
    std::cout << "histogram_EWK = " << histogram_EWK << std::endl;
    makeBinContentsPositive(histogram_EWK);
    dumpHistogram(histogram_EWK);

    TH1* histogram_Rares = loadHistogram(inputFile, *category, "Rares");
    std::cout << "histogram_Rares = " << histogram_Rares << std::endl;
    makeBinContentsPositive(histogram_Rares);
    dumpHistogram(histogram_Rares);

    TH1* histogram_fakes = loadHistogram(inputFile, *category, "fakes_data");
    std::cout << "histogram_fakes = " << histogram_fakes << std::endl;
    makeBinContentsPositive(histogram_fakes);
    dumpHistogram(histogram_fakes);

    TH1* histogramSum_mcBgr = loadHistogram(inputFile, *category, "TotalBkg");
    std::cout << "histogramSum_mcBgr = " << histogramSum_mcBgr << std::endl;
    makeBinContentsPositive(histogramSum_mcBgr);
    dumpHistogram(histogramSum_mcBgr);
    TH1* histogramSum_mc = (TH1*)histogramSum_mcBgr->Clone("histogramSum_mc");
    histogramSum_mc->Add(histogram_ttH);
    std::cout << "histogramSum_mc = " << histogramSum_mc << std::endl;
    TH1* histogramErr_mc = (TH1*)histogramSum_mc->Clone("TotalBkgErr");

    std::string outputFilePath = string(getenv("CMSSW_BASE")) + "/src/CombineHarvester/ttH_htt/macros";
    std::string outputFileName = Form("%s/plots/makePostFitPlots_%s.pdf", outputFilePath.data(), category->data());
    makePlot(histogram_data, doKeepBlinded,
	     histogram_ttH, 
	     histogram_ttZ,
	     histogram_ttW,
	     histogram_EWK,
	     histogram_Rares,
	     histogram_fakes,
	     histogramSum_mc,
	     histogramErr_mc,		
	     "MVA Discriminator", 
	     "Events", 1.01e-2, 1.99e+1, 
	     true,
	     "3l_1tau",
	     outputFileName,
	     true);

    delete histogram_ttH;
    delete histogramErr_mc;
    delete inputFile;
  }
}
Exemplo n.º 9
0
void makeAllPlots( analysisType ana, bool plotData )
{
  TH1::SetDefaultSumw2();

  bool electrons=false;
  if (ana==_2eTrack) electrons=true;

  TString anaType(getTypeName(ana));

  // Get lumi
  // If not plotting any data, normalise arbitrarily
  float lumi = 5000;
  if ( plotData ) {
    lumi = getLumi(electrons);
    std::cout << "===============================" << std::endl;
    std::cout << "Total lumi in data : " << lumi/1000 << " /fb" << std::endl;
    std::cout << "===============================" << std::endl;
  }
  else std::cout << "Not plotting data, will normalise to lumi of " << lumi/1000 << " /fb" << std::endl;

  TFile * outputFile = new TFile("output_"+anaType+".root", "RECREATE");

  // makePlot function
  // Arguments :
  ////
  //// TString : Name of histogram in root file
  //// TFile : Output file
  //// TString : String version of anaType_
  //// TString : x axis label
  //// double : x axis min
  //// double x axis max
  //// double : y axis min
  //// double : y axis max
  //// bool : log y (true) or not (false)
  //// float : lumi to scale histograms to
  //// bool : Plot data (true) or not (false)

  // Dilepton Inverted lifetime cuts
  makePlot("Mass_removedLifetimeCuts", outputFile, anaType,
      "mass[Gev/c^{2}]", 0, 500, 0.1, 10000000, true,
      lumi, plotData );

  makePlot("nMinus1_isolationLeptonH_removedLifetimeCuts", outputFile, anaType,
      "#Sigma p_{t}", 0, 20, 0.1, 10000000, true,
      lumi, plotData );

  makePlot("nMinus1_relIsolationLeptonH_removedLifetimeCuts", outputFile, anaType,
      "#Sigma p_{t}/p_{t}^{lepton}", 0, 0.2, 1, 5000000, true,
      lumi, plotData );

  makePlot("leptonLPt_removedLifetimeCuts", outputFile, anaType,
      "Lepton L p_{t}", 0, 100, 0.1, 5000000, true,
      lumi, plotData );

  makePlot("leptonHPt_removedLifetimeCuts", outputFile, anaType,
      "Lepton H p_{t}", 0, 100, 0.1, 5000000, true,
      lumi, plotData );

  makePlot("leptonLEta_removedLifetimeCuts", outputFile, anaType,
      "Lepton L #eta", -3, 3, 0.1, 5000000, true,
      lumi, plotData );

  makePlot("leptonHEta_removedLifetimeCuts", outputFile, anaType,
      "Lepton H #eta", -3, 3, 0.1, 5000000, true,
      lumi, plotData );

  makePlot("leptonLCaloMatchDeltaR_removedLifetimeCuts", outputFile, anaType,
      "Lepton L Calo Match #Delta R", 0, 0.1, 0.1, 5000000, true,
      lumi, plotData );

  makePlot("leptonHCaloMatchDeltaR_removedLifetimeCuts", outputFile, anaType,
      "Lepton H Calo Match #Delta R", 0, 0.1, 0.1, 5000000, true,
      lumi, plotData );

  makePlot("LxySig_removedLifetimeCuts", outputFile, anaType,
      "L_{xy}/#sigma_{xy}", -20, 5, 0.1, 1000000, true,
      lumi, plotData, true );

  makePlot("leptonAbsD0Sig_removedLifetimeCuts", outputFile, anaType,
      "Minimum Lepton d0/#sigma_{d}", 0, 3.5, 0.1, 1000000, true,
      lumi, plotData, true );


  ///////////////////////////////
  // No looking at signal region!
  ///////////////////////////////

  // Final cuts
  makePlot("Mass_finalCuts", outputFile, anaType,
      "mass[Gev/c^{2}]", 0, 500, 0.01, 5000, true,
      lumi, false );

  makePlot("Lxy_finalCuts", outputFile, anaType,
      "Candidate L_{xy} [cm]", 0, 50, 0.01, 5000, true,
      lumi, false );

  makePlot("nRecoPV_finalCuts", outputFile, anaType,
      "Number reco PV",0,50,0.1,1000000, true,
      lumi, false);

  // n-1 final cuts

  makePlot("nMinus1_LxySig_finalCuts", outputFile, anaType,
      "Candidate L_{xy}/#sigma_{xy}", 0, 30, 0.01, 5000, true,
      lumi, false );

  makePlot("nMinus1_LxySig_removeDeltaPhi_finalCuts", outputFile, anaType,
      "Candidate L_{xy}/#sigma_{xy}", -30, 0, 0.01, 5000, true,
      lumi, true );

  makePlot("nMinus1_vertexChi2_finalCuts", outputFile, anaType,
      "Candidate Vertex #Chi^2", 0, 20, 0.1, 5000, true,
      lumi, false );

  makePlot("nMinus1_deltaPhi_finalCuts", outputFile, anaType,
      "Candidate #Delta#Phi", 0, 1, 0.1, 5000, true,
      lumi, false );

  makePlot("nMinus1_leptonAbsD0Sig_finalCuts", outputFile, anaType,
      "Minimum Lepton d0/#sigma_{d}", 0, 20, 0.1, 5000, true,
      lumi, false );

  makePlot("nMinus1_leptonCaloMatchDeltaR_finalCuts", outputFile, anaType,
      "Maximum Lepton Calo Match #Delta R", 0, 0.1, 0.1, 5000000, true,
      lumi, false );

  makePlot("nMinus1_leptonCaloMatchDeltaEta_finalCuts", outputFile, anaType,
      "Maximum Lepton Calo Match #Delta #eta", 0, 0.1, 0.1, 5000000, true,
      lumi, false );

  makePlot("nMinus1_leptonCaloMatchDeltaPhi_finalCuts", outputFile, anaType,
      "Maximum Lepton Calo Match #Delta #phi", 0, 0.1, 0.1, 5000000, true,
      lumi, false );

  makePlot("nMinus1_leptonTrackPt_finalCuts", outputFile, anaType,
      "Minimum Lepton Track p_{t}", 0, 150, 0.1, 5000000, true,
      lumi, false );

  // Event histograms
  makePlot("nRecoPV", outputFile, anaType,
      "Number reco PV",0,50,0,320000, false,
      lumi, true);


  //  // Signal only plots
  //  makeSignalPlots("nMinus1_isolationLeptonH_finalCuts_genMatched",outputFile, anaType,
  //                  "#Sigma p_{t}", 0, 20, 0.1, 10000000, true);
  //
  //  makeSignalPlots("nMinus1_relIsolationLeptonH_finalCuts_genMatched",outputFile, anaType,
  //                    "#Sigma p_{t}/p_{t}^{lepton}", 0, 0.2, 0.1, 10000000, true);

  // Make 2D plots of isolation vs pileup
  makeIsoPlots("nMinus1_isolationLeptonL_vsPU_finalCuts_genMatched", outputFile, anaType,
      "# reco PV", 0, 50, "#Sigma p_{t} [GeV]", 0, 10, false );

  makeIsoPlots("nMinus1_isolationLeptonH_vsPU_finalCuts_genMatched", outputFile, anaType,
      "# reco PV", 0, 50, "#Sigma p_{t} [GeV]", 0, 10, false );

  makeIsoPlots("nMinus1_relIsolationLeptonL_vsPU_finalCuts_genMatched", outputFile, anaType,
      "# reco PV", 0, 50, "#Sigma p_{t}/p^{lepton L}_{t}", 0, 10, false );

  makeIsoPlots("nMinus1_relIsolationLeptonH_vsPU_finalCuts_genMatched", outputFile, anaType,
      "# reco PV", 0, 50, "#Sigma p_{t}/p^{lepton H}_{t}", 0, 10, false );

  outputFile->Write();
  outputFile->Close();
}