CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 (G4String, const DDCompactView &, const SensitiveDetectorCatalog &, edm::ParameterSet const &, const SimTrackManager *)
 
virtual bool ProcessHits (G4Step *step, G4TouchableHistory *tHistory)
 
virtual uint32_t setDetUnitId (G4Step *)
 
virtual ~DreamSD ()
 
- Public Member Functions inherited from CaloSD
 CaloSD (G4String aSDname, const DDCompactView &cpv, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p, const SimTrackManager *, float timeSlice=1., bool ignoreTkID=false)
 
virtual void clear ()
 
virtual void DrawAll ()
 
virtual void EndOfEvent (G4HCofThisEvent *eventHC)
 
void fillHits (edm::PCaloHitContainer &, std::string n)
 
virtual double getEnergyDeposit (G4Step *step)
 
virtual void Initialize (G4HCofThisEvent *HCE)
 
virtual void PrintAll ()
 
virtual bool ProcessHits (G4GFlashSpot *aSpot, G4TouchableHistory *)
 
virtual ~CaloSD ()
 
- Public Member Functions inherited from SensitiveCaloDetector
 SensitiveCaloDetector (std::string &iname, const DDCompactView &cpv, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p)
 
- Public Member Functions inherited from SensitiveDetector
virtual void AssignSD (const std::string &vname)
 
Local3DPoint ConvertToLocal3DPoint (const G4ThreeVector &point)
 
Local3DPoint FinalStepPosition (G4Step *s, coordinates)
 
virtual std::vector< std::string > getNames ()
 
Local3DPoint InitialStepPosition (G4Step *s, coordinates)
 
std::string nameOfSD ()
 
void NaNTrap (G4Step *step)
 
void Register ()
 
 SensitiveDetector (std::string &iname, const DDCompactView &cpv, const SensitiveDetectorCatalog &, edm::ParameterSet const &p)
 
virtual ~SensitiveDetector ()
 
- 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

virtual G4bool getStepInfo (G4Step *aStep)
 
virtual void initRun ()
 
- Protected Member Functions inherited from CaloSD
G4bool checkHit ()
 
virtual void clearHits ()
 
CaloG4HitcreateNewHit ()
 
virtual bool filterHit (CaloG4Hit *, double)
 
double getAttenuation (G4Step *aStep, double birk1, double birk2, double birk3)
 
virtual uint16_t getDepth (G4Step *)
 
int getNumberOfHits ()
 
double getResponseWt (G4Track *)
 
virtual int getTrackID (G4Track *)
 
G4bool hitExists ()
 
void resetForNewPrimary (const G4ThreeVector &, double)
 
G4ThreeVector setToGlobal (const G4ThreeVector &, const G4VTouchable *)
 
G4ThreeVector setToLocal (const G4ThreeVector &, const G4VTouchable *)
 
virtual void update (const BeginOfRun *)
 This routine will be called when the appropriate signal arrives. More...
 
virtual void update (const BeginOfEvent *)
 This routine will be called when the appropriate signal arrives. More...
 
virtual void update (const BeginOfTrack *trk)
 This routine will be called when the appropriate signal arrives. More...
 
virtual void update (const EndOfTrack *trk)
 This routine will be called when the appropriate signal arrives. More...
 
virtual void update (const ::EndOfEvent *)
 
void updateHit (CaloG4Hit *)
 
- 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 *, Doubles
DimensionMap
 
typedef std::pair< double, double > Doubles
 

Private Member Functions

double cherenkovDeposit_ (G4Step *aStep)
 Returns the total energy due to Cherenkov radiation. More...
 
const double crystalLength (G4LogicalVolume *) const
 
const double crystalWidth (G4LogicalVolume *) const
 
double curve_LY (G4Step *, int)
 
double getAverageNumberOfPhotons_ (const double charge, const double beta, const G4Material *aMaterial, 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 (G4String, const DDCompactView &)
 
bool setPbWO2MaterialProperties_ (G4Material *aMaterial)
 Sets material properties at run-time... More...
 

Private Attributes

double birk1
 
double birk2
 
double birk3
 
std::auto_ptr
< G4PhysicsOrderedFreeVector > 
chAngleIntegrals_
 Table of Cherenkov angle integrals vs photon momentum. More...
 
bool doCherenkov_
 
G4MaterialPropertiesTable * materialPropertiesTable
 
int nphotons_
 
TTree * ntuple_
 
float px_ [MAXPHOTONS]
 
float py_ [MAXPHOTONS]
 
float pz_ [MAXPHOTONS]
 
bool readBothSide_
 
int side
 
double slopeLY
 
bool useBirk
 
float x_ [MAXPHOTONS]
 
DimensionMap xtalLMap
 
float y_ [MAXPHOTONS]
 
float z_ [MAXPHOTONS]
 

Additional Inherited Members

- Public Types inherited from SensitiveDetector
enum  coordinates { WorldCoordinates, LocalCoordinates }
 
- Protected Attributes inherited from CaloSD
int checkHits
 
double correctT
 
bool corrTOFBeam
 
CaloG4HitcurrentHit
 
CaloHitID currentID
 
float edepositEM
 
float edepositHAD
 
double eminHit
 
double eminHitD
 
G4int emPDG
 
double energyCut
 
G4ThreeVector entranceLocal
 
G4ThreeVector entrancePoint
 
G4int epPDG
 
bool forceSave
 
G4int gammaPDG
 
float incidentEnergy
 
double kmaxIon
 
double kmaxNeutron
 
double kmaxProton
 
const SimTrackManagerm_trackManager
 
G4ThreeVector posGlobal
 
G4StepPoint * preStepPoint
 
CaloHitID previousID
 
int primIDSaved
 
bool runInit
 
bool suppressHeavy
 
G4Track * theTrack
 
double tmaxHit
 
bool useMap
 

Detailed Description

Definition at line 19 of file DreamSD.h.

Member Typedef Documentation

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

Definition at line 37 of file DreamSD.h.

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

Definition at line 36 of file DreamSD.h.

Constructor & Destructor Documentation

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

Definition at line 29 of file DreamSD.cc.

References birk1, birk2, birk3, doCherenkov_, g, edm::ParameterSet::getParameter(), edm::ParameterSet::getUntrackedParameter(), initMap(), edm::Service< T >::isAvailable(), TFileService::make(), MeV, nphotons_, ntuple_, px_, py_, pz_, readBothSide_, slopeLY, useBirk, x_, y_, and z_.

31  :
32  CaloSD(name, cpv, clg, p, manager) {
33 
34  edm::ParameterSet m_EC = p.getParameter<edm::ParameterSet>("ECalSD");
35  useBirk= m_EC.getParameter<bool>("UseBirkLaw");
36  doCherenkov_ = m_EC.getParameter<bool>("doCherenkov");
37  birk1 = m_EC.getParameter<double>("BirkC1")*(g/(MeV*cm2));
38  birk2 = m_EC.getParameter<double>("BirkC2");
39  birk3 = m_EC.getParameter<double>("BirkC3");
40  slopeLY= m_EC.getParameter<double>("SlopeLightYield");
41  readBothSide_ = m_EC.getUntrackedParameter<bool>("ReadBothSide", false);
42 
43  edm::LogInfo("EcalSim") << "Constructing a DreamSD with name " << GetName() << "\n"
44  << "DreamSD:: Use of Birks law is set to "
45  << useBirk << " with three constants kB = "
46  << birk1 << ", C1 = " << birk2 << ", C2 = "
47  << birk3 << "\n"
48  << " Slope for Light yield is set to "
49  << slopeLY << "\n"
50  << " Parameterization of Cherenkov is set to "
51  << doCherenkov_ << " and readout both sides is "
52  << readBothSide_;
53 
54  initMap(name,cpv);
55 
56  // Init histogramming
58 
59  if ( !tfile.isAvailable() )
60  throw cms::Exception("BadConfig") << "TFileService unavailable: "
61  << "please add it to config file";
62 
63  ntuple_ = tfile->make<TTree>("tree","Cherenkov photons");
64  if (doCherenkov_) {
65  ntuple_->Branch("nphotons",&nphotons_,"nphotons/I");
66  ntuple_->Branch("px",px_,"px[nphotons]/F");
67  ntuple_->Branch("py",py_,"py[nphotons]/F");
68  ntuple_->Branch("pz",pz_,"pz[nphotons]/F");
69  ntuple_->Branch("x",x_,"x[nphotons]/F");
70  ntuple_->Branch("y",y_,"y[nphotons]/F");
71  ntuple_->Branch("z",z_,"z[nphotons]/F");
72  }
73 
74 }
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
bool readBothSide_
Definition: DreamSD.h:58
float y_[MAXPHOTONS]
Definition: DreamSD.h:72
double birk1
Definition: DreamSD.h:59
T * make(const Args &...args) const
make new ROOT object
Definition: TFileService.h:64
double birk3
Definition: DreamSD.h:59
float px_[MAXPHOTONS]
Definition: DreamSD.h:71
TTree * ntuple_
Definition: DreamSD.h:69
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
CaloSD(G4String aSDname, const DDCompactView &cpv, const SensitiveDetectorCatalog &clg, edm::ParameterSet const &p, const SimTrackManager *, float timeSlice=1., bool ignoreTkID=false)
Definition: CaloSD.cc:24
const double MeV
float z_[MAXPHOTONS]
Definition: DreamSD.h:72
int nphotons_
Definition: DreamSD.h:70
float pz_[MAXPHOTONS]
Definition: DreamSD.h:71
bool isAvailable() const
Definition: Service.h:46
double birk2
Definition: DreamSD.h:59
float x_[MAXPHOTONS]
Definition: DreamSD.h:72
bool doCherenkov_
Definition: DreamSD.h:58
double slopeLY
Definition: DreamSD.h:60
float py_[MAXPHOTONS]
Definition: DreamSD.h:71
void initMap(G4String, const DDCompactView &)
Definition: DreamSD.cc:194
bool useBirk
Definition: DreamSD.h:58
virtual DreamSD::~DreamSD ( )
inlinevirtual

Definition at line 25 of file DreamSD.h.

25 {}

Member Function Documentation

double DreamSD::cherenkovDeposit_ ( G4Step *  aStep)
private

Returns the total energy due to Cherenkov radiation.

Definition at line 296 of file DreamSD.cc.

References beta, RecoTauCleanerPlugins::charge, funct::cos(), reco::dp, getAverageNumberOfPhotons_(), getPhotonEnergyDeposit_(), LogDebug, materialPropertiesTable, nphotons_, ntuple_, NULL, phi, px_, py_, pz_, funct::sin(), mathSSE::sqrt(), x_, y_, and z_.

Referenced by getStepInfo().

296  {
297 
298  double cherenkovEnergy = 0;
299  if (!materialPropertiesTable) return cherenkovEnergy;
300  G4Material* material = aStep->GetTrack()->GetMaterial();
301 
302  // Retrieve refractive index
303  G4MaterialPropertyVector* Rindex = materialPropertiesTable->GetProperty("RINDEX");
304  if ( Rindex == NULL ) {
305  edm::LogWarning("EcalSim") << "Couldn't retrieve refractive index";
306  return cherenkovEnergy;
307  }
308 
309  // V.Ivanchenko - temporary close log output for 9.5
310  // Material refraction properties
311  int Rlength = Rindex->GetVectorLength() - 1;
312  double Pmin = Rindex->Energy(0);
313  double Pmax = Rindex->Energy(Rlength);
314  LogDebug("EcalSim") << "Material properties: " << "\n"
315  << " Pmin = " << Pmin
316  << " Pmax = " << Pmax;
317 
318  // Get particle properties
319  G4StepPoint* pPreStepPoint = aStep->GetPreStepPoint();
320  G4StepPoint* pPostStepPoint = aStep->GetPostStepPoint();
321  G4ThreeVector x0 = pPreStepPoint->GetPosition();
322  G4ThreeVector p0 = aStep->GetDeltaPosition().unit();
323  const G4DynamicParticle* aParticle = aStep->GetTrack()->GetDynamicParticle();
324  const double charge = aParticle->GetDefinition()->GetPDGCharge();
325  // beta is averaged over step
326  double beta = 0.5*( pPreStepPoint->GetBeta() + pPostStepPoint->GetBeta() );
327  double BetaInverse = 1.0/beta;
328 
329  LogDebug("EcalSim") << "Particle properties: " << "\n"
330  << " charge = " << charge
331  << " beta = " << beta;
332 
333  // Now get number of photons generated in this step
334  double meanNumberOfPhotons = getAverageNumberOfPhotons_( charge, beta, material, Rindex );
335  if ( meanNumberOfPhotons <= 0.0 ) { // Don't do anything
336  LogDebug("EcalSim") << "Mean number of photons is zero: " << meanNumberOfPhotons
337  << ", stopping here";
338  return cherenkovEnergy;
339  }
340 
341  // number of photons is in unit of Geant4...
342  meanNumberOfPhotons *= aStep->GetStepLength();
343 
344  // Now get a poisson distribution
345  int numPhotons = static_cast<int>( G4Poisson(meanNumberOfPhotons) );
346  //edm::LogVerbatim("EcalSim") << "Number of photons = " << numPhotons;
347  if ( numPhotons <= 0 ) {
348  LogDebug("EcalSim") << "Poission number of photons is zero: " << numPhotons
349  << ", stopping here";
350  return cherenkovEnergy;
351  }
352 
353  // Material refraction properties
354  double dp = Pmax - Pmin;
355  double maxCos = BetaInverse / (*Rindex)[Rlength];
356  double maxSin2 = (1.0 - maxCos) * (1.0 + maxCos);
357 
358  // Finally: get contribution of each photon
359  for ( int iPhoton = 0; iPhoton<numPhotons; ++iPhoton ) {
360 
361  // Determine photon momentum
362  double randomNumber;
363  double sampledMomentum, sampledRI;
364  double cosTheta, sin2Theta;
365 
366  // sample a momentum (not sure why this is needed!)
367  do {
368  randomNumber = G4UniformRand();
369  sampledMomentum = Pmin + randomNumber * dp;
370  sampledRI = Rindex->Value(sampledMomentum);
371  cosTheta = BetaInverse / sampledRI;
372 
373  sin2Theta = (1.0 - cosTheta)*(1.0 + cosTheta);
374  randomNumber = G4UniformRand();
375 
376  } while (randomNumber*maxSin2 > sin2Theta);
377 
378  // Generate random position of photon on cone surface
379  // defined by Theta
380  randomNumber = G4UniformRand();
381 
382  double phi = twopi*randomNumber;
383  double sinPhi = sin(phi);
384  double cosPhi = cos(phi);
385 
386  // Create photon momentum direction vector
387  // The momentum direction is still w.r.t. the coordinate system where the primary
388  // particle direction is aligned with the z axis
389  double sinTheta = sqrt(sin2Theta);
390  double px = sinTheta*cosPhi;
391  double py = sinTheta*sinPhi;
392  double pz = cosTheta;
393  G4ThreeVector photonDirection(px, py, pz);
394 
395  // Rotate momentum direction back to global (crystal) reference system
396  photonDirection.rotateUz(p0);
397 
398  // Create photon position and momentum
399  randomNumber = G4UniformRand();
400  G4ThreeVector photonPosition = x0 + randomNumber * aStep->GetDeltaPosition();
401  G4ThreeVector photonMomentum = sampledMomentum*photonDirection;
402 
403  // Collect energy on APD
404  cherenkovEnergy += getPhotonEnergyDeposit_( photonMomentum, photonPosition, aStep );
405 
406  // Ntuple variables
407  nphotons_ = numPhotons;
408  px_[iPhoton] = photonMomentum.x();
409  py_[iPhoton] = photonMomentum.y();
410  pz_[iPhoton] = photonMomentum.z();
411  x_[iPhoton] = photonPosition.x();
412  y_[iPhoton] = photonPosition.y();
413  z_[iPhoton] = photonPosition.z();
414  }
415 
416  // Fill ntuple
417  ntuple_->Fill();
418 
419 
420  return cherenkovEnergy;
421 
422 }
#define LogDebug(id)
const double beta
double getPhotonEnergyDeposit_(const G4ParticleMomentum &p, const G4ThreeVector &x, const G4Step *aStep)
Returns energy deposit for a given photon.
Definition: DreamSD.cc:563
float y_[MAXPHOTONS]
Definition: DreamSD.h:72
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
double getAverageNumberOfPhotons_(const double charge, const double beta, const G4Material *aMaterial, G4MaterialPropertyVector *rIndex)
Returns average number of photons created by track.
Definition: DreamSD.cc:428
#define NULL
Definition: scimark2.h:8
float px_[MAXPHOTONS]
Definition: DreamSD.h:71
TTree * ntuple_
Definition: DreamSD.h:69
float z_[MAXPHOTONS]
Definition: DreamSD.h:72
T sqrt(T t)
Definition: SSEVec.h:18
int nphotons_
Definition: DreamSD.h:70
float pz_[MAXPHOTONS]
Definition: DreamSD.h:71
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
G4MaterialPropertiesTable * materialPropertiesTable
Definition: DreamSD.h:67
auto dp
Definition: deltaR.h:22
float x_[MAXPHOTONS]
Definition: DreamSD.h:72
float py_[MAXPHOTONS]
Definition: DreamSD.h:71
const double DreamSD::crystalLength ( G4LogicalVolume *  lv) const
private

Definition at line 273 of file DreamSD.cc.

References xtalLMap.

Referenced by curve_LY(), and getPhotonEnergyDeposit_().

273  {
274 
275  double length= -1.;
276  DimensionMap::const_iterator ite = xtalLMap.find(lv);
277  if (ite != xtalLMap.end()) length = ite->second.first;
278  return length;
279 
280 }
DimensionMap xtalLMap
Definition: DreamSD.h:61
const double DreamSD::crystalWidth ( G4LogicalVolume *  lv) const
private

Definition at line 283 of file DreamSD.cc.

References create_public_lumi_plots::width, and xtalLMap.

Referenced by getPhotonEnergyDeposit_().

283  {
284 
285  double width= -1.;
286  DimensionMap::const_iterator ite = xtalLMap.find(lv);
287  if (ite != xtalLMap.end()) width = ite->second.second;
288  return width;
289 
290 }
DimensionMap xtalLMap
Definition: DreamSD.h:61
double DreamSD::curve_LY ( G4Step *  aStep,
int  flag 
)
private

Definition at line 242 of file DreamSD.cc.

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

Referenced by getStepInfo().

242  {
243 
244  G4StepPoint* stepPoint = aStep->GetPreStepPoint();
245  G4LogicalVolume* lv = stepPoint->GetTouchable()->GetVolume(0)->GetLogicalVolume();
246  G4String nameVolume= lv->GetName();
247 
248  double weight = 1.;
249  G4ThreeVector localPoint = setToLocal(stepPoint->GetPosition(),
250  stepPoint->GetTouchable());
251  double crlength = crystalLength(lv);
252  double localz = localPoint.x();
253  double dapd = 0.5 * crlength - flag*localz; // Distance from closest APD
254  if (dapd >= -0.1 || dapd <= crlength+0.1) {
255  if (dapd <= 100.)
256  weight = 1.0 + slopeLY - dapd * 0.01 * slopeLY;
257  } else {
258  edm::LogWarning("EcalSim") << "DreamSD: light coll curve : wrong distance "
259  << "to APD " << dapd << " crlength = "
260  << crlength << " crystal name = " << nameVolume
261  << " z of localPoint = " << localz
262  << " take weight = " << weight;
263  }
264  LogDebug("EcalSim") << "DreamSD, light coll curve : " << dapd
265  << " crlength = " << crlength
266  << " crystal name = " << nameVolume
267  << " z of localPoint = " << localz
268  << " take weight = " << weight;
269  return weight;
270 }
#define LogDebug(id)
double slopeLY
Definition: DreamSD.h:60
int weight
Definition: histoStyle.py:50
const double crystalLength(G4LogicalVolume *) const
Definition: DreamSD.cc:273
G4ThreeVector setToLocal(const G4ThreeVector &, const G4VTouchable *)
Definition: CaloSD.cc:296
double DreamSD::getAverageNumberOfPhotons_ ( const double  charge,
const double  beta,
const G4Material *  aMaterial,
G4MaterialPropertyVector *  rIndex 
)
private

Returns average number of photons created by track.

Definition at line 428 of file DreamSD.cc.

References beta, chAngleIntegrals_, reco::dp, and LogDebug.

Referenced by cherenkovDeposit_().

432 {
433  const G4double rFact = 369.81/(eV * cm);
434 
435  if( beta <= 0.0 ) return 0.0;
436 
437  double BetaInverse = 1./beta;
438 
439  // Vectors used in computation of Cerenkov Angle Integral:
440  // - Refraction Indices for the current material
441  // - new G4PhysicsOrderedFreeVector allocated to hold CAI's
442 
443  // Min and Max photon momenta
444  int Rlength = Rindex->GetVectorLength() - 1;
445  double Pmin = Rindex->Energy(0);
446  double Pmax = Rindex->Energy(Rlength);
447 
448  // Min and Max Refraction Indices
449  double nMin = (*Rindex)[0];
450  double nMax = (*Rindex)[Rlength];
451 
452  // Max Cerenkov Angle Integral
453  double CAImax = chAngleIntegrals_->GetMaxValue();
454 
455  double dp = 0., ge = 0., CAImin = 0.;
456 
457  // If n(Pmax) < 1/Beta -- no photons generated
458  if ( nMax < BetaInverse) { }
459 
460  // otherwise if n(Pmin) >= 1/Beta -- photons generated
461  else if (nMin > BetaInverse) {
462  dp = Pmax - Pmin;
463  ge = CAImax;
464  }
465  // If n(Pmin) < 1/Beta, and n(Pmax) >= 1/Beta, then
466  // we need to find a P such that the value of n(P) == 1/Beta.
467  // Interpolation is performed by the GetPhotonEnergy() and
468  // GetProperty() methods of the G4MaterialPropertiesTable and
469  // the GetValue() method of G4PhysicsVector.
470  else {
471  Pmin = Rindex->Value(BetaInverse);
472  dp = Pmax - Pmin;
473  // need boolean for current implementation of G4PhysicsVector
474  // ==> being phased out
475  double CAImin = chAngleIntegrals_->Value(Pmin);
476  ge = CAImax - CAImin;
477 
478  }
479 
480  // Calculate number of photons
481  double numPhotons = rFact * charge/eplus * charge/eplus *
482  (dp - ge * BetaInverse*BetaInverse);
483 
484  LogDebug("EcalSim") << "@SUB=getAverageNumberOfPhotons"
485  << "CAImin = " << CAImin << "\n"
486  << "CAImax = " << CAImax << "\n"
487  << "dp = " << dp << ", ge = " << ge << "\n"
488  << "numPhotons = " << numPhotons;
489 
490 
491 
492  return numPhotons;
493 
494 }
#define LogDebug(id)
const double beta
std::auto_ptr< G4PhysicsOrderedFreeVector > chAngleIntegrals_
Table of Cherenkov angle integrals vs photon momentum.
Definition: DreamSD.h:66
auto dp
Definition: deltaR.h:22
double DreamSD::getPhotonEnergyDeposit_ ( const G4ParticleMomentum &  p,
const G4ThreeVector &  x,
const G4Step *  aStep 
)
private

Returns energy deposit for a given photon.

Definition at line 563 of file DreamSD.cc.

References crystalLength(), crystalWidth(), relval_parameters_module::energy, PMTResponse::getEfficiency(), LogDebug, and y.

Referenced by cherenkovDeposit_().

566 {
567 
568  double energy = 0;
569 
570  // Crystal dimensions
571 
572  //edm::LogVerbatim("EcalSim") << p << x;
573 
574  // 1. Check if this photon goes straight to the APD:
575  // - assume that APD is at x=xtalLength/2.0
576  // - extrapolate from x=x0 to x=xtalLength/2.0 using momentum in x-y
577 
578  G4StepPoint* stepPoint = aStep->GetPreStepPoint();
579  G4LogicalVolume* lv = stepPoint->GetTouchable()->GetVolume(0)->GetLogicalVolume();
580  G4String nameVolume= lv->GetName();
581 
582  double crlength = crystalLength(lv);
583  double crwidth = crystalWidth(lv);
584  double dapd = 0.5 * crlength - x.x(); // Distance from closest APD
585  double y = p.y()/p.x()*dapd;
586 
587  LogDebug("EcalSim") << "Distance to APD: " << dapd
588  << " - y at APD: " << y;
589 
590  // Not straight: compute probability
591  if ( fabs(y)>crwidth*0.5 ) {
592 
593  }
594 
595  // 2. Retrieve efficiency for this wavelength (in nm, from MeV)
596  double waveLength = p.mag()*1.239e8;
597 
598 
599  energy = p.mag()*PMTResponse::getEfficiency(waveLength);
600 
601  LogDebug("EcalSim") << "Wavelength: " << waveLength << " - Energy: " << energy;
602 
603  return energy;
604 
605 }
#define LogDebug(id)
const double crystalWidth(G4LogicalVolume *) const
Definition: DreamSD.cc:283
const double crystalLength(G4LogicalVolume *) const
Definition: DreamSD.cc:273
static const double getEfficiency(const double &waveLengthNm)
Return efficiency for given photon wavelength (in nm)
Definition: PMTResponse.cc:6
bool DreamSD::getStepInfo ( G4Step *  aStep)
protectedvirtual

Reimplemented from CaloSD.

Definition at line 99 of file DreamSD.cc.

References birk1, birk2, birk3, cherenkovDeposit_(), CaloSD::currentID, curve_LY(), TauDecayModes::dec, doCherenkov_, CaloSD::edepositEM, CaloSD::edepositHAD, CaloSD::getAttenuation(), TrackInformation::getIDonCaloSurface(), LogDebug, MeV, CaloSD::preStepPoint, setDetUnitId(), CaloHitID::setID(), side, CaloSD::theTrack, CaloHitID::unitID(), useBirk, and histoStyle::weight.

Referenced by ProcessHits().

99  {
100 
101  preStepPoint = aStep->GetPreStepPoint();
102  theTrack = aStep->GetTrack();
103  G4String nameVolume = preStepPoint->GetPhysicalVolume()->GetName();
104 
105  // take into account light collection curve for crystals
106  double weight = 1.;
107  weight *= curve_LY(aStep, side);
108  if (useBirk) weight *= getAttenuation(aStep, birk1, birk2, birk3);
109  edepositEM = aStep->GetTotalEnergyDeposit() * weight;
110  LogDebug("EcalSim") << "DreamSD:: " << nameVolume << " Side " << side
111  <<" Light Collection Efficiency " << weight
112  << " Weighted Energy Deposit " << edepositEM/MeV
113  << " MeV";
114  // Get cherenkov contribution
115  if ( doCherenkov_ ) {
116  edepositHAD = cherenkovDeposit_( aStep );
117  } else {
118  edepositHAD = 0;
119  }
120 
121  double time = (aStep->GetPostStepPoint()->GetGlobalTime())/nanosecond;
122  unsigned int unitID= setDetUnitId(aStep);
123  if (side < 0) unitID++;
124  TrackInformation * trkInfo = (TrackInformation *)(theTrack->GetUserInformation());
125  int primaryID;
126 
127  if (trkInfo)
128  primaryID = trkInfo->getIDonCaloSurface();
129  else
130  primaryID = 0;
131 
132  if (primaryID == 0) {
133  edm::LogWarning("EcalSim") << "CaloSD: Problem with primaryID **** set by "
134  << "force to TkID **** "
135  << theTrack->GetTrackID() << " in Volume "
136  << preStepPoint->GetTouchable()->GetVolume(0)->GetName();
137  primaryID = theTrack->GetTrackID();
138  }
139 
140  bool flag = (unitID > 0);
141  G4TouchableHistory* touch =(G4TouchableHistory*)(theTrack->GetTouchable());
142  if (flag) {
143  currentID.setID(unitID, time, primaryID, 0);
144 
145  LogDebug("EcalSim") << "CaloSD:: GetStepInfo for"
146  << " PV " << touch->GetVolume(0)->GetName()
147  << " PVid = " << touch->GetReplicaNumber(0)
148  << " MVid = " << touch->GetReplicaNumber(1)
149  << " Unit " << currentID.unitID()
150  << " Edeposit = " << edepositEM << " " << edepositHAD;
151  } else {
152  LogDebug("EcalSim") << "CaloSD:: GetStepInfo for"
153  << " PV " << touch->GetVolume(0)->GetName()
154  << " PVid = " << touch->GetReplicaNumber(0)
155  << " MVid = " << touch->GetReplicaNumber(1)
156  << " Unit " << std::hex << unitID << std::dec
157  << " Edeposit = " << edepositEM << " " << edepositHAD;
158  }
159  return flag;
160 
161 }
#define LogDebug(id)
float edepositEM
Definition: CaloSD.h:121
int getIDonCaloSurface() const
double birk1
Definition: DreamSD.h:59
double birk3
Definition: DreamSD.h:59
virtual uint32_t setDetUnitId(G4Step *)
Definition: DreamSD.cc:185
const double MeV
float edepositHAD
Definition: CaloSD.h:121
int side
Definition: DreamSD.h:63
double birk2
Definition: DreamSD.h:59
double getAttenuation(G4Step *aStep, double birk1, double birk2, double birk3)
Definition: CaloSD.cc:465
G4Track * theTrack
Definition: CaloSD.h:118
void setID(uint32_t unitID, double timeSlice, int trackID, uint16_t depth=0)
Definition: CaloHitID.cc:44
G4StepPoint * preStepPoint
Definition: CaloSD.h:120
double cherenkovDeposit_(G4Step *aStep)
Returns the total energy due to Cherenkov radiation.
Definition: DreamSD.cc:296
CaloHitID currentID
Definition: CaloSD.h:117
bool doCherenkov_
Definition: DreamSD.h:58
int weight
Definition: histoStyle.py:50
uint32_t unitID() const
Definition: CaloHitID.h:22
double curve_LY(G4Step *, int)
Definition: DreamSD.cc:242
bool useBirk
Definition: DreamSD.h:58
void DreamSD::initMap ( G4String  sd,
const DDCompactView cpv 
)
private

Definition at line 194 of file DreamSD.cc.

References DDFilteredView::addFilter(), equals, alcazmumu_cfi::filter, DDFilteredView::firstChild(), i, LogDebug, DDFilteredView::logicalPart(), DDName::name(), SensitiveDetector::name, DDBase< N, C >::name(), DDFilteredView::next(), DDSolid::parameters(), DDSpecificsFilter::setCriteria(), DDSolid::shape(), DDLogicalPart::solid(), create_public_lumi_plots::width, and xtalLMap.

Referenced by DreamSD().

194  {
195 
196  G4String attribute = "ReadOutName";
198  DDValue ddv(attribute,sd,0);
199  filter.setCriteria(ddv,DDCompOp::equals);
200  DDFilteredView fv(cpv);
201  fv.addFilter(filter);
202  fv.firstChild();
203 
204  const G4LogicalVolumeStore * lvs = G4LogicalVolumeStore::GetInstance();
205  std::vector<G4LogicalVolume *>::const_iterator lvcite;
206  bool dodet=true;
207  while (dodet) {
208  const DDSolid & sol = fv.logicalPart().solid();
209  std::vector<double> paras(sol.parameters());
210  G4String name = sol.name().name();
211  G4LogicalVolume* lv=0;
212  for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++)
213  if ((*lvcite)->GetName() == name) {
214  lv = (*lvcite);
215  break;
216  }
217  LogDebug("EcalSim") << "DreamSD::initMap (for " << sd << "): Solid "
218  << name << " Shape " << sol.shape() <<" Parameter 0 = "
219  << paras[0] << " Logical Volume " << lv;
220  double length = 0, width = 0;
221  // Set length to be the largest size, width the smallest
222  std::sort( paras.begin(), paras.end() );
223  length = 2.0*paras.back();
224  width = 2.0*paras.front();
225  xtalLMap.insert( std::pair<G4LogicalVolume*,Doubles>(lv,Doubles(length,width)) );
226  dodet = fv.next();
227  }
228  LogDebug("EcalSim") << "DreamSD: Length Table for " << attribute << " = "
229  << sd << ":";
230  DimensionMap::const_iterator ite = xtalLMap.begin();
231  int i=0;
232  for (; ite != xtalLMap.end(); ite++, i++) {
233  G4String name = "Unknown";
234  if (ite->first != 0) name = (ite->first)->GetName();
235  LogDebug("EcalSim") << " " << i << " " << ite->first << " " << name
236  << " L = " << ite->second.first
237  << " W = " << ite->second.second;
238  }
239 }
#define LogDebug(id)
int i
Definition: DBlmapReader.cc:9
const std::vector< double > & parameters(void) const
Give the parameters of the solid.
Definition: DDSolid.cc:150
const N & name() const
Definition: DDBase.h:78
std::pair< double, double > Doubles
Definition: DreamSD.h:36
A DDSolid represents the shape of a part.
Definition: DDSolid.h:35
DDSolidShape shape(void) const
The type of the solid.
Definition: DDSolid.cc:144
DimensionMap xtalLMap
Definition: DreamSD.h:61
double sd
const std::string & name() const
Returns the name.
Definition: DDName.cc:87
void setCriteria(const DDValue &nameVal, DDCompOp, DDLogOp l=DDLogOp::AND, bool asString=true, bool merged=true)
Definition: DDFilter.cc:245
The DDGenericFilter is a runtime-parametrized Filter looking on DDSpecifcs.
Definition: DDFilter.h:32
void DreamSD::initRun ( void  )
protectedvirtual

Reimplemented from CaloSD.

Definition at line 165 of file DreamSD.cc.

References materialPropertiesTable, setPbWO2MaterialProperties_(), and xtalLMap.

165  {
166 
167  // Get the material and set properties if needed
168  DimensionMap::const_iterator ite = xtalLMap.begin();
169  G4LogicalVolume* lv = (ite->first);
170  G4Material* material = lv->GetMaterial();
171  edm::LogInfo("EcalSim") << "DreamSD::initRun: Initializes for material "
172  << material->GetName() << " in " << lv->GetName();
173  materialPropertiesTable = material->GetMaterialPropertiesTable();
174  if ( !materialPropertiesTable ) {
175  if ( !setPbWO2MaterialProperties_( material ) ) {
176  edm::LogWarning("EcalSim") << "Couldn't retrieve material properties table\n"
177  << " Material = " << material->GetName();
178  }
179  materialPropertiesTable = material->GetMaterialPropertiesTable();
180  }
181 }
bool setPbWO2MaterialProperties_(G4Material *aMaterial)
Sets material properties at run-time...
Definition: DreamSD.cc:500
G4MaterialPropertiesTable * materialPropertiesTable
Definition: DreamSD.h:67
DimensionMap xtalLMap
Definition: DreamSD.h:61
bool DreamSD::ProcessHits ( G4Step *  step,
G4TouchableHistory *  tHistory 
)
virtual

Reimplemented from CaloSD.

Definition at line 77 of file DreamSD.cc.

References CaloSD::createNewHit(), CaloSD::currentHit, CaloSD::edepositEM, CaloSD::edepositHAD, getStepInfo(), CaloSD::hitExists(), NULL, readBothSide_, and side.

77  {
78 
79  if (aStep == NULL) {
80  return true;
81  } else {
82  side = 1;
83  if (getStepInfo(aStep)) {
84  if (hitExists() == false && edepositEM+edepositHAD>0.)
86  if (readBothSide_) {
87  side = -1;
88  getStepInfo(aStep);
89  if (hitExists() == false && edepositEM+edepositHAD>0.)
91  }
92  }
93  }
94  return true;
95 }
float edepositEM
Definition: CaloSD.h:121
bool readBothSide_
Definition: DreamSD.h:58
virtual G4bool getStepInfo(G4Step *aStep)
Definition: DreamSD.cc:99
#define NULL
Definition: scimark2.h:8
float edepositHAD
Definition: CaloSD.h:121
int side
Definition: DreamSD.h:63
CaloG4Hit * currentHit
Definition: CaloSD.h:128
G4bool hitExists()
Definition: CaloSD.cc:310
CaloG4Hit * createNewHit()
Definition: CaloSD.cc:363
uint32_t DreamSD::setDetUnitId ( G4Step *  aStep)
virtual

Implements CaloSD.

Definition at line 185 of file DreamSD.cc.

References LogDebug.

Referenced by getStepInfo().

185  {
186  const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
187  uint32_t id = (touch->GetReplicaNumber(1))*10 + (touch->GetReplicaNumber(0));
188  LogDebug("EcalSim") << "DreamSD:: ID " << id;
189  return id;
190 }
#define LogDebug(id)
bool DreamSD::setPbWO2MaterialProperties_ ( G4Material *  aMaterial)
private

Sets material properties at run-time...

Definition at line 500 of file DreamSD.cc.

References chAngleIntegrals_, cmsHarvester::index, LogDebug, AlCaHLTBitMon_QueryRunRegistry::string, and TableParser::table.

Referenced by initRun().

500  {
501 
502  std::string pbWO2Name("E_PbWO4");
503  if ( pbWO2Name != aMaterial->GetName() ) { // Wrong material!
504  edm::LogWarning("EcalSim") << "This is not the right material: "
505  << "expecting " << pbWO2Name
506  << ", got " << aMaterial->GetName();
507  return false;
508  }
509 
510  G4MaterialPropertiesTable* table = new G4MaterialPropertiesTable();
511 
512  // Refractive index as a function of photon momentum
513  // FIXME: Should somehow put that in the configuration
514  const int nEntries = 14;
515  double PhotonEnergy[nEntries] = { 1.7712*eV, 1.8368*eV, 1.90745*eV, 1.98375*eV, 2.0664*eV,
516  2.15625*eV, 2.25426*eV, 2.3616*eV, 2.47968*eV, 2.61019*eV,
517  2.75521*eV, 2.91728*eV, 3.09961*eV, 3.30625*eV };
518  double RefractiveIndex[nEntries] = { 2.17728, 2.18025, 2.18357, 2.18753, 2.19285,
519  2.19813, 2.20441, 2.21337, 2.22328, 2.23619,
520  2.25203, 2.27381, 2.30282, 2.34666 };
521 
522  table->AddProperty( "RINDEX", PhotonEnergy, RefractiveIndex, nEntries );
523  aMaterial->SetMaterialPropertiesTable(table); // FIXME: could this leak? What does G4 do?
524 
525  // Calculate Cherenkov angle integrals:
526  // This is an ad-hoc solution (we hold it in the class, not in the material)
528  std::auto_ptr<G4PhysicsOrderedFreeVector>( new G4PhysicsOrderedFreeVector() );
529 
530  int index = 0;
531  double currentRI = RefractiveIndex[index];
532  double currentPM = PhotonEnergy[index];
533  double currentCAI = 0.0;
534  chAngleIntegrals_->InsertValues(currentPM, currentCAI);
535  double prevPM = currentPM;
536  double prevCAI = currentCAI;
537  double prevRI = currentRI;
538  while ( ++index < nEntries ) {
539  currentRI = RefractiveIndex[index];
540  currentPM = PhotonEnergy[index];
541  currentCAI = 0.5*(1.0/(prevRI*prevRI) + 1.0/(currentRI*currentRI));
542  currentCAI = prevCAI + (currentPM - prevPM) * currentCAI;
543 
544  chAngleIntegrals_->InsertValues(currentPM, currentCAI);
545 
546  prevPM = currentPM;
547  prevCAI = currentCAI;
548  prevRI = currentRI;
549  }
550 
551  LogDebug("EcalSim") << "Material properties set for " << aMaterial->GetName();
552 
553  return true;
554 
555 }
#define LogDebug(id)
std::auto_ptr< G4PhysicsOrderedFreeVector > chAngleIntegrals_
Table of Cherenkov angle integrals vs photon momentum.
Definition: DreamSD.h:66

Member Data Documentation

double DreamSD::birk1
private

Definition at line 59 of file DreamSD.h.

Referenced by DreamSD(), and getStepInfo().

double DreamSD::birk2
private

Definition at line 59 of file DreamSD.h.

Referenced by DreamSD(), and getStepInfo().

double DreamSD::birk3
private

Definition at line 59 of file DreamSD.h.

Referenced by DreamSD(), and getStepInfo().

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

Table of Cherenkov angle integrals vs photon momentum.

Definition at line 66 of file DreamSD.h.

Referenced by getAverageNumberOfPhotons_(), and setPbWO2MaterialProperties_().

bool DreamSD::doCherenkov_
private

Definition at line 58 of file DreamSD.h.

Referenced by DreamSD(), and getStepInfo().

G4MaterialPropertiesTable* DreamSD::materialPropertiesTable
private

Definition at line 67 of file DreamSD.h.

Referenced by cherenkovDeposit_(), and initRun().

int DreamSD::nphotons_
private

Definition at line 70 of file DreamSD.h.

Referenced by cherenkovDeposit_(), and DreamSD().

TTree* DreamSD::ntuple_
private

Definition at line 69 of file DreamSD.h.

Referenced by cherenkovDeposit_(), and DreamSD().

float DreamSD::px_[MAXPHOTONS]
private

Definition at line 71 of file DreamSD.h.

Referenced by cherenkovDeposit_(), and DreamSD().

float DreamSD::py_[MAXPHOTONS]
private

Definition at line 71 of file DreamSD.h.

Referenced by cherenkovDeposit_(), and DreamSD().

float DreamSD::pz_[MAXPHOTONS]
private

Definition at line 71 of file DreamSD.h.

Referenced by cherenkovDeposit_(), and DreamSD().

bool DreamSD::readBothSide_
private

Definition at line 58 of file DreamSD.h.

Referenced by DreamSD(), and ProcessHits().

int DreamSD::side
private

Definition at line 63 of file DreamSD.h.

Referenced by getStepInfo(), and ProcessHits().

double DreamSD::slopeLY
private

Definition at line 60 of file DreamSD.h.

Referenced by curve_LY(), and DreamSD().

bool DreamSD::useBirk
private

Definition at line 58 of file DreamSD.h.

Referenced by DreamSD(), and getStepInfo().

float DreamSD::x_[MAXPHOTONS]
private

Definition at line 72 of file DreamSD.h.

Referenced by cherenkovDeposit_(), and DreamSD().

DimensionMap DreamSD::xtalLMap
private

Definition at line 61 of file DreamSD.h.

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

float DreamSD::y_[MAXPHOTONS]
private

Definition at line 72 of file DreamSD.h.

Referenced by cherenkovDeposit_(), and DreamSD().

float DreamSD::z_[MAXPHOTONS]
private

Definition at line 72 of file DreamSD.h.

Referenced by cherenkovDeposit_(), and DreamSD().