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
81StatusCode TileRawChannelMaker::execute(const EventContext& ctx) {
82
83
84 // get named TileDigitsContaner from TES
86
87 if (!digitsContaner.isValid()) {
88 ATH_MSG_WARNING( "Can't retrieve TileDigitsContainer '"
89 << m_digitsContainerKey.key() << "' from TDS" );
90
91 return StatusCode::SUCCESS;
92 }
93
94 ATH_MSG_DEBUG( "Got TileDigitsContainer '" << m_digitsContainerKey.key() << "'" );
95
96 // create RawChannel Containers for all sub-algs
97 for (ToolHandle<TileRawChannelBuilder>& rawChannelBuilder : m_tileRawChannelBuilderList) {
98 ATH_CHECK( rawChannelBuilder->createContainer(ctx) );
99 rawChannelBuilder->resetDrawer();
100 }
101
102 // clean memory about overflows
103 if (m_fitOverflow) {
104 for (ToolHandle<TileRawChannelBuilder>& rawChannelBuilder : m_tileRawChannelBuilderList) {
105 rawChannelBuilder->resetOverflows();
106 }
107 }
108
109 // Iterate over all collections (drawers) with digits
110 for (const TileDigitsCollection* digitsCollection : *digitsContaner) {
111
112 // Iterate over all sub-algs
113 for (ToolHandle<TileRawChannelBuilder>& rawChannelBuilder : m_tileRawChannelBuilderList) {
114 // reconstruct all channels in one drawer
115 ATH_CHECK( rawChannelBuilder->build(digitsCollection, ctx) );
116 }
117
118 }
119
120 if (m_fitOverflow
121 && !(*m_tileRawChannelBuilderList.begin())->getOverflowedChannels().empty()) {
123 }
124
125 // commit RawChannel Containers for all sub-algs
126 for (ToolHandle<TileRawChannelBuilder>& rawChannelBuilder : m_tileRawChannelBuilderList) {
127 ATH_CHECK( rawChannelBuilder->commitContainer(ctx) );
128 }
129
130 ATH_MSG_DEBUG( "execute completed successfully" );
131
132 return StatusCode::SUCCESS;
133}
134
139
140 ATH_MSG_INFO(" finalize completed successfully" );
141
142 return StatusCode::SUCCESS;
143}
144
145void TileRawChannelMaker::fitOverflowedChannels(const EventContext& ctx) {
146
147 for (ToolHandle<TileRawChannelBuilder> rawChannelBuilder : m_tileRawChannelBuilderList) {
148
149 Overflows_t overflows = rawChannelBuilder->getOverflowedChannels();
150
151 for (std::pair<TileRawChannel*, const TileDigits*>& overflow : overflows) {
152
153 TileRawChannel* rwCh = overflow.first;
154 const TileDigits* pDigits = overflow.second;
155
156 TileRawChannel* fittedRwCh = m_tileRawChannelBuilderFitOverflow->rawChannel(pDigits, ctx);
157
158 bool fitOK = ( ( fabs(fittedRwCh->time()) < m_overflowReplaceTimeCut ) &&
159 ( fittedRwCh->pedestal() < m_overflowReplacePedestalCut ) &&
160 ( fittedRwCh->quality() < m_overflowReplaceChi2Cut ) );
161
162 int nSatSamples = 0;
163 std::vector<double> digits = pDigits->get_digits();
164 for (size_t ii = 0; ii<digits.size(); ii++) {
165 if (digits[ii] > m_ADCmaxMinusEps) nSatSamples++;
166 }
167
168 // NOTE: Optimal filtering is always run first and the fit method is used just in cases when there is an overflow.
169 // NOTE: Mathematically, a maximum pedestal range is [-460.607488, 4556.603392] and it happens for the phase 0.1 ns.
170 // Therefore, we use the following intervals:
171 // - if optimal filtering is used: (-500, 4600)
172 // - if fit method is used: (5000, 9095)
173 // NOTE: Overlay magic number is 4800.
174
175 if ( !fitOK || nSatSamples > 2) {
176 // If the fit is bad, reset the energy.
177 //The same if the number of saturated samples is 3 (or bigger)
178
179 //If we reject pulse, the quality must be above 9999 in order to mask the
180 // channel. So we set it at 10000 * nSatSamples. But if the fit completely fails,
181 // the quality is 100000, and we can keep this info in quality as well.
182 float quality = 10000. * ( (nSatSamples) ? nSatSamples : 9);
183 if (fittedRwCh->quality() > 99999.9) quality += 100000.;
184 rwCh->insert(0.0, 0.0, quality);
185
186 // 20000 - Indicates overflow, 9400 - indicates bad fit or >2 saturations.
187 // 30000 - Indicates overflow + underflow, 9400 - indicates bad fit or >2 saturations.
188 float pedestal = (rwCh->pedestal() < 29500.) ? (29400.)
189 : (39400.);
190 ATH_MSG_DEBUG("Overflow " << (std::string)(*rwCh) <<
191 " change ped from " << rwCh->pedestal() << " to " << pedestal);
192 rwCh->setPedestal(pedestal);
193 } else {
194 //If the fit is OK replace
195
196 //The range of the quality factor is very different in the fit (0-100k)
197 //than in the OF (0-255). So we rescale by a factor of 400.
198 rwCh->insert(fittedRwCh->amplitude(),
199 fittedRwCh->time(),
200 fittedRwCh->quality()*(1./400.));
201 // 20000 - Indicates overflow, 5000 - indicates fitted
202 // 30000 - Indicates overflow + underflow, 5000 - indicates fitted.
203 float pedestal = (rwCh->pedestal() < 29500.) ? fittedRwCh->pedestal() + 25000.
204 : fittedRwCh->pedestal() + 35000.;
205 ATH_MSG_DEBUG("Overflow " << (std::string)(*rwCh) <<
206 " change ped from " << rwCh->pedestal() << " to " << pedestal);
207 rwCh->setPedestal(pedestal);
208 }
209
210 }
211 }
212
213}
#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.
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.
SG::ReadHandleKey< TileDigitsContainer > m_digitsContainerKey
virtual StatusCode execute(const EventContext &ctx) override
Execute.
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