Back to home page

EIC code displayed by LXR

 
 

    


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

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 field/field02/src/F02CalorimeterSD.cc
0027 /// \brief Implementation of the F02CalorimeterSD class
0028 //
0029 //
0030 //
0031 //
0032 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0033 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0034 
0035 #include "F02CalorimeterSD.hh"
0036 
0037 #include "F02CalorHit.hh"
0038 #include "F02DetectorConstruction.hh"
0039 
0040 #include "G4SDManager.hh"
0041 #include "G4Step.hh"
0042 #include "G4TouchableHistory.hh"
0043 #include "G4VPhysicalVolume.hh"
0044 #include "G4VTouchable.hh"
0045 
0046 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0047 
0048 F02CalorimeterSD::F02CalorimeterSD(G4String name, F02DetectorConstruction* det)
0049   : G4VSensitiveDetector(name), fDetector(det), fHitID(new G4int[500])
0050 {
0051   collectionName.insert("CalCollection");
0052 }
0053 
0054 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0055 
0056 F02CalorimeterSD::~F02CalorimeterSD()
0057 {
0058   delete[] fHitID;
0059 }
0060 
0061 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0062 
0063 void F02CalorimeterSD::Initialize(G4HCofThisEvent*)
0064 {
0065   fCalCollection = new F02CalorHitsCollection(SensitiveDetectorName, collectionName[0]);
0066   for (G4int j = 0; j < 1; j++) {
0067     fHitID[j] = -1;
0068   };
0069 }
0070 
0071 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0072 
0073 G4bool F02CalorimeterSD::ProcessHits(G4Step* step, G4TouchableHistory*)
0074 {
0075   G4double edep = step->GetTotalEnergyDeposit();
0076   G4double stepl = 0.;
0077 
0078   stepl = step->GetStepLength();
0079 
0080   if ((edep == 0.) && (stepl == 0.)) return false;
0081 
0082   auto theTouchable = (G4TouchableHistory*)(step->GetPreStepPoint()->GetTouchable());
0083 
0084   G4VPhysicalVolume* physVol = theTouchable->GetVolume();
0085 
0086   G4int number = 0;
0087   if (fHitID[number] == -1) {
0088     auto calHit = new F02CalorHit();
0089     if (physVol == fDetector->GetAbsorber()) calHit->AddAbs(edep, stepl);
0090     fHitID[number] = fCalCollection->insert(calHit) - 1;
0091     if (verboseLevel > 0) G4cout << " New Calorimeter Hit on F02: " << number << G4endl;
0092   }
0093   else {
0094     if (physVol == fDetector->GetAbsorber()) (*fCalCollection)[fHitID[number]]->AddAbs(edep, stepl);
0095     if (verboseLevel > 0) G4cout << " Energy added to F02: " << number << G4endl;
0096   }
0097 
0098   return true;
0099 }
0100 
0101 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0102 
0103 void F02CalorimeterSD::EndOfEvent(G4HCofThisEvent* hce)
0104 {
0105   static G4int hcID = -1;
0106   if (hcID < 0) {
0107     hcID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
0108   }
0109   hce->AddHitsCollection(hcID, fCalCollection);
0110 }
0111 
0112 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......