source: trunk/examples/advanced/Rich/src/RichTbEventAction.cc@ 1344

Last change on this file since 1344 was 1337, checked in by garnier, 15 years ago

tag geant4.9.4 beta 1 + modifs locales

File size: 4.3 KB
Line 
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// Rich advanced example for Geant4
27// RichTbEventAction.cc for Rich of LHCb
28// History:
29// Created: Sajan Easo (Sajan.Easo@cern.ch)
30// Revision and changes: Patricia Mendez (Patricia.Mendez@cern.ch)
31/////////////////////////////////////////////////////////////////////////////
32#include "RichTbEventAction.hh"
33#include "G4Event.hh"
34#include "G4EventManager.hh"
35#include "G4TrajectoryContainer.hh"
36#include "G4Trajectory.hh"
37#include "G4HCofThisEvent.hh"
38#include "G4VHitsCollection.hh"
39#include "G4SDManager.hh"
40#include "G4VVisManager.hh"
41#include "G4UImanager.hh"
42#include "G4ios.hh"
43#include "RichTbSD.hh"
44#include "RichTbHit.hh"
45#include "RichTbRunConfig.hh"
46#include "RichTbAnalysisManager.hh"
47#include "RichTbIOData.hh"
48
49RichTbEventAction::RichTbEventAction()
50{
51 RichTbCollID = -1;
52}
53
54RichTbEventAction::RichTbEventAction(RichTbRunConfig* RConfig,
55 G4VVisManager* RVisManager, RichTbIOData* RIOData)
56{
57 RichTbCollID = -1;
58 runConfiguration=RConfig;
59
60 pVisManager=RVisManager;
61 rTbIOData = RIOData;
62}
63
64RichTbEventAction::~RichTbEventAction()
65{
66}
67
68void RichTbEventAction::BeginOfEventAction(const G4Event* evt)
69{
70
71 G4SDManager * SDman = G4SDManager::GetSDMpointer();
72 if(RichTbCollID<0){
73 RichTbCollID = SDman->GetCollectionID("RichTbHitsCollection");
74 }
75
76#ifdef G4ANALYSIS_USE
77 RichTbAnalysisManager * analysis = RichTbAnalysisManager::getInstance();
78 analysis->BeginOfEventAnalysis(evt);
79#endif
80}
81
82void RichTbEventAction::EndOfEventAction(const G4Event* evt)
83{
84 RichTbRunConfig* RConfig = runConfiguration;
85
86 // first get the trajectories
87 G4TrajectoryContainer* trajectoryContainer=evt->GetTrajectoryContainer();
88 G4int n_trajectories=0;
89
90 G4int totalhits = 0;
91
92 if(trajectoryContainer){n_trajectories=trajectoryContainer->entries();
93 G4cout << " " << n_trajectories
94 << " Tracks are stored in Trajectorycontainer." << G4endl;
95 }
96 // Now get the hits
97
98 if(RichTbCollID<0) return;
99
100
101 G4HCofThisEvent * HCE = evt->GetHCofThisEvent();
102 RichTbHitsCollection* RHC = 0;
103 G4int n_hit = 0;
104
105 if(HCE)
106 {
107
108 RHC = (RichTbHitsCollection*)(HCE->GetHC(RichTbCollID));
109
110 }
111
112 if(RHC)
113 {
114 n_hit = RHC->entries();
115 for(G4int i=0;i<n_hit;i++)
116 {
117 totalhits += i;
118 }
119 // G4cout << " " << n_hit
120 // << " hits are stored in RichTbHitsCollection." << G4endl;
121 }
122
123 //Now to Fill the Histograms
124
125#ifdef G4ANALYSIS_USE
126 RichTbAnalysisManager * analysis = RichTbAnalysisManager::getInstance();
127 analysis->EndOfEventAnalysis(evt);
128#endif
129
130 // Now to write out the data
131 if(RConfig -> DoWriteOutputFile() )
132 {
133 rTbIOData -> WriteOutEventHeaderData(evt);
134 rTbIOData -> WriteOutHitData(evt);
135 G4cout << ">>> End of Event Number " << evt->GetEventID() << G4endl;
136 }
137}
Note: See TracBrowser for help on using the repository browser.