]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/AliFMDPedestalDA.h
Fix to allow new initialization of AliReconstruction (C.H.Christinsen)
[u/mrichter/AliRoot.git] / FMD / AliFMDPedestalDA.h
1 #ifndef ALIFMDPEDESTALDA_H
2 #define ALIFMDPEDESTALDA_H
3
4 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights
5  * reserved. 
6  *
7  * See cxx source for full Copyright notice                               
8  */
9 // This class implements the pedestal detector algorithm (DA) for the FMD.
10 // It uses 51200 TH1S histograms to store the data for each channel of the FMD.
11 // The mean and standard deviation of a histogram define the pedestal and 
12 // the noise for that channel.
13
14
15 #include "AliFMDBaseDA.h"
16 #include "TH1.h"
17 #include "TObjArray.h"
18 class TH2;
19
20 class AliFMDPedestalDA: public AliFMDBaseDA 
21 {
22 public:
23   /** 
24    * Constructor.
25    * 
26    */  
27   AliFMDPedestalDA();
28   /** 
29    * Copy constructor 
30    * 
31    * @param pedDA Object to copy from
32    */  
33   AliFMDPedestalDA(const AliFMDPedestalDA & pedDA);
34   /** 
35    * Assignment operator 
36    * 
37    * @param pedDA Object to assign from
38    */  
39   AliFMDPedestalDA& operator=(const AliFMDPedestalDA&) { return *this; }
40   /** 
41    * Destructor
42    * 
43    */
44   virtual ~AliFMDPedestalDA();
45   /** 
46    * Initialiser
47    * 
48    */  
49   void Init();
50  
51 protected:
52   enum { 
53     kPedestalOffset = 1, 
54     kNoiseOffset   = 2
55   };
56   /** 
57    * Add a channel to the containers. 
58    * 
59    * @param sectorArray  Array of sectors
60    * @param det          Detector 
61    * @param ring         Ring
62    * @param sec          Sector 
63    * @param strip        Strip
64    */
65   void AddChannelContainer(TObjArray* sectorArray, UShort_t det, 
66                            Char_t ring, UShort_t sec, UShort_t strip);
67   /** 
68    * Add summary(s) for sectors 
69    * 
70    * @param secArray 
71    * @param det 
72    * @param ring 
73    * @param sector 
74    * @param nStrip 
75    */
76   virtual void AddSectorSummary(TObjArray* secArray, UShort_t det, 
77                                 Char_t ring, UShort_t sector, 
78                                 UShort_t nStrip);
79   /** 
80    * Fill ADC values from a digit into the corresponding histogram.
81    * 
82    * @param digit Digit to fill ADC values for.
83    */
84   void FillChannels(AliFMDDigit* digit);
85   /** 
86    * Analyse a strip.  That is, compute the mean and spread of the ADC
87    * spectra for all strips.  Also output on files the values. 
88    * 
89    * @param det   Detector
90    * @param ring  Ring
91    * @param sec   Sector 
92    * @param strip Strip.
93    * @param h     Summary histogram with bins for sector and strip
94    */
95   void Analyse(UShort_t det, Char_t ring, UShort_t sec, UShort_t strip);
96   /** 
97    * Write headers to files. 
98    * 
99    */  
100   void WriteHeaderToFile();
101   /** 
102    * Called at the end of an event.
103    * 
104    */  
105   void FinishEvent() {}
106   /** 
107    * Called at the end of a job.  Fills in missing time-bins and
108    * closes output files  
109    * 
110    */  
111   void Terminate(TFile* );
112 private:
113   /** 
114    * Get the histogram corresponding to a strip sample.
115    * 
116    * @param det    Detector
117    * @param ring   Ring
118    * @param sec    Sector
119    * @param strip  Strip
120    * @param sample Sample
121    * 
122    * @return ADC spectra of a strip.
123    */
124   TH1S* GetChannel(UShort_t det, Char_t ring, UShort_t sec, 
125                    UShort_t strip, UInt_t sample);
126   /** 
127    * Get the summary for a sector
128    * 
129    * @param det    Detector
130    * @param ring   Ring 
131    * @param sec    Sector 
132    * @param pedNotNoise Option
133    * 
134    * @return histogram 
135    */
136   TH1F* GetSectorSummary(UShort_t det, Char_t   ring, UShort_t sec, 
137                          Bool_t   pedNotNoise);
138   /** 
139    * Calculate the hardware index
140    * 
141    * @param ddl    DDL number
142    * @param board  Board number
143    * @param altro  ALTRO number
144    * @param chan   Channel number
145    * 
146    * @return Index into hardware cache.
147    */
148   Int_t HWIndex(UShort_t ddl, UShort_t board, UShort_t altro, 
149                 UShort_t chan) const;
150   void FillinTimebins(std::ofstream& out, UShort_t ddl);
151   /** Current strip */ 
152   Int_t fCurrentChannel;                           //The current channel
153   /** Pedestal summary */ 
154   TH1F  fPedSummary;                               //Summary of pedestals
155   /** Noise summary */
156   TH1F  fNoiseSummary;                             //Summary of noises
157   /** Output file for zero-suppression for FMD1 */
158   std::ofstream fZSfileFMD1;                       //Stream for ZS FMD1
159   /** Output file for zero-suppression for FMD2 */
160   std::ofstream fZSfileFMD2;                       //Stream for ZS FMD2
161   /** Output file for zero-suppression for FMD3 */
162   std::ofstream fZSfileFMD3;                       //Stream for ZS FMD3 
163   /** The minimum timebin seen for all channels */
164   TArrayS fMinTimebin;                             //minimum timebin
165   /** The maximum timebin seen for all channels */
166   TArrayS fMaxTimebin;                             //maximum timebin
167   
168   void  MakeSummary(UShort_t det, Char_t ring);
169
170   TH2* fSummaryFMD1i;                              //Summary of FMD1
171   TH2* fSummaryFMD2i;                              //Summary of FMD2I 
172   TH2* fSummaryFMD2o;                              //Summary of FMD2O
173   TH2* fSummaryFMD3i;                              //Summary of FMD3I
174   TH2* fSummaryFMD3o;                              //Summary of FMD3O
175   
176   ClassDef(AliFMDPedestalDA,0)
177 };
178
179 inline Int_t
180 AliFMDPedestalDA::HWIndex(UShort_t ddl, UShort_t b, 
181                           UShort_t a, UShort_t c) const
182 {
183   // Save some array entries 
184   UShort_t lb = (b > 1 ? b-16+2 : b);
185   const Int_t kNDDL     = 3;
186   const Int_t kNBoard   = 4;
187   const Int_t kNAltro   = 3;
188   const Int_t kNChannel = 16;
189   Int_t idx =  c + kNChannel * (a + kNAltro * (lb + kNBoard * ddl));
190   if (idx > kNDDL * kNBoard * kNAltro * kNChannel) return -1;
191   return idx;
192 }
193
194 #endif
195 //
196 // Local Variables:
197 //  mode: C++
198 // End:
199 //