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 Bcm1fSD BscSD FP420SD MuonSensitiveDetector PltSD TkAccumulatingSensitiveDetector TotemSD

Public Types

enum  coordinates { WorldCoordinates, LocalCoordinates }
 

Public Member Functions

virtual void AssignSD (std::string &vname)
 
virtual void clearHits ()=0
 
Local3DPoint ConvertToLocal3DPoint (const 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 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,
SensitiveDetectorCatalog clg,
edm::ParameterSet const &  p 
)
explicit

Definition at line 14 of file SensitiveDetector.cc.

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

Definition at line 20 of file SensitiveDetector.cc.

20 {}

Member Function Documentation

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

Definition at line 30 of file SensitiveDetector.cc.

References findQualityFiles::v.

Referenced by Bcm1fSD::Bcm1fSD(), BscSD::BscSD(), CaloSD::CaloSD(), 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)
virtual
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  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

Reimplemented in FP420SD, BscSD, MuonSensitiveDetector, and TkAccumulatingSensitiveDetector.

Definition at line 41 of file SensitiveDetector.h.

References nameOfSD(), and groupFilesInBlocks::temp.

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

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

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

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  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().

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

Definition at line 77 of file SensitiveDetector.cc.

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

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

78 {
79 
80  if ( aStep == NULL ) return ;
81 
82  G4Track* CurrentTrk = aStep->GetTrack() ;
83  G4ThreeVector CurrentPos = CurrentTrk->GetPosition() ;
84  G4ThreeVector CurrentMom = CurrentTrk->GetMomentum() ;
85  G4VPhysicalVolume* pCurrentVol = CurrentTrk->GetVolume() ;
86  G4String NameOfVol ;
87  if ( pCurrentVol != NULL )
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  // std::cout << " NaN detected in volume " << NameOfVol << std::endl ;
112  throw SimG4Exception( "SimG4CoreSensitiveDetector: Corrupted Event - NaN detected (position)" );
113  }
114 
115  xyz[0] = CurrentMom.x() ;
116  xyz[1] = CurrentMom.y() ;
117  xyz[2] = CurrentMom.z() ;
118  if ( !(xyz[0]==xyz[0]) || !(xyz[1]==xyz[1]) || !(xyz[2]==xyz[2]) ||
119  edm::isNotFinite(xyz[0]) != 0 || edm::isNotFinite(xyz[1]) != 0 ||
120  edm::isNotFinite(xyz[2]) != 0 )
121  {
122  std::cout << " NaN detected in volume " << NameOfVol << std::endl ;
123  throw SimG4Exception( "SimG4CoreSensitiveDetector: Corrupted Event - NaN detected (3-momentum)" ) ;
124  }
125 
126  return;
127 
128 }
#define NULL
Definition: scimark2.h:8
bool isNotFinite(T x)
Definition: isFinite.h:10
return(e1-e2)*(e1-e2)+dp *dp
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 52 of file SensitiveDetector.h.

Referenced by FinalStepPosition(), and InitialStepPosition().

std::string SensitiveDetector::name
private