CMS 3D CMS Logo

HGCalTB16SD01.cc
Go to the documentation of this file.
3 
4 #include "CLHEP/Units/GlobalSystemOfUnits.h"
5 #include "G4LogicalVolumeStore.hh"
6 #include "G4Track.hh"
7 
8 #include <string>
9 
10 //#define EDM_ML_DEBUG
11 
12 
14  const SensitiveDetectorCatalog& clg,
15  edm::ParameterSet const& p,
16  const SimTrackManager* manager)
17  : CaloSD(name, clg, p, manager), initialize_(true) {
18  // Values from NIM 80 (1970) 239-244: as implemented in Geant3
19  edm::ParameterSet m_HC = p.getParameter<edm::ParameterSet>("HGCalTestBeamSD");
20  matName_ = m_HC.getParameter<std::string>("Material");
21  useBirk_ = m_HC.getParameter<bool>("UseBirkLaw");
22  birk1_ = m_HC.getParameter<double>("BirkC1") * (g / (MeV * cm2));
23  birk2_ = m_HC.getParameter<double>("BirkC2");
24  birk3_ = m_HC.getParameter<double>("BirkC3");
25  matScin_ = nullptr;
26 
27  edm::LogVerbatim("HGCSim") << "HGCalTB16SD01:: Use of Birks law is set to " << useBirk_ << " for " << matName_
28  << " with three constants kB = " << birk1_ << ", C1 = " << birk2_ << ", C2 = " << birk3_;
29 }
30 
31 double HGCalTB16SD01::getEnergyDeposit(const G4Step* aStep) {
32  auto const point = aStep->GetPreStepPoint();
33  if (initialize_)
35  double destep = aStep->GetTotalEnergyDeposit();
36  double wt2 = aStep->GetTrack()->GetWeight();
37  double weight = (wt2 > 0.0) ? wt2 : 1.0;
38  if (useBirk_ && matScin_ == point->GetMaterial()) {
40  }
41 #ifdef EDM_ML_DEBUG
42  edm::LogVerbatim("HGCSim") << "HGCalTB16SD01: Detector " << point->GetTouchable()->GetVolume()->GetName() << " with "
43  << point->GetMaterial()->GetName() << " weight " << weight << ":" << wt2;
44 #endif
45  return weight * destep;
46 }
47 
48 uint32_t HGCalTB16SD01::setDetUnitId(const G4Step* aStep) {
49  const G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
50  const G4VTouchable* touch = preStepPoint->GetTouchable();
51 
52  int det(1), x(0), y(0);
53  int lay = (touch->GetReplicaNumber(0));
54 
55  return packIndex(det, lay, x, y);
56 }
57 
58 uint32_t HGCalTB16SD01::packIndex(int det, int lay, int x, int y) {
59  int ix = 0, ixx = x;
60  if (x < 0) {
61  ix = 1;
62  ixx = -x;
63  }
64  int iy = 0, iyy = y;
65  if (y < 0) {
66  iy = 1;
67  iyy = -y;
68  }
69  uint32_t idx = (det & 15) << 28; // bits 28-31
70  idx += (lay & 127) << 21; // bits 21-27
71  idx += (iy & 1) << 19; // bit 19
72  idx += (iyy & 511) << 10; // bits 10-18
73  idx += (ix & 1) << 9; // bit 9
74  idx += (ixx & 511); // bits 0-8
75 
76 #ifdef EDM_ML_DEBUG
77  edm::LogVerbatim("HGCSim") << "HGCalTB16SD01: Detector " << det << " Layer " << lay << " x " << x << " " << ix << " "
78  << ixx << " y " << y << " " << iy << " " << iyy << " ID " << std::hex << idx << std::dec;
79 #endif
80  return idx;
81 }
82 
83 void HGCalTB16SD01::unpackIndex(const uint32_t& idx, int& det, int& lay, int& x, int& y) {
84  det = (idx >> 28) & 15;
85  lay = (idx >> 21) & 127;
86  y = (idx >> 10) & 511;
87  if (((idx >> 19) & 1) == 1)
88  y = -y;
89  x = (idx)&511;
90  if (((idx >> 9) & 1) == 1)
91  x = -x;
92 }
93 
94 void HGCalTB16SD01::initialize(const G4StepPoint* point) {
95  if (matName_ == point->GetMaterial()->GetName()) {
96  matScin_ = point->GetMaterial();
97  initialize_ = false;
98  }
99 #ifdef EDM_ML_DEBUG
100  edm::LogVerbatim("HGCSim") << "HGCalTB16SD01: Material pointer for " << matName_
101  << " is initialized to : " << matScin_;
102 #endif
103 }
Log< level::Info, true > LogVerbatim
double getEnergyDeposit(const G4Step *) override
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
Definition: CaloSD.h:40
Definition: weight.py:1
static void unpackIndex(const uint32_t &idx, int &det, int &lay, int &x, int &y)
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
const int iyy[18][41][3]
const int ixx[18][41][3]
std::string matName_
Definition: HGCalTB16SD01.h:29
HGCalTB16SD01(const std::string &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
uint32_t setDetUnitId(const G4Step *step) override
G4Material * matScin_
Definition: HGCalTB16SD01.h:33
double getAttenuation(const G4Step *aStep, double birk1, double birk2, double birk3) const
Definition: CaloSD.cc:666
void initialize(const G4StepPoint *point)
float x
static uint32_t packIndex(int det, int lay, int x, int y)
*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