Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:21:14

0001 //
0002 // ********************************************************************
0003 // * License and Disclaimer                                           *
0004 // *                                                                  *
0005 // * The  Geant4 software  is  copyright of the Copyright Holders  of *
0006 // * the Geant4 Collaboration.  It is provided  under  the terms  and *
0007 // * conditions of the Geant4 Software License,  included in the file *
0008 // * LICENSE and available at  http://cern.ch/geant4/license .  These *
0009 // * include a list of copyright holders.                             *
0010 // *                                                                  *
0011 // * Neither the authors of this software system, nor their employing *
0012 // * institutes,nor the agencies providing financial support for this *
0013 // * work  make  any representation or  warranty, express or implied, *
0014 // * regarding  this  software system or assume any liability for its *
0015 // * use.  Please see the license in the file  LICENSE  and URL above *
0016 // * for the full disclaimer and the limitation of liability.         *
0017 // *                                                                  *
0018 // * This  code  implementation is the result of  the  scientific and *
0019 // * technical work of the GEANT4 collaboration.                      *
0020 // * By using,  copying,  modifying or  distributing the software (or *
0021 // * any work based  on the software)  you  agree  to acknowledge its *
0022 // * use  in  resulting  scientific  publications,  and indicate your *
0023 // * acceptance of all terms of the Geant4 Software license.          *
0024 // ********************************************************************
0025 //
0026 /// \file SAXSEventAction.cc
0027 /// \brief Implementation of the SAXSEventAction class
0028 //
0029 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0030 
0031 #ifdef G4MULTITHREADED
0032 #  include "G4MTRunManager.hh"
0033 #else
0034 #  include "G4RunManager.hh"
0035 #endif
0036 
0037 #include "SAXSEventAction.hh"
0038 #include "SAXSSensitiveDetectorHit.hh"
0039 
0040 #include "G4AnalysisManager.hh"
0041 #include "G4Event.hh"
0042 #include "G4EventManager.hh"
0043 #include "G4HCofThisEvent.hh"
0044 #include "G4SDManager.hh"
0045 #include "G4SystemOfUnits.hh"
0046 #include "G4Trajectory.hh"
0047 #include "G4TrajectoryContainer.hh"
0048 #include "G4UImanager.hh"
0049 #include "G4VHitsCollection.hh"
0050 #include "G4VVisManager.hh"
0051 #include "G4ios.hh"
0052 
0053 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0054 
0055 SAXSEventAction::SAXSEventAction()
0056   : G4UserEventAction(),
0057     fSensitiveDetector_ID(-1),
0058     fVerboseLevel(0),
0059     fNRi(0),
0060     fNCi(0),
0061     fNDi(0),
0062     fEventWeight(0.)
0063 {}
0064 
0065 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0066 
0067 SAXSEventAction::~SAXSEventAction() {}
0068 
0069 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0070 
0071 void SAXSEventAction::BeginOfEventAction(const G4Event*)
0072 {
0073   fNRi = 0;
0074   fNCi = 0;
0075   fNDi = 0;
0076   fEventWeight = 1.;
0077 }
0078 
0079 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0080 
0081 void SAXSEventAction::EndOfEventAction(const G4Event* aEvent)
0082 {
0083   // instantiating The Sensitive Detector Manager
0084   G4SDManager* SDman = G4SDManager::GetSDMpointer();
0085 
0086   // Hit Detection System
0087   if (fSensitiveDetector_ID == -1) {
0088     G4String SensitiveDetectorName;
0089     if (SDman->FindSensitiveDetector(SensitiveDetectorName = "det", 0)) {
0090       fSensitiveDetector_ID = SDman->GetCollectionID(SensitiveDetectorName = "det/collection");
0091     }
0092   }
0093 
0094   SensitiveDetectorHitsCollection* fSensitiveDetectorHC = 0;
0095   G4HCofThisEvent* HCE = aEvent->GetHCofThisEvent();
0096 
0097   if (HCE) {
0098     if (fSensitiveDetector_ID != -1) {
0099       G4VHitsCollection* aHC = HCE->GetHC(fSensitiveDetector_ID);
0100       fSensitiveDetectorHC = (SensitiveDetectorHitsCollection*)(aHC);
0101     }
0102   }
0103 
0104   // instantiating The Analysis Manager
0105   G4AnalysisManager* analysisManager = G4AnalysisManager::Instance();
0106 
0107   // get the Event Number
0108   G4int eventNumber = G4RunManager::GetRunManager()->GetCurrentEvent()->GetEventID();
0109 
0110   // filling the SD scoring ntuple
0111   if (fSensitiveDetectorHC) {
0112     size_t vNumberOfHit = fSensitiveDetectorHC->entries();
0113     for (size_t i = 0; i < vNumberOfHit; i++) {
0114       SAXSSensitiveDetectorHit* aHit = (*fSensitiveDetectorHC)[i];
0115       analysisManager->FillNtupleDColumn(0, 0, aHit->GetEnergy() / CLHEP::keV);
0116       analysisManager->FillNtupleDColumn(0, 1, aHit->GetPos().x() / CLHEP::mm);
0117       analysisManager->FillNtupleDColumn(0, 2, aHit->GetPos().y() / CLHEP::mm);
0118       analysisManager->FillNtupleDColumn(0, 3, aHit->GetPos().z() / CLHEP::mm);
0119       analysisManager->FillNtupleDColumn(0, 4, aHit->GetMom().x());
0120       analysisManager->FillNtupleDColumn(0, 5, aHit->GetMom().y());
0121       analysisManager->FillNtupleDColumn(0, 6, aHit->GetMom().z());
0122       analysisManager->FillNtupleDColumn(0, 7, aHit->GetTime() / CLHEP::ns);
0123       analysisManager->FillNtupleIColumn(0, 8, aHit->GetType());
0124       analysisManager->FillNtupleIColumn(0, 9, aHit->GetTrackID());
0125       analysisManager->FillNtupleIColumn(0, 10, fNRi);
0126       analysisManager->FillNtupleIColumn(0, 11, fNCi);
0127       analysisManager->FillNtupleIColumn(0, 12, fNDi);
0128       analysisManager->FillNtupleIColumn(0, 13, eventNumber);
0129       analysisManager->FillNtupleDColumn(0, 14, aHit->GetWeight());
0130       analysisManager->AddNtupleRow(0);
0131     }
0132   }
0133 }
0134 
0135 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....