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::LogVerbatim("SensitiveDetector")
41  << " <" << iname <<"> : Assigns SD to LVs " << ss.str();
42 }
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 44 of file SensitiveDetector.cc.

44 {}

Member Function Documentation

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

Definition at line 50 of file SensitiveDetector.cc.

Referenced by ConvertToLocal3DPoint(), and SensitiveDetector().

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

Definition at line 99 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().

100 {
101  TrackInformation* info = (TrackInformation*)(aTrack->GetUserInformation());
102  if (!info) {
103  edm::LogWarning("SensitiveDetector")
104  << " no TrackInformation available for trackID= "
105  << aTrack->GetTrackID();
106  throw SimG4Exception("SimG4CoreSensitiveDetector: cannot handle hits for "
107  + GetName());
108  }
109  return info;
110 }
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 48 of file SensitiveDetector.cc.

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

Definition at line 72 of file SensitiveDetector.cc.

References ConvertToLocal3DPoint(), and WorldCoordinates.

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

73 {
74  const G4StepPoint * postStepPoint = step->GetPostStepPoint();
75  const G4ThreeVector& globalCoordinates = postStepPoint->GetPosition();
76  if (cd == WorldCoordinates) { return ConvertToLocal3DPoint(globalCoordinates); }
77  const G4StepPoint * preStepPoint = step->GetPreStepPoint();
78  const G4ThreeVector localCoordinates = preStepPoint->GetTouchable()->GetHistory()
79  ->GetTopTransform().TransformPoint(globalCoordinates);
80  return ConvertToLocal3DPoint(localCoordinates);
81 }
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 46 of file SensitiveDetector.cc.

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

Definition at line 61 of file SensitiveDetector.cc.

References ConvertToLocal3DPoint(), and WorldCoordinates.

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

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

Definition at line 91 of file SensitiveDetector.cc.

References ConvertToLocal3DPoint().

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

92 {
93  const G4ThreeVector& globalCoordinates = step->GetPostStepPoint()->GetPosition();
94  G4ThreeVector localCoordinates = step->GetPreStepPoint()->GetTouchable()->GetHistory()
95  ->GetTopTransform().TransformPoint(globalCoordinates);
96  return ConvertToLocal3DPoint(localCoordinates);
97 }
Local3DPoint ConvertToLocal3DPoint(const G4ThreeVector &point) const
step
Local3DPoint SensitiveDetector::LocalPreStepPosition ( const G4Step *  step) const
protected

Definition at line 83 of file SensitiveDetector.cc.

References ConvertToLocal3DPoint().

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

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

Definition at line 118 of file SensitiveDetector.cc.

References edm::isNotFinite().

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

119 {
120  const G4Track* CurrentTrk = aStep->GetTrack();
121  const G4ThreeVector& CurrentPos = CurrentTrk->GetPosition();
122  double xyz = CurrentPos.x() + CurrentPos.y() + CurrentPos.z();
123  const G4ThreeVector& CurrentMom = CurrentTrk->GetMomentum();
124  xyz += CurrentMom.x() + CurrentMom.y() + CurrentMom.z();
125 
126  if( edm::isNotFinite(xyz) ) {
127 
128  const G4VPhysicalVolume* pCurrentVol = aStep->GetPreStepPoint()->GetPhysicalVolume();
129  const G4String& NameOfVol = pCurrentVol->GetName();
130  throw SimG4Exception("SimG4CoreSensitiveDetector: Corrupted Event - NaN detected in volume "
131  + NameOfVol);
132  }
133 }
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 112 of file SensitiveDetector.cc.

References namesOfSD.

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

113 {
114  namesOfSD.clear();
115  namesOfSD = hnames;
116 }
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().