QwGeant4
QweakSimLeadGlass_DetectorSD.cc
Go to the documentation of this file.
1 
2 // QweakSimLeadGlass_DetectorSD.cc
3 // Fang Guo
4 // 2012/07/31
5 
6 /////// --------------------------------------------------------------------
7 
9 
10 //--- user classes
14 
15 
16 
17 /////// --------------------------------------------------------------------
18 
20 :G4VSensitiveDetector(name)
21 {
22  collectionName.insert("LeadGlassCollection");
24 }
25 
26 
27 
28 /////// --------------------------------------------------------------------
29 
31 {
32  //delete LeadGlass_HitsCollection;
33 }
34 
35 
36 
37 /////// --------------------------------------------------------------------
38 
39 void QweakSimLeadGlass_DetectorSD::Initialize(G4HCofThisEvent* HCE)
40 {
41  LeadGlass_DetectorHitsCollection = new QweakSimLeadGlass_DetectorHitsCollection(SensitiveDetectorName,collectionName[0]);
42  //if(LeadGlass_CollectionID<0)
43  LeadGlass_CollectionID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
45 
46 }
47 
48 
49 /////// --------------------------------------------------------------------
50 
51 G4bool QweakSimLeadGlass_DetectorSD::ProcessHits(G4Step* aStep, G4TouchableHistory* )
52 {
53 
54  G4TouchableHandle theTouchable = aStep->GetPreStepPoint()->GetTouchableHandle();
55  G4int motherCopyNo = theTouchable->GetVolume(1)->GetCopyNo(); // one Mother Volume
56 
57  //G4double parentID = aStep->GetTrack()->GetParentID();
58  G4double trackID = aStep->GetTrack()->GetTrackID();
59 
60  G4ParticleDefinition* fpParticleDefinition = aStep->GetTrack()->GetDefinition();
61  G4String particleName = fpParticleDefinition->GetParticleName();
62  //G4double pdgCharge = fpParticleDefinition->GetPDGCharge();
63  G4int pdgEncoding = fpParticleDefinition->GetPDGEncoding();
64 
65  //GlobalTimeOfHit
66  G4double globalTime = aStep->GetPreStepPoint()->GetGlobalTime();
67 
68  G4ThreeVector worldPos = aStep->GetPreStepPoint()->GetPosition();
69  G4ThreeVector localPos = theTouchable->GetHistory()->GetTopTransform().TransformPoint(worldPos);
70  //localExitPos;
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  //calculated in Event Action
79  //G4double originVertexThetaAngle;
80  //G4double originVertexPhiAngle;
81 
82  G4double originVertexKineticEnergy = aStep->GetTrack()->GetVertexKineticEnergy();
83  G4double originVertexTotalEnergy = aStep->GetTrack()->GetVertexKineticEnergy();//GetVertexTotalEnergy();
84 
85  G4double currentKineticEnergy = aStep->GetTrack()->GetKineticEnergy();
86  G4double currentTotalEnergy = aStep->GetTrack()->GetTotalEnergy();
87 
88  //--- Get User Track Info
89  //QweakSimTrackInformation* info = (QweakSimTrackInformation*)(aStep->GetTrack()->GetUserInformation());
90 
91  //G4int primaryTrackID = info->GetPrimaryTrackID();
92  //G4double primaryQ2 = info->GetPrimaryQ2();
93  //G4double crossSection = info->GetCrossSection();
94  //G4double crossSectionWeight = info->GetCrossSectionWeight();
95 
96  //calculated in Event Action
97  //G4double globalThetaAngle;
98  //G4double globalPhiAngle;
99 
100  //--- LeadGlass deposited energy
101  G4double depositedEnergy = aStep->GetTotalEnergyDeposit();
102 
103 
104  //----------------- Store Hit information
105 
107 
108  aHit -> StoreTrackID(trackID);
109 
110  aHit -> StoreParticleName(particleName);
111  aHit -> StoreParticleType(pdgEncoding);
112 
113  aHit -> StoreGlobalTime(globalTime);
114 
115  //aHit -> StoreHasBeenHit(hasBeenHit);
116  //aHit -> StoreEdgeEventFlag(edgeEventFlag);
117  //aHit -> SotreNbOfHits(nbOfHits);
118 
119  aHit -> StoreWorldPosition(worldPos);
120  aHit -> StoreLocalPosition(localPos);
121  //aHit -> StoreLocalExitPosition(localExitPos);
122  aHit -> StoreOriginVertexPosition(originVertexPosition);
123 
124  aHit -> StoreWorldMomentum(worldMomentum);
125  aHit -> StoreLocalMomentum(localMomentum);
126  aHit -> StoreMomentumDirection(currentMomentumDirection);
127  aHit -> StoreOriginVertexMomentumDirection(originVertexMomentumDirection);
128 
129  //aHit -> StoreOriginVertexThetaAngle; //calculated in EventAction
130  //aHit -> StoreOriginVertexPhiAngle;
131 
132  aHit -> StoreOriginVertexKineticEnergy(originVertexKineticEnergy);
133  aHit -> StoreOriginVertexTotalEnergy(originVertexTotalEnergy); // kinetic energy
134 
135  aHit -> StoreKineticEnergy(currentKineticEnergy);
136  aHit -> StoreTotalEnergy(currentTotalEnergy);
137 
138  //aHit -> StorePrimaryQ2(primaryQ2);
139  //aHit -> StoreCrossSection(crossSection);
140  //aHit -> StoreCrossSectionWeight(crossSectionWeight);
141 
142  //aHit -> StoreGlobalThetaAngle; //calculated in EventAction
143  //aHit -> StoreGlobalPhiAngle;
144 
145  //--- LeadGlass deposited energy
146  aHit -> StoreHitDepositedEnergy(depositedEnergy);
147 
148  // aHit->Print();
149 
150  //----------------- check if it is first touch
151 
152  if ( !(aHit -> GetLogVolume()) )
153  {
154  //--- store translation and rotation matrix of the drift cell
155  //--- for the sake of drawing the hit
156  aHit -> StoreLogVolume(theTouchable->GetVolume()->GetLogicalVolume());
157  G4AffineTransform aTrans = theTouchable->GetHistory()->GetTopTransform();
158  aTrans.Invert();
159  aHit -> StoreCellRotation(aTrans.NetRotation());
160  aHit -> StoreCellPosition(aTrans.NetTranslation());
161  }
162 
163  LeadGlass_DetectorHitsCollection->insert(aHit);
164 
165  return true;
166 }
167 
168 
169 
170 /////// --------------------------------------------------------------------
171 
173 {
174  //G4int NbDCHits = DC_hitsCollection->entries();
175 
176  //G4cout << "\n-------->Hits Collection: in this event they are " << NbDCHits
177  // << " hits in the Drift Cells : " << G4endl;
178  //for (G4int i=0;i<NbDCHits;i++) (
179  // *DC_hitsCollection)[i]->Print();
180 
181 }
182 
183 
184 
185 /////// --------------------------------------------------------------------
186 
187 
188 
G4bool ProcessHits(G4Step *aStep, G4TouchableHistory *ROhist)
G4THitsCollection< QweakSimLeadGlass_DetectorHit > QweakSimLeadGlass_DetectorHitsCollection
QweakSimLeadGlass_DetectorHitsCollection * LeadGlass_DetectorHitsCollection