1- // Checks which strangeness tables (and which versions) are present in a derived AO2D
2- // and reports which steps of the V0 tutorial (o2-analysistutorial-lf-strangeness-derived-v0-*) can run.
1+ // Copyright 2019-2020 CERN and copyright holders of ALICE O2.
2+ // See https://alice-o2.web.cern.ch/copyright for details of the copyright holders.
3+ // All rights not expressly granted are reserved.
34//
4- // Usage: root -l -b -q 'checkTables.C("data/AO2D.root")' or something like root -l -b -q "checkTables.C(\"$(cat input_data.txt)\")"
5+ // This software is distributed under the terms of the GNU General Public
6+ // License v3 (GPL Version 3), copied verbatim in the file "COPYING".
7+ //
8+ // In applying this license CERN does not waive the privileges and immunities
9+ // granted to it by virtue of its status as an Intergovernmental Organization
10+ // or submit itself to any jurisdiction.
11+
12+ /// \file checkTables.C
13+ /// \brief Checks which strangeness tables (and which versions) are present in a derived AO2D
14+ /// and reports which steps of the V0 tutorial (o2-analysistutorial-lf-strangeness-derived-v0-*) can run.
15+ ///
16+ /// Usage: root -l -b -q 'checkTables.C("data/AO2D.root")' or something like root -l -b -q "checkTables.C(\"$(cat input_data.txt)\")"
517
18+ #include <TCollection.h>
619#include <TDirectory.h>
720#include <TFile.h>
821#include <TKey.h>
1427#include <vector>
1528
1629struct RequiredTable {
17- std ::string base ; // tree name without version, e.g. "o2straevsels"
18- int version ; // version required by the current O2Physics data model
19- int firstStep ; // first step that uses it (-1 = skeleton)
20- std ::string hint ; // converter to use if the version in the file is older
30+ std ::string base ; // tree name without version, e.g. "o2straevsels"
31+ int version { 0 }; // version required by the current O2Physics data model
32+ int firstStep { -1 }; // first step that uses it (-1 = skeleton)
33+ std ::string hint ; // converter to use if the version in the file is older
2134};
2235
2336int findVersion (TDirectory * dir , const std ::string & base )
2437{
2538 int found = -1 ;
2639 TIter next (dir -> GetListOfKeys ());
27- while (TKey * key = static_cast < TKey * > (next ())) {
40+ while (TKey * key = dynamic_cast < TKey * > (next ())) {
2841 TString name = key -> GetName ();
2942 name .ToLower ();
3043 if (name == base .c_str ()) {
@@ -42,27 +55,27 @@ int findVersion(TDirectory* dir, const std::string& base)
4255void checkTables (const char * fname = "data/AO2D.root" )
4356{
4457 const std ::vector < RequiredTable > required = {
45- {"o2stracollision" , 0 , -1 , "" },
46- {"o2straevsels" , 6 , -1 , "o2-analysis-lf-straevselsconverterN (chain up to straevselsconverter6)" },
47- {"o2v0core" , 0 , 0 , "" },
48- {"o2v0extra" , 0 , 2 , "" },
49- {"o2dautrackextra" , 3 , 2 , "o2-analysis-lf-stradautracksextraconverterN (up to stradautracksextraconverter3)" },
50- {"o2dautracktpcpid" , 1 , 2 , "o2-analysis-lf-stradautrackstpcpidconverter" },
58+ {. base = "o2stracollision" , . version = 0 , . firstStep = -1 , . hint = "" },
59+ {. base = "o2straevsels" , . version = 6 , . firstStep = -1 , . hint = "o2-analysis-lf-straevselsconverterN (chain up to straevselsconverter6)" },
60+ {. base = "o2v0core" , . version = 0 , . firstStep = 0 , . hint = "" },
61+ {. base = "o2v0extra" , . version = 0 , . firstStep = 2 , . hint = "" },
62+ {. base = "o2dautrackextra" , . version = 3 , . firstStep = 2 , . hint = "o2-analysis-lf-stradautracksextraconverterN (up to stradautracksextraconverter3)" },
63+ {. base = "o2dautracktpcpid" , . version = 1 , . firstStep = 2 , . hint = "o2-analysis-lf-stradautrackstpcpidconverter" },
5164 // step 3: tables read as input by the helper task strangenesstofpid,
5265 // not by the analysis itself: the tutorial only uses V0s
53- {"o2strastamps" , 1 , 3 , "o2-analysis-lf-strastampsconverter" },
54- {"o2straevtimes" , 1 , 3 , "o2-analysis-lf-stradautrackstofpidconverter3" },
55- {"o2dautracktofpid" , 3 , 3 , "o2-analysis-lf-stradautrackstofpidconverterN (up to stradautrackstofpidconverter4)" },
56- {"o2v0collref" , 0 , 3 , "" },
57- {"o2casccore" , 0 , 3 , "" },
58- {"o2cascextra" , 0 , 3 , "" },
59- {"o2casccollref" , 0 , 3 , "" },
66+ {. base = "o2strastamps" , . version = 1 , . firstStep = 3 , . hint = "o2-analysis-lf-strastampsconverter" },
67+ {. base = "o2straevtimes" , . version = 1 , . firstStep = 3 , . hint = "o2-analysis-lf-stradautrackstofpidconverter3" },
68+ {. base = "o2dautracktofpid" , . version = 3 , . firstStep = 3 , . hint = "o2-analysis-lf-stradautrackstofpidconverterN (up to stradautrackstofpidconverter4)" },
69+ {. base = "o2v0collref" , . version = 0 , . firstStep = 3 , . hint = "" },
70+ {. base = "o2casccore" , . version = 0 , . firstStep = 3 , . hint = "" },
71+ {. base = "o2cascextra" , . version = 0 , . firstStep = 3 , . hint = "" },
72+ {. base = "o2casccollref" , . version = 0 , . firstStep = 3 , . hint = "" },
6073 // step 4: MC
61- {"o2v0coremclabel" , 0 , 4 , "" },
62- {"o2v0mccore" , 2 , 4 , "o2-analysis-lf-v0coresconverter / v0coresconverter2" },
63- {"o2v0mccollref" , 0 , 4 , "" },
64- {"o2stracolllabels" , 0 , 4 , "" },
65- {"o2stramccollision" , 2 , 4 , "o2-analysis-lf-stramccollisionconverter / stramccollisionconverter2" },
74+ {. base = "o2v0coremclabel" , . version = 0 , . firstStep = 4 , . hint = "" },
75+ {. base = "o2v0mccore" , . version = 2 , . firstStep = 4 , . hint = "o2-analysis-lf-v0coresconverter / v0coresconverter2" },
76+ {. base = "o2v0mccollref" , . version = 0 , . firstStep = 4 , . hint = "" },
77+ {. base = "o2stracolllabels" , . version = 0 , . firstStep = 4 , . hint = "" },
78+ {. base = "o2stramccollision" , . version = 2 , . firstStep = 4 , . hint = "o2-analysis-lf-stramccollisionconverter / stramccollisionconverter2" },
6679 };
6780
6881 TFile * f = TFile ::Open (fname );
@@ -72,7 +85,7 @@ void checkTables(const char* fname = "data/AO2D.root")
7285 }
7386 TDirectory * df = nullptr ;
7487 TIter next (f -> GetListOfKeys ());
75- while (TKey * key = static_cast < TKey * > (next ())) {
88+ while (TKey * key = dynamic_cast < TKey * > (next ())) {
7689 if (TString (key -> GetName ()).BeginsWith ("DF_" )) {
7790 df = f -> GetDirectory (key -> GetName ());
7891 break ;
@@ -85,7 +98,7 @@ void checkTables(const char* fname = "data/AO2D.root")
8598
8699 std ::cout << "\nTrees in " << df -> GetName () << ":\n" ;
87100 TIter nextTree (df -> GetListOfKeys ());
88- while (TKey * key = static_cast < TKey * > (nextTree ())) {
101+ while (TKey * key = dynamic_cast < TKey * > (nextTree ())) {
89102 std ::cout << " " << key -> GetName () << "\n" ;
90103 }
91104
@@ -116,7 +129,7 @@ void checkTables(const char* fname = "data/AO2D.root")
116129 std ::cout << "\nSummary:\n" ;
117130 for (int s = -1 ; s <= 4 ; s ++ ) {
118131 TString name = s < 0 ? "skeleton" : Form ("step%d" , s );
119- TString res = s >= firstBrokenStep ? "CANNOT run with this file"
132+ TString res = s >= firstBrokenStep ? "CANNOT run with this file"
120133 : s >= firstConverterStep ? "ok, but converters are needed"
121134 : "ok" ;
122135 std ::cout << Form (" %-8s %s\n" , name .Data (), res .Data ());
0 commit comments