CMS 3D CMS Logo

List of all members | Public Types | Public Member Functions | Private Attributes
SensitiveDetector Class Referenceabstract

#include <SensitiveDetector.h>

Inheritance diagram for SensitiveDetector:
SensitiveCaloDetector SensitiveTkDetector CaloSD CaloTrkProcessing FiberSD HFChamberSD HFWedgeSD Bcm1fSD BHMSD BscSD FastTimerSD FP420SD MuonSensitiveDetector PltSD TkAccumulatingSensitiveDetector TotemSD

Public Types

enum  coordinates { WorldCoordinates, LocalCoordinates }
 

Public Member Functions

virtual void AssignSD (const std::string &vname)
 
virtual void clearHits ()=0
 
Local3DPoint ConvertToLocal3DPoint (const G4ThreeVector &point)
 
void EndOfEvent (G4HCofThisEvent *eventHC) override
 
Local3DPoint FinalStepPosition (G4Step *s, coordinates)
 
virtual std::vector< std::string > getNames ()
 
void Initialize (G4HCofThisEvent *eventHC) override
 
Local3DPoint InitialStepPosition (G4Step *s, coordinates)
 
std::string nameOfSD ()
 
void NaNTrap (G4Step *step)
 
G4bool ProcessHits (G4Step *step, G4TouchableHistory *tHistory) override=0
 
void Register ()
 
 SensitiveDetector (std::string &iname, const DDCompactView &cpv, const SensitiveDetectorCatalog &, edm::ParameterSet const &p)
 
virtual uint32_t setDetUnitId (G4Step *step)=0
 
 ~SensitiveDetector () override
 

Private Attributes

G4Step * currentStep
 
std::string name
 

Detailed Description

Definition at line 22 of file SensitiveDetector.h.

Member Enumeration Documentation

Enumerator
WorldCoordinates 
LocalCoordinates 

Definition at line 36 of file SensitiveDetector.h.

Constructor & Destructor Documentation

SensitiveDetector::SensitiveDetector ( std::string &  iname,
const DDCompactView cpv,
const SensitiveDetectorCatalog clg,
edm::ParameterSet const &  p 
)
explicit

Definition at line 14 of file SensitiveDetector.cc.

17  :
18  G4VSensitiveDetector(iname), name(iname) {}
SensitiveDetector::~SensitiveDetector ( )
override

Definition at line 20 of file SensitiveDetector.cc.

20 {}

Member Function Documentation

void SensitiveDetector::AssignSD ( const std::string &  vname)
virtual

Definition at line 30 of file SensitiveDetector.cc.

References findQualityFiles::v.

Referenced by Bcm1fSD::Bcm1fSD(), BHMSD::BHMSD(), BscSD::BscSD(), CaloSD::CaloSD(), FastTimerSD::FastTimerSD(), FiberSD::FiberSD(), FP420SD::FP420SD(), HFChamberSD::HFChamberSD(), HFWedgeSD::HFWedgeSD(), MuonSensitiveDetector::MuonSensitiveDetector(), PltSD::PltSD(), TkAccumulatingSensitiveDetector::TkAccumulatingSensitiveDetector(), and TotemSD::TotemSD().

31 {
32  G4LogicalVolumeStore * theStore = G4LogicalVolumeStore::GetInstance();
33  G4LogicalVolumeStore::const_iterator it;
34  for (it = theStore->begin(); it != theStore->end(); it++)
35  {
36  G4LogicalVolume * v = *it;
37  if (vname==v->GetName()) { v->SetSensitiveDetector(this); }
38  }
39 }
virtual void SensitiveDetector::clearHits ( )
pure virtual
Local3DPoint SensitiveDetector::ConvertToLocal3DPoint ( const G4ThreeVector &  point)
void SensitiveDetector::EndOfEvent ( G4HCofThisEvent *  eventHC)
override

Definition at line 41 of file SensitiveDetector.cc.

41 {}
Local3DPoint SensitiveDetector::FinalStepPosition ( G4Step *  s,
coordinates  c 
)

Definition at line 58 of file SensitiveDetector.cc.

References ConvertToLocal3DPoint(), currentStep, alignCSCRings::s, and WorldCoordinates.

Referenced by Bcm1fSD::createHit(), PltSD::createHit(), TkAccumulatingSensitiveDetector::createHit(), MuonSensitiveDetector::createHit(), Bcm1fSD::updateHit(), PltSD::updateHit(), TkAccumulatingSensitiveDetector::updateHit(), and MuonSensitiveDetector::updateHit().

59 {
60  currentStep = s;
61  G4StepPoint * postStepPoint = currentStep->GetPostStepPoint();
62  G4StepPoint * preStepPoint = currentStep->GetPreStepPoint();
63  const G4ThreeVector& globalCoordinates = postStepPoint->GetPosition();
64  if (c == WorldCoordinates) return ConvertToLocal3DPoint(globalCoordinates);
65  G4TouchableHistory * theTouchable = (G4TouchableHistory *)
66  (preStepPoint->GetTouchable());
67  G4ThreeVector localCoordinates = theTouchable->GetHistory()
68  ->GetTopTransform().TransformPoint(globalCoordinates);
69  return ConvertToLocal3DPoint(localCoordinates);
70 }
Local3DPoint ConvertToLocal3DPoint(const G4ThreeVector &point)
virtual std::vector<std::string> SensitiveDetector::getNames ( )
inlinevirtual
void SensitiveDetector::Initialize ( G4HCofThisEvent *  eventHC)
override

Definition at line 22 of file SensitiveDetector.cc.

22 {}
Local3DPoint SensitiveDetector::InitialStepPosition ( G4Step *  s,
coordinates  c 
)

Definition at line 45 of file SensitiveDetector.cc.

References ConvertToLocal3DPoint(), currentStep, alignCSCRings::s, and WorldCoordinates.

Referenced by Bcm1fSD::closeHit(), PltSD::closeHit(), TkAccumulatingSensitiveDetector::closeHit(), Bcm1fSD::createHit(), PltSD::createHit(), TkAccumulatingSensitiveDetector::createHit(), MuonSensitiveDetector::createHit(), and MuonSensitiveDetector::ProcessHits().

46 {
47  currentStep = s;
48  G4StepPoint * preStepPoint = currentStep->GetPreStepPoint();
49  const G4ThreeVector& globalCoordinates = preStepPoint->GetPosition();
50  if (c == WorldCoordinates) return ConvertToLocal3DPoint(globalCoordinates);
51  G4TouchableHistory * theTouchable=(G4TouchableHistory *)
52  (preStepPoint->GetTouchable());
53  G4ThreeVector localCoordinates = theTouchable->GetHistory()
54  ->GetTopTransform().TransformPoint(globalCoordinates);
55  return ConvertToLocal3DPoint(localCoordinates);
56 }
Local3DPoint ConvertToLocal3DPoint(const G4ThreeVector &point)
std::string SensitiveDetector::nameOfSD ( )
inline

Definition at line 40 of file SensitiveDetector.h.

References name.

Referenced by getNames(), and HGCSD::HGCSD().

40 { return name; }
void SensitiveDetector::NaNTrap ( G4Step *  step)

Definition at line 77 of file SensitiveDetector.cc.

References edm::isNotFinite(), and reco::return().

Referenced by getNames(), ZdcSD::ProcessHits(), HGCSD::ProcessHits(), HCalSD::ProcessHits(), and CaloSD::ProcessHits().

78 {
79 
80  if ( aStep == nullptr ) return ;
81 
82  G4Track* CurrentTrk = aStep->GetTrack() ;
83  const G4ThreeVector& CurrentPos = CurrentTrk->GetPosition() ;
84  G4ThreeVector CurrentMom = CurrentTrk->GetMomentum() ;
85  G4VPhysicalVolume* pCurrentVol = CurrentTrk->GetVolume() ;
86  G4String NameOfVol ;
87  if ( pCurrentVol != nullptr )
88  {
89  NameOfVol = pCurrentVol->GetName() ;
90  }
91  else
92  {
93  NameOfVol = "CorruptedVolumeInfo" ;
94  }
95 
96  // for simplicity... maybe edm::isNotFinite() will work on the
97  // 3-vector directly...
98 
99  double xyz[3] ;
100  xyz[0] = CurrentPos.x() ;
101  xyz[1] = CurrentPos.y() ;
102  xyz[2] = CurrentPos.z() ;
103 
104  //
105  // this is another trick to check on a NaN, maybe it's even CPU-faster...
106  // but ler's stick to system function edm::isNotFinite(...) for now
107  //
108  // if ( !(xyz[0]==xyz[0]) || !(xyz[1]==xyz[1]) || !(xyz[2]==xyz[2]) )
109  if( edm::isNotFinite(xyz[0]+xyz[1]+xyz[2]) != 0 )
110  {
111  throw SimG4Exception( "SimG4CoreSensitiveDetector: Corrupted Event - NaN detected (position) in volume " + NameOfVol);
112  }
113 
114  xyz[0] = CurrentMom.x() ;
115  xyz[1] = CurrentMom.y() ;
116  xyz[2] = CurrentMom.z() ;
117  if ( !(xyz[0]==xyz[0]) || !(xyz[1]==xyz[1]) || !(xyz[2]==xyz[2]) ||
118  edm::isNotFinite(xyz[0]) != 0 || edm::isNotFinite(xyz[1]) != 0 ||
119  edm::isNotFinite(xyz[2]) != 0 )
120  {
121  throw SimG4Exception( "SimG4CoreSensitiveDetector: Corrupted Event - NaN detected (3-momentum) in volume " + NameOfVol);
122  }
123 
124  return;
125 
126 }
bool isNotFinite(T x)
Definition: isFinite.h:10
return(e1-e2)*(e1-e2)+dp *dp
G4bool SensitiveDetector::ProcessHits ( G4Step *  step,
G4TouchableHistory *  tHistory 
)
overridepure virtual
void SensitiveDetector::Register ( )
virtual uint32_t SensitiveDetector::setDetUnitId ( G4Step *  step)
pure virtual

Member Data Documentation

G4Step* SensitiveDetector::currentStep
private

Definition at line 52 of file SensitiveDetector.h.

Referenced by FinalStepPosition(), and InitialStepPosition().

std::string SensitiveDetector::name
private