Geant4  10.03.p03
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
GammaRayTelEventAction Class Reference

#include <GammaRayTelEventAction.hh>

Inheritance diagram for GammaRayTelEventAction:
Collaboration diagram for GammaRayTelEventAction:

Public Member Functions

 GammaRayTelEventAction (GammaRayTelRunAction *runAction=0)
 
virtual ~GammaRayTelEventAction ()
 
virtual void BeginOfEventAction (const G4Event *)
 
virtual void EndOfEventAction (const G4Event *)
 
void SetDrawFlag (G4String val)
 
- Public Member Functions inherited from G4UserEventAction
 G4UserEventAction ()
 
virtual ~G4UserEventAction ()
 
virtual void SetEventManager (G4EventManager *value)
 

Additional Inherited Members

- Protected Attributes inherited from G4UserEventAction
G4EventManagerfpEventManager
 

Detailed Description

Definition at line 53 of file GammaRayTelEventAction.hh.

Constructor & Destructor Documentation

GammaRayTelEventAction::GammaRayTelEventAction ( GammaRayTelRunAction runAction = 0)

Definition at line 69 of file GammaRayTelEventAction.cc.

70  :trackerCollID(-1),calorimeterCollID(-1),
71  anticoincidenceCollID(-1), drawFlag("all"),
72  theRunAction(runAction)
73 {
74  GammaRayTelDigitizer * myDM = new GammaRayTelDigitizer( "GammaRayTelDigitizer" );
76 }
static G4DigiManager * GetDMpointer()
void AddNewModule(G4VDigitizerModule *DM)

Here is the call graph for this function:

GammaRayTelEventAction::~GammaRayTelEventAction ( )
virtual

Definition at line 80 of file GammaRayTelEventAction.cc.

81 {;}

Member Function Documentation

void GammaRayTelEventAction::BeginOfEventAction ( const G4Event evt)
virtual

Reimplemented from G4UserEventAction.

Definition at line 85 of file GammaRayTelEventAction.cc.

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) {
95  anticoincidenceCollID =
96  SDman->GetCollectionID("AnticoincidenceCollection");
97  }
98  if(calorimeterCollID==-1) {
99  calorimeterCollID =
100  SDman->GetCollectionID("CalorimeterCollection");
101  }
102 }
G4int GetCollectionID(G4String colName)
Definition: G4SDManager.cc:135
int G4int
Definition: G4Types.hh:78
G4int GetEventID() const
Definition: G4Event.hh:151
G4GLOB_DLL std::ostream G4cout
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
#define G4endl
Definition: G4ios.hh:61

Here is the call graph for this function:

void GammaRayTelEventAction::EndOfEventAction ( const G4Event evt)
virtual

Reimplemented from G4UserEventAction.

Definition at line 106 of file GammaRayTelEventAction.cc.

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  {
132  THC = (GammaRayTelTrackerHitsCollection*)(HCE->GetHC(trackerCollID));
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 }
void setNtuple(float E, float p, float x, float y, float z)
std::ofstream * GetOutputFile()
static constexpr double mm
Definition: G4SIunits.hh:115
G4VHitsCollection * GetHC(G4int i)
static GammaRayTelAnalysis * getInstance()
void InsertPositionXZ(double x, double z)
static G4DigiManager * GetDMpointer()
G4int entries() const
tuple x
Definition: test.py:50
int G4int
Definition: G4Types.hh:78
G4int GetEventID() const
Definition: G4Event.hh:151
G4GLOB_DLL std::ostream G4cout
G4int entries() const
void InsertPositionYZ(double y, double z)
void EndOfEvent(G4int flag)
void G4Exception(const char *originOfException, const char *exceptionCode, G4ExceptionSeverity severity, const char *comments)
Definition: G4Exception.cc:41
G4int GetDigiCollectionID(G4String DCname)
void InsertHits(int nplane)
tuple z
Definition: test.py:28
#define G4endl
Definition: G4ios.hh:61
const G4VDigiCollection * GetDigiCollection(G4int DCID, G4int eventID=0)
G4HCofThisEvent * GetHCofThisEvent() const
Definition: G4Event.hh:185
double G4double
Definition: G4Types.hh:76
void InsertEnergy(double en)
G4VDigitizerModule * FindDigitizerModule(G4String mName)
static constexpr double keV
Definition: G4SIunits.hh:216

Here is the call graph for this function:

void GammaRayTelEventAction::SetDrawFlag ( G4String  val)
inline

Definition at line 64 of file GammaRayTelEventAction.hh.

64 {drawFlag = val;};

The documentation for this class was generated from the following files: