9#ifndef ANALYSISCDIREADER_H
10#define ANALYSISCDIREADER_H
17#include <unordered_map>
21#include "TDirectoryFile.h"
24#include "TObjString.h"
41 typedef std::vector<std::string>
Labels;
42 typedef std::map<std::string, Labels>
Data;
43 typedef std::map<std::string, Data>
WPoint;
44 typedef std::map<std::string, WPoint>
JetColl;
45 typedef std::map<std::string, JetColl>
Meta;
54 std::cout <<
"number of taggers: " <<
m_taggers.size() << std::endl;
56 std::cout << el <<
", ";
57 } std::cout << std::endl;
61 std::cout <<
"number of jet collections: " <<
m_jetcollections.size() << std::endl;
63 std::cout << el <<
", ";
64 } std::cout << std::endl;
68 std::cout <<
"number of working points: " <<
m_workingpoints.size() << std::endl;
70 std::cout << el <<
", ";
71 } std::cout << std::endl;
75 std::cout <<
"number of labels: " <<
m_labels.size() << std::endl;
76 for(
const std::string& el :
m_labels){
77 std::cout << el <<
", ";
78 } std::cout << std::endl;
83 std::cout <<
"number of DSIDs: " << DSIDs.size() << std::endl;
84 for(
const std::string& el : DSIDs){
85 std::cout << el <<
", ";
86 } std::cout << std::endl;
89 bool checkConfig(
const std::string& tagger,
const std::string& jetcoll,
const std::string& wp,
bool verbose =
false);
90 Labels getDSIDs(
const std::string& tagger =
"",
const std::string& jetcollection =
"",
const std::string& workingpoint =
"");
91 Labels getLabels(
const std::string& tagger =
"",
const std::string& jetcollection =
"",
const std::string& workingpoint =
"");
98 void printMetadata(
int tagger = -1,
int jetcoll = -1,
int wpoint = -1,
int label = -1);
111 void crawlCDI(TDirectoryFile* parentDir,
int depth = 0,
const std::string& metamap =
"");
128 std::cout <<
" record_metadata :: depth is " <<
depth << std::endl;
134 int size = metamap_path.size();
136 m_metadata[metamap_path.at(0)][metamap_path.at(1)][metamap_path.at(2)] =
data;
138 std::cout <<
" record_metadata_map :: the directory structure doesn't match what we expect!" << std::endl;
145 for(
const auto label : *list){
146 const char* labelname =
label->GetName();
147 if(strcmp(labelname,
"B") == 0 || strcmp(labelname,
"C") == 0
148 || strcmp(labelname,
"Light") == 0 || strcmp(labelname,
"T") == 0
149 || strcmp(labelname,
"Z_BB") == 0 || strcmp(labelname,
"QCD_BB") == 0
150 || strcmp(labelname,
"Top_BX") == 0)
return true;
156 std::string
trim(
const std::string&
str,
const std::string& whitespace =
" \t") {
157 const auto strBegin =
str.find_first_not_of(whitespace);
158 if (strBegin == std::string::npos){
161 const auto strEnd =
str.find_last_not_of(whitespace);
162 const auto strRange = strEnd - strBegin + 1;
163 return str.substr(strBegin, strRange);
167 std::vector<std::string>
split(
const std::string&
str,
char token =
';') {
168 std::vector<std::string>
result;
169 if (
str.size() > 0) {
170 std::string::size_type end;
171 std::string tmp(
str);
173 end = tmp.find(token);
174 std::string entry =
trim(tmp.substr(0,end));
175 if (!entry.empty())
result.push_back(std::move(entry));
176 if (end != std::string::npos) tmp = tmp.substr(end+1);
177 }
while (end != std::string::npos);
char data[hepevt_bytes_allocation_ATLAS]
void record_metadata(const std::string &datum, int depth=0)
Labels getDSIDs(const std::string &tagger="", const std::string &jetcollection="", const std::string &workingpoint="")
void printWorkingPoints()
Labels getLabels(const std::string &tagger="", const std::string &jetcollection="", const std::string &workingpoint="")
std::unique_ptr< TFile > m_CDIFile
std::set< std::string > m_taggers
std::set< std::string > m_DSIDs
void record_metadata_map(const Data &data, const std::string &path)
Labels getWorkingPoints(const std::string &tagger, const std::string &jetcollection)
bool checkConfig(const std::string &tagger, const std::string &jetcoll, const std::string &wp, bool verbose=false)
bool isWPdirectory(TList *list)
std::set< std::string > m_workingpoints
void printJetCollections()
Labels getJetCollections(const std::string &tagger)
std::map< std::string, JetColl > Meta
std::set< std::string > m_jetcollections
std::map< std::string, WPoint > JetColl
CDIReader(const std::string &cdipath, bool verbose=false)
normal constructor.
std::string trim(const std::string &str, const std::string &whitespace=" \t")
std::set< std::string > m_labels
std::map< std::string, Labels > Data
std::vector< std::string > split(const std::string &str, char token=';')
void printMetadata(int tagger=-1, int jetcoll=-1, int wpoint=-1, int label=-1)
std::map< std::string, Data > WPoint
std::vector< std::string > Labels
bool m_initialized
flag whether the initialization has been carried out
void crawlCDI(TDirectoryFile *parentDir, int depth=0, const std::string &metamap="")
std::string depth
tag string for intendation
std::string label(const std::string &format, int i)
The namespace of all packages in PhysicsAnalysis/JetTagging.