Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-01-31 09:22:53

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