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
18 #include "HcalTB02SD.h"
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 
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)
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_)
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 }
SimTrackManager
Definition: SimTrackManager.h:35
MessageLogger.h
HcalTB02SD::numberingScheme_
std::unique_ptr< HcalTB02NumberingScheme > numberingScheme_
Definition: HcalTB02SD.h:49
HcalTB02XtalNumberingScheme
Definition: HcalTB02XtalNumberingScheme.h:24
mps_merge.weight
weight
Definition: mps_merge.py:88
HcalTB02SD::birk1_
double birk1_
Definition: HcalTB02SD.h:51
CaloSD::getAttenuation
double getAttenuation(const G4Step *aStep, double birk1, double birk2, double birk3) const
Definition: CaloSD.cc:683
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:101
HcalTB02Parameters
Definition: HcalTB02Parameters.h:9
HcalTB02SD::birk2_
double birk2_
Definition: HcalTB02SD.h:51
CaloSD::setToLocal
G4ThreeVector setToLocal(const G4ThreeVector &, const G4VTouchable *) const
Definition: CaloSD.cc:385
HcalTB02SD::birk3_
double birk3_
Definition: HcalTB02SD.h:51
HcalTB02HcalNumberingScheme.h
SensitiveDetectorCatalog
Definition: SensitiveDetectorCatalog.h:10
HcalTB02SD::hcalTB02Parameters_
const HcalTB02Parameters * hcalTB02Parameters_
Definition: HcalTB02SD.h:52
HcalTB02SD::useBirk_
bool useBirk_
Definition: HcalTB02SD.h:50
edm::ParameterSet
Definition: ParameterSet.h:47
AlCaHLTBitMon_ParallelJobs.p
def p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
HcalTB02SD::getEnergyDeposit
double getEnergyDeposit(const G4Step *) override
Definition: HcalTB02SD.cc:79
HcalTB02SD.h
HcalTB02SD::useWeight_
bool useWeight_
Definition: HcalTB02SD.h:50
HcalTB02Parameters::lengthMap_
std::map< std::string, double > lengthMap_
Definition: HcalTB02Parameters.h:14
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
generator_cfi.scheme
scheme
Definition: generator_cfi.py:22
HcalTB02SD::setDetUnitId
uint32_t setDetUnitId(const G4Step *step) override
Definition: HcalTB02SD.cc:97
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:108
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
HcalTB02SD::HcalTB02SD
HcalTB02SD(const std::string &, const HcalTB02Parameters *, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
Definition: HcalTB02SD.cc:34
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
HcalTB02SD::crystalLength
double crystalLength(const std::string &)
Definition: HcalTB02SD.cc:130
ParameterSet.h
HcalTB02SD::~HcalTB02SD
~HcalTB02SD() override
Definition: HcalTB02SD.cc:73
weight
Definition: weight.py:1
CaloSD
Definition: CaloSD.h:39
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