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 13 of file SensitiveDetector.cc.

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

Definition at line 18 of file SensitiveDetector.cc.

18 {}

Member Function Documentation

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

Definition at line 28 of file SensitiveDetector.cc.

References v.

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

29 {
30  G4LogicalVolumeStore * theStore = G4LogicalVolumeStore::GetInstance();
31  G4LogicalVolumeStore::const_iterator it;
32  for (it = theStore->begin(); it != theStore->end(); it++)
33  {
34  G4LogicalVolume * v = *it;
35  if (vname==v->GetName()) v->SetSensitiveDetector(this);
36  }
37 }
mathSSE::Vec4< T > v
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 56 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().

57 {
58  currentStep = s;
59  G4StepPoint * postStepPoint = currentStep->GetPostStepPoint();
60  G4StepPoint * preStepPoint = currentStep->GetPreStepPoint();
61  G4ThreeVector globalCoordinates = postStepPoint->GetPosition();
62  if (c == WorldCoordinates) return ConvertToLocal3DPoint(globalCoordinates);
63  G4TouchableHistory * theTouchable = (G4TouchableHistory *)
64  (preStepPoint->GetTouchable());
65  G4ThreeVector localCoordinates = theTouchable->GetHistory()
66  ->GetTopTransform().TransformPoint(globalCoordinates);
67  return ConvertToLocal3DPoint(localCoordinates);
68 }
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 20 of file SensitiveDetector.cc.

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

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

44 {
45  currentStep = s;
46  G4StepPoint * preStepPoint = currentStep->GetPreStepPoint();
47  G4ThreeVector globalCoordinates = preStepPoint->GetPosition();
48  if (c == WorldCoordinates) return ConvertToLocal3DPoint(globalCoordinates);
49  G4TouchableHistory * theTouchable=(G4TouchableHistory *)
50  (preStepPoint->GetTouchable());
51  G4ThreeVector localCoordinates = theTouchable->GetHistory()
52  ->GetTopTransform().TransformPoint(globalCoordinates);
53  return ConvertToLocal3DPoint(localCoordinates);
54 }
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 75 of file SensitiveDetector.cc.

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

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

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