NAIA
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
UnbExtHitFill.cpp
Go to the documentation of this file.
1 #include "Containers/UnbExtHit.h"
2 
3 namespace NAIA {
4 
5 void UnbExtHitBaseData::Fill(AMSEventR *evPtr) {
6 
7  auto fillHit = [this](ExtHit type, TrRecHitR *hit, int imult, float beta) {
8  m_hits[type].ChargeStatus = hit->GetQStatus();
9  m_hits[type].HitPosX = hit->GetCoord(imult).x();
10  m_hits[type].HitPosY = hit->GetCoord(imult).y();
11  m_hits[type].Charge[TrTrack::ChargeRecoType::STD] = hit->GetQ(2, beta);
12  m_hits[type].Charge[TrTrack::ChargeRecoType::HL] = hit->GetQH(2, beta);
13  m_hits[type].Charge[TrTrack::ChargeRecoType::YJ] = hit->GetQYJ(2, beta);
14  };
15 
16  // need at least a good beta and charge measurement
17  if (tofBase->Beta.find(Tof::BetaType::BetaH) == end(tofBase->Beta) ||
19  return;
20 
22 
23  // Search unbiased hits on external layers
24  TrRecHitR *hitL1 = nullptr;
25  TrRecHitR *hitL9 = nullptr;
26 
27  if (floor(tofBase->Charge.at(Tof::ChargeType::Total) + 0.5) > 1) {
28  // Case Helium or higher we use the highest charge hit
29  Float_t prev_charge1 = 0;
30  Float_t prev_charge9 = 0;
31  for (int ihit = 0; ihit < evPtr->NTrRecHit(); ihit++) {
32  if (evPtr->pTrRecHit(ihit)->OnlyX() || evPtr->pTrRecHit(ihit)->OnlyY())
33  continue;
34  if (evPtr->pTrRecHit(ihit)->GetLayerJ() == 1) {
35  if (evPtr->pTrRecHit(ihit)->GetXCluster()->GetQ() > prev_charge1) {
36  hitL1 = evPtr->pTrRecHit(ihit);
37  prev_charge1 = evPtr->pTrRecHit(ihit)->GetXCluster()->GetQ();
38  }
39  } else if (evPtr->pTrRecHit(ihit)->GetLayerJ() == 9) {
40  if (evPtr->pTrRecHit(ihit)->GetXCluster()->GetQ() > prev_charge9) {
41  hitL9 = evPtr->pTrRecHit(ihit);
42  prev_charge9 = evPtr->pTrRecHit(ihit)->GetXCluster()->GetQ();
43  }
44  }
45  }
46  // Solve multiplicity with tof standalone
47  Int_t mult1 = -1, mult9 = -1;
48  if (hitL1 != nullptr) {
49  TVector3 betaInt = tofBase->InterpolateAtZ(hitL1->GetCoord().z());
50  AMSPoint tofh_point = AMSPoint(betaInt[0], betaInt[1], betaInt[2]);
51  hitL1->HitPointDist(tofh_point, mult1);
52  // cout << mult1 << " " << hitL1->GetResolvedMultiplicity() << endl;
53  fillHit(ExtHit::L1, hitL1, mult1, _beta);
54  }
55  if (hitL9 != nullptr) {
56  TVector3 betaInt = tofBase->InterpolateAtZ(hitL9->GetCoord().z());
57  AMSPoint tofh_point = AMSPoint(betaInt[0], betaInt[1], betaInt[2]);
58  hitL9->HitPointDist(tofh_point, mult9);
59  // cout << mult9 << " " << hitL9->GetResolvedMultiplicity() << endl;
60  fillHit(ExtHit::L9, hitL9, mult9, _beta);
61  }
62 
63  } else if (tofBase->Charge.at(Tof::ChargeType::Total) > 0) {
64  TVector3 betaL1Int = tofBase->InterpolateAtZ(158.920);
65  TVector3 betaL9Int = tofBase->InterpolateAtZ(-135.882);
66 
67  AMSPoint tofh_point_L1 = AMSPoint(betaL1Int[0], betaL1Int[1], betaL1Int[2]);
68  AMSPoint tofh_point_L9 = AMSPoint(betaL9Int[0], betaL9Int[1], betaL9Int[2]);
69 
70  Float_t prev_dist1 = 99999;
71  Float_t prev_dist9 = 99999;
72  Int_t mult1 = -1, mult9 = -1;
73  for (int ihit = 0; ihit < evPtr->NTrRecHit(); ihit++) {
74  if (evPtr->pTrRecHit(ihit)->OnlyX() || evPtr->pTrRecHit(ihit)->OnlyY())
75  continue;
76  if (evPtr->pTrRecHit(ihit)->GetLayerJ() == 1) {
77  if (evPtr->pTrRecHit(ihit)->HitPointDist(tofh_point_L1, mult1).norm() < prev_dist1) {
78  hitL1 = evPtr->pTrRecHit(ihit);
79  prev_dist1 = hitL1->HitPointDist(tofh_point_L1, mult1).norm();
80  }
81  } else if (evPtr->pTrRecHit(ihit)->GetLayerJ() == 9) {
82  if (evPtr->pTrRecHit(ihit)->HitPointDist(tofh_point_L9, mult9).norm() < prev_dist9) {
83  hitL9 = evPtr->pTrRecHit(ihit);
84  prev_dist9 = hitL9->HitPointDist(tofh_point_L9, mult9).norm();
85  }
86  }
87  }
88 
89  if (hitL1 != nullptr)
90  fillHit(ExtHit::L1, hitL1, mult1, _beta);
91  if (hitL9 != nullptr)
92  fillHit(ExtHit::L9, hitL9, mult9, _beta);
93  }
94 }
95 } // namespace NAIA
UnbExtHit container class description.
TofBetaVariable< float > Beta
Beta measurement, one for each type. See Tof::BetaType for list of types.
Definition: Tof.h:48
Hu Liu reconstruction.
Definition: Utils.h:86
IHEP reconstruction.
Definition: Utils.h:342
TVector3 InterpolateAtZ(float z) const
Get Tof track interpolation at given height.
Definition: Tof.cpp:33
TofChargeVariable< float > Charge
Charge measurement, one for each type. See Tof::ChargeType for list of types.
Definition: Tof.h:49
Charge estimated using the whole TRD.
Definition: Utils.h:225
const TofBaseData * tofBase
Definition: UnbExtHit.h:102
SingleTreeChain::EventItr end(SingleTreeChain &chain)
std::map< ExtHit, HitData > m_hits
Definition: UnbExtHit.h:117
ExtHit
Handy enum to distinguish L1 and L9.
Definition: UnbExtHit.h:41
Yi Jia reconstruction.
Definition: Utils.h:87
Standard tracker charge reconstruction.
Definition: Utils.h:85