4 /**************************************************************************
5 * This file is property of and copyright by the ALICE HLT Project *
6 * All rights reserved. *
8 * Primary Authors: Oystein Djuvsland *
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 **************************************************************************/
19 #ifndef ALIHLTPHOSBASELINEANALYZER_H
20 #define ALIHLTPHOSBASELINEANALYZER_H
23 * Measures the baselines and calculates relevant values
25 * @file AliHLTPHOSBaselineAnalyzer.h
26 * @author Oystein Djuvsland
28 * @brief Baseline analyzer for PHOS HLT
31 // see below for class documentation
33 // refer to README to build package
35 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
37 #include "AliHLTPHOSConstants.h"
38 #include "AliHLTPHOSBase.h"
40 class AliHLTPHOSRcuCellEnergyDataStruct;
41 class AliHLTPHOSValidCellDataStruct;
42 class AliHLTPHOSSanityInspector;
48 using namespace PhosHLTConst;
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.
58 * @ingroup alihlt_phos
61 class AliHLTPHOSBaselineAnalyzer : public AliHLTPHOSBase
67 AliHLTPHOSBaselineAnalyzer();
70 virtual ~AliHLTPHOSBaselineAnalyzer();
72 /** Copy constructor */
73 AliHLTPHOSBaselineAnalyzer(const AliHLTPHOSBaselineAnalyzer &) :
76 fMaxCrazyDifference(0),
82 fRMSMapHighGainHistogramPtr(0),
83 fRMSMapLowGainHistogramPtr(0),
84 fFixedRMSHistogramPtr(0),
85 fFixedRMSMapHighGainHistogramPtr(0),
86 fFixedRMSMapLowGainHistogramPtr(0),
89 //Copy constructor not implemented
93 AliHLTPHOSBaselineAnalyzer & operator = (const AliHLTPHOSBaselineAnalyzer)
100 * Calculate baselines for an RCU
101 * @param rcuData is a pointer to energy and timing data from an RCU
103 void CalculateRcuBaselines(AliHLTPHOSRcuCellEnergyDataStruct* rcuData);
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
113 Float_t CalculateChannelBaseline(AliHLTPHOSValidCellDataStruct *cellData, Int_t* rawDataPtr, Int_t xOff, Int_t zOff);
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
122 void CalculateAccumulatedChannelBaseline(Int_t x, Int_t z, Int_t gain, Float_t baseline);
125 * Calculate the channels baseline RMS
127 void CalculateChannelsBaselineRMS();
130 // void CalculateAccumulatedBaselines();
132 /** Set the ROOT objects to be filled */
133 void SetRootObjects(TTree *tree, TClonesArray *array);
138 /** Write the accumulated baselines */
139 void WriteAccumulatedBaselines(const Char_t* filename);
141 /** Write the channel histograms */
142 void WriteChannelHistograms(const Char_t* filename);
144 /** Write the RMS histograms */
145 void WriteRMSHistogram(const Char_t* filename);
147 /** Reset the baseline array */
148 void ResetBaselines();
150 /** Reset the channel count */
151 void ResetChannelCount();
153 /** Reset the accumulated baseline array */
154 void ResetAccumulatedBaselines();
156 /** Set the number of samples to be used for the baseline calculation */
157 void SetNumberOfSamples(Int_t nSamples) { fNSamples = nSamples; }
159 /** Set the max difference between 2 samples before flagging crazy */
160 void SetMaxCrazyDifference(Int_t diff);
162 /** Set the maximum signal before flagging that a real signal is in the samples */
163 void SetMaxSignal(Int_t max) { fMaxSignal = max; }
165 // void SetChannelsHistograms(TH1F *channelLowGainHistArray[N_XCOLUMNS_MOD][N_ZROWS_MOD], TH1F *channelLowGainHistArray[N_XCOLUMNS_MOD][N_ZROWS_MOD]);
170 /** At which time index to start the measuring of the baseline */
171 Int_t fSampleStart; // Shutting up rule checker
173 /** Not used anymore */
174 Int_t fMaxCrazyDifference; // Shutting up rule checker
176 /** Maximum signal level, used to not count channels with signals for baseline measurement */
177 Int_t fMaxSignal; // Shutting up rule checker
179 /** Count of channels, not used anymore */
180 Int_t fChannelCount; // Shutting up rule checker
182 /** Array containing the baselines of all channels */
183 Float_t fBaselines[N_XCOLUMNS_MOD][N_ZROWS_MOD][N_GAINS]; // Shutting up rule checker
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
188 /** Pointer to a tree containing TClonesArray of AliHLTPHOSBaseline objects */
189 TTree *fTreePtr; //! transient
191 /** Pointer to an array of AliHLTPHOSBaseline objects */
192 TClonesArray *fBaselineArrayPtr; //! transient
195 // TH1F *fChannelLowGainHistogramsPtr[N_XCOLUMNS_MOD][N_ZROWS_MOD]; //comment
196 // TH1F *fChannelHighGainHistogramsPtr[N_XCOLUMNS_MOD][N_ZROWS_MOD]; //comment
199 /** Pointer to an array of histograms containg the baselines */
200 TH1F *fChannelHistogramsPtr[N_XCOLUMNS_MOD][N_ZROWS_MOD][N_GAINS]; //! transient
202 /** Pointer to an array of histograms containg the "fixed" baselines */
203 TH1F *fFixedChannelHistogramsPtr[N_XCOLUMNS_MOD][N_ZROWS_MOD][N_GAINS]; //! transient
205 /** Pointer to a histograms containing the RMS values for all channels */
206 TH1F *fRMSHistogramPtr; //! transient
208 /** Pointer to a 2D histogram of the high gain RMS */
209 TH2F *fRMSMapHighGainHistogramPtr; //! transient
211 /** Pointer to a 2D histogram of the low gain RMS */
212 TH2F *fRMSMapLowGainHistogramPtr; //! transient
214 /** Pointer to a histogram containing the "fixed" RMS values for all channels */
215 TH1F *fFixedRMSHistogramPtr; //! transient
217 /** Pointer to a 2D histogram of the "fixed" high gain channels */
218 TH2F *fFixedRMSMapHighGainHistogramPtr; //! transient
220 /** Pointer to a 2D histogram of the "fixed" low gain channels */
221 TH2F *fFixedRMSMapLowGainHistogramPtr; //! transient
223 /** Pointer to a sanity inspector */
224 AliHLTPHOSSanityInspector *fSanityInspector; //! transient
226 ClassDef(AliHLTPHOSBaselineAnalyzer, 1);