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";
190 edm::LogError(
"ValidHGCal") <<
"Cannot find HGCalDDDConstants for " << nameX;
191 throw cms::Exception(
"Unknown",
"ValidHGCal") <<
"Cannot find HGCalDDDConstants for " << nameX <<
"\n";
194 nameX =
"HcalEndcap";
203 edm::LogError(
"ValidHGCal") <<
"Cannot find HcalDDDSimConstant";
204 throw cms::Exception(
"Unknown",
"ValidHGCal") <<
"Cannot find HcalDDDSimConstant\n";
210 }
else if (detType == 1) {
225 int iev = (*evt)()->GetEventID();
228 <<
"event = " << iev;
247 if (aStep !=
nullptr) {
248 G4VPhysicalVolume* curPV = aStep->GetPreStepPoint()->GetPhysicalVolume();
249 const G4String&
name = curPV->GetName();
250 G4VSensitiveDetector* curSD = aStep->GetPreStepPoint()->GetSensitiveDetector();
253 << aStep->GetPreStepPoint()->GetPosition();
256 if (curSD !=
nullptr) {
258 for (
unsigned int k = 0;
k <
names_.size(); ++
k) {
259 if (
name.find(
names_[
k].c_str()) != std::string::npos) {
271 const G4TouchableHistory* touchable =
272 static_cast<const G4TouchableHistory*>(aStep->GetPreStepPoint()->GetTouchable());
273 unsigned int index(0);
275 G4ThreeVector hitPoint = aStep->GetPreStepPoint()->GetPosition();
278 G4ThreeVector localpos = touchable->GetHistory()->GetTopTransform().TransformPoint(hitPoint);
279 float globalZ = touchable->GetTranslation(0).z();
280 int iz(globalZ > 0 ? 1 : -1);
283 if (touchable->GetHistoryDepth() ==
levelT1_) {
284 layer = touchable->GetReplicaNumber(0);
286 layer = touchable->GetReplicaNumber(2);
287 module = touchable->GetReplicaNumber(1);
288 cell = touchable->GetReplicaNumber(0);
293 if ((touchable->GetHistoryDepth() ==
levelT1_) || (touchable->GetHistoryDepth() ==
levelT2_)) {
294 layer = touchable->GetReplicaNumber(0);
296 layer = touchable->GetReplicaNumber(3);
297 module = touchable->GetReplicaNumber(2);
298 cell = touchable->GetReplicaNumber(1);
305 <<
"HGCal: " <<
name <<
" Layer " << layer <<
" Module " <<
module <<
" Cell " << cell;
308 int depth = (touchable->GetReplicaNumber(0)) % 10 + 1;
309 int lay = (touchable->GetReplicaNumber(0) / 10) % 100 + 1;
310 int det = (touchable->GetReplicaNumber(1)) / 1000;
317 <<
"HCAL: " << det <<
":" <<
depth <<
":" << lay <<
" o/p " <<
tmp.subdet <<
":" <<
tmp.zside <<
":"
318 <<
tmp.depth <<
":" <<
tmp.etaR <<
":" <<
tmp.phis <<
":" <<
tmp.lay <<
" point " << hitPoint <<
" "
319 << hitPoint.rho() <<
":" << hitPoint.eta() <<
":" << hitPoint.phi();
322 double edeposit = aStep->GetTotalEnergyDeposit();
325 << edeposit <<
" hit at " << hitPoint;
330 }
else if (detType == 1) {
339 G4String nextVolume(
"XXX");
340 if (aStep->GetTrack()->GetNextVolume() !=
nullptr)
341 nextVolume = aStep->GetTrack()->GetNextVolume()->GetName();
343 if (nextVolume.c_str() !=
name.c_str()) {