]> git.uio.no Git - u/mrichter/AliRoot.git/blob - HLT/PHOS/AliHLTPHOSBaselineAnalyzer.h
67620d50ca95279295f382b90cafc2cf92bd956a
[u/mrichter/AliRoot.git] / HLT / PHOS / AliHLTPHOSBaselineAnalyzer.h
1 /**************************************************************************
2  * This file is property of and copyright by the ALICE HLT Project        * 
3  * All rights reserved.                                                   *
4  *                                                                        *
5  * Primary Authors: Oystein Djuvsland                                     *
6  *                                                                        *
7  * Permission to use, copy, modify and distribute this software and its   *
8  * documentation strictly for non-commercial purposes is hereby granted   *
9  * without fee, provided that the above copyright notice appears in all   *
10  * copies and that both the copyright notice and this permission notice   *
11  * appear in the supporting documentation. The authors make no claims     *
12  * about the suitability of this software for any purpose. It is          * 
13  * provided "as is" without express or implied warranty.                  *
14  **************************************************************************/
15
16 #ifndef ALIHLTPHOSBASELINEANALYZER_H
17 #define ALIHLTPHOSBASELINEANALYZER_H
18
19 /**
20  * Measures the baselines and calculates relevant values
21  *
22  * @file   AliHLTPHOSBaselineAnalyzer.h
23  * @author Oystein Djuvsland
24  * @date
25  * @brief  Baseline analyzer for PHOS HLT
26  */
27
28 // see below for class documentation
29 // or
30 // refer to README to build package
31 // or
32 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
33
34 #include "AliHLTPHOSConstants.h"
35 #include "AliHLTPHOSBase.h"
36
37 class AliHLTPHOSRcuCellEnergyDataStruct;
38 class AliHLTPHOSValidCellDataStruct;
39 class AliHLTPHOSSanityInspector;
40 class TTree;
41 class TClonesArray;
42 class TH1F;
43 class TH2F;
44
45 using namespace PhosHLTConst;
46
47
48 /**
49  * @class AliHLTPHOSBaselineAnalyzer
50  * Measures the baseline in a baseline run. It also calculates 
51  * RMS of the signal noise in each channel. It takes as input raw signals,
52  * and outputs an object of AliHLTPHOSBaseline class for each channel. 
53  * It also creates several histograms for each channel.
54  *
55  * @ingroup alihlt_phos
56  */
57
58 class AliHLTPHOSBaselineAnalyzer : public AliHLTPHOSBase
59 {
60   
61 public:
62
63   /** Constructor */
64   AliHLTPHOSBaselineAnalyzer();
65   
66   /** Destructor */ 
67   virtual ~AliHLTPHOSBaselineAnalyzer();
68   
69   /** Copy constructor */
70   AliHLTPHOSBaselineAnalyzer(const AliHLTPHOSBaselineAnalyzer &) : 
71     AliHLTPHOSBase(),
72     fSampleStart(5),
73     fMaxCrazyDifference(0),     
74     fMaxSignal(0),  
75     fChannelCount(0),
76     fTreePtr(0),
77     fBaselineArrayPtr(0),
78     fRMSHistogramPtr(0),
79     fRMSMapHighGainHistogramPtr(0),
80     fRMSMapLowGainHistogramPtr(0),
81     fFixedRMSHistogramPtr(0),
82     fFixedRMSMapHighGainHistogramPtr(0),
83     fFixedRMSMapLowGainHistogramPtr(0),
84     fSanityInspector(0)
85   {
86     //Copy constructor not implemented
87   }
88   
89   /** Assignment */
90   AliHLTPHOSBaselineAnalyzer & operator = (const AliHLTPHOSBaselineAnalyzer)
91     {
92       //Assignment
93       return *this; 
94     }
95     
96   /** 
97    * Calculate baselines for an RCU
98    * @param rcuData is a pointer to energy and timing data from an RCU
99    */
100   void CalculateRcuBaselines(AliHLTPHOSRcuCellEnergyDataStruct* rcuData);
101
102   /**
103    * Calculate the baseline of channels
104    * @param cellData is a pointer to a valid channel
105    * @param xOff is the offset in the x position given by the RCU number
106    * @param zOff is the offset in the z position given by the RCU number
107    * @return the baseline
108    */
109   Float_t CalculateChannelBaseline(AliHLTPHOSValidCellDataStruct *cellData, Int_t xOff, Int_t zOff);
110
111   /** 
112    * Calculate the accumulated baseline of a channel
113    * @param x is the x coord of the channel
114    * @param z is the z coord of the channel
115    * @param gain is the gain of the channel
116    * @param baseline is the most recent measured baseline
117    */
118   void CalculateAccumulatedChannelBaseline(Int_t x, Int_t z, Int_t gain, Float_t baseline);
119
120   /**
121    * Calculate the channels baseline RMS
122    */
123   void CalculateChannelsBaselineRMS();
124
125
126   // void CalculateAccumulatedBaselines();
127
128   /** Set the ROOT objects to be filled */
129   void SetRootObjects(TTree *tree, TClonesArray *array);
130
131   /** Fill the tree */
132   void FillTree();
133
134   /** Write the accumulated baselines */
135   void WriteAccumulatedBaselines(const Char_t* filename);
136
137   /** Write the channel histograms */
138   void WriteChannelHistograms(const Char_t* filename);
139
140   /** Write the RMS histograms */
141   void WriteRMSHistogram(const Char_t* filename);
142
143   /** Reset the baseline array */
144   void ResetBaselines();
145
146   /** Reset the channel count */
147   void ResetChannelCount();
148
149   /** Reset the accumulated baseline array */ 
150   void ResetAccumulatedBaselines();
151
152   /** Set the number of samples to be used for the baseline calculation */
153   void SetNumberOfSamples(Int_t nSamples) { fNSamples = nSamples; }
154
155   /** Set the max difference between 2 samples before flagging crazy  */
156   void SetMaxCrazyDifference(Int_t diff);
157
158   /** Set the maximum signal before flagging that a real signal is in the samples */
159   void SetMaxSignal(Int_t max) { fMaxSignal = max; }
160   
161  // void SetChannelsHistograms(TH1F *channelLowGainHistArray[N_XCOLUMNS_MOD][N_ZROWS_MOD], TH1F *channelLowGainHistArray[N_XCOLUMNS_MOD][N_ZROWS_MOD]);
162  
163      
164 private:
165
166   /** At which time index to start the measuring of the baseline */
167   Int_t fSampleStart;  // Shutting up rule checker
168
169   /** Not used anymore */
170   Int_t fMaxCrazyDifference;  // Shutting up rule checker
171
172   /** Maximum signal level, used to not count channels with signals for baseline measurement */
173   Int_t fMaxSignal;  // Shutting up rule checker
174
175   /** Count of channels, not used anymore */
176   Int_t fChannelCount;   // Shutting up rule checker
177
178   /** Array containing the baselines of all channels */
179   Float_t fBaselines[N_XCOLUMNS_MOD][N_ZROWS_MOD][N_GAINS];      // Shutting up rule checker
180
181   /** Array containing the accumulated baselines for all channels */
182   Float_t fAccumulatedBaselines[N_XCOLUMNS_MOD][N_ZROWS_MOD][N_GAINS][2];    // Shutting up rule checker
183
184   /** Pointer to a tree containing TClonesArray of AliHLTPHOSBaseline objects */ 
185   TTree *fTreePtr;                                      //! transient
186
187   /** Pointer to an array of AliHLTPHOSBaseline objects */
188   TClonesArray *fBaselineArrayPtr;                      //! transient
189
190
191  // TH1F *fChannelLowGainHistogramsPtr[N_XCOLUMNS_MOD][N_ZROWS_MOD]; //comment
192  // TH1F *fChannelHighGainHistogramsPtr[N_XCOLUMNS_MOD][N_ZROWS_MOD]; //comment
193
194
195   /** Pointer to an array of histograms containg the baselines */ 
196   TH1F *fChannelHistogramsPtr[N_XCOLUMNS_MOD][N_ZROWS_MOD][N_GAINS];      //! transient
197
198   /** Pointer to an array of histograms containg the "fixed" baselines */
199   TH1F *fFixedChannelHistogramsPtr[N_XCOLUMNS_MOD][N_ZROWS_MOD][N_GAINS]; //! transient
200
201   /** Pointer to a histograms containing the RMS values for all channels */ 
202   TH1F *fRMSHistogramPtr;                             //! transient
203
204   /** Pointer to a 2D histogram of the high gain RMS */ 
205   TH2F *fRMSMapHighGainHistogramPtr;                         //! transient
206
207   /** Pointer to a 2D histogram of the low gain RMS */ 
208   TH2F *fRMSMapLowGainHistogramPtr;                          //! transient
209
210   /** Pointer to a histogram containing the "fixed" RMS values for all channels */ 
211   TH1F *fFixedRMSHistogramPtr;                               //! transient
212
213   /** Pointer to a 2D histogram of the "fixed" high gain channels */ 
214   TH2F *fFixedRMSMapHighGainHistogramPtr;                    //! transient
215
216   /** Pointer to a 2D histogram of the "fixed" low gain channels */
217   TH2F *fFixedRMSMapLowGainHistogramPtr;                     //! transient
218
219   /** Pointer to a sanity inspector */
220   AliHLTPHOSSanityInspector *fSanityInspector;               //! transient
221  
222   ClassDef(AliHLTPHOSBaselineAnalyzer, 1);
223 };
224
225 #endif
226