コード例 #1
0
ファイル: plot_corr.C プロジェクト: dladams/dune_extensions
void plot_corr(TH2* phin, float cmin, float cmax) {
  ostringstream ssnam;
  ssnam << phin->GetName() << "_" << cmin << "_" << cmax;
  new TCanvas;
  TH2* ph = phin->Clone(ssnam.str().c_str());
  ph->GetXaxis()->SetRangeUser(cmin, cmax);
  ph->GetYaxis()->SetRangeUser(cmin, cmax);
  ph->Draw("colz");
  addaxis();
}
コード例 #2
0
ファイル: polar.C プロジェクト: alisw/AliRoot
void
polar()
{
   TCanvas *c1 = new TCanvas("c1","c1",500,500);
   TGraphPolar * grP1 = new TGraphPolar();
   grP1->SetTitle("TGraphPolar example");

   for (Int_t i = 0; i < 2; i++) {
     grP1->SetPoint(i, (i+1) * TMath::Pi() / 4, (i+1) * 0.05);
     grP1->SetPointError(i, 9*TMath::Pi()/180, 0.0);
     Double_t rr = grP1->GetY()[i];
     Double_t tt = grP1->GetX()[i];
     Double_t x  = rr * TMath::Cos(tt);
     Double_t y  = rr * TMath::Sin(tt);
     Printf("(x,y)=(%f,%f)", x, y);
   }
   Double_t r = 1;
   TH2* frame = new TH2F("frame", "Frame", 100, -r,r, 100, -r, r);
   frame->Draw();

   grP1->SetMarkerStyle(1);
   grP1->SetMarkerSize(1.);
   grP1->SetMarkerColor(4);
   grP1->SetLineColor(4);
   grP1->SetLineWidth(3);
   grP1->SetFillColor(kRed+1);
   grP1->SetFillStyle(3001);
   grP1->Draw("PNEF same");
   // grP1->Draw("APNEF");

   // Update, otherwise GetPolargram returns 0
   c1->Update();
   TGraphPolargram* gram = grP1->GetPolargram();
   gram->SetLineWidth(0);
   // gram->SetLineColor(kWhite);
   gram->SetNdivPolar(20);
   gram->SetNdivRadial(10);   
   gram->SetTextSize(0);
   gram->SetRadialLabelSize(0);
   gram->SetPolarLabelSize(0);
   gram->SetAxisAngle(9*TMath::Pi()/180);
   gram->SetTwoPi();
   gram->SetToRadian();
   c1->SetGridx();
   c1->SetGridy();
   c1->Update();
}
コード例 #3
0
void root_hist_test()
{
  // Project3D uses overflows?
  TH3* h3D = new TH3D("h3D", "h3D", 2,0,2, 2,0,2, 2,0,2);
  for(int i=0; i<=h3D->GetNbinsX()+1; i++) {
    for(int j=0; j<=h3D->GetNbinsY()+1; j++) {
      for(int k=0; k<=h3D->GetNbinsZ()+1; k++) {
        h3D->SetBinContent(i,j,k, 1);
      }
    }
  }

  printf("h3D integral = %d\tentries = %d\n", h3D->Integral(), h3D->GetEntries());

  h3D->GetZaxis()->SetRange(3,3);
  TH2* hYX = (TH2*) h3D->Project3D("yx");

  printf("hYX integral = %d\tentries = %d\n", hYX->Integral(), hYX->GetEntries());
  hYX->Draw("colz");
}
コード例 #4
0
ファイル: XSection.C プロジェクト: alisw/AliRoot
  void Draw() 
  {
    float min = 100000;
    float max = 0;
    std::vector<TGraph*> gs;
    float_array bg(fTKine.size());
    for (size_t i = 0; i < fTKine.size(); i++) bg[i] = fTKine[i]/fPDG->Mass();
    for (mech_array::iterator j = fMechs.begin(); j != fMechs.end(); ++j) {
      if (!(*j)->fStatus) continue;
      for (size_t i = 0; i < fTKine.size(); i++) {
	if ((*j)->fValues[i] == 0) continue;
	min = std::min(min, (*j)->fValues[i]);
	max = std::max(max, (*j)->fValues[i]);
      }
    }

    TCanvas* c = new TCanvas("c", "C", 700, 700);
    c->SetFillColor(0);
    c->SetLogy();
    c->SetLogx();
    c->SetGridy();
    c->SetGridx();
    float_array y(101);
    float ymin = log10(min);
    float dy   = (log10(max)+.5 - log10(min)) / y.size();
    for (size_t i = 1; i < y.size(); i++)  y[i] = pow(10, ymin + i * dy);
    TH2* f = new TH2F("x", "X-sec",bg.size()-1,&(bg[0]),y.size()-1,&(y[0]));
    f->SetXTitle("#beta#gamma");
    f->SetDirectory(0);
    f->SetStats(kFALSE);
    f->Draw();
    TLegend* l = new TLegend(0.45, 0.125, 0.90, 0.45);
    l->SetFillColor(0);
    // l->SetFillStyle(0);
    for (mech_array::iterator j = fMechs.begin(); j != fMechs.end(); ++j) {
      if (!(*j)->fStatus) continue;
      TGraph& g = (*j)->Draw();
      l->AddEntry(&g, g.GetTitle(), "l");
    }
    l->Draw("same");
  }
コード例 #5
0
// Make 2D efficiency plots
void makeplots2D( TH2& eff, TString name) {
  gROOT->ProcessLine(".L ~/tdrstyle.C");
  setTDRStyle();

  const Int_t NRGBs = 5;
  const Int_t NCont = 200;
  Double_t stops[NRGBs] = { 0.00, 0.34, 0.61, 0.84, 1.00 };
  Double_t red[NRGBs]   = { 0.00, 0.00, 0.87, 1.00, 0.51 };
  Double_t green[NRGBs] = { 0.00, 0.81, 1.00, 0.20, 0.00 };
  Double_t blue[NRGBs]  = { 0.51, 1.00, 0.12, 0.00, 0.00 };
  TColor::CreateGradientColorTable(NRGBs, stops, red, green, blue, NCont);
  tdrStyle->SetNumberContours(NCont);

  
  if(name.Contains("_Pt")) {
    eff.GetXaxis()->SetTitle("p_{T} (GeV/c)");
    eff.GetYaxis()->SetTitle("#eta     ");
  }

  if(name.Contains("_Phi")) {
    eff.GetXaxis()->SetTitle("#phi     ");
    eff.GetYaxis()->SetTitle("#eta     ");
  }

  eff.GetYaxis()->SetTitleOffset(1);


  tdrStyle->SetPadLeftMargin(0.08);
  tdrStyle->SetPadRightMargin(0.1);
 
  TCanvas canvas("canvas",name,600,600);
  eff.Draw("colz");
  gPad->Update();
  TPaletteAxis* palette = 
    (TPaletteAxis*)eff.GetListOfFunctions()->FindObject("palette");
  palette->SetLabelSize(0.02);
  canvas.SaveAs(name + TString(".eps"));
  canvas.SaveAs(name + TString(".gif"));
  canvas.Close();

}
コード例 #6
0
ファイル: chain_display.C プロジェクト: ayerbeg/track_finder
void DrawGrid()
{

Int_t ncol = 100;
  Int_t nrow = 200;
  
  
   TPad *grid = new TPad("grid","",0,0,1,1);
   grid->Draw();
   grid->cd();
   grid->SetGrid();
   grid->SetFillStyle(4000);
   grid->SetFrameFillStyle(0);


   TH2 *hgrid = new TH2C("hgrid","", ncol+1, -5, ncol+5, nrow, -5, nrow-1+5);
   hgrid->Draw();
   hgrid->GetXaxis()->SetNdivisions(6,100);
   hgrid->GetYaxis()->SetNdivisions(200);
   hgrid->GetYaxis()->SetLabelOffset(999.);
   hgrid->GetXaxis()->SetLabelOffset(999.);
}
コード例 #7
0
ファイル: IslandLoss.C プロジェクト: alcap-org/AlcapDAQ
void IslandLoss()
{
  /*****************************************************************/
  // Prepare the canvas
  gStyle->SetOptStat(""); 
  TCanvas *canvas = (TCanvas *) gROOT->GetListOfCanvases()->At(0);
  canvas->Clear();

  /*****************************************************************/
  TH2 *hExpected = (TH2 *)gDirectory->Get("hExpectedNumberOfIslands");
  TH2 *hActual = (TH2 *)gDirectory->Get("hNumberOfIslands");
  if (hExpected && hActual)
    {
      TVirtualPad *pad = canvas->cd(1);

      hExpected->Add(hActual, -1);
      hExpected->SetTitle("Difference between Expected Number of TPulseIslands and Actual Number of TPulseIslands");
      hExpected->GetXaxis()->SetRange(9,9);
      hExpected->GetYaxis()->SetRangeUser(0, 1200);
      hExpected->Draw("COLZ");
    }
}
コード例 #8
0
ファイル: DrawHistos.C プロジェクト: LehighRHIG/ControlCard
void DrawHistos(TString infile = "histos.root"){
    set_plot_style();
    gStyle->SetOptStat(0);
    gStyle->SetOptTitle(0);
    
    TFile *_file0 = TFile::Open(infile);
    TH1* hHardPartonspT = (TH1*)gROOT->FindObject("hHardPartonspT");
    TH1* hHardPartonsName = (TH1*)gROOT->FindObject("hHardPartonsName");
    TH1* hParticlepT = (TH1*)gROOT->FindObject("hParticlepT");
    TH2* hParticleEtaPhi = (TH2*)gROOT->FindObject("hParticleEtaPhi");

    TCanvas* can1 = new TCanvas("can1","",600,600);
    gPad->SetLeftMargin(0.15);
    gPad->SetLogy();
    SetHist(hParticlepT,"p_{T} (GeV/c)","Counts",2);
    SetHist(hHardPartonspT,"p_{T} (GeV/c)","Counts",1);
    hParticlepT->Draw();
    hHardPartonspT->Draw("same");
    TLegend* leg1 = new TLegend(0.6,0.7,0.85,0.85);
    SetLeg(leg1);
    leg1->AddEntry(hHardPartonspT,"Hard Parton","L");
    leg1->AddEntry(hParticlepT,"Final Particles","L");
    leg1->Draw();
    can1->SaveAs("pTgraph.png");
    
    TCanvas* can2 = new TCanvas("can2","",600,600);
    gPad->SetLeftMargin(0.15);
    SetHist(hHardPartonsName,"parton ID","Counts",1);
    hHardPartonsName->Draw();
    
    TCanvas* can3 = new TCanvas("can3","",600,600);
    gPad->SetLeftMargin(0.15);
    SetHist(hParticleEtaPhi,"p_{T} (GeV/c)","Counts",1);
    hParticleEtaPhi->Draw("COLZ");
   
    
  }
コード例 #9
0
ファイル: ExclusionPlot.C プロジェクト: SusyRa2b/NtupleTools
TList* getContours(const TH2* hist,double contourLevel,const TString filename)
{
  TH2* h = (TH2*)hist->Clone("_clone");
  double limitValue[1] = {contourLevel};
  h->SetContour(1,limitValue);
  TCanvas* c = new TCanvas("contour_canvas","Contour List",0,0,600,600);
  h->Draw("CONT LIST");
  c->Update();
  TList* contours = (TList*)((TObjArray*)gROOT->GetListOfSpecials()->FindObject("contours"))->At(0);
  TGraph* contour = (TGraph*)contours->First();
  if(filename!="") 
    {
      for(unsigned int j = 0; j < contours->GetSize(); j++)
	{
	  TString newFilename = filename+"_";
	  newFilename+=j;
	  contour->SaveAs(newFilename+".C");
	  contour = (TGraph*)contours->After(contour); // Get Next graph
	}
    }
  delete h;
  delete c;
  return contours;
}
コード例 #10
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");

  
  
}
コード例 #11
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();

}
コード例 #12
0
ファイル: main.cpp プロジェクト: cthornsb/SimplePixieScan
int Execute(int argc, char *argv[]){
	if(argc > 1 && (strcmp(argv[1], "-h") == 0 || strcmp(argv[1], "--help") == 0)){
		help(argv[0]);
		return 1;
	}
	else if(argc < 3){
		std::cout << " Error: Invalid number of arguments to " << argv[0] << ". Expected 2, received " << argc-1 << ".\n";
		help(argv[0]);
		return 1;
	}

	std::string draw_string = "";
	std::string save_filename = "";
	std::string save_histname = "";
	bool create_hist = false;
	int index = 3;
	while(index < argc){
		if(strcmp(argv[index], "--draw") == 0){
			if(index + 1 >= argc){
				std::cout << " Error! Missing required argument to '--draw'!\n";
				help(argv[0]);
				return 1;
			}
			draw_string = std::string(argv[++index]);
			create_hist = true;
		}
		else if(strcmp(argv[index], "--save") == 0){
			if(index + 2 >= argc){
				std::cout << " Error! Missing required argument to '--save'!\n";
				help(argv[0]);
				return 1;
			}
			save_filename = std::string(argv[++index]);
			save_histname = std::string(argv[++index]);
		}
		else{ 
			std::cout << " Error! Unrecognized option '" << argv[index] << "'!\n";
			help(argv[0]);
			return 1;
		}
		index++;
	}

	TApplication* rootapp = new TApplication("rootapp", 0, NULL);
	
	TCanvas *can1 = new TCanvas("can1", "Canvas");
	can1->cd()->SetLogz();

	TH2 *hist = NULL;
	TFile *file = new TFile(argv[1], "READ");
	if(!file->IsOpen()){
		std::cout << " Error! Failed to open input file '" << argv[1] << "'.\n";
		return 1;
	}

	if(!create_hist){
		hist = (TH2*)file->Get(argv[2]);
		if(!hist){
			std::cout << " Error! Failed to load input histogram '" << argv[2] << "'.\n";
			file->Close();
			return 1;
		}
	}
	else{	
		TTree *tree = (TTree*)file->Get(argv[2]);
		if(!tree){
			std::cout << " Error! Failed to load input histogram '" << argv[2] << "'.\n";
			file->Close();
			return 1;
		}
	
		std::cout << " " << argv[2] << "->Draw(\"" << draw_string << "\", \"\", \"COLZ\");\n";
		std::cout << " Filling TH2... " << std::flush;	
		//tree->Draw("vandle.loc:vandle.ctof>>(250,-80,-20,42,16,58)"); // VANDLE
		//tree->Draw("liquidbar.loc:liquidbar.ctof>>(250,-80,-20,10,64,74)"); // NeuDLES
		//tree->Draw("generic.loc:generic.tof>>(250,-80,-20,10,80,90)"); // HAGRiD
		tree->Draw(draw_string.c_str(), "", "COLZ");
		std::cout << "DONE\n";
	
		hist = (TH2*)tree->GetHistogram();	
	}

	if(!save_filename.empty()){
		TFile *ofile = new TFile(save_filename.c_str(), "RECREATE");
		ofile->cd();
		hist->Write(save_histname.c_str());
		ofile->Close();
		std::cout << " Saved histogram '" << save_histname << "' to file '" << save_filename << "'.\n";
	}

	hist->Draw("COLZ");
	can1->WaitPrimitive();

	TCanvas *can2 = new TCanvas("can2", "Canvas");

	Process(hist, can2);

	file->Close();
	can1->Close();
	can2->Close();
	
	delete file;
	delete can1;
	delete can2;
	
	return 0;
}
コード例 #13
0
ファイル: MUONStatusMap.C プロジェクト: ktf/AliRoot
//______________________________________________________________________________
void DrawEvolution(const char* file, bool normalized=true)
{

  TFile* f = TFile::Open(gSystem->ExpandPathName(file));

  if (!f) return;

  TCanvas* c = new TCanvas("mch-status-evolution","mch-status-evolution");

  c->SetGridy();
  c->SetTicky();

  c->Draw();

  TLegend* l = new TLegend(0.1,0.7,0.3,0.95,"ch evolution");

  TGraph* g = static_cast<TGraph*>(f->Get("nbad"));
  if (!g) return;

  int runmin = TMath::Nint(g->GetX()[0]);
  int runmax = TMath::Nint(g->GetX()[g->GetN()-1]);

  cout << Form("Run range found in file %s = %d - %d",file,runmin,runmax) << endl;

  double ymax(0.4);

  TH2* h = new TH2F("hframe","hframe;Run number;Fraction of dead channels",100,runmin-200,runmax+200,100,0,ymax);

  gStyle->SetOptStat(kFALSE);
  h->Draw();
  h->GetXaxis()->SetNoExponent();
  h->GetXaxis()->SetNdivisions(505);

  gStyle->SetOptTitle(kFALSE);

  DrawPeriod(runmin,runmax,115881,117222,0,ymax,"10b");
  DrawPeriod(runmin,runmax,119159,120824,0,ymax,"10c");
  DrawPeriod(runmin,runmax,122374,126424,0,ymax,"10d");
  DrawPeriod(runmin,runmax,127724,130850,0,ymax,"10e");
  DrawPeriod(runmin,runmax,133005,134929,0,ymax,"10f");
  DrawPeriod(runmin,runmax,135658,136376,0,ymax,"10g");
  DrawPeriod(runmin,runmax,137133,139513,0,ymax,"10h");
  DrawPeriod(runmin,runmax,143856,146860,0,ymax,"11a");
  DrawPeriod(runmin,runmax,148370,150702,0,ymax,"11b");
  DrawPeriod(runmin,runmax,151566,154583,0,ymax,"11c");
  DrawPeriod(runmin,runmax,158084,159606,0,ymax,"11d");
  DrawPeriod(runmin,runmax,160677,162717,0,ymax,"11e");
  DrawPeriod(runmin,runmax,162933,165744,0,ymax,"11f");
  DrawPeriod(runmin,runmax,167703,170593,0,ymax,"11h");

  // 2012

  DrawPeriod(runmin,runmax,176661,177295,0,ymax,"12a");
  DrawPeriod(runmin,runmax,177384,178053,0,ymax,"12b");
  DrawPeriod(runmin,runmax,179603,180569,0,ymax,"12c");
  DrawPeriod(runmin,runmax,183913,186320,0,ymax,"12d");
  DrawPeriod(runmin,runmax,186365,186602,0,ymax,"12e");
  DrawPeriod(runmin,runmax,186668,188123,0,ymax,"12f");
  DrawPeriod(runmin,runmax,188362,188503,0,ymax,"12g");
  DrawPeriod(runmin,runmax,189122,190110,0,ymax,"12h");

  // 2013

  DrawPeriod(runmin,runmax,195344,195483,0,ymax,"13b");
  DrawPeriod(runmin,runmax,195529,195677,0,ymax,"13c");
  DrawPeriod(runmin,runmax,195681,195873,0,ymax,"13d");
  DrawPeriod(runmin,runmax,195949,196311,0,ymax,"13e");
  DrawPeriod(runmin,runmax,196433,197388,0,ymax,"13f");

  // 2015
  // periods are from the logbook, taking only PHYSICS% partitions
  // into account
  DrawPeriod(runmin,runmax,213329,215151,0,ymax,"15a");
  DrawPeriod(runmin,runmax,215160,215579,0,ymax,"15b");
  DrawPeriod(runmin,runmax,215580,219968,0,ymax,"15c");
  DrawPeriod(runmin,runmax,220050,223195,0,ymax,"15d");
  DrawPeriod(runmin,runmax,223227,224779,0,ymax,"15e");
  DrawPeriod(runmin,runmax,224826,226606,0,ymax,"15f");
  DrawPeriod(runmin,runmax,228936,231321,0,ymax,"15g");
  DrawPeriod(runmin,runmax,232914,234050,0,ymax,"15h");
  DrawPeriod(runmin,runmax,235196,236866,0,ymax,"15i");
  DrawPeriod(runmin,runmax,236965,238621,0,ymax,"15j");
  DrawPeriod(runmin,runmax,238890,239025,0,ymax,"15k");
  DrawPeriod(runmin,runmax,239319,241544,0,ymax,"15l");
  DrawPeriod(runmin,runmax,244340,244628,0,ymax,"15n");
  DrawPeriod(runmin,runmax,244918,246994,0,ymax,"15o");

  // 2016
  DrawPeriod(runmin,runmax,247189,247193,0,ymax,"16a");
  DrawPeriod(runmin,runmax,247723,250585,0,ymax,"16b");
  DrawPeriod(runmin,runmax,250647,252091,0,ymax,"16c");
  
  DrawPeriod(runmin,runmax,252191,252518,0,ymax,"16d");
  DrawPeriod(runmin,runmax,252598,253609,0,ymax,"16e");
  DrawPeriod(runmin,runmax,253613,253979,0,ymax,"16f");
  DrawPeriod(runmin,runmax,253991,254332,0,ymax,"16g");
  DrawPeriod(runmin,runmax,254373,255469,0,ymax,"16h");
  DrawPeriod(runmin,runmax,255515,255650,0,ymax,"16i");
  DrawPeriod(runmin,runmax,256083,256420,0,ymax,"16j");
  DrawPeriod(runmin,runmax,256504,258574,0,ymax,"16k");
  DrawPeriod(runmin,runmax,258883,260187,0,ymax,"16l");
  DrawPeriod(runmin,runmax,260216,260647,0,ymax,"16m");
  DrawPeriod(runmin,runmax,260649,261812,0,ymax,"16n");
  DrawPeriod(runmin,runmax,262394,262858,0,ymax,"16o");

  Draw(f,"nbad",l,normalized);
  Draw(f,"nbadped",l,normalized);
  Draw(f,"nbadocc",l,normalized);
  Draw(f,"nbadhv",l,normalized);
  Draw(f,"nbadlv",l,normalized);
  Draw(f,"nmissing",l,normalized);
  Draw(f,"nreco",l,normalized);

  h->Draw("same");

  c->RedrawAxis("g");

  l->Draw();
}
コード例 #14
0
void simple2Dmodel_ex(Int_t statexp, Int_t statmod)
{
   //------------Suppress RooFit info messages-----------
   RooMsgService::instance().setGlobalKillBelow(RooFit::WARNING);

   //If RooWorkspace already generated
//    TFile *file = new TFile("./workspace_PARA_par1[0.0,10.0,10]_par2[-20.0,20.0,20]_OBS_obs1[-45.0,45.0,45]_obs2[-30.0,30.0,60].root");
//    RooWorkspace *ww = (RooWorkspace *) file->Get("init_workspace");


   //----------Init weights histogram--------
//    TFile *fileh = new TFile("./histo_par1_par2.root");
//    TH2F *histo = (TH2F*) fileh->Get("fittedParameters");
   //TH2F *histo = (TH2F*) fileh->Get("dummy");

   model = new BackTrack::Simple2DModel_Binned();
   model->InitWorkspace();
   model->InitParObs();

   //===========================
   //==     "EXP" DATASET     ==
   //===========================

   //Generate data with correlated gaussian-distribution parameters
   model->SetNumGen(statexp);
   RooDataSet data("data", "data to be fitted", model->GetObservables());
   RooDataSet params("params", "input parameters", model->GetParameters());
   RooRealVar& PAR1 = *(model->GetParameter("par1"));
   RooRealVar& PAR2 = *(model->GetParameter("par2"));

   for (int i = 0; i < model->GetNumGen(); i++) {
      //Double_t par1 = gRandom->Gaus(3.5,1.);
      Int_t par1     = (int) gRandom->Gaus(3.5, 1.);
      Double_t par2m = 15. - 0.5 * pow(par1, 2.);
      Double_t par2 = gRandom->Gaus(par2m, 1.);
      PAR1.setVal(par1);
      PAR2.setVal(par2);
      model->generateEvent(RooArgList(PAR1, PAR2), data);
      params.add(model->GetParameters());
   }

   //Create the "experimental" RooDataHist used for the fit  with the RooDataSet
   //generated just before
   RooDataHist datahist("datahist_exp", "input parameters", model->GetObservables(), data);

//    Modify the ranges for the fit
//    model->GetObservable("obs1")->setRange("RANGE",-10,32);
//    model->GetObservable("obs2")->setRange("RANGE",-20,15);

   //===========================
   //==    BACKTRACKING       ==
   //===========================
   //Initialise the BackTracking
   model->SetExperimentalDataHist(datahist);
   model->SaveInitWorkspace();
   model->SetNumInt(kTRUE);
   model->SetExtended(kFALSE);
   model->SetUniformInitWeight(kTRUE);
   model->SetNumGen(statmod);
   model->ImportAllModelData();
   model->ImportParamInitWeight();
   model->ConstructPseudoPDF(kFALSE);
   //model->fitTo(datahist, Save(), NumCPU(6), SumW2Error(kTRUE), PrintLevel(1), Minimizer("TMinuit","migrad"), Extended(kFALSE), Offset(kTRUE));
   model->fitTo(datahist, Save(), NumCPU(6), SumW2Error(kTRUE), PrintLevel(1), Minimizer("TMinuit", "migrad"), Extended(kFALSE), Offset(kTRUE), SetMaxIter(500000), SetMaxCalls(500000));
   //model->fitTo(datahist, Save(), NumCPU(6), SumW2Error(kTRUE), PrintLevel(1), Minimizer("GSLMultiMin","conjugatefr"), Extended(kFALSE), Offset(kTRUE), SetMaxCalls(500000), SetMaxIter(500000));
   //model->fitTo(datahist, Save(), NumCPU(4), SumW2Error(kTRUE), PrintLevel(1), Minimizer("GSLSimAn"), Extended(kFALSE), Offset(kTRUE)); //, SetEpsilon(0.01), SetMaxCalls(500000));


   //==================
   //==    PLOTS     ==
   //==================
   //---------------Results compared to experimental data----------------
   RooPlot* plot = model->GetObservable("obs1")->frame();
   data.plotOn(plot);
   model->GetPseudoPDF()->plotOn(plot);
   TCanvas* c = new TCanvas("Observables_results", "Observables_results");
   c->Divide(2, 1);
   c->cd(1);
   plot->Draw();

   plot = model->GetObservable("obs2")->frame();
   data.plotOn(plot);
   model->GetPseudoPDF()->plotOn(plot);
   c->cd(2);
   plot->Draw();

   //For binning
   RooRealVar* o1 = dynamic_cast<RooRealVar*>(model->GetObservables().at(0));
   RooAbsBinning& bins1 = o1->getBinning();
   Int_t N1 = bins1.numBins();

   RooRealVar* o2 = dynamic_cast<RooRealVar*>(model->GetObservables().at(1));
   RooAbsBinning& bins2 = o2->getBinning();
   Int_t N2 = bins2.numBins();


   TH2* hh = (TH2*)(model->GetPseudoPDF())->createHistogram("obs1,obs2", N1, N2);
   TH2* hhdata = (TH2*) data.createHistogram("obs1,obs2", N1, N2);

   if (hh && hhdata) {
      TCanvas* ccc = new TCanvas("Observables_results_2D", "2D_Observables_results");
      ccc->Divide(2, 2);
      ccc->cd(1);
      gPad->SetLogz();
      gPad->Modified();
      ccc->Update();
      hhdata->Draw("colz");
      ccc->cd(2);
      hhdata->Draw("lego");
      ccc->cd(3);
      gPad->SetLogz();
      gPad->Modified();
      ccc->Update();
      hh->Draw("colz");
      ccc->cd(4);
      hh->Draw("lego");

      //For binning
      RooRealVar* p1 = dynamic_cast<RooRealVar*>(model->GetParameters().at(0));
      RooAbsBinning& bins1 = p1->getBinning();
      Int_t NN1 = bins1.numBins();

      RooRealVar* p2 = dynamic_cast<RooRealVar*>(model->GetParameters().at(1));
      RooAbsBinning& bins2 = p2->getBinning();
      Int_t NN2 = bins2.numBins();


      //-----------Return input parameters---------------
      TH2F* hh_par_data = (TH2F*) params.createHistogram("par1,par2", NN1, NN2) ;
      if (hh_par_data) hh_par_data->Write();
      else printf("impossible to create hh_par_data\n");

      //-------------Return fitted parameters (see Simple2DModel.h")------------
      TH2F* hh_par_fit = (TH2F*) model->GetParameterDistributions();
      if (hh_par_fit) hh_par_fit->Write();
      else printf("impossible to create hh_par_fit\n");

      //Draw
      TCanvas* cc = new TCanvas("Parameters_results_2D", "2D_Parameters_results");
      cc->Divide(2, 2);
      cc->cd(1);
      hh_par_data->Draw("lego");
      cc->cd(2);
      hh_par_data->Draw("colz");
      cc->cd(3);
      hh_par_fit->Draw("lego");
      //hh_params->ProjectionX()->Draw();
      cc->cd(4);
      hh_par_fit->Draw("colz");
      //hh_params->ProjectionY()->Draw();

      //------Chi2 for fit result
      Double_t chi2 = hh_par_data->Chi2Test(hh_par_fit, "CHI2/NDF,P");
      printf("chi2/ndf=%e\n", chi2);

   }

   else {
      printf("WTF, impossible to createHistogram from GetPseudoPDF ???\n");
   }

   //------------------------------------------------------------------------
   RooPlot* pl = model->GetParameter("par1")->frame();
   model->GetParamDataHist()->plotOn(pl);
   new TCanvas("Plot_result_par1", "Plot PAR1");
   pl->Draw();

   pl = model->GetParameter("par2")->frame();
   model->GetParamDataHist()->plotOn(pl);
   new TCanvas("Plot_result_par2", "Plot PAR2");
   pl->Draw();
}
コード例 #15
0
ファイル: drawSupport.C プロジェクト: phuo/EPTwistRun1Pool
void drawSupport(){

#ifdef __CINT__
    gROOT->LoadMacro("AtlasUtils.C");
#endif
    SetAtlasStyle();


    char name[200];

    //sprintf(name,"Mydecorr_0_Calib1.root");
    sprintf(name,"Mydecorr_0_Calib1_1.root"); 
    //sprintf(name,"support.root");
    fin = TFile::Open(name);

    sprintf(name, "hcentrality");
    TH1* hcent = (TH1D*)fin->Get(name);

    sprintf(name, "hntrk_Fcal_%d",0);
    hntrk_Fcal[0] = (TH2*)fin->Get(name);
    hntrk_Fcal[0]->Rebin2D(5,5);

    sprintf(name, "hntrk_Fcal_%d",1);
    hntrk_Fcal[1] = (TH2*)fin->Get(name);
    sprintf(name, "hFCalAC");
    TH2* hFCalAC = (TH2*)fin->Get(name);

    TF1 *fa = new TF1("fa","[0] + [1]*x",0,7);
    double par2[] = {-1300,1125};
    fa->SetLineColor(kRed);
    fa->SetParameters(par2);
    fa->SetLineWidth(2);
    fa->SetLineStyle(2);

    TF1 *fa2 = new TF1("fa2","[0] + [1]*x",0,7);
    double par[] = {4.1,-1};
    fa2->SetLineColor(kRed);
    fa2->SetParameters(par);
    fa2->SetLineWidth(2);
    fa2->SetLineStyle(2);

    for (int ic=0; ic<NCENT; ic++) {
        sprintf(name,"hntrkloose_ic%d", ic); hntrkloose[ic] =(TH1D*)fin->Get(name);
        cout<<name<< " "<<hntrkloose[ic]->GetBinContent(3325)<< endl;
        sprintf(name,"hntrktight_ic%d", ic); hntrktight[ic] =(TH1D*)fin->Get(name);
    }

    for (int ic=0; ic<20; ic++) {
        sprintf(name,"hntrkcut_ic%d", ic); hntrkcut[ic] =(TH1D*)fin->Get(name);
    }



       sprintf(name,"sfcalAC");
       can = SetCan2(name, 2,2);
       hFCalAC->Draw("colz");
       hFCalAC->GetXaxis()->SetTitle("#Sigma E_{T}^{FCal A side} [TeV]");
       hFCalAC->GetYaxis()->SetTitle("#Sigma E_{T}^{FCal C side} [TeV]");
       hFCalAC->Rebin2D(10,10);
       hFCalAC->GetXaxis()->SetRangeUser(0,3.5);
       hFCalAC->GetYaxis()->SetRangeUser(0,3.5);
       gPad->SetLogz();
       fa2->Draw("same");
       sprintf(name,"%s.pdf", can->GetName()); can->SaveAs(name);


       sprintf(name,"sfcal");
       can = SetCan2(name, 2,2);
       hntrk_Fcal[0]->Draw("colz");
       hntrk_Fcal[0]->GetXaxis()->SetTitle("#Sigma E_{T}^{FCal} [TeV]");
       hntrk_Fcal[0]->GetYaxis()->SetTitle("N_{track}^{Loose}  [p_{T}>0.5GeV]");

       gPad->SetLogz();
       fa->Draw("same");
       sprintf(name,"%s.pdf", can->GetName()); can->SaveAs(name);



       sprintf(name,"sCentrality");
       can = SetCan2(name, 2,2);
       hcent->Draw();

       hcent->GetXaxis()->SetTitle("Centrality %");
       hcent->GetYaxis()->SetTitle("Nevents");

       sprintf(name,"%s.pdf", can->GetName()); can->SaveAs(name);



       int Nx=5, Ny=4;
       sprintf(name,"sntrkLoose");
       can = SetCan2D2(name,Nx, Ny);
       for (int ix=0; ix<Nx; ix++) {
       for (int iy=0; iy<Ny; iy++) {
       int ic = ix + iy*Nx;
       can->cd(ic+1);
       if(ic>=NCENT) continue;
       hntrkloose[ic] ->Rebin(10);
       hntrkloose[ic] ->DrawClone();
       gPad->SetLogy();
       gPad->Update();
       }
       }

       sprintf(name,"%s.pdf", can->GetName()); can->SaveAs(name);
       sprintf(name,"%s.root", can->GetName()); can->SaveAs(name);


       sprintf(name,"sntrkCut");
       can = SetCan2D2(name,Nx, Ny);
       for (int ix=0; ix<Nx; ix++) {
       for (int iy=0; iy<Ny; iy++) {
       int ic = ix + iy*Nx;
       can->cd(ic+1);
       hntrkcut[ic] ->Rebin(10);
       hntrkcut[ic] ->Draw();
       gPad->SetLogy();
       }
       }

       sprintf(name,"%s.pdf", can->GetName()); can->SaveAs(name);
       sprintf(name,"%s.root", can->GetName()); can->SaveAs(name);



}
コード例 #16
0
ファイル: pidHistogramMaker.cpp プロジェクト: jdbrice/tofPID
void pidHistogramMaker::speciesReport( string pType, int charge, int etaBin ){
	
	string name = speciesName( pType, charge );

	cout << "\tSpecies Report : " << name << endl;

	uint nBinsP = ptBins.size();
	

	TH3 * h3 = book->get3D( "nSig_" + name );

	taskProgress tp( pType + " report", nBinsP );

	for ( uint i = 0; i < nBinsP; i ++ ){

		tp.showProgress( i );

		// momentum value used for finding nice range
		double p = ptBins[ i ];


		pReport[ name ]->newPage( 2, 2 );
		pReport[ name ]->cd( 1, 2 );
		h3->GetZaxis()->SetRange( i, i );
		
		TH2* proj;
		TH1* proj1D;

		double pLow = h3->GetZaxis()->GetBinLowEdge( i );
		double pHi = h3->GetZaxis()->GetBinLowEdge( i + 1 );
		if ( 0 == i ){
			pLow = h3->GetZaxis()->GetBinLowEdge( 1 );
			pHi = h3->GetZaxis()->GetBinLowEdge( ptBins.size()-1 );
		}
		

		string order = "xy";
		string tofAxis = config->getString( "binning.tofAxis", "x" );
		if ( tofAxis == "y" )
			order = "yx";
		

		proj = (TH2*)h3->Project3D( order.c_str() );
		
		if ( i > 0 && tofMetric == inverseBeta ){
			double tofLow, tofHigh, dedxLow, dedxHigh;
			autoViewport( pType, p, &tofLow, &tofHigh, &dedxLow, &dedxHigh, tofPadding, dedxPadding, tofScalePadding, dedxScalePadding );
		
			proj->GetYaxis()->SetRangeUser( tofLow, tofHigh );
			proj->GetXaxis()->SetRangeUser( dedxLow, dedxHigh );
		}
		
		string hTitle = (pType + " : " + ts( pLow, 4 ) + " #leq " + " P #leq" + ts( pHi, 4 ) );
		string hName = (pType + "_" + ts(i) + "_" + ts(etaBin) );
		proj->SetTitle( hTitle.c_str()  );
		gPad->SetLogz( 1 );
		proj->Draw( "colz" );

	
		if ( tofAxis == "x" ){
			pReport[ name ]->cd( 2, 2 );
			proj1D = proj->ProjectionX();
			proj1D->SetTitle( ( "dedx : " + pType + " : " + ts( pLow, 4 ) + " #leq " + " P #leq" + ts( pHi, 4 )  ).c_str()  );
			proj1D->SetFillColor( kBlue );
			gPad->SetLogx( 1 );
			proj1D->Draw( "hbar" );

			pReport[ name ]->cd( 1, 1 );
			proj1D = proj->ProjectionY();
			proj1D->SetTitle( ( "1/#beta : " + pType + " : " + ts( pLow, 4 ) + " #leq " + " P #leq" + ts( pHi, 4 )  ).c_str()  );
			gPad->SetLogy( 1 );
			proj1D->SetFillColor( kBlue );
			proj1D->Draw( "" );
		} else {
			pReport[ name ]->cd( 2, 2 );
			proj1D = proj->ProjectionY();
			proj1D->SetTitle( ( "#beta^{-1} : " + pType + " : " + ts( pLow, 4 ) + " #leq " + " P #leq" + ts( pHi, 4 )  ).c_str()  );
			proj1D->SetFillColor( kBlue );
			gPad->SetLogx( 1 );
			proj1D->Draw( "hbar" );

			pReport[ name ]->cd( 1, 1 );
			proj1D = proj->ProjectionX();
			proj1D->SetTitle( ( "dedx : " + pType + " : " + ts( pLow, 4 ) + " #leq " + " P #leq" + ts( pHi, 4 )  ).c_str()  );
			gPad->SetLogy( 1 );
			proj1D->SetFillColor( kBlue );
			proj1D->Draw( "" );
		}

		


		pReport[ name ]->savePage();

	}

	

} 
コード例 #17
0
void plot_fitter_validation()
{
  TFile* fin = new TFile("fitter_validation_cafana.root");

  const int dcpCols[] = {kBlack, kRed, kGreen+2, kBlue};
  const std::string dcpStrs[] = {"0", "#pi/2", "#pi", "3#pi/2"};

  for(std::string hcStr: {"fhc", "rhc"}){
    const std::string HCStr = (hcStr == "fhc") ? "FHC" : "RHC";

    for(std::string chanStr: {"numu", "nue"}){
      const std::string CHANStr = (chanStr == "numu") ? "#nu_{#mu}" : "#nu_{e}";

      for(std::string hieStr: {"nh", "ih"}){
        const std::string HIEStr = (hieStr == "nh") ? "NH" : "IH";

        new TCanvas;

        for(int deltaIdx2 = 0; deltaIdx2 < 4; ++deltaIdx2){
          // For neutrinos 3pi/2 is the tallest histogram, draw it first, for
          // antineutrinos we need pi/2 first.
          const int deltaIdx = (hcStr == "fhc") ? 3-deltaIdx2 : (deltaIdx2+1)%4;

          const std::string dcpStr = TString::Format("%gpi", deltaIdx/2.).Data();

          TH1* h = (TH1*)fin->Get((chanStr+"_"+hcStr+"_"+hieStr+"_"+dcpStr).c_str());
          h->SetLineColor(dcpCols[deltaIdx]);
          h->Draw("same");

          h->SetTitle(("5 yrs "+HCStr+" "+CHANStr+" "+HIEStr).c_str());
        } // end for deltaIdx

        TLegend* leg = new TLegend(.6, .6, .85, .85);
        leg->SetFillStyle(0);
        for(int deltaIdx = 0; deltaIdx < 4; ++deltaIdx){
          TH1* dummy = new TH1F("", "", 1, 0, 1);
          dummy->SetLineColor(dcpCols[deltaIdx]);
          leg->AddEntry(dummy, ("#delta_{CP}="+dcpStrs[deltaIdx]).c_str(), "l");
        }
        leg->Draw("same");

        gPad->Print((hcStr+"_"+chanStr+"_"+hieStr+".pdf").c_str());
      } // end for hieStr
    } // end for chanStr
  } // end for hcStr


  TGraph* gNH = (TGraph*)fin->Get("sens_nh");
  TGraph* gIH = (TGraph*)fin->Get("sens_ih");
  TGraph* gNHOscErr = (TGraph*)fin->Get("sens_nh_oscerr");
  TGraph* gIHOscErr = (TGraph*)fin->Get("sens_ih_oscerr");

  TGraph* gNHFlux[10];
  TGraph* gIHFlux[10];
  for(int i = 0; i < 10; ++i){
    gNHFlux[i] = (TGraph*)fin->Get(TString::Format("sens_nh_flux%d", i).Data());
    gIHFlux[i] = (TGraph*)fin->Get(TString::Format("sens_ih_flux%d", i).Data());
  }

  TGraph* gNHXSec[10];
  TGraph* gIHXSec[10];
  for(int i = 0; i < 10; ++i){
    gNHXSec[i] = (TGraph*)fin->Get(TString::Format("sens_nh_xsec%d", i).Data());
    gIHXSec[i] = (TGraph*)fin->Get(TString::Format("sens_ih_xsec%d", i).Data());
  }

  TH2* axes = new TH2F("", ";#delta_{CP} / #pi;#sigma = #sqrt{#Delta#chi^{2}}", 100, 0, 2, 100, 0, 8);
  axes->GetXaxis()->CenterTitle();
  axes->GetYaxis()->SetTitleOffset(.75);
  axes->GetYaxis()->CenterTitle();
  axes->Draw();

  gNH->Draw("l same");
  gIH->Draw("l same");
  gNHOscErr->Draw("l same");
  gIHOscErr->Draw("l same");

  TLegend* leg = new TLegend(.4, .65, .6, .875);
  leg->SetFillStyle(0);
  leg->AddEntry(gNH, "NH", "l");
  leg->AddEntry(gIH, "IH", "l");
  leg->AddEntry(gNHOscErr, "NH osc err", "l");
  leg->AddEntry(gIHOscErr, "IH osc err", "l");
  leg->Draw();

  gPad->Print("mcd.pdf");


  new TCanvas;
  axes->Draw();
  for(int i = 0; i < 10; ++i){
    gNHFlux[i]->Draw("l same");
    gIHFlux[i]->Draw("l same");
  }
  gNH->Draw("l same");
  gIH->Draw("l same");

  leg = new TLegend(.4, .65, .6, .875);
  leg->SetFillStyle(0);
  leg->AddEntry(gNH, "NH", "l");
  leg->AddEntry(gIH, "IH", "l");
  leg->AddEntry(gNHFlux[0], "NH flux err", "l");
  leg->AddEntry(gIHFlux[0], "IH flux err", "l");
  leg->Draw();

  gPad->Print("mcd_flux.pdf");


  new TCanvas;
  axes->Draw();
  for(int i = 0; i < 10; ++i){
    gNHXSec[i]->Draw("l same");
    gIHXSec[i]->Draw("l same");
  }
  gNH->Draw("l same");
  gIH->Draw("l same");

  leg = new TLegend(.4, .65, .6, .875);
  leg->SetFillStyle(0);
  leg->AddEntry(gNH, "NH", "l");
  leg->AddEntry(gIH, "IH", "l");
  leg->AddEntry(gNHXSec[0], "NH xsec err", "l");
  leg->AddEntry(gIHXSec[0], "IH xsec err", "l");
  leg->Draw();

  gPad->Print("mcd_xsec.pdf");
}
コード例 #18
0
void ClusterDensityFromQA(const char* qaFile="")
{
    if ( TString(qaFile).BeginsWith("alien"))
    {
        TGrid::Connect("alien://");
    }

    TFile* f = TFile::Open(qaFile);


    std::vector<IntegrationRange> rangesLow;
    std::vector<IntegrationRange> rangesHigh;

    rangesLow.push_back(IntegrationRange{-10,10, 80, 85});
    rangesLow.push_back(IntegrationRange{-10,10, 80, 85});
    rangesLow.push_back(IntegrationRange{-10,10, 95,100});
    rangesLow.push_back(IntegrationRange{-10,10, 95,100});

    for ( int i = 0; i < 4; ++i )
    {
        IntegrationRange ref = rangesLow[i];

        TObjArray* a = static_cast<TObjArray*>(f->Get("MUON_QA/expert"));

        TH2* h = static_cast<TH2*>(a->FindObject(Form("hClusterHitMapInCh%d",i+1)));

        // derive other symetric ranges from that one
        
        std::vector<IntegrationRange> ranges;

        double ysize = ref.ymax - ref.ymin;
        double xsize = (ref.xmax - ref.xmin)/2.0;

        ranges.push_back(ref);
        ranges.push_back(IntegrationRange{ref.xmin,ref.xmax,-ref.ymax,-ref.ymin});
        ranges.push_back(IntegrationRange{ref.ymin+ysize/2.0,ref.ymax,ref.xmin,ref.xmax});

        TCanvas* c = new TCanvas(Form("Chamber%d",i+1),Form("Chamber%d",i+1));

        h->Draw("colz");

        std::cout << "CHAMBER " << i+1 << " LOW = ";

        for ( auto r : ranges )
        {
            double count = h->Integral(
                h->GetXaxis()->FindBin(r.xmin),
                h->GetXaxis()->FindBin(r.xmax),
                h->GetYaxis()->FindBin(r.ymin),
                h->GetYaxis()->FindBin(r.ymax)
                );

            std::cout << " " << count << "(" << r.Surface() << " cm^2)";
            std::vector<double> x = { r.xmin,r.xmax,r.xmax,r.xmin,r.xmin };
            std::vector<double> y = { r.ymax,r.ymax,r.ymin,r.ymin,r.ymax };

            TPolyLine* l = new TPolyLine(5,&x[0],&y[0]);
            l->SetLineColor(1);
            l->SetLineStyle(9);
            l->Draw();
        }

        std::cout << std::endl;

    }
}
コード例 #19
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" : "")));
	    
					   
}
コード例 #20
0
ファイル: binary.C プロジェクト: jdbrice/tofPID
void binary( string inFile = "allSim.root", int cSpecies = 1, bool cutDedx = false ){

	TCanvas * c = new TCanvas( "c", "c", 800, 800 );
	string outName = "rpBinaryPid.pdf";
	c->Print( (outName+"[").c_str() );

	TFile * f = new TFile( inFile.c_str(), "READ" );

	string rOutName = "rootBinaryPid.root";
	TFile * fOut = new TFile( rOutName.c_str(), "RECREATE" );

	vector<double>effVsP;
	vector<double>pureVsP;

	c->Divide( 2, 2 );
	for ( int i = 0; i < 70; i++ ){

		stringstream sstr;
		sstr << "h_dedx_tof_p3_b" << i;
		TH2* sum = (TH2*)f->Get( sstr.str().c_str() );
		
		sstr.str("");
		sstr << "h_dedx_tof_p0_b" << i;

		TH2* p0 = (TH2*)f->Get( sstr.str().c_str() );
		sstr.str("");
		sstr << "h_dedx_tof_p1_b" << i;
		TH2* p1 = (TH2*)f->Get( sstr.str().c_str() );
		sstr.str("");
		sstr << "h_dedx_tof_p2_b" << i;
		TH2* p2 = (TH2*)f->Get( sstr.str().c_str() );

		pidBinary * pid = new pidBinary( sum, cSpecies, p0, p1, p2 );
		pid->cutDedx( cutDedx );

		c->cd( 3 );
		gPad->SetLogz(1);
		sum->Draw("colz");
		

		c->cd( 4 );
		gPad->SetLogx(1);
		TH1* pX = sum->ProjectionX();
		TH1* pY = sum->ProjectionY();
		pY->SetFillColor( kBlue );
		pY->SetLineColor( kBlue );
		pY->Draw("hbar");


		c->cd(1);
		gPad->SetLogy(1);
		pX->SetFillColor( kBlue );
		pX->SetLineColor( kBlue );
		pX->Draw("h");
		c->cd(2);
		
		sstr.str("");
		sstr << "eff_" << i;
		TH1D* eff = pid->efficiency( sstr.str(), 0.0, 5.0, 0.1 );
		sstr.str("");
		sstr << "pure_" << i;
		TH1D* pure = pid->purity( sstr.str(), 0.0, 5.0, 0.1 );

		gStyle->SetOptStat( 0 );
		eff->SetTitle( "Efficiecy (Blue), Purity (Red)" );
		eff->GetYaxis()->SetRangeUser(0, 1.05);
		eff->SetLineWidth( 2 );
		eff->Draw();
		pure->SetLineColor( kRed );
		pure->SetLineWidth( 2 );
		pure->Draw("same");

		effVsP.push_back( pid->efficiency() );
		pureVsP.push_back( pid->purity( ) );

		c->Print( outName.c_str());
	}

	int nBins = (3.7 - 0.2) / 0.05;
	TH1D * hEffVsP = new TH1D( "hEffVsP", "Efficiency Vs. P; P [GeV]", nBins, 0.2, 3.7 );
	for ( int i = 0; i < effVsP.size(); i++ ){
		hEffVsP->SetBinContent( i, effVsP[ i ] );
	}
	TH1D * hPureVsP = new TH1D( "hPureVsP", "Purity Vs. P; P [GeV]", nBins, 0.2, 3.7 );
	for ( int i = 0; i < pureVsP.size(); i++ ){
		hPureVsP->SetBinContent( i, pureVsP[ i ] );
	}

	c->Divide( 1 );
	c->cd( 0 );
	hEffVsP->GetYaxis()->SetRangeUser( 0.0, 1.05);
	hEffVsP->SetLineWidth( 2 );
	hEffVsP->SetTitle( "Efficiency (Blue), Purity (Red)" );
	hEffVsP->Draw( "");
	hPureVsP->SetLineColor( kRed );
	hPureVsP->SetLineWidth( 2 );
	hPureVsP->Draw( "same" );

	c->Print( outName.c_str());



	c->Print( (outName+"]").c_str() );

	fOut->Write();

}
コード例 #21
0
void eregtest_flextest(bool dobarrel, bool doele) {
  
  TString dirname = "/afs/cern.ch/work/b/bendavid/bare/eregtestoutalphafix2_float/"; 
  gSystem->mkdir(dirname,true);
  gSystem->cd(dirname);    
  
  
  
  TString fname;
  if (doele && dobarrel) 
    fname = "wereg_ele_eb.root";
  else if (doele && !dobarrel) 
    fname = "wereg_ele_ee.root";
  else if (!doele && dobarrel) 
    fname = "wereg_ph_eb.root";
  else if (!doele && !dobarrel) 
    fname = "wereg_ph_ee.root";
  
  //TString infile = TString::Format("/afs/cern.ch/work/b/bendavid/bare/eregAug10RCalphafixphiblind//%s",fname.Data());
    
  TString infile = TString::Format("/data/bendavid/regflextesting/%s",fname.Data());
   
  TFile *fws = TFile::Open(infile); 
  RooWorkspace *ws = (RooWorkspace*)fws->Get("wereg");
  
  //RooGBRFunction *func = static_cast<RooGBRFunction*>(ws->arg("func"));
  RooGBRTargetFlex *sigmeant = (RooGBRTargetFlex*)ws->function("sigmeant");
  RooRealVar *tgtvar = ws->var("tgtvar");

  //tgtvar->removeRange();
  //tgtvar->setRange(0.98,1.02);

  
  RooRealVar *rawptvar = new RooRealVar("rawptvar","ph.scrawe/cosh(ph.eta)",1.);
  if (!dobarrel) rawptvar->SetTitle("(ph.scrawe+ph.scpse)/cosh(ph.eta)");
  
  RooRealVar *rawevar = new RooRealVar("rawevar","ph.scrawe",1.);
  if (!dobarrel) rawevar->SetTitle("(ph.scrawe+ph.scpse)");  
  
  RooRealVar *nomevar = new RooRealVar("nomevar","ph.e",1.);
  
  
  RooArgList vars;
  vars.add(sigmeant->FuncVars());
  vars.add(*tgtvar);
  vars.add(*rawptvar);
  vars.add(*rawevar);
  vars.add(*nomevar);
   
  RooArgList condvars;
  condvars.add(sigmeant->FuncVars());
  
  RooRealVar weightvar("weightvar","",1.);

  TTree *dtree;
  
  if (doele) {
    TFile *fdin = TFile::Open("/data/bendavid/regTreesAug1/hgg-2013Final8TeV_reg_s12-zllm50-v7n_noskim.root");
    TDirectory *ddir = (TDirectory*)fdin->FindObjectAny("PhotonTreeWriterSingleInvert");
    dtree = (TTree*)ddir->Get("hPhotonTreeSingle");       
  }
  else {
    TFile *fdin = TFile::Open("/data/bendavid/idTreesAug1/hgg-2013Final8TeV_ID_s12-h124gg-gf-v7n_noskim.root");
    //TFile *fdin = TFile::Open("/data/bendavid/idTrees_7TeV_Sept17/hgg-2013Final7TeV_ID_s11-h125gg-gf-lv3_noskim.root");
    TDirectory *ddir = (TDirectory*)fdin->FindObjectAny("PhotonTreeWriterPreselNoSmear");
    dtree = (TTree*)ddir->Get("hPhotonTreeSingle");       
  }
  
//   if (0)
//   {
//    
//     TFile *fdin = TFile::Open("/data/bendavid/8TeVFinalTreesSept17/hgg-2013Final8TeV_s12-diphoj-v7n_noskim.root");
//     TDirectory *ddir = (TDirectory*)fdin->FindObjectAny("PhotonTreeWriterPresel");
//     dtree = (TTree*)ddir->Get("hPhotonTreeSingle");        
//     
//   }

  if (0)
  {
   
    TFile *fdin = TFile::Open("/data/bendavid/diphoTrees8TeVOct6/hgg-2013Final8TeV_s12-h123gg-gf-v7n_noskim.root");
    TDirectory *ddir = (TDirectory*)fdin->FindObjectAny("PhotonTreeWriterPreselNoSmear");
    dtree = (TTree*)ddir->Get("hPhotonTreeSingle");        
    
  }
  
//   //TFile *fdin = TFile::Open("/home/mingyang/cms/hist/hgg-2013Moriond/merged/hgg-2013Moriond_s12-diphoj-3-v7a_noskim.root");
//   //TFile *fdin = TFile::Open("root://eoscms.cern.ch//eos/cms/store/cmst3/user/bendavid/trainingtreesJul1/hgg-2013Final8TeV_s12-zllm50-v7n_noskim.root");
//   TFile *fdin = TFile::Open("root://eoscms.cern.ch///eos/cms/store/cmst3/user/bendavid/idTreesAug1/hgg-2013Final8TeV_ID_s12-h124gg-gf-v7n_noskim.root");
//   //TFile *fdin = TFile::Open("root://eoscms.cern.ch//eos/cms/store/cmst3/user/bendavid/regTreesAug1/hgg-2013Final8TeV_reg_s12-zllm50-v7n_noskim.root");
//   //TDirectory *ddir = (TDirectory*)fdin->FindObjectAny("PhotonTreeWriterSingleInvert");
//   TDirectory *ddir = (TDirectory*)fdin->FindObjectAny("PhotonTreeWriterPreselNoSmear");
//   TTree *dtree = (TTree*)ddir->Get("hPhotonTreeSingle");    
  
/*  TFile *fdinsig = TFile::Open("/home/mingyang/cms/hist/hgg-2013Moriond/merged/hgg-2013Moriond_s12-h125gg-gf-v7a_noskim.root");
  TDirectory *ddirsig = (TDirectory*)fdinsig->FindObjectAny("PhotonTreeWriterPreselNoSmear");
  TTree *dtreesig = (TTree*)ddirsig->Get("hPhotonTreeSingle"); */     
  
  TCut selcut;
  if (dobarrel) {
    selcut = "ph.pt>25. && ph.isbarrel && ph.ispromptgen && abs(ph.sceta)>(-1.0)";
    //selcut = "ph.pt>25. && ph.isbarrel && ph.ispromptgen && abs(ph.sceta)>(-1.0) && run==194533 && lumi==5 && evt==1400"; 
  }
  else {
    selcut = "ph.pt>25 && !ph.isbarrel && ph.ispromptgen";
    //selcut = "ph.pt>25 && !ph.isbarrel && ph.ispromptgen && run==194533 && lumi==5 && evt==1400"; 
  }
  
//  TCut selcut = "ph.pt>25. && ph.isbarrel && ph.ispromptgen && abs(ph.sceta)<1.0"; 
  //TCut selcut = "ph.pt>25. && ph.isbarrel && (ph.scrawe/ph.gene)>0. && (ph.scrawe/ph.gene)<2. && ph.ispromptgen";
  //TCut selcut = "ph.pt>25. && ph.isbarrel && (ph.gene/ph.scrawe)>0. && (ph.gene/ph.scrawe)<2.";
  TCut selweight = "xsecweight(procidx)*puweight(numPU,procidx)";
  TCut prescale10 = "(evt%10==0)";
  TCut prescale10alt = "(evt%10==1)";
  TCut prescale25 = "(evt%25==0)";
  TCut prescale100 = "(evt%100==0)";  
  TCut prescale1000 = "(evt%1000==0)";  
  TCut evenevents = "(evt%2==0)";
  TCut oddevents = "(evt%2==1)";
  TCut prescale100alt = "(evt%100==1)";
  TCut prescale1000alt = "(evt%1000==1)";
  TCut prescale50alt = "(evt%50==1)";
  //TCut oddevents = prescale100;
  
  if (doele) 
    weightvar.SetTitle(prescale100alt*selcut);
  else
    weightvar.SetTitle(selcut);
  
  RooDataSet *hdata = RooTreeConvert::CreateDataSet("hdata",dtree,vars,weightvar);   

  
//   for (int iev=0; iev<hdata->numEntries(); ++iev) {
//     const RooArgSet *dset = hdata->get(iev);
//     
//     condvars = *dset;
//     condvars.Print("V");
//     
//   }
  
  //return;
  
  
//   if (doele) 
//     weightvar.SetTitle(prescale100alt*selcut);
//   else
//     weightvar.SetTitle(selcut);
  
  //RooDataSet *hdatasmall = RooTreeConvert::CreateDataSet("hdatasmall",dtree,vars,weightvar);     
  
    
//   const HybridGBRForestD *forest = func->Forest();
//   for (unsigned int itgt=0; itgt<forest->Trees().size(); ++itgt) {
//     int ntrees = 0;
//     for (unsigned int itree = 0; itree<forest->Trees().at(itgt).size(); ++itree) {
//       if (forest->Trees()[itgt][itree].Responses().size()>1) ++ntrees;
//     }
//     printf("itgt = %i, ntrees = %i\n", int(itgt),ntrees);
//   }
  
  
  RooAbsPdf *sigpdf = ws->pdf("sigpdf");
  
  RooRealVar *scetavar = ws->var("var_1");
  
  RooAbsReal *sigmeanlim = ws->function("sigmeanlim");
  RooAbsReal *sigwidthlim = ws->function("sigwidthlim");
  RooAbsReal *signlim = ws->function("signlim");
  RooAbsReal *sign2lim = ws->function("sign2lim");
  RooAbsReal *alphalim = ws->function("sigalphalim");
  RooAbsReal *alpha2lim = ws->function("sigalpha2lim");  

  //RooFormulaVar ecor("ecor","","1./(@0*@1)",RooArgList(*tgtvar,*sigmeanlim));
  RooFormulaVar ecor("ecor","","@1/@0",RooArgList(*tgtvar,*sigmeanlim));
  //RooFormulaVar ecor("ecor","","@0/@1",RooArgList(*tgtvar,*sigmeanlim));
  //RooFormulaVar ecor("ecor","","exp(@1-@0)",RooArgList(*tgtvar,*sigmeanlim));
  
  
  RooAbsReal *condnll = sigpdf->createNLL(*hdata,ConditionalObservables(sigmeant->FuncVars()));

  double condnllval = condnll->getVal();
  
  
  //RooFormulaVar ecor("ecor","","@1/@0",RooArgList(*tgtvar,*sigmeanlim));
  //RooFormulaVar ecor("ecor","","@0/@1",RooArgList(*tgtvar,*sigmeanlim));
  //RooFormulaVar ecor("ecor","","@0",RooArgList(*tgtvar));
  //RooRealVar *ecorvar = (RooRealVar*)hdata->addColumn(ecor);
//   ecorvar->setRange(0.,2.);
//   ecorvar->setBins(800);
  
//    RooFormulaVar raw("raw","","1./@0",RooArgList(*tgtvar));
//    //RooRealVar *rawvar = (RooRealVar*)hdata->addColumn(raw);
//    rawvar->setRange(0.,2.);
//    rawvar->setBins(800);

/*  RooFormulaVar eraw("eraw","","@0",RooArgList(*tgtvar));
  RooRealVar *erawvar = (RooRealVar*)hdatasig->addColumn(eraw);
  erawvar->setRange(0.,2.);
  erawvar->setBins(400); */ 

  //RooFormulaVar ecor("ptcor","","@0/(@1)",RooArgList(*tgtvar,*sigmeanlim));
  
  RooDataSet *hdataclone = new RooDataSet(*hdata,"hdataclone");
  RooRealVar *ecorvar = (RooRealVar*)hdataclone->addColumn(ecor);
  RooRealVar *meanvar = (RooRealVar*)hdataclone->addColumn(*sigmeanlim);
  RooRealVar *widthvar = (RooRealVar*)hdataclone->addColumn(*sigwidthlim);
  RooRealVar *nvar = 0;
  if (signlim) nvar = (RooRealVar*)hdataclone->addColumn(*signlim);
  RooRealVar *n2var = 0;
  if (sign2lim) n2var = (RooRealVar*)hdataclone->addColumn(*sign2lim);
  RooRealVar *alphavar = 0;; 
  if (alphalim) alphavar = (RooRealVar*)hdataclone->addColumn(*alphalim);
  RooRealVar *alpha2var = 0;
  if (alpha2lim) alpha2var = (RooRealVar*)hdataclone->addColumn(*alpha2lim);  
  
  RooFormulaVar ecorfull("ecorfull","","@0*@1",RooArgList(*sigmeanlim,*rawevar));
  RooRealVar *ecorfullvar = (RooRealVar*)hdataclone->addColumn(ecorfull);
  
  RooFormulaVar ediff("ediff","","(@0 - @1)/@1",RooArgList(*nomevar,ecorfull));
  RooRealVar *ediffvar = (RooRealVar*)hdataclone->addColumn(ediff);  
  
  RooFormulaVar fullerr("fullerr","","@0*@1",RooArgList(*ecorvar,*sigwidthlim));
  RooRealVar *fullerrvar = (RooRealVar*)hdataclone->addColumn(fullerr);
  
  RooFormulaVar relerr("relerr","","@0/@1",RooArgList(*sigwidthlim,*sigmeanlim));
  RooRealVar *relerrvar = (RooRealVar*)hdataclone->addColumn(relerr);  
  
  ecorvar->setRange(0.,2.);
  ecorvar->setBins(800);  
  
  RooFormulaVar raw("raw","","1./@0",RooArgList(*tgtvar));
  //RooFormulaVar raw("raw","","exp(-@0)",RooArgList(*tgtvar));
  RooRealVar *rawvar = (RooRealVar*)hdataclone->addColumn(raw);
  rawvar->setRange(0.,2.);
  rawvar->setBins(800);
  
  RooNormPdf sigpdfpeaknorm("sigpdfpeaknorm","",*sigpdf,*tgtvar);
  RooRealVar *sigpdfpeaknormvar = (RooRealVar*)hdataclone->addColumn(sigpdfpeaknorm);   
  
  RooFormulaVar equivsigma("equivsigma","","@0/sqrt(2.0*TMath::Pi())/@1",RooArgList(sigpdfpeaknorm,*sigmeanlim));
  RooRealVar *equivsigmavar = (RooRealVar*)hdataclone->addColumn(equivsigma);   
  
//   for (int iev=0; iev<hdataclone->numEntries(); ++iev) {
//     const RooArgSet *dset = hdataclone->get(iev);
//     
//     //condvars = *dset;
//     //condvars.Print("V");
//     dset->Print("V");
//   }  
//   
//   return;
  
  //hdataclone = (RooDataSet*)hdataclone->reduce("(rawptvar/sigmeanlim)>45.");
  

  
  //hdataclone = (RooDataSet*)hdataclone->reduce("relerr>0.1");
  
 // hdataclone = (RooDataSet*)hdataclone->reduce("sigwidthlim>0.017");
  
  
//   RooLinearVar *tgtscaled = (RooLinearVar*)ws->function("tgtscaled");
//   
//   TCanvas *ccor = new TCanvas;
//   //RooPlot *plot = tgtvar->frame(0.6,1.2,100);
//   RooPlot *plotcor = tgtscaled->frame(0.6,2.0,100);
//   hdataclone->plotOn(plotcor);
//   sigpdf->plotOn(plotcor,ProjWData(*hdataclone));
//   plotcor->Draw();
//   ccor->SaveAs("CorE.eps");
//   ccor->SetLogy();
//   plotcor->SetMinimum(0.1);
//   ccor->SaveAs("CorElog.eps"); 
  
  
  
  TCanvas *craw = new TCanvas;
  //RooPlot *plot = tgtvar->frame(0.6,1.2,100);
  RooPlot *plot = tgtvar->frame(0.8,1.4,400);
  //RooPlot *plot = tgtvar->frame(0.0,5.,400);
  //RooPlot *plot = tgtvar->frame(0.,5.,400);
  //RooPlot *plot = tgtvar->frame(-2.0,2.0,200);
  hdataclone->plotOn(plot);
  sigpdf->plotOn(plot,ProjWData(*hdataclone));
  plot->Draw();
  craw->SaveAs("RawE.eps");
  craw->SetLogy();
  plot->SetMinimum(0.1);
  craw->SaveAs("RawElog.eps");
  

  
/*  new TCanvas;
  RooPlot *plotsig = tgtvar->frame(0.6,1.2,100);
  hdatasig->plotOn(plotsig);
  sigpdf.plotOn(plotsig,ProjWData(*hdatasig));
  plotsig->Draw(); */ 
  
  TCanvas *cmean = new TCanvas;
  RooPlot *plotmean = meanvar->frame(0.0,5.0,200);
  //RooPlot *plotmean = meanvar->frame(0.5,1.5,200);
  //RooPlot *plotmean = meanvar->frame(-1.0,1.0,200);
  hdataclone->plotOn(plotmean);
  plotmean->Draw();
  cmean->SaveAs("mean.eps");
  cmean->SetLogy();
  plotmean->SetMinimum(0.1);
  
  TCanvas *cwidth = new TCanvas;
  RooPlot *plotwidth = widthvar->frame(0.,1.0,200);
  hdataclone->plotOn(plotwidth);
  plotwidth->Draw();
  cwidth->SaveAs("width.eps");
  cwidth->SetLogy();
  plotwidth->SetMinimum(0.1);
  
  if (signlim) {
    TCanvas *cn = new TCanvas;
    RooPlot *plotn = nvar->frame(0.,20.,200);
    hdataclone->plotOn(plotn);
    plotn->Draw();
    cn->SaveAs("n.eps");
    
    TCanvas *cnwide = new TCanvas;
    RooPlot *plotnwide = nvar->frame(0.,2100.,200);
    hdataclone->plotOn(plotnwide);
    plotnwide->Draw();
    cnwide->SaveAs("nwide.eps");  
  }

  
  if (sign2lim) {
    TCanvas *cn2 = new TCanvas;
    RooPlot *plotn2 = n2var->frame(0.,20.,200);
    hdataclone->plotOn(plotn2);
    plotn2->Draw();
    cn2->SaveAs("n2.eps");
    
    TCanvas *cn2wide = new TCanvas;
    RooPlot *plotn2wide = n2var->frame(0.,2100.,200);
    hdataclone->plotOn(plotn2wide);
    plotn2wide->Draw();
    cn2wide->SaveAs("n2wide.eps");   
  }
  
  if (alphalim) {
    TCanvas *calpha = new TCanvas;
    RooPlot *plotalpha = alphavar->frame(0.,6.,200);
    hdataclone->plotOn(plotalpha);
    plotalpha->Draw();    
    calpha->SaveAs("alpha.eps");
    calpha->SetLogy();
    plotalpha->SetMinimum(0.1);
  }
  
  if (alpha2lim) {
    TCanvas *calpha2 = new TCanvas;
    RooPlot *plotalpha2 = alpha2var->frame(0.,6.,200);
    hdataclone->plotOn(plotalpha2);
    plotalpha2->Draw();      
    calpha2->SaveAs("alpha2.eps");
  }
  
  
  TCanvas *ceta = new TCanvas;
  RooPlot *ploteta = scetavar->frame(-2.6,2.6,200);
  hdataclone->plotOn(ploteta);
  ploteta->Draw();      
  ceta->SaveAs("eta.eps");  
  
  //TH1 *heold = hdatasigtest->createHistogram("heold",testvar);
  //TH1 *heraw = hdata->createHistogram("heraw",*tgtvar,Binning(800,0.,2.));
  TH1 *heraw = hdataclone->createHistogram("hraw",*rawvar,Binning(800,0.,2.));
  TH1 *hecor = hdataclone->createHistogram("hecor",*ecorvar);
  
  
  //heold->SetLineColor(kRed);
  hecor->SetLineColor(kBlue);
  heraw->SetLineColor(kMagenta);
  
  hecor->GetXaxis()->SetRangeUser(0.6,1.2);
  //heold->GetXaxis()->SetRangeUser(0.6,1.2);
  
  TCanvas *cresponse = new TCanvas;
  
  hecor->Draw("HIST");
  //heold->Draw("HISTSAME");
  heraw->Draw("HISTSAME");
  cresponse->SaveAs("response.eps");
  cresponse->SetLogy();
  cresponse->SaveAs("responselog.eps");
  
  TCanvas *cpeakval = new TCanvas;
  RooPlot *plotpeak = sigpdfpeaknormvar->frame(0.,10.,100);
  hdataclone->plotOn(plotpeak);
  plotpeak->Draw();
  
  TCanvas *cequivsigmaval = new TCanvas;
  RooPlot *plotequivsigma = equivsigmavar->frame(0.,0.04,100);
  hdataclone->plotOn(plotequivsigma);
  plotequivsigma->Draw();  
  
  TCanvas *cediff = new TCanvas;
  RooPlot *plotediff = ediffvar->frame(-0.01,0.01,100);
  hdataclone->plotOn(plotediff);
  plotediff->Draw();    
  
  printf("make fine histogram\n");
  TH1 *hecorfine = hdataclone->createHistogram("hecorfine",*ecorvar,Binning(20e3,0.,2.));

  printf("calc effsigma\n");
  
  double effsigma = effSigma(hecorfine);
  
  printf("effsigma = %5f\n",effsigma);
  printf("condnll = %5f\n",condnllval);
  
  
  TFile *fhist = new TFile("hist.root","RECREATE");
  fhist->WriteTObject(hecor);
  fhist->Close();
  
  return;
  
/*  new TCanvas;
  RooPlot *ploteold = testvar.frame(0.6,1.2,100);
  hdatasigtest->plotOn(ploteold);
  ploteold->Draw();    
  
  new TCanvas;
  RooPlot *plotecor = ecorvar->frame(0.6,1.2,100);
  hdatasig->plotOn(plotecor);
  plotecor->Draw(); */   
  
  TH2 *profhist = (TH2*)hdataclone->createHistogram("relerrvsE",*ecorfullvar,Binning(50,0.,200.), YVar(*relerrvar,Binning(100,0.,0.05)));
  new TCanvas;
  profhist->Draw("COLZ");
  
  new TCanvas;
  profhist->ProfileX()->Draw();
  
  new TCanvas;
  profhist->ProfileY()->Draw();
  
  TH2 *profhistequiv = (TH2*)hdataclone->createHistogram("equiverrvsE",*ecorfullvar,Binning(50,0.,200.), YVar(*equivsigmavar,Binning(100,0.,0.05)));
  new TCanvas;
  profhistequiv->Draw("COLZ");
  
  new TCanvas;
  profhistequiv->ProfileX()->Draw();
  
  new TCanvas;
  profhistequiv->ProfileY()->Draw();  
  
}
コード例 #22
0
ファイル: playV0M.C プロジェクト: ktf/AliPhysics
TH2 *
ReturnCorrFromFit(TH2 *hcorr)
{

  gStyle->SetOptStat(kFALSE);
  gStyle->SetOptFit(kTRUE);

  TObjArray *oa = new TObjArray();
  hcorr->FitSlicesX(0, 0, -1, 0, "QNR", oa);

  TCanvas *cFit = new TCanvas("cFit", "cFit");
  cFit->Divide(2, 2);

  TF1 *fMean = new TF1("fMean", "[0] + [1] * TMath::Power(x, [2])", 1., 100.);
  fMean->SetParameter(0, 0.);
  fMean->SetParameter(1, 1.);
  fMean->SetParameter(2, 1.);
  TH1 *hMean = (TH1 *)oa->At(1);
  hMean->Fit(fMean, "0q", "I", 1., 100.);
  cFit->cd(1)->SetLogx();
  cFit->cd(1)->SetLogy();
  hMean->Draw();
  fMean->Draw("same");

  TF1 *fSigma = new TF1("fSigma", "[0] + [1] * TMath::Power(x, [2])", 1., 100.);
  fSigma->SetParameter(0, 0.);
  fSigma->SetParameter(1, 1.);
  fSigma->SetParameter(2, 0.5);
  TH1 *hSigma = (TH1 *)oa->At(2);
  hSigma->Fit(fSigma, "0q", "", 1., 100.);
  cFit->cd(3)->SetLogx();
  cFit->cd(3)->SetLogy();
  hSigma->Draw();
  fSigma->Draw("same");

  cFit->cd(2)->SetLogx();
  cFit->cd(2)->SetLogy();
  cFit->cd(2)->SetLogz();
  hcorr->Draw("colz");

  TH2 *hcorrfit = (TH2 *)hcorr->Clone("hcorrfit");
  //  hcorrfit->Reset();
  for (Int_t i = 0; i < hcorr->GetNbinsX(); i++) {
    Float_t cent = hcorr->GetXaxis()->GetBinCenter(i + 1);
    Float_t mean = fMean->Eval(cent);
    Float_t sigma = fSigma->Eval(cent);
    if (cent < 25 || cent > 100) continue;
    for (Int_t j = 0; j < 10000; j++) {
      Float_t val = gRandom->Gaus(mean, sigma);
      if (val <= 0.) continue;
      hcorrfit->Fill(val, cent);
    }
  }

  cFit->cd(4)->SetLogx();
  cFit->cd(4)->SetLogy();
  cFit->cd(4)->SetLogz();
  hcorrfit->Draw("colz");

  return hcorrfit;
}
コード例 #23
0
void PerformanceSpectrumUncorr(const Char_t *fname = "HFEtask.root"){

  gROOT->SetStyle("Plain");
  gStyle->SetTitleFillColor(0);
  gStyle->SetTitleBorderSize(0);
  gStyle->SetTitleX(0.1);
  gStyle->SetTitleY(0.96);

  TFile *in = TFile::Open(fname);
  TList *res = (TList *)in->Get("HFE_Results");
  TList *qa = (TList *)in->Get("HFE_QA");
  gROOT->cd();
  AliHFEcontainer *tcont = dynamic_cast<AliHFEcontainer *>(res->FindObject("trackContainer"));
  AliCFContainer *c = tcont->GetCFContainer("recTrackContReco");
  AliCFContainer *cb = tcont->GetCFContainer("hadronicBackground");

  TH1 *spec = c->Project(c->GetNStep() - 1, 0);
  spec->GetXaxis()->SetTitle("p_{T} / GeV/c");
  spec->GetYaxis()->SetTitle("#frac{dN}{dp_{T}} / (GeV/c)^{-1}");
  spec->GetXaxis()->SetRangeUser(ptmin, ptmax);
  spec->GetYaxis()->SetTitleOffset(1.1);
  spec->SetTitle();
  spec->SetStats(kFALSE);

  spec->SetLineColor(kBlue);
  spec->SetLineWidth(1);
  spec->SetMarkerColor(kBlue);
  spec->SetMarkerStyle(22);

  // Produce background subtracted spectrum
  AliCFDataGrid tracks("tracks", "track grid", *c, c->GetNStep() - 1);
  AliCFDataGrid background("background", "background grid", *cb, 1);
  tracks.ApplyBGCorrection(background);
  TH1 *spec_subtracted = tracks.Project(0);
  spec_subtracted->GetXaxis()->SetTitle("p_{T} / GeV/c");
  spec_subtracted->GetYaxis()->SetTitle("#frac{dN}{dp_{T}} / (GeV/c)^{-1}");
  spec_subtracted->GetXaxis()->SetRangeUser(ptmin, ptmax);
  spec_subtracted->GetYaxis()->SetTitleOffset(1.1);
  spec_subtracted->SetTitle();
  spec_subtracted->SetStats(kFALSE);
  spec_subtracted->SetLineColor(kRed);
  spec_subtracted->SetLineWidth(1);
  spec_subtracted->SetMarkerColor(kRed);
  spec_subtracted->SetMarkerStyle(22);

  TLegend *leg = new TLegend(0.2, 0.25, 0.4, 0.35);
  leg->SetBorderSize(0);
  leg->SetFillStyle(0);
  leg->AddEntry(spec, "Raw Spectrum", "p");
  leg->AddEntry(spec_subtracted, "Spectrum after background subtraction", "p");
 
  TCanvas *c1 = new TCanvas("cspec", "Single-inclusive electron spectrum", 1200, 750);
  c1->cd();
  c1->SetLogy();
  c1->SetGridx(kFALSE);
  c1->SetGridy(kFALSE);
  spec->Draw("ep");
  spec_subtracted->Draw("epsame");
  leg->Draw();
  ALICEWorkInProgress(c1, "today");

  // PID
  TList *pidqa = (TList *)qa->FindObject("HFEpidQA");
  AliHFEtpcPIDqa *tpcqa = (AliHFEtpcPIDqa *)pidqa->FindObject("TPCQA");
  AliHFEtofPIDqa *tofqa = (AliHFEtofPIDqa *)pidqa->FindObject("TOFQA");

  // Make Plots for TPC
  // Create histograms by projecting the THnSparse
  TH2 *hTPCall = tpcqa->MakeSpectrumdEdx(AliHFEdetPIDqa::kBeforePID);
  TH2 *hTPCselected = tpcqa->MakeSpectrumdEdx(AliHFEdetPIDqa::kAfterPID);
  TH2 *hTPCsigmaAll = tpcqa->MakeSpectrumNSigma(AliHFEdetPIDqa::kBeforePID);
  TH2* hTPCsigmaSelected = tpcqa->MakeSpectrumNSigma(AliHFEdetPIDqa::kAfterPID);
  // Make Plots for TOF
  TH2 *hTOFsigmaAll = tofqa->MakeSpectrumNSigma(AliHFEdetPIDqa::kBeforePID);
  TH2 *hTOFsigmaSelected = tofqa->MakeSpectrumNSigma(AliHFEdetPIDqa::kAfterPID);

  hTPCsigmaAll->SetTitle("TPC n#sigma around the electron line");
  hTPCsigmaSelected->SetTitle("TPC n#sigma around the electron line for selected tracks");
  hTOFsigmaAll->SetTitle("TOF n#sigma around the electron line");
  hTOFsigmaSelected->SetTitle("TOF n#sigma around the electron line for selected tracks");
  DefineTPChisto(hTPCall, "TPC Signal / a.u");
  DefineTPChisto(hTPCselected, "TPC Signal / a.u.");
  DefineTPChisto(hTPCsigmaAll, "TPC Sigma");
  DefineTPChisto(hTPCsigmaSelected, "TPC Sigma");

  // Also make nice histograms for TOF
  DefineTPChisto(hTOFsigmaAll, "TOF Sigma");
  DefineTPChisto(hTOFsigmaSelected, "TOF Sigma");

  // Plot them
  TCanvas *c2 = new TCanvas("cTPCall", "TPC Signal for all tracks", 640, 480);
  c2->cd();
  c2->SetGridx(kFALSE);
  c2->SetGridy(kFALSE);
  c2->SetLogx();
  c2->SetLogz();
  hTPCall->GetYaxis()->SetRangeUser(40., 100.);
  hTPCall->Draw("colz");
  ALICEWorkInProgress(c2, "today");

  TCanvas *c3 = new TCanvas("cTPCsel", "TPC Signal for selected tracks", 640, 480);
  c3->cd();
  c3->SetGridx(kFALSE);
  c3->SetGridy(kFALSE);
  c3->SetLogx();
  c3->SetLogz();
  hTPCselected->GetYaxis()->SetRangeUser(40., 100.);
  hTPCselected->Draw("colz");
  ALICEWorkInProgress(c3, "today");

  TCanvas *c4 = new TCanvas("cTPCsigAll", "TPC Sigma for all tracks", 640, 480);
  c4->cd();
  c4->SetGridx(kFALSE);
  c4->SetGridy(kFALSE);
  c4->SetLogx();
  c4->SetLogz();
  //hTPCsigmaAll->GetYaxis()->SetRangeUser(-3.5, 5.);
  hTPCsigmaAll->Draw("colz");
  ALICEWorkInProgress(c4, "today");

  TCanvas *c5 = new TCanvas("cTPCsigSel", "TPC Sigma for selected tracks", 640, 480);
  c5->cd();
  c5->SetGridx(kFALSE);
  c5->SetGridy(kFALSE);
  c5->SetLogx();
  c5->SetLogz();
  hTPCsigmaSelected->GetYaxis()->SetRangeUser(-3.5, 5.);
  hTPCsigmaSelected->Draw("colz");
  ALICEWorkInProgress(c5, "today");

  TCanvas *c6 = new TCanvas("cTOFsigAll", "TOF Sigma for all tracks", 640, 480);
  c6->cd();
  c6->SetGridx(kFALSE);
  c6->SetGridy(kFALSE);
  c6->SetLogx();
  c6->SetLogz();
  hTOFsigmaAll->Draw("colz");
  ALICEWorkInProgress(c6, "today");

  TCanvas *c7 = new TCanvas("cTOFsigSel", "TOF Sigma for selected tracks", 640, 480);
  c7->cd();
  c7->SetGridx(kFALSE);
  c7->SetGridy(kFALSE);
  c7->SetLogx();
  c7->SetLogz();
  //hTOFsigmaSelected->GetYaxis()->SetRangeUser(-3, 3);
  hTOFsigmaSelected->Draw("colz");
  ALICEWorkInProgress(c7, "today");

  TFile *output = new TFile("Performance.root", "RECREATE");
  output->cd();
  spec->Write();
  hTPCall->Write();
  hTPCselected->Write();
  hTPCsigmaAll->Write();
  hTPCsigmaSelected->Write();
  c1->Write();
  c2->Write();
  c3->Write();
  c4->Write();
  c5->Write();
  c6->Write();
  c7->Write();
  output->Close();
  delete output;
}
コード例 #24
0
ファイル: Fit_2D.C プロジェクト: frmeier/usercode
void Fit_2D(TString type)
{
   if(!Configure(type, cfg)) return;
   tree=(TTree*) cfg.f->Get("fittree");

   RooRealVar mass("mass", "mass [GeV/c^{2}]", cfg.mass_low, cfg.mass_high);
   RooRealVar t("t", "lifetime [ps]", -1.0e-12, 15e-12);
   RooRealVar tE("tE", "lifetime error", 0, 1e-12);
   RooRealVar weight("weight","Event weight", 1, 10);
   RooDataSet data("data", "data", tree, RooArgSet(mass, t, tE));
   //   RooDataSet data("data", "data", tree, RooArgSet(mass, t, weight), "", "weight");
 
   /*********************************************************************************************
    *    Non-prompt background = 1st order polynomial (mass) x (Decay (x) double Gauss)(lifetime)
    *    Prompt background = 1st order polynomial (mass) x double Gauss (lifetime)
    *********************************************************************************************/

   if(cfg.prompt_bk){
      RooRealVar reso_mean("reso_mean", "mean of resolution function", 0);
   // prompt mass polynomial
      RooRealVar prompt_p1("prompt_p1","Linear coefficient of prompt background mass polynomial",0.1, -0.2, 5.0);
      RooPolynomial prompt_mass("prompt_mass", "Linear function for prompt background mass", mass, RooArgList(prompt_p1));
   // prompt lifetime resolution
      RooRealVar prompt_sigma_core("prompt_sigma_core","Gauss sigma core of prompt background", 1e-13, 5e-14, 1.2e-13);
      RooRealVar prompt_sigma_tail("prompt_sigma_tail","Gauss sigma tail of prompt background", 2e-13, 1.2e-13, 9e-13);
      RooGaussian prompt_core("prompt_core","Gauss core for prompt background", t, reso_mean, prompt_sigma_core);
      RooGaussian prompt_tail("prompt_tail","Gauss tail for prompt background", t, reso_mean, prompt_sigma_tail);
      RooRealVar core_frac("core_frac","Fraction of core in prompt background",0.8, 0.5, 0.99);
      RooAddPdf prompt_lt("prompt_lt","Double Gauss for prompt background lifetime",RooArgList(prompt_core, prompt_tail), core_frac);
      RooProdPdf prompt("prompt","Prompt 2D background model", RooArgSet(prompt_mass, prompt_lt));   

      RooGaussModel reso_core("reso_core", "First Gauss of resolution function", t, reso_mean, prompt_sigma_core);
      RooGaussModel reso_tail("reso_tail", "Second Gauss of resolution function", t, reso_mean, prompt_sigma_tail);
      RooAddModel tau_reso("tau_reso", "Double Gauss of resolution function", RooArgList(reso_core, reso_tail), core_frac);
   } else {
      RooRealVar tau_reso_sigma("tau_reso_sigma","Sigma of lifetime resolution function",0.1e-13, 1e-15,9.0e-13) ;
      //      tau_reso_sigma=6.26e-14;
      //      tau_reso_sigma.setConstant(kTRUE);
      RooGaussModel tau_reso("tau_reso","Gauss of lifetime resolution function", t, RooConst(0), tau_reso_sigma) ;
   }

   if(cfg.nonprompt_bk){
      // non-prompt mass polynomial
      if(cfg.constant_prompt_fraction){
	 cout<<"Constant prompt-to-nonprompt fraction in mass."<<endl;
         RooPolynomial nonprompt_mass("nonprompt_mass", "Linear function for nonprompt background mass", mass, RooArgList(prompt_p1));
         RooPolynomial nonprompt_mass2("nonprompt_mass2", "Linear function for nonprompt background mass", mass, RooArgList(prompt_p1));
      } else {
	 cout<<"Different mass polynomials for prompt and nonprompt backgrounds."<<endl;
         RooRealVar nonprompt_p1("nonprompt_p1","Linear coefficient of nonprompt background mass polynomial", 0.1, -0.2, 0.3);
         RooRealVar nonprompt_p2("nonprompt_p2","Linear coefficient of nonprompt background mass polynomial", 0.1, -0.2, 0.3);
         RooPolynomial nonprompt_mass("nonprompt_mass", "Linear function for nonprompt background mass", mass, RooArgList(nonprompt_p1));
         RooPolynomial nonprompt_mass2("nonprompt_mass", "Linear function for nonprompt background mass", mass, RooArgList(nonprompt_p2));
      }
      // non-prompt lifetime model
      RooRealVar tau_bk("tau_bk","Background lifetime",1.2e-12, 5e-15, 2e-12);
      RooDecay nonprompt_lt("nonprompt_lt","decay (x) double Gauss for background lifetime", t, tau_bk, tau_reso, RooDecay::SingleSided) ;
      if(cfg.single_lt){
	 cout<<"Nonprompt background has one lifetime component."<<endl;
         RooProdPdf nonprompt("nonprompt", "Non-prompt background PDF", RooArgSet(nonprompt_mass, nonprompt_lt));   
      } else {
	 cout<<"Nonprompt background has two lifetime components."<<endl;
         RooRealVar tau_bk2("tau_bk2","Second background lifetime",0.6e-12, 5e-15, 2e-12);
         RooDecay nonprompt_lt2("nonprompt_lt2","decay (x) double Gauss for second background lifetime", t, tau_bk2, tau_reso, RooDecay::SingleSided) ;
         RooProdPdf nonprompt1("nonprompt1", "Non-prompt background PDF", RooArgSet(nonprompt_mass, nonprompt_lt));   
         RooProdPdf nonprompt2("nonprompt2", "Non-prompt background PDF", RooArgSet(nonprompt_mass, nonprompt_lt2));
         RooRealVar lt_frac("lt_frac", "fraction of longer background lifetime", 0.2, 0.01, 0.99);
         RooAddPdf nonprompt("nonprompt", "Non-prompt background PDF", RooArgList(nonprompt1, nonprompt2), RooArgList(lt_frac));
      }
   }
   
   /***************************************************************************************
    *    Signal = Double Gauss (mass) x (Decay (x) double Gauss)(lifetime)
    ***************************************************************************************/

   //  mass peak 
   RooRealVar mass_peak("mass_peak","Gauss mean of signal mass peak", cfg.masspeak, cfg.masspeak-0.04, cfg.masspeak+0.04);
   RooRealVar m_sigma1("m_sigma1","Gauss core sigma for signal mass",0.007,0.001,0.012);
   RooRealVar m_sigma2("m_sigma2","Gauss tail sigma for signal mass",0.02, 0.010, 0.035);
   RooGaussian m_gauss1("m_gauss1","Core Gauss for signal mass", mass, mass_peak, m_sigma1);
   RooGaussian m_gauss2("m_gauss2","Tail Gauss for signal mass", mass, mass_peak, m_sigma2);
   RooRealVar frac_m_gauss("frac_m_gauss","Fraction of tail Gauss for signal mass",0.2, 0.1, 0.99);
   if (cfg.single_sig)
       RooGaussian mgauss("mgauss","Single gauss for signal mass", mass, mass_peak, m_sigma1);
   else
       RooAddPdf mgauss("mgauss","Double gauss for signal mass",RooArgList(m_gauss1, m_gauss2),RooArgList(frac_m_gauss));

   // signal lifetime
   RooRealVar tau("tau","Lambda_b lifetime",1.5e-12, 0.1e-12, 2e-12);
   RooDecay tau_decay_model("tau_decay_model","decay (x) double Gauss for signal lifetime", t, tau, tau_reso, RooDecay::SingleSided) ;
   RooProdPdf signal("signal", "Signal PDF", RooArgSet(mgauss, tau_decay_model));

   /*********************************************************************************************
    *    Function for efficiency
    *********************************************************************************************/

   double effSlope(0);
   if (cfg.type==B0) effSlope = -7.019e9;
   if (cfg.type==Lambda_b) effSlope = +1.316e9;
   effSlope*=.5;
   RooFormulaVar eff("eff",("1.0 + TMath::Abs(t)*"+toString(effSlope)).c_str(),t) ;

   //RooRealVar eff0("eff0","eff0",1);
   //RooRealVar eff1("eff1","eff1",cfg.type==B0?-7.019e9:+1.316e9);
   //RooPolynomial eff("eff","eff",t,RooArgSet(eff0, eff1));

   //RooEffProd modelEff("modelEff","model with efficiency", full_model, eff) ;


   /*********************************************************************************************
    *    Complete 2D model
    *********************************************************************************************/
 
   RooRealVar n_prompt("n_prompt","Number of prompt background events",1000, 0, 50000);
   RooRealVar n_nonprompt("n_nonprompt","Number of non-prompt background events",300, 0, 20000);
   RooRealVar n_signal("n_signal","Number of signal events",4000, 10, 20000);
   if(cfg.no_bkgd && !cfg.eff) RooAddPdf full_model("full_model", "Full 2D model", RooArgList(signal), RooArgList(n_signal));
   else if(cfg.no_bkgd && cfg.eff)
   {
       RooAddPdf intermed_model("intermed_model", "Full 2D model", RooArgList(signal), RooArgList(n_signal));
       RooEffProd full_model("full_model", "Full 2D model", intermed_model, eff);
   }
   else if(!cfg.nonprompt_bk) RooAddPdf full_model("full_model", "Full 2D model", RooArgList(signal, prompt), RooArgList(n_signal, n_prompt));
   else if(!cfg.prompt_bk) RooAddPdf full_model("full_model", "Full 2D model", RooArgList(signal, nonprompt), RooArgList(n_signal, n_nonprompt));
   else if(cfg.eff)
   {
       RooAddPdf intermed_model("intermed_model", "Full 2D model", RooArgList(signal, prompt, nonprompt), RooArgList(n_signal, n_prompt, n_nonprompt));
       RooEffProd full_model("full_model", "Full 2D model", intermed_model, eff);
   }
   else RooAddPdf full_model("full_model", "Full 2D model", RooArgList(signal, prompt, nonprompt), RooArgList(n_signal, n_prompt, n_nonprompt));


   /*********************************************************************************************
    *    Do the fitting
    *********************************************************************************************/ 

   t.setRange("all", -1.0e-12, 15e-12);

   full_model.fitTo(data, Save(kTRUE), NumCPU(6));
   
   RooAbsReal *cdf=mgauss.createCdf(mass);
   two_sigma_upper=cdf->findRoot(mass, cfg.mass_low, cfg.mass_high, 0.97725);
   two_sigma_lower=cdf->findRoot(mass, cfg.mass_low, cfg.mass_high, 0.02275);
   three_sigma_upper=cdf->findRoot(mass, cfg.mass_low, cfg.mass_high, 0.99865);
   three_sigma_lower=cdf->findRoot(mass, cfg.mass_low, cfg.mass_high, 1.0-0.99865);


   /*********************************************************************************************
    *     Plot results
    *********************************************************************************************/  

   TH2* hd = data.createHistogram("hd",t,Binning(60),YVar(mass,Binning(20)));
   TH2* hf = full_model.createHistogram("hf",t,Binning(60),YVar(mass,Binning(20))) ;

   c1=new TCanvas(name_c1, cfg.title1);
   c1->Divide(2) ;
   c1->cd(1); 
   gPad->SetLogz();
   hd->Draw("surf") ;
   c1->cd(2); 
   gPad->SetLogz();
   hf->Draw("surf") ;

   c2=new TCanvas(name_c2, cfg.title2, 1100, 550);
   c2->Divide(2) ;
   c2->cd(1);
   RooPlot* framex = mass.frame(Title("Mass projection")) ;
   data.plotOn(framex) ;
   full_model.plotOn(framex, Range("all"), LineColor(kBlue));
   full_model.plotOn(framex, Components(signal), LineColor(kRed));
   if(cfg.prompt_bk) full_model.plotOn(framex, Components(prompt), LineStyle(kDashed), LineColor(kBlack));
   if(cfg.nonprompt_bk) full_model.plotOn(framex, Components(nonprompt), LineStyle(kDotted), LineColor(kBlack));
   framex->addObject(writeTLatex("mass: " +
   roundToString(mass_peak.getVal(), 3) + " #pm " +
   roundToString(mass_peak.getError()+0.0004, 3) + " GeV/c^{2}", 0.32, 0.87, 0.05));
   framex->Draw();
   c2->cd(2);
   gPad->SetLogy(); 
   RooPlot* framey = t.frame(Title("Lifetime projection")) ;
   data.plotOn(framey) ;
   full_model.plotOn(framey, Range("all"), LineColor(kBlue)) ;
   full_model.plotOn(framey, Components(signal), LineColor(kRed));
   if(cfg.prompt_bk) full_model.plotOn(framey, Components(prompt), LineStyle(kDashed), LineColor(kBlack));
   if(cfg.nonprompt_bk) full_model.plotOn(framey, Components(nonprompt), LineStyle(kDotted), LineColor(kBlack));

   framey->addObject(writeTLatex("#tau: " +
   roundToString(tau.getVal()*1e12, 3) + " #pm " +
   roundToString(tau.getError()*1e12, 3) + " ps", 0.5,
   0.87, 0.05));
   framey->Draw();
    
   c3=new TCanvas(name_c3, cfg.title3, 1100, 550);
   c3->cd();
   c3->Divide(3);
   c3->cd(1);
   gPad->SetLogy();
   mass.setRange("sbl", cfg.mass_low, three_sigma_lower);
   RooPlot* framesbl = t.frame(Title("Lower sideband"), Range("sbl")) ;
   data.plotOn(framesbl, CutRange("sbl")) ;
   full_model.plotOn(framesbl, ProjectionRange("sbl")) ;
   full_model.plotOn(framesbl, Components(signal), LineColor(kRed), ProjectionRange("sbl"));
   if(cfg.prompt_bk) full_model.plotOn(framesbl, Components(prompt), LineStyle(kDashed), LineColor(kBlack), ProjectionRange("sbl"));
   if(cfg.nonprompt_bk) full_model.plotOn(framesbl, Components(nonprompt), LineStyle(kDotted), LineColor(kBlack), ProjectionRange("sbl"));
   framesbl->Draw();

   c3->cd(2);
   gPad->SetLogy();
   mass.setRange("sig", two_sigma_lower, two_sigma_upper);
   RooPlot* framesig = t.frame(Title("Signal region"),Range("sig")) ;
   data.plotOn(framesig, CutRange("sig")) ;
   full_model.plotOn(framesig, ProjectionRange("sig")) ;
   full_model.plotOn(framesig, Components(signal), LineColor(kRed), ProjectionRange("sig"));
   if(cfg.prompt_bk) full_model.plotOn(framesig, Components(prompt), LineStyle(kDashed), LineColor(kBlack), ProjectionRange("sig"));
   if(cfg.nonprompt_bk) full_model.plotOn(framesig, Components(nonprompt), LineStyle(kDotted), LineColor(kBlack), ProjectionRange("sig"));
   framesig->Draw();

   c3->cd(3);
   gPad->SetLogy();
   mass.setRange("sb", three_sigma_upper, cfg.mass_high);
   RooPlot* framesbh = t.frame(Title("Upper sideband"),Range("sb")) ;
   data.plotOn(framesbh, CutRange("sb")) ;
   full_model.plotOn(framesbh, ProjectionRange("sb")) ;
   full_model.plotOn(framesbh, Components(signal), LineColor(kRed), ProjectionRange("sb"));
   if(cfg.prompt_bk) full_model.plotOn(framesbh, Components(prompt), LineStyle(kDashed), LineColor(kBlack), ProjectionRange("sb"));
   if(cfg.nonprompt_bk) full_model.plotOn(framesbh, Components(nonprompt), LineStyle(kDotted), LineColor(kBlack), ProjectionRange("sb"));
   framesbh->Draw();

   //cout << "Fitresults: t: "<< tau.getVal()*1e12 << " +- "<<tau.getError()*1e12<<" ps ";
   //cout << " chisq(m): " << framex->chiSquare() << " chisq(t): " << framey->chiSquare();
   //cout << " mass: " << mass_peak.getVal() << " m_sigma1: " << m_sigma1.getVal() << " m_sigma2: " << m_sigma2.getVal() << " tau_bk: " << tau_bk.getVal();
   //cout <<  " nsig: " << n_signal.getVal()<<" npr: "<<n_prompt.getVal()<<" nnpr: "<<n_nonprompt.getVal()<<endl;
   
   cfg.f->Close();
   cfg.f->Delete();
   delete cfg.f;

   cout << "FITRESULTS: ";
   cout << tau.getVal()*1e12 << " " << tau.getError()*1e12 << " ";
   cout << mass_peak.getVal() << " " << mass_peak.getError() << " ";
   cout << m_sigma1.getVal() << " " << m_sigma1.getError() << " ";
   cout << m_sigma2.getVal() << " " << m_sigma2.getError() << " ";
   cout << frac_m_gauss.getVal() << " " << frac_m_gauss.getError() << " ";
   cout << core_frac.getVal() << " " << core_frac.getError() << " ";
   cout << tau_bk.getVal()*1e12 << " " << tau_bk.getError()*1e12 << " ";
   cout << n_nonprompt.getVal() << " " << n_nonprompt.getError() << " ";
   cout << n_prompt.getVal() << " " << n_prompt.getError() << " ";
   cout << n_signal.getVal() << " " << n_signal.getError() << " ";
   cout << prompt_p1.getVal() << " " << prompt_p1.getError() << " ";
   cout << prompt_sigma_core.getVal() << " " << prompt_sigma_core.getError() << " ";
   cout << prompt_sigma_tail.getVal() << " " << prompt_sigma_tail.getError() << " ";
   cout << endl;
}
コード例 #25
0
ファイル: kirk_dune.C プロジェクト: DUNE/lblpwgtools
void kirk_dune()
{
  //  this binning is a primary determinant of the time this macro takes to run

  //  very coarse binning, just to test macro, will worsen results: ~ 45 min
  //  int binsnumuE = 4;
  //  int binsnumuPID = 4;
  //  int binsnueE = 4;
  //  int binsnuePID = 4;

  // full binning: 2-3 hours
  int binsnumuE = 15;
  int binsnumuPID = 15;
  int binsnueE = 15;
  int binsnuePID = 20;

  int binsnumu2d = binsnumuE*binsnumuPID;
  int binsnue2d = binsnumuE*binsnumuPID;

  rootlogon(); // style

  // POT/yr * 3.5yrs * mass correction
  const double pot = 3.5 * 1.47e21 * 40/1.13;

  SpectrumLoader loaderNumu("/pnfs/dune/persistent/TaskForce_AnaTree/far/train/v2.2/numutest.root");
  SpectrumLoader loaderNue("/pnfs/dune/persistent/TaskForce_AnaTree/far/train/v2.2/nuetest.root");

  SpectrumLoader loaderNumuRHC("/pnfs/dune/persistent/TaskForce_AnaTree/far/train/v2.2/anumutest.root");
  SpectrumLoader loaderNueRHC("/pnfs/dune/persistent/TaskForce_AnaTree/far/train/v2.2/anuetest.root");

  osc::IOscCalculatorAdjustable* calc = DefaultOscCalc();
  calc->SetL(1300);
  calc->SetdCP(TMath::Pi()*1.5);

  // Standard DUNE numbers from Matt Bass
  calc->SetTh12(0.5857);
  calc->SetTh13(0.148);
  calc->SetTh23(0.7854);
  calc->SetDmsq21(0.000075);
  calc->SetDmsq32(0.002524-0.000075); // quoted value is 31

  osc::IOscCalculatorAdjustable* calci = DefaultOscCalc();
  calci->SetL(1300);
  calci->SetdCP(TMath::Pi()*1.5);

  // Standard DUNE numbers from Matt Bass
  calci->SetTh12(0.5857);
  calci->SetTh13(0.148);
  calci->SetTh23(0.7854);
  calci->SetDmsq21(0.000075);
  calci->SetDmsq32(-(0.002524+0.000075)); // quoted value is 31

  // One sigma errors
  // (t12,t13,t23,dm21,dm32)=(0.023,0.018,0.058,0.0,0.024,0.016)

  auto* loaderNumuBeam  = loaderNumu.LoaderForRunPOT(20000001);
  auto* loaderNumuNue   = loaderNumu.LoaderForRunPOT(20000002);
  auto* loaderNumuNuTau = loaderNumu.LoaderForRunPOT(20000003);
  auto* loaderNumuNC    = loaderNumu.LoaderForRunPOT(0);

  auto* loaderNueBeam  = loaderNue.LoaderForRunPOT(20000001);
  auto* loaderNueNue   = loaderNue.LoaderForRunPOT(20000002);
  auto* loaderNueNuTau = loaderNue.LoaderForRunPOT(20000003);
  auto* loaderNueNC    = loaderNue.LoaderForRunPOT(0);

  auto* loaderNumuBeamRHC  = loaderNumuRHC.LoaderForRunPOT(20000004);
  auto* loaderNumuNueRHC   = loaderNumuRHC.LoaderForRunPOT(20000005);
  auto* loaderNumuNuTauRHC = loaderNumuRHC.LoaderForRunPOT(20000006);
  auto* loaderNumuNCRHC    = loaderNumuRHC.LoaderForRunPOT(0);

  auto* loaderNueBeamRHC  = loaderNueRHC.LoaderForRunPOT(20000004);
  auto* loaderNueNueRHC   = loaderNueRHC.LoaderForRunPOT(20000005);
  auto* loaderNueNuTauRHC = loaderNueRHC.LoaderForRunPOT(20000006);
  auto* loaderNueNCRHC    = loaderNueRHC.LoaderForRunPOT(0);

  Loaders loadersdunenue;
  loadersdunenue.AddLoader(loaderNueBeam,  caf::kFARDET, Loaders::kMC, ana::kBeam, Loaders::kNonSwap);
  loadersdunenue.AddLoader(loaderNueNue,   caf::kFARDET, Loaders::kMC, ana::kBeam, Loaders::kNue);
  loadersdunenue.AddLoader(loaderNueNuTau, caf::kFARDET, Loaders::kMC, ana::kBeam, Loaders::kTau);
  loadersdunenue.AddLoader(loaderNueNC,   caf::kFARDET, Loaders::kMC, ana::kBeam, Loaders::kNC);

  Loaders loadersdunenuerhc;
  loadersdunenuerhc.AddLoader(loaderNueBeamRHC,  caf::kFARDET, Loaders::kMC, ana::kBeam, Loaders::kNonSwap);
  loadersdunenuerhc.AddLoader(loaderNueNueRHC,   caf::kFARDET, Loaders::kMC, ana::kBeam, Loaders::kNue);
  loadersdunenuerhc.AddLoader(loaderNueNuTauRHC, caf::kFARDET, Loaders::kMC, ana::kBeam, Loaders::kTau);
  loadersdunenuerhc.AddLoader(loaderNueNCRHC,   caf::kFARDET, Loaders::kMC, ana::kBeam, Loaders::kNC);

  Loaders loadersdunenumu;
  loadersdunenumu.AddLoader(loaderNumuBeam,  caf::kFARDET, Loaders::kMC, ana::kBeam, Loaders::kNonSwap);
  loadersdunenumu.AddLoader(loaderNumuNue,   caf::kFARDET, Loaders::kMC, ana::kBeam, Loaders::kNue);
  loadersdunenumu.AddLoader(loaderNumuNuTau, caf::kFARDET, Loaders::kMC, ana::kBeam, Loaders::kTau);
  loadersdunenumu.AddLoader(loaderNumuNC,   caf::kFARDET, Loaders::kMC, ana::kBeam, Loaders::kNC);

  Loaders loadersdunenumurhc;
  loadersdunenumurhc.AddLoader(loaderNumuBeamRHC,  caf::kFARDET, Loaders::kMC, ana::kBeam, Loaders::kNonSwap);
  loadersdunenumurhc.AddLoader(loaderNumuNueRHC,   caf::kFARDET, Loaders::kMC, ana::kBeam, Loaders::kNue);
  loadersdunenumurhc.AddLoader(loaderNumuNuTauRHC, caf::kFARDET, Loaders::kMC, ana::kBeam, Loaders::kTau);
  loadersdunenumurhc.AddLoader(loaderNumuNCRHC,   caf::kFARDET, Loaders::kMC, ana::kBeam, Loaders::kNC);

  const Var Enu_reco = SIMPLEVAR(dune.Ev_reco);
  const Var pid_reco = SIMPLEVAR(dune.mvaresult);

  float kNumuMVACutFHC = 0.25;
  float kNumuMVACutRHC = 0.5;
  float kNueMVACut = 0.8;

  const Cut kSelNumu = SIMPLEVAR(dune.mvaresult) > kNumuMVACutFHC;
  const Cut kSelNumuRHC = SIMPLEVAR(dune.mvaresult) > kNumuMVACutRHC;
  const Cut kSelNue = SIMPLEVAR(dune.mvaresult) > kNueMVACut;
  const Cut kSelNueRHC = SIMPLEVAR(dune.mvaresult) > kNueMVACut;


  std::vector<const ISyst*> systsE = {&kEnergyScaleSyst, &kEnergyResSyst};
  std::vector<const ISyst*> systsnorm = {&kNCSyst, &kNutauSyst,  &kNueBeamSyst};
  std::vector<const ISyst*> systsall = {&kEnergyScaleSyst, &kEnergyResSyst, &kNCSyst, &kNutauSyst, &kNueBeamSyst};
  std::vector<const ISyst*> systsall2 = {&kEnergyScaleSyst, &kEnergyResSyst, &kNCSyst2, &kNutauSyst, &kNueBeamSyst};


  const Var kEnuPidNumu = Var2D(Enu_reco, Binning::Simple(binsnumuE, 0, 10), pid_reco, Binning::Simple(binsnumuPID, -1, +1));
  const Var kEnuPidNue = Var2D(Enu_reco, Binning::Simple(binsnueE, 0, 6), pid_reco, Binning::Simple(binsnuePID, -1, +1));

  // 2D w/ Loaders
  NoExtrapGenerator gendunenumu(HistAxis("PID/E2d", Binning::Simple(binsnumu2d,0,binsnumu2d), kEnuPidNumu), kNoCut);
  NoExtrapGenerator gendunenue (HistAxis("PID/E2d", Binning::Simple(binsnue2d,0,binsnue2d), kEnuPidNue),  kNoCut);
  PredictionInterp preddunenumu(systsall, calc, gendunenumu, loadersdunenumu);
  PredictionInterp preddunenue (systsall, calc, gendunenue,  loadersdunenue);

  NoExtrapGenerator gendunenumurhc(HistAxis("PID/E2d", Binning::Simple(binsnumu2d,0,binsnumu2d), kEnuPidNumu), kNoCut);
  NoExtrapGenerator gendunenuerhc (HistAxis("PID/E2d", Binning::Simple(binsnue2d,0,binsnue2d), kEnuPidNue),  kNoCut);
  PredictionInterp preddunenumurhc(systsall, calc, gendunenumurhc, loadersdunenumurhc);
  PredictionInterp preddunenuerhc (systsall, calc, gendunenuerhc,  loadersdunenuerhc);


  // 1D w/ Loaders
  NoExtrapGenerator gendunenumu1d(HistAxis("Reconstructed Energy (GeV)", Binning::Simple(80,0,10), Enu_reco), kSelNumu);
  NoExtrapGenerator gendunenue1d (HistAxis("Reconstructed Energy (GeV)", Binning::Simple(80,0,10), Enu_reco), kSelNue);
  PredictionInterp preddunenumu1d(systsall, calc, gendunenumu1d, loadersdunenumu);
  PredictionInterp preddunenue1d (systsall, calc, gendunenue1d,  loadersdunenue);

  NoExtrapGenerator gendunenumu1drhc(HistAxis("Reconstructed Energy (GeV)", Binning::Simple(80,0,10), Enu_reco), kSelNumuRHC);
  NoExtrapGenerator gendunenue1drhc (HistAxis("Reconstructed Energy (GeV)", Binning::Simple(80,0,10), Enu_reco), kSelNueRHC);
  PredictionInterp preddunenumu1drhc(systsall, calc, gendunenumu1drhc, loadersdunenumurhc);
  PredictionInterp preddunenue1drhc (systsall, calc, gendunenue1drhc,  loadersdunenuerhc);


  // SpectrumLoader instead of Loaders
  PredictionNoExtrap predNumuPID(*loaderNumuBeam, *loaderNumuNue, *loaderNumuNuTau, *loaderNumuNC, "PID", Binning::Simple(100, -1, +1), SIMPLEVAR(dune.mvaresult), kNoCut);

  PredictionNoExtrap predNumuPIDRHC(*loaderNumuBeamRHC, *loaderNumuNueRHC, *loaderNumuNuTauRHC, *loaderNumuNCRHC, "PID", Binning::Simple(100, -1, +1), SIMPLEVAR(dune.mvaresult), kNoCut);

  PredictionNoExtrap predNuePID(*loaderNueBeam, *loaderNueNue, *loaderNueNuTau, *loaderNueNC, "PID", Binning::Simple(100, -1, +1), SIMPLEVAR(dune.mvaresult), kNoCut);

  PredictionNoExtrap predNuePIDRHC(*loaderNueBeamRHC, *loaderNueNueRHC, *loaderNueNuTauRHC, *loaderNueNCRHC, "PID", Binning::Simple(100, -1, +1), SIMPLEVAR(dune.mvaresult), kNoCut);

  PredictionNoExtrap pred(*loaderNumuBeam, *loaderNumuNue, *loaderNumuNuTau, *loaderNumuNC, "Reconstructed E (GeV)", Binning::Simple(80, 0, 10), Enu_reco, kSelNumu);

  PredictionNoExtrap pred2d(*loaderNumuBeam, *loaderNumuNue, *loaderNumuNuTau, *loaderNumuNC, "Reconstructed E (GeV)", Binning::Simple(binsnumu2d, 0, binsnumu2d), kEnuPidNumu, kNoCut);

  PredictionNoExtrap predRHC(*loaderNumuBeamRHC, *loaderNumuNueRHC, *loaderNumuNuTauRHC, *loaderNumuNCRHC, "Reconstructed E (GeV)", Binning::Simple(80, 0, 10), Enu_reco, kSelNumuRHC);

  PredictionNoExtrap predNue(*loaderNueBeam, *loaderNueNue, *loaderNueNuTau, *loaderNueNC, "Reconstructed E (GeV)", Binning::Simple(24, 0, 6), Enu_reco, kSelNue);

  PredictionNoExtrap predNue2d(*loaderNueBeam, *loaderNueNue, *loaderNueNuTau, *loaderNueNC, "Reconstructed E (GeV)", Binning::Simple(binsnue2d, 0, binsnue2d), kEnuPidNue, kNoCut);

  PredictionNoExtrap predNueRHC(*loaderNueBeamRHC, *loaderNueNueRHC, *loaderNueNuTauRHC, *loaderNueNCRHC, "Reconstructed E (GeV)", Binning::Simple(24, 0, 6), Enu_reco, kSelNueRHC);


  // test systematics are really shifting
  SystShifts scaleshift, resshift;
  scaleshift.SetShift(&kEnergyScaleSyst, +3);
  resshift.SetShift(&kEnergyResSyst, +3);

  Spectrum nom2(*loaderNumuBeam, HistAxis("blah", Binning::Simple(binsnumuE,0,binsnumuE), Enu_reco), kNoCut);
  Spectrum scale2(*loaderNumuBeam, HistAxis("blah", Binning::Simple(binsnumuE,0,binsnumuE), Enu_reco), kNoCut, scaleshift);
  Spectrum res2(*loaderNumuBeam, HistAxis("blah", Binning::Simple(binsnumuE,0,binsnumuE), Enu_reco), kNoCut, resshift);


  loaderNumu.Go();
  loaderNue.Go();
  loaderNumuRHC.Go();
  loaderNueRHC.Go();

  // have to have this for each prediction from a Loaders or it doesn't work; TODO fix this in source code
  preddunenue.LoadedCallback();
  preddunenumu.LoadedCallback();
  preddunenuerhc.LoadedCallback();
  preddunenumurhc.LoadedCallback();

  preddunenue1d.LoadedCallback();
  preddunenumu1d.LoadedCallback();
  preddunenue1drhc.LoadedCallback();
  preddunenumu1drhc.LoadedCallback();


  SaveToFile(preddunenue, "pred_nue_fhc.root", "pred");
  SaveToFile(preddunenuerhc, "pred_nue_rhc.root", "pred");
  SaveToFile(preddunenumu, "pred_numu_fhc.root", "pred");
  SaveToFile(preddunenumurhc, "pred_numu_rhc.root", "pred");


  Spectrum mock = pred.Predict(calc).FakeData(pot);
  SingleSampleExperiment expt(&pred, mock);

  Spectrum mock2d = pred2d.Predict(calc).FakeData(pot);
  SingleSampleExperiment expt2d(&pred2d, mock2d);

  Spectrum mock2dsysts = preddunenumu.Predict(calc).FakeData(pot);
  SingleSampleExperiment expt2dsysts(&preddunenumu, mock2dsysts);

  Spectrum mock2dsystsrhc = preddunenumurhc.Predict(calc).FakeData(pot);
  SingleSampleExperiment expt2dsystsrhc(&preddunenumurhc, mock2dsystsrhc);

  Spectrum mock2di = pred2d.Predict(calci).FakeData(pot);
  SingleSampleExperiment expt2di(&pred2d, mock2di);

  Spectrum mock2disysts = preddunenumu.Predict(calci).FakeData(pot);
  SingleSampleExperiment expt2disysts(&preddunenumu, mock2disysts);

  Spectrum mock2disystsrhc = preddunenumurhc.Predict(calci).FakeData(pot);
  SingleSampleExperiment expt2disystsrhc(&preddunenumurhc, mock2disystsrhc);

  Spectrum mockRHC = predRHC.Predict(calc).FakeData(pot);
  SingleSampleExperiment exptRHC(&predRHC, mockRHC);

  Spectrum mockNue = predNue.Predict(calc).FakeData(pot);
  SingleSampleExperiment exptNue(&predNue, mockNue);

  Spectrum mockNue2d = predNue2d.Predict(calc).FakeData(pot);
  SingleSampleExperiment exptNue2d(&predNue2d, mockNue2d);

  Spectrum mockNue2dsysts = preddunenue.Predict(calc).FakeData(pot);
  SingleSampleExperiment exptNue2dsysts(&preddunenue, mockNue2dsysts);

  Spectrum mockNue2dsystsrhc = preddunenuerhc.Predict(calc).FakeData(pot);
  SingleSampleExperiment exptNue2dsystsrhc(&preddunenuerhc, mockNue2dsystsrhc);

  Spectrum mockNue2di = predNue2d.Predict(calci).FakeData(pot);
  SingleSampleExperiment exptNue2di(&predNue2d, mockNue2di);

  Spectrum mockNue2disysts = preddunenue.Predict(calci).FakeData(pot);
  SingleSampleExperiment exptNue2disysts(&preddunenue, mockNue2disysts);

  Spectrum mockNue2disystsrhc = preddunenuerhc.Predict(calci).FakeData(pot);
  SingleSampleExperiment exptNue2disystsrhc(&preddunenuerhc, mockNue2disystsrhc);

  Spectrum mockNueRHC = predNueRHC.Predict(calc).FakeData(pot);
  SingleSampleExperiment exptNueRHC(&predNueRHC, mockNueRHC);

  Spectrum mockNuePID = predNuePID.Predict(calc).FakeData(pot);
  Spectrum mockNuePIDRHC = predNuePIDRHC.Predict(calc).FakeData(pot);
  Spectrum mockNumuPID = predNumuPID.Predict(calc).FakeData(pot);
  Spectrum mockNumuPIDRHC = predNumuPIDRHC.Predict(calc).FakeData(pot);


  Surface surf(&expt, calc, &kFitSinSqTheta23, 20, .4, .6, &kFitDmSq32Scaled, 20, 2.35, 2.55);
  Surface surf2d(&expt2d, calc, &kFitSinSqTheta23, 20, .4, .6, &kFitDmSq32Scaled, 20, 2.35, 2.55);
  Surface surf2dcheck(&expt2dsysts, calc, &kFitSinSqTheta23, 20, .4, .6, &kFitDmSq32Scaled, 20, 2.35, 2.55); //should be same as previous line, let's check
  Surface surf2dsysts(&expt2dsysts, calc, &kFitSinSqTheta23, 20, .4, .6, &kFitDmSq32Scaled, 20, 2.35, 2.55, {}, systsnorm);
  Surface surf2dsystsall(&expt2dsysts, calc, &kFitSinSqTheta23, 20, .4, .6, &kFitDmSq32Scaled, 20, 2.35, 2.55, {}, systsall);
  Surface surfRHC(&exptRHC, calc, &kFitSinSqTheta23, 20, .4, .6, &kFitDmSq32Scaled, 20, 2.35, 2.55);

  MultiExperiment numuall({&expt2dsysts, &expt2dsystsrhc});

  Surface surfAll(&numuall, calc, &kFitSinSqTheta23, 20, .4, .6, &kFitDmSq32Scaled, 20, 2.35, 2.55, {}, systsall);

  MultiExperiment me({&expt, &exptNue, new SolarConstraints()});
  MultiExperiment me2d({&expt2d, &exptNue2d, new SolarConstraints()});
  MultiExperiment me2dsysts({&expt2dsysts, &exptNue2dsysts, new SolarConstraints()});
  MultiExperiment me2di({&expt2di, &exptNue2di, new SolarConstraints()});
  MultiExperiment me2disysts({&expt2disysts, &exptNue2disysts, new SolarConstraints()});
  MultiExperiment meRHC({&exptRHC, &exptNueRHC, new SolarConstraints()});
  MultiExperiment meAll({&exptNue2dsysts, &exptNue2dsystsrhc, &expt2dsysts, &expt2dsystsrhc, new SolarConstraints()});

  Surface surfNue(&me, calc, &kFitDeltaInPiUnits, 20, 0, 2, &kFitSinSqTheta23, 20, .4, .6);
  Surface surfNue2d(&me2d, calc, &kFitDeltaInPiUnits, 20, 0, 2, &kFitSinSqTheta23, 20, .4, .6);
  Surface surfNue2dsysts(&me2dsysts, calc, &kFitDeltaInPiUnits, 20, 0, 2, &kFitSinSqTheta23, 20, .4, .6, {}, systsnorm);
  Surface surfNue2dsystsall(&me2dsysts, calc, &kFitDeltaInPiUnits, 20, 0, 2, &kFitSinSqTheta23, 20, .4, .6, {}, systsall);
  Surface surfNue2dsystsall2(&me2dsysts, calc, &kFitDeltaInPiUnits, 20, 0, 2, &kFitSinSqTheta23, 20, .4, .6, {}, systsall2);
  Surface surfNueRHC(&meRHC, calc, &kFitDeltaInPiUnits, 20, 0, 2, &kFitSinSqTheta23, 20, .4, .6);
  Surface surfNueAll(&meAll, calc, &kFitDeltaInPiUnits, 20, 0, 2, &kFitSinSqTheta23, 20, .4, .6, {}, systsall);

  new TCanvas;
  TH1* h3 = DataMCComparisonComponents(mock, &pred, calc);
  h3->SetTitle("#nu_{#mu} FHC selection (MVA>0.25) 3.5yrs #times 40kt");
  CenterTitles(h3);
  Legend();
  gPad->Print("components.pdf");
  gPad->Print("components.C");

  new TCanvas;
  TH1* h3r = DataMCComparisonComponents(mockRHC, &predRHC, calc);
  h3r->SetTitle("#nu_{#mu} RHC selection (MVA>0.5) 3.5yrs #times 40kt");
  CenterTitles(h3);
  Legend();
  gPad->Print("components_rhc.pdf");
  gPad->Print("components_rhc.C");

  new TCanvas;
  TH1* h4 = DataMCComparisonComponents(mockNue, &predNue, calc);
  h4->SetTitle("#nu_{e} FHC selection (MVA>0.8) 3.5yrs #times 40kt");
  CenterTitles(h4);
  Legend();
  gPad->Print("components_nue.pdf");
  gPad->Print("components_nue.C");

  new TCanvas;
  TH1* h4r = DataMCComparisonComponents(mockNueRHC, &predNueRHC, calc);
  h4r->SetTitle("#nu_{e} RHC selection (MVA>0.8) 3.5yrs #times 40kt");
  CenterTitles(h4);
  Legend();
  gPad->Print("components_nue_rhc.pdf");
  gPad->Print("components_nue_rhc.C");

  new TCanvas;
  TH1* h2 = DataMCComparisonComponents(mockNumuPID, &predNumuPID, calc);
  h2->SetTitle("#nu_{#mu} FHC 3.5yrs #times 40kt");
  CenterTitles(h2);
  Legend();
  h2->GetYaxis()->SetRangeUser(1, 1e4);
  gPad->SetLogy();
  gPad->Print("components_pid.pdf");
  gPad->Print("components_pid.C");

  new TCanvas;
  TH1* h2d = DataMCComparisonComponents(mock2d, &pred2d, calc);
  h2d->SetTitle("#nu_{#mu} FHC 3.5yrs #times 40kt");
  CenterTitles(h2);
  Legend();
  h2->GetYaxis()->SetRangeUser(1, 1e4);
  gPad->SetLogy();
  gPad->Print("components_pid_2d.pdf");
  gPad->Print("components_pid_2d.C");

  new TCanvas;
  TH1* h2r = DataMCComparisonComponents(mockNumuPIDRHC, &predNumuPIDRHC, calc);
  h2r->SetTitle("#nu_{#mu} RHC 3.5yrs #times 40kt");
  CenterTitles(h2);
  Legend();
  h2->GetYaxis()->SetRangeUser(1, 1e4);
  gPad->SetLogy();
  gPad->Print("components_pid_rhc.pdf");
  gPad->Print("components_pid_rhc.C");

  new TCanvas;
  TH1* h = DataMCComparisonComponents(mockNuePID, &predNuePID, calc);
  h->SetTitle("#nu_{e} FHC 3.5yrs #times 40kt");
  CenterTitles(h);
  Legend();
  h->GetYaxis()->SetRangeUser(0, 600);
  gPad->Print("components_nue_pid.pdf");
  gPad->Print("components_nue_pid.C");

  new TCanvas;
  TH1* hd = DataMCComparisonComponents(mockNue2d, &predNue2d, calc);
  hd->SetTitle("#nu_{e} FHC 3.5yrs #times 40kt");
  CenterTitles(h);
  Legend();
  h->GetYaxis()->SetRangeUser(0, 600);
  gPad->Print("components_nue_pid_2d.pdf");
  gPad->Print("components_nue_pid_2d.C");

  new TCanvas;
  TH1* hr = DataMCComparisonComponents(mockNuePIDRHC, &predNuePIDRHC, calc);
  h->SetTitle("#nu_{e} RHC 3.5yrs #times 40kt");
  CenterTitles(h);
  Legend();
  h->GetYaxis()->SetRangeUser(0, 600);
  gPad->Print("components_nue_pid_rhc.pdf");
  gPad->Print("components_nue_pid_rhc.C");

  new TCanvas;
  surf.DrawContour(Gaussian90Percent2D(surf), kSolid, 4);
  //  surfRHC.DrawContour(Gaussian90Percent2D(surfRHC), kSolid, kGreen+2);
  surf2d.DrawContour(Gaussian90Percent2D(surf2d), kSolid, 1);
  surf2dcheck.DrawContour(Gaussian90Percent2D(surf2d), kSolid, 1); // if there are 2 solid black lines there is a problem
  surf2dsysts.DrawContour(Gaussian90Percent2D(surf2dsysts), kSolid, kGreen+2);
  surf2dsystsall.DrawContour(Gaussian90Percent2D(surf2dsystsall), kSolid, 2);
  surf.DrawBestFit(kRed);
  surfAll.DrawContour(Gaussian90Percent2D(surfAll), 1, kMagenta);
  gPad->Print("cont.pdf");

  new TCanvas;
  surfNue.DrawContour(Gaussian90Percent2D(surfNue), kSolid, 4);
  surfNue2d.DrawContour(Gaussian90Percent2D(surfNue2d), kSolid, 1);
  surfNue2dsysts.DrawContour(Gaussian90Percent2D(surfNue2dsysts), kSolid, kGreen+2);
  surfNue2dsystsall.DrawContour(Gaussian90Percent2D(surfNue2dsystsall), kSolid, 2);
  //  surfNue2dsystsall2.DrawContour(Gaussian90Percent2D(surfNue2dsystsall2), kSolid, kMagenta); // just a check that a 50% NC syst is same as a 5%
  surfNueAll.DrawContour(Gaussian90Percent2D(surfNueAll), kSolid, kMagenta);
  surfNue.DrawBestFit(kRed);
  gPad->Print("cont_nue.pdf");

  Spectrum testnom = preddunenumu.Predict(calc);
  Spectrum scaleshifted = preddunenumu.PredictSyst(calc,scaleshift);
  Spectrum resshifted = preddunenumu.PredictSyst(calc,resshift);

  new TCanvas;

  TH1* htestnom = testnom.ToTH1(pot);
  TH1* hscaleshifted = scaleshifted.ToTH1(pot);
  TH1* hresshifted = resshifted.ToTH1(pot);

  htestnom->SetLineWidth(2);
  hscaleshifted->SetLineWidth(2);
  hresshifted->SetLineWidth(2);

  hscaleshifted->SetLineColor(2);
  hresshifted->SetLineColor(4);

  htestnom->Draw();
  hscaleshifted->Draw("same");
  hresshifted->Draw("same");

  gPad->Print("testsysts.pdf"); // yes things are really shifting, here we can see it happen

  new TCanvas;

  TH1* hnom2 = nom2.ToTH1(pot);
  TH1* hscale2 = scale2.ToTH1(pot);
  TH1* hres2 = res2.ToTH1(pot);

  hnom2->SetLineWidth(2);
  hscale2->SetLineWidth(2);
  hres2->SetLineWidth(2);

  hscale2->SetLineColor(2);
  hres2->SetLineColor(4);

  hnom2->Draw();
  hscale2->Draw("same");
  hres2->Draw("same");

  gPad->Print("testsysts2.pdf"); // check shifts are happening in 2D variable also

  new TCanvas;

  // This is a very cheesy way to make the McD plot - would have to be very
  // different if we were varying any other parameters; leave in for now but don't trust this
  calc->SetdCP(0);
  Spectrum zeroNumu = pred.Predict(calc).FakeData(pot);
  Spectrum zeroNue = predNue.Predict(calc).FakeData(pot);
  Spectrum zeroNumu2d = pred2d.Predict(calc).FakeData(pot);
  Spectrum zeroNue2d = predNue2d.Predict(calc).FakeData(pot);
  Spectrum zeroNumuRHC = predRHC.Predict(calc).FakeData(pot);
  Spectrum zeroNueRHC = predNueRHC.Predict(calc).FakeData(pot);
  calc->SetdCP(TMath::Pi());
  Spectrum oneNumu = pred.Predict(calc).FakeData(pot);
  Spectrum oneNue = predNue.Predict(calc).FakeData(pot);
  Spectrum oneNumu2d = pred2d.Predict(calc).FakeData(pot);
  Spectrum oneNue2d = predNue2d.Predict(calc).FakeData(pot);
  Spectrum oneNumuRHC = predRHC.Predict(calc).FakeData(pot);
  Spectrum oneNueRHC = predNueRHC.Predict(calc).FakeData(pot);

  TGraph* g = new TGraph;
  TGraph* g2d = new TGraph;
  TGraph* grhc = new TGraph;
  TGraph* gold = new TGraph;
  TGraph* gold2 = new TGraph;

  for(int i = -100; i <= 100; ++i){
    calc->SetdCP(i/100.*TMath::Pi());

    Spectrum mockNumu = pred.Predict(calc).FakeData(pot);
    Spectrum mockNue = predNue.Predict(calc).FakeData(pot);
    Spectrum mockNumu2d = pred2d.Predict(calc).FakeData(pot);
    Spectrum mockNue2d = predNue2d.Predict(calc).FakeData(pot);
    Spectrum mockNumuRHC = predRHC.Predict(calc).FakeData(pot);
    Spectrum mockNueRHC = predNueRHC.Predict(calc).FakeData(pot);

    const double llZero = LogLikelihood(zeroNumu.ToTH1(pot), mockNumu.ToTH1(pot))+
      LogLikelihood(zeroNue.ToTH1(pot), mockNue.ToTH1(pot));

    const double llOne = LogLikelihood(oneNumu.ToTH1(pot), mockNumu.ToTH1(pot))+
      LogLikelihood(oneNue.ToTH1(pot), mockNue.ToTH1(pot));

    const double llZero2d = LogLikelihood(zeroNumu2d.ToTH1(pot), mockNumu2d.ToTH1(pot))+
      LogLikelihood(zeroNue2d.ToTH1(pot), mockNue2d.ToTH1(pot));

    const double llOne2d = LogLikelihood(oneNumu2d.ToTH1(pot), mockNumu2d.ToTH1(pot))+
      LogLikelihood(oneNue2d.ToTH1(pot), mockNue2d.ToTH1(pot));

    const double llZeroRHC = LogLikelihood(zeroNumuRHC.ToTH1(pot), mockNumuRHC.ToTH1(pot))+LogLikelihood(zeroNumu.ToTH1(pot), mockNumu.ToTH1(pot))+
      LogLikelihood(zeroNueRHC.ToTH1(pot), mockNueRHC.ToTH1(pot))+LogLikelihood(zeroNue.ToTH1(pot), mockNue.ToTH1(pot));

    const double llOneRHC = LogLikelihood(oneNumuRHC.ToTH1(pot), mockNumuRHC.ToTH1(pot))+LogLikelihood(oneNumu.ToTH1(pot), mockNumu.ToTH1(pot))+
      LogLikelihood(oneNueRHC.ToTH1(pot), mockNueRHC.ToTH1(pot))+LogLikelihood(oneNue.ToTH1(pot), mockNue.ToTH1(pot));

    const double ll = std::min(llZero, llOne);
    const double ll2d = std::min(llZero2d, llOne2d);
    const double llrhc = std::min(llZeroRHC, llOneRHC);

    if(ll>0) g->SetPoint(g->GetN(), i/100., sqrt(ll));
    if(ll2d>0) g2d->SetPoint(g2d->GetN(), i/100., sqrt(ll2d));
    if(llrhc>0) grhc->SetPoint(grhc->GetN(), i/100., sqrt(llrhc));
  }

  TH2* axes = new TH2F("", "3.5yrs #times 40kt, stats only;#delta / #pi;#sqrt{#chi^{2}}", 200, -1, +1, 50, 0, 8);

  CenterTitles(axes);
  axes->Draw();

  g2d->SetLineWidth(2);
  g2d->SetLineColor(1);
  g2d->Draw("l same");

  g->SetLineWidth(2);
  g->SetLineColor(4);
  g->Draw("l same");

  grhc->SetLineWidth(2);
  grhc->SetLineColor(kMagenta);
  grhc->Draw("l same");

  gPad->SetGridx();
  gPad->SetGridy();

  gPad->Print("mcd_hacky.pdf");
  gPad->Print("mcd_hacky.C");



  new TCanvas; // now try to make the plot right

  TH2* axes2 = new TH2F("", "3.5yrs #times 40kt, stats only;#delta / #pi;#sqrt{#chi^{2}}", 100, -1, +1, 50, 0, 8);

  TGraph* gr1d = new TGraph;    // IH+NH, all systs, 1D (E only)
  TGraph* grfull = new TGraph;  // IH+NH, all systs, 2D (ExPID)
  TGraph* gr2 = new TGraph;     // IH+NH, norm systs only, 2D
  TGraph* gr3 = new TGraph;     // FHC only, all systs, 2D, IH+NH
  TGraph* grstat = new TGraph;  // FHC only, no  systs, 2D, IH+NH
  TGraph* grnh = new TGraph;    // NH only part of previous
  TGraph* grih = new TGraph;    // IH only part


  // lots of possible combinations here: 2 hierarchies x 2 (FHC, RHC) x 2 expts (numu, nue) 2 x variables (1D, 2D) = 16, at 2 values of dCP = 32

  // do dCP = 0 case

  calc->SetdCP(0);
  calci->SetdCP(0);

  Spectrum tempnumu = preddunenumu.Predict(calc).FakeData(pot);
  SingleSampleExperiment expttempnumu(&preddunenumu, tempnumu);
  Spectrum tempnue = preddunenue.Predict(calc).FakeData(pot);
  SingleSampleExperiment expttempnue(&preddunenue, tempnue);

  Spectrum tempnumui = preddunenumu.Predict(calci).FakeData(pot);
  SingleSampleExperiment expttempnumui(&preddunenumu, tempnumu);
  Spectrum tempnuei = preddunenue.Predict(calci).FakeData(pot);
  SingleSampleExperiment expttempnuei(&preddunenue, tempnue);

  Spectrum tempnumurhc = preddunenumurhc.Predict(calc).FakeData(pot);
  SingleSampleExperiment expttempnumurhc(&preddunenumurhc, tempnumurhc);
  Spectrum tempnuerhc = preddunenuerhc.Predict(calc).FakeData(pot);
  SingleSampleExperiment expttempnuerhc(&preddunenuerhc, tempnuerhc);

  Spectrum tempnumuirhc = preddunenumurhc.Predict(calci).FakeData(pot);
  SingleSampleExperiment expttempnumuirhc(&preddunenumurhc, tempnumurhc);
  Spectrum tempnueirhc = preddunenuerhc.Predict(calci).FakeData(pot);
  SingleSampleExperiment expttempnueirhc(&preddunenuerhc, tempnuerhc);

  Spectrum tempnumu1d = preddunenumu1d.Predict(calc).FakeData(pot);
  SingleSampleExperiment expttempnumu1d(&preddunenumu1d, tempnumu1d);
  Spectrum tempnue1d = preddunenue1d.Predict(calc).FakeData(pot);
  SingleSampleExperiment expttempnue1d(&preddunenue1d, tempnue1d);

  Spectrum tempnumui1d = preddunenumu1d.Predict(calci).FakeData(pot);
  SingleSampleExperiment expttempnumui1d(&preddunenumu1d, tempnumu1d);
  Spectrum tempnuei1d = preddunenue1d.Predict(calci).FakeData(pot);
  SingleSampleExperiment expttempnuei1d(&preddunenue1d, tempnue1d);

  Spectrum tempnumurhc1d = preddunenumu1drhc.Predict(calc).FakeData(pot);
  SingleSampleExperiment expttempnumurhc1d(&preddunenumu1drhc, tempnumurhc1d);
  Spectrum tempnuerhc1d = preddunenue1drhc.Predict(calc).FakeData(pot);
  SingleSampleExperiment expttempnuerhc1d(&preddunenue1drhc, tempnuerhc1d);

  Spectrum tempnumuirhc1d = preddunenumu1drhc.Predict(calci).FakeData(pot);
  SingleSampleExperiment expttempnumuirhc1d(&preddunenumu1drhc, tempnumurhc1d);
  Spectrum tempnueirhc1d = preddunenue1drhc.Predict(calci).FakeData(pot);
  SingleSampleExperiment expttempnueirhc1d(&preddunenue1drhc, tempnuerhc1d);

  MultiExperiment tempme({&expttempnumu, &expttempnue, new SolarConstraints()}); // FHC only NH numu+nue
  MultiExperiment tempmei({&expttempnumui, &expttempnuei, new SolarConstraints()}); // FHC only IH numu+nue

  MultiExperiment tempmefull({&expttempnumu, &expttempnue, &expttempnumurhc, &expttempnuerhc, new SolarConstraints()}); // nue+numu FHC+RHC NH 2D
  MultiExperiment tempmeifull({&expttempnumui, &expttempnuei, &expttempnumuirhc, &expttempnueirhc, new SolarConstraints()}); // nue+numu FHC+RHC IH 2D

  MultiExperiment tempmefull1d({&expttempnumu1d, &expttempnue1d, &expttempnumurhc1d, &expttempnuerhc1d, new SolarConstraints()}); // nue+numu FHC+RHC NH 1D
  MultiExperiment tempmeifull1d({&expttempnumui1d, &expttempnuei1d, &expttempnumuirhc1d, &expttempnueirhc1d, new SolarConstraints()}); // nue+numu FHC+RHC IH 1D

  // now dCP = PI case

  calc->SetdCP(TMath::Pi());
  calci->SetdCP(TMath::Pi());

  Spectrum tempnumu2 = preddunenumu.Predict(calc).FakeData(pot);
  SingleSampleExperiment expttempnumu2(&preddunenumu, tempnumu2);
  Spectrum tempnue2 = preddunenue.Predict(calc).FakeData(pot);
  SingleSampleExperiment expttempnue2(&preddunenue, tempnue2);

  Spectrum tempnumui2 = preddunenumu.Predict(calci).FakeData(pot);
  SingleSampleExperiment expttempnumui2(&preddunenumu, tempnumu2);
  Spectrum tempnuei2 = preddunenue.Predict(calci).FakeData(pot);
  SingleSampleExperiment expttempnuei2(&preddunenue, tempnue2);

  Spectrum tempnumurhc2 = preddunenumurhc.Predict(calc).FakeData(pot);
  SingleSampleExperiment expttempnumurhc2(&preddunenumurhc, tempnumurhc2);
  Spectrum tempnuerhc2 = preddunenuerhc.Predict(calc).FakeData(pot);
  SingleSampleExperiment expttempnuerhc2(&preddunenuerhc, tempnuerhc2);

  Spectrum tempnumuirhc2 = preddunenumurhc.Predict(calci).FakeData(pot);
  SingleSampleExperiment expttempnumuirhc2(&preddunenumurhc, tempnumurhc2);
  Spectrum tempnueirhc2 = preddunenuerhc.Predict(calci).FakeData(pot);
  SingleSampleExperiment expttempnueirhc2(&preddunenuerhc, tempnuerhc2);

  Spectrum tempnumu1d2 = preddunenumu1d.Predict(calc).FakeData(pot);
  SingleSampleExperiment expttempnumu1d2(&preddunenumu1d, tempnumu1d2);
  Spectrum tempnue1d2 = preddunenue1d.Predict(calc).FakeData(pot);
  SingleSampleExperiment expttempnue1d2(&preddunenue1d, tempnue1d2);

  Spectrum tempnumui1d2 = preddunenumu1d.Predict(calci).FakeData(pot);
  SingleSampleExperiment expttempnumui1d2(&preddunenumu1d, tempnumu1d2);
  Spectrum tempnuei1d2 = preddunenue1d.Predict(calci).FakeData(pot);
  SingleSampleExperiment expttempnuei1d2(&preddunenue1d, tempnue1d2);

  Spectrum tempnumurhc1d2 = preddunenumu1drhc.Predict(calc).FakeData(pot);
  SingleSampleExperiment expttempnumurhc1d2(&preddunenumu1drhc, tempnumurhc1d2);
  Spectrum tempnuerhc1d2 = preddunenue1drhc.Predict(calc).FakeData(pot);
  SingleSampleExperiment expttempnuerhc1d2(&preddunenue1drhc, tempnuerhc1d2);

  Spectrum tempnumuirhc1d2 = preddunenumu1drhc.Predict(calci).FakeData(pot);
  SingleSampleExperiment expttempnumuirhc1d2(&preddunenumu1drhc, tempnumurhc1d2);
  Spectrum tempnueirhc1d2 = preddunenue1drhc.Predict(calci).FakeData(pot);
  SingleSampleExperiment expttempnueirhc1d2(&preddunenue1drhc, tempnuerhc1d2);

  MultiExperiment tempme2({&expttempnumu2, &expttempnue2, new SolarConstraints()});
  MultiExperiment tempmei2({&expttempnumui2, &expttempnuei2, new SolarConstraints()});

  MultiExperiment tempmefull2({&expttempnumu2, &expttempnue2, &expttempnumurhc2, &expttempnuerhc2, new SolarConstraints()});
  MultiExperiment tempmeifull2({&expttempnumui2, &expttempnuei2, &expttempnumuirhc2, &expttempnueirhc2, new SolarConstraints()});

  MultiExperiment tempmefull1d2({&expttempnumu1d2, &expttempnue1d2, &expttempnumurhc1d2, &expttempnuerhc1d2, new SolarConstraints()});
  MultiExperiment tempmeifull1d2({&expttempnumui1d2, &expttempnuei1d2, &expttempnumuirhc1d2, &expttempnueirhc1d2, new SolarConstraints()});

  // now make fitters that will do actual fits // TODO make variable names intelligible
  // these allow Dmsq32, sinsqth23, sinsq2th13 to float, constrained only by the data itself
  // they also allow Dmsq21 and sinsq2th12 to float, constrained be external solar data (see CAFAna/Experiments/SolarConstraints.*)

  // dCP = 0 fits
  Fitter fit(&tempme, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21}, systsnorm);            // FHC only, NH, norm systs only
  Fitter fit2(&tempme, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21});                      // FHC only, NH, no systs
  Fitter fit3(&tempme, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21}, systsall);            // FHC only, NH, all systs
  Fitter fitfull(&tempmefull, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21}, systsall);     // FHC+ RHC, NH, all systs
  Fitter fitfull1d(&tempmefull1d, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21}, systsall); // FHC+ RHC, NH, all systs, 1D
  SystShifts systsout = SystShifts::Nominal();
  Fitter fiti(&tempmei, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21}, systsnorm);          // same but IH now
  Fitter fit2i(&tempmei, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21});
  Fitter fit3i(&tempmei, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21}, systsall);
  Fitter fitfulli(&tempmeifull, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21}, systsall);
  Fitter fitfull1di(&tempmeifull1d, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21}, systsall);
  SystShifts systsouti = SystShifts::Nominal();


  // dCP = PI fits
  Fitter xfit(&tempme2, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21}, systsnorm);
  Fitter xfit2(&tempme2, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21});
  Fitter xfit3(&tempme2, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21}, systsall);
  Fitter xfitfull(&tempmefull2, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21}, systsall);
  Fitter xfitfull1d(&tempmefull1d2, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21}, systsall);
  SystShifts xsystsout = SystShifts::Nominal();
  Fitter xfiti(&tempmei2, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21}, systsnorm);
  Fitter xfit2i(&tempmei2, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21});
  Fitter xfit3i(&tempmei2, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21}, systsall);
  Fitter xfitfulli(&tempmeifull2, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21}, systsall);
  Fitter xfitfull1di(&tempmeifull1d2, {&kFitDmSq32Scaled, &kFitSinSq2Theta23, &kFitSinSq2Theta13, &kFitSinSq2Theta12, &kFitDmSq21}, systsall);
  SystShifts xsystsouti = SystShifts::Nominal();

  for(int i = -50; i <= 50; ++i){    // scan over dCP, create fake data at each dCP value, compare to dCP = 0 or PI cases, for each hierarchy
    calc->SetdCP(i/50.*TMath::Pi());
    calci->SetdCP(i/50.*TMath::Pi());

    std::cout << "Doing fits for dCP significance: " << i+50 << "%" << std::endl;

    // do the actual fits here, returns are chisq value of fits
    double throwaway = fit.Fit(calc, systsout, Fitter::kQuiet);  // debugging some odd behavior
    double chisqout = fit.Fit(calc, systsout, Fitter::kQuiet);
    double chisqouti = fiti.Fit(calci, systsouti, Fitter::kQuiet);
    double chisqout2 = fit2.Fit(calc, systsout, Fitter::kQuiet);
    double chisqout2i = fit2i.Fit(calci, systsout, Fitter::kQuiet);
    double chisqout3 = fit3.Fit(calc, systsout, Fitter::kQuiet);
    double chisqout3i = fit3i.Fit(calci, systsouti, Fitter::kQuiet);
    double chisqoutfull = fitfull.Fit(calc, systsout, Fitter::kQuiet);
    double chisqoutfulli = fitfulli.Fit(calci, systsout, Fitter::kQuiet);
    double chisqoutfull1d = fitfull1d.Fit(calc, systsout, Fitter::kQuiet);
    double chisqoutfull1di = fitfull1di.Fit(calci, systsout, Fitter::kQuiet);

    double xthrowaway = xfit.Fit(calc, systsout, Fitter::kQuiet);
    double xchisqout = xfit.Fit(calc, systsout, Fitter::kQuiet);
    double xchisqouti = xfiti.Fit(calci, systsouti, Fitter::kQuiet);
    double xchisqout2 = xfit2.Fit(calc, systsout, Fitter::kQuiet);
    double xchisqout2i = xfit2i.Fit(calci, systsout, Fitter::kQuiet);
    double xchisqout3 = xfit3.Fit(calc, systsout, Fitter::kQuiet);
    double xchisqout3i = xfit3i.Fit(calci, systsouti, Fitter::kQuiet);
    double xchisqoutfull = xfitfull.Fit(calc, systsout, Fitter::kQuiet);
    double xchisqoutfulli = xfitfulli.Fit(calci, systsout, Fitter::kQuiet);
    double xchisqoutfull1d = xfitfull1d.Fit(calc, systsout, Fitter::kQuiet);
    double xchisqoutfull1di = xfitfull1di.Fit(calci, systsout, Fitter::kQuiet);
    //    std::cout << " for dcp = " << i/50.*TMath::Pi() << " chisqs are: " << chisqout << " " << chisqouti << " " << sqrt(std::min(chisqout,chisqouti)) << std::endl; // debug

    // prevent possible errors
    if(chisqout < 0) chisqout = 0;
    if(chisqouti < 0) chisqouti = 0;
    if(chisqout2 < 0) chisqout = 0;
    if(chisqout2i < 0) chisqouti = 0;
    if(chisqout3 < 0) chisqout = 0;
    if(chisqout3i < 0) chisqouti = 0;
    if(chisqoutfull < 0) chisqoutfull = 0;
    if(chisqoutfulli < 0) chisqoutfulli = 0;
    if(chisqoutfull1d < 0) chisqoutfull1d = 0;
    if(chisqoutfull1di < 0) chisqoutfull1di = 0;

    if(xchisqout < 0) xchisqout = 0;
    if(xchisqouti < 0) xchisqouti = 0;
    if(xchisqout2 < 0) xchisqout = 0;
    if(xchisqout2i < 0) xchisqouti = 0;
    if(xchisqout3 < 0) xchisqout = 0;
    if(xchisqout3i < 0) xchisqouti = 0;
    if(xchisqoutfull < 0) xchisqoutfull = 0;
    if(xchisqoutfulli < 0) xchisqoutfulli = 0;
    if(xchisqoutfull1d < 0) xchisqoutfull1d = 0;
    if(xchisqoutfull1di < 0) xchisqoutfull1di = 0;

    //chisq for each point is minimum chisq of fit comparing to dCP = 0, PI, for either hierarchy

    gr2->SetPoint(gr2->GetN(), i/50., sqrt(std::min( std::min(chisqout,chisqouti), std::min(xchisqout,xchisqouti) )));
    gr3->SetPoint(gr3->GetN(), i/50., sqrt(std::min(std::min(chisqout3,chisqout3i),std::min(xchisqout3,xchisqout3i))));
    grnh->SetPoint(grnh->GetN(), i/50., sqrt(std::min(chisqout2,xchisqout2)));
    grih->SetPoint(grih->GetN(), i/50., sqrt(std::min(chisqout2i,xchisqout2i)));
    grstat->SetPoint(grstat->GetN(), i/50., sqrt(std::min(std::min(chisqout2i,chisqout2),std::min(xchisqout2i,xchisqout2))));
    grfull->SetPoint(grfull->GetN(), i/50., sqrt(std::min(std::min(chisqoutfulli,chisqoutfull),std::min(xchisqoutfulli,xchisqoutfull))));
    gr1d->SetPoint(gr1d->GetN(), i/50., sqrt(std::min(std::min(chisqoutfull1di,chisqoutfull1d),std::min(xchisqoutfull1di,xchisqoutfull1d))));
  }

  axes2->Draw();

  grfull->SetLineWidth(2);
  grfull->SetLineColor(2);
  grfull->Draw("l same");

  gr1d->SetLineWidth(2);
  gr1d->SetLineColor(4);
  gr1d->Draw("l same");

  gr2->SetLineWidth(2);
  gr2->SetLineColor(4);
  //  gr2->Draw("l same");

  gr3->SetLineWidth(2);
  gr3->SetLineColor(kGreen+2);
  gr3->Draw("l same");

  grnh->SetLineWidth(2);
  grnh->SetLineColor(1);
  //  grnh->Draw("l same");

  grih->SetLineWidth(2);
  grih->SetLineColor(2);
  //  grih->Draw("l same");

  grstat->SetLineWidth(2);
  grstat->SetLineColor(1);
  grstat->Draw("l same");

  gPad->SetGridx();
  gPad->SetGridy();

  gPad->Print("mcd.pdf");
  gPad->Print("mcd.C");
}