CMS 3D CMS Logo

List of all members | Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes
DreamSD Class Reference

#include <DreamSD.h>

Inheritance diagram for DreamSD:
CaloSD SensitiveCaloDetector Observer< const BeginOfRun * > Observer< const BeginOfEvent * > Observer< const BeginOfTrack * > Observer< const EndOfTrack * > Observer< const EndOfEvent * > SensitiveDetector

Public Member Functions

 DreamSD (const std::string &, const DDCompactView &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
 
uint32_t setDetUnitId (const G4Step *) override
 
 ~DreamSD () override
 
- Public Member Functions inherited from CaloSD
 CaloSD (const std::string &aSDname, const DDCompactView &cpv, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p, const SimTrackManager *, float timeSlice=1., bool ignoreTkID=false)
 
void clear () override
 
void clearHits () override
 
void DrawAll () override
 
void EndOfEvent (G4HCofThisEvent *eventHC) override
 
void fillHits (edm::PCaloHitContainer &, const std::string &) override
 
void Initialize (G4HCofThisEvent *HCE) override
 
void PrintAll () override
 
G4bool ProcessHits (G4Step *step, G4TouchableHistory *) override
 
bool ProcessHits (G4GFlashSpot *aSpot, G4TouchableHistory *) override
 
void reset () override
 
 ~CaloSD () override
 
- Public Member Functions inherited from SensitiveCaloDetector
 SensitiveCaloDetector (const std::string &iname, const DDCompactView &cpv, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p)
 
- Public Member Functions inherited from SensitiveDetector
void EndOfEvent (G4HCofThisEvent *eventHC) override
 
const std::vector< std::string > & getNames () const
 
void Initialize (G4HCofThisEvent *eventHC) override
 
bool isCaloSD () const
 
 SensitiveDetector (const std::string &iname, const DDCompactView &cpv, const SensitiveDetectorCatalog &, edm::ParameterSet const &p, bool calo)
 
 ~SensitiveDetector () override
 
- Public Member Functions inherited from Observer< const BeginOfRun * >
 Observer ()
 
void slotForUpdate (const BeginOfRun * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const BeginOfEvent * >
 Observer ()
 
void slotForUpdate (const BeginOfEvent * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const BeginOfTrack * >
 Observer ()
 
void slotForUpdate (const BeginOfTrack * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const EndOfTrack * >
 Observer ()
 
void slotForUpdate (const EndOfTrack * iT)
 
virtual ~Observer ()
 
- Public Member Functions inherited from Observer< const EndOfEvent * >
 Observer ()
 
void slotForUpdate (const EndOfEvent * iT)
 
virtual ~Observer ()
 

Protected Member Functions

double getEnergyDeposit (const G4Step *) override
 
void initRun () override
 
- Protected Member Functions inherited from CaloSD
bool checkHit ()
 
CaloG4HitcreateNewHit (const G4Step *)
 
virtual void endEvent ()
 
virtual bool filterHit (CaloG4Hit *, double)
 
double getAttenuation (const G4Step *aStep, double birk1, double birk2, double birk3) const
 
virtual uint16_t getDepth (const G4Step *)
 
virtual bool getFromLibrary (const G4Step *step)
 
int getNumberOfHits ()
 
double getResponseWt (const G4Track *)
 
virtual int getTrackID (const G4Track *)
 
bool hitExists (const G4Step *)
 
virtual void initEvent (const BeginOfEvent *)
 
void processHit (const G4Step *step)
 
void resetForNewPrimary (const G4Step *)
 
void setNumberCheckedHits (int val)
 
void setParameterized (bool val)
 
G4ThreeVector setToGlobal (const G4ThreeVector &, const G4VTouchable *) const
 
G4ThreeVector setToLocal (const G4ThreeVector &, const G4VTouchable *) const
 
virtual int setTrackID (const G4Step *)
 
void setUseMap (bool val)
 
void update (const BeginOfRun *) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const BeginOfEvent *) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const BeginOfTrack *trk) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const EndOfTrack *trk) override
 This routine will be called when the appropriate signal arrives. More...
 
void update (const ::EndOfEvent *) override
 
void updateHit (CaloG4Hit *)
 
- Protected Member Functions inherited from SensitiveDetector
TrackInformationcmsTrackInformation (const G4Track *aTrack)
 
Local3DPoint ConvertToLocal3DPoint (const G4ThreeVector &point) const
 
Local3DPoint FinalStepPosition (const G4Step *step, coordinates) const
 
Local3DPoint InitialStepPosition (const G4Step *step, coordinates) const
 
Local3DPoint LocalPostStepPosition (const G4Step *step) const
 
Local3DPoint LocalPreStepPosition (const G4Step *step) const
 
void NaNTrap (const G4Step *step) const
 
void setNames (const std::vector< std::string > &)
 
- Protected Member Functions inherited from Observer< const EndOfEvent * >
virtual void update (const EndOfEvent *)=0
 This routine will be called when the appropriate signal arrives. More...
 

Private Types

typedef std::map< G4LogicalVolume *, DoublesDimensionMap
 
typedef std::pair< double, double > Doubles
 

Private Member Functions

double cherenkovDeposit_ (const G4Step *aStep)
 Returns the total energy due to Cherenkov radiation. More...
 
double crystalLength (G4LogicalVolume *) const
 
double crystalWidth (G4LogicalVolume *) const
 
double curve_LY (const G4Step *, int)
 
double getAverageNumberOfPhotons_ (const double charge, const double beta, const G4Material *aMaterial, const G4MaterialPropertyVector *rIndex)
 Returns average number of photons created by track. More...
 
double getPhotonEnergyDeposit_ (const G4ParticleMomentum &p, const G4ThreeVector &x, const G4Step *aStep)
 Returns energy deposit for a given photon. More...
 
void initMap (const std::string &, const DDCompactView &)
 
bool setPbWO2MaterialProperties_ (G4Material *aMaterial)
 Sets material properties at run-time... More...
 

Private Attributes

double birk1
 
double birk2
 
double birk3
 
std::unique_ptr< G4PhysicsOrderedFreeVector > chAngleIntegrals_
 Table of Cherenkov angle integrals vs photon momentum. More...
 
bool doCherenkov_
 
G4MaterialPropertiesTable * materialPropertiesTable
 
int nphotons_
 
bool readBothSide_
 
int side
 
double slopeLY
 
bool useBirk
 
DimensionMap xtalLMap
 

Additional Inherited Members

- Protected Types inherited from SensitiveDetector
enum  coordinates { WorldCoordinates, LocalCoordinates }
 
- Protected Attributes inherited from CaloSD
CaloG4HitcurrentHit
 
CaloHitID currentID
 
float edepositEM
 
float edepositHAD
 
double eminHit
 
double energyCut
 
G4ThreeVector entranceLocal
 
G4ThreeVector entrancePoint
 
bool forceSave
 
float incidentEnergy
 
double kmaxIon
 
double kmaxNeutron
 
double kmaxProton
 
G4ThreeVector posGlobal
 
CaloHitID previousID
 
bool suppressHeavy
 
double tmaxHit
 

Detailed Description

Definition at line 15 of file DreamSD.h.

Member Typedef Documentation

typedef std::map<G4LogicalVolume *, Doubles> DreamSD::DimensionMap
private

Definition at line 32 of file DreamSD.h.

typedef std::pair<double, double> DreamSD::Doubles
private

Definition at line 31 of file DreamSD.h.

Constructor & Destructor Documentation

DreamSD::DreamSD ( const std::string &  name,
const DDCompactView cpv,
const SensitiveDetectorCatalog clg,
edm::ParameterSet const &  p,
const SimTrackManager manager 
)

Definition at line 27 of file DreamSD.cc.

References birk1, birk2, birk3, chAngleIntegrals_, doCherenkov_, g, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), initMap(), MeV, readBothSide_, slopeLY, and useBirk.

32  : CaloSD(name, cpv, clg, p, manager) {
33  edm::ParameterSet m_EC = p.getParameter<edm::ParameterSet>("ECalSD");
34  useBirk = m_EC.getParameter<bool>("UseBirkLaw");
35  doCherenkov_ = m_EC.getParameter<bool>("doCherenkov");
36  birk1 = m_EC.getParameter<double>("BirkC1") * (g / (MeV * cm2));
37  birk2 = m_EC.getParameter<double>("BirkC2");
38  birk3 = m_EC.getParameter<double>("BirkC3");
39  slopeLY = m_EC.getParameter<double>("SlopeLightYield");
40  readBothSide_ = m_EC.getUntrackedParameter<bool>("ReadBothSide", false);
41 
42  chAngleIntegrals_.reset(nullptr);
43 
44  edm::LogInfo("EcalSim") << "Constructing a DreamSD with name " << GetName() << "\n"
45  << "DreamSD:: Use of Birks law is set to " << useBirk
46  << " with three constants kB = " << birk1 << ", C1 = " << birk2 << ", C2 = " << birk3 << "\n"
47  << " Slope for Light yield is set to " << slopeLY << "\n"
48  << " Parameterization of Cherenkov is set to " << doCherenkov_
49  << " and readout both sides is " << readBothSide_;
50 
51  initMap(name, cpv);
52 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
bool readBothSide_
Definition: DreamSD.h:51
double birk1
Definition: DreamSD.h:52
double birk3
Definition: DreamSD.h:52
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
Definition: Activities.doc:4
const double MeV
double birk2
Definition: DreamSD.h:52
CaloSD(const std::string &aSDname, const DDCompactView &cpv, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p, const SimTrackManager *, float timeSlice=1., bool ignoreTkID=false)
Definition: CaloSD.cc:27
std::unique_ptr< G4PhysicsOrderedFreeVector > chAngleIntegrals_
Table of Cherenkov angle integrals vs photon momentum.
Definition: DreamSD.h:59
bool doCherenkov_
Definition: DreamSD.h:51
double slopeLY
Definition: DreamSD.h:53
void initMap(const std::string &, const DDCompactView &)
Definition: DreamSD.cc:104
bool useBirk
Definition: DreamSD.h:51
DreamSD::~DreamSD ( )
inlineoverride

Definition at line 22 of file DreamSD.h.

References getEnergyDeposit(), initRun(), and setDetUnitId().

22 {}

Member Function Documentation

double DreamSD::cherenkovDeposit_ ( const G4Step *  aStep)
private

Returns the total energy due to Cherenkov radiation.

Definition at line 191 of file DreamSD.cc.

References pfBoostedDoubleSVAK8TagInfos_cfi::beta, ALCARECOTkAlJpsiMuMu_cff::charge, funct::cos(), getAverageNumberOfPhotons_(), getPhotonEnergyDeposit_(), LogDebug, materialPropertiesTable, phi, dataAnalyzerFineBiningParameters_cff::Pmax, funct::sin(), and mathSSE::sqrt().

Referenced by getEnergyDeposit().

191  {
192  double cherenkovEnergy = 0;
194  return cherenkovEnergy;
195  G4Material *material = aStep->GetTrack()->GetMaterial();
196 
197  // Retrieve refractive index
198  G4MaterialPropertyVector *Rindex = materialPropertiesTable->GetProperty("RINDEX");
199  if (Rindex == nullptr) {
200  edm::LogWarning("EcalSim") << "Couldn't retrieve refractive index";
201  return cherenkovEnergy;
202  }
203 
204  // V.Ivanchenko - temporary close log output for 9.5
205  // Material refraction properties
206  int Rlength = Rindex->GetVectorLength() - 1;
207  double Pmin = Rindex->Energy(0);
208  double Pmax = Rindex->Energy(Rlength);
209  LogDebug("EcalSim") << "Material properties: "
210  << "\n"
211  << " Pmin = " << Pmin << " Pmax = " << Pmax;
212 
213  // Get particle properties
214  const G4StepPoint *pPreStepPoint = aStep->GetPreStepPoint();
215  const G4StepPoint *pPostStepPoint = aStep->GetPostStepPoint();
216  const G4ThreeVector &x0 = pPreStepPoint->GetPosition();
217  G4ThreeVector p0 = aStep->GetDeltaPosition().unit();
218  const G4DynamicParticle *aParticle = aStep->GetTrack()->GetDynamicParticle();
219  const double charge = aParticle->GetDefinition()->GetPDGCharge();
220  // beta is averaged over step
221  double beta = 0.5 * (pPreStepPoint->GetBeta() + pPostStepPoint->GetBeta());
222  double BetaInverse = 1.0 / beta;
223 
224  LogDebug("EcalSim") << "Particle properties: "
225  << "\n"
226  << " charge = " << charge << " beta = " << beta;
227 
228  // Now get number of photons generated in this step
229  double meanNumberOfPhotons = getAverageNumberOfPhotons_(charge, beta, material, Rindex);
230  if (meanNumberOfPhotons <= 0.0) { // Don't do anything
231  LogDebug("EcalSim") << "Mean number of photons is zero: " << meanNumberOfPhotons << ", stopping here";
232  return cherenkovEnergy;
233  }
234 
235  // number of photons is in unit of Geant4...
236  meanNumberOfPhotons *= aStep->GetStepLength();
237 
238  // Now get a poisson distribution
239  int numPhotons = static_cast<int>(G4Poisson(meanNumberOfPhotons));
240  // edm::LogVerbatim("EcalSim") << "Number of photons = " << numPhotons;
241  if (numPhotons <= 0) {
242  LogDebug("EcalSim") << "Poission number of photons is zero: " << numPhotons << ", stopping here";
243  return cherenkovEnergy;
244  }
245 
246  // Material refraction properties
247  double dp = Pmax - Pmin;
248  double maxCos = BetaInverse / (*Rindex)[Rlength];
249  double maxSin2 = (1.0 - maxCos) * (1.0 + maxCos);
250 
251  // Finally: get contribution of each photon
252  for (int iPhoton = 0; iPhoton < numPhotons; ++iPhoton) {
253  // Determine photon momentum
254  double randomNumber;
255  double sampledMomentum, sampledRI;
256  double cosTheta, sin2Theta;
257 
258  // sample a momentum (not sure why this is needed!)
259  do {
260  randomNumber = G4UniformRand();
261  sampledMomentum = Pmin + randomNumber * dp;
262  sampledRI = Rindex->Value(sampledMomentum);
263  cosTheta = BetaInverse / sampledRI;
264 
265  sin2Theta = (1.0 - cosTheta) * (1.0 + cosTheta);
266  randomNumber = G4UniformRand();
267 
268  } while (randomNumber * maxSin2 > sin2Theta);
269 
270  // Generate random position of photon on cone surface
271  // defined by Theta
272  randomNumber = G4UniformRand();
273 
274  double phi = twopi * randomNumber;
275  double sinPhi = sin(phi);
276  double cosPhi = cos(phi);
277 
278  // Create photon momentum direction vector
279  // The momentum direction is still w.r.t. the coordinate system where the
280  // primary particle direction is aligned with the z axis
281  double sinTheta = sqrt(sin2Theta);
282  double px = sinTheta * cosPhi;
283  double py = sinTheta * sinPhi;
284  double pz = cosTheta;
285  G4ThreeVector photonDirection(px, py, pz);
286 
287  // Rotate momentum direction back to global (crystal) reference system
288  photonDirection.rotateUz(p0);
289 
290  // Create photon position and momentum
291  randomNumber = G4UniformRand();
292  G4ThreeVector photonPosition = x0 + randomNumber * aStep->GetDeltaPosition();
293  G4ThreeVector photonMomentum = sampledMomentum * photonDirection;
294 
295  // Collect energy on APD
296  cherenkovEnergy += getPhotonEnergyDeposit_(photonMomentum, photonPosition, aStep);
297  }
298  return cherenkovEnergy;
299 }
#define LogDebug(id)
double getPhotonEnergyDeposit_(const G4ParticleMomentum &p, const G4ThreeVector &x, const G4Step *aStep)
Returns energy deposit for a given photon.
Definition: DreamSD.cc:451
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
T sqrt(T t)
Definition: SSEVec.h:18
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
double getAverageNumberOfPhotons_(const double charge, const double beta, const G4Material *aMaterial, const G4MaterialPropertyVector *rIndex)
Returns average number of photons created by track.
Definition: DreamSD.cc:304
G4MaterialPropertiesTable * materialPropertiesTable
Definition: DreamSD.h:60
double DreamSD::crystalLength ( G4LogicalVolume *  lv) const
private

Definition at line 171 of file DreamSD.cc.

References xtalLMap.

Referenced by curve_LY(), and getPhotonEnergyDeposit_().

171  {
172  double length = -1.;
173  DimensionMap::const_iterator ite = xtalLMap.find(lv);
174  if (ite != xtalLMap.end())
175  length = ite->second.first;
176  return length;
177 }
DimensionMap xtalLMap
Definition: DreamSD.h:54
double DreamSD::crystalWidth ( G4LogicalVolume *  lv) const
private

Definition at line 180 of file DreamSD.cc.

References ApeEstimator_cff::width, and xtalLMap.

Referenced by getPhotonEnergyDeposit_().

180  {
181  double width = -1.;
182  DimensionMap::const_iterator ite = xtalLMap.find(lv);
183  if (ite != xtalLMap.end())
184  width = ite->second.second;
185  return width;
186 }
DimensionMap xtalLMap
Definition: DreamSD.h:54
double DreamSD::curve_LY ( const G4Step *  aStep,
int  flag 
)
private

Definition at line 146 of file DreamSD.cc.

References crystalLength(), LogDebug, CaloSD::setToLocal(), slopeLY, and mps_merge::weight.

Referenced by getEnergyDeposit().

146  {
147  auto const stepPoint = aStep->GetPreStepPoint();
148  auto const lv = stepPoint->GetTouchable()->GetVolume(0)->GetLogicalVolume();
149  G4String nameVolume = lv->GetName();
150 
151  double weight = 1.;
152  G4ThreeVector localPoint = setToLocal(stepPoint->GetPosition(), stepPoint->GetTouchable());
153  double crlength = crystalLength(lv);
154  double localz = localPoint.x();
155  double dapd = 0.5 * crlength - flag * localz; // Distance from closest APD
156  if (dapd >= -0.1 || dapd <= crlength + 0.1) {
157  if (dapd <= 100.)
158  weight = 1.0 + slopeLY - dapd * 0.01 * slopeLY;
159  } else {
160  edm::LogWarning("EcalSim") << "DreamSD: light coll curve : wrong distance "
161  << "to APD " << dapd << " crlength = " << crlength << " crystal name = " << nameVolume
162  << " z of localPoint = " << localz << " take weight = " << weight;
163  }
164  LogDebug("EcalSim") << "DreamSD, light coll curve : " << dapd << " crlength = " << crlength
165  << " crystal name = " << nameVolume << " z of localPoint = " << localz
166  << " take weight = " << weight;
167  return weight;
168 }
#define LogDebug(id)
Definition: weight.py:1
G4ThreeVector setToLocal(const G4ThreeVector &, const G4VTouchable *) const
Definition: CaloSD.cc:294
double crystalLength(G4LogicalVolume *) const
Definition: DreamSD.cc:171
double slopeLY
Definition: DreamSD.h:53
double DreamSD::getAverageNumberOfPhotons_ ( const double  charge,
const double  beta,
const G4Material *  aMaterial,
const G4MaterialPropertyVector *  rIndex 
)
private

Returns average number of photons created by track.

Definition at line 304 of file DreamSD.cc.

References pfBoostedDoubleSVAK8TagInfos_cfi::beta, chAngleIntegrals_, LogDebug, and dataAnalyzerFineBiningParameters_cff::Pmax.

Referenced by cherenkovDeposit_().

307  {
308  const double rFact = 369.81 / (eV * cm);
309 
310  if (beta <= 0.0)
311  return 0.0;
312 
313  double BetaInverse = 1. / beta;
314 
315  // Vectors used in computation of Cerenkov Angle Integral:
316  // - Refraction Indices for the current material
317  // - new G4PhysicsOrderedFreeVector allocated to hold CAI's
318 
319  // Min and Max photon momenta
320  int Rlength = Rindex->GetVectorLength() - 1;
321  double Pmin = Rindex->Energy(0);
322  double Pmax = Rindex->Energy(Rlength);
323 
324  // Min and Max Refraction Indices
325  double nMin = (*Rindex)[0];
326  double nMax = (*Rindex)[Rlength];
327 
328  // Max Cerenkov Angle Integral
329  double CAImax = chAngleIntegrals_.get()->GetMaxValue();
330 
331  double dp = 0., ge = 0., CAImin = 0.;
332 
333  // If n(Pmax) < 1/Beta -- no photons generated
334  if (nMax < BetaInverse) {
335  }
336 
337  // otherwise if n(Pmin) >= 1/Beta -- photons generated
338  else if (nMin > BetaInverse) {
339  dp = Pmax - Pmin;
340  ge = CAImax;
341  }
342  // If n(Pmin) < 1/Beta, and n(Pmax) >= 1/Beta, then
343  // we need to find a P such that the value of n(P) == 1/Beta.
344  // Interpolation is performed by the GetPhotonEnergy() and
345  // GetProperty() methods of the G4MaterialPropertiesTable and
346  // the GetValue() method of G4PhysicsVector.
347  else {
348  Pmin = Rindex->Value(BetaInverse);
349  dp = Pmax - Pmin;
350  // need boolean for current implementation of G4PhysicsVector
351  // ==> being phased out
352  double CAImin = chAngleIntegrals_->Value(Pmin);
353  ge = CAImax - CAImin;
354  }
355 
356  // Calculate number of photons
357  double numPhotons = rFact * charge / eplus * charge / eplus * (dp - ge * BetaInverse * BetaInverse);
358 
359  LogDebug("EcalSim") << "@SUB=getAverageNumberOfPhotons"
360  << "CAImin = " << CAImin << "\n"
361  << "CAImax = " << CAImax << "\n"
362  << "dp = " << dp << ", ge = " << ge << "\n"
363  << "numPhotons = " << numPhotons;
364 
365  return numPhotons;
366 }
#define LogDebug(id)
std::unique_ptr< G4PhysicsOrderedFreeVector > chAngleIntegrals_
Table of Cherenkov angle integrals vs photon momentum.
Definition: DreamSD.h:59
double DreamSD::getEnergyDeposit ( const G4Step *  aStep)
overrideprotectedvirtual

Reimplemented from CaloSD.

Definition at line 55 of file DreamSD.cc.

References birk1, birk2, birk3, cherenkovDeposit_(), curve_LY(), doCherenkov_, CaloSD::getAttenuation(), LogDebug, MeV, side, useBirk, and mps_merge::weight.

Referenced by ~DreamSD().

55  {
56  // take into account light collection curve for crystals
57  double weight = curve_LY(aStep, side);
58  if (useBirk)
59  weight *= getAttenuation(aStep, birk1, birk2, birk3);
60  double edep = aStep->GetTotalEnergyDeposit() * weight;
61 
62  // Get Cerenkov contribution
63  if (doCherenkov_) {
64  edep += cherenkovDeposit_(aStep);
65  }
66  LogDebug("EcalSim") << "DreamSD:: " << aStep->GetPreStepPoint()->GetPhysicalVolume()->GetName() << " Side " << side
67  << " Light Collection Efficiency " << weight << " Weighted Energy Deposit " << edep / MeV
68  << " MeV";
69 
70  return edep;
71 }
#define LogDebug(id)
Definition: weight.py:1
double birk1
Definition: DreamSD.h:52
double birk3
Definition: DreamSD.h:52
const double MeV
double cherenkovDeposit_(const G4Step *aStep)
Returns the total energy due to Cherenkov radiation.
Definition: DreamSD.cc:191
int side
Definition: DreamSD.h:56
double birk2
Definition: DreamSD.h:52
double curve_LY(const G4Step *, int)
Definition: DreamSD.cc:146
double getAttenuation(const G4Step *aStep, double birk1, double birk2, double birk3) const
Definition: CaloSD.cc:438
bool doCherenkov_
Definition: DreamSD.h:51
bool useBirk
Definition: DreamSD.h:51
double DreamSD::getPhotonEnergyDeposit_ ( const G4ParticleMomentum &  p,
const G4ThreeVector &  x,
const G4Step *  aStep 
)
private

Returns energy deposit for a given photon.

Definition at line 451 of file DreamSD.cc.

References funct::abs(), crystalLength(), crystalWidth(), randomXiThetaGunProducer_cfi::energy, PMTResponse::getEfficiency(), LogDebug, and y.

Referenced by cherenkovDeposit_().

451  {
452  double energy = 0;
453 
454  // Crystal dimensions
455 
456  // edm::LogVerbatim("EcalSim") << p << x;
457 
458  // 1. Check if this photon goes straight to the APD:
459  // - assume that APD is at x=xtalLength/2.0
460  // - extrapolate from x=x0 to x=xtalLength/2.0 using momentum in x-y
461 
462  G4StepPoint *stepPoint = aStep->GetPreStepPoint();
463  G4LogicalVolume *lv = stepPoint->GetTouchable()->GetVolume(0)->GetLogicalVolume();
464  G4String nameVolume = lv->GetName();
465 
466  double crlength = crystalLength(lv);
467  double crwidth = crystalWidth(lv);
468  double dapd = 0.5 * crlength - x.x(); // Distance from closest APD
469  double y = p.y() / p.x() * dapd;
470 
471  LogDebug("EcalSim") << "Distance to APD: " << dapd << " - y at APD: " << y;
472 
473  // Not straight: compute probability
474  if (std::abs(y) > crwidth * 0.5) {
475  }
476 
477  // 2. Retrieve efficiency for this wavelength (in nm, from MeV)
478  double waveLength = p.mag() * 1.239e8;
479 
480  energy = p.mag() * PMTResponse::getEfficiency(waveLength);
481 
482  LogDebug("EcalSim") << "Wavelength: " << waveLength << " - Energy: " << energy;
483 
484  return energy;
485 }
#define LogDebug(id)
static double getEfficiency(const double &waveLengthNm)
Return efficiency for given photon wavelength (in nm)
Definition: PMTResponse.cc:6
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
double crystalWidth(G4LogicalVolume *) const
Definition: DreamSD.cc:180
double crystalLength(G4LogicalVolume *) const
Definition: DreamSD.cc:171
void DreamSD::initMap ( const std::string &  sd,
const DDCompactView cpv 
)
private

Definition at line 104 of file DreamSD.cc.

References ALCARECOTkAlBeamHalo_cff::filter, DDFilteredView::firstChild(), mps_fire::i, LogDebug, DDFilteredView::logicalPart(), DDName::name(), dataset::name, DDBase< N, C >::name(), DDFilteredView::next(), DDSolid::parameters(), DDSolid::shape(), DDLogicalPart::solid(), ApeEstimator_cff::width, and xtalLMap.

Referenced by DreamSD().

104  {
105  G4String attribute = "ReadOutName";
107  DDFilteredView fv(cpv, filter);
108  fv.firstChild();
109 
110  const G4LogicalVolumeStore *lvs = G4LogicalVolumeStore::GetInstance();
111  std::vector<G4LogicalVolume *>::const_iterator lvcite;
112  bool dodet = true;
113  while (dodet) {
114  const DDSolid &sol = fv.logicalPart().solid();
115  std::vector<double> paras(sol.parameters());
116  G4String name = sol.name().name();
117  G4LogicalVolume *lv = nullptr;
118  for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++)
119  if ((*lvcite)->GetName() == name) {
120  lv = (*lvcite);
121  break;
122  }
123  LogDebug("EcalSim") << "DreamSD::initMap (for " << sd << "): Solid " << name << " Shape " << sol.shape()
124  << " Parameter 0 = " << paras[0] << " Logical Volume " << lv;
125  double length = 0, width = 0;
126  // Set length to be the largest size, width the smallest
127  std::sort(paras.begin(), paras.end());
128  length = 2.0 * paras.back();
129  width = 2.0 * paras.front();
130  xtalLMap.insert(std::pair<G4LogicalVolume *, Doubles>(lv, Doubles(length, width)));
131  dodet = fv.next();
132  }
133  LogDebug("EcalSim") << "DreamSD: Length Table for " << attribute << " = " << sd << ":";
134  DimensionMap::const_iterator ite = xtalLMap.begin();
135  int i = 0;
136  for (; ite != xtalLMap.end(); ite++, i++) {
137  G4String name = "Unknown";
138  if (ite->first != nullptr)
139  name = (ite->first)->GetName();
140  LogDebug("EcalSim") << " " << i << " " << ite->first << " " << name << " L = " << ite->second.first
141  << " W = " << ite->second.second;
142  }
143 }
#define LogDebug(id)
const std::vector< double > & parameters(void) const
Give the parameters of the solid.
Definition: DDSolid.cc:144
const N & name() const
Definition: DDBase.h:74
A DDSolid represents the shape of a part.
Definition: DDSolid.h:39
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:138
std::pair< double, double > Doubles
Definition: DreamSD.h:31
DimensionMap xtalLMap
Definition: DreamSD.h:54
double sd
const std::string & name() const
Returns the name.
Definition: DDName.cc:53
void DreamSD::initRun ( )
overrideprotectedvirtual

Reimplemented from CaloSD.

Definition at line 74 of file DreamSD.cc.

References materialPropertiesTable, setPbWO2MaterialProperties_(), and xtalLMap.

Referenced by ~DreamSD().

74  {
75  // Get the material and set properties if needed
76  DimensionMap::const_iterator ite = xtalLMap.begin();
77  const G4LogicalVolume *lv = (ite->first);
78  G4Material *material = lv->GetMaterial();
79  edm::LogInfo("EcalSim") << "DreamSD::initRun: Initializes for material " << material->GetName() << " in "
80  << lv->GetName();
81  materialPropertiesTable = material->GetMaterialPropertiesTable();
83  if (!setPbWO2MaterialProperties_(material)) {
84  edm::LogWarning("EcalSim") << "Couldn't retrieve material properties table\n"
85  << " Material = " << material->GetName();
86  }
87  materialPropertiesTable = material->GetMaterialPropertiesTable();
88  }
89 }
bool setPbWO2MaterialProperties_(G4Material *aMaterial)
Sets material properties at run-time...
Definition: DreamSD.cc:371
G4MaterialPropertiesTable * materialPropertiesTable
Definition: DreamSD.h:60
DimensionMap xtalLMap
Definition: DreamSD.h:54
uint32_t DreamSD::setDetUnitId ( const G4Step *  aStep)
overridevirtual

Implements CaloSD.

Definition at line 92 of file DreamSD.cc.

References triggerObjects_cff::id, LogDebug, readBothSide_, and side.

Referenced by ~DreamSD().

92  {
93  const G4VTouchable *touch = aStep->GetPreStepPoint()->GetTouchable();
94  uint32_t id = (touch->GetReplicaNumber(1)) * 10 + (touch->GetReplicaNumber(0));
95  side = readBothSide_ ? -1 : 1;
96  if (side < 0) {
97  ++id;
98  }
99  LogDebug("EcalSim") << "DreamSD:: ID " << id;
100  return id;
101 }
#define LogDebug(id)
bool readBothSide_
Definition: DreamSD.h:51
int side
Definition: DreamSD.h:56
bool DreamSD::setPbWO2MaterialProperties_ ( G4Material *  aMaterial)
private

Sets material properties at run-time...

Definition at line 371 of file DreamSD.cc.

References chAngleIntegrals_, LogDebug, and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by initRun().

371  {
372  std::string pbWO2Name("E_PbWO4");
373  if (pbWO2Name != aMaterial->GetName()) { // Wrong material!
374  edm::LogWarning("EcalSim") << "This is not the right material: "
375  << "expecting " << pbWO2Name << ", got " << aMaterial->GetName();
376  return false;
377  }
378 
379  G4MaterialPropertiesTable *table = new G4MaterialPropertiesTable();
380 
381  // Refractive index as a function of photon momentum
382  // FIXME: Should somehow put that in the configuration
383  const int nEntries = 14;
384  double PhotonEnergy[nEntries] = {1.7712 * eV,
385  1.8368 * eV,
386  1.90745 * eV,
387  1.98375 * eV,
388  2.0664 * eV,
389  2.15625 * eV,
390  2.25426 * eV,
391  2.3616 * eV,
392  2.47968 * eV,
393  2.61019 * eV,
394  2.75521 * eV,
395  2.91728 * eV,
396  3.09961 * eV,
397  3.30625 * eV};
398  double RefractiveIndex[nEntries] = {2.17728,
399  2.18025,
400  2.18357,
401  2.18753,
402  2.19285,
403  2.19813,
404  2.20441,
405  2.21337,
406  2.22328,
407  2.23619,
408  2.25203,
409  2.27381,
410  2.30282,
411  2.34666};
412 
413  table->AddProperty("RINDEX", PhotonEnergy, RefractiveIndex, nEntries);
414  aMaterial->SetMaterialPropertiesTable(table); // FIXME: could this leak? What does G4 do?
415 
416  // Calculate Cherenkov angle integrals:
417  // This is an ad-hoc solution (we hold it in the class, not in the material)
418  chAngleIntegrals_.reset(new G4PhysicsOrderedFreeVector());
419 
420  int index = 0;
421  double currentRI = RefractiveIndex[index];
422  double currentPM = PhotonEnergy[index];
423  double currentCAI = 0.0;
424  chAngleIntegrals_.get()->InsertValues(currentPM, currentCAI);
425  double prevPM = currentPM;
426  double prevCAI = currentCAI;
427  double prevRI = currentRI;
428  while (++index < nEntries) {
429  currentRI = RefractiveIndex[index];
430  currentPM = PhotonEnergy[index];
431  currentCAI = 0.5 * (1.0 / (prevRI * prevRI) + 1.0 / (currentRI * currentRI));
432  currentCAI = prevCAI + (currentPM - prevPM) * currentCAI;
433 
434  chAngleIntegrals_.get()->InsertValues(currentPM, currentCAI);
435 
436  prevPM = currentPM;
437  prevCAI = currentCAI;
438  prevRI = currentRI;
439  }
440 
441  LogDebug("EcalSim") << "Material properties set for " << aMaterial->GetName();
442 
443  return true;
444 }
#define LogDebug(id)
std::unique_ptr< G4PhysicsOrderedFreeVector > chAngleIntegrals_
Table of Cherenkov angle integrals vs photon momentum.
Definition: DreamSD.h:59

Member Data Documentation

double DreamSD::birk1
private

Definition at line 52 of file DreamSD.h.

Referenced by DreamSD(), and getEnergyDeposit().

double DreamSD::birk2
private

Definition at line 52 of file DreamSD.h.

Referenced by DreamSD(), and getEnergyDeposit().

double DreamSD::birk3
private

Definition at line 52 of file DreamSD.h.

Referenced by DreamSD(), and getEnergyDeposit().

std::unique_ptr<G4PhysicsOrderedFreeVector> DreamSD::chAngleIntegrals_
private

Table of Cherenkov angle integrals vs photon momentum.

Definition at line 59 of file DreamSD.h.

Referenced by DreamSD(), getAverageNumberOfPhotons_(), and setPbWO2MaterialProperties_().

bool DreamSD::doCherenkov_
private

Definition at line 51 of file DreamSD.h.

Referenced by DreamSD(), and getEnergyDeposit().

G4MaterialPropertiesTable* DreamSD::materialPropertiesTable
private

Definition at line 60 of file DreamSD.h.

Referenced by cherenkovDeposit_(), and initRun().

int DreamSD::nphotons_
private

Definition at line 62 of file DreamSD.h.

bool DreamSD::readBothSide_
private

Definition at line 51 of file DreamSD.h.

Referenced by DreamSD(), and setDetUnitId().

int DreamSD::side
private

Definition at line 56 of file DreamSD.h.

Referenced by getEnergyDeposit(), and setDetUnitId().

double DreamSD::slopeLY
private

Definition at line 53 of file DreamSD.h.

Referenced by curve_LY(), and DreamSD().

bool DreamSD::useBirk
private

Definition at line 51 of file DreamSD.h.

Referenced by DreamSD(), and getEnergyDeposit().

DimensionMap DreamSD::xtalLMap
private

Definition at line 54 of file DreamSD.h.

Referenced by crystalLength(), crystalWidth(), initMap(), and initRun().