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.)
198 G4ThreeVector
local = (touch->GetHistory()->GetTransform(dn - moduleLev).TransformPoint(hitPoint));
201 << touch->GetHistory()->GetTransform(dn).TransformPoint(hitPoint) <<
" Down1 " 202 << touch->GetHistory()->GetTransform(dn - 1).TransformPoint(hitPoint) <<
" Down2 " 203 << touch->GetHistory()->GetTransform(dn - 2).TransformPoint(hitPoint) <<
" Down3 " 204 << touch->GetHistory()->GetTransform(dn - 3).TransformPoint(hitPoint) <<
" Local " 232 std::string_view pid = (cshift ?
"HGCSim" :
"HGCalSim");
235 double xx = (hid1.
zside() > 0) ?
xy.first : -
xy.first;
236 double dx =
xx - (hitPoint.x() / CLHEP::cm);
237 double dy =
xy.second - (hitPoint.y() / CLHEP::cm);
239 constexpr
double tol = 2.0 * 2.0;
241 if ((
diff > tol) || (!valid1))
246 <<
module <<
":" << cell <<
":" << moduleLev <<
" SimWt:history " <<
useSimWt_ <<
":" 247 << touch->GetHistoryDepth() <<
":" <<
levelT1_ <<
":" <<
levelT2_ <<
" input position: (" 248 << hitPoint.x() / CLHEP::cm <<
", " << hitPoint.y() / CLHEP::cm <<
":" 249 <<
convertRadToDeg(std::atan2(hitPoint.y(), hitPoint.x())) <<
"); position from ID (" <<
xx 251 <<
" Valid " << valid1 <<
" Wafer type|rotation " << partn.first <<
":" << partn.second
255 if ((
diff > tol) || (!valid1)) {
293 <<
":" << mouseBiteNew <<
":" <<
mouseBiteCut_ <<
" useOffset " << useOffset
301 guardRing_ = std::make_unique<HGCGuardRing>(*hgcons_);
317 std::ostringstream st1;
321 std::ostringstream st2;
325 std::ostringstream st3;
329 std::ostringstream st4;
335 throw cms::Exception(
"Unknown",
"HGCalSD") <<
"Cannot find HGCalDDDConstants for " <<
nameX_ <<
"\n";
385 int indx = 100 * cellU + cellV;
400 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)
constexpr void unpack(int &ty, int &zs, int &ly, int &wU, int &wV, int &cU, int &cV) const
static constexpr bool waferHD(int32_t type)
T getParameter(std::string const &) const
constexpr int cellV() 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
constexpr std::pair< int, int > waferUV() const
T getUntrackedParameter(std::string const &, T const &) const
double getEnergyDeposit(const G4Step *) override
double getResponseWt(const G4Track *, int k=0)
constexpr int zside() const
get the z-side of the cell (1/-1)
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)
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 int layer() const
get the layer #
constexpr int 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_
std::pair< float, float > locateCell(int cell, int lay, int type, bool reco) const
bool waferHexagon8File() const
bool hitExists(const G4Step *, int k)
std::unique_ptr< HGCalCellOffset > cellOffset_
void printDetectorLevels(const G4VTouchable *) const
std::unique_ptr< HGCGuardRingPartial > guardRingPartial_
constexpr int waferU() const
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_
int levelTop(int ind=0) const
constexpr int waferV() 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.