source: trunk/examples/extended/electromagnetic/TestEm8/src/Em8CalorimeterSD.cc

Last change on this file was 1337, checked in by garnier, 14 years ago

tag geant4.9.4 beta 1 + modifs locales

File size: 4.8 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: Em8CalorimeterSD.cc,v 1.7 2006/06/29 17:00:05 gunter Exp $
28// GEANT4 tag $Name: geant4-09-04-beta-01 $
29//
30//
31
32//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
33//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
34
35#include "Em8CalorimeterSD.hh"
36
37#include "Em8CalorHit.hh"
38#include "Em8DetectorConstruction.hh"
39
40#include "G4VPhysicalVolume.hh"
41#include "G4Step.hh"
42#include "G4VTouchable.hh"
43#include "G4TouchableHistory.hh"
44#include "G4SDManager.hh"
45 
46#include "G4ios.hh"
47
48//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
49
50Em8CalorimeterSD::Em8CalorimeterSD(G4String name,
51                                   Em8DetectorConstruction* det)
52:G4VSensitiveDetector(name),Detector(det)
53{
54  collectionName.insert("CalCollection");
55  HitID = new G4int[500];
56}
57
58//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
59
60Em8CalorimeterSD::~Em8CalorimeterSD()
61{
62  delete [] HitID;
63}
64
65//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
66
67void Em8CalorimeterSD::Initialize(G4HCofThisEvent*)
68{
69  CalCollection = new Em8CalorHitsCollection
70                      (SensitiveDetectorName,collectionName[0]); 
71
72  for (G4int j=0;j<1; j++) 
73  {
74    HitID[j] = -1;
75  }
76}
77
78//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
79
80G4bool Em8CalorimeterSD::ProcessHits(G4Step* aStep,G4TouchableHistory*)
81{
82  G4double edep = aStep->GetTotalEnergyDeposit();
83   
84  G4double stepl = 0.;
85
86  if (aStep->GetTrack()->GetDefinition()->GetPDGCharge() != 0.)
87  {
88    stepl = aStep->GetStepLength();
89  }   
90  if ( ( edep == 0. ) && ( stepl == 0. ) ) return false;     
91
92  G4TouchableHistory* theTouchable
93    = (G4TouchableHistory*)(aStep->GetPreStepPoint()->GetTouchable());
94   
95  G4VPhysicalVolume* physVol = theTouchable->GetVolume(); 
96 
97  G4int Em8Number = 0 ;
98
99  if ( HitID[Em8Number] == -1 )
100  { 
101    Em8CalorHit* calHit = new Em8CalorHit();
102
103    if ( physVol == Detector->GetAbsorber()) // &&
104      //  aStep->GetTrack()->GetTrackID() == 1)
105    {
106      calHit->AddAbs(edep,stepl);
107    }
108    HitID[Em8Number] = CalCollection->insert(calHit) - 1;
109
110    if ( verboseLevel > 0 )
111    {
112      G4cout << " New Calorimeter Hit on Em8: " << Em8Number << G4endl;
113    }
114  }
115  else
116  { 
117    if (physVol == Detector->GetAbsorber()) // &&
118      //   aStep->GetTrack()->GetTrackID() == 1 )
119    {
120       (*CalCollection)[HitID[Em8Number]]->AddAbs(edep,stepl);
121    }
122    if ( verboseLevel > 0 )
123    {
124      G4cout << " Energy added to Em8: " << Em8Number << G4endl;
125    } 
126  }   
127  return true;
128}
129
130//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
131
132void Em8CalorimeterSD::EndOfEvent(G4HCofThisEvent* HCE)
133{
134  static G4int HCID = -1;
135  if(HCID<0)
136  { HCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]); }
137  HCE->AddHitsCollection(HCID,CalCollection);
138}
139
140//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
141
142void Em8CalorimeterSD::clear()
143{} 
144
145//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
146
147
148void Em8CalorimeterSD::PrintAll()
149{} 
150
151//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
152
Note: See TracBrowser for help on using the repository browser.