]> git.uio.no Git - u/mrichter/AliRoot.git/blame - FMD/FMDutil/AliFMDBaseDA.h
Fix Coverity 24835
[u/mrichter/AliRoot.git] / FMD / FMDutil / AliFMDBaseDA.h
CommitLineData
e9c06036 1// -*- mode: C++ -*-
a3b36d36 2#ifndef ALIFMDBASEDA_H
3#define ALIFMDBASEDA_H
4
5/* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights
6 * reserved.
7 *
8 * See cxx source for full Copyright notice
9 */
10//
e9c06036 11// This class provides a base interface for the Detector Algorithms
12// (DA) of the FMD. At least three implementations are needed:
13// AliFMDPedestalDA, AliFMDGainDA and AliFMDPhysicsDA . These classes
14// will provide the calibration data for the AliFMDPreprocessor to be
15// used in the shuttle. The input for this class are raw data
16// (AliRawReader) and the output is a comma-separated file
17// (std::ofstream) that contains the values defined in the
18// implementations of this class.
a3b36d36 19//
e9c06036 20// Author: Hans Hjersing Dalsgaard, hans.dalsgaard@cern.ch
a3b36d36 21//
22
23#include "TNamed.h"
24#include "TObjArray.h"
a7e41e8d 25#include "TString.h"
427e8f99 26#include "TArrayS.h"
09b6c804 27#include <iosfwd>
28#include <fstream>
29class AliFMDDigit;
30class AliRawReader;
31class AliFMDParameters;
3effc6e7 32class AliFMDRawReader;
09b6c804 33class TDirectory;
2a082c96 34class TH2;
09b6c804 35class TFile;
36class TClonesArray;
a3b36d36 37
6cf6e7a0 38class AliFMDBaseDA: public TNamed
39{
e9c06036 40public:
6cf6e7a0 41 /**
42 * Constructor
43 *
44 */
a3b36d36 45 AliFMDBaseDA() ;
6cf6e7a0 46 /**
47 * Copy constructor
48 *
49 * @param baseDA
50 */
a3b36d36 51 AliFMDBaseDA(const AliFMDBaseDA & baseDA) ;
fb10ff39 52 // AliFMDBaseDA& operator = (const AliFMDBaseDA & baseDA) ;
6cf6e7a0 53 /**
54 * Destructor
55 *
56 */
a3b36d36 57 ~AliFMDBaseDA() ;
d015ecfe 58 AliFMDBaseDA& operator=(const AliFMDBaseDA&) { return *this; }
6cf6e7a0 59 /**
60 * Run this DA
61 *
62 * @param fmdReader Raw input reader
63 */
a3b36d36 64 void Run(AliRawReader* fmdReader);
6cf6e7a0 65 /**
66 * Set whether to save diagnostics
67 *
68 * @param save If true, will output diagnostics file
69 */
a3b36d36 70 void SetSaveDiagnostics(Bool_t save) {fSaveHistograms = save;}
a31ea3ce 71 /**
72 * Set the diagnostics file name
73 *
74 * @param f Diagnostics file name
75 */
76 void SetDiagnosticsFilename(const TString& f) { fDiagnosticsFilename = f; }
2a082c96 77 /**
78 * Set whether to make summary histograms to be published to AMORE
79 *
80 * @param save If true, will generate summary QA histograms
81 */
82 void SetMakeSummaries(Bool_t save) {fMakeSummaries = save;}
6cf6e7a0 83 /**
84 * Set the number of requried events
85 *
86 * @param nEvents Number of event we need
87 */
a3b36d36 88 void SetRequiredEvents(Int_t nEvents) {fRequiredEvents = nEvents;}
91c99839 89 /**
90 * Set whether we should try to get all detectors
91 *
92 * @param all If true, try to get all detectors
93 */
94 void SetTryAll(Bool_t all=true) { fAll = all; }
6cf6e7a0 95 /**
96 * Get the number of required events
97 *
98 *
99 * @return number of required events
100 */
c5569fbc 101 Int_t GetRequiredEvents() const {return fRequiredEvents ;}
2a082c96 102 /**
103 * Get list of summary histograms
104 *
105 * @return Array of summary histograms or null if not defined
106 */
107 const TObjArray& GetSummaries() const { return fSummaries; }
108 /**
109 * Check if we saw data for detector
110 *
111 * @param det Detector number to check
112 * @return true if the code has seen data from the detector
113 */
09b6c804 114 Bool_t HasSeenDetector(UShort_t d) const;
a31ea3ce 115
116 /**
117 * Class to run the DAs
118 */
119 struct Runner {
120 Runner();
91c99839 121 Runner(const Runner&)
122 : fReader(0), fDiagFile(""), fDiag(false), fAll(false) {}
a31ea3ce 123 ~Runner() {}
124 Runner& operator=(const Runner&) { return *this; }
125 void AddHandlers();
126 void ShowUsage(std::ostream& o, const char* progname);
127 Int_t Init(int argc, char** argv);
128 void Exec(AliFMDBaseDA& da);
129 Int_t RunNumber() const;
130 AliRawReader* fReader;
131 TString fDiagFile;
132 Bool_t fDiag;
91c99839 133 Bool_t fAll;
a31ea3ce 134 };
e9c06036 135protected:
6cf6e7a0 136 /**
137 * Initialize
6cf6e7a0 138 */
26be6417 139 virtual void Init() {};
6cf6e7a0 140 /**
141 * Fill channels
6cf6e7a0 142 */
26be6417 143 virtual void FillChannels(AliFMDDigit* ) {};
6cf6e7a0 144 /**
145 * Analyse a single strip result
6cf6e7a0 146 */
2a082c96 147 virtual void Analyse(UShort_t, Char_t, UShort_t, UShort_t) {};
6cf6e7a0 148 /**
149 * Write header to output file
6cf6e7a0 150 */
26be6417 151 virtual void WriteHeaderToFile() {};
6cf6e7a0 152 /**
153 * Add a strip container
6cf6e7a0 154 */
155 virtual void AddChannelContainer(TObjArray*, UShort_t, Char_t,
156 UShort_t, UShort_t ) {};
a31ea3ce 157 /**
158 * Add summary(s) for sectors
159 *
160 */
161 virtual void AddSectorSummary(TObjArray*, UShort_t, Char_t, UShort_t,
162 UShort_t) {}
6cf6e7a0 163 /**
164 * End of event
6cf6e7a0 165 */
26be6417 166 virtual void FinishEvent() {};
6cf6e7a0 167 /**
168 * End of run
6cf6e7a0 169 */
f7f0b643 170 virtual void Terminate(TFile* ) {};
6cf6e7a0 171 /**
172 * Current event number
173 *
174 *
175 * @return
176 */
c5569fbc 177 Int_t GetCurrentEvent() const {return fCurrentEvent;}
6cf6e7a0 178 /**
179 * Rotate a set of files. @a base is the basic name of the files.
180 * If the file @a base.max exists it is removed.
181 * If the file @a base.n exists (where n < max) it is renamed to @a
182 * base.(n-1).
183 * If the file @a base exists, it is renamed to @a base.1
184 *
185 * @param base Base name of the files
186 * @param max Maximum number to keep (minus one for the current).
187 */
188 void Rotate(const char* base, int max) const;
6cf6e7a0 189 /**
190 * Ge the half-ring index
191 *
192 * @param UShort_t
193 * @param Char_t
194 * @param UShort_t
195 *
196 * @return
197 */
c5569fbc 198 Int_t GetHalfringIndex(UShort_t, Char_t, UShort_t) const;
6cf6e7a0 199 /**
200 * Get the pulse size
201 *
202 * @param det Detector number
203 * @param ring Rin identifier
204 * @param board Board number
205 *
206 * @return Pulse step size
207 */
427e8f99 208 Int_t GetPulseSize(UShort_t det ,
209 Char_t ring,
6cf6e7a0 210 UShort_t board)
211 {
212 return fPulseSize.At(GetHalfringIndex(det,ring,board));
213 }
214 /**
215 * Get number of events per pulse size
216 *
217 * @param det Detector number
218 * @param ring Rin identifier
219 * @param board Board number
220 *
221 * @return number of events per Pulse size
222 */
427e8f99 223 Int_t GetPulseLength(UShort_t det,
224 Char_t ring,
6cf6e7a0 225 UShort_t board)
226 {
227 return fPulseLength.At(GetHalfringIndex(det,ring,board));
228 }
427e8f99 229
6cf6e7a0 230 /**
231 * Get the detector path in diagnositcs file
232 *
233 * @param det Detector number
234 * @param full If true, return full path
235 *
236 * @return Path to detector
237 */
e9c06036 238 const char* GetDetectorPath(UShort_t det, Bool_t full=kTRUE) const;
6cf6e7a0 239 /**
240 * Get the ring path in diagnositcs file
241 *
242 * @param det Detector number
243 * @param ring Ring identifier
244 * @param full If true, return full path
245 *
246 * @return Path to ring
247 */
e9c06036 248 const char* GetRingPath(UShort_t det, Char_t ring, Bool_t full=kTRUE) const;
6cf6e7a0 249 /**
250 * Get the sector path in diagnositcs file
251 *
252 * @param det Detector number
253 * @param ring Ring identifier
254 * @param sec Sector number
255 * @param full If true, return full path
256 *
257 * @return Path to sector
258 */
e9c06036 259 const char* GetSectorPath(UShort_t det, Char_t ring, UShort_t sec,
260 Bool_t full=kTRUE) const;
6cf6e7a0 261 /**
262 * Get the strip path in diagnositcs file
263 *
264 * @param det Detector number
265 * @param ring Ring identifier
266 * @param sec Sector number
267 * @param str Strip number
268 * @param full If true, return full path
269 *
270 * @return Path to strip
271 */
e9c06036 272 const char* GetStripPath(UShort_t det, Char_t ring, UShort_t sec,
273 UShort_t str, Bool_t full=kTRUE) const;
a31ea3ce 274 TObjArray* GetDetectorArray(UShort_t det);
275 TObjArray* GetRingArray(UShort_t det, Char_t ring);
276 TObjArray* GetSectorArray(UShort_t det, Char_t ring, UShort_t sector);
277 TObjArray* GetStripArray(UShort_t det, Char_t ring,
278 UShort_t sector, UShort_t strip);
6cf6e7a0 279 /**
280 * Write conditions file
281 *
282 * @param fmdReader Raw input
283 */
3effc6e7 284 void WriteConditionsData(AliFMDRawReader* fmdReader);
6cf6e7a0 285 /**
286 * Set the current event
287 *
288 * @param currentEvent
289 */
a3b36d36 290 void SetCurrentEvent(Int_t currentEvent) {fCurrentEvent = currentEvent; }
6cf6e7a0 291 /**
292 * Initialize container
293 *
294 * @param dir Directory to make containers in
295 */
a31ea3ce 296 virtual void InitContainer(TDirectory* dir);
2a082c96 297 /**
298 * Utility function for defining summary histograms
299 *
300 * @param det Detector
301 * @param ring Ring identifier
302 * @param prefix Histogram prefix
303 * @param title Histogram title
304 */
305 TH2* MakeSummaryHistogram(const char* prefix, const char* title,
306 UShort_t det, Char_t ring);
09b6c804 307 /**
308 * Make a summary
309 *
310 */
2a082c96 311 virtual void MakeSummary(UShort_t, Char_t) { }
a31ea3ce 312
313 virtual Bool_t HaveEnough(Int_t nEvent) const;
314 virtual UShort_t GetProgress(Int_t nEvent) const;
09b6c804 315
316
317
318 static const UInt_t fgkBaseDDL = 3072; // base FMD ddl
319 //Char_t* fDiagnosticsFilename;
320 TString fDiagnosticsFilename; // name of diagnostics file
321 std::ofstream fOutputFile; // output file
322 std::ofstream fConditionsFile; // conditions file
323 Bool_t fSaveHistograms; // save hists or not
324 Bool_t fMakeSummaries; // save hists or not
325 TObjArray fDetectorArray; // array indiced by detector
326 TArrayS fPulseSize; // Pulse size for gain calib
327 TArrayS fPulseLength; // Pulse length for gain calib
328 Bool_t fSeenDetectors[3]; // Detectors seen so far
a31ea3ce 329 UInt_t fNEventsPerDetector[3];// # events per detector
09b6c804 330 Int_t fRequiredEvents; // # events required for this calib
331 Int_t fCurrentEvent; // the current event
332 UInt_t fRunno; // Current run number
333 TObjArray fSummaries; // Summary histograms
91c99839 334 Bool_t fAll; // Try to get data from all dets
427e8f99 335
6cf6e7a0 336 ClassDef(AliFMDBaseDA,0) // Base Detector algorithm for all run types
a3b36d36 337
338};
09b6c804 339//____________________________________________________________________
340inline Bool_t
341AliFMDBaseDA::HasSeenDetector(UShort_t d) const
342{
343 return (d == 0 || d > 3) ? false : fSeenDetectors[d-1];
344}
345
a3b36d36 346#endif
347