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 79 of file MCTruthUtil.cc.

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

Referenced by secondary().

79  {
80  bool out = false;
81  G4String tName(aTrack->GetVolume()->GetLogicalVolume()->GetRegion()->GetName());
82  if (tName == "FastTimerRegionBTL" || tName == "FastTimerRegionSensBTL") {
83  out = true;
84  }
85  return out;
86 }

◆ primary()

void MCTruthUtil::primary ( G4Track *  aPrimary)
static

Definition at line 7 of file MCTruthUtil.cc.

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

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

7  {
8  TrackInformation *trkInfo = new TrackInformation();
9  trkInfo->setPrimary(true);
10  trkInfo->setStoreTrack();
11  trkInfo->setGenParticlePID(aTrack->GetDefinition()->GetPDGEncoding());
12  trkInfo->setGenParticleP(aTrack->GetMomentum().mag());
13  trkInfo->setMCTruthID(aTrack->GetTrackID());
14  aTrack->SetUserInformation(trkInfo);
15 }
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 17 of file MCTruthUtil.cc.

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

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

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