86{
87
88 G4double edep = aStep->GetTotalEnergyDeposit();
89 G4double stepl = aStep->GetStepLength();
90 if ((edep==0.)&&(stepl==0.)) return false;
91
92 G4TouchableHistory* theTouchable
93 = (G4TouchableHistory*)(aStep->GetPreStepPoint()->GetTouchable());
94 G4VPhysicalVolume* physVol = theTouchable->GetVolume();
95
96 if(physVol->GetName().contains("physicalCrystal"))
97 {
98 PartId=1;
99 CryNumberPhi=theTouchable->GetReplicaNumber(2);
100 CryNumberTheta=theTouchable->GetReplicaNumber(1);
101 }
102 else if(physVol->GetName().contains("logicalCrystal"))
103 {
104 PartId=1;
105 std::istringstream thetaBuf((theTouchable->GetVolume(1)->GetName()).substr(16,2));
106 thetaBuf >> CryNumberTheta ;
107 CryNumberPhi = 308-theTouchable->GetCopyNumber(2);
108 }
109 else if(physVol->GetName().contains("physicalEndCrystal"))
110 {
111 PartId=theTouchable->GetReplicaNumber(3);
112 G4int endSector=theTouchable->GetReplicaNumber(2);
113 G4int endNb=theTouchable->GetReplicaNumber(0);
115 }
116 else if(physVol->GetName().contains("logicalEndCrystal"))
117 {
118 PartId=2-2*theTouchable->GetCopyNumber(3);
119 G4int endSector=theTouchable->GetCopyNumber(2);
120 G4int endNb,endNbGDML;
121 std::istringstream thetaBuf((theTouchable->GetVolume(0)->GetName()).substr(20,2));
122 thetaBuf >> endNb ;
126 }
127 else if(physVol->GetName().contains("physicalPD"))
128 {
129 edep*=50.;
130 PartId=1;
131 CryNumberPhi=theTouchable->GetReplicaNumber(2);
132 CryNumberTheta=theTouchable->GetReplicaNumber(1);
133 }
134 else if(physVol->GetName().contains("logicalPD"))
135 {
136 edep*=50.;
137 PartId=1;
138 G4int nb=theTouchable->GetCopyNumber(1);
139 if(nb==216) {
140 CryNumberTheta=0;
141 } else {
142 CryNumberTheta = 43-(nb-2)/5;
143 }
144 CryNumberPhi = 308-theTouchable->GetCopyNumber(2);
145 }
146
147 if (verboseLevel>1)
148 G4cout << "(Check ID)New EMC Hit on crystal: "
149 << CryNumberPhi << "(phi)"
150 << CryNumberTheta << "(theta)"
151 << " and the volume is " << physVol->GetName()
152 << G4endl;
153
154
155 G4int trackId = aStep->GetTrack()->GetTrackID();
156
162 calHit->
SetPosCrystal(aStep->GetPreStepPoint()->GetPosition());
163 calHit->
SetTimeCrystal(aStep->GetPreStepPoint()->GetGlobalTime());
164 calHit->
SetMomentum(aStep->GetPreStepPoint()->GetMomentum());
166
167 if(edep>0){
168 G4int idhit = CalCollection->insert(calHit)-1;
169 if(nHit<40000) HitID[nHit]=idhit;
170 nHit++;
171 }
172 else
173 {
174 delete calHit;
175
176
177 }
178
179
180 if(CalList)
181 {
182 G4int trackIndex, g4TrackId;
185
186 if(m_trackIndex != trackIndex)
187 {
188 m_trackIndex = trackIndex;
189
191 G4int pdg =
abs(aStep->GetTrack()->GetDefinition()->GetPDGEncoding());
192 if(pdg==12 || pdg==14 || pdg==16) {
194 }
195
196 if(
flag && aStep->GetTrack()->GetTrackID()==g4TrackId )
197 {
203 truHit->
SetPosCrystal(aStep->GetPreStepPoint()->GetPosition());
204 truHit->
SetTimeCrystal(aStep->GetPreStepPoint()->GetGlobalTime());
205 truHit->
SetMomentum(aStep->GetPreStepPoint()->GetMomentum());
207 CalList->insert(truHit);
208 }
209 }
210
211 else if(m_trackIndex == trackIndex)
212 {
213 G4int length = CalList->entries();
214 if(length>=1)
215 {
216 for(G4int i=0;i<length;i++)
217 {
220 {
222 break;
223 }
224 }
225 }
226 }
227
228 }
229
230
231 if(CalTruthList)
232 {
233 G4int trackIndex, g4TrackId;
236
238 if(CalTruthList->entries()>0) {
239 for(G4int i=0;i<CalTruthList->entries();i++) {
244 if(oldHit->
Find(
id)!=oldHit->
End()) {
246 } else {
248 }
249 break;
250 }
251 }
252 }
253
255 G4int pdg =
abs(aStep->GetTrack()->GetDefinition()->GetPDGEncoding());
256 if(!(pdg==12 || pdg==14 || pdg==16)) {
263
264 if(aStep->GetTrack()->GetTrackID()==g4TrackId) {
266 truHit->
SetPDGCode(aStep->GetTrack()->GetDefinition()->GetPDGEncoding());
267 truHit->
SetPDGCharge(aStep->GetTrack()->GetDefinition()->GetPDGCharge());
268 truHit->
SetParticleName(aStep->GetTrack()->GetDefinition()->GetParticleName());
269 truHit->
SetTime(aStep->GetPreStepPoint()->GetGlobalTime());
270 truHit->
SetPosition(aStep->GetPreStepPoint()->GetPosition());
271 truHit->
SetMomentum(aStep->GetPreStepPoint()->GetMomentum());
272
273 } else {
274
276 std::vector<BesTruthTrack*> *trackList = sensitiveManager->
GetTrackList();
277
278 for(unsigned i=0;i<trackList->size();i++) {
280
281 if(trackIndex==truthTrack->
GetIndex()) {
286
290 } else {
293 }
294
295 break;
296 }
297
298 }
299 }
300
301 CalTruthList->insert(truHit);
302 }
303 }
304 }
305
306 return true;
307}
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.