12#include "TDirectory.h"
45 if (fIn->IsZombie()) {
46 ATH_MSG_FATAL( name() <<
": requested input ROOT file invalid: "
48 return StatusCode::FAILURE;
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;
57 return StatusCode::FAILURE;
60 if (fOut->IsZombie()) {
63 return StatusCode::FAILURE;
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);
84 if (fIn) fIn->Close();
88 return StatusCode::SUCCESS;
94 TObject* obj = fOut->Get(
Name.c_str());
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);
115 string fullName(dir); fullName +=
"/"; fullName += defaultName;
116 if (fOut->Get(fullName.c_str()))
return;
119 ATH_MSG_INFO( name() <<
": copying parametrisation name: "
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());
137 TFile* fIn, TFile* fOut)
const
145 TObject* in = fIn->Get(from.c_str());
154 std::string fromCov(from); fromCov +=
"_stat";
155 std::string toCov(to); toCov +=
"_stat";
156 in = fIn->Get(fromCov.c_str());
158 ATH_MSG_WARNING( name() <<
": input parametrisation covariance matrix name not found: "
165 std::string fromSyst(from); fromSyst +=
"_syst";
166 std::string toSyst(to); toSyst +=
"_syst";
167 in = fIn->Get(fromSyst.c_str());
169 ATH_MSG_WARNING( name() <<
": input parametrisation systematics name not found: "
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(
"/");
218 << gDirectory->GetPath() );
219 in->Write(
Name.c_str());
#define ATH_MSG_WARNING(x)
StatusCode initialize() override
standard Athena-Algorithm method
std::string m_inputRootFile
input ROOT file containing new results
void writeOutput(TObject *in, const std::string &Name, TFile *fOut) const
void copyResults(const std::string &from, const std::string &to, TFile *fIn, TFile *fOut) const
std::string m_DbRootFile
ROOT file to be entered in COOL.
Gaudi::Property m_overrideDefaults
flag if these results are to be used as defaults (they will anyway if no other results exist for the ...
bool isValidName(const std::string &Name) const
std::vector< std::string > m_paramNames
names of input and output parametrisations
CalibrationDataUpdater(const std::string &name, ISvcLocator *pSvcLocator)
Standard Athena-Algorithm Constructor.
void setDefaultResults(const std::string &Name, TFile *fOut) const
auxiliary functions
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)