]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/AliFMDBaseDA.h
first working version of the DCSPublisher
[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 "TClonesArray.h"
26 #include "TFile.h"
27 #include "iostream"
28 #include "fstream"
29 #include "TString.h"
30 #include "AliRawReader.h"
31 #include "AliFMDDigit.h"
32 #include "AliFMDParameters.h"
33 #include "TArrayS.h"
34 class TDirectory;
35 class AliFMDRawReader;
36
37 class AliFMDBaseDA: public TNamed 
38 {
39 public:
40   /** 
41    * Constructor 
42    * 
43    */
44   AliFMDBaseDA() ;
45   /** 
46    * Copy constructor 
47    * 
48    * @param baseDA 
49    */
50   AliFMDBaseDA(const AliFMDBaseDA & baseDA) ;
51   //  AliFMDBaseDA& operator = (const AliFMDBaseDA & baseDA) ; 
52   /** 
53    * Destructor
54    * 
55    */  
56   ~AliFMDBaseDA() ;
57   /** 
58    * Run this DA
59    * 
60    * @param fmdReader Raw input reader
61    */  
62   void Run(AliRawReader* fmdReader);
63   /** 
64    * Set whether to save diagnostics 
65    * 
66    * @param save If true, will output diagnostics file
67    */
68   void SetSaveDiagnostics(Bool_t save) {fSaveHistograms = save;}
69   /** 
70    * Set the number of requried events
71    * 
72    * @param nEvents Number of event we need
73    */
74   void SetRequiredEvents(Int_t nEvents) {fRequiredEvents = nEvents;}
75   /** 
76    * Get the number of required events
77    * 
78    * 
79    * @return number of required events
80    */
81   Int_t GetRequiredEvents() const {return fRequiredEvents ;}
82 protected:
83   /** 
84    * Initialize 
85    * 
86    */  
87   virtual void Init()  {};
88   /** 
89    * Fill channels 
90    * 
91    */
92   virtual void FillChannels(AliFMDDigit* )  {};
93   /** 
94    * Analyse a single strip result
95    * 
96    */
97   virtual void Analyse(UShort_t, Char_t, UShort_t, UShort_t )  {};
98   /** 
99    * Write header to output file
100    * 
101    */
102   virtual void WriteHeaderToFile()  {};
103   /** 
104    * Add a strip container 
105    * 
106    */
107   virtual void AddChannelContainer(TObjArray*, UShort_t, Char_t, 
108                                    UShort_t, UShort_t )  {};
109   /** 
110    * End of event
111    * 
112    */
113   virtual void FinishEvent()  {};
114   /** 
115    * End of run
116    * 
117    */
118   virtual void Terminate(TFile* ) {};
119   /** 
120    * Current event number
121    * 
122    * 
123    * @return 
124    */  
125   Int_t GetCurrentEvent() const {return fCurrentEvent;}
126   /** 
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
130    * base.(n-1).  
131    * If the file @a base exists, it is renamed to @a base.1 
132    * 
133    * @param base Base name of the files
134    * @param max  Maximum number to keep (minus one for the current).
135    */
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
144   /** 
145    * Ge the half-ring index 
146    * 
147    * @param UShort_t 
148    * @param Char_t 
149    * @param UShort_t 
150    * 
151    * @return 
152    */
153   Int_t GetHalfringIndex(UShort_t, Char_t, UShort_t) const;
154   /** 
155    * Get the pulse size 
156    * 
157    * @param det   Detector number
158    * @param ring  Rin identifier
159    * @param board Board number 
160    * 
161    * @return Pulse step size
162    */
163   Int_t GetPulseSize(UShort_t det , 
164                      Char_t ring, 
165                      UShort_t board) 
166   {
167     return fPulseSize.At(GetHalfringIndex(det,ring,board));
168   }
169   /** 
170    * Get number of events per pulse size 
171    * 
172    * @param det   Detector number
173    * @param ring  Rin identifier
174    * @param board Board number 
175    * 
176    * @return number of events per Pulse size
177    */
178   Int_t GetPulseLength(UShort_t det, 
179                        Char_t ring, 
180                        UShort_t board) 
181   {
182     return fPulseLength.At(GetHalfringIndex(det,ring,board));
183   }
184
185   /** 
186    * Get the detector path in diagnositcs file
187    * 
188    * @param det  Detector number
189    * @param full If true, return full path
190    * 
191    * @return Path to detector
192    */  
193   const char* GetDetectorPath(UShort_t det, Bool_t full=kTRUE) const;
194   /** 
195    * Get the ring path in diagnositcs file
196    * 
197    * @param det  Detector number
198    * @param ring Ring identifier 
199    * @param full If true, return full path
200    * 
201    * @return Path to ring
202    */  
203   const char* GetRingPath(UShort_t det, Char_t ring, Bool_t full=kTRUE) const;
204   /** 
205    * Get the sector path in diagnositcs file
206    * 
207    * @param det  Detector number
208    * @param ring Ring identifier 
209    * @param sec  Sector number
210    * @param full If true, return full path
211    * 
212    * @return Path to sector
213    */  
214   const char* GetSectorPath(UShort_t det, Char_t ring, UShort_t sec, 
215                             Bool_t full=kTRUE) const;
216   /** 
217    * Get the strip path in diagnositcs file
218    * 
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
224    * 
225    * @return Path to strip
226    */  
227   const char* GetStripPath(UShort_t det, Char_t ring, UShort_t sec, 
228                            UShort_t str, Bool_t full=kTRUE) const;
229   
230
231   
232   TArrayS fPulseSize;                     // Pulse size for gain calib
233   TArrayS fPulseLength;                   // Pulse length for gain calib
234
235   Bool_t  fSeenDetectors[3];              // Detectors seen so far
236 private:
237   /** 
238    * Write conditions file 
239    * 
240    * @param fmdReader Raw input
241    */ 
242   void WriteConditionsData(AliFMDRawReader* fmdReader);
243   /** 
244    * Set the current event 
245    * 
246    * @param currentEvent 
247    */
248   void SetCurrentEvent(Int_t currentEvent) {fCurrentEvent = currentEvent; }
249   /** 
250    * Initialize container 
251    * 
252    * @param dir Directory to make containers in 
253    */
254   void InitContainer(TDirectory* dir);
255   Int_t fRequiredEvents;            // number of events required for this calib
256   Int_t fCurrentEvent;              // the current event       
257 protected:
258   UInt_t fRunno;                    // Current run number 
259   
260   
261   ClassDef(AliFMDBaseDA,0) // Base Detector algorithm for all run types
262
263 };
264 #endif
265