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 // CaTS (Calorimetry and Tracking Simulation) 29 // 30 // Authors : Hans Wenzel 31 // Soon Yung Jun 32 // (Fermi National Accelerator Labo 33 // 34 // History 35 // October 18th, 2021 : first implementation 36 // 37 // ******************************************* 38 // 39 /// \file DRCalorimeterSD.cc 40 /// \brief Implementation of the CaTS::DRCalor 41 42 // Geant4 headers 43 #include "G4HCofThisEvent.hh" 44 #include "G4Step.hh" 45 #include "G4ThreeVector.hh" 46 #include "G4SDManager.hh" 47 #include "G4ios.hh" 48 #include "G4SteppingManager.hh" 49 #include "G4EventManager.hh" 50 #include "G4Cerenkov.hh" 51 // project headers 52 #include "DRCalorimeterSD.hh" 53 #include "ConfigurationManager.hh" 54 55 DRCalorimeterSD::DRCalorimeterSD(G4String name 56 : G4VSensitiveDetector(name) 57 , fDRCalorimeterHitsCollection(0) 58 , fHCID(0) 59 { 60 G4String HCname = name + "_HC"; 61 collectionName.insert(HCname); 62 G4cout << collectionName.size() << " DRCal 63 << " collection Name: " << HCname << 64 fHCID = -1; 65 verbose = ConfigurationManager::getInstance( 66 } 67 68 DRCalorimeterSD::~DRCalorimeterSD() {} 69 70 void DRCalorimeterSD::Initialize(G4HCofThisEve 71 { 72 fDRCalorimeterHitsCollection = 73 new DRCalorimeterHitsCollection(SensitiveD 74 if(fHCID < 0) 75 { 76 if(verbose) 77 G4cout << "DRCalorimeterSD::Initialize: 78 << " " << collectionName[0] << 79 fHCID = G4SDManager::GetSDMpointer()->GetC 80 } 81 hce->AddHitsCollection(fHCID, fDRCalorimeter 82 } 83 84 G4bool DRCalorimeterSD::ProcessHits(G4Step* aS 85 { 86 G4double edep = aStep->GetTotalEnergyDeposit 87 if(edep == 0.) 88 return false; 89 G4double time = aStep->GetPreStepPoint()->Ge 90 const G4VTouchable* touch = aStep->GetPreSte 91 G4ThreeVector cellpos = touch->GetTransl 92 unsigned int ID = aStep->GetPreStepPoint()-> 93 G4Track* theTrack = aStep->GetTrack 94 G4String particleType = theTrack->GetDe 95 unsigned int NCerenPhotons = 0; 96 G4SteppingManager* fpSteppingManager = G4Eve 97 ->G 98 ->G 99 G4StepStatus stepStatus = fpSteppingManager- 100 if(stepStatus != fAtRestDoItProc) 101 { 102 G4ProcessVector* procPost = fpSteppingMana 103 size_t MAXofPostStepLoops = fpSteppingMana 104 for(size_t i3 = 0; i3 < MAXofPostStepLoops 105 { 106 if((*procPost)[i3]->GetProcessName() == 107 { 108 G4Cerenkov* proc = (G4Cerenkov*) (*pro 109 NCerenPhotons += proc->GetNumPhotons() 110 } 111 } 112 } 113 // 114 // check if this cell has been hit before 115 // fDRCalorimeterHitsCollection 116 for(unsigned int j = 0; j < fDRCalorimeterHi 117 { 118 DRCalorimeterHit* aPreviousHit = (*fDRCalo 119 if(ID == aPreviousHit->GetId()) 120 { 121 aPreviousHit->SetEdep(aStep->GetTotalEne 122 aPreviousHit->GetE 123 aPreviousHit->SetNceren(aPreviousHit->Ge 124 if((particleType == "e+") || (particleTy 125 (particleType == "e-")) 126 { 127 aPreviousHit->SetEm_Edep(edep + aPrevi 128 } 129 return true; 130 } 131 } 132 // 133 // otherwise create a new hit: 134 // 135 DRCalorimeterHit* newHit; 136 if((particleType == "e+") || (particleType = 137 (particleType == "e-")) 138 { 139 newHit = new DRCalorimeterHit(ID, edep, ed 140 } 141 else 142 { 143 newHit = new DRCalorimeterHit(ID, edep, 0. 144 } 145 fDRCalorimeterHitsCollection->insert(newHit) 146 return true; 147 } 148 149 void DRCalorimeterSD::EndOfEvent(G4HCofThisEve 150 { 151 G4int NbHits = fDRCalorimeterHitsCollection- 152 if(verbose) 153 G4cout << " Number of DRCalorimeterHits: 154 } 155