14 #include "G4NavigationHistory.hh"
17 #include "G4VSolid.hh"
18 #include "Randomize.hh"
19 #include "CLHEP/Units/GlobalPhysicalConstants.h"
20 #include "CLHEP/Units/GlobalSystemOfUnits.h"
35 edm::LogInfo(
"HFShower") <<
"HFShower:: Maximum probability cut off "
36 << probMax <<
" Check flag " <<
chkFibre;
49 std::vector<HFShower::Hit> hits;
52 double edep = weight*(aStep->GetTotalEnergyDeposit());
54 edm::LogInfo(
"HFShower") <<
"HFShower::getHits: energy " << aStep->GetTotalEnergyDeposit() <<
" weight " << weight <<
" edep " << edep;
58 if (aStep->GetTrack()->GetDefinition()->GetPDGCharge() != 0.)
59 stepl = aStep->GetStepLength();
60 if ((edep == 0.) || (stepl == 0.)) {
62 edm::LogInfo(
"HFShower") <<
"HFShower::getHits: Number of Hits " << nHit;
66 G4Track *aTrack = aStep->GetTrack();
67 const G4DynamicParticle *aParticle = aTrack->GetDynamicParticle();
70 double energy = aParticle->GetTotalEnergy();
71 double momentum = aParticle->GetTotalMomentum();
72 double pBeta = momentum /
energy;
76 G4ThreeVector momentumDir = aParticle->GetMomentumDirection();
77 G4ParticleDefinition *particleDef = aTrack->GetDefinition();
79 G4StepPoint * preStepPoint = aStep->GetPreStepPoint();
80 G4ThreeVector globalPos = preStepPoint->GetPosition();
81 G4String
name = preStepPoint->GetTouchable()->GetSolid(0)->GetName();
84 G4ThreeVector localPos = G4ThreeVector(globalPos.x(),globalPos.y(), zv);
85 G4ThreeVector localMom = preStepPoint->GetTouchable()->GetHistory()->
86 GetTopTransform().TransformAxis(momentumDir);
91 if (zv < 0. || zv >
gpar[1]) {
98 }
else if (npmt > 24) {
107 <<
" zv " <<
std::abs(globalPos.z())
108 <<
":" << gpar[4] <<
":" << zv <<
":"
109 << gpar[0] <<
" ok " << ok <<
" depth " << depth;
112 depth = (preStepPoint->GetTouchable()->GetReplicaNumber(0))%10;
114 G4ThreeVector translation =
115 preStepPoint->GetTouchable()->GetVolume(1)->GetObjectTranslation();
117 double u = localMom.x();
118 double v = localMom.y();
119 double w = localMom.z();
120 double zCoor = localPos.z();
121 double zFibre = (0.5*gpar[1]-zCoor-translation.z());
122 double tSlice = (aStep->GetPostStepPoint()->GetGlobalTime());
126 edm::LogInfo(
"HFShower") <<
"HFShower::getHits: in " << name <<
" Z "
127 << zCoor <<
"(" << globalPos.z() <<
") " << zFibre
128 <<
" Trans " << translation <<
" Time " << tSlice
129 <<
" " << time <<
"\n Direction "
130 << momentumDir <<
" Local " << localMom;
134 std::vector<double> wavelength;
135 std::vector<double> momz;
137 if (ok) npe =
cherenkov->
computeNPE(aStep,particleDef,pBeta,u,v,w,stepl,zFibre,dose, npeDose);
142 for (
int i = 0;
i<npe; ++
i) {
145 double r1 = G4UniformRand();
146 double r2 = G4UniformRand();
148 edm::LogInfo(
"HFShower") <<
"HFShower::getHits: " << i <<
" attenuation "
149 << r1 <<
":" <<
exp(-p*zFibre) <<
" r2 " << r2
150 <<
":" <<
probMax <<
" Survive: "
171 edm::LogInfo(
"HFShower") <<
"HFShower::getHits: Number of Hits " << nHit;
172 for (
int i=0;
i<nHit; ++
i)
173 edm::LogInfo(
"HFShower") <<
"HFShower::Hit " <<
i <<
" WaveLength "
174 << hits[
i].wavelength <<
" Time " << hits[
i].time
175 <<
" Momentum " << hits[
i].momentum <<
" Position "
183 bool forLibraryProducer,
186 std::vector<HFShower::Hit> hits;
189 double edep = aStep->GetTotalEnergyDeposit();
192 if (aStep->GetTrack()->GetDefinition()->GetPDGCharge() != 0.)
193 stepl = aStep->GetStepLength();
194 if ((edep == 0.) || (stepl == 0.)) {
196 edm::LogInfo(
"HFShower") <<
"HFShower::getHits: Number of Hits " << nHit;
200 G4Track *aTrack = aStep->GetTrack();
201 const G4DynamicParticle *aParticle = aTrack->GetDynamicParticle();
204 double energy = aParticle->GetTotalEnergy();
205 double momentum = aParticle->GetTotalMomentum();
206 double pBeta = momentum /
energy;
210 G4ThreeVector momentumDir = aParticle->GetMomentumDirection();
211 G4ParticleDefinition *particleDef = aTrack->GetDefinition();
213 G4StepPoint * preStepPoint = aStep->GetPreStepPoint();
214 G4ThreeVector globalPos = preStepPoint->GetPosition();
215 G4String
name = preStepPoint->GetTouchable()->GetSolid(0)->GetName();
218 double zv =
gpar[1]-(
std::abs(globalPos.z()) - zoffset);
219 G4ThreeVector localPos = G4ThreeVector(globalPos.x(),globalPos.y(), zv);
220 G4ThreeVector localMom = preStepPoint->GetTouchable()->GetHistory()->
221 GetTopTransform().TransformAxis(momentumDir);
226 if (zv < 0. || zv >
gpar[1]) {
233 }
else if (npmt > 24) {
242 <<
" zv " <<
std::abs(globalPos.z())
243 <<
":" << gpar[4] <<
":" << zv <<
":"
244 << gpar[0] <<
" ok " << ok <<
" depth " << depth;
247 depth = (preStepPoint->GetTouchable()->GetReplicaNumber(0))%10;
249 G4ThreeVector translation =
250 preStepPoint->GetTouchable()->GetVolume(1)->GetObjectTranslation();
252 double u = localMom.x();
253 double v = localMom.y();
254 double w = localMom.z();
255 double zCoor = localPos.z();
256 double zFibre = (0.5*gpar[1]-zCoor-translation.z());
257 double tSlice = (aStep->GetPostStepPoint()->GetGlobalTime());
261 edm::LogInfo(
"HFShower") <<
"HFShower::getHits: in " << name <<
" Z " <<zCoor
262 <<
"(" << globalPos.z() <<
") " << zFibre <<
" Trans "
263 << translation <<
" Time " << tSlice <<
" " << time
264 <<
"\n Direction " << momentumDir
265 <<
" Local " << localMom;
269 std::vector<double> wavelength;
270 std::vector<double> momz;
272 if (ok) npe =
cherenkov->
computeNPE(aStep,particleDef,pBeta,u,v,w,stepl,zFibre,dose, npeDose);
277 for (
int i = 0;
i<npe; ++
i) {
280 double r1 = G4UniformRand();
281 double r2 = G4UniformRand();
283 edm::LogInfo(
"HFShower") <<
"HFShower::getHits: " << i <<
" attenuation "
284 << r1 <<
":" <<
exp(-p*zFibre) <<
" r2 " << r2
285 <<
":" <<
probMax <<
" Survive: "
306 edm::LogInfo(
"HFShower") <<
"HFShower::getHits: Number of Hits " << nHit;
307 for (
int i=0;
i<nHit; ++
i)
308 edm::LogInfo(
"HFShower") <<
"HFShower::Hit " <<
i <<
" WaveLength "
309 << hits[
i].wavelength <<
" Time " << hits[
i].time
310 <<
" Momentum " << hits[
i].momentum <<
" Position "
318 std::vector<HFShower::Hit> hits;
321 double edep = aStep->GetTotalEnergyDeposit();
324 if (aStep->GetTrack()->GetDefinition()->GetPDGCharge() != 0.)
325 stepl = aStep->GetStepLength();
326 if ((edep == 0.) || (stepl == 0.)) {
328 edm::LogInfo(
"HFShower") <<
"HFShower::getHits: Number of Hits " << nHit;
333 G4Track *aTrack = aStep->GetTrack();
334 const G4DynamicParticle *aParticle = aTrack->GetDynamicParticle();
337 double energy = aParticle->GetTotalEnergy();
338 double momentum = aParticle->GetTotalMomentum();
339 double pBeta = momentum /
energy;
343 G4ThreeVector momentumDir = aParticle->GetMomentumDirection();
344 G4ParticleDefinition *particleDef = aTrack->GetDefinition();
346 G4StepPoint * preStepPoint = aStep->GetPreStepPoint();
347 G4ThreeVector globalPos = preStepPoint->GetPosition();
348 G4String
name = preStepPoint->GetTouchable()->GetSolid(0)->GetName();
350 G4ThreeVector localPos = G4ThreeVector(globalPos.x(),globalPos.y(), zv);
351 G4ThreeVector localMom = preStepPoint->GetTouchable()->GetHistory()->
352 GetTopTransform().TransformAxis(momentumDir);
357 if (zv < 0 || zv >
gpar[1]) {
364 }
else if (npmt > 24) {
372 edm::LogInfo(
"HFShower") <<
"HFShower:getHits(SL): npmt " << npmt
373 <<
" zv " <<
std::abs(globalPos.z())
374 <<
":" << gpar[4] <<
":" << zv <<
":"
375 << gpar[0] <<
" ok " << ok <<
" depth " << depth;
378 depth = (preStepPoint->GetTouchable()->GetReplicaNumber(0))%10;
380 G4ThreeVector translation =
381 preStepPoint->GetTouchable()->GetVolume(1)->GetObjectTranslation();
383 double u = localMom.x();
384 double v = localMom.y();
385 double w = localMom.z();
386 double zCoor = localPos.z();
387 double zFibre = (0.5*gpar[1]-zCoor-translation.z());
388 double tSlice = (aStep->GetPostStepPoint()->GetGlobalTime());
392 edm::LogInfo(
"HFShower") <<
"HFShower::getHits(SL): in " << name <<
" Z "
393 << zCoor <<
"(" << globalPos.z() <<
") " << zFibre
394 <<
" Trans " << translation <<
" Time " << tSlice
395 <<
" " << time <<
"\n Direction "
396 << momentumDir <<
" Local " << localMom;
400 if(ok) npe =
cherenkov->
computeNPE(aStep,particleDef,pBeta,u,v,w, stepl,zFibre, dose, npeDose);
404 for (
int i = 0;
i<npe; ++
i) {
420 LogDebug(
"HFShower") <<
"HFShower:getDDDArray called for " << str
421 <<
" with nMin " << nmin;
428 const std::vector<double> & fvec = value.
doubles();
429 int nval = fvec.size();
432 edm::LogError(
"HFShower") <<
"HFShower : # of " << str <<
" bins "
433 << nval <<
" < " << nmin <<
" ==> illegal";
435 <<
"nval < nmin for array " << str <<
"\n";
439 edm::LogError(
"HFShower") <<
"HFShower : # of " << str <<
" bins " << nval
440 <<
" < 2 ==> illegal" <<
" (nmin=" << nmin <<
")";
442 <<
"nval < 2 for array " << str <<
"\n";
449 edm::LogError(
"HFShower") <<
"HFShower : cannot get array " << str;
450 throw cms::Exception(
"Unknown",
"HFShower") <<
"cannot get array " << str <<
"\n";
459 for (
unsigned int ig=0; ig<
gpar.size(); ig++)
460 edm::LogInfo(
"HFShower") <<
"HFShower: gpar[" << ig <<
"] = "
461 <<
gpar[ig]/cm <<
" cm";
double tShift(const G4ThreeVector &point, int depth, int fromEndAbs=0)
T getParameter(std::string const &) const
const std::vector< double > & doubles() const
a reference to the double-valued values stored in the given instance of DDValue
void initRun(HcalDDDSimConstants *)
void initRun(G4ParticleTable *, HcalDDDSimConstants *)
double attLength(double lambda)
type of data representation of DDCompactView
bool DDfetch(const DDsvalues_type *, DDValue &)
helper for retrieving DDValues from DDsvalues_type *.
static int PMTNumber(const G4ThreeVector &pe_effect)
std::vector< double > getWL()
std::vector< std::pair< unsigned int, DDValue > > DDsvalues_type
std::maps an index to a DDValue. The index corresponds to the index assigned to the name of the std::...
std::vector< Hit > getHits(G4Step *aStep, double weight)
Abs< T >::type abs(const T &t)
std::vector< double > getMom()
std::vector< double > gpar
const std::vector< double > & getGparHF() const
HFShower(const RandomEngineAndDistribution *engine, HDShowerParametrization *myParam, EcalHitMaker *myGrid, HcalHitMaker *myHcalHitMaker, int onECAL, double epart)
std::vector< double > getDDDArray(const std::string &, const DDsvalues_type &, int &)
int computeNPE(G4Step *step, G4ParticleDefinition *pDef, double pBeta, double u, double v, double w, double step_length, double zFiber, double Dose, int Npe_Dose)