QwGeant4
QweakSimTungstenPlug_DetectorSD.cc
Go to the documentation of this file.
1 
2 // QweakSimTungstenPlug_DetectorSD.cc
3 // Martin McHugh
4 // 2015-05-04
5 
6 /////// --------------------------------------------------------------------
8 
9 //--- user classes
13 
14 /////// --------------------------------------------------------------------
16 :G4VSensitiveDetector(name)
17 {
18  G4cout << name << G4endl;
19  collectionName.insert("TungstenPlugCollection");
21 }
22 
23 
24 
25 /////// --------------------------------------------------------------------
27 {
28  //delete TungstenPlug_DetectorHitsCollection;
29 }
30 
31 
32 
33 /////// --------------------------------------------------------------------
34 
36 {
37  TungstenPlug_DetectorHitsCollection = new QweakSimTungstenPlug_DetectorHitsCollection(SensitiveDetectorName,collectionName[0]);
38  //if(TungstenPlug_CollectionID<0)
39  TungstenPlug_CollectionID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
41 
42 }
43 
44 
45 /////// --------------------------------------------------------------------
46 
47 G4bool QweakSimTungstenPlug_DetectorSD::ProcessHits(G4Step* aStep, G4TouchableHistory* )
48 {
49  //--- Not Entering Geometry
50  if (aStep->GetPreStepPoint()->GetStepStatus() != fGeomBoundary ) return false;
51 
52  G4TouchableHandle theTouchable = aStep->GetPreStepPoint()->GetTouchableHandle();
53 
54  G4int motherCopyNo = theTouchable->GetVolume(1)->GetCopyNo(); // one Mother Volume
55 
56  //G4double parentID = aStep->GetTrack()->GetParentID();
57  G4double trackID = aStep->GetTrack()->GetTrackID();
58 
59  G4ParticleDefinition* fpParticleDefinition = aStep->GetTrack()->GetDefinition();
60  G4String particleName = fpParticleDefinition->GetParticleName();
61  //G4double pdgCharge = fpParticleDefinition->GetPDGCharge();
62  G4int pdgEncoding = fpParticleDefinition->GetPDGEncoding();
63 
64  //GlobalTimeOfHit
65  G4double globalTime = aStep->GetPreStepPoint()->GetGlobalTime();
66 
67  G4ThreeVector worldPos = aStep->GetPreStepPoint()->GetPosition();
68  G4ThreeVector localPos = theTouchable->GetHistory()->GetTopTransform().TransformPoint(worldPos);
69 
70  // Local Origin (where did the hit come from)
71  G4ThreeVector originVertexPosition = aStep->GetTrack()->GetVertexPosition();
72 
73  G4ThreeVector worldMomentum = aStep->GetPreStepPoint()->GetMomentum();
74  G4ThreeVector localMomentum = theTouchable->GetHistory()->GetTopTransform().TransformPoint(worldMomentum);
75  G4ThreeVector currentMomentumDirection = aStep->GetTrack()->GetMomentumDirection();
76  G4ThreeVector originVertexMomentumDirection = aStep->GetTrack()->GetVertexMomentumDirection();
77 
78  G4double originVertexKineticEnergy = aStep->GetTrack()->GetVertexKineticEnergy();
79  G4double originVertexTotalEnergy = aStep->GetTrack()->GetVertexKineticEnergy();//GetVertexTotalEnergy();
80 
81  G4double currentKineticEnergy = aStep->GetTrack()->GetKineticEnergy();
82  G4double currentTotalEnergy = aStep->GetTrack()->GetTotalEnergy();
83 
84  //--- TungstenPlug deposited energy
85  G4double depositedEnergy = aStep->GetTotalEnergyDeposit();
86 
87  //----------------- Store Hit information
89 
90  aHit -> StoreTrackID(trackID);
91 
92  aHit -> StoreParticleName(particleName);
93  aHit -> StoreParticleType(pdgEncoding);
94 
95  aHit -> StoreGlobalTime(globalTime);
96 
97  aHit -> StoreWorldPosition(worldPos);
98  aHit -> StoreLocalPosition(localPos);
99  aHit -> StoreOriginVertexPosition(originVertexPosition);
100 
101  aHit -> StoreWorldMomentum(worldMomentum);
102  aHit -> StoreLocalMomentum(localMomentum);
103  aHit -> StoreMomentumDirection(currentMomentumDirection);
104  aHit -> StoreOriginVertexMomentumDirection(originVertexMomentumDirection);
105 
106  aHit -> StoreOriginVertexKineticEnergy(originVertexKineticEnergy);
107  aHit -> StoreOriginVertexTotalEnergy(originVertexTotalEnergy); // kinetic energy
108 
109  aHit -> StoreKineticEnergy(currentKineticEnergy);
110  aHit -> StoreTotalEnergy(currentTotalEnergy);
111 
112  //--- TungstenPlug deposited energy
113  aHit -> StoreDepositedEnergy(depositedEnergy);
114 
116 
117  return true;
118 }
119 
120 
121 
122 /////// --------------------------------------------------------------------
123 
125 {
126  //G4int NbDCHits = DC_hitsCollection->entries();
127 
128  //G4cout << "\n-------->Hits Collection: in this event they are " << NbDCHits
129  // << " hits in the Drift Cells : " << G4endl;
130  //for (G4int i=0;i<NbDCHits;i++) (
131  // *DC_hitsCollection)[i]->Print();
132 
133 }
134 
135 
136 
137 /////// --------------------------------------------------------------------
138 
139 
140 
G4THitsCollection< QweakSimTungstenPlug_DetectorHit > QweakSimTungstenPlug_DetectorHitsCollection
G4bool ProcessHits(G4Step *aStep, G4TouchableHistory *ROhist)
QweakSimTungstenPlug_DetectorHitsCollection * TungstenPlug_DetectorHitsCollection