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 * Set whether we should try to get all detectors
92 * @param all If true, try to get all detectors
94 void SetTryAll(Bool_t all=true) { fAll = all; }
96 * Get the number of required events
99 * @return number of required events
101 Int_t GetRequiredEvents() const {return fRequiredEvents ;}
103 * Get list of summary histograms
105 * @return Array of summary histograms or null if not defined
107 const TObjArray& GetSummaries() const { return fSummaries; }
109 * Check if we saw data for detector
111 * @param det Detector number to check
112 * @return true if the code has seen data from the detector
114 Bool_t HasSeenDetector(UShort_t d) const;
117 * Class to run the DAs
121 Runner(const Runner&)
122 : fReader(0), fDiagFile(""), fDiag(false), fAll(false) {}
124 Runner& operator=(const Runner&) { return *this; }
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;
139 virtual void Init() {};
143 virtual void FillChannels(AliFMDDigit* ) {};
145 * Analyse a single strip result
147 virtual void Analyse(UShort_t, Char_t, UShort_t, UShort_t) {};
149 * Write header to output file
151 virtual void WriteHeaderToFile() {};
153 * Add a strip container
155 virtual void AddChannelContainer(TObjArray*, UShort_t, Char_t,
156 UShort_t, UShort_t ) {};
158 * Add summary(s) for sectors
161 virtual void AddSectorSummary(TObjArray*, UShort_t, Char_t, UShort_t,
166 virtual void FinishEvent() {};
170 virtual void Terminate(TFile* ) {};
172 * Current event number
177 Int_t GetCurrentEvent() const {return fCurrentEvent;}
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
183 * If the file @a base exists, it is renamed to @a base.1
185 * @param base Base name of the files
186 * @param max Maximum number to keep (minus one for the current).
188 void Rotate(const char* base, int max) const;
190 * Ge the half-ring index
198 Int_t GetHalfringIndex(UShort_t, Char_t, UShort_t) const;
202 * @param det Detector number
203 * @param ring Rin identifier
204 * @param board Board number
206 * @return Pulse step size
208 Int_t GetPulseSize(UShort_t det ,
212 return fPulseSize.At(GetHalfringIndex(det,ring,board));
215 * Get number of events per pulse size
217 * @param det Detector number
218 * @param ring Rin identifier
219 * @param board Board number
221 * @return number of events per Pulse size
223 Int_t GetPulseLength(UShort_t det,
227 return fPulseLength.At(GetHalfringIndex(det,ring,board));
231 * Get the detector path in diagnositcs file
233 * @param det Detector number
234 * @param full If true, return full path
236 * @return Path to detector
238 const char* GetDetectorPath(UShort_t det, Bool_t full=kTRUE) const;
240 * Get the ring path in diagnositcs file
242 * @param det Detector number
243 * @param ring Ring identifier
244 * @param full If true, return full path
246 * @return Path to ring
248 const char* GetRingPath(UShort_t det, Char_t ring, Bool_t full=kTRUE) const;
250 * Get the sector path in diagnositcs file
252 * @param det Detector number
253 * @param ring Ring identifier
254 * @param sec Sector number
255 * @param full If true, return full path
257 * @return Path to sector
259 const char* GetSectorPath(UShort_t det, Char_t ring, UShort_t sec,
260 Bool_t full=kTRUE) const;
262 * Get the strip path in diagnositcs file
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
270 * @return Path to strip
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);
280 * Write conditions file
282 * @param fmdReader Raw input
284 void WriteConditionsData(AliFMDRawReader* fmdReader);
286 * Set the current event
288 * @param currentEvent
290 void SetCurrentEvent(Int_t currentEvent) {fCurrentEvent = currentEvent; }
292 * Initialize container
294 * @param dir Directory to make containers in
296 virtual void InitContainer(TDirectory* dir);
298 * Utility function for defining summary histograms
300 * @param det Detector
301 * @param ring Ring identifier
302 * @param prefix Histogram prefix
303 * @param title Histogram title
305 TH2* MakeSummaryHistogram(const char* prefix, const char* title,
306 UShort_t det, Char_t ring);
311 virtual void MakeSummary(UShort_t, Char_t) { }
313 virtual Bool_t HaveEnough(Int_t nEvent) const;
314 virtual UShort_t GetProgress(Int_t nEvent) const;
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
336 ClassDef(AliFMDBaseDA,0) // Base Detector algorithm for all run types
339 //____________________________________________________________________
341 AliFMDBaseDA::HasSeenDetector(UShort_t d) const
343 return (d == 0 || d > 3) ? false : fSeenDetectors[d-1];