24 #include "G4LogicalVolumeStore.hh" 25 #include "G4LogicalVolume.hh" 28 #include "G4VProcess.hh" 30 #include "G4SystemOfUnits.hh" 37 bool any(
const std::vector<T> &
v,
const T &what) {
38 return std::find(v.begin(), v.end(), what) != v.end();
44 CaloSD(name, cpv, clg, p, manager,
90 if (!tempD.empty()) {
if (tempD[0] < 0.1) useWeight =
false; }
92 edm::LogInfo(
"EcalSim") <<
"ECalSD:: useWeight " << tempD.size() <<
":" 93 << useWeight << std::endl;
108 }
else if (name ==
"EcalHitsEB") {
111 }
else if (name ==
"EcalHitsEE") {
114 }
else if (name ==
"EcalHitsES") {
124 edm::LogInfo(
"EcalSim") <<
"Constructing a ECalSD with name " << GetName();
127 edm::LogInfo(
"EcalSim") <<
"ECalSD:: Use of Birks law is set to " 128 << useBirk <<
" with three constants kB = " 129 << birk1 <<
", C1 = " << birk2 <<
", C2 = " 130 << birk3 <<
"\n Use of L3 parametrization " 131 << useBirkL3 <<
" with slope " << birkSlope
132 <<
" and cut off " << birkCut <<
"\n" 133 <<
" Slope for Light yield is set to " 136 edm::LogInfo(
"EcalSim") <<
"ECalSD:: energy deposit is not corrected " 137 <<
" by Birk or light yield curve";
141 <<
"\tprotons below " <<
kmaxProton <<
" MeV," 143 <<
"\tions below " <<
kmaxIon <<
" MeV" 146 <<
"\n\tstoreRL" << storeRL <<
":" << scaleRL
148 <<
"\n\ttime Granularity " 151 if (useWeight)
initMap(name,cpv);
156 static const std::string ctype[4] = {
"EB",
"EBref",
"EE",
"EERef"};
157 for (
int k=0;
k<4; ++
k) {
160 double xmin = (
k > 1) ? 3000.0 : 1000.0;
161 g2L_[
k] = ecDir.
make<TH2F>(name.c_str(),title.c_str(),100,
xmin,
162 xmin+1000.,100,0.0,3000.);
165 for (
int k=0;
k<4; ++
k) g2L_[
k] = 0;
177 const G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
178 const G4Track* theTrack = aStep->GetTrack();
179 double edep = aStep->GetTotalEnergyDeposit();
186 int pdg = theTrack->GetDefinition()->GetPDGEncoding();
188 double ke = theTrack->GetKineticEnergy();
189 if (((pdg/1000000000 == 1 && ((pdg/10000)%100) > 0 &&
190 ((pdg/10)%100) > 0)) && (ke<
kmaxIon)) weight = 0;
191 if ((pdg == 2212) && (ke <
kmaxProton)) weight = 0;
192 if ((pdg == 2112) && (ke <
kmaxNeutron)) weight = 0;
196 const G4LogicalVolume* lv = preStepPoint->GetTouchable()->GetVolume(0)->GetLogicalVolume();
208 double wt2 = theTrack->GetWeight();
209 if(wt2 > 0.0) { edep *= wt2; }
212 <<
" Light Collection Efficiency " << weight <<
":" 213 << wt1 <<
" wt2= " << wt2
214 <<
" Weighted Energy Deposit " << edep/
MeV <<
" MeV";
223 primaryID = aTrack->GetTrackID();
233 const G4StepPoint* hitPoint = aStep->GetPreStepPoint();
235 const G4LogicalVolume* lv = hitPoint->GetTouchable()->GetVolume(0)->GetLogicalVolume();
244 uint16_t depth1 = (ite ==
xtalLMap.end()) ? 0 : (((ite->second) >= 0) ? 0 :
253 edm::LogVerbatim(
"EcalSim") <<
"ECalSD::Depth " << std::hex << depth1 <<
":" 255 << (ite ==
xtalLMap.end()) <<
":" <<ite->second;
264 double radl = hitPoint->GetMaterial()->GetRadlen();
268 int k1 = (lvname.find(
"EFRY")!=std::string::npos) ? 2 : 0;
269 int k2 = (lvname.find(
"refl")!=std::string::npos) ? 1 : 0;
271 double rz = (k1 == 0) ? (hitPoint->GetPosition()).
rho() :
274 << kk <<
" rz " << rz <<
" D " << thisX0;
275 g2L_[
kk]->Fill(rz,thisX0);
279 << hitPoint->GetPosition() <<
":" 280 << (hitPoint->GetPosition()).
rho()
281 <<
" Local " << localPoint
282 <<
" Crystal Length " << crlength
283 <<
" Radl " << radl <<
" DetZ " << detz
284 <<
" Index " << thisX0
293 const double invLayerSize = 0.1;
307 if (scheme !=
nullptr) {
308 edm::LogInfo(
"EcalSim") <<
"EcalSD: updates numbering scheme for " 317 G4String attribute =
"ReadOutName";
322 std::vector<const G4LogicalVolume*> lvused;
323 const G4LogicalVolumeStore * lvs = G4LogicalVolumeStore::GetInstance();
324 std::vector<const G4LogicalVolume *>::const_iterator lvcite;
325 std::map<const std::string, const G4LogicalVolume *> nameMap;
326 for (
auto lvi = lvs->begin(), lve = lvs->end(); lvi != lve; ++lvi)
327 nameMap.insert(std::make_pair((*lvi)->GetName(), *lvi));
333 const G4LogicalVolume* lv = nameMap[lvname];
334 int ibec = (lvname.find(
"EFRY") == std::string::npos) ? 0 : 1;
335 int iref = (lvname.find(
"refl") == std::string::npos) ? 0 : 1;
336 int type = (ibec+iref == 1) ? 1 : -1;
338 if (strncmp(lvname.c_str(),
depth1Name.c_str(), 4) == 0) {
342 edm::LogInfo(
"EcalSim") <<
"ECalSD::initMap Logical Volume " 343 << lvname <<
" in Depth 1 volume list";
346 const G4LogicalVolume* lvr = nameMap[lvname +
"_refl"];
350 edm::LogInfo(
"EcalSim") <<
"ECalSD::initMap Logical Volume " 352 <<
" in Depth 1 volume list";
358 if (strncmp(lvname.c_str(),
depth2Name.c_str(), 4) == 0) {
362 edm::LogInfo(
"EcalSim") <<
"ECalSD::initMap Logical Volume " 363 << lvname <<
" in Depth 2 volume list";
366 const G4LogicalVolume* lvr = nameMap[lvname +
"_refl"];
370 edm::LogInfo(
"EcalSim") <<
"ECalSD::initMap Logical Volume " 372 <<
" in Depth 2 volume list";
379 if (!
any(lvused,lv)) {
380 lvused.push_back(lv);
382 const std::vector<double> & paras = sol.
parameters();
384 edm::LogInfo(
"EcalSim") <<
"ECalSD::initMap (for " << sd
385 <<
"): Solid " << lvname <<
" Shape " 386 << sol.
shape() <<
" Parameter 0 = " 387 << paras[0] <<
" Logical Volume " << lv;
390 double dz = 2*paras[0];
391 xtalLMap.insert(std::pair<const G4LogicalVolume*,double>(lv,dz*type));
392 lv = nameMap[lvname +
"_refl"];
394 xtalLMap.insert(std::pair<const G4LogicalVolume*,double>(lv,-dz*type));
402 edm::LogInfo(
"EcalSim") <<
"ECalSD::initMap Logical Volume " 403 << lvname <<
" Material " << matname
404 <<
" in noWeight list";
407 lv = nameMap[lvname];
411 edm::LogInfo(
"EcalSim") <<
"ECalSD::initMap Logical Volume " 412 << lvname <<
" Material " << matname
413 <<
" in noWeight list";
421 edm::LogInfo(
"EcalSim") <<
"ECalSD: Length Table for " << attribute <<
" = " 425 G4String
name(
"Unknown");
426 if (ite.first != 0) name = (ite.first)->GetName();
427 edm::LogInfo(
"EcalSim") <<
" " << i <<
" " << ite.first <<
" " << name
428 <<
" L = " << ite.second;
448 edm::LogWarning(
"EcalSim") <<
"ECalSD: light coll curve : wrong distance " 449 <<
"to APD " << dapd <<
" crlength = " 452 <<
" take weight = " <<
weight;
461 const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
462 int theSize = touch->GetHistoryDepth()+1;
466 for (
int ii = 0;
ii < theSize ;
ii++) {
469 edm::LogInfo(
"EcalSim") <<
"ECalSD::getBaseNumber(): Adding level " <<
ii 470 <<
": " << touch->GetVolume(
ii)->GetName() <<
"[" 471 << touch->GetReplicaNumber(
ii) <<
"]";
480 const G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
481 double charge = preStepPoint->GetCharge();
483 if (charge != 0. && aStep->GetStepLength() > 0.) {
484 const G4Material* mat = preStepPoint->GetMaterial();
485 double density = mat->GetDensity();
486 double dedx = aStep->GetTotalEnergyDeposit()/aStep->GetStepLength();
487 double rkb =
birk1/density;
491 else if (weight > 1.) weight = 1.;
494 edm::LogInfo(
"EcalSim") <<
"ECalSD::getBirkL3 in " << mat->GetName()
495 <<
" Charge " << charge <<
" dE/dx " << dedx
496 <<
" Birk Const " << rkb <<
" Weight = " << weight
497 <<
" dE " << aStep->GetTotalEnergyDeposit();
514 const std::vector<double> & fvec = value.
doubles();
517 std::vector<double> fvec;
533 const std::vector<std::string> & fvec = value.
strings();
536 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 * > noWeight
void getBaseNumber(const G4Step *)
static const int kEcalDepthRefz
bool any(const std::vector< T > &v, const T &what)
std::vector< const G4LogicalVolume * > useDepth2
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)
Compact representation of the geometrical detector hierarchy.
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.
static TrackerG4SimHitNumberingScheme & numberingScheme(const DDCompactView &cpv, const GeometricDet &det)
double getBirkL3(const G4Step *)
int getTrackID(const G4Track *) override
void addLevel(const std::string &name, const int ©Number)
EcalBaseNumber theBaseNumber
bool next()
set current node to the next node in the filtered tree
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
std::maps an index to a DDValue. The index corresponds to the index assigned to the name of the std::...
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)
void initMap(const G4String &, const DDCompactView &)
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
std::map< const G4LogicalVolume *, double > xtalLMap
double getAttenuation(const G4Step *aStep, double birk1, double birk2, double birk3) const
std::vector< const G4LogicalVolume * > useDepth1
ECalSD(const std::string &, const DDCompactView &, const SensitiveDetectorCatalog &, edm::ParameterSet const &p, const SimTrackManager *)
bool firstChild()
set the current node to the first child ...
double curve_LY(const G4LogicalVolume *)
EcalNumberingScheme * numberingScheme
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.
uint16_t getDepth(const G4Step *) override