Geant4 Cross Reference |
1 // 1 2 // ******************************************* 3 // * License and Disclaimer 4 // * 5 // * The Geant4 software is copyright of th 6 // * the Geant4 Collaboration. It is provided 7 // * conditions of the Geant4 Software License 8 // * LICENSE and available at http://cern.ch/ 9 // * include a list of copyright holders. 10 // * 11 // * Neither the authors of this software syst 12 // * institutes,nor the agencies providing fin 13 // * work make any representation or warran 14 // * regarding this software system or assum 15 // * use. Please see the license in the file 16 // * for the full disclaimer and the limitatio 17 // * 18 // * This code implementation is the result 19 // * technical work of the GEANT4 collaboratio 20 // * By using, copying, modifying or distri 21 // * any work based on the software) you ag 22 // * use in resulting scientific publicati 23 // * acceptance of all terms of the Geant4 Sof 24 // ******************************************* 25 // 26 // 27 // ------------------------------------------- 28 // GEANT 4 class implementation file 29 // CERN Geneva Switzerland 30 // 31 // 32 // ------------ GammaRayTelEventAction - 33 // by R.Giannitrapani, F.Longo & G. 34 // 35 // - inclusion of Digits by F.Longo & R.Gianni 36 // 37 // - Modification of analysis management by G. 38 // 39 // ******************************************* 40 41 #include "GammaRayTelEventAction.hh" 42 #include "GammaRayTelTrackerHit.hh" 43 #include "GammaRayTelAnticoincidenceHit.hh" 44 #include "GammaRayTelCalorimeterHit.hh" 45 #include "GammaRayTelAnalysis.hh" 46 #include "GammaRayTelDigi.hh" 47 #include "GammaRayTelDigitizer.hh" 48 49 #include "G4DigiManager.hh" 50 #include "G4Event.hh" 51 #include "G4EventManager.hh" 52 #include "G4HCofThisEvent.hh" 53 #include "G4ios.hh" 54 #include "G4SDManager.hh" 55 #include "G4SystemOfUnits.hh" 56 #include "G4UImanager.hh" 57 #include "G4UnitsTable.hh" 58 #include "G4VHitsCollection.hh" 59 #include "Randomize.hh" 60 61 //....oooOO0OOooo........oooOO0OOooo........oo 62 63 // This file is a global variable in which we 64 // and other relevant information 65 66 GammaRayTelEventAction::GammaRayTelEventAction 67 auto *digitizer = new GammaRayTelDigitizer 68 G4DigiManager::GetDMpointer()->AddNewModul 69 } 70 71 //....oooOO0OOooo........oooOO0OOooo........oo 72 73 GammaRayTelEventAction::~GammaRayTelEventActio 74 } 75 76 //....oooOO0OOooo........oooOO0OOooo........oo 77 78 void GammaRayTelEventAction::BeginOfEventActio 79 G4int eventIdentifer = event->GetEventID() 80 G4cout << "Event: " << eventIdentifer << G 81 auto *sensitiveDetectorManager = G4SDManag 82 83 if (trackerCollectionID == -1) { 84 trackerCollectionID = sensitiveDetecto 85 } 86 if (anticoincidenceCollectionID == -1) { 87 anticoincidenceCollectionID = sensitiv 88 } 89 if (calorimeterCollectionID == -1) { 90 calorimeterCollectionID = sensitiveDet 91 } 92 } 93 94 //....oooOO0OOooo........oooOO0OOooo........oo 95 96 void GammaRayTelEventAction::EndOfEventAction( 97 G4int eventIdentifier = event->GetEventID( 98 99 if (theRunAction == nullptr) { 100 G4Exception("GammaRayTelEventAction::B 101 } 102 103 #ifdef G4STORE_DATA 104 auto *outputFile = theRunAction->GetOutput 105 #endif 106 107 auto *collection = event->GetHCofThisEvent 108 GammaRayTelTrackerHitsCollection *trackerC 109 // GammaRayTelCalorimeterHitsCollection* c 110 // GammaRayTelAnticoincidenceHitsCollectio 111 112 auto *fDM = G4DigiManager::GetDMpointer(); 113 GammaRayTelAnalysis *analysis = GammaRayTe 114 115 if (collection != nullptr) { 116 trackerCollection = (GammaRayTelTracke 117 // calorimeterCollection = (GammaRayTe 118 // anticoincidenceCollection = (GammaR 119 120 if (trackerCollection != nullptr) { 121 G4int numberOfHits = trackerCollec 122 G4cout << "Number of tracker hits 123 124 G4double depositedEnergy{0}; 125 G4int stripNumber; 126 G4int planeNumber; 127 G4int isXPlane; 128 129 // This is a cycle on all the trac 130 131 for (auto i = 0; i < numberOfHits; 132 // Here we put the hit data in 133 depositedEnergy = (*trackerCol 134 stripNumber = (*trackerCollect 135 planeNumber = (*trackerCollect 136 isXPlane = (*trackerCollection 137 138 #ifdef G4STORE_DATA 139 (*outputFile) << std::setw(7) 140 << " " << depositedEnergy/ 141 << " " << stripNumber 142 << " " << planeNumber 143 << " " << isXPlane 144 << " " << (*trackerCollect 145 << " " << (*trackerCollect 146 << " " << (*trackerCollect 147 << " " << G4endl; 148 #else 149 G4cout << std::setw(7) << even 150 << " " << depositedEnergy 151 << " " << stripNumber 152 << " " << planeNumber 153 << " " << isXPlane 154 << " " << (*trackerCollect 155 << " " << (*trackerCollect 156 << " " << (*trackerCollect 157 << " " << G4endl; 158 #endif 159 160 // Here we fill the histograms 161 if (isXPlane != 0) { 162 if (analysis->GetHisto2DMo 163 analysis->InsertPositi 164 } else { 165 analysis->InsertPositi 166 } 167 168 if (planeNumber == 0) { 169 analysis->InsertEnergy 170 } 171 analysis->InsertHits(plane 172 } else { 173 if (analysis->GetHisto2DMo 174 analysis->InsertPositi 175 } else { 176 analysis->InsertPositi 177 } 178 if (planeNumber == 0) { 179 analysis->InsertEnergy 180 } 181 analysis->InsertHits(plane 182 } 183 analysis->setNtuple(depositedE 184 (*trackerCollection)[i]->G 185 (*trackerCollection)[i]->G 186 (*trackerCollection)[i]->G 187 ); 188 } 189 analysis->EndOfEvent(numberOfHits) 190 } 191 192 auto *myDM = (GammaRayTelDigitizer*) f 193 myDM->Digitize(); 194 195 #ifdef G4STORE_DATA 196 // The whole block is needed only when 197 // protect block to avoid compilations 198 199 auto digitsCollectionIdentifier = fDM->Get 200 // G4cout << "Digits collection: " << 201 202 auto *digitsCollection = (GammaRayTelDigit 203 204 if (digitsCollection != nullptr) { 205 auto numberOfDigits = digitsCollec 206 // G4cout << "Total number of digi 207 208 G4int stripNumber; 209 G4int planeNumber; 210 G4int isXPlane; 211 212 for (auto i = 0; i < numberOfDigit 213 // Here we put the digi data i 214 stripNumber = (*digitsCollecti 215 planeNumber = (*digitsCollecti 216 isXPlane = (*digitsCollection) 217 218 (*outputFile) << std::setw(7) 219 << eventIdentifier 220 << " " << stripNumber 221 << " " << planeNumber 222 << " " << isXPlane 223 << " " << G4endl; 224 } 225 } 226 #endif 227 } 228 } 229