Updates to PHOSPi0Flow QA macros
authorhqvigsta <hqvigsta@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 8 Oct 2012 15:58:54 +0000 (15:58 +0000)
committerhqvigsta <hqvigsta@f7af4fe6-9843-0410-8265-dc069ae4e863>
Mon, 8 Oct 2012 15:58:54 +0000 (15:58 +0000)
PWGGA/PHOSTasks/PHOS_PbPb/macros/QA/DrawQA.C
PWGGA/PHOSTasks/PHOS_PbPb/macros/QA/DrawQAFill.C [new file with mode: 0644]
PWGGA/PHOSTasks/PHOS_PbPb/macros/QA/ExtractQA.C
PWGGA/PHOSTasks/PHOS_PbPb/macros/QA/ExtractQAFill.C [new file with mode: 0644]

index 89eda68..873971d 100644 (file)
@@ -123,16 +123,20 @@ void DrawCPVRatio()
 void DrawNPhotAllAndHigh()
 {
   for(int cent=0; cent<kNCents; ++cent) {
-    TH1* grNPhotAll = (TH1*)file->Get(Form("grNPhotAll_cen0", cent))->Clone();
-    TH1* grNPhotAllHigh = (TH1*)file->Get(Form("grNPhotAllHigh_cen0", cent))->Clone();
+    TH1* grNPhotAll = (TH1*)file->Get(Form("grNPhotAll_cen%d", cent))->Clone();
+    TH1* grNPhotAllHigh = (TH1*)file->Get(Form("grNPhotAllHigh_cen%d", cent))->Clone();
+    TH1* grNPhotAllcoreHigh = (TH1*)file->Get(Form("grNPhotAllcoreHigh_cen%d", cent))->Clone();
 
     double sizeAll = grNPhotAll->Integral();
     double sizeAllHigh = grNPhotAllHigh->Integral();
-    double scale = (sizeAll / sizeAllHigh);
+    int scale = TMath::Nint(sizeAll / sizeAllHigh);
     grNPhotAllHigh->Scale(scale);
+    grNPhotAllcoreHigh->Scale(scale);
   
     grNPhotAllHigh->SetMarkerColor(kRed);
     grNPhotAllHigh->SetLineColor(kRed);
+    grNPhotAllcoreHigh->SetMarkerColor(kGreen+1);
+    grNPhotAllcoreHigh->SetLineColor(kGreen+1);
 
     TCanvas* canv = new TCanvas;
     canv->Divide(1,2);
@@ -140,30 +144,32 @@ void DrawNPhotAllAndHigh()
     canv->cd(1);
     grNPhotAll->SetTitle("#LTN_{clusters}#GT");
     grNPhotAll->GetXaxis()->SetRange(0, 84);
-    int min = grNPhotAll->GetMinimum(1.);
-    int max = grNPhotAll->GetMaximum() +1;
-    //grNPhotAll->GetYaxis()->SetRangeUser( min, max);
+    grNPhotAll->GetYaxis()->SetRange(15, 40);
+    //grNPhotAll->GetYaxis()->SetRangeUser(15, 45);
     grNPhotAll->DrawCopy();
     grNPhotAllHigh->DrawCopy("same");
+    grNPhotAllcoreHigh->DrawCopy("same");
 
     canv->cd(2);
     grNPhotAll->GetXaxis()->SetRange(85, 200);
     grNPhotAll->DrawCopy();
     grNPhotAllHigh->DrawCopy("same");
+    grNPhotAllcoreHigh->DrawCopy("same");
 
     canv->cd(1);
-    leg = new TLegend(0.8,0.8,0.99,0.99);
+    leg = new TLegend(0.8, 0.15, 0.99, 0.4);
     leg->SetFillColor(kWhite);
     leg->SetBorderSize(1);
     leg->AddEntry(grNPhotAll, Form("All"),"lP");
-    leg->AddEntry(grNPhotAllHigh, Form("High * %f", scale),"lP");
+    leg->AddEntry(grNPhotAllHigh, Form("AllHigh * %d", scale),"lP");
+    leg->AddEntry(grNPhotAllcoreHigh, Form("AllcoreHigh * %d", scale),"lP");
     leg->Draw();
 
     canv->SaveAs( Form("%s%s%s", prefixToName, Form("nPhotAllAndHigh_cen%d", cent), appendToName ));
   }
 }
 
-void DrawPIDRatiosHighCore(const char* pidNames[], int nPids, const char* append)
+void DrawPIDRatiosHighCore(const char* pidNames[], int nPids, const char* high)
 {
   int kNColors = 8;
   const Int_t colors[8] = {kBlack, kRed-1, kRed+1, kBlue, kCyan, kGreen+3, kYellow+1, kMagenta};
@@ -171,7 +177,7 @@ void DrawPIDRatiosHighCore(const char* pidNames[], int nPids, const char* append
   Int_t color;
   
   for(int cent=0; cent<kNCents; ++cent) {
-    TH1* hAll = (TH1*)file->Get( Form("grNPhot%s%s_cen%d", pidNames[0], append, cent) )->Clone();
+    TH1* hAll = (TH1*)file->Get( Form("grNPhot%s%s_cen%d", pidNames[0], high, cent) )->Clone();
 
     leg = new TLegend(0.91,0.6,0.99,0.99);
     leg->SetFillColor(kWhite);
@@ -181,7 +187,7 @@ void DrawPIDRatiosHighCore(const char* pidNames[], int nPids, const char* append
     canv->Divide(1,2);
     char* same = "";
     for(int ipid = 1; ipid < nPids; ++ipid) {
-      TString name(Form("grNPhot%s%s_cen%d", pidNames[ipid], append, cent));
+      TString name(Form("grNPhot%s%s_cen%d", pidNames[ipid], high, cent));
       TH1* hPID = (TH1*)file->Get( name.Data() )->Clone();
       hPID->Divide(hAll);
 
@@ -197,7 +203,7 @@ void DrawPIDRatiosHighCore(const char* pidNames[], int nPids, const char* append
       leg->AddEntry( hPID , pidNames[ipid], "lP");
 
       canv->cd(1);
-      hPID->SetTitle( Form("#LTN_{clusters}^{PID}#GT, cent=%d, %s", cent, append) );
+      hPID->SetTitle( Form("#LTN_{clusters}^{PID}#GT / #LTN_{clusters}^{%s}#GT, cent=%d, %s", pidNames[0], cent, high) );
       hPID->GetXaxis()->SetRange(0, 84);
       hPID->DrawCopy(same);
 
@@ -210,7 +216,8 @@ void DrawPIDRatiosHighCore(const char* pidNames[], int nPids, const char* append
     }
     canv->cd(1);
     leg->Draw();
-    canv->SaveAs(Form("%s%s%s", prefixToName, Form("CPVtoAllRatio_cen%d", cent), appendToName ));
+    TString fn(Form("CPVtoAllRatio%s_cen%d", high, cent));
+    canv->SaveAs(Form("%s%s%s", prefixToName, fn.Data(), appendToName ));
   }
 }
 
@@ -221,9 +228,9 @@ void DrawPIDRatios()
   const char* kPIDNames[nn] = {"All", "Allwou", "CPV", "CPV2", "Disp", "Disp2", "Dispwou", "Both"};
   const char* kPIDNamesCore[nc] = {"Allcore", "CPVcore", "Dispcore", "Bothcore"};
   const char* fillHigh[2] = {"", "High"};
-  for(int ihigh = 0; ihigh < 1; ++ihigh) {
+  for(int ihigh = 0; ihigh < 2; ++ihigh) {
     DrawPIDRatiosHighCore(kPIDNames, nn, fillHigh[ihigh]);
-    //DrawPIDRatiosHighCore(kPIDNamesCore, nc, fillHigh[ihigh]);
+    DrawPIDRatiosHighCore(kPIDNamesCore, nc, fillHigh[ihigh]);
   }
 }
 
@@ -231,7 +238,7 @@ void DrawQA()
 {
   gStyle->SetOptStat(0);
 
-  file = TFile::Open("runQA.root", "read");
+  file = TFile::Open("outputQA.root", "read");
 
   // Draw("grVtxZ10Cent", "", 0.7, 1.);
   // Draw("grNCellsM1", "E");
@@ -266,7 +273,11 @@ void DrawQA()
   // DrawPID();
   // DrawCPVRatio();
   DrawNPhotAllAndHigh();
-  DrawPIDRatios();
+  //DrawPIDRatios();
+
+  Draw("grMPi0");
+  Draw("grWPi0");
+  Draw("grNPi0");
 
   file->Close();
 }
diff --git a/PWGGA/PHOSTasks/PHOS_PbPb/macros/QA/DrawQAFill.C b/PWGGA/PHOSTasks/PHOS_PbPb/macros/QA/DrawQAFill.C
new file mode 100644 (file)
index 0000000..19b258e
--- /dev/null
@@ -0,0 +1,70 @@
+#include "TCanvas.h" // needed for some reason.
+
+TFile* file;
+const char* prefixToName = "imgsFill/";
+const char* appendToName = ".pdf";
+const int kNCents = 1;
+
+void Draw(const char* name, const char* options = "", double yFrom=0., double yTo=-1.)
+{
+  TH1* hist = ((TH1*)file->Get(name))->Clone();
+
+  if( yFrom < yTo )
+    hist->GetYaxis()->SetRangeUser(yFrom, yTo);
+
+  TCanvas* canv = new TCanvas;
+  //canv->SetGrid();
+  //hist->GetYaxis()->SetNdivisions(16);
+
+  if( TString(options).Contains("LINFIT") )
+    hist->Fit("pol0", "Q");
+
+  hist->DrawCopy(options);
+
+  canv->SaveAs(Form("%s%s%s", prefixToName, hist->GetName(), appendToName ));
+  delete hist;
+}
+
+void DrawQAFill()
+{
+  gStyle->SetOptStat(0);
+  gStyle->SetOptFit(1);
+
+  file = TFile::Open("outputQAFill.root", "read");
+
+  Draw("grVtxZ10Cent", "", 0.7, 1.);
+  // Draw("grNCellsM1", "E");
+  // Draw("grNCellsM2");
+  // Draw("grNCellsM3");
+  // Draw("grECluster", "", 0.5, 0.7);
+  Draw("grNCluster", "", 0, 40);
+  Draw("grNTracks0", "", 0 , 12000);
+  // Draw("grNPhotAll_cen0", "", 0, 40);
+  // Draw("grNPhotAllcore_cen0", "", 0, 40);
+  // Draw("grNPhotAllwou_cen0", "", 0, 40);
+  // Draw("grNPhotDisp_cen0", "", 0, 40);
+  // Draw("grNPhotDisp2_cen0", "", 0, 40);
+  // Draw("grNPhotDispwou_cen0", "", 0, 40);
+  // Draw("grNPhotCPV_cen0", "", 0, 40);
+  // Draw("grNPhotCPV2_cen0", "", 0, 40);
+  // Draw("grNPhotBoth_cen0", "", 0, 40);
+  // Draw("grEnAll_cen0", "", 0.4, 0.7);
+  // Draw("grEnAllcore_cen0", "", 0.4, 0.7);
+  // Draw("grEnAllwou_cen0", "", 0.4, 0.7);
+  // Draw("grEnDisp_cen0", "", 0.4, 0.7);
+  // Draw("grEnDisp2_cen0", "", 0.4, 0.7);
+  // Draw("grEnDispcore_cen0", "", 0.4, 0.7);
+  // Draw("grEnDispwou_cen0", "", 0.4, 0.7);
+  // Draw("grEnCPV_cen0", "", 0.4, 0.7);
+  // Draw("grEnCPVcore_cen0", "", 0.4, 0.7);
+  // Draw("grEnCPV2_cen0", "", 0.4, 0.7);
+  // Draw("grEnBoth_cen0", "", 0.4, 0.7);
+  // Draw("grEnBothcore_cen0", "", 0.4, 0.7);
+
+
+  Draw("grMPi0", "LINFIT", 0.13, 0.15);
+  Draw("grWPi0", "LINFIT");
+  Draw("grNPi0", "LINFIT");
+
+  file->Close();
+}
index 3bc4219..6676149 100644 (file)
@@ -78,7 +78,8 @@ Double_t nPi0Event[500], ePi0Event[500];
 
 //-----------------------------------------------------------------------------
 void ExtractQA(const TString filelist="filelist.txt",
-              const TString runlist="runlist.txt")
+              const TString runlist="runlist.txt",
+              const TString outputFileName = "outputQA.root")
 {
   // Loop over per-run root files and run various QA functions
 
@@ -117,7 +118,7 @@ void ExtractQA(const TString filelist="filelist.txt",
     QAFillOccupancy();
     QAFillClusters();
     QAFillTracks();
-//     QAFillNPi0();
+    QAFillNPi0();
 
     listHist->Clear();
     rootFile->Close();
@@ -125,12 +126,12 @@ void ExtractQA(const TString filelist="filelist.txt",
   }
 
   
-  TFile *fileQA = TFile::Open("runQA.root","recreate");
+  TFile *fileQA = TFile::Open(outputFileName.Data(), "recreate");
   QAWriteEventSelection();
   QAWriteOccupancy();
   QAWriteClusters();
   QAWriteTracks();
-//   QAWriteNPi0();
+  QAWriteNPi0();
   fileQA         ->Close();
 
 }
@@ -244,11 +245,19 @@ void QAFillTracks()
 //-----------------------------------------------------------------------------
 void QAFillNPi0()
 {
+  TH1 *hTotSelEvents = (TH1*)listHist->FindObject("hTotSelEvents");
+  Int_t nEvents4 = hTotSelEvents->GetBinContent(4);
+
+  if( nEvents4 < 10000 ) {
+    Printf(" -> skipping due to small number of selected events: %d", nEvents4);
+    return;
+  }
+  
+  
   TCanvas* canv = new TCanvas;
   canv->Divide(3,3);
   canv->cd(1);
   
-  TH1 *hTotSelEvents = (TH1*)listHist->FindObject("hTotSelEvents");
   TH2F *hReMassPt = (TH2F*)listHist->FindObject("hPi0All_cen0");
   TH2 *hMiMassPt = (TH2*)listHist->FindObject("hMiPi0All_cen0");
   TH1* hReMass = Pi0InvMass(hReMassPt,2.,10.);
@@ -261,14 +270,15 @@ void QAFillNPi0()
   // Draw
   hReMassPt->DrawCopy("colz");
   canv->cd(2);
-  hReMass->DrawCopy();
+  //hReMass->SetAxisRange(0.1, 0.2);
+  hReMass->DrawCopy("E");
   canv->cd(3);
   
   
   TH1* hReMiRatio = (TH1*)hReMass->Clone("hReMiRatio");
   TH1* hPi0SubBG  = (TH1*)hReMass->Clone("hPi0SubBG");
   hReMiRatio->Divide(hMiMass);
-  hReMiRatio->DrawCopy();
+  hReMiRatio->DrawCopy("E");
   canv->cd(4);
   
 
@@ -294,27 +304,48 @@ void QAFillNPi0()
   fitBG->SetParName(1,"a_{1}") ;
   fitBG->SetParName(2,"a_{2}") ;
 
-  fitM->SetParameters(0.1,0.136,0.007,0.0013,-0.0007, 0.0) ;
-  fitM->SetParLimits(0,0.000,1.000) ;
-  fitM->SetParLimits(1,0.130,0.14) ;
-  fitM->SetParLimits(2,0.005,0.012) ;
+  fitM->SetParameters(0.003, 0.134, 0.007, 0.14, -0.02, -0.01) ;
+  fitM->SetParLimits(0, 0., 1. ) ;
+  fitM->SetParLimits(1, 0.1, 0.2 ) ;
+  fitM->SetParLimits(2, 0., 0.05) ;
 
   Double_t rangeMin=0.06 ;
   Double_t rangeMax=0.25 ;
-  hReMiRatio->Fit(fitM,"NQ","",rangeMin,rangeMax) ;
-  hReMiRatio->Fit(fitM,"MQ","",rangeMin,rangeMax) ;
+  TFitResultPtr mrp = hReMiRatio->Fit(fitM,"Q","",rangeMin,rangeMax) ;
+  //mrp = hReMiRatio->Fit(fitM,"MQ","",rangeMin,rangeMax) ; // "M" always fail...
+  int error = mrp;
+  if( error % 1000) {
+    Printf(" -> fit of fitM to hReMiRatio failed with error code %d", error % 1000);
+    continue;
+  }
+  else if( error )
+    Printf("Warning: failure of 'improve result' of fit of fitM to hReMiRatio");
   fitBG->SetParameters(fitM->GetParameter(3),
                       fitM->GetParameter(4),
                       fitM->GetParameter(5)); 
+  hReMiRatio->SetAxisRange(rangeMin, rangeMax);
+  hReMiRatio->DrawCopy();
+  canv->cd(5);
+
+
   hMiMass->Multiply(fitBG) ;
   hPi0SubBG ->Add(hMiMass,-1.) ;
 
 
   fitG->SetParameters(100.,fitM->GetParameter(1),fitM->GetParameter(2)) ;
-  fitG->SetParLimits(0,0.000,1.e+5) ;
-  fitG->SetParLimits(1,0.120,0.145) ;
-  fitG->SetParLimits(2,0.005,0.012) ;
-  hPi0SubBG->Fit(fitG,"Q","",rangeMin,rangeMax);
+  // fitG->SetParLimits(0,0.000,1.e+5) ;
+  fitG->SetParLimits(1, rangeMin, rangeMax) ;
+  fitG->SetParLimits(2, 0., rangeMax) ;
+  mrp = hPi0SubBG->Fit(fitG,"Q","",rangeMin,rangeMax);
+  if( (error=mrp) ) {
+    Printf(" -> fit of fitG to hPi0SubBG failed with error code %d, skipping", error );
+    continue;
+  }
+  hPi0SubBG->SetAxisRange(rangeMin, rangeMax);
+  hPi0SubBG->DrawCopy();
+
+
+
   Double_t pi0Peak  = fitG->GetParameter(1);
   Double_t pi0Sigma = fitG->GetParameter(2);
   Double_t epi0Peak  = fitG->GetParError(1);
@@ -324,31 +355,17 @@ void QAFillNPi0()
 
   Double_t nPi0,ePi0;
   
-  nPi0 = hPi0SubBG->Integral(iMin,iMax);
-  ePi0 = TMath::Sqrt(nPi0);
+  
+  nPi0 = hPi0SubBG->IntegralAndError(iMin, iMax, ePi0);
+  //ePi0 = TMath::Sqrt(nPi0);
   // Fit1Pi0(hMass,2,0.05,0.20,nPi0,ePi0); 
   
-  Double_t nEvents4 = hTotSelEvents->GetBinContent(4);
   mPi0     [runIndex] = pi0Peak;
   emPi0    [runIndex] = epi0Peak;
   wPi0     [runIndex] = pi0Sigma;
   ewPi0    [runIndex] = epi0Sigma;
   nPi0Event[runIndex] = nPi0/nEvents4;
   ePi0Event[runIndex] = ePi0/nEvents4;
-
-  // printf("Npi0(%d,%d) = %.1f\n",iMin,iMax,nPi0);
-  // TCanvas *c1 = new TCanvas("c1","c1",0,0,800,600);
-  // c1->Divide(2,2);
-  // c1->cd(1);
-  // hReMass->DrawCopy();
-  // c1->cd(2);
-  // hMiMass->DrawCopy();
-  // c1->cd(3);
-  // hReMiRatio->DrawCopy();
-  // fitBG->Draw("same");
-  // c1->cd(4);
-  // hPi0SubBG->DrawCopy();
-
 }
 
 //-----------------------------------------------------------------------------
@@ -537,6 +554,8 @@ TH1D * Pi0InvMass(TH2 *hMassPt, Float_t ptmin, Float_t ptmax)
   sprintf(htitle,"%.1f<p_{T}<%.1f GeV/c",ptmin,ptmax);
   hMass->SetTitle(htitle);
   
+  hMass->Sumw2();
+
   return hMass;
 
 }
diff --git a/PWGGA/PHOSTasks/PHOS_PbPb/macros/QA/ExtractQAFill.C b/PWGGA/PHOSTasks/PHOS_PbPb/macros/QA/ExtractQAFill.C
new file mode 100644 (file)
index 0000000..0b056ca
--- /dev/null
@@ -0,0 +1,6 @@
+void ExtractQAFill(const TString fillFileList="fillFileList.txt",
+              const TString fillList="fillList.txt")
+{
+  gROOT->LoadMacro("ExtractQA.C");
+  ExtractQA(fillFileList, fillList, "outputQAFill.root");
+}