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" 47 edm::LogVerbatim(
"Step") <<
"CaloSteppingAction:: " << nameEBSD_.size() <<
" names for EB SD's";
48 for (
unsigned int k = 0;
k < nameEBSD_.size(); ++
k)
50 edm::LogVerbatim(
"Step") <<
"CaloSteppingAction:: " << nameEESD_.size() <<
" names for EE SD's";
51 for (
unsigned int k = 0;
k < nameEESD_.size(); ++
k)
53 edm::LogVerbatim(
"Step") <<
"CaloSteppingAction:: " << nameHCSD_.size() <<
" names for HC SD's";
54 for (
unsigned int k = 0;
k < nameHCSD_.size(); ++
k)
56 edm::LogVerbatim(
"Step") <<
"CaloSteppingAction::Constants for ECAL: slope " << slopeLY_ <<
" Birk constants " 57 << birkC1EC_ <<
":" << birkSlopeEC_ <<
":" <<
birkCutEC_;
59 <<
"constants " << birkC1HC_ <<
":" << birkC2HC_ <<
":" <<
birkC3HC_;
60 edm::LogVerbatim(
"Step") <<
"CaloSteppingAction:: " << nameHitC_.size() <<
" hit collections";
61 for (
unsigned int k = 0;
k < nameHitC_.size(); ++
k)
68 #ifdef HcalNumberingTest 69 hcNumbering_.reset(
nullptr);
72 slave_[
k] = std::make_unique<CaloSlaveSD>(nameHitC_[
k]);
73 produces<edm::PCaloHitContainer>(nameHitC_[
k]);
79 <<
"selected entries : " <<
count_;
85 auto product = std::make_unique<edm::PCaloHitContainer>();
92 edm::LogVerbatim(
"Step") <<
"CaloSteppingAction::fillHits for type " << type <<
" with " 93 <<
slave_[
type].get()->hits().size() <<
" hits";
101 #ifdef HcalNumberingTest 104 (*job)()->get<HcalSimNumberingRecord>().get(hdc);
107 <<
"HcalNumberingFromDDD";
108 hcNumbering_ = std::make_unique<HcalNumberingFromDDD>(hcons_);
114 int irun = (*run)()->GetRunID();
117 const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
119 std::map<const std::string, const G4LogicalVolume*> nameMap;
120 std::map<const std::string, const G4LogicalVolume*>::const_iterator itr;
121 for (
auto lvi = lvs->begin(), lve = lvs->end(); lvi != lve; ++lvi)
122 nameMap.emplace((*lvi)->GetName(), *lvi);
124 for (itr = nameMap.begin(); itr != nameMap.end(); ++itr) {
126 if (lvname.find(
name) != std::string::npos) {
128 int type = (lvname.find(
"refl") == std::string::npos) ? -1 : 1;
129 G4Trap* solid =
static_cast<G4Trap*
>(itr->second->GetSolid());
130 double dz = 2 * solid->GetZHalfLength();
131 xtalMap_.insert(std::pair<const G4LogicalVolume*, double>(itr->second, dz * type));
136 for (itr = nameMap.begin(); itr != nameMap.end(); ++itr) {
138 if (lvname.find(
name) != std::string::npos) {
140 int type = (lvname.find(
"refl") == std::string::npos) ? 1 : -1;
141 G4Trap* solid =
static_cast<G4Trap*
>(itr->second->GetSolid());
142 double dz = 2 * solid->GetZHalfLength();
143 xtalMap_.insert(std::pair<const G4LogicalVolume*, double>(itr->second, dz * type));
148 for (itr = nameMap.begin(); itr != nameMap.end(); ++itr) {
150 if (lvname.find(
name) != std::string::npos)
182 auto lv = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume();
186 if (hc || eb || ee) {
187 double dEStep = aStep->GetTotalEnergyDeposit();
188 auto const theTrack = aStep->GetTrack();
189 double time = theTrack->GetGlobalTime() / nanosecond;
190 int primID = theTrack->GetTrackID();
192 auto const touch = aStep->GetPreStepPoint()->GetTouchable();
193 auto const& hitPoint = aStep->GetPreStepPoint()->GetPosition();
195 int depth = (touch->GetReplicaNumber(0)) % 10 + 1;
196 int lay = (touch->GetReplicaNumber(0) / 10) % 100 + 1;
197 int det = (touch->GetReplicaNumber(1)) / 1000;
199 if (unitID > 0 && dEStep > 0.0) {
201 aStep->GetStepLength(),
202 aStep->GetPreStepPoint()->GetCharge(),
203 aStep->GetPreStepPoint()->GetMaterial()->GetDensity());
204 fillHit(unitID, dEStep, time, primID, 0, em, 2);
208 int size = touch->GetHistoryDepth() + 1;
214 theBaseNumber.
addLevel(touch->GetVolume(
ii)->GetName(), touch->GetReplicaNumber(
ii));
219 if (unitID > 0 && dEStep > 0.0) {
220 auto local = touch->GetHistory()->GetTopTransform().TransformPoint(hitPoint);
222 double crystalLength = ((ite ==
xtalMap_.end()) ? 230.0 :
std::abs(ite->second));
224 double radl = aStep->GetPreStepPoint()->GetMaterial()->GetRadlen();
225 bool flag = ((ite ==
xtalMap_.end()) ?
true : (((ite->second) >= 0) ?
true :
false));
228 aStep->GetStepLength(),
229 aStep->GetPreStepPoint()->GetCharge(),
230 aStep->GetPreStepPoint()->GetMaterial()->GetDensity()) *
231 curve_LY(crystalLength, crystalDepth));
232 fillHit(unitID, dEStep, time, primID,
depth, em, (eb ? 0 : 1));
242 edm::LogVerbatim(
"Step") <<
"CaloSteppingAction: EndOfEvent " << (*evt)()->GetEventID();
246 auto currentPos = aStep->GetTrack()->GetPosition();
247 double xyz = currentPos.x() + currentPos.y() + currentPos.z();
248 auto currentMom = aStep->GetTrack()->GetMomentum();
249 xyz += currentMom.x() + currentMom.y() + currentMom.z();
252 auto pCurrentVol = aStep->GetPreStepPoint()->GetPhysicalVolume();
253 auto& nameOfVol = pCurrentVol->GetName();
255 <<
" Corrupted Event - NaN detected in volume " << nameOfVol <<
"\n";
261 #ifdef HcalNumberingTest 272 CaloHitID currentID(
id, time, primID, depth);
273 double edepEM = (em ? dE : 0);
274 double edepHAD = (em ? 0 : dE);
275 std::pair<int, CaloHitID> evID = std::make_pair(
eventID_, currentID);
278 (it->second).addEnergyDeposit(edepEM, edepHAD);
282 aHit.
setID(currentID);
290 uint16_t depth2 = (uint16_t)floor(crystalDepth / radl);
293 edm::LogVerbatim(
"Step") <<
"CaloSteppingAction::getDepth radl " << radl <<
":" << crystalDepth <<
" depth " <<
depth;
300 double dapd = crystalLength - crystalDepth;
301 if (dapd >= -0.1 || dapd <= crystalLength + 0.1) {
305 edm::LogVerbatim(
"Step") <<
"CaloSteppingAction::curve_LY " << crystalDepth <<
":" << crystalLength <<
":" << dapd
309 edm::LogWarning(
"Step") <<
"CaloSteppingAction: light coll curve : wrong " 310 <<
"distance to APD " << dapd <<
" crlength = " << crystalLength
311 <<
" crystal Depth = " << crystalDepth <<
" weight = " <<
weight;
318 if (charge != 0. && step > 0.) {
319 double dedx = dEStep /
step;
325 else if (weight > 1.)
329 edm::LogVerbatim(
"Step") <<
"CaloSteppingAction::getBirkL3 Charge " << charge <<
" dE/dx " << dedx <<
" Birk Const " 330 << rkb <<
" Weight = " << weight <<
" dE " << dEStep <<
" step " <<
step;
338 if (charge != 0. && step > 0.) {
339 double dedx = dEStep /
step;
344 weight = 1. / (1. + rkb * dedx + c * dedx * dedx);
346 edm::LogVerbatim(
"Step") <<
"CaloSteppingAction::getBirkHC Charge " << charge <<
" dE/dx " << dedx <<
" Birk Const " 347 << rkb <<
", " << c <<
" Weight = " << weight <<
" dE " << dEStep;
360 hit.second.getHadr() /
GeV,
361 hit.second.getTimeSlice(),
362 hit.second.getTrackID(),
363 hit.second.getDepth());
std::map< std::pair< int, CaloHitID >, CaloGVHit > hitMap_[nSD_]
std::vector< const G4LogicalVolume * > volEBSD_
T getParameter(std::string 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_
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 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::vector< std::vector< double > > tmp
std::unique_ptr< EcalBarrelNumberingScheme > ebNumberingScheme_
static bool isGammaElectronPositron(int pdgCode)
std::unique_ptr< EcalEndcapNumberingScheme > eeNumberingScheme_
std::vector< std::string > nameEESD_
void setSize(const int &size)
uint16_t getDepth(bool flag, double crystalDepth, double radl) const
T const * product() const
~CaloSteppingAction() override