Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
B4cCalorimeterSD.cc
이 파일의 문서화 페이지로 가기
1 //
2 // ********************************************************************
3 // * License and Disclaimer *
4 // * *
5 // * The Geant4 software is copyright of the Copyright Holders of *
6 // * the Geant4 Collaboration. It is provided under the terms and *
7 // * conditions of the Geant4 Software License, included in the file *
8 // * LICENSE and available at http://cern.ch/geant4/license . These *
9 // * include a list of copyright holders. *
10 // * *
11 // * Neither the authors of this software system, nor their employing *
12 // * institutes,nor the agencies providing financial support for this *
13 // * work make any representation or warranty, express or implied, *
14 // * regarding this software system or assume any liability for its *
15 // * use. Please see the license in the file LICENSE and URL above *
16 // * for the full disclaimer and the limitation of liability. *
17 // * *
18 // * This code implementation is the result of the scientific and *
19 // * technical work of the GEANT4 collaboration. *
20 // * By using, copying, modifying or distributing the software (or *
21 // * any work based on the software) you agree to acknowledge its *
22 // * use in resulting scientific publications, and indicate your *
23 // * acceptance of all terms of the Geant4 Software license. *
24 // ********************************************************************
25 //
26 // $Id: B4cCalorimeterSD.cc 100946 2016-11-03 11:28:08Z gcosmo $
27 //
30 
31 #include "B4cCalorimeterSD.hh"
32 #include "G4HCofThisEvent.hh"
33 #include "G4Step.hh"
34 #include "G4ThreeVector.hh"
35 #include "G4SDManager.hh"
36 #include "G4ios.hh"
37 
38 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
39 
41  const G4String& name,
42  const G4String& hitsCollectionName,
43  G4int nofCells)
44  : G4VSensitiveDetector(name),
45  fHitsCollection(nullptr),
46  fNofCells(nofCells)
47 {
48  collectionName.insert(hitsCollectionName);
49 }
50 
51 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
52 
54 {
55 }
56 
57 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
58 
60 {
61  // Create hits collection
64 
65  // Add this collection in hce
66  auto 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++ ) {
74  }
75 }
76 
77 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
78 
81 {
82  // energy deposit
83  auto 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  auto touchable = (step->GetPreStepPoint()->GetTouchable());
94 
95  // Get calorimeter cell id
96  auto layerNumber = touchable->GetReplicaNumber(1);
97 
98  // Get hit accounting data for this cell
99  auto hit = (*fHitsCollection)[layerNumber];
100  if ( ! hit ) {
102  msg << "Cannot access hit " << layerNumber;
103  G4Exception("B4cCalorimeterSD::ProcessHits()",
104  "MyCode0004", FatalException, msg);
105  }
106 
107  // Get hit for total accounting
108  auto hitTotal
109  = (*fHitsCollection)[fHitsCollection->entries()-1];
110 
111  // Add values
112  hit->Add(edep, stepLength);
113  hitTotal->Add(edep, stepLength);
114 
115  return true;
116 }
117 
118 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
119 
121 {
122  if ( verboseLevel>1 ) {
123  auto nofHits = fHitsCollection->entries();
124  G4cout
125  << G4endl
126  << "-------->Hits Collection: in this event they are " << nofHits
127  << " hits in the tracker chambers: " << G4endl;
128  for ( G4int i=0; i<nofHits; i++ ) (*fHitsCollection)[i]->Print();
129  }
130 }
131 
132 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4int GetCollectionID(G4String colName)
Definition: G4SDManager.cc:135
const XML_Char * name
Definition: expat.h:151
const G4VTouchable * GetTouchable() const
std::ostringstream G4ExceptionDescription
Definition: G4Exception.hh:45
G4StepPoint * GetPreStepPoint() const
#define G4endl
Definition: G4ios.hh:61
void AddHitsCollection(G4int HCID, G4VHitsCollection *aHC)
G4double GetPDGCharge() const
G4ParticleDefinition * GetDefinition() const
double G4double
Definition: G4Types.hh:76
bool G4bool
Definition: G4Types.hh:79
virtual ~B4cCalorimeterSD()
B4cCalorHitsCollection * fHitsCollection
G4double GetStepLength() const
Definition of the B4cCalorimeterSD class.
G4Track * GetTrack() const
G4double GetTotalEnergyDeposit() const
Definition: G4Step.hh:76
Double_t edep
G4THitsCollection< B4cCalorHit > B4cCalorHitsCollection
Definition: B4cCalorHit.hh:78
B4cCalorimeterSD(const G4String &name, const G4String &hitsCollectionName, G4int nofCells)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.hh:65
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
int G4int
Definition: G4Types.hh:78
G4CollectionNameVector collectionName
virtual void EndOfEvent(G4HCofThisEvent *hitCollection)
G4GLOB_DLL std::ostream G4cout
virtual G4bool ProcessHits(G4Step *step, G4TouchableHistory *history)
virtual void Initialize(G4HCofThisEvent *hitCollection)