Geant4 Cross Reference |
1 // 1 // 2 // ******************************************* 2 // ******************************************************************** 3 // * License and Disclaimer 3 // * License and Disclaimer * 4 // * 4 // * * 5 // * The Geant4 software is copyright of th 5 // * The Geant4 software is copyright of the Copyright Holders of * 6 // * the Geant4 Collaboration. It is provided 6 // * the Geant4 Collaboration. It is provided under the terms and * 7 // * conditions of the Geant4 Software License 7 // * conditions of the Geant4 Software License, included in the file * 8 // * LICENSE and available at http://cern.ch/ 8 // * LICENSE and available at http://cern.ch/geant4/license . These * 9 // * include a list of copyright holders. 9 // * include a list of copyright holders. * 10 // * 10 // * * 11 // * Neither the authors of this software syst 11 // * Neither the authors of this software system, nor their employing * 12 // * institutes,nor the agencies providing fin 12 // * institutes,nor the agencies providing financial support for this * 13 // * work make any representation or warran 13 // * work make any representation or warranty, express or implied, * 14 // * regarding this software system or assum 14 // * regarding this software system or assume any liability for its * 15 // * use. Please see the license in the file 15 // * use. Please see the license in the file LICENSE and URL above * 16 // * for the full disclaimer and the limitatio 16 // * for the full disclaimer and the limitation of liability. * 17 // * 17 // * * 18 // * This code implementation is the result 18 // * This code implementation is the result of the scientific and * 19 // * technical work of the GEANT4 collaboratio 19 // * technical work of the GEANT4 collaboration. * 20 // * By using, copying, modifying or distri 20 // * By using, copying, modifying or distributing the software (or * 21 // * any work based on the software) you ag 21 // * any work based on the software) you agree to acknowledge its * 22 // * use in resulting scientific publicati 22 // * use in resulting scientific publications, and indicate your * 23 // * acceptance of all terms of the Geant4 Sof 23 // * acceptance of all terms of the Geant4 Software license. * 24 // ******************************************* 24 // ******************************************************************** 25 // 25 // 26 // 26 // >> 27 // $Id: XrayFluoSD.cc >> 28 // GEANT4 tag $Name: xray_fluo-V04-01-03 27 // 29 // 28 // Author: Elena Guardincerri (Elena.Guardince 30 // Author: Elena Guardincerri (Elena.Guardincerri@ge.infn.it) 29 // 31 // 30 // History: 32 // History: 31 // ----------- 33 // ----------- 32 // 28 Nov 2001 Elena Guardincerri Created 34 // 28 Nov 2001 Elena Guardincerri Created 33 // 29 Nov 2002 Energy deposition bug fixed (Al 35 // 29 Nov 2002 Energy deposition bug fixed (Alfonso.mantero@ge.infn.it) 34 // 17 Jul 2003 Name changed to XrayFluoSD 36 // 17 Jul 2003 Name changed to XrayFluoSD 35 // 01 Sep 2003 Constructor overload for differ 37 // 01 Sep 2003 Constructor overload for different geometries handling 36 // ------------------------------------------- 38 // ------------------------------------------------------------------- 37 39 38 #include "XrayFluoSD.hh" 40 #include "XrayFluoSD.hh" 39 #include "XrayFluoSensorHit.hh" 41 #include "XrayFluoSensorHit.hh" 40 #include "XrayFluoDetectorConstruction.hh" 42 #include "XrayFluoDetectorConstruction.hh" 41 #include "XrayFluoPlaneDetectorConstruction.hh 43 #include "XrayFluoPlaneDetectorConstruction.hh" 42 #include "XrayFluoMercuryDetectorConstruction. 44 #include "XrayFluoMercuryDetectorConstruction.hh" 43 #include "G4VPhysicalVolume.hh" 45 #include "G4VPhysicalVolume.hh" 44 #include "G4Step.hh" 46 #include "G4Step.hh" 45 #include "G4VTouchable.hh" 47 #include "G4VTouchable.hh" 46 #include "G4TouchableHistory.hh" 48 #include "G4TouchableHistory.hh" 47 #include "G4SDManager.hh" 49 #include "G4SDManager.hh" 48 #include "G4ios.hh" 50 #include "G4ios.hh" 49 #include "G4VProcess.hh" 51 #include "G4VProcess.hh" 50 52 51 //....oooOO0OOooo........oooOO0OOooo........oo 53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 52 54 53 XrayFluoSD::XrayFluoSD(G4String name, 55 XrayFluoSD::XrayFluoSD(G4String name, 54 XrayFluoDet 56 XrayFluoDetectorConstruction* det) 55 :G4VSensitiveDetector(name),Detector(0),plan 57 :G4VSensitiveDetector(name),Detector(0),planeDetector(0),mercuryDetector(0) 56 { 58 { 57 59 58 Detector = det; 60 Detector = det; 59 collectionName.insert("HPGeCollection"); 61 collectionName.insert("HPGeCollection"); 60 HitHPGeID = new G4int[500]; 62 HitHPGeID = new G4int[500]; 61 G4cout << "XrayFluoSD created" << G4endl; 63 G4cout << "XrayFluoSD created" << G4endl; 62 64 63 } 65 } 64 66 65 //....oooOO0OOooo........oooOO0OOooo........oo 67 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 66 68 67 XrayFluoSD::XrayFluoSD(G4String name, 69 XrayFluoSD::XrayFluoSD(G4String name, 68 XrayFluoPlaneDetectorConstruction* 70 XrayFluoPlaneDetectorConstruction* det) 69 :G4VSensitiveDetector(name),Detector(0),plan 71 :G4VSensitiveDetector(name),Detector(0),planeDetector(0),mercuryDetector(0) 70 { 72 { 71 planeDetector = det; 73 planeDetector = det; 72 collectionName.insert("HPGeCollection"); 74 collectionName.insert("HPGeCollection"); 73 HitHPGeID = new G4int[500]; 75 HitHPGeID = new G4int[500]; 74 G4cout << "XrayFluoSD created" << G4endl; 76 G4cout << "XrayFluoSD created" << G4endl; 75 77 76 } 78 } 77 79 78 //....oooOO0OOooo........oooOO0OOooo........oo 80 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 79 81 80 XrayFluoSD::XrayFluoSD(G4String name, 82 XrayFluoSD::XrayFluoSD(G4String name, 81 XrayFluoMercuryDetectorConstruction 83 XrayFluoMercuryDetectorConstruction* det) 82 :G4VSensitiveDetector(name),Detector(0),plan 84 :G4VSensitiveDetector(name),Detector(0),planeDetector(0),mercuryDetector(0) 83 { 85 { 84 mercuryDetector = det; 86 mercuryDetector = det; 85 collectionName.insert("HPGeCollection"); 87 collectionName.insert("HPGeCollection"); 86 HitHPGeID = new G4int[500]; 88 HitHPGeID = new G4int[500]; 87 G4cout << "XrayFluoSD created" << G4endl; 89 G4cout << "XrayFluoSD created" << G4endl; 88 } 90 } 89 91 90 // //....oooOO0OOooo........oooOO0OOooo....... 92 // //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 91 93 92 94 93 95 94 96 95 XrayFluoSD::~XrayFluoSD() 97 XrayFluoSD::~XrayFluoSD() 96 { 98 { 97 99 98 delete [] HitHPGeID; 100 delete [] HitHPGeID; 99 101 100 // delete HPGeCollection; 102 // delete HPGeCollection; 101 103 102 G4cout << "XrayFluoSD deleted" << G4endl; 104 G4cout << "XrayFluoSD deleted" << G4endl; 103 } 105 } 104 106 105 //....oooOO0OOooo........oooOO0OOooo........oo 107 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 106 108 107 void XrayFluoSD::Initialize(G4HCofThisEvent*) 109 void XrayFluoSD::Initialize(G4HCofThisEvent*) 108 110 109 //initializes HCE with the hits collection(s) 111 //initializes HCE with the hits collection(s) created by this 110 //sensitive detector 112 //sensitive detector 111 { 113 { 112 HPGeCollection = new XrayFluoSensorHitsColle 114 HPGeCollection = new XrayFluoSensorHitsCollection 113 (SensitiveDetectorName,collectionName[0]); 115 (SensitiveDetectorName,collectionName[0]); 114 116 115 G4int nPixel = 0; 117 G4int nPixel = 0; 116 118 117 if (Detector) {nPixel = Detector->GetNbOfPix 119 if (Detector) {nPixel = Detector->GetNbOfPixels();} 118 else if (planeDetector) {nPixel = planeDetec 120 else if (planeDetector) {nPixel = planeDetector->GetNbOfPixels();} 119 else if (mercuryDetector) {nPixel = mercuryD 121 else if (mercuryDetector) {nPixel = mercuryDetector->GetNbOfPixels();} 120 122 121 for (G4int j=0;j<nPixel;j++) 123 for (G4int j=0;j<nPixel;j++) 122 {HitHPGeID [j]= -1;}; 124 {HitHPGeID [j]= -1;}; 123 } 125 } 124 126 125 //....oooOO0OOooo........oooOO0OOooo........oo 127 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 126 128 127 G4bool XrayFluoSD::ProcessHits(G4Step* aStep,G 129 G4bool XrayFluoSD::ProcessHits(G4Step* aStep,G4TouchableHistory*) 128 { 130 { 129 131 130 132 131 133 132 G4double edep = aStep->GetTotalEnergyDeposit 134 G4double edep = aStep->GetTotalEnergyDeposit(); 133 135 134 /* 136 /* 135 G4String particleName = aStep->GetTrack()- 137 G4String particleName = aStep->GetTrack()->GetDynamicParticle()->GetDefinition()->GetParticleName(); 136 138 137 G4Track* track = aStep->GetTrack(); 139 G4Track* track = aStep->GetTrack(); 138 G4int trackId = track->GetTrackID(); 140 G4int trackId = track->GetTrackID(); 139 //G4String processName = aStep->GetTrack() 141 //G4String processName = aStep->GetTrack()->GetCreatorProcess()->GetProcessName(); 140 142 141 G4double partEnergy = aStep->GetPreStepPoi 143 G4double partEnergy = aStep->GetPreStepPoint()->GetKineticEnergy(); 142 G4double secondEnergy = aStep->GetPostStep 144 G4double secondEnergy = aStep->GetPostStepPoint()->GetKineticEnergy(); 143 G4cout << " la particella che deposita e': 145 G4cout << " la particella che deposita e': " << particleName << " ha una energia di keV " 144 << partEnergy << " e deposita "<< edep < 146 << partEnergy << " e deposita "<< edep << G4endl; 145 G4cout << " la particella creata ha energi 147 G4cout << " la particella creata ha energia cinetica: " << secondEnergy << G4endl; 146 */ 148 */ 147 149 148 if (edep==0.) return false; << 150 if ((edep==0.)) return false; 149 151 150 //G4cout << " edep = " << edep << G4endl; 152 //G4cout << " edep = " << edep << G4endl; 151 153 152 G4TouchableHistory* theTouchable 154 G4TouchableHistory* theTouchable 153 = (G4TouchableHistory*)(aStep->GetPreStepP 155 = (G4TouchableHistory*)(aStep->GetPreStepPoint()->GetTouchable()); 154 156 155 157 156 158 157 G4VPhysicalVolume* physVol = theTouchable->G 159 G4VPhysicalVolume* physVol = theTouchable->GetVolume(); 158 G4int PixelNumber = 0; 160 G4int PixelNumber = 0; 159 161 160 if (Detector && Detector->GetNbOfPixels()>1) 162 if (Detector && Detector->GetNbOfPixels()>1) {PixelNumber= physVol->GetCopyNo();} 161 else if (planeDetector && planeDetector->Get 163 else if (planeDetector && planeDetector->GetNbOfPixels()>1) {PixelNumber= physVol->GetCopyNo();} 162 else if (mercuryDetector && mercuryDetector- 164 else if (mercuryDetector && mercuryDetector->GetNbOfPixels()>1) {PixelNumber= physVol->GetCopyNo();} 163 165 164 166 165 167 166 if ( HitHPGeID[PixelNumber]==-1) 168 if ( HitHPGeID[PixelNumber]==-1) 167 { 169 { 168 XrayFluoSensorHit* HPGeHit = new XrayFlu 170 XrayFluoSensorHit* HPGeHit = new XrayFluoSensorHit(); 169 HPGeHit->AddEnergy(edep); 171 HPGeHit->AddEnergy(edep); 170 HitHPGeID[PixelNumber] = HPGeCollection- 172 HitHPGeID[PixelNumber] = HPGeCollection->insert(HPGeHit) - 1; 171 if (verboseLevel>0){ 173 if (verboseLevel>0){ 172 G4cout << " New Hit on pixel: " << PixelNumb 174 G4cout << " New Hit on pixel: " << PixelNumber << G4endl; 173 } 175 } 174 } 176 } 175 else 177 else 176 { 178 { 177 (*HPGeCollection)[HitHPGeID[PixelNumber] 179 (*HPGeCollection)[HitHPGeID[PixelNumber]]->AddEnergy(edep); 178 //G4double ED =(*HPGeCollection)[HitHPGe 180 //G4double ED =(*HPGeCollection)[HitHPGeID[PixelNumber]]->GetEdepTot(); 179 if (verboseLevel>0) 181 if (verboseLevel>0) 180 G4cout << " Energy added to Pixel: " << Pixe 182 G4cout << " Energy added to Pixel: " << PixelNumber << G4endl; 181 } 183 } 182 184 183 return true; 185 return true; 184 } 186 } 185 187 186 188 187 //....oooOO0OOooo........oooOO0OOooo........oo 189 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 188 190 189 void XrayFluoSD::EndOfEvent(G4HCofThisEvent* H 191 void XrayFluoSD::EndOfEvent(G4HCofThisEvent* HCE) 190 { 192 { 191 static G4int HCID = -1; 193 static G4int HCID = -1; 192 if(HCID<0) 194 if(HCID<0) 193 { HCID = G4SDManager::GetSDMpointer()->GetCo 195 { HCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]); } 194 HCE->AddHitsCollection(HCID,HPGeCollection); 196 HCE->AddHitsCollection(HCID,HPGeCollection); 195 } 197 } 196 198 197 //....oooOO0OOooo........oooOO0OOooo........oo 199 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 198 200 199 void XrayFluoSD::clear() 201 void XrayFluoSD::clear() 200 {} 202 {} 201 203 202 //....oooOO0OOooo........oooOO0OOooo........oo 204 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 203 205 204 void XrayFluoSD::DrawAll() 206 void XrayFluoSD::DrawAll() 205 {} 207 {} 206 208 207 //....oooOO0OOooo........oooOO0OOooo........oo 209 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 208 210 209 void XrayFluoSD::PrintAll() 211 void XrayFluoSD::PrintAll() 210 {} 212 {} 211 213 212 //....oooOO0OOooo........oooOO0OOooo........oo 214 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 213 215 214 216 215 217 216 218 217 219 218 220 219 221 220 222 221 223 222 224 223 225 224 226 225 227 226 228 227 229 228 230