3 #include "TDatabasePDG.h"
9 static float amu = 0.93146;
12 MCParticle particle{TDatabasePDG::Instance()->ConvertGeant3ToPdg(mcp.Particle),
13 static_cast<int>(mcp.Charge),
14 TMath::Nint(mcp.Mass /
amu),
15 {mcp.
Momentum * TVector3{mcp.Dir[0], mcp.Dir[1], mcp.Dir[2]}},
16 {TVector3{mcp.Coo[0], mcp.Coo[1], mcp.Coo[2]}},
20 mcp.Nskip & 0xFFFFFF};
28 unsigned int layerOld = tkID / 100;
41 AMSEventR *
event = AMSEventR::Head();
43 throw std::runtime_error(
"Invalid pointer for AMSEventR::Head");
44 if (event->nMCEventgC() == 0)
45 throw std::runtime_error(
"No MCEventg information in this event");
49 if (!pTrTrack->TestHitLayerJ(jLayer))
52 AMSPlaneM plm = pTrTrack->GetHitCooLJN(jLayer);
53 TVector3 mglob = plm.getMGlobal();
54 AMSPoint point = AMSPoint(mglob.x(), mglob.y(), mglob.z());
57 std::min_element(
begin(event->TrMCCluster()),
end(event->TrMCCluster()),
58 [&point](
auto &cl1,
auto &cl2) {
return cl1.GetXgl().dist(point) < cl2.GetXgl().dist(point); });
60 if (mcclusterIt ==
end(event->TrMCCluster()))
64 auto rmin = mcclusterIt->GetXgl().dist(point);
65 if (rmin > match_radius)
68 mcHit.
pID = mcclusterIt->GetPart();
69 for (
unsigned int ic = 0; ic < 3; ic++) {
70 mcHit.
Coo[ic] = mcclusterIt->GetXgl()[ic];
71 mcHit.
Mom[ic] = mcclusterIt->GetMom()[ic];
78 if (a.parentID < b.parentID)
80 else if (a.parentID > b.parentID)
83 if (a.Coo[2] > b.Coo[2])
85 else if (a.Coo[2] < b.Coo[2])
88 return a.Momentum > b.Momentum;
92 bool MCTruthBaseData::Fill(AMSEventR *evPtr) {
97 auto primIt = std::find_if(
begin(evPtr->MCEventg()),
end(evPtr->MCEventg()),
98 [](
const MCEventgR &mcp) {
return mcp.Coo[2] > 160.0; });
100 if (primIt ==
end(evPtr->MCEventg())) {
101 throw std::runtime_error(
"No generation point found for primary particle (with CooZ > 160 cm)");
104 constexpr
float z_tolerance = 0.35f;
107 for (
const auto &mcp : evPtr->MCEventg()) {
108 if (mcp.parentID != 0)
112 [&mcp](
float height) {
return fabs(mcp.Coo[2] - height) < z_tolerance; });
116 Primary.
Momentum[position] = mcp.Momentum * TVector3{mcp.Dir[0], mcp.Dir[1], mcp.Dir[2]};
119 Primary.
Position[position] = TVector3{mcp.Coo[0], mcp.Coo[1], mcp.Coo[2]};
126 bool MCTruthPlusData::Fill(AMSEventR *evPtr) {
134 const MCEventgR &firstPrim = evPtr->MCEventg()[0];
136 const auto lastPrimIt = std::find_if(rbegin(evPtr->MCEventg()), rend(evPtr->MCEventg()),
137 [](
const MCEventgR &mcp) {
return mcp.parentID == 0; });
139 if (lastPrimIt == rend(evPtr->MCEventg()))
142 for (MCEventgR &mcp : evPtr->MCEventg()) {
143 if (mcp.Momentum / firstPrim.Momentum > 0.01 && mcp.Coo[2] <= lastPrimIt->Coo[2]) {
151 bool MCTruthPlusData::FillTrMCHit(TrTrackR *pTrTrack) {
152 for (
unsigned int ij = 0; ij < 9; ij++) {
std::vector< TVector3 > Position
particle position at different z-heights. See MCTruth::MCHeights for a description of the possible he...
MCTruthPlusData::TrMCHit GetTrMCHit(TrTrackR *pTrTrack, unsigned int jLayer, double match_radius=0.1)
std::vector< TVector3 > Momentum
particle momentum at different z-heights. See MCTruth::MCHeights for a description of the possible he...
MCParticle GetMCParticle(const MCEventgR &mcp)
constexpr std::array< float, numMCHeights > MCHeightsZ
NAIAChain::EventItr begin(NAIAChain &chain)
std::array< float, 3 > Coo
hit position
Simple struct for MC tracker hits.
MCParticle Primary
primary particle
unsigned int TkIDToLayerJ(int tkID)
std::vector< MCParticle > Secondaries
list of particles created by interaction of the primary particle
MCTruth container class description.
Simple struct to describe a MC particle.
NAIAChain::EventItr end(NAIAChain &chain)
std::array< float, 3 > Mom
hit momentum
LayerVariable< TrMCHit > TrackMCHits
A collection of the closest MCHit to the TrTrack cluster on each layer.
unsigned int pID
particle PID