Geant4  9.6.p02
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
FCALTBEventAction.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 // $Id: FCALTBEventAction.cc 69896 2013-05-17 09:57:59Z gcosmo $
27 //
28 //
29 
30 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
31 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
32 
33 #include "FCALTBEventAction.hh"
34 
36 
37 #include "FCALRunAction.hh"
38 
39 #include "FCALCalorHit.hh"
40 
41 #include <vector>
42 
43 #include "G4Event.hh"
44 #include "G4EventManager.hh"
45 #include "G4HCofThisEvent.hh"
46 #include "G4VHitsCollection.hh"
47 #include "G4SDManager.hh"
48 #include "G4UImanager.hh"
49 #include "G4ios.hh"
50 #include "G4UnitsTable.hh"
51 #include "Randomize.hh"
52 #include "FCALSteppingAction.hh"
53 
54 #include "FCALAnalysisManager.hh"
55 
56 #include "G4ios.hh"
57 #include <fstream>
58 #include <iostream>
59 
60 #ifdef G4ANALYSIS_USE
61  #include <AIDA/AIDA.h>
62 #endif
63 
64 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
65 
67  :calorimeterCollID(-1),drawFlag("all"),printModulo(10), StepAction(SA), eventMessenger(0)
68 {
69  eventMessenger = new FCALTBEventActionMessenger(this);
70  runManager = new FCALRunAction();
71 }
72 
73 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
74 
76 {
77  delete eventMessenger;
78  eventMessenger = 0;
79  delete runManager;
80  runManager = 0;
81 }
82 
83 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
84 
86 {
87  G4int evtNb = evt->GetEventID();
88  if (evtNb%printModulo == 0)
89  {
90  G4cout << "\n---> Begin of event: " << evtNb+1 << G4endl;
91 // HepRandom::showEngineStatus();
92  }
93 
94  NTracksOutOfWorld = 0;
95  NSecondaries = 0;
96 
97  StepAction->initialize(evtNb+1);
98 }
99 
100 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
101 
103 {
104 #ifdef G4ANALYSIS_USE
105  FCALAnalysisManager* analysis = FCALAnalysisManager::getInstance();
106 #endif
107 
108  G4int i,j;
109  NTracksOutOfWorld = StepAction->GetOutOfWorldTracks(0, 0);
110  G4cout << "N Tracks out of world " << NTracksOutOfWorld << G4endl;
111 
112  // Write Leaving Particles in File
113  //--------------------------------
114  G4String FileName1 = "OutTracks_802_1mm.dat";
115  std::ios::openmode iostemp1;
116  if(Init1 == 0) {
117  iostemp1 = std::ios::out;
118  Init1++;
119  } else {
120  iostemp1 = std::ios::out|std::ios::app; // std::ios::app;
121  };
122  std::ofstream OutTracks(FileName1, iostemp1);
123 
124  OutTracks << NTracksOutOfWorld << G4endl;
125 
126  G4double OutOfWorld;
127  for(i=1; i<= NTracksOutOfWorld ; i++){
128  for(j=1; j<11 ; j++) {
129  // G4double OutOfWorld = StepAction->GetOutOfWorldTracks(i,j);
130  OutOfWorld = StepAction->GetOutOfWorldTracks(i,j);
131  OutTracks << OutOfWorld << " " ;
132  }
133  OutTracks << std::endl;
134  // G4double OutOfWorld2 = StepAction->GetOutOfWorldTracks(i,j);
135  }
136  OutTracks.close();
137 
138 #ifdef G4ANALYSIS_USE
139  analysis->getfhisto_1()->fill(NTracksOutOfWorld);
140 #endif
141 
142  NSecondaries = StepAction->GetSecondaries(0,0);
143  G4cout << "N Scondaries " << NSecondaries << G4endl;
144 
145  // Write Secondary Particles in File
146  //----------------------------------
147  G4String FileName2 = "SecndTracks_802_1mm.dat";
148  std::ios::openmode iostemp2;
149  if(Init2 == 0) {
150  iostemp2 = std::ios::out;
151  Init2++;
152  } else {
153  iostemp2 = std::ios::out|std::ios::app; // std::ios::app;
154  };
155 
156  std::ofstream SecndTracks(FileName2, iostemp2);
157 
158  SecndTracks << NSecondaries << std::endl;
159 
160  G4double Secondary;
161  for(i=1; i<= NSecondaries ; i++){
162  for(j=1; j<11 ; j++) {
163  Secondary = StepAction->GetSecondaries(i,j);
164  SecndTracks << Secondary << " " ;
165  }
166  SecndTracks << std::endl;
167  // G4double Secondary2 = StepAction->GetSecondaries(i,j);
168  }
169  SecndTracks.close();
170 
171 #ifdef G4ANALYSIS_USE
172  analysis->getfhisto_2()->fill(NSecondaries);
173 #endif
174 
175  // Write Edep in FCAL1 and FCAL2
176  G4String FileName3 = "EdepFCAL_802_1mm.dat";
177  std::ios::openmode iostemp3;
178  if(Init3 == 0) {
179  iostemp3 = std::ios::out;
180  Init3++;
181  } else {
182  iostemp3 = std::ios::out|std::ios::app; // std::ios::app;
183  };
184 
185  std::ofstream EdepFCAL(FileName3, iostemp3);
186 
187  G4double EmEdep = StepAction->GetEdepFCAL("FCALEm");
188  G4double HadEdep = StepAction->GetEdepFCAL("FCALHad");
189 
190  EdepFCAL << EmEdep << " ";
191  EdepFCAL << HadEdep;
192  EdepFCAL << std::endl;
193  EdepFCAL.close();
194 
195 #ifdef G4ANALYSIS_USE
196  analysis->getfhisto_3()->fill(EmEdep);
197  analysis->getfhisto_4()->fill(HadEdep);
198 #endif
199 
200  G4cout<<"EmEdep is="<<EmEdep<<G4endl;
201  G4cout<<"HadEdep is="<<HadEdep<<G4endl;
202 
203  G4cout << "Edep in FCAL1 FCAl2 : " << StepAction->GetEdepFCAL("FCALEm") << " ";
204  G4cout << StepAction->GetEdepFCAL("FCALHad") << G4endl;
205 }
206 
207 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....