20 #ifndef SIMULATIONBASE
22 #endif // not SIMULATIONBASE
38 bool findBranch(TBranch*
br,
const std::string& nametag,
const std::string&
type,
39 std::pair<bool,T*>& destination)
const;
49 std::pair<bool,T*>& destination)
const {
50 const std::string
brName(
br->GetName());
51 const std::string brType(
br->GetClassName());
52 if (
brName.find(nametag)!=std::string::npos && brType==
type) {
53 if (destination.first) {
54 std::cerr <<
"WARNING: Found more than one " <<
type <<
" labelled '" << nametag <<
"'. Ignoring " <<
brName << std::endl;
57 destination.first=
true;
58 br->SetAddress(&destination.second);
73 std::unique_ptr<TFile> tf(TFile::Open(
filename));
74 if (!tf || tf->IsZombie()) {
75 std::cerr <<
"Failed to open file " <<
filename << std::endl;
80 if (vbs) std::cout <<
"Time to open input file: " << std::chrono::duration_cast<std::chrono::milliseconds>(
stop-
start).count() <<
" msec" << std::endl;
83 TTree* md=(TTree*)tf->Get(
"MetaData");
87 std::pair<bool,EventStreamInfo_p3*> esi{
false,
nullptr};
88 std::pair<bool,EventStreamInfo_p2*> esi2{
false,
nullptr};
89 std::pair<bool,IOVMetaDataContainer_p1*> taginfo{
false,
nullptr};
90 std::pair<bool,IOVMetaDataContainer_p1*> genparam{
false,
nullptr};
91 std::pair<bool,IOVMetaDataContainer_p1*> simparam{
false,
nullptr};
92 std::pair<bool,IOVMetaDataContainer_p1*> digiparam{
false,
nullptr};
93 #ifndef SIMULATIONBASE
94 std::pair<bool,ByteStreamMetadataContainer_p1*> bmdc{
false,
nullptr};
95 #endif // not SIMULATIONBASE
96 TObjArray* mdBranches=md->GetListOfBranches();
97 const size_t mdnBranches=mdBranches->GetEntriesFast();
98 for (
size_t i=0;
i<mdnBranches;++
i) {
99 TBranch*
br=(TBranch*)mdBranches->At(
i);
100 if (vbs) std::cout <<
"Branch "<<
br->GetName() <<
" of type " <<
br->GetClassName() << std::endl;
101 #ifndef SIMULATIONBASE
102 if (
findBranch(
br,
"ByteStreamMetadata",
"ByteStreamMetadataContainer_p1",bmdc))
continue;
103 #endif // not SIMULATIONBASE
104 if (
findBranch(
br,
"_TagInfo",
"IOVMetaDataContainer_p1",taginfo))
continue;
105 if (
findBranch(
br,
"_Generation_Parameters",
"IOVMetaDataContainer_p1",genparam))
continue;
106 if (
findBranch(
br,
"_Simulation_Parameters",
"IOVMetaDataContainer_p1",simparam))
continue;
107 if (
findBranch(
br,
"_Digitization_Parameters",
"IOVMetaDataContainer_p1",digiparam))
continue;
108 if (
findBranch(
br,
"Stream",
"EventStreamInfo_p3",esi))
continue;
109 if (
findBranch(
br,
"Stream",
"EventStreamInfo_p2",esi2))
continue;
118 if (genparam.first) {
119 if (vbs) std::cout <<
" Got IOVMetaDataContainer for /Generation/Parameters " << std::endl;
120 for (
const auto&
idx : genparam.second->m_payload.m_attrIndexes) {
121 const unsigned short nameIdx=
idx.nameIndex();
123 const unsigned short iObj=
idx.objIndex();
124 const std::string objKey=genparam.second->m_payload.m_attrName[nameIdx];
125 const std::string objValue=genparam.second->m_payload.m_string[iObj];
126 if (vbs) std::cout <<
"Genparam: " << objKey <<
" : " << objValue << std::endl;
130 delete genparam.second;
131 genparam.second=
nullptr;
134 if (simparam.first) {
135 if (vbs) std::cout <<
" Got IOVMetaDataContainer for /Simulation/Parameters " << std::endl;
136 for (
const auto&
idx : simparam.second->m_payload.m_attrIndexes) {
137 const unsigned short nameIdx=
idx.nameIndex();
139 const unsigned short iObj=
idx.objIndex();
140 const std::string objKey=simparam.second->m_payload.m_attrName[nameIdx];
141 const std::string objValue=simparam.second->m_payload.m_string[iObj];
142 if (vbs) std::cout <<
"Simparam: " << objKey <<
" : " << objValue << std::endl;
143 if (objKey==
"TRTRangeCut") {
144 std::string::size_type
sz;
147 if (objKey==
"beamType") {
153 delete simparam.second;
154 simparam.second=
nullptr;
157 if (digiparam.first) {
158 if (vbs) std::cout <<
" Got IOVMetaDataContainer for /Digitization/Parameters " << std::endl;
159 for (
const auto&
idx : digiparam.second->m_payload.m_attrIndexes) {
160 const unsigned short nameIdx=
idx.nameIndex();
162 const unsigned short iObj=
idx.objIndex();
163 const std::string objKey=digiparam.second->m_payload.m_attrName[nameIdx];
164 const std::string objValue=digiparam.second->m_payload.m_string[iObj];
165 if (vbs) std::cout <<
"Digiparam: " << objKey <<
" : " << objValue << std::endl;
166 if (objKey==
"IOVDbGlobalTag") {
169 if (objKey==
"DetDescrVersion") {
172 if (objKey==
"beamType") {
178 delete digiparam.second;
179 digiparam.second=
nullptr;
183 if (vbs) std::cout <<
" Got IOVMetaDataContainer for TagInfo " << std::endl;
184 for (
const auto&
idx : taginfo.second->m_payload.m_attrIndexes) {
186 const unsigned short nameIdx=
idx.nameIndex();
188 const unsigned short iObj=
idx.objIndex();
189 const std::string objKey=taginfo.second->m_payload.m_attrName[nameIdx];
190 const std::string objValue=taginfo.second->m_payload.m_string[iObj];
191 if (vbs) std::cout <<
"Taginfo: " << objKey <<
" : " << objValue << std::endl;
192 if (objKey==
"IOVDbGlobalTag") {
195 if (objKey==
"GeoAtlas") {
198 if (objKey==
"beam_energy") {
201 if (objKey==
"beam_type") {
207 delete taginfo.second;
208 taginfo.second=
nullptr;
212 if (vbs) std::cout <<
" Got EventStreamInfo_p3" << std::endl;
214 esi.second->m_runNumbers.end());
216 esi.second->m_lumiBlockNumbers.end());
220 const std::vector<std::pair<unsigned int, std::string> >& itemList=esi.second->m_itemList;
221 for (
const auto& kw : itemList) {
229 else if (esi2.first) {
231 if (vbs) std::cout <<
" Got legacy EventStreamInfo_p2" << std::endl;
233 esi2.second->m_runNumbers.end());
235 esi2.second->m_lumiBlockNumbers.end());
241 std::set<unsigned> bmc_runNumbers;
242 #ifndef SIMULATIONBASE
244 if (vbs) std::cout <<
" Got ByteStreamMetadataContainer" << std::endl;
246 for (
const auto& bmd : *bmdc.second) {
247 bmc_runNumbers.insert(bmd.m_runNumber);
252 std::cerr <<
"Conflicting stream names in file! Got " <<
260 std::cerr <<
"Conflicting project names in file! Got " <<
265 const std::vector<std::string>& freeMDs=bmd.m_freeMetaDataStrings;
266 for (
const std::string& freeMD : freeMDs) {
267 if (freeMD.compare(0,11,
"Event type:")==0 && freeMD.find(
"is sim")!=std::string::npos) {
276 #endif // not SIMULATIONBASE
287 std::cerr <<
"Mismatching run numbers in file metadata!" << std::endl;
288 std::cerr <<
"EventStreamInfo: ";
290 std::cerr << std::endl;
291 std::cerr <<
"ByteStreamEventInfo: ";
292 std::copy(bmc_runNumbers.begin(),bmc_runNumbers.end(),std::ostream_iterator<unsigned>(std::cerr,
" "));
293 std::cerr << std::endl;
299 TTree*
params=(TTree*)tf->Get(
"##Params");
300 const unsigned nParamsEntries=
params->GetEntries();
303 params->SetBranchAddress(
"db_string",&dbStr);
305 const std::string starter(
"[NAME=FID][VALUE=");
306 for (
unsigned i=0;
i<nParamsEntries;++
i) {
309 const std::string
field(dbStr);
311 if (
field.compare(starter)) {
318 TTree*
tt=(TTree*)tf->Get(
"CollectionTree");
320 std::cerr <<
"Failed to read collectionTree" << std::endl;
336 while ((
c = getopt (
argc,
argv,
"vk")) != -1) {
345 std::cerr <<
"Unkown command line option" << std::endl;
350 const int nfiles=
argc-optind;
352 std::cerr <<
"Expected at least one file name as parameter" << std::endl;
357 std::vector<FileMetaData>
output;
359 for (
int iFile=optind;iFile<
argc;++iFile) {
371 for (
const auto& o :
output) o.keyValueDump();
374 for (
const auto& o :
output) o.dump();