12 #include "TDirectory.h"
42 bool newInput = (m_inputRootFile.empty());
44 fIn =
new TFile(m_inputRootFile.c_str());
45 if (
fIn->IsZombie()) {
48 return StatusCode::FAILURE;
50 }
else if (! m_overrideDefaults) {
51 ATH_MSG_FATAL(
name() <<
": no input ROOT file given and no defaults to be modified:"
52 <<
" no action to be taken" );
53 return StatusCode::FAILURE;
55 if (m_DbRootFile.empty()) {
57 return StatusCode::FAILURE;
59 TFile*
fOut =
new TFile(m_DbRootFile.c_str(),
"UPDATE");
60 if (
fOut->IsZombie()) {
63 return StatusCode::FAILURE;
66 for (
const std::string& itname : m_paramNames){
71 const string::size_type delim = itname->find(
"->");
72 string from = (delim == string::npos) ? *itname : itname->substr(0, delim);
73 if (delim != string::npos)
to = itname->substr(delim+2);
75 }
else if (! isValidName(
to)) {
80 setDefaultResults(
to,
fOut);
88 return StatusCode::SUCCESS;
100 string::size_type delim =
Name.rfind(
"/");
101 string dir =
Name.substr(0, delim);
102 TDirectory* newdir =
fOut->GetDirectory(
dir.c_str());
103 if (! newdir->cd()) {
106 <<
gDirectory->GetPath() <<
"; cd() to subdir "
107 <<
dir <<
" failed!" );
112 delim =
Name.rfind(
"_");
113 string defaultName(
"default"); defaultName +=
Name.substr(delim);
114 if (! m_overrideDefaults) {
120 <<
Name <<
" (+ stat., syst.) as default" );
123 obj->Write(defaultName.c_str());
126 string nameCov(
Name); nameCov +=
"_stat";
127 string defaultNameCov(defaultName); defaultNameCov +=
"_stat";
128 fOut->Get(nameCov.c_str())->Write(defaultNameCov.c_str());
131 string nameSyst(
Name); nameSyst +=
"_syst";
132 string defaultNameSyst(defaultName); defaultNameSyst +=
"_syst";
133 fOut->Get(nameSyst.c_str())->Write(defaultNameSyst.c_str());
139 if (! isValidName(
to)) {
145 TObject* in =
fIn->Get(from.c_str());
151 writeOutput(in,
to,
fOut);
154 std::string fromCov(from); fromCov +=
"_stat";
155 std::string toCov(
to); toCov +=
"_stat";
156 in =
fIn->Get(fromCov.c_str());
162 writeOutput(in, toCov,
fOut);
165 std::string fromSyst(from); fromSyst +=
"_syst";
166 std::string toSyst(
to); toSyst +=
"_syst";
167 in =
fIn->Get(fromSyst.c_str());
173 writeOutput(in, toSyst,
fOut);
182 string::size_type delim =
Name.find(
"/");
183 while (delim != string::npos) {
186 delim =
Name.find(
"/");
188 if (slashes != 4)
return false;
190 delim =
Name.rfind(
"_");
191 if (delim == string::npos)
return false;
193 return (
Name ==
"SF" ||
Name ==
"Eff");
200 TDirectory* tdir =
dynamic_cast<TDirectory*
>(
fOut);
201 string::size_type delim =
Name.find(
"/");
202 while (delim != string::npos) {
203 string dir =
Name.substr(0, delim);
204 TDirectory* newdir = tdir->GetDirectory(
dir.c_str());
205 if (! newdir) newdir = tdir->mkdir(
dir.c_str());
206 if (! newdir->cd()) {
208 <<
gDirectory->GetPath() <<
"; cd() to subdir "
209 <<
dir <<
" failed!" );
212 Name =
Name.substr(delim+1, string::npos);
213 delim =
Name.find(
"/");
219 in->Write(
Name.c_str());