QwGeant4
QweakSimCerenkov_DetectorSD Class Reference

Storing hit information of the Cerenkov detector. More...

#include <QweakSimCerenkov_DetectorSD.hh>

Inherits G4VSensitiveDetector.

Public Member Functions

 QweakSimCerenkov_DetectorSD (G4String name)
 
virtual ~QweakSimCerenkov_DetectorSD ()
 
void Initialize (G4HCofThisEvent *HCE)
 
G4bool ProcessHits (G4Step *aStep, G4TouchableHistory *ROhist)
 
void EndOfEvent (G4HCofThisEvent *HCE)
 

Private Attributes

QweakSimCerenkovDetectorHitsCollectionCerenkovDetectorHitsCollection
 
G4int CerenkovDetectorCollectionID
 

Detailed Description

Storing hit information of the Cerenkov detector.

Definition at line 15 of file QweakSimCerenkov_DetectorSD.hh.

Constructor & Destructor Documentation

QweakSimCerenkov_DetectorSD::QweakSimCerenkov_DetectorSD ( G4String  name)

Definition at line 8 of file QweakSimCerenkov_DetectorSD.cc.

9 : G4VSensitiveDetector(name),
12 {
13  collectionName.insert("CerenkovDetectorCollection");
14 }
QweakSimCerenkovDetectorHitsCollection * CerenkovDetectorHitsCollection
QweakSimCerenkov_DetectorSD::~QweakSimCerenkov_DetectorSD ( )
virtual

Definition at line 17 of file QweakSimCerenkov_DetectorSD.cc.

17 { }

Member Function Documentation

void QweakSimCerenkov_DetectorSD::EndOfEvent ( G4HCofThisEvent *  HCE)

Definition at line 194 of file QweakSimCerenkov_DetectorSD.cc.

195 {
196  //G4cout << G4endl << "###### Calling QweakSimCerenkov_DetectorSD::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_DetectorSD::EndOfEvent() " << G4endl << G4endl;
205 }
void QweakSimCerenkov_DetectorSD::Initialize ( G4HCofThisEvent *  HCE)

Definition at line 20 of file QweakSimCerenkov_DetectorSD.cc.

References CerenkovDetectorCollectionID, and CerenkovDetectorHitsCollection.

21 {
22  CerenkovDetectorHitsCollection = new QweakSimCerenkovDetectorHitsCollection(SensitiveDetectorName,collectionName[0]);
23 
24  CerenkovDetectorCollectionID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
25 
27 }
QweakSimCerenkovDetectorHitsCollection * CerenkovDetectorHitsCollection
G4THitsCollection< QweakSimCerenkov_DetectorHit > QweakSimCerenkovDetectorHitsCollection
G4bool QweakSimCerenkov_DetectorSD::ProcessHits ( G4Step *  aStep,
G4TouchableHistory *  ROhist 
)

Definition at line 30 of file QweakSimCerenkov_DetectorSD.cc.

References CerenkovDetectorHitsCollection, QweakSimCerenkov_DetectorHit::GetLogVolume(), QweakSimCerenkov_DetectorHit::StoreCellPosition(), QweakSimCerenkov_DetectorHit::StoreCellRotation(), QweakSimCerenkov_DetectorHit::StoreCreatorProcessName(), QweakSimCerenkov_DetectorHit::StoreDetectorID(), QweakSimCerenkov_DetectorHit::StoreGlobalTime(), QweakSimCerenkov_DetectorHit::StoreKineticEnergy(), QweakSimCerenkov_DetectorHit::StoreLocalMomentum(), QweakSimCerenkov_DetectorHit::StoreLocalPosition(), QweakSimCerenkov_DetectorHit::StoreLogVolume(), QweakSimCerenkov_DetectorHit::StoreMomentumDirection(), QweakSimCerenkov_DetectorHit::StoreOriginVertexKineticEnergy(), QweakSimCerenkov_DetectorHit::StoreOriginVertexMomentumDirection(), QweakSimCerenkov_DetectorHit::StoreOriginVertexPosition(), QweakSimCerenkov_DetectorHit::StoreOriginVertexTotalEnergy(), QweakSimCerenkov_DetectorHit::StoreParentID(), QweakSimCerenkov_DetectorHit::StoreParticleName(), QweakSimCerenkov_DetectorHit::StoreParticleType(), QweakSimCerenkov_DetectorHit::StorePolarization(), QweakSimCerenkov_DetectorHit::StoreTotalEnergy(), QweakSimCerenkov_DetectorHit::StoreTrackID(), QweakSimCerenkov_DetectorHit::StoreWorldMomentum(), and QweakSimCerenkov_DetectorHit::StoreWorldPosition().

31 {
32 
33 //G4cout << G4endl << "###### Calling QweakSimCerenkov_DetectorSD::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(),"ActiveArea_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_DetectorSD " << 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_DetectorSD: We are NOT crossing a boundary <<<<<<" << G4endl;
86  // G4cout << ">>>> Aborting QweakSimCerenkov_DetectorSD::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  CerenkovDetectorHitsCollection->insert(aHit);
184 
185 // G4cout << G4endl << "###### Leaving QweakSimCerenkovDetectorSD::ProcessHits() " << G4endl << G4endl;
186 
187 // Peiqing: comment this disable geting secondary info
188 // info->StoreCerenkovHitEnergy(info->GetParticleHistoryLength()-1,currentTotalEnergy);
189 
190  return true;
191 }
void StoreOriginVertexPosition(G4ThreeVector oxyz)
Handling of a hit in the Cerenkov detector.
const G4LogicalVolume * GetLogVolume() const
void StoreOriginVertexMomentumDirection(G4ThreeVector opxyz)
void StoreWorldMomentum(G4ThreeVector gpxyz)
QweakSimCerenkovDetectorHitsCollection * CerenkovDetectorHitsCollection
void StoreMomentumDirection(G4ThreeVector pxyz)
void StoreCellRotation(G4RotationMatrix rmat)
void StoreLogVolume(G4LogicalVolume *val)
void StoreLocalMomentum(G4ThreeVector lpxyz)

+ Here is the call graph for this function:

Field Documentation

G4int QweakSimCerenkov_DetectorSD::CerenkovDetectorCollectionID
private

Definition at line 30 of file QweakSimCerenkov_DetectorSD.hh.

Referenced by Initialize().

QweakSimCerenkovDetectorHitsCollection* QweakSimCerenkov_DetectorSD::CerenkovDetectorHitsCollection
private

Definition at line 28 of file QweakSimCerenkov_DetectorSD.hh.

Referenced by Initialize(), and ProcessHits().


The documentation for this class was generated from the following files: