ATLAS Offline Software
Loading...
Searching...
No Matches
RT_Relation_DB_DigiTool Class Reference

#include <RT_Relation_DB_DigiTool.h>

Inheritance diagram for RT_Relation_DB_DigiTool:
Collaboration diagram for RT_Relation_DB_DigiTool:

Public Member Functions

 RT_Relation_DB_DigiTool (const std::string &type, const std::string &name, const IInterface *parent)
virtual StatusCode initialize () override
virtual MdtDigiToolOutput digitize (const EventContext &ctx, const MdtDigiToolInput &input, CLHEP::HepRandomEngine *rndmEngine) const override final
ServiceHandle< StoreGateSvc > & evtStore ()
 The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
const ServiceHandle< StoreGateSvc > & detStore () const
 The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
virtual StatusCode sysInitialize () override
 Perform system initialization for an algorithm.
virtual StatusCode sysStart () override
 Handle START transition.
virtual std::vector< Gaudi::DataHandle * > inputHandles () const override
 Return this algorithm's input handles.
virtual std::vector< Gaudi::DataHandle * > outputHandles () const override
 Return this algorithm's output handles.
Gaudi::Details::PropertyBase & declareProperty (Gaudi::Property< T, V, H > &t)
void updateVHKA (Gaudi::Details::PropertyBase &)
MsgStream & msg () const
bool msgLvl (const MSG::Level lvl) const
 DeclareInterfaceID (IMDT_DigitizationTool, 1, 0)

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed.

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t

Private Member Functions

double getDriftTime (const EventContext &ctx, double measRadius, double innerTubeRadius, const Identifier &DigitId, CLHEP::HepRandomEngine *rndmEngine) const
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey>

Static Private Member Functions

static double getAdcResponse (double radius, CLHEP::HepRandomEngine *rndmEngine)

Private Attributes

SG::ReadCondHandleKey< MuonCalib::MdtCalibDataContainerm_calibDbKey
SG::ReadCondHandleKey< MuonGM::MuonDetectorManagerm_detMgrKey {this, "DetMgr", "MuonDetectorManager", ""}
Gaudi::Property< double > m_effRadius {this, "EffectiveRadius", 14.4275}
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default)
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
bool m_varHandleArraysDeclared

Detailed Description

Definition at line 32 of file RT_Relation_DB_DigiTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ RT_Relation_DB_DigiTool()

RT_Relation_DB_DigiTool::RT_Relation_DB_DigiTool ( const std::string & type,
const std::string & name,
const IInterface * parent )

Definition at line 15 of file RT_Relation_DB_DigiTool.cxx.

15 :
16 AthAlgTool(type, name, parent) {
17 declareInterface<IMDT_DigitizationTool>(this);
18}
AthAlgTool()
Default constructor:

Member Function Documentation

◆ declareGaudiProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T, V, H > & hndl,
const SG::VarHandleKeyType &  )
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158 {
160 hndl.value(),
161 hndl.documentation());
162
163 }
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)

◆ DeclareInterfaceID()

IMDT_DigitizationTool::DeclareInterfaceID ( IMDT_DigitizationTool ,
1 ,
0  )
inherited

◆ declareProperty()

Gaudi::Details::PropertyBase & AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T, V, H > & t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145 {
146 typedef typename SG::HandleClassifier<T>::type htype;
148 }
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T, V, H > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>

◆ detStore()

const ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

◆ digitize()

MdtDigiToolOutput RT_Relation_DB_DigiTool::digitize ( const EventContext & ctx,
const MdtDigiToolInput & input,
CLHEP::HepRandomEngine * rndmEngine ) const
finaloverridevirtual

Implements IMDT_DigitizationTool.

Definition at line 27 of file RT_Relation_DB_DigiTool.cxx.

29 {
30 ATH_MSG_DEBUG("Digitizing input ");
31 SG::ReadCondHandle<MuonGM::MuonDetectorManager> detMgr{m_detMgrKey, ctx};
32 const Identifier DigitId = input.getHitID();
33 const double maxTubeRadius{detMgr->getMdtReadoutElement(DigitId)->innerTubeRadius()};
34 const double radius{input.radius()};
35 const double eff = 1.0 - (m_effRadius - radius) / (m_effRadius - maxTubeRadius);
36 if ((radius < 0) || (radius > maxTubeRadius) ||
37 (radius >=m_effRadius && CLHEP::RandFlat::shoot(rndmEngine, 0.0, 1.0) > eff)) {
38 return MdtDigiToolOutput{false, 0., 0.};
39 }
40
41 MdtDigiToolOutput output(true, getDriftTime(ctx, radius, maxTubeRadius, DigitId, rndmEngine),
42 getAdcResponse(radius, rndmEngine));
43 return output;
44}
#define ATH_MSG_DEBUG(x)
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_detMgrKey
Gaudi::Property< double > m_effRadius
static double getAdcResponse(double radius, CLHEP::HepRandomEngine *rndmEngine)
double getDriftTime(const EventContext &ctx, double measRadius, double innerTubeRadius, const Identifier &DigitId, CLHEP::HepRandomEngine *rndmEngine) const
output
Definition merge.py:16

◆ evtStore()

ServiceHandle< StoreGateSvc > & AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase & ExtraDeps)
protectedinherited

Add StoreName to extra input/output deps as needed.

use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given

◆ getAdcResponse()

double RT_Relation_DB_DigiTool::getAdcResponse ( double radius,
CLHEP::HepRandomEngine * rndmEngine )
staticprivate

Definition at line 126 of file RT_Relation_DB_DigiTool.cxx.

126 {
127 // parametrization of the average adc value with respect to radius
128 constexpr double p0 = 57.38141;
129 constexpr double p1 = 8.616943;
130 constexpr double p2 = 2.497827;
131 constexpr double p3 = -1.625900;
132 constexpr double p4 = 0.3125281;
133 constexpr double p5 = -0.02929554;
134 constexpr double p6 = 0.001367115;
135 constexpr double p7 = -0.00002541936;
136
137 double adcfunc = p0 + p1 * radius + p2 * std::pow(radius, 2) + p3 * std::pow(radius, 3) + p4 * std::pow(radius, 4) +
138 p5 * std::pow(radius, 5) + p6 * std::pow(radius, 6) + p7 * std::pow(radius, 7);
139
140 // now the resolution function
141 constexpr double g0 = 10.27808;
142 constexpr double g1 = -0.3774593;
143 constexpr double g2 = 0.02751001;
144 constexpr double g3 = -0.0005994742;
145
146 double adcWidth = g0 + g1 * radius + g2 * std::pow(radius, 2) + g3 * std::pow(radius, 3);
147
148 // now smear according to adc width
149 double adc = CLHEP::RandGaussZiggurat::shoot(rndmEngine, adcfunc, adcWidth);
150
151 return adc;
152}

◆ getDriftTime()

double RT_Relation_DB_DigiTool::getDriftTime ( const EventContext & ctx,
double measRadius,
double innerTubeRadius,
const Identifier & DigitId,
CLHEP::HepRandomEngine * rndmEngine ) const
private

Definition at line 46 of file RT_Relation_DB_DigiTool.cxx.

50 {
51 // Get RT relation from DB
52 SG::ReadCondHandle<MuonCalib::MdtCalibDataContainer> calibConstants{m_calibDbKey, ctx};
53
54 if (!calibConstants.isValid()) {
55 ATH_MSG_FATAL("Failed to retrieve calib constants "<<m_calibDbKey.fullKey());
56 throw std::runtime_error("No Mdt calibration constants");
57 }
59 const RtRelationPtr& data{calibConstants->getCalibData(DigitId, msgStream())->rtRelation};
60
61 double time = 0.0;
62 double t = 0.0;
63
64 if (data) {
65 // get RT relation and resolution function
66 const MuonCalib::IRtRelation *rtRelation = data->rt();
67 const MuonCalib::IRtResolution *rtResolution = data->rtRes();
68
69 // get inverse rt and calculate time resolution
70 const MuonCalib::ITrRelation *trRelation = data->tr();
71 time = trRelation->driftTime(std::abs(measRadius)).value_or(0.);
72
73 if (time < 0.0) {
74 time = 0.0;
75 ATH_MSG_WARNING("Drift time <0 ! Returning 0.0 as drift time");
76 return (time);
77 }
78
79 double radiusWidth = rtResolution->resolution(time);
80 double velocity = rtRelation->driftVelocity(time);
81 // std::cout << "time = " << time << " drift radius = " << measRadius << " outOfBound = "<< outOfBound << " velocity = " << velocity <<
82 // std::endl;
83
84 if (velocity <= 0) {
85 ATH_MSG_WARNING("Drift velocity <=0 ! Time will not be smeared with resolution but will take the default measRadius-t value");
86 return time;
87 }
88 double timeWidth = radiusWidth / velocity;
89
90 // now smear t according to t resolution
91 double tUp = rtRelation->tUpper();
92 // double tLow = rtRelation->tLower();
93
94 double tmin = time - 3.4 * timeWidth;
95 double tmax = time + 3.4 * timeWidth;
96
97 if (tmin < 0.0) tmin = 0.0;
98 if (tmax > tUp)
99 tmax = trRelation->driftTime(innerTubeRadius).value_or(0.); // tmax = tUp+tLow; //means: tmax = (tmax of rt relation) + (one binwidth )
100
101 double gaussian;
102 constexpr double sqrt_one_over_two_pi = 0.39894228;
103 double p1r = 0.8480 * std::exp(-0.5879 * measRadius);
104 int flag = 0;
105 int cutoff = 0;
106
107 do {
108 cutoff++; // avoid eternal loop in case of problems
109 t = CLHEP::RandFlat::shoot(rndmEngine, tmin, tmax);
110
111 gaussian = (1 - p1r) * sqrt_one_over_two_pi * exp(-(t - time) * (t - time) / (2.0 * timeWidth * timeWidth));
112 if (gaussian >= CLHEP::RandFlat::shoot(rndmEngine, 0.0, 1.0) || cutoff > 200) { flag = 1; }
113 } while (flag == 0);
114
115 // print summary
116 ATH_MSG_DEBUG("t from r = " << time << " t resolution = " << timeWidth << "\nr resolution = " << radiusWidth
117 << " driftvelocity = " << velocity << "\nsmeared t = " << t << " cutoff = " << cutoff);
118 } else {
119 ATH_MSG_ERROR("Null pointer returned from CalibDBSvc. Returning 0.0 as drift time");
120 return 0.0;
121 }
122
123 return t;
124}
#define ATH_MSG_ERROR(x)
#define ATH_MSG_FATAL(x)
#define ATH_MSG_WARNING(x)
char data[hepevt_bytes_allocation_ATLAS]
Definition HepEvt.cxx:11
virtual double tUpper() const =0
Returns the upper time covered by the r-t.
virtual double driftVelocity(double t) const =0
Returns the drift velocity for a given time.
virtual double resolution(double t, double bgRate=0.0) const =0
returns resolution for a give time and background rate
virtual std::optional< double > driftTime(const double r) const =0
Interface method for fetching the drift-time from the radius Returns a nullopt if the time is out of ...
MdtFullCalibData::RtRelationPtr RtRelationPtr
SG::ReadCondHandleKey< MuonCalib::MdtCalibDataContainer > m_calibDbKey
time(flags, cells_name, *args, **kw)
bool flag
Definition master.py:29

◆ initialize()

StatusCode RT_Relation_DB_DigiTool::initialize ( )
overridevirtual

Definition at line 20 of file RT_Relation_DB_DigiTool.cxx.

20 {
21 ATH_MSG_INFO("Initializing RT_Relation_DB_DigiTool");
22 ATH_CHECK(m_calibDbKey.initialize());
23 ATH_CHECK(m_detMgrKey.initialize());
24 return StatusCode::SUCCESS;
25}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_INFO(x)

◆ inputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

Return this algorithm's input handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ msg()

MsgStream & AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24 {
25 return this->msgStream();
26 }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30 {
31 return this->msgLevel(lvl);
32 }

◆ outputHandles()

virtual std::vector< Gaudi::DataHandle * > AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

Return this algorithm's output handles.

We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.

◆ renounce()

std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T & h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381 {
382 h.renounce();
384 }
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce(T &h)

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray & handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364 {
366 }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in asg::AsgMetadataTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and DerivationFramework::CfAthAlgTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase & )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308 {
309 // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310 // << " size: " << m_vhka.size() << endmsg;
311 for (auto &a : m_vhka) {
313 for (auto k : keys) {
314 k->setOwner(this);
315 }
316 }
317 }
std::vector< SG::VarHandleKeyArray * > m_vhka

Member Data Documentation

◆ m_calibDbKey

SG::ReadCondHandleKey<MuonCalib::MdtCalibDataContainer> RT_Relation_DB_DigiTool::m_calibDbKey
private
Initial value:
{this, "CalibDataKey", "MdtCalibConstants",
"Conditions object containing the calibrations"}

Definition at line 53 of file RT_Relation_DB_DigiTool.h.

53 {this, "CalibDataKey", "MdtCalibConstants",
54 "Conditions object containing the calibrations"};

◆ m_detMgrKey

SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> RT_Relation_DB_DigiTool::m_detMgrKey {this, "DetMgr", "MuonDetectorManager", ""}
private

Definition at line 56 of file RT_Relation_DB_DigiTool.h.

56{this, "DetMgr", "MuonDetectorManager", ""};

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_effRadius

Gaudi::Property<double> RT_Relation_DB_DigiTool::m_effRadius {this, "EffectiveRadius", 14.4275}
private

Definition at line 58 of file RT_Relation_DB_DigiTool.h.

58{this, "EffectiveRadius", 14.4275};

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files: