1 /**************************************************************************
2 * This file is property of and copyright by the ALICE HLT Project *
3 * All rights reserved. *
5 * Primary Authors: Oystein Djuvsland *
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 **************************************************************************/
16 #ifndef ALIHLTPHOSBASELINEANALYZER_H
17 #define ALIHLTPHOSBASELINEANALYZER_H
20 * Measures the baselines and calculates relevant values
22 * @file AliHLTPHOSBaselineAnalyzer.h
23 * @author Oystein Djuvsland
25 * @brief Baseline analyzer for PHOS HLT
28 // see below for class documentation
30 // refer to README to build package
32 // visit http://web.ift.uib.no/~kjeks/doc/alice-hlt
34 #include "AliHLTPHOSConstants.h"
35 #include "AliHLTPHOSBase.h"
37 class AliHLTPHOSRcuCellEnergyDataStruct;
38 class AliHLTPHOSValidCellDataStruct;
39 class AliHLTPHOSSanityInspector;
45 using namespace PhosHLTConst;
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.
55 * @ingroup alihlt_phos
58 class AliHLTPHOSBaselineAnalyzer : public AliHLTPHOSBase
64 AliHLTPHOSBaselineAnalyzer();
67 virtual ~AliHLTPHOSBaselineAnalyzer();
69 /** Copy constructor */
70 AliHLTPHOSBaselineAnalyzer(const AliHLTPHOSBaselineAnalyzer &) :
73 fMaxCrazyDifference(0),
79 fRMSMapHighGainHistogramPtr(0),
80 fRMSMapLowGainHistogramPtr(0),
81 fFixedRMSHistogramPtr(0),
82 fFixedRMSMapHighGainHistogramPtr(0),
83 fFixedRMSMapLowGainHistogramPtr(0),
86 //Copy constructor not implemented
90 AliHLTPHOSBaselineAnalyzer & operator = (const AliHLTPHOSBaselineAnalyzer)
97 * Calculate baselines for an RCU
98 * @param rcuData is a pointer to energy and timing data from an RCU
100 void CalculateRcuBaselines(AliHLTPHOSRcuCellEnergyDataStruct* rcuData);
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
109 Float_t CalculateChannelBaseline(AliHLTPHOSValidCellDataStruct *cellData, Int_t xOff, Int_t zOff);
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
118 void CalculateAccumulatedChannelBaseline(Int_t x, Int_t z, Int_t gain, Float_t baseline);
121 * Calculate the channels baseline RMS
123 void CalculateChannelsBaselineRMS();
126 // void CalculateAccumulatedBaselines();
128 /** Set the ROOT objects to be filled */
129 void SetRootObjects(TTree *tree, TClonesArray *array);
134 /** Write the accumulated baselines */
135 void WriteAccumulatedBaselines(const Char_t* filename);
137 /** Write the channel histograms */
138 void WriteChannelHistograms(const Char_t* filename);
140 /** Write the RMS histograms */
141 void WriteRMSHistogram(const Char_t* filename);
143 /** Reset the baseline array */
144 void ResetBaselines();
146 /** Reset the channel count */
147 void ResetChannelCount();
149 /** Reset the accumulated baseline array */
150 void ResetAccumulatedBaselines();
152 /** Set the number of samples to be used for the baseline calculation */
153 void SetNumberOfSamples(Int_t nSamples) { fNSamples = nSamples; }
155 /** Set the max difference between 2 samples before flagging crazy */
156 void SetMaxCrazyDifference(Int_t diff);
158 /** Set the maximum signal before flagging that a real signal is in the samples */
159 void SetMaxSignal(Int_t max) { fMaxSignal = max; }
161 // void SetChannelsHistograms(TH1F *channelLowGainHistArray[N_XCOLUMNS_MOD][N_ZROWS_MOD], TH1F *channelLowGainHistArray[N_XCOLUMNS_MOD][N_ZROWS_MOD]);
166 /** At which time index to start the measuring of the baseline */
167 Int_t fSampleStart; // Shutting up rule checker
169 /** Not used anymore */
170 Int_t fMaxCrazyDifference; // Shutting up rule checker
172 /** Maximum signal level, used to not count channels with signals for baseline measurement */
173 Int_t fMaxSignal; // Shutting up rule checker
175 /** Count of channels, not used anymore */
176 Int_t fChannelCount; // Shutting up rule checker
178 /** Array containing the baselines of all channels */
179 Float_t fBaselines[N_XCOLUMNS_MOD][N_ZROWS_MOD][N_GAINS]; // Shutting up rule checker
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
184 /** Pointer to a tree containing TClonesArray of AliHLTPHOSBaseline objects */
185 TTree *fTreePtr; //! transient
187 /** Pointer to an array of AliHLTPHOSBaseline objects */
188 TClonesArray *fBaselineArrayPtr; //! transient
191 // TH1F *fChannelLowGainHistogramsPtr[N_XCOLUMNS_MOD][N_ZROWS_MOD]; //comment
192 // TH1F *fChannelHighGainHistogramsPtr[N_XCOLUMNS_MOD][N_ZROWS_MOD]; //comment
195 /** Pointer to an array of histograms containg the baselines */
196 TH1F *fChannelHistogramsPtr[N_XCOLUMNS_MOD][N_ZROWS_MOD][N_GAINS]; //! transient
198 /** Pointer to an array of histograms containg the "fixed" baselines */
199 TH1F *fFixedChannelHistogramsPtr[N_XCOLUMNS_MOD][N_ZROWS_MOD][N_GAINS]; //! transient
201 /** Pointer to a histograms containing the RMS values for all channels */
202 TH1F *fRMSHistogramPtr; //! transient
204 /** Pointer to a 2D histogram of the high gain RMS */
205 TH2F *fRMSMapHighGainHistogramPtr; //! transient
207 /** Pointer to a 2D histogram of the low gain RMS */
208 TH2F *fRMSMapLowGainHistogramPtr; //! transient
210 /** Pointer to a histogram containing the "fixed" RMS values for all channels */
211 TH1F *fFixedRMSHistogramPtr; //! transient
213 /** Pointer to a 2D histogram of the "fixed" high gain channels */
214 TH2F *fFixedRMSMapHighGainHistogramPtr; //! transient
216 /** Pointer to a 2D histogram of the "fixed" low gain channels */
217 TH2F *fFixedRMSMapLowGainHistogramPtr; //! transient
219 /** Pointer to a sanity inspector */
220 AliHLTPHOSSanityInspector *fSanityInspector; //! transient
222 ClassDef(AliHLTPHOSBaselineAnalyzer, 1);