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: XrayFluoSD.cc >> 25 // GEANT4 tag $Name: xray_fluo-V04-01-03 27 // 26 // 28 // Author: Elena Guardincerri (Elena.Guardince 27 // Author: Elena Guardincerri (Elena.Guardincerri@ge.infn.it) 29 // 28 // 30 // History: 29 // History: 31 // ----------- 30 // ----------- 32 // 28 Nov 2001 Elena Guardincerri Created 31 // 28 Nov 2001 Elena Guardincerri Created 33 // 29 Nov 2002 Energy deposition bug fixed (Al 32 // 29 Nov 2002 Energy deposition bug fixed (Alfonso.mantero@ge.infn.it) 34 // 17 Jul 2003 Name changed to XrayFluoSD 33 // 17 Jul 2003 Name changed to XrayFluoSD 35 // 01 Sep 2003 Constructor overload for differ 34 // 01 Sep 2003 Constructor overload for different geometries handling 36 // ------------------------------------------- 35 // ------------------------------------------------------------------- 37 36 38 #include "XrayFluoSD.hh" 37 #include "XrayFluoSD.hh" 39 #include "XrayFluoSensorHit.hh" 38 #include "XrayFluoSensorHit.hh" 40 #include "XrayFluoDetectorConstruction.hh" 39 #include "XrayFluoDetectorConstruction.hh" 41 #include "XrayFluoPlaneDetectorConstruction.hh 40 #include "XrayFluoPlaneDetectorConstruction.hh" 42 #include "XrayFluoMercuryDetectorConstruction. 41 #include "XrayFluoMercuryDetectorConstruction.hh" 43 #include "G4VPhysicalVolume.hh" 42 #include "G4VPhysicalVolume.hh" 44 #include "G4Step.hh" 43 #include "G4Step.hh" 45 #include "G4VTouchable.hh" 44 #include "G4VTouchable.hh" 46 #include "G4TouchableHistory.hh" 45 #include "G4TouchableHistory.hh" 47 #include "G4SDManager.hh" 46 #include "G4SDManager.hh" 48 #include "G4ios.hh" 47 #include "G4ios.hh" 49 #include "G4VProcess.hh" 48 #include "G4VProcess.hh" 50 49 51 //....oooOO0OOooo........oooOO0OOooo........oo 50 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 52 51 53 XrayFluoSD::XrayFluoSD(G4String name, 52 XrayFluoSD::XrayFluoSD(G4String name, 54 XrayFluoDet 53 XrayFluoDetectorConstruction* det) 55 :G4VSensitiveDetector(name),Detector(0),plan 54 :G4VSensitiveDetector(name),Detector(0),planeDetector(0),mercuryDetector(0) 56 { 55 { 57 56 58 Detector = det; 57 Detector = det; 59 collectionName.insert("HPGeCollection"); 58 collectionName.insert("HPGeCollection"); 60 HitHPGeID = new G4int[500]; 59 HitHPGeID = new G4int[500]; 61 G4cout << "XrayFluoSD created" << G4endl; 60 G4cout << "XrayFluoSD created" << G4endl; 62 61 63 } 62 } 64 63 65 //....oooOO0OOooo........oooOO0OOooo........oo 64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 66 65 67 XrayFluoSD::XrayFluoSD(G4String name, 66 XrayFluoSD::XrayFluoSD(G4String name, 68 XrayFluoPlaneDetectorConstruction* 67 XrayFluoPlaneDetectorConstruction* det) 69 :G4VSensitiveDetector(name),Detector(0),plan 68 :G4VSensitiveDetector(name),Detector(0),planeDetector(0),mercuryDetector(0) 70 { 69 { 71 planeDetector = det; 70 planeDetector = det; 72 collectionName.insert("HPGeCollection"); 71 collectionName.insert("HPGeCollection"); 73 HitHPGeID = new G4int[500]; 72 HitHPGeID = new G4int[500]; 74 G4cout << "XrayFluoSD created" << G4endl; 73 G4cout << "XrayFluoSD created" << G4endl; 75 74 76 } 75 } 77 76 78 //....oooOO0OOooo........oooOO0OOooo........oo 77 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 79 78 80 XrayFluoSD::XrayFluoSD(G4String name, 79 XrayFluoSD::XrayFluoSD(G4String name, 81 XrayFluoMercuryDetectorConstruction 80 XrayFluoMercuryDetectorConstruction* det) 82 :G4VSensitiveDetector(name),Detector(0),plan 81 :G4VSensitiveDetector(name),Detector(0),planeDetector(0),mercuryDetector(0) 83 { 82 { 84 mercuryDetector = det; 83 mercuryDetector = det; 85 collectionName.insert("HPGeCollection"); 84 collectionName.insert("HPGeCollection"); 86 HitHPGeID = new G4int[500]; 85 HitHPGeID = new G4int[500]; 87 G4cout << "XrayFluoSD created" << G4endl; 86 G4cout << "XrayFluoSD created" << G4endl; 88 } 87 } 89 88 90 // //....oooOO0OOooo........oooOO0OOooo....... 89 // //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 91 90 92 91 93 92 94 93 95 XrayFluoSD::~XrayFluoSD() 94 XrayFluoSD::~XrayFluoSD() 96 { 95 { 97 96 98 delete [] HitHPGeID; 97 delete [] HitHPGeID; 99 98 100 // delete HPGeCollection; 99 // delete HPGeCollection; 101 100 102 G4cout << "XrayFluoSD deleted" << G4endl; 101 G4cout << "XrayFluoSD deleted" << G4endl; 103 } 102 } 104 103 105 //....oooOO0OOooo........oooOO0OOooo........oo 104 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 106 105 107 void XrayFluoSD::Initialize(G4HCofThisEvent*) 106 void XrayFluoSD::Initialize(G4HCofThisEvent*) 108 107 109 //initializes HCE with the hits collection(s) 108 //initializes HCE with the hits collection(s) created by this 110 //sensitive detector 109 //sensitive detector 111 { 110 { 112 HPGeCollection = new XrayFluoSensorHitsColle 111 HPGeCollection = new XrayFluoSensorHitsCollection 113 (SensitiveDetectorName,collectionName[0]); 112 (SensitiveDetectorName,collectionName[0]); 114 113 115 G4int nPixel = 0; 114 G4int nPixel = 0; 116 115 117 if (Detector) {nPixel = Detector->GetNbOfPix 116 if (Detector) {nPixel = Detector->GetNbOfPixels();} 118 else if (planeDetector) {nPixel = planeDetec 117 else if (planeDetector) {nPixel = planeDetector->GetNbOfPixels();} 119 else if (mercuryDetector) {nPixel = mercuryD 118 else if (mercuryDetector) {nPixel = mercuryDetector->GetNbOfPixels();} 120 119 121 for (G4int j=0;j<nPixel;j++) 120 for (G4int j=0;j<nPixel;j++) 122 {HitHPGeID [j]= -1;}; 121 {HitHPGeID [j]= -1;}; 123 } 122 } 124 123 125 //....oooOO0OOooo........oooOO0OOooo........oo 124 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 126 125 127 G4bool XrayFluoSD::ProcessHits(G4Step* aStep,G 126 G4bool XrayFluoSD::ProcessHits(G4Step* aStep,G4TouchableHistory*) 128 { 127 { 129 128 130 129 131 130 132 G4double edep = aStep->GetTotalEnergyDeposit 131 G4double edep = aStep->GetTotalEnergyDeposit(); 133 132 134 /* 133 /* 135 G4String particleName = aStep->GetTrack()- 134 G4String particleName = aStep->GetTrack()->GetDynamicParticle()->GetDefinition()->GetParticleName(); 136 135 137 G4Track* track = aStep->GetTrack(); 136 G4Track* track = aStep->GetTrack(); 138 G4int trackId = track->GetTrackID(); 137 G4int trackId = track->GetTrackID(); 139 //G4String processName = aStep->GetTrack() 138 //G4String processName = aStep->GetTrack()->GetCreatorProcess()->GetProcessName(); 140 139 141 G4double partEnergy = aStep->GetPreStepPoi 140 G4double partEnergy = aStep->GetPreStepPoint()->GetKineticEnergy(); 142 G4double secondEnergy = aStep->GetPostStep 141 G4double secondEnergy = aStep->GetPostStepPoint()->GetKineticEnergy(); 143 G4cout << " la particella che deposita e': 142 G4cout << " la particella che deposita e': " << particleName << " ha una energia di keV " 144 << partEnergy << " e deposita "<< edep < 143 << partEnergy << " e deposita "<< edep << G4endl; 145 G4cout << " la particella creata ha energi 144 G4cout << " la particella creata ha energia cinetica: " << secondEnergy << G4endl; 146 */ 145 */ 147 146 148 if (edep==0.) return false; << 147 if ((edep==0.)) return false; 149 148 150 //G4cout << " edep = " << edep << G4endl; 149 //G4cout << " edep = " << edep << G4endl; 151 150 152 G4TouchableHistory* theTouchable 151 G4TouchableHistory* theTouchable 153 = (G4TouchableHistory*)(aStep->GetPreStepP 152 = (G4TouchableHistory*)(aStep->GetPreStepPoint()->GetTouchable()); 154 153 155 154 156 155 157 G4VPhysicalVolume* physVol = theTouchable->G 156 G4VPhysicalVolume* physVol = theTouchable->GetVolume(); 158 G4int PixelNumber = 0; 157 G4int PixelNumber = 0; 159 158 160 if (Detector && Detector->GetNbOfPixels()>1) 159 if (Detector && Detector->GetNbOfPixels()>1) {PixelNumber= physVol->GetCopyNo();} 161 else if (planeDetector && planeDetector->Get 160 else if (planeDetector && planeDetector->GetNbOfPixels()>1) {PixelNumber= physVol->GetCopyNo();} 162 else if (mercuryDetector && mercuryDetector- 161 else if (mercuryDetector && mercuryDetector->GetNbOfPixels()>1) {PixelNumber= physVol->GetCopyNo();} 163 162 164 163 165 164 166 if ( HitHPGeID[PixelNumber]==-1) 165 if ( HitHPGeID[PixelNumber]==-1) 167 { 166 { 168 XrayFluoSensorHit* HPGeHit = new XrayFlu 167 XrayFluoSensorHit* HPGeHit = new XrayFluoSensorHit(); 169 HPGeHit->AddEnergy(edep); 168 HPGeHit->AddEnergy(edep); 170 HitHPGeID[PixelNumber] = HPGeCollection- 169 HitHPGeID[PixelNumber] = HPGeCollection->insert(HPGeHit) - 1; 171 if (verboseLevel>0){ 170 if (verboseLevel>0){ 172 G4cout << " New Hit on pixel: " << PixelNumb 171 G4cout << " New Hit on pixel: " << PixelNumber << G4endl; 173 } 172 } 174 } 173 } 175 else 174 else 176 { 175 { 177 (*HPGeCollection)[HitHPGeID[PixelNumber] 176 (*HPGeCollection)[HitHPGeID[PixelNumber]]->AddEnergy(edep); 178 //G4double ED =(*HPGeCollection)[HitHPGe 177 //G4double ED =(*HPGeCollection)[HitHPGeID[PixelNumber]]->GetEdepTot(); 179 if (verboseLevel>0) 178 if (verboseLevel>0) 180 G4cout << " Energy added to Pixel: " << Pixe 179 G4cout << " Energy added to Pixel: " << PixelNumber << G4endl; 181 } 180 } 182 181 183 return true; 182 return true; 184 } 183 } 185 184 186 185 187 //....oooOO0OOooo........oooOO0OOooo........oo 186 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 188 187 189 void XrayFluoSD::EndOfEvent(G4HCofThisEvent* H 188 void XrayFluoSD::EndOfEvent(G4HCofThisEvent* HCE) 190 { 189 { 191 static G4int HCID = -1; 190 static G4int HCID = -1; 192 if(HCID<0) 191 if(HCID<0) 193 { HCID = G4SDManager::GetSDMpointer()->GetCo 192 { HCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]); } 194 HCE->AddHitsCollection(HCID,HPGeCollection); 193 HCE->AddHitsCollection(HCID,HPGeCollection); 195 } 194 } 196 195 197 //....oooOO0OOooo........oooOO0OOooo........oo 196 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 198 197 199 void XrayFluoSD::clear() 198 void XrayFluoSD::clear() 200 {} 199 {} 201 200 202 //....oooOO0OOooo........oooOO0OOooo........oo 201 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 203 202 204 void XrayFluoSD::DrawAll() 203 void XrayFluoSD::DrawAll() 205 {} 204 {} 206 205 207 //....oooOO0OOooo........oooOO0OOooo........oo 206 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 208 207 209 void XrayFluoSD::PrintAll() 208 void XrayFluoSD::PrintAll() 210 {} 209 {} 211 210 212 //....oooOO0OOooo........oooOO0OOooo........oo 211 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo.... 213 212 214 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