9#ifndef ANALYSISCDIREADER_H
10#define ANALYSISCDIREADER_H
17#include "TDirectoryFile.h"
20#include "TObjString.h"
30#include <unordered_map>
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::vector<std::string>
split(
const std::string&
str,
char token =
';') {
157 std::vector<std::string> result;
158 if (
str.size() > 0) {
159 std::string::size_type end;
160 std::string tmp(
str);
162 end = tmp.find(token);
164 if (!entry.empty()) result.push_back(std::move(entry));
165 if (end != std::string::npos) tmp = tmp.substr(end+1);
166 }
while (end != std::string::npos);
char data[hepevt_bytes_allocation_ATLAS]
size_t size() const
Number of registered mappings.
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::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.
std::string_view trimWhiteSpaces(std::string_view str) noexcept
Removes all trailing and starting whitespaces from a string.