5 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights
8 * See cxx source for full Copyright notice
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.
20 // Author: Hans Hjersing Dalsgaard, hans.dalsgaard@cern.ch
24 #include "TObjArray.h"
31 class AliFMDParameters;
32 class AliFMDRawReader;
38 class AliFMDBaseDA: public TNamed
51 AliFMDBaseDA(const AliFMDBaseDA & baseDA) ;
52 // AliFMDBaseDA& operator = (const AliFMDBaseDA & baseDA) ;
58 AliFMDBaseDA& operator=(const AliFMDBaseDA&) { return *this; }
62 * @param fmdReader Raw input reader
64 void Run(AliRawReader* fmdReader);
66 * Set whether to save diagnostics
68 * @param save If true, will output diagnostics file
70 void SetSaveDiagnostics(Bool_t save) {fSaveHistograms = save;}
72 * Set the diagnostics file name
74 * @param f Diagnostics file name
76 void SetDiagnosticsFilename(const TString& f) { fDiagnosticsFilename = f; }
78 * Set whether to make summary histograms to be published to AMORE
80 * @param save If true, will generate summary QA histograms
82 void SetMakeSummaries(Bool_t save) {fMakeSummaries = save;}
84 * Set the number of requried events
86 * @param nEvents Number of event we need
88 void SetRequiredEvents(Int_t nEvents) {fRequiredEvents = nEvents;}
90 * Get the number of required events
93 * @return number of required events
95 Int_t GetRequiredEvents() const {return fRequiredEvents ;}
97 * Get list of summary histograms
99 * @return Array of summary histograms or null if not defined
101 const TObjArray& GetSummaries() const { return fSummaries; }
103 * Check if we saw data for detector
105 * @param det Detector number to check
106 * @return true if the code has seen data from the detector
108 Bool_t HasSeenDetector(UShort_t d) const;
111 * Class to run the DAs
115 Runner(const Runner&) : fReader(0), fDiagFile(""), fDiag(false) {}
117 Runner& operator=(const Runner&) { return *this; }
119 void ShowUsage(std::ostream& o, const char* progname);
120 Int_t Init(int argc, char** argv);
121 void Exec(AliFMDBaseDA& da);
122 Int_t RunNumber() const;
123 AliRawReader* fReader;
131 virtual void Init() {};
135 virtual void FillChannels(AliFMDDigit* ) {};
137 * Analyse a single strip result
139 virtual void Analyse(UShort_t, Char_t, UShort_t, UShort_t) {};
141 * Write header to output file
143 virtual void WriteHeaderToFile() {};
145 * Add a strip container
147 virtual void AddChannelContainer(TObjArray*, UShort_t, Char_t,
148 UShort_t, UShort_t ) {};
150 * Add summary(s) for sectors
153 virtual void AddSectorSummary(TObjArray*, UShort_t, Char_t, UShort_t,
158 virtual void FinishEvent() {};
162 virtual void Terminate(TFile* ) {};
164 * Current event number
169 Int_t GetCurrentEvent() const {return fCurrentEvent;}
171 * Rotate a set of files. @a base is the basic name of the files.
172 * If the file @a base.max exists it is removed.
173 * If the file @a base.n exists (where n < max) it is renamed to @a
175 * If the file @a base exists, it is renamed to @a base.1
177 * @param base Base name of the files
178 * @param max Maximum number to keep (minus one for the current).
180 void Rotate(const char* base, int max) const;
182 * Ge the half-ring index
190 Int_t GetHalfringIndex(UShort_t, Char_t, UShort_t) const;
194 * @param det Detector number
195 * @param ring Rin identifier
196 * @param board Board number
198 * @return Pulse step size
200 Int_t GetPulseSize(UShort_t det ,
204 return fPulseSize.At(GetHalfringIndex(det,ring,board));
207 * Get number of events per pulse size
209 * @param det Detector number
210 * @param ring Rin identifier
211 * @param board Board number
213 * @return number of events per Pulse size
215 Int_t GetPulseLength(UShort_t det,
219 return fPulseLength.At(GetHalfringIndex(det,ring,board));
223 * Get the detector path in diagnositcs file
225 * @param det Detector number
226 * @param full If true, return full path
228 * @return Path to detector
230 const char* GetDetectorPath(UShort_t det, Bool_t full=kTRUE) const;
232 * Get the ring path in diagnositcs file
234 * @param det Detector number
235 * @param ring Ring identifier
236 * @param full If true, return full path
238 * @return Path to ring
240 const char* GetRingPath(UShort_t det, Char_t ring, Bool_t full=kTRUE) const;
242 * Get the sector path in diagnositcs file
244 * @param det Detector number
245 * @param ring Ring identifier
246 * @param sec Sector number
247 * @param full If true, return full path
249 * @return Path to sector
251 const char* GetSectorPath(UShort_t det, Char_t ring, UShort_t sec,
252 Bool_t full=kTRUE) const;
254 * Get the strip path in diagnositcs file
256 * @param det Detector number
257 * @param ring Ring identifier
258 * @param sec Sector number
259 * @param str Strip number
260 * @param full If true, return full path
262 * @return Path to strip
264 const char* GetStripPath(UShort_t det, Char_t ring, UShort_t sec,
265 UShort_t str, Bool_t full=kTRUE) const;
266 TObjArray* GetDetectorArray(UShort_t det);
267 TObjArray* GetRingArray(UShort_t det, Char_t ring);
268 TObjArray* GetSectorArray(UShort_t det, Char_t ring, UShort_t sector);
269 TObjArray* GetStripArray(UShort_t det, Char_t ring,
270 UShort_t sector, UShort_t strip);
272 * Write conditions file
274 * @param fmdReader Raw input
276 void WriteConditionsData(AliFMDRawReader* fmdReader);
278 * Set the current event
280 * @param currentEvent
282 void SetCurrentEvent(Int_t currentEvent) {fCurrentEvent = currentEvent; }
284 * Initialize container
286 * @param dir Directory to make containers in
288 virtual void InitContainer(TDirectory* dir);
290 * Utility function for defining summary histograms
292 * @param det Detector
293 * @param ring Ring identifier
294 * @param prefix Histogram prefix
295 * @param title Histogram title
297 TH2* MakeSummaryHistogram(const char* prefix, const char* title,
298 UShort_t det, Char_t ring);
303 virtual void MakeSummary(UShort_t, Char_t) { }
305 virtual Bool_t HaveEnough(Int_t nEvent) const;
306 virtual UShort_t GetProgress(Int_t nEvent) const;
310 static const UInt_t fgkBaseDDL = 3072; // base FMD ddl
311 //Char_t* fDiagnosticsFilename;
312 TString fDiagnosticsFilename; // name of diagnostics file
313 std::ofstream fOutputFile; // output file
314 std::ofstream fConditionsFile; // conditions file
315 Bool_t fSaveHistograms; // save hists or not
316 Bool_t fMakeSummaries; // save hists or not
317 TObjArray fDetectorArray; // array indiced by detector
318 TArrayS fPulseSize; // Pulse size for gain calib
319 TArrayS fPulseLength; // Pulse length for gain calib
320 Bool_t fSeenDetectors[3]; // Detectors seen so far
321 UInt_t fNEventsPerDetector[3];// # events per detector
322 Int_t fRequiredEvents; // # events required for this calib
323 Int_t fCurrentEvent; // the current event
324 UInt_t fRunno; // Current run number
325 TObjArray fSummaries; // Summary histograms
327 ClassDef(AliFMDBaseDA,0) // Base Detector algorithm for all run types
330 //____________________________________________________________________
332 AliFMDBaseDA::HasSeenDetector(UShort_t d) const
334 return (d == 0 || d > 3) ? false : fSeenDetectors[d-1];