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