NAIA  1.0.2
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups
testReadNtp.cpp
Go to the documentation of this file.
1 // dependencies headers
2 #include "spdlog/sinks/stdout_color_sinks.h"
3 #include "spdlog/spdlog.h"
4 
5 // NAIA headers
6 #include "Chain/NAIAChain.h"
7 
8 using namespace NAIA;
9 
10 int main(int argc, char const *argv[]) {
12  chain.Add("test.root");
13  // chain.Add("skimmed.root");
14 
15  chain.SetupBranches();
16 
17  spdlog::info("{} entries in the chain", chain.GetEntries());
18 
19  auto handle1 = chain.CreateSkimTree("skimmed.root", "RichBase;RichPlus");
20 
21  unsigned long long nEntries = chain.GetEntries();
22  // unsigned long long nEntries = 1;
23 
24  unsigned long long skimmedEntries = 0;
25 
26  // auto firstEvent = chain.GetEvent(0);
27 
28  // std::vector<unsigned long long> evList = {0, 1, 0, 1, 2, 1, 3, 1};
29 
30  // for (auto iEv : evList) {
31  // for (unsigned long long iEv = 0; iEv < nEntries; iEv++) {
32  // auto &event = chain.GetEvent(iEv);
33  for (auto &event : chain) {
34 
35  // if (!event.CheckMask(NAIA::Category::HasEcal))
36  // continue;
37 
38  spdlog::info("Entry {} - Mask {}", event.header->EventNo, to_string_binary<32>(event.header->Mask()));
39 
40  // const RTIInfo &rtiInfo = chain.GetEventRTIInfo();
41  // if (rtiInfo.IsInSAA())
42  // continue;
43 
44  // float tofCharge, innerCharge, rigidity;
45 
46  // if (KeyExists(Tof::ChargeType::Upper, event.tofBase->Charge))
47  // tofCharge = event.tofBase->Charge[Tof::ChargeType::Upper];
48 
49  // innerCharge = event.trTrackBase->Charge[TrTrack::ChargeRecoType::YJ];
50 
51  // if (event.trTrackBase->FitIDExists(TrTrack::Fit::Kalman, TrTrack::Span::InnerOnly))
52  // rigidity = event.trTrackBase->Rigidity[TrTrack::Fit::Kalman][TrTrack::Span::InnerOnly];
53 
54  // chain.GetEventFileInfo().Dump();
55  // chain.GetEventRTIInfo().Dump();
56 
57  // event.header->Dump();
58  // event.evSummary->Dump();
59 
60  // event.mcTruthBase->Dump();
61  // event.mcTruthPlus->Dump();
62 
63  // event.tofBaseSt->Dump();
64  // event.tofPlusSt->Dump();
65  // event.trdKBaseSt->Dump();
66  // event.extHitBase->Dump();
67 
68  // event.tofBase->Dump();
69  // event.tofPlus->Dump();
70 
71  // event.trdKBase->Dump();
72 
73  // event.trTrackBase->Dump();
74  // event.trTrackPlus->Dump();
75  // auto x_pattern = event.trTrackNase->GetTrackPattern(TrTrack::Side::X);
76  // auto y_pattern = event.trTrackNase->GetTrackPattern(TrTrack::Side::Y);
77  //
78  // spdlog::info("X: {} Y: {}", x_pattern.to_string(), y_pattern.to_string());
79 
80  // event.ecalBase->Dump();
81  // event.ecalPlus->Dump();
82 
83  // event.richBase->Dump();
84  // event.richPlus->Dump();
85 
86  if (event.CheckMask(NAIA::Category::ChargeGT2_Trk)) {
87  handle1.Fill();
88  skimmedEntries++;
89  }
90 
91  std::cin.get();
92  }
93 
94  spdlog::info("We skimmed {} entries", skimmedEntries);
95 
96  handle1.Write();
97 
98  return 0;
99 }
void SetupBranches(bool create_MC_branches=false)
Set all branch addresses for reading operations, or create all branches for writing operation...
Definition: NAIAChain.cpp:227
NAIAChain class description.
unsigned long int GetEntries()
Get the total number of events.
Definition: NAIAChain.cpp:178
int main(int argc, char **argv)
Definition: NtpMaker.cpp:31
SkimTreeHandle< NAIAChain > CreateSkimTree(const std::string &filename, const std::string &exclBranches)
Create a new SkimTree handle object and setup all internal branches.
Definition: NAIAChain.cpp:278
int Add(const std::string &filePath)
Add a file to the chain.
Definition: NAIAChain.cpp:127
This event is classified as charge &gt;2 according to tracker (Q &gt; 2.5)