Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-02-23 09:21:08

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