ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Simulation
G4Utilities
G4UserActions
src
HitWrapper.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include <cmath>
6
#include <iostream>
7
#include <cstdlib>
8
9
#include "
HitWrapper.h
"
10
#include "G4Step.hh"
11
12
#include "
StoreGate/WriteHandle.h
"
13
14
#include "
MuonSimEvent/CSCSimHitCollection.h
"
15
#include "
MuonSimEvent/MDTSimHitCollection.h
"
16
#include "
MuonSimEvent/RPCSimHitCollection.h
"
17
#include "
MuonSimEvent/TGCSimHitCollection.h
"
19
#include "
MuonSimEvent/sTGCSimHitCollection.h
"
20
#include "
MuonSimEvent/MMSimHitCollection.h
"
21
22
#include "
InDetSimEvent/TRTUncompressedHitCollection.h
"
23
#include "
InDetSimEvent/SiHitCollection.h
"
24
25
26
namespace
G4UA
27
{
28
29
//---------------------------------------------------------------------------
30
HitWrapper::HitWrapper
(
const
Config
& config)
31
:
AthMessaging
(
Gaudi
::svcLocator()->service<IMessageSvc>(
"MessageSvc"
),
32
"HitWrapper"
),
33
m_evtStore
(
"StoreGateSvc/StoreGateSvc"
,
"HitWrapper"
),
34
m_detStore
(
"StoreGateSvc/DetectorStore"
,
"HitWrapper"
),
35
m_config
(config)
36
{}
37
38
//---------------------------------------------------------------------------
39
void
HitWrapper::EndOfEventAction
(
const
G4Event*)
40
{
41
42
SG::WriteHandle<CSCSimHitCollection>
csc(
"CSC_Hits"
);
43
SG::WriteHandle<MDTSimHitCollection>
mdt(
"MDT_Hits"
);
44
SG::WriteHandle<TGCSimHitCollection>
tgc(
"TGC_Hits"
);
45
SG::WriteHandle<RPCSimHitCollection>
rpc(
"RPC_Hits"
);
47
SG::WriteHandle<MMSimHitCollection>
mmhits(
"MM_Hits"
);
48
SG::WriteHandle<sTGCSimHitCollection>
stgc(
"sTGC_Hits"
);
49
50
if
(!csc.
isValid
() )
ATH_MSG_WARNING
(
" HitWrapper could not access csc hit collection"
);
51
else
{
52
// std::cout << "Working on a collection of size " << cscC->size() << std::endl;
53
//CSCSimHitCollection * csc = const_cast< CSCSimHitCollection * > (&(*cscC));
54
for
(
CSCSimHitCollection::iterator
hit
=csc->begin();
hit
!=csc->end();++
hit
){
55
//std::cout << "Wrapping CSC hit with time " << (*hit).globalTime() << std::endl;
56
(*hit).setGlobalTime( fmod( (*hit).globalTime() ,
m_config
.time ) );
57
}
58
}
59
60
if
( ! mdt.
isValid
() )
ATH_MSG_WARNING
(
" HitWrapper could not access mdt hit collection"
);
61
else
{
62
// std::cout << "Working on a collection of size " << mdtC->size() << std::endl;
63
//MDTSimHitCollection * mdt = const_cast< MDTSimHitCollection * > (&(*mdtC));
64
for
(
MDTSimHitCollection::iterator
hit
=mdt->begin();
hit
!=mdt->end();++
hit
){
65
//std::cout << "Wrapping MDT hit with time " << (*hit).globalTime() << std::endl;
66
(*hit).setGlobalTime( fmod( (*hit).globalTime() ,
m_config
.time ) );
67
}
68
}
69
70
if
(! rpc.
isValid
() )
ATH_MSG_WARNING
(
" HitWrapper could not access rpc hit collection"
);
71
else
{
72
// std::cout << "Working on a collection of size " << rpcC->size() << std::endl;
73
//RPCSimHitCollection * rpc = const_cast< RPCSimHitCollection * > (&(*rpcC));
74
for
(
RPCSimHitCollection::iterator
hit
=rpc->begin();
hit
!=rpc->end();++
hit
){
75
//std::cout << "Wrapping RPC hit with time " << (*hit).globalTime() << std::endl;
76
(*hit).setGlobalTime( fmod( (*hit).globalTime() ,
m_config
.time ) );
77
}
78
}
79
80
81
if
(! tgc.
isValid
() )
ATH_MSG_WARNING
(
" HitWrapper could not access tgc hit collection"
);
82
else
{
83
// std::cout << "Working on a collection of size " << tgcC->size() << std::endl;
84
//TGCSimHitCollection * tgc = const_cast< TGCSimHitCollection * > (&(*tgcC));
85
for
(
TGCSimHitCollection::iterator
hit
=tgc->begin();
hit
!=tgc->end();++
hit
){
86
//std::cout << "Wrapping TGC hit with time " << (*hit).globalTime() << std::endl;
87
(*hit).setGlobalTime( fmod( (*hit).globalTime() ,
m_config
.time ) );
88
}
89
}
90
91
93
if
(! mmhits.
isValid
() )
ATH_MSG_WARNING
(
" HitWrapper could not access Micromegas hit collection"
);
94
else
{
95
// std::cout << "Working on a collection of size " << nswC->size() << std::endl;
96
//GenericMuonSimHitCollection *mm = const_cast< GenericMuonSimHitCollection * > (&(*mmC));
97
for
(
MMSimHitCollection::iterator
hit
=mmhits->begin();
hit
!=mmhits->end();++
hit
){
98
//std::cout << "Wrapping GenericMuon hit with time " << (*hit).globalTime() << std::endl;
99
(*hit).setGlobalTime( fmod( (*hit).globalTime() ,
m_config
.time ) );
100
}
101
}
102
103
if
(! stgc.
isValid
() )
ATH_MSG_WARNING
(
" HitWrapper could not access sTGC hit collection"
);
104
else
{
105
// std::cout << "Working on a collection of size " << nswC->size() << std::endl;
106
//GenericMuonSimHitCollection *stgc = const_cast< GenericMuonSimHitCollection * > (&(*stgcC));
107
for
(
sTGCSimHitCollection::iterator
hit
=stgc->begin();
hit
!=stgc->end();++
hit
){
108
//std::cout << "Wrapping GenericMuon hit with time " << (*hit).globalTime() << std::endl;
109
(*hit).setGlobalTime( fmod( (*hit).globalTime() ,
m_config
.time ) );
110
}
111
}
112
113
// Handle the inner detector next
114
SG::WriteHandle<TRTUncompressedHitCollection>
trt(
"TRTUncompressedHits"
);
115
SG::WriteHandle<SiHitCollection>
pix
(
"PixelHits"
);
116
SG::WriteHandle<SiHitCollection>
sct(
"SCT_Hits"
);
117
118
if
(! trt.
isValid
() )
ATH_MSG_WARNING
(
" HitWrapper could not access trt hit collection"
);
119
else
{
120
//TRTUncompressedHitCollection * trt = const_cast< TRTUncompressedHitCollection * > (&*trtC);
121
for
(
TRTUncompressedHitCollection::iterator
hit
=trt->begin();
hit
!=trt->end();++
hit
){
122
//std::cout << "Wrapping TRT hit with time " << (*hit).globalTime() << std::endl;
123
(*hit).SetGlobalTime( std::fmod( (*hit).GetGlobalTime() ,
m_config
.time ) );
124
}
125
}
126
127
if
(!
pix
.isValid())
ATH_MSG_WARNING
(
" HitWrapper could not access pix hit collection"
);
128
else
{
129
//SiHitCollection * pix = const_cast<SiHitCollection *> (&*pixC);
130
for
(
SiHitCollection::iterator
hit
=
pix
->begin();
hit
!=
pix
->end();++
hit
){
131
//std::cout << "Wrapping Pix hit with time " << (*hit).meanTime() << std::endl;
132
(*hit).setMeanTime( fmod( (*hit).meanTime() ,
m_config
.time ) );
133
}
134
}
135
136
if
(! sct.
isValid
() )
ATH_MSG_WARNING
(
" HitWrapper could not access sct hit collection"
);
137
else
{
138
//SiHitCollection * sct = const_cast<SiHitCollection *> (&*sctC);
139
for
(
SiHitCollection::iterator
hit
=sct->begin();
hit
!=sct->end();++
hit
){
140
//std::cout << "Wrapping SCT hit with time " << (*hit).meanTime() << std::endl;
141
(*hit).setMeanTime( fmod( (*hit).meanTime() ,
m_config
.time ) );
142
}
143
}
144
145
}
146
147
}
// namespace G4UA
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x,...)
Definition
AthMsgStreamMacros.h:46
CSCSimHitCollection.h
HitWrapper.h
hit
bool hit(const Container &ids, int pdgId)
Definition
JetIRCSafeLabelTool.cxx:64
MDTSimHitCollection.h
MMSimHitCollection.h
RPCSimHitCollection.h
SiHitCollection.h
WriteHandle.h
Handle class for recording to StoreGate.
TGCSimHitCollection.h
TRTUncompressedHitCollection.h
AthMessaging::AthMessaging
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
Definition
AthMessaging.cxx:13
AtlasHitsVector< CSCSimHit >::iterator
CONT::iterator iterator
Definition
AtlasHitsVector.h:41
G4UA::HitWrapper::m_detStore
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default).
Definition
HitWrapper.h:36
G4UA::HitWrapper::m_config
Config m_config
Definition
HitWrapper.h:38
G4UA::HitWrapper::HitWrapper
HitWrapper(const Config &config)
Definition
HitWrapper.cxx:30
G4UA::HitWrapper::EndOfEventAction
virtual void EndOfEventAction(const G4Event *) override
Definition
HitWrapper.cxx:39
G4UA::HitWrapper::m_evtStore
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default).
Definition
HitWrapper.h:34
SG::WriteHandle
Definition
StoreGate/StoreGate/WriteHandle.h:73
SG::WriteHandle::isValid
virtual bool isValid() override final
Can the handle be successfully dereferenced?
G4UA
for nSW
Definition
CalibrationDefaultProcessing.h:19
Gaudi
=============================================================================
Definition
CaloGPUClusterAndCellDataMonitorOptions.h:273
pix
Definition
PixelMapping.cxx:16
sTGCSimHitCollection.h
G4UA::HitWrapper::Config
Definition
HitWrapper.h:23
Generated on
for ATLAS Offline Software by
1.17.0