CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 BscSD FP420SD MuonSensitiveDetector PLTSensitiveDetector TkAccumulatingSensitiveDetector TotemSD

Public Types

enum  coordinates { WorldCoordinates, LocalCoordinates }
 

Public Member Functions

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

Private Attributes

G4Step * currentStep
 
std::string name
 

Detailed Description

Definition at line 24 of file SensitiveDetector.h.

Member Enumeration Documentation

Enumerator
WorldCoordinates 
LocalCoordinates 

Definition at line 38 of file SensitiveDetector.h.

Constructor & Destructor Documentation

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

Definition at line 14 of file SensitiveDetector.cc.

16  :
17  G4VSensitiveDetector(iname), name(iname) {}
SensitiveDetector::~SensitiveDetector ( )
virtual

Definition at line 19 of file SensitiveDetector.cc.

19 {}

Member Function Documentation

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

Definition at line 29 of file SensitiveDetector.cc.

References findQualityFiles::v.

Referenced by BscSD::BscSD(), CaloSD::CaloSD(), FiberSD::FiberSD(), FP420SD::FP420SD(), HFChamberSD::HFChamberSD(), HFWedgeSD::HFWedgeSD(), MuonSensitiveDetector::MuonSensitiveDetector(), PLTSensitiveDetector::PLTSensitiveDetector(), TkAccumulatingSensitiveDetector::TkAccumulatingSensitiveDetector(), and TotemSD::TotemSD().

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

Definition at line 57 of file SensitiveDetector.cc.

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

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

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

Reimplemented in FP420SD, BscSD, MuonSensitiveDetector, and TkAccumulatingSensitiveDetector.

Definition at line 43 of file SensitiveDetector.h.

References nameOfSD(), and groupFilesInBlocks::temp.

Referenced by CaloTrkProcessing::CaloTrkProcessing(), HCalSD::HCalSD(), and HcalTB06BeamSD::HcalTB06BeamSD().

44  {
45  std::vector<std::string> temp;
46  temp.push_back(nameOfSD());
47  return temp;
48  }
std::string nameOfSD()
void SensitiveDetector::Initialize ( G4HCofThisEvent *  eventHC)
virtual

Reimplemented in FP420SD, BscSD, CaloSD, TotemSD, FiberSD, CaloTrkProcessing, HFWedgeSD, and HFChamberSD.

Definition at line 21 of file SensitiveDetector.cc.

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

Definition at line 44 of file SensitiveDetector.cc.

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

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

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

Definition at line 42 of file SensitiveDetector.h.

References name.

Referenced by getNames().

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

Definition at line 76 of file SensitiveDetector.cc.

References gather_cfg::cout, edm::isNotFinite(), NULL, and hitfit::return.

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

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

Member Data Documentation

G4Step* SensitiveDetector::currentStep
private

Definition at line 54 of file SensitiveDetector.h.

Referenced by FinalStepPosition(), and InitialStepPosition().

std::string SensitiveDetector::name
private