CMS 3D CMS Logo

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

#include <SensitiveDetector.h>

Inheritance diagram for SensitiveDetector:
SensitiveCaloDetector SensitiveTkDetector CaloSD CaloTrkProcessing FiberSD HFChamberSD HFWedgeSD FP420SD MuonSensitiveDetector TimingSD TkAccumulatingSensitiveDetector TotemSD

Public Member Functions

virtual void clearHits ()=0
 
void EndOfEvent (G4HCofThisEvent *eventHC) override
 
const std::vector< std::string > & getNames () const
 
void Initialize (G4HCofThisEvent *eventHC) override
 
G4bool ProcessHits (G4Step *step, G4TouchableHistory *tHistory) override=0
 
 SensitiveDetector (const std::string &iname, const DDCompactView &cpv, const SensitiveDetectorCatalog &, edm::ParameterSet const &p)
 
virtual uint32_t setDetUnitId (const G4Step *step)=0
 
 ~SensitiveDetector () override
 

Protected Types

enum  coordinates { WorldCoordinates, LocalCoordinates }
 

Protected Member Functions

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 > &)
 

Private Member Functions

void AssignSD (const std::string &vname)
 

Private Attributes

std::vector< std::string > namesOfSD
 

Detailed Description

Definition at line 22 of file SensitiveDetector.h.

Member Enumeration Documentation

Enumerator
WorldCoordinates 
LocalCoordinates 

Definition at line 43 of file SensitiveDetector.h.

Constructor & Destructor Documentation

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

Definition at line 18 of file SensitiveDetector.cc.

References AssignSD(), ecaldqm::collectionName, SensitiveDetectorCatalog::logicalNames(), and namesOfSD.

21  :
22  G4VSensitiveDetector(iname)
23 {
24  // for CMS hits
25  namesOfSD.push_back(iname);
26 
27  // Geant4 hit collection
28  collectionName.insert(iname);
29 
30  // register sensitive detector
31  G4SDManager * SDman = G4SDManager::GetSDMpointer();
32  SDman->AddNewDetector(this);
33 
34  const std::vector<std::string>& lvNames = clg.logicalNames(iname);
35  std::stringstream ss;
36  for (auto & lvname : lvNames) {
37  this->AssignSD(lvname);
38  ss << " " << lvname;
39  }
40  edm::LogInfo("SensitiveDetector") << " <" << iname <<"> : Assigns SD to LVs "
41  << ss.str();
42 
43 }
const std::vector< std::string > & logicalNames(const std::string &readoutName) const
void AssignSD(const std::string &vname)
std::string const collectionName[nCollections]
Definition: Collections.h:47
std::vector< std::string > namesOfSD
SensitiveDetector::~SensitiveDetector ( )
override

Definition at line 45 of file SensitiveDetector.cc.

45 {}

Member Function Documentation

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

Definition at line 51 of file SensitiveDetector.cc.

Referenced by ConvertToLocal3DPoint(), and SensitiveDetector().

52 {
53  G4LogicalVolumeStore * theStore = G4LogicalVolumeStore::GetInstance();
54  for (auto & lv : *theStore)
55  {
56  if (vname == lv->GetName()) {
57  lv->SetSensitiveDetector(this);
58  }
59  }
60 }
virtual void SensitiveDetector::clearHits ( )
pure virtual
TrackInformation * SensitiveDetector::cmsTrackInformation ( const G4Track *  aTrack)
protected

Definition at line 104 of file SensitiveDetector.cc.

References info().

Referenced by ConvertToLocal3DPoint(), TkAccumulatingSensitiveDetector::createHit(), MuonSensitiveDetector::createHit(), CaloSD::createNewHit(), CaloSD::getResponseWt(), TimingSD::getStepInfo(), CaloSD::getTrackID(), CaloSD::setTrackID(), TkAccumulatingSensitiveDetector::update(), and CaloSD::update().

105 {
106  TrackInformation* info = (TrackInformation*)(aTrack->GetUserInformation());
107  if (!info) {
108  edm::LogWarning("SensitiveDetector")
109  << " no TrackInformation available for trackID= "
110  << aTrack->GetTrackID();
111  throw SimG4Exception("SimG4CoreSensitiveDetector: cannot handle hits for "
112  + GetName());
113  }
114  return info;
115 }
static const TGPicture * info(bool iBackgroundIsBlack)
Local3DPoint SensitiveDetector::ConvertToLocal3DPoint ( const G4ThreeVector &  point) const
inlineprotected

Definition at line 50 of file SensitiveDetector.h.

References AssignSD(), cmsTrackInformation(), NaNTrap(), setNames(), and AlCaHLTBitMon_QueryRunRegistry::string.

Referenced by TkAccumulatingSensitiveDetector::createHit(), MuonSensitiveDetector::createHit(), TimingSD::EndOfEvent(), FinalStepPosition(), MuonSensitiveDetector::FinalStepPositionVsParent(), InitialStepPosition(), MuonSensitiveDetector::InitialStepPositionVsParent(), LocalPostStepPosition(), LocalPreStepPosition(), and TkAccumulatingSensitiveDetector::updateHit().

51  { return Local3DPoint(point.x(),point.y(),point.z()); }
Point3DBase< float, LocalTag > Local3DPoint
Definition: LocalPoint.h:9
*vegas h *****************************************************used in the default bin number in original ***version of VEGAS is ***a higher bin number might help to derive a more precise ***grade subtle point
Definition: invegas.h:5
void SensitiveDetector::EndOfEvent ( G4HCofThisEvent *  eventHC)
override

Definition at line 49 of file SensitiveDetector.cc.

49 {}
Local3DPoint SensitiveDetector::FinalStepPosition ( const G4Step *  step,
coordinates  cd 
) const
protected

Definition at line 73 of file SensitiveDetector.cc.

References ConvertToLocal3DPoint(), and WorldCoordinates.

Referenced by MuonSensitiveDetector::createHit(), and MuonSensitiveDetector::updateHit().

74 {
75  const G4StepPoint * postStepPoint = step->GetPostStepPoint();
76  const G4ThreeVector& globalCoordinates = postStepPoint->GetPosition();
77  if (cd == WorldCoordinates) { return ConvertToLocal3DPoint(globalCoordinates); }
78  const G4StepPoint * preStepPoint = step->GetPreStepPoint();
79  G4TouchableHistory * theTouchable = (G4TouchableHistory *)(preStepPoint->GetTouchable());
80  const G4ThreeVector localCoordinates = theTouchable->GetHistory()
81  ->GetTopTransform().TransformPoint(globalCoordinates);
82  return ConvertToLocal3DPoint(localCoordinates);
83 }
Local3DPoint ConvertToLocal3DPoint(const G4ThreeVector &point) const
step
const std::vector<std::string>& SensitiveDetector::getNames ( ) const
inline
void SensitiveDetector::Initialize ( G4HCofThisEvent *  eventHC)
override

Definition at line 47 of file SensitiveDetector.cc.

47 {}
Local3DPoint SensitiveDetector::InitialStepPosition ( const G4Step *  step,
coordinates  cd 
) const
protected

Definition at line 62 of file SensitiveDetector.cc.

References ConvertToLocal3DPoint(), and WorldCoordinates.

Referenced by MuonSensitiveDetector::createHit(), and MuonSensitiveDetector::ProcessHits().

63 {
64  const G4StepPoint * preStepPoint = step->GetPreStepPoint();
65  const G4ThreeVector& globalCoordinates = preStepPoint->GetPosition();
66  if (cd == WorldCoordinates) { return ConvertToLocal3DPoint(globalCoordinates); }
67  G4TouchableHistory * theTouchable=(G4TouchableHistory *)(preStepPoint->GetTouchable());
68  const G4ThreeVector localCoordinates = theTouchable->GetHistory()
69  ->GetTopTransform().TransformPoint(globalCoordinates);
70  return ConvertToLocal3DPoint(localCoordinates);
71 }
Local3DPoint ConvertToLocal3DPoint(const G4ThreeVector &point) const
step
Local3DPoint SensitiveDetector::LocalPostStepPosition ( const G4Step *  step) const
protected

Definition at line 94 of file SensitiveDetector.cc.

References ConvertToLocal3DPoint().

Referenced by TkAccumulatingSensitiveDetector::createHit(), and TkAccumulatingSensitiveDetector::updateHit().

95 {
96  const G4ThreeVector& globalCoordinates = step->GetPostStepPoint()->GetPosition();
97  G4TouchableHistory * theTouchable =
98  (G4TouchableHistory *)(step->GetPreStepPoint()->GetTouchable());
99  G4ThreeVector localCoordinates = theTouchable->GetHistory()
100  ->GetTopTransform().TransformPoint(globalCoordinates);
101  return ConvertToLocal3DPoint(localCoordinates);
102 }
Local3DPoint ConvertToLocal3DPoint(const G4ThreeVector &point) const
step
Local3DPoint SensitiveDetector::LocalPreStepPosition ( const G4Step *  step) const
protected

Definition at line 85 of file SensitiveDetector.cc.

References ConvertToLocal3DPoint().

Referenced by TkAccumulatingSensitiveDetector::closeHit(), and TkAccumulatingSensitiveDetector::createHit().

86 {
87  const G4StepPoint * preStepPoint = step->GetPreStepPoint();
88  G4TouchableHistory * theTouchable=(G4TouchableHistory *)(preStepPoint->GetTouchable());
89  G4ThreeVector localCoordinates = theTouchable->GetHistory()
90  ->GetTopTransform().TransformPoint(preStepPoint->GetPosition());
91  return ConvertToLocal3DPoint(localCoordinates);
92 }
Local3DPoint ConvertToLocal3DPoint(const G4ThreeVector &point) const
step
void SensitiveDetector::NaNTrap ( const G4Step *  step) const
protected

Definition at line 123 of file SensitiveDetector.cc.

References edm::isNotFinite().

Referenced by ConvertToLocal3DPoint(), and CaloSD::ProcessHits().

124 {
125  const G4Track* CurrentTrk = aStep->GetTrack();
126  const G4ThreeVector& CurrentPos = CurrentTrk->GetPosition();
127  double xyz = CurrentPos.x() + CurrentPos.y() + CurrentPos.z();
128  const G4ThreeVector& CurrentMom = CurrentTrk->GetMomentum();
129  xyz += CurrentMom.x() + CurrentMom.y() + CurrentMom.z();
130 
131  if( edm::isNotFinite(xyz) ) {
132 
133  const G4VPhysicalVolume* pCurrentVol = aStep->GetPreStepPoint()->GetPhysicalVolume();
134  const G4String& NameOfVol = pCurrentVol->GetName();
135  throw SimG4Exception("SimG4CoreSensitiveDetector: Corrupted Event - NaN detected in volume "
136  + NameOfVol);
137  }
138 }
bool isNotFinite(T x)
Definition: isFinite.h:10
G4bool SensitiveDetector::ProcessHits ( G4Step *  step,
G4TouchableHistory *  tHistory 
)
overridepure virtual
virtual uint32_t SensitiveDetector::setDetUnitId ( const G4Step *  step)
pure virtual
void SensitiveDetector::setNames ( const std::vector< std::string > &  hnames)
protected

Definition at line 117 of file SensitiveDetector.cc.

References namesOfSD.

Referenced by ConvertToLocal3DPoint(), and TkAccumulatingSensitiveDetector::TkAccumulatingSensitiveDetector().

118 {
119  namesOfSD.clear();
120  namesOfSD = hnames;
121 }
std::vector< std::string > namesOfSD

Member Data Documentation

std::vector<std::string> SensitiveDetector::namesOfSD
private

Definition at line 62 of file SensitiveDetector.h.

Referenced by getNames(), SensitiveDetector(), and setNames().