ATLAS Offline Software
Loading...
Searching...
No Matches
TileRawChannelMaker.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
3*/
4
5// Tile includes
8
9// Atlas includes
11// access all RawChannels inside container
14
15// Gaudi includes
16
17#include <algorithm>
18#include <set>
19
26 ISvcLocator* pSvcLocator)
27 : AthAlgorithm(name, pSvcLocator)
28 , m_fitOverflow(false)
29 , m_tileInfo(0)
31{
32 declareProperty("FitOverflow", m_fitOverflow, "Fit or not overflows");
33 declareProperty("TileInfoName", m_infoName = "TileInfo");
34
37 m_overflowReplaceChi2Cut = 40000.0;
38}
39
45
50
51 ATH_MSG_DEBUG( "starting to retrieve list " << m_tileRawChannelBuilderList);
53
55
57 ATH_MSG_INFO( "TileRawChannelBuilder list is empty - will not do anything");
58 m_fitOverflow = false;
59 }
60
61 if (m_fitOverflow) {
63 } else {
65 }
66
67 ATH_CHECK( m_digitsContainerKey.initialize() );
68
69 ATH_MSG_INFO( "Initialization completed successfully");
70
71 // TileInfo
72 ATH_CHECK( detStore()->retrieve(m_tileInfo, m_infoName) );
73 m_ADCmaxMinusEps = m_tileInfo->ADCmax() - 0.01; // indicates channels which were masked in background dataset
74
75 return StatusCode::SUCCESS;
76}
77
82
83 const EventContext& ctx = Gaudi::Hive::currentContext();
84
85 // get named TileDigitsContaner from TES
87
88 if (!digitsContaner.isValid()) {
89 ATH_MSG_WARNING( "Can't retrieve TileDigitsContainer '"
90 << m_digitsContainerKey.key() << "' from TDS" );
91
92 return StatusCode::SUCCESS;
93 }
94
95 ATH_MSG_DEBUG( "Got TileDigitsContainer '" << m_digitsContainerKey.key() << "'" );
96
97 // create RawChannel Containers for all sub-algs
98 for (ToolHandle<TileRawChannelBuilder>& rawChannelBuilder : m_tileRawChannelBuilderList) {
99 ATH_CHECK( rawChannelBuilder->createContainer(ctx) );
100 rawChannelBuilder->resetDrawer();
101 }
102
103 // clean memory about overflows
104 if (m_fitOverflow) {
105 for (ToolHandle<TileRawChannelBuilder>& rawChannelBuilder : m_tileRawChannelBuilderList) {
106 rawChannelBuilder->resetOverflows();
107 }
108 }
109
110 // Iterate over all collections (drawers) with digits
111 for (const TileDigitsCollection* digitsCollection : *digitsContaner) {
112
113 // Iterate over all sub-algs
114 for (ToolHandle<TileRawChannelBuilder>& rawChannelBuilder : m_tileRawChannelBuilderList) {
115 // reconstruct all channels in one drawer
116 ATH_CHECK( rawChannelBuilder->build(digitsCollection, ctx) );
117 }
118
119 }
120
121 if (m_fitOverflow
122 && !(*m_tileRawChannelBuilderList.begin())->getOverflowedChannels().empty()) {
124 }
125
126 // commit RawChannel Containers for all sub-algs
127 for (ToolHandle<TileRawChannelBuilder>& rawChannelBuilder : m_tileRawChannelBuilderList) {
128 ATH_CHECK( rawChannelBuilder->commitContainer(ctx) );
129 }
130
131 ATH_MSG_DEBUG( "execute completed successfully" );
132
133 return StatusCode::SUCCESS;
134}
135
140
141 ATH_MSG_INFO(" finalize completed successfully" );
142
143 return StatusCode::SUCCESS;
144}
145
146void TileRawChannelMaker::fitOverflowedChannels(const EventContext& ctx) {
147
148 for (ToolHandle<TileRawChannelBuilder> rawChannelBuilder : m_tileRawChannelBuilderList) {
149
150 Overflows_t overflows = rawChannelBuilder->getOverflowedChannels();
151
152 for (std::pair<TileRawChannel*, const TileDigits*>& overflow : overflows) {
153
154 TileRawChannel* rwCh = overflow.first;
155 const TileDigits* pDigits = overflow.second;
156
157 TileRawChannel* fittedRwCh = m_tileRawChannelBuilderFitOverflow->rawChannel(pDigits, ctx);
158
159 bool fitOK = ( ( fabs(fittedRwCh->time()) < m_overflowReplaceTimeCut ) &&
160 ( fittedRwCh->pedestal() < m_overflowReplacePedestalCut ) &&
161 ( fittedRwCh->quality() < m_overflowReplaceChi2Cut ) );
162
163 int nSatSamples = 0;
164 std::vector<double> digits = pDigits->get_digits();
165 for (size_t ii = 0; ii<digits.size(); ii++) {
166 if (digits[ii] > m_ADCmaxMinusEps) nSatSamples++;
167 }
168
169 // NOTE: Optimal filtering is always run first and the fit method is used just in cases when there is an overflow.
170 // NOTE: Mathematically, a maximum pedestal range is [-460.607488, 4556.603392] and it happens for the phase 0.1 ns.
171 // Therefore, we use the following intervals:
172 // - if optimal filtering is used: (-500, 4600)
173 // - if fit method is used: (5000, 9095)
174 // NOTE: Overlay magic number is 4800.
175
176 if ( !fitOK || nSatSamples > 2) {
177 // If the fit is bad, reset the energy.
178 //The same if the number of saturated samples is 3 (or bigger)
179
180 //If we reject pulse, the quality must be above 9999 in order to mask the
181 // channel. So we set it at 10000 * nSatSamples. But if the fit completely fails,
182 // the quality is 100000, and we can keep this info in quality as well.
183 float quality = 10000. * ( (nSatSamples) ? nSatSamples : 9);
184 if (fittedRwCh->quality() > 99999.9) quality += 100000.;
185 rwCh->insert(0.0, 0.0, quality);
186
187 // 20000 - Indicates overflow, 9400 - indicates bad fit or >2 saturations.
188 // 30000 - Indicates overflow + underflow, 9400 - indicates bad fit or >2 saturations.
189 float pedestal = (rwCh->pedestal() < 29500.) ? (29400.)
190 : (39400.);
191 ATH_MSG_DEBUG("Overflow " << (std::string)(*rwCh) <<
192 " change ped from " << rwCh->pedestal() << " to " << pedestal);
193 rwCh->setPedestal(pedestal);
194 } else {
195 //If the fit is OK replace
196
197 //The range of the quality factor is very different in the fit (0-100k)
198 //than in the OF (0-255). So we rescale by a factor of 400.
199 rwCh->insert(fittedRwCh->amplitude(),
200 fittedRwCh->time(),
201 fittedRwCh->quality()*(1./400.));
202 // 20000 - Indicates overflow, 5000 - indicates fitted
203 // 30000 - Indicates overflow + underflow, 5000 - indicates fitted.
204 float pedestal = (rwCh->pedestal() < 29500.) ? fittedRwCh->pedestal() + 25000.
205 : fittedRwCh->pedestal() + 35000.;
206 ATH_MSG_DEBUG("Overflow " << (std::string)(*rwCh) <<
207 " change ped from " << rwCh->pedestal() << " to " << pedestal);
208 rwCh->setPedestal(pedestal);
209 }
210
211 }
212 }
213
214}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)
#define ATH_MSG_WARNING(x)
#define ATH_MSG_DEBUG(x)
Helpers for checking error return status codes and reporting errors.
Handle class for reading from StoreGate.
std::vector< std::pair< TileRawChannel *, const TileDigits * > > Overflows_t
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
virtual bool isValid() override final
Can the handle be successfully dereferenced?
std::vector< double > get_digits(void) const
Definition TileDigits.h:65
void fitOverflowedChannels(const EventContext &ctx)
ToolHandleArray< TileRawChannelBuilder > m_tileRawChannelBuilderList
Vector of builder algtools.
virtual StatusCode execute() override
Execute.
SG::ReadHandleKey< TileDigitsContainer > m_digitsContainerKey
virtual ~TileRawChannelMaker()
Destructor.
TileRawChannelMaker(const std::string &name, ISvcLocator *pSvcLocator)
Standard constructor.
virtual StatusCode finalize() override
Finalize.
const TileInfo * m_tileInfo
ToolHandle< TileRawChannelBuilder > m_tileRawChannelBuilderFitOverflow
virtual StatusCode initialize() override
Initialize algorithm.
float pedestal(void) const
float time(int ind=0) const
float quality(int ind=0) const
void setPedestal(float ped)
int insert(float amplitude, float time, float quality)
float amplitude(int ind=0) const