ATLAS Offline Software
LArG4SimpleSD.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 LARG4CODE_LARG4SIMPLESD_H
6 #define LARG4CODE_LARG4SIMPLESD_H
7 
8 #include "G4VSensitiveDetector.hh"
9 
11 
12 #include "LArSimEvent/LArHit.h"
13 #include "CLHEP/Units/SystemOfUnits.h"
14 #include <gtest/gtest_prod.h>
15 
16 #include <set>
17 
18 // Forward declarations
19 class LArEM_ID;
20 class LArFCAL_ID;
21 class LArHEC_ID;
22 
23 class ILArCalculatorSvc;
24 class LArHitContainer;
25 
26 class StoreGateSvc;
27 
28 
35 class LArG4SimpleSD : public G4VSensitiveDetector
36 {
37 FRIEND_TEST( LArG4SimpleSDtest, ProcessHits );
38 FRIEND_TEST( LArG4SimpleSDtest, EndOfAthenaEvent );
39 FRIEND_TEST( LArG4SimpleSDtest, setupHelpers );
40 FRIEND_TEST( LArG4SimpleSDtest, getTimeBin );
41 FRIEND_TEST( LArG4SimpleSDtest, SimpleHit );
42 FRIEND_TEST( LArG4SimpleSDtest, ConvertID );
43 FRIEND_TEST( SDWrappertest, Initialize );
44 FRIEND_TEST( SDWrappertest, EndOfAthenaEvent );
45 FRIEND_TEST( SDWrappertest, addSD );
46 FRIEND_TEST( SDWrappertest, addFastSimSD );
47 FRIEND_TEST( SDWrappertest, ProcessHits );
48 public:
49 
51  {
54  };
55 
58  const std::string& type="Default",
59  const float width=2.5*CLHEP::ns);
60 
62  LArG4SimpleSD(G4String a_name, StoreGateSvc* detStore);
63 
65  virtual ~LArG4SimpleSD();
66 
68  G4bool ProcessHits(G4Step* a_step, G4TouchableHistory*) override;
69 
71  G4bool SimpleHit( const LArG4Identifier& lar_id , G4double time , G4double energy );
72 
74  void EndOfAthenaEvent( LArHitContainer* hitContnainer );
75 
77  void setupHelpers( const LArEM_ID* EM ,
78  const LArFCAL_ID* FCAL ,
79  const LArHEC_ID* HEC ) {
80  m_larEmID = EM;
81  m_larFcalID = FCAL;
82  m_larHecID = HEC;
83  }
84 
86  Identifier ConvertID(const LArG4Identifier& a_ident) const;
87 
88 protected:
90  G4int getTimeBin(G4double time) const;
91 
94 
97 
98  // We need two types containers for hits:
99 
100  // The set defined below is used to tell us if we've already had a
101  // hit in a cell. We store these hits in a set, so we can quickly
102  // search it. Note the use of a custom definition of a "less"
103  // function for the set, so we're not just comparing hit pointers.
104 
105  class LessHit {
106  public:
107  bool operator() ( LArHit* const& p, LArHit* const& q ) const
108  {
109  return p->Less(q);
110  }
111  };
112 
113  typedef std::set< LArHit*, LessHit > hits_t;
114 
115  // The hits are grouped into time bins, with the width of a bin
116  // determined by a user parameter. This map is used to associate a
117  // time bin with its corresponding set of hits.
118 
119  typedef std::map < G4int, hits_t* > timeBins_t;
120 
121  // Two types of LAr hit time binning
122  // 1. 'Default'
123  //
124  // All negative times to the bin 0
125  // 0 <= time < 10 by 2.5ns
126  // 10 <= time < 50 by 10ns
127  // 50 <= time < 100 by 25ns
128  // All others to the bin 14
129  //
130  //
131  // 2. 'Uniform'
132  //
133  // Old style time binning by 2.5ns
135 
137  G4float m_timeBinWidth;
138 
141 
146 
147 };
148 
149 #endif
LArG4SimpleSD::FRIEND_TEST
FRIEND_TEST(SDWrappertest, addSD)
LArG4SimpleSD::EndOfAthenaEvent
void EndOfAthenaEvent(LArHitContainer *hitContnainer)
End of athena event processing.
LArG4Identifier
Definition: LArG4Identifier.h:121
LArG4SimpleSD::m_timeBinType
LArG4SimpleSD::LArHitTimeBins m_timeBinType
Definition: LArG4SimpleSD.h:134
LArSamples::HEC
@ HEC
Definition: CaloId.h:26
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
LArG4SimpleSD::getTimeBin
G4int getTimeBin(G4double time) const
Helper method for time info.
LArG4SimpleSD::LArHitTimeBins
LArHitTimeBins
Definition: LArG4SimpleSD.h:51
LArG4SimpleSD
Common sensitive detector class for LAr systems.
Definition: LArG4SimpleSD.h:36
LArHEC_ID
Helper class for LArHEC offline identifiers.
Definition: LArHEC_ID.h:85
LArG4SimpleSD::FRIEND_TEST
FRIEND_TEST(LArG4SimpleSDtest, setupHelpers)
LArHitContainer
Hit collection.
Definition: LArHitContainer.h:26
LArG4SimpleSD::FRIEND_TEST
FRIEND_TEST(SDWrappertest, EndOfAthenaEvent)
LArG4SimpleSD::FRIEND_TEST
FRIEND_TEST(LArG4SimpleSDtest, ProcessHits)
LArG4SimpleSD::FRIEND_TEST
FRIEND_TEST(LArG4SimpleSDtest, getTimeBin)
LArG4SimpleSD::HitTimeBinUniform
@ HitTimeBinUniform
Definition: LArG4SimpleSD.h:53
LArG4SimpleSD::LArG4SimpleSD
LArG4SimpleSD(G4String a_name, StoreGateSvc *detStore)
Alternative constructor, particularly for fast simulations.
StoreGateSvc
The Athena Transient Store API.
Definition: StoreGateSvc.h:128
ParticleGun_FastCalo_ChargeFlip_Config.energy
energy
Definition: ParticleGun_FastCalo_ChargeFlip_Config.py:78
Ringer::EM
@ EM
Definition: CaloRingsDefs.h:19
LArG4SimpleSD::m_larFcalID
const LArFCAL_ID * m_larFcalID
Definition: LArG4SimpleSD.h:144
LArG4SimpleSD::m_timeBins
timeBins_t m_timeBins
The map of hit sets binned in time.
Definition: LArG4SimpleSD.h:140
Identifier
Definition: DetectorDescription/Identifier/Identifier/Identifier.h:32
LArG4SimpleSD::timeBins_t
std::map< G4int, hits_t * > timeBins_t
Definition: LArG4SimpleSD.h:119
LArG4SimpleSD::m_timeBinWidth
G4float m_timeBinWidth
Width of the time bins for summing hits - for the uniform binning.
Definition: LArG4SimpleSD.h:137
LArG4SimpleSD::m_calculator
ILArCalculatorSvc * m_calculator
Member variable - the calculator we'll use.
Definition: LArG4SimpleSD.h:93
LArG4SimpleSD::FRIEND_TEST
FRIEND_TEST(LArG4SimpleSDtest, EndOfAthenaEvent)
LArG4SimpleSD::LessHit
Definition: LArG4SimpleSD.h:105
LArG4SimpleSD::setupHelpers
void setupHelpers(const LArEM_ID *EM, const LArFCAL_ID *FCAL, const LArHEC_ID *HEC)
Sets the ID helper pointers.
Definition: LArG4SimpleSD.h:77
LArG4SimpleSD::m_larEmID
const LArEM_ID * m_larEmID
Pointers to the identifier helpers.
Definition: LArG4SimpleSD.h:143
LArG4SimpleSD::ConvertID
Identifier ConvertID(const LArG4Identifier &a_ident) const
Helper function for making "real" identifiers from LArG4Identifiers.
ILArCalculatorSvc
Definition: ILArCalculatorSvc.h:25
LArG4Identifier.h
LArG4SimpleSD::FRIEND_TEST
FRIEND_TEST(SDWrappertest, Initialize)
LArG4SimpleSD::ProcessHits
G4bool ProcessHits(G4Step *a_step, G4TouchableHistory *) override
Main processing method.
LArG4SimpleSD::SimpleHit
G4bool SimpleHit(const LArG4Identifier &lar_id, G4double time, G4double energy)
First method translates to this - also for fast sims.
python.PyKernel.detStore
detStore
Definition: PyKernel.py:41
LArG4SimpleSD::FRIEND_TEST
FRIEND_TEST(SDWrappertest, addFastSimSD)
LArG4SimpleSD::HitTimeBinDefault
@ HitTimeBinDefault
Definition: LArG4SimpleSD.h:52
LArG4SimpleSD::m_numberInvalidHits
G4int m_numberInvalidHits
Count the number of invalid hits.
Definition: LArG4SimpleSD.h:96
jobOptions.Initialize
Initialize
Definition: jobOptions.pA.py:28
LArHit
Class to store hit energy and time in LAr cell from G4 simulation.
Definition: LArHit.h:25
LArG4SimpleSD::FRIEND_TEST
FRIEND_TEST(LArG4SimpleSDtest, ConvertID)
LArHit.h
LArSamples::FCAL
@ FCAL
Definition: CaloId.h:26
Base_Fragment.width
width
Definition: Sherpa_i/share/common/Base_Fragment.py:59
CaloSwCorrections.time
def time(flags, cells_name, *args, **kw)
Definition: CaloSwCorrections.py:242
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
LArG4SimpleSD::LArG4SimpleSD
LArG4SimpleSD(G4String a_name, ILArCalculatorSvc *calc, const std::string &type="Default", const float width=2.5 *CLHEP::ns)
Constructor.
extractSporadic.q
list q
Definition: extractSporadic.py:98
LArG4SimpleSD::FRIEND_TEST
FRIEND_TEST(SDWrappertest, ProcessHits)
python.SystemOfUnits.ns
int ns
Definition: SystemOfUnits.py:130
LArEM_ID
Helper class for LArEM offline identifiers.
Definition: LArEM_ID.h:118
LArG4SimpleSD::~LArG4SimpleSD
virtual ~LArG4SimpleSD()
Destructor.
LArG4SimpleSD::m_larHecID
const LArHEC_ID * m_larHecID
Definition: LArG4SimpleSD.h:145
LArFCAL_ID
Helper class for LArFCAL offline identifiers.
Definition: LArFCAL_ID.h:60
LArG4SimpleSD::LessHit::operator()
bool operator()(LArHit *const &p, LArHit *const &q) const
Definition: LArG4SimpleSD.h:107
beamspotnt.calc
calc
Definition: bin/beamspotnt.py:1252
LArG4SimpleSD::FRIEND_TEST
FRIEND_TEST(LArG4SimpleSDtest, SimpleHit)
LArG4SimpleSD::hits_t
std::set< LArHit *, LessHit > hits_t
Definition: LArG4SimpleSD.h:113