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" 49 edm::LogVerbatim(
"Step") <<
"CaloSteppingAction:: " << nameEBSD_.size() <<
" names for EB SD's";
50 for (
unsigned int k = 0;
k < nameEBSD_.size(); ++
k)
52 edm::LogVerbatim(
"Step") <<
"CaloSteppingAction:: " << nameEESD_.size() <<
" names for EE SD's";
53 for (
unsigned int k = 0;
k < nameEESD_.size(); ++
k)
55 edm::LogVerbatim(
"Step") <<
"CaloSteppingAction:: " << nameHCSD_.size() <<
" names for HC SD's";
56 for (
unsigned int k = 0;
k < nameHCSD_.size(); ++
k)
58 edm::LogVerbatim(
"Step") <<
"CaloSteppingAction::Constants for ECAL: slope " << slopeLY_ <<
" Birk constants " 59 << birkC1EC_ <<
":" << birkSlopeEC_ <<
":" <<
birkCutEC_;
61 <<
"constants " << birkC1HC_ <<
":" << birkC2HC_ <<
":" <<
birkC3HC_;
63 edm::LogVerbatim(
"Step") <<
"CaloSteppingAction:: " << nameHitC_.size() <<
" hit collections";
64 for (
unsigned int k = 0;
k < nameHitC_.size(); ++
k)
71 #ifdef HcalNumberingTest 72 hcNumbering_.reset(
nullptr);
75 slave_[
k] = std::make_unique<CaloSlaveSD>(nameHitC_[
k]);
76 produces<edm::PCaloHitContainer>(nameHitC_[
k]);
79 produces<edm::PassiveHitContainer>(
"AllPassiveHits");
80 edm::LogVerbatim(
"Step") <<
"CaloSteppingAction:: All Steps Flag " << allSteps_ <<
" for passive hits";
85 <<
"selected entries : " <<
count_;
91 auto product = std::make_unique<edm::PCaloHitContainer>();
103 edm::LogVerbatim(
"Step") <<
"CaloSteppingAction::fillHits for type " << type <<
" with " 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 cc.emplace_back(hit);
131 #ifdef HcalNumberingTest 134 (*job)()->get<HcalSimNumberingRecord>().get(hdc);
137 <<
"HcalNumberingFromDDD";
138 hcNumbering_ = std::make_unique<HcalNumberingFromDDD>(hcons_);
144 int irun = (*run)()->GetRunID();
147 const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
149 std::map<const std::string, const G4LogicalVolume*> nameMap;
150 std::map<const std::string, const G4LogicalVolume*>::const_iterator itr;
151 for (
auto lvi = lvs->begin(), lve = lvs->end(); lvi != lve; ++lvi) {
152 nameMap.emplace((*lvi)->GetName(), *lvi);
154 mapLV_[*lvi] = (*lvi)->GetName();
157 for (itr = nameMap.begin(); itr != nameMap.end(); ++itr) {
159 if (lvname.find(
name) != std::string::npos) {
161 int type = (lvname.find(
"refl") == std::string::npos) ? -1 : 1;
162 G4Trap* solid =
static_cast<G4Trap*
>(itr->second->GetSolid());
163 double dz = 2 * solid->GetZHalfLength() / CLHEP::mm;
164 xtalMap_.insert(std::pair<const G4LogicalVolume*, double>(itr->second, dz * type));
169 for (itr = nameMap.begin(); itr != nameMap.end(); ++itr) {
171 if (lvname.find(
name) != std::string::npos) {
173 int type = (lvname.find(
"refl") == std::string::npos) ? 1 : -1;
174 G4Trap* solid =
static_cast<G4Trap*
>(itr->second->GetSolid());
175 double dz = 2 * solid->GetZHalfLength() / CLHEP::mm;
176 xtalMap_.insert(std::pair<const G4LogicalVolume*, double>(itr->second, dz * type));
181 for (itr = nameMap.begin(); itr != nameMap.end(); ++itr) {
183 if (lvname.find(
name) != std::string::npos)
217 auto lv = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume();
221 if (hc || eb || ee) {
222 double dEStep = aStep->GetTotalEnergyDeposit() /
CLHEP::MeV;
223 auto const theTrack = aStep->GetTrack();
224 double time = theTrack->GetGlobalTime() / CLHEP::nanosecond;
225 int primID = theTrack->GetTrackID();
227 auto const touch = aStep->GetPreStepPoint()->GetTouchable();
228 auto const& hitPoint = aStep->GetPreStepPoint()->GetPosition();
230 int depth = (touch->GetReplicaNumber(0)) % 10 + 1;
231 int lay = (touch->GetReplicaNumber(0) / 10) % 100 + 1;
232 int det = (touch->GetReplicaNumber(1)) / 1000;
234 if (unitID > 0 && dEStep > 0.0) {
236 (aStep->GetStepLength() / CLHEP::cm),
237 aStep->GetPreStepPoint()->GetCharge(),
238 (aStep->GetPreStepPoint()->GetMaterial()->GetDensity() / (
CLHEP::g / CLHEP::cm3)));
239 fillHit(unitID, dEStep, time, primID, 0, em, 2);
243 int size = touch->GetHistoryDepth() + 1;
249 theBaseNumber.
addLevel(touch->GetVolume(
ii)->GetName(), touch->GetReplicaNumber(
ii));
254 if (unitID > 0 && dEStep > 0.0) {
255 auto local = touch->GetHistory()->GetTopTransform().TransformPoint(hitPoint);
257 double crystalLength = ((ite ==
xtalMap_.end()) ? 230.0 :
std::abs(ite->second));
258 double crystalDepth =
260 double radl = aStep->GetPreStepPoint()->GetMaterial()->GetRadlen() / CLHEP::mm;
261 bool flag = ((ite ==
xtalMap_.end()) ?
true : (((ite->second) >= 0) ?
true :
false));
264 (aStep->GetStepLength() / CLHEP::cm),
265 aStep->GetPreStepPoint()->GetCharge(),
266 (aStep->GetPreStepPoint()->GetMaterial()->GetDensity() / (
CLHEP::g / CLHEP::cm3))) *
267 curve_LY(crystalLength, crystalDepth));
268 fillHit(unitID, dEStep, time, primID,
depth, em, (eb ? 0 : 1));
274 auto it =
mapLV_.find(lv);
276 auto const touch = aStep->GetPreStepPoint()->GetTouchable();
277 double time = aStep->GetTrack()->GetGlobalTime() / CLHEP::nanosecond;
278 int trackId = aStep->GetTrack()->GetTrackID();
279 int pdg = aStep->GetTrack()->GetDefinition()->GetPDGEncoding();
280 double stepl = (aStep->GetStepLength() / CLHEP::cm);
282 edm::LogVerbatim(
"Step") <<
"CaloSteppingAction: Volume " << lv->GetName() <<
" History " 283 << touch->GetHistoryDepth() <<
" Pointers " << aStep->GetPostStepPoint() <<
":" 284 << aStep->GetTrack()->GetNextVolume() <<
":" << aStep->IsLastStepInVolume() <<
" E " 285 << energy <<
" T " << time <<
" PDG " << pdg <<
" step " << stepl;
288 if (((aStep->GetPostStepPoint() ==
nullptr) || (aStep->GetTrack()->GetNextVolume() ==
nullptr)) &&
289 (aStep->IsLastStepInVolume())) {
290 energy += (aStep->GetPreStepPoint()->GetKineticEnergy() /
CLHEP::MeV);
292 time = aStep->GetPostStepPoint()->GetGlobalTime() / CLHEP::nanosecond;
293 copy = (touch->GetHistoryDepth() < 1)
294 ? static_cast<uint32_t>(touch->GetReplicaNumber(0))
295 : static_cast<uint32_t>(touch->GetReplicaNumber(0) + 1000 * touch->GetReplicaNumber(1));
298 PassiveData key(std::make_tuple(lv, copy, trackId, pdg, time, energy, energy, stepl));
308 edm::LogVerbatim(
"Step") <<
"CaloSteppingAction: EndOfEvent " << (*evt)()->GetEventID();
312 auto currentPos = aStep->GetTrack()->GetPosition();
313 double xyz = currentPos.x() + currentPos.y() + currentPos.z();
314 auto currentMom = aStep->GetTrack()->GetMomentum();
315 xyz += currentMom.x() + currentMom.y() + currentMom.z();
318 auto pCurrentVol = aStep->GetPreStepPoint()->GetPhysicalVolume();
319 auto& nameOfVol = pCurrentVol->GetName();
321 <<
" Corrupted Event - NaN detected in volume " << nameOfVol <<
"\n";
327 #ifdef HcalNumberingTest 339 double edepEM = (em ? dE : 0);
340 double edepHAD = (em ? 0 : dE);
341 std::pair<int, CaloHitID> evID = std::make_pair(
eventID_, currentID);
344 (it->second).addEnergyDeposit(edepEM, edepHAD);
348 aHit.
setID(currentID);
356 uint16_t depth2 = (uint16_t)floor(crystalDepth / radl);
359 edm::LogVerbatim(
"Step") <<
"CaloSteppingAction::getDepth radl " << radl <<
":" << crystalDepth <<
" depth " <<
depth;
366 double dapd = crystalLength - crystalDepth;
367 if (dapd >= -0.1 || dapd <= crystalLength + 0.1) {
371 edm::LogVerbatim(
"Step") <<
"CaloSteppingAction::curve_LY " << crystalDepth <<
":" << crystalLength <<
":" << dapd
375 edm::LogWarning(
"Step") <<
"CaloSteppingAction: light coll curve : wrong " 376 <<
"distance to APD " << dapd <<
" crlength = " << crystalLength
377 <<
" crystal Depth = " << crystalDepth <<
" weight = " <<
weight;
384 if (charge != 0. && step > 0.) {
385 double dedx = dEStep /
step;
391 else if (weight > 1.)
395 edm::LogVerbatim(
"Step") <<
"CaloSteppingAction::getBirkL3 Charge " << charge <<
" dE/dx " << dedx <<
" Birk Const " 396 << rkb <<
" Weight = " << weight <<
" dE " << dEStep <<
" step " <<
step;
404 if (charge != 0. && step > 0.) {
405 double dedx = dEStep /
step;
410 weight = 1. / (1. + rkb * dedx + c * dedx * dedx);
412 edm::LogVerbatim(
"Step") <<
"CaloSteppingAction::getBirkHC Charge " << charge <<
" dE/dx " << dedx <<
" Birk Const " 413 << rkb <<
", " << c <<
" Weight = " << weight <<
" dE " << dEStep;
425 0.001 *
hit.second.getEM(),
426 0.001 *
hit.second.getHadr(),
427 hit.second.getTimeSlice(),
428 hit.second.getTrackID(),
429 hit.second.getDepth());
std::map< std::pair< int, CaloHitID >, CaloGVHit > hitMap_[nSD_]
std::vector< const G4LogicalVolume * > volEBSD_
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
void setID(uint32_t i, double d, int j, uint16_t k=0)
std::vector< PCaloHit > PCaloHitContainer
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
double getBirkL3(double dE, double step, double chg, double dens) const
static const int kEcalDepthRefz
constexpr bool isNotFinite(T x)
void produce(edm::Event &, const edm::EventSetup &) override
uint32_t getDetIDHC(int det, int lay, int depth, const math::XYZVectorD &pos) const
double getBirkHC(double dE, double step, double chg, double dens) const
double curve_LY(double crystalLength, double crystalDepth) const
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
void fillHits(edm::PCaloHitContainer &cc, int type)
void addLevel(const std::string &name, const int ©Number)
std::vector< const G4LogicalVolume * > volEESD_
ROOT::Math::DisplacementVector3D< ROOT::Math::Cartesian3D< double > > XYZVectorD
spatial vector with cartesian internal representation
std::vector< std::string > nameHitC_
std::map< const G4LogicalVolume *, std::string > mapLV_
CaloSteppingAction(const edm::ParameterSet &p)
std::vector< const G4LogicalVolume * > volHCSD_
static const int kEcalDepthMask
std::vector< std::string > nameHCSD_
Abs< T >::type abs(const T &t)
std::map< const G4LogicalVolume *, double > xtalMap_
static const int kEcalDepthOffset
void fillPassiveHits(edm::PassiveHitContainer &cc)
std::vector< PassiveHit > PassiveHitContainer
void addEnergyDeposit(double em, double hd)
std::unique_ptr< CaloSlaveSD > slave_[nSD_]
std::vector< std::string > nameEBSD_
void fillHit(uint32_t id, double dE, double time, int primID, uint16_t depth, double em, int flag)
void NaNTrap(const G4Step *) const
std::unique_ptr< HcalNumberingFromPS > hcNumberingPS_
std::unique_ptr< HcalNumberingScheme > hcNumberingScheme_
void update(const BeginOfJob *job) override
This routine will be called when the appropriate signal arrives.
std::unique_ptr< EcalBarrelNumberingScheme > ebNumberingScheme_
static bool isGammaElectronPositron(int pdgCode)
std::unique_ptr< EcalEndcapNumberingScheme > eeNumberingScheme_
std::vector< std::string > nameEESD_
std::vector< PassiveData > store_
void setSize(const int &size)
uint16_t getDepth(bool flag, double crystalDepth, double radl) const
T const * product() const
~CaloSteppingAction() override
std::tuple< const G4LogicalVolume *, uint32_t, int, int, double, double, double, double > PassiveData