11 #include "G4SDManager.hh" 14 #include "G4VProcess.hh" 16 #include "G4Cerenkov.hh" 17 #include "G4ParticleTable.hh" 18 #include "CLHEP/Units/GlobalSystemOfUnits.h" 19 #include "CLHEP/Units/GlobalPhysicalConstants.h" 20 #include "Randomize.hh" 21 #include "G4Poisson.hh" 32 int verbn = verbosity/10;
39 <<
"***************************************************\n" 41 <<
"* Constructing a ZdcSD with name " << name <<
" *\n" 43 <<
"***************************************************";
46 <<
"\nUse of shower library is set to " 48 <<
"\nUse of Shower hits method is set to " 52 <<
"\nEnergy Threshold Cut set to " 53 << zdcHitEnergyCut/
GeV 72 G4ParticleTable *theParticleTable = G4ParticleTable::GetParticleTable();
82 if (aStep ==
nullptr) {
127 <<
"----------------New track------------------------------\n" 128 <<
"Incident EnergyTrack: "<<etrack<<
" MeV \n" 130 <<
"ZdcSD::getFromLibrary " <<
hits.size() <<
" hits for " 131 << GetName() <<
" of " << primaryID <<
" with " 132 <<
theTrack->GetDefinition()->GetParticleName() <<
" of " 139 for (
unsigned int i=0;
i<
hits.size();
i++) {
143 unsigned int unitID =
hits[
i].detID;
161 LogDebug(
"ForwardSim") <<
"ZdcSD: Final Hit number:"<<
i<<
"-->" 173 theTrack->SetTrackStatus(fStopAndKill);
174 G4TrackVector tv = *(aStep->GetSecondary());
175 for (
unsigned int kk=0;
kk<tv.size();
kk++) {
177 tv[
kk]->SetTrackStatus(fStopAndKill);
184 float NCherPhot = 0.;
187 if (aStep ==
nullptr) {
188 LogDebug(
"ForwardSim") <<
"ZdcSD:: getEnergyDeposit: aStep is NULL!";
192 G4SteppingControl stepControlFlag = aStep->GetControlFlag();
194 G4VPhysicalVolume* currentPV = preStepPoint->GetPhysicalVolume();
195 const G4String& nameVolume = currentPV->GetName();
197 const G4ThreeVector& hitPoint = preStepPoint->GetPosition();
198 const G4ThreeVector& hit_mom = preStepPoint->GetMomentumDirection();
199 G4double stepL = aStep->GetStepLength()/cm;
200 G4double
beta = preStepPoint->GetBeta();
201 G4double
charge = preStepPoint->GetCharge();
210 G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
211 G4VPhysicalVolume* postPV = postStepPoint->GetPhysicalVolume();
212 const G4String& postnameVolume = postPV->GetName();
215 G4Track*
theTrack = aStep->GetTrack();
216 G4String
particleType = theTrack->GetDefinition()->GetParticleName();
217 G4int primaryID = theTrack->GetTrackID();
218 G4double entot = theTrack->GetTotalEnergy();
219 const G4ThreeVector& vert_mom = theTrack->GetVertexMomentumDirection();
220 G4ThreeVector localPoint = theTrack->GetTouchable()->GetHistory()->GetTopTransform().TransformPoint(hitPoint);
223 float costheta = vert_mom.z()/
sqrt(vert_mom.x()*vert_mom.x()+
224 vert_mom.y()*vert_mom.y()+
225 vert_mom.z()*vert_mom.z());
229 if (vert_mom.x() != 0) phi = atan2(vert_mom.y(),vert_mom.x());
230 if (phi < 0.) phi += twopi;
233 double stepE = aStep->GetTotalEnergyDeposit();
235 <<
"ZdcSD:: getEnergyDeposit: " 236 <<
"*****************HHHHHHHHHHHHHHHHHHHHHHHHHHLLLLLLLLLlllllllllll&&&&&&&&&&\n" 237 <<
" preStepPoint: " << nameVolume <<
"," << stepL <<
"," << stepE
238 <<
"," << beta <<
"," << charge <<
"\n" 239 <<
" postStepPoint: " << postnameVolume <<
"," << costheta <<
"," 240 << theta <<
"," << eta <<
"," << phi <<
"," << particleType <<
"," 243 float bThreshold = 0.67;
244 if ((beta > bThreshold) && (charge != 0) && (nameVolume ==
"ZDC_EMFiber" || nameVolume ==
"ZDC_HadFiber")) {
245 LogDebug(
"ForwardSim") <<
"ZdcSD:: getEnergyDeposit: pass ";
247 float nMedium = 1.4925;
251 float photEnSpectrDE = 1.24;
257 float effPMTandTransport = 0.15;
260 float thFullRefl = 23.;
261 float thFullReflRad = thFullRefl*
pi/180.;
266 float thFibDirRad = thFibDir*
pi/180.;
272 float costh = hit_mom.z()/
sqrt(hit_mom.x()*hit_mom.x()+
273 hit_mom.y()*hit_mom.y()+
274 hit_mom.z()*hit_mom.z());
277 if (th < 0.) th += twopi;
280 float costhcher =1./(nMedium*
beta);
284 float DelFibPart = fabs(th - thFibDirRad);
287 float d = fabs(
tan(th)-
tan(thFibDirRad));
291 float a =
tan(thFibDirRad)+
tan(fabs(thFibDirRad-thFullReflRad));
292 float r =
tan(th)+
tan(fabs(th-thcher));
307 if (DelFibPart > (thFullReflRad + thcher) ) {
308 variant = 0.; d_qz = 0.;
311 if ((th + thcher) < (thFibDirRad+thFullReflRad) && (th - thcher) > (thFibDirRad-thFullReflRad) ) {
312 variant = 1.; d_qz = 1.;
315 if ((thFibDirRad + thFullReflRad) < (th + thcher) && (thFibDirRad - thFullReflRad) > (th - thcher) ) {
316 variant = 2.; d_qz = 0.;
322 float arg_arcos = 0.;
323 float tan_arcos = 2.*a*
d;
324 if (tan_arcos != 0.) arg_arcos =(r*r-a*a-d*
d)/tan_arcos;
326 arg_arcos = fabs(arg_arcos);
330 d_qz = th_arcos/
pi/2.;
340 double meanNCherPhot = 0.;
341 G4int poissNCherPhot = 0;
343 meanNCherPhot = 370.*charge*charge*( 1. - 1./(nMedium*nMedium*beta*
beta) ) * photEnSpectrDE * stepL;
347 poissNCherPhot = (G4int) G4Poisson(meanNCherPhot);
349 if (poissNCherPhot < 0) poissNCherPhot = 0;
352 NCherPhot = poissNCherPhot * effPMTandTransport * d_qz;
356 <<
"ZdcSD:: getEnergyDeposit: gED: " 368 <<
"," << stepControlFlag
377 <<
"," << meanNCherPhot
378 <<
"," << poissNCherPhot
396 if (beta <= bThreshold)
398 <<
"ZdcSD:: getEnergyDeposit: fail beta=" <<
beta;
401 <<
"ZdcSD:: getEnergyDeposit: fail charge=0";
402 if ( !(nameVolume ==
"ZDC_EMFiber" || nameVolume ==
"ZDC_HadFiber") )
404 <<
"ZdcSD:: getEnergyDeposit: fail nv=" << nameVolume;
412 uint32_t returnNumber = 0;
419 if (scheme !=
nullptr) {
420 edm::LogInfo(
"ForwardSim") <<
"ZdcSD: updates numbering scheme for " 432 if (primaryID == 0) {
434 LogDebug(
"ZdcSD") <<
"ZdcSD: Problem with primaryID **** set by force " 435 <<
"to TkID **** " <<
theTrack->GetTrackID();
void setNumberingScheme(ZdcNumberingScheme *scheme)
T getParameter(std::string const &) const
void updateHit(CaloG4Hit *)
virtual unsigned int getUnitID(const G4Step *aStep) const
std::vector< ZdcShowerLibrary::Hit > hits
void setIncidentEnergy(double e)
virtual double getEnergyDeposit(G4Step *, edm::ParameterSet const &)
Geom::Theta< T > theta() const
ZdcNumberingScheme * numberingScheme
double getIncidentEnergy() const
ZdcSD(G4String, const DDCompactView &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
std::vector< Hit > & getHits(G4Step *aStep, bool &ok)
type of data representation of DDCompactView
static TrackerG4SimHitNumberingScheme & numberingScheme(const DDCompactView &cpv, const GeometricDet &det)
void resetForNewPrimary(const G4ThreeVector &, double)
Tan< T >::type tan(const T &t)
bool ProcessHits(G4Step *step, G4TouchableHistory *tHistory) override
void NaNTrap(G4Step *step)
virtual G4bool getStepInfo(G4Step *aStep)
void setID(uint32_t unitID, double timeSlice, int trackID, uint16_t depth=0)
G4StepPoint * preStepPoint
void getFromLibrary(G4Step *step)
static const G4LogicalVolume * GetVolume(const std::string &name)
math::XYZPoint getEntryLocal() const
int setTrackID(G4Step *step)
uint32_t getUnitID() const
void initRun(G4ParticleTable *theParticleTable)
CaloG4Hit * createNewHit()
G4ThreeVector entrancePoint
G4ThreeVector entranceLocal
uint32_t setDetUnitId(G4Step *step) override
ZdcShowerLibrary * showerLibrary