]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/AliFMDBaseDA.h
coverity
[u/mrichter/AliRoot.git] / FMD / AliFMDBaseDA.h
1 // -*- mode: C++ -*- 
2 #ifndef ALIFMDBASEDA_H
3 #define ALIFMDBASEDA_H
4
5 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights
6  * reserved. 
7  *
8  * See cxx source for full Copyright notice                               
9  */
10 //
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.
19 //
20 // Author: Hans Hjersing Dalsgaard, hans.dalsgaard@cern.ch
21 //
22
23 #include "TNamed.h"
24 #include "TObjArray.h"
25 #include "TString.h"
26 #include "TArrayS.h"
27 #include <iosfwd>
28 #include <fstream>
29 class AliFMDDigit;
30 class AliRawReader;
31 class AliFMDParameters;
32 class AliFMDRawReader;
33 class TDirectory;
34 class TH2;
35 class TFile;
36 class TClonesArray;
37
38 class AliFMDBaseDA: public TNamed 
39 {
40 public:
41   /** 
42    * Constructor 
43    * 
44    */
45   AliFMDBaseDA() ;
46   /** 
47    * Copy constructor 
48    * 
49    * @param baseDA 
50    */
51   AliFMDBaseDA(const AliFMDBaseDA & baseDA) ;
52   //  AliFMDBaseDA& operator = (const AliFMDBaseDA & baseDA) ; 
53   /** 
54    * Destructor
55    * 
56    */  
57   ~AliFMDBaseDA() ;
58   AliFMDBaseDA& operator=(const AliFMDBaseDA&) { return *this; }
59   /** 
60    * Run this DA
61    * 
62    * @param fmdReader Raw input reader
63    */  
64   void Run(AliRawReader* fmdReader);
65   /** 
66    * Set whether to save diagnostics 
67    * 
68    * @param save If true, will output diagnostics file
69    */
70   void SetSaveDiagnostics(Bool_t save) {fSaveHistograms = save;}
71   /** 
72    * Set whether to make summary histograms to be published to AMORE
73    * 
74    * @param save If true, will generate summary QA histograms
75    */
76   void SetMakeSummaries(Bool_t save) {fMakeSummaries = save;}
77   /** 
78    * Set the number of requried events
79    * 
80    * @param nEvents Number of event we need
81    */
82   void SetRequiredEvents(Int_t nEvents) {fRequiredEvents = nEvents;}
83   /** 
84    * Get the number of required events
85    * 
86    * 
87    * @return number of required events
88    */
89   Int_t GetRequiredEvents() const {return fRequiredEvents ;}
90   /** 
91    * Get list of summary histograms 
92    *
93    * @return Array of summary histograms or null if not defined 
94    */
95   const TObjArray& GetSummaries() const { return fSummaries; }
96   /** 
97    * Check if we saw data for detector 
98    * 
99    * @param det Detector number to check 
100    * @return true if the code has seen data from the detector 
101    */
102   Bool_t HasSeenDetector(UShort_t d) const;
103 protected:
104   /** 
105    * Initialize 
106    */  
107   virtual void Init()  {};
108   /** 
109    * Fill channels 
110    */
111   virtual void FillChannels(AliFMDDigit* )  {};
112   /** 
113    * Analyse a single strip result
114    */
115   virtual void Analyse(UShort_t, Char_t, UShort_t, UShort_t)  {};
116   /** 
117    * Write header to output file
118    */
119   virtual void WriteHeaderToFile()  {};
120   /** 
121    * Add a strip container 
122    */
123   virtual void AddChannelContainer(TObjArray*, UShort_t, Char_t, 
124                                    UShort_t, UShort_t )  {};
125   /** 
126    * End of event
127    */
128   virtual void FinishEvent()  {};
129   /** 
130    * End of run
131    */
132   virtual void Terminate(TFile* ) {};
133   /** 
134    * Current event number
135    * 
136    * 
137    * @return 
138    */  
139   Int_t GetCurrentEvent() const {return fCurrentEvent;}
140   /** 
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
144    * base.(n-1).  
145    * If the file @a base exists, it is renamed to @a base.1 
146    * 
147    * @param base Base name of the files
148    * @param max  Maximum number to keep (minus one for the current).
149    */
150   void Rotate(const char* base, int max) const;
151   /** 
152    * Ge the half-ring index 
153    * 
154    * @param UShort_t 
155    * @param Char_t 
156    * @param UShort_t 
157    * 
158    * @return 
159    */
160   Int_t GetHalfringIndex(UShort_t, Char_t, UShort_t) const;
161   /** 
162    * Get the pulse size 
163    * 
164    * @param det   Detector number
165    * @param ring  Rin identifier
166    * @param board Board number 
167    * 
168    * @return Pulse step size
169    */
170   Int_t GetPulseSize(UShort_t det , 
171                      Char_t ring, 
172                      UShort_t board) 
173   {
174     return fPulseSize.At(GetHalfringIndex(det,ring,board));
175   }
176   /** 
177    * Get number of events per pulse size 
178    * 
179    * @param det   Detector number
180    * @param ring  Rin identifier
181    * @param board Board number 
182    * 
183    * @return number of events per Pulse size
184    */
185   Int_t GetPulseLength(UShort_t det, 
186                        Char_t ring, 
187                        UShort_t board) 
188   {
189     return fPulseLength.At(GetHalfringIndex(det,ring,board));
190   }
191
192   /** 
193    * Get the detector path in diagnositcs file
194    * 
195    * @param det  Detector number
196    * @param full If true, return full path
197    * 
198    * @return Path to detector
199    */  
200   const char* GetDetectorPath(UShort_t det, Bool_t full=kTRUE) const;
201   /** 
202    * Get the ring path in diagnositcs file
203    * 
204    * @param det  Detector number
205    * @param ring Ring identifier 
206    * @param full If true, return full path
207    * 
208    * @return Path to ring
209    */  
210   const char* GetRingPath(UShort_t det, Char_t ring, Bool_t full=kTRUE) const;
211   /** 
212    * Get the sector path in diagnositcs file
213    * 
214    * @param det  Detector number
215    * @param ring Ring identifier 
216    * @param sec  Sector number
217    * @param full If true, return full path
218    * 
219    * @return Path to sector
220    */  
221   const char* GetSectorPath(UShort_t det, Char_t ring, UShort_t sec, 
222                             Bool_t full=kTRUE) const;
223   /** 
224    * Get the strip path in diagnositcs file
225    * 
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
231    * 
232    * @return Path to strip
233    */  
234   const char* GetStripPath(UShort_t det, Char_t ring, UShort_t sec, 
235                            UShort_t str, Bool_t full=kTRUE) const;
236   /** 
237    * Write conditions file 
238    * 
239    * @param fmdReader Raw input
240    */ 
241   void WriteConditionsData(AliFMDRawReader* fmdReader);
242   /** 
243    * Set the current event 
244    * 
245    * @param currentEvent 
246    */
247   void SetCurrentEvent(Int_t currentEvent) {fCurrentEvent = currentEvent; }
248   /** 
249    * Initialize container 
250    * 
251    * @param dir Directory to make containers in 
252    */
253   void InitContainer(TDirectory* dir);
254   /** 
255    * Utility function for defining summary histograms 
256    *
257    * @param det    Detector 
258    * @param ring   Ring identifier 
259    * @param prefix Histogram prefix 
260    * @param title  Histogram title 
261    */
262   TH2* MakeSummaryHistogram(const char* prefix, const char* title, 
263                             UShort_t det, Char_t ring);
264   /** 
265    * Make a summary
266    * 
267    */
268   virtual void  MakeSummary(UShort_t, Char_t) { }
269
270
271
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 
287   
288   ClassDef(AliFMDBaseDA,0) // Base Detector algorithm for all run types
289
290 };
291 //____________________________________________________________________
292 inline Bool_t
293 AliFMDBaseDA::HasSeenDetector(UShort_t d) const
294
295   return (d == 0 || d > 3) ? false : fSeenDetectors[d-1]; 
296 }
297
298 #endif
299