ATLAS Offline Software
Classes | Public Member Functions | Static Public Member Functions | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
ParticleScaleFactorTool Class Reference

#include <ParticleScaleFactorTool.h>

Inheritance diagram for ParticleScaleFactorTool:
Collaboration diagram for ParticleScaleFactorTool:

Classes

struct  Hists
 

Public Member Functions

 ParticleScaleFactorTool (const std::string &name)
 
 ~ParticleScaleFactorTool ()
 
virtual StatusCode initialize () override
 Initialize is required by AsgTool base class. More...
 
virtual double evaluate (const xAOD::IParticle *particle) const override
 returns: the value that was calculated from the xAOD::IParticle More...
 
bool isAffectedBySystematic (const CP::SystematicVariation &systematic) const override
 The ISystematicsTool methods. More...
 
CP::SystematicSet affectingSystematics () const override
 the list of all systematics this tool can be affected by More...
 
CP::SystematicSet recommendedSystematics () const override
 the list of all systematics this tool recommends to use More...
 
StatusCode applySystematicVariation (const CP::SystematicSet &systConfig) override
 effects: configure this tool for the given list of systematic variations. 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 Public Member Functions

static double part_pt (const xAOD::IParticle &p)
 
static double part_pt_gev (const xAOD::IParticle &p)
 
static double part_eta (const xAOD::IParticle &p)
 
static double part_decor (const xAOD::IParticle &p, const std::string &varname)
 

Protected Member Functions

void renounceArray (SG::VarHandleKeyArray &handlesArray)
 remove all handles from I/O resolution More...
 
std::enable_if_t< std::is_void_v< std::result_of_t< decltype(&T::renounce)(T)> > &&!std::is_base_of_v< SG::VarHandleKeyArray, T > &&std::is_base_of_v< Gaudi::DataHandle, T >, void > renounce (T &h)
 
void extraDeps_update_handler (Gaudi::Details::PropertyBase &ExtraDeps)
 Add StoreName to extra input/output deps as needed. More...
 

Private Types

typedef ServiceHandle< StoreGateSvcStoreGateSvc_t
 

Private Member Functions

Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
 specialization for handling Gaudi::Property<SG::VarHandleKey> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleKeyArrayType &)
 specialization for handling Gaudi::Property<SG::VarHandleKeyArray> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &hndl, const SG::VarHandleType &)
 specialization for handling Gaudi::Property<SG::VarHandleBase> More...
 
Gaudi::Details::PropertyBase & declareGaudiProperty (Gaudi::Property< T > &t, const SG::NotHandleType &)
 specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray> More...
 

Private Attributes

std::string m_configFile
 
CP::SystematicVariation m_currentSyst
 
std::map< xAOD::Type::ObjectType, Histsm_hists
 
CP::SystematicSet m_affectingSysts
 
bool m_isNominal =true
 
StoreGateSvc_t m_evtStore
 Pointer to StoreGate (event store by default) More...
 
StoreGateSvc_t m_detStore
 Pointer to StoreGate (detector store by default) More...
 
std::vector< SG::VarHandleKeyArray * > m_vhka
 
bool m_varHandleArraysDeclared
 

Detailed Description

Definition at line 19 of file ParticleScaleFactorTool.h.

Member Typedef Documentation

◆ StoreGateSvc_t

typedef ServiceHandle<StoreGateSvc> AthCommonDataStore< AthCommonMsg< AlgTool > >::StoreGateSvc_t
privateinherited

Definition at line 388 of file AthCommonDataStore.h.

Constructor & Destructor Documentation

◆ ParticleScaleFactorTool()

ParticleScaleFactorTool::ParticleScaleFactorTool ( const std::string &  name)

Definition at line 17 of file ParticleScaleFactorTool.cxx.

17  : asg::AsgTool( name ){
18 
19  declareProperty( "File", m_configFile = "" , "User should specify config file to read");
20 
21 }

◆ ~ParticleScaleFactorTool()

ParticleScaleFactorTool::~ParticleScaleFactorTool ( )

Definition at line 23 of file ParticleScaleFactorTool.cxx.

23  {
24 
25  //delete all histograms
26  for(auto& a : m_hists) {
27  for(auto& b : a.second.hists) {
28  delete b.second;
29  }
30  }
31 
32 }

Member Function Documentation

◆ affectingSystematics()

CP::SystematicSet ParticleScaleFactorTool::affectingSystematics ( ) const
inlineoverridevirtual

the list of all systematics this tool can be affected by

Implements CP::IReentrantSystematicsTool.

Definition at line 63 of file ParticleScaleFactorTool.h.

63 { return m_affectingSysts; }

◆ applySystematicVariation()

StatusCode ParticleScaleFactorTool::applySystematicVariation ( const CP::SystematicSet systConfig)
overridevirtual

effects: configure this tool for the given list of systematic variations.

any requested systematics that are not affecting this tool will be silently ignored (unless they cause other errors). failures: systematic unknown failures: requesting multiple variations on the same systematic (e.g. up & down) failures: requesting an unsupported variation on an otherwise supported systematic (e.g. a 2 sigma variation and the tool only supports 1 sigma variations) failures: unsupported combination of supported systematic failures: other tool specific errors

Implements CP::ISystematicsTool.

Definition at line 241 of file ParticleScaleFactorTool.cxx.

241  {
242  for(auto& syst : systConfig) {
243  for(auto& s : m_affectingSysts) {
244  if(s.basename()==syst.basename()) {
245  m_currentSyst = syst; m_isNominal=false;
246  return StatusCode::SUCCESS;
247  }
248  }
249  }
251  m_isNominal = true;
252  return StatusCode::SUCCESS;
253 }

◆ declareGaudiProperty() [1/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleKeyArrayType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKeyArray>

Definition at line 170 of file AthCommonDataStore.h.

172  {
173  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
174  hndl.value(),
175  hndl.documentation());
176 
177  }

◆ declareGaudiProperty() [2/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleKeyType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleKey>

Definition at line 156 of file AthCommonDataStore.h.

158  {
159  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
160  hndl.value(),
161  hndl.documentation());
162 
163  }

◆ declareGaudiProperty() [3/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  hndl,
const SG::VarHandleType  
)
inlineprivateinherited

specialization for handling Gaudi::Property<SG::VarHandleBase>

Definition at line 184 of file AthCommonDataStore.h.

186  {
187  return *AthCommonDataStore<PBASE>::declareProperty(hndl.name(),
188  hndl.value(),
189  hndl.documentation());
190  }

◆ declareGaudiProperty() [4/4]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareGaudiProperty ( Gaudi::Property< T > &  t,
const SG::NotHandleType  
)
inlineprivateinherited

specialization for handling everything that's not a Gaudi::Property<SG::VarHandleKey> or a <SG::VarHandleKeyArray>

Definition at line 199 of file AthCommonDataStore.h.

200  {
201  return PBASE::declareProperty(t);
202  }

◆ declareProperty() [1/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleBase hndl,
const std::string &  doc,
const SG::VarHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation 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.

249  {
250  this->declare(hndl.vhKey());
251  hndl.vhKey().setOwner(this);
252 
253  return PBASE::declareProperty(name,hndl,doc);
254  }

◆ declareProperty() [2/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleKey hndl,
const std::string &  doc,
const SG::VarHandleKeyType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
hndlObject holding the property value.
docDocumentation 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.

225  {
226  this->declare(hndl);
227  hndl.setOwner(this);
228 
229  return PBASE::declareProperty(name,hndl,doc);
230  }

◆ declareProperty() [3/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
SG::VarHandleKeyArray hndArr,
const std::string &  doc,
const SG::VarHandleKeyArrayType  
)
inlineinherited

Definition at line 259 of file AthCommonDataStore.h.

263  {
264 
265  // std::ostringstream ost;
266  // ost << Algorithm::name() << " VHKA declareProp: " << name
267  // << " size: " << hndArr.keys().size()
268  // << " mode: " << hndArr.mode()
269  // << " vhka size: " << m_vhka.size()
270  // << "\n";
271  // debug() << ost.str() << endmsg;
272 
273  hndArr.setOwner(this);
274  m_vhka.push_back(&hndArr);
275 
276  Gaudi::Details::PropertyBase* p = PBASE::declareProperty(name, hndArr, doc);
277  if (p != 0) {
278  p->declareUpdateHandler(&AthCommonDataStore<PBASE>::updateVHKA, this);
279  } else {
280  ATH_MSG_ERROR("unable to call declareProperty on VarHandleKeyArray "
281  << name);
282  }
283 
284  return p;
285 
286  }

◆ declareProperty() [4/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc,
const SG::NotHandleType  
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation 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.

337  {
338  return PBASE::declareProperty(name, property, doc);
339  }

◆ declareProperty() [5/6]

Gaudi::Details::PropertyBase* AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( const std::string &  name,
T &  property,
const std::string &  doc = "none" 
)
inlineinherited

Declare a new Gaudi property.

Parameters
nameName of the property.
propertyObject holding the property value.
docDocumentation 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.

355  {
356  typedef typename SG::HandleClassifier<T>::type htype;
357  return declareProperty (name, property, doc, htype());
358  }

◆ declareProperty() [6/6]

Gaudi::Details::PropertyBase& AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty ( Gaudi::Property< T > &  t)
inlineinherited

Definition at line 145 of file AthCommonDataStore.h.

145  {
146  typedef typename SG::HandleClassifier<T>::type htype;
148  }

◆ detStore()

const ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::detStore ( ) const
inlineinherited

The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 95 of file AthCommonDataStore.h.

95 { return m_detStore; }

◆ evaluate()

double ParticleScaleFactorTool::evaluate ( const xAOD::IParticle ) const
overridevirtual

returns: the value that was calculated from the xAOD::IParticle

Implements IObservableTool.

Definition at line 189 of file ParticleScaleFactorTool.cxx.

189  {
190  //check we have a hist for this particle type
191  auto histItr = m_hists.find(particle->type());
192  if(histItr==m_hists.end()) {
193  ATH_MSG_ERROR("No scale factor available for particle type: " << particle->type());
194  throw std::runtime_error(TString::Format("%s : No scale factor available for particle type %d",name().c_str(),int(particle->type())).Data());
195  }
196 
197 
198  std::pair<CP::SystematicVariation,TH1*> res = histItr->second.getHist(m_currentSyst);
199 
200  const TH1* hist = res.second;
201 
202 
203  int bin = 0;
204  switch(hist->GetDimension()) {
205  case 1: bin = hist->FindFixBin(histItr->second.axisFuncs[0](*particle)); break;
206  case 2: bin = hist->FindFixBin(histItr->second.axisFuncs[0](*particle),histItr->second.axisFuncs[1](*particle)); break;
207  case 3: bin = hist->FindFixBin(histItr->second.axisFuncs[0](*particle),histItr->second.axisFuncs[1](*particle),histItr->second.axisFuncs[2](*particle)); break;
208  }
209 
210  if(!res.first.parameter()) return hist->GetBinContent(bin); //must have been nominal;
211 
212  double nom = histItr->second.getHist(CP::SystematicVariation("")).second->GetBinContent(bin);
213  //got here so get nominal hist and do difference ...
214  return nom + (m_currentSyst.parameter()/res.first.parameter()) * (hist->GetBinContent(bin) - nom);
215 
216 
217 
218 
219 
220 }

◆ evtStore() [1/2]

ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( )
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 85 of file AthCommonDataStore.h.

85 { return m_evtStore; }

◆ evtStore() [2/2]

const ServiceHandle<StoreGateSvc>& AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore ( ) const
inlineinherited

The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.

Definition at line 90 of file AthCommonDataStore.h.

90 { return m_evtStore; }

◆ extraDeps_update_handler()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::extraDeps_update_handler ( Gaudi::Details::PropertyBase &  ExtraDeps)
protectedinherited

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

◆ getKey()

SG::sgkey_t asg::AsgTool::getKey ( const void *  ptr) const
inherited

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
ptrThe 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.

119  {
120 
121 #ifdef XAOD_STANDALONE
122  // In case we use @c xAOD::TEvent, we have a direct function call
123  // for this.
124  return evtStore()->event()->getKey( ptr );
125 #else
126  const SG::DataProxy* proxy = evtStore()->proxy( ptr );
127  return ( proxy == nullptr ? 0 : proxy->sgkey() );
128 #endif // XAOD_STANDALONE
129  }

◆ 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
ptrThe 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.

106  {
107 
108 #ifdef XAOD_STANDALONE
109  // In case we use @c xAOD::TEvent, we have a direct function call
110  // for this.
111  return evtStore()->event()->getName( ptr );
112 #else
113  const SG::DataProxy* proxy = evtStore()->proxy( ptr );
114  static const std::string dummy = "";
115  return ( proxy == nullptr ? dummy : proxy->name() );
116 #endif // XAOD_STANDALONE
117  }

◆ getProperty()

template<class T >
const T* asg::AsgTool::getProperty ( const std::string &  name) const
inherited

Get one of the tool's properties.

◆ initialize()

StatusCode ParticleScaleFactorTool::initialize ( )
overridevirtual

Initialize is required by AsgTool base class.

Reimplemented from asg::AsgTool.

Definition at line 34 of file ParticleScaleFactorTool.cxx.

34  {
35 
36 
38  if(file=="") return StatusCode::FAILURE;
39 
40  TFile* f = TFile::Open(file.c_str());
41 
42  if(!f) {
43  ATH_MSG_ERROR("Could not open file " << file);
44  return StatusCode::FAILURE;
45  }
46 
47  m_affectingSysts.insert(CP::SystematicVariation("")); //add the nominal syst
48 
49  //loop over the keys in the file, we are looking for TDirectory (systematics) and TH1 (factors)
50  std::unique_ptr<TIterator> itr(f->GetListOfKeys()->MakeIterator());
51  TKey* key = 0;
52  while( (key = static_cast<TKey*>(itr->Next())) ) {
53  TClass* cl = TClass::GetClass(key->GetClassName());
54  if(!cl || !cl->InheritsFrom(TDirectory::Class())) continue;
55  ATH_MSG_DEBUG("Detected systematic " << key->GetName());
57  if(!CP::SystematicVariation(key->GetName()).parameter()) {
58  ATH_MSG_ERROR("Systematic must be of form: <string>__Xup OR <string>__Xdown ... where X is a number");
59  return StatusCode::FAILURE;
60  }
61  }
62 
63  itr->Reset();
64  while( (key = static_cast<TKey*>(itr->Next())) ) {
65  TClass* cl = TClass::GetClass(key->GetClassName());
66  if(!cl || !cl->InheritsFrom("TH1")) continue;
67 
68 
69  ATH_MSG_DEBUG("Detected scale factor " << key->GetName());
70 
71  //loop over systematics
72  for(auto& syst : m_affectingSysts) {
73  TString h = (syst==CP::SystematicVariation("")) ? std::string(key->GetName()) : syst.name()+ "/" + std::string(key->GetName());
74  TH1* hist = static_cast<TH1*>(f->Get(h));
75  if(!hist) {
76  if(!(syst==CP::SystematicVariation(""))) {
77  ATH_MSG_VERBOSE("No " << syst.name() << " variation of " << key->GetName());
78  continue; //fine, just no systematic variation
79  } else {
80  ATH_MSG_ERROR("Failed at retrieving " << key->GetName());
81  return StatusCode::FAILURE;
82  }
83  }
84  //detect particle type from title
85  xAOD::Type::ObjectType type = xAOD::Type::Other;
86  if(strcmp(hist->GetTitle(),"Electron")==0) type = xAOD::Type::Electron;
87  else if(strcmp(hist->GetTitle(),"Muon")==0) type = xAOD::Type::Muon;
88  else if(strcmp(hist->GetTitle(),"Jet")==0) type = xAOD::Type::Jet;
89  else if(strcmp(hist->GetTitle(),"Photon")==0) type = xAOD::Type::Photon;
90  else if(strcmp(hist->GetTitle(),"Tau")==0) type = xAOD::Type::Tau;
91  else {
92  ATH_MSG_ERROR("Unknown particle type: " << hist->GetTitle());
93  return StatusCode::FAILURE;
94  }
95 
96  //check all axis are labelled
97  if(strlen(hist->GetXaxis()->GetTitle())==0 ||
98  (hist->GetDimension()>1 && strlen(hist->GetYaxis()->GetTitle())==0) ||
99  (hist->GetDimension()>2 && strlen(hist->GetZaxis()->GetTitle())==0) ) {
100  ATH_MSG_ERROR("All axis of histogram " << hist->GetName() << " need to be labelled");
101  return StatusCode::FAILURE;
102  }
103  //see if nominal already present, if it is we have to 'extend' the existing histogram
104  TH1*& existHist = m_hists[type].hists[syst.name()];
105  if(existHist) {
106  ATH_MSG_DEBUG("Combining " << hist->GetTitle() << ": f(" <<
107  existHist->GetXaxis()->GetTitle() << "," << hist->GetXaxis()->GetTitle() <<
108  ") = 2*f(" << existHist->GetXaxis()->GetTitle() << ")*f(" <<
109  hist->GetXaxis()->GetTitle() << ")/[f(" << existHist->GetXaxis()->GetTitle() <<
110  ")+f(" << hist->GetXaxis()->GetTitle() << ")]");
111 
112  TH1* newHist = 0;
113  if(existHist->GetDimension()==1 && hist->GetDimension()==1) {
114  std::vector<double> binEdges1, binEdges2;
115  for(int i=1;i<=existHist->GetNbinsX()+1;i++) binEdges1.push_back(existHist->GetBinLowEdge(i));
116  for(int i=1;i<=hist->GetNbinsX()+1;i++) binEdges2.push_back(hist->GetBinLowEdge(i));
117  newHist = new TH2D("myHist","myHist",existHist->GetNbinsX(),&binEdges1[0],hist->GetNbinsX(),&binEdges2[0]);
118  newHist->SetDirectory(0);
119  newHist->GetXaxis()->SetTitle(existHist->GetTitle());
120  newHist->GetYaxis()->SetTitle(hist->GetTitle());
121  for(int i=0;i<=existHist->GetNbinsX()+1;i++) {
122  for(int j=0;j<=hist->GetNbinsX()+1;j++) {
123  double a = existHist->GetBinContent(i); double b = hist->GetBinContent(j);
124  if(a && b) newHist->SetBinContent(newHist->GetBin(i,j), 2.0 * (a*b)/(a+b) );
125  //combine error ...
126  if(!(syst==CP::SystematicVariation(""))) {
127  double da = existHist->GetBinError(i);double db = hist->GetBinError(j);
128  if(a && b) newHist->SetBinError(newHist->GetBin(i,j), 2.0 * (da*b*b + db*a*a)/((a+b)*(a+b)) );
129  }
130  }
131  }
132  delete existHist;
133  existHist = newHist;
134  } else {
135  ATH_MSG_ERROR("Unsupported scale factor reparamertization :-(");
136  return StatusCode::FAILURE;
137  }
138 
139  } else {
140  existHist = static_cast<TH1*>(hist->Clone("myHist")); existHist->SetDirectory(0);
141  //no systematic if nominal hist ...
142  //if(syst==CP::SystematicVariation("")) for(int i=0;i<(hist->GetNbinsX()+2)*(hist->GetNbinsY()+2)*(hist->GetNbinsZ()+2);i++) hist->SetBinError(i,0);
143  }
144 
145  if(syst==CP::SystematicVariation("")) {
146  for(int i=0;i<hist->GetDimension();i++) {
147  std::string axisTitle = ( i==0 ) ? hist->GetXaxis()->GetTitle() : ( (i==1) ? hist->GetYaxis()->GetTitle() : hist->GetZaxis()->GetTitle() );
148  axisTitle.erase(remove_if(axisTitle.begin(), axisTitle.end(), isspace),axisTitle.end());
149  std::function<double(const xAOD::IParticle&)> bfunc;
150  ATH_MSG_DEBUG(" Parameter " << axisTitle);
151  if(axisTitle=="pt" || axisTitle=="pt/MeV" || axisTitle=="pt[MeV]") {
152  bfunc = part_pt;
153  } else if(axisTitle == "pt/GeV" || axisTitle=="pt[GeV]") {
154  bfunc = part_pt_gev;
155  } else if(axisTitle=="eta") {
156  bfunc = part_eta;
157  } else {
158  bfunc = std::bind(part_decor, std::placeholders::_1, axisTitle);
159  }
160  m_hists[type].axisFuncs.push_back(bfunc);
161  }
162  }
163  }
164 
165 
166 
167 
168  }
169 
170  //remove the nominal syst to finish up
173  for(auto& s : tmpSet) {
174  if(s==CP::SystematicVariation("")) continue;
176  //m_affectingSysts.insert(CP::SystematicVariation(s.basename(),-1)); //add the negative fluctuation
177  }
178 
179 
180  f->Close();
181  delete f;
182  f = 0;
183 
184  if(CP::SystematicRegistry::getInstance().registerSystematics(*this) != StatusCode::SUCCESS ) return StatusCode::FAILURE;
185 
186  return StatusCode::SUCCESS;
187 }

◆ inputHandles()

virtual std::vector<Gaudi::DataHandle*> AthCommonDataStore< AthCommonMsg< AlgTool > >::inputHandles ( ) const
overridevirtualinherited

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.

◆ isAffectedBySystematic()

bool ParticleScaleFactorTool::isAffectedBySystematic ( const CP::SystematicVariation systematic) const
inlineoverridevirtual

The ISystematicsTool methods.

Implements CP::ISystematicsTool.

Definition at line 62 of file ParticleScaleFactorTool.h.

62 { return (m_affectingSysts.find(systematic)!=m_affectingSysts.end()); }

◆ msg() [1/2]

MsgStream& AthCommonMsg< AlgTool >::msg ( ) const
inlineinherited

Definition at line 24 of file AthCommonMsg.h.

24  {
25  return this->msgStream();
26  }

◆ msg() [2/2]

MsgStream& AthCommonMsg< AlgTool >::msg ( const MSG::Level  lvl) const
inlineinherited

Definition at line 27 of file AthCommonMsg.h.

27  {
28  return this->msgStream(lvl);
29  }

◆ 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.

101  {
102 
103  return MSG::name( msg().level() );
104  }

◆ msgLvl()

bool AthCommonMsg< AlgTool >::msgLvl ( const MSG::Level  lvl) const
inlineinherited

Definition at line 30 of file AthCommonMsg.h.

30  {
31  return this->msgLevel(lvl);
32  }

◆ outputHandles()

virtual std::vector<Gaudi::DataHandle*> AthCommonDataStore< AthCommonMsg< AlgTool > >::outputHandles ( ) const
overridevirtualinherited

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.

◆ part_decor()

static double ParticleScaleFactorTool::part_decor ( const xAOD::IParticle p,
const std::string &  varname 
)
inlinestatic

Definition at line 37 of file ParticleScaleFactorTool.h.

37  {
39  const SG::auxid_t auxid = reg.findAuxID( varname );
40  if( auxid == SG::null_auxid ) {
41  throw std::runtime_error("unknown aux id for decoration: " + varname);
42  }
43  const std::type_info* ti = reg.getType( auxid );
44  if( *ti == typeid( double ) ) {
46  return acc(p);
47  } else if( *ti == typeid( float ) ) {
49  return acc(p);
50  } else if( *ti == typeid( int ) ) {
52  return acc(p);
53  } else if( *ti == typeid( unsigned int ) ) {
55  return acc(p);
56  }
57  throw std::runtime_error("Unrecognised type for decoration: " + varname);
58  }

◆ part_eta()

static double ParticleScaleFactorTool::part_eta ( const xAOD::IParticle p)
inlinestatic

Definition at line 36 of file ParticleScaleFactorTool.h.

36 {return p.eta();}

◆ part_pt()

static double ParticleScaleFactorTool::part_pt ( const xAOD::IParticle p)
inlinestatic

Definition at line 34 of file ParticleScaleFactorTool.h.

34 {return p.pt();}

◆ part_pt_gev()

static double ParticleScaleFactorTool::part_pt_gev ( const xAOD::IParticle p)
inlinestatic

Definition at line 35 of file ParticleScaleFactorTool.h.

35 {return p.pt()*1e-3;}

◆ print()

void asg::AsgTool::print ( ) const
virtualinherited

◆ recommendedSystematics()

CP::SystematicSet ParticleScaleFactorTool::recommendedSystematics ( ) const
inlineoverridevirtual

the list of all systematics this tool recommends to use

Implements CP::IReentrantSystematicsTool.

Definition at line 64 of file ParticleScaleFactorTool.h.

64 { return affectingSystematics(); }

◆ renounce()

std::enable_if_t<std::is_void_v<std::result_of_t<decltype(&T::renounce)(T)> > && !std::is_base_of_v<SG::VarHandleKeyArray, T> && std::is_base_of_v<Gaudi::DataHandle, T>, void> AthCommonDataStore< AthCommonMsg< AlgTool > >::renounce ( T &  h)
inlineprotectedinherited

Definition at line 380 of file AthCommonDataStore.h.

381  {
382  h.renounce();
383  PBASE::renounce (h);
384  }

◆ renounceArray()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::renounceArray ( SG::VarHandleKeyArray handlesArray)
inlineprotectedinherited

remove all handles from I/O resolution

Definition at line 364 of file AthCommonDataStore.h.

364  {
365  handlesArray.renounce();
366  }

◆ sysInitialize()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysInitialize ( )
overridevirtualinherited

Perform system initialization for an algorithm.

We override this to declare all the elements of handle key arrays at the end of initialization. See comments on updateVHKA.

Reimplemented in DerivationFramework::CfAthAlgTool, AthCheckedComponent< AthAlgTool >, AthCheckedComponent<::AthAlgTool >, and asg::AsgMetadataTool.

◆ sysStart()

virtual StatusCode AthCommonDataStore< AthCommonMsg< AlgTool > >::sysStart ( )
overridevirtualinherited

Handle START transition.

We override this in order to make sure that conditions handle keys can cache a pointer to the conditions container.

◆ updateVHKA()

void AthCommonDataStore< AthCommonMsg< AlgTool > >::updateVHKA ( Gaudi::Details::PropertyBase &  )
inlineinherited

Definition at line 308 of file AthCommonDataStore.h.

308  {
309  // debug() << "updateVHKA for property " << p.name() << " " << p.toString()
310  // << " size: " << m_vhka.size() << endmsg;
311  for (auto &a : m_vhka) {
312  std::vector<SG::VarHandleKey*> keys = a->keys();
313  for (auto k : keys) {
314  k->setOwner(this);
315  }
316  }
317  }

Member Data Documentation

◆ m_affectingSysts

CP::SystematicSet ParticleScaleFactorTool::m_affectingSysts
private

Definition at line 80 of file ParticleScaleFactorTool.h.

◆ m_configFile

std::string ParticleScaleFactorTool::m_configFile
private

Definition at line 68 of file ParticleScaleFactorTool.h.

◆ m_currentSyst

CP::SystematicVariation ParticleScaleFactorTool::m_currentSyst
private

Definition at line 70 of file ParticleScaleFactorTool.h.

◆ m_detStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
privateinherited

Pointer to StoreGate (detector store by default)

Definition at line 393 of file AthCommonDataStore.h.

◆ m_evtStore

StoreGateSvc_t AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
privateinherited

Pointer to StoreGate (event store by default)

Definition at line 390 of file AthCommonDataStore.h.

◆ m_hists

std::map<xAOD::Type::ObjectType,Hists> ParticleScaleFactorTool::m_hists
private

Definition at line 78 of file ParticleScaleFactorTool.h.

◆ m_isNominal

bool ParticleScaleFactorTool::m_isNominal =true
private

Definition at line 81 of file ParticleScaleFactorTool.h.

◆ m_varHandleArraysDeclared

bool AthCommonDataStore< AthCommonMsg< AlgTool > >::m_varHandleArraysDeclared
privateinherited

Definition at line 399 of file AthCommonDataStore.h.

◆ m_vhka

std::vector<SG::VarHandleKeyArray*> AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
privateinherited

Definition at line 398 of file AthCommonDataStore.h.


The documentation for this class was generated from the following files:
python.CaloRecoConfig.f
f
Definition: CaloRecoConfig.py:127
asg::AsgTool
Base class for the dual-use tool implementation classes.
Definition: AsgTool.h:47
Trk::ParticleSwitcher::particle
constexpr ParticleHypothesis particle[PARTICLEHYPOTHESES]
the array of masses
Definition: ParticleHypothesis.h:76
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
xAOD::Electron
Electron_v1 Electron
Definition of the current "egamma version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/Electron.h:17
StateLessPT_NewConfig.proxy
proxy
Definition: StateLessPT_NewConfig.py:392
python.PerfMonSerializer.p
def p
Definition: PerfMonSerializer.py:743
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
SG::AuxTypeRegistry::instance
static AuxTypeRegistry & instance()
Return the singleton registry instance.
Definition: AuxTypeRegistry.cxx:49
ObjectType
ObjectType
Definition: BaseObject.h:11
AthCommonDataStore< AthCommonMsg< AlgTool > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
plotmaker.hist
hist
Definition: plotmaker.py:148
StateLessPT_NewConfig.Format
Format
Definition: StateLessPT_NewConfig.py:146
CaloCondBlobAlgs_fillNoiseFromASCII.db
db
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:43
CP::SystematicSet
Class to wrap a set of SystematicVariations.
Definition: SystematicSet.h:31
bin
Definition: BinsDiffFromStripMedian.h:43
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_evtStore
StoreGateSvc_t m_evtStore
Pointer to StoreGate (event store by default)
Definition: AthCommonDataStore.h:390
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_vhka
std::vector< SG::VarHandleKeyArray * > m_vhka
Definition: AthCommonDataStore.h:398
ParticleScaleFactorTool::part_decor
static double part_decor(const xAOD::IParticle &p, const std::string &varname)
Definition: ParticleScaleFactorTool.h:37
SG::ConstAccessor< double >
read_hist_ntuple.t
t
Definition: read_hist_ntuple.py:5
ATH_MSG_VERBOSE
#define ATH_MSG_VERBOSE(x)
Definition: AthMsgStreamMacros.h:28
CP::SystematicVariation
Definition: SystematicVariation.h:47
xAOD::IParticle
Class providing the definition of the 4-vector interface.
Definition: Event/xAOD/xAODBase/xAODBase/IParticle.h:40
python.DomainsRegistry.reg
reg
globals -----------------------------------------------------------------—
Definition: DomainsRegistry.py:343
python.iconfTool.models.loaders.level
level
Definition: loaders.py:20
SG::VarHandleKeyArray::setOwner
virtual void setOwner(IDataHandleHolder *o)=0
ParticleScaleFactorTool::affectingSystematics
CP::SystematicSet affectingSystematics() const override
the list of all systematics this tool can be affected by
Definition: ParticleScaleFactorTool.h:63
SG::AuxTypeRegistry
Handle mappings between names and auxid_t.
Definition: AuxTypeRegistry.h:62
ParticleScaleFactorTool::m_currentSyst
CP::SystematicVariation m_currentSyst
Definition: ParticleScaleFactorTool.h:70
AthCommonDataStore< AthCommonMsg< AlgTool > >::evtStore
ServiceHandle< StoreGateSvc > & evtStore()
The standard StoreGateSvc (event store) Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:85
SG::auxid_t
size_t auxid_t
Identifier for a particular aux data item.
Definition: AuxTypes.h:27
AthCommonDataStore
Definition: AthCommonDataStore.h:52
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
ParticleScaleFactorTool::part_pt
static double part_pt(const xAOD::IParticle &p)
Definition: ParticleScaleFactorTool.h:34
lumiFormat.i
int i
Definition: lumiFormat.py:92
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
MakeNewFileFromOldAndSubstitution.newHist
dictionary newHist
Definition: ICHEP2016/MakeNewFileFromOldAndSubstitution.py:96
ParticleScaleFactorTool::m_affectingSysts
CP::SystematicSet m_affectingSysts
Definition: ParticleScaleFactorTool.h:80
res
std::pair< std::vector< unsigned int >, bool > res
Definition: JetGroupProductTest.cxx:14
file
TFile * file
Definition: tile_monitor.h:29
CP::SystematicSet::end
const_iterator end() const
description: const iterator to the end of the set
Definition: SystematicSet.h:59
AthenaPoolTestRead.acc
acc
Definition: AthenaPoolTestRead.py:16
python.xAODType.dummy
dummy
Definition: xAODType.py:4
MSG::name
const std::string & name(Level lvl)
Convenience function for translating message levels to strings.
Definition: MsgLevel.cxx:19
AthCommonDataStore< AthCommonMsg< AlgTool > >::m_detStore
StoreGateSvc_t m_detStore
Pointer to StoreGate (detector store by default)
Definition: AthCommonDataStore.h:393
TH2D
Definition: rootspy.cxx:430
xAOD::double
double
Definition: CompositeParticle_v1.cxx:159
SG::VarHandleKeyArray::renounce
virtual void renounce()=0
SG::HandleClassifier::type
std::conditional< std::is_base_of< SG::VarHandleKeyArray, T >::value, VarHandleKeyArrayType, type2 >::type type
Definition: HandleClassifier.h:54
merge_scale_histograms.doc
string doc
Definition: merge_scale_histograms.py:9
PlotSFuncertainty.nom
nom
Definition: PlotSFuncertainty.py:141
CP::SystematicSet::insert
void insert(const SystematicVariation &systematic)
description: insert a systematic into the set
Definition: SystematicSet.cxx:88
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
plotBeamSpotMon.b
b
Definition: plotBeamSpotMon.py:77
TH1::GetBinContent
double GetBinContent(int) const
Definition: rootspy.cxx:298
ParticleScaleFactorTool::m_configFile
std::string m_configFile
Definition: ParticleScaleFactorTool.h:68
ParticleScaleFactorTool::m_hists
std::map< xAOD::Type::ObjectType, Hists > m_hists
Definition: ParticleScaleFactorTool.h:78
xAOD::Photon
Photon_v1 Photon
Definition of the current "egamma version".
Definition: Event/xAOD/xAODEgamma/xAODEgamma/Photon.h:17
PathResolverFindCalibFile
std::string PathResolverFindCalibFile(const std::string &logical_file_name)
Definition: PathResolver.cxx:431
Muon
struct TBPatternUnitContext Muon
CP::SystematicSet::clear
void clear()
description: clear the set
Definition: SystematicSet.cxx:119
CP::SystematicSet::find
iterator find(const SystematicVariation &sys) const
description: find an element in the set
Definition: SystematicSet.h:63
ParticleScaleFactorTool::m_isNominal
bool m_isNominal
Definition: ParticleScaleFactorTool.h:81
LArG4AODNtuplePlotter.varname
def varname(hname)
Definition: LArG4AODNtuplePlotter.py:37
DiTauMassTools::MaxHistStrategyV2::e
e
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:26
a
TList * a
Definition: liststreamerinfos.cxx:10
h
std::remove_if
DataModel_detail::iterator< DVL > remove_if(typename DataModel_detail::iterator< DVL > beg, typename DataModel_detail::iterator< DVL > end, Predicate pred)
Specialization of remove_if for DataVector/List.
Definition: DVL_algorithms.h:70
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
TH1
Definition: rootspy.cxx:268
ParticleScaleFactorTool::part_eta
static double part_eta(const xAOD::IParticle &p)
Definition: ParticleScaleFactorTool.h:36
AthCommonMsg< AlgTool >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
SG::VarHandleBase::vhKey
SG::VarHandleKey & vhKey()
Return a non-const reference to the HandleKey.
Definition: StoreGate/src/VarHandleBase.cxx:616
declareProperty
#define declareProperty(n, p, h)
Definition: BaseFakeBkgTool.cxx:15
xAODType::Tau
@ Tau
The object is a tau (jet)
Definition: ObjectType.h:49
python.Bindings.keys
keys
Definition: Control/AthenaPython/python/Bindings.py:790
SG::DataProxy
Definition: DataProxy.h:44
dq_make_web_display.cl
cl
print [x.__class__ for x in toList(dqregion.getSubRegions()) ]
Definition: dq_make_web_display.py:26
AthCommonDataStore::declareGaudiProperty
Gaudi::Details::PropertyBase & declareGaudiProperty(Gaudi::Property< T > &hndl, const SG::VarHandleKeyType &)
specialization for handling Gaudi::Property<SG::VarHandleKey>
Definition: AthCommonDataStore.h:156
xAOD::Jet
Jet_v1 Jet
Definition of the current "jet version".
Definition: Event/xAOD/xAODJet/xAODJet/Jet.h:17
ParticleScaleFactorTool::part_pt_gev
static double part_pt_gev(const xAOD::IParticle &p)
Definition: ParticleScaleFactorTool.h:35
fitman.k
k
Definition: fitman.py:528
CP::SystematicRegistry::getInstance
static SystematicRegistry & getInstance()
Get the singleton instance of the registry for the curren thread.
Definition: SystematicRegistry.cxx:25
mapkey::key
key
Definition: TElectronEfficiencyCorrectionTool.cxx:37
CP::SystematicVariation::parameter
float parameter() const
description: the numeric parameter contained in the subvariation(), or 0 if the subvariation can't be...
Definition: SystematicVariation.cxx:340