Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:21:46

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 // ********************************************************************
0029 //
0030 //  CaTS (Calorimetry and Tracking Simulation)
0031 //
0032 //  Authors : Hans Wenzel
0033 //            Soon Yung Jun
0034 //            (Fermi National Accelerator Laboratory)
0035 //
0036 // History
0037 //   October 18th, 2021 : first implementation
0038 //
0039 // ********************************************************************
0040 //
0041 /// \file PhotonHit.hh
0042 /// \brief Definition of the CaTS::PhotonHit class
0043 
0044 #pragma once
0045 
0046 #include "G4VHit.hh"
0047 #include "G4THitsCollection.hh"
0048 #include "G4Allocator.hh"
0049 #include "G4ThreeVector.hh"
0050 
0051 class PhotonHit : public G4VHit
0052 {
0053  public:
0054   PhotonHit();
0055   ~PhotonHit() = default;
0056   PhotonHit(const PhotonHit&);
0057   const PhotonHit& operator=(const PhotonHit&);
0058   G4bool operator==(const PhotonHit&) const;
0059   inline void* operator new(size_t);
0060   inline void operator delete(void*);
0061   void Draw() final;
0062 
0063   inline void Print() final
0064   {
0065     G4cout << "PhotonHit id: " << fid << " pid: " << fpid
0066            << " wavelength: " << fwavelength << " time: " << ftime
0067            << " position X: " << fposition.getX() << " Y: " << fposition.getY()
0068            << " Z: " << fposition.getZ()
0069            << " direction X: " << fdirection.getX()
0070            << " Y: " << fdirection.getY() << " Z: " << fdirection.getZ()
0071            << " polarization: X:" << fpolarization.getX()
0072            << " Y: " << fpolarization.getY() << " Z: " << fpolarization.getZ()
0073            << G4endl;
0074   }
0075 
0076   PhotonHit(unsigned id, unsigned pid, G4double wavelength, G4double time,
0077             G4ThreeVector position, G4ThreeVector direction,
0078             G4ThreeVector polarization);
0079   inline void SetWavelength(G4double wavelength) { fwavelength = wavelength; }
0080   inline G4double GetWavelength() { return fwavelength; }
0081   inline void SetPolarization(G4ThreeVector polarization)
0082   {
0083     fpolarization = polarization;
0084   }
0085   inline G4ThreeVector GetPolarization() const { return fpolarization; }
0086   inline void SetDirection(G4ThreeVector direction) { fdirection = direction; }
0087   inline G4ThreeVector GetDirection() const { return fdirection; }
0088   inline void SetPosition(G4ThreeVector position) { fposition = position; }
0089   inline G4ThreeVector GetPosition() const { return fposition; }
0090   inline void SetTime(G4double time) { ftime = time; }
0091   inline G4double GetTime() const { return ftime; }
0092   inline void SetPid(unsigned pid) { fpid = pid; }
0093   inline unsigned GetPid() const { return fpid; }
0094   inline void SetId(unsigned id) { fid = id; }
0095   inline unsigned GetId() const { return fid; }
0096 
0097  private:
0098   unsigned int fid{ 0 };
0099   unsigned int fpid{ 0 };
0100   G4double fwavelength{ 0 };
0101   G4double ftime{ 0 };
0102   G4ThreeVector fposition{ 0, 0, 0 };
0103   G4ThreeVector fdirection{ 0, 0, 0 };
0104   G4ThreeVector fpolarization{ 0, 0, 0 };
0105 };
0106 
0107 using PhotonHitsCollection = G4THitsCollection<PhotonHit>;
0108 extern G4ThreadLocal G4Allocator<PhotonHit>* PhotonHitAllocator;
0109 
0110 inline void* PhotonHit::operator new(size_t)
0111 {
0112   if(!PhotonHitAllocator)
0113   {
0114     PhotonHitAllocator = new G4Allocator<PhotonHit>;
0115   }
0116   return (void*) PhotonHitAllocator->MallocSingle();
0117 }
0118 
0119 inline void PhotonHit::operator delete(void* aHit)
0120 {
0121   PhotonHitAllocator->FreeSingle((PhotonHit*) aHit);
0122 }