CMS 3D CMS Logo

HcalTB06BeamSD.cc
Go to the documentation of this file.
1 // File: HcalTB06BeamSD.cc
3 // Description: Sensitive Detector class for beam counters in TB06 setup
5 
11 #include "HcalTB06BeamSD.h"
12 
13 #include "G4Step.hh"
14 #include "G4Track.hh"
15 #include "G4Material.hh"
16 #include "CLHEP/Units/GlobalSystemOfUnits.h"
17 
18 //#define EDM_ML_DEBUG
19 
21  const edm::EventSetup& es,
22  const SensitiveDetectorCatalog& clg,
23  edm::ParameterSet const& p,
24  const SimTrackManager* manager)
25  : CaloSD(name, es, clg, p, manager) {
26  // Values from NIM 80 (1970) 239-244: as implemented in Geant3
27  edm::ParameterSet m_HC = p.getParameter<edm::ParameterSet>("HcalTB06BeamSD");
28  useBirk_ = m_HC.getParameter<bool>("UseBirkLaw");
29  birk1_ = m_HC.getParameter<double>("BirkC1") * (CLHEP::g / (CLHEP::MeV * CLHEP::cm2));
30  birk2_ = m_HC.getParameter<double>("BirkC2");
31  birk3_ = m_HC.getParameter<double>("BirkC3");
32 
33 #ifdef EDM_ML_DEBUG
34  edm::LogVerbatim("HcalTBSim") << "HcalTB06BeamSD:: Use of Birks law is set to " << useBirk_
35  << " with three constants kB = " << birk1_ << ", C1 = " << birk2_
36  << ", C2 = " << birk3_;
37 #endif
38 
39  // Get pointers to HcalTB06BeamParameters
41  es.get<IdealGeometryRecord>().get(hdc);
42  if (hdc.isValid()) {
43  hcalBeamPar_ = hdc.product();
44  } else {
45  throw cms::Exception("Unknown", "HCalTB06BeamSD") << "Cannot find HcalTB06BeamParameters";
46  }
47 }
48 
50 
51 double HcalTB06BeamSD::getEnergyDeposit(const G4Step* aStep) {
52  double destep = aStep->GetTotalEnergyDeposit();
53  double weight = 1;
54  if (useBirk_ && aStep->GetPreStepPoint()->GetMaterial()->GetName() == static_cast<G4String>(hcalBeamPar_->material_))
56 #ifdef EDM_ML_DEBUG
57  edm::LogVerbatim("HcalTBSim") << "HcalTB06BeamSD: Detector "
58  << aStep->GetPreStepPoint()->GetTouchable()->GetVolume()->GetName() << " weight "
59  << weight;
60 #endif
61  return weight * destep;
62 }
63 
64 uint32_t HcalTB06BeamSD::setDetUnitId(const G4Step* aStep) {
65  const G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
66  const G4VTouchable* touch = preStepPoint->GetTouchable();
67  std::string name = static_cast<std::string>(preStepPoint->GetPhysicalVolume()->GetName());
68 
69  int det = 1;
70  int lay = 0, x = 0, y = 0;
71  if (!isItWireChamber(name)) {
72  lay = (touch->GetReplicaNumber(0));
73  } else {
74  det = 2;
75  lay = (touch->GetReplicaNumber(1));
76  G4ThreeVector localPoint = setToLocal(preStepPoint->GetPosition(), touch);
77  x = (int)(localPoint.x() / (0.2 * mm));
78  y = (int)(localPoint.y() / (0.2 * mm));
79  }
80 
81  return HcalTestBeamNumbering::packIndex(det, lay, x, y);
82 }
83 
85  std::vector<std::string>::const_iterator it = hcalBeamPar_->wchambers_.begin();
86  for (; it != hcalBeamPar_->wchambers_.end(); it++)
87  if (name == *it)
88  return true;
89  return false;
90 }
edm::ESHandle::product
T const * product() const
Definition: ESHandle.h:86
HcalTB06BeamSD::hcalBeamPar_
const HcalTB06BeamParameters * hcalBeamPar_
Definition: HcalTB06BeamSD.h:36
DDAxes::y
HcalTestBeamNumbering::packIndex
static uint32_t packIndex(int det, int lay, int x, int y)
Definition: HcalTestBeamNumbering.cc:6
SimTrackManager
Definition: SimTrackManager.h:35
HcalTB06BeamParameters::wchambers_
std::vector< std::string > wchambers_
Definition: HcalTB06BeamParameters.h:13
MessageLogger.h
mps_merge.weight
weight
Definition: mps_merge.py:88
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
HcalTB06BeamSD::isItWireChamber
bool isItWireChamber(const std::string &)
Definition: HcalTB06BeamSD.cc:84
CaloSD::getAttenuation
double getAttenuation(const G4Step *aStep, double birk1, double birk2, double birk3) const
Definition: CaloSD.cc:517
HcalTB06BeamSD::birk3_
double birk3_
Definition: HcalTB06BeamSD.h:35
MeV
const double MeV
DDAxes::x
HcalTB06BeamSD::HcalTB06BeamSD
HcalTB06BeamSD(const std::string &, const edm::EventSetup &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
Definition: HcalTB06BeamSD.cc:20
HcalTB06BeamSD::getEnergyDeposit
double getEnergyDeposit(const G4Step *) override
Definition: HcalTB06BeamSD.cc:51
HcalTB06BeamParameters::material_
std::string material_
Definition: HcalTB06BeamParameters.h:14
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
CaloSD::setToLocal
G4ThreeVector setToLocal(const G4ThreeVector &, const G4VTouchable *) const
Definition: CaloSD.cc:373
HcalTestBeamNumbering.h
HcalTB06BeamSD.h
edm::ESHandle
Definition: DTSurvey.h:22
HcalTB06BeamSD::useBirk_
bool useBirk_
Definition: HcalTB06BeamSD.h:34
SensitiveDetectorCatalog
Definition: SensitiveDetectorCatalog.h:10
HcalTB06BeamSD::setDetUnitId
uint32_t setDetUnitId(const G4Step *step) override
Definition: HcalTB06BeamSD.cc:64
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HcalTB06BeamSD::birk1_
double birk1_
Definition: HcalTB06BeamSD.h:35
edm::ParameterSet
Definition: ParameterSet.h:47
createfilelist.int
int
Definition: createfilelist.py:10
IdealGeometryRecord.h
edm::EventSetup
Definition: EventSetup.h:57
HcalTB06BeamSD::~HcalTB06BeamSD
~HcalTB06BeamSD() override
Definition: HcalTB06BeamSD.cc:49
TrackInformation.h
get
#define get
edm::ESHandleBase::isValid
bool isValid() const
Definition: ESHandle.h:44
HcalTB06BeamSD::birk2_
double birk2_
Definition: HcalTB06BeamSD.h:35
edm::LogVerbatim
Log< level::Info, true > LogVerbatim
Definition: MessageLogger.h:128
Exception
Definition: hltDiff.cc:246
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Exception.h
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