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;
37 class AliFMDBaseDA: public TNamed
50 AliFMDBaseDA(const AliFMDBaseDA & baseDA) ;
51 // AliFMDBaseDA& operator = (const AliFMDBaseDA & baseDA) ;
60 * @param fmdReader Raw input reader
62 void Run(AliRawReader* fmdReader);
64 * Set whether to save diagnostics
66 * @param save If true, will output diagnostics file
68 void SetSaveDiagnostics(Bool_t save) {fSaveHistograms = save;}
70 * Set the number of requried events
72 * @param nEvents Number of event we need
74 void SetRequiredEvents(Int_t nEvents) {fRequiredEvents = nEvents;}
76 * Get the number of required events
79 * @return number of required events
81 Int_t GetRequiredEvents() const {return fRequiredEvents ;}
87 virtual void Init() {};
92 virtual void FillChannels(AliFMDDigit* ) {};
94 * Analyse a single strip result
97 virtual void Analyse(UShort_t, Char_t, UShort_t, UShort_t ) {};
99 * Write header to output file
102 virtual void WriteHeaderToFile() {};
104 * Add a strip container
107 virtual void AddChannelContainer(TObjArray*, UShort_t, Char_t,
108 UShort_t, UShort_t ) {};
113 virtual void FinishEvent() {};
118 virtual void Terminate(TFile* ) {};
120 * Current event number
125 Int_t GetCurrentEvent() const {return fCurrentEvent;}
127 * Rotate a set of files. @a base is the basic name of the files.
128 * If the file @a base.max exists it is removed.
129 * If the file @a base.n exists (where n < max) it is renamed to @a
131 * If the file @a base exists, it is renamed to @a base.1
133 * @param base Base name of the files
134 * @param max Maximum number to keep (minus one for the current).
136 void Rotate(const char* base, int max) const;
137 static const UInt_t fgkBaseDDL = 3072; // base FMD ddl
138 //Char_t* fDiagnosticsFilename;
139 TString fDiagnosticsFilename; // name of diagnostics file
140 std::ofstream fOutputFile; // output file
141 std::ofstream fConditionsFile; // conditions file
142 Bool_t fSaveHistograms; // save hists or not
143 TObjArray fDetectorArray; // array indiced by detector
145 * Ge the half-ring index
153 Int_t GetHalfringIndex(UShort_t, Char_t, UShort_t) const;
157 * @param det Detector number
158 * @param ring Rin identifier
159 * @param board Board number
161 * @return Pulse step size
163 Int_t GetPulseSize(UShort_t det ,
167 return fPulseSize.At(GetHalfringIndex(det,ring,board));
170 * Get number of events per pulse size
172 * @param det Detector number
173 * @param ring Rin identifier
174 * @param board Board number
176 * @return number of events per Pulse size
178 Int_t GetPulseLength(UShort_t det,
182 return fPulseLength.At(GetHalfringIndex(det,ring,board));
186 * Get the detector path in diagnositcs file
188 * @param det Detector number
189 * @param full If true, return full path
191 * @return Path to detector
193 const char* GetDetectorPath(UShort_t det, Bool_t full=kTRUE) const;
195 * Get the ring path in diagnositcs file
197 * @param det Detector number
198 * @param ring Ring identifier
199 * @param full If true, return full path
201 * @return Path to ring
203 const char* GetRingPath(UShort_t det, Char_t ring, Bool_t full=kTRUE) const;
205 * Get the sector path in diagnositcs file
207 * @param det Detector number
208 * @param ring Ring identifier
209 * @param sec Sector number
210 * @param full If true, return full path
212 * @return Path to sector
214 const char* GetSectorPath(UShort_t det, Char_t ring, UShort_t sec,
215 Bool_t full=kTRUE) const;
217 * Get the strip path in diagnositcs file
219 * @param det Detector number
220 * @param ring Ring identifier
221 * @param sec Sector number
222 * @param str Strip number
223 * @param full If true, return full path
225 * @return Path to strip
227 const char* GetStripPath(UShort_t det, Char_t ring, UShort_t sec,
228 UShort_t str, Bool_t full=kTRUE) const;
232 TArrayS fPulseSize; // Pulse size for gain calib
233 TArrayS fPulseLength; // Pulse length for gain calib
235 Bool_t fSeenDetectors[3]; // Detectors seen so far
238 * Write conditions file
240 * @param fmdReader Raw input
242 void WriteConditionsData(AliFMDRawReader* fmdReader);
244 * Set the current event
246 * @param currentEvent
248 void SetCurrentEvent(Int_t currentEvent) {fCurrentEvent = currentEvent; }
250 * Initialize container
252 * @param dir Directory to make containers in
254 void InitContainer(TDirectory* dir);
255 Int_t fRequiredEvents; // number of events required for this calib
256 Int_t fCurrentEvent; // the current event
258 UInt_t fRunno; // Current run number
261 ClassDef(AliFMDBaseDA,0) // Base Detector algorithm for all run types