Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-10 08:05:40

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/HepMCEx01/src/ExN04MuonSD.cc
0027 /// \brief Implementation of the ExN04MuonSD class
0028 //
0029 //
0030 
0031 #include "ExN04MuonSD.hh"
0032 
0033 #include "ExN04MuonHit.hh"
0034 
0035 #include "G4HCofThisEvent.hh"
0036 #include "G4Step.hh"
0037 #include "G4SystemOfUnits.hh"
0038 #include "G4TouchableHistory.hh"
0039 #include "G4Track.hh"
0040 #include "G4ios.hh"
0041 
0042 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0043 ExN04MuonSD::ExN04MuonSD(G4String name)
0044   : G4VSensitiveDetector(name), fMuonCollection(NULL), fPositionResolution(5 * cm)
0045 {
0046   G4String HCname;
0047   collectionName.insert(HCname = "muonCollection");
0048 }
0049 
0050 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0051 ExN04MuonSD::~ExN04MuonSD()
0052 {
0053   ;
0054 }
0055 
0056 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0057 void ExN04MuonSD::Initialize(G4HCofThisEvent* HCE)
0058 {
0059   static int HCID = -1;
0060   fMuonCollection = new ExN04MuonHitsCollection(SensitiveDetectorName, collectionName[0]);
0061   if (HCID < 0) {
0062     HCID = GetCollectionID(0);
0063   }
0064   HCE->AddHitsCollection(HCID, fMuonCollection);
0065 }
0066 
0067 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0068 G4bool ExN04MuonSD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
0069 {
0070   G4double edep = aStep->GetTotalEnergyDeposit();
0071 
0072   if (edep == 0.) return true;
0073 
0074   ExN04MuonHit* aHit;
0075   int nHit = fMuonCollection->entries();
0076   G4ThreeVector hitpos = aStep->GetPreStepPoint()->GetPosition();
0077   for (int i = 0; i < nHit; i++) {
0078     aHit = (*fMuonCollection)[i];
0079     G4ThreeVector pos = aHit->GetPos();
0080     G4double dist2 =
0081       sqr(pos.x() - hitpos.x()) + sqr(pos.y() - hitpos.y()) + sqr(pos.z() - hitpos.z());
0082     if (dist2 <= sqr(fPositionResolution)) aHit->AddEdep(edep);
0083     return true;
0084   }
0085 
0086   aHit = new ExN04MuonHit();
0087   aHit->SetEdep(edep);
0088   aHit->SetPos(aStep->GetPreStepPoint()->GetPosition());
0089   fMuonCollection->insert(aHit);
0090 
0091   return true;
0092 }
0093 
0094 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0095 void ExN04MuonSD::EndOfEvent(G4HCofThisEvent*) {}
0096 
0097 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0098 void ExN04MuonSD::clear() {}
0099 
0100 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0101 void ExN04MuonSD::DrawAll() {}
0102 
0103 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0104 void ExN04MuonSD::PrintAll() {}