source: ELYSE/HEAD/source/TrappingVolume.cxx@ 288

Last change on this file since 288 was 286, checked in by campagne, 19 years ago

ELYSE sauvegarde provisoire (JEC)

File size: 3.3 KB
Line 
1#include "ELYSE/TrappingVolume.hh"
2
3//Geant4
4#include "G4ParticleTypes.hh"
5#include "G4HCofThisEvent.hh"
6#include "G4TouchableHistory.hh"
7#include "G4Step.hh"
8#include "G4ThreeVector.hh"
9#include "G4SDManager.hh"
10#include "G4ios.hh"
11
12//std
13#include <sstream>
14#include <stdio.h>
15
16//ELYSE
17#include "ELYSE/DetectorConstruction.hh"
18
19ELYSE::TrappingVolume::TrappingVolume(G4String name,
20 DetectorConstruction* aDetConstruction)
21:G4VSensitiveDetector(name),ELYSEDetConstruction(aDetConstruction) {
22
23 G4String HCname;
24 collectionName.insert(HCname="TrappingVolume");
25
26 HCID = -1;
27
28}//Ctor
29
30//-----------------------------------------------------------------------------------------
31
32ELYSE::TrappingVolume::~TrappingVolume() {
33}//Dtor
34
35//-----------------------------------------------------------------------------------------
36
37
38void ELYSE::TrappingVolume::Initialize(G4HCofThisEvent* HCE) {
39 // Make a new hits collection. With the name we set in the constructor
40 hitsCollection = new TrappVolHitsCollection(SensitiveDetectorName,collectionName[0]);
41
42 // Get the Id of the "0th" collection
43 if (HCID<0) HCID = GetCollectionID(0); //JEC FIXME: is it necessary?
44
45 // Add it to the Hit collection of this event.
46 HCE->AddHitsCollection( HCID, hitsCollection ); //JEC FIXME: is it necessary?
47
48}//Initialize
49
50//-----------------------------------------------------------------------------------------
51G4bool ELYSE::TrappingVolume::ProcessHits(G4Step* aStep, G4TouchableHistory* aTH) {
52 return ProcessHits_constStep(aStep,aTH);
53}
54//-----------------------------------------------------------------------------------------
55
56G4bool ELYSE::TrappingVolume::ProcessHits_constStep(const G4Step* aStep, G4TouchableHistory*) {
57
58 // G4ParticleDefinition *particleDefinition = aStep->GetTrack()->GetDefinition();
59
60// if ( particleDefinition != G4OpticalPhoton::OpticalPhotonDefinition()) return false;
61// if ( aStep->GetTrack()->GetTrackStatus() == fAlive ) return false;
62
63
64 TrappVolHit* newHit = new TrappVolHit();
65
66 G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
67 G4Track* theTrack = aStep->GetTrack();
68
69
70 //related to the StepPoint or the Track????
71 newHit->SetTime(preStepPoint->GetGlobalTime());
72 newHit->SetEtot(preStepPoint->GetTotalEnergy());
73 newHit->SetCoordinates(preStepPoint->GetPosition());
74 newHit->SetTrkId(theTrack->GetTrackID());
75 newHit->SetParentId(theTrack->GetParentID());
76 newHit->SetPDGEncoding(theTrack->GetDefinition()->GetPDGEncoding());
77 newHit->SetEdep(aStep->GetTotalEnergyDeposit());
78
79
80 G4cout << "New Hit \n"
81 << "Global Time: " << preStepPoint->GetGlobalTime() << " =?= "
82 << theTrack->GetGlobalTime()
83 << "\n"
84 << "TotalEnergy: " << preStepPoint->GetTotalEnergy() << " =?= "
85 << theTrack->GetTotalEnergy()
86 << "\n"
87 << "Position: " << preStepPoint->GetPosition() << " =?= "
88 << theTrack->GetPosition()
89 << G4endl;
90
91
92 //store the hit
93 hitsCollection->insert( newHit );
94
95 return true;
96}//ProcessHits
97
98//-----------------------------------------------------------------------------------------
99
100void ELYSE::TrappingVolume::EndOfEvent(G4HCofThisEvent*) {
101 if (verboseLevel>0) {
102 G4int numHits = hitsCollection->entries();
103
104 G4cout << "There are " << numHits << " hits in the WC: " << G4endl;
105 for (G4int i=0; i < numHits; i++)
106 (*hitsCollection)[i]->Print();
107 }
108}//EndOfEvent
109
Note: See TracBrowser for help on using the repository browser.