]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/AliFMDPedestalDA.h
Savannah 96506
[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   /** 
53    * Add a channel to the containers. 
54    * 
55    * @param sectorArray  Array of sectors
56    * @param det          Detector 
57    * @param ring         Ring
58    * @param sec          Sector 
59    * @param strip        Strip
60    */
61   void AddChannelContainer(TObjArray* sectorArray, UShort_t det, 
62                            Char_t ring, UShort_t sec, UShort_t strip);
63   /** 
64    * Fill ADC values from a digit into the corresponding histogram.
65    * 
66    * @param digit Digit to fill ADC values for.
67    */
68   void FillChannels(AliFMDDigit* digit);
69   /** 
70    * Analyse a strip.  That is, compute the mean and spread of the ADC
71    * spectra for all strips.  Also output on files the values. 
72    * 
73    * @param det   Detector
74    * @param ring  Ring
75    * @param sec   Sector 
76    * @param strip Strip.
77    * @param h     Summary histogram with bins for sector and strip
78    */
79   void Analyse(UShort_t det, Char_t ring, UShort_t sec, UShort_t strip);
80   /** 
81    * Write headers to files. 
82    * 
83    */  
84   void WriteHeaderToFile();
85   /** 
86    * Called at the end of an event.
87    * 
88    */  
89   void FinishEvent() {}
90   /** 
91    * Called at the end of a job.  Fills in missing time-bins and
92    * closes output files  
93    * 
94    */  
95   void Terminate(TFile* );
96 private:
97   /** 
98    * Get the histogram corresponding to a strip sample.
99    * 
100    * @param det    Detector
101    * @param ring   Ring
102    * @param sec    Sector
103    * @param strip  Strip
104    * @param sample Sample
105    * 
106    * @return ADC spectra of a strip.
107    */
108   TH1S* GetChannel(UShort_t det, Char_t ring, UShort_t sec, 
109                    UShort_t strip, UInt_t sample);
110   /** 
111    * Calculate the hardware index
112    * 
113    * @param ddl    DDL number
114    * @param board  Board number
115    * @param altro  ALTRO number
116    * @param chan   Channel number
117    * 
118    * @return Index into hardware cache.
119    */
120   Int_t HWIndex(UShort_t ddl, UShort_t board, UShort_t altro, 
121                 UShort_t chan) const;
122   void FillinTimebins(std::ofstream& out, UShort_t ddl);
123   /** Current strip */ 
124   Int_t fCurrentChannel;                           //The current channel
125   /** Pedestal summary */ 
126   TH1F  fPedSummary;                               //Summary of pedestals
127   /** Noise summary */
128   TH1F  fNoiseSummary;                             //Summary of noises
129   /** Output file for zero-suppression for FMD1 */
130   std::ofstream fZSfileFMD1;                       //Stream for ZS FMD1
131   /** Output file for zero-suppression for FMD2 */
132   std::ofstream fZSfileFMD2;                       //Stream for ZS FMD2
133   /** Output file for zero-suppression for FMD3 */
134   std::ofstream fZSfileFMD3;                       //Stream for ZS FMD3 
135   /** The minimum timebin seen for all channels */
136   TArrayS fMinTimebin;                             //minimum timebin
137   /** The maximum timebin seen for all channels */
138   TArrayS fMaxTimebin;                             //maximum timebin
139   
140   void  MakeSummary(UShort_t det, Char_t ring);
141
142   TH2* fSummaryFMD1i;                              //Summary of FMD1
143   TH2* fSummaryFMD2i;                              //Summary of FMD2I 
144   TH2* fSummaryFMD2o;                              //Summary of FMD2O
145   TH2* fSummaryFMD3i;                              //Summary of FMD3I
146   TH2* fSummaryFMD3o;                              //Summary of FMD3O
147   
148   ClassDef(AliFMDPedestalDA,0)
149 };
150
151 inline Int_t
152 AliFMDPedestalDA::HWIndex(UShort_t ddl, UShort_t b, 
153                           UShort_t a, UShort_t c) const
154 {
155   // Save some array entries 
156   UShort_t lb = (b > 1 ? b-16+2 : b);
157   const Int_t kNDDL     = 3;
158   const Int_t kNBoard   = 4;
159   const Int_t kNAltro   = 3;
160   const Int_t kNChannel = 16;
161   Int_t idx =  c + kNChannel * (a + kNAltro * (lb + kNBoard * ddl));
162   if (idx > kNDDL * kNBoard * kNAltro * kNChannel) return -1;
163   return idx;
164 }
165
166 #endif
167 //
168 // Local Variables:
169 //  mode: C++
170 // End:
171 //