43 #include "G4NavigationHistory.hh"
44 #include "G4TouchableHistory.hh"
46 #include "CLHEP/Units/GlobalSystemOfUnits.h"
47 #include "CLHEP/Units/GlobalPhysicalConstants.h"
58 public Observer<const BeginOfEvent*>,
107 : numberingFromDDD_(nullptr), levelT1_(999), levelT2_(999), count_(0) {
119 <<
"observer of begin events and of G4step "
120 <<
"with Parameter values: \n\tLabel : " <<
labelLayer_ <<
" and with "
121 <<
names_.size() <<
" detectors";
122 for (
unsigned int k = 0;
k <
names_.size(); ++
k)
147 G4String nameX =
"HGCal";
153 else if (detType == 1)
161 else if (detType == 1)
167 nameX =
"HGCalEESensitive";
168 else if (detType == 1)
169 nameX =
"HGCalHESiliconSensitive";
171 nameX =
"HGCalHEScintillatorSensitive";
189 edm::LogError(
"ValidHGCal") <<
"Cannot find HGCalDDDConstants for " << nameX;
190 throw cms::Exception(
"Unknown",
"ValidHGCal") <<
"Cannot find HGCalDDDConstants for " << nameX <<
"\n";
193 nameX =
"HcalEndcap";
202 edm::LogError(
"ValidHGCal") <<
"Cannot find HcalDDDSimConstant";
203 throw cms::Exception(
"Unknown",
"ValidHGCal") <<
"Cannot find HcalDDDSimConstant\n";
209 }
else if (detType == 1) {
224 int iev = (*evt)()->GetEventID();
227 <<
"event = " << iev;
246 if (aStep !=
nullptr) {
247 G4VPhysicalVolume* curPV = aStep->GetPreStepPoint()->GetPhysicalVolume();
248 const G4String&
name = curPV->GetName();
249 G4VSensitiveDetector* curSD = aStep->GetPreStepPoint()->GetSensitiveDetector();
252 << aStep->GetPreStepPoint()->GetPosition();
255 if (curSD !=
nullptr) {
257 for (
unsigned int k = 0;
k <
names_.size(); ++
k) {
258 if (
name.find(
names_[
k].c_str()) != std::string::npos) {
270 const G4TouchableHistory* touchable =
271 static_cast<const G4TouchableHistory*>(aStep->GetPreStepPoint()->GetTouchable());
272 unsigned int index(0);
274 G4ThreeVector hitPoint = aStep->GetPreStepPoint()->GetPosition();
277 G4ThreeVector localpos = touchable->GetHistory()->GetTopTransform().TransformPoint(hitPoint);
278 float globalZ = touchable->GetTranslation(0).z();
279 int iz(globalZ > 0 ? 1 : -1);
280 int module(-1), cell(-1);
282 if (touchable->GetHistoryDepth() ==
levelT1_) {
283 layer = touchable->GetReplicaNumber(0);
285 layer = touchable->GetReplicaNumber(2);
286 module = touchable->GetReplicaNumber(1);
287 cell = touchable->GetReplicaNumber(0);
292 if ((touchable->GetHistoryDepth() ==
levelT1_) || (touchable->GetHistoryDepth() ==
levelT2_)) {
293 layer = touchable->GetReplicaNumber(0);
295 layer = touchable->GetReplicaNumber(3);
296 module = touchable->GetReplicaNumber(2);
297 cell = touchable->GetReplicaNumber(1);
304 <<
"HGCal: " <<
name <<
" Layer " << layer <<
" Module " << module <<
" Cell " << cell;
307 int depth = (touchable->GetReplicaNumber(0)) % 10 + 1;
308 int lay = (touchable->GetReplicaNumber(0) / 10) % 100 + 1;
309 int det = (touchable->GetReplicaNumber(1)) / 1000;
316 <<
"HCAL: " << det <<
":" <<
depth <<
":" << lay <<
" o/p " <<
tmp.subdet <<
":" <<
tmp.zside <<
":"
317 <<
tmp.depth <<
":" <<
tmp.etaR <<
":" <<
tmp.phis <<
":" <<
tmp.lay <<
" point " << hitPoint <<
" "
318 << hitPoint.rho() <<
":" << hitPoint.eta() <<
":" << hitPoint.phi();
321 double edeposit = aStep->GetTotalEnergyDeposit();
324 << edeposit <<
" hit at " << hitPoint;
329 }
else if (detType == 1) {
338 G4String nextVolume(
"XXX");
339 if (aStep->GetTrack()->GetNextVolume() !=
nullptr)
340 nextVolume = aStep->GetTrack()->GetNextVolume()->GetName();
342 if (nextVolume.c_str() !=
name.c_str()) {