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