CMS 3D CMS Logo

List of all members | Static Public Member Functions
MCTruthUtil Class Reference

#include <MCTruthUtil.h>

Static Public Member Functions

static bool isInBTL (const G4Track *)
 
static void primary (G4Track *aPrimary)
 
static void secondary (G4Track *aSecondary, const G4Track &mother, int)
 

Detailed Description

Definition at line 13 of file MCTruthUtil.h.

Member Function Documentation

◆ isInBTL()

bool MCTruthUtil::isInBTL ( const G4Track *  aTrack)
static

Definition at line 73 of file MCTruthUtil.cc.

References MillePedeFileConverter_cfg::out, and simpleEdmComparison::tName.

Referenced by secondary().

73  {
74  bool out = false;
75  G4String tName(aTrack->GetVolume()->GetLogicalVolume()->GetRegion()->GetName());
76  if (tName == "FastTimerRegionBTL" || tName == "FastTimerRegionSensBTL") {
77  out = true;
78  }
79  return out;
80 }

◆ primary()

void MCTruthUtil::primary ( G4Track *  aPrimary)
static

Definition at line 8 of file MCTruthUtil.cc.

References TrackInformation::setGenParticleP(), TrackInformation::setGenParticlePID(), TrackInformation::setMCTruthID(), TrackInformation::setPrimary(), and TrackInformation::setStoreTrack().

Referenced by KillSecondariesStackingAction::ClassifyNewTrack(), and StackingAction::ClassifyNewTrack().

8  {
9  TrackInformation *trkInfo = new TrackInformation();
10  trkInfo->setPrimary(true);
11  trkInfo->setStoreTrack();
12  trkInfo->setGenParticlePID(aTrack->GetDefinition()->GetPDGEncoding());
13  trkInfo->setGenParticleP(aTrack->GetMomentum().mag());
14  trkInfo->setMCTruthID(aTrack->GetTrackID());
15  aTrack->SetUserInformation(trkInfo);
16 }
void setStoreTrack()
can only be set to true, cannot be reset to false!
void setGenParticlePID(int id)
void setPrimary(bool v)
void setMCTruthID(int id)
void setGenParticleP(double p)

◆ secondary()

void MCTruthUtil::secondary ( G4Track *  aSecondary,
const G4Track &  mother,
int  flag 
)
static

Definition at line 18 of file MCTruthUtil.cc.

References RemoveAddSevLevel::flag, isInBTL(), and LogDebug.

Referenced by KillSecondariesStackingAction::ClassifyNewTrack(), and StackingAction::ClassifyNewTrack().

18  {
19  auto motherInfo = static_cast<const TrackInformation *>(mother.GetUserInformation());
20  auto trkInfo = new TrackInformation();
21  LogDebug("SimG4CoreApplication") << "MCTruthUtil called for " << aTrack->GetTrackID() << " mother "
22  << motherInfo->isPrimary() << " flag " << flag;
23 
24  // Take care of cascade decays
25  if (flag == 1) {
26  trkInfo->setPrimary(true);
27  trkInfo->setStoreTrack();
28  trkInfo->setGenParticlePID(aTrack->GetDefinition()->GetPDGEncoding());
29  trkInfo->setGenParticleP(aTrack->GetMomentum().mag());
30  trkInfo->setMCTruthID(aTrack->GetTrackID());
31  } else {
32  // secondary
33  trkInfo->setGenParticlePID(motherInfo->genParticlePID());
34  trkInfo->setGenParticleP(motherInfo->genParticleP());
35  trkInfo->setMCTruthID(motherInfo->mcTruthID());
36  }
37 
38  // Store if decay or conversion
39  if (flag > 0) {
40  trkInfo->setStoreTrack();
41  trkInfo->setIDonCaloSurface(aTrack->GetTrackID(),
42  motherInfo->getIDCaloVolume(),
43  motherInfo->getIDLastVolume(),
44  aTrack->GetDefinition()->GetPDGEncoding(),
45  aTrack->GetMomentum().mag());
46  } else {
47  // transfer calo ID from mother (to be checked in TrackingAction)
48  trkInfo->setIDonCaloSurface(motherInfo->getIDonCaloSurface(),
49  motherInfo->getIDCaloVolume(),
50  motherInfo->getIDLastVolume(),
51  motherInfo->caloSurfaceParticlePID(),
52  motherInfo->caloSurfaceParticleP());
53  }
54 
55  // for Run1 and Run2
56  if (motherInfo->hasCastorHit()) {
57  trkInfo->setCastorHitPID(motherInfo->getCastorHitPID());
58  }
59 
60  // manage ID of tracks in BTL to map them to SimTracks to be stored
61  if (isInBTL(aTrack)) {
62  if ((motherInfo->storeTrack() && motherInfo->isFromTtoBTL()) || motherInfo->isBTLdaughter()) {
63  trkInfo->setBTLdaughter();
64  trkInfo->setIdAtBTLentrance(motherInfo->idAtBTLentrance());
65  LogDebug("SimG4CoreApplication") << "NewTrackAction: secondary in BTL " << trkInfo->isBTLdaughter()
66  << " from mother ID " << trkInfo->idAtBTLentrance();
67  }
68  }
69 
70  aTrack->SetUserInformation(trkInfo);
71 }
static bool isInBTL(const G4Track *)
Definition: MCTruthUtil.cc:73
#define LogDebug(id)