QwGeant4
QweakSimCerenkov_RadiatorSD.cc
Go to the documentation of this file.
2 
3 // user includes
7 
9 : G4VSensitiveDetector(name),
10  CerenkovRadiatorHitsCollection(0),
11  CerenkovRadiatorCollectionID(-1)
12 {
13  collectionName.insert("CerenkovRadiatorCollection");
14 }
15 
16 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
18 
19 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
20 void QweakSimCerenkov_RadiatorSD::Initialize(G4HCofThisEvent* HCE)
21 {
22  CerenkovRadiatorHitsCollection = new QweakSimCerenkovRadiatorHitsCollection(SensitiveDetectorName,collectionName[0]);
23 
24  CerenkovRadiatorCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
25 
27 }
28 
29 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
30 G4bool QweakSimCerenkov_RadiatorSD::ProcessHits(G4Step* aStep, G4TouchableHistory* /*ROhist*/)
31 {
32 
33 //G4cout << G4endl << "###### Calling QweakSimCerenkov_RadiatorSD::ProcessHits() " << G4endl << G4endl;
34 
35  G4double charge = aStep->GetTrack()->GetDefinition()->GetPDGCharge();
36  if(charge==0. && aStep->GetTrack()->GetTotalEnergy()/MeV < 0.1) {
37 
38  //G4cout << "Return on charge = 0" << G4endl;
39  return false;
40  }
41 
42  if( aStep->GetTrack()->GetDefinition()->GetParticleName() == "opticalphoton") {
43 
44  //std::cout << "Return on optical photon" << std::endl;
45  return false;
46  }
47 
48  G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
49 // G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
50  G4TouchableHistory* theTouchable = (G4TouchableHistory*)(preStepPoint->GetTouchable());
51  G4VPhysicalVolume* physVol = theTouchable->GetVolume();
52 
53 // if(strcmp(physVol->GetName(),"CerenkovDetector_Physical")) {
54  if(strcmp(physVol->GetName(),"Radiator_Physical")) {
55  return false;
56  }
57 
58  G4ThreeVector worldPos = preStepPoint->GetPosition();
59  G4ThreeVector localPos = theTouchable->GetHistory()->GetTopTransform().TransformPoint(worldPos);
60 
61  //======================================================================================
62  // for test purpose only : print out all the source and primary info of this track
63 
64 // G4cout << "Printing Track Info inside QweakSimCerenkov_RadiatorSD " << G4endl;
65 //
66 // QweakSimTrackInformation* trackInfo;
67 //
68 // trackInfo = (QweakSimTrackInformation*)(aStep->GetTrack()->GetUserInformation());
69 // trackInfo->PrintSourceTrackInfo();
70 // trackInfo->PrintPrimaryTrackInfo();
71 
72  //======================================================================================
73 
74 
75  //G4cout << "PreStep Process in the Cerenkov = " << aStep->GetPreStepPoint()->GetProcessDefinedStep()->GetProcessName() << G4endl;
76  //G4cout << "PostStep Process in the Cerenkov = " << aStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName() << G4endl;
77 
78  // here we are only interested if the particle is crossing a boundary
79  // If you want to identify the first step in a volume: pick fGeomBoundary status in preStepPoint
80  // If you want to identify a step out of a volume : pick fGeomBoundary status in postStepPoint
81 
82  if (preStepPoint->GetStepStatus() != fGeomBoundary) {
83 
84  // G4cout << "=======================================================================" << G4endl;
85  // G4cout << ">>>> QweakSimCerenkov_RadiatorSD: We are NOT crossing a boundary <<<<<<" << G4endl;
86  // G4cout << ">>>> Aborting QweakSimCerenkov_RadiatorSD::ProcessHits <<<<<<" << G4endl;
87  // G4cout << "=======================================================================" << G4endl;
88  return false;
89  }
90 
91  G4ThreeVector worldMomentum = preStepPoint->GetMomentum();
92  G4ThreeVector localMomentum = theTouchable->GetHistory()->GetTopTransform().TransformPoint(worldMomentum);
93 
94  // Vertex: where this track was generated
95  G4ThreeVector originVertexPosition = aStep->GetTrack()->GetVertexPosition();
96  G4ThreeVector originVertexMomentumDirection = aStep->GetTrack()->GetVertexMomentumDirection();
97  G4double originVertexKineticEnergy = aStep->GetTrack()->GetVertexKineticEnergy();
98 
99  G4double currentKineticEnergy = aStep->GetTrack()->GetKineticEnergy();
100  G4double currentTotalEnergy = aStep->GetTrack()->GetTotalEnergy();
101  G4ThreeVector currentMomentumDirection = aStep->GetTrack()->GetMomentumDirection();
102  G4ThreeVector currentPolarization = aStep->GetTrack()->GetPolarization();
103 
104  G4int trackID = aStep->GetTrack()->GetTrackID();
105  G4int parentID = aStep->GetTrack()->GetParentID();
106 // G4String processName = aStep->GetTrack()->GetCreatorProcess()->GetProcessName();
107  G4String processName = aStep->GetPostStepPoint()->GetProcessDefinedStep()->GetProcessName();
108 
109  G4ParticleDefinition* fpParticleDefinition = aStep->GetTrack()->GetDefinition();
110  G4String ParticleName = fpParticleDefinition->GetParticleName();
111 // G4double PDGCharge = fpParticleDefinition->GetPDGCharge();
112  G4int PDGEncoding = fpParticleDefinition->GetPDGEncoding();
113  G4double particlemass = fpParticleDefinition->GetPDGMass()/MeV;
114 
115  G4int MotherCopyNo = theTouchable->GetVolume(1)->GetCopyNo(); // one Mother Volume
116 // G4int DetectorCopyNo = theTouchable->GetVolume()->GetCopyNo(); // but several detectors per MV
117 // G4int DetectorReplicaNo = theTouchable->GetReplicaNumber(); // but several detectors per MV
118 // G4int MotherReplicaNo = theTouchable->GetReplicaNumber(1); // Several MotherVolumes
119 // G4int MotherCopyNo2 = theTouchable->GetVolume(2)->GetCopyNo(); // Several MotherVolumes
120 // G4int MotherReplicaNo2 = theTouchable->GetReplicaNumber(2); // Several MotherVolumes
121 
122 
123 // G4cout << "%%%%%%%%%%%%%%%%%%% Cerenkov MV CopyNumber :" << MotherCopyNo << G4endl;
124 // G4cout << "%%%%%%%%%%%%%%%%%%% Cerenkov CopyNumber :" << DetectorCopyNo << G4endl;
125 // G4cout << "%%%%%%%%%%%%%%%%%%% Cerenkov ReplicaNumber :" << DetectorReplicaNo << G4endl;
126 // G4cout << "%%%%%%%%%%%%%%%%%%% Cerenkov MV ReplicaNumber :" << MotherReplicaNo << G4endl;
127 // G4cout << "%%%%%%%%%%%%%%%%%%% Cerenkov MV CopyNumber2 :" << MotherCopyNo2 << G4endl;
128 // G4cout << "%%%%%%%%%%%%%%%%%%% Cerenkov ReplicaNumber2 :" << MotherReplicaNo2 << G4endl;
129 
130 
131  // get User Track Info
132 // QweakSimTrackInformation* info = (QweakSimTrackInformation*)(aStep->GetTrack()->GetUserInformation());
133 
134 // G4int primaryTrackID = info->GetPrimaryTrackID();
135 // G4double primaryQ2 = info->GetPrimaryQ2();
136 // G4double crossSection = info->GetCrossSection();
137 // G4double crossSectionWeight = info->GetCrossSectionWeight();
138 
140 
141  aHit->StoreTrackID(trackID);
142  aHit->StoreParentID(parentID);
143  aHit->StoreCreatorProcessName(processName);
144 
145  aHit->StoreDetectorID(MotherCopyNo);
146 
147  aHit->StoreGlobalTime(preStepPoint->GetGlobalTime());
148 
149  aHit->StoreWorldPosition(worldPos);
150  aHit->StoreLocalPosition(localPos);
151 
152  aHit->StoreWorldMomentum(worldMomentum);
153  aHit->StoreLocalMomentum(localMomentum);
154 
155  aHit->StoreOriginVertexPosition(originVertexPosition);
156  aHit->StoreOriginVertexKineticEnergy(originVertexKineticEnergy);
157  //aHit->StoreOriginVertexTotalEnergy(originVertexKineticEnergy); /// \todo beware: total.neq.kinetic (testing only)
158  aHit->StoreOriginVertexTotalEnergy(originVertexKineticEnergy + particlemass);
159  aHit->StoreOriginVertexMomentumDirection(originVertexMomentumDirection);
160 
161  aHit->StoreMomentumDirection(currentMomentumDirection);
162  aHit->StoreKineticEnergy(currentKineticEnergy);
163  aHit->StoreTotalEnergy(currentTotalEnergy);
164  aHit->StorePolarization(currentPolarization);
165 
166  aHit->StoreParticleName(ParticleName);
167  aHit->StoreParticleType(PDGEncoding);
168 
169  // check if it is first touch
170  if(!(aHit->GetLogVolume()))
171  {
172  // store translation and rotation matrix of the drift cell
173  // for the sake of drawing the hit
174  aHit->StoreLogVolume(physVol->GetLogicalVolume());
175  G4AffineTransform aTrans = theTouchable->GetHistory()->GetTopTransform();
176  aTrans.Invert();
177  aHit->StoreCellRotation(aTrans.NetRotation());
178  aHit->StoreCellPosition(aTrans.NetTranslation());
179  }
180 
181 // G4cout << "%%%%%%%%%%%%%%%%%%%%%%% before inserting the hit" << G4endl;
182 
183  CerenkovRadiatorHitsCollection->insert(aHit);
184 
185 // G4cout << G4endl << "###### Leaving QweakSimCerenkovRadiatorSD::ProcessHits() " << G4endl << G4endl;
186 
187 // Peiqing: comment this disable geting secondary info
188 // info->StoreCerenkovHitEnergy(info->GetParticleHistoryLength()-1,currentTotalEnergy);
189 
190  return true;
191 }
192 
193 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
195 {
196  //G4cout << G4endl << "###### Calling QweakSimCerenkov_RadiatorSD::EndOfEvent() " << G4endl << G4endl;
197 
198 // G4int NbDCHits = DC_hitsCollection->entries();
199 
200 // G4cout << "\n-------->Hits Collection: in this event they are " << NbDCHits
201 // << " hits in the Drift Cells : " << G4endl;
202 // for (G4int i=0;i<NbDCHits;i++) (*DC_hitsCollection)[i]->Print();
203 
204  //G4cout << G4endl << "###### Leaving QweakSimCerenkov_RadiatorSD::EndOfEvent() " << G4endl << G4endl;
205 }
206 
207 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
void StoreWorldMomentum(G4ThreeVector gpxyz)
G4THitsCollection< QweakSimCerenkov_RadiatorHit > QweakSimCerenkovRadiatorHitsCollection
void StoreCellRotation(G4RotationMatrix rmat)
QweakSimCerenkovRadiatorHitsCollection * CerenkovRadiatorHitsCollection
Handling of a hit in the Cerenkov radiator.
void EndOfEvent(G4HCofThisEvent *HCE)
G4bool ProcessHits(G4Step *aStep, G4TouchableHistory *ROhist)
void StoreLocalMomentum(G4ThreeVector lpxyz)
void Initialize(G4HCofThisEvent *HCE)
void StoreLogVolume(G4LogicalVolume *val)
void StoreOriginVertexMomentumDirection(G4ThreeVector opxyz)
const G4LogicalVolume * GetLogVolume() const
void StoreMomentumDirection(G4ThreeVector pxyz)
void StoreOriginVertexPosition(G4ThreeVector oxyz)