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