ATLAS Offline Software
sTgcDigitizationTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef MUONDIGITIZATION_STGC_DIGITIZATIONTOOL_H
6 #define MUONDIGITIZATION_STGC_DIGITIZATIONTOOL_H
7 
20 
30 #include "CLHEP/Random/RandGaussZiggurat.h"
31 #include "CLHEP/Random/RandomEngine.h"
32 #include "CLHEP/Geometry/Point3D.h"
33 #include "CLHEP/Vector/ThreeVector.h"
35 #include "CLHEP/Units/PhysicalConstants.h"
38 
39 /*******************************************************************************/
40 namespace MuonGM{
41  class MuonDetectorManager;
42 }
43 namespace CLHEP {
44  class HepRandomEngine;
45 }
46 
47 class sTgcHitIdHelper;
48 
49 /*******************************************************************************/
51 
52 public:
53  sTgcDigitizationTool(const std::string& type, const std::string& name, const IInterface* parent);
54 
56  virtual StatusCode initialize();
57 
58  // /** When being run from PileUpToolsAlgs, this method is called at the start of
59  // the subevts loop. Not able to access SubEvents */
60  StatusCode prepareEvent(const EventContext& ctx, const unsigned int /*nInputEvents*/);
61  //
62  // /** When being run from PileUpToolsAlgs, this method is called for each active
63  // bunch-crossing to process current SubEvents bunchXing is in ns */
64  StatusCode processBunchXing(int bunchXing,
65  SubEventIterator bSubEvents,
66  SubEventIterator eSubEvents);
67 
68  // /** When being run from PileUpToolsAlgs, this method is called at the end of
69  // the subevts loop. Not (necessarily) able to access SubEvents */
70  StatusCode mergeEvent(const EventContext& ctx);
73  virtual StatusCode processAllSubEvents(const EventContext& ctx);
74 
87  StatusCode digitize(const EventContext& ctx);
88 
90  public:
91  sTgcSimDigitData() = default;
93  m_sTGCSimData{std::move(simData)},
94  m_sTGCDigit{std::move(digit)}{}
96  const MuonSimData& getSimData() const { return m_sTGCSimData; }
99  const sTgcDigit& getDigit() const { return m_sTGCDigit; }
101 
102  Identifier identify() const { return getDigit().identify(); }
103  double time() const {return getDigit().time(); }
104 
105  private:
108 
109  };
110  using sTgcSimDigitVec = std::vector<sTgcSimDigitData>;
111  using sTgcSimDigitCont = std::vector<sTgcSimDigitVec>;
112 
115  using sTgcDigtCont = std::vector<sTgcDigitVec>;
116 private:
117 
118  CLHEP::HepRandomEngine* getRandomEngine(const std::string& streamName, const EventContext& ctx) const;
119  template <class CondType> StatusCode retrieveCondData(const EventContext& ctx,
121  const CondType* & condPtr) const;
122 
124  StatusCode getNextEvent(const EventContext& ctx);
126  StatusCode doDigitization(const EventContext& ctx);
127 
128  ServiceHandle<PileUpMergeSvc> m_mergeSvc{this, "PileUpMergeSvc", "PileUpMergeSvc", "Merge service used in digitization"};
129  ServiceHandle<IAthRNGSvc> m_rndmSvc{this, "RndmSvc", "AthRNGSvc", "Random Number Service used in Muon digitization"};
130  ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};
131 
132  SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> m_detMgrKey{this, "DetectorManagerKey", "MuonDetectorManager",
133  "Key of input MuonDetectorManager condition data"};
134 
135  SG::ReadCondHandleKey<Muon::DigitEffiData> m_effiKey{this, "EffiDigiKey", "sTgcDigitEff",
136  "Key of the efficiency data in the CondStore"};
137 
138 
139  std::unique_ptr<sTgcDigitMaker> m_digitizer{};
140  std::unique_ptr<TimedHitCollection<sTGCSimHit>> m_thpcsTGC{};
141  std::vector<std::unique_ptr<sTGCSimHitCollection>> m_STGCHitCollList{};
142 
143  ToolHandle<Muon::INSWCalibSmearingTool> m_smearingTool{this,"SmearingTool","Muon::NSWCalibSmearingTool/STgcCalibSmearingTool"};
144  ToolHandle<Muon::INSWCalibTool> m_calibTool{this,"CalibrationTool","Muon::NSWCalibTool/NSWCalibTool"};
145 
146  SG::WriteHandleKey<sTgcDigitContainer> m_outputDigitCollectionKey{this,"OutputObjectName","sTGC_DIGITS","WriteHandleKey for Output sTgcDigitContainer"}; // name of the output digits
147  SG::WriteHandleKey<MuonSimDataCollection> m_outputSDO_CollectionKey{this,"OutputSDOName","sTGC_SDO","WriteHandleKey for Output MuonSimDataCollection"}; // name of the output SDOs
148 
149  Gaudi::Property<bool> m_doSmearing{this,"doSmearing",false};
150  Gaudi::Property<bool> m_doToFCorrection{this,"doToFCorrection",false};
151  Gaudi::Property<bool> m_doEfficiencyCorrection{this,"doEfficiencyCorrection",false};
152 
153  // voltage applied to gas gaps: Nominal condition in RUN3 as of Nov 2022 is 2.8 kV
154  // this value serves to modify the gas gain caused by the electric field in the sTGC
155  Gaudi::Property<double> m_runVoltage{this,"operatingHVinkV",2.8};
156 
157  Gaudi::Property<std::string> m_rndmEngineName{this,"RndmEngine","MuonDigitization","Random engine name"};
158 
159  Gaudi::Property<bool> m_onlyUseContainerName{this, "OnlyUseContainerName", true, "Don't use the ReadHandleKey directly. Just extract the container name from it."};
160  SG::ReadHandleKey<sTGCSimHitCollection> m_hitsContainerKey{this, "InputObjectName", "sTGC_Hits", "name of the input object"};
161  std::string m_inputObjectName{""};
162 
163  Gaudi::Property<bool> m_useCondThresholds{this, "useCondThresholds", false, "Use conditions data to get VMM charge threshold values"};
164  SG::ReadCondHandleKey<NswCalibDbThresholdData> m_condThrshldsKey {this, "CondThrshldsKey", "NswCalibDbThresholdData", "Key of NswCalibDbThresholdData object containing calibration data (VMM thresholds)"};
165 
166  Gaudi::Property<int> m_doChannelTypes{this,"doChannelTypes",3};
167  Gaudi::Property<bool> m_doPadSharing{this,"padChargeSharing", false};
168 
169  // sTgc VMM configurables accessible by python steering
170  Gaudi::Property<double> m_deadtimeStrip{this,"deadtimeStrip", 250};
171  Gaudi::Property<double> m_deadtimePad{this,"deadtimePad" , 250};
172  Gaudi::Property<double> m_deadtimeWire{this,"deadtimeWire" , 250};
173  Gaudi::Property<bool> m_doNeighborOn{this,"neighborOn", true};
174 
175  Gaudi::Property<double> m_energyDepositThreshold{this,"energyDepositThreshold",300.0*CLHEP::eV,"Minimum energy deposit for hit to be digitized"};
176  Gaudi::Property<double> m_limitElectronKineticEnergy{this,"limitElectronKineticEnergy",5.0*CLHEP::MeV,"Minimum kinetic energy for electron hit to be digitized"};
177 
178  Gaudi::Property<double> m_chargeThreshold{this,"chargeThreshold", 0.002, "vmm charge threshold in pC, need to set useCondThresholds to false if one wants to use this threshold value otherwise the one from the conditions database is used"};
179 
180  Gaudi::Property<double> m_stripChargeScale{this, "stripChargeScale",0.4, "strip charge scale"};
181 
182  const double m_timeJitterElectronicsStrip{2.f}; //ns
183  const double m_timeJitterElectronicsPad{2.f}; //ns
184  const double m_hitTimeMergeThreshold{30.f}; //30ns = resolution of peak finding descriminator
185 
186  static uint16_t bcTagging(const double digittime) ;
187 
188  double getChannelThreshold(const EventContext& ctx,
189  const Identifier& channelID,
190  const NswCalibDbThresholdData& thresholdData) const;
191 
192 
193  StatusCode processDigitsWithVMM(const EventContext& ctx,
194  const DigiConditions& digiCond,
195  sTgcSimDigitCont& unmergedContainer,
196  const double vmmDeadTime,
197  const bool isNeighbourOn,
198  sTgcDigtCont& outDigitContainer,
199  MuonSimDataCollection& outSdoContainer) const;
200 
201  sTgcSimDigitVec processDigitsWithVMM(const EventContext& ctx,
202  const DigiConditions& digiCond,
203  const double vmmDeadTime,
204  sTgcSimDigitVec& unmergedDigits,
205  const bool isNeighborOn) const;
206 
207 };
208 
209 #endif // MUONDIGITIZATION_STGC_DIGITIZATIONTOOL_H
sTgcDigitizationTool::m_doSmearing
Gaudi::Property< bool > m_doSmearing
Definition: sTgcDigitizationTool.h:149
sTgcDigitizationTool::getChannelThreshold
double getChannelThreshold(const EventContext &ctx, const Identifier &channelID, const NswCalibDbThresholdData &thresholdData) const
Definition: sTgcDigitizationTool.cxx:558
sTgcDigitizationTool::m_mergeSvc
ServiceHandle< PileUpMergeSvc > m_mergeSvc
Definition: sTgcDigitizationTool.h:128
MuonGM
Ensure that the Athena extensions are properly loaded.
Definition: GeoMuonHits.h:27
sTgcDigitizationTool::sTgcDigitizationTool
sTgcDigitizationTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: sTgcDigitizationTool.cxx:52
NswCalibDbThresholdData
Definition: NswCalibDbThresholdData.h:17
sTgcDigitizationTool::m_doToFCorrection
Gaudi::Property< bool > m_doToFCorrection
Definition: sTgcDigitizationTool.h:150
sTgcDigitizationTool::DigiConditions
sTgcDigitMaker::DigiConditions DigiConditions
Definition: sTgcDigitizationTool.h:113
sTgcDigitizationTool::m_doEfficiencyCorrection
Gaudi::Property< bool > m_doEfficiencyCorrection
Definition: sTgcDigitizationTool.h:151
sTgcDigitizationTool::retrieveCondData
StatusCode retrieveCondData(const EventContext &ctx, SG::ReadCondHandleKey< CondType > &key, const CondType *&condPtr) const
Definition: sTgcDigitizationTool.cxx:259
sTgcDigitizationTool::initialize
virtual StatusCode initialize()
Initialize.
Definition: sTgcDigitizationTool.cxx:58
python.SystemOfUnits.MeV
int MeV
Definition: SystemOfUnits.py:154
sTgcDigitizationTool::m_smearingTool
ToolHandle< Muon::INSWCalibSmearingTool > m_smearingTool
Definition: sTgcDigitizationTool.h:143
sTGCSimHit.h
sTgcSimDigitVec
sTgcDigitizationTool::sTgcSimDigitVec sTgcSimDigitVec
Definition: sTgcDigitizationTool.cxx:48
INSWCalibTool.h
sTGCSimHitCollection.h
sTgcDigitizationTool::m_deadtimePad
Gaudi::Property< double > m_deadtimePad
Definition: sTgcDigitizationTool.h:171
sTgcDigitMaker::DigiConditions
Digitize a given hit, determining the time and charge spread on wires, pads and strips.
Definition: sTgcDigitMaker.h:57
checkRpcDigits.digit
digit
Definition: checkRpcDigits.py:186
sTgcDigitizationTool::m_deadtimeWire
Gaudi::Property< double > m_deadtimeWire
Definition: sTgcDigitizationTool.h:172
SG::ReadHandleKey
Property holding a SG store/key/clid from which a ReadHandle is made.
Definition: StoreGate/StoreGate/ReadHandleKey.h:39
sTgcDigitizationTool::m_energyDepositThreshold
Gaudi::Property< double > m_energyDepositThreshold
Definition: sTgcDigitizationTool.h:175
sTgcDigitizationTool::sTgcDigitVec
sTgcDigitMaker::sTgcDigitVec sTgcDigitVec
Definition: sTgcDigitizationTool.h:114
sTgcDigitizationTool::m_doNeighborOn
Gaudi::Property< bool > m_doNeighborOn
Definition: sTgcDigitizationTool.h:173
sTgcDigitizationTool::m_inputObjectName
std::string m_inputObjectName
Definition: sTgcDigitizationTool.h:161
sTgcDigitizationTool::m_condThrshldsKey
SG::ReadCondHandleKey< NswCalibDbThresholdData > m_condThrshldsKey
Definition: sTgcDigitizationTool.h:164
sTgcDigitizationTool::sTgcSimDigitData::getDigit
const sTgcDigit & getDigit() const
Get the sTGC digit.
Definition: sTgcDigitizationTool.h:99
sTgcDigitizationTool::m_chargeThreshold
Gaudi::Property< double > m_chargeThreshold
Definition: sTgcDigitizationTool.h:178
sTgcDigitizationTool::getNextEvent
StatusCode getNextEvent(const EventContext &ctx)
Get next event and extract collection of hit collections.
Definition: sTgcDigitizationTool.cxx:173
sTgcDigitizationTool::sTgcSimDigitData::getSimData
MuonSimData & getSimData()
Definition: sTgcDigitizationTool.h:97
sTgcDigit
Definition: sTgcDigit.h:20
sTgcDigitizationTool::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: sTgcDigitizationTool.h:130
sTgcDigitizationTool::sTgcSimDigitData::time
double time() const
Definition: sTgcDigitizationTool.h:103
sTgcDigitizationTool::m_doPadSharing
Gaudi::Property< bool > m_doPadSharing
Definition: sTgcDigitizationTool.h:167
sTgcDigitizationTool::processAllSubEvents
virtual StatusCode processAllSubEvents(const EventContext &ctx)
alternative interface which uses the PileUpMergeSvc to obtain all the required SubEvents.
Definition: sTgcDigitizationTool.cxx:246
sTgcDigitizationTool::m_digitizer
std::unique_ptr< sTgcDigitMaker > m_digitizer
Definition: sTgcDigitizationTool.h:139
sTgcDigitizationTool::m_useCondThresholds
Gaudi::Property< bool > m_useCondThresholds
Definition: sTgcDigitizationTool.h:163
sTgcDigitizationTool::m_calibTool
ToolHandle< Muon::INSWCalibTool > m_calibTool
Definition: sTgcDigitizationTool.h:144
sTgcDigitizationTool::m_timeJitterElectronicsPad
const double m_timeJitterElectronicsPad
Definition: sTgcDigitizationTool.h:183
SG::WriteHandleKey< sTgcDigitContainer >
sTgcDigitizationTool::sTgcSimDigitData::m_sTGCSimData
MuonSimData m_sTGCSimData
Definition: sTgcDigitizationTool.h:106
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:88
sTgcDigitizationTool::m_hitsContainerKey
SG::ReadHandleKey< sTGCSimHitCollection > m_hitsContainerKey
Definition: sTgcDigitizationTool.h:160
sTgcDigitizationTool::m_doChannelTypes
Gaudi::Property< int > m_doChannelTypes
Definition: sTgcDigitizationTool.h:166
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
sTgcDigitizationTool::m_effiKey
SG::ReadCondHandleKey< Muon::DigitEffiData > m_effiKey
Definition: sTgcDigitizationTool.h:135
CLHEP
STD'S.
Definition: IAtRndmGenSvc.h:19
MuonSimDataCollection
Definition: MuonSimDataCollection.h:21
sTgcDigit::time
float time() const
Definition: sTgcDigit.cxx:61
sTgcDigitizationTool::m_rndmSvc
ServiceHandle< IAthRNGSvc > m_rndmSvc
Definition: sTgcDigitizationTool.h:129
sTgcDigitizationTool::m_deadtimeStrip
Gaudi::Property< double > m_deadtimeStrip
Definition: sTgcDigitizationTool.h:170
test_pyathena.parent
parent
Definition: test_pyathena.py:15
TimedHitCollection.h
sTgcDigitizationTool::processBunchXing
StatusCode processBunchXing(int bunchXing, SubEventIterator bSubEvents, SubEventIterator eSubEvents)
Definition: sTgcDigitizationTool.cxx:133
sTgcDigitizationTool::m_limitElectronKineticEnergy
Gaudi::Property< double > m_limitElectronKineticEnergy
Definition: sTgcDigitizationTool.h:176
sTgcDigitizationTool::sTgcSimDigitData::sTgcSimDigitData
sTgcSimDigitData()=default
sTgcDigitizationTool::sTgcSimDigitCont
std::vector< sTgcSimDigitVec > sTgcSimDigitCont
Definition: sTgcDigitizationTool.h:111
PileUpToolBase
Definition: PileUpToolBase.h:18
sTgcDigitizationTool::m_timeJitterElectronicsStrip
const double m_timeJitterElectronicsStrip
Definition: sTgcDigitizationTool.h:182
sTgcDigitizationTool::sTgcSimDigitVec
std::vector< sTgcSimDigitData > sTgcSimDigitVec
Definition: sTgcDigitizationTool.h:110
sTgcDigitizationTool::m_onlyUseContainerName
Gaudi::Property< bool > m_onlyUseContainerName
Definition: sTgcDigitizationTool.h:159
sTgcDigitizationTool::prepareEvent
StatusCode prepareEvent(const EventContext &ctx, const unsigned int)
Definition: sTgcDigitizationTool.cxx:124
sTgcDigitizationTool::m_rndmEngineName
Gaudi::Property< std::string > m_rndmEngineName
Definition: sTgcDigitizationTool.h:157
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
sTgcDigitizationTool::processDigitsWithVMM
StatusCode processDigitsWithVMM(const EventContext &ctx, const DigiConditions &digiCond, sTgcSimDigitCont &unmergedContainer, const double vmmDeadTime, const bool isNeighbourOn, sTgcDigtCont &outDigitContainer, MuonSimDataCollection &outSdoContainer) const
Definition: sTgcDigitizationTool.cxx:583
sTgcDigitizationTool::mergeEvent
StatusCode mergeEvent(const EventContext &ctx)
Definition: sTgcDigitizationTool.cxx:232
python.SystemOfUnits.eV
int eV
Definition: SystemOfUnits.py:155
sTgcDigitizationTool::doDigitization
StatusCode doDigitization(const EventContext &ctx)
Core part of digitization use by mergeEvent (IPileUpTool) and digitize (IMuonDigitizationTool)
Definition: sTgcDigitizationTool.cxx:277
sTgcDigitizationTool::sTgcSimDigitData::getDigit
sTgcDigit & getDigit()
Definition: sTgcDigitizationTool.h:100
MuonSimData
Definition: MuonSimData.h:62
EventInfo.h
SG::ReadCondHandleKey
Definition: ReadCondHandleKey.h:20
MuonDigit::identify
Identifier identify() const
Definition: MuonDigit.h:30
sTgcDigitizationTool::getRandomEngine
CLHEP::HepRandomEngine * getRandomEngine(const std::string &streamName, const EventContext &ctx) const
Definition: sTgcDigitizationTool.cxx:573
AthenaPoolExample_Copy.streamName
string streamName
Definition: AthenaPoolExample_Copy.py:39
sTgcDigitizationTool::m_outputDigitCollectionKey
SG::WriteHandleKey< sTgcDigitContainer > m_outputDigitCollectionKey
Definition: sTgcDigitizationTool.h:146
sTgcHitIdHelper
Definition: sTgcHitIdHelper.h:13
sTgcDigitizationTool::m_stripChargeScale
Gaudi::Property< double > m_stripChargeScale
Definition: sTgcDigitizationTool.h:180
PileUpMergeSvc.h
the preferred mechanism to access information from the different event stores in a pileup job.
sTgcDigitizationTool::sTgcSimDigitData
Definition: sTgcDigitizationTool.h:89
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
sTgcDigitizationTool::sTgcDigtCont
std::vector< sTgcDigitVec > sTgcDigtCont
Definition: sTgcDigitizationTool.h:115
sTgcDigitizationTool::m_hitTimeMergeThreshold
const double m_hitTimeMergeThreshold
Definition: sTgcDigitizationTool.h:184
sTgcDigitizationTool::sTgcSimDigitData::m_sTGCDigit
sTgcDigit m_sTGCDigit
Definition: sTgcDigitizationTool.h:107
sTgcDigitizationTool::m_STGCHitCollList
std::vector< std::unique_ptr< sTGCSimHitCollection > > m_STGCHitCollList
Definition: sTgcDigitizationTool.h:141
sTgcDigitizationTool::sTgcSimDigitData::identify
Identifier identify() const
Definition: sTgcDigitizationTool.h:102
sTgcDigitMaker::sTgcDigitVec
std::vector< std::unique_ptr< sTgcDigit > > sTgcDigitVec
Definition: sTgcDigitMaker.h:64
sTgcDigitContainer.h
DigitEffiData.h
SubEventIterator
std::vector< xAOD::EventInfo::SubEvent >::const_iterator SubEventIterator
Definition: IPileUpTool.h:22
sTgcDigitMaker.h
simData
constexpr bool simData
Definition: constants.h:36
MuonSimDataCollection.h
sTgcDigitizationTool::digitize
StatusCode digitize(const EventContext &ctx)
Just calls processAllSubEvents - leaving for back-compatibility (IMuonDigitizationTool)
Definition: sTgcDigitizationTool.cxx:242
INSWCalibSmearingTool.h
PileUpToolBase.h
helper base class IPileUpTool::toProcess().
sTgcDigitizationTool::sTgcSimDigitData::getSimData
const MuonSimData & getSimData() const
Get the SimData.
Definition: sTgcDigitizationTool.h:96
sTgcDigitizationTool::m_runVoltage
Gaudi::Property< double > m_runVoltage
Definition: sTgcDigitizationTool.h:155
sTgcDigitizationTool::m_thpcsTGC
std::unique_ptr< TimedHitCollection< sTGCSimHit > > m_thpcsTGC
Definition: sTgcDigitizationTool.h:140
sTgcDigitizationTool::m_outputSDO_CollectionKey
SG::WriteHandleKey< MuonSimDataCollection > m_outputSDO_CollectionKey
Definition: sTgcDigitizationTool.h:147
sTgcDigitizationTool::m_detMgrKey
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_detMgrKey
Definition: sTgcDigitizationTool.h:132
sTgcDigitizationTool
Definition: sTgcDigitizationTool.h:50
IMuonIdHelperSvc.h
sTgcDigitizationTool::bcTagging
static uint16_t bcTagging(const double digittime)
Definition: sTgcDigitizationTool.cxx:545
IAthRNGSvc.h
ServiceHandle< PileUpMergeSvc >
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
sTgcDigitizationTool::sTgcSimDigitData::sTgcSimDigitData
sTgcSimDigitData(MuonSimData &&simData, sTgcDigit &&digit)
Definition: sTgcDigitizationTool.h:92
Identifier
Definition: IdentifierFieldParser.cxx:14