Geant4  v4-10.4-release
 모두 클래스 네임스페이스들 파일들 함수 변수 타입정의 열거형 타입 열거형 멤버 Friends 매크로 그룹들 페이지들
GammaRayTelEventAction.cc
이 파일의 문서화 페이지로 가기
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: GammaRayTelEventAction.cc 82334 2014-06-16 09:59:16Z gcosmo $
28 // ------------------------------------------------------------
29 // GEANT 4 class implementation file
30 // CERN Geneva Switzerland
31 //
32 //
33 // ------------ GammaRayTelEventAction ------
34 // by R.Giannitrapani, F.Longo & G.Santin (13 nov 2000)
35 //
36 // - inclusion of Digits by F.Longo & R.Giannitrapani (24 oct 2001)
37 //
38 // - Modification of analysis management by G.Santin (18 Nov 2001)
39 //
40 // ************************************************************
41 
43 #include "GammaRayTelTrackerHit.hh"
46 
47 #include "GammaRayTelAnalysis.hh"
48 
49 #include "G4SystemOfUnits.hh"
50 #include "G4Event.hh"
51 #include "G4EventManager.hh"
52 #include "G4HCofThisEvent.hh"
53 #include "G4VHitsCollection.hh"
54 #include "G4SDManager.hh"
55 #include "G4UImanager.hh"
56 #include "G4ios.hh"
57 #include "G4UnitsTable.hh"
58 #include "Randomize.hh"
59 
60 #include "GammaRayTelDigi.hh"
61 #include "GammaRayTelDigitizer.hh"
62 #include "G4DigiManager.hh"
63 
64 // This file is a global variable in which we store energy deposition per hit
65 // and other relevant information
66 
67 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
68 
70  :trackerCollID(-1),calorimeterCollID(-1),
71  anticoincidenceCollID(-1), drawFlag("all"),
72  theRunAction(runAction)
73 {
74  GammaRayTelDigitizer * myDM = new GammaRayTelDigitizer( "GammaRayTelDigitizer" );
76 }
77 
78 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
79 
81 {;}
82 
83 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
84 
86 {
87  G4int evtNb = evt->GetEventID();
88  G4cout << "Event: " << evtNb << G4endl;
90 
91  if (trackerCollID==-1) {
92  trackerCollID = SDman->GetCollectionID("TrackerCollection");
93  }
94  if(anticoincidenceCollID==-1) {
96  SDman->GetCollectionID("AnticoincidenceCollection");
97  }
98  if(calorimeterCollID==-1) {
100  SDman->GetCollectionID("CalorimeterCollection");
101  }
102 }
103 
104 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
105 
107 {
108  G4int event_id = evt->GetEventID();
109 
110 
111  if (!theRunAction)
112  {
113  G4Exception("GammaRayTelEventAction::BeginOfEventAction()",
114  "GTR0001",FatalException,"Null pointer to Run Action: this should not be");
115  }
116 #ifdef G4STORE_DATA
117  std::ofstream* outFile = theRunAction->GetOutputFile();
118 #endif
119 
120  G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
122 
123  // GammaRayTelCalorimeterHitsCollection* CHC = 0;
124  // GammaRayTelAnticoincidenceHitsCollection* AHC = 0;
125 
126 
129 
130  if (HCE)
131  {
133  // CHC = (GammaRayTelCalorimeterHitsCollection*)
134  // (HCE->GetHC(calorimeterCollID));
135  // AHC = (GammaRayTelAnticoincidenceHitsCollection*)
136  // (HCE->GetHC(anticoincidenceCollID));
137 
138  if (THC)
139  {
140  int n_hit = THC->entries();
141  G4cout << "Number of tracker hits in this event = " << n_hit << G4endl;
142  G4double ESil=0;
143  G4int NStrip, NPlane, IsX;
144 
145  // This is a cycle on all the tracker hits of this event
146 
147  for (int i=0;i<n_hit;i++)
148  {
149  // Here we put the hit data in a an ASCII file for
150  // later analysis
151  ESil = (*THC)[i]->GetEdepSil();
152  NStrip = (*THC)[i]->GetNStrip();
153  NPlane = (*THC)[i]->GetNSilPlane();
154  IsX = (*THC)[i]->GetPlaneType();
155 
156 #ifdef G4STORE_DATA
157 
158 
159  (*outFile) << std::setw(7) << event_id << " " <<
160  ESil/keV << " " << NStrip <<
161  " " << NPlane << " " << IsX << " " <<
162  (*THC)[i]->GetPos().x()/mm <<" "<<
163  (*THC)[i]->GetPos().y()/mm <<" "<<
164  (*THC)[i]->GetPos().z()/mm <<" "<<
165  G4endl;
166 #else
167  G4cout << std::setw(7) << event_id << " " <<
168  ESil/keV << " " << NStrip <<
169  " " << NPlane << " " << IsX << " " <<
170  (*THC)[i]->GetPos().x()/mm <<" "<<
171  (*THC)[i]->GetPos().y()/mm <<" "<<
172  (*THC)[i]->GetPos().z()/mm <<" "<<
173  G4endl;
174 #endif
175 
176 
177  // Here we fill the histograms of the Analysis manager
178  if(IsX)
179  {
180  if (analysis->GetHisto2DMode()=="position")
181  analysis->InsertPositionXZ((*THC)[i]->GetPos().x()/mm,(*THC)[i]->GetPos().z()/mm);
182  else
183  analysis->InsertPositionXZ(NStrip, NPlane);
184  if (NPlane == 0) analysis->InsertEnergy(ESil/keV);
185  analysis->InsertHits(NPlane);
186  }
187  else
188  {
189  if (analysis->GetHisto2DMode()=="position")
190  analysis->InsertPositionYZ((*THC)[i]->GetPos().y()/mm,(*THC)[i]->GetPos().z()/mm);
191  else
192  analysis->InsertPositionYZ(NStrip, NPlane);
193  if (NPlane == 0) analysis->InsertEnergy(ESil/keV);
194  analysis->InsertHits(NPlane);
195  }
196 
197  analysis->setNtuple( ESil/keV, NPlane, (*THC)[i]->GetPos().x()/mm,
198  (*THC)[i]->GetPos().y()/mm,
199  (*THC)[i]->GetPos().z()/mm);
200 
201  }
202  analysis->EndOfEvent(n_hit);
203  }
204 
205  GammaRayTelDigitizer * myDM =
206  (GammaRayTelDigitizer*)fDM->FindDigitizerModule( "GammaRayTelDigitizer" );
207  myDM->Digitize();
208 
209 #ifdef G4STORE_DATA
210  // the whole block is needed only when outfile is active; protect block to avoid
211  // compilations warnings from gcc4.6, Gunter Folger
212 
213  G4int myDigiCollID = fDM->GetDigiCollectionID("DigitsCollection");
214 
215  // G4cout << "digi collecion" << myDigiCollID << G4endl;
216 
218 
219  if(DC) {
220  // G4cout << "Total Digits " << DC->entries() << G4endl;
221  G4int n_digi = DC->entries();
222  G4int NStrip, NPlane, IsX;
223  for (G4int i=0;i<n_digi;i++) {
224  // Here we put the digi data in a an ASCII file for
225  // later analysis
226  NStrip = (*DC)[i]->GetStripNumber();
227  NPlane = (*DC)[i]->GetPlaneNumber();
228  IsX = (*DC)[i]->GetPlaneType();
229 
230  (*outFile) << std::setw(7) << event_id << " " << NStrip <<
231  " " << NPlane << " " << IsX << " " << G4endl;
232  }
233  }
234 #endif
235  }
236 }
237 
238 
239 
240 
241 
242 
243 
244 
245 
246 
247 
248 
249 
Float_t x
Definition: compare.C:6
static G4DigiManager * GetDMpointer()
G4int GetCollectionID(G4String colName)
Definition: G4SDManager.cc:135
void EndOfEvent(G4int flag)
G4int GetEventID() const
Definition: G4Event.hh:151
G4int GetDigiCollectionID(G4String DCname)
static constexpr double keV
Definition: G4SIunits.hh:216
static constexpr double mm
Definition: G4SIunits.hh:115
void InsertPositionXZ(double x, double z)
#define G4endl
Definition: G4ios.hh:61
Float_t y
Definition: compare.C:6
Double_t z
void InsertHits(int nplane)
void InsertPositionYZ(double y, double z)
static GammaRayTelAnalysis * getInstance()
G4HCofThisEvent * GetHCofThisEvent() const
Definition: G4Event.hh:185
void InsertEnergy(double en)
double G4double
Definition: G4Types.hh:76
void AddNewModule(G4VDigitizerModule *DM)
virtual void EndOfEventAction(const G4Event *)
GammaRayTelRunAction * theRunAction
const G4VDigiCollection * GetDigiCollection(G4int DCID, G4int eventID=0)
void setNtuple(float E, float p, float x, float y, float z)
std::ofstream * GetOutputFile()
G4int entries() const
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *description)
Definition: G4Exception.hh:65
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
int G4int
Definition: G4Types.hh:78
G4GLOB_DLL std::ostream G4cout
virtual void BeginOfEventAction(const G4Event *)
G4VDigitizerModule * FindDigitizerModule(G4String mName)
GammaRayTelEventAction(GammaRayTelRunAction *runAction=0)