22 #include "G4LogicalVolumeStore.hh" 23 #include "G4LogicalVolume.hh" 26 #include "G4VProcess.hh" 28 #include <CLHEP/Units/SystemOfUnits.h> 37 bool any(
const std::vector<T>&
v,
const T& what) {
52 ecalSimParameters_(ecpar) {
65 double bunit = (
CLHEP::g / (CLHEP::MeV * CLHEP::cm2));
89 edm::LogError(
"EcalSim") <<
"ECalSD : Cannot find EcalSimulationParameters for " <<
name;
90 throw cms::Exception(
"Unknown",
"ECalSD") <<
"Cannot find EcalSimulationParameters for " <<
name <<
"\n";
108 }
else if (
name ==
"EcalHitsEB") {
111 dump = ((dumpGeom % 10) > 0);
112 }
else if (
name ==
"EcalHitsEE") {
115 dump = (((dumpGeom / 10) % 10) > 0);
116 }
else if (
name ==
"EcalHitsES") {
123 dump = (((dumpGeom / 100) % 10) > 0);
127 int type0 = dumpGeom / 1000;
128 type += (10 * type0);
134 edm::LogVerbatim(
"EcalSim") <<
"Constructing a ECalSD with name " << GetName();
138 <<
" with three constants kB = " <<
birk1 / bunit <<
", C1 = " <<
birk2 139 <<
", C2 = " <<
birk3 <<
"\n Use of L3 parametrization " <<
useBirkL3 141 <<
" Slope for Light yield is set to " <<
slopeLY;
144 <<
" by Birk or light yield curve";
149 <<
" MeV,\tions below " <<
kmaxIon / CLHEP::MeV <<
" MeV \n\tDepth1 Name = " <<
depth1Name 158 if (
tfile.isAvailable()) {
160 static const std::string ctype[4] = {
"EB",
"EBref",
"EE",
"EERef"};
161 for (
int k = 0;
k < 4; ++
k) {
164 double xmin = (
k > 1) ? 3000.0 : 1000.0;
168 for (
int k = 0;
k < 4; ++
k)
182 const G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
183 const G4Track* theTrack = aStep->GetTrack();
184 double edep = aStep->GetTotalEnergyDeposit();
191 int pdg = theTrack->GetDefinition()->GetPDGEncoding();
193 double ke = theTrack->GetKineticEnergy();
194 if (((
pdg / 1000000000 == 1 && ((
pdg / 10000) % 100) > 0 && ((
pdg / 10) % 100) > 0)) && (ke <
kmaxIon))
203 const G4LogicalVolume* lv = preStepPoint->GetTouchable()->GetVolume(0)->GetLogicalVolume();
217 double wt2 = theTrack->GetWeight();
224 <<
" Light Collection Efficiency " <<
weight <<
":" << wt1 <<
" wt2= " << wt2
225 <<
" Weighted Energy Deposit " << edep / CLHEP::MeV <<
" MeV at " 226 << preStepPoint->GetPosition();
232 const G4StepPoint* hitPoint =
step.GetPreStepPoint();
233 const G4LogicalVolume* lv = hitPoint->GetTouchable()->GetVolume(0)->GetLogicalVolume();
234 if (lv->GetSensitiveDetector() !=
this)
237 double edep =
step.GetTotalEnergyDeposit();
252 primaryID = aTrack->GetTrackID();
261 const G4StepPoint* hitPoint = aStep->GetPreStepPoint();
263 const G4LogicalVolume* lv = hitPoint->GetTouchable()->GetVolume(0)->GetLogicalVolume();
269 uint16_t depth1(0), depth2(0);
281 <<
std::dec <<
" Global " << (hitPoint->GetPosition()).
rho() <<
":" 285 <<
" L " << (ite ==
xtalLMap.end()) <<
":" << ite->second <<
" local " 294 double radl = hitPoint->GetMaterial()->GetRadlen();
298 int k1 = (lvname.find(
"EFRY") != std::string::npos) ? 2 : 0;
299 int k2 = (lvname.find(
"refl") != std::string::npos) ? 1 : 0;
301 double rz = (k1 == 0) ? (hitPoint->GetPosition()).
rho() :
std::abs((hitPoint->GetPosition()).
z());
302 edm::LogVerbatim(
"EcalSim") << lvname <<
" # " << k1 <<
":" << k2 <<
":" <<
kk <<
" rz " << rz <<
" D " << thisX0;
303 g2L_[
kk]->Fill(rz, thisX0);
306 G4ThreeVector localPoint =
setToLocal(hitPoint->GetPosition(), hitPoint->GetTouchable());
309 << hitPoint->GetPosition() <<
":" << (hitPoint->GetPosition()).
rho() <<
" Local " 310 << localPoint <<
" Crystal Length " <<
crystalLength <<
" Radl " << radl
311 <<
" crystalDepth " <<
crystalDepth <<
" Index " << thisX0 <<
" : " 319 const double invLayerSize = 0.1;
334 edm::LogVerbatim(
"EcalSim") <<
"EcalSD: updates numbering scheme for " << GetName();
340 std::vector<const G4LogicalVolume*> lvused;
341 const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
342 std::map<const std::string, const G4LogicalVolume*> nameMap;
343 for (
auto lvi = lvs->begin(), lve = lvs->end(); lvi != lve; ++lvi)
349 const G4LogicalVolume* lv = nameMap[lvname];
350 int ibec = (lvname.find(
"EFRY") == std::string::npos) ? 0 : 1;
351 int iref = (lvname.find(
"refl") == std::string::npos) ? 0 : 1;
352 int type = (ibec + iref == 1) ? 1 : -1;
354 if (strncmp(lvname.c_str(),
depth1Name.c_str(), 4) == 0) {
358 edm::LogVerbatim(
"EcalSim") <<
"ECalSD::initMap Logical Volume " << lvname <<
" in Depth 1 volume list";
361 const G4LogicalVolume* lvr = nameMap[lvname +
"_refl"];
365 edm::LogVerbatim(
"EcalSim") <<
"ECalSD::initMap Logical Volume " << lvname <<
"_refl" 366 <<
" in Depth 1 volume list";
372 if (strncmp(lvname.c_str(),
depth2Name.c_str(), 4) == 0) {
376 edm::LogVerbatim(
"EcalSim") <<
"ECalSD::initMap Logical Volume " << lvname <<
" in Depth 2 volume list";
379 const G4LogicalVolume* lvr = nameMap[lvname +
"_refl"];
383 edm::LogVerbatim(
"EcalSim") <<
"ECalSD::initMap Logical Volume " << lvname <<
"_refl" 384 <<
" in Depth 2 volume list";
391 if (!
any(lvused, lv)) {
392 lvused.push_back(lv);
394 xtalLMap.insert(std::pair<const G4LogicalVolume*, double>(lv,
dz *
type));
395 lv = nameMap[lvname +
"_refl"];
397 xtalLMap.insert(std::pair<const G4LogicalVolume*, double>(lv, -
dz *
type));
404 edm::LogVerbatim(
"EcalSim") <<
"ECalSD::initMap Logical Volume " << lvname <<
" Material " << matname
405 <<
" in noWeight list";
408 lv = nameMap[lvname];
412 edm::LogVerbatim(
"EcalSim") <<
"ECalSD::initMap Logical Volume " << lvname <<
" Material " << matname
413 <<
" in noWeight list";
424 if (ite.first !=
nullptr)
444 edm::LogWarning(
"EcalSim") <<
"ECalSD: light coll curve : wrong distance " 446 <<
" crystal name = " << lv->GetName() <<
" " 453 <<
" crystal name = " << lv->GetName() <<
" " 462 const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
463 int theSize = touch->GetHistoryDepth() + 1;
468 for (
int ii = 0;
ii < theSize;
ii++) {
473 << touch->GetReplicaNumber(
ii) <<
"]";
481 const G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
482 double charge = preStepPoint->GetCharge();
484 if (
charge != 0. && aStep->GetStepLength() > 0.) {
485 const G4Material* mat = preStepPoint->GetMaterial();
486 double density = mat->GetDensity();
487 double dedx = aStep->GetTotalEnergyDeposit() / aStep->GetStepLength();
499 <<
charge <<
" dE/dx " << dedx <<
" Birk Const " << rkb <<
" Weight = " <<
weight 500 <<
" dE " << aStep->GetTotalEnergyDeposit();
Log< level::Info, true > LogVerbatim
bool isXtal(const G4LogicalVolume *)
T getParameter(std::string const &) const
std::vector< std::string > lvNames_
void setLumies(double x, double y)
std::vector< const G4LogicalVolume * > useDepth2
void getBaseNumber(const G4Step *)
static const int kEcalDepthRefz
std::vector< const G4LogicalVolume * > noWeight
bool any(const std::vector< T > &v, const T &what)
double getEnergyDeposit(const G4Step *) override
G4ThreeVector setToLocal(const G4ThreeVector &, const G4VTouchable *) const
std::unique_ptr< EcalNumberingScheme > numberingScheme_
virtual int getTrackID(const G4Track *)
std::vector< double > dzs_
Log< level::Error, false > LogError
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
const std::vector< std::string_view > logicalNames(const std::string &readoutName) const
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
double getBirkL3(const G4Step *)
T getUntrackedParameter(std::string const &, T const &) const
int getTrackID(const G4Track *) override
std::vector< std::string > matNames_
T * make(const Args &...args) const
make new ROOT object
void addLevel(const std::string &name, const int ©Number)
std::map< const G4LogicalVolume *, double > xtalLMap
double getResponseWt(const G4Track *, int k=0)
EcalBaseNumber theBaseNumber
static const int kEcalDepthMask
Abs< T >::type abs(const T &t)
uint16_t getLayerIDForTimeSim()
static const int kEcalDepthOffset
const EcalSimulationParameters * ecalSimParameters_
G4ThreeVector currentLocalPoint
uint16_t getRadiationLength(const G4StepPoint *hitPoint, const G4LogicalVolume *lv)
std::vector< const G4LogicalVolume * > useDepth1
double getAttenuation(const G4Step *aStep, double birk1, double birk2, double birk3) const
double calcLightCollectionEfficiencyWeighted(DetId id, double z)
ECalSD(const std::string &, const EcalSimulationParameters *, const SensitiveDetectorCatalog &, edm::ParameterSet const &p, const SimTrackManager *)
std::string noNameSpace(const std::string &name)
double curve_LY(const G4LogicalVolume *)
EnergyResolutionVsLumi ageing
Log< level::Warning, false > LogWarning
void setNumberingScheme(EcalNumberingScheme *)
uint32_t setDetUnitId(const G4Step *) override
void setSize(const int &size)
double EnergyCorrected(const G4Step &, const G4Track *) override
uint16_t getDepth(const G4Step *) override