42 #include "G4HCofThisEvent.hh"
43 #include "G4VHitsCollection.hh"
57 auto hce =
event->GetHCofThisEvent();
60 msg <<
"No hits collection of this event found." <<
G4endl;
66 auto hc = hce->GetHC(collId);
69 msg <<
"Hits collection " << collId <<
" of this event not found." <<
G4endl;
82 fHodHCID {{ -1, -1 }},
109 auto analysisManager = G4AnalysisManager::Instance();
112 array<G4String, kDim> hHCName
113 = {{
"hodoscope1/hodoscopeColl",
"hodoscope2/hodoscopeColl" }};
114 array<G4String, kDim> dHCName
115 = {{
"chamber1/driftChamberColl",
"chamber2/driftChamberColl" }};
116 array<G4String, kDim> cHCName
117 = {{
"EMcalorimeter/EMcalorimeterColl",
"HadCalorimeter/HadCalorimeterColl" }};
120 array<array<G4String, kDim>,
kDim> histoName
121 = {{ {{
"Chamber1",
"Chamber2" }}, {{
"Chamber1 XY",
"Chamber2 XY" }} }};
123 for (
G4int iDet = 0; iDet <
kDim; ++iDet) {
125 fHodHCID[iDet] = sdManager->GetCollectionID(hHCName[iDet]);
126 fDriftHCID[iDet] = sdManager->GetCollectionID(dHCName[iDet]);
127 fCalHCID[iDet] = sdManager->GetCollectionID(cHCName[iDet]);
144 auto analysisManager = G4AnalysisManager::Instance();
147 for (
G4int iDet = 0; iDet <
kDim; ++iDet) {
151 auto nhit =
hc->GetSize();
154 analysisManager->FillNtupleIColumn(iDet, nhit);
156 for (
unsigned long i = 0; i < nhit; ++i) {
159 analysisManager->FillH2(
fDriftHistoID[
kH2][iDet], localPos.x(), localPos.y());
164 array<G4int, kDim> totalCalHit = {{ 0, 0 }};
165 array<G4double, kDim> totalCalEdep = {{ 0., 0. }};
167 for (
G4int iDet = 0; iDet <
kDim; ++iDet) {
171 totalCalHit[iDet] = 0;
172 totalCalEdep[iDet] = 0.;
173 for (
unsigned long i = 0; i <
hc->GetSize(); ++i) {
185 totalCalEdep[iDet] +=
edep;
190 analysisManager->FillNtupleDColumn(iDet + 2, totalCalEdep[iDet]);
194 for (
G4int iDet = 0; iDet <
kDim; ++iDet) {
198 for (
unsigned int i = 0; i<
hc->GetSize(); ++i) {
201 analysisManager->FillNtupleDColumn(iDet + 4, hit->GetTime());
204 analysisManager->AddNtupleRow();
211 if ( printModulo == 0 || event->
GetEventID() % printModulo != 0)
return;
213 auto primary =
event->GetPrimaryVertex(0)->GetPrimary(0);
216 <<
">>> Event " <<
event->GetEventID() <<
" >>> Simulation truth : "
217 << primary->GetG4code()->GetParticleName()
218 <<
" " << primary->GetMomentum() <<
G4endl;
221 for (
G4int iDet = 0; iDet <
kDim; ++iDet) {
224 G4cout <<
"Hodoscope " << iDet + 1 <<
" has " <<
hc->GetSize() <<
" hits." <<
G4endl;
225 for (
unsigned int i = 0; i<
hc->GetSize(); ++i) {
226 hc->GetHit(i)->Print();
231 for (
G4int iDet = 0; iDet <
kDim; ++iDet) {
234 G4cout <<
"Drift Chamber " << iDet + 1 <<
" has " <<
hc->GetSize() <<
" hits." <<
G4endl;
236 for (
unsigned int i = 0; i <
hc->GetSize(); i++) {
238 if (hit->GetLayerID() == layer) hit->
Print();
244 array<G4String, kDim> calName = {{
"EM",
"Hadron" }};
245 for (
G4int iDet = 0; iDet <
kDim; ++iDet) {
246 G4cout << calName[iDet] <<
" Calorimeter has " << totalCalHit[iDet] <<
" hits."
247 <<
" Total Edep is " << totalCalEdep[iDet]/
MeV <<
" (MeV)" <<
G4endl;
Definition of the B5DriftChamberHit class.
static G4RunManager * GetRunManager()
std::ostringstream G4ExceptionDescription
static constexpr double MeV
Definition of the B5HadCalorimeterHit class.
std::array< G4int, kDim > fHodHCID
Selection of the analysis technology.
constexpr G4int kNofHadCells
Definition of the B5EventAction class.
std::array< std::vector< G4double >, kDim > fCalEdep
std::array< std::array< G4int, kDim >, kDim > fDriftHistoID
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
static G4SDManager * GetSDMpointer()
std::array< G4int, kDim > fDriftHCID
std::array< G4int, kDim > fCalHCID
constexpr G4int kNofChambers
G4GLOB_DLL std::ostream G4cout
Definition of the B5HodoscopeHit class.
virtual void BeginOfEventAction(const G4Event *)
virtual void EndOfEventAction(const G4Event *)
constexpr G4int kNofEmCells
const G4double hc
[MeV*fm]
Definition of the B5EmCalorimeterHit class.
G4ThreeVector GetLocalPos() const
void SetPrintProgress(G4int i)