예제 #1
0
파일: QA.C 프로젝트: ktf/AliPhysics
void QAcentrality(const Char_t *fdata)
{
  style();

  TFile *fin = TFile::Open(fdata);
  TList *lin = (TList *)fin->Get("clist");
  lin->ls();
  TH1 *hin = (TH1 *)lin->FindObject("EvCentrDist");
  Float_t sum = 1.2 * hin->Integral(hin->FindBin(0.1), hin->FindBin(79.9));
  hin->Scale(1. / sum);
  SetHistoStyle(hin, 20, kRed+1);
  TCanvas *c = new TCanvas("cQAcentrality", "cQAcentrality", 800, 800);
  TH1 * hfr = c->DrawFrame(0., 0.005, 100., 0.015);
  hfr->SetTitle(";centrality percentile;events");
  hin->Draw("same");
  c->SaveAs(canvasPrefix+"centrality.pdf");

  TH2 *hinv0 = (TH2 *)lin->FindObject("V0");
  TCanvas *cv0 = new TCanvas("cQAcentralityV0", "cQAcentralityV0", 800, 800);
  cv0->SetLogx();
  cv0->SetLogz();
  //  TH1 * hfrv0 = cv0->DrawFrame(100., -0.5, 50000., 10.5);
  // DrawBinLabelsY(hfrv0, kTRUE);
  // hfrv0->SetTitle(";V0 signal;");
  //hinv0->Draw("same,col");
  hinv0->Draw("col");
  cv0->SaveAs(canvasPrefix+"centralityV0.pdf");
}
예제 #2
0
void AnaCombineEvH()
{
  TFile *file = TFile::Open("AnalysisResults_EmcalEvH.root", "READ");
  TList *list = (TList*)file->Get("listEmcalEvH");
  file->Close();
//=============================================================================

  TH2D *hist2 = 0;
  TH2D *hCentMtCh = 0;
  TH2D *hMtChMtEm = 0;
  for (Int_t i=0; i<4; i++) {
    hist2 = (TH2D*)list->FindObject(Form("hCentMtCh_%d",i));
    if (i==0) { hCentMtCh = (TH2D*)hist2->Clone("hCentMtCh"); hCentMtCh->Reset(); } hCentMtCh->Add(hist2); hist2 = 0;

    hist2 = (TH2D*)list->FindObject(Form("hMtChMtEm_%d",i));
    if (i==0) { hMtChMtEm = (TH2D*)hist2->Clone("hMtChMtEm"); hMtChMtEm->Reset(); } hMtChMtEm->Add(hist2); hist2 = 0;
  }
//=============================================================================

/*file = TFile::Open("AnalysisResults_EmcalEvH.root", "UPDATE");
  hCentMtCh->Write();
  hMtChMtEm->Write();
  file->Close();*/
//=============================================================================

  return;
}
예제 #3
0
파일: qtroot.cpp 프로젝트: Dr15Jones/root
void ApplicationWindow::closeEvent( QCloseEvent* ce )
{
   int testvar =  QMessageBox::information( 0, "Qt Application Example",
                                            "Do you want to close QtRoot? "
                                            "", "Save", "Cancel", "Close",
                                            0, 1 );
   switch (testvar) {
      case 0: // here we should save
         // data
         save();
         ce->accept();
         break;
      case 1:
      default: // just for sanity
         ce->ignore();
         break;
      case 2: // Here i close all windows
         // do now an explicit release of Histogram's
         // child windows
         TList *lc = (TList*)gROOT->GetListOfCanvases();
         TObject *fitpanel  =  lc->FindObject("R__fitpanel");
         TObject *drawpanel =  lc->FindObject("R__drawpanelhist");
         if (fitpanel) {
            qDebug("detecting fitpanel %x \n",fitpanel);
            delete fitpanel;
         }
         if (drawpanel) {
            qDebug("detecting drawpanel %x \n",drawpanel);
            delete drawpanel;
         }
         ce->accept();
         break;
   }
}
예제 #4
0
int countEntries(TH1D* inComing, double ptMin, double ptMax, int fileNum)
{
  if(fileNum < 0 || fileNum > 4)
    {
      cout << "number not in the cut range" << endl;
      return;
    }
  TFile *myFile = TFile::Open("GammaCalo_MC_LHC15g2_60.root");
  TList *myL = (TList*)myFile->Get("GammaCalo;1");
  
  TString cutString[5];
  cutString[0] = "00000113_1111121063032220000_0163103100000050";
  cutString[1] = "00000013_1111121063032220000_0163103100000050";
  cutString[2] = "00052013_1111121063032220000_0163103100000050";
  cutString[3] = "00083013_1111121063032220000_0163103100000050";
  cutString[4] = "00085013_1111121063032220000_0163103100000050";
  
  //cout << "Cut selection: " << cutString[fileNum] << endl;
 
  TString folderString = "Cut Number " + cutString[fileNum];
  TList* cut_folder = (TList*)myL->FindObject(folderString);

  TString esdString = cutString[fileNum] + " ESD histograms";
  TList* esdHists = (TList*)cut_folder->FindObject(esdString);

  TH2F* hist = (TH2F*)esdHists->FindObject("ESD_Mother_InvMass_Pt");
  TH1D* pi0WBg = hist->ProjectionX("pi0WBg",ptBinMin,ptBinMax,"");
  int entries = pi0WBg->GetEntries();
  cout << "Num entries: " << entries << endl;
  return entries;
}
예제 #5
0
void PlotMinEtFromSim(Bool_t isPhos = kFALSE){
  gStyle->SetOptTitle(0);
  gStyle->SetOptStat(0);
  gStyle->SetOptFit(0);
  Float_t min = 0;
  float max = 1;
  TString filename, detname;
  if(isPhos){
    min = 0.655;
    max = 0.785;
    detname = "PHOS";
    filename = "rootFiles/LHC11a10a_bis/Et.ESD.simPbPb.PHOS.LHC11a10a_bis.Run139465.root";
  }
  else{
    min = 0.58;
    max = 0.725;
    filename = "rootFiles/LHC11a10a_bis/Et.ESD.simPbPb.EMCal.LHC11a10a_bis.Run139465.root";
    detname = "EMCal";
  }
  
  TFile *f = TFile::Open(filename, "READ");
  TList *l = dynamic_cast<TList*>(f->Get("out1"));
  TH1F *fHistSimulatedGammaEnergyAboveThreshold = l->FindObject("fHistSimulatedGammaEnergyAboveThreshold");
  TH1F *fHistSimulatedGammaEnergy = l->FindObject("fHistSimulatedGammaEnergy");
  SetStyles(fHistSimulatedGammaEnergyAboveThreshold,20,TColor::kRed);
  fHistSimulatedGammaEnergyAboveThreshold->Divide(fHistSimulatedGammaEnergy);

    TCanvas *c1 = new TCanvas("c1","Simulation",600,400);
    c1->SetTopMargin(0.02);
    c1->SetRightMargin(0.03);
    c1->SetLeftMargin(0.11745);
    c1->SetBottomMargin(0.11745);
    c1->SetBorderSize(0);
    c1->SetFillColor(0);
    c1->SetFillColor(0);
    c1->SetBorderMode(0);
    c1->SetFrameFillColor(0);
    c1->SetFrameBorderMode(0);
    fHistSimulatedGammaEnergyAboveThreshold->SetMaximum(max +0.1);
    fHistSimulatedGammaEnergyAboveThreshold->SetMinimum(min-0.1);
    fHistSimulatedGammaEnergyAboveThreshold->GetXaxis()->SetTitle("Centrality bin");
    fHistSimulatedGammaEnergyAboveThreshold->GetYaxis()->SetTitle("f_{minEt}");
    fHistSimulatedGammaEnergyAboveThreshold->GetYaxis()->SetLabelSize(0.06);
    fHistSimulatedGammaEnergyAboveThreshold->GetXaxis()->SetLabelSize(0.06);
    fHistSimulatedGammaEnergyAboveThreshold->GetYaxis()->SetTitleSize(0.06);
    fHistSimulatedGammaEnergyAboveThreshold->GetXaxis()->SetTitleSize(0.06);
    fHistSimulatedGammaEnergyAboveThreshold->Draw();
    TLine *lineMin = new TLine(-0.5,min,19.5,min);
    lineMin->Draw();
    TLine *lineMax = new TLine(-0.5,max,19.5,max);
    lineMax->Draw();
    lineMin->SetLineColor(TColor::kBlue);
    lineMax->SetLineColor(TColor::kBlue);
    lineMin->SetLineStyle(2);
    lineMax->SetLineStyle(2);

    TString outfile = "/tmp/MinEtFromSim"+detname+".png";
    c1->SaveAs(outfile.Data());
}
예제 #6
0
파일: QA.C 프로젝트: ktf/AliPhysics
void QAvertex(const Char_t *fdata, const Char_t *fmc)
{
  style();

  TFile *fdtin = TFile::Open(fdata);
  TList *ldtin = (TList *)fdtin->Get("clist");
  TH2 *hdtin = (TH2 *)ldtin->FindObject("zv");
  TH1 *hdt = (TH1 *)ldtin->FindObject("zvNoSel");
  SetHistoStyle(hdt, 20, kRed+1);
  hdt->Scale(1. / hdt->Integral());

  TH1 *hdt0010 = hdtin->ProjectionX("hdt0010", 1, 4);
  SetHistoStyle(hdt0010, 20, kRed+1);
  hdt0010->Scale(1. / hdt0010->Integral());

  TH1 *hdt7080 = hdtin->ProjectionX("hdt7080", 11, 11);
  SetHistoStyle(hdt7080, 25, kAzure-3);
  hdt7080->Scale(1. / hdt7080->Integral());
  
  TFile *fmcin = TFile::Open(fmc);
  TList *lmcin = (TList *)fmcin->Get("clist");
  TH1 *hmc = (TH1 *)lmcin->FindObject("zvNoSel");
  SetHistoStyle(hmc, 25, kAzure-3);
  hmc->Scale(1. / hmc->Integral());

  TCanvas *c = new TCanvas("cVertex", "cVertex", 800, 800);
  TH1 * hfr = c->DrawFrame(-20., 0., 20., 0.1);
  hfr->SetTitle(";#it{z}_{vtx};");
  hdt0010->Draw("same");
  hdt7080->Draw("same");
  TLegend *legend = new TLegend(0.20, 0.18+0.60, 0.50, 0.30+0.60);
  legend->SetFillColor(0);
  legend->SetBorderSize(0);
  legend->SetTextFont(42);
  legend->SetTextSize(0.04);
  legend->AddEntry(hdt0010, "0-10%", "p");
  legend->AddEntry(hdt7080, "70-80%", "p");
  legend->Draw("same");
  c->SaveAs(canvasPrefix+"vertex.pdf");
  
  TCanvas *c1 = new TCanvas("cVertexDataMC", "cVertexDataMC", 800, 800);
  hfr = c1->DrawFrame(-20., 0., 20., 0.1);
  hfr->SetTitle(";#it{z}_{vtx};");
  hdt->Draw("same");
  hmc->Draw("same");
  legend = new TLegend(0.20, 0.18+0.60, 0.50, 0.30+0.60);
  legend->SetFillColor(0);
  legend->SetBorderSize(0);
  legend->SetTextFont(42);
  legend->SetTextSize(0.04);
  legend->AddEntry(hdt, "data", "p");
  legend->AddEntry(hmc, "Monte Carlo", "p");
  legend->Draw("same");
  c1->SaveAs(canvasPrefix+"vertexDataMC.pdf");
  
  //return 0;  
}
예제 #7
0
파일: QA.C 프로젝트: ktf/AliPhysics
void QAoccupancy(const Char_t *fdata, const Char_t *fmc)
{
  style();

  TFile *fdtin = TFile::Open(fdata);
  TList *ldtin = (TList *)fdtin->Get("clist");
  TH2 *hdtin = (TH2 *)ldtin->FindObject("NClustersSPD2");
  TProfile *pdtin = hdtin->ProfileY("pdtin_clusters");
  pdtin->SetMarkerStyle(20);
  pdtin->SetMarkerSize(2);
  pdtin->SetMarkerColor(kAzure-3);
  
  TFile *fmcin = TFile::Open(fmc);
  TList *lmcin = (TList *)fmcin->Get("clist");
  TH2 *hmcin = (TH2 *)lmcin->FindObject("NClustersSPD2");
  TProfile *pmcin = hmcin->ProfileY("pmcin_clusters");
  pmcin->SetMarkerStyle(25);
  pmcin->SetMarkerSize(2);
  pmcin->SetMarkerColor(kRed+1);

  TCanvas *c = new TCanvas("cOccupancy", "cOccupancy", 800, 800);
  c->SetLogy();
  TH1 * hfr = c->DrawFrame(-0.5, 2., 10.5, 500.);
  DrawBinLabelsX(hfr, kTRUE);
  hfr->SetTitle(";;#LT#it{N}_{clusters,SPD-1}#GT");
  pdtin->DrawCopy("same");
  pmcin->DrawCopy("same");
  TLegend *legend = new TLegend(0.20, 0.18, 0.50, 0.30);
  legend->SetFillColor(0);
  legend->SetBorderSize(0);
  legend->SetTextFont(42);
  legend->SetTextSize(0.04);
  legend->AddEntry(pdtin, "data", "pl");
  legend->AddEntry(pmcin, "Monte Carlo", "pl");
  legend->Draw("same");
  c->SaveAs(canvasPrefix+"occupancy.pdf");
  return;
  TCanvas *cr = new TCanvas("cOccupancyr", "cOccupancyr", 800, 800);
  // hfr = cr->DrawFrame(-0.5, 0.75, 10.5, 1.25);
  // DrawBinLabelsX(hfr, kTRUE);
  // hfr->SetTitle(";;#LT#it{N}_{clusters,SPD-1}#GT ratio");
  pdtin->SetLineColor(kAzure-3);
  pdtin->SetLineWidth(3);
  pdtin->Divide(pmcin);
  pdtin->Draw("same,histo"); 
  legend = new TLegend(0.505025, 0.760673, 0.805276, 0.930142);
  legend->SetFillColor(0);
  legend->SetBorderSize(0);
  legend->SetTextFont(42);
  legend->SetTextSize(0.04);
  legend->AddEntry(pdtin, "data / Monte Carlo", "l");
  legend->Draw("same");
  cr->SaveAs(canvasPrefix+"occupancyr.pdf");
  
}
Double_t MakeHistsForSlides(TString goodFile, TString badFile, TString rootFile)
{
  //Extracting the histogram
  TFile* f = TFile::Open(rootFile);
  TDirectoryFile* dirFile = (TDirectoryFile*)(f->Get("AliAnalysisTaskCalibEmcal"));
  TList* list = (TList*)(dirFile->Get("histogram"));
  TH2D* cellVAmplitude = (TH2D*)(list->FindObject("_histogram_cell_id_amplitude"));

    
  //Getting a Good Cell
  TH1D* goodC = new TH1D();
  ifstream myFile(goodFile);
  TString title = "";

  const int num = 500;

  if(myFile.is_open())
    {
      string line = "";
      std::getline(myFile,line);

      int index = 0;
      double chi2 = 0.0;
      
      while(myFile >> index >> chi2 && index < num)
	{
	  //cout << index << "\t" << chi2 << endl;
	  title = Form("Energy distribution of Cell %d",index);
	  TH1D* goodCell = cellVAmplitude->ProjectionY("goodCell", index+1,index+1);
	  goodC = (TH1D*)goodCell->Clone();
	}
    }
예제 #9
0
//_______________________________________________________________________________________
static void AddGrid()
{ 
  TVirtualPad *thisPad = qPad();

  if (thisPad) {
 
    TView *view = thisPad->GetView(); 
    if (!view) return;
    Double_t min[3],max[3];
    view->GetRange(min,max);

    TList *list      = thisPad->GetListOfPrimitives();
    TString histName = thisPad->GetName();
    TH2F *m_DummyHist = 0; 
    const Char_t *dummyName = "Axis3D";
    histName += dummyName;
    m_DummyHist = list->FindObject(histName.Data());
    if (!m_DummyHist) { 
      m_DummyHist = new TH2F(histName.Data(),"",1,min[0],max[0],1,min[1],max[1]);
      m_DummyHist->SetDirectory(0);
      m_DummyHist->Draw("surf,same");
    }
    m_DummyHist->GetXaxis()->SetLimits(min[0],max[0]);
    m_DummyHist->GetYaxis()->SetLimits(min[1],max[1]);
    m_DummyHist->GetZaxis()->SetLimits(min[2],max[2]);
 
    thisPad->Modified();
    thisPad->Update();
  }
}
예제 #10
0
TH2* Get2DHistogramfromList(TList *pidqalist, const char* listname, const char* histoname)
{
  TList *histolist = (TList *)pidqalist->FindObject(listname);
  if (!histolist) {printf(" list not found \n");  return 0x0; }
  TH2* histo = (TH2*)histolist->FindObject(histoname);
  //   if (!histo) {printf(" histogram not found \n");  return 0x0; }
  return histo;
}
예제 #11
0
int trackMatchingEff(TString file = "Et.ESD.simPbPb.PHOS.root")
{
  TFile *f = TFile::Open(file, "READ");
  if(!f)
  {
    std::cout << "Could not open file: " << file << " !" << std::endl;
    return -1;
  }
  
  TList *l = (TList*)(f->Get("out1"));
  
  if(!l)
  {
    std::cout << "Could not find list!" << std::endl;
    return -1;
  }
  
  TTree *primTree = (TTree*)(l->FindObject("fPrimaryTreePhosMC"));
  
  if(!primTree)
  {
    std::cout << "Could not find tree!" << std::endl;
    return -1;
  }
  
  
  TString emSelect = "(fPrimaryCode==22||fPrimaryCode==221||TMath::Abs(fPrimaryCode)==11)";
  TString chargeSelect = "(fPrimaryCharge!=0 && TMath::Abs(fPrimaryCode)!=11)";
  TString neutralSelect = "(!"+emSelect+")&&fPrimaryCharge==0&&(!fSecondary)"; 
  TString secondarySelect = "(fSecondary)";
  emSelect += "&&(!fSecondary)";
  chargeSelect += "&&(!fSecondary)";
  
  TString matchedSelect = "fPrimaryMatched==1&&";
  TString notMatchedSelect = "fPrimaryMatched==0&&";
  
  
  int n = primTree->Draw("fDepositedEt", notMatchedSelect+ emSelect);
  int nRemoved = primTree->Draw("fDepositedEt", matchedSelect + emSelect);
  std::cout << "EM: " << float(n)/(n+nRemoved) << std::endl;
  
  n = primTree->Draw("fDepositedEt", notMatchedSelect+ chargeSelect);
  nRemoved = primTree->Draw("fDepositedEt", matchedSelect + chargeSelect);
  std::cout << "Charged: " << float(n)/(n+nRemoved) << std::endl;

  n = primTree->Draw("fDepositedEt", notMatchedSelect+ neutralSelect);
  nRemoved = primTree->Draw("fDepositedEt", matchedSelect + neutralSelect);
  std::cout << "Neutral: " << float(n)/(n+nRemoved) << std::endl;

  n = primTree->Draw("fDepositedEt", notMatchedSelect+ secondarySelect);
  nRemoved = primTree->Draw("fDepositedEt", matchedSelect + secondarySelect);
  if(n+nRemoved) std::cout << "Secondary: " << float(n)/(n+nRemoved) << std::endl;
  else std::cout << "No secondaries" << std::endl;
  return 0;
  
  
}
예제 #12
0
Bool_t KVDMS::DirectoryContains(const Char_t* name, const Char_t* directory)
{
   // Returns true if the current directory (default) or the given directory
   // contains a file or a container with given name.

   TList* list = GetListing(directory);
   if (!list)
      return kFALSE;
   Bool_t ok = list->FindObject(name);
   delete list;
   return ok;
}
예제 #13
0
TH1D *
GetITSsaSpectrum(TFile *file, Int_t part, Int_t charge, Int_t cent, Bool_t cutSpectrum = kTRUE, Bool_t addSystematicError = kTRUE)
{
  /* pt limits for combined spectra */
  Double_t ptMin[AliPID::kSPECIES] = {0., 0., 0.1, 0.2, 0.3};
  Double_t ptMax[AliPID::kSPECIES] = {0., 0., 0.6, 0.5, 0.6};

  TList *list = (TList *)file->Get("output");
  TH1D *hin = (TH1D *)list->FindObject(Form("h_%s_%s_cen_%d", ITSsaPartName[part], ITSsaChargeName[charge], cent));
  if (!hin) return NULL;  

  /* get systematics */
  TFile *fsys = TFile::Open("SPECTRASYS_ITSsa.root");
  TH1 *hsys = fsys->Get(Form("hSystTot%s%s", ITSsaChargeName[charge], ITSsaPartName[part]));
			
  TH1D *h = new TH1D(Form("hITSsa_cent%d_%s_%s", cent, AliPID::ParticleName(part), chargeName[charge]), "ITSsa", NptBins, ptBin);
  Double_t pt, width, value, error, sys;
  Int_t bin;
  for (Int_t ipt = 0; ipt < NptBins; ipt++) {
    /* get input bin */
    pt = h->GetBinCenter(ipt + 1);
    width = h->GetBinWidth(ipt + 1);
    bin = hin->FindBin(pt);
    /* sanity check */
    if (TMath::Abs(hin->GetBinCenter(bin) - pt) > 0.001 ||
	TMath::Abs(hin->GetBinWidth(bin) - width) > 0.001)
      continue;
    /* check pt limits */
    if (cutSpectrum && (pt < ptMin[part] || pt > ptMax[part])) continue;
    /* copy bin */
    value = hin->GetBinContent(bin);
    error = hin->GetBinError(bin);
    /*** TEMP ADD SYS ***/
    if (addSystematicError) {
      sys = hsys->GetBinContent(bin) * value;
      error = TMath::Sqrt(error * error + sys * sys);
    }
    h->SetBinContent(ipt + 1, value);
    h->SetBinError(ipt + 1, error);
  }

  h->SetTitle("ITSsa");
  h->SetLineWidth(1);
  h->SetLineColor(1);
  h->SetMarkerStyle(20);
  h->SetMarkerColor(1);
  h->SetFillStyle(0);
  h->SetFillColor(0);

  return h;
}
예제 #14
0
//______________________________________________________________________________
TObject* GetHistogram(TFile* file, 
		      const Char_t* cutClass, 
		      const Char_t* histList, 
		      const Char_t* histName) {
  //
  // get a histogram from the J/psi output
  //
  TKey* qaKey = (TKey*)file->GetListOfKeys()->At(0);
  TList* qaList = (TList*)qaKey->ReadObj();
  
  THashList* qaCutClass = (THashList*)qaList->FindObject(cutClass);
  THashList* qaHistList = (THashList*)qaCutClass->FindObject(histList);
  return qaHistList->FindObject(histName);
}
예제 #15
0
void plotQApid(Int_t ic,Float_t pt,Int_t addbin){
  char name[100];
  char stringa[200];
  LoadLib();

  snprintf(name,100,"AnalysisResults.root");
  if(!fo) fo = new TFile(name);
  snprintf(name,100,"contVZEROv2");
  TList *cont = (TList *) fo->Get(name);
  AliFlowVZEROResults *pidqa = cont->FindObject("qaPID");
  Float_t xval[2] = {2.,pt+0.00001};
  Float_t xval2[2] = {2.+addbin,pt+0.00001};

  TProfile *proTPCpi = pidqa->GetV2(0,xval,xval2);
  TProfile *proTOFpi = pidqa->GetV2(1,xval,xval2);
  TProfile *proTPCka = pidqa->GetV2(2,xval,xval2);
  TProfile *proTOFka = pidqa->GetV2(3,xval,xval2);
  TProfile *proTPCpr = pidqa->GetV2(4,xval,xval2);
  TProfile *proTOFpr = pidqa->GetV2(5,xval,xval2);

  proTPCpi->SetName("hPiTPC");
  proTOFpi->SetName("hPiTOF");
  proTPCka->SetName("hKaTPC");
  proTOFka->SetName("hKaTOF");
  proTPCpr->SetName("hPrTPC");
  proTOFpr->SetName("hPrTOF");
  
  proTPCpi->GetXaxis()->SetTitle("dE/dx - dE/dx_{calc}^{#pi} (a.u)");
  proTOFpi->GetXaxis()->SetTitle("t_{tof} - t_{calc}^{#pi} (ps)");
  proTPCka->GetXaxis()->SetTitle("dE/dx - dE/dx_{calc}^{K} (a.u)");
  proTOFka->GetXaxis()->SetTitle("t_{tof} - t_{calc}^{K} (ps)");
  proTPCpr->GetXaxis()->SetTitle("dE/dx - dE/dx_{calc}^{p} (a.u)");
  proTOFpr->GetXaxis()->SetTitle("t_{tof} - t_{calc}^{p} (ps)");

  TCanvas *c = new TCanvas("cVproj","cVproj");
  c->Divide(2,3);
  c->cd(1);
  proTPCpi->Draw();
  c->cd(2);
  proTOFpi->Draw();
  c->cd(3);
  proTPCka->Draw();
  c->cd(4);
  proTOFka->Draw();
  c->cd(5);
  proTPCpr->Draw();
  c->cd(6);
  proTOFpr->Draw();
}
예제 #16
0
TH1D *
GetITSTPCSpectrum(TFile *file, Int_t part, Int_t charge, Int_t cent)
{
  TList *list = (TList *)file->Get("output");
  TH1D *hin = (TH1D *)list->FindObject(Form("h_%s_%s_cen_%d", ITSTPCPartName[part], ITSTPCChargeName[charge], cent + 1));
  if (!hin) return NULL;

  TH1D *h = new TH1D(Form("hITSTPC_cent%d_%s_%s", cent, AliPID::ParticleName(part), chargeName[charge]), "ITSTPC", NptBins, ptBin);
  Double_t pt, width, value, error;
  Int_t bin;
  for (Int_t ipt = 0; ipt < NptBins; ipt++) {
    /* get input bin */
    pt = h->GetBinCenter(ipt + 1);
    width = h->GetBinWidth(ipt + 1);
    bin = hin->FindBin(pt);
    /* sanity check */
    if (TMath::Abs(hin->GetBinCenter(bin) - pt) > 0.001 ||
	TMath::Abs(hin->GetBinWidth(bin) - width) > 0.001)
      continue;
    /* copy bin */
    value = hin->GetBinContent(bin);
    error = hin->GetBinError(bin);
    h->SetBinContent(ipt + 1, value);
    h->SetBinError(ipt + 1, error);
  }
  
#if 0
  /* add systematic error */
  Double_t sys;
  if (part == 2) sys = 0.5;
  else sys = 0.1;
  Double_t cont, conte;
  for (Int_t ipt = 0; ipt < h->GetNbinsX(); ipt++) {
    cont = h->GetBinContent(ipt + 1);
    conte = h->GetBinError(ipt + 1);
    conte = TMath::Sqrt(conte * conte + sys * sys * cont * cont);
    h->SetBinError(ipt + 1, conte);
  }
#endif
  
  h->SetTitle("ITSTPC");
  h->SetLineWidth(1);
  h->SetLineColor(1);
  h->SetMarkerStyle(21);
  h->SetMarkerColor(2);
  h->SetFillStyle(0);
  h->SetFillColor(0);
  return h;
}
예제 #17
0
UInt_t KVASGroup::GetDetectorLayer(KVDetector* det)
{
   //Find the "detector layer" to which this detector belongs

   TList* list;
   for (UInt_t i = 1; i <= GetNumberOfDetectorLayers(); i++) {
      list = GetDetectorsInLayer(i);
      if (list->FindObject(det)) {
         delete list;
         return i;
      }
      delete list;
   }
   return 0;
}
예제 #18
0
파일: printStat.C 프로젝트: shahor02/align
void printStat(const char* fl)
{
  printf("Stat for %s\n",fl);
  TFile* ff = TFile::Open(fl);
  TList* lst = (TList*)ff->Get("clist");
  if (!lst) {printf("no clist\n");return;}
  TH1* hstat = (TH1*)lst->FindObject("stat");
  if (!hstat) {printf("no hstat\n");return;}
  //
  TAxis* ax = hstat->GetXaxis();
  for (int ib=1;ib<ax->GetNbins();ib++) {
    double val = hstat->GetBinContent(ib);
    if (val) printf("%-20s\t%9d\n",ax->GetBinLabel(ib),int(val));
  }
  ff->Close();
  delete ff;
  return;
}
예제 #19
0
/** 
 * Draw the Poisson estimate of the occupancy in a given ring.
 * 
 * @param p            List 
 * @param d            Detector
 * @param r            Ring
 * 
 * @return The occupancy (in percent)
 *
 * @deprecated Use QATrender instead
 * @ingroup pwglf_forward_scripts_qa
 */
Double_t
DrawRingOccupancy(TList* p, UShort_t d, Char_t r)
{
  if (!p) return 0;

  TList* ring = static_cast<TList*>(p->FindObject(Form("FMD%d%c",d,r)));
  if (!ring) { 
    Error("DrawOccupancy", "List FMD%d%c not found in %s",d,r,p->GetName());
    return 0;
  }
  
  TH1* corr = static_cast<TH1*>(ring->FindObject("occupancy"));
  if (!corr) { 
    Error("DrawRingOccupancy", "Histogram occupancy not found in FMD%d%c",
	  d, r);
    return 0;
  }
  corr->Rebin(4);

  TPad* pad = static_cast<TPad*>(gPad);
  pad->SetGridy();
  pad->SetGridx();
  pad->SetLogy();
  pad->SetFillColor(0);
    pad->SetRightMargin(0.01);
#if 0
  if (d == 3) { 
    pad->SetPad(pad->GetXlowNDC(), pad->GetYlowNDC(), .99, 
		 pad->GetYlowNDC()+pad->GetHNDC());
    pad->SetRightMargin(0.15);
  }
#endif

  corr->Draw("hist");

  TLatex* ltx = new TLatex(.95, .95, Form("FMD%d%c", d, r));
  ltx->SetNDC();
  ltx->SetTextAlign(33);
  ltx->SetTextSize(.08);
  ltx->Draw();

  return corr->GetMean();
}
int GetCoefficient(TString txtFile, TString rootFile)
{
  //Extracting the histogram
  TFile* f = TFile::Open(rootFile);
  TDirectoryFile* dirFile = (TDirectoryFile*)(f->Get("AliAnalysisTaskCalibEmcal"));
  TList* list = (TList*)(dirFile->Get("histogram"));
  TH2D* cellVAmplitude = (TH2D*)(list->FindObject("_histogram_cell_id_amplitude"));
  
  //cout << __FILE__ << __LINE__ << endl;

  //Cell Tower range to analyse
  const Int_t CVALow = 0;
  const Int_t CVAHigh = 17670;
  
  //cout << __FILE__ << __LINE__ << endl;

  //Obtaining a histogram of the Good cells.
  TList* goodHistList = new TList;
  ifstream goodFile(txtFile);
  int numCells = 0;
  if(goodFile.is_open())
    {

      //cout << __FILE__ << __LINE__ << endl;

      string line = "";
      std::getline(goodFile,line);
      int index = 0;
      double chi2 = 0.0;
      
      //cout << __FILE__ << __LINE__ << endl;

      //for(index = 0; index < 3; index++)
      while(goodFile >> index >> chi2)
	{
	  //cout << Form("cell%d",index) << endl;
	  TH1D* cell = cellVAmplitude->ProjectionY(Form("cell%d",index),index+1,index+1);
	  goodHistList->Add(cell);
	  numCells++;
	}
      
    }
예제 #21
0
  /** 
   * Get or create a stack legend.  This is done by adding a TLegend
   * object to the list of functions for the first histogram in the
   * stack.
   * 
   * @param stack Stack to get the legend from/modify 
   * 
   * @return The legend object or null
   */
  TLegend* StackLegend(THStack* stack) 
  {
    TList* hists = stack->GetHists();
    if (!hists) return 0;
    
    TObject* first = hists->First();
    if (!first) return 0;

    TH1*    hist = static_cast<TH1*>(first);
    TList*  list = hist->GetListOfFunctions();
    TObject* o   = list->FindObject("legend");
    if (o) return static_cast<TLegend*>(o);
    
    TLegend* l = new TLegend(0.65, 0.65, 0.9, 0.9, "", "NDC");
    l->SetName("legend");
    l->SetBorderSize(0);
    l->SetFillColor(0);
    l->SetFillStyle(0);
    l->SetTextFont(42);
    list->Add(l);
    
    return l;
  }
예제 #22
0
파일: CalcEffic.C 프로젝트: ktf/AliPhysics
TEfficiency* CalcEffic(const char* fileName, Bool_t makeDraw=kFALSE)
{
	// open the input file
	TFile *file = new TFile(fileName);
	
	// ********************************************
	// parameters to check before running the macro
	// ********************************************

	const Float_t E_MIN = 0.1;
	const Int_t NHISTS = 6; // Check the number of histograms for different particle species
	const Int_t NOUTPUTS = 3;
	const Int_t NHISTOUT[NOUTPUTS] = {6,3,3};
	Int_t IHISTOUT[NOUTPUTS][NHISTS] = {{0,1,2,3,4,5},{0,1,2,-1,-1,-1},{3,4,5,-1,-1,-1}};
	
	Int_t style[NOUTPUTS] = {20,21,22};
	Int_t color[NOUTPUTS] = {1,2,4};
		
	const Int_t fgNumOfEBins = 78; // Check the number of eta bins in the histograms
	const Int_t fgNumOfEtaBins = 16; // Check the number of E bins in the histograms
	Double_t fgEAxis[79]={0., 0.05, 0.10, 0.15, 0.20, 0.25, 0.30, 0.35, 0.4, 0.45, 0.5, 0.55, 0.6, 0.65, 0.7, 0.75, 0.8, 0.85, 0.9, 0.95,
		1.,1.5,2.,2.5,3.,3.5,4.,4.5,5.,5.5,6.,6.5,7.,7.5,8.,8.5,9.,9.5,10.,11.,
		12.,13.,14.,15.,16.,17.,18.,19.,20.,21.,22.,23.,24.,25.,26.,27.,28.,29.,30.,31.,
		32.,33.,34.,35.,36.,37.,38.,39.,40.,41.,42.,43.,44.,45.,46.,47.,48.,49.,50.};
	
	// declare histograms and graphs
	TH2F *histNum[NHISTS];
	TH2F *histDen[NHISTS];
	TGraphErrors *graph[NOUTPUTS];
	TGraphErrors *graphNum[NOUTPUTS];
	TGraphErrors *graphDen[NOUTPUTS];
	TEfficiency *effic[NOUTPUTS];
	char efficName[50];
	
	//define canvas
	gStyle->SetOptTitle(0);
	gStyle->SetOptStat(0);
	gStyle->SetOptFit(0);	
	
	TCanvas *c1;
	TCanvas *c2;
	
	if (makeDraw)
	{
		c1 = new TCanvas("c1","c1",500,400);
		//c1->SetTopMargin(0.04);
		//c1->SetRightMargin(0.04);
		//c1->SetLeftMargin(0.181452);
		//c1->SetBottomMargin(0.134409);
		c1->SetBorderSize(0);
		c1->SetFillColor(0);
		c1->SetBorderMode(0);
		c1->SetFrameFillColor(0);
		c1->SetFrameBorderMode(0);
		
		c2 = new TCanvas("c2","c2",500,400);
		c2->Divide(1,3);
	}
	
	// retrieve the input list of histogram. Check the TList name in the input file.
	TList *list = (TList*) file->Get("out1");
	
	// retrieve the histograms in the list. Check the name of the histograms
	histNum[0] = (TH2F*)list->FindObject("fHistElectronRec_EtaE_EmcalMC");
	histNum[1] = (TH2F*)list->FindObject("fHistConvElectronRec_EtaE_EmcalMC");
	histNum[2] = (TH2F*)list->FindObject("fHistScatElectronRec_EtaE_EmcalMC");
	histNum[3] = (TH2F*)list->FindObject("fHistGammaRec_EtaE_EmcalMC");
	histNum[4] = (TH2F*)list->FindObject("fHistAnnihGammaRec_EtaE_EmcalMC");
	histNum[5] = (TH2F*)list->FindObject("fHistScatGammaRec_EtaE_EmcalMC");
	
	// retrieve the histograms in the list. Check the name of the histograms
	histDen[0] = (TH2F*)list->FindObject("fHistElectronAcc_EtaE_EmcalMC");
	histDen[1] = (TH2F*)list->FindObject("fHistConvElectronAcc_EtaE_EmcalMC");
	histDen[2] = (TH2F*)list->FindObject("fHistScatElectronAcc_EtaE_EmcalMC");
	histDen[3] = (TH2F*)list->FindObject("fHistGammaAcc_EtaE_EmcalMC");
	histDen[4] = (TH2F*)list->FindObject("fHistAnnihGammaAcc_EtaE_EmcalMC");
	histDen[5] = (TH2F*)list->FindObject("fHistScatGammaAcc_EtaE_EmcalMC");
	
	// ********************************************

	Float_t x[fgNumOfEBins]={0}, ex[fgNumOfEBins]={0};
	Float_t y[fgNumOfEBins]={0}, ey[fgNumOfEBins]={0};
	Float_t num[fgNumOfEBins]={0}, den[fgNumOfEBins]={0};
	
	// loop over different desired outputs
	for (int iOut=0; iOut<NOUTPUTS; iOut++)
	{
		sprintf(efficName,"effic_%d",iOut);
		effic[iOut] = new TEfficiency(efficName,efficName,fgNumOfEBins,fgEAxis);

		// loop over E bins
		for (int ix=0; ix<fgNumOfEBins; ix++)
		{
			//check minimum energy
			if (histNum[0]->GetXaxis()->GetBinLowEdge(ix+1) < E_MIN)
				continue;
			
			// initialize ET variables for a new particle species
			x[ix]=histNum[0]->GetXaxis()->GetBinCenter(ix+1);
			y[ix]=0;
			ex[ix]=0;
			ey[ix]=0;
			num[ix] = 0;
			den[ix] = 0;
			
			// loop over eta bins
			for (int iy=0; iy<fgNumOfEtaBins; iy++)
			{
				for (int iHist=0; iHist<NHISTOUT[iOut]; iHist++)
				{
					num[ix] += histNum[IHISTOUT[iOut][iHist]]->GetBinContent(ix+1,iy+1); // sum over all E bins in order to get total ET
					den[ix] += histDen[IHISTOUT[iOut][iHist]]->GetBinContent(ix+1,iy+1); // sum over all E bins in order to get total ET
				}
			}
			
			if ((num[ix]>0) && (den[ix]>0))
			{
				effic[iOut]->SetTotalEvents(ix,den[ix]);
				effic[iOut]->SetPassedEvents(ix,num[ix]);

				y[ix] = num[ix]/den[ix];
				ey[ix] = y[ix]*sqrt(1/num[ix]+1/den[ix]);				
			}
			else
			{
				y[ix] = 0;	
				ey[ix] = 0;
			}
			
		} // end of loop over E bins

		graph[iOut] = new TGraphErrors(fgNumOfEBins,x,y,ex,ey); // graphic of ET(>E_cut)/ET(total) for a given particle species and E cut
		graphNum[iOut] = new TGraphErrors(fgNumOfEBins,x,num,ex,ey); // graphic of ET(>E_cut)/ET(total) for a given particle species and E cut	
		graphDen[iOut] = new TGraphErrors(fgNumOfEBins,x,den,ex,ey); // graphic of ET(>E_cut)/ET(total) for a given particle species and E cut

	} // end of loop over different outputs

	
	// Draw the plot
	
	if (makeDraw)
	{
		for (int i=0; i<NOUTPUTS; i++)
		{		
			c2->cd(i);
			
			graphDen[i]->SetMarkerStyle(style[i]);
			graphDen[i]->SetMarkerColor(color[i]);
			graphDen[i]->SetLineColor(color[i]);
			graphDen[i]->SetFillColor(0);
			if (i == 0) 
			{
				graphDen[i]->GetXaxis()->SetTitle("E (GeV)");
				graphDen[i]->GetYaxis()->SetTitle("effic");
				//graphDen[i]->SetMaximum(1.0);
				graphDen[i]->SetMinimum(0.0);
				graphDen[i]->Draw("AP");
			}
			else 
				graphDen[i]->Draw("P");
			
			graphNum[i]->SetMarkerStyle(style[i]+4);
			graphNum[i]->SetMarkerColor(color[i]);
			graphNum[i]->SetLineColor(color[i]);
			graphNum[i]->SetFillColor(0);
			graphNum[i]->Draw("P");		
		}
		
		c1->cd();
		/*
		for (int i=0; i<NOUTPUTS; i++)
		{
			effic[i]->SetMarkerStyle(style[i]);
			effic[i]->SetMarkerColor(color[i]);
			effic[i]->SetLineColor(color[i]);
			effic[i]->SetFillColor(0);
			effic[i]->SetTitle("efficiency;E (GeV); #epsilon");
			if (i == 0) 
			{
				effic[i]->Draw("AP");
			}
			else 
				effic[i]->Draw("Psame");
		}
		*/
		for (int i=0; i<NOUTPUTS; i++)
		{
			graph[i]->SetMarkerStyle(style[i]);
			graph[i]->SetMarkerColor(color[i]);
			graph[i]->SetLineColor(color[i]);
			graph[i]->SetFillColor(0);
			if (i == 0) 
			{
				graph[i]->Draw("AP");
			}
			else 
				graph[i]->Draw("P");
		}
		
		TLegend *leg = new TLegend(0.65,0.2,0.95,0.5);
		leg->AddEntry(effic[0],"electrons+gammas");
		leg->AddEntry(effic[1],"electrons");
		leg->AddEntry(effic[2],"gammas");
		leg->SetFillStyle(0);
		leg->SetFillColor(0);
		leg->SetBorderSize(0);
		leg->SetTextSize(0.03);
		leg->Draw();
	}
	
	return effic[0];
}
예제 #23
0
파일: playV0M.C 프로젝트: ktf/AliPhysics
TH1 *
UnfoldMe_MB2(const Char_t *data, const Char_t *mc, const Char_t *anatag, Int_t bin, Bool_t useMBcorr , Bool_t usecorrfit , Bool_t ismc , Float_t smooth , Int_t iter , Int_t regul , Float_t weight , Bool_t bayesian , Int_t nloop )
{

  // MF comments:
  // usedMBcorr: changes the matrix used for unfonding, from effMatrix to bin matrix (I think this is just to use mult dependent v s mb correction_)
  // usecorrfit: if I understand correctly, fits the response matrix and uses fit to extrapolate it

  
  TFile *fdt =0;
  if (ismc)
    fdt =  TFile::Open(data);
  else
    fdt = TFile::Open(data);
  TFile *fmc = TFile::Open(mc);

  TList *ldt = (TList *)fdt->Get(Form("%s", anatag));
  TList *lmc = (TList *)fmc->Get(Form("%s", anatag));
  
  TH2 *hmatdt = (TH2 *)ldt->FindObject(Form(responseMatrix, bin));
  TH2 *hmatmc = 0;
  if (useMBcorr){
     hmatmc = (TH2 *)lmc->FindObject("effMatrix");
     std::cout << "USING MB" << std::endl;
     
  }
  else {
    hmatmc = (TH2 *)lmc->FindObject(Form(responseMatrix, bin));
  }

  TH1 *hdata = hmatdt->ProjectionY("hdata");
//  TH1 *hdata = hmatdt->ProjectionY("htrue");  // For truth Only Calculations

  hdata->Sumw2();
  hdata->SetBinContent(1, 0.);
  hdata->SetBinError(1, 0.);
  //  hdata->Scale(1. / hdata->Integral());
  hdata->SetMarkerStyle(25);
  TH1 *htrue = hmatdt->ProjectionX("htrue");
  htrue->Sumw2();
  //  htrue->Scale(1. / htrue->Integral());
  htrue->SetMarkerStyle(7);
  htrue->SetMarkerColor(2);
  htrue->SetBinContent(1, 0.);
  htrue->SetBinError(1, 0.);

  TH2 *hcorr = (TH2 *)hmatmc->Clone("hcorr");
  TH1 *hinit = (TH1 *)hdata->Clone("hinit");
  TH1 *hresu = (TH1 *)hdata->Clone("hresu");
  TH1 *hbias = (TH1 *)hdata->Clone("hbias");
  hresu->SetMarkerStyle(20);
  hresu->SetMarkerColor(4);
  hresu->Reset();

  TH1 *hnum = hcorr->ProjectionY("hnum");
  TH1 *hden = hcorr->ProjectionY("hden");
  TH1 *heff = hcorr->ProjectionY("heff");
  hnum->Reset();
  hnum->Sumw2();
  hden->Reset();
  hden->Sumw2();
  heff->Reset();
  for (Int_t i = 0; i < heff->GetNbinsX(); i++) {
    Float_t int1 = hcorr->Integral(i + 1, i + 1, 0, -1);
    if (int1 <= 0.) continue;
    Float_t int2 = hcorr->Integral(i + 1, i + 1, 2, -1);
    hnum->SetBinContent(i + 1, int2);
    hnum->SetBinError(i + 1, TMath::Sqrt(int2));
    hden->SetBinContent(i + 1, int1);
    hden->SetBinError(i + 1, TMath::Sqrt(int1));
  }
  TCanvas *cEfficiency = new TCanvas("cEfficiency", "cEfficiency");
  cEfficiency->SetLogx();
  cEfficiency->SetLogy();

  heff->Divide(hnum, hden, 1., 1., "B");
  heff->Draw();
#if 0
  for (Int_t ii = 0; ii < heff->GetNbinsX(); ii++) {
    heff->SetBinContent(ii + 1, 1.);
    heff->SetBinError(ii + 1, 0.);
  }
#endif

  for (Int_t i = 0; i < hcorr->GetNbinsX(); i++) {
    hcorr->SetBinContent(i + 1, 1, 0.);
    hcorr->SetBinError(i + 1, 1, 0.);
  }
  for (Int_t i = 0; i < hcorr->GetNbinsY(); i++) {
    hcorr->SetBinContent(1, i + 1, 0.);
    hcorr->SetBinError(1, i + 1, 0.);
  }
  TH2 *hcorrfit = ReturnCorrFromFit(hcorr);
  // Docs from AliUnfolding
  //Int_t AliUnfolding::Unfold(TH2* correlation, TH1* efficiency, TH1* measured, TH1* initialConditions, TH1* result, Bool_t check)
  // unfolds with unfolding method fgMethodType
  //
  // parameters:
  //  correlation: response matrix as measured vs. generated
  //  efficiency:  (optional) efficiency that is applied on the unfolded spectrum, i.e. it has to be in unfolded variables. If 0 no efficiency is applied.
  //  measured:    the measured spectrum
  //  initialConditions: (optional) initial conditions for the unfolding. if 0 the measured spectrum is used as initial conditions.
  //  result:      target for the unfolded result
  //  check:       depends on the unfolding method, see comments in specific functions

  for (Int_t iloop = 0; iloop < nloop; iloop++) {
    if (bayesian) {
      AliUnfolding::SetUnfoldingMethod(AliUnfolding::kBayesian);
      AliUnfolding::SetBayesianParameters(smooth, iter);
    } else {
      AliUnfolding::SetUnfoldingMethod(AliUnfolding::kChi2Minimization);
      AliUnfolding::SetChi2Regularization(AliUnfolding::RegularizationType(regul), weight);
    }
    AliUnfolding::SetSkip0BinInChi2(kTRUE);
    AliUnfolding::SetSkipBinsBegin(1);
    AliUnfolding::SetNbins(150, 150);
    AliUnfolding::Unfold(usecorrfit ? hcorrfit : hcorr, heff, hdata, hinit, hresu);
    hinit = (TH1 *)hresu->Clone(Form("hinit_%d", iloop));
  }

  printf("hdata->Integral(2, -1) = %f\n", hdata->Integral(2, -1));
  printf("hresu->Integral(2, -1) = %f\n", hresu->Integral(2, -1));


  TCanvas *cUnfolded = new TCanvas ("cUnfolded", "cUnfolded", 400, 800);
  cUnfolded->Divide(1, 2);
  cUnfolded->cd(1)->SetLogx();
  cUnfolded->cd(1)->SetLogy();
  hdata->Draw();
  hresu->Draw("same");
  htrue->Draw("same");
  cUnfolded->cd(2)->SetLogx();
  cUnfolded->cd(2)->DrawFrame(1., 0, 300., 10);
  TH1 *hrat = (TH1 *)hresu->Clone("hrat");
  hrat->Divide(htrue);
  hrat->Draw("same");

  TH1 *htrig = (TH1 *)hresu->Clone("htrig");
  htrig->Multiply(heff); 
  

  Float_t dndeta_resu = 0.;
  Float_t integr_resu = 0.;
  Float_t dndeta_trig = 0.;
  Float_t integr_trig = 0.;
  for (Int_t i = 1; i < hresu->GetNbinsX(); i++) {
    dndeta_resu += hresu->GetBinContent(i + 1) * hresu->GetBinLowEdge(i + 1);
    integr_resu += hresu->GetBinContent(i + 1);
    dndeta_trig += htrig->GetBinContent(i + 1) * htrig->GetBinLowEdge(i + 1);
    integr_trig += htrig->GetBinContent(i + 1);
  }

  cUnfolded->SaveAs("unfold_efficiency.pdf");

  integr_eff = integr_trig / integr_resu;
  integr_eff_err = TMath::Sqrt(integr_eff * (1. - integr_eff) / integr_resu);
  dndeta_eff = dndeta_trig / dndeta_resu;
  dndeta_eff_err = TMath::Sqrt(dndeta_eff * (1. - dndeta_eff) / dndeta_resu);

  printf("INEL > 0 efficiency: %.3f +- %.3f\n", integr_eff, integr_eff_err);
  printf("dN/dEta correction:  %.3f +- %.3f\n", dndeta_eff, dndeta_eff_err);

  return hresu;
}
예제 #24
0
파일: UnfoldMe.C 프로젝트: ktf/AliPhysics
TH1 *
UnfoldMe(Char_t *data, Char_t *mc, Char_t *anatag, Int_t bin, Bool_t useMBcorr = kTRUE, Bool_t usecorrfit = kFALSE, Bool_t ismc = kFALSE, Float_t smooth = 0.001, Int_t iter = 50, Int_t regul = AliUnfolding::kPowerLaw, Float_t weight = 100., Bool_t bayesian = kTRUE, Int_t nloop = 1)
{

  if (ismc)
    TFile *fdt = TFile::Open(data);
  else
    TFile *fdt = TFile::Open(data);
  TFile *fmc = TFile::Open(mc);
  
  TList *ldt = (TList *)fdt->Get(Form("clist_%s", anatag));
  TList *lmc = (TList *)fmc->Get(Form("clist_%s", anatag));
  
  TH2 *hmatdt = (TH2 *)ldt->FindObject(Form("b%d_corrMatrix", bin));
  if (useMBcorr)
    TH2 *hmatmc = (TH2 *)lmc->FindObject("effMatrix");
  else
    TH2 *hmatmc = (TH2 *)lmc->FindObject(Form("b%d_corrMatrix", bin));
 
  TH1 *hdata = hmatdt->ProjectionY("hdata");
  hdata->Sumw2();
  hdata->SetBinContent(1, 0.);
  hdata->SetBinError(1, 0.);
  //  hdata->Scale(1. / hdata->Integral());
  hdata->SetMarkerStyle(25);
  TH1 *htrue = hmatdt->ProjectionX("htrue");
  htrue->Sumw2();
  //  htrue->Scale(1. / htrue->Integral());
  htrue->SetMarkerStyle(7);
  htrue->SetMarkerColor(2);
  htrue->SetBinContent(1, 0.);
  htrue->SetBinError(1, 0.);
  TH2 *hcorr = (TH2 *)hmatmc->Clone("hcorr");
  TH1 *hinit = (TH1 *)hdata->Clone("hinit");
  TH1 *hresu = (TH1 *)hdata->Clone("hresu");
  TH1 *hbias = (TH1 *)hdata->Clone("hbias");
  hresu->SetMarkerStyle(20);
  hresu->SetMarkerColor(4);
  hresu->Reset();

  TH1 *hnum = hcorr->ProjectionY("hnum");
  TH1 *hden = hcorr->ProjectionY("hden");
  TH1 *heff = hcorr->ProjectionY("heff");
  hnum->Reset();
  hnum->Sumw2();
  hden->Reset();
  hden->Sumw2();
  heff->Reset();
  for (Int_t i = 0; i < heff->GetNbinsX(); i++) {
    Float_t int1 = hcorr->Integral(i + 1, i + 1, 0, -1);
    if (int1 <= 0.) continue;
    Float_t int2 = hcorr->Integral(i + 1, i + 1, 2, -1);
    hnum->SetBinContent(i + 1, int2);
    hnum->SetBinError(i + 1, TMath::Sqrt(int2));
    hden->SetBinContent(i + 1, int1);
    hden->SetBinError(i + 1, TMath::Sqrt(int1));
  }
  new TCanvas("cEfficiency");
  heff->Divide(hnum, hden, 1., 1., "B");
  heff->Draw();
#if 0
  for (Int_t ii = 0; ii < heff->GetNbinsX(); ii++) {
    heff->SetBinContent(ii + 1, 1.);
    heff->SetBinError(ii + 1, 0.);
  }
#endif
  
  for (Int_t i = 0; i < hcorr->GetNbinsX(); i++) {
    hcorr->SetBinContent(i + 1, 1, 0.);
    hcorr->SetBinError(i + 1, 1, 0.);
  }
  for (Int_t i = 0; i < hcorr->GetNbinsY(); i++) {
    hcorr->SetBinContent(1, i + 1, 0.);
    hcorr->SetBinError(1, i + 1, 0.);
  }
  TH2 *hcorrfit = ReturnCorrFromFit(hcorr);

  for (Int_t iloop = 0; iloop < nloop; iloop++) {
    if (bayesian) {
      AliUnfolding::SetUnfoldingMethod(AliUnfolding::kBayesian);
      AliUnfolding::SetBayesianParameters(smooth, iter);
    } else {
      AliUnfolding::SetUnfoldingMethod(AliUnfolding::kChi2Minimization);
      AliUnfolding::SetChi2Regularization(regul, weight);
    }
    AliUnfolding::SetSkip0BinInChi2(kTRUE);
    AliUnfolding::SetSkipBinsBegin(1);
    AliUnfolding::SetNbins(150, 150);
    AliUnfolding::Unfold(usecorrfit ? hcorrfit : hcorr, heff, hdata, hinit, hresu);
    hinit = (TH1 *)hresu->Clone(Form("hinit_%d", iloop));
  }

  printf("hdata->Integral(2, -1) = %f\n", hdata->Integral(2, -1));
  printf("hresu->Integral(2, -1) = %f\n", hresu->Integral(2, -1));
  
  
  TCanvas *cUnfolded = new TCanvas ("cUnfolded", "", 400, 800);
  cUnfolded->Divide(1, 2);
  cUnfolded->cd(1)->SetLogx();
  cUnfolded->cd(1)->SetLogy();
  hdata->Draw();
  hresu->Draw("same");
  htrue->Draw("same");
  cUnfolded->cd(2)->SetLogx();
  cUnfolded->cd(2)->DrawFrame(1., 0.75, 300., 1.25);
  TH1 *hrat = (TH1 *)hresu->Clone("hrat");
  hrat->Divide(htrue);
  hrat->Draw("same");

  TH1 *htrig = (TH1 *)hresu->Clone("htrig");
  htrig->Multiply(heff);

  Float_t dndeta_resu = 0.;
  Float_t integr_resu = 0.;
  Float_t dndeta_trig = 0.;
  Float_t integr_trig = 0.;
  for (Int_t i = 1; i < hresu->GetNbinsX(); i++) {
    dndeta_resu += hresu->GetBinContent(i + 1) * hresu->GetBinLowEdge(i + 1);
    integr_resu += hresu->GetBinContent(i + 1);
    dndeta_trig += htrig->GetBinContent(i + 1) * htrig->GetBinLowEdge(i + 1);
    integr_trig += htrig->GetBinContent(i + 1);
  }
  //  dndeta_resu /= integr_resu;
  //  dndeta_trig /= integr_trig;

  integr_eff = integr_trig / integr_resu;
  integr_eff_err = TMath::Sqrt(integr_eff * (1. - integr_eff) / integr_resu);
  dndeta_eff = dndeta_trig / dndeta_resu;
  dndeta_eff_err = TMath::Sqrt(dndeta_eff * (1. - dndeta_eff) / dndeta_resu);
  
  printf("INEL > 0 efficiency: %.3f +- %.3f\n", integr_eff, integr_eff_err);
  printf("dN/dEta correction:  %.3f +- %.3f\n", dndeta_eff, dndeta_eff_err);

  return hresu;
}
예제 #25
0
int drawPerformanceTPCQAMatch(const char* inFile = "perf.root") {
  //
  // Draw control histograms
  // and generate output pictures
  //

  gSystem->Load("libSTAT");
  gSystem->Load("libANALYSIS");
  gSystem->Load("libANALYSISalice");
  gSystem->Load("libANALYSIScalib");
  gSystem->Load("libCORRFW");
  gSystem->Load("libTPCcalib");
  gSystem->Load("libTRDcalib");
  gSystem->Load("libT0calib");
  gSystem->Load("libTOFcalib");
  gSystem->Load("libANALYSISalice");
  gSystem->Load("libANALYSIScalib");
  gSystem->Load("libTender");
  gSystem->Load("libPWGPP");

  gROOT->Reset();
  gROOT->SetStyle("Plain");
  gStyle->SetPalette(1);
  gStyle->SetOptStat(0);
  gStyle->SetTitleSize(0.025);
  TH1::AddDirectory(kFALSE);

  //
  // set criteria
  //
  Float_t mineta = -0.8;
  Float_t maxeta = 0.799;
  Float_t minNclust = 70.0;
  Double_t ptMax = 10;
  //
  // open input file
  //
  TFile *file = TFile::Open(inFile);
  if(!file)
    return -9;
  cout<<"QA file opened"<<endl;
  file->cd();
  // get the TPC list
  if(gROOT->FindObject("TPC_PerformanceQA")) TPC_PerformanceQA->cd();
  cout<<"TPC_PerformanceQA opened"<<endl;
  TList *TPC = (TList*)gROOT->FindObject("TPCQA");
  if(TPC==NULL) TPC = (TList*)gROOT->FindObject("TPCQA_v0_c0");
  if(TPC==NULL) TPC = (TList*)gROOT->FindObject("TPCQA_v0_c30");
  if(TPC==NULL) TPC = (TList*)gROOT->FindObject("TPCQA_v0_c70");
  if(TPC==NULL) TPC = (TList*)gROOT->FindObject("TPC");
  if(TPC==NULL) return(0);
  cout<<"TPCQA list found"<<endl;
  // get TPC performance object
  AliPerformanceTPC *obj = (AliPerformanceTPC*)TPC->FindObject("AliPerformanceTPC");
  if(obj==NULL) return(0);
  cout<<"what about here after obj  "<<endl;
  // get folder with histograms
  TFolder *fold = obj->GetAnalysisFolder();
  if(!fold) return(0);
  cout<<"what about here after folder  "<<endl;
  //
  // get the HLT list
  //	file->cd();
  //	if(gROOT->FindObject("HLT_PerformanceQA")) HLT_PerformanceQA->cd();
  //	TList *HLT = (TList*)gROOT->FindObject("HLTQA");


  //
  // Draw histograms
  //

  //
  // event level
  //



  TH1 *h1D = 0;
  TH2 *h2D = 0;
  TH3 *h3D = 0;

  h1D = (TH1*)fold->FindObject("h_tpc_event_1");
  Double_t NEvents = h1D->GetEntries();

  cout<<"number of events    "<<NEvents<<endl;

  TCanvas *can1 = new TCanvas("can1","TPC event information",1200,800);
  can1->Divide(3,2);

  can1->cd(1);
  fold->FindObject("h_tpc_event_6")->Draw("histe");

  can1->cd(2);
  gPad->SetLogy();
  h1D = (TH1*)fold->FindObject("h_tpc_event_recvertex_0");
  h1D->GetXaxis()->SetRangeUser(-1.,1.);
  h1D->Draw("histe");

  can1->cd(3);
  gPad->SetLogy();
  h1D = (TH1*)fold->FindObject("h_tpc_event_recvertex_1");
  h1D->GetXaxis()->SetRangeUser(-1.,1.);
  h1D->Draw("histe");
  PlotTimestamp(can1);

  can1->cd(4);
  gPad->SetLogy();
  fold->FindObject("h_tpc_event_recvertex_2")->Draw("histe");

  can1->cd(5);
  gPad->SetLogy();
  TH1 *hp = fold->FindObject("h_tpc_event_recvertex_3");
  hp->SetTitle("Track.Multi., ncl>70, |dcar|<3 cm, |dcaz|<3 cm");
  hp->Draw("histe");

  can1->cd(6);
  gPad->SetLogy();
  hp = (TH1*)fold->FindObject("h_tpc_event_recvertex_4");
  hp->SetTitle("Pos/neg(red) Track.Multi. ncl>70, |dcar|<3 cm, |dcaz|<3 cm");
  hp->Draw("histe");
  TH1* he = fold->FindObject("h_tpc_event_recvertex_5");
  he->SetLineColor(kRed);
  he->Draw("histesame");

  can1->SaveAs("TPC_event_info.png");


  TCanvas *can2 = new TCanvas("can2","#eta , #phi and p_{t}",1200,800);

  can2->Divide(3,2);

  can2->cd(1);
  h3D = (TH3*)fold->FindObject("h_tpc_track_pos_recvertex_0_5_6");
  h3D->GetXaxis()->SetRangeUser(minNclust,160);
  h3D->Project3D("yz")->Draw("colz");
  h3D->Project3D("yz")->SetTitle("#eta vs #phi, positive tracks");
  can2->Update();

  can2->cd(4);
  h3D = (TH3*)fold->FindObject("h_tpc_track_neg_recvertex_0_5_6");
  h3D->GetXaxis()->SetRangeUser(minNclust,160);
  h3D->Project3D("yz")->Draw("colz");
  h3D->Project3D("yz")->SetTitle("#eta vs #phi, negative tracks");
  can2->Update();

  can2->cd(2);
  h3D = (TH3*)fold->FindObject("h_tpc_track_pos_recvertex_0_5_6");
  h3D->GetXaxis()->SetRangeUser(minNclust,160);
  h1D = h3D->Project3D("y");
  h1D->SetTitle("#eta of pos/neg(red) charged tracks, ncl>70");
  h1D->Draw("histe");

  h3D = (TH3*)fold->FindObject("h_tpc_track_neg_recvertex_0_5_6");
  h3D->GetXaxis()->SetRangeUser(minNclust,160);
  h1D = h3D->Project3D("y");
  h1D->SetLineColor(kRed);
  h1D->Draw("histesame");

  can2->cd(5);
  gPad->SetLogy();
  h3D = (TH3*)fold->FindObject("h_tpc_track_pos_recvertex_0_5_7");
  h3D->GetXaxis()->SetRangeUser(minNclust,160);
  h3D->GetYaxis()->SetRangeUser(mineta,maxeta);
  h1D = h3D->Project3D("z");
  h1D->Scale(1,"width");
  h1D->SetTitle("p_{T} of pos/neg(red) charged tracks, ncl>70, |#eta|<0.8");
  h1D->Draw("histe");

  h3D = (TH3*)fold->FindObject("h_tpc_track_neg_recvertex_0_5_7");
  h3D->GetXaxis()->SetRangeUser(minNclust,160);
  h3D->GetYaxis()->SetRangeUser(mineta,maxeta);
  h1D = h3D->Project3D("z");
  h1D->Scale(1,"width");
  h1D->SetLineColor(kRed);
  h1D->Draw("histesame");

  can2->cd(3);
  h3D = (TH3*)fold->FindObject("h_tpc_track_pos_recvertex_5_6_7");
  h3D->GetZaxis()->SetRangeUser(2,20);
  h3D->GetXaxis()->SetRangeUser(mineta,-0.00001);
  TH1 *h1D = h3D->Project3D("y");
  h1D->SetTitle("#phi of pos/neg(red) charged tracks, pt>1GeV/c, -0.8<#eta<0.0");
  h1D->Draw("histe");

  h3D = (TH3*)fold->FindObject("h_tpc_track_neg_recvertex_5_6_7");
  h3D->GetZaxis()->SetRangeUser(2,20);
  h3D->GetXaxis()->SetRangeUser(mineta,-0.00001);
  h1D = h3D->Project3D("y");
  h1D->SetLineColor(kRed);
  h1D->Draw("histesame");
  PlotTimestamp(can2);

  can2->cd(6);
  h3D = (TH3*)fold->FindObject("h_tpc_track_pos_recvertex_5_6_7");
  TH3 *h3D1 = h3D->Clone("h3D1");
  h3D1->GetXaxis()->SetRangeUser(0.0,maxeta);
  h3D1->GetZaxis()->SetRangeUser(2,20);
  h1D = h3D1->Project3D("y");
  h1D->SetTitle("#phi of pos/neg(red) charged tracks, pt>1GeV/c, 0.0<#eta<0.8");
  h1D->Draw("histe");

  h3D = (TH3*)fold->FindObject("h_tpc_track_neg_recvertex_5_6_7");
  TH3 *h3D2 = h3D->Clone("h3D2");
  h3D2->GetXaxis()->SetRangeUser(0.0,maxeta);
  h3D2->GetZaxis()->SetRangeUser(2,20);
  h1D = h3D2->Project3D("y");
  h1D->SetLineColor(kRed);
  h1D->Draw("histesame");

  can2->SaveAs("eta_phi_pt.png");

  TCanvas *can3 = new TCanvas("can3","Cluster Occupancy",700,700);
  can3->Divide(1,2);

  can3->cd(1);
  TH3 *h3D_1 = (TH3*)fold->FindObject("h_tpc_clust_0_1_2");
  TH3 *h3D_2 = (TH3*) h3D_1->Clone("h3D_2");
  h3D_1->GetZaxis()->SetRangeUser(0,0.99);
  h3D_1->Project3D("xy")->Draw("colz");
  h3D_1->Project3D("xy")->SetTitle("Cluster Occupancy A Side");
  if(NEvents > 0)
    h3D_1->Project3D("xy")->Scale(1.0/NEvents);
  can3->Update();
  PlotTimestamp(can3);

  can3->cd(2);
  h3D_2->GetZaxis()->SetRangeUser(1,2) ;
  h3D_2->Project3D("xy")->Draw("colz");
  h3D_2->Project3D("xy")->SetTitle("Cluster Occupancy C Side");
  if(NEvents>0)
    h3D_2->Project3D("xy")->Scale(1.0/NEvents);

  can3->SaveAs("cluster_occupancy.png");

  TObjArray *arr1 = new TObjArray();
  TObjArray *arr2 = new TObjArray();
  TObjArray *arr3 = new TObjArray();
  TObjArray *arr4 = new TObjArray();
  TObjArray *arr5 = new TObjArray();
  TObjArray *arr6 = new TObjArray();

  TCanvas *can4 = new TCanvas("can4","Clusters in Detail",1200,800);
  can4->Divide(3,2);

  can4->cd(1);
  h3D = (TH3*)fold->FindObject("h_tpc_track_all_recvertex_0_5_7");
  h2D = (TH2*)h3D->Project3D("xy");
  h2D->SetTitle("nCluster vs #eta, |dcar|<3 cm, |dcaz|<3 cm");
  h2D->FitSlicesY(0,0,-1,0,"QNR",arr1);
  h2D->Draw("colz");
  arr1->At(1)->Draw("same");

  can4->cd(4);
  h3D = (TH3*)fold->FindObject("h_tpc_track_all_recvertex_2_5_7");
  h2D = (TH2*)h3D->Project3D("xy");
  h2D->SetTitle("Findable clusters, |dcar|<3 cm, |dcaz|<3 cm");
  h2D->FitSlicesY(0,0,-1,0,"QNR",arr2);
  h2D->Draw("colz");
  arr2->At(1)->Draw("same");

  can4->cd(2);
  h3D = (TH3*)fold->FindObject("h_tpc_track_pos_recvertex_0_5_6");
  TH3 *h3D11 = h3D->Clone("h3D11");
  h3D11->Add(((TH3*)fold->FindObject("h_tpc_track_neg_recvertex_0_5_6")),1);
  h3D11->GetYaxis()->SetRangeUser(mineta,-0.00001);
  h2D = (TH2*)h3D11->Project3D("xz");
  h2D->SetTitle("nCluster vs #phi, -0.8<#eta<0.0, |dcar|<3 cm, |dcaz|<3 cm");
  h2D->FitSlicesY(0,0,-1,0,"QNR",arr3);
  h2D->Draw("colz");
  arr3->At(1)->Draw("same");

  can4->cd(5);
  h3D = (TH3*)fold->FindObject("h_tpc_track_pos_recvertex_0_5_6");
  TH3 *h3D22 = h3D->Clone("h3D22");
  h3D22->Add(((TH3*)fold->FindObject("h_tpc_track_neg_recvertex_0_5_6")),1);
  h3D22->GetYaxis()->SetRangeUser(0.0,maxeta);
  h2D = (TH2*)h3D22->Project3D("xz");
  h2D->SetTitle("nCluster vs #phi, 0.0<#eta<0.8, |dcar|<3 cm, |dcaz|<3 cm");
  h2D->FitSlicesY(0,0,-1,0,"QNR",arr4);
  h2D->Draw("colz");
  arr4->At(1)->Draw("same");

  can4->cd(3);
  h3D = (TH3*)fold->FindObject("h_tpc_track_pos_recvertex_2_5_6");
  TH3 *h3D33 = h3D->Clone("h3D33");
  h3D33->Add(((TH3*)fold->FindObject("h_tpc_track_neg_recvertex_2_5_6")),1);
  h3D33->GetYaxis()->SetRangeUser(mineta,-0.00001);
  h2D = (TH2*)h3D33->Project3D("xz");
  h2D->SetTitle("Findable clusters vs #phi, -0.8<#eta<0.0, |dcar|<3 cm, |dcaz|<3 cm");
  h2D->FitSlicesY(0,0,-1,0,"QNR",arr5);
  h2D->Draw("colz");
  arr5->At(1)->Draw("same");
  PlotTimestamp(can4);


  can4->cd(6);
  h3D = (TH3*)fold->FindObject("h_tpc_track_pos_recvertex_2_5_6");
  TH3 *h3D44 = h3D->Clone("h3D44");
  h3D44->Add(((TH3*)fold->FindObject("h_tpc_track_neg_recvertex_2_5_6")),1);
  h3D44->GetYaxis()->SetRangeUser(0.0,maxeta);
  h2D = (TH2*)h3D44->Project3D("xz");
  h2D->SetTitle("Findalbe clusters vs #phi, 0.0<#eta<0.8, |dcar|<3 cm, |dcaz|<3 cm");
  h2D->FitSlicesY(0,0,-1,0,"QNR",arr6);
  h2D->Draw("colz");
  arr6->At(1)->Draw("same");

  can4->SaveAs("cluster_in_detail.png");
  can4->Update();

  TObjArray *arr7 = new TObjArray();
  TObjArray *arr8 = new TObjArray();

  TCanvas *can5 = new TCanvas("can5","DCA In Detail",1200,800);
  can5->Divide(3,2);

  can5->cd(1);
  h3D = (TH3*)fold->FindObject("h_tpc_track_all_recvertex_3_5_7");
  h3D->GetYaxis()->SetRangeUser(-1,1);
  h2D = (TH2*)h3D->Project3D("xy");
  h2D->FitSlicesY(0,0,-1,0,"QNR",arr7);
  h2D->SetTitle("DCAR vs #eta");
  h2D->Draw("colz");
  arr7->At(1)->Draw("same");

  can5->cd(2);
  h3D = (TH3*)fold->FindObject("h_tpc_track_pos_recvertex_3_5_7");
  h3D->GetYaxis()->SetRangeUser(-1,1);
  h3D->Project3D("xy")->Draw("colz");
  h3D->Project3D("xy")->SetTitle("DCAR vs #eta of pos. charged tracks");

  can5->cd(3);
  h3D = (TH3*)fold->FindObject("h_tpc_track_neg_recvertex_3_5_7");
  h3D->GetYaxis()->SetRangeUser(-1,1);
  h3D->Project3D("xy")->Draw("colz");
  h3D->Project3D("xy")->SetTitle("DCAR vs #eta of neg. charged tracks");
  PlotTimestamp(can5);

  can5->cd(4);
  h3D = (TH3*)fold->FindObject("h_tpc_track_all_recvertex_4_5_7");
  h3D->GetYaxis()->SetRangeUser(-1,1);
  h2D = (TH2*)h3D->Project3D("xy");
  h2D->FitSlicesY(0,0,-1,0,"QNR",arr8);
  h2D->SetTitle("DCAZ vs #eta");
  h2D->Draw("colz");
  arr8->At(1)->Draw("same");

  can5->cd(5);
  h3D = (TH3*)fold->FindObject("h_tpc_track_pos_recvertex_4_5_7");
  h3D->GetYaxis()->SetRangeUser(-1,1);
  h3D->Project3D("xy")->Draw("colz");
  h3D->Project3D("xy")->SetTitle("DCAZ vs #eta of pos. charged tracks");

  can5->cd(6);
  h3D = (TH3*)fold->FindObject("h_tpc_track_neg_recvertex_4_5_7");
  h3D->GetYaxis()->SetRangeUser(-1,1);
  h3D->Project3D("xy")->Draw("colz");
  h3D->Project3D("xy")->SetTitle("DCAZ vs #eta of neg. charged tracks");

  can5->SaveAs("dca_in_detail.png");

  TCanvas *can51 = new TCanvas("can51","DCAr versus pT",700,800);
  can51->Divide(2,2);

  TObjArray *arr9 = new TObjArray();
  TObjArray *arr10 = new TObjArray();
  TObjArray *arr11 = new TObjArray();
  TObjArray *arr12 = new TObjArray();

  can51->cd(1);
  h3D = (TH3*)fold->FindObject("h_tpc_track_pos_recvertex_3_5_7");
  TH3 *h3Dp = h3D->Clone("h3Dp");
  h3D->SetAxisRange(0.25,ptMax,"Z");
  h3D->GetYaxis()->SetRangeUser(0.0,maxeta);
  h2D  = (TH2*)h3D->Project3D("xz");
  h2D->Draw("colz");
  h2D->SetTitle("DCAR vs pT of pos. charged tracks(A Side)");
  h2D->FitSlicesY(0,0,-1,0,"QNR",arr9);
  TH1 *width1 = (TH1*)arr9->At(2);
  width1->Draw("same");
  width1->SetLineColor(2);
  arr9->At(1)->Draw("same");

  can51->cd(2);
  //h3D = (TH3*)fold->FindObject("h_tpc_track_pos_recvertex_3_5_7");
  h3Dp->SetAxisRange(0.25,ptMax,"Z");
  h3Dp->GetYaxis()->SetRangeUser(mineta,-0.00001);
  h2D  = (TH2*)h3Dp->Project3D("xz");
  h2D->Draw("colz");
  h2D->SetTitle("DCAR vs pT of pos. charged tracks(C Side)");
  h2D->FitSlicesY(0,0,-1,0,"QNR",arr10);
  TH1 *width2 = (TH1*)arr10->At(2);
  width2->Draw("same");
  width2->SetLineColor(2);
  arr10->At(1)->Draw("same");
  PlotTimestamp(can51);

  can51->cd(3);
  h3D = (TH3*)fold->FindObject("h_tpc_track_neg_recvertex_3_5_7");
  TH3 *h3Dn = h3D->Clone("h3Dn");
  h3D->SetAxisRange(0.25,ptMax,"Z");
  h3D->GetYaxis()->SetRangeUser(0.0,maxeta);
  h2D  = (TH2*)h3D->Project3D("xz");
  h2D->Draw("colz");
  h2D->SetTitle("DCAR vs pT of neg. charged tracks(A Side)");
  h2D->FitSlicesY(0,0,-1,0,"QNR",arr11);
  TH1 *width3 = (TH1*)arr11->At(2);
  width3->Draw("same");
  width3->SetLineColor(2);
  arr11->At(1)->Draw("same");

  can51->cd(4);
  //h3D = (TH3*)fold->FindObject("h_tpc_track_neg_recvertex_3_5_7");
  h3Dn->SetAxisRange(0.25,ptMax,"Z");
  h3Dn->GetYaxis()->SetRangeUser(mineta,-0.00001);
  h2D  = (TH2*)h3Dn->Project3D("xz");
  h2D->Draw("colz");
  h2D->SetTitle("DCAR vs pT of neg. charged tracks(C Side)");
  h2D->FitSlicesY(0,0,-1,0,"QNR",arr12);
  TH1 *width4 = (TH1*)arr12->At(2);
  width4->Draw("same");
  width4->SetLineColor(2);
  arr12->At(1)->Draw("same");

  can51->SaveAs("dcar_pT.png");

  // get TPC dEdx performance object
  AliPerformanceDEdx *obj1 = TPC->FindObject("AliPerformanceDEdxTPCInner");
  if(obj1==NULL) return(0);

  // get folder with histograms
  TFolder *fold1 = obj1->GetAnalysisFolder();
  if(!fold1) return(0);

  TCanvas *can6 = new TCanvas("can6","TPC dEdX",1200,800);
  can6->Divide(3,2);

  can6->cd(1);
  gPad->SetLogz();
  fold1->FindObject("h_tpc_dedx_0_1")->Draw("colz");

  can6->cd(2);
  gPad->SetLogz();
  fold1->FindObject("h_tpc_dedx_0_5")->Draw("colz");

  can6->cd(3);
  gPad->SetLogz();
  fold1->FindObject("h_tpc_dedx_0_6")->Draw("colz");
  PlotTimestamp(can6);

  can6->cd(4);
  gPad->SetLogx();
  gPad->SetLogz();
  TH2 *h2 = fold1->FindObject("h_tpc_dedx_0_7");
  h2->GetXaxis()->SetRangeUser(0.1,10);
  h2->Draw("colz");
  ////////////////////////////////////////////////////////////////////
  can6->cd(5);
  gPad->SetLogz();
  //fold1->FindObject("h_tpc_dedx_mips_a_0_1")->Draw("colz");
  TH2 *htest = fold1->FindObject("h_tpc_dedx_mips_a_0_1");
  htest->GetYaxis()->SetRangeUser(30,60);
  htest->Draw("colz");
  can6->cd(6);
  gPad->SetLogz();
  //fold1->FindObject("h_tpc_dedx_mips_c_0_1")->Draw("colz");
  TH2 *htest1 = fold1->FindObject("h_tpc_dedx_mips_c_0_1");
  htest1->GetYaxis()->SetRangeUser(30,60);
  htest1->Draw("colz");

  /////////////////////////////////////////////////////////////////////
  can6->SaveAs("TPC_dEdx_track_info.png");

  TObjArray *arr9 = new TObjArray();
  TObjArray *arr10 = new TObjArray();

  TCanvas *can7 = new TCanvas("can7","DCA vs #phi",1200,800);
  can7->Divide(4,2);

  can7->cd(1);
  h3D = (TH3*)fold->FindObject("h_tpc_track_pos_recvertex_3_5_6");
  TH3 *h3D71 = h3D->Clone("h3D71");
  h3D->GetYaxis()->SetRangeUser(0.0,maxeta);
  h3D->Project3D("xz")->Draw("colz");
  h3D->Project3D("xz")->SetTitle("DCAR vs #phi of pos. charged tracks(A)");

  can7->cd(2);
  h3D = (TH3*)fold->FindObject("h_tpc_track_neg_recvertex_3_5_6");
  TH3 *h3D72 = h3D->Clone("h3D72");
  h3D->GetYaxis()->SetRangeUser(0.0,maxeta);
  h3D->Project3D("xz")->Draw("colz");
  h3D->Project3D("xz")->SetTitle("DCAR vs #phi of neg. charged tracks(A)");

  can7->cd(3);
  h3D = (TH3*)fold->FindObject("h_tpc_track_pos_recvertex_4_5_6");
  TH3 *h3D73 = h3D->Clone("h3D73");
  h3D->GetYaxis()->SetRangeUser(0.0,maxeta);
  h3D->Project3D("xz")->Draw("colz");
  h3D->Project3D("xz")->SetTitle("DCAZ vs #phi of pos. charged tracks(A)");

  can7->cd(4);
  h3D = (TH3*)fold->FindObject("h_tpc_track_neg_recvertex_4_5_6");
  TH3 *h3D74 = h3D->Clone("h3D74");
  h3D->GetYaxis()->SetRangeUser(0.0,maxeta);
  h3D->Project3D("xz")->Draw("colz");
  h3D->Project3D("xz")->SetTitle("DCAZ vs #phi of neg. charged tracks(A)");
  PlotTimestamp(can7);

  can7->cd(5);
  //h3D = (TH3*)fold->FindObject("h_tpc_track_pos_recvertex_3_5_6");
  h3D71->GetYaxis()->SetRangeUser(mineta,-0.00001);
  h3D71->Project3D("xz")->Draw("colz");
  h3D71->Project3D("xz")->SetTitle("DCAR vs #phi of pos. charged tracks(C)");

  can7->cd(6);
  //h3D = (TH3*)fold->FindObject("h_tpc_track_neg_recvertex_3_5_6");
  h3D72->GetYaxis()->SetRangeUser(mineta,-0.00001);
  h3D72->Project3D("xz")->Draw("colz");
  h3D72->Project3D("xz")->SetTitle("DCAR vs #phi of neg. charged tracks(C)");

  can7->cd(7);
  //h3D = (TH3*)fold->FindObject("h_tpc_track_pos_recvertex_4_5_6");
  h3D73->GetYaxis()->SetRangeUser(mineta,-0.00001);
  h3D73->Project3D("xz")->Draw("colz");
  h3D73->Project3D("xz")->SetTitle("DCAZ vs #phi of pos. charged tracks(C)");

  can7->cd(8);
  //h3D = (TH3*)fold->FindObject("h_tpc_track_neg_recvertex_4_5_6");
  h3D74->GetYaxis()->SetRangeUser(mineta,-0.00001);
  h3D74->Project3D("xz")->Draw("colz");
  h3D74->Project3D("xz")->SetTitle("DCAZ vs #phi of neg. charged tracks(C)");


  can7->SaveAs("dca_and_phi.png");


  AliPerformanceMatch *obj2 = (AliPerformanceMatch*)TPC->FindObject("AliPerformanceMatchTPCITS");
  TFolder *pMatch = obj2->GetAnalysisFolder();

  AliPerformanceMatch *obj3 = (AliPerformanceMatch*)TPC->FindObject("AliPerformanceMatchITSTPC");
  TFolder *pPull = obj3->GetAnalysisFolder();

  //
  // event level
  //

  TH1 *h1D = 0;
  TH1 *h1D1 = 0;
  TH1 *h1D2 = 0;
  TH1 *h1D3 = 0;
  TH2 *h2D = 0;
  TH2 *h2D1 = 0;

  TCanvas *can8 = new TCanvas("can8","TPC-ITS Matching Efficiency",800,800);
  can8->Divide(2,2);

  can8->cd(1);
  h2D = (TH2*)(pMatch->FindObject("h_tpc_match_trackingeff_all_2_3"));
  h2D1 = (TH2*)(pMatch->FindObject("h_tpc_match_trackingeff_tpc_2_3"));
  TH2 *h2D2 = h2D->Clone("h2D2");
  TH2 *h2D3 = h2D1->Clone("h2D3");

  h2D->GetXaxis()->SetRangeUser(0,1.5);
  h2D1->GetXaxis()->SetRangeUser(0,1.5);
  h1D = h2D->ProjectionY();
  h1D1 = h2D1->ProjectionY();
  h1D1->Divide(h1D);
  h1D1->GetYaxis()->SetRangeUser(0,1.05);
  h1D1->SetTitle("TPC-ITS Matching Efficiency (A)");
  h1D1->Draw("e0");

  can8->cd(2);
  h2D2->GetXaxis()->SetRangeUser(-1.5,0);
  h2D3->GetXaxis()->SetRangeUser(-1.5,0);
  h1D2 = h2D2->ProjectionY();
  h1D3 = h2D3->ProjectionY();
  h1D3->Divide(h1D2);
  h1D3->SetLineColor(2);
  h1D3->GetYaxis()->SetRangeUser(0,1.05);
  h1D3->SetTitle("TPC-ITS Matching Efficiency (C)");
  h1D3->Draw("e0");
  PlotTimestamp(can8);

  can8->cd(3);
  h2D = (TH2*)(pMatch->FindObject("h_tpc_match_trackingeff_all_1_3"));
  h2D1 = (TH2*)(pMatch->FindObject("h_tpc_match_trackingeff_tpc_1_3"));
  TH2 *h2D4 = h2D->Clone("h2D4");
  TH2 *h2D5 = h2D1->Clone("h2D5");

  h2D->GetXaxis()->SetRangeUser(0,1.5);
  h2D1->GetXaxis()->SetRangeUser(0,1.5);
  h1D = h2D->ProjectionY();
  h1D1 = h2D1->ProjectionY();
  h1D1->Divide(h1D);
  h1D1->SetTitle("TPC-ITS Matching Efficiency (A)");
  h1D1->Draw("e0");

  can8->cd(4);
  h2D4->GetXaxis()->SetRangeUser(-1.5,0);
  h2D5->GetXaxis()->SetRangeUser(-1.5,0);
  h1D2 = h2D4->ProjectionY();
  h1D3 = h2D5->ProjectionY();
  h1D3->Divide(h1D2);
  h1D3->SetLineColor(2);
  h1D3->SetTitle("TPC-ITS Matching Efficiency (C)");
  h1D3->Draw("e0");

  can8->SaveAs("TPC-ITS.png");
  //  TH2 *h2D = 0;

  TCanvas *can9 = new TCanvas("can9","Pulls of TPC Tracks vs 1/pT",1200,800);
  can9->Divide(3,2);

  TObjArray *arr1 = new TObjArray();
  TObjArray *arr2 = new TObjArray();
  TObjArray *arr3 = new TObjArray();
  TObjArray *arr4 = new TObjArray();
  TObjArray *arr5 = new TObjArray();

  can9->cd(1);
  h2D = (TH2*)(pPull->FindObject("h_tpc_match_pull_0_7"));
  h2D->FitSlicesY(0,0,-1,0,"QNR",arr1);
  h2D->Draw("colz");
  arr1->At(1)->Draw("same");

  can9->cd(2);
  h2D = (TH2*)(pPull->FindObject("h_tpc_match_pull_1_7"));
  h2D->FitSlicesY(0,0,-1,0,"QNR",arr2);
  h2D->Draw("colz");
  arr2->At(1)->Draw("same");

  can9->cd(3);
  h2D = (TH2*)(pPull->FindObject("h_tpc_match_pull_2_7"));
  h2D->FitSlicesY(0,0,-1,0,"QNR",arr3);
  h2D->Draw("colz");
  arr3->At(1)->Draw("same");

  can9->cd(4);
  h2D = (TH2*)(pPull->FindObject("h_tpc_match_pull_3_7"));
  h2D->FitSlicesY(0,0,-1,0,"QNR",arr4);
  h2D->Draw("colz");
  arr4->At(1)->Draw("same");

  can9->cd(5);
  h2D = (TH2*)(pPull->FindObject("h_tpc_match_pull_4_7"));
  h2D->FitSlicesY(0,0,-1,0,"QNR",arr5);
  h2D->Draw("colz");
  arr5->At(1)->Draw("same");

  can9->cd(6);
  PlotTimestamp(can9);

  can9->SaveAs("pull-pt.png");

  TCanvas *can10 = new TCanvas("can10","Pulls of TPC Tracks vs Eta",1200,800);
  can10->Divide(3,2);

  TObjArray *arr6 = new TObjArray();
  TObjArray *arr7 = new TObjArray();
  TObjArray *arr8 = new TObjArray();
  TObjArray *arr9 = new TObjArray();
  TObjArray *arr10 = new TObjArray();

  can10->cd(1);
  h2D = (TH2*)(pPull->FindObject("h_tpc_match_pull_0_6"));
  h2D->FitSlicesY(0,0,-1,0,"QNR",arr6);
  h2D->Draw("colz");
  arr6->At(1)->Draw("same");

  can10->cd(2);
  h2D = (TH2*)(pPull->FindObject("h_tpc_match_pull_1_6"));
  h2D->FitSlicesY(0,0,-1,0,"QNR",arr7);
  h2D->Draw("colz");
  arr7->At(1)->Draw("same");

  can10->cd(3);
  h2D = (TH2*)(pPull->FindObject("h_tpc_match_pull_2_6"));
  h2D->FitSlicesY(0,0,-1,0,"QNR",arr8);
  h2D->Draw("colz");
  arr8->At(1)->Draw("same");

  can10->cd(4);
  h2D = (TH2*)(pPull->FindObject("h_tpc_match_pull_3_6"));
  h2D->FitSlicesY(0,0,-1,0,"QNR",arr9);
  h2D->Draw("colz");
  arr9->At(1)->Draw("same");

  can10->cd(5);
  h2D = (TH2*)(pPull->FindObject("h_tpc_match_pull_4_6"));
  h2D->FitSlicesY(0,0,-1,0,"QNR",arr10);
  h2D->Draw("colz");
  arr10->At(1)->Draw("same");

  can10->cd(6);
  PlotTimestamp(can10);

  can10->SaveAs("pull-eta.png");

  TCanvas *can11 = new TCanvas("can11","Pulls of TPC Tracks vs Phi",1200,800);
  can11->Divide(3,2);

  TObjArray *arr11 = new TObjArray();
  TObjArray *arr12 = new TObjArray();
  TObjArray *arr13 = new TObjArray();
  TObjArray *arr14 = new TObjArray();
  TObjArray *arr15 = new TObjArray();

  can11->cd(1);
  h2D = (TH2*)(pPull->FindObject("h_tpc_match_pull_0_5"));
  h2D->FitSlicesY(0,0,-1,0,"QNR",arr11);
  h2D->Draw("colz");
  arr11->At(1)->Draw("same");

  can11->cd(2);
  h2D = (TH2*)(pPull->FindObject("h_tpc_match_pull_1_5"));
  h2D->FitSlicesY(0,0,-1,0,"QNR",arr12);
  h2D->Draw("colz");
  arr12->At(1)->Draw("same");

  can11->cd(3);
  h2D = (TH2*)(pPull->FindObject("h_tpc_match_pull_2_5"));
  h2D->FitSlicesY(0,0,-1,0,"QNR",arr13);
  h2D->Draw("colz");
  arr13->At(1)->Draw("same");

  can11->cd(4);
  h2D = (TH2*)(pPull->FindObject("h_tpc_match_pull_3_5"));
  h2D->FitSlicesY(0,0,-1,0,"QNR",arr14);
  h2D->Draw("colz");
  arr14->At(1)->Draw("same");

  can11->cd(5);
  h2D = (TH2*)(pPull->FindObject("h_tpc_match_pull_4_5"));
  h2D->FitSlicesY(0,0,-1,0,"QNR",arr15);
  h2D->Draw("colz");
  arr15->At(1)->Draw("same");

  can11->cd(6);
  PlotTimestamp(can11);

  can11->SaveAs("pull-phi.png");

  AliPerformanceMatch *obj4 = (AliPerformanceMatch*)TPC->FindObject("AliPerformanceMatchTPCConstrain");
  TFolder *pConstrain = obj4->GetAnalysisFolder();

  TCanvas *can12 = new TCanvas("can12","#delta_{sin#phi}/#sigma_{sin#phi}",800,800);
  can12->Divide(2,2);

  h3D = (TH3*)pConstrain->FindObject("h_tpc_constrain_tpc_0_2_3");
  TH3 *h31 = h3D->Clone("h31");

  can12->cd(1);
  h3D->GetZaxis()->SetRangeUser(0,maxeta);
  //  h3D->GetYaxis()->SetRangeUser(0.25,10);
  h2D = (TH2*)h3D->Project3D("xy");
  h2D->Draw("colz");
  h2D->SetTitle("A Side");
  h2D->SetYTitle("(sin#phi_{TPC} - sin#phi_{Global})/#sigma");
  h2D->FitSlicesY(0,0,-1,0,"QNR",arr11);
  arr11->At(1)->Draw("same");
  TH1 *width1 = (TH1*)arr11->At(2);
  width1->Draw("same");
  width1->SetLineColor(2);

  /*  h3D->Project3D("xy")->Draw("colz");
      h3D->Project3D("xy")->SetTitle("A Side");
      h3D->Project3D("xy")->SetYTitle("#delta_{sin#phi}/#sigma_{sin#phi}");
      h3D->Project3D("xy")->FitSlicesY(0,0,-1,0,"QNR",arr11);
      arr11->At(1)->Draw("same");  */

  can12->cd(2);
  h31->GetZaxis()->SetRangeUser(mineta,-0.001);
  //  h31->GetYaxis()->SetRangeUser(0.25,10);
  h2D = (TH2*)h31->Project3D("xy");
  h2D->Draw("colz");
  h2D->SetTitle("C Side");
  h2D->SetYTitle("(sin#phi_{TPC} - sin#phi_{Global})/#sigma");
  h2D->FitSlicesY(0,0,-1,0,"QNR",arr12);
  arr12->At(1)->Draw("same");
  TH1 *width2 = (TH1*)arr12->At(2);
  width2->Draw("same");
  width2->SetLineColor(2);
  PlotTimestamp(can1);

  /*  h31->Project3D("xy")->Draw("colz");
      h31->Project3D("xy")->SetTitle("C Side");
      h31->Project3D("xy")->SetYTitle("#delta_{sin#phi}/#sigma_{sin#phi}");
      h31->Project3D("xy")->FitSlicesY(0,0,-1,0,"QNR",arr12);
      arr12->At(1)->Draw("same");  */

  can12->cd(3);
  h3D = (TH3*)pConstrain->FindObject("h_tpc_constrain_tpc_0_1_3");
  h3D->GetZaxis()->SetRangeUser(0,maxeta);
  TH3 *h32 = h3D->Clone("h32");
  h2D = (TH2*)h3D->Project3D("xy");
  h2D->Draw("colz");
  h2D->SetTitle("A Side");
  h2D->SetYTitle("(sin#phi_{TPC} - sin#phi_{Global})/#sigma");
  h2D->FitSlicesY(0,0,-1,0,"QNR",arr13);
  arr13->At(1)->Draw("same");
  TH1 *width3 = (TH1*)arr13->At(2);
  width3->Draw("same");
  width3->SetLineColor(2);

  /*  h3D->Project3D("xy")->Draw("colz");
      h3D->Project3D("xy")->SetTitle("A Side");
      h3D->Project3D("xy")->SetYTitle("#delta_{sin#phi}/#sigma_{sin#phi}");
      h3D->Project3D("xy")->FitSlicesY(0,0,-1,0,"QNR",arr13);
      arr13->At(1)->Draw("same");  */

  can12->cd(4);
  h32->GetZaxis()->SetRangeUser(mineta,-0.001);
  h2D = (TH2*)h32->Project3D("xy");
  h2D->Draw("colz");
  h2D->SetTitle("C Side");
  h2D->SetYTitle("(sin#phi_{TPC} - sin#phi_{Global})/#sigma");
  h2D->FitSlicesY(0,0,-1,0,"QNR",arr14);
  arr14->At(1)->Draw("same");
  TH1 *width4 = (TH1*)arr14->At(2);
  width4->Draw("same");
  width4->SetLineColor(2);

  /*  h32->Project3D("xy")->Draw("colz");
      h32->Project3D("xy")->SetTitle("C Side");
      h32->Project3D("xy")->SetYTitle("#delta_{sin#phi}/#sigma_{sin#phi}");
      h32->Project3D("xy")->FitSlicesY(0,0,-1,0,"QNR",arr14);
      arr14->At(1)->Draw("same");  */

  can12->SaveAs("pullPhiConstrain.png");

  //
  // resolution and efficiency plots from David - added by Patrick
  //
  /*
     AliPerformanceRes *objPerfRes = (AliPerformanceRes*) TPC->FindObject("AliPerformanceRes");
     if (objPerfRes == NULL) {printf("Error getting AliPerformanceRes\n");}
     TFolder *folderRes = objPerfRes->GetAnalysisFolder();
     TH1F* h_resPt_vs_Pt       = (TH1F*)folderRes->FindObject("h_res_4_vs_9");
     TH1F* h_mean_resPt_vs_Pt  = (TH1F*)folderRes->FindObject("h_mean_res_4_vs_9");
     TH1F* h_pullPt_vs_Pt      = (TH1F*)folderRes->FindObject("h_pull_4_vs_9");
     TH1F* h_mean_pullPt_vs_Pt = (TH1F*)folderRes->FindObject("h_mean_pull_4_vs_9");

     TCanvas *can13 = new TCanvas("can13","Resolution p_{T}",800,800);
     can13->Divide(2,2);
     can13->cd(1);
     h_resPt_vs_Pt      ->Draw();
     can13->cd(2);
     h_mean_resPt_vs_Pt ->Draw();
     can13->cd(3);
     h_pullPt_vs_Pt     ->Draw();
     can13->cd(4);
     h_mean_pullPt_vs_Pt->Draw();

     can13->SaveAs("res_pT_1overpT.png");

     AliPerformanceEff *objPerfEff = (AliPerformanceEff*) TPC->FindObject("AliPerformanceEff");
     if (objPerfEff == NULL) {printf("Error getting AliPerformanceEff\n");}
     TFolder *folderEff = objPerfEff->GetAnalysisFolder();
     TH1F* eta_all              = (TH1F*)folderEff->FindObject("etaRecEff");
     TH1F* eta_all_neg          = (TH1F*)folderEff->FindObject("etaRecEffNeg");
     TH1F* eta_all_pos          = (TH1F*)folderEff->FindObject("etaRecEffPos");
     TH1F* phi_all              = (TH1F*)folderEff->FindObject("phiRecEff");
     TH1F* phi_all_neg          = (TH1F*)folderEff->FindObject("phiRecEffNeg");
     TH1F* phi_all_pos          = (TH1F*)folderEff->FindObject("phiRecEffPos");
     TH1F* pt_all               = (TH1F*)folderEff->FindObject("ptRecEff");
     TH1F* pt_all_neg           = (TH1F*)folderEff->FindObject("ptRecEffNeg");
     TH1F* pt_all_pos           = (TH1F*)folderEff->FindObject("ptRecEffPos");
     TH1F* eta_all_findable     = (TH1F*)folderEff->FindObject("etaRecEffF");
     TH1F* eta_all_findable_neg = (TH1F*)folderEff->FindObject("etaRecEffFNeg");
     TH1F* eta_all_findable_pos = (TH1F*)folderEff->FindObject("etaRecEffFPos");
     TH1F* phi_all_findable     = (TH1F*)folderEff->FindObject("phiRecEffF");
     TH1F* phi_all_findable_neg = (TH1F*)folderEff->FindObject("phiRecEffFNeg");
     TH1F* phi_all_findable_pos = (TH1F*)folderEff->FindObject("phiRecEffFPos");
     TH1F* pt_all_findable      = (TH1F*)folderEff->FindObject("ptRecEffF");
     TH1F* pt_all_findable_neg  = (TH1F*)folderEff->FindObject("ptRecEffFNeg");
     TH1F* pt_all_findable_pos  = (TH1F*)folderEff->FindObject("ptRecEffFPos");
     TH1F* eta_Pi               = (TH1F*)folderEff->FindObject("etaRecEffPi");
     TH1F* eta_Pi_neg           = (TH1F*)folderEff->FindObject("etaRecEffPiNeg");
     TH1F* eta_Pi_pos           = (TH1F*)folderEff->FindObject("etaRecEffPiPos");
     TH1F* phi_Pi               = (TH1F*)folderEff->FindObject("phiRecEffPi");
     TH1F* phi_Pi_neg           = (TH1F*)folderEff->FindObject("phiRecEffPiNeg");
     TH1F* phi_Pi_pos           = (TH1F*)folderEff->FindObject("phiRecEffPiPos");
     TH1F* pt_Pi                = (TH1F*)folderEff->FindObject("ptRecEffPi");
     TH1F* pt_Pi_neg            = (TH1F*)folderEff->FindObject("ptRecEffPiNeg");
     TH1F* pt_Pi_pos            = (TH1F*)folderEff->FindObject("ptRecEffPiPos");
     TH1F* eta_K                = (TH1F*)folderEff->FindObject("etaRecEffK");
     TH1F* eta_K_neg            = (TH1F*)folderEff->FindObject("etaRecEffKNeg");
     TH1F* eta_K_pos            = (TH1F*)folderEff->FindObject("etaRecEffKPos");
     TH1F* phi_K                = (TH1F*)folderEff->FindObject("phiRecEffK");
     TH1F* phi_K_neg            = (TH1F*)folderEff->FindObject("phiRecEffKNeg");
     TH1F* phi_K_pos            = (TH1F*)folderEff->FindObject("phiRecEffKPos");
     TH1F* pt_K                 = (TH1F*)folderEff->FindObject("ptRecEffK");
     TH1F* pt_K_neg             = (TH1F*)folderEff->FindObject("ptRecEffKNeg");
     TH1F* pt_K_pos             = (TH1F*)folderEff->FindObject("ptRecEffKPos");
     TH1F* eta_P                = (TH1F*)folderEff->FindObject("etaRecEffP");
     TH1F* eta_P_neg            = (TH1F*)folderEff->FindObject("etaRecEffPNeg");
     TH1F* eta_P_pos            = (TH1F*)folderEff->FindObject("etaRecEffPPos");
     TH1F* phi_P                = (TH1F*)folderEff->FindObject("phiRecEffP");
     TH1F* phi_P_neg            = (TH1F*)folderEff->FindObject("phiRecEffPNeg");
     TH1F* phi_P_pos            = (TH1F*)folderEff->FindObject("phiRecEffPPos");
     TH1F* pt_P                 = (TH1F*)folderEff->FindObject("ptRecEffP");
     TH1F* pt_P_neg             = (TH1F*)folderEff->FindObject("ptRecEffPNeg");
     TH1F* pt_P_pos             = (TH1F*)folderEff->FindObject("ptRecEffPPos");
     eta_all             ->SetLineWidth(2);
  eta_all_neg         ->SetLineColor(kRed);
  eta_all_pos         ->SetLineColor(kBlue);
  phi_all             ->SetLineWidth(2);
  phi_all_neg         ->SetLineColor(kRed);
  phi_all_pos         ->SetLineColor(kBlue);
  pt_all              ->SetLineWidth(2);
  pt_all_neg          ->SetLineColor(kRed);
  pt_all_pos          ->SetLineColor(kBlue);
  eta_all_findable    ->SetLineWidth(2);
  eta_all_findable_neg->SetLineColor(kRed);
  eta_all_findable_pos->SetLineColor(kBlue);
  phi_all_findable    ->SetLineWidth(2);
  phi_all_findable_neg->SetLineColor(kRed);
  phi_all_findable_pos->SetLineColor(kBlue);
  pt_all_findable     ->SetLineWidth(2);
  pt_all_findable_neg ->SetLineColor(kRed);
  pt_all_findable_pos ->SetLineColor(kBlue);
  eta_Pi              ->SetLineWidth(2);
  eta_Pi_neg          ->SetLineColor(kRed);
  eta_Pi_pos          ->SetLineColor(kBlue);
  phi_Pi              ->SetLineWidth(2);
  phi_Pi_neg          ->SetLineColor(kRed);
  phi_Pi_pos          ->SetLineColor(kBlue);
  pt_Pi               ->SetLineWidth(2);
  pt_Pi_neg           ->SetLineColor(kRed);
  pt_Pi_pos           ->SetLineColor(kBlue);
  eta_K               ->SetLineWidth(2);
  eta_K_neg           ->SetLineColor(kRed);
  eta_K_pos           ->SetLineColor(kBlue);
  phi_K               ->SetLineWidth(2);
  phi_K_neg           ->SetLineColor(kRed);
  phi_K_pos           ->SetLineColor(kBlue);
  pt_K                ->SetLineWidth(2);
  pt_K_neg            ->SetLineColor(kRed);
  pt_K_pos            ->SetLineColor(kBlue);
  eta_P               ->SetLineWidth(2);
  eta_P_neg           ->SetLineColor(kRed);
  eta_P_pos           ->SetLineColor(kBlue);
  phi_P               ->SetLineWidth(2);
  phi_P_neg           ->SetLineColor(kRed);
  phi_P_pos           ->SetLineColor(kBlue);
  pt_P                ->SetLineWidth(2);
  pt_P_neg            ->SetLineColor(kRed);
  pt_P_pos            ->SetLineColor(kBlue);

  TCanvas *can14 = new TCanvas("can14","Efficiency All",1000,800);
  can14->Divide(3, 2);
  can14->cd(1);
  eta_all             ->Draw();
  eta_all_neg         ->Draw("same");
  eta_all_pos         ->Draw("same");
  can14->cd(2);
  phi_all             ->Draw();
  phi_all_neg         ->Draw("same");
  phi_all_pos         ->Draw("same");
  can14->cd(3);
  pt_all              ->Draw();
  pt_all_neg          ->Draw("same");
  pt_all_pos          ->Draw("same");
  can14->cd(4);
  eta_all_findable    ->Draw();
  eta_all_findable_neg->Draw("same");
  eta_all_findable_pos->Draw("same");
  can14->cd(5);
  phi_all_findable    ->Draw();
  phi_all_findable_neg->Draw("same");
  phi_all_findable_pos->Draw("same");
  can14->cd(6);
  pt_all_findable     ->Draw();
  pt_all_findable_neg ->Draw("same");
  pt_all_findable_pos ->Draw("same");

  can14->SaveAs("eff_all+all_findable.png");

  TCanvas *can15 = new TCanvas("can15","Efficiency Pi K P",1000,1000);
  can15->Divide(3, 3);
  can15->cd(1);
  eta_Pi              ->Draw();
  eta_Pi_neg          ->Draw("same");
  eta_Pi_pos          ->Draw("same");
  can15->cd(2);
  phi_Pi              ->Draw();
  phi_Pi_neg          ->Draw("same");
  phi_Pi_pos          ->Draw("same");
  can15->cd(3);
  pt_Pi               ->Draw();
  pt_Pi_neg           ->Draw("same");
  pt_Pi_pos           ->Draw("same");
  can15->cd(4);
  eta_K               ->Draw();
  eta_K_neg           ->Draw("same");
  eta_K_pos           ->Draw("same");
  can15->cd(5);
  phi_K               ->Draw();
  phi_K_neg           ->Draw("same");
  phi_K_pos           ->Draw("same");
  can15->cd(6);
  pt_K                ->Draw();
  pt_K_neg            ->Draw("same");
  pt_K_pos            ->Draw("same");
  can15->cd(7);
  eta_P               ->Draw();
  eta_P_neg           ->Draw("same");
  eta_P_pos           ->Draw("same");
  can15->cd(8);
  phi_P               ->Draw();
  phi_P_neg           ->Draw("same");
  phi_P_pos           ->Draw("same");
  can15->cd(9);
  pt_P                ->Draw();
  pt_P_neg            ->Draw("same");
  pt_P_pos            ->Draw("same");

  can15->SaveAs("eff_Pi_K_P.png");

  //get more histos from THnSparse...
  THnSparseF* EffHisto = (THnSparseF*) objPerfEff->GetEffHisto();
  //mceta:mcphi:mcpt:pid:recStatus:findable:charge:nclones:nfakes
  //pid:e-=0,mu-=1,pi+=2,K+=3,p+=4
  TH1* h_pid    = (TH1*) EffHisto->Projection(3);
  TH1* h_charge = (TH1*) EffHisto->Projection(6);
  //TH1* h_find  = (TH1*) EffHisto->Projection(5);
  //TH1* eta_All = (TH1*) EffHisto->Projection(0);

  cout<<"before setrange"<<endl;
  EffHisto->GetAxis(5)->SetRangeUser(1, 1.999); //set findable
  EffHisto->GetAxis(3)->SetRangeUser(2, 2.999); //set pion
  cout<<"after setrange"<<endl;
  TH1* h_charge_sel = (TH1*) EffHisto->Projection(6);
  cout<<"after projection"<<endl;
  EffHisto->GetAxis(6)->UnZoom(); //set all charges
  TH1* eta_Pi_findable = (TH1*) EffHisto->Projection(0);
  TH1* phi_Pi_findable = (TH1*) EffHisto->Projection(1);
  TH1* pt_Pi_findable  = (TH1*) EffHisto->Projection(2);
  EffHisto->GetAxis(6)->SetRangeUser(-1.5, -0.499); //set negative
  TH1* eta_Pi_findable_neg = (TH1*) EffHisto->Projection(0);
  TH1* phi_Pi_findable_neg = (TH1*) EffHisto->Projection(1);
  TH1* pt_Pi_findable_neg  = (TH1*) EffHisto->Projection(2);
  EffHisto->GetAxis(6)->SetRangeUser(0.5, 1.499); //set positive
  TH1* eta_Pi_findable_pos = (TH1*) EffHisto->Projection(0);
  TH1* phi_Pi_findable_pos = (TH1*) EffHisto->Projection(1);
  TH1* pt_Pi_findable_pos  = (TH1*) EffHisto->Projection(2);
  //EffHisto->GetAxis(3)->SetRangeUser(3, 3.999); //set kaon
  //EffHisto->GetAxis(6)->UnZoom(); //set all charges

  //EffHisto->GetAxis(3)->SetRangeUser(4, 4.999); //set proton

  eta_Pi_findable     ->SetLineWidth(2);
  eta_Pi_findable_neg ->SetLineColor(kRed);
  eta_Pi_findable_pos ->SetLineColor(kBlue);
  phi_Pi_findable     ->SetLineWidth(2);
  phi_Pi_findable_neg ->SetLineColor(kRed);
  phi_Pi_findable_pos ->SetLineColor(kBlue);
  pt_Pi_findable      ->SetLineWidth(2);
  pt_Pi_findable_neg  ->SetLineColor(kRed);
  pt_Pi_findable_pos  ->SetLineColor(kBlue);
  //eta_K_findable      ->SetLineWidth(2);
  //eta_K_findable_neg  ->SetLineColor(kRed);
  //eta_K_findable_pos  ->SetLineColor(kBlue);
  //phi_K_findable      ->SetLineWidth(2);
  //phi_K_findable_neg  ->SetLineColor(kRed);
  //phi_K_findable_pos  ->SetLineColor(kBlue);
  //pt_K_findable       ->SetLineWidth(2);
  //pt_K_findable_neg   ->SetLineColor(kRed);
  //pt_K_findable_pos   ->SetLineColor(kBlue);
  //eta_P_findable      ->SetLineWidth(2);
  //eta_P_findable_neg  ->SetLineColor(kRed);
  //eta_P_findable_pos  ->SetLineColor(kBlue);
  //phi_P_findable      ->SetLineWidth(2);
  //phi_P_findable_neg  ->SetLineColor(kRed);
  //phi_P_findable_pos  ->SetLineColor(kBlue);
  //pt_P_findable       ->SetLineWidth(2);
  //pt_P_findable_neg   ->SetLineColor(kRed);
  //pt_P_findable_pos   ->SetLineColor(kBlue);

  TCanvas *can16 = new TCanvas("can16","Efficiency Pi K P findable",1000,1000);
  can16->Divide(3,3);
  can16->cd(7);
  h_pid->Draw();
  can16->cd(8);
  h_charge->Draw();
  can16->cd(9);
  h_charge_sel->Draw();
  can16->cd(1);
  eta_Pi_findable->Draw();
  eta_Pi_findable_neg->Draw("same");
  eta_Pi_findable_pos->Draw("same");
  can16->cd(2);
  phi_Pi_findable->Draw();
  phi_Pi_findable_neg->Draw("same");
  phi_Pi_findable_pos->Draw("same");
  can16->cd(3);
  pt_Pi_findable->Draw();
  pt_Pi_findable_neg->Draw("same");
  pt_Pi_findable_pos->Draw("same");

  can16->SaveAs("eff_Pi_K_P_findable.png");
  */

    ofstream fout("runqa_exist");
  //if(NEvents>0)
  fout.precision(10);
  fout<<NEvents<<endl;
  fout.close();

}
예제 #26
0
PostProcessQAV0(Bool_t lAttemptInvMassFit = kTRUE,
                Char_t *output            = "pdf"                          // "eps", "png" or "pdf"
               ){


  CustomGStyleSettings();  

  //==============================================================
  //Open Output File
  TFile* file = TFile::Open("AnalysisResults.root"), "READ");
  if (!file){
    cout<<"Output file not found!"<<endl;
    return;
  }
	file->cd("PWGLFQAV0_QA");
	TList* clist  = (TList*)file->FindObjectAny("clist");
  if (!clist){
    cout<<"File does not seem to hold QA list output!"<<endl;
    return;
  }  
  //==============================================================

  //==============================================================
  //Open Event Histogram: first canvas
  TH1D* fHistEvent = (TH1D*)clist->FindObject("fHistEvent");
  TCanvas *cHistEvent = new TCanvas("cHistEvent","",800,670); 
  cHistEvent->SetTopMargin(0.15);
  cHistEvent->SetGridx(); 
  cHistEvent->SetGridy();
  fHistEvent->Draw();

  fHistEvent->SetMarkerSize(1.35);
  fHistEvent->GetXaxis()->SetTitleOffset(1.2);
  fHistEvent->GetYaxis()->SetTitleOffset(1.2);
  fHistEvent->Draw("same text00");

  TLatex Tl;
  Tl.SetNDC();
  Tl.SetTextSize(0.05);
  Tl.DrawLatex(.35, .9277, "Event Counters")  ;  
  if      (output == "png") cHistEvent->SaveAs("LF_QAanalysis_V0_page1.png");  
  else if (output == "eps") cHistEvent->SaveAs("LF_QAanalysis_V0_page1.eps");
  else if (output == "pdf") cHistEvent->SaveAs("LF_QAanalysis_V0.pdf(");    

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

  //==============================================================
  //Invariant Mass Plots: Base, no dE/dx
  /*
  TH2D *f2dHistInvMassK0Short    = (TH2D*)clist->FindObject("f2dHistInvMassK0Short");
  TH2D *f2dHistInvMassLambda     = (TH2D*)clist->FindObject("f2dHistInvMassLambda");
  TH2D *f2dHistInvMassAntiLambda = (TH2D*)clist->FindObject("f2dHistInvMassAntiLambda");
    
  f2dHistInvMassK0Short     -> Scale ( 1. / ((Double_t)fHistEvent->GetBinContent(4) ) );
  f2dHistInvMassLambda      -> Scale ( 1. / ((Double_t)fHistEvent->GetBinContent(4) ) );
  f2dHistInvMassAntiLambda  -> Scale ( 1. / ((Double_t)fHistEvent->GetBinContent(4) ) );

  TCanvas *cInvMassK0Short = new TCanvas ( "cInvMassK0Short", "", 1200,800); 
  cInvMassK0Short->Divide(1,2); 
  cInvMassK0Short->cd(2)->Divide(3,1); 
  cInvMassK0Short->cd(1); 
  cInvMassK0Short->cd(1)->SetLogz();
  cInvMassK0Short->cd(1)->SetLeftMargin(0.065);
  cInvMassK0Short->cd(1)->SetTopMargin(0.13);
  cInvMassK0Short->cd(1)->SetBottomMargin(0.11);

  f2dHistInvMassK0Short->GetYaxis()->SetTitleSize(0.05);
  f2dHistInvMassK0Short->GetYaxis()->SetTitleOffset(0.6);
  f2dHistInvMassK0Short->GetXaxis()->SetTitleSize(0.05);
  f2dHistInvMassK0Short->GetXaxis()->SetTitle("p_{T} (GeV/c)");
  f2dHistInvMassK0Short->GetZaxis()->SetTitle("Counts / Event");
  f2dHistInvMassK0Short->GetZaxis()->SetTitleOffset(0.7);
  f2dHistInvMassK0Short->GetZaxis()->SetRangeUser( f2dHistInvMassK0Short->GetMinimum(1e-10)*0.9, f2dHistInvMassK0Short->GetMaximum()*1.2 );
  f2dHistInvMassK0Short->Draw("colz");
  Tl.DrawLatex(.35, .9277, "Mass under K^{0}_{S} hypothesis, no TPC dE/dx")  ;   

  TH1D *fLowPtK0ShortSample = (TH1D*) f2dHistInvMassK0Short->ProjectionY( "fLowPtK0ShortSample", 
    f2dHistInvMassK0Short->GetXaxis()->FindBin(0.5001),
    f2dHistInvMassK0Short->GetXaxis()->FindBin(0.9999) );

  TH1D *fMidPtK0ShortSample = (TH1D*) f2dHistInvMassK0Short->ProjectionY( "fMidPtK0ShortSample", 
    f2dHistInvMassK0Short->GetXaxis()->FindBin(1.5001),
    f2dHistInvMassK0Short->GetXaxis()->FindBin(2.4999) );

  TH1D *fHiPtK0ShortSample = (TH1D*) f2dHistInvMassK0Short->ProjectionY( "fHiPtK0ShortSample", 
    f2dHistInvMassK0Short->GetXaxis()->FindBin(5.0001),
    f2dHistInvMassK0Short->GetXaxis()->FindBin(9.9999) );

  for(Int_t ic = 1; ic<4; ic++){ 
    cInvMassK0Short->cd(2)->cd(ic)->SetTopMargin(0.14);
    cInvMassK0Short->cd(2)->cd(ic)->SetLeftMargin(0.15);
    cInvMassK0Short->cd(2)->cd(ic)->SetBottomMargin(0.11);
    cInvMassK0Short->cd(2)->cd(ic)->SetGridx(); 
    cInvMassK0Short->cd(2)->cd(ic)->SetGridy();
  }

  cInvMassK0Short->cd(2)->cd(1); 
  fLowPtK0ShortSample->GetXaxis()->SetTitleOffset(1.1);
  fLowPtK0ShortSample->GetYaxis()->SetTitleOffset(2.33);
  fLowPtK0ShortSample->GetYaxis()->SetTitle("Counts/Event");
  fLowPtK0ShortSample->Draw(); 
  Tl.DrawLatex(.25, .9277, "0.5 < p_{T} (GeV/c^{2}) < 1.0");

  cInvMassK0Short->cd(2)->cd(2); 
  fMidPtK0ShortSample->GetXaxis()->SetTitleOffset(1.1);
  fMidPtK0ShortSample->GetYaxis()->SetTitleOffset(2.33);
  fMidPtK0ShortSample->GetYaxis()->SetTitle("Counts/Event");
  fMidPtK0ShortSample->Draw(); 
  Tl.DrawLatex(.25, .9277, "1.5 < p_{T} (GeV/c^{2}) < 2.5");

  cInvMassK0Short->cd(2)->cd(3); 
  fHiPtK0ShortSample->GetXaxis()->SetTitleOffset(1.1);
  fHiPtK0ShortSample->GetYaxis()->SetTitleOffset(2.33);
  fHiPtK0ShortSample->GetYaxis()->SetTitle("Counts/Event");
  fHiPtK0ShortSample->Draw(); 
  Tl.DrawLatex(.25, .9277, "5 < p_{T} (GeV/c^{2}) < 10");  
  if      (output == "png") cInvMassK0Short->SaveAs("LF_QAanalysis_V0_pageX.png");
  else if (output == "eps") cInvMassK0Short->SaveAs("LF_QAanalysis_V0_pageX.eps");
  else if (output == "pdf") cInvMassK0Short->SaveAs("LF_QAanalysis_V0.pdf");

  */
  //==============================================================

  //==============================================================
  //Invariant Mass Plots: WITH dE/dx
  TH2D *f2dHistInvMassWithdEdxK0Short    = (TH2D*)clist->FindObject("f2dHistInvMassWithdEdxK0Short");
  TH2D *f2dHistInvMassWithdEdxLambda     = (TH2D*)clist->FindObject("f2dHistInvMassWithdEdxLambda");
  TH2D *f2dHistInvMassWithdEdxAntiLambda = (TH2D*)clist->FindObject("f2dHistInvMassWithdEdxAntiLambda");
    
  f2dHistInvMassWithdEdxK0Short     -> Scale ( 1. / ((Double_t)fHistEvent->GetBinContent(4) ) );
  f2dHistInvMassWithdEdxLambda      -> Scale ( 1. / ((Double_t)fHistEvent->GetBinContent(4) ) );
  f2dHistInvMassWithdEdxAntiLambda  -> Scale ( 1. / ((Double_t)fHistEvent->GetBinContent(4) ) );

  TCanvas *cInvMassK0ShortWithdEdx = new TCanvas ( "cInvMassK0ShortWithdEdx", "", 1200,800); 
  cInvMassK0ShortWithdEdx->Divide(1,2); 
  cInvMassK0ShortWithdEdx->cd(2)->Divide(3,1); 
  cInvMassK0ShortWithdEdx->cd(1); 
  cInvMassK0ShortWithdEdx->cd(1)->SetLogz();
  cInvMassK0ShortWithdEdx->cd(1)->SetLeftMargin(0.065);
  cInvMassK0ShortWithdEdx->cd(1)->SetTopMargin(0.13);
  cInvMassK0ShortWithdEdx->cd(1)->SetBottomMargin(0.11);

  f2dHistInvMassWithdEdxK0Short->GetYaxis()->SetTitleSize(0.05);
  f2dHistInvMassWithdEdxK0Short->GetYaxis()->SetTitleOffset(0.6);
  f2dHistInvMassWithdEdxK0Short->GetXaxis()->SetTitleSize(0.05);
  f2dHistInvMassWithdEdxK0Short->GetXaxis()->SetTitle("p_{T} (GeV/c)");
  f2dHistInvMassWithdEdxK0Short->GetZaxis()->SetTitle("Counts / Event");
  f2dHistInvMassWithdEdxK0Short->GetZaxis()->SetTitleOffset(0.7);
  f2dHistInvMassWithdEdxK0Short->GetZaxis()->SetRangeUser( f2dHistInvMassWithdEdxK0Short->GetMinimum(1e-10)*0.9, f2dHistInvMassWithdEdxK0Short->GetMaximum()*1.2 );
  f2dHistInvMassWithdEdxK0Short->Draw("colz");
  Tl.DrawLatex(.35, .9277, "Mass under K^{0}_{S} hypothesis, With TPC dE/dx")  ;   

  TH1D *fLowPtK0ShortSampleWithdEdx = (TH1D*) f2dHistInvMassWithdEdxK0Short->ProjectionY( "fLowPtK0ShortSampleWithdEdx", 
    f2dHistInvMassWithdEdxK0Short->GetXaxis()->FindBin(0.5001),
    f2dHistInvMassWithdEdxK0Short->GetXaxis()->FindBin(0.9999) );

  TH1D *fMidPtK0ShortSampleWithdEdx = (TH1D*) f2dHistInvMassWithdEdxK0Short->ProjectionY( "fMidPtK0ShortSampleWithdEdx", 
    f2dHistInvMassWithdEdxK0Short->GetXaxis()->FindBin(1.5001),
    f2dHistInvMassWithdEdxK0Short->GetXaxis()->FindBin(2.4999) );

  TH1D *fHiPtK0ShortSampleWithdEdx = (TH1D*) f2dHistInvMassWithdEdxK0Short->ProjectionY( "fHiPtK0ShortSampleWithdEdx", 
    f2dHistInvMassWithdEdxK0Short->GetXaxis()->FindBin(5.0001),
    f2dHistInvMassWithdEdxK0Short->GetXaxis()->FindBin(9.9999) );

  for(Int_t ic = 1; ic<4; ic++){ 
    cInvMassK0ShortWithdEdx->cd(2)->cd(ic)->SetTopMargin(0.14);
    cInvMassK0ShortWithdEdx->cd(2)->cd(ic)->SetLeftMargin(0.15);
    cInvMassK0ShortWithdEdx->cd(2)->cd(ic)->SetBottomMargin(0.11);
    cInvMassK0ShortWithdEdx->cd(2)->cd(ic)->SetGridx(); 
    cInvMassK0ShortWithdEdx->cd(2)->cd(ic)->SetGridy();
  }

  cInvMassK0ShortWithdEdx->cd(2)->cd(1); 
  fLowPtK0ShortSampleWithdEdx->GetXaxis()->SetTitleOffset(1.1);
  fLowPtK0ShortSampleWithdEdx->GetYaxis()->SetTitleOffset(2.33);
  fLowPtK0ShortSampleWithdEdx->GetYaxis()->SetTitle("Counts/Event");
  fLowPtK0ShortSampleWithdEdx->Draw(); 
  Tl.DrawLatex(.25, .9277, "0.5 < p_{T} (GeV/c^{2}) < 1.0");

  cInvMassK0ShortWithdEdx->cd(2)->cd(2); 
  fMidPtK0ShortSampleWithdEdx->GetXaxis()->SetTitleOffset(1.1);
  fMidPtK0ShortSampleWithdEdx->GetYaxis()->SetTitleOffset(2.33);
  fMidPtK0ShortSampleWithdEdx->GetYaxis()->SetTitle("Counts/Event");
  fMidPtK0ShortSampleWithdEdx->Draw(); 
  Tl.DrawLatex(.25, .9277, "1.5 < p_{T} (GeV/c^{2}) < 2.5");

  cInvMassK0ShortWithdEdx->cd(2)->cd(3); 
  fHiPtK0ShortSampleWithdEdx->GetXaxis()->SetTitleOffset(1.1);
  fHiPtK0ShortSampleWithdEdx->GetYaxis()->SetTitleOffset(2.33);
  fHiPtK0ShortSampleWithdEdx->GetYaxis()->SetTitle("Counts/Event");
  fHiPtK0ShortSampleWithdEdx->Draw(); 
  Tl.DrawLatex(.25, .9277, "5 < p_{T} (GeV/c^{2}) < 10");  

  TLatex Tli;
  Tli.SetNDC();
  Tli.SetTextSize(0.05);  

  if( lAttemptInvMassFit ){ 
    //Attempt rough signal extraction   
    TF1 *f1 = new TF1("f1","[0]+[1]*x+[2]*x*x+[3]*TMath::Gaus(x,[4],[5])",0.435, 0.565);
    //Reasonable first guess
    f1->SetParameter(0, fLowPtK0ShortSampleWithdEdx -> GetBinContent( fLowPtK0ShortSampleWithdEdx->FindBin(0.497-0.01) ) );
    f1->SetParameter(1, 0 );
    f1->SetParameter(2, 0 );
    f1->SetParameter(3, 0.5*fLowPtK0ShortSampleWithdEdx->GetMaximum() ); 
    f1->SetParameter(4, 0.497);
    f1->SetParameter(5, 0.0045);
    cout<<"Will now fit, please wait!"<<endl;
    fLowPtK0ShortSampleWithdEdx->Fit("f1","REM0");
    cInvMassK0ShortWithdEdx->cd(2)->cd(1); 
    f1->Draw("same"); 
    //Peak Position, Width: printout 
    fLowPtK0ShortSampleWithdEdx->GetYaxis()->SetRangeUser(0,fLowPtK0ShortSampleWithdEdx->GetMaximum() * 1.2);
    Tli.DrawLatex(0.2,0.8,Form("peak = %.4f #pm %.4f MeV/c^{2}",f1->GetParameter(4),f1->GetParameter(5)) ) ;
    
    //Attempt rough signal extraction   
    TF1 *f2 = new TF1("f2","[0]+[1]*x+[2]*x*x+[3]*TMath::Gaus(x,[4],[5])",0.375, 0.635);
    //Reasonable first guess
    f2->SetParameter(0, fMidPtK0ShortSampleWithdEdx -> GetBinContent( fMidPtK0ShortSampleWithdEdx->FindBin(0.497-0.01) ) );
    f2->SetParameter(1, 0 );
    f2->SetParameter(2, 0 );
    f2->SetParameter(3, 0.5*fMidPtK0ShortSampleWithdEdx->GetMaximum() ); 
    f2->SetParameter(4, 0.497);
    f2->SetParameter(5, 0.0045);
    cout<<"Will now fit, please wait!"<<endl;
    fMidPtK0ShortSampleWithdEdx->Fit("f2","REM0");
    cInvMassK0ShortWithdEdx->cd(2)->cd(2); 
    f2->Draw("same"); 
    //Peak Position, Width: printout 
    fMidPtK0ShortSampleWithdEdx->GetYaxis()->SetRangeUser(0,fMidPtK0ShortSampleWithdEdx->GetMaximum() * 1.2);
    Tli.DrawLatex(0.2,0.8,Form("peak = %.4f #pm %.4f MeV/c^{2}",f2->GetParameter(4),f2->GetParameter(5)) ) ;

    //Attempt rough signal extraction   
    TF1 *f3 = new TF1("f3","[0]+[1]*x+[2]*x*x+[3]*TMath::Gaus(x,[4],[5])",0.375, 0.665);
    //Reasonable first guess
    f3->SetParameter(0, fHiPtK0ShortSampleWithdEdx -> GetBinContent( fHiPtK0ShortSampleWithdEdx->FindBin(0.497-0.01) ) );
    f3->SetParameter(1, 0 );
    f3->SetParameter(2, 0 );
    f3->SetParameter(3, 0.5*fHiPtK0ShortSampleWithdEdx->GetMaximum() ); 
    f3->SetParameter(4, 0.497);
    f3->SetParameter(5, 0.0045);
    cout<<"Will now fit, please wait!"<<endl;
    fHiPtK0ShortSampleWithdEdx->Fit("f3","REM0");
    cInvMassK0ShortWithdEdx->cd(2)->cd(3); 
    f3->Draw("same"); 
    //Peak Position, Width: printout 
    fHiPtK0ShortSampleWithdEdx->GetYaxis()->SetRangeUser(0,fHiPtK0ShortSampleWithdEdx->GetMaximum() * 1.2);
    Tli.DrawLatex(0.2,0.8,Form("peak = %.4f #pm %.4f MeV/c^{2}",f3->GetParameter(4),f3->GetParameter(5)) ) ;
  }

  if      (output == "png") cInvMassK0ShortWithdEdx->SaveAs("LF_QAanalysis_V0_page2.png");      
  else if (output == "eps") cInvMassK0ShortWithdEdx->SaveAs("LF_QAanalysis_V0_page2.eps");
  else if (output == "pdf") cInvMassK0ShortWithdEdx->SaveAs("LF_QAanalysis_V0.pdf"); 

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


  //==============================================================
  //Invariant Mass Plots: Base, no dE/dx
  /*
  TCanvas *cInvMassLambda = new TCanvas ( "cInvMassLambda", "", 1200,800); 
  cInvMassLambda->Divide(1,2); 
  cInvMassLambda->cd(2)->Divide(3,1); 
  cInvMassLambda->cd(1); 
  cInvMassLambda->cd(1)->SetLogz();
  cInvMassLambda->cd(1)->SetLeftMargin(0.065);
  cInvMassLambda->cd(1)->SetTopMargin(0.13);
  cInvMassLambda->cd(1)->SetBottomMargin(0.11);

  f2dHistInvMassLambda->GetYaxis()->SetTitleSize(0.05);
  f2dHistInvMassLambda->GetYaxis()->SetTitleOffset(0.6);
  f2dHistInvMassLambda->GetXaxis()->SetTitleSize(0.05);
  f2dHistInvMassLambda->GetXaxis()->SetTitle("p_{T} (GeV/c)");
  f2dHistInvMassLambda->GetZaxis()->SetTitle("Counts / Event");
  f2dHistInvMassLambda->GetZaxis()->SetTitleOffset(0.7);
  f2dHistInvMassLambda->GetZaxis()->SetRangeUser( f2dHistInvMassLambda->GetMinimum(1e-10)*0.9, f2dHistInvMassLambda->GetMaximum()*1.2 );
  f2dHistInvMassLambda->Draw("colz");
  Tl.DrawLatex(.35, .9277, "Mass under #Lambda hypothesis, no TPC dE/dx")  ;   

  TH1D *fLowPtLambdaSample = (TH1D*) f2dHistInvMassLambda->ProjectionY( "fLowPtLambdaSample", 
    f2dHistInvMassLambda->GetXaxis()->FindBin(0.5001),
    f2dHistInvMassLambda->GetXaxis()->FindBin(0.9999) );

  TH1D *fMidPtLambdaSample = (TH1D*) f2dHistInvMassLambda->ProjectionY( "fMidPtLambdaSample", 
    f2dHistInvMassLambda->GetXaxis()->FindBin(1.5001),
    f2dHistInvMassLambda->GetXaxis()->FindBin(2.4999) );

  TH1D *fHiPtLambdaSample = (TH1D*) f2dHistInvMassLambda->ProjectionY( "fHiPtLambdaSample", 
    f2dHistInvMassLambda->GetXaxis()->FindBin(5.0001),
    f2dHistInvMassLambda->GetXaxis()->FindBin(9.9999) );

  for(Int_t ic = 1; ic<4; ic++){ 
    cInvMassLambda->cd(2)->cd(ic)->SetTopMargin(0.14);
    cInvMassLambda->cd(2)->cd(ic)->SetLeftMargin(0.15);
    cInvMassLambda->cd(2)->cd(ic)->SetBottomMargin(0.11);
    cInvMassLambda->cd(2)->cd(ic)->SetGridx(); 
    cInvMassLambda->cd(2)->cd(ic)->SetGridy();
  }

  cInvMassLambda->cd(2)->cd(1); 
  fLowPtLambdaSample->GetXaxis()->SetTitleOffset(1.1);
  fLowPtLambdaSample->GetYaxis()->SetTitleOffset(2.33);
  fLowPtLambdaSample->GetYaxis()->SetTitle("Counts/Event");
  fLowPtLambdaSample->Draw(); 
  Tl.DrawLatex(.25, .9277, "0.5 < p_{T} (GeV/c^{2}) < 1.0");

  cInvMassLambda->cd(2)->cd(2); 
  fMidPtLambdaSample->GetXaxis()->SetTitleOffset(1.1);
  fMidPtLambdaSample->GetYaxis()->SetTitleOffset(2.33);
  fMidPtLambdaSample->GetYaxis()->SetTitle("Counts/Event");
  fMidPtLambdaSample->Draw(); 
  Tl.DrawLatex(.25, .9277, "1.5 < p_{T} (GeV/c^{2}) < 2.5");

  cInvMassLambda->cd(2)->cd(3); 
  fHiPtLambdaSample->GetXaxis()->SetTitleOffset(1.1);
  fHiPtLambdaSample->GetYaxis()->SetTitleOffset(2.33);
  fHiPtLambdaSample->GetYaxis()->SetTitle("Counts/Event");
  fHiPtLambdaSample->Draw(); 
  Tl.DrawLatex(.25, .9277, "5 < p_{T} (GeV/c^{2}) < 10");  
  if      (output == "png") cInvMassLambda->SaveAs("LF_QAanalysis_V0_pageY.png");
  else if (output == "eps") cInvMassLambda->SaveAs("LF_QAanalysis_V0_pageY.eps");
  else if (output == "pdf") cInvMassLambda->SaveAs("LF_QAanalysis_V0.pdf");

  */
  //==============================================================

  //==============================================================
  //Invariant Mass Plots: WITH dE/dx
  TCanvas *cInvMassLambdaWithdEdx = new TCanvas ( "cInvMassLambdaWithdEdx", "", 1200,800); 
  cInvMassLambdaWithdEdx->Divide(1,2); 
  cInvMassLambdaWithdEdx->cd(2)->Divide(3,1); 
  cInvMassLambdaWithdEdx->cd(1); 
  cInvMassLambdaWithdEdx->cd(1)->SetLogz();
  cInvMassLambdaWithdEdx->cd(1)->SetLeftMargin(0.065);
  cInvMassLambdaWithdEdx->cd(1)->SetTopMargin(0.13);
  cInvMassLambdaWithdEdx->cd(1)->SetBottomMargin(0.11);

  f2dHistInvMassWithdEdxLambda->GetYaxis()->SetTitleSize(0.05);
  f2dHistInvMassWithdEdxLambda->GetYaxis()->SetTitleOffset(0.6);
  f2dHistInvMassWithdEdxLambda->GetXaxis()->SetTitleSize(0.05);
  f2dHistInvMassWithdEdxLambda->GetXaxis()->SetTitle("p_{T} (GeV/c)");
  f2dHistInvMassWithdEdxLambda->GetZaxis()->SetTitle("Counts / Event");
  f2dHistInvMassWithdEdxLambda->GetZaxis()->SetTitleOffset(0.7);
  f2dHistInvMassWithdEdxLambda->GetZaxis()->SetRangeUser( f2dHistInvMassWithdEdxLambda->GetMinimum(1e-10)*0.9, f2dHistInvMassWithdEdxLambda->GetMaximum()*1.2 );
  f2dHistInvMassWithdEdxLambda->Draw("colz");
  Tl.DrawLatex(.35, .9277, "Mass under #Lambda hypothesis, With TPC dE/dx")  ;   

  TH1D *fLowPtLambdaSampleWithdEdx = (TH1D*) f2dHistInvMassWithdEdxLambda->ProjectionY( "fLowPtLambdaSampleWithdEdx", 
    f2dHistInvMassWithdEdxLambda->GetXaxis()->FindBin(0.5001),
    f2dHistInvMassWithdEdxLambda->GetXaxis()->FindBin(0.9999) );

  TH1D *fMidPtLambdaSampleWithdEdx = (TH1D*) f2dHistInvMassWithdEdxLambda->ProjectionY( "fMidPtLambdaSampleWithdEdx", 
    f2dHistInvMassWithdEdxLambda->GetXaxis()->FindBin(1.5001),
    f2dHistInvMassWithdEdxLambda->GetXaxis()->FindBin(2.4999) );

  TH1D *fHiPtLambdaSampleWithdEdx = (TH1D*) f2dHistInvMassWithdEdxLambda->ProjectionY( "fHiPtLambdaSampleWithdEdx", 
    f2dHistInvMassWithdEdxLambda->GetXaxis()->FindBin(5.0001),
    f2dHistInvMassWithdEdxLambda->GetXaxis()->FindBin(9.9999) );

  for(Int_t ic = 1; ic<4; ic++){ 
    cInvMassLambdaWithdEdx->cd(2)->cd(ic)->SetTopMargin(0.14);
    cInvMassLambdaWithdEdx->cd(2)->cd(ic)->SetLeftMargin(0.15);
    cInvMassLambdaWithdEdx->cd(2)->cd(ic)->SetBottomMargin(0.11);
    cInvMassLambdaWithdEdx->cd(2)->cd(ic)->SetGridx(); 
    cInvMassLambdaWithdEdx->cd(2)->cd(ic)->SetGridy();
  }

  cInvMassLambdaWithdEdx->cd(2)->cd(1); 
  fLowPtLambdaSampleWithdEdx->GetXaxis()->SetTitleOffset(1.1);
  fLowPtLambdaSampleWithdEdx->GetYaxis()->SetTitleOffset(2.33);
  fLowPtLambdaSampleWithdEdx->GetYaxis()->SetTitle("Counts/Event");
  fLowPtLambdaSampleWithdEdx->Draw(); 
  Tl.DrawLatex(.25, .9277, "0.5 < p_{T} (GeV/c^{2}) < 1.0");

  cInvMassLambdaWithdEdx->cd(2)->cd(2); 
  fMidPtLambdaSampleWithdEdx->GetXaxis()->SetTitleOffset(1.1);
  fMidPtLambdaSampleWithdEdx->GetYaxis()->SetTitleOffset(2.33);
  fMidPtLambdaSampleWithdEdx->GetYaxis()->SetTitle("Counts/Event");
  fMidPtLambdaSampleWithdEdx->Draw(); 
  Tl.DrawLatex(.25, .9277, "1.5 < p_{T} (GeV/c^{2}) < 2.5");

  cInvMassLambdaWithdEdx->cd(2)->cd(3); 
  fHiPtLambdaSampleWithdEdx->GetXaxis()->SetTitleOffset(1.1);
  fHiPtLambdaSampleWithdEdx->GetYaxis()->SetTitleOffset(2.33);
  fHiPtLambdaSampleWithdEdx->GetYaxis()->SetTitle("Counts/Event");
  fHiPtLambdaSampleWithdEdx->Draw(); 
  Tl.DrawLatex(.25, .9277, "5 < p_{T} (GeV/c^{2}) < 10"); 

  if( lAttemptInvMassFit ){ 
    //Attempt rough signal extraction   
    TF1 *fl1 = new TF1("fl1","[0]+[1]*x+[2]*x*x+[3]*TMath::Gaus(x,[4],[5])",1.095, 1.14);
    //Reasonable first guess
    fl1->SetParameter(0, fLowPtLambdaSampleWithdEdx -> GetBinContent( fLowPtLambdaSampleWithdEdx->FindBin(1.116+0.01) ) );
    fl1->SetParameter(1, 0 );
    fl1->SetParameter(2, 0 );
    fl1->SetParameter(3, 0.35*fLowPtLambdaSampleWithdEdx->GetMaximum() ); 
    fl1->SetParameter(4, 1.115683);
    fl1->SetParLimits(4,1.116-0.01,1.116+0.01);
    fl1->SetParameter(5, 0.002);
    fl1->SetParLimits(5,0.0005,0.01);
    cout<<"Will now fit, please wait!"<<endl;
    fLowPtLambdaSampleWithdEdx->Fit("fl1","REM0");
    cInvMassLambdaWithdEdx->cd(2)->cd(1); 
    fl1->Draw("same"); 
    //Peak Position, Width: printout 
    fLowPtLambdaSampleWithdEdx->GetYaxis()->SetRangeUser(0,fLowPtLambdaSampleWithdEdx->GetMaximum() * 1.2);
    Tli.DrawLatex(0.2,0.8,Form("peak = %.4f #pm %.4f MeV/c^{2}",fl1->GetParameter(4),fl1->GetParameter(5)) ) ;
    
    //Attempt rough signal extraction   
    TF1 *fl2 = new TF1("fl2","[0]+[1]*x+[2]*x*x+[3]*TMath::Gaus(x,[4],[5])",1.085, 1.15);
    //Reasonable first guess
    fl2->SetParameter(0, fMidPtLambdaSampleWithdEdx -> GetBinContent( fMidPtLambdaSampleWithdEdx->FindBin(1.116+0.01) ) );
    fl2->SetParameter(1, 0 );
    fl2->SetParameter(2, 0 );
    fl2->SetParameter(3, 0.6*fMidPtLambdaSampleWithdEdx->GetMaximum() ); 
    fl2->SetParLimits(4,1.116-0.01,1.116+0.01);
    fl2->SetParameter(4, 1.116);
    fl2->SetParameter(5, 0.0025);
    fl2->SetParLimits(5,0.0005,0.01);
    cout<<"Will now fit, please wait!"<<endl;
    fMidPtLambdaSampleWithdEdx->Fit("fl2","REM0");
    cInvMassLambdaWithdEdx->cd(2)->cd(2); 
    fl2->Draw("same"); 
    //Peak Position, Width: printout 
    fMidPtLambdaSampleWithdEdx->GetYaxis()->SetRangeUser(0,fMidPtLambdaSampleWithdEdx->GetMaximum() * 1.2);
    Tli.DrawLatex(0.2,0.8,Form("peak = %.4f #pm %.4f MeV/c^{2}",fl2->GetParameter(4),fl2->GetParameter(5)) ) ;

    //Attempt rough signal extraction   
    TF1 *fl3 = new TF1("fl3","[0]+[1]*x+[2]*x*x+[3]*TMath::Gaus(x,[4],[5])",1.095, 1.15);
    //Reasonable first guess
    fl3->SetParameter(0, fHiPtLambdaSampleWithdEdx -> GetBinContent( fHiPtLambdaSampleWithdEdx->FindBin(1.116+0.01) ) );
    fl3->SetParameter(1, 0 );
    fl3->SetParameter(2, 0 );
    fl3->SetParameter(3, 0.6*fHiPtLambdaSampleWithdEdx->GetMaximum() ); 
    fl3->SetParameter(4, 1.116);
    fl3->SetParLimits(4,1.116-0.005,1.116+0.005);
    fl3->SetParameter(5, 0.0035);
    fl3->SetParLimits(5,0.0005,0.01);
    cout<<"Will now fit, please wait!"<<endl;
    fHiPtLambdaSampleWithdEdx->Fit("fl3","REM0");
    cInvMassLambdaWithdEdx->cd(2)->cd(3); 
    fl3->Draw("same"); 
    //Peak Position, Width: printout 
    fHiPtLambdaSampleWithdEdx->GetYaxis()->SetRangeUser(0,fHiPtLambdaSampleWithdEdx->GetMaximum() * 1.2);
    Tli.DrawLatex(0.2,0.8,Form("peak = %.4f #pm %.4f MeV/c^{2}",fl3->GetParameter(4),fl3->GetParameter(5)) ) ;
  }

 
  if      (output == "png") cInvMassLambdaWithdEdx->SaveAs("LF_QAanalysis_V0_page3.png");
  else if (output == "eps") cInvMassLambdaWithdEdx->SaveAs("LF_QAanalysis_V0_page3.eps");
  else if (output == "pdf") cInvMassLambdaWithdEdx->SaveAs("LF_QAanalysis_V0.pdf");
  //==============================================================  

  //==============================================================
  //Invariant Mass Plots: Base, no dE/dx
  /*
  TCanvas *cInvMassAntiLambda = new TCanvas ( "cInvMassAntiLambda", "", 1200,800); 
  cInvMassAntiLambda->Divide(1,2); 
  cInvMassAntiLambda->cd(2)->Divide(3,1); 
  cInvMassAntiLambda->cd(1); 
  cInvMassAntiLambda->cd(1)->SetLogz();
  cInvMassAntiLambda->cd(1)->SetLeftMargin(0.065);
  cInvMassAntiLambda->cd(1)->SetTopMargin(0.13);
  cInvMassAntiLambda->cd(1)->SetBottomMargin(0.11);

  f2dHistInvMassAntiLambda->GetYaxis()->SetTitleSize(0.05);
  f2dHistInvMassAntiLambda->GetYaxis()->SetTitleOffset(0.6);
  f2dHistInvMassAntiLambda->GetXaxis()->SetTitleSize(0.05);
  f2dHistInvMassAntiLambda->GetXaxis()->SetTitle("p_{T} (GeV/c)");
  f2dHistInvMassAntiLambda->GetZaxis()->SetTitle("Counts / Event");
  f2dHistInvMassAntiLambda->GetZaxis()->SetTitleOffset(0.7);
  f2dHistInvMassAntiLambda->GetZaxis()->SetRangeUser( f2dHistInvMassAntiLambda->GetMinimum(1e-10)*0.9, f2dHistInvMassAntiLambda->GetMaximum()*1.2 );
  f2dHistInvMassAntiLambda->Draw("colz");
  Tl.DrawLatex(.35, .9277, "Mass under #bar{#Lambda} hypothesis, no TPC dE/dx")  ;   

  TH1D *fLowPtAntiLambdaSample = (TH1D*) f2dHistInvMassAntiLambda->ProjectionY( "fLowPtAntiLambdaSample", 
    f2dHistInvMassAntiLambda->GetXaxis()->FindBin(0.5001),
    f2dHistInvMassAntiLambda->GetXaxis()->FindBin(0.9999) );

  TH1D *fMidPtAntiLambdaSample = (TH1D*) f2dHistInvMassAntiLambda->ProjectionY( "fMidPtAntiLambdaSample", 
    f2dHistInvMassAntiLambda->GetXaxis()->FindBin(1.5001),
    f2dHistInvMassAntiLambda->GetXaxis()->FindBin(2.4999) );

  TH1D *fHiPtAntiLambdaSample = (TH1D*) f2dHistInvMassAntiLambda->ProjectionY( "fHiPtAntiLambdaSample", 
    f2dHistInvMassAntiLambda->GetXaxis()->FindBin(5.0001),
    f2dHistInvMassAntiLambda->GetXaxis()->FindBin(9.9999) );

  for(Int_t ic = 1; ic<4; ic++){ 
    cInvMassAntiLambda->cd(2)->cd(ic)->SetTopMargin(0.14);
    cInvMassAntiLambda->cd(2)->cd(ic)->SetLeftMargin(0.15);
    cInvMassAntiLambda->cd(2)->cd(ic)->SetBottomMargin(0.11);
    cInvMassAntiLambda->cd(2)->cd(ic)->SetGridx(); 
    cInvMassAntiLambda->cd(2)->cd(ic)->SetGridy();
  }

  cInvMassAntiLambda->cd(2)->cd(1); 
  fLowPtAntiLambdaSample->GetXaxis()->SetTitleOffset(1.1);
  fLowPtAntiLambdaSample->GetYaxis()->SetTitleOffset(2.33);
  fLowPtAntiLambdaSample->GetYaxis()->SetTitle("Counts/Event");
  fLowPtAntiLambdaSample->Draw(); 
  Tl.DrawLatex(.25, .9277, "0.5 < p_{T} (GeV/c^{2}) < 1.0");

  cInvMassAntiLambda->cd(2)->cd(2); 
  fMidPtAntiLambdaSample->GetXaxis()->SetTitleOffset(1.1);
  fMidPtAntiLambdaSample->GetYaxis()->SetTitleOffset(2.33);
  fMidPtAntiLambdaSample->GetYaxis()->SetTitle("Counts/Event");
  fMidPtAntiLambdaSample->Draw(); 
  Tl.DrawLatex(.25, .9277, "1.5 < p_{T} (GeV/c^{2}) < 2.5");

  cInvMassAntiLambda->cd(2)->cd(3); 
  fHiPtAntiLambdaSample->GetXaxis()->SetTitleOffset(1.1);
  fHiPtAntiLambdaSample->GetYaxis()->SetTitleOffset(2.33);
  fHiPtAntiLambdaSample->GetYaxis()->SetTitle("Counts/Event");
  fHiPtAntiLambdaSample->Draw(); 
  Tl.DrawLatex(.25, .9277, "5 < p_{T} (GeV/c^{2}) < 10");  
  if      (output == "png") cInvMassAntiLambda->SaveAs("LF_QAanalysis_V0_pageZ.png");
  else if (output == "eps") cInvMassAntiLambda->SaveAs("LF_QAanalysis_V0_pageZ.eps");
  else if (output == "pdf") cInvMassAntiLambda->SaveAs("LF_QAanalysis_V0.pdf");

  */
  //==============================================================

  //==============================================================
  //Invariant Mass Plots: WITH dE/dx
  TCanvas *cInvMassAntiLambdaWithdEdx = new TCanvas ( "cInvMassAntiLambdaWithdEdx", "", 1200,800); 
  cInvMassAntiLambdaWithdEdx->Divide(1,2); 
  cInvMassAntiLambdaWithdEdx->cd(2)->Divide(3,1); 
  cInvMassAntiLambdaWithdEdx->cd(1); 
  cInvMassAntiLambdaWithdEdx->cd(1)->SetLogz();
  cInvMassAntiLambdaWithdEdx->cd(1)->SetLeftMargin(0.065);
  cInvMassAntiLambdaWithdEdx->cd(1)->SetTopMargin(0.13);
  cInvMassAntiLambdaWithdEdx->cd(1)->SetBottomMargin(0.11);

  f2dHistInvMassWithdEdxAntiLambda->GetYaxis()->SetTitleSize(0.05);
  f2dHistInvMassWithdEdxAntiLambda->GetYaxis()->SetTitleOffset(0.6);
  f2dHistInvMassWithdEdxAntiLambda->GetXaxis()->SetTitleSize(0.05);
  f2dHistInvMassWithdEdxAntiLambda->GetXaxis()->SetTitle("p_{T} (GeV/c)");
  f2dHistInvMassWithdEdxAntiLambda->GetZaxis()->SetTitle("Counts / Event");
  f2dHistInvMassWithdEdxAntiLambda->GetZaxis()->SetTitleOffset(0.7);
  f2dHistInvMassWithdEdxAntiLambda->GetZaxis()->SetRangeUser( f2dHistInvMassWithdEdxAntiLambda->GetMinimum(1e-10)*0.9, f2dHistInvMassWithdEdxAntiLambda->GetMaximum()*1.2 );
  f2dHistInvMassWithdEdxAntiLambda->Draw("colz");
  Tl.DrawLatex(.35, .9277, "Mass under #bar{#Lambda} hypothesis, With TPC dE/dx")  ;   

  TH1D *fLowPtAntiLambdaSampleWithdEdx = (TH1D*) f2dHistInvMassWithdEdxAntiLambda->ProjectionY( "fLowPtAntiLambdaSampleWithdEdx", 
    f2dHistInvMassWithdEdxAntiLambda->GetXaxis()->FindBin(0.5001),
    f2dHistInvMassWithdEdxAntiLambda->GetXaxis()->FindBin(0.9999) );

  TH1D *fMidPtAntiLambdaSampleWithdEdx = (TH1D*) f2dHistInvMassWithdEdxAntiLambda->ProjectionY( "fMidPtAntiLambdaSampleWithdEdx", 
    f2dHistInvMassWithdEdxAntiLambda->GetXaxis()->FindBin(1.5001),
    f2dHistInvMassWithdEdxAntiLambda->GetXaxis()->FindBin(2.4999) );

  TH1D *fHiPtAntiLambdaSampleWithdEdx = (TH1D*) f2dHistInvMassWithdEdxAntiLambda->ProjectionY( "fHiPtAntiLambdaSampleWithdEdx", 
    f2dHistInvMassWithdEdxAntiLambda->GetXaxis()->FindBin(5.0001),
    f2dHistInvMassWithdEdxAntiLambda->GetXaxis()->FindBin(9.9999) );

  for(Int_t ic = 1; ic<4; ic++){ 
    cInvMassAntiLambdaWithdEdx->cd(2)->cd(ic)->SetTopMargin(0.14);
    cInvMassAntiLambdaWithdEdx->cd(2)->cd(ic)->SetLeftMargin(0.15);
    cInvMassAntiLambdaWithdEdx->cd(2)->cd(ic)->SetBottomMargin(0.11);
    cInvMassAntiLambdaWithdEdx->cd(2)->cd(ic)->SetGridx(); 
    cInvMassAntiLambdaWithdEdx->cd(2)->cd(ic)->SetGridy();
  }

  cInvMassAntiLambdaWithdEdx->cd(2)->cd(1); 
  fLowPtAntiLambdaSampleWithdEdx->GetXaxis()->SetTitleOffset(1.1);
  fLowPtAntiLambdaSampleWithdEdx->GetYaxis()->SetTitleOffset(2.33);
  fLowPtAntiLambdaSampleWithdEdx->GetYaxis()->SetTitle("Counts/Event");
  fLowPtAntiLambdaSampleWithdEdx->Draw(); 
  Tl.DrawLatex(.25, .9277, "0.5 < p_{T} (GeV/c^{2}) < 1.0");

  cInvMassAntiLambdaWithdEdx->cd(2)->cd(2); 
  fMidPtAntiLambdaSampleWithdEdx->GetXaxis()->SetTitleOffset(1.1);
  fMidPtAntiLambdaSampleWithdEdx->GetYaxis()->SetTitleOffset(2.33);
  fMidPtAntiLambdaSampleWithdEdx->GetYaxis()->SetTitle("Counts/Event");
  fMidPtAntiLambdaSampleWithdEdx->Draw(); 
  Tl.DrawLatex(.25, .9277, "1.5 < p_{T} (GeV/c^{2}) < 2.5");

  cInvMassAntiLambdaWithdEdx->cd(2)->cd(3); 
  fHiPtAntiLambdaSampleWithdEdx->GetXaxis()->SetTitleOffset(1.1);
  fHiPtAntiLambdaSampleWithdEdx->GetYaxis()->SetTitleOffset(2.33);
  fHiPtAntiLambdaSampleWithdEdx->GetYaxis()->SetTitle("Counts/Event");
  fHiPtAntiLambdaSampleWithdEdx->Draw(); 
  Tl.DrawLatex(.25, .9277, "5 < p_{T} (GeV/c^{2}) < 10"); 

  if( lAttemptInvMassFit ){ 
    //Attempt rough signal extraction   
    TF1 *fal1 = new TF1("fal1","[0]+[1]*x+[2]*x*x+[3]*TMath::Gaus(x,[4],[5])",1.095, 1.14);
    //Reasonable first guess
    fal1->SetParameter(0, fLowPtAntiLambdaSampleWithdEdx -> GetBinContent( fLowPtAntiLambdaSampleWithdEdx->FindBin(1.116+0.01) ) );
    fal1->SetParameter(1, 0 );
    fal1->SetParameter(2, 0 );
    fal1->SetParameter(3, 0.35*fLowPtAntiLambdaSampleWithdEdx->GetMaximum() ); 
    fal1->SetParameter(4, 1.115683);
    fal1->SetParLimits(4,1.116-0.01,1.116+0.01);
    fal1->SetParameter(5, 0.002);
    fal1->SetParLimits(5,0.0005,0.01);
    cout<<"Will now fit, please wait!"<<endl;
    fLowPtAntiLambdaSampleWithdEdx->Fit("fal1","REM0");
    cInvMassAntiLambdaWithdEdx->cd(2)->cd(1); 
    fal1->Draw("same"); 
    //Peak Position, Width: printout 
    fLowPtAntiLambdaSampleWithdEdx->GetYaxis()->SetRangeUser(0,fLowPtAntiLambdaSampleWithdEdx->GetMaximum() * 1.2);
    Tli.DrawLatex(0.2,0.8,Form("peak = %.4f #pm %.4f MeV/c^{2}",fal1->GetParameter(4),fal1->GetParameter(5)) ) ;
    
    //Attempt rough signal extraction   
    TF1 *fal2 = new TF1("fal2","[0]+[1]*x+[2]*x*x+[3]*TMath::Gaus(x,[4],[5])",1.085, 1.15);
    //Reasonable first guess
    fal2->SetParameter(0, fMidPtAntiLambdaSampleWithdEdx -> GetBinContent( fMidPtAntiLambdaSampleWithdEdx->FindBin(1.116+0.01) ) );
    fal2->SetParameter(1, 0 );
    fal2->SetParameter(2, 0 );
    fal2->SetParameter(3, 0.6*fMidPtAntiLambdaSampleWithdEdx->GetMaximum() ); 
    fal2->SetParLimits(4,1.116-0.01,1.116+0.01);
    fal2->SetParameter(4, 1.116);
    fal2->SetParameter(5, 0.0025);
    fal2->SetParLimits(5,0.0005,0.01);
    cout<<"Will now fit, please wait!"<<endl;
    fMidPtAntiLambdaSampleWithdEdx->Fit("fal2","REM0");
    cInvMassAntiLambdaWithdEdx->cd(2)->cd(2); 
    fal2->Draw("same"); 
    //Peak Position, Width: printout 
    fMidPtAntiLambdaSampleWithdEdx->GetYaxis()->SetRangeUser(0,fMidPtAntiLambdaSampleWithdEdx->GetMaximum() * 1.2);
    Tli.DrawLatex(0.2,0.8,Form("peak = %.4f #pm %.4f MeV/c^{2}",fal2->GetParameter(4),fal2->GetParameter(5)) ) ;

    //Attempt rough signal extraction   
    TF1 *fal3 = new TF1("fal3","[0]+[1]*x+[2]*x*x+[3]*TMath::Gaus(x,[4],[5])",1.095, 1.15);
    //Reasonable first guess
    fal3->SetParameter(0, fHiPtAntiLambdaSampleWithdEdx -> GetBinContent( fHiPtAntiLambdaSampleWithdEdx->FindBin(1.116+0.01) ) );
    fal3->SetParameter(1, 0 );
    fal3->SetParameter(2, 0 );
    fal3->SetParameter(3, 0.6*fHiPtAntiLambdaSampleWithdEdx->GetMaximum() ); 
    fal3->SetParameter(4, 1.116);
    fal3->SetParLimits(4,1.116-0.005,1.116+0.005);
    fal3->SetParameter(5, 0.0035);
    fal3->SetParLimits(5,0.0005,0.01);
    cout<<"Will now fit, please wait!"<<endl;
    fHiPtAntiLambdaSampleWithdEdx->Fit("fal3","REM0");
    cInvMassAntiLambdaWithdEdx->cd(2)->cd(3); 
    fal3->Draw("same"); 
    //Peak Position, Width: printout 
    fHiPtAntiLambdaSampleWithdEdx->GetYaxis()->SetRangeUser(0,fHiPtAntiLambdaSampleWithdEdx->GetMaximum() * 1.2);
    Tli.DrawLatex(0.2,0.8,Form("peak = %.4f #pm %.4f MeV/c^{2}",fal3->GetParameter(4),fal3->GetParameter(5)) ) ;
  }

 
  if      (output == "png") cInvMassAntiLambdaWithdEdx->SaveAs("LF_QAanalysis_V0_page4.png");
  else if (output == "eps") cInvMassAntiLambdaWithdEdx->SaveAs("LF_QAanalysis_V0_page4.eps");
  else if (output == "pdf") cInvMassAntiLambdaWithdEdx->SaveAs("LF_QAanalysis_V0.pdf");

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

  //==============================================================  
  // Strict Lambda Analysis for dE/dx Calibration Check 
  TH2D *f2dHistdEdxSignalPionFromLambda    = (TH2D*)clist->FindObject("f2dHistdEdxSignalPionFromLambda");
  TH2D *f2dHistdEdxSignalProtonFromLambda  = (TH2D*)clist->FindObject("f2dHistdEdxSignalProtonFromLambda");
  TH2D *f2dHistResponsePionFromLambda      = (TH2D*)clist->FindObject("f2dHistResponsePionFromLambda");
  TH2D *f2dHistResponseProtonFromLambda    = (TH2D*)clist->FindObject("f2dHistResponseProtonFromLambda");

  f2dHistdEdxSignalPionFromLambda->Rebin2D(2,10);
  f2dHistdEdxSignalProtonFromLambda->Rebin2D(2,10);
    
  
  TH1D *fLowPtPionResponse = (TH1D*) f2dHistResponsePionFromLambda->ProjectionY( "fLowPtPionResponse", 
    f2dHistResponsePionFromLambda->GetXaxis()->FindBin(0.5001),
    f2dHistResponsePionFromLambda->GetXaxis()->FindBin(0.9999) );

  TH1D *fMidPtPionResponse = (TH1D*) f2dHistResponsePionFromLambda->ProjectionY( "fMidPtPionResponse", 
    f2dHistResponsePionFromLambda->GetXaxis()->FindBin(1.5001),
    f2dHistResponsePionFromLambda->GetXaxis()->FindBin(2.4999) );

  TH1D *fLowPtProtonResponse = (TH1D*) f2dHistResponseProtonFromLambda->ProjectionY( "fLowPtProtonResponse", 
    f2dHistResponseProtonFromLambda->GetXaxis()->FindBin(0.5001),
    f2dHistResponseProtonFromLambda->GetXaxis()->FindBin(0.9999) );

  TH1D *fMidPtProtonResponse = (TH1D*) f2dHistResponseProtonFromLambda->ProjectionY( "fMidPtProtonResponse", 
    f2dHistResponseProtonFromLambda->GetXaxis()->FindBin(1.5001),
    f2dHistResponseProtonFromLambda->GetXaxis()->FindBin(2.4999) );



  TCanvas *cdEdxPure = new TCanvas("cdEdxPure","",1500,800);
  cdEdxPure->Divide(4,2); 

  for(Int_t ic = 1; ic<9; ic++){ 
    cdEdxPure->SetLeftMargin(0.15);
    cdEdxPure->cd(ic)->SetLogz();
    //cdEdxPure->cd(ic)->SetTopMargin(0.133);
    if( ic%4 == 1 || ic%4 == 2){
      cdEdxPure->cd(ic)->SetRightMargin(0.133);
    }
    if( ic%4 != 1 && ic%4 != 2){
      cdEdxPure->cd(ic)->SetGridx();
      cdEdxPure->cd(ic)->SetGridy();
    }
  }



  cdEdxPure->cd(1); 
  f2dHistdEdxSignalPionFromLambda->Draw("colz"); 
  cdEdxPure->cd(2); 
  f2dHistResponsePionFromLambda->Draw("colz"); 
  cdEdxPure->cd(3); 
  fLowPtPionResponse->Draw();
  cdEdxPure->cd(4); 
  fMidPtPionResponse->Draw();

  cdEdxPure->cd(5); 
  f2dHistdEdxSignalProtonFromLambda->Draw("colz"); 
  cdEdxPure->cd(6); 
  f2dHistResponseProtonFromLambda->Draw("colz"); 
  cdEdxPure->cd(7); 
  fLowPtProtonResponse->Draw();
  cdEdxPure->cd(8); 
  fMidPtProtonResponse->Draw();



  //Write explanations on canvases
  cdEdxPure->cd(1); Tl.DrawLatex(.25, .9277, "#pi^{-} from #Lambda: TPC Signal");
  cdEdxPure->cd(2); Tl.DrawLatex(.15, .9277, "#pi^{-} from #Lambda: AliPIDResponse Value");
  cdEdxPure->cd(3); Tl.DrawLatex(.21, .9277, "#pi^{-} N#sigma, 0.5 < p_{T} (GeV/c) < 1.0");
  cdEdxPure->cd(4); Tl.DrawLatex(.21, .9277, "#pi^{-} N#sigma, 1.5 < p_{T} (GeV/c) < 2.5");

  cdEdxPure->cd(5); Tl.DrawLatex(.25, .9277, "p from #Lambda: TPC Signal");
  cdEdxPure->cd(6); Tl.DrawLatex(.15, .9277, "p from #Lambda: AliPIDResponse Value");
  cdEdxPure->cd(7); Tl.DrawLatex(.21, .9277, "p N#sigma, 0.5 < p_{T} (GeV/c) < 1.0");
  cdEdxPure->cd(8); Tl.DrawLatex(.21, .9277, "p N#sigma, 1.5 < p_{T} (GeV/c) < 2.5");

  Double_t lLowPtPeakPion         = fLowPtPionResponse->GetBinCenter( fLowPtPionResponse->GetMaximumBin() );
  Double_t lMidPtPeakPion         = fMidPtPionResponse->GetBinCenter( fMidPtPionResponse->GetMaximumBin() );
  Double_t lLowPtPeakProton       = fLowPtProtonResponse->GetBinCenter( fLowPtProtonResponse->GetMaximumBin() );
  Double_t lMidPtPeakProton       = fMidPtProtonResponse->GetBinCenter( fMidPtProtonResponse->GetMaximumBin() );

  //List Maximal Values
  cout<<"Maximal Value for pion from Lambda at low pt...............: " <<lLowPtPeakPion<<endl;
  cout<<"Maximal Value for pion from Lambda at mid pt...............: " <<lMidPtPeakPion<<endl;
  cout<<"Maximal Value for proton from Lambda at low pt.............: " <<lLowPtPeakProton<<endl;
  cout<<"Maximal Value for proton from Lambda at mid pt.............: " <<lMidPtPeakProton<<endl;

  if( TMath::Abs( lLowPtPeakPion ) > 0.3)   cout<<"*** WARNING: Check Low Pt pion PID Response! ***"<<endl;
  if( TMath::Abs( lMidPtPeakPion ) > 0.3)   cout<<"*** WARNING: Check Mid Pt pion PID Response! ***"<<endl;
  if( TMath::Abs( lLowPtPeakProton ) > 0.3) cout<<"*** WARNING: Check Low Pt proton PID Response! ***"<<endl;
  if( TMath::Abs( lMidPtPeakProton ) > 0.3) cout<<"*** WARNING: Check Mid Pt proton PID Response! ***"<<endl;

  TLatex Tlq;
  Tlq.SetNDC();
  Tlq.SetTextSize(0.06);

  //Draw Arrows to be sure!
  Double_t lFractionHeight = 0.33;
  cdEdxPure->cd(3);  
  TArrow *ar1 = new TArrow(lLowPtPeakPion,lFractionHeight * fLowPtPionResponse->GetMaximum(),lLowPtPeakPion,0.0, 0.008 ,"|>");
  ar1->SetLineWidth(2);
  ar1->Draw();
  if( TMath::Abs( lLowPtPeakPion ) < 0.3) {
    Tlq.SetTextColor(8); 
    Tlq.DrawLatex ( 0.15,0.8, "OK!");
  } else { 
    Tlq.SetTextColor(kRed); 
    Tlq.DrawLatex ( 0.15,0.8, "Prob.! Check dEd/x!");
  }

  cdEdxPure->cd(4);  
  TArrow *ar2 = new TArrow(lMidPtPeakPion,lFractionHeight * fMidPtPionResponse->GetMaximum(),lLowPtPeakPion,0.0, 0.008 ,"|>");
  ar2->SetLineWidth(2);
  ar2->Draw();
  if( TMath::Abs( lMidPtPeakPion ) < 0.3) {
    Tlq.SetTextColor(8); 
    Tlq.DrawLatex ( 0.15,0.8, "OK!");
  } else { 
    Tlq.SetTextColor(kRed); 
    Tlq.DrawLatex ( 0.15,0.8, "Prob.! Check dEd/x!");
  }
  
  cdEdxPure->cd(7);  
  TArrow *ar3 = new TArrow(lLowPtPeakProton,lFractionHeight * fLowPtProtonResponse->GetMaximum(),lLowPtPeakPion,0.0, 0.008 ,"|>");
  ar3->SetLineWidth(2);
  ar3->Draw();
  if( TMath::Abs( lLowPtPeakProton ) < 0.3) {
    Tlq.SetTextColor(8); 
    Tlq.DrawLatex ( 0.15,0.8, "OK!");
  } else { 
    Tlq.SetTextColor(kRed); 
    Tlq.DrawLatex ( 0.15,0.8, "Prob.! Check dEd/x!");
  }

  cdEdxPure->cd(8);  
  TArrow *ar4 = new TArrow(lMidPtPeakProton,lFractionHeight * fMidPtProtonResponse->GetMaximum(),lLowPtPeakPion,0.0, 0.008 ,"|>");
  ar4->SetLineWidth(2);
  ar4->Draw();
  if( TMath::Abs( lMidPtPeakProton ) < 0.3) {
    Tlq.SetTextColor(8); 
    Tlq.DrawLatex ( 0.15,0.8, "OK!");
  } else { 
    Tlq.SetTextColor(kRed); 
    Tlq.DrawLatex ( 0.15,0.8, "Prob.! Check dEd/x!");
  }

  if      (output == "png") cdEdxPure->SaveAs("LF_QAanalysis_V0_page5.png");
  else if (output == "eps") cdEdxPure->SaveAs("LF_QAanalysis_V0_page5.eps");
  else if (output == "pdf") cdEdxPure->SaveAs("LF_QAanalysis_V0.pdf");


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

  //==============================================================    
  //Topological variable QA
  // FIXME: This is still only a rough first version. 
  // Adjustments will be required for easy / long-term operation.
  TH1D *fHistTopDCAPosToPV      = (TH1D*)clist->FindObject("fHistSelectedTopDCAPosToPV");
  TH1D *fHistTopDCANegToPV      = (TH1D*)clist->FindObject("fHistSelectedTopDCANegToPV");
  TH1D *fHistTopDCAV0Daughters  = (TH1D*)clist->FindObject("fHistSelectedTopDCAV0Daughters");
  TH1D *fHistTopCosinePA        = (TH1D*)clist->FindObject("fHistSelectedTopCosinePA");
  TH1D *fHistTopV0Radius        = (TH1D*)clist->FindObject("fHistSelectedTopV0Radius");

  //Zoom in on selection in Cosine of pointing angle...
  Int_t iLowBin=-1; 
  Int_t iLowBin2 = -1; 
  Int_t iLowBin3 = -1; 

  //Normalize to per-event 
  fHistTopDCAPosToPV      -> Scale ( 1. / ((Double_t)fHistEvent->GetBinContent(4) ) );
  fHistTopDCANegToPV      -> Scale ( 1. / ((Double_t)fHistEvent->GetBinContent(4) ) );
  fHistTopDCAV0Daughters  -> Scale ( 1. / ((Double_t)fHistEvent->GetBinContent(4) ) );
  fHistTopCosinePA        -> Scale ( 1. / ((Double_t)fHistEvent->GetBinContent(4) ) );
  fHistTopV0Radius        -> Scale ( 1. / ((Double_t)fHistEvent->GetBinContent(4) ) );

  fHistTopDCAPosToPV      -> GetYaxis() -> SetTitle("Counts / Event");
  fHistTopDCANegToPV      -> GetYaxis() -> SetTitle("Counts / Event");
  fHistTopDCAV0Daughters  -> GetYaxis() -> SetTitle("Counts / Event");
  fHistTopCosinePA        -> GetYaxis() -> SetTitle("Counts / Event");
  fHistTopV0Radius        -> GetYaxis() -> SetTitle("Counts / Event");

  fHistTopDCAPosToPV      -> GetYaxis() -> SetTitleSize(0.05);
  fHistTopDCANegToPV      -> GetYaxis() -> SetTitleSize(0.05);
  fHistTopDCAV0Daughters  -> GetYaxis() -> SetTitleSize(0.05);
  fHistTopCosinePA        -> GetYaxis() -> SetTitleSize(0.05);
  fHistTopV0Radius        -> GetYaxis() -> SetTitleSize(0.05);

  fHistTopDCAPosToPV      -> GetXaxis() -> SetTitleSize(0.05);
  fHistTopDCANegToPV      -> GetXaxis() -> SetTitleSize(0.05);
  fHistTopDCAV0Daughters  -> GetXaxis() -> SetTitleSize(0.05);
  fHistTopCosinePA        -> GetXaxis() -> SetTitleSize(0.05);
  fHistTopV0Radius        -> GetXaxis() -> SetTitleSize(0.05);

  Double_t lMinimumCosPADraw = 1.-1.25*(1.-GetXForMinValue ( fHistTopCosinePA ) ); //assumes monotonically increasing dist
  cout<<"Function test: "<< lMinimumCosPADraw <<endl;
  fHistTopCosinePA->GetXaxis()->SetRangeUser(lMinimumCosPADraw,1.001);  

  Double_t lmin[5]; 
  Double_t lminPrecision[5]; 
  lmin[3] = GetXForMinValue ( fHistTopCosinePA );
  lmin[4] = GetXForMinValue ( fHistTopV0Radius );
  lmin[0] = GetXForMaxValue ( fHistTopDCAPosToPV );
  lmin[1] = GetXForMaxValue ( fHistTopDCANegToPV );
  lmin[2] = GetXForMinValue ( fHistTopDCAV0Daughters );

  lminPrecision[3] = fHistTopCosinePA        -> GetBinWidth(1);
  lminPrecision[4] = fHistTopV0Radius        -> GetBinWidth(1);
  lminPrecision[0] = fHistTopDCAPosToPV      -> GetBinWidth(1);
  lminPrecision[1] = fHistTopDCANegToPV      -> GetBinWidth(1);
  lminPrecision[2] = fHistTopDCAV0Daughters  -> GetBinWidth(1);

  cout<<"Minimum Values Found: "<<endl;
  cout<<"Cosine of Pointing Angle...........: "<<GetXForMinValue (fHistTopCosinePA )<<" precision = "<<lminPrecision[3]<<endl;
  cout<<"DCA Neg Daughter to PV.............: "<<GetXForMaxValue (fHistTopDCAPosToPV )<<" precision = "<<lminPrecision[1]<<endl;
  cout<<"DCA Pos Daughter to PV.............: "<<GetXForMaxValue (fHistTopDCANegToPV )<<" precision = "<<lminPrecision[0]<<endl;
  cout<<"DCA V0 Daughers....................: "<<GetXForMinValue (fHistTopDCAV0Daughters )<<" precision = "<<lminPrecision[2]<<endl;
  cout<<"V0 Decay Radius....................: "<<GetXForMinValue (fHistTopV0Radius )<<" precision = "<<lminPrecision[4]<<endl;


  TCanvas *cTopo = new TCanvas ("cTopo","",1200,800);
  cTopo->Divide(3,2); 
  for(Int_t ic = 1; ic<7; ic++){ 
    cTopo->cd(ic)->SetLeftMargin(0.15);
    cTopo->cd(ic)->SetGridx(); 
    cTopo->cd(ic)->SetGridy(); 
  }

  cTopo->cd(1);   
  fHistTopDCAPosToPV->Draw(); 
  cTopo->cd(2);   
  fHistTopDCANegToPV->Draw(); 
  cTopo->cd(3);   
  fHistTopDCAV0Daughters->Draw(); 
  cTopo->cd(4);   
  fHistTopCosinePA->Draw(); 
  cTopo->cd(5);   
  fHistTopV0Radius->Draw(); 

  TLatex Tlt;
  Tlt.SetNDC();
  Tlt.SetTextSize(0.05);
  cTopo->cd(6);
    
  Tlt.DrawLatex(.22, .9, "Boundary Checks")  ;


        
  TString lCut[5];
  lCut [ 0 ] = "Min DCA Pos D. To PV (cm)";
  lCut [ 1 ] = "Min DCA Neg D. To PV (cm)";
  lCut [ 2 ] = "Max DCA V0 Daughters (#sigma)";
  lCut [ 3 ] = "Min Cosine PA";
  lCut [ 4 ] = "Min 2D Decay Radius (cm)";

  TString lCutVal[5]; 
  TString lCutValPrec[5]; 
    
  Tlt.SetTextSize(0.04);
  Tlt.SetTextFont(42);

  Tlt.DrawLatex(.01, .80, "Topological Var.")  ;
  Tlt.DrawLatex(.6, .80, "Value")  ;
  Tlt.DrawLatex(.75, .80, "Precision")  ;

  for (Int_t il=0;il<5;il++){ 
    Tlt.DrawLatex(.01,0.72-((double)il)*0.075, lCut[il].Data() );
    lCutVal[il] = Form( "%.4f", lmin[il] );
    Tlt.DrawLatex(.5925,0.72-((double)il)*0.075, lCutVal[il].Data() );
    lCutValPrec[il] = Form( "%.4f", lminPrecision[il] );
    Tlt.DrawLatex(.7675,0.72-((double)il)*0.075, lCutValPrec[il].Data() );
  }

  Tlt.SetTextSize(0.05);
  Tlt.SetTextFont(42);

  //Try to make a wild guess... 
  if ( TMath::Abs( lmin[0] - 0.100 ) < 2*lminPrecision[0] &&
       TMath::Abs( lmin[1] - 0.100 ) < 2*lminPrecision[1] &&
       TMath::Abs( lmin[2] - 1.000 ) < 2*lminPrecision[2] &&
       TMath::Abs( lmin[3] - 0.998 ) < 2*lminPrecision[3] &&
       TMath::Abs( lmin[4] - 0.500 ) < 2*lminPrecision[4] ){
    Tlt.DrawLatex( 0.17, 0.275, "#bf{Autodetect Interpretation}: "); 
    Tlt.DrawLatex( 0.1, 0.2, "Typical #bf{Pb-Pb} Reconstruction Cuts");
  }
  if ( TMath::Abs( lmin[0] - 0.020 ) < 2*lminPrecision[0] &&
       TMath::Abs( lmin[1] - 0.020 ) < 2*lminPrecision[1] &&
       TMath::Abs( lmin[2] - 1.500 ) < 2*lminPrecision[2] &&
       TMath::Abs( lmin[3] - 0.98 )  < 2*lminPrecision[3] &&
       TMath::Abs( lmin[4] - 0.500 ) < 2*lminPrecision[4] ){
    Tlt.DrawLatex( 0.15, 0.29, "#bf{Autodetect Interpretation}: ");  
    Tlt.DrawLatex( 0.1, 0.2, "Typical pp Reconstruction Cuts"); //To be checked
  }

  if      (output == "png") cTopo->SaveAs("LF_QAanalysis_V0_page6.png");
  else if (output == "eps") cTopo->SaveAs("LF_QAanalysis_V0_page6.eps");
  else if (output == "pdf") cTopo->SaveAs("LF_QAanalysis_V0.pdf)");


}
예제 #27
0
파일: Outliers.C 프로젝트: ktf/AliPhysics
void
TestSPD(const TString& which, Double_t nVar=2)
{
  TFile* file = TFile::Open("forward.root", "READ");
  if (!file) return;

  Bool_t spd = which.EqualTo("spd", TString::kIgnoreCase);
  
  TList* l = 0;
  if (spd) l = static_cast<TList*>(file->Get("CentralSums"));
  else     l = static_cast<TList*>(file->Get("ForwardSums"));
  if (!l) { 
    Warning("", "%sSums not found", spd ? "Central" : "Forward");
    return;
  }

  TList* ei = static_cast<TList*>(l->FindObject("fmdEventInspector"));
  if (!l) { 
    Warning("", "fmdEventInspector not found");
    return;
  }
  
  TObject* run = ei->FindObject("runNo");
  if (!run) 
    Warning("", "No run number found");
  ULong_t runNo = run ? run->GetUniqueID() : 0;

  TH2* h = 0;
  if (spd) h = static_cast<TH2*>(l->FindObject("nClusterVsnTracklet"));
  else { 
    TList* den = static_cast<TList*>(l->FindObject("fmdDensityCalculator"));
    if (!den) { 
      Error("", "fmdDensityCalculator not found");
      return;
    }
    TList* rng = static_cast<TList*>(den->FindObject(which));
    if (!rng) { 
      Error("", "%s not found", which.Data());
      return;
    }
    h = static_cast<TH2*>(rng->FindObject("elossVsPoisson"));
  }
  if (!h) { 
    Warning("", "%s not found", spd ? nClusterVsnTracklet : "elossVsPoisson");
    return;
  }

  gStyle->SetOptFit(1111);
  gStyle->SetOptStat(0);
  TCanvas* c = new TCanvas("c", Form("Run %u", runNo));
  c->Divide(2,2);
  
  TVirtualPad* p = c->cd(1);
  if (spd) {
    p->SetLogx();
    p->SetLogy();
  }
  p->SetLogz();
  h->Draw("colz");

  TObjArray* fits = new TObjArray;
  h->FitSlicesY(0, 1, -1, 0, "QN", fits);

  TF1* mean = new TF1("mean", "pol1");
  TF1* var  = new TF1("var", "pol1");
  // mean->FixParameter(0, 0);
  // var->FixParameter(0, 0);
  for (Int_t i = 0; i < 3; i++) { 
    p = c->cd(2+i);
    if (spd) { 
      p->SetLogx();
      p->SetLogy();
    }
    TH1* hh = static_cast<TH1*>(fits->At(i));
    hh->Draw();

    if (i == 0) continue;
    
    hh->Fit((i == 1? mean : var), "+Q");
    
  }

  TGraphErrors* g1 = new TGraphErrors(h->GetNbinsX());
  g1->SetFillColor(kBlue-10);
  g1->SetFillStyle(3001);
  g1->SetLineStyle(1);
  TGraph* u1 = new TGraph(h->GetNbinsX());
  TGraph* l1 = new TGraph(h->GetNbinsX());
  u1->SetLineColor(kBlue+1);
  l1->SetLineColor(kBlue+1);
  u1->SetName("u1");
  l1->SetName("l1");
  TGraphErrors* g2 = new TGraphErrors(h->GetNbinsX());
  g2->SetFillColor(kRed-10);
  g2->SetFillStyle(3001);
  g2->SetLineStyle(2);
  TGraph* u2 = new TGraph(h->GetNbinsX());
  TGraph* l2 = new TGraph(h->GetNbinsX());
  u2->SetLineColor(kRed+1);
  l2->SetLineColor(kRed+1);
  u2->SetName("u2");
  l2->SetName("l2");
  for (Int_t i = 1; i <= h->GetNbinsX(); i++) {
    Double_t x  = hh->GetXaxis()->GetBinCenter(i);
    Double_t y  = mean->Eval(x);
    Double_t e  = var->Eval(y);
    Double_t e1 = nVar * e;
    if (spd) e1 *= TMath::Log10(e);
    // Printf("%10e -> %10e +/- %10e", x, y, ee);
    g1->SetPoint(i-1, x, y);
    g1->SetPointError(i-1, 0, e1);
    u1->SetPoint(i-1, x, y+e1);
    l1->SetPoint(i-1, x, y-e1);
    // Printf("%3d: %f -> %f +/- %f", i, x, y, ee);

    Double_t e2 = nVar*0.05*x;
    g2->SetPoint(i-1, x, x);
    g2->SetPointError(i-1, 0, e2);
    u2->SetPoint(i-1, x, x+e2);
    l2->SetPoint(i-1, x, x-e2);
  }

  p = c->cd(1);
  c->Clear();
  c->cd();
  c->SetLogz();
  h->Draw("colz");
  g1->Draw("3 same");
  u1->Draw("l same");
  l1->Draw("l same");
  g2->Draw("3 same");
  u2->Draw("l same");
  l2->Draw("l same");

  Double_t ly = 0.9;
  Double_t dy = 0.06;
  TLatex* ltx = new TLatex(0.15, ly, Form("#LTy#GT = %f + %f x",
					   mean->GetParameter(0),
					   mean->GetParameter(1)));
  ltx->SetNDC();
  ltx->SetTextSize(dy);
  ltx->SetTextAlign(13);
  ltx->Draw();

  ly -= dy + 0.01;
  ltx->DrawLatex(0.15, ly, Form("#sigma_{y} = %f + %f x", 
				var->GetParameter(0),
				var->GetParameter(1)));
  
  ly -= dy + 0.01;
  ltx->DrawLatex(0.15, ly, Form("#delta = %f #sigma %s", 
				nVar, (spd ? "log_{10}(#sigma" : "")));
	    
					   
}
예제 #28
0
파일: QA.C 프로젝트: ktf/AliPhysics
void QAtracklets(const Char_t *fdata, const Char_t *fmc)
{

  style();
  
  TFile *fdtin = TFile::Open(fdata);
  TList *ldtin = (TList *)fdtin->Get("clist");
  TH2 *hdtin = (TH2 *)ldtin->FindObject("etaphiTracklets");
  TH1 *pdtin = (TH1 *)hdtin->ProjectionY("pdtin_tracklets");
  pdtin->SetMarkerStyle(20);
  pdtin->SetMarkerSize(1.);
  pdtin->SetMarkerColor(kAzure-3);
  hdtin->Scale(1. / hdtin->GetEntries());
  pdtin->Scale(1. / hdtin->GetEntries());
  
  TFile *fmcin = TFile::Open(fmc);
  TList *lmcin = (TList *)fmcin->Get("clist");

  if(!lmcin) {
      std::cout << "NOLIST" << std::endl;

  }
  lmcin->ls();
  TH2 *hmcin = (TH2 *)lmcin->FindObject("etaphiTracklets");
  if(!hmcin) {
    std::cout << "NO H!! etaphiTracklets" << std::endl;
    
  }
  TH1 *pmcin = (TH1 *)hmcin->ProjectionY("pmcin_tracklets");
  pmcin->SetLineColor(kRed+1);
  pmcin->SetFillStyle(1001);
  pmcin->SetFillColorAlpha(kRed+1, 0.1);
  hmcin->Scale(1. / hmcin->GetEntries());
  pmcin->Scale(1. / hmcin->GetEntries());
  

  /*  
  pdtin->Scale(pmcin->Integral(pmcin->FindBin(0. + 0.001),
			       pmcin->FindBin(1. - 0.001))
	       / pdtin->Integral(pdtin->FindBin(0. + 0.001),
				 pdtin->FindBin(1. - 0.001)));
  */  
  
  TCanvas *cData = new TCanvas("cTrackletData", "cTrackletData", 800, 800);
  //  cData->SetLogz();
  TH1 * hfr = cData->DrawFrame(-2.5, 0., 2.5, 2. * TMath::Pi());
  hfr->SetTitle(";#eta;#varphi");
  hdtin->Draw("same,col");
  cData->SaveAs(canvasPrefix+"trackletData.pdf");

  TCanvas *cMC = new TCanvas("cTrackletMC", "cTrackletMC", 800, 800);
  //  cMC->SetLogz();
  hfr = cMC->DrawFrame(-2.5, 0., 2.5, 2. * TMath::Pi());
  hfr->SetTitle(";#eta;#varphi");
  hmcin->Draw("same,col");
  cMC->SaveAs(canvasPrefix+"trackletMC.pdf");
  
  TCanvas *cPhi = new TCanvas("cTrackletPhi", "cTrackletPhi", 800, 800);
  //  cPhi->SetLogy();
  hfr = cPhi->DrawFrame(0., 0., 2. * TMath::Pi(), 0.01);
  hfr->SetTitle(";#varphi;");
  pdtin->DrawCopy("same");
  pmcin->DrawCopy("same,histo");
  TLegend *legend = new TLegend(0.20, 0.18+0.63, 0.50, 0.30+0.63);
  legend->SetFillColor(0);
  legend->SetBorderSize(0);
  legend->SetTextFont(42);
  legend->SetTextSize(0.04);
  legend->AddEntry(pdtin, "data", "pl");
  legend->AddEntry(pmcin, "Monte Carlo", "l");
  legend->Draw("same");
  cPhi->SaveAs(canvasPrefix+"trackletPhi.pdf");
  
  TCanvas *cPhir = new TCanvas("cTrackletPhir", "cTrackletPhir", 800, 800);
  //  cPhi->SetLogy();
  hfr = cPhir->DrawFrame(0., 0.5, 2. * TMath::Pi(), 1.5);
  hfr->SetTitle(";#varphi;data / Monte Carlo");
  pdtin->Divide(pmcin);
  pdtin->Draw("same");
  cPhir->SaveAs(canvasPrefix+"trackletPhir.pdf");

  
  
}
void analysisMacroSingleCanv(){
	TFile *withPDCAFile=new TFile("full_analysis_outputs/withPDCA/AnalysisResults.root","READ");
	TFile *noPDCAFile=new TFile("full_analysis_outputs/noPDCA/AnalysisResults.root","READ");

	TFile *outputHistoFile=new TFile("outputHistos.root","RECREATE");


	TList *withPDCAProcessedNumberList;
	withPDCAFile->GetObject("MultSelection/cListMultSelection",withPDCAProcessedNumberList);
	TList *withPDCAList;
	withPDCAFile->GetObject("Upsilonfirst/UpsilonOutfirst",withPDCAList);

	TList *noPDCAProcessedNumberList;
	noPDCAFile->GetObject("MultSelection/cListMultSelection",noPDCAProcessedNumberList);
	TList *noPDCAList;
	noPDCAFile->GetObject("Upsilonfirst/UpsilonOutfirst",noPDCAList);


	TH1D *withPDCAProcessedHisto;
	withPDCAProcessedHisto=(TH1D*)withPDCAProcessedNumberList->FindObject("fHistEventCounter");
	TTree *withPDCATree;
	withPDCATree=(TTree*)withPDCAList->FindObject("MuonData");

	TH1D *noPDCAProcessedHisto;
	noPDCAProcessedHisto=(TH1D*)noPDCAProcessedNumberList->FindObject("fHistEventCounter");
	TTree *noPDCATree;
	noPDCATree=(TTree*)noPDCAList->FindObject("MuonData");

	Double_t processedWithPDCA=withPDCAProcessedHisto->GetBinContent(1);
	Double_t processedNoPDCA=noPDCAProcessedHisto->GetBinContent(1);
	Double_t normalizationFactor=processedWithPDCA/processedNoPDCA;

///////////////////////////////////////////////////////////////////

	TCanvas *canvHistos090=new TCanvas("canvHistos090","canvHistos090");
	canvHistos090->SetFrameBorderMode(0);
	TPad *Pad1=canvHistos090->cd();
	Pad1->Divide(1,2,0.01,0.0);
	Pad1->cd(1)->SetLogy();
	TH1D *histoInvariantMassWithPDCA090FullRap=new TH1D("Invariant mass 0%-90% 2.5<eta<4.0 PDCA","Invariant mass 0%-90% 2.5<eta<4.0 PDCA",250,2.5,15.);
	withPDCATree->Project("Invariant mass 0%-90% 2.5<eta<4.0 PDCA","dimuon_mass","enevt_centrality>0 && enevt_centrality<90 && dimuon_rapidity>-4. && dimuon_rapidity<-2.5 && highest_muon_transverse_momentum>0. && lowest_muon_transverse_momentum>0.");
//  histoInvariantMassWithPDCA090FullRap->ShowPeaks();
	histoInvariantMassWithPDCA090FullRap->Draw();
	outputHistoFile->cd();
	histoInvariantMassWithPDCA090FullRap->Write();

	TH1D *histoInvariantMassNoPDCA090FullRap=new TH1D("Invariant mass 0%-90% 2.5<eta<4.0","Invariant mass 0%-90% 2.5<eta<4.0",250,2.5,15.);
	noPDCATree->Project("Invariant mass 0%-90% 2.5<eta<4.0","dimuon_mass","enevt_centrality>0 && enevt_centrality<90 && dimuon_rapidity>-4. && dimuon_rapidity<-2.5 && highest_muon_transverse_momentum>0. && lowest_muon_transverse_momentum>0.");
//  histoInvariantMassNoPDCA090FullRap->ShowPeaks();
	histoInvariantMassNoPDCA090FullRap->SetLineColor(kRed);
	histoInvariantMassNoPDCA090FullRap->Draw("SAME");
	outputHistoFile->cd();
	histoInvariantMassNoPDCA090FullRap->Write();

	Pad1->cd(2);
	TH1D *histoInvariantMass090FullRapRatio=new TH1D("Ratio PDCA/NoPDCA 0%-90% 2.5<eta<4.0","Invariant mass 0%-90% 2.5<eta<4.0 PDCA",250,2.5,15.);
	histoInvariantMass090FullRapRatio->Add(histoInvariantMassWithPDCA090FullRap,histoInvariantMassNoPDCA090FullRap,1.,-1.*normalizationFactor);
	histoInvariantMass090FullRapRatio->Divide(histoInvariantMass090FullRapRatio,histoInvariantMassNoPDCA090FullRap);
	histoInvariantMass090FullRapRatio->SetLineColor(kBlack);
	histoInvariantMass090FullRapRatio->Draw();
	histoInvariantMass090FullRapRatio->Write();

///////////////////////////////////////////////////////////////////
	TCanvas *canvHistosAll=new TCanvas("canvHistosAll","canvHistosAll");
	canvHistosAll->SetFrameBorderMode(0);
	TPad *Pad2=canvHistosAll->cd();
	TH1D *histoInvariantMassWithPDCA=new TH1D("All entries PDCA","All entries PDCA",250,2.5,15.);
	withPDCATree->Project("All entries PDCA","dimuon_mass");
//  histoInvariantMassWithPDCA->ShowPeaks();
	histoInvariantMassWithPDCA->Draw();
	outputHistoFile->cd();
	histoInvariantMassWithPDCA->Write();

	TH1D *histoInvariantMassNoPDCA=new TH1D("All entries","All entries",250,2.5,15.);
	noPDCATree->Project("All entries","dimuon_mass");
//  histoInvariantMassNoPDCA->ShowPeaks();
	histoInvariantMassNoPDCA->SetLineColor(kRed);
	histoInvariantMassNoPDCA->Draw("SAME");  
	outputHistoFile->cd();
	histoInvariantMassNoPDCA->Write();  

///////////////////////////////////////////////////////////////////
	TCanvas *canvHistos020=new TCanvas("canvHistos020","canvHistos020");
	canvHistos020->SetFrameBorderMode(0);
	TPad *Pad3=canvHistos020->cd();
	Pad3->Divide(1,2,0.01,0.0);
	Pad3->cd(1)->SetLogy();
	TH1D *histoInvariantMassWithPDCA020FullRap=new TH1D("Invariant mass 0%-20% 2.5<eta<4.0 PDCA","Invariant mass 0%-20% 2.5<eta<4.0 PDCA",250,2.5,15.);
	withPDCATree->Project("Invariant mass 0%-20% 2.5<eta<4.0 PDCA","dimuon_mass","enevt_centrality>0 && enevt_centrality<20 && dimuon_rapidity>-4. && dimuon_rapidity<-2.5 && highest_muon_transverse_momentum>0. && lowest_muon_transverse_momentum>0.");
//  histoInvariantMassWithPDCA020FullRap->ShowPeaks();
	histoInvariantMassWithPDCA020FullRap->Draw();
	outputHistoFile->cd();
	histoInvariantMassWithPDCA020FullRap->Write();

	TH1D *histoInvariantMassNoPDCA020FullRap=new TH1D("Invariant mass 0%-20% 2.5<eta<4.0","Invariant mass 0%-20% 2.5<eta<4.0",250,2.5,15.);
	noPDCATree->Project("Invariant mass 0%-20% 2.5<eta<4.0","dimuon_mass","enevt_centrality>0 && enevt_centrality<20 && dimuon_rapidity>-4. && dimuon_rapidity<-2.5 && highest_muon_transverse_momentum>0. && lowest_muon_transverse_momentum>0.");
//  histoInvariantMassNoPDCA020FullRap->ShowPeaks();
	histoInvariantMassNoPDCA020FullRap->SetLineColor(kRed);
	histoInvariantMassNoPDCA020FullRap->Draw("SAME");  
	outputHistoFile->cd();
	histoInvariantMassNoPDCA020FullRap->Write();  

	Pad3->cd(2);
	TH1D *histoInvariantMass020FullRapRatio=new TH1D("Ratio PDCA/NoPDCA 0%-20% 2.5<eta<4.0","Invariant mass 0%-20% 2.5<eta<4.0 PDCA",250,2.5,15.);
	histoInvariantMass020FullRapRatio->Add(histoInvariantMassWithPDCA020FullRap,histoInvariantMassNoPDCA020FullRap,1.,-1.*normalizationFactor);
	histoInvariantMass020FullRapRatio->Divide(histoInvariantMass020FullRapRatio,histoInvariantMassNoPDCA020FullRap);
	histoInvariantMass020FullRapRatio->SetLineColor(kBlack);
	histoInvariantMass020FullRapRatio->Draw();
	outputHistoFile->cd();
	histoInvariantMass020FullRapRatio->Write();

///////////////////////////////////////////////////////////////////
	TCanvas *canvHistos2090=new TCanvas("canvHistos2090","canvHistos2090");
	canvHistos2090->SetFrameBorderMode(0);
	TPad *Pad4=canvHistos2090->cd();
	Pad4->Divide(1,2,0.01,0.0);
	Pad4->cd(1)->SetLogy();
	TH1D *histoInvariantMassWithPDCA2090FullRap=new TH1D("20%-90% 2.5<eta<4.0 PDCA","20%-90% 2.5<eta<4.0 PDCA",250,2.5,15.);
	withPDCATree->Project("20%-90% 2.5<eta<4.0 PDCA","dimuon_mass","enevt_centrality>20 && enevt_centrality<90 && dimuon_rapidity>-4. && dimuon_rapidity<-2.5 && highest_muon_transverse_momentum>0. && lowest_muon_transverse_momentum>0.");
//  histoInvariantMassWithPDCA2090FullRap->ShowPeaks();
	histoInvariantMassWithPDCA2090FullRap->Draw();
	outputHistoFile->cd();
	histoInvariantMassWithPDCA2090FullRap->Write();

	TH1D *histoInvariantMassNoPDCA2090FullRap=new TH1D("20%-90% 2.5<eta<4.0","20%-90% 2.5<eta<4.0",250,2.5,15.);
	noPDCATree->Project("20%-90% 2.5<eta<4.0","dimuon_mass","enevt_centrality>20 && enevt_centrality<90 && dimuon_rapidity>-4. && dimuon_rapidity<-2.5 && highest_muon_transverse_momentum>0. && lowest_muon_transverse_momentum>0.");
//  histoInvariantMassNoPDCA2090FullRap->ShowPeaks();
	histoInvariantMassNoPDCA2090FullRap->SetLineColor(kRed);
	histoInvariantMassNoPDCA2090FullRap->Draw("SAME");  
	outputHistoFile->cd();
	histoInvariantMassNoPDCA2090FullRap->Write();  

	Pad4->cd(2);
	TH1D *histoInvariantMass2090FullRapRatio=new TH1D("20%-90% 2.5<eta<4.0","20%-90% 2.5<eta<4.0 PDCA",250,2.5,15.);
	histoInvariantMass2090FullRapRatio->Add(histoInvariantMassWithPDCA2090FullRap,histoInvariantMassNoPDCA2090FullRap,1.,-1.*normalizationFactor);
	histoInvariantMass2090FullRapRatio->Divide(histoInvariantMass2090FullRapRatio,histoInvariantMassNoPDCA2090FullRap);
	histoInvariantMass2090FullRapRatio->SetLineColor(kBlack);
	histoInvariantMass2090FullRapRatio->Draw();
	outputHistoFile->cd();
	histoInvariantMass2090FullRapRatio->Write();

///////////////////////////////////////////////////////////////////
	TCanvas *canvHistos090r1=new TCanvas("canvHistos090r1","canvHistos090r1");
	canvHistos090r1->SetFrameBorderMode(0);
	TPad *Pad5=canvHistos090r1->cd();
	Pad5->Divide(1,2,0.01,0.0);
	Pad5->cd(1)->SetLogy();
	TH1D *histoInvariantMassWithPDCA090SecondRap=new TH1D("Invariant mass 0%-90% 2.5<eta<3.2 PDCA","Invariant mass 0%-90% 2.5<eta<3.2 PDCA",250,2.5,15.);
	withPDCATree->Project("Invariant mass 0%-90% 2.5<eta<3.2 PDCA","dimuon_mass","enevt_centrality>0 && enevt_centrality<90 && dimuon_rapidity>-3.2 && dimuon_rapidity<-2.5 && highest_muon_transverse_momentum>0. && lowest_muon_transverse_momentum>0.");
//  histoInvariantMassWithPDCA090SecondRap->ShowPeaks();
	histoInvariantMassWithPDCA090SecondRap->Draw();
	outputHistoFile->cd();
	histoInvariantMassWithPDCA090SecondRap->Write();

	TH1D *histoInvariantMassNoPDCA090SecondRap=new TH1D("Invariant mass 0%-90% 2.5<eta<3.2","Invariant mass 0%-90% 2.5<eta<3.2",250,2.5,15.);
	noPDCATree->Project("Invariant mass 0%-90% 2.5<eta<3.2","dimuon_mass","enevt_centrality>0 && enevt_centrality<90 && dimuon_rapidity>-3.2 && dimuon_rapidity<-2.5 && highest_muon_transverse_momentum>0. && lowest_muon_transverse_momentum>0.");
//  histoInvariantMassNoPDCA090SecondRap->ShowPeaks();
	histoInvariantMassNoPDCA090SecondRap->SetLineColor(kRed);
	histoInvariantMassNoPDCA090SecondRap->Draw("SAME");
	outputHistoFile->cd();
	histoInvariantMassNoPDCA090SecondRap->Write();

	Pad5->cd(2);
	TH1D *histoInvariantMass090SecondRapRatio=new TH1D("Ratio PDCA/NoPDCA 0%-90% 2.5<eta<3.2","Invariant mass 0%-90% 2.5<eta<3.2 PDCA",250,2.5,15.);
	histoInvariantMass090SecondRapRatio->Add(histoInvariantMassWithPDCA090SecondRap,histoInvariantMassNoPDCA090SecondRap,1.,-1.*normalizationFactor);
	histoInvariantMass090SecondRapRatio->Divide(histoInvariantMass090SecondRapRatio,histoInvariantMassNoPDCA090SecondRap);
	histoInvariantMass090SecondRapRatio->SetLineColor(kBlack);
	histoInvariantMass090SecondRapRatio->Draw();
	outputHistoFile->cd();
	histoInvariantMass090SecondRapRatio->Write();

///////////////////////////////////////////////////////////////////
	TCanvas *canvHistos090r2=new TCanvas("canvHistos090r2","canvHistos090r2");
	canvHistos090r2->SetFrameBorderMode(0);
	TPad *Pad6=canvHistos090r2->cd();
	Pad6->Divide(1,2,0.01,0.0);
	Pad6->cd(1)->SetLogy();
	TH1D *histoInvariantMassWithPDCA090FirstRap=new TH1D("Invariant mass 0%-90% 3.2<eta<4.0 PDCA","Invariant mass 0%-90% 3.2<eta<4.0 PDCA",250,2.5,15.);
	withPDCATree->Project("Invariant mass 0%-90% 3.2<eta<4.0 PDCA","dimuon_mass","enevt_centrality>0 && enevt_centrality<90 && dimuon_rapidity>-4. && dimuon_rapidity<-3.2 && highest_muon_transverse_momentum>0. && lowest_muon_transverse_momentum>0.");
//  histoInvariantMassWithPDCA090FirstRap->ShowPeaks();
	histoInvariantMassWithPDCA090FirstRap->Draw();
	outputHistoFile->cd();
	histoInvariantMassWithPDCA090FirstRap->Write();

	TH1D *histoInvariantMassNoPDCA090FirstRap=new TH1D("Invariant mass 0%-90% 3.2<eta<4.0","Invariant mass 0%-90% 3.2<eta<4.0",250,2.5,15.);
	noPDCATree->Project("Invariant mass 0%-90% 3.2<eta<4.0","dimuon_mass","enevt_centrality>0 && enevt_centrality<90 && dimuon_rapidity>-4. && dimuon_rapidity<-3.2 && highest_muon_transverse_momentum>0. && lowest_muon_transverse_momentum>0.");
//  histoInvariantMassNoPDCA090FirstRap->ShowPeaks();
	histoInvariantMassNoPDCA090FirstRap->SetLineColor(kRed);
	histoInvariantMassNoPDCA090FirstRap->Draw("SAME");
	outputHistoFile->cd();
	histoInvariantMassNoPDCA090FirstRap->Write();

	Pad6->cd(2);
	TH1D *histoInvariantMass090FirstRapRatio=new TH1D("Ratio PDCA/NoPDCA 0%-90% 3.2<eta<4.0","Invariant mass 0%-90% 3.2<eta<4.0 PDCA",250,2.5,15.);
	histoInvariantMass090FirstRapRatio->Add(histoInvariantMassWithPDCA090FirstRap,histoInvariantMassNoPDCA090FirstRap,1.,-1.*normalizationFactor);
	histoInvariantMass090FirstRapRatio->Divide(histoInvariantMass090FirstRapRatio,histoInvariantMassNoPDCA090FirstRap);
	histoInvariantMass090FirstRapRatio->SetLineColor(kBlack);
	histoInvariantMass090FirstRapRatio->Draw();
	outputHistoFile->cd();
	histoInvariantMass090FirstRapRatio->Write();
}
void AnalyzeClipping(TString inputWaveName = "sum trigger input ch5 960mV",
TString outputWaveName = "sum trigger output ch5 - 2V clip - 960mV input", 
Double_t inputDelay = 1.1E-8, Double_t lowerCut = 16E-9, Double_t upperCut = 23E-9,
const char *inFile = "Data.root",const char *WaveformsFile = "Waveforms.root") {
	
	//try to access data file and in case of failure return
	if(gSystem->AccessPathName(inFile,kFileExists)) {
		cout << "Error: file " << inFile << " does not exsist. Run .x DataParse.C to create it" << endl;
		return;
	}

	TFile *f = TFile::Open(inFile);
	TFolder *dataSet;
	
	TString dataFolderS = "SumTriggerBoardData";
	dataFolderS.Append(";1");

	dataSet = (TFolder*)f->Get(dataFolderS);
	
	cout << dataSet << endl;

	cout << dataSet->GetName() << endl;
	
	Int_t nScope = 150; // number of measurements done by the scope evey time
	
	//try to access waveforms file and in case of failure return
	if(gSystem->AccessPathName(WaveformsFile,kFileExists)) {
		cout << "Error: file " << WaveformsFile << " does not exsist. Run .x WaveformsFileMaker.C to create it" << endl;
		return;
	}
	
	TFile *f = TFile::Open(WaveformsFile);
	TList *listOfKeys = f->GetListOfKeys();
	Int_t numberOfKeys = listOfKeys->GetEntries();
	TList *listOfGraphs = new TList();
	
	// if the waveform file name begins with the string "comparator" it goes in this list
	TList *listOfCompWaves = new TList();
	// if the waveform file name begins with the string "sum output" it goes in this list
	TList *listOfAdderWaves = new TList();

	for(Int_t i = 0; i < numberOfKeys; i++) {
		TString *keyName = new TString(listOfKeys->At(i)->GetName());
		TTree *tree = (TTree*)f->Get(keyName->Data());
		Float_t x = 0;
		Float_t y = 0;
		tree->SetBranchAddress("x",&x);
		tree->SetBranchAddress("y",&y);
		Int_t nentries = tree->GetEntries();

		TString *gName = new TString(keyName->Data());
		gName->Append(" graph");
		TGraphErrors *gWave = new TGraphErrors(nentries);
		gWave->SetName(gName->Data());
		gWave->SetTitle(gName->Data());
		gWave->GetXaxis()->SetTitle("Time");
		gWave->GetYaxis()->SetTitle("Voltage");

		for (Int_t j = 0; j < nentries; j++) {
			tree->GetEntry(j);
			gWave->SetPoint(j,x,y);
		}

		listOfGraphs->Add(gWave);
	}
	
	// Global variables
	
	Double_t *xInput, *xOutput, *yInput, *yOutput;
	
	// V input 960 mV
	
	TString path = "Clipping/Output width analysis/Channel 5/V input 960mV/";
	
	TGraphErrors *gClip960mV = TBGraphErrors(dataSet,path,"V clip","Output FWHM",1,nScope);
	
	gClip960mV->SetMarkerStyle(20);
	gClip960mV->SetMarkerSize(0.8);
	gClip960mV->GetXaxis()->SetTitle("V clipping (mV)");
	gClip960mV->GetYaxis()->SetTitle("Output FWHM (ns)");
	
	TCanvas *cClip960mV = new TCanvas("cClip960mV","Output FWHM in function of V clipping",800,600);
	gClip960mV->Draw("APEL");
	
	// Expected output FWHM
	
	TGraphErrors *gInput960mV = listOfGraphs->FindObject("sum trigger input ch5 960mV graph");
	
	Double_t *xClip = gClip960mV->GetX();
	Int_t nClip = gClip960mV->GetN();
	cout << "nClip = " << nClip << endl;
	Long64_t graphPoints = gInput960mV->GetN();
	yInput = gInput960mV->GetY();
	xInput = gInput960mV->GetX();
	
	vector<double> xFirst(nClip);
	vector<double> xLast(nClip);
	Double_t half;
	
	Int_t flag = 0;
	
	vector<double> yConv(graphPoints);
	for(Int_t i = 0; i < graphPoints; i++) {
		yConv[i] = -(yInput[i]);
		yConv[i] *= 1000;
		if(xInput[i] + inputDelay < lowerCut || xInput[i] + inputDelay > upperCut) 
			yConv[i] = 0;
	}
	
	Double_t yInput960mVMax = TMath::MaxElement(graphPoints,&yConv[0]);
	
	for(Int_t i = 0; i < nClip; i++) {
		if(xClip[i] > yInput960mVMax) half = yInput960mVMax;
		else half = xClip[i];
		
		half /=2;
		cout << half << endl;
		
		flag = 0;
		
		for(Int_t j = 0; j < graphPoints - 3; j++) {
			if((yConv[j + 1] - half)*(yConv[j] - half) < 0 && flag == 0) {
				xFirst[i] = xInput[j];
				flag = 1;
				cout << "found first point! " << xFirst[i] << endl;
				continue;
			}
			if((yConv[j + 1] - half)*(yConv[j] - half) < 0 && flag == 1) {
				xLast[i] = xInput[j];
				cout << "found last point! " << xLast[i] << endl;
				break;
			}
		}
	}
	
	vector<double> expectedFWHM960mV(nClip);
	for(Int_t i = 0; i < expectedFWHM960mV.size(); i++) {
		expectedFWHM960mV[i] = xLast[i] - xFirst[i];
		// convert from seconds to nanoseconds
		expectedFWHM960mV[i] *= 10E8;
		cout << "expectedFWHM960mV[" << i << "] = " << expectedFWHM960mV[i] << endl;
	}
	
	// expected FWHM 960 mV graph
	
	TGraphErrors *gExpClip960mV = new TGraphErrors(nClip,xClip,&expectedFWHM960mV[0],0,0);
	gExpClip960mV->SetLineStyle(7);
	gExpClip960mV->SetMarkerStyle(20);
	gExpClip960mV->SetMarkerSize(0.8);
	
	// V input 1.9 V
	
	path = "Clipping/Output width analysis/Channel 5/V input 1.9V/";
	
	TGraphErrors *gClip1Point9V = TBGraphErrors(dataSet,path,"V clip","Output FWHM",1,nScope);
	
	gClip1Point9V->SetMarkerStyle(20);
	gClip1Point9V->SetMarkerSize(0.8);
	gClip1Point9V->SetLineColor(kRed);
	gClip1Point9V->GetXaxis()->SetTitle("V clipping (mV)");
	gClip1Point9V->GetYaxis()->SetTitle("Output FWHM (ns)");
	TCanvas *cClip1Point9V = new TCanvas("cClip1Point9V","Output FWHM in function of V clipping",800,600);
	gClip1Point9V->Draw("APEL");
	
	// Expected output FWHM
	
	TGraphErrors *gInput1Point9V = listOfGraphs->FindObject("sum trigger input ch5 1900mV graph");
	
	xClip = gClip1Point9V->GetX();
	nClip = gClip1Point9V->GetN();
	cout << "nClip = " << nClip << endl;
	graphPoints = gInput1Point9V->GetN();
	yInput = gInput1Point9V->GetY();
	xInput = gInput1Point9V->GetX();
	
	vector<double> xFirst(nClip);
	vector<double> xLast(nClip);
	
	flag = 0;
	
	vector<double> yConv(graphPoints);
	for(Int_t i = 0; i < graphPoints; i++) {
		yConv[i] = -(yInput[i]);
		yConv[i] *= 1000;
		if(xInput[i] + inputDelay < lowerCut || xInput[i] + inputDelay > upperCut) yConv[i] = 0;
	}
	
	Double_t yInput1Point9VMax = TMath::MaxElement(graphPoints,&yConv[0]);
	
	for(Int_t i = 0; i < nClip; i++) {
		if(xClip[i] > yInput1Point9VMax) half = yInput1Point9VMax;
		else half = xClip[i];
		
		half /= 2;
		cout << half << endl;
		
		flag = 0;
		
		for(Int_t j = 0; j < graphPoints - 3; j++) {
			if((yConv[j + 1] - half)*(yConv[j] - half) < 0 && flag == 0) {
				xFirst[i] = xInput[j];
				flag = 1;
				cout << "found first point! " << xFirst[i] << endl;
				continue;
			}
			if((yConv[j + 1] - half)*(yConv[j] - half) < 0 && flag == 1) {
				xLast[i] = xInput[j];
				cout << "found last point! " << xLast[i] << endl;
				break;
			}
		}
	}
	
	vector<double> expectedFWHM1Point9V(nClip);
	for(Int_t i = 0; i < expectedFWHM1Point9V.size(); i++) {
		expectedFWHM1Point9V[i] = xLast[i] - xFirst[i];
		// convert from seconds to nanoseconds
		expectedFWHM1Point9V[i] *= 10E8;
		cout << "expectedFWHM1Point9V[" << i << "] = " << expectedFWHM1Point9V[i] << endl;
	}
	
	// expected FWHM 960 mV graph
	
	TGraphErrors *gExpClip1Point9V = new TGraphErrors(nClip,xClip,&expectedFWHM1Point9V[0],0,0);
	gExpClip1Point9V->SetLineStyle(7);
	gExpClip1Point9V->SetLineColor(kRed);
	gExpClip1Point9V->SetMarkerStyle(20);
	gExpClip1Point9V->SetMarkerSize(0.8);
	
	// Collection of Output FWHM graphs, 2 amplitudes, serveral V clipping
	
	TMultiGraph *mgClipOutputFWHM = new TMultiGraph();
	mgClipOutputFWHM->SetTitle("Collection of Output FWHM graphs, 2 amplitudes, serveral V clipping");
	
	mgClipOutputFWHM->Add(gClip1Point9V);
	mgClipOutputFWHM->Add(gClip960mV);
	mgClipOutputFWHM->Add(gExpClip960mV);
	mgClipOutputFWHM->Add(gExpClip1Point9V);
	
	
	TCanvas *cmgClipOutputFWHM = new TCanvas("cmgClipOutputFWHM","Collection of Output FWHM graphs, 2 amplitudes, serveral V clipping");
	mgClipOutputFWHM->Draw("APEL");
	
	cmgClipOutputFWHM->Modified();
	mgClipOutputFWHM->GetXaxis()->SetTitle("V clipping (mV)");
	mgClipOutputFWHM->GetYaxis()->SetTitle("Output FWHM (ns)");
	cmgClipOutputFWHM->Update();
		
	legend = new TLegend(0.6,0.67,0.89,0.86,"V input");
	legend->AddEntry(gClip1Point9V, "1.9 V", "lp");
	legend->AddEntry(gClip960mV, "960 mV", "lp");
	legend->AddEntry(gExpClip960mV, "Exp 960 mV", "lp");
	legend->AddEntry(gExpClip1Point9V, "Exp 1.9 V", "lp");
	legend->SetTextSize(0.04);
	legend->SetMargin(0.5);
	legend->Draw();
	
	// Hysteresis plot: V output (t) in function of V input (t) for several clipping values
	
	// variables used in the analysis
	
	Long64_t iInputMax, iOutputMax;
	Float_t xInputMax, xOutputMax, xInputHalf, xOutputHalf;
	Double_t InputMax, OutputMax, InputHalf, OutputHalf;
	
	Long64_t firstIndex = 0;
	Long64_t lastIndex = 0;
	Long64_t inputGraphPoints = 0;
	Long64_t outputGraphPoints = 0;
	
	// hard coded values to cut the x axis of both waves
	// Input wave
	
	inputWaveName += " graph";
	
	TGraphErrors *gInput = listOfGraphs->FindObject(inputWaveName);
	gInput->SetLineColor(kRed);
	gInput->SetLineWidth(2);
	
	xInput = gInput->GetX();
	yInput = gInput->GetY();
	inputGraphPoints = gInput->GetN();
	
	cout << inputGraphPoints << endl;
	
	// Invert the input wave
	
	for(Int_t i = 0; i < inputGraphPoints; i++) {
		yInput[i] = -(yInput[i]);
	}
	
	// find the x at which the graph reaches the max value
	
	iInputMax = TMath::LocMax(inputGraphPoints, yInput);
	xInputMax = xInput[iInputMax];
	cout << "iInputMax = " << iInputMax << endl;
	cout << "xInputMax = " << xInputMax << endl;
	InputMax = gInput->Eval(xInput[iInputMax]);
	cout << "InputMax = " << InputMax << endl;
	
	// Output wave
	
	outputWaveName += " graph";
	
	TGraphErrors *gOutput = listOfGraphs->FindObject(outputWaveName);
	gOutput->SetLineWidth(2);
	
	xOutput = gOutput->GetX();
	yOutput = gOutput->GetY();
	outputGraphPoints = gOutput->GetN();
	
	// find the x at which the graph reaches the max value
	
	iOutputMax = TMath::LocMax(outputGraphPoints, yOutput);
	xOutputMax = xOutput[iOutputMax];
	cout << "iOutputMax = " << iOutputMax << endl;
	cout << "xOutputMax = " << xOutputMax << endl;
	OutputMax = gOutput->Eval(xOutput[iOutputMax]);
	cout << "OutputMax = " << OutputMax << endl;
	
	// compute x delay between max points
	
	Double_t delay = xOutputMax - xInputMax;
	cout << "delay = " << delay << endl;
	
	// Shift the x axis of the input graph and create a new graph with only a portion of the first graph
	
	for(Int_t i = 0; i < inputGraphPoints; i++) {
		xInput[i] += inputDelay;
		
		if(xInput[i] >= lowerCut) {
			if(firstIndex == 0) firstIndex = i;
		}

		if(xInput[i] <= upperCut)
			lastIndex = i;
	}
	
	cout << "firstIndex = " << firstIndex << endl;
	cout << "lastIndex = " << lastIndex << endl;
	cout << "xInput[firstIndex] = " << xInput[firstIndex] << endl;
	cout << lastIndex - firstIndex << endl;
	
	Long64_t input2GraphPoints = lastIndex - firstIndex;
	
	TGraphErrors *gInput2 = new TGraphErrors(input2GraphPoints);
	gInput2->SetTitle(inputWaveName);
	
	for(Int_t i = firstIndex; i <= lastIndex; i++) {
		gInput2->SetPoint(i - firstIndex,xInput[i],yInput[i]);
	}
	
	TCanvas *cgInput2 = new TCanvas("cgInput2", "cgInput2", 1200,800);
	gInput2->Draw("AL");
	
	// create a new graph with only a portion of the first graph
	
	firstIndex = 0;
	lastIndex = 0;
	
	for(Int_t i = 0; i < outputGraphPoints; i++) {
		if(xOutput[i] >= lowerCut) {
			if(firstIndex == 0) firstIndex = i;
		}

		if(xOutput[i] <= upperCut)
			lastIndex = i;
	}
	
	cout << "firstIndex = " << firstIndex << endl;
	cout << "lastIndex = " << lastIndex << endl;
	cout << "xOutput[firstIndex] = " << xOutput[firstIndex] << endl;
	cout << lastIndex - firstIndex << endl;
	
	Long64_t output2GraphPoints = lastIndex - firstIndex;
	
	TGraphErrors *gOutput2 = new TGraphErrors(output2GraphPoints);
	gOutput2->SetTitle(outputWaveName);
	
	for(Int_t i = firstIndex; i <= lastIndex; i++) {
		gOutput2->SetPoint(i - firstIndex,xOutput[i],yOutput[i]);
	}
	
	TCanvas *cgOutput2 = new TCanvas("cgOutput2", "cgOutput2", 1200,800);
	gOutput2->Draw("AL");
	
	// first hysteresis plot
	
	Double_t step;
	
	Double_t *xInput2;
	xInput2 = gInput2->GetX();
	
	cout << "xInput2[input2GraphPoints - 1] = " << xInput2[input2GraphPoints - 1] << endl;
	cout << "xInput2[0] = " << xInput2[0] << endl;
	
	step = (xInput2[input2GraphPoints - 1] - xInput2[0])/output2GraphPoints;
	
	cout << "step = " << step << endl;
	
	// in case gInput2 and gOutput2 contain a different number of points create the hysteresis plot with gOutput2 points
	// and modify the yInput2 to match the number of points of yOutput2
	
	vector<double> yInput2;
	
	for(Int_t i = 0; i < output2GraphPoints; i++) {
		yInput2.push_back(gInput2->Eval(xInput2[0] + i*step));
	}
	
	Double_t *yOutput2;
	yOutput2 = gOutput2->GetY();
	
	TGraphErrors *gHyst = new TGraphErrors(output2GraphPoints, &yInput2.at(0),yOutput2);
	gHyst->SetTitle("Hysteresis plot");
	
	gHyst->GetXaxis()->SetTitle("Vin(t) [mV]");
	gHyst->GetYaxis()->SetTitle("Vout(t) [mV]");
	gHyst->GetYaxis()->SetTitleOffset(1.4);
	
	TCanvas *cgHyst = new TCanvas("cgHyst", "cgHyst", 1200,800);
	cgHyst->SetLeftMargin(0.12);
	gHyst->Draw("AL");
	
	// collection of graphs
	
	TMultiGraph *mgInputOutput = new TMultiGraph();
	mgInputOutput->Add(gInput);
	mgInputOutput->Add(gOutput);
	mgInputOutput->SetTitle("Input and output");
	
	TCanvas *cmgInputOutput = new TCanvas("cmgInputOutput", "Input and output", 1200,800);
	mgInputOutput->Draw("AL");
	cmgInputOutput->Update();
	legend = new TLegend(0.65,0.68,0.86,0.86);
	legend->AddEntry(gInput, "Input", "lp");
	legend->AddEntry(gOutput, "Output", "lp");
	legend->SetMargin(0.4);
	legend->SetTextSize(0.04);
	legend->Draw();
	cmgInputOutput->Modified();

	
}