aboutsummaryrefslogtreecommitdiffstats
path: root/src/G4BeamTestEventAction.cxx
blob: 53402c998e5060fc3683e9dfe5624420ebe3dfc5 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include "G4Event.hh"

#include "G4HCofThisEvent.hh"
#include "G4VHitsCollection.hh"
#include "G4SDManager.hh"
#include "G4ios.hh"
#include "G4VDigitizerModule.hh"
#include "G4DigiManager.hh"
#include "G4Event.hh"
#include "G4RunManager.hh"

#include "G4BeamTestSiSD.h"
#include "G4BeamTestSiHit.h"
#include "G4BeamTestEventAction.h"

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
G4BeamTestEventAction::G4BeamTestEventAction()
  : G4UserEventAction(),
 
    SiCollID(0)
{
} 

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

G4BeamTestEventAction::~G4BeamTestEventAction()
{}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

void G4BeamTestEventAction::BeginOfEventAction(const G4Event* event )
{    
 
  
  G4SDManager * SDman = G4SDManager::GetSDMpointer();
  SDman->ListTree();
  if(SiCollID<0)
    {
      G4String colNam;
      SiCollID = SDman->GetCollectionID(colNam="G4BeamTestSiSDCollection");
     
    }


}

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

void G4BeamTestEventAction::EndOfEventAction(const G4Event* event)
{   

  G4cout << ">>> Summary of Event " << event->GetEventID() << G4endl;
  // testnew << ">>> Summary of Event " << event->GetEventID() << G4endl;

  G4cout << SiCollID << G4endl;

  if(SiCollID<0) return;

  G4HCofThisEvent* HCE = event->GetHCofThisEvent();
  G4BeamTestSiHitsCollection* SiHC = 0;

  if(HCE)
    {
      SiHC = (G4BeamTestSiHitsCollection*)(HCE->GetHC(SiCollID));

    }



  if(SiHC)
    {
      int n_hit = SiHC->entries();
      // testnew << std::flush;
      G4cout << G4endl;
      // G4cout << "Si hits " <<
      // "--------------------------------------------------------------"
      //    << G4endl;
      G4cout << n_hit << " hits are stored in G4BeamTestSiHitsCollection."
	     << G4endl;
      /* G4cout << "List of hits in tracker" << G4endl; */
      // testnew << G4endl;
      // testnew << "Si hits " <<
      // "--------------------------------------------------------------"
      testnew << n_hit << " hits are stored in G4BeamTestSiHitsCollection."
	     << G4endl;
      /* testnew << "List of hits in tracker" << G4endl; */
      for(int i=0;i<n_hit;i++)
      {
          /* (*SiHC)[i]->Print(); */
          (*SiHC)[i]->Dataout();
      }

      //      G4cout << "sid + " << SiCollID << G4endl;
      //      testnew << "sid + " << SiCollID << G4endl;
      testnew << std::flush;

    } 

}


//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......