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