Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer << 3 // * DISCLAIMER * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th << 5 // * The following disclaimer summarizes all the specific disclaimers * 6 // * the Geant4 Collaboration. It is provided << 6 // * of contributors to this software. The specific disclaimers,which * 7 // * conditions of the Geant4 Software License << 7 // * govern, are listed with their locations in: * 8 // * LICENSE and available at http://cern.ch/ << 8 // * http://cern.ch/geant4/license * 9 // * include a list of copyright holders. << 10 // * 9 // * * 11 // * Neither the authors of this software syst 10 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 11 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 12 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 13 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file << 14 // * use. * 16 // * for the full disclaimer and the limitatio << 17 // * 15 // * * 18 // * This code implementation is the result << 16 // * This code implementation is the intellectual property of the * 19 // * technical work of the GEANT4 collaboratio << 17 // * GEANT4 collaboration. * 20 // * By using, copying, modifying or distri << 18 // * By copying, distributing or modifying the Program (or any work * 21 // * any work based on the software) you ag << 19 // * based on the Program) you indicate your acceptance of this * 22 // * use in resulting scientific publicati << 20 // * statement, and all its terms. * 23 // * acceptance of all terms of the Geant4 Sof << 24 // ******************************************* 21 // ******************************************************************** 25 // 22 // 26 // 23 // >> 24 // $Id: GammaRayTelCalorimeterSD.cc,v 1.6 2003/11/14 14:59:48 flongo Exp $ >> 25 // GEANT4 tag $Name: geant4-07-00-patch-01 $ 27 // ------------------------------------------- 26 // ------------------------------------------------------------ 28 // GEANT 4 class implementation file 27 // GEANT 4 class implementation file 29 // CERN Geneva Switzerland 28 // CERN Geneva Switzerland 30 // 29 // 31 // 30 // 32 // ------------ GammaRayTelCalorimeterSD 31 // ------------ GammaRayTelCalorimeterSD ------ 33 // by R.Giannitrapani, F.Longo & G. 32 // by R.Giannitrapani, F.Longo & G.Santin (13 nov 2000) 34 // 33 // 35 // ******************************************* 34 // ************************************************************ 36 << 37 #include "G4RunManager.hh" 35 #include "G4RunManager.hh" 38 #include "GammaRayTelCalorimeterSD.hh" 36 #include "GammaRayTelCalorimeterSD.hh" 39 #include "GammaRayTelCalorimeterHit.hh" 37 #include "GammaRayTelCalorimeterHit.hh" 40 #include "GammaRayTelDetectorConstruction.hh" 38 #include "GammaRayTelDetectorConstruction.hh" 41 39 42 #include "G4SystemOfUnits.hh" << 43 #include "G4VPhysicalVolume.hh" 40 #include "G4VPhysicalVolume.hh" 44 #include "G4Step.hh" 41 #include "G4Step.hh" 45 #include "G4VTouchable.hh" 42 #include "G4VTouchable.hh" 46 #include "G4TouchableHistory.hh" 43 #include "G4TouchableHistory.hh" 47 #include "G4SDManager.hh" 44 #include "G4SDManager.hh" 48 #include "G4ios.hh" 45 #include "G4ios.hh" 49 46 50 //....oooOO0OOooo........oooOO0OOooo........oo 47 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 51 48 52 GammaRayTelCalorimeterSD::GammaRayTelCalorimet << 49 GammaRayTelCalorimeterSD::GammaRayTelCalorimeterSD(G4String name):G4VSensitiveDetector(name) 53 auto *runManager = G4RunManager::GetRunManag << 50 { 54 detector = (GammaRayTelDetectorConstruction* << 51 G4RunManager* runManager = G4RunManager::GetRunManager(); 55 << 52 Detector = 56 numberOfCALBars = detector->GetNbOfCALBars() << 53 (GammaRayTelDetectorConstruction*)(runManager->GetUserDetectorConstruction()); 57 numberOfCALLayers = detector->GetNbOfCALLaye << 54 >> 55 NbOfCALBars = Detector->GetNbOfCALBars(); >> 56 NbOfCALLayers = Detector->GetNbOfCALLayers(); >> 57 >> 58 //G4cout << NbOfCALBars << " bars " << G4endl; >> 59 //G4cout << NbOfCALLayers << " layers " << G4endl; >> 60 >> 61 NbOfCALChannels = NbOfCALBars*NbOfCALLayers; >> 62 >> 63 ChitXID = new G4int[NbOfCALChannels]; >> 64 ChitYID = new G4int[NbOfCALChannels]; >> 65 collectionName.insert("CalorimeterCollection"); >> 66 } >> 67 >> 68 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 69 >> 70 GammaRayTelCalorimeterSD::~GammaRayTelCalorimeterSD() >> 71 { >> 72 delete [] ChitXID; >> 73 delete [] ChitYID; >> 74 } >> 75 >> 76 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 77 >> 78 void GammaRayTelCalorimeterSD::Initialize(G4HCofThisEvent*) >> 79 { >> 80 CalorimeterCollection = new GammaRayTelCalorimeterHitsCollection >> 81 (SensitiveDetectorName,collectionName[0]); >> 82 for (G4int i=0;i<NbOfCALChannels;i++) >> 83 { >> 84 ChitXID[i] = -1; >> 85 ChitYID[i] = -1; >> 86 }; >> 87 } >> 88 >> 89 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 90 >> 91 G4bool GammaRayTelCalorimeterSD::ProcessHits(G4Step* aStep,G4TouchableHistory*) >> 92 { >> 93 >> 94 G4double edep = aStep->GetTotalEnergyDeposit(); >> 95 if ((edep/keV == 0.)) return false; >> 96 >> 97 // This TouchableHistory is used to obtain the physical volume >> 98 // of the hit >> 99 G4TouchableHistory* theTouchable >> 100 = (G4TouchableHistory*)(aStep->GetPreStepPoint()->GetTouchable()); >> 101 >> 102 G4VPhysicalVolume* cal_bar = theTouchable->GetVolume(); >> 103 G4VPhysicalVolume* cal_plane = theTouchable->GetVolume(1); >> 104 >> 105 G4int CALBarNumber=cal_bar->GetCopyNo(); >> 106 G4String CALBarName = cal_bar->GetName(); >> 107 >> 108 G4int PlaneNumber = 0; >> 109 PlaneNumber=cal_plane->GetCopyNo(); >> 110 G4String PlaneName = cal_plane->GetName(); >> 111 >> 112 >> 113 G4int NChannel = 0; >> 114 >> 115 NChannel = PlaneNumber * NbOfCALBars + CALBarNumber; >> 116 >> 117 if (PlaneName == "CALLayerX" ) >> 118 >> 119 // The hit is on an X CsI plane >> 120 >> 121 { >> 122 // This is a new hit >> 123 if (ChitXID[NChannel]==-1) >> 124 { >> 125 GammaRayTelCalorimeterHit* CalorimeterHit = new GammaRayTelCalorimeterHit; >> 126 CalorimeterHit->SetCALType(1); >> 127 CalorimeterHit->AddEnergy(edep); >> 128 CalorimeterHit->SetPos(aStep->GetPreStepPoint()->GetPosition()); >> 129 CalorimeterHit->SetCALPlaneNumber(PlaneNumber); >> 130 CalorimeterHit->SetCALBarNumber(CALBarNumber); >> 131 ChitXID[NChannel] = >> 132 CalorimeterCollection->insert(CalorimeterHit) -1; >> 133 } >> 134 else // This is not new >> 135 { >> 136 (*CalorimeterCollection) >> 137 [ChitXID[NChannel]]->AddEnergy(edep); >> 138 } >> 139 } >> 140 >> 141 if (PlaneName == "CALLayerY") >> 142 // The hit is on an Y CsI plane >> 143 { >> 144 // This is a new hit >> 145 if (ChitYID[NChannel]==-1) >> 146 { >> 147 GammaRayTelCalorimeterHit* CalorimeterHit >> 148 = new GammaRayTelCalorimeterHit; >> 149 CalorimeterHit->SetCALType(0); >> 150 CalorimeterHit->AddEnergy(edep); >> 151 CalorimeterHit->SetPos(aStep->GetPreStepPoint()->GetPosition()); >> 152 CalorimeterHit->SetCALPlaneNumber(PlaneNumber); >> 153 CalorimeterHit->SetCALBarNumber(CALBarNumber); >> 154 ChitYID[NChannel] = >> 155 CalorimeterCollection->insert(CalorimeterHit)-1; >> 156 } >> 157 else // This is not new >> 158 { >> 159 (*CalorimeterCollection) >> 160 [ChitYID[NChannel]]->AddEnergy(edep); >> 161 } >> 162 } >> 163 >> 164 return true; >> 165 } >> 166 >> 167 >> 168 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 169 void GammaRayTelCalorimeterSD::EndOfEvent(G4HCofThisEvent* HCE) >> 170 { >> 171 static G4int HCID = -1; >> 172 if(HCID<0) >> 173 { >> 174 HCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]); >> 175 } >> 176 HCE->AddHitsCollection(HCID,CalorimeterCollection); >> 177 >> 178 >> 179 for (G4int i=0;i<NbOfCALChannels;i++) >> 180 { >> 181 ChitXID[i] = -1; >> 182 ChitYID[i] = -1; >> 183 }; >> 184 } 58 185 59 // G4cout << NbOfCALBars << " bars " << G4en << 60 // G4cout << NbOfCALLayers << " layers " << << 61 186 62 numberOfCALChannels = numberOfCALBars * numb << 187 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 63 188 64 calHitXID = new G4int[numberOfCALChannels]; << 189 void GammaRayTelCalorimeterSD::clear() 65 calHitYID = new G4int[numberOfCALChannels]; << 190 {} 66 collectionName.insert("CalorimeterCollection << 67 } << 68 191 69 //....oooOO0OOooo........oooOO0OOooo........oo 192 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 70 193 71 GammaRayTelCalorimeterSD::~GammaRayTelCalorime << 194 void GammaRayTelCalorimeterSD::DrawAll() 72 delete[] calHitXID; << 195 {} 73 delete[] calHitYID; << 74 } << 75 196 76 //....oooOO0OOooo........oooOO0OOooo........oo 197 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 77 198 78 void GammaRayTelCalorimeterSD::Initialize(G4HC << 199 void GammaRayTelCalorimeterSD::PrintAll() 79 calorimeterCollection = new GammaRayTelCal << 200 {} 80 for (auto i = 0; i < numberOfCALChannels; i+ << 81 calHitXID[i] = -1; << 82 calHitYID[i] = -1; << 83 } << 84 } << 85 201 86 //....oooOO0OOooo........oooOO0OOooo........oo 202 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 87 203 88 auto GammaRayTelCalorimeterSD::ProcessHits(G4S << 89 G4double depositedEnergy = 0.; << 90 depositedEnergy = step->GetTotalEnergyDeposi << 91 if (depositedEnergy == 0.) { << 92 return false; << 93 } << 94 204 95 // This TouchableHistory is used to obtain t << 96 auto *theTouchable = (G4TouchableHistory*) ( << 97 auto *calorimeterBar = theTouchable->GetVolu << 98 auto *calorimeterPlane = theTouchable->GetVo << 99 auto calorimeterBarNumber = calorimeterBar-> << 100 auto calorimeterBarName = calorimeterBar->Ge << 101 << 102 G4int planeNumber{0}; << 103 planeNumber = calorimeterPlane->GetCopyNo(); << 104 << 105 auto planeName = calorimeterPlane->GetName() << 106 << 107 G4int NChannel = 0; << 108 NChannel = planeNumber * numberOfCALBars + c << 109 << 110 if (planeName == "CALLayerX") { // The hit i << 111 if (calHitXID[NChannel] == -1) { // This i << 112 auto *calorimeterHit = new GammaRayTelCa << 113 calorimeterHit->SetCALType(1); << 114 calorimeterHit->AddEnergy(depositedEnerg << 115 calorimeterHit->SetPosition(step->GetPre << 116 calorimeterHit->SetCALPlaneNumber(planeN << 117 calorimeterHit->SetCALBarNumber(calorime << 118 calHitXID[NChannel] = calorimeterCollect << 119 } else { // This is not new << 120 (*calorimeterCollection)[calHitXID[NChan << 121 } << 122 } << 123 205 124 if (planeName == "CALLayerY") { // The hit i << 125 if (calHitYID[NChannel] == -1) { // This i << 126 auto *calorimeterHit = new GammaRayTelCa << 127 calorimeterHit->SetCALType(0); << 128 calorimeterHit->AddEnergy(depositedEnerg << 129 calorimeterHit->SetPosition(step->GetPre << 130 calorimeterHit->SetCALPlaneNumber(planeN << 131 calorimeterHit->SetCALBarNumber(calorime << 132 calHitYID[NChannel] = calorimeterCollect << 133 } else { // This is not new << 134 (*calorimeterCollection)[calHitYID[NChan << 135 } << 136 } << 137 206 138 return true; << 139 } << 140 207 141 //....oooOO0OOooo........oooOO0OOooo........oo << 142 208 143 void GammaRayTelCalorimeterSD::EndOfEvent(G4HC << 144 static G4int collectionIdentifier = -1; << 145 if (collectionIdentifier < 0) { << 146 collectionIdentifier = G4SDManager::GetSDM << 147 } << 148 HCE->AddHitsCollection(collectionIdentifier, << 149 209 150 for (auto i = 0; i < numberOfCALChannels; i+ << 151 calHitXID[i] = -1; << 152 calHitYID[i] = -1; << 153 } << 154 } << 155 210 156 //....oooOO0OOooo........oooOO0OOooo........oo << 157 211 158 void GammaRayTelCalorimeterSD::clear() { << 159 } << 160 212 161 //....oooOO0OOooo........oooOO0OOooo........oo << 162 213 163 void GammaRayTelCalorimeterSD::DrawAll() { << 164 } << 165 214 166 //....oooOO0OOooo........oooOO0OOooo........oo << 167 215 168 void GammaRayTelCalorimeterSD::PrintAll() { << 216 169 } << 170 217