CMS 3D CMS Logo

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
19 #include "HcalTB02SD.h"
22 
23 #include "G4Step.hh"
24 #include "G4Track.hh"
25 #include "G4VProcess.hh"
26 
27 #include "G4SystemOfUnits.hh"
28 
29 //#define EDM_ML_DEBUG
30 
31 //
32 // constructors and destructor
33 //
34 
36  const edm::EventSetup& es,
37  const SensitiveDetectorCatalog& clg,
38  edm::ParameterSet const& p,
39  const SimTrackManager* manager)
40  : CaloSD(name, es, clg, p, manager) {
41  numberingScheme_.reset(nullptr);
42  edm::ParameterSet m_SD = p.getParameter<edm::ParameterSet>("HcalTB02SD");
43  useBirk_ = m_SD.getUntrackedParameter<bool>("UseBirkLaw", false);
44  birk1_ = m_SD.getUntrackedParameter<double>("BirkC1", 0.013) * (CLHEP::g / (CLHEP::MeV * CLHEP::cm2));
45  birk2_ = m_SD.getUntrackedParameter<double>("BirkC2", 0.0568);
46  birk3_ = m_SD.getUntrackedParameter<double>("BirkC3", 1.75);
47  useWeight_ = true;
48 
50  if (name == "EcalHitsEB") {
51  scheme = dynamic_cast<HcalTB02NumberingScheme*>(new HcalTB02XtalNumberingScheme());
52  useBirk_ = false;
53  } else if (name == "HcalHits") {
54  scheme = dynamic_cast<HcalTB02NumberingScheme*>(new HcalTB02HcalNumberingScheme());
55  useWeight_ = false;
56  } else {
57  edm::LogWarning("HcalTBSim") << "HcalTB02SD: ReadoutName " << name << " not supported\n";
58  }
59 
60  if (scheme)
62 #ifdef EDM_ML_DEBUG
63  edm::LogVerbatim("HcalTBSim") << "***************************************************\n"
64  << "* *\n"
65  << "* Constructing a HcalTB02SD with name " << GetName() << "\n"
66  << "* *\n"
67  << "***************************************************";
68  edm::LogVerbatim("HcalTBSim") << "HcalTB02SD:: Use of Birks law is set to " << useBirk_
69  << " with three constants kB = " << birk1_ << ", C1 = " << birk2_
70  << ", C2 = " << birk3_;
71 #endif
72  // Get pointers to HcalTB02Parameters
74  es.get<IdealGeometryRecord>().get(hdc);
75  if (hdc.isValid()) {
77  } else {
78  throw cms::Exception("Unknown", "HcalTB02SD") << "Cannot find HcalTB02Parameters\n";
79  }
80 }
81 
83 
84 //
85 // member functions
86 //
87 
88 double HcalTB02SD::getEnergyDeposit(const G4Step* aStep) {
89  auto const preStepPoint = aStep->GetPreStepPoint();
90  std::string nameVolume = static_cast<std::string>(preStepPoint->GetPhysicalVolume()->GetName());
91 
92  // take into account light collection curve for crystals
93  double weight = 1.;
94  if (useWeight_)
95  weight *= curve_LY(nameVolume, preStepPoint);
96  if (useBirk_)
98  double edep = aStep->GetTotalEnergyDeposit() * weight;
99 #ifdef EDM_ML_DEBUG
100  edm::LogVerbatim("HcalTBSim") << "HcalTB02SD:: " << nameVolume << " Light Collection Efficiency " << weight
101  << " Weighted Energy Deposit " << edep / CLHEP::MeV << " MeV";
102 #endif
103  return edep;
104 }
105 
106 uint32_t HcalTB02SD::setDetUnitId(const G4Step* aStep) {
107  return (numberingScheme_ == nullptr ? 0 : (uint32_t)(numberingScheme_->getUnitID(aStep)));
108 }
109 
111  if (scheme != nullptr) {
112  edm::LogVerbatim("HcalTBSim") << "HcalTB02SD: updates numbering scheme for " << GetName();
113  numberingScheme_.reset(scheme);
114  }
115 }
116 
117 double HcalTB02SD::curve_LY(const std::string& nameVolume, const G4StepPoint* stepPoint) {
118  double weight = 1.;
119  G4ThreeVector localPoint = setToLocal(stepPoint->GetPosition(), stepPoint->GetTouchable());
120  double crlength = crystalLength(nameVolume);
121  double dapd = 0.5 * crlength - localPoint.z();
122  if (dapd >= -0.1 || dapd <= crlength + 0.1) {
123  if (dapd <= 100.)
124  weight = 1.05 - dapd * 0.0005;
125  } else {
126  edm::LogWarning("HcalTBSim") << "HcalTB02SD: light coll curve : wrong "
127  << "distance to APD " << dapd << " crlength = " << crlength
128  << " crystal name = " << nameVolume << " z of localPoint = " << localPoint.z()
129  << " take weight = " << weight;
130  }
131 #ifdef EDM_ML_DEBUG
132  edm::LogVerbatim("HcalTBSim") << "HcalTB02SD, light coll curve : " << dapd << " crlength = " << crlength
133  << " crystal name = " << nameVolume << " z of localPoint = " << localPoint.z()
134  << " take weight = " << weight;
135 #endif
136  return weight;
137 }
138 
140  double length = 230.;
141  std::map<std::string, double>::const_iterator it = hcalTB02Parameters_->lengthMap_.find(name);
142  if (it != hcalTB02Parameters_->lengthMap_.end())
143  length = it->second;
144  return length;
145 }
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
SimTrackManager
Definition: SimTrackManager.h:35
ESTransientHandle.h
MessageLogger.h
HcalTB02SD::numberingScheme_
std::unique_ptr< HcalTB02NumberingScheme > numberingScheme_
Definition: HcalTB02SD.h:47
HcalTB02XtalNumberingScheme
Definition: HcalTB02XtalNumberingScheme.h:24
mps_merge.weight
weight
Definition: mps_merge.py:88
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
HcalTB02SD::birk1_
double birk1_
Definition: HcalTB02SD.h:49
CaloSD::getAttenuation
double getAttenuation(const G4Step *aStep, double birk1, double birk2, double birk3) const
Definition: CaloSD.cc:685
MeV
const double MeV
edm::ParameterSet::getUntrackedParameter
T getUntrackedParameter(std::string const &, T const &) const
edm::LogWarning
Log< level::Warning, false > LogWarning
Definition: MessageLogger.h:122
HcalTB02SD::setNumberingScheme
void setNumberingScheme(HcalTB02NumberingScheme *scheme)
Definition: HcalTB02SD.cc:110
edm::EventSetup::get
T get() const
Definition: EventSetup.h:87
HcalTB02SD::birk2_
double birk2_
Definition: HcalTB02SD.h:49
CaloSD::setToLocal
G4ThreeVector setToLocal(const G4ThreeVector &, const G4VTouchable *) const
Definition: CaloSD.cc:387
HcalTB02SD::birk3_
double birk3_
Definition: HcalTB02SD.h:49
edm::ESHandle
Definition: DTSurvey.h:22
HcalTB02HcalNumberingScheme.h
SensitiveDetectorCatalog
Definition: SensitiveDetectorCatalog.h:10
HcalTB02SD::hcalTB02Parameters_
const HcalTB02Parameters * hcalTB02Parameters_
Definition: HcalTB02SD.h:50
HcalTB02SD::useBirk_
bool useBirk_
Definition: HcalTB02SD.h:48
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
edm::ParameterSet
Definition: ParameterSet.h:47
HcalTB02SD::getEnergyDeposit
double getEnergyDeposit(const G4Step *) override
Definition: HcalTB02SD.cc:88
HcalTB02SD.h
HcalTB02SD::useWeight_
bool useWeight_
Definition: HcalTB02SD.h:48
IdealGeometryRecord.h
edm::EventSetup
Definition: EventSetup.h:58
HcalTB02Parameters::lengthMap_
std::map< std::string, double > lengthMap_
Definition: HcalTB02Parameters.h:14
get
#define get
edm::ESHandleBase::isValid
bool isValid() const
Definition: ESHandle.h:44
generator_cfi.scheme
scheme
Definition: generator_cfi.py:22
HcalTB02SD::setDetUnitId
uint32_t setDetUnitId(const G4Step *step) override
Definition: HcalTB02SD.cc:106
HcalTB02XtalNumberingScheme.h
HcalTB02HcalNumberingScheme
Definition: HcalTB02HcalNumberingScheme.h:24
HcalTB02NumberingScheme
Definition: HcalTB02NumberingScheme.h:24
HcalTB02SD::curve_LY
double curve_LY(const std::string &, const G4StepPoint *)
Definition: HcalTB02SD.cc:117
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
Exception
Definition: hltDiff.cc:245
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
HcalTB02SD::HcalTB02SD
HcalTB02SD(const std::string &, const edm::EventSetup &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
Definition: HcalTB02SD.cc:35
HcalTB02SD::crystalLength
double crystalLength(const std::string &)
Definition: HcalTB02SD.cc:139
HcalTB02SD::~HcalTB02SD
~HcalTB02SD() override
Definition: HcalTB02SD.cc:82
weight
Definition: weight.py:1
IdealGeometryRecord
Definition: IdealGeometryRecord.h:25
CaloSD
Definition: CaloSD.h:38
g
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