ATLAS Offline Software
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>
22 using std::string;
23 using std::cout;
24 using std::cerr;
25 using std::endl;
26 using std::setw;
27 using std::setfill;
28 
29 void
30 Analysis::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 
48 std::map<string, string>
49 Analysis::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 
73 void
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 }
xAOD::iterator
JetConstituentVector::iterator iterator
Definition: JetConstituentVector.cxx:68
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
Analysis::showBuildNumber
void showBuildNumber(const char *filename)
CaloCondBlobAlgs_fillNoiseFromASCII.spec
spec
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:47
skel.it
it
Definition: skel.GENtoEVGEN.py:396
fillPileUpNoiseLumi.next
next
Definition: fillPileUpNoiseLumi.py:52
DeMoScan.directory
string directory
Definition: DeMoScan.py:80
Analysis::getHadronisations
std::map< std::string, std::string > getHadronisations(const char *filename, const char *directory)
Analysis::showHadronisations
void showHadronisations(const char *filename, const char *directory)
file
TFile * file
Definition: tile_monitor.h:29
ref
const boost::regex ref(r_ef)
CaloCellTimeCorrFiller.filename
filename
Definition: CaloCellTimeCorrFiller.py:24
CalibrationDataUtilities.h