Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
B4c::CalorimeterSD Class Reference
basic » B4 » B4c

Calorimeter sensitive detector class. More...

#include <Doxymodules_basic.h>

Inheritance diagram for B4c::CalorimeterSD:
G4VSensitiveDetector

Public Member Functions

 CalorimeterSD (const G4String &name, const G4String &hitsCollectionName, G4int nofCells)
 
 ~CalorimeterSD () override=default
 
void Initialize (G4HCofThisEvent *hitCollection) override
 
G4bool ProcessHits (G4Step *step, G4TouchableHistory *history) override
 
void EndOfEvent (G4HCofThisEvent *hitCollection) override
 

Private Attributes

CalorHitsCollectionfHitsCollection = nullptr
 
G4int fNofCells = 0
 

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 158 of file Doxymodules_basic.h.

Constructor & Destructor Documentation

◆ CalorimeterSD()

B4c::CalorimeterSD::CalorimeterSD ( const G4String name,
const G4String hitsCollectionName,
G4int  nofCells 
)

Definition at line 42 of file CalorimeterSD.cc.

46 fNofCells(nofCells)
47{
48 collectionName.insert(hitsCollectionName);
49}

◆ ~CalorimeterSD()

B4c::CalorimeterSD::~CalorimeterSD ( )
overridedefault

Member Function Documentation

◆ Initialize()

void B4c::CalorimeterSD::Initialize ( G4HCofThisEvent hitCollection)
override

Definition at line 53 of file CalorimeterSD.cc.

54{
55 // Create hits collection
57 = new CalorHitsCollection(SensitiveDetectorName, collectionName[0]);
58
59 // Add this collection in hce
60 auto hcID
61 = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
62 hce->AddHitsCollection( hcID, fHitsCollection );
63
64 // Create hits
65 // fNofCells for cells + one more for total sums
66 for (G4int i=0; i<fNofCells+1; i++ ) {
67 fHitsCollection->insert(new CalorHit());
68 }
69}
CalorHitsCollection * fHitsCollection
G4THitsCollection< CalorHit > CalorHitsCollection
Definition CalorHit.hh:80

◆ ProcessHits()

G4bool B4c::CalorimeterSD::ProcessHits ( G4Step step,
G4TouchableHistory history 
)
override

Definition at line 73 of file CalorimeterSD.cc.

75{
76 // energy deposit
77 auto edep = step->GetTotalEnergyDeposit();
78
79 // step length
80 G4double stepLength = 0.;
81 if ( step->GetTrack()->GetDefinition()->GetPDGCharge() != 0. ) {
82 stepLength = step->GetStepLength();
83 }
84
85 if ( edep==0. && stepLength == 0. ) return false;
86
87 auto touchable = (step->GetPreStepPoint()->GetTouchable());
88
89 // Get calorimeter cell id
90 auto layerNumber = touchable->GetReplicaNumber(1);
91
92 // Get hit accounting data for this cell
93 auto hit = (*fHitsCollection)[layerNumber];
94 if ( ! hit ) {
95 G4ExceptionDescription msg;
96 msg << "Cannot access hit " << layerNumber;
97 G4Exception("CalorimeterSD::ProcessHits()",
98 "MyCode0004", FatalException, msg);
99 }
100
101 // Get hit for total accounting
102 auto hitTotal
103 = (*fHitsCollection)[fHitsCollection->entries()-1];
104
105 // Add values
106 hit->Add(edep, stepLength);
107 hitTotal->Add(edep, stepLength);
108
109 return true;
110}

◆ EndOfEvent()

void B4c::CalorimeterSD::EndOfEvent ( G4HCofThisEvent hitCollection)
override

Definition at line 114 of file CalorimeterSD.cc.

115{
116 if ( verboseLevel>1 ) {
117 auto nofHits = fHitsCollection->entries();
118 G4cout
119 << G4endl
120 << "-------->Hits Collection: in this event they are " << nofHits
121 << " hits in the tracker chambers: " << G4endl;
122 for ( std::size_t i=0; i<nofHits; ++i ) (*fHitsCollection)[i]->Print();
123 }
124}

Member Data Documentation

◆ fHitsCollection

CalorHitsCollection* B4c::CalorimeterSD::fHitsCollection = nullptr
private

Definition at line 67 of file CalorimeterSD.hh.

◆ fNofCells

G4int B4c::CalorimeterSD::fNofCells = 0
private

Definition at line 68 of file CalorimeterSD.hh.


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

Applications | User Support | Publications | Collaboration