forked from mcoquet642/AliceO2
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcheckStack.C
More file actions
83 lines (71 loc) · 2.62 KB
/
checkStack.C
File metadata and controls
83 lines (71 loc) · 2.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
// Macro to check functioning of stack
// Analyses kinematics and track references of a kinematics file
#if !defined(__CLING__) || defined(__ROOTCLING__)
#include "SimulationDataFormat/MCTrack.h"
#include "SimulationDataFormat/MCTruthContainer.h"
#include "SimulationDataFormat/Stack.h"
#include "SimulationDataFormat/TrackReference.h"
#include "TFile.h"
#include "TTree.h"
#endif
#ifdef NDEBUG
#undef NDEBUG
#endif
#include <cassert>
#include "FairLogger.h"
void checkStack(const char* name = "o2sim.root")
{
FairLogger::GetLogger()->SetLogScreenLevel("DEBUG");
TFile f(name);
LOG(DEBUG) << "Checking input file :" << f.GetPath();
std::vector<o2::MCTrack>* mctracks = nullptr;
auto tr = (TTree*)f.Get("o2sim");
assert(tr);
auto mcbr = tr->GetBranch("MCTrack");
assert(mcbr);
mcbr->SetAddress(&mctracks);
std::vector<o2::TrackReference>* trackrefs = nullptr;
auto refbr = tr->GetBranch("TrackRefs");
assert(refbr);
refbr->SetAddress(&trackrefs);
o2::dataformats::MCTruthContainer<o2::TrackReference>* indexedtrackrefs = nullptr;
auto irefbr = tr->GetBranch("IndexedTrackRefs");
irefbr->SetAddress(&indexedtrackrefs);
for (int i = 0; i < mcbr->GetEntries(); ++i) {
mcbr->GetEntry(i);
refbr->GetEntry(i);
irefbr->GetEntry(i);
LOG(DEBUG) << "-- Entry --" << i << "\n";
LOG(DEBUG) << "Have " << mctracks->size() << " tracks \n";
int ti = 0;
// record tracks that left a hit in TPC
// (we know that these tracks should then have a TrackRef)
std::vector<int> trackidsinTPC;
for (auto& t : *mctracks) {
// check that mother indices are reasonable
assert(ti > t.getMotherTrackId());
if (t.leftTrace(o2::detectors::DetID::TPC)) {
trackidsinTPC.emplace_back(ti);
}
LOG(DEBUG) << " track " << ti << "\t" << t.getMotherTrackId() << " hits " << t.hasHits() << "\n";
ti++;
}
LOG(DEBUG) << "Have " << trackidsinTPC.size() << " tracks with hits in TPC\n";
LOG(DEBUG) << "Have " << trackrefs->size() << " track refs \n";
LOG(DEBUG) << "Have " << indexedtrackrefs->getIndexedSize() << " mapped tracks\n";
LOG(DEBUG) << "Have " << indexedtrackrefs->getNElements() << " track refs\n";
bool havereferences = trackrefs->size();
if (havereferences) {
for (auto& i : trackidsinTPC) {
auto labels = indexedtrackrefs->getLabels(i);
assert(labels.size() > 0);
LOG(DEBUG) << " Track " << i << " has " << labels.size() << " TrackRefs "
<< "\n";
for (int j = 0; j < labels.size(); ++j) {
LOG(DEBUG) << labels[j];
}
}
}
}
LOG(INFO) << "STACK TEST SUCCESSFULL\n";
}