ATLAS Offline Software
Loading...
Searching...
No Matches
TRTDigCondBase.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 CERN for the benefit of the ATLAS collaboration
3*/
4
5#ifndef TRT_DIGITIZATION_TRTDIGCONDBASE_H
6#define TRT_DIGITIZATION_TRTDIGCONDBASE_H
7
10#include "TRT_ConditionsServices/ITRT_StrawStatusSummaryTool.h" // added by Sasha for Argon
11
12#include "GaudiKernel/ServiceHandle.h"
13#include "GaudiKernel/ToolHandle.h"
14
15
16#include <atomic>
17#include <map>
18#include <mutex>
19
20class TRT_ID;
21class Identifier;
22
23namespace CLHEP{
24 class HepRandomEngine;
25}
26
27namespace InDetDD {
29}
30class TRTDigSettings;
35
36public:
37
41 const TRT_ID*,
42 int UseGasMix,
43 ToolHandle<ITRT_StrawStatusSummaryTool> sumTool
44 );
45
47 virtual ~TRTDigCondBase() {};
48
52 void initialize(CLHEP::HepRandomEngine* rndmEngine);
53
55 float strawAverageNoiseLevel() const; //[first time slow, else fast]
56
58 unsigned int totalNumberOfActiveStraws() const; //[fast]
59
69 void getStrawData( const int& hitID,
70 double& lowthreshold,
71 double& noiseamplitude ) const;
72
73 //--- For noise in unhit straws:
74
79
85 bool getNextNoisyStraw( CLHEP::HepRandomEngine*, int& hitID, float& noiselevel );
86
87
88 //Crosstalk noise
89 bool crossTalkNoise( CLHEP::HepRandomEngine* ) const;
90 bool crossTalkNoiseOtherEnd( CLHEP::HepRandomEngine* ) const;
91
92 //--- For looping over all straws (only to be used at initialization):
93
97 void resetGetNextStraw();
98
105 bool getNextStraw( int& hitID, float& noiselevel, float& noiseamp );
106
113 void setRefinedStrawParameters( const int& hitID,
114 const double& lowthreshold,
115 const double& noiseamplitude );
116
117protected:
118
132 virtual void setStrawStateInfo(Identifier& TRT_Identifier,
133 const double& strawlength,
134 double& noiselevel,
135 double& relative_noiseamplitude,
136 CLHEP::HepRandomEngine *rndmEngine) = 0;
137
138protected:
142
143private:
145 struct StrawState {
146 float noiselevel{};
148 float lowthreshold{};
149 };
150
151 //--- Data maps:
152
154 // StrawState is struct with members:
155 // 1) noiselevel - the same for Xenon/Argon straws
156 // 2) noiseamplitude - the same for Xenon/Argon straws
157 // 3) lowthreshold - different for Xenon and Argon straws
158 // for more info see info for setStrawStateInfo function, 28 lines above!
159
160 std::map<int,StrawState> m_hitid_to_StrawState; //<--------- 7MB!!!!
161
162 //--- iterators:
163
165 std::map<int,StrawState>::const_iterator m_it_hitid_to_StrawState{};
167 std::map<int,StrawState>::const_iterator m_it_hitid_to_StrawState_End{};
169 mutable std::map<int,StrawState>::const_iterator m_it_hitid_to_StrawState_Last ATLAS_THREAD_SAFE {}; // Guarded by m_mutex
170 mutable std::mutex m_mutex;
171
172 mutable std::atomic<float> m_averageNoiseLevel{};
175
176 //--- For iterating through all of the straw hitids:
178 std::map<int,StrawState>::iterator m_all_it_hitid_to_StrawState{};
180 std::map<int,StrawState>::iterator m_all_it_hitid_to_StrawState_previous{};
181
182protected:
184 ToolHandle<ITRT_StrawStatusSummaryTool> m_sumTool; // added by Sasha for Argon
185
186};
187
191
192//___________________________________________________________________________
193inline void TRTDigCondBase::getStrawData( const int& hitID,
194 double& lowthreshold,
195 double& noiseamplitude ) const {
196 //fixme: do we actually benefit from this caching?
197 std::lock_guard<std::mutex> lock(m_mutex);
198 if (m_it_hitid_to_StrawState_Last->first != hitID)
199 m_it_hitid_to_StrawState_Last = m_hitid_to_StrawState.find(hitID);
200
201 lowthreshold = m_it_hitid_to_StrawState_Last->second.lowthreshold;
202 noiseamplitude = m_it_hitid_to_StrawState_Last->second.noiseamplitude;
203}
204
205//___________________________________________________________________________
206inline unsigned int TRTDigCondBase::totalNumberOfActiveStraws() const {
207 return m_hitid_to_StrawState.size();
208}
209
210//___________________________________________________________________________
214
215//___________________________________________________________________________
216inline bool TRTDigCondBase::getNextStraw( int& hitID,
217 float& noiselevel,
218 float& noiseamp ) {
221 hitID = 0;
222 noiselevel = 0.;
223 return false;
224 } else {
225 hitID = m_all_it_hitid_to_StrawState->first;
226 noiselevel = m_all_it_hitid_to_StrawState->second.noiselevel;
227 noiseamp = m_all_it_hitid_to_StrawState->second.noiseamplitude;
228 return true;
229 };
230}
231
232//___________________________________________________________________________
233inline void TRTDigCondBase::setRefinedStrawParameters( const int& hitID,
234 const double& lowthreshold,
235 const double& noiseamplitude ) {
236 //we might have the iterator cached already (fixme... nah)
237 if (hitID == m_all_it_hitid_to_StrawState_previous->first) {
238 m_all_it_hitid_to_StrawState_previous->second.lowthreshold = lowthreshold;
239 m_all_it_hitid_to_StrawState_previous->second.noiseamplitude =
240 noiseamplitude;
241 } else {
243 m_hitid_to_StrawState.find(hitID)->second.lowthreshold = lowthreshold;
244 m_hitid_to_StrawState.find(hitID)->second.noiseamplitude = noiseamplitude;
245 };
246}
247
248#endif
abstract interface to TRT straw status constants
Define macros for attributes used to control the static checker.
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
The Detector Manager for all TRT Detector elements, it acts as the interface to the detector elements...
void setRefinedStrawParameters(const int &hitID, const double &lowthreshold, const double &noiseamplitude)
Set straw parameters.
double m_crosstalk_noiselevel_other_end
virtual void setStrawStateInfo(Identifier &TRT_Identifier, const double &strawlength, double &noiselevel, double &relative_noiseamplitude, CLHEP::HepRandomEngine *rndmEngine)=0
Get straw state info based on hitid and strawlength.
virtual ~TRTDigCondBase()
Destructor.
float strawAverageNoiseLevel() const
Get average noise level in straw.
std::map< int, StrawState >::const_iterator m_it_hitid_to_StrawState_End
Iterator pointing to last straw in straw state map.
std::map< int, StrawState >::const_iterator m_it_hitid_to_StrawState
Iterator over straw state map.
std::map< int, StrawState > m_hitid_to_StrawState
Global map from straw ID to straw state.
std::atomic< float > m_averageNoiseLevel
Average noise level.
const InDetDD::TRT_DetectorManager * m_detmgr
bool getNextNoisyStraw(CLHEP::HepRandomEngine *, int &hitID, float &noiselevel)
For simulation of noise in unhit straws: get next noisy straw.
const TRT_ID * m_id_helper
bool getNextStraw(int &hitID, float &noiselevel, float &noiseamp)
For looping over all straws: get next straw.
void getStrawData(const int &hitID, double &lowthreshold, double &noiseamplitude) const
Get straw data mixed condition is implemented function will return both Argon and Xenon straws (with ...
const TRTDigSettings * m_settings
TRTDigCondBase(const TRTDigSettings *, const InDetDD::TRT_DetectorManager *, const TRT_ID *, int UseGasMix, ToolHandle< ITRT_StrawStatusSummaryTool > sumTool)
Constructor.
std::mutex m_mutex
std::map< int, StrawState >::iterator m_all_it_hitid_to_StrawState
Iterator over straw state map.
std::map< int, StrawState >::iterator m_all_it_hitid_to_StrawState_previous
Iterator used for caching.
bool crossTalkNoiseOtherEnd(CLHEP::HepRandomEngine *) const
ToolHandle< ITRT_StrawStatusSummaryTool > m_sumTool
double m_crosstalk_noiselevel
void resetGetNextStraw()
For looping over all straws: Rewind straw list to start from beginning.
void resetGetNextNoisyStraw()
For noise in unhit straws: Rewind straw list to start from beginning.
bool crossTalkNoise(CLHEP::HepRandomEngine *) const
std::map< int, StrawState >::const_iterator m_it_hitid_to_StrawState_Last ATLAS_THREAD_SAFE
Iterator used for caching (ought to be called _Previous)
unsigned int totalNumberOfActiveStraws() const
Get total number of active straws.
Class containing parameters and settings used by TRT digitization.
This is an Identifier helper class for the TRT subdetector.
Definition TRT_ID.h:82
Message Stream Member.
void initialize()
float noiseamplitude
Noise amplitude.
float lowthreshold
Low threshold discriminator setting.
float noiselevel
Noise level.