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;
243 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
397 if (beta <= bThreshold)
399 <<
"ZdcSD:: getEnergyDeposit: fail beta=" <<
beta;
402 <<
"ZdcSD:: getEnergyDeposit: fail charge=0";
403 if ( !(nameVolume ==
"ZDC_EMFiber" || nameVolume ==
"ZDC_HadFiber") )
405 <<
"ZdcSD:: getEnergyDeposit: fail nv=" << nameVolume;
413 uint32_t returnNumber = 0;
421 edm::LogInfo(
"ForwardSim") <<
"ZdcSD: updates numbering scheme for "
433 if (primaryID == 0) {
435 LogDebug(
"ZdcSD") <<
"ZdcSD: Problem with primaryID **** set by force "
436 <<
"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 &)
ZdcNumberingScheme * numberingScheme
double getIncidentEnergy() const
Geom::Theta< T > theta() 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)
Log< T >::type log(const T &t)
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