]> git.uio.no Git - u/mrichter/AliRoot.git/commitdiff
cleanup
authorhqvigsta <hqvigsta@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 11 Jun 2013 11:02:16 +0000 (11:02 +0000)
committerhqvigsta <hqvigsta@f7af4fe6-9843-0410-8265-dc069ae4e863>
Tue, 11 Jun 2013 11:02:16 +0000 (11:02 +0000)
PWGGA/PHOSTasks/PHOS_PbPb/macros/QA/DrawQA.C
PWGGA/PHOSTasks/PHOS_PbPb/macros/QA/ExtractQA.C

index b25a7bf9f08c10bdab60b1fe96142e433482cf15..e39f4b8f7711218418a399ed75052120c518438c 100644 (file)
@@ -2,7 +2,6 @@
 
 TFile* file;
 const char* prefixToName = "imgs/";
-const char* appendToName = ".pdf";
 const int kNCents = 1;
 
 void Draw(const char* name, const char* options = "", double yFrom=0., double yTo=-1.)
@@ -46,61 +45,63 @@ void Draw(const char* name, const char* options = "", double yFrom=0., double yT
   hist->DrawCopy(options);
 
 
-  canv->SaveAs(Form("%s%s%s", prefixToName, hist->GetName(), appendToName ));
+  canv->SaveAs(Form("%s%s.pdf", prefixToName, hist->GetName()));
+  canv->SaveAs(Form("%s%s.png", prefixToName, hist->GetName()));
   delete hist;
 }
 
 void DrawPID()
 {
   for(int cent=0; cent<kNCents; ++cent) {
-    TH1* grNPhotAll = (TH1*)file->Get(Form("grNPhotAll_cen%d", cent))->Clone();
-    TH1* grNPhotDisp = (TH1*)file->Get(Form("grNPhotDisp_cen%d", cent))->Clone();
-    TH1* grNPhotDisp2 = (TH1*)file->Get(Form("grNPhotDisp2_cen%d", cent))->Clone();
-    TH1* grNPhotCPV = (TH1*)file->Get(Form("grNPhotCPV_cen%d", cent))->Clone();
-    TH1* grNPhotCPV2 = (TH1*)file->Get(Form("grNPhotCPV2_cen%d", cent))->Clone();
-
-    grNPhotAll->GetXaxis()->SetLabelSize(0.045);
-    grNPhotAll->GetYaxis()->SetRangeUser(0, 40);
-
-    grNPhotAll  ->SetMarkerColor(kBlack);
-    grNPhotDisp ->SetMarkerColor(kCyan+1);
-    grNPhotDisp2->SetMarkerColor(kBlue);
-    grNPhotCPV  ->SetMarkerColor(kOrange+1);
-    grNPhotCPV2 ->SetMarkerColor(kRed);
-
-    TCanvas* canv = new TCanvas;
+    TString key = Form("nPhotPID_cen%i", cent);
+    
+    TH1* grNPhotAllcore = (TH1*)file->Get(Form("grNPhotAllcore_cen%d", cent))->Clone();
+    TH1* grNPhotCPVcore = (TH1*)file->Get(Form("grNPhotCPVcore_cen%d", cent))->Clone();
+    TH1* grNPhotDisp2core = (TH1*)file->Get(Form("grNPhotDisp2core_cen%d", cent))->Clone();
+    TH1* grNPhotBoth2core = (TH1*)file->Get(Form("grNPhotBoth2core_cen%d", cent))->Clone();
+
+    grNPhotAllcore->GetXaxis()->SetLabelSize(0.045);
+    grNPhotAllcore->GetYaxis()->SetRangeUser(0, grNPhotAllcore->GetMaximum()*1.2);
+
+    grNPhotAllcore  ->SetMarkerColor(kBlack);
+    grNPhotCPVcore ->SetMarkerColor(kCyan+1);
+    grNPhotDisp2core->SetMarkerColor(kBlue);
+    grNPhotBoth2core  ->SetMarkerColor(kOrange+1);
+
+    TCanvas* canv = new TCanvas(key.Data(), key.Data(), 1024, 768);
     canv->Divide(1,2);
 
     canv->cd(1);
-    grNPhotAll->SetTitle("#LTN_{clusters}^{PID}#GT");
-    grNPhotAll->GetXaxis()->SetRange(0, kFirstBinTo);
-    grNPhotAll->DrawCopy();
-    grNPhotDisp->DrawCopy("same");
-    grNPhotDisp2->DrawCopy("same");
-    grNPhotCPV->DrawCopy("same");
-    grNPhotCPV2->DrawCopy("same");
+    grNPhotAllcore->SetTitle("#LTN_{clusters}^{PID}#GT");
+    gPad->SetGridy();
+    grNPhotAllcore->GetXaxis()->SetRange(0, 85);
+    grNPhotAllcore->DrawCopy();
+    grNPhotCPVcore->DrawCopy("same");
+    grNPhotDisp2core->DrawCopy("same");
+    grNPhotBoth2core->DrawCopy("same");
 
     canv->cd(2);
-    grNPhotAll->SetTitle("");
-    grNPhotAll->GetXaxis()->SetRange(85, 200);
-    grNPhotAll->DrawCopy();
-    grNPhotDisp->DrawCopy("same");
-    grNPhotDisp2->DrawCopy("same");
-    grNPhotCPV->DrawCopy("same");
-    grNPhotCPV2->DrawCopy("same");
+    gPad->SetGridy();
+    grNPhotAllcore->SetTitle("");
+    grNPhotAllcore->GetXaxis()->SetRange(85, 200);
+    grNPhotAllcore->DrawCopy();
+    grNPhotCPVcore->DrawCopy("same");
+    grNPhotDisp2core->DrawCopy("same");
+    grNPhotBoth2core->DrawCopy("same");
 
     canv->cd(1);
     leg = new TLegend(0.9,0.7,0.99,0.99);
     leg->SetFillColor(kWhite);
     leg->SetBorderSize(1);
-    leg->AddEntry(Form("grNPhotAll_cen%d",cent),"All","lP");
-    leg->AddEntry(Form("grNPhotCPV_cen%d",cent),"CPV","lP");
-    leg->AddEntry(Form("grNPhotCPV2_cen%d",cent),"CPV2","lP");
-    leg->AddEntry(Form("grNPhotDisp_cen%d",cent),"Disp","lP");
-    leg->AddEntry(Form("grNPhotDisp2_cen%d",cent),"Disp2","lP");
+    leg->AddEntry(Form("grNPhotAllcore_cen%d",cent),"All","lP");
+    leg->AddEntry(Form("grNPhotCPVcore_cen%d",cent),"CPVcore","lP");
+    leg->AddEntry(Form("grNPhotDisp2core_cen%d",cent),"Disp2core","lP");
+    leg->AddEntry(Form("grNPhotBoth2core_cen%d",cent),"Both2core","lP");
+    
     leg->Draw();
   
-    canv->SaveAs(Form("%s%s%s", prefixToName, Form("nPhotPID_cen%d", cent), appendToName ));
+    canv->SaveAs(Form("%s%s_squeezed.pdf", prefixToName, key.Data()));
+    canv->SaveAs(Form("%s%s_squeezed.png", prefixToName, key.Data()));
   }
 }
 
@@ -120,7 +121,7 @@ void DrawCPVRatio()
     TCanvas* canv = new TCanvas;
     canv->Divide(1,2);
     canv->cd(1);
-    grNPhotCPV->GetXaxis()->SetRange(0, kFirstBinTo);
+    grNPhotCPV->GetXaxis()->SetRange(0, 85);
     grNPhotCPV->DrawCopy();
 
     canv->cd(2);
@@ -128,7 +129,8 @@ void DrawCPVRatio()
     grNPhotCPV->GetXaxis()->SetRange(85, 200);
     grNPhotCPV->DrawCopy();
   
-    canv->SaveAs(Form("%s%s%s", prefixToName, Form("CPVtoAllRatio_cen%d", cent), appendToName ));
+    canv->SaveAs(Form("%sCPVtoAllRatio_cen%d.pdf", prefixToName, cent));
+    canv->SaveAs(Form("%sCPVtoAllRatio_cen%d.png", prefixToName, cent));
   }
 }
 
@@ -155,7 +157,7 @@ void DrawNPhotAllAndHigh()
   
     canv->cd(1);
     grNPhotAll->SetTitle("#LTN_{clusters}#GT");
-    grNPhotAll->GetXaxis()->SetRange(0, kFirstBinTo);
+    grNPhotAll->GetXaxis()->SetRange(0, 85);
     grNPhotAll->GetYaxis()->SetRange(15, 40);
     //grNPhotAll->GetYaxis()->SetRangeUser(15, 45);
     grNPhotAll->DrawCopy();
@@ -177,7 +179,8 @@ void DrawNPhotAllAndHigh()
     leg->AddEntry(grNPhotAllcoreHigh, Form("AllcoreHigh * %d", scale),"lP");
     leg->Draw();
 
-    canv->SaveAs( Form("%s%s%s", prefixToName, Form("nPhotAllAndHigh_cen%d", cent), appendToName ));
+    canv->SaveAs( Form("%s%s.pdf", prefixToName, Form("nPhotAllAndHigh_cen%d", cent)));
+    canv->SaveAs( Form("%s%s.png", prefixToName, Form("nPhotAllAndHigh_cen%d", cent)));
   }
 }
 
@@ -216,7 +219,7 @@ void DrawPIDRatiosHighCore(const char* pidNames[], int nPids, const char* high)
 
       canv->cd(1);
       hPID->SetTitle( Form("#LTN_{clusters}^{PID}#GT / #LTN_{clusters}^{%s}#GT, cent=%d, %s", pidNames[0], cent, high) );
-      hPID->GetXaxis()->SetRange(0, kFirstBinTo);
+      hPID->GetXaxis()->SetRange(0, 85);
       hPID->DrawCopy(same);
 
       canv->cd(2);
@@ -229,7 +232,9 @@ void DrawPIDRatiosHighCore(const char* pidNames[], int nPids, const char* high)
     canv->cd(1);
     leg->Draw();
     TString fn(Form("CPVtoAllRatio%s_cen%d", high, cent));
-    canv->SaveAs(Form("%s%s%s", prefixToName, fn.Data(), appendToName ));
+
+    canv->SaveAs(Form("%s%s.pdf", prefixToName, fn.Data()));
+    canv->SaveAs(Form("%s%s.png", prefixToName, fn.Data()));
   }
 }
 
@@ -253,55 +258,55 @@ void DrawQA()
 
   file = TFile::Open("outputQA.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);
-
-
-  // DrawPID();
-  // DrawCPVRatio();
-  //  DrawNPhotAllAndHigh();
-  //DrawPIDRatios();
-
-  // Draw("grMPi0", "LINFIT", 0.13, 0.15 );
-  // Draw("grWPi0", "LINFIT");
-  // Draw("grNPi0", "LINFIT");
-
-  // Draw("grSERPV0Aflat", "", 0, 0.4);
-  // Draw("grSERPV0Cflat", "", 0, 0.4);
-  // Draw("grSERPTPCflat", "", 0, 0.4);
-
-  // Draw("grChi2RPV0A", "", 0.1, 500);
-  // Draw("grChi2RPV0C", "", 0.1, 500);
-  // Draw("grChi2RPTPC", "", 0.1, 500);
-  // Draw("grChi2RPV0Aflat", "", 0.1, 500);
-  // Draw("grChi2RPV0Cflat", "", 0.1, 500);
-  // Draw("grChi2RPTPCflat", "", 0.1, 500);
+  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);
+
+
+  DrawPID();
+  DrawCPVRatio();
+  DrawNPhotAllAndHigh();
+  DrawPIDRatios();
+
+  Draw("grMPi0", "LINFIT", 0.13, 0.15 );
+  Draw("grWPi0", "LINFIT");
+  Draw("grNPi0", "LINFIT");
+
+  Draw("grSERPV0Aflat", "", 0, 0.4);
+  Draw("grSERPV0Cflat", "", 0, 0.4);
+  Draw("grSERPTPCflat", "", 0, 0.4);
+
+  Draw("grChi2RPV0A", "", 0.1, 500);
+  Draw("grChi2RPV0C", "", 0.1, 500);
+  Draw("grChi2RPTPC", "", 0.1, 500);
+  Draw("grChi2RPV0Aflat", "", 0.1, 500);
+  Draw("grChi2RPV0Cflat", "", 0.1, 500);
+  Draw("grChi2RPTPCflat", "", 0.1, 500);
 
   Draw("grSinRPV0A1", "", 0, 0.7);
   Draw("grSinRPV0A2", "", 0, 10);
index a717beebe94e9437ed60b983a7fa871f4e5b5f26..90aa30e1fa47a052489c99690ec8d02e3f1bd08d 100644 (file)
@@ -2,6 +2,8 @@
 
 #if !defined(__CINT__) || defined(__MAKECINT__)
 #include <TGrid.h>
+#include <TStyle.h>
+#include <TRandom.h>
 #include <TFile.h>
 #include <TF1.h>
 #include <TH1F.h>
@@ -11,6 +13,8 @@
 #include <TMath.h>
 #include <TGraphErrors.h>
 #include <TString.h>
+#include "TFitResult.h"
+#include "THashList.h"
 #include "Riostream.h"
 #include "stdio.h"
 using namespace std;
@@ -50,9 +54,9 @@ Double_t bgP2     (Double_t *x, Double_t *par);
 // Global variabes
 const Int_t kNEventsBin = 4;
 const Int_t kNCents = 1;
-const Int_t kNPID = 8+4;
+const Int_t kNPID = 8+6;
 const char* kPIDNames[kNPID] = {"All", "Allwou", "Disp", "Disp2", "Dispwou", "CPV", "CPV2", "Both",
-                               "Allcore", "Dispcore", "CPVcore", "Bothcore"};
+                               "Allcore", "Dispcore", "CPVcore", "Bothcore", "Both2core", "Disp2core"};
 const char* fullMergeFileName = "AnalysisResults.root";
 
 Int_t runIndex;
@@ -118,15 +122,15 @@ void ExtractQA(const TString runFile="runFile.txt",
     printf("root file is %s, run # = %d\n",rootFileName,runNumber);
     // char *runNum = strtok(rootFileName+35,".");
     rootFile = TFile::Open(rootFileName,"read");
-    listHist = (TList*)rootFile->Get("PHOSPi0Flow_kCentral/PHOSPi0Flow_kCentralCoutput1");
+    listHist = (TList*)rootFile->Get("PHOSPi0Flow_kMB/PHOSPi0Flow_kMBCoutput1");
 
     run[runIndex]            = runIndex+1;
-    // QAFillEventSelection();
-    // QAFillOccupancy();
-    // QAFillClusters();
+    QAFillEventSelection();
+    QAFillOccupancy();
+    QAFillClusters();
     QAFillRP();
-    // QAFillTracks();
-    // QAFillNPi0();
+    QAFillTracks();
+    QAFillNPi0();
 
     listHist->Clear();
     rootFile->Close();
@@ -137,12 +141,12 @@ void ExtractQA(const TString runFile="runFile.txt",
 
 
   TFile *fileQA = TFile::Open(outputFileName.Data(), "recreate");
-  // QAWriteEventSelection();
-  // QAWriteOccupancy();
-  // QAWriteClusters();
+  QAWriteEventSelection();
+  QAWriteOccupancy();
+  QAWriteClusters();
   QAWriteRP();
-  // QAWriteTracks();
-  // QAWriteNPi0();
+  QAWriteTracks();
+  QAWriteNPi0();
   fileQA         ->Close();
 
 }
@@ -215,7 +219,8 @@ void QAFillClusters()
 
   for(int cent = 0; cent < kNCents; ++cent) {
     for(int ipid = 0; ipid < kNPID; ++ipid) {
-      TH1* hPhot = listHist->FindObject( Form("hPhot%s_cen%d", kPIDNames[ipid], cent) );
+      TObject* obj = listHist->FindObject( Form("hPhot%s_cen%d", kPIDNames[ipid], cent) );
+      TH1* hPhot = dynamic_cast<TH1*> ( obj );
 
       hPhot->SetAxisRange(0., 100.);
       double nPhot = hPhot->Integral() /nEvents4;
@@ -247,7 +252,7 @@ void QAFillRP()
 
   //int nEvents = hev->GetBinContent(kNEventsBin);
 
-  TH1D* phiRP1[nRPD][2] = {0};
+  TH1D* phiRP1[nRPD][2] = {{0}};
   phiRP1[V0A][0] = phiRPV0A->ProjectionX();
   phiRP1[V0C][0] = phiRPV0C->ProjectionX();
   phiRP1[TPC][0] = phiRP->ProjectionX();
@@ -404,7 +409,7 @@ void QAFillNPi0()
   int error = mrp;
   if( error % 1000) {
     Printf(" -> fit of fitM to hReMiRatio failed with error code %d", error % 1000);
-    continue;
+    return;
   }
   else if( error )
     Printf("Warning: failure of 'improve result' of fit of fitM to hReMiRatio");
@@ -427,7 +432,7 @@ void QAFillNPi0()
   mrp = hPi0SubBG->Fit(fitG,"Q","",rangeMin,rangeMax);
   if( (error=mrp) ) {
     Printf(" -> fit of fitG to hPi0SubBG failed with error code %d, skipping", error );
-    continue;
+    return;
   }
   hPi0SubBG->SetAxisRange(rangeMin, rangeMax);
   hPi0SubBG->DrawCopy();
@@ -559,7 +564,8 @@ void QAWriteClusters()
   TString name, title;
   for(int cent=0; cent<kNCents; ++cent) {
     for(int ipid = 0; ipid < kNPID; ++ipid) {
-      TH1* hPhot = listHist->FindObject( Form("hPhot%s_cen%d", kPIDNames[ipid], cent) );
+      TObject* obj = listHist->FindObject( Form("hPhot%s_cen%d", kPIDNames[ipid], cent) );
+      TH1* hPhot = dynamic_cast<TH1*> (obj);
       name = Form("grNPhot%s_cen%d", kPIDNames[ipid], cent);
       title = Form("#LTN_{clusters}^{%s}#GT, c.bin=%d", kPIDNames[ipid], cent);
       AddWriteTH1F(name, title, nPhotPID[cent][ipid], enPhotPID[cent][ipid]);
@@ -776,7 +782,6 @@ const TF1* GetPeriodRPFit(const char* histName)
   func->SetParLimits(3, -TMath::Pi(), TMath::Pi());
   func->SetParNames("s_{0}", "s_{1}", "#omega", "#psi");
   hist->GetXaxis()->SetTitle("#phi");
-  int error = 0;
   TCanvas* canv = new TCanvas(name.Data());
   gStyle->SetOptStat(0);
   gStyle->SetOptFit(1);
@@ -810,7 +815,7 @@ void AddNoise(TH1D* hist, double noise)
   for(int bin=1; bin<=nBins; ++bin) {
     hist->SetBinContent( bin, hist->GetBinContent(bin) + gRandom->Gaus(0, noise) );
     double err = hist->GetBinError(bin);
-    hist->SetBinError( bin, TMath::Sqrt( err**2 + noise**2 ) );
+    hist->SetBinError( bin, TMath::Sqrt( err*err + noise*noise ) );
   }
 }