Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-04-29 07:38:43

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