|
|
|||
File indexing completed on 2026-06-18 07:53:14
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 TrackerSD.cc 0027 /// \brief Implementation of the B2::TrackerSD class 0028 0029 #include "TrackerSD.hh" 0030 0031 #include "G4HCofThisEvent.hh" 0032 #include "G4SDManager.hh" 0033 #include "G4Step.hh" 0034 0035 namespace B2 0036 { 0037 0038 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0039 0040 TrackerSD::TrackerSD(const G4String& name, const G4String& hitsCollectionName) 0041 : G4VSensitiveDetector(name) 0042 { 0043 collectionName.insert(hitsCollectionName); 0044 } 0045 0046 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0047 0048 void TrackerSD::Initialize(G4HCofThisEvent* hce) 0049 { 0050 // Create hits collection 0051 0052 fHitsCollection = new TrackerHitsCollection(SensitiveDetectorName, collectionName[0]); 0053 0054 // Add this collection in hce 0055 0056 G4int hcID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]); 0057 hce->AddHitsCollection(hcID, fHitsCollection); 0058 } 0059 0060 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0061 0062 G4bool TrackerSD::ProcessHits(G4Step* step, G4TouchableHistory*) 0063 { 0064 // energy deposit 0065 G4double edep = step->GetTotalEnergyDeposit(); 0066 0067 if (edep == 0.) return false; 0068 0069 auto newHit = new TrackerHit(); 0070 0071 newHit->SetTrackID(step->GetTrack()->GetTrackID()); 0072 newHit->SetChamberNb(step->GetPreStepPoint()->GetTouchableHandle()->GetCopyNumber()); 0073 newHit->SetEdep(edep); 0074 newHit->SetPos(step->GetPostStepPoint()->GetPosition()); 0075 0076 fHitsCollection->insert(newHit); 0077 0078 // newHit->Print(); 0079 0080 return true; 0081 } 0082 0083 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0084 0085 void TrackerSD::EndOfEvent(G4HCofThisEvent*) 0086 { 0087 if (verboseLevel > 1) { 0088 std::size_t nofHits = fHitsCollection->entries(); 0089 G4cout << G4endl << "-------->Hits Collection: in this event they are " << nofHits 0090 << " hits in the tracker chambers: " << G4endl; 0091 for (std::size_t i = 0; i < nofHits; i++) 0092 (*fHitsCollection)[i]->Print(); 0093 } 0094 } 0095 0096 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo...... 0097 0098 } // namespace B2
| [ Source navigation ] | [ Diff markup ] | [ Identifier search ] | [ general search ] |
|
This page was automatically generated by the 2.3.7 LXR engine. The LXR team |
|