Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
B4cCalorimeterSD Class Reference

#include <B4cCalorimeterSD.hh>

Inheritance diagram for B4cCalorimeterSD:
G4VSensitiveDetector

Public Member Functions

 B4cCalorimeterSD (const G4String &name, const G4String &hitsCollectionName, G4int nofCells)
 
virtual ~B4cCalorimeterSD ()
 
virtual void Initialize (G4HCofThisEvent *hitCollection)
 
virtual G4bool ProcessHits (G4Step *step, G4TouchableHistory *history)
 
virtual void EndOfEvent (G4HCofThisEvent *hitCollection)
 
- Public Member Functions inherited from G4VSensitiveDetector
 G4VSensitiveDetector (G4String name)
 
 G4VSensitiveDetector (const G4VSensitiveDetector &right)
 
virtual ~G4VSensitiveDetector ()
 
const G4VSensitiveDetectoroperator= (const G4VSensitiveDetector &right)
 
G4int operator== (const G4VSensitiveDetector &right) const
 
G4int operator!= (const G4VSensitiveDetector &right) const
 
virtual void clear ()
 
virtual void DrawAll ()
 
virtual void PrintAll ()
 
G4bool Hit (G4Step *aStep)
 
void SetROgeometry (G4VReadOutGeometry *value)
 
void SetFilter (G4VSDFilter *value)
 
G4int GetNumberOfCollections () const
 
G4String GetCollectionName (G4int id) const
 
void SetVerboseLevel (G4int vl)
 
void Activate (G4bool activeFlag)
 
G4bool isActive () const
 
G4String GetName () const
 
G4String GetPathName () const
 
G4String GetFullPathName () const
 
G4VReadOutGeometryGetROgeometry () const
 
G4VSDFilterGetFilter () const
 
virtual G4VSensitiveDetectorClone () const
 

Additional Inherited Members

- Protected Member Functions inherited from G4VSensitiveDetector
virtual G4int GetCollectionID (G4int i)
 
- Protected Attributes inherited from G4VSensitiveDetector
G4CollectionNameVector collectionName
 
G4String SensitiveDetectorName
 
G4String thePathName
 
G4String fullPathName
 
G4int verboseLevel
 
G4bool active
 
G4VReadOutGeometryROgeometry
 
G4VSDFilterfilter
 

Detailed Description

Calorimeter sensitive detector class

In Initialize(), it creates one hit for each calorimeter layer and one more hit for accounting the total quantities in all layers.

The values are accounted in hits in ProcessHits() function which is called by Geant4 kernel at each step.

Definition at line 51 of file B4cCalorimeterSD.hh.

Constructor & Destructor Documentation

B4cCalorimeterSD::B4cCalorimeterSD ( const G4String name,
const G4String hitsCollectionName,
G4int  nofCells 
)

Definition at line 40 of file B4cCalorimeterSD.cc.

References G4VSensitiveDetector::collectionName, and G4CollectionNameVector::insert().

44  : G4VSensitiveDetector(name),
45  fHitsCollection(0),
46  fNofCells(nofCells)
47 {
48  collectionName.insert(hitsCollectionName);
49 }
G4VSensitiveDetector(G4String name)
G4CollectionNameVector collectionName
B4cCalorimeterSD::~B4cCalorimeterSD ( )
virtual

Definition at line 53 of file B4cCalorimeterSD.cc.

54 {
55 }

Member Function Documentation

void B4cCalorimeterSD::EndOfEvent ( G4HCofThisEvent hitCollection)
virtual

Reimplemented from G4VSensitiveDetector.

Definition at line 121 of file B4cCalorimeterSD.cc.

References G4THitsCollection< T >::entries(), G4cout, G4endl, and G4VSensitiveDetector::verboseLevel.

122 {
123  if ( verboseLevel>1 ) {
124  G4int nofHits = fHitsCollection->entries();
125  G4cout << "\n-------->Hits Collection: in this event they are " << nofHits
126  << " hits in the tracker chambers: " << G4endl;
127  for ( G4int i=0; i<nofHits; i++ ) (*fHitsCollection)[i]->Print();
128  }
129 }
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
void B4cCalorimeterSD::Initialize ( G4HCofThisEvent hitCollection)
virtual

Reimplemented from G4VSensitiveDetector.

Definition at line 59 of file B4cCalorimeterSD.cc.

References G4HCofThisEvent::AddHitsCollection(), G4VSensitiveDetector::collectionName, G4SDManager::GetCollectionID(), G4SDManager::GetSDMpointer(), G4THitsCollection< T >::insert(), and G4VSensitiveDetector::SensitiveDetectorName.

60 {
61  // Create hits collection
62  fHitsCollection
64 
65  // Add this collection in hce
66  G4int hcID
68  hce->AddHitsCollection( hcID, fHitsCollection );
69 
70  // Create hits
71  // fNofCells for cells + one more for total sums
72  for (G4int i=0; i<fNofCells+1; i++ ) {
73  fHitsCollection->insert(new B4cCalorHit());
74  }
75 }
G4int GetCollectionID(G4String colName)
Definition: G4SDManager.cc:131
G4THitsCollection< B4cCalorHit > B4cCalorHitsCollection
Definition: B4cCalorHit.hh:78
int G4int
Definition: G4Types.hh:78
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
G4CollectionNameVector collectionName
G4bool B4cCalorimeterSD::ProcessHits ( G4Step step,
G4TouchableHistory history 
)
virtual

Implements G4VSensitiveDetector.

Definition at line 79 of file B4cCalorimeterSD.cc.

References B4cCalorHit::Add(), G4THitsCollection< T >::entries(), FatalException, G4Exception(), G4Track::GetDefinition(), G4ParticleDefinition::GetPDGCharge(), G4Step::GetPreStepPoint(), G4TouchableHistory::GetReplicaNumber(), G4Step::GetStepLength(), G4Step::GetTotalEnergyDeposit(), G4StepPoint::GetTouchable(), and G4Step::GetTrack().

81 {
82  // energy deposit
83  G4double edep = step->GetTotalEnergyDeposit();
84 
85  // step length
86  G4double stepLength = 0.;
87  if ( step->GetTrack()->GetDefinition()->GetPDGCharge() != 0. ) {
88  stepLength = step->GetStepLength();
89  }
90 
91  if ( edep==0. && stepLength == 0. ) return false;
92 
93  G4TouchableHistory* touchable
95 
96  // Get calorimeter cell id
97  G4int layerNumber = touchable->GetReplicaNumber(1);
98 
99  // Get hit accounting data for this cell
100  B4cCalorHit* hit = (*fHitsCollection)[layerNumber];
101  if ( ! hit ) {
103  msg << "Cannot access hit " << layerNumber;
104  G4Exception("B4cCalorimeterSD::ProcessHits()",
105  "MyCode0004", FatalException, msg);
106  }
107 
108  // Get hit for total accounting
109  B4cCalorHit* hitTotal
110  = (*fHitsCollection)[fHitsCollection->entries()-1];
111 
112  // Add values
113  hit->Add(edep, stepLength);
114  hitTotal->Add(edep, stepLength);
115 
116  return true;
117 }
G4ParticleDefinition * GetDefinition() const
std::ostringstream G4ExceptionDescription
Definition: globals.hh:76
G4double GetStepLength() const
void Add(G4double de, G4double dl)
Definition: B4cCalorHit.hh:100
const G4VTouchable * GetTouchable() const
int G4int
Definition: G4Types.hh:78
G4StepPoint * GetPreStepPoint() const
G4int GetReplicaNumber(G4int depth=0) const
G4double GetTotalEnergyDeposit() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
double G4double
Definition: G4Types.hh:76
G4Track * GetTrack() const
G4double GetPDGCharge() const

The documentation for this class was generated from the following files: