ATLAS Offline Software
PadTdsOfflineTool.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 PADTDSOFFLINETOOL_H
6 #define PADTDSOFFLINETOOL_H
7 
11 #include "CLHEP/Random/RandGauss.h"
13 #include "Gaudi/Property.h"
14 #include "GaudiKernel/EventContext.h"
15 #include "GaudiKernel/IIncidentSvc.h"
16 #include "GaudiKernel/ITHistSvc.h"
17 #include "GaudiKernel/ServiceHandle.h"
18 #include "GaudiKernel/ThreadLocalContext.h"
29 #include "PadTdsValidationTree.h"
30 
31 #include "TTree.h"
32 #include <functional>
33 #include <algorithm>
34 #include <map>
35 #include <utility>
36 
37 class sTgcDigit;
38 class TTree;
40 class sTgcDigitContainer;
41 
42 namespace CLHEP {
43 class HepRandomEngine;
44 }
45 
46 namespace MuonGM {
47 class MuonDetectorManager;
48 }
49 
50 
51 // namespace for the NSW LVL1 related classes
52 namespace NSWL1 {
80  class PadHits;
81  class PadTrigger;
82 
83  class PadTdsOfflineTool: virtual public IPadTdsTool,
84  public AthAlgTool,
85  public IIncidentListener {
86 
87  public:
88  PadTdsOfflineTool(const std::string& type,
89  const std::string& name,
90  const IInterface* parent);
91  virtual ~PadTdsOfflineTool()=default;
93  virtual void handle (const Incident& inc) override;
94  virtual StatusCode gather_pad_data(std::vector<std::shared_ptr<PadData>>& pads, int side=-1, int sector=-1) const override;
95 
96  public:
102  static size_t firstSector() { return 0; }
104  static size_t lastSector() { return 31; }
105  static size_t numberOfSectors() { return 32; }
106  static size_t numberOfSectorsPerSide() { return 16; }
107  static size_t firstSectorAside() { return 0; }
108  static size_t lastSectorAside() { return 15; }
109  static size_t firstSectorCside() { return 16; }
110  static size_t lastSectorCside() { return 31; }
111  static size_t firstSector(const int &side)
112  { return (side==0 ? firstSectorAside() : side==1 ? firstSectorCside() : 0); }
113  static size_t lastSector(const int &side)
114  { return (side==0 ? lastSectorAside() : side==1 ? lastSectorCside() : 0); }
115  static char sideLabel(const int &side)
116  { return (side==0 ? 'A' : side==1 ? 'C' : '?'); }
118  static size_t sectorIndex(const int &side, const int &sector)
119  { return side * numberOfSectorsPerSide() + sector; }
121 
122  private:
123  // methods implementing the internal data processing
124  StatusCode fill_pad_cache(std::vector< std::vector<std::shared_ptr<PadData>> > &pad_cache) const;
125  StatusCode fill_pad_validation_id ATLAS_NOT_THREAD_SAFE (std::vector< std::vector<std::shared_ptr<PadData>> > &pad_cache) const;
126 
127  double computeTof(const sTgcDigit* digit) const;
128  double computeTimeJitter() const;
129  void simulateDeadTime(std::vector<PadHits>& h) const;
130  bool get_truth_hits_this_pad(const Identifier &pad_id, std::vector<MuonSimData::Deposit> &deposits) const;
131  bool is_pad_digit(const sTgcDigit* digit) const;
132  int cache_index(const sTgcDigit* digit) const;
133  /*
134  * Apply time delay and determine BC tag for the hit according to the trigger capture window.
135  * BC tag: bit nr. 8 correspond to the current bunch for simulated events
136  */
137  // FIXME: method not used anywhere, drop it?
138  bool determine_delay_and_bc(const sTgcDigit* digit, const int pad_hit_number, double &delayed_time, uint16_t &BCtag) const;
139  void store_pads(const std::vector<PadHits> &pad_hits, std::vector< std::vector<std::shared_ptr<PadData>> > &pad_cache) const;
140  void print_digit(const sTgcDigit* digit) const;
141 
142  void print_pad_time(const std::vector<PadHits> &pad_hits) const;
143  void print_pad_cache(std::vector< std::vector<std::shared_ptr<PadData>> > &pad_cache) const;
144 
145  // needed Servives, Tools and Helpers
146  ServiceHandle<IIncidentSvc> m_incidentSvc{this, "IncidentSvc", "IncidentSvc"};
147  ServiceHandle<IAthRNGSvc> m_rndmSvc{this, "RndmSvc", "AthRNGSvc", ""};
148  ServiceHandle<Muon::IMuonIdHelperSvc> m_idHelperSvc {this, "MuonIdHelperSvc", "Muon::MuonIdHelperSvc/MuonIdHelperSvc"};
150 
151  // properties: container and service names
152  Gaudi::Property<bool> m_isMC {this, "IsMC", true, "This is MC"};
153  Gaudi::Property<std::string> m_rndmEngineName{this, "RndmEngineName", "PadTdsOfflineTool", "Name of the random engine"};
154  Gaudi::Property<bool> m_doNtuple {this, "DoNtuple", false, "Input PadTds branches into the analysis ntuple"};
155  Gaudi::Property<float> m_vmmTimeOverThreshold{this, "VMM_TimeOverThreshold", 0., "Time to form a digital signal"};
156  Gaudi::Property<float> m_vmmShapingTime {this, "VMM_ShapingTime", 0., "Time from the leading edge of the signal and its peak"};
157  Gaudi::Property<float> m_vmmDeadTime {this, "VMM_DeadTime", 50., "VMM chip dead time to produce another signal on the same channel"};
158  Gaudi::Property<float> m_triggerCaptureWindow{this, "TriggerCaptureWindow", 30., "Time window for valid hit coincidences"};
159  Gaudi::Property<float> m_timeJitter {this, "TimeJitter", 2., "Time jitter"};
160 
161  Gaudi::Property<bool> m_applyTDS_TofSubtraction {this, "ApplyTofSubtraction", false, "Time of flight subtraction"};
162  Gaudi::Property<bool> m_applyTDS_TimeJitterSubtraction{this, "ApplyTimeJitterSubtraction", false, "Time jitter subtraction"};
163  Gaudi::Property<bool> m_applyVMM_ToT {this, "ApplyToT", false, "Time over threshold criteria"};
164  Gaudi::Property<bool> m_applyVMM_ShapingTime {this, "ApplyVMMShapingTime", false, "VMM Shaping time condition"};
165  Gaudi::Property<bool> m_applyVMM_DeadTime {this, "ApplyVMMDeadTime", false, "VMM Dead time condition"};
166 
167  std::unique_ptr<PadTdsValidationTree> m_validation_tree;
168  SG::ReadHandleKey<sTgcDigitContainer> m_sTgcDigitContainer = {this,"sTGC_DigitContainerName","sTGC_DIGITS","the name of the sTGC digit container"};
169  SG::ReadHandleKey<MuonSimDataCollection> m_sTgcSdoContainer = {this,"sTGC_SdoContainerName","sTGC_SDO","the name of the sTGC SDO container"};
170  };
171 }
172 #endif
NSWL1::PadTdsOfflineTool::sideLabel
static char sideLabel(const int &side)
Definition: PadTdsOfflineTool.h:115
sTgcDigitContainer
Use IdentifiableContainer with sTgcDigitCollection.
Definition: sTgcDigitContainer.h:50
NSWL1::PadTdsOfflineTool::m_applyTDS_TimeJitterSubtraction
Gaudi::Property< bool > m_applyTDS_TimeJitterSubtraction
Definition: PadTdsOfflineTool.h:162
MuonGM
Ensure that the Athena extensions are properly loaded.
Definition: GeoMuonHits.h:27
NSWL1::PadTdsOfflineTool::print_pad_time
void print_pad_time(const std::vector< PadHits > &pad_hits) const
Print time for each pad.
Definition: PadTdsOfflineTool.cxx:456
tdr_compat_enum.h
NSWL1::PadTdsOfflineTool::numberOfSectors
static size_t numberOfSectors()
Definition: PadTdsOfflineTool.h:105
NSWL1::PadTdsOfflineTool::m_validation_tree
std::unique_ptr< PadTdsValidationTree > m_validation_tree
Definition: PadTdsOfflineTool.h:167
NSWL1::PadTdsOfflineTool::m_doNtuple
Gaudi::Property< bool > m_doNtuple
Definition: PadTdsOfflineTool.h:154
NSWL1::PadTdsOfflineTool::computeTimeJitter
double computeTimeJitter() const
extract the time jitter t subtract from the PAD hit time
Definition: PadTdsOfflineTool.cxx:282
sTgcReadoutElement.h
NSWL1::PadTdsOfflineTool
Definition: PadTdsOfflineTool.h:85
initialize
void initialize()
Definition: run_EoverP.cxx:894
NSWL1::PadTdsOfflineTool::determine_delay_and_bc
bool determine_delay_and_bc(const sTgcDigit *digit, const int pad_hit_number, double &delayed_time, uint16_t &BCtag) const
Definition: PadTdsOfflineTool.cxx:346
NSWL1::PadTdsOfflineTool::lastSector
static size_t lastSector()
Definition: PadTdsOfflineTool.h:104
NSWL1::PadTdsOfflineTool::m_triggerCaptureWindow
Gaudi::Property< float > m_triggerCaptureWindow
Definition: PadTdsOfflineTool.h:158
NSWL1::PadTdsOfflineTool::firstSectorAside
static size_t firstSectorAside()
Definition: PadTdsOfflineTool.h:107
NSWL1::PadTdsOfflineTool::ATLAS_NOT_THREAD_SAFE
virtual StatusCode initialize ATLAS_NOT_THREAD_SAFE() override
NSWL1::PadTdsOfflineTool::m_incidentSvc
ServiceHandle< IIncidentSvc > m_incidentSvc
Athena/Gaudi incident Service.
Definition: PadTdsOfflineTool.h:146
NSWL1::PadTdsOfflineTool::numberOfSectorsPerSide
static size_t numberOfSectorsPerSide()
Definition: PadTdsOfflineTool.h:106
checkRpcDigits.digit
digit
Definition: checkRpcDigits.py:186
SG::ReadHandleKey< sTgcDigitContainer >
NSWL1::PadTdsOfflineTool::get_truth_hits_this_pad
bool get_truth_hits_this_pad(const Identifier &pad_id, std::vector< MuonSimData::Deposit > &deposits) const
Definition: PadTdsOfflineTool.cxx:393
NSWL1::PadTdsOfflineTool::cache_index
int cache_index(const sTgcDigit *digit) const
Definition: PadTdsOfflineTool.cxx:333
NSWL1::PadTdsOfflineTool::m_vmmShapingTime
Gaudi::Property< float > m_vmmShapingTime
Definition: PadTdsOfflineTool.h:156
NSWL1::PadTdsOfflineTool::handle
virtual void handle(const Incident &inc) override
Definition: PadTdsOfflineTool.cxx:91
NSWL1::PadTdsOfflineTool::fill_pad_cache
StatusCode fill_pad_cache(std::vector< std::vector< std::shared_ptr< PadData >> > &pad_cache) const
Apply the additional processing then fill the cache, locally.
Definition: PadTdsOfflineTool.cxx:223
TRT::Hit::side
@ side
Definition: HitInfo.h:83
NSWL1::PadTdsOfflineTool::computeTof
double computeTof(const sTgcDigit *digit) const
compute the time of flight of particle giving the PAD hit
Definition: PadTdsOfflineTool.cxx:268
NSWL1::PadTdsOfflineTool::m_sTgcSdoContainer
SG::ReadHandleKey< MuonSimDataCollection > m_sTgcSdoContainer
Definition: PadTdsOfflineTool.h:169
sTgcDigit
Definition: sTgcDigit.h:20
NSWL1::PadTdsOfflineTool::gather_pad_data
virtual StatusCode gather_pad_data(std::vector< std::shared_ptr< PadData >> &pads, int side=-1, int sector=-1) const override
Definition: PadTdsOfflineTool.cxx:157
NSWL1::PadTdsOfflineTool::m_vmmDeadTime
Gaudi::Property< float > m_vmmDeadTime
Definition: PadTdsOfflineTool.h:157
NSWL1::PadTdsOfflineTool::firstSector
static size_t firstSector()
Definition: PadTdsOfflineTool.h:103
IPadTdsTool.h
xAOD::uint16_t
setWord1 uint16_t
Definition: eFexEMRoI_v1.cxx:93
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
NSWL1::IPadTdsTool
interface for the PadTDS tools
Definition: IPadTdsTool.h:34
NSWL1::PadTdsOfflineTool::m_sTgcDigitContainer
SG::ReadHandleKey< sTgcDigitContainer > m_sTgcDigitContainer
Definition: PadTdsOfflineTool.h:168
NSWL1::PadTdsOfflineTool::m_isMC
Gaudi::Property< bool > m_isMC
Definition: PadTdsOfflineTool.h:152
CLHEP
STD'S.
Definition: IAtRndmGenSvc.h:19
MuonSimDataCollection
Definition: MuonSimDataCollection.h:21
AthAlgTool.h
NSWL1::PadTdsOfflineTool::m_idHelperSvc
ServiceHandle< Muon::IMuonIdHelperSvc > m_idHelperSvc
Definition: PadTdsOfflineTool.h:148
NSWL1::PadTdsOfflineTool::m_rndmSvc
ServiceHandle< IAthRNGSvc > m_rndmSvc
Random number generator engine to use.
Definition: PadTdsOfflineTool.h:147
test_pyathena.parent
parent
Definition: test_pyathena.py:15
NSWL1::PadTdsOfflineTool::sectorIndex
static size_t sectorIndex(const int &side, const int &sector)
internal index.
Definition: PadTdsOfflineTool.h:118
NSWL1::PadTdsOfflineTool::m_detManager
const MuonGM::MuonDetectorManager * m_detManager
MuonDetectorManager.
Definition: PadTdsOfflineTool.h:149
NSWL1::PadTdsOfflineTool::PadTdsOfflineTool
PadTdsOfflineTool(const std::string &type, const std::string &name, const IInterface *parent)
Definition: PadTdsOfflineTool.cxx:32
NSWL1::PadTdsOfflineTool::~PadTdsOfflineTool
virtual ~PadTdsOfflineTool()=default
NSWL1::PadTdsOfflineTool::m_applyTDS_TofSubtraction
Gaudi::Property< bool > m_applyTDS_TofSubtraction
Definition: PadTdsOfflineTool.h:161
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:228
NSWL1::PadTdsOfflineTool::m_timeJitter
Gaudi::Property< float > m_timeJitter
Definition: PadTdsOfflineTool.h:159
PadOfflineData.h
NSWL1::PadTdsOfflineTool::firstSector
static size_t firstSector(const int &side)
Definition: PadTdsOfflineTool.h:111
NSWL1::PadTdsOfflineTool::print_pad_cache
void print_pad_cache(std::vector< std::vector< std::shared_ptr< PadData >> > &pad_cache) const
Print all info stored in the pad cache.
Definition: PadTdsOfflineTool.cxx:461
MuonDetectorManager.h
RNGWrapper.h
NSWL1::PadTdsOfflineTool::lastSectorAside
static size_t lastSectorAside()
Definition: PadTdsOfflineTool.h:108
h
MuonGM::MuonDetectorManager
The MuonDetectorManager stores the transient representation of the Muon Spectrometer geometry and pro...
Definition: MuonDetDescr/MuonReadoutGeometry/MuonReadoutGeometry/MuonDetectorManager.h:50
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
NSWL1::PadTdsOfflineTool::lastSectorCside
static size_t lastSectorCside()
Definition: PadTdsOfflineTool.h:110
sTgcDigit.h
NSWL1::PadTdsOfflineTool::m_applyVMM_ShapingTime
Gaudi::Property< bool > m_applyVMM_ShapingTime
Definition: PadTdsOfflineTool.h:164
sTgcDigitContainer.h
NSWL1::PadTdsOfflineTool::m_applyVMM_ToT
Gaudi::Property< bool > m_applyVMM_ToT
Definition: PadTdsOfflineTool.h:163
NSWL1::PadTdsOfflineTool::m_vmmTimeOverThreshold
Gaudi::Property< float > m_vmmTimeOverThreshold
Definition: PadTdsOfflineTool.h:155
NSWL1::PadTdsOfflineTool::lastSector
static size_t lastSector(const int &side)
Definition: PadTdsOfflineTool.h:113
AthAlgTool
Definition: AthAlgTool.h:26
NSWL1::PadTdsOfflineTool::m_rndmEngineName
Gaudi::Property< std::string > m_rndmEngineName
Definition: PadTdsOfflineTool.h:153
MuonSimDataCollection.h
NSWL1::PadTdsOfflineTool::store_pads
void store_pads(const std::vector< PadHits > &pad_hits, std::vector< std::vector< std::shared_ptr< PadData >> > &pad_cache) const
Store pad data in the cache.
Definition: PadTdsOfflineTool.cxx:411
checker_macros.h
Define macros for attributes used to control the static checker.
NSWL1::PadTdsOfflineTool::m_applyVMM_DeadTime
Gaudi::Property< bool > m_applyVMM_DeadTime
Definition: PadTdsOfflineTool.h:165
NSWL1::PadTdsOfflineTool::is_pad_digit
bool is_pad_digit(const sTgcDigit *digit) const
Definition: PadTdsOfflineTool.cxx:328
NSWL1
A trigger trigger candidate for a stgc sector.
Definition: NSWL1Simulation.cxx:9
NSWL1::PadTdsOfflineTool::firstSectorCside
static size_t firstSectorCside()
Definition: PadTdsOfflineTool.h:109
IMuonIdHelperSvc.h
NSWL1::PadTdsOfflineTool::print_digit
void print_digit(const sTgcDigit *digit) const
Definition: PadTdsOfflineTool.cxx:427
MuonSimData.h
NSWL1::PadTdsOfflineTool::ATLAS_NOT_THREAD_SAFE
StatusCode fill_pad_validation_id ATLAS_NOT_THREAD_SAFE(std::vector< std::vector< std::shared_ptr< PadData >> > &pad_cache) const
Fill the ntuple branch for the PadTdsOffline.
PadTdsValidationTree.h
IAthRNGSvc.h
ServiceHandle< IIncidentSvc >
NSWL1::PadTdsOfflineTool::simulateDeadTime
void simulateDeadTime(std::vector< PadHits > &h) const
simulate the dead time of the VMM
Definition: PadTdsOfflineTool.cxx:288
Identifier
Definition: IdentifierFieldParser.cxx:14