Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-17 08:30:42

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 HodoscopeHit.hh
0027 /// \brief Definition of the B5::HodoscopeHit class
0028 
0029 #ifndef B5HodoscopeHit_h
0030 #define B5HodoscopeHit_h 1
0031 
0032 #include "G4VHit.hh"
0033 
0034 #include "G4Allocator.hh"
0035 #include "G4RotationMatrix.hh"
0036 #include "G4THitsCollection.hh"
0037 #include "G4Threading.hh"
0038 #include "G4ThreeVector.hh"
0039 #include "globals.hh"
0040 
0041 #include <map>
0042 #include <vector>
0043 
0044 class G4AttDef;
0045 class G4AttValue;
0046 class G4LogicalVolume;
0047 
0048 namespace B5
0049 {
0050 
0051 /// Hodoscope hit
0052 ///
0053 /// It records:
0054 /// - the strip ID
0055 /// - the particle time
0056 /// - the strip logical volume, its position and rotation
0057 
0058 class HodoscopeHit : public G4VHit
0059 {
0060   public:
0061     HodoscopeHit(G4int i, G4double t);
0062     HodoscopeHit(const HodoscopeHit& right) = default;
0063     ~HodoscopeHit() override = default;
0064 
0065     HodoscopeHit& operator=(const HodoscopeHit& right) = default;
0066     G4bool operator==(const HodoscopeHit& right) const;
0067 
0068     inline void* operator new(size_t);
0069     inline void operator delete(void* aHit);
0070 
0071     void Draw() override;
0072     const std::map<G4String, G4AttDef>* GetAttDefs() const override;
0073     std::vector<G4AttValue>* CreateAttValues() const override;
0074     void Print() override;
0075 
0076     G4int GetID() const { return fId; }
0077 
0078     void SetTime(G4double val) { fTime = val; }
0079     G4double GetTime() const { return fTime; }
0080 
0081     void SetPos(G4ThreeVector xyz) { fPos = xyz; }
0082     G4ThreeVector GetPos() const { return fPos; }
0083 
0084     void SetRot(G4RotationMatrix rmat) { fRot = rmat; }
0085     G4RotationMatrix GetRot() const { return fRot; }
0086 
0087     void SetLogV(G4LogicalVolume* val) { fPLogV = val; }
0088     const G4LogicalVolume* GetLogV() const { return fPLogV; }
0089 
0090   private:
0091     G4int fId = -1;
0092     G4double fTime = 0.;
0093     G4ThreeVector fPos;
0094     G4RotationMatrix fRot;
0095     const G4LogicalVolume* fPLogV = nullptr;
0096 };
0097 
0098 using HodoscopeHitsCollection = G4THitsCollection<HodoscopeHit>;
0099 
0100 extern G4ThreadLocal G4Allocator<HodoscopeHit>* HodoscopeHitAllocator;
0101 
0102 inline void* HodoscopeHit::operator new(size_t)
0103 {
0104   if (!HodoscopeHitAllocator) {
0105     HodoscopeHitAllocator = new G4Allocator<HodoscopeHit>;
0106   }
0107   return (void*)HodoscopeHitAllocator->MallocSingle();
0108 }
0109 
0110 inline void HodoscopeHit::operator delete(void* aHit)
0111 {
0112   HodoscopeHitAllocator->FreeSingle((HodoscopeHit*)aHit);
0113 }
0114 
0115 }  // namespace B5
0116 
0117 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0118 
0119 #endif