GRSISort "v4.0.0.5"
An extension of the ROOT analysis Framework
Loading...
Searching...
No Matches
GetTreeEntries.cxx
Go to the documentation of this file.
1#include <iostream>
2
3#include "TFile.h"
4#include "TTree.h"
5
6#include "TS3.h"
7#include "TTip.h"
8#include "TSiLi.h"
9#include "TSharc.h"
10#include "TTAC.h"
11#include "TGriffin.h"
12#include "TDescant.h"
13#include "TFragment.h"
14#include "TLaBr.h"
15#include "TZeroDegree.h"
16#include "TSceptar.h"
17#include "TPaces.h"
18#include "TTigress.h"
19
20////////////////////////////////////////////////////////////////////////////////
21///
22/// This program simply prints the entries of the FragmentTree in the file (if
23/// it finds one).
24/// If there is no FragmentTree, but an AnalysisTree, it prints the number of
25/// entries in it, plus the number if hits for each detector (though not all are
26/// implemented yet).
27///
28////////////////////////////////////////////////////////////////////////////////
29
30int main(int argc, char** argv)
31{
32 if(argc == 1) {
33 std::cout << "Usage: " << argv[0] << " <root file name>" << std::endl;
34 return -1;
35 }
36
37 std::cout << "Running on " << argc - 1 << " file(s)" << std::endl;
38
39 for(int i = 1; i < argc; ++i) {
40 TFile f(argv[i]);
41 if(!f.IsOpen()) {
42 std::cout << "Failed to open " << argv[i] << std::endl;
43 continue;
44 }
45
46 auto* tree = dynamic_cast<TTree*>(f.Get("FragmentTree"));
47 if(tree != nullptr) {
48 std::cout << argv[i] << " - FragmentTree: " << tree->GetEntries() << std::endl;
49 continue;
50 }
51
52 tree = dynamic_cast<TTree*>(f.Get("AnalysisTree"));
53 if(tree != nullptr) {
54 std::cout << argv[i] << " - AnalysisTree: " << tree->GetEntries() << std::endl;
55
56 // S3
57
58 // Tip
59
60 // SiLi
61
62 // TSharc
63
64 // TTAC
65
66 bool gotGriffin = (tree->FindBranch("TGriffin") != nullptr);
67 TGriffin* grif = nullptr;
68 if(gotGriffin) {
69 tree->SetBranchAddress("TGriffin", &grif);
70 }
71 int64_t numGriffin = 0;
72
73 bool gotDescant = (tree->FindBranch("TDescant") != nullptr);
74 TDescant* desc = nullptr;
75 if(gotDescant) {
76 tree->SetBranchAddress("TDescant", &desc);
77 }
78 int64_t numDescant = 0;
79
80 bool gotLaBr = (tree->FindBranch("TLaBr") != nullptr);
81 TLaBr* laBr = nullptr;
82 if(gotLaBr) {
83 tree->SetBranchAddress("TLaBr", &laBr);
84 }
85 int64_t numLaBr = 0;
86
87 bool gotZeroDegree = (tree->FindBranch("TZeroDegree") != nullptr);
88 TZeroDegree* zd = nullptr;
89 if(gotZeroDegree) {
90 tree->SetBranchAddress("TZeroDegree", &zd);
91 }
92 int64_t numZeroDegree = 0;
93
94 bool gotSceptar = (tree->FindBranch("TSceptar") != nullptr);
95 TSceptar* scep = nullptr;
96 if(gotSceptar) {
97 tree->SetBranchAddress("TSceptar", &scep);
98 }
99 int64_t numSceptar = 0;
100
101 bool gotPaces = (tree->FindBranch("TPaces") != nullptr);
102 TPaces* pace = nullptr;
103 if(gotPaces) {
104 tree->SetBranchAddress("TPaces", &pace);
105 }
106 int64_t numPaces = 0;
107
108 // Tigress
109
110 for(int64_t e = 0; e < tree->GetEntries(); ++e) {
111 tree->GetEntry(e);
112
113 if(gotGriffin) {
114 numGriffin += grif->GetMultiplicity();
115 }
116 if(gotDescant) {
117 numDescant += desc->GetMultiplicity();
118 }
119 if(gotLaBr) {
120 numLaBr += laBr->GetMultiplicity();
121 }
122 if(gotZeroDegree) {
123 numZeroDegree += zd->GetMultiplicity();
124 }
125 if(gotSceptar) {
126 numSceptar += scep->GetMultiplicity();
127 }
128 if(gotPaces) {
129 numPaces += pace->GetMultiplicity();
130 }
131 }
132
133 if(gotGriffin) {
134 std::cout << numGriffin << " GRIFFIN, ";
135 }
136 if(gotDescant) {
137 std::cout << numDescant << " DESCANT, ";
138 }
139 if(gotLaBr) {
140 std::cout << numLaBr << " LABR, ";
141 }
142 if(gotZeroDegree) {
143 std::cout << numZeroDegree << " ZERO-DEGREE, ";
144 }
145 if(gotSceptar) {
146 std::cout << numSceptar << " SCEPTAR, ";
147 }
148 if(gotPaces) {
149 std::cout << numPaces << " PACES, ";
150 }
151 std::cout << " " << numGriffin + numDescant + numLaBr + numZeroDegree + numSceptar + numPaces << " total hits"
152 << std::endl;
153
154 continue;
155 }
156
157 std::cout << "Failed to find 'FragmentTree' or 'AnalysisTree' in " << argv[i] << std::endl;
158
159 f.ls();
160 }
161
162 return -1;
163}
int main(int argc, char **argv)
virtual Short_t GetMultiplicity() const
Definition TDetector.h:73
Short_t GetMultiplicity() const override
Definition TGriffin.h:52
Definition TLaBr.h:28