14 #include "G4EventManager.hh"
16 #include "G4LogicalVolumeStore.hh"
17 #include "G4LogicalVolume.hh"
21 #include "G4SystemOfUnits.hh"
42 <<
" (History), " <<
doFineCalo_ <<
" (Special Calorimeter)";
54 for (
unsigned int i = 0;
i < csp->
levels_.size();
i++)
66 <<
" entries for fineCalorimeterNames:";
70 <<
" entries for fineCalorimeterLevels:";
71 for (
unsigned int i = 0;
i < csp->
fLevels_.size();
i++)
77 <<
" does not match with " << csp->
neighbours_.size() <<
" ==> illegal ";
79 <<
"Calorimeter array size does not match with size of neighbours\n";
82 const G4LogicalVolumeStore* lvs = G4LogicalVolumeStore::GetInstance();
83 std::vector<G4LogicalVolume*>::const_iterator lvcite;
86 G4LogicalVolume* lv =
nullptr;
88 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) {
89 if ((*lvcite)->GetName() ==
name) {
101 <<
" too few compaerd to " << istart + csp->
neighbours_[
i]
102 <<
" requested ==> illegal ";
104 <<
"InsideNames array size does not match with list of neighbours\n";
106 std::vector<std::string> inside;
107 std::vector<G4LogicalVolume*> insideLV;
108 std::vector<int> insideLevels;
112 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) {
113 if ((*lvcite)->GetName() ==
name) {
118 inside.push_back(
name);
119 insideLV.push_back(lv);
131 G4LogicalVolume* lv =
nullptr;
133 for (lvcite = lvs->begin(); lvcite != lvs->end(); lvcite++) {
134 if ((*lvcite)->GetName() ==
name) {
151 edm::LogError(
"HcalSim") <<
"CaloTrkProcessing: Cannot find CaloSimulationParameters";
152 throw cms::Exception(
"Unknown",
"CaloSD") <<
"Cannot find CaloSimulationParameters\n";
179 G4Track* theTrack = aStep->GetTrack();
180 int id = theTrack->GetTrackID();
182 TrackInformation* trkInfo = dynamic_cast<TrackInformation*>(theTrack->GetUserInformation());
184 if (trkInfo ==
nullptr) {
185 edm::LogError(
"CaloSim") <<
"CaloTrkProcessing: No trk info !!!! abort ";
186 throw cms::Exception(
"Unknown",
"CaloTrkProcessing") <<
"cannot get trkInfo for Track " <<
id <<
"\n";
192 edm::LogVerbatim(
"CaloSim") <<
"CaloTrkProcessing set IDonCaloSurface to " <<
id <<
" at step Number "
193 << theTrack->GetCurrentStepNumber();
195 trkInfo->
setIDonCaloSurface(
id, 0, 0, theTrack->GetDefinition()->GetPDGEncoding(), theTrack->GetMomentum().mag());
206 edm::LogVerbatim(
"CaloSim") <<
"CaloTrkProcessing Entered for " <<
id <<
" at stepNumber "
207 << theTrack->GetCurrentStepNumber() <<
" IDonCaloSur.. "
212 G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
213 const G4VTouchable* post_touch = postStepPoint->GetTouchable();
222 G4StepPoint* postStepPoint = aStep->GetPostStepPoint();
223 const G4VTouchable* post_touch = postStepPoint->GetTouchable();
226 G4StepPoint* preStepPoint = aStep->GetPreStepPoint();
227 const G4VTouchable* pre_touch = preStepPoint->GetTouchable();
229 if (inside >= 0 || (theTrack->GetCurrentStepNumber() == 1)) {
231 id, ical, inside, theTrack->GetDefinition()->GetPDGEncoding(), theTrack->GetMomentum().mag());
237 edm::LogVerbatim(
"CaloSim") <<
"CaloTrkProcessing: set ID on Calo " << ical <<
" surface (Inside " << inside
238 <<
") to " <<
id <<
" of a Track with Kinetic Energy "
239 << theTrack->GetKineticEnergy() /
CLHEP::MeV <<
" MeV";
246 const G4VTouchable* touch = aStep->GetPreStepPoint()->GetTouchable();
248 int pdg = aStep->GetTrack()->GetDefinition()->GetPDGEncoding();
250 if (aStep->GetTrack()->GetKineticEnergy() /
CLHEP::MeV >
cut) {
255 edm::LogVerbatim(
"CaloSim") <<
"CaloTrkProcessing: the track " << aStep->GetTrack()->GetTrackID()
256 <<
" with PDGID " <<
pdg <<
" and kinetic energy "
257 << aStep->GetTrack()->GetKineticEnergy() /
CLHEP::MeV <<
" is tested against " <<
cut
258 <<
" to be put in history";
266 G4LogicalVolume* lv =
nullptr;
267 for (
unsigned int it = 0; it <
detectors.size(); it++) {
270 lv =
detLV(touch, lastLevel);
274 name1 = lv->GetName();
275 edm::LogVerbatim(
"CaloSim") <<
"CaloTrkProcessing: volume " << name1 <<
" at Level " << lastLevel;
295 G4LogicalVolume* lv =
nullptr;
304 for (
int it1 =
id1; it1 <
id2; it1++) {
306 for (
unsigned int it2 = 0; it2 <
detectors_[it1].fromDets.size(); it2++) {
307 if (lastLevel !=
detectors_[it1].fromLevels[it2]) {
309 lv =
detLV(touch, lastLevel);
313 name1 = lv->GetName();
314 edm::LogVerbatim(
"CaloSim") <<
"CaloTrkProcessing: volume " << name1 <<
" at Level " << lastLevel;
331 lv =
detLV(touch, lastLevel);
335 name1 = lv->GetName();
336 edm::LogVerbatim(
"CaloSim") <<
"CaloTrkProcessing: volume " << name1 <<
" at Level " << lastLevel;
357 return ((touch->GetHistoryDepth()) + 1);
363 G4LogicalVolume* lv =
nullptr;
365 int level = ((touch->GetHistoryDepth()) + 1);
368 lv = touch->GetVolume(
ii)->GetLogicalVolume();
381 G4VPhysicalVolume*
pv = touch->GetVolume(
i);
386 copyno[
ii] = touch->GetReplicaNumber(
i);