Go to the documentation of this file.00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016 #include "EventAction.h"
00017 #include "RunAction.h"
00018
00019 #include "GN_Data.h"
00020 #include "EV_Data.h"
00021 #include "GT_Data.h"
00022 #include "WC_Data.h"
00023 #include "TF_Data.h"
00024 #include "LM_Data.h"
00025 #include "MW_Data.h"
00026 #include "SM_Data.h"
00027
00028
00029
00030 #include "G4Event.hh"
00031 #include "G4PrimaryVertex.hh"
00032 #include "G4PrimaryParticle.hh"
00033 #include "G4ParticleDefinition.hh"
00034
00035
00036
00037 #include <iomanip>
00038
00039
00040
00041 #include "TTree.h"
00042
00043
00044
00045 GN_Data * EventAction::gndata = new GN_Data();
00046 EV_Data * EventAction::evdata = new EV_Data();
00047 GT_Data * EventAction::gtdata = new GT_Data();
00048 WC_Data * EventAction::wcdata = new WC_Data();
00049 TF_Data * EventAction::tfdata = new TF_Data();
00050 LM_Data * EventAction::lmdata = new LM_Data();
00051 MW_Data * EventAction::mwdata = new MW_Data();
00052 SM_Data * EventAction::smdata = new SM_Data();
00053
00054
00055
00056
00057
00058 EventAction::EventAction() {}
00059
00060
00061
00062 EventAction::~EventAction() {}
00063
00064
00065
00066 void EventAction::BeginOfEventAction( const G4Event * event ) {
00067
00068
00069
00070
00071
00072
00073
00074
00075
00076 G4int id = event->GetEventID();
00077
00078
00079
00080 if( id == 0 ) G4cout << "\nEvent processing status. One dot = 100 events."
00081 << endl;
00082 if( id % 5000 == 0 ) G4cout << "\nEvent " << setw(10) << id << " " << flush;
00083 else if( id % 1000 == 0 ) G4cout << "|" << flush;
00084 else if( id % 500 == 0 ) G4cout << "+" << flush;
00085 else if( id % 100 == 0 ) G4cout << "." << flush;
00086
00087 }
00088
00089
00090
00091 void EventAction::EndOfEventAction( const G4Event * event ) {
00092
00093
00094
00095
00096
00097
00098
00099
00100
00101 TTree * Tree = RunAction::Tree;
00102
00103
00104
00105 if( !Tree->GetBranchStatus("GN") ) Tree->Branch( "GN", "GN_Data", &gndata );
00106
00107 if( !Tree->GetBranchStatus("EV") ) Tree->Branch( "EV", "EV_Data", &evdata );
00108
00109 if( !Tree->GetBranchStatus("GT") ) Tree->Branch( "GT", "GT_Data", >data );
00110
00111 if( !Tree->GetBranchStatus("WC") ) Tree->Branch( "WC", "WC_Data", &wcdata );
00112
00113 if( !Tree->GetBranchStatus("TF") ) Tree->Branch( "TF", "TF_Data", &tfdata );
00114
00115 if( !Tree->GetBranchStatus("LM") ) Tree->Branch( "LM", "LM_Data", &lmdata );
00116
00117 if( !Tree->GetBranchStatus("MW") ) Tree->Branch( "MW", "MW_Data", &mwdata );
00118
00119 if( !Tree->GetBranchStatus("SM") ) Tree->Branch( "SM", "SM_Data", &smdata );
00120
00121
00122
00123 evdata->Reset();
00124
00125 evdata->nEV = event->GetEventID();
00126
00127
00128
00129 gndata->Reset();
00130
00131 G4int nPrim = event->GetNumberOfPrimaryVertex();
00132
00133 gndata->nGN = nPrim;
00134
00135 G4PrimaryVertex * vertex;
00136 G4PrimaryParticle * particle;
00137 G4ParticleDefinition * definition;
00138
00139 for( G4int i = 0; i < nPrim; ++i ) {
00140
00141 vertex = event->GetPrimaryVertex(i);
00142
00143 particle = vertex->GetPrimary();
00144
00145 definition = particle->GetG4code();
00146
00147 gndata->id.push_back( particle->GetPDGcode() );
00148 gndata->q.push_back( particle->GetCharge() );
00149 gndata->tr.push_back( particle->GetTrackID() );
00150
00151 gndata->x.push_back( vertex->GetX0()/cm );
00152 gndata->y.push_back( vertex->GetY0()/cm );
00153 gndata->z.push_back( vertex->GetZ0()/cm );
00154
00155 gndata->px.push_back( particle->GetPx()/GeV );
00156 gndata->py.push_back( particle->GetPy()/GeV );
00157 gndata->pz.push_back( particle->GetPz()/GeV );
00158
00159 }
00160
00161
00162
00163 RunAction::Tree->Fill();
00164
00165 }
00166
00167
00168
00169 void EventAction::Print( const G4Event * event ) {
00170
00171 G4int nPrim = event->GetNumberOfPrimaryVertex();
00172 G4PrimaryVertex * vertex;
00173 G4PrimaryParticle * particle;
00174 G4ParticleDefinition * definition;
00175
00176 G4cout << " Number of primary vertices " << nPrim << "\n" << G4endl;
00177
00178 for( G4int i = 0; i < nPrim; ++i ) {
00179
00180 vertex = event->GetPrimaryVertex(i);
00181
00182 particle = vertex->GetPrimary();
00183
00184 definition = particle->GetG4code();
00185
00186 G4cout << " Vertex " << i
00187 << " PDG ID " << particle->GetPDGcode()
00188 << " Charge " << particle->GetCharge()
00189 << " Name " << definition->GetParticleName()
00190 << G4endl;
00191
00192 G4cout << " Origin "
00193 << vertex->GetX0()/cm << " "
00194 << vertex->GetY0()/cm << " "
00195 << vertex->GetZ0()/cm << " [cm]" << G4endl;
00196
00197 G4cout << " Momentum "
00198 << particle->GetPx()/GeV << " "
00199 << particle->GetPy()/GeV << " "
00200 << particle->GetPz()/GeV << " [GeV/c]\n" << G4endl;
00201 }
00202 }