-/******************************************************************************************************************************************
-Contact person: Marco Leoncino (leoncino@to.infn.it)
-Macro to run the ZDC QA trending by accessing the std QA output, to be mainly used with the automatic scripts to fill the QA repository.
-Launch with aliroot -l -b -q "MakeTrendingZDCQA.C(\"${fullpath}/QAresults.root\", ${run}, ...)
-The macro produces a file containing the tree of trending variables and the main plots.
-A feature that displays the plots in canvases must be enable when needed.
-******************************************************************************************************************************************/
-
#if !defined(__CINT__) || defined(__MAKECINT__)
-
#include <stdio.h>
#include <stdlib.h>
#include <TROOT.h>
#include <TGridResult.h>
#include <TSystem.h>
#include <TGaxis.h>
-
#endif
-Int_t MakeTrendingZDCQA(TString qafilename, //full path of the QA output; set IsOnGrid to prepend "alien://"
- Int_t runNumber, //run number
- Bool_t isMC = kFALSE, //MC flag, to disable meaningless checks
- Bool_t canvasE = kFALSE, //enable display plots on canvas and save png
- Bool_t IsOnGrid = kFALSE, //set to kTRUE to access files on the grid
- TString ocdbStorage = "raw://") //set the default ocdb storage
-{
-
- // macro to generate tree with ZDC QA trending variables
- // access qa PWGPP output files
- if (!qafilename) {
- printf("Error - Invalid input file");
- return 1;
- }
-
- /*set graphic style*/
- gStyle->SetCanvasColor(kWhite);
- gStyle->SetFrameFillColor(kWhite);
- gStyle->SetFrameBorderMode(0);
- gStyle->SetCanvasBorderMode(0);
- gStyle->SetTitleFillColor(kWhite);
- gStyle->SetTitleBorderSize(0);
- gStyle->SetTitleFont(42);
- gStyle->SetTextFont(42);
- gStyle->SetStatColor(kWhite);
- gStyle->SetStatBorderSize(1);
- TGaxis::SetMaxDigits(3);
- gStyle->SetOptStat(10);
-
- char defaultQAoutput[30]="QAresults.root";
- char * treePostFileName="trending.root";
+int MakeTrendZDC(char *infile, int run) {
- if (IsOnGrid) TGrid::Connect("alien://");
- TFile * fin = TFile::Open(qafilename,"r");
- if (!fin) {
- Printf("ERROR: QA output not found. Exiting...\n");
- return -1;
- } else {
- Printf("INFO: QA output file %s open. \n",fin->GetName());
- }
+ TStopwatch timer;
+ timer.Start();
+ gSystem->SetIncludePath("-I$ROOTSYS/include -I$ALICE_ROOT/include -I$ALICE_ROOT");
+ gSystem->Load("libSTAT");
+ gSystem->Load("libANALYSIS");
+ gSystem->Load("libANALYSISalice");
+ gSystem->Load("libANALYSIScalib");
+ gSystem->Load("libCORRFW");
+ gSystem->Load("libANALYSISalice.so");
+ gSystem->Load("libANALYSIScalib.so");
+ gSystem->Load("libTENDER.so");
+ gSystem->Load("libPWGPP.so");
+
+ char *outfile = "trending.root";
+ if (!infile) return -1;
+ if (!outfile) return -1;
+ TFile *f =0;
+ f=TFile::Open(infile,"read");
+ if (!f) {
+ printf("File %s not available\n", infile);
+ return -1;
+ }
+
//access histograms lists
char zdcQAdirName[20]="ZDC_Performance";
char genListName[20]="QAZDCHists";
- TDirectoryFile * zdcQAdir=(TDirectoryFile*)fin->Get(zdcQAdirName);
+ TDirectoryFile * zdcQAdir=(TDirectoryFile*)f->Get(zdcQAdirName);
if (!zdcQAdir) {
Printf("ERROR: ZDC QA directory not present in input file.\n");
return -1;
if (!generalList) Printf("WARNING: general QA histograms absent or not accessible\n");
- TH1F *fhTDCZNC = (TH1F*)generalList->FindObject("fhTDCZNC"); //! TDC ZNC sum
- TH1F *fhTDCZNA = (TH1F*)generalList->FindObject("fhTDCZNA"); //! TDC DIFF sum
- TH1F *fhTDCZNSum = (TH1F*)generalList->FindObject("fhTDCZNSum"); //! TDC ZNC sum
- TH1F *fhTDCZNDiff = (TH1F*)generalList->FindObject("fhTDCZNDiff"); //! TDC DIFF sum
- TH1F *fhZNCSumQ = (TH1F*)generalList->FindObject("fhZNCSumQ"); //! ZNC sum 4Q
- TH1F *fhZNASumQ = (TH1F*)generalList->FindObject("fhZNASumQ"); //! ZNA sum 4Q
- TH1F *fhZPCSumQ = (TH1F*)generalList->FindObject("fhZPCSumQ"); //! ZPC sum 4Q
- TH1F *fhZPASumQ = (TH1F*)generalList->FindObject("fhZPASumQ"); //! ZPA sum 4Q
- TH1F *fhZEM1Spectrum = (TH1F*)generalList->FindObject("fhZEM1Spectrum"); //! ZEM1 spectra
- TH1F *fhZEM2Spectrum = (TH1F*)generalList->FindObject("fhZEM2Spectrum"); //! ZEM2 spectra
- TH1F *fhZNCpmc = (TH1F*)generalList->FindObject("fhZNCpmc"); //! ZNC PMCs
- TH1F *fhZNApmc = (TH1F*)generalList->FindObject("fhZNApmc"); //! ZNA PMCs
- TH1F *fhZPCpmc = (TH1F*)generalList->FindObject("fhZPCpmc"); //! ZPC PMCs
- TH1F *fhZPApmc = (TH1F*)generalList->FindObject("fhZPApmc"); //! ZPA PMCs
- TH2F *fhZNCCentroid = (TH2F*)generalList->FindObject("fhZNCCentroid"); //! ZNC centroid
- TH2F *fhZNACentroid = (TH2F*)generalList->FindObject("fhZNACentroid"); //! ZNA centroid
- TH1F *fhPMCZNCemd = (TH1F*)generalList->FindObject("fhPMCZNCemd"); //! ZNC PMC low gain chain
- TH1F *fhPMCZNAemd = (TH1F*)generalList->FindObject("fhPMCZNAemd"); //! ZNA PMC low gain chain
- TH2F *fDebunch = (TH2F*)generalList->FindObject("fDebunch"); //! TDC sum vs. diff
- TH1F *fhTDCZNAcorr = (TH1F*)generalList->FindObject("fhTDCZNAcorr"); //! ZNA corrected TDC
- TH1F *fhTDCZNCcorr = (TH1F*)generalList->FindObject("fhTDCZNCcorr"); //! ZNC corrected TDC
+ TH1D *fhTDCZNC = (TH1D*)generalList->FindObject("fhTDCZNC"); //! TDC ZNC sum
+ TH1D *fhTDCZNA = (TH1D*)generalList->FindObject("fhTDCZNA"); //! TDC DIFF sum
+ TH1D *fhTDCZNSum = (TH1D*)generalList->FindObject("fhTDCZNSum"); //! TDC ZNC sum
+ TH1D *fhTDCZNDiff = (TH1D*)generalList->FindObject("fhTDCZNDiff"); //! TDC DIFF sum
+ TH1D *fhZNCSumQ = (TH1D*)generalList->FindObject("fhZNCSumQ"); //! ZNC sum 4Q
+ TH1D *fhZNASumQ = (TH1D*)generalList->FindObject("fhZNASumQ"); //! ZNA sum 4Q
+ TH1D *fhZPCSumQ = (TH1D*)generalList->FindObject("fhZPCSumQ"); //! ZPC sum 4Q
+ TH1D *fhZPASumQ = (TH1D*)generalList->FindObject("fhZPASumQ"); //! ZPA sum 4Q
+ TH1D *fhZEM1Spectrum = (TH1D*)generalList->FindObject("fhZEM1Spectrum"); //! ZEM1 spectra
+ TH1D *fhZEM2Spectrum = (TH1D*)generalList->FindObject("fhZEM2Spectrum"); //! ZEM2 spectra
+ TH1D *fhZNCpmc = (TH1D*)generalList->FindObject("fhZNCpmc"); //! ZNC PMCs
+ TH1D *fhZNApmc = (TH1D*)generalList->FindObject("fhZNApmc"); //! ZNA PMCs
+ TH1D *fhZPCpmc = (TH1D*)generalList->FindObject("fhZPCpmc"); //! ZPC PMCs
+ TH1D *fhZPApmc = (TH1D*)generalList->FindObject("fhZPApmc"); //! ZPA PMCs
+ TH1D *fhPMCZNCemd = (TH1D*)generalList->FindObject("fhPMCZNCemd"); //! ZNC PMC low gain chain
+ TH1D *fhPMCZNAemd = (TH1D*)generalList->FindObject("fhPMCZNAemd"); //! ZNA PMC low gain chain
+ TH1D *fhTDCZNAcorr = (TH1D*)generalList->FindObject("fhTDCZNAcorr"); //! ZNA corrected TDC
+ TH1D *fhTDCZNCcorr = (TH1D*)generalList->FindObject("fhTDCZNCcorr"); //! ZNC corrected TDC
+ TH2D *fhZNCCentroid = (TH2D*)generalList->FindObject("fhZNCCentroid"); //! ZNC centroid
+ TH2D *fhZNACentroid = (TH2D*)generalList->FindObject("fhZNACentroid"); //! ZNA centroid
+ TH2D *fDebunch = (TH2D*)generalList->FindObject("fDebunch"); //! TDC sum vs. diff
+
+ Double_t ZNC_mean = 0.;
+ Double_t ZNA_mean = 0.;
+ Double_t ZPC_mean = 0.;
+ Double_t ZPA_mean = 0.;
+ Double_t ZEM1_mean = 0.;
+ Double_t ZEM2_mean = 0.;
Int_t fhZNCpmcEntries = fhZNCpmc->GetEntries();
Int_t fhZNApmcEntries = fhZNApmc->GetEntries();
Int_t fhZPCpmcEntries = fhZPCpmc->GetEntries();
Int_t fhZPApmcEntries = fhZPApmc->GetEntries();
- Double_t ZNC_mean = 0.0;
- Double_t ZNA_mean = 0.0;
- Double_t ZPC_mean = 0.0;
- Double_t ZPA_mean = 0.0;
- if (fhZNCpmcEntries>0) ZNC_mean = fhZNCpmc->GetMean()/TMath::Sqrt(fhZNCpmcEntries);
- if (fhZNApmcEntries>0) ZNA_mean = fhZNApmc->GetMean()/TMath::Sqrt(fhZNApmcEntries);
- if (fhZPCpmcEntries>0) ZPC_mean = fhZPCpmc->GetMean()/TMath::Sqrt(fhZPCpmcEntries);
- if (fhZPApmcEntries>0) ZPA_mean = fhZPApmc->GetMean()/TMath::Sqrt(fhZPApmcEntries);
Int_t fhZEM1SpectrumEntries = fhZEM1Spectrum->GetEntries();
- Int_t fhZEM2SpectrumEntries = fhZEM2Spectrum->GetEntries();
- Double_t ZEM1_mean = 0.;
- Double_t ZEM2_mean = 0.;
- if (fhZEM1SpectrumEntries>0) ZEM1_mean = fhZEM1Spectrum->GetMean()/TMath::Sqrt(fhZEM1SpectrumEntries);
- if (fhZEM2SpectrumEntries>0) ZEM2_mean = fhZEM2Spectrum->GetMean()/TMath::Sqrt(fhZEM2SpectrumEntries);
+ Int_t fhZEM2SpectrumEntries = fhZEM2Spectrum->GetEntries();
+
+ if (fhZNCpmcEntries>0) ZNC_mean = fhZNCpmc->GetMean();
+ if (fhZNApmcEntries>0) ZNA_mean = fhZNApmc->GetMean();
+ if (fhZPCpmcEntries>0) ZPC_mean = fhZPCpmc->GetMean();
+ if (fhZPApmcEntries>0) ZPA_mean = fhZPApmc->GetMean();
+ if (fhZEM1SpectrumEntries>0) ZEM1_mean = fhZEM1Spectrum->GetMean();
+ if (fhZEM2SpectrumEntries>0) ZEM2_mean = fhZEM2Spectrum->GetMean();
+
Double_t ZNC_XCent = fhZNCCentroid->GetMean(1);
Double_t ZNC_YCent = fhZNCCentroid->GetMean(2);
Double_t ZNA_XCent = fhZNACentroid->GetMean(1);
Double_t ZN_TDC_Diff_err = fhTDCZNDiff->GetRMS();
TTree * ttree=new TTree("trending","tree of trending variables");
- ttree->Branch("run",&runNumber,"run/I");
+ ttree->Branch("run",&run,"run/I");
ttree->Branch("ZNC_mean_value",&ZNC_mean,"ZNC_mean_value/D");
ttree->Branch("ZNA_mean_value",&ZNA_mean,"ZNA_mean_value/D");
ttree->Branch("ZPC_mean_value",&ZPC_mean,"ZPC_mean_value/D");
ttree->Branch("ZN_TDC_Sum_Err",&ZN_TDC_Sum_err,"ZN_TDC_Sum_Err/D");
ttree->Branch("ZN_TDC_Diff_Err",&ZN_TDC_Diff_err,"ZN_TDC_Diff_Err/D");
- Printf(":::: Getting post-analysis info for run %i",runNumber);
- TFile * trendFile = new TFile(treePostFileName,"recreate");
+ Printf(":::: Getting post-analysis info for run %i",run);
+ TFile * trendFile = new TFile(outfile,"recreate");
- printf("============== Saving histograms for run %i ===============\n",runNumber);
+ printf("============== Saving histograms for run %i ===============\n",run);
fhTDCZNC->Write();
fhTDCZNA->Write();
fhTDCZNCcorr->Write();
ttree->Fill();
- printf("============== Saving trending quantities in tree for run %i ===============\n",runNumber);
+ printf("============== Saving trending quantities in tree for run %i ===============\n",run);
trendFile->cd();
ttree->Write();