ATLAS Offline Software
Loading...
Searching...
No Matches
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
19class LArEM_ID;
20class LArFCAL_ID;
21class LArHEC_ID;
22
24class LArHitContainer;
25
26class StoreGateSvc;
27
28
35class LArG4SimpleSD : public G4VSensitiveDetector
36{
37FRIEND_TEST( LArG4SimpleSDtest, ProcessHits );
38FRIEND_TEST( LArG4SimpleSDtest, EndOfAthenaEvent );
39FRIEND_TEST( LArG4SimpleSDtest, setupHelpers );
40FRIEND_TEST( LArG4SimpleSDtest, getTimeBin );
41FRIEND_TEST( LArG4SimpleSDtest, SimpleHit );
42FRIEND_TEST( LArG4SimpleSDtest, ConvertID );
43FRIEND_TEST( SDWrappertest, Initialize );
44FRIEND_TEST( SDWrappertest, EndOfAthenaEvent );
45FRIEND_TEST( SDWrappertest, addSD );
46FRIEND_TEST( SDWrappertest, addFastSimSD );
47FRIEND_TEST( SDWrappertest, ProcessHits );
48public:
49
55
57 LArG4SimpleSD(G4String a_name, ILArCalculatorSvc* calc,
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
88protected:
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
138
141
146
147};
148
149#endif
const double width
Helper class for LArEM offline identifiers.
Definition LArEM_ID.h:111
Helper class for LArFCAL offline identifiers.
Definition LArFCAL_ID.h:49
bool operator()(LArHit *const &p, LArHit *const &q) const
FRIEND_TEST(LArG4SimpleSDtest, ConvertID)
FRIEND_TEST(LArG4SimpleSDtest, SimpleHit)
const LArHEC_ID * m_larHecID
LArG4SimpleSD(G4String a_name, StoreGateSvc *detStore)
Alternative constructor, particularly for fast simulations.
LArG4SimpleSD::LArHitTimeBins m_timeBinType
const LArFCAL_ID * m_larFcalID
FRIEND_TEST(SDWrappertest, ProcessHits)
FRIEND_TEST(SDWrappertest, addSD)
G4int m_numberInvalidHits
Count the number of invalid hits.
FRIEND_TEST(LArG4SimpleSDtest, EndOfAthenaEvent)
G4bool ProcessHits(G4Step *a_step, G4TouchableHistory *) override
Main processing method.
void setupHelpers(const LArEM_ID *EM, const LArFCAL_ID *FCAL, const LArHEC_ID *HEC)
Sets the ID helper pointers.
Identifier ConvertID(const LArG4Identifier &a_ident) const
Helper function for making "real" identifiers from LArG4Identifiers.
timeBins_t m_timeBins
The map of hit sets binned in time.
LArG4SimpleSD(G4String a_name, ILArCalculatorSvc *calc, const std::string &type="Default", const float width=2.5 *CLHEP::ns)
Constructor.
const LArEM_ID * m_larEmID
Pointers to the identifier helpers.
G4float m_timeBinWidth
Width of the time bins for summing hits - for the uniform binning.
FRIEND_TEST(SDWrappertest, EndOfAthenaEvent)
void EndOfAthenaEvent(LArHitContainer *hitContnainer)
End of athena event processing.
virtual ~LArG4SimpleSD()
Destructor.
FRIEND_TEST(LArG4SimpleSDtest, getTimeBin)
ILArCalculatorSvc * m_calculator
Member variable - the calculator we'll use.
G4int getTimeBin(G4double time) const
Helper method for time info.
FRIEND_TEST(LArG4SimpleSDtest, setupHelpers)
std::map< G4int, hits_t * > timeBins_t
FRIEND_TEST(SDWrappertest, Initialize)
FRIEND_TEST(LArG4SimpleSDtest, ProcessHits)
G4bool SimpleHit(const LArG4Identifier &lar_id, G4double time, G4double energy)
First method translates to this - also for fast sims.
std::set< LArHit *, LessHit > hits_t
FRIEND_TEST(SDWrappertest, addFastSimSD)
Helper class for LArHEC offline identifiers.
Definition LArHEC_ID.h:76
Hit collection.
Class to store hit energy and time in LAr cell from G4 simulation.
Definition LArHit.h:25
The Athena Transient Store API.