source: trunk/examples/novice/N05/src/ExN05EventAction.cc @ 1143

Last change on this file since 1143 was 807, checked in by garnier, 16 years ago

update

File size: 4.2 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//
27// $Id: ExN05EventAction.cc,v 1.9 2006/06/29 17:53:16 gunter Exp $
28// GEANT4 tag $Name:  $
29//
30
31#include "ExN05EventAction.hh"
32#include "ExN05EventActionMessenger.hh"
33#include "ExN05CalorimeterHit.hh"
34
35#include "G4Event.hh"
36#include "G4EventManager.hh"
37#include "G4HCofThisEvent.hh"
38#include "G4VHitsCollection.hh"
39#include "G4TrajectoryContainer.hh"
40#include "G4Trajectory.hh"
41#include "G4VVisManager.hh"
42#include "G4SDManager.hh"
43#include "G4UImanager.hh"
44#include "G4ios.hh"
45
46ExN05EventAction::ExN05EventAction()
47  :drawFlag(false)
48{
49  new ExN05EventActionMessenger(this);
50}
51
52ExN05EventAction::~ExN05EventAction()
53{;}
54
55void ExN05EventAction::BeginOfEventAction(const G4Event*)
56{
57  if(drawFlag)
58    {
59      G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
60      if(pVVisManager)
61        {
62          G4UImanager::GetUIpointer()->ApplyCommand("/vis~/draw/current");
63        }
64    }
65}
66
67void ExN05EventAction::EndOfEventAction(const G4Event* evt )
68{
69  G4SDManager * SDman = G4SDManager::GetSDMpointer();
70  G4String colNam;
71  calorimeterCollID    = SDman->GetCollectionID(colNam="CalCollection");
72  hadCalorimeterCollID = SDman->GetCollectionID(colNam="HadCollection");
73 
74   G4cout << ">>> Event " << evt->GetEventID() << G4endl;
75 
76  G4HCofThisEvent * HCE = evt->GetHCofThisEvent();
77  ExN05CalorimeterHitsCollection* CaloHC    = 0;
78  ExN05CalorimeterHitsCollection* HadCaloHC = 0;
79  if(HCE)
80    {
81      CaloHC    = (ExN05CalorimeterHitsCollection*)(HCE->GetHC(calorimeterCollID));
82      HadCaloHC = (ExN05CalorimeterHitsCollection*)(HCE->GetHC(hadCalorimeterCollID));
83    }
84 
85  if(CaloHC)
86    {
87      int n_hit = CaloHC->entries();
88      G4cout << "     " << n_hit
89           << " hits are stored in EM ExN05CalorimeterHitsCollection." << G4endl;
90      G4double totE = 0;
91      for(int i=0;i<n_hit;i++)
92        { totE += (*CaloHC)[i]->GetEdep(); }
93      G4cout << "     Total energy deposition in EM calorimeter crytals : "
94           << totE / GeV << " (GeV)" << G4endl;
95    }
96
97  if(HadCaloHC)
98    {
99      int n_hit = HadCaloHC->entries();
100      G4cout << "     " << n_hit
101           << " hits are stored in HAD ExN05CalorimeterHitsCollection." << G4endl;
102      G4double totE = 0;
103      for(int i=0;i<n_hit;i++)
104        { totE += (*HadCaloHC)[i]->GetEdep(); }
105      G4cout << "     Total energy deposition in HAD calorimeter towers : "
106           << totE / GeV << " (GeV)" << G4endl;
107    }
108 
109  if(drawFlag)
110    {
111      G4VVisManager* pVVisManager = G4VVisManager::GetConcreteInstance();
112      if(pVVisManager)
113        {
114          if(CaloHC)    CaloHC->DrawAllHits();
115          if(HadCaloHC) HadCaloHC->DrawAllHits();
116          G4UImanager::GetUIpointer()->ApplyCommand("/vis~/show/view");
117        }
118    }
119}
120
121
122
Note: See TracBrowser for help on using the repository browser.