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

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

Referenced by secondary().

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

◆ primary()

void MCTruthUtil::primary ( G4Track *  aPrimary)
static

Definition at line 8 of file MCTruthUtil.cc.

References TrackInformation::putInHistory(), TrackInformation::setGenParticleP(), TrackInformation::setGenParticlePID(), 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->putInHistory();
13  trkInfo->setGenParticlePID(aTrack->GetDefinition()->GetPDGEncoding());
14  trkInfo->setGenParticleP(aTrack->GetMomentum().mag());
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 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->setGenParticlePID(aTrack->GetDefinition()->GetPDGEncoding());
28  trkInfo->setGenParticleP(aTrack->GetMomentum().mag());
29  } else {
30  trkInfo->setGenParticlePID(motherInfo->genParticlePID());
31  trkInfo->setGenParticleP(motherInfo->genParticleP());
32  }
33 
34  // Store if decay or conversion
35  if (flag > 0) {
36  trkInfo->setStoreTrack();
37  trkInfo->putInHistory();
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  // manage ID of tracks in BTL to map them to SimTracks to be stored
58  if (isInBTL(aTrack)) {
59  if ((motherInfo->storeTrack() && motherInfo->isFromTtoBTL()) || motherInfo->isBTLdaughter()) {
60  trkInfo->setBTLdaughter();
61  trkInfo->setIdAtBTLentrance(motherInfo->idAtBTLentrance());
62  LogDebug("SimG4CoreApplication") << "NewTrackAction: secondary in BTL " << trkInfo->isBTLdaughter()
63  << " from mother ID " << trkInfo->idAtBTLentrance();
64  }
65  }
66 
67  aTrack->SetUserInformation(trkInfo);
68 }
static bool isInBTL(const G4Track *)
Definition: MCTruthUtil.cc:70
#define LogDebug(id)