Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[12_4_X] Fixed MC truth data on particle transfer from tracker to calorimeter #38717

Merged
merged 1 commit into from Jul 15, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
6 changes: 0 additions & 6 deletions SimG4Core/Application/interface/SteppingAction.h
Expand Up @@ -43,7 +43,6 @@ class SteppingAction : public G4UserSteppingAction {

inline bool isInsideDeadRegion(const G4Region* reg) const;
inline bool isOutOfTimeWindow(const G4Region* reg, const double& time) const;
inline bool isThisVolume(const G4VTouchable* touch, const G4VPhysicalVolume* pv) const;

bool isLowEnergy(const G4LogicalVolume*, const G4Track*) const;
void PrintKilledTrack(const G4Track*, const TrackStatus&) const;
Expand Down Expand Up @@ -99,9 +98,4 @@ inline bool SteppingAction::isOutOfTimeWindow(const G4Region* reg, const double&
return (time > tofM);
}

inline bool SteppingAction::isThisVolume(const G4VTouchable* touch, const G4VPhysicalVolume* pv) const {
int level = (touch->GetHistoryDepth()) + 1;
return (level >= 3) ? (touch->GetVolume(level - 3) == pv) : false;
}

#endif
17 changes: 8 additions & 9 deletions SimG4Core/Application/src/SteppingAction.cc
@@ -1,4 +1,3 @@

#include "SimG4Core/Application/interface/SteppingAction.h"
#include "SimG4Core/Application/interface/EventAction.h"
#include "SimG4Core/Notification/interface/CMSSteppingVerbose.h"
Expand Down Expand Up @@ -174,13 +173,13 @@ void SteppingAction::UserSteppingAction(const G4Step* aStep) {
// check transition tracker/calo
bool isKilled = false;
if (sAlive == tstat || sVeryForward == tstat) {
if (isThisVolume(preStep->GetTouchable(), tracker) && isThisVolume(postStep->GetTouchable(), calo)) {
math::XYZVectorD pos((preStep->GetPosition()).x(), (preStep->GetPosition()).y(), (preStep->GetPosition()).z());
if (preStep->GetPhysicalVolume() == tracker && postStep->GetPhysicalVolume() == calo) {
math::XYZVectorD pos((postStep->GetPosition()).x(), (postStep->GetPosition()).y(), (postStep->GetPosition()).z());

math::XYZTLorentzVectorD mom((preStep->GetMomentum()).x(),
(preStep->GetMomentum()).y(),
(preStep->GetMomentum()).z(),
preStep->GetTotalEnergy());
math::XYZTLorentzVectorD mom((postStep->GetMomentum()).x(),
(postStep->GetMomentum()).y(),
(postStep->GetMomentum()).z(),
postStep->GetTotalEnergy());

uint32_t id = theTrack->GetTrackID();

Expand Down Expand Up @@ -220,9 +219,9 @@ bool SteppingAction::initPointer() {
const G4PhysicalVolumeStore* pvs = G4PhysicalVolumeStore::GetInstance();
for (auto const& pvcite : *pvs) {
const G4String& pvname = pvcite->GetName();
if (pvname == "Tracker")
if (pvname == "Tracker" || pvname == "tracker:Tracker_1")
tracker = pvcite;
else if (pvname == "CALO")
else if (pvname == "CALO" || pvname == "caloBase:CALO_1")
calo = pvcite;

if (tracker && calo)
Expand Down