Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-18 09:17:09

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 // Author: Elena Guardincerri (Elena.Guardincerri@ge.infn.it)
0029 //
0030 // History:
0031 // -----------
0032 // 28 Nov 2001 Elena Guardincerri     Created
0033 // 15 Jul 2003 Alfonso Mantero        "DetectorType" use integration
0034 // 23 Sep 2003 Alfonso Mantero        differnt geometries integration
0035 //
0036 // -------------------------------------------------------------------
0037 
0038 #include "XrayFluoEventAction.hh"
0039 #include "XrayFluoSensorHit.hh"
0040 #include "XrayFluoEventActionMessenger.hh"
0041 #include "XrayFluoDataSet.hh"
0042 #include "XrayFluoAnalysisManager.hh"
0043 
0044 #include "G4SystemOfUnits.hh"
0045 #include "G4Event.hh"
0046 #include "G4EventManager.hh"
0047 #include "G4HCofThisEvent.hh"
0048 #include "G4VHitsCollection.hh"
0049 #include "G4SDManager.hh"
0050 #include "G4UImanager.hh"
0051 #include "G4ios.hh"
0052 #include "G4UnitsTable.hh"
0053 #include "Randomize.hh"
0054 #include <fstream>
0055 
0056 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0057 
0058 XrayFluoEventAction::XrayFluoEventAction(const XrayFluoDetectorConstruction* det)
0059   :drawFlag("all"),
0060    HPGeCollID(0),
0061    eventMessenger(0),
0062    printModulo(1),
0063    detectorType(0)
0064 {
0065   eventMessenger = new XrayFluoEventActionMessenger(this);
0066   
0067   if (!(det->GetPhaseSpaceFlag()) ){
0068     detectorType = det->GetDetectorType();
0069     HPGeCollID=-1;
0070   }
0071 }
0072 
0073 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0074 
0075 XrayFluoEventAction::XrayFluoEventAction(const XrayFluoPlaneDetectorConstruction* det)
0076   :drawFlag("all"),
0077    HPGeCollID(-1),
0078    eventMessenger(0),
0079    printModulo(1),
0080    detectorType(0)
0081 {
0082   eventMessenger = new XrayFluoEventActionMessenger(this);
0083   detectorType = det->GetDetectorType();
0084 }
0085 
0086 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0087 
0088 XrayFluoEventAction::XrayFluoEventAction(const XrayFluoMercuryDetectorConstruction* det)
0089   :drawFlag("all"),
0090    HPGeCollID(-1),
0091    eventMessenger(0),
0092    printModulo(1),
0093    detectorType(0)
0094 {
0095   eventMessenger = new XrayFluoEventActionMessenger(this);
0096   detectorType = det->GetDetectorType();
0097 }
0098 
0099 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0100 
0101 XrayFluoEventAction::~XrayFluoEventAction()
0102 {
0103    delete eventMessenger;
0104    eventMessenger = 0;
0105 }
0106 
0107 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0108 
0109 void XrayFluoEventAction::BeginOfEventAction(const G4Event* evt)
0110 {
0111 
0112   G4int eventNumber = (evt->GetEventID())+1;
0113   if ( eventNumber == 1){
0114 
0115   G4cout << "# = 100000 events" << G4endl;
0116   G4cout << "1--------+---------+---------+---------+---------5e6"<<G4endl;
0117   }
0118 
0119   if ( ((eventNumber) % 100000) == 0 )  {
0120 
0121     if ( eventNumber % (G4int)5e6 != 0 ) G4cout << "#" << std::flush;
0122     else G4cout << "#"<< G4endl;   
0123   }
0124 
0125   if (HPGeCollID==-1)    
0126     {
0127       G4SDManager * SDman = G4SDManager::GetSDMpointer();
0128       HPGeCollID = SDman->GetCollectionID("HPGeCollection");
0129       //the pointer points to the ID number of the sensitive detector
0130     }
0131 }
0132   
0133 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0134 
0135 void XrayFluoEventAction::EndOfEventAction(const G4Event* evt)
0136 {
0137   if (detectorType) {
0138     
0139     // extracted from hits, compute the total energy deposit (and total charged
0140     // track length) 
0141     G4HCofThisEvent* HCE = evt->GetHCofThisEvent();
0142     
0143     XrayFluoSensorHitsCollection* HPGeHC = 0;
0144     G4int n_hit = 0;
0145     G4double totEnergy=0., energyD=0.;
0146     
0147     if (HCE) HPGeHC = 
0148       (XrayFluoSensorHitsCollection*)(HCE->GetHC(HPGeCollID));
0149 
0150     if(HPGeHC)            
0151       {
0152     n_hit = HPGeHC->entries();
0153     
0154     for (G4int i=0;i<n_hit;i++)
0155       {
0156         totEnergy += (*HPGeHC)[i]->GetEdepTot(); 
0157         energyD = detectorType->ResponseFunction(totEnergy);        
0158         XrayFluoAnalysisManager* analysis = XrayFluoAnalysisManager::getInstance();
0159         analysis->analyseEnergyDep(energyD);
0160       }
0161       }
0162   }  
0163 }
0164 
0165 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0166 
0167 
0168 G4double XrayFluoEventAction::RandomCut(G4double energy)
0169   
0170 {
0171   G4double efficiency = 1.;
0172   G4double F = 0.15;
0173   G4double epsilon = 2.96 * eV;
0174   G4double deltaE = 220 * eV;
0175   G4double EdepDetect = 0.;
0176 
0177   G4double  Random = G4UniformRand(); 
0178 
0179   if ( Random<efficiency )
0180     {
0181       G4double sigma = std::sqrt(F*epsilon*energy+std::pow(deltaE/2355,2));      
0182       EdepDetect = G4RandGauss::shoot(energy, sigma );
0183       
0184     }
0185   else {EdepDetect = 0.;}
0186 
0187   return   EdepDetect;  
0188 }
0189 
0190