Geant4.10
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
Public Member Functions
GammaRayTelEventAction Class Reference

#include <GammaRayTelEventAction.hh>

Inheritance diagram for GammaRayTelEventAction:
G4UserEventAction

Public Member Functions

 GammaRayTelEventAction ()
 
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 ()
 
void SetEventManager (G4EventManager *value)
 

Additional Inherited Members

- Protected Attributes inherited from G4UserEventAction
G4EventManagerfpEventManager
 

Detailed Description

Definition at line 52 of file GammaRayTelEventAction.hh.

Constructor & Destructor Documentation

GammaRayTelEventAction::GammaRayTelEventAction ( )

Definition at line 75 of file GammaRayTelEventAction.cc.

References G4DigiManager::AddNewModule(), and G4DigiManager::GetDMpointer().

76  :trackerCollID(-1),calorimeterCollID(-1),
77  anticoincidenceCollID(-1), drawFlag("all")
78 {
80  GammaRayTelDigitizer * myDM = new GammaRayTelDigitizer( "GammaRayTelDigitizer" );
81  fDM->AddNewModule(myDM);
82 }
static G4DigiManager * GetDMpointer()
void AddNewModule(G4VDigitizerModule *DM)
GammaRayTelEventAction::~GammaRayTelEventAction ( )
virtual

Definition at line 86 of file GammaRayTelEventAction.cc.

87 {
88 }

Member Function Documentation

void GammaRayTelEventAction::BeginOfEventAction ( const G4Event evt)
virtual

Reimplemented from G4UserEventAction.

Definition at line 92 of file GammaRayTelEventAction.cc.

References G4cout, G4endl, G4SDManager::GetCollectionID(), G4Event::GetEventID(), and G4SDManager::GetSDMpointer().

93 {
94 
95  G4int evtNb = evt->GetEventID();
96  G4cout << "Event: " << evtNb << G4endl;
98 
99  if (trackerCollID==-1) {
100  trackerCollID = SDman->GetCollectionID("TrackerCollection");
101  }
102  if(anticoincidenceCollID==-1) {
103  anticoincidenceCollID =
104  SDman->GetCollectionID("AnticoincidenceCollection");
105  }
106  if(calorimeterCollID==-1) {
107  calorimeterCollID =
108  SDman->GetCollectionID("CalorimeterCollection");
109  }
110 }
G4int GetCollectionID(G4String colName)
Definition: G4SDManager.cc:131
int G4int
Definition: G4Types.hh:78
G4int GetEventID() const
Definition: G4Event.hh:140
G4GLOB_DLL std::ostream G4cout
static G4SDManager * GetSDMpointer()
Definition: G4SDManager.cc:40
#define G4endl
Definition: G4ios.hh:61
void GammaRayTelEventAction::EndOfEventAction ( const G4Event evt)
virtual

Reimplemented from G4UserEventAction.

Definition at line 114 of file GammaRayTelEventAction.cc.

References GammaRayTelDigitizer::Digitize(), G4TDigiCollection< T >::entries(), G4THitsCollection< T >::entries(), G4DigiManager::FindDigitizerModule(), G4cout, G4endl, G4DigiManager::GetDigiCollection(), G4DigiManager::GetDigiCollectionID(), G4DigiManager::GetDMpointer(), G4Event::GetEventID(), G4HCofThisEvent::GetHC(), G4Event::GetHCofThisEvent(), python.hepunit::keV, python.hepunit::mm, outFile, test::x, and z.

115 {
116  G4int event_id = evt->GetEventID();
117 
118 
119  G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
121 // GammaRayTelCalorimeterHitsCollection* CHC = 0;
122 // GammaRayTelAnticoincidenceHitsCollection* AHC = 0;
123 
124 
126 
127  if (HCE)
128  {
129  THC = (GammaRayTelTrackerHitsCollection*)(HCE->GetHC(trackerCollID));
130 // CHC = (GammaRayTelCalorimeterHitsCollection*)
131 // (HCE->GetHC(calorimeterCollID));
132 // AHC = (GammaRayTelAnticoincidenceHitsCollection*)
133 // (HCE->GetHC(anticoincidenceCollID));
134 
135  if (THC)
136  {
137  int n_hit = THC->entries();
138  G4cout << "Number of tracker hits in this event = " << n_hit << G4endl;
139  G4double ESil=0;
140  G4int NStrip, NPlane, IsX;
141 
142  // This is a cycle on all the tracker hits of this event
143 
144  for (int i=0;i<n_hit;i++)
145  {
146  // Here we put the hit data in a an ASCII file for
147  // later analysis
148  ESil = (*THC)[i]->GetEdepSil();
149  NStrip = (*THC)[i]->GetNStrip();
150  NPlane = (*THC)[i]->GetNSilPlane();
151  IsX = (*THC)[i]->GetPlaneType();
152 
153 #ifdef G4STORE_DATA
154  outFile << std::setw(7) << event_id << " " <<
155  ESil/keV << " " << NStrip <<
156  " " << NPlane << " " << IsX << " " <<
157  (*THC)[i]->GetPos().x()/mm <<" "<<
158  (*THC)[i]->GetPos().y()/mm <<" "<<
159  (*THC)[i]->GetPos().z()/mm <<" "<<
160  G4endl;
161 #else
162  G4cout << std::setw(7) << event_id << " " <<
163  ESil/keV << " " << NStrip <<
164  " " << NPlane << " " << IsX << " " <<
165  (*THC)[i]->GetPos().x()/mm <<" "<<
166  (*THC)[i]->GetPos().y()/mm <<" "<<
167  (*THC)[i]->GetPos().z()/mm <<" "<<
168  G4endl;
169 #endif
170 
171 #ifdef G4ANALYSIS_USE
172 
173  // Here we fill the histograms of the Analysis manager
174  GammaRayTelAnalysis* analysis = GammaRayTelAnalysis::getInstance();
175 
176  if(IsX)
177  {
178  if (analysis->GetHisto2DMode()=="position")
179  analysis->InsertPositionXZ((*THC)[i]->GetPos().x()/mm,(*THC)[i]->GetPos().z()/mm);
180  else
181  analysis->InsertPositionXZ(NStrip, NPlane);
182  if (NPlane == 0) analysis->InsertEnergy(ESil/keV);
183  analysis->InsertHits(NPlane);
184  }
185  else
186  {
187  if (analysis->GetHisto2DMode()=="position")
188  analysis->InsertPositionYZ((*THC)[i]->GetPos().y()/mm,(*THC)[i]->GetPos().z()/mm);
189  else
190  analysis->InsertPositionYZ(NStrip, NPlane);
191  if (NPlane == 0) analysis->InsertEnergy(ESil/keV);
192  analysis->InsertHits(NPlane);
193  }
194 
195 #ifdef G4ANALYSIS_USE
196  analysis->setNtuple( ESil/keV, NPlane, (*THC)[i]->GetPos().x()/mm,
197  (*THC)[i]->GetPos().y()/mm,
198  (*THC)[i]->GetPos().z()/mm);
199 #endif
200 
201 #endif
202 
203  }
204 #ifdef G4ANALYSIS_USE
205  GammaRayTelAnalysis* analysis = GammaRayTelAnalysis::getInstance();
206  analysis->EndOfEvent(n_hit);
207 #endif
208 
209  }
210 
211  GammaRayTelDigitizer * myDM =
212  (GammaRayTelDigitizer*)fDM->FindDigitizerModule( "GammaRayTelDigitizer" );
213  myDM->Digitize();
214 
215 #ifdef write_outfile
216  // the whole block is needed only when outfile is active; protect block to avoid
217  // compilations warnings from gcc4.6, Gunter Folger
218 
219  G4int myDigiCollID = fDM->GetDigiCollectionID("DigitsCollection");
220 
221  // G4cout << "digi collecion" << myDigiCollID << G4endl;
222 
224 
225  if(DC) {
226  // G4cout << "Total Digits " << DC->entries() << G4endl;
227  G4int n_digi = DC->entries();
228  G4int NStrip, NPlane, IsX;
229  for (G4int i=0;i<n_digi;i++) {
230  // Here we put the digi data in a an ASCII file for
231  // later analysis
232  NStrip = (*DC)[i]->GetStripNumber();
233  NPlane = (*DC)[i]->GetPlaneNumber();
234  IsX = (*DC)[i]->GetPlaneType();
235 
236  outFile << std::setw(7) << event_id << " " << NStrip <<
237  " " << NPlane << " " << IsX << " " << G4endl;
238  }
239  }
240 #endif
241  }
242 }
std::ofstream outFile
Definition: GammaRayTel.cc:68
G4double z
Definition: TRTMaterials.hh:39
static G4DigiManager * GetDMpointer()
int G4int
Definition: G4Types.hh:78
G4int GetEventID() const
Definition: G4Event.hh:140
G4GLOB_DLL std::ostream G4cout
G4int entries() const
G4int GetDigiCollectionID(G4String DCname)
#define G4endl
Definition: G4ios.hh:61
const G4VDigiCollection * GetDigiCollection(G4int DCID, G4int eventID=0)
G4HCofThisEvent * GetHCofThisEvent() const
Definition: G4Event.hh:174
double G4double
Definition: G4Types.hh:76
G4VDigitizerModule * FindDigitizerModule(G4String mName)
void GammaRayTelEventAction::SetDrawFlag ( G4String  val)
inline

Definition at line 63 of file GammaRayTelEventAction.hh.

63 {drawFlag = val;};

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