]> git.uio.no Git - u/mrichter/AliRoot.git/blob - ANALYSIS/macros/PhysSelQA/AliPSQA.h
Adding Domenico Colella as responsible for SPD part in TRI pp
[u/mrichter/AliRoot.git] / ANALYSIS / macros / PhysSelQA / AliPSQA.h
1 /////////////////////////////////////
2 // Created by: Kevin McDermott     //
3 // email: kmcderm3@nd.edu          //
4 // CERN Summer Student 2012        //
5 // University of Notre Dame du Lac //
6 //                                 // 
7 // Revision: 1.0                   //
8 // Created on: August 6, 2012      //
9 /////////////////////////////////////
10
11 #ifndef ALIPSQA_H
12 #define ALIPSQA_H
13
14 #if !defined(__CINT__) || defined(__MAKECINT__)
15 #include "TCanvas.h"
16 #include "TH2D.h"
17 #include "TGraphErrors.h"
18 #include "TFile.h"
19 #include "TMath.h"
20 #include "TList.h"
21 #include <Riostream.h>
22 #include "TSystem.h"
23 #include "TGaxis.h"
24 #include "TStyle.h"
25 #endif
26
27 class AliPSQA : public TObject
28 {
29  public: 
30   AliPSQA();
31   ~AliPSQA();
32   
33   // Functions listed in order of their appearance in the macro/class
34
35   // Initializers in constructor
36
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();
45   
46   // In order of calls in macro
47
48   void CacheFiles(); // Potential First call in macro
49   void MakeDir(TString dir);
50
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);
65   void SaveQAPlots(); 
66   void CleanUpGraphs(TGraphErrors * plot); 
67
68   TList * GetBadFiles(){return fListBadFiles;}; // Potential third call in macro
69
70   void DrawAllTGraphs(); // Potential fourth call in macro
71
72   // Getters and Setters for macro conditions
73   
74   void    SetSaveCache(Bool_t save){fSaveCache = save;};
75   Bool_t  GetSaveCache(){return fSaveCache;};
76
77   void    SetCachePath(TString cpath){fCachePath = cpath;};
78   TString GetCachePath(){return fCachePath;};
79
80   void    SetLocalMode(Bool_t mode){fLocalMode = mode;};
81   Bool_t  GetLocalMode(){return fLocalMode;};
82
83   void    SetLocalPath(TString lpath){fLocalPath = lpath;};
84   TString GetLocalPath(){return fLocalPath;};
85
86   void    SetGridPath(TString gpath){fGridPath = gpath;};
87   TString GetGridPath(){return fGridPath;}; 
88
89   void    SetPSInput(TString input){fPSInput = input;};
90   TString GetPSInput(){return fPSInput;};
91
92   void    SetROOTInput(TString RI){fROOTInput = RI;};
93   TString GetROOTInput(){return fROOTInput;};
94
95   void    SetRootOutDirectory(TString out){fRootOutDirectory = out;};
96   TString GetRootOutDirectory(){return fRootOutDirectory;};  
97
98   void    SetTxtOutDirectory(TString out){fTxtOutDirectory = out;};
99   TString GetTxtOutDirectory(){return fTxtOutDirectory;}; 
100
101   void    SetOutRootName(TString name){fOutRootName = name;};
102   TString GetOutRootName(){return fOutRootName;};
103
104   void    SetSaveQAValToTxtFile(Bool_t savetxt){fSaveQAValToTxtFile = savetxt;};
105   Bool_t  GetSaveQAValToTxtFile(){return fSaveQAValToTxtFile;};
106
107   void    SetTxtFileName(TString txt){fTxtFileName = txt;};
108   TString GetTxtFileName(){return fTxtFileName;};  
109
110   void    SetSaveQAToROOTFile(Bool_t saverf){fSaveQAToROOTFile = saverf;};
111   Bool_t  GetSaveQAToROOTFile(){return fSaveQAToROOTFile;};
112
113   void    SetDrawAllTGraphs(Bool_t drawall){fDrawAllTGraphs = drawall;};
114   Bool_t  GetDrawAllTGraphs(){return fDrawAllTGraphs;};
115
116   // Legacy get/set
117
118   void    SetQACycle(Int_t cycle){fQAcycle = cycle;};
119   Int_t   GetQACycle(){return fQAcycle;};
120
121  private: 
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
131
132   // Cache Variables
133
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()) 
137   
138   // Grid location variables
139
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; // ??
143
144   // Local run variables
145
146   Bool_t fLocalMode; // Run on the Grid or Locally
147   TString fLocalPath; // Location of files to be processed locally
148   
149   // Variables for storing output
150
151   Bool_t fSaveQAToROOTFile;
152   TString fOutRootName;  // Name of macro output root file
153   TString fRootOutDirectory; // Path for root output
154   
155   Bool_t fSaveQAValToTxtFile;
156   TString fTxtFileName; // txt file name for each run
157   TString fTxtOutDirectory; // Path for txt output files
158
159   TList * fListBadFiles; // List of runs with no event data
160   Int_t fNGoodRuns; // Number of Good Files
161
162   Bool_t fDrawAllTGraphs;
163
164   // Trigger Info
165
166   TString * fTrigClasses; // Mapped trigger name from & trig mask
167   Int_t fNTrigClasses; // Number of triggers used, given by number of trigger names
168   
169
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, 
172
173
174   TString * fTrigChannels; // Mapped names for fast/regular channels, room for more
175   Int_t fNTrigChannels; // Number of trigger channels used
176   
177   ////////////////////////////////// !!!!!!!!!!!!!! Needs to be automated, hard code for now!!!!!!!!!!
178
179
180   ///////////////////////////////  ///////////////////////////////  ///////////////////////////////
181   static const Int_t fgkNTrigLogic = 18;
182   ///////////////////////////////  ///////////////////////////////  ///////////////////////////////
183
184
185   ////////////////////////////////// !!!!!!!!!!!!!! Needs to be automated, hard code for now!!!!!!!!!!
186
187   TGraphErrors * fGraphs[15][30][2][fgkNTrigLogic]; // Plots to be generated
188  
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
192
193   ClassDef(AliPSQA,1)
194
195 };
196
197 #endif