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"
25 #include "TClonesArray.h"
30 #include "AliRawReader.h"
31 #include "AliFMDDigit.h"
32 #include "AliFMDParameters.h"
35 class AliFMDRawReader;
38 class AliFMDBaseDA: public TNamed
51 AliFMDBaseDA(const AliFMDBaseDA & baseDA) ;
52 // AliFMDBaseDA& operator = (const AliFMDBaseDA & baseDA) ;
61 * @param fmdReader Raw input reader
63 void Run(AliRawReader* fmdReader);
65 * Set whether to save diagnostics
67 * @param save If true, will output diagnostics file
69 void SetSaveDiagnostics(Bool_t save) {fSaveHistograms = save;}
71 * Set whether to make summary histograms to be published to AMORE
73 * @param save If true, will generate summary QA histograms
75 void SetMakeSummaries(Bool_t save) {fMakeSummaries = save;}
77 * Set the number of requried events
79 * @param nEvents Number of event we need
81 void SetRequiredEvents(Int_t nEvents) {fRequiredEvents = nEvents;}
83 * Get the number of required events
86 * @return number of required events
88 Int_t GetRequiredEvents() const {return fRequiredEvents ;}
90 * Get list of summary histograms
92 * @return Array of summary histograms or null if not defined
94 const TObjArray& GetSummaries() const { return fSummaries; }
96 * Check if we saw data for detector
98 * @param det Detector number to check
99 * @return true if the code has seen data from the detector
101 bool HasSeenDetector(UShort_t d) { return (d == 0 || d > 3) ? false : fSeenDetectors[d-1]; }
107 virtual void Init() {};
112 virtual void FillChannels(AliFMDDigit* ) {};
114 * Analyse a single strip result
117 virtual void Analyse(UShort_t, Char_t, UShort_t, UShort_t) {};
119 * Write header to output file
122 virtual void WriteHeaderToFile() {};
124 * Add a strip container
127 virtual void AddChannelContainer(TObjArray*, UShort_t, Char_t,
128 UShort_t, UShort_t ) {};
133 virtual void FinishEvent() {};
138 virtual void Terminate(TFile* ) {};
140 * Current event number
145 Int_t GetCurrentEvent() const {return fCurrentEvent;}
147 * Rotate a set of files. @a base is the basic name of the files.
148 * If the file @a base.max exists it is removed.
149 * If the file @a base.n exists (where n < max) it is renamed to @a
151 * If the file @a base exists, it is renamed to @a base.1
153 * @param base Base name of the files
154 * @param max Maximum number to keep (minus one for the current).
156 void Rotate(const char* base, int max) const;
157 static const UInt_t fgkBaseDDL = 3072; // base FMD ddl
158 //Char_t* fDiagnosticsFilename;
159 TString fDiagnosticsFilename; // name of diagnostics file
160 std::ofstream fOutputFile; // output file
161 std::ofstream fConditionsFile; // conditions file
162 Bool_t fSaveHistograms; // save hists or not
163 Bool_t fMakeSummaries; // save hists or not
164 TObjArray fDetectorArray; // array indiced by detector
166 * Ge the half-ring index
174 Int_t GetHalfringIndex(UShort_t, Char_t, UShort_t) const;
178 * @param det Detector number
179 * @param ring Rin identifier
180 * @param board Board number
182 * @return Pulse step size
184 Int_t GetPulseSize(UShort_t det ,
188 return fPulseSize.At(GetHalfringIndex(det,ring,board));
191 * Get number of events per pulse size
193 * @param det Detector number
194 * @param ring Rin identifier
195 * @param board Board number
197 * @return number of events per Pulse size
199 Int_t GetPulseLength(UShort_t det,
203 return fPulseLength.At(GetHalfringIndex(det,ring,board));
207 * Get the detector path in diagnositcs file
209 * @param det Detector number
210 * @param full If true, return full path
212 * @return Path to detector
214 const char* GetDetectorPath(UShort_t det, Bool_t full=kTRUE) const;
216 * Get the ring path in diagnositcs file
218 * @param det Detector number
219 * @param ring Ring identifier
220 * @param full If true, return full path
222 * @return Path to ring
224 const char* GetRingPath(UShort_t det, Char_t ring, Bool_t full=kTRUE) const;
226 * Get the sector path in diagnositcs file
228 * @param det Detector number
229 * @param ring Ring identifier
230 * @param sec Sector number
231 * @param full If true, return full path
233 * @return Path to sector
235 const char* GetSectorPath(UShort_t det, Char_t ring, UShort_t sec,
236 Bool_t full=kTRUE) const;
238 * Get the strip path in diagnositcs file
240 * @param det Detector number
241 * @param ring Ring identifier
242 * @param sec Sector number
243 * @param str Strip number
244 * @param full If true, return full path
246 * @return Path to strip
248 const char* GetStripPath(UShort_t det, Char_t ring, UShort_t sec,
249 UShort_t str, Bool_t full=kTRUE) const;
253 TArrayS fPulseSize; // Pulse size for gain calib
254 TArrayS fPulseLength; // Pulse length for gain calib
256 Bool_t fSeenDetectors[3]; // Detectors seen so far
259 * Write conditions file
261 * @param fmdReader Raw input
263 void WriteConditionsData(AliFMDRawReader* fmdReader);
265 * Set the current event
267 * @param currentEvent
269 void SetCurrentEvent(Int_t currentEvent) {fCurrentEvent = currentEvent; }
271 * Initialize container
273 * @param dir Directory to make containers in
275 void InitContainer(TDirectory* dir);
276 Int_t fRequiredEvents; // number of events required for this calib
277 Int_t fCurrentEvent; // the current event
279 UInt_t fRunno; // Current run number
281 * Utility function for defining summary histograms
283 * @param det Detector
284 * @param ring Ring identifier
285 * @param prefix Histogram prefix
286 * @param title Histogram title
288 TH2* MakeSummaryHistogram(const char* prefix, const char* title,
289 UShort_t det, Char_t ring);
290 virtual void MakeSummary(UShort_t, Char_t) { }
291 TObjArray fSummaries;
293 ClassDef(AliFMDBaseDA,0) // Base Detector algorithm for all run types