ATLAS Offline Software
Loading...
Searching...
No Matches
MuonDigitization/MDT_Digitization/src/MdtDigitizationTool.h
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
33#ifndef MUONDIGITIZATION_MDT_DIGITIZATIONTOOL_H
34#define MUONDIGITIZATION_MDT_DIGITIZATIONTOOL_H
35
36#include <sstream>
37#include <string>
38#include <vector>
39
41#include "CLHEP/Geometry/Point3D.h"
42#include "CLHEP/Random/RandGaussZiggurat.h"
43#include "CLHEP/Random/RandomEngine.h"
44#include "GaudiKernel/PhysicalConstants.h"
45#include "GaudiKernel/ServiceHandle.h"
46#include "GaudiKernel/ToolHandle.h"
48#include "Identifier/Identifier.h"
59#include "xAODEventInfo/EventInfo.h" // NEW EDM
60
61// Outputs
65
66namespace MuonGM {
69} // namespace MuonGM
70
71class MdtHitIdHelper;
72// Digitization class for MDT hits
73/*
74 +DSL--------------------------------------------------------------------------
75 The drift time can be modified according to the amount of wire sag,
76 the track angle, the distance from the end of the tube, the tube length, the
77 chamber phi angle. This drift time delta is turned on/off via m_useWireSagRT
78 It operates only on small wheel and big wheel end cap chambers (EIL/EIS; EML/EMS)
79 The EOL/EOS chambers are presumably built with tubes bent to conform to the wire sag-
80 so this code does not introduce wire-sag induced RT distortions for these chambers
81
82 -DSL----------------------------------------------------------------------------
83
84*/
86
88public:
89 MdtDigitizationTool(const std::string& type, const std::string& name, const IInterface* pIID);
90 virtual ~MdtDigitizationTool() = default;
91
93 virtual StatusCode initialize() override final;
94
96 StatusCode prepareEvent(const EventContext& ctx, const unsigned int /*nInputEvents*/) override final;
97
100 virtual StatusCode processBunchXing(int bunchXing, SubEventIterator bSubEvents, SubEventIterator eSubEvents) override final;
103 StatusCode mergeEvent(const EventContext& ctx) override final;
104
107 virtual StatusCode processAllSubEvents(const EventContext& ctx) override final;
108
109 struct GeoCorOut {
110 GeoCorOut(double sSag, double sTrack, Amg::Vector3D lp, double lSag) :
111 sagSign(sSag), trackingSign(sTrack), localPosition(lp), localSag(lSag) {}
112 double sagSign; // sign indicating wether the particle passed above or below the wire
113 double trackingSign; // sign in tracking convention indicating whether the particle passed left ot right of the wire
114 Amg::Vector3D localPosition; // point of closest approach of the particle to the wire
115 double localSag;
116 };
117
118private:
119 using Collections_t = std::vector<std::unique_ptr<MdtDigitCollection> >;
120 CLHEP::HepRandomEngine* getRandomEngine(const std::string& streamName, const EventContext& ctx) const;
121 int digitizeTime(double time, bool isHPTDC, CLHEP::HepRandomEngine* rndmEngine) const;
122 double minimumTof(Identifier DigitId, const MuonGM::MuonDetectorManager* detMgr) const;
123
124 bool insideMatchingWindow(double time) const;
125 bool insideMaskWindow(double time) const;
126 bool checkMDTSimHit(const EventContext& ctx, const MDTSimHit& hit) const;
127
128 bool handleMDTSimHit(const EventContext& ctx, const TimedHitPtr<MDTSimHit>& phit, CLHEP::HepRandomEngine* twinRndmEngine,
129 CLHEP::HepRandomEngine* toolRndmEngine);
130 bool createDigits(const EventContext& ctx, Collections_t& collections, MuonSimDataCollection* sdoContainer, CLHEP::HepRandomEngine* rndmEngine);
131
132 // calculate local hit position in local sagged wire frame, also returns whether the hit passed above or below the wire
133 GeoCorOut correctGeometricalWireSag(const MDTSimHit& hit, const Identifier& id, const MuonGM::MdtReadoutElement* element) const;
134
136
137 ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc{this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};
139
141
143
144 ToolHandle<IMDT_DigitizationTool> m_digiTool{this, "DigitizationTool", "MDT_Response_DigiTool",
145 "Tool which handle the digitization process"};
146 std::vector<MDTSimHitCollection*> m_MDTHitCollList;
147
148 // TDC ELECTRONICS
149 Gaudi::Property<double> m_offsetTDC{this, "OffsetTDC", 800., "TDC offset used if no calibration data is found"};
150 Gaudi::Property<double> m_signalSpeed{this, "SignalSpeed", 0.85*Gaudi::Units::c_light};
151
152 Gaudi::Property<double> m_ns2TDCAMT{this, "ns2TDCAMT", 0.78125, "Conversion factor TDC/ns for AMT chips"};
153 Gaudi::Property<double> m_ns2TDCHPTDC{this, "ns2TDCHPTDC", 0.1953125, "Conversion factor TDC/ns for HPTDC chips"};
154 Gaudi::Property<double> m_resTDC{this, "ResolutionTDC", 0.5, "TDC resolution"};
155 Gaudi::Property<double> m_t0ShiftTuning{this,"TunedT0Shift",-17.,"Fine tuned t0 shift value in ns"};
156
157 // CONFIGURATION
158 Gaudi::Property<bool> m_checkMDTSimHits{this, "CheckSimHits", true, "Control on the hit validity"};
159 Gaudi::Property<bool> m_useTof{this, "UseTof", true, "Option for the tof calculation"};
160 Gaudi::Property<bool> m_useAttenuation{this, "UseAttenuation", false, ""};
161 Gaudi::Property<bool> m_useProp{this, "UseProp", true, ""};
162
163 // TWIN TUBE
164 Gaudi::Property<bool> m_useTwin{this, "UseTwin", false, ""};
165 Gaudi::Property<bool> m_useAllBOLTwin{this, "UseAllBOLTwin", false, ""};
166 Gaudi::Property<double> m_resTwin{this, "ResolutionTwinTube", 1.05, "Twin Tube resolution"};
167
168 // TIMING SCHEME
169 Gaudi::Property<bool> m_useTimeWindow{this, "UseTimeWindow", true, ""};
170 Gaudi::Property<double> m_bunchCountOffset{this, "BunchCountOffset", -200., "Bunch crossing offset"};
171 Gaudi::Property<double> m_matchingWindow{this, "MatchingWindow", 1000., "Matching window"};
172 Gaudi::Property<double> m_maskWindow{this, "MaskWindow", 250., "Masked window"};
173 Gaudi::Property<double> m_deadTime{this, "DeadTime", 700., "MDT drift tube dead time"};
174 Gaudi::Property<bool> m_DiscardEarlyHits{this, "DiscardEarlyHits", true, ""};
175
176 // COSMICS
177 Gaudi::Property<bool> m_useOffSet1{this, "UseOffSet1", true, ""};
178 Gaudi::Property<bool> m_useOffSet2{this, "UseOffSet2", true, ""};
179
180
181 // B-lines
182 Gaudi::Property<bool> m_useDeformations{this, "UseDeformations", false, ""};
183
184 // MULTI-CHARGE PARTICLES DIGITIZATION
185 Gaudi::Property<bool> m_DoQballCharge{this, "DoQballCharge", false, "dEdx for Qballs with account of electric charge"};
186
187 // pile-up
188 std::unique_ptr<TimedHitCollection<MDTSimHit>> m_thpcMDT{}; // the hits
189
190 // pileup truth veto
191 Gaudi::Property<bool> m_includePileUpTruth{this, "IncludePileUpTruth", true, "Include pile-up truth info"};
192
194 // Access to the event methods:
196 // Get next event and extract collection of hit collections:
197 StatusCode getNextEvent(const EventContext& ctx);
198 StatusCode doDigitization(const EventContext& ctx, Collections_t& collections, MuonSimDataCollection* sdoContainer);
200 void fillMaps(const MDTSimHit* mdtHit, const Identifier digitId, const double driftR);
201
202protected:
203 ServiceHandle<PileUpMergeSvc> m_mergeSvc{this, "PileUpMergeSvc", "PileUpMergeSvc", ""}; // Pile up service
204 BooleanProperty m_onlyUseContainerName{this, "OnlyUseContainerName", true,
205 "Don't use the ReadHandleKey directly. Just extract the container name from it."};
206 SG::ReadHandleKey<MDTSimHitCollection> m_hitsContainerKey{this, "InputObjectName", "MDT_Hits", ""}; // name of the input objects
207 std::string m_inputObjectName{""};
208 SG::WriteHandleKey<MdtDigitContainer> m_outputObjectKey{this, "OutputObjectName", "MDT_DIGITS",
209 "WriteHandleKey for Output MdtDigitContainer"};
211 "WriteHandleKey for Output MuonSimDataCollection"};
212
213 ServiceHandle<IAthRNGSvc> m_rndmSvc{this, "RndmSvc", "AthRNGSvc", ""}; // Random number service
214
216 "Conditions object containing the calibrations"};
217
218 SG::ReadCondHandleKey<MdtCondDbData> m_readKey{this, "ReadKey", "MdtCondDbData", "Key of MdtCondDbData"};
219};
220
221#endif
std::vector< xAOD::EventInfo::SubEvent >::const_iterator SubEventIterator
Definition IPileUpTool.h:22
the preferred mechanism to access information from the different event stores in a pileup job.
helper base class IPileUpTool::toProcess().
SG::ReadCondHandleKey< MuonCalib::MdtCalibDataContainer > m_calibDbKey
void fillMaps(const MDTSimHit *mdtHit, const Identifier digitId, const double driftR)
std::vector< std::unique_ptr< MdtDigitCollection > > Collections_t
SG::ReadHandleKey< MDTSimHitCollection > m_hitsContainerKey
StatusCode mergeEvent(const EventContext &ctx) override final
When being run from PileUpToolsAlgs, this method is called at the end of the subevts loop.
bool handleMDTSimHit(const EventContext &ctx, const TimedHitPtr< MDTSimHit > &phit, CLHEP::HepRandomEngine *twinRndmEngine, CLHEP::HepRandomEngine *toolRndmEngine)
CLHEP::HepRandomEngine * getRandomEngine(const std::string &streamName, const EventContext &ctx) const
double minimumTof(Identifier DigitId, const MuonGM::MuonDetectorManager *detMgr) const
virtual ~MdtDigitizationTool()=default
static MDTSimHit applyDeformations(const MDTSimHit &, const MuonGM::MdtReadoutElement *, const Identifier &)
bool createDigits(const EventContext &ctx, Collections_t &collections, MuonSimDataCollection *sdoContainer, CLHEP::HepRandomEngine *rndmEngine)
std::unique_ptr< TimedHitCollection< MDTSimHit > > m_thpcMDT
MdtDigitCollection * getDigitCollection(Identifier elementId, Collections_t &collections)
bool checkMDTSimHit(const EventContext &ctx, const MDTSimHit &hit) const
virtual 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 ...
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.
StatusCode doDigitization(const EventContext &ctx, Collections_t &collections, MuonSimDataCollection *sdoContainer)
int digitizeTime(double time, bool isHPTDC, CLHEP::HepRandomEngine *rndmEngine) const
SG::WriteHandleKey< MdtDigitContainer > m_outputObjectKey
MdtDigitizationTool(const std::string &type, const std::string &name, const IInterface *pIID)
virtual StatusCode initialize() override final
Initialize.
GeoCorOut correctGeometricalWireSag(const MDTSimHit &hit, const Identifier &id, const MuonGM::MdtReadoutElement *element) const
SG::WriteHandleKey< MuonSimDataCollection > m_outputSDOKey
virtual StatusCode processAllSubEvents(const EventContext &ctx) override final
alternative interface which uses the PileUpMergeSvc to obtain all the required SubEvents.
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
PileUpToolBase(const std::string &type, const std::string &name, const IInterface *parent)
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.
a smart pointer to a hit that also provides access to the extended timing info of the host event.
Definition TimedHitPtr.h:18
Eigen::Matrix< double, 3, 1 > Vector3D
Ensure that the Athena extensions are properly loaded.
Definition GeoMuonHits.h:27
GeoCorOut(double sSag, double sTrack, Amg::Vector3D lp, double lSag)