CMS 3D CMS Logo

AHCalSD.cc
Go to the documentation of this file.
5 
8 
9 #include "G4LogicalVolume.hh"
10 #include "G4LogicalVolumeStore.hh"
11 #include "G4ParticleTable.hh"
12 #include "G4Track.hh"
13 #include "G4VProcess.hh"
14 
15 #include "G4PhysicalConstants.hh"
16 #include "G4SystemOfUnits.hh"
17 
18 #include <iomanip>
19 #include <map>
20 
21 //#define EDM_ML_DEBUG
22 
24  const SensitiveDetectorCatalog& clg,
25  edm::ParameterSet const& p,
26  const SimTrackManager* manager)
27  : CaloSD(name,
28  clg,
29  p,
30  manager,
31  (float)(p.getParameter<edm::ParameterSet>("AHCalSD").getParameter<double>("TimeSliceUnit")),
32  p.getParameter<edm::ParameterSet>("AHCalSD").getParameter<bool>("IgnoreTrackID")) {
33  edm::ParameterSet m_HC = p.getParameter<edm::ParameterSet>("AHCalSD");
34  useBirk = m_HC.getParameter<bool>("UseBirkLaw");
35  birk1 = m_HC.getParameter<double>("BirkC1") * (CLHEP::g / (CLHEP::MeV * CLHEP::cm2));
36  birk2 = m_HC.getParameter<double>("BirkC2");
37  birk3 = m_HC.getParameter<double>("BirkC3");
38  eminHit = m_HC.getParameter<double>("EminHit") * CLHEP::MeV;
39 
40  edm::LogVerbatim("HcalSim") << "AHCalSD:: Use of Birks law is set to " << useBirk
41  << " with three constants kB = " << birk1 << ", C1 = " << birk2 << ", C2 = " << birk3
42  << "\nAHCalSD:: Threshold for storing"
43  << " hits: " << eminHit;
44 }
45 
46 double AHCalSD::getEnergyDeposit(const G4Step* aStep) {
47  double destep = aStep->GetTotalEnergyDeposit();
48  double wt2 = aStep->GetTrack()->GetWeight();
49  double weight = (wt2 > 0.0) ? wt2 : 1.0;
50 #ifdef EDM_ML_DEBUG
51  double weight0 = weight;
52 #endif
53  if (useBirk)
54  weight *= getAttenuation(aStep, birk1, birk2, birk3);
55 #ifdef EDM_ML_DEBUG
56  edm::LogVerbatim("HcalSim") << "AHCalSD: weight " << weight0 << " " << weight;
57 #endif
58  double edep = weight * destep;
59  return edep;
60 }
61 
62 uint32_t AHCalSD::setDetUnitId(const G4Step* aStep) {
63  const G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
64  const G4VTouchable* touch = preStepPoint->GetTouchable();
65 
66  int depth = (touch->GetReplicaNumber(1));
67  int incol = ((touch->GetReplicaNumber(0)) % AHCalParameters::kColumn_);
68  int inrow = ((touch->GetReplicaNumber(0)) / AHCalParameters::kColumn_) % AHCalParameters::kRow_;
69  int jncol = ((touch->GetReplicaNumber(0)) / AHCalParameters::kRowColumn_) % AHCalParameters::kSign_;
70  int jnrow = ((touch->GetReplicaNumber(0)) / AHCalParameters::kSignRowColumn_) % AHCalParameters::kSign_;
71  int col = (jncol == 0) ? incol : -incol;
72  int row = (jnrow == 0) ? inrow : -inrow;
73  uint32_t index = AHCalDetId(row, col, depth).rawId();
74 #ifdef EDM_ML_DEBUG
75  edm::LogVerbatim("HcalSim") << "AHCalSD: det = " << HcalOther << " depth = " << depth << " row = " << row
76  << " column = " << col << " packed index = 0x" << std::hex << index << std::dec;
77  bool flag = unpackIndex(index, row, col, depth);
78  edm::LogVerbatim("HcalSim") << "Results from unpacker for 0x" << std::hex << index << std::dec << " Flag " << flag
79  << " Row " << row << " Col " << col << " Depth " << depth;
80 #endif
81  return index;
82 }
83 
84 bool AHCalSD::unpackIndex(const uint32_t& idx, int& row, int& col, int& depth) {
85  DetId gen(idx);
86  HcalSubdetector subdet = (HcalSubdetector(gen.subdetId()));
87  bool rcode = (gen.det() == DetId::Hcal && subdet != HcalOther);
88  row = col = depth = 0;
89  if (rcode) {
90  row = AHCalDetId(idx).irow();
91  col = AHCalDetId(idx).icol();
93  }
94 #ifdef EDM_ML_DEBUG
95  edm::LogVerbatim("HcalSim") << "AHCalSD: packed index = 0x" << std::hex << idx << std::dec << " Row " << row
96  << " Column " << col << " Depth " << depth << " OK " << rcode;
97 #endif
98  return rcode;
99 }
100 
101 bool AHCalSD::filterHit(CaloG4Hit* aHit, double time) {
102  return ((time <= tmaxHit) && (aHit->getEnergyDeposit() > eminHit));
103 }
Log< level::Info, true > LogVerbatim
static constexpr int kSignRowColumn_
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
double birk1
Definition: AHCalSD.h:27
int icol() const
get the column number
Definition: AHCalDetId.cc:36
Definition: CaloSD.h:40
double birk3
Definition: AHCalSD.h:27
Definition: weight.py:1
static constexpr int kRow_
bool filterHit(CaloG4Hit *, double) override
Definition: AHCalSD.cc:101
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
AHCalSD(const std::string &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
Definition: AHCalSD.cc:23
HcalSubdetector
Definition: HcalAssistant.h:31
double birk2
Definition: AHCalSD.h:27
double getEnergyDeposit(const G4Step *) override
Definition: AHCalSD.cc:46
uint32_t setDetUnitId(const G4Step *step) override
Definition: AHCalSD.cc:62
def gen(fragment, howMuch)
Production test section ####.
double tmaxHit
Definition: CaloSD.h:148
Definition: DetId.h:17
static constexpr int kRowColumn_
double eminHit
Definition: AHCalSD.h:28
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:57
double getAttenuation(const G4Step *aStep, double birk1, double birk2, double birk3) const
Definition: CaloSD.cc:726
double getEnergyDeposit() const
Definition: CaloG4Hit.h:79
int irow() const
get the row number
Definition: AHCalDetId.cc:29
HLT enums.
col
Definition: cuy.py:1009
bool useBirk
Definition: AHCalSD.h:26
static constexpr int kSign_
static constexpr int kColumn_
Constants used.
int depth() const
get the layer number
Definition: AHCalDetId.cc:43
bool unpackIndex(const uint32_t &idx, int &row, int &col, int &depth)
Definition: AHCalSD.cc:84