24 #include "G4LogicalVolumeStore.hh" 25 #include "G4LogicalVolume.hh" 28 #include "G4ParticleTable.hh" 29 #include "G4VProcess.hh" 42 CaloSD(name, cpv, clg, p, manager,
45 slopeMin_(0), levelT_(99), tree_(
nullptr) {
64 G4String myName =
name;
67 if (myName.find(
"HitsEE")!=std::string::npos) {
69 nameX_ =
"HGCalEESensitive";
70 }
else if (myName.find(
"HitsHEfront")!=std::string::npos) {
72 nameX_ =
"HGCalHESiliconSensitive";
73 }
else if (myName.find(
"HitsHEback")!=std::string::npos) {
75 nameX_ =
"HGCalHEScintillatorSensitive";
79 edm::LogVerbatim(
"HGCSim")<<
"**************************************************" 83 <<
"* Constructing a HGCSD with name " << name <<
"\n" 86 <<
"**************************************************";
94 <<
" Size of wafer " << waferSize
95 <<
" Mouse Bite " << mouseBite <<
":" 96 << mouseBiteCut_ <<
" along " << angles_.size()
102 double r = aStep->GetPreStepPoint()->GetPosition().perp();
103 double z =
std::abs(aStep->GetPreStepPoint()->GetPosition().z());
106 G4int parCode = aStep->GetTrack()->GetDefinition()->GetPDGEncoding();
107 G4LogicalVolume* lv =
108 aStep->GetPreStepPoint()->GetPhysicalVolume()->GetLogicalVolume();
110 << lv->GetName() <<
" for Track " 111 << aStep->GetTrack()->GetTrackID() <<
" (" 112 << aStep->GetTrack()->GetDefinition()->GetParticleName()
113 <<
") R = " << r <<
" Z = " 114 << z <<
" slope = " << r/z <<
":" <<
slopeMin_;
118 if (r < z*slopeMin_) {
return 0.0; }
121 double wt2 = aStep->GetTrack()->GetWeight();
122 double destep = wt1*aStep->GetTotalEnergyDeposit();
123 if (wt2 > 0) destep *= wt2;
126 const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
127 G4double tmptrackE = aStep->GetTrack()->GetKineticEnergy();
128 G4int parCode = aStep->GetTrack()->GetDefinition()->GetPDGEncoding();
129 G4double
angle = (aStep->GetTrack()->GetMomentumDirection().theta())/CLHEP::deg;
130 G4int layer = ((touch->GetHistoryDepth() ==
levelT_) ?
131 touch->GetReplicaNumber(0) : touch->GetReplicaNumber(2));
132 G4int ilayer = (layer-1)/3;
133 if (aStep->GetTotalEnergyDeposit() > 0) {
136 t_dEStep1_.emplace_back(aStep->GetTotalEnergyDeposit());
148 const G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
149 const G4VTouchable* touch = preStepPoint->GetTouchable();
152 G4ThreeVector hitPoint = preStepPoint->GetPosition();
153 float globalZ=touch->GetTranslation(0).z();
154 int iz( globalZ>0 ? 1 : -1);
157 G4ThreeVector localpos = touch->GetHistory()->GetTopTransform().TransformPoint(hitPoint);
163 if (touch->GetHistoryDepth() ==
levelT_) {
164 layer = touch->GetReplicaNumber(0);
169 <<
" name " << touch->GetVolume(0)->GetName()
170 <<
" layer:module:cell " << layer <<
":" 171 << module <<
":" << cell;
174 layer = touch->GetReplicaNumber(2);
175 module = touch->GetReplicaNumber(1);
176 cell = touch->GetReplicaNumber(0);
180 <<
" name " << touch->GetVolume(0)->GetName()
181 <<
":" << touch->GetReplicaNumber(0) <<
" " 182 << touch->GetVolume(1)->GetName()
183 <<
":" << touch->GetReplicaNumber(1) <<
" " 184 << touch->GetVolume(2)->GetName()
185 <<
":" << touch->GetReplicaNumber(2) <<
" " 186 <<
" layer:module:cell " << layer <<
":" 187 << module <<
":" << cell <<
" Material " 188 << mat->GetName() <<
":" 189 << aStep->GetPreStepPoint()->GetMaterial()->GetRadlen();
193 if (aStep->GetPreStepPoint()->GetMaterial()->GetRadlen() > 100000.)
return 0;
195 uint32_t
id =
setDetUnitId (subdet, layer, module, cell, iz, localpos);
197 int det,
z, lay, wafer,
type, ic;
201 <<
" Decode " << det <<
":" << z <<
":" << lay
202 <<
":" << wafer <<
":" << type <<
":" << ic;
204 if (
mouseBite_->exclude(hitPoint, z, wafer, 0))
id = 0;
223 edm::LogError(
"HGCSim") <<
"HCalSD : Cannot find HGCalDDDConstants for " 226 <<
"Cannot find HGCalDDDConstants for " <<
nameX_ <<
"\n";
230 <<
" Slope cut " <<
slopeMin_ <<
" top Level " 239 tree_ = tfile->
make<TTree>(
"TreeHGCSD",
"TreeHGCSD");
252 const G4Event* evt = (*g4Event)();
275 int cell,
int iz, G4ThreeVector &
pos) {
std::vector< double > t_TrackE_
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
double getEnergyDeposit(const G4Step *) override
std::vector< double > t_dEStep1_
void setNumberCheckedHits(int val)
std::vector< double > t_dEStep2_
std::vector< int > t_Layer_
std::vector< double > angles_
T * make(const Args &...args) const
make new ROOT object
Compact representation of the geometrical detector hierarchy.
HGCalGeometryMode::GeometryMode geom_mode_
std::unique_ptr< HGCMouseBite > mouseBite_
Tan< T >::type tan(const T &t)
Abs< T >::type abs(const T &t)
HGCalGeometryMode::GeometryMode geomMode() const
std::vector< int > t_Parcode_
std::unique_ptr< HGCNumberingScheme > numberingScheme_
void initEvent(const BeginOfEvent *) override
std::vector< double > t_Angle_
HGCSD(const std::string &, const DDCompactView &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
uint32_t setDetUnitId(const G4Step *step) override
void update(const BeginOfJob *) override
This routine will be called when the appropriate signal arrives.
bool filterHit(CaloG4Hit *, double) override
int levelTop(int ind=0) const
double getResponseWt(const G4Track *)
ForwardSubdetector myFwdSubdet_
static void unpackHexagonIndex(const uint32_t &idx, int &subdet, int &z, int &lay, int &wafer, int &celltyp, int &cell)
double getEnergyDeposit() const
T angle(T x1, T y1, T z1, T x2, T y2, T z2)