|
ATLAS Offline Software
|
A tool used by the egammaMVASvc to help calibrate energy for one particle type.
More...
#include <egammaMVACalibTool.h>
|
| egammaMVACalibTool (const std::string &type) |
|
virtual | ~egammaMVACalibTool () override=default |
|
virtual StatusCode | initialize () override |
| Dummy implementation of the initialisation function. More...
|
|
float | getEnergy (const xAOD::CaloCluster &clus, const xAOD::Egamma *eg) const override final |
| returns the calibrated energy More...
|
|
virtual void | print () const |
| Print the state of the tool. More...
|
|
ServiceHandle< StoreGateSvc > & | evtStore () |
| The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc . More...
|
|
const ServiceHandle< StoreGateSvc > & | evtStore () const |
| The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc . More...
|
|
const ServiceHandle< StoreGateSvc > & | detStore () const |
| The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc . More...
|
|
virtual StatusCode | sysInitialize () override |
| Perform system initialization for an algorithm. More...
|
|
virtual StatusCode | sysStart () override |
| Handle START transition. More...
|
|
virtual std::vector< Gaudi::DataHandle * > | inputHandles () const override |
| Return this algorithm's input handles. More...
|
|
virtual std::vector< Gaudi::DataHandle * > | outputHandles () const override |
| Return this algorithm's output handles. More...
|
|
Gaudi::Details::PropertyBase & | declareProperty (Gaudi::Property< T > &t) |
|
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, SG::VarHandleKey &hndl, const std::string &doc, const SG::VarHandleKeyType &) |
| Declare a new Gaudi property. More...
|
|
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, SG::VarHandleBase &hndl, const std::string &doc, const SG::VarHandleType &) |
| Declare a new Gaudi property. More...
|
|
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, SG::VarHandleKeyArray &hndArr, const std::string &doc, const SG::VarHandleKeyArrayType &) |
|
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, T &property, const std::string &doc, const SG::NotHandleType &) |
| Declare a new Gaudi property. More...
|
|
Gaudi::Details::PropertyBase * | declareProperty (const std::string &name, T &property, const std::string &doc="none") |
| Declare a new Gaudi property. More...
|
|
void | updateVHKA (Gaudi::Details::PropertyBase &) |
|
MsgStream & | msg () const |
|
MsgStream & | msg (const MSG::Level lvl) const |
|
bool | msgLvl (const MSG::Level lvl) const |
|
|
static const TString & | getString (TObject *obj) |
| a utility to get a TString out of an TObjString pointer More...
|
|
A tool used by the egammaMVASvc to help calibrate energy for one particle type.
The particle type to be calibrated must be specified by the property ParticleType. The property folder must be set with the path to a folder containig three files:
- MVACalib_electron.weights.root
- MVACalib_unconvertedPhoton.weights.root
- MVACalib_convertedPhoton.weights.root
The ROOT files should have in the following content:
- a TH2Poly object named "hPoly". This is used to decide which BDT to use. The x-axis is cluster eta, the y-axis is the raw-accordion-Et in GeV. The BDT that will be used for each event is the one with index equal to the content of the TH2Poly - 1, e.g. const int bin = m_hPoly->FindBin(etaVar, energyVarGeV) - 1. (the minimum value in the TH2Poly is 1)
- several TTree named BDTX where X is an integer index (not padded). X here counts from 0. Each TTree has the weights of a BDT and it is the input to MVAUtils::BDT. Alternatively the TTree can be inside a TObjArray named "trees".
- a TObjArray named "variables" containing many TObjString, each one for each BDT. Each TObjString is a string containing the names of the input variables for each BDT, separated by ";". The names should be understandable by egammaMVAFunctions::initializeElectronFuncs, egammaMVAFunctions::initializeUnconvertedPhotonFuncs, egammaMVAFunctions::initializeConvertedPhotonFuncs.
- a TObjectArray named "shifts" containing many TObjString, each one for each BDT. Each TObjString is a string which represent the formula to compute the shift (used to construct a TFormula). The variables is the Et in GeV after the calibration. The value of the shift is divided by the energy calibrated by the BDT.
On data the property use_layer_corrected should be set to true. In reconstruction this flag is always false. In PhysicsAnalysis it should be set appropriately. When set to true when using the layer energies as input the data-driver-corrected version are used.
Definition at line 66 of file egammaMVACalibTool.h.
◆ StoreGateSvc_t
◆ CalibrationType
how the output of the BDT is used correctEaccordion: energy = raw energy * BDT fullCalibration: energy = BDT
Enumerator |
---|
correctEaccordion | |
fullCalibration | |
Definition at line 78 of file egammaMVACalibTool.h.
◆ ShiftType
shift to be applied after the BDT.
Only MEAN10TOTRUE and MEAN10TOTRUE are supperted
Enumerator |
---|
NOSHIFT | |
MEAN10TOTRUE | |
Definition at line 83 of file egammaMVACalibTool.h.
◆ egammaMVACalibTool()
egammaMVACalibTool::egammaMVACalibTool |
( |
const std::string & |
type | ) |
|
◆ ~egammaMVACalibTool()
virtual egammaMVACalibTool::~egammaMVACalibTool |
( |
| ) |
|
|
overridevirtualdefault |
◆ declareGaudiProperty() [1/4]
specialization for handling Gaudi::Property<SG::VarHandleKeyArray>
Definition at line 170 of file AthCommonDataStore.h.
175 hndl.documentation());
◆ declareGaudiProperty() [2/4]
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition at line 156 of file AthCommonDataStore.h.
161 hndl.documentation());
◆ declareGaudiProperty() [3/4]
specialization for handling Gaudi::Property<SG::VarHandleBase>
Definition at line 184 of file AthCommonDataStore.h.
189 hndl.documentation());
◆ declareGaudiProperty() [4/4]
◆ declareProperty() [1/6]
Declare a new Gaudi property.
- Parameters
-
name | Name of the property. |
hndl | Object holding the property value. |
doc | Documentation string for the property. |
This is the version for types that derive from SG::VarHandleBase
. The property value object is put on the input and output lists as appropriate; then we forward to the base class.
Definition at line 245 of file AthCommonDataStore.h.
250 this->declare(hndl.
vhKey());
251 hndl.
vhKey().setOwner(
this);
253 return PBASE::declareProperty(
name,hndl,
doc);
◆ declareProperty() [2/6]
Declare a new Gaudi property.
- Parameters
-
name | Name of the property. |
hndl | Object holding the property value. |
doc | Documentation string for the property. |
This is the version for types that derive from SG::VarHandleKey
. The property value object is put on the input and output lists as appropriate; then we forward to the base class.
Definition at line 221 of file AthCommonDataStore.h.
229 return PBASE::declareProperty(
name,hndl,
doc);
◆ declareProperty() [3/6]
◆ declareProperty() [4/6]
Declare a new Gaudi property.
- Parameters
-
name | Name of the property. |
property | Object holding the property value. |
doc | Documentation string for the property. |
This is the generic version, for types that do not derive from SG::VarHandleKey
. It just forwards to the base class version of declareProperty
.
Definition at line 333 of file AthCommonDataStore.h.
338 return PBASE::declareProperty(
name, property,
doc);
◆ declareProperty() [5/6]
Declare a new Gaudi property.
- Parameters
-
name | Name of the property. |
property | Object holding the property value. |
doc | Documentation string for the property. |
This dispatches to either the generic declareProperty
or the one for VarHandle/Key/KeyArray.
Definition at line 352 of file AthCommonDataStore.h.
◆ declareProperty() [6/6]
◆ detStore()
◆ evtStore() [1/2]
◆ evtStore() [2/2]
◆ extraDeps_update_handler()
Add StoreName to extra input/output deps as needed.
use the logic of the VarHandleKey to parse the DataObjID keys supplied via the ExtraInputs and ExtraOuputs Properties to add the StoreName if it's not explicitly given
◆ getEnergy()
returns the calibrated energy
Implements IegammaMVACalibTool.
Definition at line 213 of file egammaMVACalibTool.cxx.
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");
◆ getKey()
Get the (hashed) key of an object that is in the event store.
This is a bit of a special one. StoreGateSvc
and xAOD::TEvent
both provide ways for getting the SG::sgkey_t
key for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.
In order to allow tools to efficiently perform this operation, they can use this helper function.
- See also
- asg::AsgTool::getName
- Parameters
-
ptr | The bare pointer to the object that the event store should know about |
- Returns
- The hashed key of the object in the store. If not found, an invalid (zero) key.
Definition at line 119 of file AsgTool.cxx.
121 #ifdef XAOD_STANDALONE
127 return (
proxy ==
nullptr ? 0 :
proxy->sgkey() );
128 #endif // XAOD_STANDALONE
◆ getName()
const std::string & asg::AsgTool::getName |
( |
const void * |
ptr | ) |
const |
|
inherited |
Get the name of an object that is / should be in the event store.
This is a bit of a special one. StoreGateSvc
and xAOD::TEvent
both provide ways for getting the std::string
name for an object that is in the store, based on a bare pointer. But they provide different interfaces for doing so.
In order to allow tools to efficiently perform this operation, they can use this helper function.
- See also
- asg::AsgTool::getKey
- Parameters
-
ptr | The bare pointer to the object that the event store should know about |
- Returns
- The string name of the object in the store. If not found, an empty string.
Definition at line 106 of file AsgTool.cxx.
108 #ifdef XAOD_STANDALONE
114 static const std::string
dummy =
"";
116 #endif // XAOD_STANDALONE
◆ getProperty()
template<class T >
const T* asg::AsgTool::getProperty |
( |
const std::string & |
name | ) |
const |
|
inherited |
Get one of the tool's properties.
◆ getString()
const TString & egammaMVACalibTool::getString |
( |
TObject * |
obj | ) |
|
|
staticprivate |
a utility to get a TString out of an TObjString pointer
Definition at line 204 of file egammaMVACalibTool.cxx.
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();
◆ initialize()
StatusCode egammaMVACalibTool::initialize |
( |
| ) |
|
|
overridevirtual |
Dummy implementation of the initialisation function.
It's here to allow the dual-use tools to skip defining an initialisation function. Since many are doing so...
Reimplemented from asg::AsgTool.
Definition at line 33 of file egammaMVACalibTool.cxx.
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;
◆ inputHandles()
Return this algorithm's input handles.
We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.
◆ msg() [1/2]
◆ msg() [2/2]
◆ msg_level_name()
const std::string & asg::AsgTool::msg_level_name |
( |
| ) |
const |
|
inherited |
A deprecated function for getting the message level's name.
Instead of using this, weirdly named function, user code should get the string name of the current minimum message level (in case they really need it...), with:
MSG::name( msg().level() )
This function's name doesn't follow the ATLAS coding rules, and as such will be removed in the not too distant future.
- Returns
- The string name of the current minimum message level that's printed
Definition at line 101 of file AsgTool.cxx.
◆ msgLvl()
◆ outputHandles()
Return this algorithm's output handles.
We override this to include handle instances from key arrays if they have not yet been declared. See comments on updateVHKA.
◆ print()
void asg::AsgTool::print |
( |
| ) |
const |
|
virtualinherited |
Print the state of the tool.
Implements asg::IAsgTool.
Reimplemented in JetRecTool, JetFinder, JetModifiedMassDrop, JetFromPseudojet, JetReclusterer, JetReclusteringTool, JetTruthLabelingTool, JetPileupLabelingTool, HI::HIPileupTool, JetDumper, JetBottomUpSoftDrop, JetRecursiveSoftDrop, JetSoftDrop, JetConstituentsRetriever, JetSubStructureMomentToolsBase, JetSplitter, JetToolRunner, JetPruner, JetPseudojetRetriever, JetTrimmer, AsgHelloTool, and KtDeltaRTool.
Definition at line 131 of file AsgTool.cxx.
◆ renounce()
◆ renounceArray()
◆ setupBDT()
a function called by initialize to setup the BDT, funcs, and shifts.
Definition at line 90 of file egammaMVACalibTool.cxx.
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;
◆ sysInitialize()
◆ sysStart()
Handle START transition.
We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.
◆ updateVHKA()
◆ m_BDTs
◆ m_calibrationType
Gaudi::Property<int> egammaMVACalibTool::m_calibrationType |
|
private |
◆ m_clusterEif0
Gaudi::Property<bool> egammaMVACalibTool::m_clusterEif0 |
|
private |
Initial value:{this,
"useClusterIf0", true,
"Use cluster energy if MVA response is 0"}
Definition at line 102 of file egammaMVACalibTool.h.
◆ m_detStore
◆ m_evtStore
◆ m_folder
Gaudi::Property<std::string> egammaMVACalibTool::m_folder |
|
private |
Initial value:{this,
"folder", "",
"string with folder for weight files"}
string with folder for weight files
Definition at line 107 of file egammaMVACalibTool.h.
◆ m_funcs
◆ m_hPoly
std::unique_ptr<TH2Poly> egammaMVACalibTool::m_hPoly |
|
private |
A TH2Poly used to extract bin numbers. Note there is an offset of 1.
Definition at line 116 of file egammaMVACalibTool.h.
◆ m_particleType
Gaudi::Property<int> egammaMVACalibTool::m_particleType |
|
private |
◆ m_shifts
std::vector<TFormula> egammaMVACalibTool::m_shifts |
|
private |
◆ m_shiftType
Gaudi::Property<int> egammaMVACalibTool::m_shiftType |
|
private |
Initial value:{this,
"Shift corrections to apply to value"}
Definition at line 94 of file egammaMVACalibTool.h.
◆ m_useLayerCorrected
Gaudi::Property<bool> egammaMVACalibTool::m_useLayerCorrected |
|
private |
Initial value:{this,
"use_layer_corrected", false,
"whether to use layer corrections"}
Definition at line 111 of file egammaMVACalibTool.h.
◆ m_varHandleArraysDeclared
◆ m_vhka
The documentation for this class was generated from the following files:
float compute_rawcl_Eacc(const xAOD::CaloCluster &cl)
These functions are for calculating variables used by the MVA calibration.
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
std::vector< SG::VarHandleKeyArray * > m_vhka
virtual void setOwner(IDataHandleHolder *o)=0
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
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
std::unique_ptr< funcMap_t > initializeUnconvertedPhotonFuncs(bool useLayerCorrected)
A function to build the map for uncoverted photons.
const std::string & name(Level lvl)
Convenience function for translating message levels to strings.
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
size_t index() const
Return the index of this element within its container.
float compute_correctedcl_Eacc(const xAOD::CaloCluster &cl)
virtual void renounce()=0
std::conditional< std::is_base_of< SG::VarHandleKeyArray, T >::value, VarHandleKeyArrayType, type2 >::type type
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)
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
#define ATLAS_THREAD_SAFE
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
virtual double e() const
The total energy of the particle.