NAIA  1.0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
EventSummaryFill.cpp
Go to the documentation of this file.
2 
3 namespace NAIA {
4 bool EventSummaryData::Fill(AMSEventR *evPtr) {
5  NAntiCluster = evPtr->NAntiCluster();
6  NTofCluster = evPtr->NTofCluster();
7  NTrRecHit = evPtr->NTrRecHit();
8  NTrTrack = evPtr->NTrTrack();
9  NRichRing = evPtr->NRichRing();
10  NEcalShower = evPtr->NEcalShower();
11  NParticle = evPtr->NParticle();
12 
13  HighestEcalEnergyParticle = static_cast<short>(std::distance(
14  begin(evPtr->Particle()),
15  std::max_element(begin(evPtr->Particle()), end(evPtr->Particle()), [](ParticleR &p1, ParticleR &p2) {
16  if (p2.pEcalShower() == p1.pEcalShower())
17  return false;
18 
19  double e1 = p1.pEcalShower() ? p1.pEcalShower()->EnergyD : 0;
20  double e2 = p2.pEcalShower() ? p2.pEcalShower()->EnergyD : 0;
21  return e1 < e2;
22  })));
23 
24  HighestBetaHChargeParticle = static_cast<short>(std::distance(
25  begin(evPtr->Particle()),
26  std::max_element(begin(evPtr->Particle()), end(evPtr->Particle()), [](ParticleR &p1, ParticleR &p2) {
27  if (p2.pBetaH() == p1.pBetaH())
28  return false;
29 
30  int nlayers = 0;
31  float qrms = 0;
32 
33  double q1 = p1.pBetaH() ? p1.pBetaH()->GetQ(nlayers, qrms, 2, TofClusterHR::DefaultQOptIon) : 0;
34  double q2 = p2.pBetaH() ? p2.pBetaH()->GetQ(nlayers, qrms, 2, TofClusterHR::DefaultQOptIon) : 0;
35  return q1 < q2;
36  })));
37 
38  HighestInnerChargeParticle = static_cast<short>(std::distance(
39  begin(evPtr->Particle()),
40  std::max_element(begin(evPtr->Particle()), end(evPtr->Particle()), [](ParticleR &p1, ParticleR &p2) {
41  if (p2.pTrTrack() == p1.pTrTrack())
42  return false;
43 
44  double q1 = p1.pTrTrack() ? p1.pTrTrack()->GetInnerQ_all().Mean : 0;
45  double q2 = p2.pTrTrack() ? p2.pTrTrack()->GetInnerQ_all().Mean : 0;
46  return q1 < q2;
47  })));
48 
49  if (evPtr->pLevel1(0)) {
50  JMembPatt = evPtr->pLevel1(0)->JMembPatt;
51  if (_isMC) {
52  // how not to design a datamodel:
53  // PhysBPatt only uses the lower 8 bits to store information
54  // however the API requires an int and only an int
55  // so if you want to save space you have to cast the result
56  // Another excellent demonstration of how using parameters
57  // as return values in c++ is inherently stupid
58  int dummy = 0;
59  int otherDummy = 0;
60 
61  evPtr->pLevel1(0)->RebuildTrigPatt(dummy, otherDummy);
62  PhysBPatt = static_cast<unsigned short>(otherDummy);
63  } else {
64  // evPtr->pLevel1(0)->RestorePhysBPat();
65  PhysBPatt = evPtr->pLevel1(0)->PhysBPatt;
66  }
67 
68  // neat trick to count how many bits are set in AntiPatt
69  NAcc = std::bitset<8>(evPtr->pLevel1(0)->AntiPatt).count();
70  }
71 
72  return true;
73 }
74 } // namespace NAIA
unsigned short NParticle
Total number of reconstructed particles in the event.
Definition: EventSummary.h:69
unsigned short NAcc
Number of fired ACC counters.
Definition: EventSummary.h:79
NAIAChain::EventItr begin(NAIAChain &chain)
Definition: NAIAChain.h:297
unsigned short NAntiCluster
Number of fired ACC clusters.
Definition: EventSummary.h:63
unsigned short PhysBPatt
same as in gbatch, see https://ams.cern.ch/AMS/Analysis/hpl3itp1/root02_v5/html/development/html/clas...
Definition: EventSummary.h:76
unsigned short NTrRecHit
Total number of Tracker hits in the event.
Definition: EventSummary.h:65
unsigned short NEcalShower
Total number of Ecal showers in the event.
Definition: EventSummary.h:68
short HighestEcalEnergyParticle
ID of the ParticleR object with the highest ECAL shower energy.
Definition: EventSummary.h:71
short HighestInnerChargeParticle
ID of the ParticleR object with the highest Inner Tracker charge.
Definition: EventSummary.h:72
unsigned short NTrTrack
Total number of Tracker tracks in the event.
Definition: EventSummary.h:66
short HighestBetaHChargeParticle
ID of the ParticleR object with the highest BetaH charge.
Definition: EventSummary.h:73
unsigned short NTofCluster
Total number of Tof clusters in the event.
Definition: EventSummary.h:64
unsigned short JMembPatt
same as in gbatch, see https://ams.cern.ch/AMS/Analysis/hpl3itp1/root02_v5/html/development/html/clas...
Definition: EventSummary.h:77
NAIAChain::EventItr end(NAIAChain &chain)
Definition: NAIAChain.h:298
Event summary container class description.
unsigned short NRichRing
Total number of Rich rings in the event.
Definition: EventSummary.h:67