Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-03-28 07:51:05

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 Par01CalorimeterSD.cc
0027 /// \brief Implementation of the Par01CalorimeterSD class
0028 
0029 #include "Par01CalorimeterSD.hh"
0030 
0031 #include "Par01CalorimeterHit.hh"
0032 
0033 #include "G4LogicalVolume.hh"
0034 #include "G4ParticleDefinition.hh"
0035 #include "G4SDManager.hh"
0036 #include "G4Track.hh"
0037 #include "G4VPhysicalVolume.hh"
0038 #include "G4ios.hh"
0039 
0040 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0041 
0042 Par01CalorimeterSD::Par01CalorimeterSD(G4String name, G4int nCells, G4String colName)
0043   : G4VSensitiveDetector(name), fNumberOfCells(nCells), fHCID(-1)
0044 {
0045   G4String HCname;
0046   collectionName.insert(HCname = colName);
0047   fCellID = new G4int[fNumberOfCells];
0048 }
0049 
0050 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0051 
0052 Par01CalorimeterSD::~Par01CalorimeterSD()
0053 {
0054   delete[] fCellID;
0055 }
0056 
0057 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0058 
0059 void Par01CalorimeterSD::Initialize(G4HCofThisEvent*)
0060 {
0061   fCalCollection = new Par01CalorimeterHitsCollection(SensitiveDetectorName, collectionName[0]);
0062   for (G4int j = 0; j < fNumberOfCells; j++) {
0063     fCellID[j] = -1;
0064   }
0065 }
0066 
0067 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0068 
0069 G4bool Par01CalorimeterSD::ProcessHits(G4Step* aStep, G4TouchableHistory*)
0070 {
0071   G4double edep = aStep->GetTotalEnergyDeposit();
0072   if (edep <= 0.) return false;
0073 
0074   auto hist = (G4TouchableHistory*)(aStep->GetPreStepPoint()->GetTouchable());
0075   const G4VPhysicalVolume* physVol = hist->GetVolume();
0076   G4int copyID = hist->GetReplicaNumber();
0077 
0078   if (fCellID[copyID] == -1) {
0079     Par01CalorimeterHit* calHit = new Par01CalorimeterHit(physVol->GetLogicalVolume());
0080     calHit->SetEdep(edep);
0081     G4AffineTransform aTrans = hist->GetHistory()->GetTopTransform();
0082     aTrans.Invert();
0083     calHit->SetPos(aTrans.NetTranslation());
0084     calHit->SetRot(aTrans.NetRotation());
0085     G4int icell = fCalCollection->insert(calHit);
0086     fCellID[copyID] = icell - 1;
0087     if (verboseLevel > 0) {
0088       G4cout << " New Calorimeter Hit on CellID " << copyID << G4endl;
0089     }
0090   }
0091   else {
0092     (*fCalCollection)[fCellID[copyID]]->AddEdep(edep);
0093     if (verboseLevel > 0) {
0094       G4cout << " Energy added to CellID " << copyID << G4endl;
0095     }
0096   }
0097 
0098   return true;
0099 }
0100 
0101 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0102 
0103 void Par01CalorimeterSD::EndOfEvent(G4HCofThisEvent* HCE)
0104 {
0105   if (fHCID < 0) {
0106     fHCID = G4SDManager::GetSDMpointer()->GetCollectionID(collectionName[0]);
0107   }
0108   HCE->AddHitsCollection(fHCID, fCalCollection);
0109 }
0110 
0111 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0112 
0113 void Par01CalorimeterSD::clear() {}
0114 
0115 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0116 
0117 void Par01CalorimeterSD::DrawAll() {}
0118 
0119 //....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......
0120 
0121 void Par01CalorimeterSD::PrintAll() {}