]> git.uio.no Git - u/mrichter/AliRoot.git/blame_incremental - FMD/AliFMDBaseDA.h
Compilation with Root6
[u/mrichter/AliRoot.git] / FMD / AliFMDBaseDA.h
... / ...
CommitLineData
1// -*- mode: C++ -*-
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//
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.
19//
20// Author: Hans Hjersing Dalsgaard, hans.dalsgaard@cern.ch
21//
22
23#include "TNamed.h"
24#include "TObjArray.h"
25#include "TString.h"
26#include "TArrayS.h"
27#include <iosfwd>
28#include <fstream>
29class AliFMDDigit;
30class AliRawReader;
31class AliFMDParameters;
32class AliFMDRawReader;
33class TDirectory;
34class TH2;
35class TFile;
36class TClonesArray;
37
38class AliFMDBaseDA: public TNamed
39{
40public:
41 /**
42 * Constructor
43 *
44 */
45 AliFMDBaseDA() ;
46 /**
47 * Copy constructor
48 *
49 * @param baseDA
50 */
51 AliFMDBaseDA(const AliFMDBaseDA & baseDA) ;
52 // AliFMDBaseDA& operator = (const AliFMDBaseDA & baseDA) ;
53 /**
54 * Destructor
55 *
56 */
57 ~AliFMDBaseDA() ;
58 AliFMDBaseDA& operator=(const AliFMDBaseDA&) { return *this; }
59 /**
60 * Run this DA
61 *
62 * @param fmdReader Raw input reader
63 */
64 void Run(AliRawReader* fmdReader);
65 /**
66 * Set whether to save diagnostics
67 *
68 * @param save If true, will output diagnostics file
69 */
70 void SetSaveDiagnostics(Bool_t save) {fSaveHistograms = save;}
71 /**
72 * Set the diagnostics file name
73 *
74 * @param f Diagnostics file name
75 */
76 void SetDiagnosticsFilename(const TString& f) { fDiagnosticsFilename = f; }
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;}
83 /**
84 * Set the number of requried events
85 *
86 * @param nEvents Number of event we need
87 */
88 void SetRequiredEvents(Int_t nEvents) {fRequiredEvents = nEvents;}
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; }
95 /**
96 * Get the number of required events
97 *
98 *
99 * @return number of required events
100 */
101 Int_t GetRequiredEvents() const {return fRequiredEvents ;}
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 */
114 Bool_t HasSeenDetector(UShort_t d) const;
115
116 /**
117 * Class to run the DAs
118 */
119 struct Runner {
120 Runner();
121 Runner(const Runner&)
122 : fReader(0), fDiagFile(""), fDiag(false), fAll(false) {}
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;
133 Bool_t fAll;
134 };
135protected:
136 /**
137 * Initialize
138 */
139 virtual void Init() {};
140 /**
141 * Fill channels
142 */
143 virtual void FillChannels(AliFMDDigit* ) {};
144 /**
145 * Analyse a single strip result
146 */
147 virtual void Analyse(UShort_t, Char_t, UShort_t, UShort_t) {};
148 /**
149 * Write header to output file
150 */
151 virtual void WriteHeaderToFile() {};
152 /**
153 * Add a strip container
154 */
155 virtual void AddChannelContainer(TObjArray*, UShort_t, Char_t,
156 UShort_t, UShort_t ) {};
157 /**
158 * Add summary(s) for sectors
159 *
160 */
161 virtual void AddSectorSummary(TObjArray*, UShort_t, Char_t, UShort_t,
162 UShort_t) {}
163 /**
164 * End of event
165 */
166 virtual void FinishEvent() {};
167 /**
168 * End of run
169 */
170 virtual void Terminate(TFile* ) {};
171 /**
172 * Current event number
173 *
174 *
175 * @return
176 */
177 Int_t GetCurrentEvent() const {return fCurrentEvent;}
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;
189 /**
190 * Ge the half-ring index
191 *
192 * @param UShort_t
193 * @param Char_t
194 * @param UShort_t
195 *
196 * @return
197 */
198 Int_t GetHalfringIndex(UShort_t, Char_t, UShort_t) const;
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 */
208 Int_t GetPulseSize(UShort_t det ,
209 Char_t ring,
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 */
223 Int_t GetPulseLength(UShort_t det,
224 Char_t ring,
225 UShort_t board)
226 {
227 return fPulseLength.At(GetHalfringIndex(det,ring,board));
228 }
229
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 */
238 const char* GetDetectorPath(UShort_t det, Bool_t full=kTRUE) const;
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 */
248 const char* GetRingPath(UShort_t det, Char_t ring, Bool_t full=kTRUE) const;
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 */
259 const char* GetSectorPath(UShort_t det, Char_t ring, UShort_t sec,
260 Bool_t full=kTRUE) const;
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 */
272 const char* GetStripPath(UShort_t det, Char_t ring, UShort_t sec,
273 UShort_t str, Bool_t full=kTRUE) const;
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);
279 /**
280 * Write conditions file
281 *
282 * @param fmdReader Raw input
283 */
284 void WriteConditionsData(AliFMDRawReader* fmdReader);
285 /**
286 * Set the current event
287 *
288 * @param currentEvent
289 */
290 void SetCurrentEvent(Int_t currentEvent) {fCurrentEvent = currentEvent; }
291 /**
292 * Initialize container
293 *
294 * @param dir Directory to make containers in
295 */
296 virtual void InitContainer(TDirectory* dir);
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);
307 /**
308 * Make a summary
309 *
310 */
311 virtual void MakeSummary(UShort_t, Char_t) { }
312
313 virtual Bool_t HaveEnough(Int_t nEvent) const;
314 virtual UShort_t GetProgress(Int_t nEvent) const;
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
329 UInt_t fNEventsPerDetector[3];// # events per detector
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
334 Bool_t fAll; // Try to get data from all dets
335
336 ClassDef(AliFMDBaseDA,0) // Base Detector algorithm for all run types
337
338};
339//____________________________________________________________________
340inline Bool_t
341AliFMDBaseDA::HasSeenDetector(UShort_t d) const
342{
343 return (d == 0 || d > 3) ? false : fSeenDetectors[d-1];
344}
345
346#endif
347