Import Geant4 9.5.0 source tree
This commit is contained in:
@@ -0,0 +1,129 @@
|
||||
//
|
||||
// ********************************************************************
|
||||
// * License and Disclaimer *
|
||||
// * *
|
||||
// * The Geant4 software is copyright of the Copyright Holders of *
|
||||
// * the Geant4 Collaboration. It is provided under the terms and *
|
||||
// * conditions of the Geant4 Software License, included in the file *
|
||||
// * LICENSE and available at http://cern.ch/geant4/license . These *
|
||||
// * include a list of copyright holders. *
|
||||
// * *
|
||||
// * Neither the authors of this software system, nor their employing *
|
||||
// * institutes,nor the agencies providing financial support for this *
|
||||
// * work make any representation or warranty, express or implied, *
|
||||
// * regarding this software system or assume any liability for its *
|
||||
// * use. Please see the license in the file LICENSE and URL above *
|
||||
// * for the full disclaimer and the limitation of liability. *
|
||||
// * *
|
||||
// * This code implementation is the result of the scientific and *
|
||||
// * technical work of the GEANT4 collaboration. *
|
||||
// * By using, copying, modifying or distributing the software (or *
|
||||
// * any work based on the software) you agree to acknowledge its *
|
||||
// * use in resulting scientific publications, and indicate your *
|
||||
// * acceptance of all terms of the Geant4 Software license. *
|
||||
// ********************************************************************
|
||||
//
|
||||
// $Id$
|
||||
//
|
||||
/// \file B4cCalorimeterSD.cc
|
||||
/// \brief Implementation of the B4cCalorimeterSD class
|
||||
|
||||
#include "B4cCalorimeterSD.hh"
|
||||
#include "G4HCofThisEvent.hh"
|
||||
#include "G4Step.hh"
|
||||
#include "G4ThreeVector.hh"
|
||||
#include "G4SDManager.hh"
|
||||
#include "G4ios.hh"
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
B4cCalorimeterSD::B4cCalorimeterSD(
|
||||
const G4String& name,
|
||||
const G4String& hitsCollectionName,
|
||||
G4int nofCells)
|
||||
: G4VSensitiveDetector(name),
|
||||
fHitsCollection(0),
|
||||
fNofCells(nofCells)
|
||||
{
|
||||
collectionName.insert(hitsCollectionName);
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
B4cCalorimeterSD::~B4cCalorimeterSD()
|
||||
{
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void B4cCalorimeterSD::Initialize(G4HCofThisEvent* hce)
|
||||
{
|
||||
// Create hits collection
|
||||
fHitsCollection
|
||||
= new B4cCalorHitsCollection(SensitiveDetectorName, collectionName[0]);
|
||||
|
||||
// Add this collection in hce
|
||||
G4int hcID
|
||||
= G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
|
||||
hce->AddHitsCollection( hcID, fHitsCollection );
|
||||
|
||||
// Create hits
|
||||
// fNofCells for cells + one more for total sums
|
||||
for (G4int i=0; i<fNofCells+1; i++ ) {
|
||||
fHitsCollection->insert(new B4cCalorHit());
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
G4bool B4cCalorimeterSD::ProcessHits(G4Step* step,
|
||||
G4TouchableHistory*)
|
||||
{
|
||||
// energy deposit
|
||||
G4double edep = step->GetTotalEnergyDeposit();
|
||||
|
||||
// step length
|
||||
G4double stepLength = 0.;
|
||||
if ( step->GetTrack()->GetDefinition()->GetPDGCharge() != 0. ) {
|
||||
stepLength = step->GetStepLength();
|
||||
}
|
||||
|
||||
if ( edep==0. && stepLength == 0. ) return false;
|
||||
|
||||
G4TouchableHistory* touchable
|
||||
= (G4TouchableHistory*)(step->GetPreStepPoint()->GetTouchable());
|
||||
|
||||
// Get calorimeter cell id
|
||||
G4int layerNumber = touchable->GetReplicaNumber(1);
|
||||
|
||||
// Get hit accounting data for this cell
|
||||
B4cCalorHit* hit = (*fHitsCollection)[layerNumber];
|
||||
if ( ! hit ) {
|
||||
G4cerr << "Cannot access hit " << layerNumber << G4endl;
|
||||
exit(1);
|
||||
}
|
||||
|
||||
// Get hit for total accounting
|
||||
B4cCalorHit* hitTotal
|
||||
= (*fHitsCollection)[fHitsCollection->entries()-1];
|
||||
|
||||
// Add values
|
||||
hit->Add(edep, stepLength);
|
||||
hitTotal->Add(edep, stepLength);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
|
||||
void B4cCalorimeterSD::EndOfEvent(G4HCofThisEvent*)
|
||||
{
|
||||
if ( verboseLevel>1 ) {
|
||||
G4int nofHits = fHitsCollection->entries();
|
||||
G4cout << "\n-------->Hits Collection: in this event they are " << nofHits
|
||||
<< " hits in the tracker chambers: " << G4endl;
|
||||
for ( G4int i=0; i<nofHits; i++ ) (*fHitsCollection)[i]->Print();
|
||||
}
|
||||
}
|
||||
|
||||
//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
|
||||
Reference in New Issue
Block a user