Loading...
Searching...
No Matches
RE01StackingAction.cc
Go to the documentation of this file.
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/// \file runAndEvent/RE01/src/RE01StackingAction.cc
27/// \brief Implementation of the RE01StackingAction class
28//
29//
30
31#include "RE01StackingAction.hh"
33#include "RE01CalorimeterHit.hh"
34
35#include "G4SDManager.hh"
36#include "G4RunManager.hh"
37#include "G4Event.hh"
38#include "G4HCofThisEvent.hh"
39#include "G4Track.hh"
40#include "G4TrackStatus.hh"
41#include "G4ParticleDefinition.hh"
42#include "G4ParticleTypes.hh"
43#include "G4SystemOfUnits.hh"
44#include "G4ios.hh"
45
46//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
49 fStage(0),fCalorimeterHitsColID(-1)
50{;}
51
52//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
55
56//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
57G4ClassificationOfNewTrack RE01StackingAction
58::ClassifyNewTrack(const G4Track * aTrack)
59{
60 G4ClassificationOfNewTrack classification = fUrgent;
61
62 if(fStage==0)
63 {
64 RE01TrackInformation* trackInfo;
65 if(aTrack->GetTrackStatus()==fSuspend) // Track reached to calorimeter
66 {
67 trackInfo = (RE01TrackInformation*)(aTrack->GetUserInformation());
68 trackInfo->SetTrackingStatus(0);
69 trackInfo->SetSourceTrackInformation(aTrack);
70// G4cout << "Track " << aTrack->GetTrackID()
71// << " (parentID " << aTrack->GetParentID()
72// << ") has reached to calorimeter and has been suspended at "
73// << aTrack->GetPosition() << G4endl;
74 classification = fWaiting;
75 }
76 else if(aTrack->GetParentID()==0) // Primary particle
77 {
78 trackInfo = new RE01TrackInformation(aTrack);
79 trackInfo->SetTrackingStatus(1);
80 G4Track* theTrack = (G4Track*)aTrack;
81 theTrack->SetUserInformation(trackInfo);
82 }
83 }
84 return classification;
85}
86
87//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
89{
90 G4SDManager* SDMan = G4SDManager::GetSDMpointer();
91 G4RunManager* runMan = G4RunManager::GetRunManager();
93 { fCalorimeterHitsColID = SDMan->GetCollectionID("calCollection"); }
95 {
96 const G4Event* currentEvent = runMan->GetCurrentEvent();
97 G4HCofThisEvent* HCE = currentEvent->GetHCofThisEvent();
98 return HCE->GetHC(fCalorimeterHitsColID);
99 }
100 return 0;
101}
102
103//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
105{
106 // G4cout << "+++++++++++ Stage " << fStage << G4endl;
107 if(fStage==0)
108 {
109 // display trajetory information in the tracking region
110 G4cout << G4endl;
111 G4cout << "Tracks in tracking region have been processed. -- Stage 0 over."
112 << G4endl;
113 G4cout << G4endl;
114 }
115 else
116 {
117 // display calorimeter information caused by a "source" track
118 // in the tracker region
119 // G4cout << G4endl;
120 // G4cout << "Processing one shower originated by a source track "
121 // << "in tracker region is over." << G4endl;
122 // G4cout << G4endl;
125 if(CHC)
126 {
127 int n_hit = CHC->entries();
128 G4double totE = 0;
129 G4int n_hitByATrack = 0;
130 for(int i=0;i<n_hit;i++)
131 {
132 G4double edepByATrack = (*CHC)[i]->GetEdepByATrack();
133 if(edepByATrack>0.)
134 {
135 totE += edepByATrack;
136 if(n_hitByATrack==0)
137 { (*CHC)[i]->GetTrackInformation()->Print(); }
138 n_hitByATrack++;
139 G4cout << "Cell[" << (*CHC)[i]->GetZ() << ","
140 << (*CHC)[i]->GetPhi() << "] "
141 << edepByATrack/GeV << " [GeV]" << G4endl;
142 (*CHC)[i]->ClearEdepByATrack();
143 }
144 }
145 if(n_hitByATrack>0)
146 {
147 G4cout <<
148 "### Total energy deposition in calorimeter by a source track in "
149 << n_hitByATrack << " cells : " << totE / GeV << " (GeV)"
150 << G4endl;
151 G4cout << G4endl;
152 }
153 }
154 }
155
156 if(stackManager->GetNUrgentTrack())
157 {
158 // Transfer all tracks in Urgent stack to Waiting stack, since all tracks
159 // in Waiting stack have already been transfered to Urgent stack before
160 // invokation of this method.
161 stackManager->TransferStackedTracks(fUrgent,fWaiting);
162
163 // Then, transfer only one track to Urgent stack.
164 stackManager->TransferOneStackedTrack(fWaiting,fUrgent);
165
166 fStage++;
167 }
168}
169
170//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
Definition of the RE01CalorimeterHit class.
G4THitsCollection< RE01CalorimeterHit > RE01CalorimeterHitsCollection
Definition of the RE01StackingAction class.
Definition of the RE01TrackInformation class.
virtual void PrepareNewEvent()
G4VHitsCollection * GetCalCollection()
void SetSourceTrackInformation(const G4Track *aTrack)

Applications | User Support | Publications | Collaboration