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

MC truth classes renaming #41315

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion SimG4Core/Application/interface/EventAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@

#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "SimG4Core/Notification/interface/G4SimEvent.h"
#include "SimG4Core/Notification/interface/SimTrackManager.h"
#include "SimG4Core/Notification/interface/TrackWithHistory.h"
#include "SimG4Core/Notification/interface/TrackContainer.h"
Expand Down
8 changes: 4 additions & 4 deletions SimG4Core/Application/interface/RunManagerMTWorker.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@

#include "MagneticField/Engine/interface/MagneticField.h"
#include "MagneticField/Records/interface/IdealMagneticFieldRecord.h"
#include "SimG4Core/Notification/interface/G4SimEvent.h"
#include "SimG4Core/Notification/interface/TmpSimEvent.h"

#include <memory>
#include <unordered_map>
Expand Down Expand Up @@ -54,7 +54,7 @@ class RunManagerMTWorker {
void beginRun(const edm::EventSetup&);
void endRun();

G4SimEvent* produce(const edm::Event& inpevt, const edm::EventSetup& es, RunManagerMT& runManagerMaster);
TmpSimEvent* produce(const edm::Event& inpevt, const edm::EventSetup& es, RunManagerMT& runManagerMaster);

void abortEvent();
void abortRun(bool softAbort = false);
Expand All @@ -71,7 +71,7 @@ class RunManagerMTWorker {

void initializeG4(RunManagerMT* runManagerMaster, const edm::EventSetup& es);

inline G4SimEvent* simEvent() { return &m_simEvent; }
inline TmpSimEvent* simEvent() { return &m_simEvent; }
inline int getThreadIndex() const { return m_thread_index; }

private:
Expand Down Expand Up @@ -116,7 +116,7 @@ class RunManagerMTWorker {
TLSData* m_tls{nullptr};

CustomUIsession* m_UIsession{nullptr};
G4SimEvent m_simEvent;
TmpSimEvent m_simEvent;
std::unique_ptr<CMSSimEventManager> m_evtManager;
std::unique_ptr<CMSSteppingVerbose> m_sVerbose;
std::unordered_map<std::string, std::unique_ptr<SensitiveDetectorMakerBase>> m_sdMakers;
Expand Down
4 changes: 2 additions & 2 deletions SimG4Core/Application/interface/SimRunInterface.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ class RunAction;
class EventAction;
class TrackingAction;
class SteppingAction;
class G4SimEvent;
class TmpSimEvent;

class SimRunInterface {
public:
Expand Down Expand Up @@ -40,7 +40,7 @@ class SimRunInterface {

void abortRun(bool softAbort);

G4SimEvent* simEvent();
TmpSimEvent* simEvent();

private:
RunManagerMT* m_runManagerMT;
Expand Down
6 changes: 1 addition & 5 deletions SimG4Core/Application/interface/StackingAction.h
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
#define SimG4Core_StackingAction_H

#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "SimG4Core/Notification/interface/TrackInformationExtractor.h"

#include "G4UserStackingAction.hh"
#include "G4Region.hh"
Expand All @@ -12,7 +11,6 @@
#include <string>
#include <vector>

class NewTrackAction;
class TrackingAction;
class CMSSteppingVerbose;
class G4VProcess;
Expand All @@ -21,7 +19,7 @@ class StackingAction : public G4UserStackingAction {
public:
explicit StackingAction(const TrackingAction*, const edm::ParameterSet& ps, const CMSSteppingVerbose*);

~StackingAction() override;
~StackingAction() override = default;

G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track* aTrack) final;

Expand Down Expand Up @@ -74,8 +72,6 @@ class StackingAction : public G4UserStackingAction {
const TrackingAction* trackAction;
const CMSSteppingVerbose* steppingVerbose;
const G4VProcess* m_Compton{nullptr};
NewTrackAction* newTA;
TrackInformationExtractor extractor;

// Russian roulette regions
const G4Region* regionEcal{nullptr};
Expand Down
8 changes: 4 additions & 4 deletions SimG4Core/Application/plugins/OscarMTProducer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,9 @@
#include "SimG4Core/Application/interface/OscarMTMasterThread.h"
#include "SimG4Core/Application/interface/RunManagerMT.h"
#include "SimG4Core/Application/interface/RunManagerMTWorker.h"
#include "SimG4Core/Notification/interface/G4SimEvent.h"
#include "SimG4Core/Notification/interface/G4SimVertex.h"
#include "SimG4Core/Notification/interface/G4SimTrack.h"
#include "SimG4Core/Notification/interface/TmpSimEvent.h"
#include "SimG4Core/Notification/interface/TmpSimVertex.h"
#include "SimG4Core/Notification/interface/TmpSimTrack.h"

#include "SimG4Core/SensitiveDetector/interface/SensitiveTkDetector.h"
#include "SimG4Core/SensitiveDetector/interface/SensitiveCaloDetector.h"
Expand Down Expand Up @@ -277,7 +277,7 @@ void OscarMTProducer::produce(edm::Event& e, const edm::EventSetup& es) {
auto& sTk = m_runManagerWorker->sensTkDetectors();
auto& sCalo = m_runManagerWorker->sensCaloDetectors();

G4SimEvent* evt = nullptr;
TmpSimEvent* evt = nullptr;
auto token = edm::ServiceRegistry::instance().presentToken();
m_handoff.runAndWait([this, &e, &es, &evt, token, engine]() {
edm::ServiceRegistry::Operate guard{token};
Expand Down
5 changes: 3 additions & 2 deletions SimG4Core/Application/src/EventAction.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
#include "SimG4Core/Application/interface/EventAction.h"
#include "SimG4Core/Application/interface/SimRunInterface.h"
#include "SimG4Core/Notification/interface/G4SimVertex.h"
#include "SimG4Core/Notification/interface/G4SimTrack.h"
#include "SimG4Core/Notification/interface/TmpSimEvent.h"
#include "SimG4Core/Notification/interface/TmpSimVertex.h"
#include "SimG4Core/Notification/interface/TmpSimTrack.h"
#include "SimG4Core/Notification/interface/BeginOfEvent.h"
#include "SimG4Core/Notification/interface/EndOfEvent.h"
#include "SimG4Core/Notification/interface/CMSSteppingVerbose.h"
Expand Down
1 change: 0 additions & 1 deletion SimG4Core/Application/src/RunManagerMT.cc
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@

#include "SimG4Core/Watcher/interface/SimWatcherFactory.h"

#include "SimG4Core/Notification/interface/G4SimEvent.h"
#include "SimG4Core/Notification/interface/SimTrackManager.h"
#include "SimG4Core/Notification/interface/BeginOfJob.h"
#include "SimG4Core/Notification/interface/CurrentG4Track.h"
Expand Down
6 changes: 3 additions & 3 deletions SimG4Core/Application/src/RunManagerMTWorker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -507,9 +507,9 @@ void RunManagerMTWorker::terminateRun() {
edm::LogVerbatim("SimG4CoreApplication") << "RunManagerMTWorker::terminateRun done for thread " << id;
}

G4SimEvent* RunManagerMTWorker::produce(const edm::Event& inpevt,
const edm::EventSetup& es,
RunManagerMT& runManagerMaster) {
TmpSimEvent* RunManagerMTWorker::produce(const edm::Event& inpevt,
const edm::EventSetup& es,
RunManagerMT& runManagerMaster) {
// The initialization and begin/end run is a bit convoluted due to
// - Geant4 deals per-thread
// - OscarMTProducer deals per-stream
Expand Down
6 changes: 3 additions & 3 deletions SimG4Core/Application/src/SimRunInterface.cc
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
#include "SimG4Core/Application/interface/EventAction.h"
#include "SimG4Core/Application/interface/TrackingAction.h"
#include "SimG4Core/Application/interface/SteppingAction.h"
#include "SimG4Core/Notification/interface/G4SimEvent.h"
#include "SimG4Core/Notification/interface/TmpSimEvent.h"

//....oooOO0OOooo........oooOO0OOooo........oooOO0OOooo........oooOO0OOooo......

Expand Down Expand Up @@ -63,8 +63,8 @@ void SimRunInterface::abortRun(bool softAbort) {
}
}

G4SimEvent* SimRunInterface::simEvent() {
G4SimEvent* ptr = nullptr;
TmpSimEvent* SimRunInterface::simEvent() {
TmpSimEvent* ptr = nullptr;
if (m_runManagerMTWorker) {
ptr = m_runManagerMTWorker->simEvent();
}
Expand Down
21 changes: 9 additions & 12 deletions SimG4Core/Application/src/StackingAction.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#include "SimG4Core/Application/interface/StackingAction.h"
#include "SimG4Core/Application/interface/TrackingAction.h"
#include "SimG4Core/Notification/interface/NewTrackAction.h"
#include "SimG4Core/Notification/interface/MCTruthUtil.h"
#include "SimG4Core/Notification/interface/TrackInformation.h"
#include "SimG4Core/Notification/interface/CMSSteppingVerbose.h"

Expand Down Expand Up @@ -76,7 +76,6 @@ StackingAction::StackingAction(const TrackingAction* trka, const edm::ParameterS
}

initPointer();
newTA = new NewTrackAction();

edm::LogVerbatim("SimG4CoreApplication")
<< "StackingAction initiated with"
Expand Down Expand Up @@ -156,8 +155,6 @@ StackingAction::StackingAction(const TrackingAction* trka, const edm::ParameterS
->GetSolid();
}

StackingAction::~StackingAction() { delete newTA; }

G4ClassificationOfNewTrack StackingAction::ClassifyNewTrack(const G4Track* aTrack) {
// G4 interface part
G4ClassificationOfNewTrack classification = fUrgent;
Expand All @@ -184,7 +181,7 @@ G4ClassificationOfNewTrack StackingAction::ClassifyNewTrack(const G4Track* aTrac
} else if (worldSolid->Inside(aTrack->GetPosition()) == kOutside) {
classification = fKill;
} else {
newTA->primary(track);
MCTruthUtil::primary(track);
}
} else {
// secondary
Expand All @@ -203,7 +200,7 @@ G4ClassificationOfNewTrack StackingAction::ClassifyNewTrack(const G4Track* aTrac
classification = fKill;
} else {
const G4Track* mother = trackAction->geant4Track();
newTA->secondary(track, *mother, 0);
MCTruthUtil::secondary(track, *mother, 0);
}

} else if (isItOutOfTimeWindow(reg, time)) {
Expand Down Expand Up @@ -358,7 +355,7 @@ G4ClassificationOfNewTrack StackingAction::ClassifyNewTrack(const G4Track* aTrac
}
}
if (classification != fKill) {
newTA->secondary(track, *mother, flag);
MCTruthUtil::secondary(track, *mother, flag);
}
LogDebug("SimG4CoreApplication")
<< "StackingAction:Classify Track " << aTrack->GetTrackID() << " Parent " << aTrack->GetParentID()
Expand Down Expand Up @@ -453,9 +450,9 @@ bool StackingAction::isThisRegion(const G4Region* reg, std::vector<const G4Regio

int StackingAction::isItPrimaryDecayProductOrConversion(const int stype, const G4Track& mother) const {
int flag = 0;
const TrackInformation& motherInfo(extractor(mother));
auto motherInfo = static_cast<const TrackInformation*>(mother.GetUserInformation());
// Check whether mother is a primary
if (motherInfo.isPrimary()) {
if (motherInfo->isPrimary()) {
if (stype == fDecay) {
flag = 1;
} else if (stype == fGammaConversion) {
Expand All @@ -466,17 +463,17 @@ int StackingAction::isItPrimaryDecayProductOrConversion(const int stype, const G
}

bool StackingAction::rrApplicable(const G4Track* aTrack, const G4Track& mother) const {
const TrackInformation& motherInfo(extractor(mother));
auto motherInfo = static_cast<const TrackInformation*>(mother.GetUserInformation());

// Check whether mother is gamma, e+, e-
const int genID = motherInfo.genParticlePID();
const int genID = motherInfo->genParticlePID();
return (22 != genID && 11 != std::abs(genID));
}

int StackingAction::isItFromPrimary(const G4Track& mother, int flagIn) const {
int flag = flagIn;
if (flag != 1) {
const TrackInformation* ptr = static_cast<TrackInformation*>(mother.GetUserInformation());
auto ptr = static_cast<const TrackInformation*>(mother.GetUserInformation());
if (ptr->isPrimary()) {
flag = 3;
}
Expand Down
1 change: 0 additions & 1 deletion SimG4Core/Application/src/TrackingAction.cc
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
#include "SimG4Core/Application/interface/TrackingAction.h"

#include "SimG4Core/Notification/interface/NewTrackAction.h"
#include "SimG4Core/Notification/interface/CurrentG4Track.h"
#include "SimG4Core/Notification/interface/BeginOfTrack.h"
#include "SimG4Core/Notification/interface/EndOfTrack.h"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ class G4Track;
class KillSecondariesStackingAction : public G4UserStackingAction {
public:
KillSecondariesStackingAction() {}
~KillSecondariesStackingAction() override {}
~KillSecondariesStackingAction() override = default;
G4ClassificationOfNewTrack ClassifyNewTrack(const G4Track *) override;
};

Expand Down
Original file line number Diff line number Diff line change
@@ -1,18 +1,17 @@
#include "SimG4Core/KillSecondaries/interface/KillSecondariesStackingAction.h"
#include "SimG4Core/Notification/interface/CurrentG4Track.h"
#include "SimG4Core/Notification/interface/NewTrackAction.h"
#include "SimG4Core/Notification/interface/MCTruthUtil.h"

#include "G4Track.hh"

G4ClassificationOfNewTrack KillSecondariesStackingAction::ClassifyNewTrack(const G4Track *aTrack) {
NewTrackAction newTA;
auto track = const_cast<G4Track *>(aTrack);
if (aTrack->GetCreatorProcess() == nullptr || aTrack->GetParentID() == 0) {
newTA.primary(track);
MCTruthUtil::primary(track);
return fUrgent;
} else {
const G4Track *mother = CurrentG4Track::track();
newTA.secondary(track, *mother, 0);
MCTruthUtil::secondary(track, *mother, 0);
return fKill;
}
}
19 changes: 19 additions & 0 deletions SimG4Core/Notification/interface/MCTruthUtil.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
#ifndef SimG4Core_MCTruthUtil_H
#define SimG4Core_MCTruthUtil_H

class G4Track;

/*
* Creation and filling initial MC truth information for
* primary and secondary G4Track objects, addition to G4Track
* an extra CMS container TrackInformation.
* Currently is used in StackingAction.
*/

class MCTruthUtil {
public:
static void primary(G4Track* aPrimary);
static void secondary(G4Track* aSecondary, const G4Track& mother, int);
};

#endif
26 changes: 0 additions & 26 deletions SimG4Core/Notification/interface/NewTrackAction.h

This file was deleted.

8 changes: 4 additions & 4 deletions SimG4Core/Notification/interface/SimTrackManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

// forward declarations

class G4SimEvent;
class TmpSimEvent;
class G4Track;

class SimTrackManager {
Expand All @@ -41,7 +41,7 @@ class SimTrackManager {

const std::vector<TrackWithHistory*>* trackContainer() const { return &m_trackContainer; }

void storeTracks(G4SimEvent* simEvent);
void storeTracks(TmpSimEvent* simEvent);

void reset();
void deleteTracks();
Expand Down Expand Up @@ -93,9 +93,9 @@ class SimTrackManager {

private:
void saveTrackAndItsBranch(TrackWithHistory*);
int getOrCreateVertex(TrackWithHistory*, int, G4SimEvent* simEvent);
int getOrCreateVertex(TrackWithHistory*, int, TmpSimEvent* simEvent);
void cleanVertexMap();
void reallyStoreTracks(G4SimEvent* simEvent);
void reallyStoreTracks(TmpSimEvent* simEvent);
void fillMotherList();
int idSavedTrack(int) const;
void ReportException(unsigned int id) const;
Expand Down
Loading