Back to home page

EIC code displayed by LXR

 
 

    


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

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 #include "SiliconPixelHit.hh"
0027 
0028 #include "G4RotationMatrix.hh"
0029 #include "G4SubtractionSolid.hh"
0030 #include "G4Transform3D.hh"
0031 #include "G4VVisManager.hh"
0032 #include "G4VisAttributes.hh"
0033 #include "HGCalTBMaterials.hh"
0034 
0035 #include <cstdlib>
0036 
0037 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0038 
0039 SiliconPixelHit::SiliconPixelHit(G4String aVolumeName, G4int aCopyNumSensor,
0040                                  G4int aCopyNumCell)
0041     : fVolumeName(aVolumeName), fCopyNumCell(aCopyNumCell),
0042       fCopyNumSensor(aCopyNumSensor) {}
0043 
0044 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0045 
0046 void SiliconPixelHit::Digitise(const G4double aTimeWindow,
0047                                const G4double aToaThreshold) {
0048 
0049   // process energy deposits
0050   if (fEdep.empty()) {
0051     fIsValidHit = false;
0052     return;
0053   }
0054 
0055   std::sort(fEdep.begin(), fEdep.end(),
0056             [](const std::pair<G4double, G4double> &left,
0057                const std::pair<G4double, G4double> &right) {
0058               return left.second < right.second; // second = time
0059             });
0060 
0061   G4double firstHitTime = fEdep[0].second;
0062   fEdepDigi = 0;
0063   for (size_t i = 0; i < fEdep.size(); ++i) {
0064     if (aTimeWindow < 0 || fEdep[i].second < firstHitTime + aTimeWindow)
0065       fEdepDigi += fEdep[i].first;
0066     if (fEdepDigi > aToaThreshold) {
0067       if (fTimeOfArrival == -1)
0068         fTimeOfArrival = fEdep[i].second;
0069       fTimeOfArrivalLast = fEdep[i].second;
0070     }
0071   }
0072   fIsValidHit = (fEdepDigi > 0);
0073 
0074   // non ionizing part, does not contribute to TOAs
0075   if (fEdepNonIonizing.empty())
0076     return;
0077 
0078   std::sort(fEdepNonIonizing.begin(), fEdepNonIonizing.end(),
0079             [](const std::pair<G4double, G4double> &left,
0080                const std::pair<G4double, G4double> &right) {
0081               return left.second < right.second; // second = time
0082             });
0083 
0084   fEdepNonIonizingDigi = 0;
0085   for (size_t i = 0; i < fEdepNonIonizing.size(); ++i) {
0086     if (aTimeWindow == -1 ||
0087         fEdepNonIonizing[i].second < firstHitTime + aTimeWindow)
0088       fEdepNonIonizingDigi += fEdepNonIonizing[i].first;
0089   }
0090 }
0091 
0092 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0093 
0094 void SiliconPixelHit::Draw() {
0095   G4VVisManager *pVVisManager = G4VVisManager::GetConcreteInstance();
0096   if (!(fEdepDigi > 0))
0097     return;
0098   if (pVVisManager) {
0099     if (!pVVisManager->FilterHit(*this))
0100       return;
0101     G4Transform3D trans(G4RotationMatrix(),
0102                         G4ThreeVector(fPosX * CLHEP::cm, fPosY * CLHEP::cm, fPosZ * CLHEP::cm));
0103     G4VisAttributes attribs;
0104     auto solid = HexagonSolid("dummy", 0.3 * CLHEP::mm, 0.6496345 * CLHEP::cm);
0105     G4Colour colour(1, 0, 0);
0106     attribs.SetColour(colour);
0107     attribs.SetForceSolid(true);
0108     pVVisManager->Draw(*solid, attribs, trans);
0109   }
0110 }
0111 
0112 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......