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

#include <CCalEndOfEventAction.hh>

Inheritance diagram for CCalEndOfEventAction:
G4UserEventAction

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 ()
 
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 59 of file CCalEndOfEventAction.cc.

References G4cout, G4endl, and testem0::pg.

59  :
60  isInitialized(false),SDnames(0),numberOfSD(0) {
61 
62  primaryGenerator = pg;
63 #ifdef debug
64  G4cout << "Instantiate CCalEndOfEventAction" << G4endl;
65 #endif
66 
67  G4cout << "Now Instantiate stepping action" << G4endl;
68  instanciateSteppingAction();
69 
70  G4cout << "Get Calorimter organisation" << G4endl;
71  theOrg = new CCaloOrganization;
72  G4cout << "end of instantiation of EndofEventAction" << G4endl;
73 }
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61
G4bool isInitialized()
CCalEndOfEventAction::~CCalEndOfEventAction ( )

Definition at line 76 of file CCalEndOfEventAction.cc.

References G4cout, and G4endl.

76  {
77 
78  if (theOrg)
79  delete theOrg;
80  if (SDnames)
81  delete[] SDnames;
82  G4cout << "CCalEndOfEventAction deleted" << G4endl;
83 }
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 114 of file CCalEndOfEventAction.cc.

References G4THitsCollection< T >::entries(), G4cout, G4endl, G4SDManager::GetCollectionID(), CCalHit::getEnergyDeposit(), G4HCofThisEvent::GetHC(), G4Event::GetHCofThisEvent(), CCalPrimaryGeneratorAction::GetParticleEnergy(), CCalPrimaryGeneratorAction::GetParticlePosition(), G4SDManager::GetSDMpointer(), CCalHit::getTimeSlice(), CCalHit::getUnitID(), python.hepunit::GeV, python.hepunit::MeV, python.hepunit::mm, test::x, CLHEP::Hep3Vector::x(), CLHEP::Hep3Vector::y(), z, and CLHEP::Hep3Vector::z().

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

Definition at line 109 of file CCalEndOfEventAction.cc.

References G4cout, G4endl, and G4Event::GetEventID().

109  {
110  G4cout << "\n---> Begin of event: " << evt->GetEventID() << G4endl;
111 }
G4int GetEventID() const
Definition: G4Event.hh:140
G4GLOB_DLL std::ostream G4cout
#define G4endl
Definition: G4ios.hh:61

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