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 whether to make summary histograms to be published to AMORE
74 * @param save If true, will generate summary QA histograms
76 void SetMakeSummaries(Bool_t save) {fMakeSummaries = save;}
78 * Set the number of requried events
80 * @param nEvents Number of event we need
82 void SetRequiredEvents(Int_t nEvents) {fRequiredEvents = nEvents;}
84 * Get the number of required events
87 * @return number of required events
89 Int_t GetRequiredEvents() const {return fRequiredEvents ;}
91 * Get list of summary histograms
93 * @return Array of summary histograms or null if not defined
95 const TObjArray& GetSummaries() const { return fSummaries; }
97 * Check if we saw data for detector
99 * @param det Detector number to check
100 * @return true if the code has seen data from the detector
102 Bool_t HasSeenDetector(UShort_t d) const;
107 virtual void Init() {};
111 virtual void FillChannels(AliFMDDigit* ) {};
113 * Analyse a single strip result
115 virtual void Analyse(UShort_t, Char_t, UShort_t, UShort_t) {};
117 * Write header to output file
119 virtual void WriteHeaderToFile() {};
121 * Add a strip container
123 virtual void AddChannelContainer(TObjArray*, UShort_t, Char_t,
124 UShort_t, UShort_t ) {};
128 virtual void FinishEvent() {};
132 virtual void Terminate(TFile* ) {};
134 * Current event number
139 Int_t GetCurrentEvent() const {return fCurrentEvent;}
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
145 * If the file @a base exists, it is renamed to @a base.1
147 * @param base Base name of the files
148 * @param max Maximum number to keep (minus one for the current).
150 void Rotate(const char* base, int max) const;
152 * Ge the half-ring index
160 Int_t GetHalfringIndex(UShort_t, Char_t, UShort_t) const;
164 * @param det Detector number
165 * @param ring Rin identifier
166 * @param board Board number
168 * @return Pulse step size
170 Int_t GetPulseSize(UShort_t det ,
174 return fPulseSize.At(GetHalfringIndex(det,ring,board));
177 * Get number of events per pulse size
179 * @param det Detector number
180 * @param ring Rin identifier
181 * @param board Board number
183 * @return number of events per Pulse size
185 Int_t GetPulseLength(UShort_t det,
189 return fPulseLength.At(GetHalfringIndex(det,ring,board));
193 * Get the detector path in diagnositcs file
195 * @param det Detector number
196 * @param full If true, return full path
198 * @return Path to detector
200 const char* GetDetectorPath(UShort_t det, Bool_t full=kTRUE) const;
202 * Get the ring path in diagnositcs file
204 * @param det Detector number
205 * @param ring Ring identifier
206 * @param full If true, return full path
208 * @return Path to ring
210 const char* GetRingPath(UShort_t det, Char_t ring, Bool_t full=kTRUE) const;
212 * Get the sector path in diagnositcs file
214 * @param det Detector number
215 * @param ring Ring identifier
216 * @param sec Sector number
217 * @param full If true, return full path
219 * @return Path to sector
221 const char* GetSectorPath(UShort_t det, Char_t ring, UShort_t sec,
222 Bool_t full=kTRUE) const;
224 * Get the strip path in diagnositcs file
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
232 * @return Path to strip
234 const char* GetStripPath(UShort_t det, Char_t ring, UShort_t sec,
235 UShort_t str, Bool_t full=kTRUE) const;
237 * Write conditions file
239 * @param fmdReader Raw input
241 void WriteConditionsData(AliFMDRawReader* fmdReader);
243 * Set the current event
245 * @param currentEvent
247 void SetCurrentEvent(Int_t currentEvent) {fCurrentEvent = currentEvent; }
249 * Initialize container
251 * @param dir Directory to make containers in
253 void InitContainer(TDirectory* dir);
255 * Utility function for defining summary histograms
257 * @param det Detector
258 * @param ring Ring identifier
259 * @param prefix Histogram prefix
260 * @param title Histogram title
262 TH2* MakeSummaryHistogram(const char* prefix, const char* title,
263 UShort_t det, Char_t ring);
268 virtual void MakeSummary(UShort_t, Char_t) { }
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
288 ClassDef(AliFMDBaseDA,0) // Base Detector algorithm for all run types
291 //____________________________________________________________________
293 AliFMDBaseDA::HasSeenDetector(UShort_t d) const
295 return (d == 0 || d > 3) ? false : fSeenDetectors[d-1];