7 #ifdef HcalNumberingTest
18 #include "G4LogicalVolumeStore.hh"
19 #include "G4NavigationHistory.hh"
20 #include "G4ParticleTable.hh"
21 #include "G4PhysicalVolumeStore.hh"
22 #include "G4RegionStore.hh"
24 #include "G4UnitsTable.hh"
25 #include "G4SystemOfUnits.hh"
71 #ifdef HcalNumberingTest
72 hcNumbering_.reset(
nullptr);
76 produces<edm::PCaloHitContainer>(
nameHitC_[
k]);
79 produces<edm::PassiveHitContainer>(
"AllPassiveHits");
85 <<
"selected entries : " <<
count_;
91 auto product = std::make_unique<edm::PCaloHitContainer>();
104 <<
slave_[
type].get()->hits().size() <<
" hits";
111 for (
const auto& element :
store_) {
112 auto lv = std::get<0>(element);
113 auto it =
mapLV_.find(lv);
116 std::get<1>(element),
117 std::get<5>(element),
118 std::get<6>(element),
119 std::get<4>(element),
120 std::get<2>(element),
121 std::get<3>(element),
122 std::get<7>(element),
123 std::get<8>(element),
124 std::get<9>(element),
125 std::get<10>(element));
126 cc.emplace_back(
hit);
134 #ifdef HcalNumberingTest
137 (*job)()->get<HcalSimNumberingRecord>().get(hdc);
140 <<
"HcalNumberingFromDDD";
141 hcNumbering_ = std::make_unique<HcalNumberingFromDDD>(hcons_);
147 int irun = (*run)()->GetRunID();
150 const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
152 std::map<const std::string, const G4LogicalVolume*> nameMap;
153 std::map<const std::string, const G4LogicalVolume*>::const_iterator
itr;
154 for (
auto lvi = lvs->begin(), lve = lvs->end(); lvi != lve; ++lvi) {
155 nameMap.emplace((*lvi)->GetName(), *lvi);
157 mapLV_[*lvi] = (*lvi)->GetName();
161 for (
itr = nameMap.begin();
itr != nameMap.end(); ++
itr) {
163 if (lvname.find(
name) != std::string::npos) {
165 int type = (lvname.find(
"refl") == std::string::npos) ? -1 : 1;
166 G4Trap* solid = static_cast<G4Trap*>(
itr->second->GetSolid());
167 double dz = 2 * solid->GetZHalfLength() / CLHEP::mm;
168 xtalMap_.insert(std::pair<const G4LogicalVolume*, double>(
itr->second,
dz *
type));
175 for (
itr = nameMap.begin();
itr != nameMap.end(); ++
itr) {
177 if (lvname.find(
name) != std::string::npos) {
179 int type = (lvname.find(
"refl") == std::string::npos) ? 1 : -1;
180 G4Trap* solid = static_cast<G4Trap*>(
itr->second->GetSolid());
181 double dz = 2 * solid->GetZHalfLength() / CLHEP::mm;
182 xtalMap_.insert(std::pair<const G4LogicalVolume*, double>(
itr->second,
dz *
type));
190 for (
itr = nameMap.begin();
itr != nameMap.end(); ++
itr) {
192 if (lvname.find(
name) != std::string::npos) {
235 auto lv = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume();
240 if (hc || eb || ee) {
241 double dEStep = aStep->GetTotalEnergyDeposit() /
CLHEP::MeV;
242 auto const theTrack = aStep->GetTrack();
243 double time = theTrack->GetGlobalTime() / CLHEP::nanosecond;
244 int primID = theTrack->GetTrackID();
246 auto const touch = aStep->GetPreStepPoint()->GetTouchable();
247 auto const& hitPoint = aStep->GetPreStepPoint()->GetPosition();
249 int depth = (touch->GetReplicaNumber(0)) % 10 + 1;
250 int lay = (touch->GetReplicaNumber(0) / 10) % 100 + 1;
251 int det = (touch->GetReplicaNumber(1)) / 1000;
253 if (unitID > 0 && dEStep > 0.0) {
255 (aStep->GetStepLength() / CLHEP::cm),
256 aStep->GetPreStepPoint()->GetCharge(),
257 (aStep->GetPreStepPoint()->GetMaterial()->GetDensity() / (
CLHEP::g / CLHEP::cm3)));
262 int size = touch->GetHistoryDepth() + 1;
268 theBaseNumber.
addLevel(touch->GetVolume(
ii)->GetName(), touch->GetReplicaNumber(
ii));
272 if (unitID > 0 && dEStep > 0.0) {
273 auto local = touch->GetHistory()->GetTopTransform().TransformPoint(hitPoint);
275 double crystalLength = ((ite ==
xtalMap_.end()) ? 230.0 :
std::abs(ite->second));
276 double crystalDepth =
278 double radl = aStep->GetPreStepPoint()->GetMaterial()->GetRadlen() / CLHEP::mm;
279 bool flag = ((ite ==
xtalMap_.end()) ?
true : (((ite->second) >= 0) ?
true :
false));
282 (aStep->GetStepLength() / CLHEP::cm),
283 aStep->GetPreStepPoint()->GetCharge(),
284 (aStep->GetPreStepPoint()->GetMaterial()->GetDensity() / (
CLHEP::g / CLHEP::cm3))) *
285 curve_LY(crystalLength, crystalDepth));
292 auto it =
mapLV_.find(lv);
295 auto const touch = aStep->GetPreStepPoint()->GetTouchable();
296 double time = aStep->GetTrack()->GetGlobalTime() / CLHEP::nanosecond;
297 int trackId = aStep->GetTrack()->GetTrackID();
298 int pdg = aStep->GetTrack()->GetDefinition()->GetPDGEncoding();
299 double stepl = (aStep->GetStepLength() / CLHEP::cm);
300 double xp = aStep->GetPreStepPoint()->GetPosition().x() / CLHEP::cm;
301 double yp = aStep->GetPreStepPoint()->GetPosition().y() / CLHEP::cm;
302 double zp = aStep->GetPreStepPoint()->GetPosition().z() / CLHEP::cm;
304 edm::LogVerbatim(
"Step") <<
"CaloSteppingAction: Volume " << lv->GetName() <<
" History "
305 << touch->GetHistoryDepth() <<
" Pointers " << aStep->GetPostStepPoint() <<
":"
306 << aStep->GetTrack()->GetNextVolume() <<
":" << aStep->IsLastStepInVolume() <<
" E "
307 <<
energy <<
" T " <<
time <<
" PDG " <<
pdg <<
" step " << stepl <<
" Position (" << xp
308 <<
", " << yp <<
", " << zp <<
")";
311 if (((aStep->GetPostStepPoint() ==
nullptr) || (aStep->GetTrack()->GetNextVolume() ==
nullptr)) &&
312 (aStep->IsLastStepInVolume())) {
315 time = aStep->GetPostStepPoint()->GetGlobalTime() / CLHEP::nanosecond;
317 copy = (touch->GetHistoryDepth() < 1)
318 ? static_cast<uint32_t>(touch->GetReplicaNumber(0))
319 : static_cast<uint32_t>(touch->GetReplicaNumber(0) + 1000 * touch->GetReplicaNumber(1));
321 PassiveData key(std::make_tuple(lv,
copy, trackId,
pdg,
time,
energy,
energy, stepl, xp, yp, zp));
331 edm::LogVerbatim(
"Step") <<
"CaloSteppingAction: EndOfEvent " << (*evt)()->GetEventID();
335 auto currentPos = aStep->GetTrack()->GetPosition();
336 double xyz = currentPos.x() + currentPos.y() + currentPos.z();
337 auto currentMom = aStep->GetTrack()->GetMomentum();
338 xyz += currentMom.x() + currentMom.y() + currentMom.z();
341 auto pCurrentVol = aStep->GetPreStepPoint()->GetPhysicalVolume();
342 auto& nameOfVol = pCurrentVol->GetName();
344 <<
" Corrupted Event - NaN detected in volume " << nameOfVol <<
"\n";
350 #ifdef HcalNumberingTest
362 double edepEM = (em ? dE : 0);
363 double edepHAD = (em ? 0 : dE);
364 std::pair<int, CaloHitID> evID = std::make_pair(
eventID_, currentID);
367 (it->second).addEnergyDeposit(edepEM, edepHAD);
371 aHit.
setID(currentID);
379 uint16_t depth2 = (uint16_t)floor(crystalDepth / radl);
382 edm::LogVerbatim(
"Step") <<
"CaloSteppingAction::getDepth radl " << radl <<
":" << crystalDepth <<
" depth " <<
depth;
389 double dapd = crystalLength - crystalDepth;
390 if (dapd >= -0.1 || dapd <= crystalLength + 0.1) {
394 edm::LogVerbatim(
"Step") <<
"CaloSteppingAction::curve_LY " << crystalDepth <<
":" << crystalLength <<
":" << dapd
398 edm::LogWarning(
"Step") <<
"CaloSteppingAction: light coll curve : wrong "
399 <<
"distance to APD " << dapd <<
" crlength = " << crystalLength
400 <<
" crystal Depth = " << crystalDepth <<
" weight = " <<
weight;
408 double dedx = dEStep /
step;
418 edm::LogVerbatim(
"Step") <<
"CaloSteppingAction::getBirkL3 Charge " <<
charge <<
" dE/dx " << dedx <<
" Birk Const "
419 << rkb <<
" Weight = " <<
weight <<
" dE " << dEStep <<
" step " <<
step;
428 double dedx = dEStep /
step;
433 weight = 1. / (1. + rkb * dedx +
c * dedx * dedx);
435 edm::LogVerbatim(
"Step") <<
"CaloSteppingAction::getBirkHC Charge " <<
charge <<
" dE/dx " << dedx <<
" Birk Const "
436 << rkb <<
", " <<
c <<
" Weight = " <<
weight <<
" dE " << dEStep;
448 0.001 *
hit.second.getEM(),
449 0.001 *
hit.second.getHadr(),
450 hit.second.getTimeSlice(),
451 hit.second.getTrackID(),
452 hit.second.getDepth());