CMS 3D CMS Logo

AHCalSD.cc
Go to the documentation of this file.
4 
7 
8 #include "G4LogicalVolume.hh"
9 #include "G4LogicalVolumeStore.hh"
10 #include "G4ParticleTable.hh"
11 #include "G4Step.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 #include <string>
21 
22 //#define EDM_ML_DEBUG
23 
24 class AHCalSD : public CaloSD {
25  public:
26  AHCalSD(const std::string&, const DDCompactView&,
28  const SimTrackManager*);
29  ~AHCalSD() override = default;
30  uint32_t setDetUnitId(const G4Step* step) override;
31  bool unpackIndex(const uint32_t& idx, int& row, int& col, int& depth);
32 
33  protected:
34  double getEnergyDeposit(const G4Step*) override;
35  bool filterHit(CaloG4Hit*, double) override;
36 
37  private:
38  bool useBirk;
39  double birk1, birk2, birk3, betaThr;
40  double eminHit;
41 };
42 
44  const SensitiveDetectorCatalog& clg,
45  edm::ParameterSet const& p, const SimTrackManager* manager)
46  : CaloSD(name, cpv, clg, p, manager,
47  (float)(p.getParameter<edm::ParameterSet>("AHCalSD")
48  .getParameter<double>("TimeSliceUnit")),
49  p.getParameter<edm::ParameterSet>("AHCalSD").getParameter<bool>(
50  "IgnoreTrackID")) {
52  useBirk = m_HC.getParameter<bool>("UseBirkLaw");
53  birk1 = m_HC.getParameter<double>("BirkC1") *
54  (CLHEP::g / (CLHEP::MeV * CLHEP::cm2));
55  birk2 = m_HC.getParameter<double>("BirkC2");
56  birk3 = m_HC.getParameter<double>("BirkC3");
57  eminHit = m_HC.getParameter<double>("EminHit") * CLHEP::MeV;
58 
59  edm::LogVerbatim("HcalSim")
60  << "AHCalSD:: Use of Birks law is set to " << useBirk
61  << " with three constants kB = " << birk1 << ", C1 = " << birk2
62  << ", C2 = " << birk3 << "\nAHCalSD:: Threshold for storing"
63  << " hits: " << eminHit;
64 }
65 
66 double AHCalSD::getEnergyDeposit(const G4Step* aStep) {
67  double destep = aStep->GetTotalEnergyDeposit();
68  double wt2 = aStep->GetTrack()->GetWeight();
69  double weight = (wt2 > 0.0) ? wt2 : 1.0;
70 #ifdef EDM_ML_DEBUG
71  double weight0 = weight;
72 #endif
73  if (useBirk) weight *= getAttenuation(aStep, birk1, birk2, birk3);
74 #ifdef EDM_ML_DEBUG
75  edm::LogVerbatim("HcalSim") << "AHCalSD: weight " << weight0 << " " << weight;
76 #endif
77  double edep = weight * destep;
78  return edep;
79 }
80 
81 uint32_t AHCalSD::setDetUnitId(const G4Step* aStep) {
82  const G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
83  const G4VTouchable* touch = preStepPoint->GetTouchable();
84 
85  int depth = (touch->GetReplicaNumber(1));
86  int incol = ((touch->GetReplicaNumber(0)) % 10);
87  int inrow = ((touch->GetReplicaNumber(0)) / 10) % 10;
88  int jncol = ((touch->GetReplicaNumber(0)) / 100) % 10;
89  int jnrow = ((touch->GetReplicaNumber(0)) / 1000) % 10;
90  int col = (jncol == 0) ? incol : -incol;
91  int row = (jnrow == 0) ? inrow : -inrow;
92  uint32_t index = AHCalDetId(row, col, depth).rawId();
93 #ifdef EDM_ML_DEBUG
94  edm::LogVerbatim("HcalSim")
95  << "AHCalSD: det = " << HcalOther << " depth = " << depth
96  << " row = " << row << " column = " << col << " packed index = 0x"
97  << std::hex << index << std::dec;
98  bool flag = unpackIndex(index, row, col, depth);
99  edm::LogVerbatim("HcalSim")
100  << "Results from unpacker for 0x" << std::hex << index << std::dec
101  << " Flag " << flag << " Row " << row << " Col " << col << " Depth "
102  << depth;
103 #endif
104  return index;
105 }
106 
107 bool AHCalSD::unpackIndex(const uint32_t& idx, int& row, int& col, int& depth) {
108  DetId gen(idx);
109  HcalSubdetector subdet = (HcalSubdetector(gen.subdetId()));
110  bool rcode = (gen.det() == DetId::Hcal && subdet != HcalOther);
111  row = col = depth = 0;
112  if (rcode) {
113  row = AHCalDetId(idx).irow();
114  col = AHCalDetId(idx).icol();
115  depth = AHCalDetId(idx).depth();
116  }
117 #ifdef EDM_ML_DEBUG
118  edm::LogVerbatim("HcalSim")
119  << "AHCalSD: packed index = 0x" << std::hex << idx << std::dec << " Row "
120  << row << " Column " << col << " Depth " << depth << " OK " << rcode;
121 #endif
122  return rcode;
123 }
124 
125 bool AHCalSD::filterHit(CaloG4Hit* aHit, double time) {
126  return ((time <= tmaxHit) && (aHit->getEnergyDeposit() > eminHit));
127 }
128 
132 
T getParameter(std::string const &) const
double birk1
Definition: AHCalSD.cc:39
Definition: CaloSD.h:38
constexpr uint32_t rawId() const
get the raw id
Definition: DetId.h:50
double betaThr
Definition: AHCalSD.cc:39
~AHCalSD() override=default
double birk3
Definition: AHCalSD.cc:39
int irow() const
get the row number
Definition: AHCalDetId.cc:34
Definition: weight.py:1
Compact representation of the geometrical detector hierarchy.
Definition: DDCompactView.h:80
bool filterHit(CaloG4Hit *, double) override
Definition: AHCalSD.cc:125
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
int depth() const
Definition: AHCalDetId.cc:46
const double MeV
int icol() const
get the column number
Definition: AHCalDetId.cc:40
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector&#39;s numbering enum) ...
Definition: DetId.h:41
HcalSubdetector
Definition: HcalAssistant.h:31
double birk2
Definition: AHCalSD.cc:39
double getEnergyDeposit(const G4Step *) override
Definition: AHCalSD.cc:66
uint32_t setDetUnitId(const G4Step *step) override
Definition: AHCalSD.cc:81
def gen(fragment, howMuch)
Production test section ####.
AHCalSD(const std::string &, const DDCompactView &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
Definition: AHCalSD.cc:43
double tmaxHit
Definition: CaloSD.h:133
Definition: DetId.h:18
double eminHit
Definition: AHCalSD.cc:40
double getAttenuation(const G4Step *aStep, double birk1, double birk2, double birk3) const
Definition: CaloSD.cc:438
HLT enums.
AHCalSD AHcalSensitiveDetector
Definition: AHCalSD.cc:133
col
Definition: cuy.py:1010
bool useBirk
Definition: AHCalSD.cc:38
step
Definition: StallMonitor.cc:94
#define DEFINE_SENSITIVEDETECTOR(type)
bool unpackIndex(const uint32_t &idx, int &row, int &col, int &depth)
Definition: AHCalSD.cc:107
double getEnergyDeposit() const
Definition: CaloG4Hit.h:77
constexpr Detector det() const
get the detector field from this detid
Definition: DetId.h:39