32int main(
int argc,
char** argv)
34 const char* nameprefix = argv[1];
36 fair::Logger::SetConsoleSeverity(
"DEBUG");
39 LOG(
debug) <<
"Checking input file :" <<
f.GetPath();
41 std::vector<o2::MCTrack>* mctracks =
nullptr;
42 auto tr = (TTree*)
f.Get(
"o2sim");
45 auto mcbr = tr->GetBranch(
"MCTrack");
47 mcbr->SetAddress(&mctracks);
49 std::vector<o2::TrackReference>* trackrefs =
nullptr;
50 auto refbr = tr->GetBranch(
"TrackRefs");
52 refbr->SetAddress(&trackrefs);
58 auto hittr = (TTree*)hitf.Get(
"o2sim");
59 auto hitbr = hittr ? hittr->GetBranch(
"ITSHit") :
nullptr;
60 std::vector<o2::itsmft::Hit>* hits =
nullptr;
62 hitbr->SetAddress(&hits);
65 for (
int eventID = 0; eventID < mcbr->GetEntries(); ++eventID) {
66 mcbr->GetEntry(eventID);
67 refbr->GetEntry(eventID);
68 LOG(
debug) <<
"-- Entry --" << eventID;
69 LOG(
debug) <<
"Have " << mctracks->size() <<
" tracks";
71 std::unordered_map<int, bool> trackidsinITS_fromhits;
73 hitbr->GetEntry(eventID);
74 LOG(
debug) <<
"Have " << hits->size() <<
" hits";
78 for (
auto&
h : *hits) {
79 maxid = std::max(maxid,
h.GetTrackID());
80 trackidsinITS_fromhits[
h.GetTrackID()] =
true;
81 assert(maxid < mctracks->
size());
89 std::vector<int> trackidsinTPC;
90 std::vector<int> trackidsinITS;
96 int physicalprimaries = 0;
98 for (
auto& t : *mctracks) {
100 if (t.GetMass() < 0) {
101 LOG(info) <<
"Mass not found for PDG " << t.GetPdgCode();
104 if (t.isSecondary()) {
107 assert(ti > t.getMotherTrackId());
111 trackidsinTPC.emplace_back(ti);
114 trackidsinITS.emplace_back(ti);
118 LOG(
debug) <<
" track " << ti <<
"\t" << t.getMotherTrackId() <<
" hits " << t.hasHits() <<
" isPhysicalPrimary " << physicalPrim;
131 assert(trackidsinITS.size() == trackidsinITS_fromhits.size());
132 for (
auto id : trackidsinITS) {
133 assert(trackidsinITS_fromhits[
id] ==
true);
137 LOG(
debug) <<
"Have " << trackidsinTPC.size() <<
" tracks with hits in TPC";
138 LOG(
debug) <<
"Have " << trackrefs->size() <<
" track refs";
139 LOG(info) <<
"Have " << primaries <<
" primaries and " << physicalprimaries <<
" physical primaries";
142 bool havereferences = trackrefs->size();
143 if (havereferences) {
144 for (
auto& trackID : trackidsinTPC) {
145 auto tpc_trackrefs = mcreader.
getTrackRefs(eventID, trackID);
146 LOG(
debug) <<
" Track " << trackID <<
" has " << tpc_trackrefs.size() <<
" TrackRefs";
147 assert(tpc_trackrefs.size() > 0);
148 for (
auto&
ref : tpc_trackrefs) {
149 assert(
ref.getTrackID() == trackID);
154 LOG(info) <<
"STACK TEST SUCCESSFULL\n";