Back to home page

EIC code displayed by LXR

 
 

    


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

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 #ifndef SIPMHIT_HHinline
0028 #define SIPMHIT_HHinline
0029 
0030 #include "G4THitsCollection.hh"
0031 #include "G4VHit.hh"
0032 #include "G4Types.hh"
0033 #include "G4String.hh"
0034 
0035 #include <vector>
0036 
0037 /**
0038  * @brief SiPM hit
0039  *
0040  * Stores information of energy deposited in the SiPM.
0041  *
0042  * Hits can be digitised, to take into account the time window for the deposits
0043  * as well as to set the time information based on the energy threshold.
0044  * By default no time window is used (all energy deposits are counted), as well
0045  * as no energy threshold is used (time of the first energy deposit, however
0046  * small, is counted as hit time).
0047  *
0048  */
0049 
0050 class SiPMHit : public G4VHit {
0051 public:
0052   ///   Constructor
0053   /// @param[in] aName Name of the pixel volume
0054   /// @param[in] aCopyNoSensor ID of the sensor
0055   /// @param[in] aCopyNoCell ID of the cell
0056   SiPMHit(G4String aName, G4int aCopyNoSensor, G4int aCopyNoCell);
0057   ~SiPMHit(){};
0058   /// Get hit ID calculated as 1000 * sensorID + cellID
0059   G4int ID() { return 1000 * fCopyNumSensor + fCopyNumCell; }
0060   /// Add non-zero energy deposit to vector of deposits
0061   /// @param[in] aEnergy Deposited energy
0062   /// @param[in] aTime Time of deposit
0063   inline void AddEdep(const G4double aEnergy, const G4double aTime) {
0064     if (aEnergy > 0)
0065       fEdep.push_back(std::make_pair(aEnergy, aTime));
0066   }
0067   /// Add non-zero non-ionizing energy deposit to vector of deposits
0068   /// @param[in] aEnergy Deposited energy
0069   /// @param[in] aTime Time of deposit
0070   inline void AddEdepNonIonizing(const G4double aEnergy, const G4double aTime) {
0071     if (aEnergy > 0)
0072       fEdepNonIonizing.push_back(std::make_pair(aEnergy, aTime));
0073   }
0074   /// Digitise hit
0075   /// Calculate time of hit as global time of energy deposit which added
0076   /// to hit energy exceeds the energy threshold. Take into account only
0077   /// deposits with global time within the timeWindow.
0078   /// @param[in] timeWindow Maximal global time for deposit, caounted from
0079   /// the time of the first deposit
0080   /// @param[in] toaThreshold Energy threshold, first deposit that adds to
0081   /// the hit energy and exceeds the threshold is counted as time of
0082   /// arrival.
0083   void Digitise(const G4double timeWindow, const G4double toaThreshold);
0084   /// Set hit position
0085   /// @param[in] x X position
0086   /// @param[in] y Y position
0087   /// @param[in] z Z position
0088   inline void SetPosition(G4double x, G4double y, G4double z) {
0089     fPosX = x;
0090     fPosY = y;
0091     fPosZ = z;
0092   }
0093   /// Get hit X position
0094   inline G4double GetX() const { return fPosX; }
0095   /// Get hit Y position
0096   inline G4double GetY() const { return fPosY; }
0097   /// Get hit Z position
0098   inline G4double GetZ() const { return fPosZ; }
0099   /// Check if hit is valid
0100   inline G4bool isValidHit() const { return fIsValidHit; }
0101   /// Get hit energy
0102   inline G4double GetEdep() const { return fEdepDigi; }
0103   /// Get hit non-ionizing energy
0104   inline G4double GetEdepNonIonizing() const { return fEdepNonIonizingDigi; }
0105   /// Get time of arrival
0106   inline G4double GetTOA() const { return fTimeOfArrival; }
0107 
0108 private:
0109   ///   Name of the logical volume
0110   G4String fVolumeName = "";
0111   /// ID of the sensor
0112   G4int fCopyNumCell = -1;
0113   /// ID of the cell
0114   G4int fCopyNumSensor = -1;
0115   /// Position along x axis
0116   G4double fPosX = -1;
0117   /// Position along y axis
0118   G4double fPosY = -1;
0119   /// Position along z axis
0120   G4double fPosZ = -1;
0121   /// Vector of energy deposits (and their global time)
0122   std::vector<std::pair<G4double, G4double>> fEdep;
0123   /// Vector of non-ionizing energy deposits (and their global time)
0124   std::vector<std::pair<G4double, G4double>> fEdepNonIonizing;
0125   /// Flag indicating if hit is valid (digitised and with non-zero energy)
0126   G4bool fIsValidHit = false;
0127   /// Energy of the digitised hit
0128   G4double fEdepDigi = -1;
0129   /// Non-ionizing energy of the digitised hit
0130   G4double fEdepNonIonizingDigi = -1;
0131   /// Time of arrival of the digitised hit
0132   G4double fTimeOfArrival = -1;
0133 };
0134 
0135 typedef G4THitsCollection<SiPMHit> SiPMHitCollection;
0136 
0137 #endif /* SIPMHIT_HH */