Back to home page

EIC code displayed by LXR

 
 

    


Warning, file /geant4/examples/advanced/air_shower/src/UltraPMTSD.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 //    *      UltraPMTSD.cc
0036 //    ****************************************************
0037 //
0038 //    Class used to define the Ultra photomultiplier as a sensitive detector.
0039 //    Hits in this sensitive detector are defined in the UltraOpticalHit class
0040 //
0041 #include "UltraPMTSD.hh"
0042 
0043 #include "G4Material.hh"
0044 #include "G4Step.hh"
0045 #include "G4VTouchable.hh"
0046 #include "G4TouchableHistory.hh"
0047 #include "G4SDManager.hh"
0048 #include "G4OpticalPhoton.hh"
0049 #include "G4ParticleDefinition.hh"
0050 
0051 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0052 
0053 UltraPMTSD::UltraPMTSD(G4String name):G4VSensitiveDetector(name)
0054 {
0055 
0056   collectionName.insert("OpticalHitsCollection");
0057 
0058 }
0059 
0060 
0061 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0062 
0063 UltraPMTSD::~UltraPMTSD()
0064 {;}
0065 
0066 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0067 
0068 void UltraPMTSD::Initialize(G4HCofThisEvent* HCE)
0069 {
0070 
0071 
0072   static int HCID1 = -1;
0073 
0074 
0075   // SensitiveDetectorName and collectionName are data members of G4VSensitiveDetector
0076 
0077   OpticalHitsCollection =
0078     new UltraOpticalHitsCollection(SensitiveDetectorName,collectionName[0]);
0079 
0080   if(HCID1<0)
0081     { HCID1 = GetCollectionID(0); }
0082   HCE->AddHitsCollection(HCID1,OpticalHitsCollection);
0083 
0084 }
0085 
0086 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0087 
0088 G4bool UltraPMTSD::ProcessHits(G4Step* aStep,G4TouchableHistory*)
0089 {
0090 
0091   // Get Material
0092 
0093   auto thisVolume = aStep->GetTrack()->GetVolume()->GetName() ;
0094   const auto particle = aStep->GetTrack()->GetDefinition();
0095 
0096 
0097   if (thisVolume != "PMT1" && thisVolume != "PMT2")
0098     return false;
0099   if (particle != G4OpticalPhoton::Definition() )
0100     return false;
0101 
0102   if(particle == G4OpticalPhoton::Definition())
0103     aStep->GetTrack()->SetTrackStatus(fStopAndKill);
0104 
0105   auto      kineticEnergy = aStep->GetTrack()->GetKineticEnergy();
0106   auto HitPosition   = aStep->GetPreStepPoint()->GetPosition() ;
0107 
0108   auto OpticalHit = new UltraOpticalHit ;
0109   OpticalHit->SetEnergy(kineticEnergy);
0110   OpticalHit->SetPosition(HitPosition);
0111 
0112 
0113   OpticalHitsCollection->insert(OpticalHit);
0114 
0115 
0116 #ifdef ULTRA_VERBOSE
0117   G4cout << "*******************************" << G4endl;
0118   G4cout << "             PMT HIT           " << G4endl;
0119   G4cout << "  Volume:                      " << thisVolume << G4endl;
0120   G4cout << "  Photon energy (eV) :         " << kineticEnergy/CLHEP::eV << G4endl;
0121   G4cout << "  POSITION (mm) :              "
0122      << HitPosition.x()/CLHEP::mm << " " << HitPosition.y()/CLHEP::mm << " " << HitPosition.z()/CLHEP::mm << G4endl;
0123   G4cout << "*******************************" << G4endl;
0124 #endif
0125 
0126 
0127   return true;
0128 }
0129 
0130 
0131 void UltraPMTSD::EndOfEvent(G4HCofThisEvent* HCE)
0132 {
0133   static G4int HCID = -1;
0134   if(HCID<0)
0135     {
0136       HCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
0137     }
0138   HCE->AddHitsCollection(HCID,OpticalHitsCollection);
0139 
0140 }
0141 
0142 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0143 
0144 void UltraPMTSD::clear()
0145 {;}
0146 
0147 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0148 
0149 void UltraPMTSD::DrawAll()
0150 {;}
0151 
0152 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....
0153 
0154 void UltraPMTSD::PrintAll()
0155 {;}
0156 
0157 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo....