40 #include "G4HCofThisEvent.hh"
41 #include "G4VHitsCollection.hh"
56 auto hce =
event->GetHCofThisEvent();
59 msg <<
"No hits collection of this event found." <<
G4endl;
65 auto hc = hce->GetHC(collId);
68 msg <<
"Hits collection " << collId <<
" of this event not found." <<
G4endl;
81 fHodHCID {{ -1, -1 }},
111 array<G4String, kDim> hHCName
112 = {{
"hodoscope1/hodoscopeColl",
"hodoscope2/hodoscopeColl" }};
113 array<G4String, kDim> dHCName
114 = {{
"chamber1/driftChamberColl",
"chamber2/driftChamberColl" }};
115 array<G4String, kDim> cHCName
116 = {{
"EMcalorimeter/EMcalorimeterColl",
"HadCalorimeter/HadCalorimeterColl" }};
119 array<array<G4String, kDim>,
kDim> histoName
120 = {{ {{
"Chamber1",
"Chamber2" }}, {{
"Chamber1 XY",
"Chamber2 XY" }} }};
122 for (
G4int iDet = 0; iDet <
kDim; ++iDet) {
124 fHodHCID[iDet] = sdManager->GetCollectionID(hHCName[iDet]);
125 fDriftHCID[iDet] = sdManager->GetCollectionID(dHCName[iDet]);
126 fCalHCID[iDet] = sdManager->GetCollectionID(cHCName[iDet]);
146 for (
G4int iDet = 0; iDet <
kDim; ++iDet) {
150 auto nhit =
hc->GetSize();
153 analysisManager->FillNtupleIColumn(iDet, nhit);
155 for (
unsigned long i = 0; i < nhit; ++i) {
158 analysisManager->FillH2(
fDriftHistoID[
kH2][iDet], localPos.x(), localPos.y());
163 array<G4int, kDim> totalCalHit = {{ 0, 0 }};
164 array<G4double, kDim> totalCalEdep = {{ 0., 0. }};
166 for (
G4int iDet = 0; iDet <
kDim; ++iDet) {
170 totalCalHit[iDet] = 0;
171 totalCalEdep[iDet] = 0.;
172 for (
unsigned long i = 0; i <
hc->GetSize(); ++i) {
184 totalCalEdep[iDet] +=
edep;
189 analysisManager->FillNtupleDColumn(iDet + 2, totalCalEdep[iDet]);
193 for (
G4int iDet = 0; iDet <
kDim; ++iDet) {
197 for (
unsigned int i = 0; i<
hc->GetSize(); ++i) {
200 analysisManager->FillNtupleDColumn(iDet + 4, hit->GetTime());
203 analysisManager->AddNtupleRow();
210 if ( printModulo == 0 || event->
GetEventID() % printModulo != 0)
return;
212 auto primary =
event->GetPrimaryVertex(0)->GetPrimary(0);
215 <<
">>> Event " <<
event->GetEventID() <<
" >>> Simulation truth : "
216 << primary->GetG4code()->GetParticleName()
217 <<
" " << primary->GetMomentum() <<
G4endl;
220 for (
G4int iDet = 0; iDet <
kDim; ++iDet) {
223 G4cout <<
"Hodoscope " << iDet + 1 <<
" has " <<
hc->GetSize() <<
" hits." <<
G4endl;
224 for (
unsigned int i = 0; i<
hc->GetSize(); ++i) {
225 hc->GetHit(i)->Print();
230 for (
G4int iDet = 0; iDet <
kDim; ++iDet) {
233 G4cout <<
"Drift Chamber " << iDet + 1 <<
" has " <<
hc->GetSize() <<
" hits." <<
G4endl;
235 for (
unsigned int i = 0; i <
hc->GetSize(); i++) {
243 array<G4String, kDim> calName = {{
"EM",
"Hadron" }};
244 for (
G4int iDet = 0; iDet <
kDim; ++iDet) {
245 G4cout << calName[iDet] <<
" Calorimeter has " << totalCalHit[iDet] <<
" hits."
246 <<
" Total Edep is " << totalCalEdep[iDet]/
MeV <<
" (MeV)" <<
G4endl;