Geant4  10.02.p03
CCalEndOfEventAction Class Reference

#include <CCalEndOfEventAction.hh>

Inheritance diagram for CCalEndOfEventAction:
Collaboration diagram for CCalEndOfEventAction:

Public Member Functions

 CCalEndOfEventAction (CCalPrimaryGeneratorAction *)
 
 ~CCalEndOfEventAction ()
 
virtual void StartOfEventAction (const G4Event *evt)
 
virtual void EndOfEventAction (const G4Event *evt)
 
- Public Member Functions inherited from G4UserEventAction
 G4UserEventAction ()
 
virtual ~G4UserEventAction ()
 
virtual void SetEventManager (G4EventManager *value)
 
virtual void BeginOfEventAction (const G4Event *anEvent)
 

Private Member Functions

void instanciateSteppingAction ()
 
void initialize ()
 

Private Attributes

G4bool isInitialized
 
CCalPrimaryGeneratorActionprimaryGenerator
 
CCalSteppingActiontheSteppingAction
 
nameTypeSDnames
 
G4int numberOfSD
 
CCaloOrganizationtheOrg
 

Additional Inherited Members

- Protected Attributes inherited from G4UserEventAction
G4EventManagerfpEventManager
 

Detailed Description

Definition at line 44 of file CCalEndOfEventAction.hh.

Constructor & Destructor Documentation

◆ CCalEndOfEventAction()

CCalEndOfEventAction::CCalEndOfEventAction ( CCalPrimaryGeneratorAction pg)

Definition at line 57 of file CCalEndOfEventAction.cc.

57  :
58  isInitialized(false),SDnames(0),numberOfSD(0) {
59 
61 #ifdef debug
62  G4cout << "Instantiate CCalEndOfEventAction" << G4endl;
63 #endif
64 
65  G4cout << "Now Instantiate stepping action" << G4endl;
67 
68  G4cout << "Get Calorimter organisation" << G4endl;
70  G4cout << "end of instantiation of EndofEventAction" << G4endl;
71 }
CCalPrimaryGeneratorAction * primaryGenerator
G4GLOB_DLL std::ostream G4cout
CCaloOrganization * theOrg
#define G4endl
Definition: G4ios.hh:61
Here is the call graph for this function:

◆ ~CCalEndOfEventAction()

CCalEndOfEventAction::~CCalEndOfEventAction ( )

Definition at line 74 of file CCalEndOfEventAction.cc.

74  {
75 
76  if (theOrg)
77  delete theOrg;
78  if (SDnames)
79  delete[] SDnames;
80  G4cout << "CCalEndOfEventAction deleted" << G4endl;
81 }
G4GLOB_DLL std::ostream G4cout
CCaloOrganization * theOrg
#define G4endl
Definition: G4ios.hh:61

Member Function Documentation

◆ EndOfEventAction()

void CCalEndOfEventAction::EndOfEventAction ( const G4Event evt)
virtual

Reimplemented from G4UserEventAction.

Definition at line 112 of file CCalEndOfEventAction.cc.

112  {
113 
114 #ifdef debug
115  G4cout << G4endl << "=== Begin of EndOfEventAction === " << G4endl;
116 #endif
117 
118  if (!isInitialized) initialize();
119 
121 
122  //
123  // Look for the Hit Collection
124  //
125  G4HCofThisEvent* allHC = evt->GetHCofThisEvent();
126  if (allHC == 0) {
127 #ifdef debug
128  G4cout << "CCalEndOfEventAction: No Hit Collection in this event"
129  << G4endl;
130 #endif
131  return;
132  }
133 
134  //
135  // hits info
136  //
137 
138  //Now make summary
139  float hcalE[28], ecalE[49], fullE=0., edec=0, edhc=0;
140  int i = 0;
141  for (i = 0; i < 28; i++) {hcalE[i]=0.;}
142  for (i = 0; i < 49; i++) {ecalE[i]=0.;}
143 
144  float* edep = new float[numberOfSD];
145  int nhit=0;
146  for (i = 0; i < numberOfSD; i++){
147 
148  //
149  // Look for the Hit Collection
150  //
151  edep[i] = 0;
152  int caloHCid = G4SDManager::GetSDMpointer()->GetCollectionID(SDnames[i]);
153 
154  if (caloHCid >= 0) {
155  CCalG4HitCollection* theHC =
156  (CCalG4HitCollection*) allHC->GetHC(caloHCid);
157 
158  if (theHC != 0) {
159 
160  G4int nentries = theHC->entries();
161 #ifdef debug
162  G4cout << " There are " << nentries << " hits in " << SDnames[i]
163  << " :" << G4endl;
164 #endif
165 
166  if (nentries > 0) {
167 
168  int j;
169  for (j=0; j<nentries; j++){
170 #ifdef ddebug
171  G4cout << "Hit " << j;
172 #endif
173  CCalG4Hit* aHit = (*theHC)[j];
174  float En = aHit->getEnergyDeposit();
175  int unitID = aHit->getUnitID();
176  int id=-1;
177  if (unitID > 0 && unitID < 29) {
178  id = unitID - 1; // HCal
179  hcalE[id] += En/GeV;
180  } else {
181  int i0 = unitID/4096;
182  int i1 = (unitID/64)%64;
183  int i2 = unitID%64;
184  if (i0 == 1 && i1 < 8 && i2 < 8) {
185  id = i1*7 + i2; // ECal
186  ecalE[id] += En/GeV;
187  }
188  }
189 #ifdef ddebug
190  G4cout << " with Energy = " << En/MeV << " MeV in Unit " << unitID
191  << " " << id << G4endl;
192 #endif
193  fullE += En/GeV;
194  edep[i] += En/GeV;
195  nhit++;
196  }
197 #ifdef ddebug
198  G4cout << " ===> Total Energy Deposit in this Calorimeter = "
199  << edep[i]*1000.0 << " MeV " << G4endl;
200 #endif
201  }
202  }
203  }
204  if (SDnames[i] == "HadronCalorimeter") {
205  edhc = edep[i];
206  } else if (SDnames[i] == "CrystalMatrix") {
207  edec = edep[i];
208  }
209  }
210 
211  delete[] edep;
212 
214  float ener = primaryGenerator->GetParticleEnergy()/GeV;
215  float x = pos.x()/mm;
216  float y = pos.y()/mm;
217  float z = pos.z()/mm;
218 
220  analysis->InsertEnergy(fullE);
221  analysis->InsertEnergyHcal(hcalE);
222  analysis->InsertEnergyEcal(ecalE);
223  analysis->setNtuple(hcalE, ecalE, ener, x, y, z, fullE, edec, edhc);
224  analysis->EndOfEvent(nhit);
225  for (i = 0; i < numberOfSD; i++){
226  int caloHCid = G4SDManager::GetSDMpointer()->GetCollectionID(SDnames[i]);
227  if (caloHCid >= 0) {
228  CCalG4HitCollection* theHC =
229  (CCalG4HitCollection*) allHC->GetHC(caloHCid);
230  if (theHC != 0) {
231  G4int nentries = theHC->entries();
232  if (nentries > 0) {
233  for (G4int k=0; k<nentries; k++) {
234  CCalG4Hit* aHit = (*theHC)[k];
235  analysis->InsertTimeProfile(k,aHit->getTimeSlice(),
236  aHit->getEnergyDeposit()/GeV);
237  }
238  }
239  }
240  }
241  }
242 }
static const double MeV
Definition: G4SIunits.hh:211
G4int GetCollectionID(G4String colName)
Definition: G4SDManager.cc:135
void setNtuple(float *hcalE, float *ecalE, float elab, float x, float y, float z, float edep, float edec, float edhc)
double getTimeSlice() const
Definition: CCalHit.cc:77
Int_t nentries
Definition: comparison.C:29
void InsertEnergyHcal(float *)
CCalPrimaryGeneratorAction * primaryGenerator
int G4int
Definition: G4Types.hh:78
Double_t edep
void InsertEnergyEcal(float *)
Double_t y
G4GLOB_DLL std::ostream G4cout
double getEnergyDeposit() const
Definition: CCalHit.cc:86
static const double GeV
Definition: G4SIunits.hh:214
unsigned int getUnitID() const
Definition: CCalHit.cc:74
void InsertEnergy(float v)
double x() const
void EndOfEvent(G4int flag)
Alternative here is a XML file.
Definition: CCalAnalysis.hh:44
double y() const
static CCalAnalysis * getInstance()
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
G4HCofThisEvent * GetHCofThisEvent() const
Definition: G4Event.hh:185
double z() const
#define G4endl
Definition: G4ios.hh:61
CCalSteppingAction * theSteppingAction
void InsertTimeProfile(int, double, double)
static const double mm
Definition: G4SIunits.hh:114
static const G4double pos
Here is the call graph for this function:

◆ initialize()

void CCalEndOfEventAction::initialize ( )
private

Definition at line 84 of file CCalEndOfEventAction.cc.

84  {
85 
86  isInitialized = true;
88 #ifdef debug
89  G4cout << "CCalEndOfEventAction look for " << numberOfSD
90  << " calorimeter-like SD" << G4endl;
91 #endif
92  if (numberOfSD > 0) {
93  G4int n = numberOfSD;
94  if (n < 2) n = 2;
95  SDnames = new nameType[n];
96  }
97  for (int i=0; i<numberOfSD; i++) {
98  SDnames[i] = G4String(CCalSDList::getInstance()->getCaloSDName(i));
99 #ifdef debug
100  G4cout << "CCalEndOfEventAction: found SD " << i << " name "
101  << SDnames[i] << G4endl;
102 #endif
103  }
104 }
static CCalSDList * getInstance()
Definition: CCalSDList.cc:37
int G4int
Definition: G4Types.hh:78
Char_t n[5]
G4GLOB_DLL std::ostream G4cout
int getNumberOfCaloSD()
Definition: CCalSDList.cc:76
#define G4endl
Definition: G4ios.hh:61
Here is the call graph for this function:
Here is the caller graph for this function:

◆ instanciateSteppingAction()

void CCalEndOfEventAction::instanciateSteppingAction ( )
private

Definition at line 245 of file CCalEndOfEventAction.cc.

245  {
246 
248 
249  if (theUA == 0) {
250 #ifdef debug
251  G4cout << " CCalEndOfEventAction::instanciateSteppingAction creates"
252  << " CCalSteppingAction" << G4endl;
253 #endif
256  }
257 
258 }
G4GLOB_DLL std::ostream G4cout
static G4RunManager * GetRunManager()
Definition: G4RunManager.cc:79
#define G4endl
Definition: G4ios.hh:61
CCalSteppingAction * theSteppingAction
const G4UserSteppingAction * GetUserSteppingAction() const
virtual void SetUserAction(G4UserRunAction *userAction)
Here is the call graph for this function:
Here is the caller graph for this function:

◆ StartOfEventAction()

void CCalEndOfEventAction::StartOfEventAction ( const G4Event evt)
virtual

Definition at line 107 of file CCalEndOfEventAction.cc.

107  {
108  G4cout << "\n---> Begin of event: " << evt->GetEventID() << G4endl;
109 }
G4GLOB_DLL std::ostream G4cout
G4int GetEventID() const
Definition: G4Event.hh:151
#define G4endl
Definition: G4ios.hh:61
Here is the call graph for this function:

Member Data Documentation

◆ isInitialized

G4bool CCalEndOfEventAction::isInitialized
private

Definition at line 57 of file CCalEndOfEventAction.hh.

◆ numberOfSD

G4int CCalEndOfEventAction::numberOfSD
private

Definition at line 62 of file CCalEndOfEventAction.hh.

◆ primaryGenerator

CCalPrimaryGeneratorAction* CCalEndOfEventAction::primaryGenerator
private

Definition at line 59 of file CCalEndOfEventAction.hh.

◆ SDnames

nameType* CCalEndOfEventAction::SDnames
private

Definition at line 61 of file CCalEndOfEventAction.hh.

◆ theOrg

CCaloOrganization* CCalEndOfEventAction::theOrg
private

Definition at line 63 of file CCalEndOfEventAction.hh.

◆ theSteppingAction

CCalSteppingAction* CCalEndOfEventAction::theSteppingAction
private

Definition at line 60 of file CCalEndOfEventAction.hh.


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