89{
90
91
92 gErrorIgnoreLevel = kFatal;
93
94 G4double edep = aStep->GetTotalEnergyDeposit();
95 G4double stepl = aStep->GetStepLength();
96 if ((edep==0.)&&(stepl==0.)) return false;
97
98 G4TouchableHistory* theTouchable
99 = (G4TouchableHistory*)(aStep->GetPreStepPoint()->GetTouchable());
100 G4VPhysicalVolume* physVol = theTouchable->GetVolume();
101
102 if(physVol->GetName().contains("physicalCrystal"))
103 {
104 PartId=1;
105 CryNumberPhi=theTouchable->GetReplicaNumber(2);
106 CryNumberTheta=theTouchable->GetReplicaNumber(1);
107 }
108 else if(physVol->GetName().contains("logicalCrystal"))
109 {
110 PartId=1;
111 std::istringstream thetaBuf((theTouchable->GetVolume(1)->GetName()).substr(16,2));
112 thetaBuf >> CryNumberTheta ;
113 CryNumberPhi = 308-theTouchable->GetCopyNumber(2);
114 }
115 else if(physVol->GetName().contains("physicalEndCrystal"))
116 {
117 PartId=theTouchable->GetReplicaNumber(3);
118 G4int endSector=theTouchable->GetReplicaNumber(2);
119 G4int endNb=theTouchable->GetReplicaNumber(0);
121 }
122 else if(physVol->GetName().contains("logicalEndCrystal"))
123 {
124 PartId=2-2*theTouchable->GetCopyNumber(3);
125 G4int endSector=theTouchable->GetCopyNumber(2);
126 G4int endNb,endNbGDML;
127 std::istringstream thetaBuf((theTouchable->GetVolume(0)->GetName()).substr(20,2));
128 thetaBuf >> endNb ;
132 }
133 else if(physVol->GetName().contains("physicalPD"))
134 {
135 edep*=50.;
136 PartId=1;
137 CryNumberPhi=theTouchable->GetReplicaNumber(2);
138 CryNumberTheta=theTouchable->GetReplicaNumber(1);
139 }
140 else if(physVol->GetName().contains("logicalPD"))
141 {
142 edep*=50.;
143 PartId=1;
144 G4int nb=theTouchable->GetCopyNumber(1);
145 if(nb==216) {
146 CryNumberTheta=0;
147 } else {
148 CryNumberTheta = 43-(nb-2)/5;
149 }
150 CryNumberPhi = 308-theTouchable->GetCopyNumber(2);
151 }
152
153 if (verboseLevel>1)
154 G4cout << "(Check ID)New EMC Hit on crystal: "
155 << CryNumberPhi << "(phi)"
156 << CryNumberTheta << "(theta)"
157 << " and the volume is " << physVol->GetName()
158 << G4endl;
159
160
161 G4int trackId = aStep->GetTrack()->GetTrackID();
162
168 calHit->
SetPosCrystal(aStep->GetPreStepPoint()->GetPosition());
169 calHit->
SetTimeCrystal(aStep->GetPreStepPoint()->GetGlobalTime());
170 calHit->
SetMomentum(aStep->GetPreStepPoint()->GetMomentum());
172
173 if(edep>0){
174 G4int idhit = CalCollection->insert(calHit)-1;
175 if(nHit<40000) HitID[nHit]=idhit;
176 nHit++;
177 }
178 else
179 {
180 delete calHit;
181
182
183 }
184
185
186 if(CalList)
187 {
188 G4int trackIndex, g4TrackId;
191
192 if(m_trackIndex != trackIndex)
193 {
194 m_trackIndex = trackIndex;
195
197 G4int pdg =
abs(aStep->GetTrack()->GetDefinition()->GetPDGEncoding());
198 if(pdg==12 || pdg==14 || pdg==16) {
200 }
201
202 if(
flag && aStep->GetTrack()->GetTrackID()==g4TrackId )
203 {
209 truHit->
SetPosCrystal(aStep->GetPreStepPoint()->GetPosition());
210 truHit->
SetTimeCrystal(aStep->GetPreStepPoint()->GetGlobalTime());
211 truHit->
SetMomentum(aStep->GetPreStepPoint()->GetMomentum());
213 CalList->insert(truHit);
214 }
215 }
216
217 else if(m_trackIndex == trackIndex)
218 {
219 G4int length = CalList->entries();
220 if(length>=1)
221 {
222 for(G4int i=0;i<length;i++)
223 {
226 {
228 break;
229 }
230 }
231 }
232 }
233
234 }
235
236
237 if(CalTruthList)
238 {
239 G4int trackIndex, g4TrackId;
242
244 if(CalTruthList->entries()>0) {
245 for(G4int i=0;i<CalTruthList->entries();i++) {
250 if(oldHit->
Find(
id)!=oldHit->
End()) {
252 } else {
254 }
255 break;
256 }
257 }
258 }
259
261 G4int pdg =
abs(aStep->GetTrack()->GetDefinition()->GetPDGEncoding());
262 if(!(pdg==12 || pdg==14 || pdg==16)) {
269
270 if(aStep->GetTrack()->GetTrackID()==g4TrackId) {
272 truHit->
SetPDGCode(aStep->GetTrack()->GetDefinition()->GetPDGEncoding());
273 truHit->
SetPDGCharge(aStep->GetTrack()->GetDefinition()->GetPDGCharge());
274 truHit->
SetParticleName(aStep->GetTrack()->GetDefinition()->GetParticleName());
275 truHit->
SetTime(aStep->GetPreStepPoint()->GetGlobalTime());
276 truHit->
SetPosition(aStep->GetPreStepPoint()->GetPosition());
277 truHit->
SetMomentum(aStep->GetPreStepPoint()->GetMomentum());
278
279 } else {
280
282 std::vector<BesTruthTrack*> *trackList = sensitiveManager->
GetTrackList();
283
284 for(unsigned i=0;i<trackList->size();i++) {
286
287 if(trackIndex==truthTrack->
GetIndex()) {
292
296 } else {
299 }
300
301 break;
302 }
303
304 }
305 }
306
307 CalTruthList->insert(truHit);
308 }
309 }
310 }
311
312 return true;
313}
void SetNumCrystal(G4int id, G4int numTheta, G4int numPhi)
void SetEdepCrystal(G4double de)
void SetMomentum(G4ThreeVector momen)
G4double GetEdepCrystal()
void SetPosCrystal(G4ThreeVector position)
void SetTimeCrystal(G4double t)
void SetTrakCrystal(G4double dl)
void SetG4Index(G4int index)
void SetTrackIndex(G4int index)
G4int ComputeEndCopyNb(G4int)
void ComputeThetaPhi(G4int, G4int, G4int)
G4int EndPhiNumberForGDML(G4int)
void SetIdentify(Identifier id)
G4int GetTrackIndex() const
void SetMomentum(G4ThreeVector p)
void SetPosition(G4ThreeVector pos)
void AddEHit(Identifier, G4double)
void SetPDGCode(G4int code)
void SetTrackIndex(G4int index)
std::map< Identifier, G4double >::const_iterator End() const
std::map< Identifier, G4double >::const_iterator Find(Identifier) const
void Insert(Identifier, G4double)
void SetG4TrackId(G4int trackId)
void SetEDep(G4double de)
void SetParticleName(G4String name)
void SetTime(G4double time)
void SetPDGCharge(G4double charge)
void GetCurrentTrackIndex(G4int &trackIndex, G4int &g4TrackId) const
std::vector< BesTruthTrack * > * GetTrackList()
static BesSensitiveManager * GetSensitiveManager()
BesTruthVertex * GetTerminalVertex() const
G4double GetPDGCharge() const
G4String GetParticleName() const
G4ThreeVector GetPosition() const
static Identifier crystal_id(const unsigned int barrel_ec, const unsigned int theta_module, const unsigned int phi_module)
For a single crystal.