ATLAS Offline Software
Loading...
Searching...
No Matches
TileRawChannelBuilderManyAmps.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3*/
4
5// small hack to enable datapool usage
7// Tile includes
16
17// Gaudi includes
18#include "Gaudi/Property.h"
19
20//Atlas includes
23
24
25// lang include
26#include <algorithm>
27#include <cmath>
28
29// C++ STL includes
30#include <vector>
31
32
37 const std::string& name, const IInterface *parent)
38 : TileRawChannelBuilder(type, name, parent)
41{
42 //declare interfaces
43 declareInterface< TileRawChannelBuilder >( this );
44 declareInterface< TileRawChannelBuilderManyAmps >(this);
45
46 m_rawChannelContainerKey = "TileRawChannelManyAmps";
47
48 //declare properties
49 declareProperty("FilterMode", m_digitFilterMode = 2); // can be 2 or 3
50 declareProperty("FilterLevel", m_digitFilterLevel = 5); // number of parameters for fit (3-9 for mode 2)
51 declareProperty("FilterTester", m_digitFilterTest = 0); // non-zero means call Tester (during initialization phase).
52}
53
54
60
61
66
67 ATH_MSG_INFO( "TileRawChannelBuilderManyAmps::initialize()" );
68
70
71 // init in superclass
73
74
75 // **************************************************************************************
76 ATH_MSG_INFO( " TileRawChannelBuilderManyAmps init:"
77 << " FilterMode=" << m_digitFilterMode
78 << ", FilterLevel=" << m_digitFilterLevel
79 << ", FilterTest=" << m_digitFilterTest );
80
81 if (!(m_digitFilterMode == 2) && !(m_digitFilterMode == 3)) { // filter mode different from 2 or 3
82
83 ATH_MSG_WARNING( "Wrong Filter mode defined: FilterMode=" << m_digitFilterMode );
84 ATH_MSG_WARNING( "Switching to FilterMode=2" );
86 }
87
88 // if( (m_digitFilterMode == 2) || (m_digitFilterMode == 3) ) {
89 /* Get information needed to initialize TileFilterManager. */
90 int Nsamp = m_tileInfo->NdigitSamples();
91 // Set maximum number of parameters to fit, using FilterLevel
92 int nParamMax = m_digitFilterLevel;
93 if (nParamMax > Nsamp + 1) nParamMax = Nsamp;
94 if (nParamMax < 3) nParamMax = 3;
95 int InTsamp = m_tileInfo->ItrigSample();
96 int jBsamp = 0;
97 int jEsamp = Nsamp - 1;
98 int jBcross = 0;
99 int jEcross = Nsamp - 1;
100 int Nshape = m_tileInfo->NdigitSamples();
101 int InTshape = m_tileInfo->ItrigSample(); // need new method to give this !!!
102 std::vector<double> ShapeXHi = m_tileInfo->digitsShapeHi();
103 std::vector<double> ShapeXLo = m_tileInfo->digitsShapeLo();
104
105 bool lVerbose = msgLvl(MSG::VERBOSE);
107 Nsamp, InTsamp, jBsamp, jEsamp, jBcross, jEcross, Nshape, InTshape, ShapeXHi, lVerbose);
108
110 Nsamp, InTsamp, jBsamp, jEsamp, jBcross, jEcross, Nshape, InTshape, ShapeXLo, lVerbose);
111
112 // Run TileFilterTester if m_digitFilterTest in non-zero).
113
114 if (m_digitFilterTest > 0) {
115
118
119 tFilterTestHi->genEvents(10);
120 delete tFilterTestHi;
121
124
125 tFilterTestLo->genEvents(10);
126 delete tFilterTestLo;
127 } // end FilterTest
128
129 ATH_MSG_DEBUG( "TileRawChannelBuilderManyAmps::initialize() completed successfully" );
130
131 return StatusCode::SUCCESS;
132}
133
138
139 ATH_MSG_DEBUG( "Finalizing" );
142 return StatusCode::SUCCESS;
143}
144
145TileRawChannel* TileRawChannelBuilderManyAmps::rawChannel(const TileDigits* tiledigits, const EventContext& ctx) {
146
147 ++m_chCounter;
148
149 const HWIdentifier adcId = tiledigits->adc_HWID();
150 unsigned int drawerIdx(0), channel(0), gain(0);
151 m_tileIdTransforms->getIndices(adcId, drawerIdx, channel, gain);
152
153 bool lVerbose(false);
154 if (msgLvl(MSG::VERBOSE)) {
155 msg(MSG::VERBOSE) << "Running ManyAmps Fit for TileRawChannel with HWID "
156 << m_tileHWID->to_string(adcId) << endmsg;
157 lVerbose = true;
158 }
159
160
161 /* get pedestal value assumed for reconstruction */
162 //double digSigma = m_tileInfo->DigitsResolution(gain);
163 // new way to get channel-dependent sigma:
164 // but we lost difference between sigma used in digitization and
165 // sigma assumed in reconstruction - it's the same sigma now
166 double digSigma = m_tileToolNoiseSample->getHfn(drawerIdx, channel, gain, TileRawChannelUnit::ADCcounts, ctx);
167
168 /* Get vector of time-slice amplitudes. */
169 std::vector<float> digits = tiledigits->samples();
170 double amp_ch = 0; // Fitted amplitude of RC (to be returned from Filtering code).
171 double err_ch; // Error in amp_ch (from Filtering code)
172 double ped_ch; // Fitted pedestal of raw channel (from Filtering).
173 double chisq_ch = 0.; // Chisq resulting from Filtering.
174 double t_ch = 0.; // Fitted time to be supplied by Filtering code
175 // ---------------------------------------------------------------------------------------
176
177 //int icode = 0;
178
179 // Instantiate tResult, which will collect results from Filtering code.
180 TileFilterResult tResult(digits, digSigma);
181 // Call Fitter to extract the in-time pulse height and related info.
182 if (TileID::HIGHGAIN == gain)
183 /*icode =*/m_tileFilterManagerHi->fitDigits(tResult, lVerbose);
184
185 if (TileID::LOWGAIN == gain)
186 /*icode =*/m_tileFilterManagerLo->fitDigits(tResult, lVerbose);
187
188 tResult.getInTime(amp_ch, err_ch, ped_ch, chisq_ch, t_ch);
189
190 ATH_MSG_VERBOSE( " TileRawChannelBuilderManyAmps: return from FilterManager/Fitter."
191 << ", chisq_ch=" << chisq_ch );
192
193 // convert to pCb (if needed)
194 if (m_calibrateEnergy) {
195 amp_ch = m_tileToolEmscale->doCalibCis(drawerIdx, channel, gain, amp_ch);
196 }
197 // we know that time is zero here, put negative chi^2 to indicate that
198 chisq_ch = -fabs(chisq_ch);
199
200 // TileRawChannel *rawCh = new TileRawChannel(adcId,amp_ch,t_ch,chisq_ch);
202 TileRawChannel *rawCh = tileRchPool.nextElementPtr();
203 rawCh->assign (adcId, amp_ch, t_ch, chisq_ch, 0);
204 ATH_MSG_VERBOSE( "Creating RawChannel"
205 << " a=" << amp_ch
206 << " t=" << t_ch
207 << " q=" << chisq_ch );
208
209 if (TileID::HIGHGAIN == gain) {
210 ++m_nChH;
211 m_RChSumH += amp_ch;
212 } else {
213 ++m_nChL;
214 m_RChSumL += amp_ch;
215 }
216
217 return rawCh;
218}
#define endmsg
#define ATH_MSG_INFO(x)
#define ATH_MSG_VERBOSE(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Helpers for checking error return status codes and reporting errors.
#define CHECK(...)
Evaluate an expression and check for errors.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
bool msgLvl(const MSG::Level lvl) const
a typed memory pool that saves time spent allocation small object.
Definition DataPool.h:63
pointer nextElementPtr()
obtain the next available element in pool by pointer pool is resized if its limit has been reached On...
const std::vector< float > & samples() const
Definition TileDigits.h:58
Auxiliary class for TileRawChannelMakerManyAmps.
Auxiliary class for TileRawChannelMakerManyAmps.
double getInTime(double &, double &, double &, double &, double &)
Auxiliary class for TileRawChannelMakerManyAmps.
void genEvents(int nEvent)
ToolHandle< TileCondToolNoiseSample > m_tileToolNoiseSample
virtual StatusCode finalize() override
Finalize.
virtual StatusCode initialize() override
Initialize.
TileRawChannelBuilderManyAmps(const std::string &type, const std::string &name, const IInterface *parent)
Standard constructor.
virtual TileRawChannel * rawChannel(const TileDigits *digits, const EventContext &ctx) override
Builder virtual method to be implemented by subclasses.
ToolHandle< TileCondIdTransforms > m_tileIdTransforms
virtual StatusCode initialize()
Initializer.
ToolHandle< TileCondToolEmscale > m_tileToolEmscale
SG::WriteHandleKey< TileRawChannelContainer > m_rawChannelContainerKey
TileRawChannelBuilder(const std::string &type, const std::string &name, const IInterface *parent)
Constructor.
void assign(const HWIdentifier &id, float amplitude, float time, float quality, float ped=0.0)
HWIdentifier adc_HWID(void) const
Definition TileRawData.h:53
MsgStream & msg
Definition testRead.cxx:32