ATLAS Offline Software
Loading...
Searching...
No Matches
CalibrationDataUtilities.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2022 CERN for the benefit of the ATLAS collaboration
3*/
4
6// //
7// CalibrationDataUtilities //
8// //
9// This file collects a few utility functions allowing access to information stored in a //
10// CalibrationDataInterface ROOT file. //
11// //
12// CalibrationDataUtilities.cxx, (c) ATLAS Detector software //
14
16#include "TMap.h"
17#include "TFile.h"
18#include "TObjString.h"
19
20#include <iostream>
21#include <iomanip>
22using std::string;
23using std::cout;
24using std::cerr;
25using std::endl;
26using std::setw;
27using std::setfill;
28
29void
30Analysis::showHadronisations(const char* filename, const char* directory)
31{
32 // Print a summary of the fragmentation and decay settings for the specified
33 // file and internal directory
34
35 std::map<string, string> refs = getHadronisations(filename, directory);
36 if (refs.size() == 0) {
37 cerr << "unable to retrieve hadronisation references for directory " << directory << endl;
38 return;
39 }
40
41 cout << setw(27) << "hadronisation specification" << " reference calibration" << endl;
42 cout << setfill('-') << setw(60) << "-" << endl;
43 cout << setfill(' ');
44 for (std::map<string, string>::iterator it = refs.begin(); it != refs.end(); ++it)
45 cout << setw(27) << it->first << " " << it->second << endl;
46}
47
48std::map<string, string>
49Analysis::getHadronisations(const char* filename, const char* directory)
50{
51 // Retrieve the fragmentation and decay settings for the specified
52 // file and internal directory. An empty map will be returned in case
53 // of error.
54
55 std::map<string, string> final;
56
57 TFile* file = TFile::Open(filename, "READ");
58 if (file->IsZombie()) return final;
59
60 string refname(directory); refname += "/MChadronisation_ref";
61 TMap* original;
62 file->GetObject(refname.c_str(), original);
63 if (!original) return final;
64
65 TMapIter next(original); TObjString* spec;
66 while ((spec = (TObjString*) next())) {
67 TObjString* ref = (TObjString*) original->GetValue(spec);
68 final[string(spec->GetName())] = string(ref->GetName());
69 }
70 return final;
71}
72
73void
74Analysis::showBuildNumber(const char* filename)
75{
76 // Print the CDI file's build number (if it was an "official" CDI file)
77
78 TFile* file = TFile::Open(filename, "READ");
79 if (file->IsZombie()) {
80 cout << "Error opening file " << filename << endl;
81 return;
82 }
83
84 TObjString* s;
85 file->GetObject("VersionInfo/BuildNumber", s);
86 if (!s) {
87 cout << "No build number found in file " << filename << endl;
88 return;
89 }
90 cout << "File " << filename << " has build number " << s->GetName() << endl;
91}
const boost::regex ref(r_ef)
void showBuildNumber(const char *filename)
std::map< std::string, std::string > getHadronisations(const char *filename, const char *directory)
void showHadronisations(const char *filename, const char *directory)
str directory
Definition DeMoScan.py:78
TFile * file