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) ;
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_t HasSeenDetector(UShort_t d) const;
106 virtual void Init() {};
110 virtual void FillChannels(AliFMDDigit* ) {};
112 * Analyse a single strip result
114 virtual void Analyse(UShort_t, Char_t, UShort_t, UShort_t) {};
116 * Write header to output file
118 virtual void WriteHeaderToFile() {};
120 * Add a strip container
122 virtual void AddChannelContainer(TObjArray*, UShort_t, Char_t,
123 UShort_t, UShort_t ) {};
127 virtual void FinishEvent() {};
131 virtual void Terminate(TFile* ) {};
133 * Current event number
138 Int_t GetCurrentEvent() const {return fCurrentEvent;}
140 * Rotate a set of files. @a base is the basic name of the files.
141 * If the file @a base.max exists it is removed.
142 * If the file @a base.n exists (where n < max) it is renamed to @a
144 * If the file @a base exists, it is renamed to @a base.1
146 * @param base Base name of the files
147 * @param max Maximum number to keep (minus one for the current).
149 void Rotate(const char* base, int max) const;
151 * Ge the half-ring index
159 Int_t GetHalfringIndex(UShort_t, Char_t, UShort_t) const;
163 * @param det Detector number
164 * @param ring Rin identifier
165 * @param board Board number
167 * @return Pulse step size
169 Int_t GetPulseSize(UShort_t det ,
173 return fPulseSize.At(GetHalfringIndex(det,ring,board));
176 * Get number of events per pulse size
178 * @param det Detector number
179 * @param ring Rin identifier
180 * @param board Board number
182 * @return number of events per Pulse size
184 Int_t GetPulseLength(UShort_t det,
188 return fPulseLength.At(GetHalfringIndex(det,ring,board));
192 * Get the detector path in diagnositcs file
194 * @param det Detector number
195 * @param full If true, return full path
197 * @return Path to detector
199 const char* GetDetectorPath(UShort_t det, Bool_t full=kTRUE) const;
201 * Get the ring path in diagnositcs file
203 * @param det Detector number
204 * @param ring Ring identifier
205 * @param full If true, return full path
207 * @return Path to ring
209 const char* GetRingPath(UShort_t det, Char_t ring, Bool_t full=kTRUE) const;
211 * Get the sector path in diagnositcs file
213 * @param det Detector number
214 * @param ring Ring identifier
215 * @param sec Sector number
216 * @param full If true, return full path
218 * @return Path to sector
220 const char* GetSectorPath(UShort_t det, Char_t ring, UShort_t sec,
221 Bool_t full=kTRUE) const;
223 * Get the strip path in diagnositcs file
225 * @param det Detector number
226 * @param ring Ring identifier
227 * @param sec Sector number
228 * @param str Strip number
229 * @param full If true, return full path
231 * @return Path to strip
233 const char* GetStripPath(UShort_t det, Char_t ring, UShort_t sec,
234 UShort_t str, Bool_t full=kTRUE) const;
236 * Write conditions file
238 * @param fmdReader Raw input
240 void WriteConditionsData(AliFMDRawReader* fmdReader);
242 * Set the current event
244 * @param currentEvent
246 void SetCurrentEvent(Int_t currentEvent) {fCurrentEvent = currentEvent; }
248 * Initialize container
250 * @param dir Directory to make containers in
252 void InitContainer(TDirectory* dir);
254 * Utility function for defining summary histograms
256 * @param det Detector
257 * @param ring Ring identifier
258 * @param prefix Histogram prefix
259 * @param title Histogram title
261 TH2* MakeSummaryHistogram(const char* prefix, const char* title,
262 UShort_t det, Char_t ring);
267 virtual void MakeSummary(UShort_t, Char_t) { }
271 static const UInt_t fgkBaseDDL = 3072; // base FMD ddl
272 //Char_t* fDiagnosticsFilename;
273 TString fDiagnosticsFilename; // name of diagnostics file
274 std::ofstream fOutputFile; // output file
275 std::ofstream fConditionsFile; // conditions file
276 Bool_t fSaveHistograms; // save hists or not
277 Bool_t fMakeSummaries; // save hists or not
278 TObjArray fDetectorArray; // array indiced by detector
279 TArrayS fPulseSize; // Pulse size for gain calib
280 TArrayS fPulseLength; // Pulse length for gain calib
281 Bool_t fSeenDetectors[3]; // Detectors seen so far
282 Int_t fRequiredEvents; // # events required for this calib
283 Int_t fCurrentEvent; // the current event
284 UInt_t fRunno; // Current run number
285 TObjArray fSummaries; // Summary histograms
287 ClassDef(AliFMDBaseDA,0) // Base Detector algorithm for all run types
290 //____________________________________________________________________
292 AliFMDBaseDA::HasSeenDetector(UShort_t d) const
294 return (d == 0 || d > 3) ? false : fSeenDetectors[d-1];