27 #include "G4LogicalVolumeStore.hh" 28 #include "G4LogicalVolume.hh" 31 #include "G4VProcess.hh" 33 #include "G4SystemOfUnits.hh" 40 bool any(
const std::vector<T>&
v,
const T& what) {
41 return std::find(v.begin(), v.end(), what) != v.end();
85 if (ageingWithSlopeLY)
101 if (!tempD.empty()) {
106 edm::LogVerbatim(
"EcalSim") <<
"ECalSD:: useWeight " << tempD.size() <<
":" << useWeight << std::endl;
124 }
else if (name ==
"EcalHitsEB") {
126 }
else if (name ==
"EcalHitsEE") {
128 }
else if (name ==
"EcalHitsES") {
141 edm::LogVerbatim(
"EcalSim") <<
"Constructing a ECalSD with name " << GetName();
144 edm::LogVerbatim(
"EcalSim") <<
"ECalSD:: Use of Birks law is set to " << useBirk
145 <<
" with three constants kB = " << birk1 <<
", C1 = " << birk2
146 <<
", C2 = " << birk3 <<
"\n Use of L3 parametrization " << useBirkL3
147 <<
" with slope " << birkSlope <<
" and cut off " << birkCut <<
"\n" 148 <<
" Slope for Light yield is set to " <<
slopeLY;
151 <<
" by Birk or light yield curve";
157 <<
"\tions below " <<
kmaxIon <<
" MeV" 160 <<
"\n\ttime Granularity " 169 static const std::string ctype[4] = {
"EB",
"EBref",
"EE",
"EERef"};
170 for (
int k = 0;
k < 4; ++
k) {
173 double xmin = (
k > 1) ? 3000.0 : 1000.0;
174 g2L_[
k] = ecDir.
make<TH2F>(name.c_str(), title.c_str(), 100,
xmin, xmin + 1000., 100, 0.0, 3000.);
177 for (
int k = 0;
k < 4; ++
k)
186 const G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
187 const G4Track* theTrack = aStep->GetTrack();
188 double edep = aStep->GetTotalEnergyDeposit();
195 int pdg = theTrack->GetDefinition()->GetPDGEncoding();
197 double ke = theTrack->GetKineticEnergy();
198 if (((pdg / 1000000000 == 1 && ((pdg / 10000) % 100) > 0 && ((pdg / 10) % 100) > 0)) && (ke <
kmaxIon))
207 const G4LogicalVolume* lv = preStepPoint->GetTouchable()->GetVolume(0)->GetLogicalVolume();
219 edep *= weight * wt1;
221 double wt2 = theTrack->GetWeight();
226 edm::LogVerbatim(
"EcalSim") << lv->GetName() <<
" Light Collection Efficiency " << weight <<
":" << wt1
227 <<
" wt2= " << wt2 <<
" Weighted Energy Deposit " << edep /
MeV <<
" MeV";
236 primaryID = aTrack->GetTrackID();
245 const G4StepPoint* hitPoint = aStep->GetPreStepPoint();
247 const G4LogicalVolume* lv = hitPoint->GetTouchable()->GetVolume(0)->GetLogicalVolume();
253 uint16_t depth1(0), depth2(0);
264 <<
" L " << (ite ==
xtalLMap.end()) <<
":" << ite->second;
272 double radl = hitPoint->GetMaterial()->GetRadlen();
276 int k1 = (lvname.find(
"EFRY") != std::string::npos) ? 2 : 0;
277 int k2 = (lvname.find(
"refl") != std::string::npos) ? 1 : 0;
279 double rz = (k1 == 0) ? (hitPoint->GetPosition()).
rho() :
std::abs((hitPoint->GetPosition()).
z());
280 edm::LogVerbatim(
"EcalSim") << lvname <<
" # " << k1 <<
":" << k2 <<
":" << kk <<
" rz " << rz <<
" D " << thisX0;
281 g2L_[
kk]->Fill(rz, thisX0);
284 G4ThreeVector localPoint =
setToLocal(hitPoint->GetPosition(), hitPoint->GetTouchable());
285 edm::LogVerbatim(
"EcalSim") << lv->GetName() <<
" Global " << hitPoint->GetPosition() <<
":" 286 << (hitPoint->GetPosition()).
rho() <<
" Local " << localPoint <<
" Crystal Length " 295 const double invLayerSize = 0.1;
309 if (scheme !=
nullptr) {
310 edm::LogVerbatim(
"EcalSim") <<
"EcalSD: updates numbering scheme for " << GetName();
321 G4String attribute =
"ReadOutName";
326 std::vector<const G4LogicalVolume*> lvused;
327 const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
328 std::map<const std::string, const G4LogicalVolume*> nameMap;
329 for (
auto lvi = lvs->begin(), lve = lvs->end(); lvi != lve; ++lvi)
330 nameMap.emplace((*lvi)->GetName(), *lvi);
336 const G4LogicalVolume* lv = nameMap[lvname];
337 int ibec = (lvname.find(
"EFRY") == std::string::npos) ? 0 : 1;
338 int iref = (lvname.find(
"refl") == std::string::npos) ? 0 : 1;
339 int type = (ibec + iref == 1) ? 1 : -1;
341 if (strncmp(lvname.c_str(),
depth1Name.c_str(), 4) == 0) {
345 edm::LogVerbatim(
"EcalSim") <<
"ECalSD::initMap Logical Volume " << lvname <<
" in Depth 1 volume list";
348 const G4LogicalVolume* lvr = nameMap[lvname +
"_refl"];
352 edm::LogVerbatim(
"EcalSim") <<
"ECalSD::initMap Logical Volume " << lvname <<
"_refl" 353 <<
" in Depth 1 volume list";
359 if (strncmp(lvname.c_str(),
depth2Name.c_str(), 4) == 0) {
363 edm::LogVerbatim(
"EcalSim") <<
"ECalSD::initMap Logical Volume " << lvname <<
" in Depth 2 volume list";
366 const G4LogicalVolume* lvr = nameMap[lvname +
"_refl"];
370 edm::LogVerbatim(
"EcalSim") <<
"ECalSD::initMap Logical Volume " << lvname <<
"_refl" 371 <<
" in Depth 2 volume list";
378 if (!
any(lvused, lv)) {
379 lvused.push_back(lv);
381 const std::vector<double>& paras = sol.
parameters();
383 edm::LogVerbatim(
"EcalSim") <<
"ECalSD::initMap (for " << sd <<
"): Solid " << lvname <<
" Shape " 384 << sol.
shape() <<
" Parameter 0 = " << paras[0] <<
" Logical Volume " << lv;
387 double dz = 2 * paras[0];
388 xtalLMap.insert(std::pair<const G4LogicalVolume*, double>(lv, dz * type));
389 lv = nameMap[lvname +
"_refl"];
391 xtalLMap.insert(std::pair<const G4LogicalVolume*, double>(lv, -dz * type));
399 edm::LogVerbatim(
"EcalSim") <<
"ECalSD::initMap Logical Volume " << lvname <<
" Material " << matname
400 <<
" in noWeight list";
403 lv = nameMap[lvname];
407 edm::LogVerbatim(
"EcalSim") <<
"ECalSD::initMap Logical Volume " << lvname <<
" Material " << matname
408 <<
" in noWeight list";
416 edm::LogVerbatim(
"EcalSim") <<
"ECalSD: Length Table for " << attribute <<
" = " << sd <<
":";
419 G4String
name(
"Unknown");
421 name = (ite.first)->GetName();
422 edm::LogVerbatim(
"EcalSim") <<
" " << i <<
" " << ite.first <<
" " << name <<
" L = " << ite.second;
440 edm::LogWarning(
"EcalSim") <<
"ECalSD: light coll curve : wrong distance " 442 <<
" crystal name = " << lv->GetName()
451 const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
452 int theSize = touch->GetHistoryDepth() + 1;
457 for (
int ii = 0;
ii < theSize;
ii++) {
461 << touch->GetVolume(
ii)->GetName() <<
"[" << touch->GetReplicaNumber(
ii) <<
"]";
469 const G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
470 double charge = preStepPoint->GetCharge();
472 if (charge != 0. && aStep->GetStepLength() > 0.) {
473 const G4Material* mat = preStepPoint->GetMaterial();
474 double density = mat->GetDensity();
475 double dedx = aStep->GetTotalEnergyDeposit() / aStep->GetStepLength();
481 else if (weight > 1.)
485 edm::LogVerbatim(
"EcalSim") <<
"ECalSD::getBirkL3 in " << mat->GetName() <<
" Charge " << charge <<
" dE/dx " 486 << dedx <<
" Birk Const " << rkb <<
" Weight = " << weight <<
" dE " 487 << aStep->GetTotalEnergyDeposit();
502 const std::vector<double>& fvec = value.
doubles();
505 std::vector<double> fvec;
519 const std::vector<std::string>& fvec = value.
strings();
522 std::vector<std::string> fvec;
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
const std::vector< double > & parameters(void) const
Give the parameters of the solid.
const DDLogicalPart & logicalPart() const
The logical-part of the current node in the filtered-view.
const std::vector< double > & doubles() const
a reference to the double-valued values stored in the given instance of DDValue
std::vector< std::string > getStringArray(const std::string &, const DDsvalues_type &)
void setLumies(double x, double y)
std::vector< const G4LogicalVolume * > useDepth2
void getBaseNumber(const G4Step *)
static const int kEcalDepthRefz
std::vector< const G4LogicalVolume * > noWeight
void initMap(const G4String &, const edm::EventSetup &)
bool any(const std::vector< T > &v, const T &what)
double getEnergyDeposit(const G4Step *) override
virtual int getTrackID(const G4Track *)
const DDSolid & solid(void) const
Returns a reference object of the solid being the shape of this LogicalPart.
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
EcalNumberingScheme * numberingScheme_
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
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
A DDSolid represents the shape of a part.
double getBirkL3(const G4Step *)
int getTrackID(const G4Track *) override
void addLevel(const std::string &name, const int ©Number)
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
std::map< const G4LogicalVolume *, double > xtalLMap
EcalBaseNumber theBaseNumber
bool next()
set current node to the next node in the filtered tree
static const int kEcalDepthMask
Abs< T >::type abs(const T &t)
uint16_t getLayerIDForTimeSim()
DDSolidShape shape(void) const
The type of the solid.
static const int kEcalDepthOffset
T * make(const Args &...args) const
make new ROOT object
const std::vector< std::string > & strings() const
a reference to the std::string-valued values stored in the given instance of DDValue ...
G4ThreeVector setToLocal(const G4ThreeVector &, const G4VTouchable *) const
G4ThreeVector currentLocalPoint
uint16_t getRadiationLength(const G4StepPoint *hitPoint, const G4LogicalVolume *lv)
std::vector< const G4LogicalVolume * > useDepth1
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
virtual uint32_t getUnitID(const EcalBaseNumber &baseNumber) const =0
std::vector< double > getDDDArray(const std::string &, const DDsvalues_type &)
double calcLightCollectionEfficiencyWeighted(DetId id, double z)
DDsvalues_type mergedSpecifics() const
double getAttenuation(const G4Step *aStep, double birk1, double birk2, double birk3) const
bool firstChild()
set the current node to the first child ...
double curve_LY(const G4LogicalVolume *)
EnergyResolutionVsLumi ageing
void setNumberingScheme(EcalNumberingScheme *)
uint32_t setDetUnitId(const G4Step *) override
double getResponseWt(const G4Track *)
void setSize(const int &size)
const std::string & name() const
Returns the name.
const DDMaterial & material(void) const
Returns a reference object of the material this LogicalPart is made of.
ECalSD(const std::string &, const edm::EventSetup &, const SensitiveDetectorCatalog &, edm::ParameterSet const &p, const SimTrackManager *)
uint16_t getDepth(const G4Step *) override