Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /geant4/examples/advanced/air_shower/src/UltraEventAction.cc was not indexed or was modified since last indexation (in which case cross-reference links may be missing, inaccurate or erroneous).

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 //
0027 // --------------------------------------------------------------
0028 //                 GEANT 4 - ULTRA experiment example
0029 // --------------------------------------------------------------
0030 //
0031 // Code developed by:
0032 // B. Tome, M.C. Espirito-Santo, A. Trindade, P. Rodrigues
0033 //
0034 //    ****************************************************
0035 //    *      UltraEventAction.cc
0036 //    ****************************************************
0037 //
0038 //    Ultra EventAction class. The UltraAnalysisManager class is used for histogram
0039 //    filling
0040 //
0041 #include "UltraEventAction.hh"
0042 #include "UltraPrimaryGeneratorAction.hh"
0043 #include "UltraOpticalHit.hh"
0044 
0045 #include "G4RunManager.hh"
0046 #include "G4Event.hh"
0047 #include "G4EventManager.hh"
0048 #include "G4SDManager.hh"
0049 #include "G4HCofThisEvent.hh"
0050 #include "G4VHitsCollection.hh"
0051 #include "G4GeneralParticleSource.hh"
0052 #include "G4AnalysisManager.hh"
0053 #include "G4SystemOfUnits.hh"
0054 
0055 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0056 
0057 UltraEventAction::UltraEventAction()
0058   :OpticalHitsCollID(-1)
0059 {;}
0060 
0061 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0062 
0063 UltraEventAction::~UltraEventAction(){;}
0064 
0065 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0066 
0067 void UltraEventAction::BeginOfEventAction(const G4Event* evt)
0068 {
0069   auto printModulo = 100;
0070 
0071   evtNb = evt->GetEventID();
0072 
0073   auto SDman = G4SDManager::GetSDMpointer();
0074 
0075 
0076   if(OpticalHitsCollID==-1) {
0077     OpticalHitsCollID = SDman->GetCollectionID("OpticalHitsCollection");
0078   }
0079 
0080 
0081   if (evtNb%printModulo == 0)
0082     G4cout << "\n---> Begin of Event: " << evtNb << G4endl;
0083 
0084 }
0085 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0086 
0087 void UltraEventAction::EndOfEventAction(const G4Event* evt)
0088 {
0089 
0090   auto HCE = evt->GetHCofThisEvent();
0091   UltraOpticalHitsCollection* OpticalHitsColl = nullptr;
0092 
0093   // Fill histograms
0094   auto man = G4AnalysisManager::Instance();
0095 
0096   if(HCE){
0097     if(OpticalHitsCollID != -1) OpticalHitsColl =
0098       (UltraOpticalHitsCollection*)(HCE->GetHC(OpticalHitsCollID));
0099   }
0100 
0101   auto nOptHits = 0 ;
0102 
0103   if(OpticalHitsColl){
0104     nOptHits = OpticalHitsColl->entries();
0105 
0106 #ifdef ULTRA_VERBOSE
0107     if (nOptHits > 0){
0108       G4cout << " Optical Hit # " << " " << "Energy (eV)" <<  " " << "x,y,z (cm)" << G4endl ;
0109     }
0110 #endif
0111 
0112     for(auto iHit=0; iHit<nOptHits; iHit++){
0113       auto HitEnergy = (*OpticalHitsColl)[iHit]->GetEnergy() ;
0114       man->FillH1(1,HitEnergy/eV);
0115     }
0116 
0117  }
0118 
0119   man->FillH1(2,nOptHits);
0120 
0121 }