Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2026-06-10 07:53:07

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