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 /// \file field/field01/src/F01CalorimeterSD.c << 27 /// \brief Implementation of the F01Calorimete << 28 // 23 // >> 24 // $Id: F01CalorimeterSD.cc,v 1.5 2003/06/25 17:40:46 gcosmo Exp $ >> 25 // GEANT4 tag $Name: geant4-07-01 $ 29 // 26 // 30 // << 27 // 31 // << 28 32 //....oooOO0OOooo........oooOO0OOooo........oo << 29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 33 //....oooOO0OOooo........oooOO0OOooo........oo << 30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 34 31 35 #include "F01CalorimeterSD.hh" 32 #include "F01CalorimeterSD.hh" 36 33 37 #include "F01CalorHit.hh" 34 #include "F01CalorHit.hh" 38 #include "F01DetectorConstruction.hh" 35 #include "F01DetectorConstruction.hh" 39 36 40 #include "G4SDManager.hh" << 41 #include "G4Step.hh" << 42 #include "G4TouchableHistory.hh" << 43 #include "G4VPhysicalVolume.hh" 37 #include "G4VPhysicalVolume.hh" >> 38 #include "G4Step.hh" 44 #include "G4VTouchable.hh" 39 #include "G4VTouchable.hh" >> 40 #include "G4TouchableHistory.hh" >> 41 #include "G4SDManager.hh" >> 42 >> 43 #include "G4ios.hh" 45 44 46 //....oooOO0OOooo........oooOO0OOooo........oo << 45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 47 46 48 F01CalorimeterSD::F01CalorimeterSD(G4String na << 47 F01CalorimeterSD::F01CalorimeterSD(G4String name, 49 : G4VSensitiveDetector(name), fDetector(det) << 48 F01DetectorConstruction* det) >> 49 :G4VSensitiveDetector(name),Detector(det) 50 { 50 { 51 collectionName.insert("CalCollection"); 51 collectionName.insert("CalCollection"); >> 52 HitID = new G4int[500]; 52 } 53 } 53 54 54 //....oooOO0OOooo........oooOO0OOooo........oo << 55 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 55 56 56 F01CalorimeterSD::~F01CalorimeterSD() 57 F01CalorimeterSD::~F01CalorimeterSD() 57 { 58 { 58 delete[] fHitID; << 59 delete [] HitID; 59 } 60 } 60 61 61 //....oooOO0OOooo........oooOO0OOooo........oo << 62 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 62 63 63 void F01CalorimeterSD::Initialize(G4HCofThisEv 64 void F01CalorimeterSD::Initialize(G4HCofThisEvent*) 64 { 65 { 65 fCalCollection = new F01CalorHitsCollection( << 66 CalCollection = new F01CalorHitsCollection 66 for (G4int j = 0; j < 1; j++) { << 67 (SensitiveDetectorName,collectionName[0]); 67 fHitID[j] = -1; << 68 for (G4int j=0;j<1; j++) {HitID[j] = -1;}; 68 }; << 69 } 69 } 70 70 71 //....oooOO0OOooo........oooOO0OOooo........oo << 71 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 72 72 73 G4bool F01CalorimeterSD::ProcessHits(G4Step* s << 73 G4bool F01CalorimeterSD::ProcessHits(G4Step* aStep, G4TouchableHistory*) 74 { 74 { 75 G4double edep = step->GetTotalEnergyDeposit( << 75 G4double edep = aStep->GetTotalEnergyDeposit(); 76 G4double stepl = 0.; 76 G4double stepl = 0.; 77 77 78 stepl = step->GetStepLength(); << 78 stepl = aStep->GetStepLength(); 79 << 80 if ((edep == 0.) && (stepl == 0.)) return fa << 81 79 82 auto theTouchable = (G4TouchableHistory*)(st << 80 if ((edep == 0.) && (stepl == 0.) ) return false; 83 81 84 G4VPhysicalVolume* physVol = theTouchable->G << 82 G4TouchableHistory* theTouchable 85 << 83 = (G4TouchableHistory*)(aStep->GetPreStepPoint()->GetTouchable()); 86 G4int number = 0; << 84 87 if (fHitID[number] == -1) { << 85 G4VPhysicalVolume* physVol = theTouchable->GetVolume(); 88 auto calHit = new F01CalorHit(); << 86 89 if (physVol == fDetector->GetAbsorber()) c << 87 G4int F01Number = 0 ; 90 fHitID[number] = fCalCollection->insert(ca << 88 if (HitID[F01Number]==-1) 91 if (verboseLevel > 0) G4cout << " New Calo << 89 { 92 } << 90 F01CalorHit* calHit = new F01CalorHit(); 93 else { << 91 if (physVol == Detector->GetAbsorber()) calHit->AddAbs(edep,stepl); 94 if (physVol == fDetector->GetAbsorber()) ( << 92 HitID[F01Number] = CalCollection->insert(calHit) - 1; 95 if (verboseLevel > 0) G4cout << " Energy a << 93 if (verboseLevel>0) 96 } << 94 G4cout << " New Calorimeter Hit on F01: " << F01Number << G4endl; >> 95 } >> 96 else >> 97 { >> 98 if (physVol == Detector->GetAbsorber()) >> 99 (*CalCollection)[HitID[F01Number]]->AddAbs(edep,stepl); >> 100 if (verboseLevel>0) >> 101 G4cout << " Energy added to F01: " << F01Number << G4endl; >> 102 } 97 return true; 103 return true; 98 } 104 } 99 105 100 //....oooOO0OOooo........oooOO0OOooo........oo << 106 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 101 107 102 void F01CalorimeterSD::EndOfEvent(G4HCofThisEv << 108 void F01CalorimeterSD::EndOfEvent(G4HCofThisEvent* HCE) 103 { 109 { 104 static G4int hcID = -1; << 110 static G4int HCID = -1; 105 if (hcID < 0) { << 111 if(HCID<0) 106 hcID = G4SDManager::GetSDMpointer()->GetCo << 112 { HCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]); } 107 } << 113 HCE->AddHitsCollection(HCID,CalCollection); 108 hce->AddHitsCollection(hcID, fCalCollection) << 109 } 114 } 110 115 111 //....oooOO0OOooo........oooOO0OOooo........oo << 116 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 117 >> 118 void F01CalorimeterSD::clear() >> 119 {} >> 120 >> 121 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... >> 122 >> 123 >> 124 void F01CalorimeterSD::PrintAll() >> 125 {} >> 126 >> 127 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 112 128