CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
HcalTB02SD.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: HcalTestBeam
4 // Class : HcalTB02SD
5 //
6 // Implementation:
7 // Sensitive Detector class for Hcal Test Beam 2002 detectors
8 //
9 // Original Author:
10 // Created: Sun 21 10:14:34 CEST 2006
11 //
12 
13 // system include files
14 
15 // user include files
21 
22 #include "G4Step.hh"
23 #include "G4Track.hh"
24 #include "G4VProcess.hh"
25 
26 #include "G4SystemOfUnits.hh"
27 
28 //#define EDM_ML_DEBUG
29 
30 //
31 // constructors and destructor
32 //
33 
35  const HcalTB02Parameters* es,
36  const SensitiveDetectorCatalog& clg,
37  edm::ParameterSet const& p,
38  const SimTrackManager* manager)
39  : CaloSD(name, clg, p, manager), hcalTB02Parameters_(es) {
40  numberingScheme_.reset(nullptr);
41  edm::ParameterSet m_SD = p.getParameter<edm::ParameterSet>("HcalTB02SD");
42  useBirk_ = m_SD.getUntrackedParameter<bool>("UseBirkLaw", false);
43  birk1_ = m_SD.getUntrackedParameter<double>("BirkC1", 0.013) * (CLHEP::g / (CLHEP::MeV * CLHEP::cm2));
44  birk2_ = m_SD.getUntrackedParameter<double>("BirkC2", 0.0568);
45  birk3_ = m_SD.getUntrackedParameter<double>("BirkC3", 1.75);
46  useWeight_ = true;
47 
48  HcalTB02NumberingScheme* scheme = nullptr;
49  if (name == "EcalHitsEB") {
50  scheme = dynamic_cast<HcalTB02NumberingScheme*>(new HcalTB02XtalNumberingScheme());
51  useBirk_ = false;
52  } else if (name == "HcalHits") {
53  scheme = dynamic_cast<HcalTB02NumberingScheme*>(new HcalTB02HcalNumberingScheme());
54  useWeight_ = false;
55  } else {
56  edm::LogWarning("HcalTBSim") << "HcalTB02SD: ReadoutName " << name << " not supported\n";
57  }
58 
59  if (scheme)
60  setNumberingScheme(scheme);
61 #ifdef EDM_ML_DEBUG
62  edm::LogVerbatim("HcalTBSim") << "***************************************************\n"
63  << "* *\n"
64  << "* Constructing a HcalTB02SD with name " << GetName() << "\n"
65  << "* *\n"
66  << "***************************************************";
67  edm::LogVerbatim("HcalTBSim") << "HcalTB02SD:: Use of Birks law is set to " << useBirk_
68  << " with three constants kB = " << birk1_ << ", C1 = " << birk2_
69  << ", C2 = " << birk3_;
70 #endif
71 }
72 
74 
75 //
76 // member functions
77 //
78 
79 double HcalTB02SD::getEnergyDeposit(const G4Step* aStep) {
80  auto const preStepPoint = aStep->GetPreStepPoint();
81  std::string nameVolume = static_cast<std::string>(preStepPoint->GetPhysicalVolume()->GetName());
82 
83  // take into account light collection curve for crystals
84  double weight = 1.;
85  if (useWeight_)
86  weight *= curve_LY(nameVolume, preStepPoint);
87  if (useBirk_)
88  weight *= getAttenuation(aStep, birk1_, birk2_, birk3_);
89  double edep = aStep->GetTotalEnergyDeposit() * weight;
90 #ifdef EDM_ML_DEBUG
91  edm::LogVerbatim("HcalTBSim") << "HcalTB02SD:: " << nameVolume << " Light Collection Efficiency " << weight
92  << " Weighted Energy Deposit " << edep / CLHEP::MeV << " MeV";
93 #endif
94  return edep;
95 }
96 
97 uint32_t HcalTB02SD::setDetUnitId(const G4Step* aStep) {
98  return (numberingScheme_ == nullptr ? 0 : (uint32_t)(numberingScheme_->getUnitID(aStep)));
99 }
100 
102  if (scheme != nullptr) {
103  edm::LogVerbatim("HcalTBSim") << "HcalTB02SD: updates numbering scheme for " << GetName();
104  numberingScheme_.reset(scheme);
105  }
106 }
107 
108 double HcalTB02SD::curve_LY(const std::string& nameVolume, const G4StepPoint* stepPoint) {
109  double weight = 1.;
110  G4ThreeVector localPoint = setToLocal(stepPoint->GetPosition(), stepPoint->GetTouchable());
111  double crlength = crystalLength(nameVolume);
112  double dapd = 0.5 * crlength - localPoint.z();
113  if (dapd >= -0.1 || dapd <= crlength + 0.1) {
114  if (dapd <= 100.)
115  weight = 1.05 - dapd * 0.0005;
116  } else {
117  edm::LogWarning("HcalTBSim") << "HcalTB02SD: light coll curve : wrong "
118  << "distance to APD " << dapd << " crlength = " << crlength
119  << " crystal name = " << nameVolume << " z of localPoint = " << localPoint.z()
120  << " take weight = " << weight;
121  }
122 #ifdef EDM_ML_DEBUG
123  edm::LogVerbatim("HcalTBSim") << "HcalTB02SD, light coll curve : " << dapd << " crlength = " << crlength
124  << " crystal name = " << nameVolume << " z of localPoint = " << localPoint.z()
125  << " take weight = " << weight;
126 #endif
127  return weight;
128 }
129 
131  double length = 230.;
132  std::map<std::string, double>::const_iterator it = hcalTB02Parameters_->lengthMap_.find(name);
133  if (it != hcalTB02Parameters_->lengthMap_.end())
134  length = it->second;
135  return length;
136 }
Log< level::Info, true > LogVerbatim
bool useBirk_
Definition: HcalTB02SD.h:50
T getUntrackedParameter(std::string const &, T const &) const
bool useWeight_
Definition: HcalTB02SD.h:50
Definition: CaloSD.h:40
double curve_LY(const std::string &, const G4StepPoint *)
Definition: HcalTB02SD.cc:108
double getEnergyDeposit(const G4Step *) override
Definition: HcalTB02SD.cc:79
double crystalLength(const std::string &)
Definition: HcalTB02SD.cc:130
HcalTB02SD(const std::string &, const HcalTB02Parameters *, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
Definition: HcalTB02SD.cc:34
uint32_t setDetUnitId(const G4Step *step) override
Definition: HcalTB02SD.cc:97
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
~HcalTB02SD() override
Definition: HcalTB02SD.cc:73
std::unique_ptr< HcalTB02NumberingScheme > numberingScheme_
Definition: HcalTB02SD.h:49
std::map< std::string, double > lengthMap_
double birk1_
Definition: HcalTB02SD.h:51
G4ThreeVector setToLocal(const G4ThreeVector &, const G4VTouchable *) const
Definition: CaloSD.cc:394
void setNumberingScheme(HcalTB02NumberingScheme *scheme)
Definition: HcalTB02SD.cc:101
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
double birk2_
Definition: HcalTB02SD.h:51
double getAttenuation(const G4Step *aStep, double birk1, double birk2, double birk3) const
Definition: CaloSD.cc:657
const HcalTB02Parameters * hcalTB02Parameters_
Definition: HcalTB02SD.h:52
Log< level::Warning, false > LogWarning
int weight
Definition: histoStyle.py:51
double birk3_
Definition: HcalTB02SD.h:51