14 #include "G4LogicalVolumeStore.hh" 15 #include "G4LogicalVolume.hh" 18 #include "G4ParticleTable.hh" 19 #include "G4VProcess.hh" 44 (
"Calibration" +
name)),
73 dd4hep_ =
p.getParameter<
bool>(
"g4GeometryDD4hepSource");
83 if (
myName_.find(
"HitsEE") != std::string::npos) {
85 nameX_ =
"HGCalEESensitive";
86 }
else if (
myName_.find(
"HitsHEfront") != std::string::npos) {
88 nameX_ =
"HGCalHESiliconSensitive";
92 edm::LogVerbatim(
"HGCSim") <<
"**************************************************" 96 <<
"* Constructing a HGCalSD with name " <<
name <<
"\n" 99 <<
"**************************************************";
102 <<
" detector " <<
mydet_ <<
" with " <<
nHC_ <<
" hit collections";
111 double r = aStep->GetPreStepPoint()->GetPosition().perp();
112 double z =
std::abs(aStep->GetPreStepPoint()->GetPosition().z());
114 G4int parCode = aStep->GetTrack()->GetDefinition()->GetPDGEncoding();
115 G4String parName = aStep->GetTrack()->GetDefinition()->GetParticleName();
116 G4LogicalVolume* lv = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume();
117 edm::LogVerbatim(
"HGCSim") <<
"HGCalSD: Hit from standard path from " << lv->GetName() <<
" for Track " 118 << aStep->GetTrack()->GetTrackID() <<
" (" << parCode <<
":" << parName <<
") R = " <<
r 119 <<
" Z = " <<
z <<
" slope = " <<
r /
z <<
":" <<
slopeMin_;
130 double wt2 = aStep->GetTrack()->GetWeight();
131 double destep =
weight_ * wt1 * (aStep->GetTotalEnergyDeposit());
136 <<
weight_ * wt1 * wt2 <<
" deStep: " << aStep->GetTotalEnergyDeposit() <<
":" << destep;
142 const G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
143 const G4VTouchable* touch = preStepPoint->GetTouchable();
146 int dn = touch->GetHistoryDepth();
153 G4ThreeVector hitPoint = preStepPoint->GetPosition();
154 float globalZ = touch->GetTranslation(0).z();
155 int iz(globalZ > 0 ? 1 : -1);
157 int layer(0), moduleLev(-1), cell(-1);
159 layer = touch->GetReplicaNumber(2);
161 }
else if (touch->GetHistoryDepth() >
levelT2_) {
162 layer = touch->GetReplicaNumber(4);
163 cell = touch->GetReplicaNumber(1);
166 layer = touch->GetReplicaNumber(3);
169 int module = touch->GetReplicaNumber(moduleLev);
171 edm::LogVerbatim(
"HGCSim") <<
"Top " << touch->GetVolume(0)->GetName() <<
" Module " 172 << touch->GetVolume(moduleLev)->GetName();
175 <<
useSimWt_ <<
" name " << touch->GetVolume(0)->GetName() <<
" layer:module:cell " 176 <<
layer <<
":" << moduleLev <<
":" <<
module <<
":" << cell;
178 G4Material* mat = aStep->GetPreStepPoint()->GetMaterial();
179 edm::LogVerbatim(
"HGCSim") <<
"Depths: " << touch->GetHistoryDepth() <<
" name " << touch->GetVolume(0)->GetName()
180 <<
":" << touch->GetReplicaNumber(0) <<
" " << touch->GetVolume(1)->GetName() <<
":" 181 << touch->GetReplicaNumber(1) <<
" " << touch->GetVolume(2)->GetName() <<
":" 182 << touch->GetReplicaNumber(2) <<
" " << touch->GetVolume(3)->GetName() <<
":" 183 << touch->GetReplicaNumber(3) <<
" " << touch->GetVolume(4)->GetName() <<
":" 184 << touch->GetReplicaNumber(4) <<
" " 185 <<
" layer:module:cell " <<
layer <<
":" <<
module <<
":" << cell <<
" Material " 186 << mat->GetName() <<
":" << mat->GetRadlen();
189 if (aStep->GetPreStepPoint()->GetMaterial()->GetRadlen() > 100000.)
202 G4ThreeVector
local = (touch->GetHistory()->GetTransform(dn - moduleLev).TransformPoint(hitPoint));
205 << touch->GetHistory()->GetTransform(dn).TransformPoint(hitPoint) <<
" Down1 " 206 << touch->GetHistory()->GetTransform(dn - 1).TransformPoint(hitPoint) <<
" Down2 " 207 << touch->GetHistory()->GetTransform(dn - 2).TransformPoint(hitPoint) <<
" Down3 " 208 << touch->GetHistory()->GetTransform(dn - 3).TransformPoint(hitPoint) <<
" Local " 236 std::string_view pid = (cshift ?
"HGCSim" :
"HGCalSim");
239 double xx = (hid1.
zside() > 0) ?
xy.first : -
xy.first;
240 double dx =
xx - (hitPoint.x() / CLHEP::cm);
241 double dy =
xy.second - (hitPoint.y() / CLHEP::cm);
245 if ((
diff > tol) || (!valid1))
250 <<
module <<
":" << cell <<
":" << moduleLev <<
" SimWt:history " <<
useSimWt_ <<
":" 251 << touch->GetHistoryDepth() <<
":" <<
levelT1_ <<
":" <<
levelT2_ <<
" input position: (" 252 << hitPoint.x() / CLHEP::cm <<
", " << hitPoint.y() / CLHEP::cm <<
":" 253 <<
convertRadToDeg(std::atan2(hitPoint.y(), hitPoint.x())) <<
"); position from ID (" <<
xx 255 <<
" Valid " << valid1 <<
" Wafer type|rotation " << partn.first <<
":" << partn.second
259 if ((
diff > tol) || (!valid1)) {
297 <<
":" << mouseBiteNew <<
":" <<
mouseBiteCut_ <<
" useOffset " << useOffset
305 guardRing_ = std::make_unique<HGCGuardRing>(*hgcons_);
321 std::ostringstream st1;
325 std::ostringstream st2;
329 std::ostringstream st3;
333 std::ostringstream st4;
339 throw cms::Exception(
"Unknown",
"HGCalSD") <<
"Cannot find HGCalDDDConstants for " <<
nameX_ <<
"\n";
388 int indx = 100 * cellU + cellV;
403 int32_t
type = hd ? 0 : 1;
CaloG4Hit * currentHit[2]
bool maskCell(const DetId &id, int corners) const
Log< level::Info, true > LogVerbatim
static int32_t cellPlacementIndex(int32_t iz, int32_t frontBack, int32_t orient)
static constexpr bool waferHD(int32_t type)
T getParameter(std::string const &) const
void processSecondHit(const G4Step *, const G4Track *) override
edm::ParameterSet const & ps_
std::vector< int > calibCellPartLD_
const HGCalParameters * getParameter() const
void setNumberCheckedHits(int val, int k=0)
HGCalSD(const std::string &, const HGCalDDDConstants *, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
int32_t waferU(const int32_t index)
std::vector< int > calibCellPartHD_
HGCalParameters::waferInfo waferInfo(int lay, int waferU, int waferV) const
constexpr NumType convertRadToDeg(NumType radians)
void newCollection(const std::string &name, edm::ParameterSet const &p)
std::unique_ptr< HGCalNumberingScheme > numberingScheme_
std::pair< int, int > waferTypeRotation(int layer, int waferU, int waferV, bool fromFile, bool debug) const
static constexpr bool waferFull(int32_t type)
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
HGCalGeometryMode::GeometryMode geomMode() const
bool isValidHex8(int lay, int waferU, int waferV, bool fullAndPart) const
T getUntrackedParameter(std::string const &, T const &) const
constexpr int32_t waferV() const
double getEnergyDeposit(const G4Step *) override
constexpr void unpack(int32_t &ty, int32_t &zs, int32_t &ly, int32_t &wU, int32_t &wV, int32_t &cU, int32_t &cV) const
double getResponseWt(const G4Track *, int k=0)
CaloG4Hit * createNewHit(const G4Step *, const G4Track *, int k)
uint32_t setDetUnitId(const G4Step *step) override
std::tuple< int, int, int, int > waferFileInfo(unsigned int kk) const
std::vector< int > calibCellFullHD_
Cos< T >::type cos(const T &t)
constexpr int32_t zside() const
get the z-side of the cell (1/-1)
std::vector< double > angles_
const HGCalDDDConstants * hgcons_
int getUVMax(int type) const
Tan< T >::type tan(const T &t)
Abs< T >::type abs(const T &t)
double mouseBite(bool reco) const
int32_t waferIndex(int32_t layer, int32_t waferU, int32_t waferV, bool old=false)
constexpr int32_t cellU() const
get the cell #'s in u,v or in x,y
bool calibCell(const uint32_t &id)
double getEnergyDeposit() const
HGCalGeometryMode::GeometryMode geom_mode_
constexpr int32_t layer() const
get the layer #
std::pair< float, float > locateCell(int cell, int lay, int type, bool reco) const
bool waferHexagon8File() const
constexpr int32_t cellV() const
bool hitExists(const G4Step *, int k)
std::unique_ptr< HGCalCellOffset > cellOffset_
void printDetectorLevels(const G4VTouchable *) const
std::unique_ptr< HGCGuardRingPartial > guardRingPartial_
std::vector< int > calibCellFullLD_
bool filterHit(CaloG4Hit *, double) override
bool cassetteShiftSilicon(int zside, int layer, int waferU, int waferV) const
std::vector< int > calibCells(bool hd, bool full) const
int32_t waferV(const int32_t index)
double guardRingOffset(bool reco) const
std::unique_ptr< HGCGuardRing > guardRing_
double sensorSizeOffset(bool reco) const
double calibCellRad(bool hd) const
std::unique_ptr< HGCMouseBite > mouseBite_
constexpr int32_t waferU() const
int levelTop(int ind=0) const
constexpr std::pair< int32_t, int32_t > waferUV() const
double waferSize(bool reco) const
int layerType(int lay) const
static constexpr int32_t layerFrontBack(int32_t layerOrient)
void update(const BeginOfJob *) override
This routine will be called when the appropriate signal arrives.