QwGeant4
QweakSimVDC_DriftCellBackSD.cc
Go to the documentation of this file.
1 
2 //=============================================================================
3 //
4 // ---------------------------
5 // | Doxygen File Information |
6 // ---------------------------
7 //
8 /**
9 
10  \file QweakSimVDC_DriftCellBackSD.cc
11 
12  $Revision: 1.4 $
13  $Date: 2006/05/05 21:47:36 $
14 
15  \author Klaus Hans Grimm
16 
17 */
18 //=============================================================================
19 
20 //=============================================================================
21 // -----------------------
22 // | CVS File Information |
23 // -----------------------
24 //
25 // Last Update: $Author: grimm $
26 // Update Date: $Date: 2006/05/05 21:47:36 $
27 // CVS/RCS Revision: $Revision: 1.4 $
28 // Status: $State: Exp $
29 //
30 // ===================================
31 // CVS Revision Log at end of file !!
32 // ===================================
33 //
34 //============================================================================
35 
36 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
37 
39 
40 // user includes
42 #include "QweakSimVDC.hh"
44 
45 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
46 
52 
53 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55 :G4VSensitiveDetector(name)
56 {
57  //G4cout << G4endl << "###### Calling QweakSimVDC_DriftCellBackSD::QweakSimVDC_DriftCellBackSD() " << G4endl << G4endl;
58 
59  collectionName.insert("DriftCellBackCollection");
60 
61  DC_ID = -1;
62 
63  //G4cout << G4endl << "###### Leaving QweakSimVDC_DriftCellBackSD::QweakSimVDC_DriftCellBackSD() " << G4endl << G4endl;
64 }
65 
66 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
68 {
69  //G4cout << G4endl << "###### Calling QweakSimVDC_DriftCellBackSD::~QweakSimVDC_DriftCellBackSD() " << G4endl << G4endl;
70 
71 }
72 
73 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
74 void QweakSimVDC_DriftCellBackSD::Initialize(G4HCofThisEvent* HCE)
75 {
76  //G4cout << G4endl << "###### Calling QweakSimVDC_DriftCellBackSD::Initialize() " << G4endl << G4endl;
77 
78  DC_hitsCollection = new QweakSimVDC_DriftCellHitsCollection(SensitiveDetectorName,collectionName[0]);
79 
80  // for(int i=0;i<DCNumberPerPlane;i++)
81  //{ DC_hitsCollection->insert(new QweakSimVDC_DriftCellHit); }
82 
83  if(DC_ID<0)
84  { DC_ID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]); }
85  //{ DC_ID = G4SDManager::GetSDMpointer()->GetCollectionID(DC_hitsCollection); }
86  HCE->AddHitsCollection( DC_ID, DC_hitsCollection );
87 
88  //G4cout << G4endl << "###### Leaving QweakSimVDC_DriftCellBackSD::Initialize() " << G4endl << G4endl;
89 }
90 
91 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
92 //G4bool QweakSimVDC_DriftCellBackSD::ProcessHits(G4Step* aStep,G4TouchableHistory* /*ROhist*/)
93 G4bool QweakSimVDC_DriftCellBackSD::ProcessHits(G4Step* aStep,G4TouchableHistory* )
94 {
95  // G4cout << G4endl << "###### Calling QweakSimVDC_DriftCellBackSD::ProcessHits() " << G4endl << G4endl;
96 
97 // G4double charge = aStep->GetTrack()->GetDefinition()->GetPDGCharge();
98 
99 
100 // G4cout << "%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% Charge =" << charge << G4endl;
101 
102  // dismiss photons
103 // if(charge==0.) {
104 
105 // G4cout << "==================================================================" << G4endl;
106 // G4cout << ">>>> Neutral Particle detected (e.g. Photon) <<<<<<" << G4endl;
107 // G4cout << ">>>> Up to now we don't count HITs for neutrals, therefore: <<<<<<" << G4endl;
108 // G4cout << ">>>> Aborting QweakSimVDC_DriftCellBackSD::ProcessHits <<<<<<" << G4endl;
109 // G4cout << "==================================================================" << G4endl;
110 
111 // G4cout << G4endl << "###### Leaving QweakSimVDC_DriftCellBackSD::ProcessHits() " << G4endl << G4endl;
112 
113 // return false;
114 // }
115 
116  //=====================================================================================
117  G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
118 // G4StepPoint* postStepPoint = aStep->GetPreStepPoint();
119  G4TouchableHistory* theTouchable = (G4TouchableHistory*)(preStepPoint->GetTouchable());
120  G4VPhysicalVolume* physVol = theTouchable->GetVolume();
121  //=====================================================================================
122 
123  // G4cout << "==================================================================" << G4endl;
124  // G4cout << ">>>>>> We are in volume :" << physVol->GetName() << "<<<<<<" << G4endl;
125  // G4cout << "==================================================================" << G4endl;
126 
127 
128  if( physVol->GetName().compare("VDC_DriftCellBack_Physical") == 0 )
129  {
130  // G4cout << "==================================================================" << G4endl;
131  // G4cout << ">>>>>>> Particle crossing : VDC_DriftCellBack_Physical <<<<<<<<<" << G4endl;
132  // G4cout << "==================================================================" << G4endl;
133 
134  //const G4VProcess* process = aStep->GetPostStepPoint()->GetProcessDefinedStep();
135  //G4cout << "@@@@@@@@@@@@@> Physical Processes in VDC_DriftCellBack_Physical = "<< process->GetProcessName() << G4endl;
136 
137  }
138  else
139  {
140  // G4cout << "==================================================================" << G4endl;
141  // G4cout << ">>>> ERROR: We are not within a physical DriftCell Volume <<<<<<" << G4endl;
142  // G4cout << ">>>> Aborting QweakSimVDC_DriftCellBackSD::ProcessHits <<<<<<" << G4endl;
143  // G4cout << "==================================================================" << G4endl;
144 
145  return false;
146  }
147 
148  //===============================================================================================
149  // here we are only interested if the particle is crossing a boundary
150  // otherwise we get additional hits due to physical processes within the sensitive volume
151  //
152  // If you want to identify the first step in a volume: pick fGeomBoundary status in preStepPoint
153  // If you want to identify a step out of a volume : pick fGeomBoundary status in postStepPoint
154  //================================================================================================
155  //
156  if (preStepPoint->GetStepStatus() != fGeomBoundary) {
157 
158  // G4cout << "=======================================================================" << G4endl;
159  // G4cout << ">>>> QweakSimVDC_DriftCellFrontSD: We are NOT crossing a boundary <<<<<<" << G4endl;
160  // G4cout << ">>>> Aborting QweakSimVDC_DriftCellBackSD::ProcessHits <<<<<<" << G4endl;
161  // G4cout << "=======================================================================" << G4endl;
162  //
163  // G4cout << G4endl << "###### Leaving QweakSimVDC_DriftCellBackSD::ProcessHits() " << G4endl << G4endl;
164 
165  return false;
166  }
167 
168 
169  G4double currentKineticEnergy = aStep->GetTrack()->GetKineticEnergy();
170  G4double currentTotalEnergy = aStep->GetTrack()->GetTotalEnergy();
171  G4ThreeVector currentMomentumDirection = aStep->GetTrack()->GetMomentumDirection();
172 
173 // G4int trackID = aStep->GetTrack()->GetTrackID();
174 // G4cout << "====> Track ID : " << trackID << G4endl;
175 
176 // G4int parentID = aStep->GetTrack()->GetParentID();
177 // G4cout << "====> Parent ID : " << parentID << G4endl;
178 
179 
180  // Vertex: where this track was generated
181  G4ThreeVector originVertexPosition = aStep->GetTrack()->GetVertexPosition();
182  G4ThreeVector originVertexMomentumDirection = aStep->GetTrack()->GetVertexMomentumDirection();
183  G4double originVertexKineticEnergy = aStep->GetTrack()->GetVertexKineticEnergy();
184 
185 // G4cout << "====> originVertexPosition_X [cm] : " << originVertexPosition.x()/cm << G4endl;
186 // G4cout << "====> originVertexPosition_Y [cm] : " << originVertexPosition.y()/cm << G4endl;
187 // G4cout << "====> originVertexPosition_Z [cm] : " << originVertexPosition.z()/cm << G4endl;
188 
189 // G4cout << "====> originVertexMomentumDirection_X : " << originVertexMomentumDirection.x() << G4endl;
190 // G4cout << "====> originVertexMomentumDirection_Y : " << originVertexMomentumDirection.y() << G4endl;
191 // G4cout << "====> originVertexMomentumDirection_Z : " << originVertexMomentumDirection.z() << G4endl;
192 
193 // G4cout << "====> originVertexKineticEnergy [Mev] : " << originVertexKineticEnergy/MeV << G4endl;
194 
195 
196 // G4int MotherCopyNo = theTouchable->GetVolume(1)->GetCopyNo(); // one Mother Volume
197 // G4int DriftCellCopyNo = theTouchable->GetVolume()->GetCopyNo(); // but several Driftcells per MV
198  G4int DriftCellReplicaNo = theTouchable->GetReplicaNumber(); // but several Driftcells per MV
199 
200 // G4cout << "%%%%%%%%%%%%%%%%%%%%%%% VDC_DriftCellFront MV CopyNumber :" << MotherCopyNo << G4endl;
201 // G4cout << "%%%%%%%%%%%%%%%%%%%%%%% VDC_DriftCellFront CopyNumber :" << DriftCellCopyNo << G4endl;
202 // G4cout << "%%%%%%%%%%%%%%%%%%%%%%% VDC_DriftCellFront ReplicaNumber :" << DriftCellReplicaNo << G4endl;
203 
204 
205  G4ThreeVector worldPos = preStepPoint->GetPosition();
206 // G4cout << "%%%%%%%%%%%%%%%%%%%%%%% VDC_DriftCellFront WorldPos.X [cm]:" << worldPos.x()/cm << G4endl;
207 // G4cout << "%%%%%%%%%%%%%%%%%%%%%%% VDC_DriftCellFront WorldPos.Y [cm]:" << worldPos.y()/cm << G4endl;
208 // G4cout << "%%%%%%%%%%%%%%%%%%%%%%% VDC_DriftCellFront WorldPos.Z [cm]:" << worldPos.z()/cm << G4endl;
209 
210  G4ThreeVector localPos = theTouchable->GetHistory()->GetTopTransform().TransformPoint(worldPos);
211 // G4cout << "%%%%%%%%%%%%%%%%%%%%%%% VDC_DriftCellFront LocalPos.X [cm]:" << localPos.x()/cm << G4endl;
212 // G4cout << "%%%%%%%%%%%%%%%%%%%%%%% VDC_DriftCellFront LocalPos.Y [cm]:" << localPos.y()/cm << G4endl;
213 // G4cout << "%%%%%%%%%%%%%%%%%%%%%%% VDC_DriftCellFront LocalPos.Z [cm]:" << localPos.z()/cm << G4endl;
214 
215  QweakSimVDC_DriftCellHit* aHit = new QweakSimVDC_DriftCellHit(DriftCellReplicaNo);
216  //QweakSimVDC_DriftCellHit* aHit = (*DC_hitsCollection)[DriftCellReplicaNo];
217 
218 // G4cout << "%%%%%%%%%%%%%%%%%%%%%%% got QweakSimVDC_DriftCellHit* aHit" << G4endl;
219 
220  aHit->StoreWorldPos(worldPos);
221  aHit->StoreLocalPos(localPos);
222  aHit->StoreTime(preStepPoint->GetGlobalTime());
223 
224  aHit->StoreOriginVertexPosition(originVertexPosition);
225  aHit->StoreOriginVertexKineticEnergy(originVertexKineticEnergy);
226  aHit->StoreOriginVertexMomentumDirection(originVertexMomentumDirection);
227 
228  aHit->StoreMomentumDirection(currentMomentumDirection);
229  aHit->StoreKineticEnergy(currentKineticEnergy);
230  aHit->StoreTotalEnergy(currentTotalEnergy);
231 
232 
233  G4double myDCUPlaneWireAngle = 90.0*degree - DCUPlaneWireAngle;
234  G4double myDCVPlaneWireAngle = -90.0*degree - DCVPlaneWireAngle;
235 
236 // G4cout << " DCWidthOnFrame [mm] = " << DCWidthOnFrame/mm << G4endl;
237 // G4cout << " DCFullThickness [mm] = " << DCFullThickness/mm << G4endl;
238 // G4cout << " DCUPlaneWireAngle [deg] = " << myDCUPlaneWireAngle/degree << G4endl;
239 // G4cout << " DCVPlaneWireAngle [deg] = " << myDCVPlaneWireAngle/degree << G4endl;
240 
243  aHit->StoreDCUPlaneWireAngle(myDCUPlaneWireAngle);
244  aHit->StoreDCVPlaneWireAngle(myDCVPlaneWireAngle);
245 
246 
247 
248  // check if it is first touch
249  if(!(aHit->GetLogV()))
250  {
251  // store translation and rotation matrix of the drift cell
252  // for the sake of drawing the hit
253  aHit->StoreLogV(physVol->GetLogicalVolume());
254  G4AffineTransform aTrans = theTouchable->GetHistory()->GetTopTransform();
255  aTrans.Invert();
256  aHit->StoreCellRot(aTrans.NetRotation());
257  aHit->StoreCellPos(aTrans.NetTranslation());
258  }
259 
260  if( physVol->GetName().compare("VDC_DriftCellFront_Physical") == 0 ) { aHit->StoreDriftCellPlaneID(0);}
261  if( physVol->GetName().compare("VDC_DriftCellBack_Physical") == 0 ) { aHit->StoreDriftCellPlaneID(1);}
262 
263 // G4cout << "%%%%%%%%%%%%%%%%%%%%%%% before inserting the hit" << G4endl;
264 
265  DC_hitsCollection->insert(aHit);
266 
267 // G4cout << G4endl << "###### Leaving QweakSimVDC_DriftCellBackSD::ProcessHits() " << G4endl << G4endl;
268 
269  return true;
270 }
271 
272 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
273 
274 //void QweakSimVDC_DriftCellBackSD::EndOfEvent(G4HCofThisEvent* HCE)
276 {
277  //G4cout << G4endl << "###### Calling QweakSimVDC_DriftCellBackSD::EndOfEvent() " << G4endl << G4endl;
278 
279 // G4int NbDCHits = DC_hitsCollection->entries();
280 
281 // G4cout << "\n-------->Hits Collection: in this event they are " << NbDCHits
282 // << " hits in the Drift Cells : " << G4endl;
283 // for (G4int i=0;i<NbDCHits;i++) (*DC_hitsCollection)[i]->Print();
284 
285 
286 
287  //G4cout << G4endl << "###### Leaving QweakSimVDC_DriftCellBackSD::EndOfEvent() " << G4endl << G4endl;
288 
289 }
290 
291 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
292 
293 //=======================================================
294 // -----------------------
295 // | CVS File Information |
296 // -----------------------
297 //
298 // $Revisions$
299 // $Log: QweakSimVDC_DriftCellBackSD.cc,v $
300 // Revision 1.4 2006/05/05 21:47:36 grimm
301 // Seperation into DriftCellBack and DriftCellFront for testing purpose.
302 //
303 // Revision 1.3 2006/01/02 13:24:22 grimm
304 // Commenting the originVertexPosition cut (z> 635*cm). Now I'm allowing to record all charged hits of the drift cell regardless of the vertex origin.
305 // (With the target cut I got ~20k drift cell hits out of 300k primary events. The wire planes without origin cut get a hit quote of 30%)
306 //
307 // Revision 1.2 2005/12/27 19:19:16 grimm
308 // - Redesign of Doxygen header containing CVS info like revision and date
309 // - Added CVS revision log at the end of file
310 //
311 //
void StoreWorldPos(G4ThreeVector xyz)
void Initialize(G4HCofThisEvent *HCE)
G4bool ProcessHits(G4Step *aStep, G4TouchableHistory *ROhist)
void EndOfEvent(G4HCofThisEvent *HCE)
void StoreDCVPlaneWireAngle(G4double dca)
void StoreCellRot(G4RotationMatrix rmat)
G4THitsCollection< QweakSimVDC_DriftCellHit > QweakSimVDC_DriftCellHitsCollection
void StoreCellPos(G4ThreeVector xyz)
void StoreOriginVertexKineticEnergy(G4double ekin)
const G4LogicalVolume * GetLogV() const
void StoreOriginVertexPosition(G4ThreeVector xyz)
void StoreLocalPos(G4ThreeVector xyz)
void StoreOriginVertexMomentumDirection(G4ThreeVector pxyz)
void StoreKineticEnergy(G4double ekin)
Region 3 Vertical Drift Chamber Drift Cell Hit.
QweakSimVDC_DriftCellHitsCollection * DC_hitsCollection
void StoreDriftCellPlaneID(G4int dcplane_id)
void StoreLogV(G4LogicalVolume *val)
void StoreMomentumDirection(G4ThreeVector pxyz)
void StoreDCUPlaneWireAngle(G4double dca)