CMS 3D CMS Logo

HGCalTB16SD01.cc
Go to the documentation of this file.
4 
5 #include "CLHEP/Units/GlobalSystemOfUnits.h"
6 #include "G4LogicalVolumeStore.hh"
7 #include "G4Material.hh"
8 #include "G4Step.hh"
9 #include "G4Track.hh"
10 
11 #include <string>
12 
13 //#define EDM_ML_DEBUG
14 
15 class HGCalTB16SD01 : public CaloSD {
16 public:
18  const edm::EventSetup&,
20  edm::ParameterSet const&,
21  const SimTrackManager*);
22  ~HGCalTB16SD01() override = default;
23  uint32_t setDetUnitId(const G4Step* step) override;
24  static uint32_t packIndex(int det, int lay, int x, int y);
25  static void unpackIndex(const uint32_t& idx, int& det, int& lay, int& x, int& y);
26 
27 protected:
28  double getEnergyDeposit(const G4Step*) override;
29 
30 private:
31  void initialize(const G4StepPoint* point);
32 
34  bool useBirk_;
35  double birk1_, birk2_, birk3_;
37  G4Material* matScin_;
38 };
39 
41  const edm::EventSetup& es,
42  const SensitiveDetectorCatalog& clg,
43  edm::ParameterSet const& p,
44  const SimTrackManager* manager)
45  : CaloSD(name, es, clg, p, manager), initialize_(true) {
46  // Values from NIM 80 (1970) 239-244: as implemented in Geant3
47  edm::ParameterSet m_HC = p.getParameter<edm::ParameterSet>("HGCalTestBeamSD");
48  matName_ = m_HC.getParameter<std::string>("Material");
49  useBirk_ = m_HC.getParameter<bool>("UseBirkLaw");
50  birk1_ = m_HC.getParameter<double>("BirkC1") * (g / (MeV * cm2));
51  birk2_ = m_HC.getParameter<double>("BirkC2");
52  birk3_ = m_HC.getParameter<double>("BirkC3");
53  matScin_ = nullptr;
54 
55  edm::LogVerbatim("HGCSim") << "HGCalTB16SD01:: Use of Birks law is set to " << useBirk_ << " for " << matName_
56  << " with three constants kB = " << birk1_ << ", C1 = " << birk2_ << ", C2 = " << birk3_;
57 }
58 
59 double HGCalTB16SD01::getEnergyDeposit(const G4Step* aStep) {
60  auto const point = aStep->GetPreStepPoint();
61  if (initialize_)
63  double destep = aStep->GetTotalEnergyDeposit();
64  double wt2 = aStep->GetTrack()->GetWeight();
65  double weight = (wt2 > 0.0) ? wt2 : 1.0;
66  if (useBirk_ && matScin_ == point->GetMaterial()) {
68  }
69 #ifdef EDM_ML_DEBUG
70  edm::LogVerbatim("HGCSim") << "HGCalTB16SD01: Detector " << point->GetTouchable()->GetVolume()->GetName() << " with "
71  << point->GetMaterial()->GetName() << " weight " << weight << ":" << wt2;
72 #endif
73  return weight * destep;
74 }
75 
76 uint32_t HGCalTB16SD01::setDetUnitId(const G4Step* aStep) {
77  const G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
78  const G4VTouchable* touch = preStepPoint->GetTouchable();
79 
80  int det(1), x(0), y(0);
81  int lay = (touch->GetReplicaNumber(0));
82 
83  return packIndex(det, lay, x, y);
84 }
85 
86 uint32_t HGCalTB16SD01::packIndex(int det, int lay, int x, int y) {
87  int ix = 0, ixx = x;
88  if (x < 0) {
89  ix = 1;
90  ixx = -x;
91  }
92  int iy = 0, iyy = y;
93  if (y < 0) {
94  iy = 1;
95  iyy = -y;
96  }
97  uint32_t idx = (det & 15) << 28; // bits 28-31
98  idx += (lay & 127) << 21; // bits 21-27
99  idx += (iy & 1) << 19; // bit 19
100  idx += (iyy & 511) << 10; // bits 10-18
101  idx += (ix & 1) << 9; // bit 9
102  idx += (ixx & 511); // bits 0-8
103 
104 #ifdef EDM_ML_DEBUG
105  edm::LogVerbatim("HGCSim") << "HGCalTB16SD01: Detector " << det << " Layer " << lay << " x " << x << " " << ix << " "
106  << ixx << " y " << y << " " << iy << " " << iyy << " ID " << std::hex << idx << std::dec;
107 #endif
108  return idx;
109 }
110 
111 void HGCalTB16SD01::unpackIndex(const uint32_t& idx, int& det, int& lay, int& x, int& y) {
112  det = (idx >> 28) & 15;
113  lay = (idx >> 21) & 127;
114  y = (idx >> 10) & 511;
115  if (((idx >> 19) & 1) == 1)
116  y = -y;
117  x = (idx)&511;
118  if (((idx >> 9) & 1) == 1)
119  x = -x;
120 }
121 
122 void HGCalTB16SD01::initialize(const G4StepPoint* point) {
123  if (matName_ == point->GetMaterial()->GetName()) {
124  matScin_ = point->GetMaterial();
125  initialize_ = false;
126  }
127 #ifdef EDM_ML_DEBUG
128  edm::LogVerbatim("HGCSim") << "HGCalTB16SD01: Material pointer for " << matName_
129  << " is initialized to : " << matScin_;
130 #endif
131 }
132 
136 
DDAxes::y
SimTrackManager
Definition: SimTrackManager.h:35
step
step
Definition: StallMonitor.cc:94
HGCalTB1601SensitiveDetector
HGCalTB16SD01 HGCalTB1601SensitiveDetector
Definition: HGCalTB16SD01.cc:137
AlCaHLTBitMon_ParallelJobs.p
p
Definition: AlCaHLTBitMon_ParallelJobs.py:153
HGCalTB16SD01
Definition: HGCalTB16SD01.cc:15
CaloSD::getAttenuation
double getAttenuation(const G4Step *aStep, double birk1, double birk2, double birk3) const
Definition: CaloSD.cc:435
MeV
const double MeV
HGCalTB16SD01::matName_
std::string matName_
Definition: HGCalTB16SD01.cc:33
DDAxes::x
iyy
int iyy[18][41][3]
Definition: EcalDAQHandler.cc:317
training_settings.idx
idx
Definition: training_settings.py:16
MakerMacros.h
HGCalTB16SD01::packIndex
static uint32_t packIndex(int det, int lay, int x, int y)
Definition: HGCalTB16SD01.cc:86
HGCalTB16SD01::matScin_
G4Material * matScin_
Definition: HGCalTB16SD01.cc:37
HGCalTB16SD01::useBirk_
bool useBirk_
Definition: HGCalTB16SD01.cc:34
vertices_cff.x
x
Definition: vertices_cff.py:29
HGCalTB16SD01::initialize
void initialize(const G4StepPoint *point)
Definition: HGCalTB16SD01.cc:122
HGCalTB16SD01::unpackIndex
static void unpackIndex(const uint32_t &idx, int &det, int &lay, int &x, int &y)
Definition: HGCalTB16SD01.cc:111
SensitiveDetectorCatalog
Definition: SensitiveDetectorCatalog.h:10
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
HGCalTB16SD01::birk2_
double birk2_
Definition: HGCalTB16SD01.cc:35
DEFINE_SENSITIVEDETECTOR
#define DEFINE_SENSITIVEDETECTOR(type)
Definition: SensitiveDetectorPluginFactory.h:13
funct::true
true
Definition: Factorize.h:173
edm::ParameterSet
Definition: ParameterSet.h:36
CaloSD.h
ModuleDef.h
edm::LogVerbatim
Definition: MessageLogger.h:297
edm::EventSetup
Definition: EventSetup.h:57
HGCalTB16SD01::birk1_
double birk1_
Definition: HGCalTB16SD01.cc:35
TrackInformation.h
HGCalTB16SD01::~HGCalTB16SD01
~HGCalTB16SD01() override=default
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
HGCalTB16SD01::getEnergyDeposit
double getEnergyDeposit(const G4Step *) override
Definition: HGCalTB16SD01.cc:59
HGCalTB16SD01::HGCalTB16SD01
HGCalTB16SD01(const std::string &, const edm::EventSetup &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
Definition: HGCalTB16SD01.cc:40
ixx
int ixx[18][41][3]
Definition: EcalDAQHandler.cc:226
detailsBasic3DVector::y
float float y
Definition: extBasic3DVector.h:14
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
Exception.h
HGCalTB16SD01::birk3_
double birk3_
Definition: HGCalTB16SD01.cc:35
HGCalTB16SD01::initialize_
bool initialize_
Definition: HGCalTB16SD01.cc:36
SensitiveDetectorPluginFactory.h
point
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
TauDecayModes.dec
dec
Definition: TauDecayModes.py:143
weight
Definition: weight.py:1
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
HGCalTB16SD01::setDetUnitId
uint32_t setDetUnitId(const G4Step *step) override
Definition: HGCalTB16SD01.cc:76