Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-09-14 08:27:50

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 H02MuonSD.cc
0027 /// \brief Implementation of the H02MuonSD class
0028 
0029 #include "H02MuonSD.hh"
0030 
0031 #include "H02MuonHit.hh"
0032 
0033 #include "G4HCofThisEvent.hh"
0034 #include "G4Step.hh"
0035 #include "G4TouchableHistory.hh"
0036 #include "G4Track.hh"
0037 #include "G4VPhysicalVolume.hh"
0038 
0039 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0040 H02MuonSD::H02MuonSD(G4String name) : G4VSensitiveDetector(name), fHitCollection(0)
0041 {
0042   G4String HCname;
0043   collectionName.insert("muonHit");
0044 }
0045 
0046 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0047 H02MuonSD::~H02MuonSD() {}
0048 
0049 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0050 void H02MuonSD::Initialize(G4HCofThisEvent* HCE)
0051 {
0052   static int HCID = -1;
0053   fHitCollection = new H02MuonHitsCollection(SensitiveDetectorName, collectionName[0]);
0054   if (HCID < 0) HCID = GetCollectionID(0);
0055   HCE->AddHitsCollection(HCID, fHitCollection);
0056 }
0057 
0058 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0059 G4bool H02MuonSD::ProcessHits(G4Step* astep, G4TouchableHistory*)
0060 {
0061   G4ParticleDefinition* particle = astep->GetTrack()->GetDefinition();
0062   if (particle->GetPDGCharge() == 0.) return false;
0063 
0064   G4StepPoint* prestep = astep->GetPreStepPoint();
0065 
0066   if (prestep->GetStepStatus() != fGeomBoundary) return false;
0067 
0068   G4ThreeVector vmom = prestep->GetMomentum();
0069   G4ThreeVector vpos = prestep->GetPosition();
0070   G4double tof = prestep->GetGlobalTime();
0071 
0072   G4VPhysicalVolume* volume = prestep->GetPhysicalVolume();
0073   G4int id = volume->GetCopyNo();
0074   if (volume->GetName() == "ENDCAP_MUON_PV") id += 10;
0075 
0076   H02MuonHit* aHit = new H02MuonHit(id, particle->GetParticleName(), vmom, vpos, tof);
0077   fHitCollection->insert(aHit);
0078   return true;
0079 }
0080 
0081 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0082 void H02MuonSD::EndOfEvent(G4HCofThisEvent*) {}
0083 
0084 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0085 void H02MuonSD::clear() {}
0086 
0087 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0088 void H02MuonSD::DrawAll() {}
0089 
0090 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0091 void H02MuonSD::PrintAll()
0092 {
0093   G4int nHit = fHitCollection->entries();
0094   G4cout << "------------------------------------------" << G4endl
0095          << "*** Muon System Hit (#hits=" << nHit << ")" << G4endl;
0096   fHitCollection->PrintAllHits();
0097 }