CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Private Member Functions | Private Attributes
ECalSD Class Reference

#include <ECalSD.h>

Inheritance diagram for ECalSD:
CaloSD SensitiveCaloDetector Observer< const BeginOfRun * > Observer< const BeginOfEvent * > Observer< const BeginOfTrack * > Observer< const EndOfTrack * > Observer< const EndOfEvent * > SensitiveDetector

Public Member Functions

 ECalSD (const std::string &, const DDCompactView &, const SensitiveDetectorCatalog &, edm::ParameterSet const &p, const SimTrackManager *)
 
uint32_t setDetUnitId (const G4Step *) override
 
void setNumberingScheme (EcalNumberingScheme *)
 
 ~ECalSD () override
 
- Public Member Functions inherited from CaloSD
 CaloSD (const std::string &aSDname, const DDCompactView &cpv, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p, const SimTrackManager *, float timeSlice=1., bool ignoreTkID=false)
 
void clear () override
 
void clearHits () override
 
void DrawAll () override
 
void EndOfEvent (G4HCofThisEvent *eventHC) override
 
void fillHits (edm::PCaloHitContainer &, const std::string &) override
 
void Initialize (G4HCofThisEvent *HCE) override
 
void PrintAll () override
 
G4bool ProcessHits (G4Step *step, G4TouchableHistory *) override
 
bool ProcessHits (G4GFlashSpot *aSpot, G4TouchableHistory *) override
 
 ~CaloSD () override
 
- Public Member Functions inherited from SensitiveCaloDetector
 SensitiveCaloDetector (const std::string &iname, const DDCompactView &cpv, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p)
 
- Public Member Functions inherited from SensitiveDetector
void EndOfEvent (G4HCofThisEvent *eventHC) override
 
const std::vector< std::string > & getNames () const
 
void Initialize (G4HCofThisEvent *eventHC) override
 
 SensitiveDetector (const std::string &iname, const DDCompactView &cpv, const SensitiveDetectorCatalog &, edm::ParameterSet const &p)
 
 ~SensitiveDetector () override
 
- Public Member Functions inherited from Observer< const BeginOfRun * >
 Observer ()
 
void slotForUpdate (const BeginOfRun * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const BeginOfEvent * >
 Observer ()
 
void slotForUpdate (const BeginOfEvent * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const BeginOfTrack * >
 Observer ()
 
void slotForUpdate (const BeginOfTrack * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const EndOfTrack * >
 Observer ()
 
void slotForUpdate (const EndOfTrack * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const EndOfEvent * >
 Observer ()
 
void slotForUpdate (const EndOfEvent * iT)
 
virtual ~Observer ()
 

Protected Member Functions

uint16_t getDepth (const G4Step *) override
 
double getEnergyDeposit (const G4Step *) override
 
int getTrackID (const G4Track *) override
 
- Protected Member Functions inherited from CaloSD
bool checkHit ()
 
CaloG4HitcreateNewHit (const G4Step *)
 
virtual bool filterHit (CaloG4Hit *, double)
 
double getAttenuation (const G4Step *aStep, double birk1, double birk2, double birk3) const
 
virtual bool getFromLibrary (const G4Step *step)
 
int getNumberOfHits ()
 
double getResponseWt (const G4Track *)
 
bool hitExists (const G4Step *)
 
virtual void initRun ()
 
void processHit (const G4Step *step)
 
void resetForNewPrimary (const G4Step *)
 
void setNumberCheckedHits (int val)
 
void setParameterized (bool val)
 
G4ThreeVector setToGlobal (const G4ThreeVector &, const G4VTouchable *) const
 
G4ThreeVector setToLocal (const G4ThreeVector &, const G4VTouchable *) const
 
virtual int setTrackID (const G4Step *)
 
void setUseMap (bool val)
 
void update (const BeginOfRun *) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const BeginOfEvent *) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const BeginOfTrack *trk) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const EndOfTrack *trk) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const ::EndOfEvent *) override
 
void updateHit (CaloG4Hit *)
 
- Protected Member Functions inherited from SensitiveDetector
TrackInformationcmsTrackInformation (const G4Track *aTrack)
 
Local3DPoint ConvertToLocal3DPoint (const G4ThreeVector &point) const
 
Local3DPoint FinalStepPosition (const G4Step *step, coordinates) const
 
Local3DPoint InitialStepPosition (const G4Step *step, coordinates) const
 
Local3DPoint LocalPostStepPosition (const G4Step *step) const
 
Local3DPoint LocalPreStepPosition (const G4Step *step) const
 
void NaNTrap (const G4Step *step) const
 
void setNames (const std::vector< std::string > &)
 
- Protected Member Functions inherited from Observer< const EndOfEvent * >
virtual void update (const EndOfEvent *)=0
 This routine will be called when the appropriate signal arrives. More...
 

Private Member Functions

double curve_LY (const G4LogicalVolume *)
 
void getBaseNumber (const G4Step *)
 
double getBirkL3 (const G4Step *)
 
std::vector< double > getDDDArray (const std::string &, const DDsvalues_type &)
 
uint16_t getLayerIDForTimeSim ()
 
uint16_t getRadiationLength (const G4StepPoint *hitPoint, const G4LogicalVolume *lv)
 
std::vector< std::string > getStringArray (const std::string &, const DDsvalues_type &)
 
void initMap (const G4String &, const DDCompactView &)
 

Private Attributes

EnergyResolutionVsLumi ageing
 
bool ageingWithSlopeLY
 
double birk1
 
double birk2
 
double birk3
 
double birkCut
 
double birkSlope
 
double crystalDepth
 
double crystalLength
 
std::string crystalMat
 
G4ThreeVector currentLocalPoint
 
uint16_t depth
 
std::string depth1Name
 
std::string depth2Name
 
bool isEB
 
bool isEE
 
std::vector< const G4LogicalVolume * > noWeight
 
EcalNumberingSchemenumberingScheme
 
double scaleRL
 
double slopeLY
 
bool storeLayerTimeSim
 
bool storeRL
 
bool storeTrack
 
EcalBaseNumber theBaseNumber
 
bool useBirk
 
bool useBirkL3
 
std::vector< const G4LogicalVolume * > useDepth1
 
std::vector< const G4LogicalVolume * > useDepth2
 
bool useWeight
 
std::map< const G4LogicalVolume *, double > xtalLMap
 

Additional Inherited Members

- Protected Types inherited from SensitiveDetector
enum  coordinates { WorldCoordinates, LocalCoordinates }
 
- Protected Attributes inherited from CaloSD
CaloG4HitcurrentHit
 
CaloHitID currentID
 
float edepositEM
 
float edepositHAD
 
double eminHit
 
double energyCut
 
G4ThreeVector entranceLocal
 
G4ThreeVector entrancePoint
 
bool forceSave
 
float incidentEnergy
 
double kmaxIon
 
double kmaxNeutron
 
double kmaxProton
 
G4ThreeVector posGlobal
 
CaloHitID previousID
 
bool suppressHeavy
 
double tmaxHit
 

Detailed Description

Definition at line 30 of file ECalSD.h.

Constructor & Destructor Documentation

ECalSD::ECalSD ( const std::string &  name,
const DDCompactView cpv,
const SensitiveDetectorCatalog clg,
edm::ParameterSet const &  p,
const SimTrackManager manager 
)

Definition at line 41 of file ECalSD.cc.

References ageing, ageingWithSlopeLY, birk1, birk2, birk3, birkCut, birkSlope, crystalMat, depth1Name, depth2Name, ALCARECOTkAlBeamHalo_cff::filter, DDFilteredView::firstChild(), g, getDDDArray(), edm::ParameterSet::getParameter(), getStringArray(), edm::ParameterSet::getUntrackedParameter(), initMap(), edm::Service< T >::isAvailable(), isEB, isEE, gen::k, CaloSD::kmaxIon, CaloSD::kmaxNeutron, CaloSD::kmaxProton, TFileDirectory::make(), DDFilteredView::mergedSpecifics(), MeV, TFileService::mkdir(), scaleRL, EnergyResolutionVsLumi::setLumies(), setNumberingScheme(), slopeLY, storeLayerTimeSim, storeRL, storeTrack, AlCaHLTBitMon_QueryRunRegistry::string, CaloSD::suppressHeavy, pfDeepBoostedJetPreprocessParams_cfi::sv, compare::tfile, fftjetcommon_cfi::title, useBirk, useBirkL3, useWeight, and TrackerOfflineValidation_Dqm_cff::xmin.

43  :
44  CaloSD(name, cpv, clg, p, manager,
45  (float)(p.getParameter<edm::ParameterSet>("ECalSD").getParameter<double>("TimeSliceUnit")),
46  p.getParameter<edm::ParameterSet>("ECalSD").getParameter<bool>("IgnoreTrackID")),
47  numberingScheme(nullptr){
48 
49  // static SimpleConfigurable<bool> on1(false, "ECalSD:UseBirkLaw");
50  // static SimpleConfigurable<double> bk1(0.00463,"ECalSD:BirkC1");
51  // static SimpleConfigurable<double> bk2(-0.03, "ECalSD:BirkC2");
52  // static SimpleConfigurable<double> bk3(1.0, "ECalSD:BirkC3");
53  // Values from NIM A484 (2002) 239-244: as implemented in Geant3
54  // useBirk = on1.value();
55  // birk1 = bk1.value()*(g/(MeV*cm2));
56  // birk2 = bk2.value()*(g/(MeV*cm2))*(g/(MeV*cm2));
57 
58  edm::ParameterSet m_EC = p.getParameter<edm::ParameterSet>("ECalSD");
59  useBirk = m_EC.getParameter<bool>("UseBirkLaw");
60  useBirkL3 = m_EC.getParameter<bool>("BirkL3Parametrization");
61  birk1 = m_EC.getParameter<double>("BirkC1")*(g/(MeV*cm2));
62  birk2 = m_EC.getParameter<double>("BirkC2");
63  birk3 = m_EC.getParameter<double>("BirkC3");
64  birkSlope = m_EC.getParameter<double>("BirkSlope");
65  birkCut = m_EC.getParameter<double>("BirkCut");
66  slopeLY = m_EC.getParameter<double>("SlopeLightYield");
67  storeTrack = m_EC.getParameter<bool>("StoreSecondary");
68  crystalMat = m_EC.getUntrackedParameter<std::string>("XtalMat","E_PbWO4");
69  bool isItTB = m_EC.getUntrackedParameter<bool>("TestBeam", false);
70  bool nullNS = m_EC.getUntrackedParameter<bool>("NullNumbering", false);
71  storeRL = m_EC.getUntrackedParameter<bool>("StoreRadLength", false);
72  scaleRL = m_EC.getUntrackedParameter<double>("ScaleRadLength",1.0);
73 
74  //Changes for improved timing simulation
75  storeLayerTimeSim = m_EC.getUntrackedParameter<bool>("StoreLayerTimeSim", false);
76 
77  ageingWithSlopeLY = m_EC.getUntrackedParameter<bool>("AgeingWithSlopeLY", false);
78  if(ageingWithSlopeLY) ageing.setLumies(p.getParameter<edm::ParameterSet>("ECalSD").getParameter<double>("DelivLuminosity"),
79  p.getParameter<edm::ParameterSet>("ECalSD").getParameter<double>("InstLuminosity"));
80 
81  //Material list for HB/HE/HO sensitive detectors
82  std::string attribute = "ReadOutName";
84  DDFilteredView fv(cpv,filter);
85  fv.firstChild();
86  DDsvalues_type sv(fv.mergedSpecifics());
87  // Use of Weight
88  useWeight= true;
89  std::vector<double> tempD = getDDDArray("EnergyWeight",sv);
90  if (!tempD.empty()) { if (tempD[0] < 0.1) useWeight = false; }
91 #ifdef EDM_ML_DEBUG
92  edm::LogInfo("EcalSim") << "ECalSD:: useWeight " << tempD.size() << ":"
93  << useWeight << std::endl;
94 #endif
95  std::vector<std::string> tempS = getStringArray("Depth1Name",sv);
96  if (!tempS.empty()) depth1Name = tempS[0];
97  else depth1Name = " ";
98  tempS = getStringArray("Depth2Name",sv);
99  if (!tempS.empty()) depth2Name = tempS[0];
100  else depth2Name = " ";
101 #ifdef EDM_ML_DEBUG
102  edm::LogInfo("EcalSim") << "Names (Depth 1):" << depth1Name << " (Depth 2):"
103  << depth2Name << std::endl;
104 #endif
105  EcalNumberingScheme* scheme=nullptr;
106  if (nullNS) {
107  scheme = nullptr;
108  } else if (name == "EcalHitsEB") {
109  scheme = dynamic_cast<EcalNumberingScheme*>(new EcalBarrelNumberingScheme());
110  isEB=true;
111  } else if (name == "EcalHitsEE") {
112  scheme = dynamic_cast<EcalNumberingScheme*>(new EcalEndcapNumberingScheme());
113  isEE=true;
114  } else if (name == "EcalHitsES") {
115  if (isItTB) scheme = dynamic_cast<EcalNumberingScheme*>(new ESTBNumberingScheme());
116  else scheme = dynamic_cast<EcalNumberingScheme*>(new EcalPreshowerNumberingScheme());
117  useWeight = false;
118  } else {
119  edm::LogWarning("EcalSim") << "ECalSD: ReadoutName not supported";
120  }
121 
122  if (scheme) setNumberingScheme(scheme);
123 #ifdef EDM_ML_DEBUG
124  edm::LogInfo("EcalSim") << "Constructing a ECalSD with name " << GetName();
125 #endif
126  if (useWeight) {
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 "
134  << slopeLY;
135  } else {
136  edm::LogInfo("EcalSim") << "ECalSD:: energy deposit is not corrected "
137  << " by Birk or light yield curve";
138  }
139 
140  edm::LogInfo("EcalSim") << "ECalSD:: Suppression Flag " << suppressHeavy
141  << "\tprotons below " << kmaxProton << " MeV,"
142  << "\tneutrons below " << kmaxNeutron << " MeV"
143  << "\tions below " << kmaxIon << " MeV"
144  << "\n\tDepth1 Name = " << depth1Name
145  << "\tDepth2 Name = " << depth2Name
146  << "\n\tstoreRL" << storeRL << ":" << scaleRL
147  << "\tstoreLayerTimeSim " << storeLayerTimeSim
148  << "\n\ttime Granularity "
149  << p.getParameter<edm::ParameterSet>("ECalSD").getParameter<double>("TimeSliceUnit")
150  << " ns";
151  if (useWeight) initMap(name,cpv);
152 #ifdef plotDebug
154  if ( tfile.isAvailable() ) {
155  TFileDirectory ecDir = tfile->mkdir("ProfileFromECalSD");
156  static const std::string ctype[4] = {"EB","EBref","EE","EERef"};
157  for (int k=0; k<4; ++k) {
158  std::string name = "ECLL_"+ctype[k];
159  std::string title= "Local vs Global for "+ctype[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.);
163  }
164  } else {
165  for (int k=0; k<4; ++k) g2L_[k] = 0;
166  }
167 #endif
168 
169 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
bool useBirkL3
Definition: ECalSD.h:67
double kmaxNeutron
Definition: CaloSD.h:137
std::vector< std::string > getStringArray(const std::string &, const DDsvalues_type &)
Definition: ECalSD.cc:522
double birkSlope
Definition: ECalSD.h:68
double slopeLY
Definition: ECalSD.h:69
void setLumies(double x, double y)
double birk1
Definition: ECalSD.h:68
bool useWeight
Definition: ECalSD.h:66
double kmaxProton
Definition: CaloSD.h:137
bool storeLayerTimeSim
Definition: ECalSD.h:66
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
Definition: Activities.doc:4
bool storeRL
Definition: ECalSD.h:66
const double MeV
std::string depth1Name
Definition: ECalSD.h:70
bool storeTrack
Definition: ECalSD.h:66
double kmaxIon
Definition: CaloSD.h:137
bool suppressHeavy
Definition: CaloSD.h:136
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::...
Definition: DDsvalues.h:20
double scaleRL
Definition: ECalSD.h:69
bool isAvailable() const
Definition: Service.h:46
T * make(const Args &...args) const
make new ROOT object
CaloSD(const std::string &aSDname, const DDCompactView &cpv, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p, const SimTrackManager *, float timeSlice=1., bool ignoreTkID=false)
Definition: CaloSD.cc:28
int k[5][pyjets_maxn]
std::string depth2Name
Definition: ECalSD.h:70
void initMap(const G4String &, const DDCompactView &)
Definition: ECalSD.cc:315
bool ageingWithSlopeLY
Definition: ECalSD.h:75
bool useBirk
Definition: ECalSD.h:67
bool isEE
Definition: ECalSD.h:64
TFileDirectory mkdir(const std::string &dir, const std::string &descr="")
create a new subdirectory
Definition: TFileService.h:69
std::vector< double > getDDDArray(const std::string &, const DDsvalues_type &)
Definition: ECalSD.cc:503
bool isEB
Definition: ECalSD.h:63
double birk2
Definition: ECalSD.h:68
EcalNumberingScheme * numberingScheme
Definition: ECalSD.h:65
EnergyResolutionVsLumi ageing
Definition: ECalSD.h:74
void setNumberingScheme(EcalNumberingScheme *)
Definition: ECalSD.cc:306
double birkCut
Definition: ECalSD.h:68
std::string crystalMat
Definition: ECalSD.h:70
double birk3
Definition: ECalSD.h:68
ECalSD::~ECalSD ( )
override

Definition at line 171 of file ECalSD.cc.

References numberingScheme.

171  {
172  delete numberingScheme;
173 }
EcalNumberingScheme * numberingScheme
Definition: ECalSD.h:65

Member Function Documentation

double ECalSD::curve_LY ( const G4LogicalVolume *  lv)
private

Definition at line 434 of file ECalSD.cc.

References ageing, ageingWithSlopeLY, EnergyResolutionVsLumi::calcLightCollectionEfficiencyWeighted(), crystalDepth, crystalLength, CaloSD::currentID, currentLocalPoint, slopeLY, CaloHitID::unitID(), and mps_merge::weight.

Referenced by getEnergyDeposit().

434  {
435 
436  double weight = 1.;
437  if (ageingWithSlopeLY) {
438  //position along the crystal in mm from 0 to 230 (in EB)
439  if (crystalDepth >= -0.1 || crystalDepth <= crystalLength+0.1)
442  } else {
443  double dapd = crystalLength - crystalDepth;
444  if (dapd >= -0.1 || dapd <= crystalLength+0.1) {
445  if (dapd <= 100.)
446  weight = 1.0 + slopeLY - dapd * 0.01 * slopeLY;
447  } else {
448  edm::LogWarning("EcalSim") << "ECalSD: light coll curve : wrong distance "
449  << "to APD " << dapd << " crlength = "
450  << crystalLength <<" crystal name = " <<lv->GetName()
451  << " z of localPoint = " << currentLocalPoint.z()
452  << " take weight = " << weight;
453  }
454  }
455  return weight;
456 }
double crystalLength
Definition: ECalSD.h:79
double slopeLY
Definition: ECalSD.h:69
Definition: weight.py:1
double crystalDepth
Definition: ECalSD.h:80
G4ThreeVector currentLocalPoint
Definition: ECalSD.h:78
bool ageingWithSlopeLY
Definition: ECalSD.h:75
CaloHitID currentID
Definition: CaloSD.h:130
double calcLightCollectionEfficiencyWeighted(DetId id, double z)
EnergyResolutionVsLumi ageing
Definition: ECalSD.h:74
uint32_t unitID() const
Definition: CaloHitID.h:22
void ECalSD::getBaseNumber ( const G4Step *  aStep)
private

Definition at line 458 of file ECalSD.cc.

References EcalBaseNumber::addLevel(), EcalBaseNumber::getCapacity(), cuy::ii, EcalBaseNumber::reset(), EcalBaseNumber::setSize(), and theBaseNumber.

Referenced by setDetUnitId().

458  {
459 
461  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
462  int theSize = touch->GetHistoryDepth()+1;
463  if ( theBaseNumber.getCapacity() < theSize ) theBaseNumber.setSize(theSize);
464  //Get name and copy numbers
465  if ( theSize > 1 ) {
466  for (int ii = 0; ii < theSize ; ii++) {
467  theBaseNumber.addLevel(touch->GetVolume(ii)->GetName(),touch->GetReplicaNumber(ii));
468 #ifdef EDM_ML_DEBUG
469  edm::LogInfo("EcalSim") << "ECalSD::getBaseNumber(): Adding level " << ii
470  << ": " << touch->GetVolume(ii)->GetName() << "["
471  << touch->GetReplicaNumber(ii) << "]";
472 #endif
473  }
474  }
475 }
void addLevel(const std::string &name, const int &copyNumber)
EcalBaseNumber theBaseNumber
Definition: ECalSD.h:73
ii
Definition: cuy.py:589
void setSize(const int &size)
double ECalSD::getBirkL3 ( const G4Step *  aStep)
private

Definition at line 477 of file ECalSD.cc.

References birk1, birkCut, birkSlope, ALCARECOTkAlJpsiMuMu_cff::charge, cmsBatch::log, and mps_merge::weight.

Referenced by getEnergyDeposit().

477  {
478 
479  double weight = 1.;
480  const G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
481  double charge = preStepPoint->GetCharge();
482 
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;
488  if (dedx > 0) {
489  weight = 1. - birkSlope*log(rkb*dedx);
490  if (weight < birkCut) weight = birkCut;
491  else if (weight > 1.) weight = 1.;
492  }
493 #ifdef EDM_ML_DEBUG
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();
498 #endif
499  }
500  return weight;
501 }
double birkSlope
Definition: ECalSD.h:68
double birk1
Definition: ECalSD.h:68
Definition: weight.py:1
double birkCut
Definition: ECalSD.h:68
std::vector< double > ECalSD::getDDDArray ( const std::string &  str,
const DDsvalues_type sv 
)
private

Definition at line 503 of file ECalSD.cc.

References DDfetch(), DDValue::doubles(), str, and relativeConstraints::value.

Referenced by ECalSD().

504  {
505 
506 #ifdef EDM_ML_DEBUG
507  edm::LogInfo("EcalSim") << "ECalSD:getDDDArray called for " << str;
508 #endif
509  DDValue value(str);
510  if (DDfetch(&sv,value)) {
511 #ifdef EDM_ML_DEBUG
512  edm::LogInfo("EcalSim") << value;
513 #endif
514  const std::vector<double> & fvec = value.doubles();
515  return fvec;
516  } else {
517  std::vector<double> fvec;
518  return fvec;
519  }
520 }
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:81
Definition: value.py:1
#define str(s)
uint16_t ECalSD::getDepth ( const G4Step *  aStep)
overrideprotectedvirtual

Reimplemented from CaloSD.

Definition at line 230 of file ECalSD.cc.

References funct::abs(), any(), crystalDepth, crystalLength, currentLocalPoint, TauDecayModes::dec, depth, getLayerIDForTimeSim(), getRadiationLength(), PCaloHit::kEcalDepthMask, PCaloHit::kEcalDepthOffset, PCaloHit::kEcalDepthRefz, CaloSD::setToLocal(), storeLayerTimeSim, storeRL, useDepth1, useDepth2, and xtalLMap.

230  {
231 
232  // this method should be called first at a step
233  const G4StepPoint* hitPoint = aStep->GetPreStepPoint();
234  currentLocalPoint = setToLocal(hitPoint->GetPosition(), hitPoint->GetTouchable());
235  const G4LogicalVolume* lv = hitPoint->GetTouchable()->GetVolume(0)->GetLogicalVolume();
236 
237  auto ite = xtalLMap.find(lv);
238  crystalLength = (ite == xtalLMap.end()) ? 230.0 : std::abs(ite->second);
239  crystalDepth = (ite == xtalLMap.end())
240  ? 0.0 : (std::abs(0.5*(ite->second)+currentLocalPoint.z()));
241  depth = any(useDepth1,lv) ? 1 : (any(useDepth2,lv) ? 2 : 0);
242 
243  if (storeRL) {
244  uint16_t depth1 = (ite == xtalLMap.end()) ? 0 : (((ite->second) >= 0) ? 0 :
246  uint16_t depth2 = getRadiationLength(hitPoint, lv);
247  depth |= (((depth2&PCaloHit::kEcalDepthMask) << PCaloHit::kEcalDepthOffset) | depth1);
248  } else if (storeLayerTimeSim) {
249  uint16_t depth2 = getLayerIDForTimeSim();
251  }
252 #ifdef EDM_ML_DEBUG
253  edm::LogVerbatim("EcalSim") << "ECalSD::Depth " << std::hex << depth1 << ":"
254  << depth2 << ":" << depth << std::dec << " L "
255  << (ite == xtalLMap.end()) << ":" <<ite->second;
256 #endif
257  return depth;
258 }
double crystalLength
Definition: ECalSD.h:79
static const int kEcalDepthRefz
Definition: PCaloHit.h:70
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:37
std::vector< const G4LogicalVolume * > useDepth2
Definition: ECalSD.h:72
double crystalDepth
Definition: ECalSD.h:80
bool storeLayerTimeSim
Definition: ECalSD.h:66
bool storeRL
Definition: ECalSD.h:66
static const int kEcalDepthMask
Definition: PCaloHit.h:68
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
uint16_t getLayerIDForTimeSim()
Definition: ECalSD.cc:291
static const int kEcalDepthOffset
Definition: PCaloHit.h:69
G4ThreeVector setToLocal(const G4ThreeVector &, const G4VTouchable *) const
Definition: CaloSD.cc:307
G4ThreeVector currentLocalPoint
Definition: ECalSD.h:78
uint16_t getRadiationLength(const G4StepPoint *hitPoint, const G4LogicalVolume *lv)
Definition: ECalSD.cc:260
std::map< const G4LogicalVolume *, double > xtalLMap
Definition: ECalSD.h:71
std::vector< const G4LogicalVolume * > useDepth1
Definition: ECalSD.h:72
uint16_t depth
Definition: ECalSD.h:81
double ECalSD::getEnergyDeposit ( const G4Step *  aStep)
overrideprotectedvirtual

Reimplemented from CaloSD.

Definition at line 175 of file ECalSD.cc.

References any(), birk1, birk2, birk3, curve_LY(), CaloSD::getAttenuation(), getBirkL3(), CaloSD::getResponseWt(), TrackInformation::isPrimary(), ke, CaloSD::kmaxIon, CaloSD::kmaxNeutron, CaloSD::kmaxProton, MeV, noWeight, CaloSD::suppressHeavy, useBirk, useBirkL3, and useWeight.

175  {
176 
177  const G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
178  const G4Track* theTrack = aStep->GetTrack();
179  double edep = aStep->GetTotalEnergyDeposit();
180 
181  // take into account light collection curve for crystals
182  double weight = 1.;
183  if (suppressHeavy) {
184  TrackInformation * trkInfo = (TrackInformation *)(theTrack->GetUserInformation());
185  if (trkInfo) {
186  int pdg = theTrack->GetDefinition()->GetPDGEncoding();
187  if (!(trkInfo->isPrimary())) { // Only secondary particles
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;
193  }
194  }
195  }
196  const G4LogicalVolume* lv = preStepPoint->GetTouchable()->GetVolume(0)->GetLogicalVolume();
197  double wt1 = 1.0;
198  if (useWeight && !any(noWeight,lv)) {
199  weight *= curve_LY(lv);
200  if (useBirk) {
201  if (useBirkL3) weight *= getBirkL3(aStep);
202  else weight *= getAttenuation(aStep, birk1, birk2, birk3);
203  }
204  wt1 = getResponseWt(theTrack);
205  }
206  edep *= weight*wt1;
207  // Russian Roulette
208  double wt2 = theTrack->GetWeight();
209  if(wt2 > 0.0) { edep *= wt2; }
210 #ifdef EDM_ML_DEBUG
211  edm::LogInfo("EcalSim") << lv->GetName()
212  << " Light Collection Efficiency " << weight << ":"
213  << wt1 << " wt2= " << wt2
214  << " Weighted Energy Deposit " << edep/MeV << " MeV";
215 #endif
216  return edep;
217 }
bool useBirkL3
Definition: ECalSD.h:67
double kmaxNeutron
Definition: CaloSD.h:137
std::vector< const G4LogicalVolume * > noWeight
Definition: ECalSD.h:72
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:37
double birk1
Definition: ECalSD.h:68
bool useWeight
Definition: ECalSD.h:66
Definition: weight.py:1
double kmaxProton
Definition: CaloSD.h:137
double getBirkL3(const G4Step *)
Definition: ECalSD.cc:477
const double MeV
double kmaxIon
Definition: CaloSD.h:137
bool suppressHeavy
Definition: CaloSD.h:136
bool useBirk
Definition: ECalSD.h:67
int ke
bool isPrimary() const
double getAttenuation(const G4Step *aStep, double birk1, double birk2, double birk3) const
Definition: CaloSD.cc:462
double birk2
Definition: ECalSD.h:68
double curve_LY(const G4LogicalVolume *)
Definition: ECalSD.cc:434
double getResponseWt(const G4Track *)
Definition: CaloSD.cc:646
double birk3
Definition: ECalSD.h:68
uint16_t ECalSD::getLayerIDForTimeSim ( )
private

Definition at line 291 of file ECalSD.cc.

References crystalDepth.

Referenced by getDepth(), and getRadiationLength().

292 {
293  const double invLayerSize = 0.1; //layer size in 1/mm
294  return (int)crystalDepth*invLayerSize;
295 }
double crystalDepth
Definition: ECalSD.h:80
uint16_t ECalSD::getRadiationLength ( const G4StepPoint *  hitPoint,
const G4LogicalVolume *  lv 
)
private

Definition at line 260 of file ECalSD.cc.

References funct::abs(), crystalDepth, getLayerIDForTimeSim(), GetRecoTauVFromDQM_MC_cff::kk, rho, scaleRL, AlCaHLTBitMon_QueryRunRegistry::string, useWeight, and z.

Referenced by getDepth().

260  {
261 
262  uint16_t thisX0 = 0;
263  if (useWeight) {
264  double radl = hitPoint->GetMaterial()->GetRadlen();
265  thisX0 = (uint16_t)floor(scaleRL*crystalDepth/radl);
266 #ifdef plotDebug
267  const std::string& lvname = lv->GetName();
268  int k1 = (lvname.find("EFRY")!=std::string::npos) ? 2 : 0;
269  int k2 = (lvname.find("refl")!=std::string::npos) ? 1 : 0;
270  int kk = k1+k2;
271  double rz = (k1 == 0) ? (hitPoint->GetPosition()).rho() :
272  std::abs((hitPoint->GetPosition()).z());
273  edm::LogVerbatim("EcalSim") << lvname << " # " << k1 << ":" << k2 << ":"
274  << kk << " rz " << rz << " D " << thisX0;
275  g2L_[kk]->Fill(rz,thisX0);
276 #endif
277 #ifdef EDM_ML_DEBUG
278  edm::LogVerbatim("EcalSim") << lv->GetName() << " Global "
279  << hitPoint->GetPosition() << ":"
280  << (hitPoint->GetPosition()).rho()
281  << " Local " << localPoint
282  << " Crystal Length " << crlength
283  << " Radl " << radl << " DetZ " << detz
284  << " Index " << thisX0
285  << " : " << getLayerIDForTimeSim();
286 #endif
287  }
288  return thisX0;
289 }
bool useWeight
Definition: ECalSD.h:66
double crystalDepth
Definition: ECalSD.h:80
double scaleRL
Definition: ECalSD.h:69
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
uint16_t getLayerIDForTimeSim()
Definition: ECalSD.cc:291
std::vector< std::string > ECalSD::getStringArray ( const std::string &  str,
const DDsvalues_type sv 
)
private

Definition at line 522 of file ECalSD.cc.

References DDfetch(), str, DDValue::strings(), and relativeConstraints::value.

Referenced by ECalSD().

523  {
524 
525 #ifdef EDM_ML_DEBUG
526  edm::LogInfo("EcalSim") << "ECalSD:getStringArray called for " << str;
527 #endif
528  DDValue value(str);
529  if (DDfetch(&sv,value)) {
530 #ifdef EDM_ML_DEBUG
531  edm::LogInfo("EcalSim") << value;
532 #endif
533  const std::vector<std::string> & fvec = value.strings();
534  return fvec;
535  } else {
536  std::vector<std::string> fvec;
537  return fvec;
538  }
539 }
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
Definition: DDsvalues.cc:81
Definition: value.py:1
#define str(s)
int ECalSD::getTrackID ( const G4Track *  aTrack)
overrideprotectedvirtual

Reimplemented from CaloSD.

Definition at line 219 of file ECalSD.cc.

References depth, CaloSD::forceSave, CaloSD::getTrackID(), and storeTrack.

219  {
220  int primaryID(0);
221  if (storeTrack && depth > 0) {
222  forceSave = true;
223  primaryID = aTrack->GetTrackID();
224  } else {
225  primaryID = CaloSD::getTrackID(aTrack);
226  }
227  return primaryID;
228 }
virtual int getTrackID(const G4Track *)
Definition: CaloSD.cc:593
bool forceSave
Definition: CaloSD.h:139
bool storeTrack
Definition: ECalSD.h:66
uint16_t depth
Definition: ECalSD.h:81
void ECalSD::initMap ( const G4String &  sd,
const DDCompactView cpv 
)
private

Definition at line 315 of file ECalSD.cc.

References any(), crystalMat, ddtrap, depth1Name, depth2Name, PVValHelper::dz, ALCARECOTkAlBeamHalo_cff::filter, DDFilteredView::firstChild(), mps_fire::i, DDFilteredView::logicalPart(), DDLogicalPart::material(), DDName::name(), dataset::name, DDBase< N, C >::name(), DDFilteredView::next(), noWeight, DDSolid::parameters(), DDSolid::shape(), DDLogicalPart::solid(), AlCaHLTBitMon_QueryRunRegistry::string, useDepth1, useDepth2, and xtalLMap.

Referenced by ECalSD().

315  {
316 
317  G4String attribute = "ReadOutName";
319  DDFilteredView fv(cpv,filter);
320  fv.firstChild();
321 
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));
328 
329  bool dodet=true;
330  while (dodet) {
331  const std::string &matname = fv.logicalPart().material().name().name();
332  const std::string &lvname = fv.logicalPart().name().name();
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;
337  if (depth1Name != " ") {
338  if (strncmp(lvname.c_str(), depth1Name.c_str(), 4) == 0) {
339  if (!any(useDepth1, lv)) {
340  useDepth1.push_back(lv);
341 #ifdef EDM_ML_DEBUG
342  edm::LogInfo("EcalSim") << "ECalSD::initMap Logical Volume "
343  << lvname <<" in Depth 1 volume list";
344 #endif
345  }
346  const G4LogicalVolume* lvr = nameMap[lvname + "_refl"];
347  if (lvr != nullptr && !any(useDepth1, lvr)) {
348  useDepth1.push_back(lvr);
349 #ifdef EDM_ML_DEBUG
350  edm::LogInfo("EcalSim") << "ECalSD::initMap Logical Volume "
351  << lvname << "_refl"
352  <<" in Depth 1 volume list";
353 #endif
354  }
355  }
356  }
357  if (depth2Name != " ") {
358  if (strncmp(lvname.c_str(), depth2Name.c_str(), 4) == 0) {
359  if (!any(useDepth2, lv)) {
360  useDepth2.push_back(lv);
361 #ifdef EDM_ML_DEBUG
362  edm::LogInfo("EcalSim") << "ECalSD::initMap Logical Volume "
363  << lvname <<" in Depth 2 volume list";
364 #endif
365  }
366  const G4LogicalVolume* lvr = nameMap[lvname + "_refl"];
367  if (lvr != nullptr && !any(useDepth2,lvr)) {
368  useDepth2.push_back(lvr);
369 #ifdef EDM_ML_DEBUG
370  edm::LogInfo("EcalSim") << "ECalSD::initMap Logical Volume "
371  << lvname << "_refl"
372  <<" in Depth 2 volume list";
373 #endif
374  }
375  }
376  }
377  if (lv != nullptr) {
378  if (crystalMat.size() == matname.size() && !strcmp(crystalMat.c_str(), matname.c_str())) {
379  if (!any(lvused,lv)) {
380  lvused.push_back(lv);
381  const DDSolid & sol = fv.logicalPart().solid();
382  const std::vector<double> & paras = sol.parameters();
383 #ifdef EDM_ML_DEBUG
384  edm::LogInfo("EcalSim") << "ECalSD::initMap (for " << sd
385  << "): Solid " << lvname << " Shape "
386  << sol.shape() << " Parameter 0 = "
387  << paras[0] << " Logical Volume " << lv;
388 #endif
389  if (sol.shape() == DDSolidShape::ddtrap) {
390  double dz = 2*paras[0];
391  xtalLMap.insert(std::pair<const G4LogicalVolume*,double>(lv,dz*type));
392  lv = nameMap[lvname + "_refl"];
393  if (lv != nullptr) {
394  xtalLMap.insert(std::pair<const G4LogicalVolume*,double>(lv,-dz*type));
395  }
396  }
397  }
398  } else {
399  if (!any(noWeight,lv)) {
400  noWeight.push_back(lv);
401 #ifdef EDM_ML_DEBUG
402  edm::LogInfo("EcalSim") << "ECalSD::initMap Logical Volume "
403  << lvname << " Material " << matname
404  << " in noWeight list";
405 #endif
406  }
407  lv = nameMap[lvname];
408  if (lv != nullptr && !any(noWeight,lv)) {
409  noWeight.push_back(lv);
410 #ifdef EDM_ML_DEBUG
411  edm::LogInfo("EcalSim") << "ECalSD::initMap Logical Volume "
412  << lvname << " Material " << matname
413  << " in noWeight list";
414 #endif
415  }
416  }
417  }
418  dodet = fv.next();
419  }
420 #ifdef EDM_ML_DEBUG
421  edm::LogInfo("EcalSim") << "ECalSD: Length Table for " << attribute << " = "
422  << sd << ":";
423  int i=0;
424  for (auto ite : xtalLMap) {
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;
429  ++i;
430  }
431 #endif
432 }
type
Definition: HCALResponse.h:21
const std::vector< double > & parameters(void) const
Give the parameters of the solid.
Definition: DDSolid.cc:144
std::vector< const G4LogicalVolume * > noWeight
Definition: ECalSD.h:72
bool any(const std::vector< T > &v, const T &what)
Definition: ECalSD.cc:37
std::vector< const G4LogicalVolume * > useDepth2
Definition: ECalSD.h:72
A DDSolid represents the shape of a part.
Definition: DDSolid.h:38
std::string depth1Name
Definition: ECalSD.h:70
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:138
std::string depth2Name
Definition: ECalSD.h:70
double sd
std::map< const G4LogicalVolume *, double > xtalLMap
Definition: ECalSD.h:71
std::vector< const G4LogicalVolume * > useDepth1
Definition: ECalSD.h:72
std::string crystalMat
Definition: ECalSD.h:70
uint32_t ECalSD::setDetUnitId ( const G4Step *  aStep)
overridevirtual

Implements CaloSD.

Definition at line 297 of file ECalSD.cc.

References getBaseNumber(), EcalNumberingScheme::getUnitID(), numberingScheme, and theBaseNumber.

297  {
298  if (numberingScheme == nullptr) {
299  return EBDetId(1,1)();
300  } else {
301  getBaseNumber(aStep);
303  }
304 }
void getBaseNumber(const G4Step *)
Definition: ECalSD.cc:458
EcalBaseNumber theBaseNumber
Definition: ECalSD.h:73
virtual uint32_t getUnitID(const EcalBaseNumber &baseNumber) const =0
EcalNumberingScheme * numberingScheme
Definition: ECalSD.h:65
void ECalSD::setNumberingScheme ( EcalNumberingScheme scheme)

Definition at line 306 of file ECalSD.cc.

References numberingScheme.

Referenced by ECalSD(), and HcalTB04Analysis::update().

306  {
307  if (scheme != nullptr) {
308  edm::LogInfo("EcalSim") << "EcalSD: updates numbering scheme for "
309  << GetName();
310  if (numberingScheme) delete numberingScheme;
311  numberingScheme = scheme;
312  }
313 }
EcalNumberingScheme * numberingScheme
Definition: ECalSD.h:65

Member Data Documentation

EnergyResolutionVsLumi ECalSD::ageing
private

Definition at line 74 of file ECalSD.h.

Referenced by curve_LY(), and ECalSD().

bool ECalSD::ageingWithSlopeLY
private

Definition at line 75 of file ECalSD.h.

Referenced by curve_LY(), and ECalSD().

double ECalSD::birk1
private

Definition at line 68 of file ECalSD.h.

Referenced by ECalSD(), getBirkL3(), and getEnergyDeposit().

double ECalSD::birk2
private

Definition at line 68 of file ECalSD.h.

Referenced by ECalSD(), and getEnergyDeposit().

double ECalSD::birk3
private

Definition at line 68 of file ECalSD.h.

Referenced by ECalSD(), and getEnergyDeposit().

double ECalSD::birkCut
private

Definition at line 68 of file ECalSD.h.

Referenced by ECalSD(), and getBirkL3().

double ECalSD::birkSlope
private

Definition at line 68 of file ECalSD.h.

Referenced by ECalSD(), and getBirkL3().

double ECalSD::crystalDepth
private

Definition at line 80 of file ECalSD.h.

Referenced by curve_LY(), getDepth(), getLayerIDForTimeSim(), and getRadiationLength().

double ECalSD::crystalLength
private

Definition at line 79 of file ECalSD.h.

Referenced by curve_LY(), and getDepth().

std::string ECalSD::crystalMat
private

Definition at line 70 of file ECalSD.h.

Referenced by ECalSD(), and initMap().

G4ThreeVector ECalSD::currentLocalPoint
private

Definition at line 78 of file ECalSD.h.

Referenced by curve_LY(), and getDepth().

uint16_t ECalSD::depth
private
std::string ECalSD::depth1Name
private

Definition at line 70 of file ECalSD.h.

Referenced by ECalSD(), and initMap().

std::string ECalSD::depth2Name
private

Definition at line 70 of file ECalSD.h.

Referenced by ECalSD(), and initMap().

bool ECalSD::isEB
private

Definition at line 63 of file ECalSD.h.

Referenced by Electron.Electron::absIsoWithFSR(), and ECalSD().

bool ECalSD::isEE
private

Definition at line 64 of file ECalSD.h.

Referenced by ECalSD().

std::vector<const G4LogicalVolume*> ECalSD::noWeight
private

Definition at line 72 of file ECalSD.h.

Referenced by getEnergyDeposit(), and initMap().

EcalNumberingScheme* ECalSD::numberingScheme
private

Definition at line 65 of file ECalSD.h.

Referenced by setDetUnitId(), setNumberingScheme(), and ~ECalSD().

double ECalSD::scaleRL
private

Definition at line 69 of file ECalSD.h.

Referenced by ECalSD(), and getRadiationLength().

double ECalSD::slopeLY
private

Definition at line 69 of file ECalSD.h.

Referenced by curve_LY(), and ECalSD().

bool ECalSD::storeLayerTimeSim
private

Definition at line 66 of file ECalSD.h.

Referenced by ECalSD(), and getDepth().

bool ECalSD::storeRL
private

Definition at line 66 of file ECalSD.h.

Referenced by ECalSD(), and getDepth().

bool ECalSD::storeTrack
private

Definition at line 66 of file ECalSD.h.

Referenced by ECalSD(), and getTrackID().

EcalBaseNumber ECalSD::theBaseNumber
private

Definition at line 73 of file ECalSD.h.

Referenced by getBaseNumber(), and setDetUnitId().

bool ECalSD::useBirk
private

Definition at line 67 of file ECalSD.h.

Referenced by ECalSD(), and getEnergyDeposit().

bool ECalSD::useBirkL3
private

Definition at line 67 of file ECalSD.h.

Referenced by ECalSD(), and getEnergyDeposit().

std::vector<const G4LogicalVolume*> ECalSD::useDepth1
private

Definition at line 72 of file ECalSD.h.

Referenced by getDepth(), and initMap().

std::vector<const G4LogicalVolume*> ECalSD::useDepth2
private

Definition at line 72 of file ECalSD.h.

Referenced by getDepth(), and initMap().

bool ECalSD::useWeight
private

Definition at line 66 of file ECalSD.h.

Referenced by ECalSD(), getEnergyDeposit(), and getRadiationLength().

std::map<const G4LogicalVolume*,double> ECalSD::xtalLMap
private

Definition at line 71 of file ECalSD.h.

Referenced by getDepth(), and initMap().