BOSS 8.0.0
BESIII Offline Software System
Loading...
Searching...
No Matches
BesEventAction Class Reference

#include <BesEventAction.hh>

Inheritance diagram for BesEventAction:

Public Member Functions

 BesEventAction (BesRunAction *)
virtual ~BesEventAction ()
virtual void BeginOfEventAction (const G4Event *)
virtual void EndOfEventAction (const G4Event *)

Detailed Description

Definition at line 13 of file BesEventAction.hh.

Constructor & Destructor Documentation

◆ BesEventAction()

BesEventAction::BesEventAction ( BesRunAction * runAction)

Definition at line 35 of file BesEventAction.cc.

35 : m_runAction( runAction ) {
36 StatusCode sc = Gaudi::svcLocator()->service( "RealizationSvc", m_RealizationSvc );
37 if ( !sc.isSuccess() )
38 {
39 std::cout << " Could not initialize Realization Service in BesEventAction" << std::endl;
40 exit( 1 );
41 }
42
43 m_DM = G4DigiManager::GetDMpointer();
44
46 {
47 BesMdcDigitizer* mdcDM = new BesMdcDigitizer( "BesMdcDigitizer" );
48 m_DM->AddNewModule( mdcDM );
49 }
51 {
52 BesTofDigitizer* tofDM = new BesTofDigitizer( "BesTofDigitizer" );
53 m_DM->AddNewModule( tofDM );
54 }
56 {
57 BesEmcDigitizer* emcDM = new BesEmcDigitizer( "BesEmcDigitizer" );
58 m_DM->AddNewModule( emcDM );
59 }
61 {
62 BesMucDigitizer* mucDM = new BesMucDigitizer( "BesMucDigitizer" );
63 m_DM->AddNewModule( mucDM );
64 }
65}

◆ ~BesEventAction()

BesEventAction::~BesEventAction ( )
virtual

Definition at line 67 of file BesEventAction.cc.

67{ delete m_DM; }

Member Function Documentation

◆ BeginOfEventAction()

void BesEventAction::BeginOfEventAction ( const G4Event * evt)
virtual

Definition at line 69 of file BesEventAction.cc.

69 {
70
71 G4int eventId = evt->GetEventID();
72 // if (eventId%5000==0)
73 // G4cout<<"---> Begin of event: "<<eventId<<G4endl;
74
75 G4UImanager* uiMgr = G4UImanager::GetUIpointer();
76 // if(eventId == 46 || eventId == 75)
77 // uiMgr->ApplyCommand("/tracking/verbose 1");
78 // else
79 // uiMgr->ApplyCommand("/tracking/verbose 0");
80
81 // mc truth
82 if ( m_runAction )
83 if ( m_runAction->GetMCTruthFlag() != 0 )
84 {
85 BesSensitiveManager* sensitiveManager = BesSensitiveManager::GetSensitiveManager();
86 sensitiveManager->BeginOfTruthEvent( evt );
87 }
88}
void BeginOfTruthEvent(const G4Event *)

◆ EndOfEventAction()

void BesEventAction::EndOfEventAction ( const G4Event * evt)
virtual

Definition at line 90 of file BesEventAction.cc.

90 {
91 if ( G4VVisManager::GetConcreteInstance() )
92 {
93 G4TrajectoryContainer* trajectoryContainer = evt->GetTrajectoryContainer();
94 G4int n_trajectories = 0;
95 if ( trajectoryContainer ) n_trajectories = trajectoryContainer->entries();
96
97 for ( G4int i = 0; i < n_trajectories; i++ )
98 {
99 G4Trajectory* trj = (G4Trajectory*)( ( *( evt->GetTrajectoryContainer() ) )[i] );
100
101 // trj->DrawTrajectory(50);
102 }
103 }
104
105 // mc truth
106 BesSensitiveManager* sensitiveManager = BesSensitiveManager::GetSensitiveManager();
107 if ( m_runAction )
108 if ( m_runAction->GetMCTruthFlag() != 0 ) { sensitiveManager->EndOfTruthEvent( evt ); }
109
111 {
112 if ( m_runAction )
113 {
114 // Ascii I/O, output hit collections
115 BesAsciiIO* asciiIO = m_runAction->GetAsciiIO();
116 if ( asciiIO )
117 {
118 if ( m_RealizationSvc->UseDBFlag() == true )
119 asciiIO->SaveHitAsciiEvents( m_RealizationSvc->getRunId(), evt );
120 else asciiIO->SaveHitAsciiEvents( m_runAction->GetRunId(), evt );
121 }
122
123 // Root I/O, output MdcHit collections
124 BesRootIO* rootIO = m_runAction->GetRootIO();
125 if ( rootIO )
126 {
127 // emc digitization
128 if ( ReadBoostRoot::GetEmc() ) m_DM->Digitize( "BesEmcDigitizer" );
129
130 if ( m_RealizationSvc->UseDBFlag() == true )
131 rootIO->SaveHitRootEvent( m_RealizationSvc->getRunId(), evt );
132 else rootIO->SaveHitRootEvent( m_runAction->GetRunId(), evt );
133 }
134 }
135 }
136 else
137 {
138 // Tuning I/O
140 {
141 if ( m_runAction )
142 {
143 BesTuningIO* tuningIO = m_runAction->GetTuningIO();
144 if ( tuningIO )
145 {
146 if ( ReadBoostRoot::GetFormatAR() ) { tuningIO->GetRootEvent( evt->GetEventID() ); }
147 else { tuningIO->GetNextEvents(); }
148 }
149 }
150 }
151 // mdc digitization
152
153 if ( ReadBoostRoot::GetMdc() ) m_DM->Digitize( "BesMdcDigitizer" );
154
155 // tof digitization
156 if ( ReadBoostRoot::GetTof() ) m_DM->Digitize( "BesTofDigitizer" );
157
158 // emc digitization
160 m_DM->Digitize( "BesEmcDigitizer" );
161
162 // muc digitization
163 if ( ReadBoostRoot::GetMuc() ) m_DM->Digitize( "BesMucDigitizer" );
164
165 if ( m_runAction )
166 {
167 // Ascii I/O, output digi collections
168 BesAsciiIO* asciiIO = m_runAction->GetAsciiIO();
169 if ( asciiIO )
170 {
171 if ( m_RealizationSvc->UseDBFlag() == true )
172 asciiIO->SaveAsciiEvents( m_RealizationSvc->getRunId(), evt );
173 else asciiIO->SaveAsciiEvents( m_runAction->GetRunId(), evt );
174 }
175
176 // Root I/O,output digi collections
177 BesTDSWriter* tdsWriter = m_runAction->GetTDSWriter();
178 if ( tdsWriter )
179 {
180 if ( m_RealizationSvc->UseDBFlag() == true )
181 tdsWriter->SaveAll( evt, m_RealizationSvc->getRunId() );
182 else tdsWriter->SaveAll( evt, m_runAction->GetRunId() );
183 }
184 }
185 }
186
187 sensitiveManager->ClearEvent();
188 // HepRandom::saveEngineStatus("EndSimCurrEvt.rndm");
189}
void SaveHitAsciiEvents(G4int, const G4Event *)
void SaveAsciiEvents(G4int, const G4Event *)
Definition BesAsciiIO.cc:59
void SaveHitRootEvent(G4int, const G4Event *)
Definition BesRootIO.cc:64
void EndOfTruthEvent(const G4Event *)
void SaveAll(const G4Event *, int)
void GetRootEvent(int evtID)
void GetNextEvents(void)

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