|
ATLAS Offline Software
|
Go to the documentation of this file.
15 #include "TObjString.h"
22 #include "GaudiKernel/SystemOfUnits.h"
36 ATH_MSG_FATAL(
"Particle type not set: you have to set property ParticleType to a valid value");
37 return StatusCode::FAILURE;
47 return StatusCode::FAILURE;
55 std::unique_ptr<egammaMVAFunctions::funcMap_t> funcLibraryPtr =
63 std::unique_ptr<egammaMVAFunctions::funcMap_t> funcLibraryPtr =
71 std::unique_ptr<egammaMVAFunctions::funcMap_t> funcLibraryPtr =
79 return StatusCode::FAILURE;
84 TClass::GetClass (
"TH2Poly");
85 TClass::GetClass (
"TMultiGraph");
87 return StatusCode::SUCCESS;
95 std::unique_ptr<TFile>
f(TFile::Open(
fileName.c_str()));
96 if (!
f ||
f->IsZombie()) {
98 return StatusCode::FAILURE;
102 TH2Poly *hPoly =
nullptr;
103 f->GetObject(
"hPoly", hPoly);
106 return StatusCode::FAILURE;
109 m_hPoly.reset(
static_cast<TH2Poly*
>(hPoly));
110 m_hPoly->SetDirectory(
nullptr);
113 TObjArray *variablesTmp =
nullptr;
114 f->GetObject(
"variables", variablesTmp);
117 return StatusCode::FAILURE;
119 auto variables = std::unique_ptr<TObjArray>(variablesTmp);
123 TObjArray *shiftsTmp =
nullptr;
124 f->GetObject(
"shifts", shiftsTmp);
127 return StatusCode::FAILURE;
129 auto shifts = std::unique_ptr<TObjArray>(shiftsTmp);
133 TObjArray *treesTmp =
nullptr;
134 std::unique_ptr<TObjArray>
trees;
135 f->GetObject(
"trees", treesTmp);
137 trees = std::unique_ptr<TObjArray>(treesTmp);
142 trees = std::make_unique<TObjArray>();
146 TTree *
tree =
nullptr;
147 f->GetObject(Form(
"BDT%d",
i),
tree);
156 <<
" while variables has size " <<
variables->GetEntries());
157 return StatusCode::FAILURE;
165 TIter nextTree(
trees.get());
167 TIter nextShift(shifts.get());
168 for (
int i=0; (
tree = (TTree*) nextTree()) && ((TObjString*) nextVariables()); ++
i)
174 char separator_var =
';';
177 TIter nextVar(
tokens.get());
178 while ((str2 = (TObjString*) nextVar()))
183 return StatusCode::FAILURE;
186 funcs.push_back(funcLibrary.at(
varName.Data()));
187 }
catch(
const std::out_of_range&
e) {
189 return StatusCode::FAILURE;
192 m_funcs.push_back(std::move(funcs));
195 shift = (TObjString*) nextShift();
196 const TString& shiftFormula =
getString(shift);
197 m_shifts.emplace_back(
"", shiftFormula);
200 return StatusCode::SUCCESS;
206 TObjString *objS =
dynamic_cast<TObjString*
>(
obj);
208 throw std::runtime_error(
"egammaMVACalibTool::getString was passed something that was not a string object");
210 return objS->GetString();
224 const auto etVarGeV = (initEnergy / std::cosh(clus.
eta())) /
GeV;
225 const auto etaVar = std::abs(clus.
eta());
227 ATH_MSG_DEBUG(
"Looking at object with initEnergy = " << initEnergy
228 <<
", etVarGeV = " << etVarGeV
229 <<
", etaVar = " << etaVar
230 <<
", clus->e() = " << clus.
e());
237 const int bin = hPoly->FindBin(etaVar, etVarGeV) - 1;
242 ATH_MSG_DEBUG(
"The bin is under/overflow; just return the energy");
246 if (
bin >=
static_cast<int>(
m_BDTs.size())) {
247 ATH_MSG_WARNING(
"The bin is outside the range, so just return the energy");
253 const int bin_BDT =
m_BDTs.size() != 1 ?
bin : 0;
254 const auto& bdt =
m_BDTs[bin_BDT];
255 const auto& funcs =
m_funcs[bin_BDT];
257 const size_t sz = funcs.size();
260 std::vector<float> vars(
sz);
262 for (
size_t i = 0;
i <
sz; ++
i) {
263 vars[
i] = funcs[
i](
eg, &clus);
267 const float mvaOutput = bdt.GetResponse(vars);
270 if (mvaOutput == 0.) {
279 mvaOutput : (initEnergy * mvaOutput);
289 const auto etGeV = (
energy / std::cosh(clus.
eta())) /
GeV;
297 ATH_MSG_WARNING(
"Shift value too small: " << shift <<
"; not applying shift");
float compute_rawcl_Eacc(const xAOD::CaloCluster &cl)
std::unordered_map< std::string, std::function< float(const xAOD::Egamma *, const xAOD::CaloCluster *)> > funcMap_t
Define the map type since it's long.
Description of a calorimeter cluster.
std::unique_ptr< funcMap_t > initializeConvertedPhotonFuncs(bool useLayerCorrected)
A function to build the map for converted photons.
virtual double eta() const
The pseudorapidity ( ) of the particle.
string varName
end cluster ToT and charge
::StatusCode StatusCode
StatusCode definition for legacy code.
std::unique_ptr< funcMap_t > initializeUnconvertedPhotonFuncs(bool useLayerCorrected)
A function to build the map for uncoverted photons.
size_t index() const
Return the index of this element within its container.
float compute_correctedcl_Eacc(const xAOD::CaloCluster &cl)
std::unique_ptr< funcMap_t > initializeElectronFuncs(bool useLayerCorrected)
A function to build the map for electrons.
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
#define ATH_MSG_WARNING(x)
#define ATLAS_THREAD_SAFE
Define macros for attributes used to control the static checker.
virtual double e() const
The total energy of the particle.