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