source: trunk/examples/advanced/xray_fluorescence/src/XrayFluoHPGeSD.cc @ 1230

Last change on this file since 1230 was 807, checked in by garnier, 16 years ago

update

File size: 6.0 KB
Line 
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: XrayFluoHPGeSD.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// -------------------------------------------------------------------
37
38#include "XrayFluoHPGeSD.hh"
39#include "XrayFluoSensorHit.hh"
40#include "XrayFluoDetectorConstruction.hh"
41#include "G4VPhysicalVolume.hh"
42#include "G4Step.hh"
43#include "G4VTouchable.hh"
44#include "G4TouchableHistory.hh"
45#include "G4SDManager.hh"
46#include "G4ios.hh"
47#include "G4VProcess.hh"
48
49//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
50
51XrayFluoHPGeSD::XrayFluoHPGeSD(G4String name,
52                                   XrayFluoDetectorConstruction* det)
53:G4VSensitiveDetector(name),Detector(det)
54{
55  collectionName.insert("HPGeCollection");
56  HitHPGeID = new G4int[500];
57  //G4cout << "XrayFluoHPGeSD created" << G4endl;
58
59}
60
61//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
62
63XrayFluoHPGeSD::~XrayFluoHPGeSD()
64{
65
66  delete [] HitHPGeID;
67
68  // delete HPGeCollection;
69
70  G4cout << "XrayFluoHPGeSD deleted" << G4endl;
71}
72
73//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
74
75void XrayFluoHPGeSD::Initialize(G4HCofThisEvent*HCE)
76 
77//initializes HCE with the hits collection(s) created by this
78  //sensitive detector
79{ 
80  if (HCE){
81   
82    HPGeCollection = new XrayFluoSensorHitsCollection
83      (SensitiveDetectorName,collectionName[0]); 
84    for (G4int j=0;j<Detector->GetNbOfPixels();j++)
85      {HitHPGeID [j]= -1;};
86  }
87}
88//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
89
90G4bool XrayFluoHPGeSD::ProcessHits(G4Step* aStep,G4TouchableHistory* ROhist)
91{       
92 
93  if (ROhist){
94   
95    G4double edep = aStep->GetTotalEnergyDeposit();
96    //    G4String particleName = aStep->GetTrack()->GetDynamicParticle()->GetDefinition()->GetParticleName();
97    //    G4String processName = aStep->GetTrack()->GetCreatorProcess()->GetProcessName();
98   
99    //    G4double partEnergy = aStep->GetPreStepPoint()->GetKineticEnergy();
100    //    G4double secondEnergy = aStep->GetPostStepPoint()->GetKineticEnergy();
101    //    G4cout << " la particella che deposita e': " << particleName << " ha una energia di keV "
102    //           << partEnergy  << " e deposita "<< edep << G4endl;
103    //    G4cout << " la particella creata deposita: " << secondEnergy << G4endl; 
104    //    if (processName){
105   
106   
107   
108    //      G4cout << " la particella viene da: " << processName << G4endl;
109    //    }
110   
111    //    else {G4cout << " il deposito proviene da: Rayleugh" << G4endl;}
112   
113    if ((edep==0.)) return false;     
114   
115    //  G4cout << " edep =  " << edep << G4endl;
116   
117    G4TouchableHistory* theTouchable
118      = (G4TouchableHistory*)(aStep->GetPreStepPoint()->GetTouchable());
119   
120    G4VPhysicalVolume* physVol = theTouchable->GetVolume(); 
121    //  theTouchable->MoveUpHistory();     
122    G4int PixelNumber = 0;
123    if (Detector->GetNbOfPixels()>1) PixelNumber= physVol->GetCopyNo() ;
124    if ( HitHPGeID[PixelNumber]==-1)
125      { 
126        XrayFluoSensorHit* HPGeHit = new XrayFluoSensorHit();
127        HPGeHit->AddEnergy(edep);
128        HitHPGeID[PixelNumber] = HPGeCollection->insert(HPGeHit) - 1;
129        if (verboseLevel>0){
130          G4cout << " New Hit on pixel: " << PixelNumber << G4endl;
131        }
132      }
133    else
134      { 
135        (*HPGeCollection)[HitHPGeID[PixelNumber]]->AddEnergy(edep);
136        //G4double ED =(*HPGeCollection)[HitHPGeID[PixelNumber]]->GetEdepTot();
137        if (verboseLevel>0)
138          G4cout << " Energy added to Pixel: " << PixelNumber << G4endl; 
139      }
140   
141    return true;
142  }
143  else {return false;}
144
145}
146
147
148//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
149
150void XrayFluoHPGeSD::EndOfEvent(G4HCofThisEvent* HCE)
151{
152  static G4int HCID = -1;
153  if(HCID<0)
154  { HCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]); }
155  HCE->AddHitsCollection(HCID,HPGeCollection);
156}
157
158//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
159
160void XrayFluoHPGeSD::clear()
161{} 
162
163//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
164
165void XrayFluoHPGeSD::DrawAll()
166{} 
167
168//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
169
170void XrayFluoHPGeSD::PrintAll()
171{} 
172
173//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
Note: See TracBrowser for help on using the repository browser.