Back to home page

EIC code displayed by LXR

 
 

    


File indexing completed on 2025-04-10 08:05:40

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