]> git.uio.no Git - u/mrichter/AliRoot.git/blame - FMD/AliFMDBaseDA.h
coverity
[u/mrichter/AliRoot.git] / FMD / 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;}
2a082c96 71 /**
72 * Set whether to make summary histograms to be published to AMORE
73 *
74 * @param save If true, will generate summary QA histograms
75 */
76 void SetMakeSummaries(Bool_t save) {fMakeSummaries = save;}
6cf6e7a0 77 /**
78 * Set the number of requried events
79 *
80 * @param nEvents Number of event we need
81 */
a3b36d36 82 void SetRequiredEvents(Int_t nEvents) {fRequiredEvents = nEvents;}
6cf6e7a0 83 /**
84 * Get the number of required events
85 *
86 *
87 * @return number of required events
88 */
c5569fbc 89 Int_t GetRequiredEvents() const {return fRequiredEvents ;}
2a082c96 90 /**
91 * Get list of summary histograms
92 *
93 * @return Array of summary histograms or null if not defined
94 */
95 const TObjArray& GetSummaries() const { return fSummaries; }
96 /**
97 * Check if we saw data for detector
98 *
99 * @param det Detector number to check
100 * @return true if the code has seen data from the detector
101 */
09b6c804 102 Bool_t HasSeenDetector(UShort_t d) const;
e9c06036 103protected:
6cf6e7a0 104 /**
105 * Initialize
6cf6e7a0 106 */
26be6417 107 virtual void Init() {};
6cf6e7a0 108 /**
109 * Fill channels
6cf6e7a0 110 */
26be6417 111 virtual void FillChannels(AliFMDDigit* ) {};
6cf6e7a0 112 /**
113 * Analyse a single strip result
6cf6e7a0 114 */
2a082c96 115 virtual void Analyse(UShort_t, Char_t, UShort_t, UShort_t) {};
6cf6e7a0 116 /**
117 * Write header to output file
6cf6e7a0 118 */
26be6417 119 virtual void WriteHeaderToFile() {};
6cf6e7a0 120 /**
121 * Add a strip container
6cf6e7a0 122 */
123 virtual void AddChannelContainer(TObjArray*, UShort_t, Char_t,
124 UShort_t, UShort_t ) {};
125 /**
126 * End of event
6cf6e7a0 127 */
26be6417 128 virtual void FinishEvent() {};
6cf6e7a0 129 /**
130 * End of run
6cf6e7a0 131 */
f7f0b643 132 virtual void Terminate(TFile* ) {};
6cf6e7a0 133 /**
134 * Current event number
135 *
136 *
137 * @return
138 */
c5569fbc 139 Int_t GetCurrentEvent() const {return fCurrentEvent;}
6cf6e7a0 140 /**
141 * Rotate a set of files. @a base is the basic name of the files.
142 * If the file @a base.max exists it is removed.
143 * If the file @a base.n exists (where n < max) it is renamed to @a
144 * base.(n-1).
145 * If the file @a base exists, it is renamed to @a base.1
146 *
147 * @param base Base name of the files
148 * @param max Maximum number to keep (minus one for the current).
149 */
150 void Rotate(const char* base, int max) const;
6cf6e7a0 151 /**
152 * Ge the half-ring index
153 *
154 * @param UShort_t
155 * @param Char_t
156 * @param UShort_t
157 *
158 * @return
159 */
c5569fbc 160 Int_t GetHalfringIndex(UShort_t, Char_t, UShort_t) const;
6cf6e7a0 161 /**
162 * Get the pulse size
163 *
164 * @param det Detector number
165 * @param ring Rin identifier
166 * @param board Board number
167 *
168 * @return Pulse step size
169 */
427e8f99 170 Int_t GetPulseSize(UShort_t det ,
171 Char_t ring,
6cf6e7a0 172 UShort_t board)
173 {
174 return fPulseSize.At(GetHalfringIndex(det,ring,board));
175 }
176 /**
177 * Get number of events per pulse size
178 *
179 * @param det Detector number
180 * @param ring Rin identifier
181 * @param board Board number
182 *
183 * @return number of events per Pulse size
184 */
427e8f99 185 Int_t GetPulseLength(UShort_t det,
186 Char_t ring,
6cf6e7a0 187 UShort_t board)
188 {
189 return fPulseLength.At(GetHalfringIndex(det,ring,board));
190 }
427e8f99 191
6cf6e7a0 192 /**
193 * Get the detector path in diagnositcs file
194 *
195 * @param det Detector number
196 * @param full If true, return full path
197 *
198 * @return Path to detector
199 */
e9c06036 200 const char* GetDetectorPath(UShort_t det, Bool_t full=kTRUE) const;
6cf6e7a0 201 /**
202 * Get the ring path in diagnositcs file
203 *
204 * @param det Detector number
205 * @param ring Ring identifier
206 * @param full If true, return full path
207 *
208 * @return Path to ring
209 */
e9c06036 210 const char* GetRingPath(UShort_t det, Char_t ring, Bool_t full=kTRUE) const;
6cf6e7a0 211 /**
212 * Get the sector path in diagnositcs file
213 *
214 * @param det Detector number
215 * @param ring Ring identifier
216 * @param sec Sector number
217 * @param full If true, return full path
218 *
219 * @return Path to sector
220 */
e9c06036 221 const char* GetSectorPath(UShort_t det, Char_t ring, UShort_t sec,
222 Bool_t full=kTRUE) const;
6cf6e7a0 223 /**
224 * Get the strip path in diagnositcs file
225 *
226 * @param det Detector number
227 * @param ring Ring identifier
228 * @param sec Sector number
229 * @param str Strip number
230 * @param full If true, return full path
231 *
232 * @return Path to strip
233 */
e9c06036 234 const char* GetStripPath(UShort_t det, Char_t ring, UShort_t sec,
235 UShort_t str, Bool_t full=kTRUE) const;
6cf6e7a0 236 /**
237 * Write conditions file
238 *
239 * @param fmdReader Raw input
240 */
3effc6e7 241 void WriteConditionsData(AliFMDRawReader* fmdReader);
6cf6e7a0 242 /**
243 * Set the current event
244 *
245 * @param currentEvent
246 */
a3b36d36 247 void SetCurrentEvent(Int_t currentEvent) {fCurrentEvent = currentEvent; }
6cf6e7a0 248 /**
249 * Initialize container
250 *
251 * @param dir Directory to make containers in
252 */
e9c06036 253 void InitContainer(TDirectory* dir);
2a082c96 254 /**
255 * Utility function for defining summary histograms
256 *
257 * @param det Detector
258 * @param ring Ring identifier
259 * @param prefix Histogram prefix
260 * @param title Histogram title
261 */
262 TH2* MakeSummaryHistogram(const char* prefix, const char* title,
263 UShort_t det, Char_t ring);
09b6c804 264 /**
265 * Make a summary
266 *
267 */
2a082c96 268 virtual void MakeSummary(UShort_t, Char_t) { }
09b6c804 269
270
271
272 static const UInt_t fgkBaseDDL = 3072; // base FMD ddl
273 //Char_t* fDiagnosticsFilename;
274 TString fDiagnosticsFilename; // name of diagnostics file
275 std::ofstream fOutputFile; // output file
276 std::ofstream fConditionsFile; // conditions file
277 Bool_t fSaveHistograms; // save hists or not
278 Bool_t fMakeSummaries; // save hists or not
279 TObjArray fDetectorArray; // array indiced by detector
280 TArrayS fPulseSize; // Pulse size for gain calib
281 TArrayS fPulseLength; // Pulse length for gain calib
282 Bool_t fSeenDetectors[3]; // Detectors seen so far
283 Int_t fRequiredEvents; // # events required for this calib
284 Int_t fCurrentEvent; // the current event
285 UInt_t fRunno; // Current run number
286 TObjArray fSummaries; // Summary histograms
427e8f99 287
6cf6e7a0 288 ClassDef(AliFMDBaseDA,0) // Base Detector algorithm for all run types
a3b36d36 289
290};
09b6c804 291//____________________________________________________________________
292inline Bool_t
293AliFMDBaseDA::HasSeenDetector(UShort_t d) const
294{
295 return (d == 0 || d > 3) ? false : fSeenDetectors[d-1];
296}
297
a3b36d36 298#endif
299