Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
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)
 

Additional Inherited Members

- Protected Attributes inherited from G4UserEventAction
G4EventManagerfpEventManager
 

Detailed Description

Definition at line 44 of file CCalEndOfEventAction.hh.

Constructor & Destructor Documentation

CCalEndOfEventAction::CCalEndOfEventAction ( CCalPrimaryGeneratorAction pg)

Definition at line 57 of file CCalEndOfEventAction.cc.

57  :
58  isInitialized(false),SDnames(0),numberOfSD(0) {
59 
60  primaryGenerator = pg;
61 #ifdef debug
62  G4cout << "Instantiate CCalEndOfEventAction" << G4endl;
63 #endif
64 
65  G4cout << "Now Instantiate stepping action" << G4endl;
66  instanciateSteppingAction();
67 
68  G4cout << "Get Calorimter organisation" << G4endl;
69  theOrg = new CCaloOrganization;
70  G4cout << "end of instantiation of EndofEventAction" << G4endl;
71 }
G4GLOB_DLL std::ostream G4cout
tuple pg
Definition: demo.py:37
#define G4endl
Definition: G4ios.hh:61
G4bool isInitialized()
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
#define G4endl
Definition: G4ios.hh:61

Member Function Documentation

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 
120  theSteppingAction->endOfEvent();
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 
213  G4ThreeVector pos = primaryGenerator->GetParticlePosition();
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 constexpr double mm
Definition: G4SIunits.hh:115
G4VHitsCollection * GetHC(G4int i)
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 x() const
void InsertEnergyHcal(float *)
G4int entries() const
double getEnergyDeposit() const
Definition: CCalHit.cc:86
tuple x
Definition: test.py:50
int G4int
Definition: G4Types.hh:78
void InsertEnergyEcal(float *)
double z() const
G4GLOB_DLL std::ostream G4cout
double getTimeSlice() const
Definition: CCalHit.cc:77
void InsertEnergy(float v)
void initialize(Config const *const theConfig)
Initialize the clustering model based on the Config object.
void EndOfEvent(G4int flag)
Alternative here is a XML file.
Definition: CCalAnalysis.hh:44
static CCalAnalysis * getInstance()
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
double y() const
static constexpr double GeV
Definition: G4SIunits.hh:217
tuple z
Definition: test.py:28
unsigned int getUnitID() const
Definition: CCalHit.cc:74
#define G4endl
Definition: G4ios.hh:61
static constexpr double MeV
Definition: G4SIunits.hh:214
G4HCofThisEvent * GetHCofThisEvent() const
Definition: G4Event.hh:185
void InsertTimeProfile(int, double, double)
G4bool isInitialized()
static const G4double pos

Here is the call graph for this function:

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 }
G4int GetEventID() const
Definition: G4Event.hh:151
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:


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