16 #include "G4LogicalVolumeStore.hh" 17 #include "G4LogicalVolume.hh" 20 #include "G4ParticleTable.hh" 21 #include "G4VProcess.hh" 60 dd4hep_ =
p.getParameter<
bool>(
"g4GeometryDD4hepSource");
67 G4String myName =
name;
70 if (myName.find(
"HitsEE") != std::string::npos) {
72 nameX_ =
"HGCalEESensitive";
73 }
else if (myName.find(
"HitsHEfront") != std::string::npos) {
75 nameX_ =
"HGCalHESiliconSensitive";
76 }
else if (myName.find(
"HitsHEback") != std::string::npos) {
78 nameX_ =
"HGCalHEScintillatorSensitive";
82 edm::LogVerbatim(
"HGCSim") <<
"**************************************************" 86 <<
"* Constructing a HGCSD with name " <<
name <<
"\n" 89 <<
"**************************************************";
100 double r = aStep->GetPreStepPoint()->GetPosition().perp();
101 double z =
std::abs(aStep->GetPreStepPoint()->GetPosition().z());
104 G4int parCode = aStep->GetTrack()->GetDefinition()->GetPDGEncoding();
105 G4LogicalVolume* lv = aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume();
106 edm::LogVerbatim(
"HGCSim") <<
"HGCSD: Hit from standard path from " << lv->GetName() <<
" for Track " 107 << aStep->GetTrack()->GetTrackID() <<
" (" 108 << aStep->GetTrack()->GetDefinition()->GetParticleName() <<
":" << parCode <<
") R = " <<
r 109 <<
" Z = " <<
z <<
" slope = " <<
r /
z <<
":" <<
slopeMin_;
118 double wt2 = aStep->GetTrack()->GetWeight();
119 double destep = wt1 * aStep->GetTotalEnergyDeposit();
124 const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
125 G4double tmptrackE = aStep->GetTrack()->GetKineticEnergy();
126 G4int parCodex = aStep->GetTrack()->GetDefinition()->GetPDGEncoding();
127 G4double
angle = (aStep->GetTrack()->GetMomentumDirection().theta()) / CLHEP::deg;
128 G4int
layer = ((touch->GetHistoryDepth() ==
levelT_) ? touch->GetReplicaNumber(0) : touch->GetReplicaNumber(2));
129 G4int ilayer = (
layer - 1) / 3;
130 if (aStep->GetTotalEnergyDeposit() > 0) {
133 t_dEStep1_.emplace_back(aStep->GetTotalEnergyDeposit());
144 const G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
145 const G4VTouchable* touch = preStepPoint->GetTouchable();
148 G4ThreeVector hitPoint = preStepPoint->GetPosition();
149 float globalZ = touch->GetTranslation(0).z();
150 int iz(globalZ > 0 ? 1 : -1);
153 G4ThreeVector localpos = touch->GetHistory()->GetTopTransform().TransformPoint(hitPoint);
158 int layer(-1), moduleLev(-1),
module(-1), cell(-1);
159 if (touch->GetHistoryDepth() ==
levelT_) {
160 layer = touch->GetReplicaNumber(0);
162 edm::LogVerbatim(
"HGCSim") <<
"Depths: " << touch->GetHistoryDepth() <<
" name " << touch->GetVolume(0)->GetName()
163 <<
" layer:module:cell " <<
layer <<
":" << moduleLev <<
":" <<
module <<
":" << cell;
166 layer = touch->GetReplicaNumber(2);
167 module = touch->GetReplicaNumber(1);
168 cell = touch->GetReplicaNumber(0);
172 const G4Material* mat = aStep->GetPreStepPoint()->GetMaterial();
173 edm::LogVerbatim(
"HGCSim") <<
"Depths: " << touch->GetHistoryDepth() <<
" name " << touch->GetVolume(0)->GetName()
174 <<
":" << touch->GetReplicaNumber(0) <<
" " << touch->GetVolume(1)->GetName() <<
":" 175 << touch->GetReplicaNumber(1) <<
" " << touch->GetVolume(2)->GetName() <<
":" 176 << touch->GetReplicaNumber(2) <<
" layer:module:cell " <<
layer <<
":" << moduleLev
177 <<
":" <<
module <<
":" << cell <<
" Material " << mat->GetName() <<
":" 179 for (
int k = 0;
k < touch->GetHistoryDepth(); ++
k)
180 edm::LogVerbatim(
"HGCSim") <<
"Level [" <<
k <<
"] " << touch->GetVolume(
k)->GetName() <<
":" 181 << touch->GetReplicaNumber(
k);
185 if (aStep->GetPreStepPoint()->GetMaterial()->GetRadlen() > 100000.)
190 int det,
z, lay, wafer,
type, ic;
194 <<
module <<
":" << cell <<
":" << iz << localpos.x() <<
":" << localpos.y()
195 <<
" Decode " << det <<
":" <<
z <<
":" << lay <<
":" << wafer <<
":" <<
type <<
":" 198 G4ThreeVector
local =
199 ((moduleLev >= 0) ? (touch->GetHistory()->GetTransform(moduleLev).TransformPoint(hitPoint)) : G4ThreeVector());
218 throw cms::Exception(
"Unknown",
"HGCSD") <<
"Cannot find HGCalTBDDDConstants for " <<
nameX_ <<
"\n";
229 if (
tfile.isAvailable()) {
230 tree_ =
tfile->make<TTree>(
"TreeHGCSD",
"TreeHGCSD");
236 tree_->Branch(
"TrackEnergy", &
t_TrackE_);
237 tree_->Branch(
"ThetaAngle", &
t_Angle_);
243 const G4Event* evt = (*g4Event)();
std::vector< double > t_TrackE_
Log< level::Info, true > LogVerbatim
double getEnergyDeposit(const G4Step *) override
std::vector< double > t_dEStep1_
T getParameter(std::string const &) const
std::vector< double > t_dEStep2_
void setNumberCheckedHits(int val, int k=0)
std::vector< int > t_Layer_
int levelTop(int ind=0) const
HGCSD(const std::string &, const HGCalTBDDDConstants *, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
std::vector< double > angles_
Log< level::Error, false > LogError
T getUntrackedParameter(std::string const &, T const &) const
HGCalGeometryMode::GeometryMode geom_mode_
double getResponseWt(const G4Track *, int k=0)
std::unique_ptr< HGCMouseBite > mouseBite_
Tan< T >::type tan(const T &t)
Abs< T >::type abs(const T &t)
std::vector< int > t_Parcode_
std::unique_ptr< HGCNumberingScheme > numberingScheme_
void initEvent(const BeginOfEvent *) override
std::vector< double > t_Angle_
double getEnergyDeposit() const
uint32_t setDetUnitId(const G4Step *step) override
void update(const BeginOfJob *) override
This routine will be called when the appropriate signal arrives.
const HGCalTBDDDConstants * hgcons_
HGCalGeometryMode::GeometryMode geomMode() const
bool filterHit(CaloG4Hit *, double) override
ForwardSubdetector myFwdSubdet_
static void unpackHexagonIndex(const uint32_t &idx, int &subdet, int &z, int &lay, int &wafer, int &celltyp, int &cell)
T angle(T x1, T y1, T z1, T x2, T y2, T z2)