CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalTBH4BeamSD.cc
Go to the documentation of this file.
1 // File: EcalTBH4BeamSD.cc
3 // Description: Sensitive Detector class for electromagnetic calorimeters
13 
15 
16 #include "G4Step.hh"
17 #include "G4Track.hh"
18 #include "G4VProcess.hh"
19 
22  edm::ParameterSet const & p,
23  const SimTrackManager* manager) :
24  CaloSD(name, cpv, clg, p, manager), numberingScheme(0) {
25 
26  edm::ParameterSet m_EcalTBH4BeamSD = p.getParameter<edm::ParameterSet>("EcalTBH4BeamSD");
27  useBirk= m_EcalTBH4BeamSD.getParameter<bool>("UseBirkLaw");
28  birk1 = m_EcalTBH4BeamSD.getParameter<double>("BirkC1")*(g/(MeV*cm2));
29  birk2 = m_EcalTBH4BeamSD.getParameter<double>("BirkC2");
30  birk3 = m_EcalTBH4BeamSD.getParameter<double>("BirkC3");
31 
32  EcalNumberingScheme* scheme=0;
33  if (name == "EcalTBH4BeamHits") {
34  scheme = dynamic_cast<EcalNumberingScheme*>(new EcalHodoscopeNumberingScheme());
35  }
36  else {edm::LogWarning("EcalTBSim") << "EcalTBH4BeamSD: ReadoutName not supported\n";}
37 
38  if (scheme) setNumberingScheme(scheme);
39  edm::LogInfo("EcalTBSim") << "Constructing a EcalTBH4BeamSD with name "
40  << GetName();
41  edm::LogInfo("EcalTBSim") << "EcalTBH4BeamSD:: Use of Birks law is set to "
42  << useBirk << " with three constants kB = "
43  << birk1 << ", C1 = " << birk2 << ", C2 = "
44  << birk3;
45 }
46 
48  if (numberingScheme) delete numberingScheme;
49 }
50 
51 double EcalTBH4BeamSD::getEnergyDeposit(G4Step * aStep) {
52 
53  if (aStep == NULL) {
54  return 0;
55  } else {
56  preStepPoint = aStep->GetPreStepPoint();
57  G4String nameVolume = preStepPoint->GetPhysicalVolume()->GetName();
58 
59  // take into account light collection curve for crystals
60  double weight = 1.;
61  if (useBirk) weight *= getAttenuation(aStep, birk1, birk2, birk3);
62  double edep = aStep->GetTotalEnergyDeposit() * weight;
63  LogDebug("EcalTBSim") << "EcalTBH4BeamSD:: " << nameVolume
64  <<" Light Collection Efficiency " << weight
65  << " Weighted Energy Deposit " << edep/MeV << " MeV";
66  return edep;
67  }
68 }
69 
70 uint32_t EcalTBH4BeamSD::setDetUnitId(G4Step * aStep) {
71  getBaseNumber(aStep);
73 }
74 
76  if (scheme != 0) {
77  edm::LogInfo("EcalTBSim") << "EcalTBH4BeamSD: updates numbering scheme for "
78  << GetName() << "\n";
79  if (numberingScheme) delete numberingScheme;
80  numberingScheme = scheme;
81  }
82 }
83 
84 
85 void EcalTBH4BeamSD::getBaseNumber(const G4Step* aStep) {
86 
88  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
89  int theSize = touch->GetHistoryDepth()+1;
90  if ( theBaseNumber.getCapacity() < theSize ) theBaseNumber.setSize(theSize);
91  //Get name and copy numbers
92  if ( theSize > 1 ) {
93  for (int ii = 0; ii < theSize ; ii++) {
94  theBaseNumber.addLevel(touch->GetVolume(ii)->GetName(),touch->GetReplicaNumber(ii));
95  LogDebug("EcalTBSim") << "EcalTBH4BeamSD::getBaseNumber(): Adding level " << ii
96  << ": " << touch->GetVolume(ii)->GetName() << "["
97  << touch->GetReplicaNumber(ii) << "]";
98  }
99  }
100 }
#define LogDebug(id)
T getParameter(std::string const &) const
Definition: CaloSD.h:42
virtual uint32_t setDetUnitId(G4Step *step)
#define NULL
Definition: scimark2.h:8
type of data representation of DDCompactView
Definition: DDCompactView.h:77
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
static TrackerG4SimHitNumberingScheme & numberingScheme(const DDCompactView &cpv, const GeometricDet &det)
void addLevel(const std::string &name, const int &copyNumber)
virtual ~EcalTBH4BeamSD()
void setNumberingScheme(EcalNumberingScheme *scheme)
double getAttenuation(G4Step *aStep, double birk1, double birk2, double birk3)
Definition: CaloSD.cc:454
EcalNumberingScheme * numberingScheme
G4StepPoint * preStepPoint
Definition: CaloSD.h:119
EcalBaseNumber theBaseNumber
EcalTBH4BeamSD(G4String, const DDCompactView &, SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
void getBaseNumber(const G4Step *aStep)
virtual double getEnergyDeposit(G4Step *)
void setSize(const int &size)
virtual uint32_t getUnitID(const EcalBaseNumber &baseNumber) const =0