]> git.uio.no Git - u/mrichter/AliRoot.git/blob - FMD/AliFMDPedestalDA.h
New script to do common-mode-noise analysis of raw data.
[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
19 class AliFMDPedestalDA: public AliFMDBaseDA 
20 {
21 public:
22   /** 
23    * Constructor.
24    * 
25    */  
26   AliFMDPedestalDA();
27   /** 
28    * Copy constructor 
29    * 
30    * @param pedDA Object to copy from
31    */  
32   AliFMDPedestalDA(const AliFMDPedestalDA & pedDA);
33   //  AliFMDPedestalDA& operator = (const AliFMDPedestalDA & pedDA) ; 
34   /** 
35    * Destructor
36    * 
37    */
38   virtual ~AliFMDPedestalDA();
39   /** 
40    * Initialiser
41    * 
42    */  
43   void Init();
44  
45 protected:
46   /** 
47    * Add a channel to the containers. 
48    * 
49    * @param sectorArray  Array of sectors
50    * @param det          Detector 
51    * @param ring         Ring
52    * @param sec          Sector 
53    * @param strip        Strip
54    */
55   void AddChannelContainer(TObjArray* sectorArray, UShort_t det, 
56                            Char_t ring, UShort_t sec, UShort_t strip);
57   /** 
58    * Fill ADC values from a digit into the corresponding histogram.
59    * 
60    * @param digit Digit to fill ADC values for.
61    */
62   void FillChannels(AliFMDDigit* digit);
63   /** 
64    * Analyse a strip.  That is, compute the mean and spread of the ADC
65    * spectra for all strips.  Also output on files the values. 
66    * 
67    * @param det   Detector
68    * @param ring  Ring
69    * @param sec   Sector 
70    * @param strip Strip.
71    */
72   void Analyse(UShort_t det, Char_t ring, UShort_t sec, UShort_t strip);
73   /** 
74    * Write headers to files. 
75    * 
76    */  
77   void WriteHeaderToFile();
78   /** 
79    * Called at the end of an event.
80    * 
81    */  
82   void FinishEvent() {}
83   /** 
84    * Called at the end of a job.  Fills in missing time-bins and
85    * closes output files  
86    * 
87    */  
88   void Terminate(TFile* );
89 private:
90   /** 
91    * Get the histogram corresponding to a strip sample.
92    * 
93    * @param det    Detector
94    * @param ring   Ring
95    * @param sec    Sector
96    * @param strip  Strip
97    * @param sample Sample
98    * 
99    * @return ADC spectra of a strip.
100    */
101   TH1S* GetChannel(UShort_t det, Char_t ring, UShort_t sec, 
102                    UShort_t strip, UInt_t sample);
103   /** 
104    * Calculate the hardware index
105    * 
106    * @param ddl    DDL number
107    * @param board  Board number
108    * @param altro  ALTRO number
109    * @param chan   Channel number
110    * 
111    * @return Index into hardware cache.
112    */
113   Int_t HWIndex(UShort_t ddl, UShort_t board, UShort_t altro, 
114                 UShort_t chan) const;
115   void FillinTimebins(std::ofstream& out, UShort_t ddl);
116   /** Current strip */ 
117   Int_t fCurrentChannel;
118   /** Pedestal summary */
119   TH1F  fPedSummary;
120   /** Noise summary */
121   TH1F  fNoiseSummary;
122   /** Output file for zero-suppression for FMD1 */
123   std::ofstream fZSfileFMD1;
124   /** Output file for zero-suppression for FMD2 */
125   std::ofstream fZSfileFMD2;
126   /** Output file for zero-suppression for FMD3 */
127   std::ofstream fZSfileFMD3;
128   /** The minimum timebin seen for all channels */
129   TArrayS fMinTimebin;
130   /** The maximum timebin seen for all channels */
131   TArrayS fMaxTimebin;
132   
133   
134   ClassDef(AliFMDPedestalDA,0)
135 };
136
137 inline Int_t
138 AliFMDPedestalDA::HWIndex(UShort_t ddl, UShort_t b, UShort_t a, UShort_t c)const
139 {
140   // Save some array entries 
141   UShort_t lb = (b > 1 ? b-16+2 : b);
142   const Int_t kNDDL     = 3;
143   const Int_t kNBoard   = 4;
144   const Int_t kNAltro   = 3;
145   const Int_t kNChannel = 16;
146   Int_t idx =  c + kNChannel * (a + kNAltro * (lb + kNBoard * ddl));
147   if (idx > kNDDL * kNBoard * kNAltro * kNChannel) return -1;
148   return idx;
149 }
150
151 #endif
152 //
153 // Local Variables:
154 //  mode: C++
155 // End:
156 //