1 /////////////////////////////////////
2 // Created by: Kevin McDermott //
3 // email: kmcderm3@nd.edu //
4 // CERN Summer Student 2012 //
5 // University of Notre Dame du Lac //
8 // Created on: August 6, 2012 //
9 /////////////////////////////////////
14 #if !defined(__CINT__) || defined(__MAKECINT__)
17 #include "TGraphErrors.h"
21 #include <Riostream.h>
27 class AliPSQA : public TObject
33 // Functions listed in order of their appearance in the macro/class
35 // Initializers in constructor
37 void InitializeRuns(const Char_t * listOfRuns);
38 void InitializeTriggers(const Char_t * listOfTriggerNames, const Char_t * listOfTrigMaskChannel);
39 void InitializePlots(const Char_t * listOfPlots);
40 void SetQAColumnLabelForPlots(Int_t iplot);
41 void SetQAColumnLabelForMatching(Int_t iplot);
42 void InitializeRowTrigSet();
43 void InitializeFilled();
44 void InitializeValidRun();
46 // In order of calls in macro
48 void CacheFiles(); // Potential First call in macro
49 void MakeDir(TString dir);
51 Bool_t ComputeQAPerRun(); // Second call in macro
52 TString GetRootFileName(Int_t irun, TString filename);
53 void OpenTxtFile(Int_t irun, ofstream & outfile);
54 Bool_t ProcessQA(Int_t itrigclass, Int_t itrigchannel, Int_t itriglogic, Int_t irun, TH2D* hStats, ofstream & outfile);
55 Int_t SearchYLabels(Int_t itrigclass, Int_t itrigchannel, Int_t itriglogic, TH2D* hStats);
56 void GetTrigMask(TString label, Int_t * trigMask);
57 TString DecInttToBinTString(Int_t maskInt);
58 void SearchXLabels(Int_t iplot, Int_t * ibinx, TH2D * hStats);
59 void GetQAVals(TH2D * hstats, Int_t * ibinx, Int_t ibiny, Double_t * qavals);
60 void PlotQA(Int_t iplot, Int_t itrigclass, Int_t itrigchannel, Int_t itriglogic, Int_t irun, Double_t * qavals);
61 Double_t GetError(Double_t * qavals, Int_t iplot);
62 Double_t UncNRatioCorrelated(Double_t * qavals);
63 Double_t ErrorRatioNotSubsets(Double_t * qavals);
64 void SaveQAValToTxtFile(Int_t iplot, Int_t itrigclass, Int_t itrigchannel, Int_t itriglogic, Double_t * qavals, ofstream& outfile);
66 void CleanUpGraphs(TGraphErrors * plot);
68 TList * GetBadFiles(){return fListBadFiles;}; // Potential third call in macro
70 void DrawAllTGraphs(); // Potential fourth call in macro
72 // Getters and Setters for macro conditions
74 void SetSaveCache(Bool_t save){fSaveCache = save;};
75 Bool_t GetSaveCache(){return fSaveCache;};
77 void SetCachePath(TString cpath){fCachePath = cpath;};
78 TString GetCachePath(){return fCachePath;};
80 void SetLocalMode(Bool_t mode){fLocalMode = mode;};
81 Bool_t GetLocalMode(){return fLocalMode;};
83 void SetLocalPath(TString lpath){fLocalPath = lpath;};
84 TString GetLocalPath(){return fLocalPath;};
86 void SetGridPath(TString gpath){fGridPath = gpath;};
87 TString GetGridPath(){return fGridPath;};
89 void SetPSInput(TString input){fPSInput = input;};
90 TString GetPSInput(){return fPSInput;};
92 void SetROOTInput(TString RI){fROOTInput = RI;};
93 TString GetROOTInput(){return fROOTInput;};
95 void SetRootOutDirectory(TString out){fRootOutDirectory = out;};
96 TString GetRootOutDirectory(){return fRootOutDirectory;};
98 void SetTxtOutDirectory(TString out){fTxtOutDirectory = out;};
99 TString GetTxtOutDirectory(){return fTxtOutDirectory;};
101 void SetOutRootName(TString name){fOutRootName = name;};
102 TString GetOutRootName(){return fOutRootName;};
104 void SetSaveQAValToTxtFile(Bool_t savetxt){fSaveQAValToTxtFile = savetxt;};
105 Bool_t GetSaveQAValToTxtFile(){return fSaveQAValToTxtFile;};
107 void SetTxtFileName(TString txt){fTxtFileName = txt;};
108 TString GetTxtFileName(){return fTxtFileName;};
110 void SetSaveQAToROOTFile(Bool_t saverf){fSaveQAToROOTFile = saverf;};
111 Bool_t GetSaveQAToROOTFile(){return fSaveQAToROOTFile;};
113 void SetDrawAllTGraphs(Bool_t drawall){fDrawAllTGraphs = drawall;};
114 Bool_t GetDrawAllTGraphs(){return fDrawAllTGraphs;};
118 void SetQACycle(Int_t cycle){fQAcycle = cycle;};
119 Int_t GetQACycle(){return fQAcycle;};
122 TString fROOTInput; // name of root file to be analyzed
123 Int_t *fRunNumbers; // Runs to be used in macro
124 Int_t fNRuns; // Number of Runs used in macro
125 TString * fPlots; // List of plots to be generated
126 Int_t fNPlots; // Set number of plots to be used/qa numbers to be calculated per trig combo and run
127 TString * fQAColumnsNumeratorP; // Sub strings from fPlots, used for naming plots and the key for the online interface, numerator variable
128 TString * fQAColumnsDenominatorP; // Sub strings from fPlots, used for naming plots and the key for the online interface, denominator variable
129 TString * fQAColumnsNumeratorM; // Sub strings from fPlots, used for searching of x-axis, numerator variable
130 TString * fQAColumnsDenominatorM; // Sub strings from fPlots, used for searching of x-axis, denominator variable
134 Bool_t fSaveCache; // Bool to save files to cache locally
135 TString fCachePath; // cache subdirectory to be saved, subdirectory name specified in macro
136 TString fCacheDirectory; // full path directory to save files, in the format of Form("%s/%09i/%s",fCachePath.Data(),fRunNumbers[irun],fPSInput.Data())
138 // Grid location variables
140 TString fGridPath; // Location on the Grid for files to be processed
141 TString fPSInput; // Subdirectory for physics selection files to be used as input for macro
142 Int_t fQAcycle; // ??
144 // Local run variables
146 Bool_t fLocalMode; // Run on the Grid or Locally
147 TString fLocalPath; // Location of files to be processed locally
149 // Variables for storing output
151 Bool_t fSaveQAToROOTFile;
152 TString fOutRootName; // Name of macro output root file
153 TString fRootOutDirectory; // Path for root output
155 Bool_t fSaveQAValToTxtFile;
156 TString fTxtFileName; // txt file name for each run
157 TString fTxtOutDirectory; // Path for txt output files
159 TList * fListBadFiles; // List of runs with no event data
160 Int_t fNGoodRuns; // Number of Good Files
162 Bool_t fDrawAllTGraphs;
166 TString * fTrigClasses; // Mapped trigger name from & trig mask
167 Int_t fNTrigClasses; // Number of triggers used, given by number of trigger names
170 /////////////////////////////////QUASI HARD-CODED ////////////////////////////////////
171 ////////////////////// fTrigChannels[0] == Regular, fTrigChannels[1] == Fast, done this way in the case more partitions are needed, change the implementation, and otherwise just specify to loop over regular channels or fast channels,
174 TString * fTrigChannels; // Mapped names for fast/regular channels, room for more
175 Int_t fNTrigChannels; // Number of trigger channels used
177 ////////////////////////////////// !!!!!!!!!!!!!! Needs to be automated, hard code for now!!!!!!!!!!
180 /////////////////////////////// /////////////////////////////// ///////////////////////////////
181 static const Int_t fgkNTrigLogic = 18;
182 /////////////////////////////// /////////////////////////////// ///////////////////////////////
185 ////////////////////////////////// !!!!!!!!!!!!!! Needs to be automated, hard code for now!!!!!!!!!!
187 TGraphErrors * fGraphs[15][30][2][fgkNTrigLogic]; // Plots to be generated
189 Bool_t fRowTrigSet[30][2][fgkNTrigLogic]; // Check to make sure a specific combination of & and * is checked for a given run
190 Bool_t fValidRun[30][2][fgkNTrigLogic]; // Check to see if the run produces any valid plots
191 Bool_t fFilled[15][30][2][fgkNTrigLogic]; // Check to see if the run produces a specific plot