ATLAS Offline Software
Loading...
Searching...
No Matches
TileCellBuilder.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef TILERECUTILS_TILECELLBUILDER_H
6#define TILERECUTILS_TILECELLBUILDER_H
7
8/********************************************************************
9 *
10 * NAME: TileCellBuilder
11 * PACKAGE: offline/TileCalorimeter/TileRecUtils
12 *
13 * AUTHOR : A. Solodkov
14 * CREATED: 20-Jun-2004
15 *
16 * PURPOSE: Create Cells from RawChannels and store them in container
17 *
18 * Input: TileRawChannel (one by one or from TileRawChannelContainer)
19 * Output: Container or collection with TileCells
20 * Parameters:
21 * TileRawChannelContainer - Name of input container
22 *
23 ********************************************************************/
24
25// Tile includes
37
38// Calo includes
41
42// Atlas includes
48
49// Gaudi includes
50#include "GaudiKernel/ToolHandle.h"
51#include "GaudiKernel/ServiceHandle.h"
52
53#include "CLHEP/Units/SystemOfUnits.h"
54
55// C++ STL includes
56#include <string>
57#include <vector>
58#include <memory>
59
60// forward declarations
61class TileID;
62class TileTBID;
63class TileHWID;
65class TileCell;
66class TileRawChannel;
71class TileDQstatus;
72class TileInfo;
73
74
75
82 public:
83 int nChannels = 0;
85 int nBadQuality = 0;
86 int nOverflow = 0;
87 int nUnderflow = 0;
88 int nSomeSignal = 0;
89};
90
102
109 : public extends<AthAlgTool, ICaloCellMakerTool>
110{
111 public:
112 TileCellBuilder(const std::string& type, const std::string& name, const IInterface* parent);
113
115
116 virtual StatusCode initialize() override;
117
118 virtual StatusCode finalize() override;
119
121 virtual StatusCode process (CaloCellContainer* theCellContainer,
122 const EventContext& ctx) const override;
123
124 void reset(bool fullSizeCont, bool printReset = true);
125
126 //AlgTool InterfaceID
127 static const InterfaceID& interfaceID();
128
129private:
130 // FIXME: Get rid of this abomination.
131 friend class TileHid2RESrcID;
132
135
136 // properties
138 "TileRawChannelCnt",
139 "Input Tile raw channel container key"};
140
142 "TileRawChannelCnt",
143 "Input Tile DSP raw channel container key"};
144
146 "EventInfo",
147 "EventInfo key"};
148
149
150
152 "TileDQstatus",
153 "TileDQstatus key"};
154
156 "MBTSContainer",
157 "Output Tile MBTS container key"};
158
160 "E4prContainer",
161 "Output Tile E4 prime container key"};
162
164 m_eventInfoKey, "TileStatus",
165 "Dummy decoration key to aid scheduling"};
166
167
169
170 // keep time only for cells above 70 MeV (more than 35 MeV in at least one PMT to be precise)
171 Gaudi::Property<float> m_eneForTimeCut{this, "EneForTimeCut", 35. * CLHEP::MeV,
172 "Keep time for channels with energy above cut"};
173 // the same cut for MBTS, but in pC, corresponds to 3 ADC counts or 35 MeV
174 Gaudi::Property<float> m_eneForTimeCutMBTS{this, "EneForTimeCutMBTS", 0.03675,
175 "Similar cut for MBTS in pC"};
176 // never set energy to zero, but set it to some small number
177 // this will help TopoCluster to assign proper weight to the cell if needed
178 // half a MeV in both PMTs i.e. one MeV in a cell
179 Gaudi::Property<float> m_zeroEnergy{this, "BadChannelZeroEnergy", 0.5 * CLHEP::MeV,
180 "Energy to store in every PMT if both PMT are bad"};
181 // cut on overflow in quality (if quality is 255 - assume that channel is bad)
182 Gaudi::Property<int> m_qualityCut{this, "QualityCut", 254,
183 "Cut on channel quality (set energy to m_zeroEnergy for them)"};
184 Gaudi::Property<bool> m_correctTime{this, "correctTime", false,
185 "Should time be corrected (deltat added from CondDB)"};
186 Gaudi::Property<bool> m_correctAmplitude{this, "correctAmplitude", false,
187 "If true, amplitude is corrected by parabolic function (needed for OF without iterations)"};
188 Gaudi::Property<bool> m_of2{this, "OF2", true,
189 "If true, assume OF2 method for amplitude correction, otherwise - OF1"};
190 Gaudi::Property<bool> m_mergeChannels{this, "mergeChannels", true,
191 "If true, missing raw channels are taken from DSP container"};
192
193 // thresholds for parabolic amplitude correction
194 Gaudi::Property<float> m_ampMinThresh{this, "AmpMinForAmpCorrection", 15.0,
195 "Correct amplitude if it's above amplitude threshold (in ADC counts)"};
196 Gaudi::Property<float> m_timeMinThresh{this, "TimeMinForAmpCorrection", -12.5,
197 "Correct amplitude if time is above time min threshold"};
198 Gaudi::Property<float> m_timeMaxThresh{this, "TimeMaxForAmpCorrection", 12.5,
199 "Correct amplitude if time is below time max threshold"};
200
201 // channel energy thresholds for masking (normal,gap,mbts)
202 Gaudi::Property<float> m_minEneChan{this, "MinEnergyChan", -5000. * CLHEP::MeV,
203 "Normal channel energy threshold for masking"};
204 Gaudi::Property<float> m_minEneGap{this, "MinEnergyGap", -10000. * CLHEP::MeV,
205 "Gap channel energy threshold for masking"};
206 Gaudi::Property<float> m_minEneMBTS{this, "MinEnergyMBTS", -999999. * CLHEP::MeV,
207 "MBTS channel energy threshold for masking (not used currently)"};
208 Gaudi::Property<float> m_eThreshold{this, "EThreshold", -100000.,
209 "Cell energy threshold (in MeV) to consider the cell"};
210 Gaudi::Property<float> m_maxTimeDiff{this, "MaxTimeDiff", 100000.,
211 "Maximum time difference between the PMTs in the cell"};
212 Gaudi::Property<float> m_maxTime{this, "MaxTime", 100000., "Maximum time for the PMTs in the cells"};
213 Gaudi::Property<float> m_minTime{this, "MinTime", -100000., "Minimum time for the PMTs in the cells"};
214 Gaudi::Property<float> m_maxChi2{this, "MaxChi2", 100000., "Maximum chi2 for the PMTs in the cells"};
215 Gaudi::Property<float> m_minChi2{this, "MinChi2", -100000., "Minimum chi2 for the PMTs in the cells"};
216 bool m_thresholdNotSet{true};
217 Gaudi::Property<bool> m_fullSizeCont{this, "fullSizeCont", true, "Use full size cell container"};
218 Gaudi::Property<bool> m_maskBadChannels{this, "maskBadChannels", true,
219 "Put zero energy in bad channels and recover from single-channel failure using second PMT in a cell"};
220 Gaudi::Property<bool> m_fakeCrackCells{this, "fakeCrackCells", false,
221 "Create fake E3/E4 crack scintillators with zero energy when they do not exist"};
222 Gaudi::Property<int> m_skipGain{this, "SkipGain", -1,
223 "For two-gain calib runs skip one of two gains (never skip any gain by default)"};
224 Gaudi::Property<int> m_useDemoCabling{this, "UseDemoCabling", 0,
225 "Use demonstrator cabling (if set to 2015 - assume TB 2015 cabling)"};
226 Gaudi::Property<bool> m_checkDCS{this, "CheckDCS", false, "Check DCS state"};
227
228 const TileID* m_tileID{nullptr};
229 const TileTBID* m_tileTBID{nullptr};
230 const TileHWID* m_tileHWID{nullptr};
232
237 "TileBadChannels", "TileBadChannels", "Input Tile bad channel status"};
238
243 "TileEMScale", "TileEMScale", "Input Tile EMS calibration constants"};
244
245 ToolHandle<TileCondToolTiming> m_tileToolTiming{this,
246 "TileCondToolTiming", "TileCondToolTiming", "Tile timing tool"};
247
248 ToolHandleArray<ITileRawChannelTool> m_noiseFilterTools{this,
249 "NoiseFilterTools", {}, "Tile noise filter tools"};
250
255 "TileDCS", "TileDCS", "Input Tile DCS status"};
256
261 "TileCablingSvc", "TileCablingSvc", "The Tile cabling service"};
262
265
266 // These were accumulated, but never actually used.
267 // They also spoil reentrancy, so leave them commented-out for now.
268 // If this information is needed in the future, these can be changed
269 // to use atomics.
270 //TileDrawerRunStatus m_drawerRunStatus[5][64]; //!< overall status of drawer in whole run
271 //int m_eventErrorCounter[4]; //!< number of events with no errors(0), warnings(1), error(2), total(3)
272
273 std::vector<CaloAffectedRegionInfo> m_affectedRegionInfo_global;
274 std::vector<CaloAffectedRegionInfo> m_affectedRegionInfo_current_run;
275
276
278 {
279 // Type of TileRawChannels (Fit, OF2, etc.)
281
282 // Unit for TileRawChannels (ADC, pCb, etc.)
284
285 // max possible time when time correction is applied
286 float m_maxTimeCorr = 75.0;
287
288 // If true, amplitude is corrected by parabolic function (needed for OF without iterations)
289 bool m_correctAmplitude = false;
290
291 // should time be corrected (deltat added from CondDB)
292 bool m_correctTime = false;
293
294 // If true, assume OF2 method for amplitude correction, otherwise - OF1
295 bool m_of2 = false;
296 };
297
299 template<class ITERATOR, class COLLECTION>
300 void build (const EventContext& ctx,
301 TileDrawerEvtStatusArray& drawerEvtStatus,
302 VecParams& params,
303 const ITERATOR & begin,
304 const ITERATOR & end,
305 COLLECTION* coll,
306 TileCellContainer* MBTSCells,
307 TileCellContainer* E4prCells) const;
308
312 bool maskBadChannel (TileDrawerEvtStatusArray& drawerEvtStatus,
313 const TileDQstatus* DQstatus, const TileDCSState* dcsState,
314 const TileBadChannels* badChannels, TileCell* pCell, HWIdentifier hwid) const;
315 bool maskBadChannels (TileDrawerEvtStatusArray& drawerEvtStatus,
316 const TileDQstatus* DQstatus, const TileDCSState* dcsState,
317 const TileBadChannels* badChannels, TileCell* pCell) const;
318
319 void correctCell(TileCell* pCell, int correction, int pmt, int gain, float ener, float time,
320 unsigned char iqual, unsigned char qbit, int ch_type) const;
321
322 unsigned char iquality(float qual) const {
323 return std::min(255, abs((int) qual));
324 } // keep quality within 8 bits make it "unsigned char"
325
326
328 unsigned char qbits (TileDrawerEvtStatusArray& drawerEvtStatus,
329 TileFragHash::TYPE RChType,
330 int ros, int drawer,
331 bool count_over, bool good_time, bool good_ener,
332 bool overflow, bool underflow,
333 bool good_overflowfit) const;
334
335 template<typename T, typename V>
342 int m_pos;
343 typedef typename T::iterator itr_type;
345
346 public:
347
349 T* f,
350 const VecParams& params1,
351 T* s,
352 const VecParams& params2,
353 int p)
354 : m_params(params),
355 m_first(f),
356 m_params1(params1),
357 m_second(s),
358 m_params2(params2),
359 m_pos(p) {
360
361 if (m_first->begin() != m_first->end() && m_pos < 1) {
362 m_pos = 0;
363 m_itr = m_first->begin();
364 } else if (m_second->begin() != m_second->end() && m_pos < 2) {
365 m_pos = 1;
366 m_itr = m_second->begin();
367 // set parameters for second vector
368 m_params = m_params2;
369 } else {
370 m_pos = 2;
371 m_itr = m_second->end();
372 }
373 }
374
377
378
380 if (m_pos != i.m_pos || m_itr != i.m_itr) return true;
381 else return false;
382 }
383
384 V& operator*() const { return (*m_itr); }
385 V* operator->() const { return (*m_itr); }
386
388 switch (m_pos) {
389 case 0:
390 if (m_itr != m_first->end()) ++m_itr;
391 if (m_itr != m_first->end()) break;
392 m_itr = m_second->begin();
393 m_pos = 1;
394 // set parameters for second vector
396 if (m_itr != m_second->end()) break;
397 m_pos = 2;
398 // recover parameters for first vector
400 break;
401 case 1:
402 if (m_itr != m_second->end()) ++m_itr;
403 if (m_itr != m_second->end()) break;
404 m_pos = 2;
405 // recover parameters for first vector
407 break;
408 default:
409 break;
410 }
411 return *this;
412 }
413 };
414
419 bool m_run2{false};
420
421 // TileInfo
422 Gaudi::Property<std::string> m_infoName{this, "TileInfoName", "TileInfo", "Name of TileInfo object"};
423 const TileInfo* m_tileInfo{nullptr};
426 bool m_run2plus{false};
427};
428
429#endif
object to store information about affected regions in calorimeter
if(pathvar)
Property holding a SG store/key/clid from which a ReadHandle is made.
Property holding a SG store/key/clid from which a WriteHandle is made.
TileContainer< TileCell > TileCellContainer
Information produced by TileDQstatusAlg (used to be done by TileBeamInfoProvider).
Container class for CaloCell.
Property holding a SG store/key/clid from which a ReadHandle is made.
Property holding a SG store/key/clid/attr name from which a WriteDecorHandle is made.
Property holding a SG store/key/clid from which a WriteHandle is made.
Condition object to keep Tile channel and ADC status.
DoubleVectorIterator & operator=(const DoubleVectorIterator &other)=default
DoubleVectorIterator(const DoubleVectorIterator &i)=default
DoubleVectorIterator(VecParams &params, T *f, const VecParams &params1, T *s, const VecParams &params2, int p)
bool operator!=(const DoubleVectorIterator &i)
ToolHandle< TileCondToolTiming > m_tileToolTiming
const TileDetDescrManager * m_tileMgr
Pointer to TileDetDescrManager.
SG::ReadHandleKey< TileRawChannelContainer > m_dspRawChannelContainerKey
Gaudi::Property< bool > m_fakeCrackCells
virtual ~TileCellBuilder()
Destructor.
Gaudi::Property< float > m_eneForTimeCut
Gaudi::Property< float > m_ampMinThresh
TileDrawerEvtStatus TileDrawerEvtStatusArray[5][64]
status of every drawer
SG::ReadHandleKey< TileDQstatus > m_DQstatusKey
const TileTBID * m_tileTBID
Pointer to TileTBID.
Gaudi::Property< bool > m_correctTime
ServiceHandle< TileCablingSvc > m_cablingSvc
Name of Tile cabling service.
Gaudi::Property< bool > m_maskBadChannels
Gaudi::Property< int > m_qualityCut
Gaudi::Property< bool > m_correctAmplitude
TileCellBuilder(const std::string &type, const std::string &name, const IInterface *parent)
Contructor.
Gaudi::Property< bool > m_mergeChannels
SG::WriteDecorHandleKey< xAOD::EventInfo > m_EventInfoTileStatusKey
bool maskBadChannel(TileDrawerEvtStatusArray &drawerEvtStatus, const TileDQstatus *DQstatus, const TileDCSState *dcsState, const TileBadChannels *badChannels, TileCell *pCell, HWIdentifier hwid) const
method to check if channels are good or bad.
SG::ReadHandleKey< TileRawChannelContainer > m_rawChannelContainerKey
Gaudi::Property< float > m_zeroEnergy
Gaudi::Property< float > m_minChi2
friend class TileHid2RESrcID
Gaudi::Property< bool > m_of2
const MbtsDetDescrManager * m_mbtsMgr
Pointer to MbtsDetDescrManager.
const TileInfo * m_tileInfo
Gaudi::Property< float > m_maxTime
bool maskBadChannels(TileDrawerEvtStatusArray &drawerEvtStatus, const TileDQstatus *DQstatus, const TileDCSState *dcsState, const TileBadChannels *badChannels, TileCell *pCell) const
Gaudi::Property< float > m_eneForTimeCutMBTS
Gaudi::Property< float > m_timeMaxThresh
unsigned char iquality(float qual) const
bool m_thresholdNotSet
bool variable to check whether some threshold have been set
SG::ReadCondHandleKey< TileDCSState > m_DCSStateKey
Name of TileDCSState object in condition store.
Gaudi::Property< float > m_minTime
const TileCablingService * m_cabling
TileCabling instance.
Gaudi::Property< float > m_maxChi2
unsigned char qbits(TileDrawerEvtStatusArray &drawerEvtStatus, TileFragHash::TYPE RChType, int ros, int drawer, bool count_over, bool good_time, bool good_ener, bool overflow, bool underflow, bool good_overflowfit) const
method to compute the cell quality bits
const TileHWID * m_tileHWID
Pointer to TileHWID.
SG::ReadCondHandleKey< TileEMScale > m_emScaleKey
Name of TileEMScale in condition store.
std::vector< CaloAffectedRegionInfo > m_affectedRegionInfo_current_run
Gaudi::Property< float > m_eThreshold
SG::WriteHandleKey< TileCellContainer > m_E4prContainerKey
Gaudi::Property< float > m_minEneChan
Gaudi::Property< float > m_timeMinThresh
SG::WriteHandleKey< TileCellContainer > m_MBTSContainerKey
Gaudi::Property< float > m_maxTimeDiff
void correctCell(TileCell *pCell, int correction, int pmt, int gain, float ener, float time, unsigned char iqual, unsigned char qbit, int ch_type) const
Compute calibrated energy, time, etc.
SG::ReadHandleKey< xAOD::EventInfo > m_eventInfoKey
Gaudi::Property< bool > m_checkDCS
static const InterfaceID & interfaceID()
SG::ReadCondHandleKey< TileBadChannels > m_badChannelsKey
Name of TileBadChannels in condition store.
Gaudi::Property< float > m_minEneGap
ToolHandleArray< ITileRawChannelTool > m_noiseFilterTools
void build(const EventContext &ctx, TileDrawerEvtStatusArray &drawerEvtStatus, VecParams &params, const ITERATOR &begin, const ITERATOR &end, COLLECTION *coll, TileCellContainer *MBTSCells, TileCellContainer *E4prCells) const
< method to process raw channels from a given vector and store them in collection
std::vector< CaloAffectedRegionInfo > m_affectedRegionInfo_global
std::string m_dspRawChannelContainer
virtual StatusCode finalize() override
Gaudi::Property< bool > m_fullSizeCont
Gaudi::Property< int > m_useDemoCabling
Gaudi::Property< float > m_minEneMBTS
Gaudi::Property< int > m_skipGain
Gaudi::Property< std::string > m_infoName
const TileID * m_tileID
Pointer to TileID.
virtual StatusCode initialize() override
Initializer.
Condition object to keep Tile DCS status from DB.
Class that holds Data Quality fragment information and provides functions to extract the data quality...
This class keep detailed status info about one drawer in a given event.
This class keep detailed status info about one drawer in whole run.
TYPE
initialize
Helper class for TileCal online (hardware) identifiers.
Definition TileHWID.h:49
Helper class for TileCal offline identifiers.
Definition TileID.h:67
Helper class for TileCal offline identifiers of ancillary testbeam detectors and MBTS.
const std::string reset
const std::string process
TileFragHash::TYPE m_RChType
TileRawChannelUnit::UNIT m_RChUnit