CMS 3D CMS Logo

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