44 CurrentHit(0), theTrack(0), CurrentPV(0), PreviousPV(0), UnitID(0),
45 PreviousUnitID(0), PreStepPoint(0), PostStepPoint(0),
46 theDescription(numberingScheme) {
50 G4cout <<
"*******************************************************" <<
G4endl;
52 G4cout <<
"* Constructing a CCaloSD with name " << name <<
G4endl;
54 G4cout <<
"*******************************************************" <<
G4endl;
63 delete theDescription;
70 G4cout <<
"CCaloSD : Initialize called for " << SDname <<
G4endl;
88 if (aStep == NULL)
return true;
91 if (hitExists() ==
false && EdepositEM+EdepositEHAD>0.)
98 void CCaloSD::getStepInfo(
G4Step* aStep) {
112 weight = curve_LY(PreStepPoint);
116 if (particleType ==
"e-" ||
117 particleType ==
"e+" ||
118 particleType ==
"gamma" ){
128 if ( TSlice > 1.0E9 ) TSliceID = 999999999;
129 else TSliceID = (
int) TSlice;
131 if (theDescription!=0)
132 UnitID = theDescription->
GetUnitID(aStep);
139 G4bool CCaloSD::hitExists() {
142 G4cerr <<
"***** CCaloSD error: PrimaryID = " << PrimaryID
143 <<
" Maybe detector name changed"
148 if ( CurrentPV==PreviousPV && PrimaryID == PrimID && TSliceID == TSID &&
149 UnitID==PreviousUnitID) {
155 if (PrimaryID != PrimID)
156 ResetForNewPrimary();
165 if (aPreviousHit->
getTrackID() == PrimaryID &&
168 CurrentHit = aPreviousHit;
182 void CCaloSD::ResetForNewPrimary() {
184 EntrancePoint = SetToLocal(HitPoint);
192 if (PrimID<0)
return;
194 G4cout <<
"CCaloSD: hit to be stored is NULL !!" <<
G4endl;
202 void CCaloSD::createNewHit() {
205 G4int currentCopyNo = -999;
206 G4int motherCopyNo = -999;
209 if ( theTouchable ) {
215 G4cout <<
"CCaloSD createNewHit for"
216 <<
" PV " << CurrentPV->
GetName()
217 <<
" PVid = " << currentCopyNo
218 <<
" MVid = " << motherCopyNo
219 <<
" Unit " << UnitID <<
G4endl;
220 G4cout <<
" primary " << PrimaryID
221 <<
" time slice " << TSliceID
231 G4cout <<
" and created by " ;
244 CurrentHit->
setEntry(EntrancePoint);
248 StoreHit(CurrentHit);
253 void CCaloSD::updateHit() {
254 if (EdepositEM+EdepositEHAD != 0) {
257 G4cout <<
"Energy deposit in Unit " << UnitID <<
" em " << EdepositEM/
MeV
258 <<
" hadronic " << EdepositEHAD/
MeV <<
" MeV" <<
G4endl;
265 PreviousPV = CurrentPV;
266 PreviousUnitID = UnitID;
286 void CCaloSD::summarize() {
306 if (theDescription!=0)
307 delete theDescription;
308 theDescription = org;
317 G4double dapd = 0.5 * crlength - localPoint.
z();
318 if (dapd >= -0.1 || dapd <= crlength+0.1) {
320 weight = 1.05 - dapd * 0.0005;
322 G4cout <<
"CCaloSD, light coll curve : wrong distance to APD " << dapd
323 <<
" crlength = " << crlength
324 <<
" z of localPoint = " << localPoint.
z()
325 <<
" take weight = " << weight <<
G4endl;
328 G4cout <<
"CCaloSD, light coll curve : " << dapd
329 <<
" crlength = " << crlength
330 <<
" z of localPoint = " << localPoint.
z()
331 <<
" take weight = " << weight <<
G4endl;