ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
PhysicsAnalysis
JetTagging
JetTagPerformanceCalibration
CalibrationDataInterface
Root
CalibrationDataBackend.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
// 'Back-end' utilities for the CalibrationDataInterface code
8
//
10
11
#include "
CalibrationDataInterface/CalibrationDataContainer.h
"
12
#include "
CalibrationDataInterface/CalibrationDataBackend.h
"
13
14
#include <iostream>
15
#include <string>
16
17
#include "TFile.h"
18
#include "TMap.h"
19
#include "TObjString.h"
20
#include "TDirectory.h"
21
22
// Name of the object holding the MC hadronisation references
23
// (this is used for the application of MC-to-MC calibration scale factors)
24
25
static
const
std::string
hadronisationRefs
(
"MChadronisation_ref"
);
26
27
// Back-end method for addition of a container to an existing file.
28
// Notes:
29
// - "name" should be the full name (i.e., include the "_Eff" or "_SF" suffix)
30
// - this function will change the global gDirectory. If the working directory is to be
31
// preserved then the variable needs to be saved by the user prior to the function call
32
33
Int_t
34
Analysis::addContainer
(
Analysis::CalibrationDataContainer
* cnt, TFile*
file
,
const
char
* tagger,
35
const
char
* jetAuthor,
const
char
* OP,
const
char
* flavour,
const
char
* name,
36
bool
isReference) {
37
file
->cd(
"/"
); TDirectory* dir = gDirectory;
38
// top level: tagger
39
TDirectory* taggerDir = dir->GetDirectory(tagger);
40
if
(! taggerDir) taggerDir = dir->mkdir(tagger);
41
// then: jet author
42
TDirectory* authorDir = taggerDir->GetDirectory(jetAuthor);
43
if
(! authorDir) authorDir = taggerDir->mkdir(jetAuthor);
44
// then: operating point
45
TDirectory* OPDir = authorDir->GetDirectory(OP);
46
if
(! OPDir) OPDir = authorDir->mkdir(OP);
47
// finally: flavour
48
TDirectory* flavourDir = OPDir->GetDirectory(flavour);
49
if
(! flavourDir) flavourDir = OPDir->mkdir(flavour);
50
51
Int_t nbytes = flavourDir->WriteTObject (cnt, name,
"SingleKey"
);
52
53
if
(isReference) {
54
// first retrieve the hadronisation reference for this container
55
std::string
ref
= cnt->getHadronisation();
56
// make sure that the name is well defined
57
const
char
* cntname = (name) ? name : cnt->GetName();
58
if
(
ref
.empty())
59
std::cerr <<
"addContainer(): container does not have a MC hadronisation reference!"
<< std::endl;
60
else
if
(std::string(cntname).
find
(
"_Eff"
) == std::string::npos)
61
std::cerr <<
"addContainer(): container is not a MC efficiency object!"
<< std::endl;
62
else
{
63
// retrieve the map (or create it if it doesn't already exist)
64
TMap*
map
;
65
flavourDir->GetObject(
hadronisationRefs
.c_str(),
map
);
66
if
(!
map
)
map
=
new
TMap;
67
// add (or replace, if it already exists) the histogram name for this hadronisation reference
68
if
(TPair* p = (TPair*)
map
->FindObject(
ref
.c_str()))
map
->DeleteEntry(p->Key());
69
map
->Add(
new
TObjString(
ref
.c_str()),
new
TObjString(cntname));
70
// save the map to file (deleting any previous version)
71
flavourDir->WriteTObject (
map
,
hadronisationRefs
.c_str(),
"WriteDelete SingleKey"
);
72
}
73
}
74
75
return
nbytes;
76
}
77
ref
const std::regex ref(r_ef)
hadronisationRefs
static const std::string hadronisationRefs("MChadronisation_ref")
CalibrationDataBackend.h
CalibrationDataContainer.h
if
if(pathvar)
Definition
SealSharedLib.cxx:168
Analysis::CalibrationDataContainer
This is the interface for the objects to be stored in the calibration ROOT file.
Definition
CalibrationDataContainer.h:51
map
STL class.
find
std::string find(const std::string &s)
return a remapped string
Definition
hcg.cxx:140
Analysis::addContainer
Int_t addContainer(Analysis::CalibrationDataContainer *cnt, TFile *file, const char *tagger, const char *jetAuthor, const char *OP, const char *flavour, const char *name=0, bool isReference=false)
file
TFile * file
Definition
tile_monitor.h:29
Generated on
for ATLAS Offline Software by
1.17.0