Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-05-04 08:06:13

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 DriftChamberHit.hh
0027 /// \brief Definition of the B5::DriftChamberHit class
0028 
0029 #ifndef B5DriftChamberHit_h
0030 #define B5DriftChamberHit_h 1
0031 
0032 #include "G4VHit.hh"
0033 
0034 #include "G4Allocator.hh"
0035 #include "G4THitsCollection.hh"
0036 #include "G4Threading.hh"
0037 #include "G4ThreeVector.hh"
0038 #include "globals.hh"
0039 
0040 #include <map>
0041 #include <vector>
0042 
0043 class G4AttDef;
0044 class G4AttValue;
0045 
0046 namespace B5
0047 {
0048 
0049 /// Drift chamber hit
0050 ///
0051 /// It records:
0052 /// - the layer ID
0053 /// - the particle time
0054 /// - the particle local and global positions
0055 
0056 class DriftChamberHit : public G4VHit
0057 {
0058   public:
0059     DriftChamberHit() = default;
0060     DriftChamberHit(G4int layerID);
0061     DriftChamberHit(const DriftChamberHit& right) = default;
0062     ~DriftChamberHit() override = default;
0063 
0064     DriftChamberHit& operator=(const DriftChamberHit& right) = default;
0065     G4bool operator==(const DriftChamberHit& right) const;
0066 
0067     inline void* operator new(size_t);
0068     inline void operator delete(void* aHit);
0069 
0070     void Draw() override;
0071     const std::map<G4String, G4AttDef>* GetAttDefs() const override;
0072     std::vector<G4AttValue>* CreateAttValues() const override;
0073     void Print() override;
0074 
0075     void SetLayerID(G4int z) { fLayerID = z; }
0076     G4int GetLayerID() const { return fLayerID; }
0077 
0078     void SetTime(G4double t) { fTime = t; }
0079     G4double GetTime() const { return fTime; }
0080 
0081     void SetLocalPos(G4ThreeVector xyz) { fLocalPos = xyz; }
0082     G4ThreeVector GetLocalPos() const { return fLocalPos; }
0083 
0084     void SetWorldPos(G4ThreeVector xyz) { fWorldPos = xyz; }
0085     G4ThreeVector GetWorldPos() const { return fWorldPos; }
0086 
0087   private:
0088     G4int fLayerID = -1;
0089     G4double fTime = 0.;
0090     G4ThreeVector fLocalPos;
0091     G4ThreeVector fWorldPos;
0092 };
0093 
0094 using DriftChamberHitsCollection = G4THitsCollection<DriftChamberHit>;
0095 
0096 extern G4ThreadLocal G4Allocator<DriftChamberHit>* DriftChamberHitAllocator;
0097 
0098 inline void* DriftChamberHit::operator new(size_t)
0099 {
0100   if (!DriftChamberHitAllocator) {
0101     DriftChamberHitAllocator = new G4Allocator<DriftChamberHit>;
0102   }
0103   return (void*)DriftChamberHitAllocator->MallocSingle();
0104 }
0105 
0106 inline void DriftChamberHit::operator delete(void* aHit)
0107 {
0108   DriftChamberHitAllocator->FreeSingle((DriftChamberHit*)aHit);
0109 }
0110 
0111 }  // namespace B5
0112 
0113 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0114 
0115 #endif