ATLAS Offline Software
MM_DigitizationTool.h
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 #ifndef MM_DIGITIZATIONTOOL_H
6 #define MM_DIGITIZATIONTOOL_H
7 
16 
34 #include <memory>
35 #include <sstream>
36 #include <string>
37 #include <vector>
38 
40 #include "CLHEP/Geometry/Point3D.h"
41 #include "CLHEP/Random/RandomEngine.h"
42 #include "CLHEP/Vector/ThreeVector.h"
43 #include "GaudiKernel/AlgTool.h"
44 #include "GaudiKernel/ServiceHandle.h"
45 #include "GaudiKernel/ToolHandle.h"
57 #include "MuonSimEvent/MMSimHit.h"
64 #include "xAODEventInfo/EventAuxInfo.h" // SubEventIterator
65 #include "xAODEventInfo/EventInfo.h" // SubEventIterator
67 
68 /*******************************************************************************/
69 
71 class TTree;
72 class TFile;
73 
74 /*******************************************************************************/
75 
77 public:
78  MM_DigitizationTool(const std::string& type, const std::string& name, const IInterface* parent);
79 
81  virtual StatusCode initialize() override final;
82 
84  StatusCode prepareEvent(const EventContext& ctx, const unsigned int /*nInputEvents*/) override final;
85 
88  StatusCode processBunchXing(int bunchXing, SubEventIterator bSubEvents, SubEventIterator eSubEvents) override final;
89 
92  StatusCode mergeEvent(const EventContext& ctx) override final;
93 
98  virtual StatusCode processAllSubEvents(const EventContext& ctx) override;
99 
102  StatusCode digitize(const EventContext& ctx);
103 
104 private:
105  CLHEP::HepRandomEngine* getRandomEngine(const std::string& streamName, const EventContext& ctx) const;
107  StatusCode getNextEvent(const EventContext& ctx);
108  StatusCode doDigitization(const EventContext& ctx);
109 
110  bool checkMMSimHit(const MMSimHit& /* hit */) const;
111  MM_ElectronicsToolInput combinedStripResponseAllHits(const std::vector<MM_ElectronicsToolInput>& v_stripDigitOutput);
112 
113  ServiceHandle<IAthRNGSvc> m_rndmSvc{this, "RndmSvc", "AthRNGSvc", "Random Number Service used in Muon digitization"};
114  Gaudi::Property<std::string> m_rndmEngineName{this, "RndmEngine", "MuonDigitization", "Random engine name"};
115 
116  ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc{this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};
117  ToolHandle<Muon::INSWCalibSmearingTool> m_smearingTool{this, "SmearingTool", "Muon::NSWCalibSmearingTool/MMCalibSmearingTool"};
118  ToolHandle<Muon::INSWCalibTool> m_calibrationTool{this, "CalibrationTool", "Muon::NSWCalibTool/NSWCalibTool"};
119 
120  SG::ReadCondHandleKey<AtlasFieldCacheCondObj> m_fieldCondObjInputKey{this, "AtlasFieldCacheCondObj", "fieldCondObj"};
122  this, "CondThrshldsKey", "NswCalibDbThresholdData",
123  "Key of NswCalibDbThresholdData object containing calibration data (VMM thresholds)"};
124 
125  Gaudi::Property<bool> m_onlyUseContainerName{this, "OnlyUseContainerName", true,
126  "Don't use the ReadHandleKey directly. Just extract the container name from it."};
127  SG::ReadHandleKey<MMSimHitCollection> m_hitsContainerKey{this, "InputObjectName", "MM_Hits", "name of the input objects"};
128  std::string m_inputObjectName{""};
129 
130  Gaudi::Property<std::string> m_vmmReadoutMode{this, "vmmReadoutMode", "peak", "For readout (DAQ) path. Can be peak or threshold"};
131  Gaudi::Property<std::string> m_vmmARTMode{this, "vmmARTMode", "threshold", "For ART (trigger) path. Can be peak or threshold"};
132 
133  Gaudi::Property<double> m_energyThreshold{this, "EnergyThreshold", 50, "Minimal energy to produce a PRD"};
134  Gaudi::Property<double> m_timeWindowLowerOffset{this, "WindowLowerOffset", -12.5,
135  "lower boundary of the time window in which digits are accepted"};
136  Gaudi::Property<double> m_timeWindowUpperOffset{this, "WindowUpperOffset", 187.5,
137  "upper boundary of the time window in which digits are accepted"};
138  Gaudi::Property<double> m_DiffMagSecondMuonHit{this, "DiffMagSecondMuonHit", 0.1};
139 
140  Gaudi::Property<int> m_maskMultiplet{this, "MaskMultiplet", 0, "0: all, 1: first, 2: second, 3: both"};
141 
142  Gaudi::Property<bool> m_writeOutputFile{this, "SaveInternalHistos", false};
143  Gaudi::Property<bool> m_needsMcEventCollHelper{this, "UseMcEventCollectionHelper", false};
144  Gaudi::Property<bool> m_checkMMSimHits{this, "CheckSimHits", true, "Control on the hit validity"};
145  Gaudi::Property<bool> m_useTimeWindow{this, "UseTimeWindow", true};
146  Gaudi::Property<bool> m_vmmNeighborLogic{this, "VMMNeighborLogic", false};
147  Gaudi::Property<bool> m_doSmearing{this, "doSmearing", true,
148  "set the usage or not of the smearing tool for realistic detector performance"};
149  // Constants vars for the MM_StripsResponseSimulation class
150  // qThreshold=2e, we accept a good strip if the charge is >=2e
151 
152  // Three gas mixture mode, Ar/CO2=93/7, Ar/CO2=80/20, Ar/CO2/Iso=93/5/2
153  // each mode have different
154  // transverseDiffusionSigma/longitudinalDiffusionSigma/driftVelocity/avalancheGain/interactionDensityMean/interactionDensitySigma/lorentzAngle
155  Gaudi::Property<float> m_qThreshold{this, "qThreshold", 0.001, "Charge Threshold"};
156  Gaudi::Property<float> m_driftGapWidth{this, "DriftGapWidth", 5.04, "Drift Gap Width of 5.04 mm"};
157  Gaudi::Property<float> m_crossTalk1{this, "crossTalk1", 0.3, "Strip Cross Talk with Nearest Neighbor"};
158  Gaudi::Property<float> m_crossTalk2{this, "crossTalk2", 0.09, "Strip Cross Talk with 2nd Nearest Neighbor"};
159 
160  Gaudi::Property<float> m_avalancheGain{this, "AvalancheGain", 6.0e3, "avalanche Gain for rach gas mixture"};
161 
162  // Constants vars for the MM_ElectronicsResponseSimulation
163  Gaudi::Property<float> m_electronicsThreshold{this, "electronicsThreshold", 15000,
164  "threshold Voltage for histoBNL, 2*(Intrinsic noise ~3k e)"};
165  Gaudi::Property<float> m_stripdeadtime{this, "StripDeadTime", 200, "dead-time for strip, default value 200 ns = 8 BCs"};
166  Gaudi::Property<float> m_ARTdeadtime{this, "ARTDeadTime", 200, "dead-time for ART, default value 200 ns = 8 BCs"};
167 
169  this, "OutputObjectName", "MM_DIGITS", "WriteHandleKey for Output MmigitContainer"}; // name of the output digits
171  this, "OutputSDOName", "MM_SDO", "WriteHandleKey for Output MuonSimDataCollection"}; // name of the output SDOs
172 
173  ServiceHandle<PileUpMergeSvc> m_mergeSvc{this, "MergeSvc", "PileUpMergeSvc", "Merge service used in digitization"};
174 
175  Gaudi::Property<bool> m_useCondThresholds{this, "useCondThresholds", false,
176  "Use conditions data to get thresholds, overrules useThresholdScaling"};
177  Gaudi::Property<bool> m_useThresholdScaling{this, "useThresholdScaling", true,
178  "Use a strip length dependent threshold in MM digitiation"};
179  Gaudi::Property<float> m_thresholdScaleFactor{this, "thresholdScaleFactor", 7.0,
180  "Use x times the strip length dependent noise as MM threshold"};
181  Gaudi::Property<float> m_vmmDeadtime{
182  this, "vmmDeadtime", 200, "Specifies how much before the lower time limit the VMM simulation should start evaluating the signal"};
183  // The following job option is a hack until the underlying bug in the VMM sim is found which creates a peak at the upper boundary of the
184  // time window.
185  Gaudi::Property<float> m_vmmUpperGrazeWindow{
186  this, "vmmUpperGrazeWindow", 150, "Specifies how much above the upper time window boundary the VMM sim evaluates the signal."};
187 
188 
189  const MicromegasHitIdHelper* m_muonHelper{nullptr}; // not owned
190  SG::ReadCondHandleKey<MuonGM::MuonDetectorManager> m_DetectorManagerKey{this, "DetectorManagerKey", "MuonDetectorManager",
191  "Key of input MuonDetectorManager condition data"};
192 
193  std::list<std::unique_ptr<MMSimHitCollection>> m_MMHitCollList{};
194  std::unique_ptr<TimedHitCollection<MMSimHit>> m_timedHitCollection_MM{}; // the pileup hits
195  std::unique_ptr<MM_StripsResponseSimulation> m_StripsResponseSimulation{};
196  std::unique_ptr<MM_ElectronicsResponseSimulation> m_ElectronicsResponseSimulation{};
197 
201  std::map<int, NoiseCalibConstants> m_noiseParams{};
202 };
203 
204 #endif // MM_DigitizationTool
MM_DigitizationTool::m_DetectorManagerKey
SG::ReadCondHandleKey< MuonGM::MuonDetectorManager > m_DetectorManagerKey
Definition: MM_DigitizationTool.h:190
MM_DigitizationTool::m_thresholdScaleFactor
Gaudi::Property< float > m_thresholdScaleFactor
Definition: MM_DigitizationTool.h:179
MM_DigitizationTool::m_vmmUpperGrazeWindow
Gaudi::Property< float > m_vmmUpperGrazeWindow
Definition: MM_DigitizationTool.h:185
MMSimHit
Definition: MMSimHit.h:15
MM_ElectronicsResponseSimulation.h
MM_DigitizationTool::m_ARTdeadtime
Gaudi::Property< float > m_ARTdeadtime
Definition: MM_DigitizationTool.h:166
MM_DigitizationTool::m_timeWindowLowerOffset
Gaudi::Property< double > m_timeWindowLowerOffset
Definition: MM_DigitizationTool.h:134
MM_DigitizationTool::m_maskMultiplet
Gaudi::Property< int > m_maskMultiplet
Definition: MM_DigitizationTool.h:140
NswCalibDbTimeChargeData::CalibConstants
Helper struct to cache all calibration constants in a common place of the memory.
Definition: NswCalibDbTimeChargeData.h:28
NswCalibDbTimeChargeData.h
MM_DigitizationTool::doDigitization
StatusCode doDigitization(const EventContext &ctx)
Definition: MM_DigitizationTool.cxx:413
AtlasFieldCacheCondObj.h
MM_DigitizationTool::getRandomEngine
CLHEP::HepRandomEngine * getRandomEngine(const std::string &streamName, const EventContext &ctx) const
Definition: MM_DigitizationTool.cxx:897
MM_DigitizationTool::m_mergeSvc
ServiceHandle< PileUpMergeSvc > m_mergeSvc
Definition: MM_DigitizationTool.h:173
MM_DigitizationTool::MM_DigitizationTool
MM_DigitizationTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: MM_DigitizationTool.cxx:65
MM_DigitizationTool::initialize
virtual StatusCode initialize() override final
Initialize.
Definition: MM_DigitizationTool.cxx:71
INSWCalibTool.h
MM_DigitizationTool::digitize
StatusCode digitize(const EventContext &ctx)
Just calls processAllSubEvents - leaving for back-compatibility (IMuonDigitizationTool)
Definition: MM_DigitizationTool.cxx:396
MM_DigitizationTool::processAllSubEvents
virtual StatusCode processAllSubEvents(const EventContext &ctx) override
When being run from MM_Digitizer, this method is called during the event loop.
Definition: MM_DigitizationTool.cxx:398
MM_DigitizationTool::m_useTimeWindow
Gaudi::Property< bool > m_useTimeWindow
Definition: MM_DigitizationTool.h:145
MM_DigitizationTool
Definition: MM_DigitizationTool.h:76
MM_DigitizationTool::m_StripsResponseSimulation
std::unique_ptr< MM_StripsResponseSimulation > m_StripsResponseSimulation
Definition: MM_DigitizationTool.h:195
MM_DigitizationTool::checkMMSimHit
bool checkMMSimHit(const MMSimHit &) const
Definition: MM_DigitizationTool.cxx:895
SG::ReadHandleKey
Property holding a SG store/key/clid from which a ReadHandle is made.
Definition: StoreGate/StoreGate/ReadHandleKey.h:39
MM_DigitizationTool::processBunchXing
StatusCode processBunchXing(int bunchXing, SubEventIterator bSubEvents, SubEventIterator eSubEvents) override final
When being run from PileUpToolsAlgs, this method is called for each active bunch-crossing to process ...
Definition: MM_DigitizationTool.cxx:294
MM_DigitizationTool::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: MM_DigitizationTool.h:116
MM_DigitizationTool::m_rndmSvc
ServiceHandle< IAthRNGSvc > m_rndmSvc
Definition: MM_DigitizationTool.h:113
MM_SortedHitVector.h
MM_DigitizationTool::m_MMHitCollList
std::list< std::unique_ptr< MMSimHitCollection > > m_MMHitCollList
Definition: MM_DigitizationTool.h:193
MM_DigitizationTool::m_noiseParams
std::map< int, NoiseCalibConstants > m_noiseParams
Define a map to cache the noise parameters individually Key: stationName * std::abs(stationEta)
Definition: MM_DigitizationTool.h:201
MM_DigitizationTool::m_fieldCondObjInputKey
SG::ReadCondHandleKey< AtlasFieldCacheCondObj > m_fieldCondObjInputKey
Definition: MM_DigitizationTool.h:120
MM_DigitizationTool::m_muonHelper
const MicromegasHitIdHelper * m_muonHelper
Definition: MM_DigitizationTool.h:189
MM_ElectronicsToolInput
Definition: MM_ElectronicsToolInput.h:9
MMSimHit.h
SG::WriteHandleKey< MmDigitContainer >
MM_DigitizationTool::m_vmmNeighborLogic
Gaudi::Property< bool > m_vmmNeighborLogic
Definition: MM_DigitizationTool.h:146
MmDigitContainer.h
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
MM_DigitizationTool::m_calibrationTool
ToolHandle< Muon::INSWCalibTool > m_calibrationTool
Definition: MM_DigitizationTool.h:118
MM_DigitizationTool::m_timeWindowUpperOffset
Gaudi::Property< double > m_timeWindowUpperOffset
Definition: MM_DigitizationTool.h:136
MM_DigitizationTool::m_rndmEngineName
Gaudi::Property< std::string > m_rndmEngineName
Definition: MM_DigitizationTool.h:114
AtlasFieldCache.h
test_pyathena.parent
parent
Definition: test_pyathena.py:15
TimedHitCollection.h
MM_DigitizationTool::m_ElectronicsResponseSimulation
std::unique_ptr< MM_ElectronicsResponseSimulation > m_ElectronicsResponseSimulation
Definition: MM_DigitizationTool.h:196
MM_DigitizationTool::m_writeOutputFile
Gaudi::Property< bool > m_writeOutputFile
Definition: MM_DigitizationTool.h:142
MicromegasHitIdHelper
Definition: MicromegasHitIdHelper.h:13
MM_DigitizationTool::m_useCondThresholds
Gaudi::Property< bool > m_useCondThresholds
Definition: MM_DigitizationTool.h:175
PileUpToolBase
Definition: PileUpToolBase.h:18
ReadCondHandleKey.h
MM_DigitizationTool::m_vmmReadoutMode
Gaudi::Property< std::string > m_vmmReadoutMode
Definition: MM_DigitizationTool.h:130
MM_DigitizationTool::m_outputSDO_CollectionKey
SG::WriteHandleKey< MuonSimDataCollection > m_outputSDO_CollectionKey
Definition: MM_DigitizationTool.h:170
EventAuxInfo.h
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
MMSimHitCollection.h
MM_DigitizationTool::getNextEvent
StatusCode getNextEvent(const EventContext &ctx)
Record MmDigitContainer and MuonSimDataCollection.
Definition: MM_DigitizationTool.cxx:326
MM_DigitizationTool::m_avalancheGain
Gaudi::Property< float > m_avalancheGain
Definition: MM_DigitizationTool.h:160
MM_StripsResponseSimulation.h
MuonDetectorManager.h
MM_DigitizationTool::m_energyThreshold
Gaudi::Property< double > m_energyThreshold
Definition: MM_DigitizationTool.h:133
EventInfo.h
MM_DigitizationTool::m_stripdeadtime
Gaudi::Property< float > m_stripdeadtime
Definition: MM_DigitizationTool.h:165
MM_DigitizationTool::m_timedHitCollection_MM
std::unique_ptr< TimedHitCollection< MMSimHit > > m_timedHitCollection_MM
Definition: MM_DigitizationTool.h:194
MM_DigitizationTool::m_electronicsThreshold
Gaudi::Property< float > m_electronicsThreshold
Definition: MM_DigitizationTool.h:163
SG::ReadCondHandleKey< AtlasFieldCacheCondObj >
MM_DigitizationTool::m_qThreshold
Gaudi::Property< float > m_qThreshold
Definition: MM_DigitizationTool.h:155
AthenaPoolExample_Copy.streamName
string streamName
Definition: AthenaPoolExample_Copy.py:39
MM_DigitizationTool::m_smearingTool
ToolHandle< Muon::INSWCalibSmearingTool > m_smearingTool
Definition: MM_DigitizationTool.h:117
MM_DigitizationTool::m_crossTalk2
Gaudi::Property< float > m_crossTalk2
Definition: MM_DigitizationTool.h:158
PileUpMergeSvc.h
the preferred mechanism to access information from the different event stores in a pileup job.
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
MM_DigitizationTool::m_condThrshldsKey
SG::ReadCondHandleKey< NswCalibDbThresholdData > m_condThrshldsKey
Definition: MM_DigitizationTool.h:121
MM_DigitizationTool::m_outputDigitCollectionKey
SG::WriteHandleKey< MmDigitContainer > m_outputDigitCollectionKey
Definition: MM_DigitizationTool.h:168
MM_DigitizationTool::m_checkMMSimHits
Gaudi::Property< bool > m_checkMMSimHits
Definition: MM_DigitizationTool.h:144
MM_DigitizationTool::m_crossTalk1
Gaudi::Property< float > m_crossTalk1
Definition: MM_DigitizationTool.h:157
MM_DigitizationTool::prepareEvent
StatusCode prepareEvent(const EventContext &ctx, const unsigned int) override final
When being run from PileUpToolsAlgs, this method is called at the start of the subevts loop.
Definition: MM_DigitizationTool.cxx:279
SubEventIterator
std::vector< xAOD::EventInfo::SubEvent >::const_iterator SubEventIterator
Definition: IPileUpTool.h:22
MM_DigitizationTool::m_driftGapWidth
Gaudi::Property< float > m_driftGapWidth
Definition: MM_DigitizationTool.h:156
MM_DigitizationTool::m_doSmearing
Gaudi::Property< bool > m_doSmearing
Definition: MM_DigitizationTool.h:147
MM_DigitizationTool::combinedStripResponseAllHits
MM_ElectronicsToolInput combinedStripResponseAllHits(const std::vector< MM_ElectronicsToolInput > &v_stripDigitOutput)
Definition: MM_DigitizationTool.cxx:818
MuonSimDataCollection.h
INSWCalibSmearingTool.h
PileUpToolBase.h
helper base class IPileUpTool::toProcess().
MM_DigitizationTool::m_vmmDeadtime
Gaudi::Property< float > m_vmmDeadtime
Definition: MM_DigitizationTool.h:181
MM_DigitizationTool::mergeEvent
StatusCode mergeEvent(const EventContext &ctx) override final
When being run from PileUpToolsAlgs, this method is called at the end of the subevts loop.
Definition: MM_DigitizationTool.cxx:383
MM_DigitizationTool::m_vmmARTMode
Gaudi::Property< std::string > m_vmmARTMode
Definition: MM_DigitizationTool.h:131
MM_DigitizationTool::m_useThresholdScaling
Gaudi::Property< bool > m_useThresholdScaling
Definition: MM_DigitizationTool.h:177
MM_DigitizationTool::m_needsMcEventCollHelper
Gaudi::Property< bool > m_needsMcEventCollHelper
Definition: MM_DigitizationTool.h:143
IMuonIdHelperSvc.h
MM_DigitizationTool::m_hitsContainerKey
SG::ReadHandleKey< MMSimHitCollection > m_hitsContainerKey
Definition: MM_DigitizationTool.h:127
NswCalibDbThresholdData.h
MM_DigitizationTool::m_DiffMagSecondMuonHit
Gaudi::Property< double > m_DiffMagSecondMuonHit
Definition: MM_DigitizationTool.h:138
MM_DigitizationTool::m_inputObjectName
std::string m_inputObjectName
Definition: MM_DigitizationTool.h:128
IAthRNGSvc.h
ServiceHandle< IAthRNGSvc >
MM_DigitizationTool::m_onlyUseContainerName
Gaudi::Property< bool > m_onlyUseContainerName
Definition: MM_DigitizationTool.h:125