ATLAS Offline Software
Loading...
Searching...
No Matches
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
13
21
24
25
26namespace G4UA
27{
28
29 //---------------------------------------------------------------------------
31 : AthMessaging(Gaudi::svcLocator()->service<IMessageSvc>("MessageSvc"),
32 "HitWrapper"),
33 m_evtStore("StoreGateSvc/StoreGateSvc","HitWrapper"),
34 m_detStore("StoreGateSvc/DetectorStore","HitWrapper"),
36 {}
37
38 //---------------------------------------------------------------------------
39 void HitWrapper::EndOfEventAction(const G4Event*)
40 {
41
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");
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
#define ATH_MSG_WARNING(x)
Handle class for recording to StoreGate.
AthMessaging(IMessageSvc *msgSvc, const std::string &name)
Constructor.
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition HitWrapper.h:36
HitWrapper(const Config &config)
virtual void EndOfEventAction(const G4Event *) override
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
Definition HitWrapper.h:34
virtual bool isValid() override final
Can the handle be successfully dereferenced?
=============================================================================