9 #include "G4SDManager.hh"
12 #include "G4VProcess.hh"
15 #include "G4Cerenkov.hh"
16 #include "G4ParticleTable.hh"
17 #include "CLHEP/Units/GlobalSystemOfUnits.h"
18 #include "Randomize.hh"
19 #include "G4Poisson.hh"
30 int verbn = verbosity/10;
37 <<
"***************************************************\n"
39 <<
"* Constructing a ZdcSD with name " << name <<
" *\n"
41 <<
"***************************************************";
44 <<
"\nUse of shower library is set to "
46 <<
"\nUse of Shower hits method is set to "
50 <<
"\nEnergy Threshold Cut set to "
51 << zdcHitEnergyCut/GeV
70 G4ParticleTable *theParticleTable = G4ParticleTable::GetParticleTable();
125 <<
"----------------New track------------------------------\n"
126 <<
"Incident EnergyTrack: "<<etrack<<
" MeV \n"
128 <<
"ZdcSD::getFromLibrary " <<
hits.size() <<
" hits for "
129 << GetName() <<
" of " << primaryID <<
" with "
130 <<
theTrack->GetDefinition()->GetParticleName() <<
" of "
137 for (
unsigned int i=0;
i<
hits.size();
i++) {
141 unsigned int unitID =
hits[
i].detID;
159 LogDebug(
"ForwardSim") <<
"ZdcSD: Final Hit number:"<<
i<<
"-->"
171 theTrack->SetTrackStatus(fStopAndKill);
172 G4TrackVector tv = *(aStep->GetSecondary());
173 for (
unsigned int kk=0; kk<tv.size(); kk++) {
175 tv[kk]->SetTrackStatus(fStopAndKill);
182 float NCherPhot = 0.;
186 LogDebug(
"ForwardSim") <<
"ZdcSD:: getEnergyDeposit: aStep is NULL!";
190 G4SteppingControl stepControlFlag = aStep->GetControlFlag();
192 G4VPhysicalVolume* currentPV = preStepPoint->GetPhysicalVolume();
193 G4String nameVolume = currentPV->GetName();
195 G4ThreeVector hitPoint = preStepPoint->GetPosition();
196 G4ThreeVector hit_mom = preStepPoint->GetMomentumDirection();
197 G4double stepL = aStep->GetStepLength()/cm;
198 G4double
beta = preStepPoint->GetBeta();
199 G4double
charge = preStepPoint->GetCharge();
208 G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
209 G4VPhysicalVolume* postPV = postStepPoint->GetPhysicalVolume();
210 G4String postnameVolume = postPV->GetName();
213 G4Track*
theTrack = aStep->GetTrack();
214 G4String particleType = theTrack->GetDefinition()->GetParticleName();
215 G4int primaryID = theTrack->GetTrackID();
216 G4double entot = theTrack->GetTotalEnergy();
217 G4ThreeVector vert_mom = theTrack->GetVertexMomentumDirection();
218 G4ThreeVector localPoint = theTrack->GetTouchable()->GetHistory()->GetTopTransform().TransformPoint(hitPoint);
221 float costheta = vert_mom.z()/
sqrt(vert_mom.x()*vert_mom.x()+
222 vert_mom.y()*vert_mom.y()+
223 vert_mom.z()*vert_mom.z());
227 if (vert_mom.x() != 0) phi = atan2(vert_mom.y(),vert_mom.x());
228 if (phi < 0.) phi += twopi;
231 double stepE = aStep->GetTotalEnergyDeposit();
233 <<
"ZdcSD:: getEnergyDeposit: "
234 <<
"*****************HHHHHHHHHHHHHHHHHHHHHHHHHHLLLLLLLLLlllllllllll&&&&&&&&&&\n"
235 <<
" preStepPoint: " << nameVolume <<
"," << stepL <<
"," << stepE
236 <<
"," << beta <<
"," << charge <<
"\n"
237 <<
" postStepPoint: " << postnameVolume <<
"," << costheta <<
","
238 << theta <<
"," << eta <<
"," << phi <<
"," << particleType <<
","
241 float bThreshold = 0.67;
242 if ((beta > bThreshold) && (charge != 0) && (nameVolume ==
"ZDC_EMFiber" || nameVolume ==
"ZDC_HadFiber")) {
243 LogDebug(
"ForwardSim") <<
"ZdcSD:: getEnergyDeposit: pass ";
245 float nMedium = 1.4925;
249 float photEnSpectrDE = 1.24;
255 float effPMTandTransport = 0.15;
258 float thFullRefl = 23.;
259 float thFullReflRad = thFullRefl*
pi/180.;
264 float thFibDirRad = thFibDir*
pi/180.;
270 float costh = hit_mom.z()/
sqrt(hit_mom.x()*hit_mom.x()+
271 hit_mom.y()*hit_mom.y()+
272 hit_mom.z()*hit_mom.z());
275 if (th < 0.) th += twopi;
278 float costhcher =1./(nMedium*
beta);
282 float DelFibPart = fabs(th - thFibDirRad);
285 float d = fabs(
tan(th)-
tan(thFibDirRad));
289 float a =
tan(thFibDirRad)+
tan(fabs(thFibDirRad-thFullReflRad));
290 float r =
tan(th)+
tan(fabs(th-thcher));
305 if (DelFibPart > (thFullReflRad + thcher) ) {
306 variant = 0.; d_qz = 0.;
309 if ((th + thcher) < (thFibDirRad+thFullReflRad) && (th - thcher) > (thFibDirRad-thFullReflRad) ) {
310 variant = 1.; d_qz = 1.;
313 if ((thFibDirRad + thFullReflRad) < (th + thcher) && (thFibDirRad - thFullReflRad) > (th - thcher) ) {
314 variant = 2.; d_qz = 0.;
320 float arg_arcos = 0.;
321 float tan_arcos = 2.*a*d;
322 if (tan_arcos != 0.) arg_arcos =(r*r-a*a-d*d)/tan_arcos;
324 arg_arcos = fabs(arg_arcos);
328 d_qz = th_arcos/
pi/2.;
338 double meanNCherPhot = 0.;
339 G4int poissNCherPhot = 0;
341 meanNCherPhot = 370.*charge*charge*( 1. - 1./(nMedium*nMedium*beta*
beta) ) * photEnSpectrDE * stepL;
345 poissNCherPhot = (G4int) G4Poisson(meanNCherPhot);
347 if (poissNCherPhot < 0) poissNCherPhot = 0;
350 NCherPhot = poissNCherPhot * effPMTandTransport * d_qz;
354 <<
"ZdcSD:: getEnergyDeposit: gED: "
366 <<
"," << stepControlFlag
375 <<
"," << meanNCherPhot
376 <<
"," << poissNCherPhot
394 if (beta <= bThreshold)
396 <<
"ZdcSD:: getEnergyDeposit: fail beta=" <<
beta;
399 <<
"ZdcSD:: getEnergyDeposit: fail charge=0";
400 if ( !(nameVolume ==
"ZDC_EMFiber" || nameVolume ==
"ZDC_HadFiber") )
402 <<
"ZdcSD:: getEnergyDeposit: fail nv=" << nameVolume;
410 uint32_t returnNumber = 0;
418 edm::LogInfo(
"ForwardSim") <<
"ZdcSD: updates numbering scheme for "
430 if (primaryID == 0) {
432 LogDebug(
"ZdcSD") <<
"ZdcSD: Problem with primaryID **** set by force "
433 <<
"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
std::vector< Hit > & getHits(G4Step *aStep, bool &ok)
type of data representation of DDCompactView
static TrackerG4SimHitNumberingScheme & numberingScheme(const DDCompactView &cpv, const GeometricDet &det)
const T & max(const T &a, const T &b)
Tan< T >::type tan(const T &t)
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)
virtual bool ProcessHits(G4Step *step, G4TouchableHistory *tHistory)
math::XYZPoint getEntryLocal() const
int setTrackID(G4Step *step)
void resetForNewPrimary(G4ThreeVector, double)
ZdcSD(G4String, const DDCompactView &, SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
uint32_t getUnitID() const
void initRun(G4ParticleTable *theParticleTable)
virtual uint32_t setDetUnitId(G4Step *step)
CaloG4Hit * createNewHit()
G4ThreeVector entrancePoint
G4ThreeVector entranceLocal
ZdcShowerLibrary * showerLibrary