ATLAS Offline Software
ToolHandleHistoHelper.h
Go to the documentation of this file.
1 // -*- c++ -*-
2 
3 /*
4  Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
5 */
6 
7 #ifndef JETMONITORING_TOOLHANDLEHISTOHELPER_H
8 #define JETMONITORING_TOOLHANDLEHISTOHELPER_H
9 #include "GaudiKernel/ToolHandle.h"
21 
23 
24 
25 
26  struct HistoRetriever {
27 
28  std::string afterlastdot(const std::string& s){
29  size_t i = s.find_last_of(".");
30  return s.substr( i+1, s.size() );
31  }
32 
33  HistoRetriever(ToolHandleArray<HistoDefinitionTool>& h) : histos(h) {}
34 
35  HistoDefinitionTool* retrieveTool( const std::string & n){
36  for( auto toolH : histos){
37  //std::cout << " xxxx compare "<< afterlastdot( toolH->name() ) << " to "<< n <<std::endl;
38  if( afterlastdot(toolH->name()) == n ) return toolH.operator->();
39  }
40  return NULL;
41  }
42 
43  template<typename T >
44  T* build(const std::string & n){
45  std::string name = "hdef_"; name+=n;
47  if (!tool ) return NULL;
48  return tool->build<T>();
49  }
50 
51 
52  ToolHandleArray<HistoDefinitionTool>& histos;
53  };
54 
55 
56 }
57 
58 
59 #endif
HistoDefinitionTool.h
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
ToolHandleHistoHelper::HistoRetriever::histos
ToolHandleArray< HistoDefinitionTool > & histos
Definition: ToolHandleHistoHelper.h:52
ToolHandleHistoHelper::HistoRetriever::HistoRetriever
HistoRetriever(ToolHandleArray< HistoDefinitionTool > &h)
Definition: ToolHandleHistoHelper.h:33
ToolHandleHistoHelper::HistoRetriever::retrieveTool
HistoDefinitionTool * retrieveTool(const std::string &n)
Definition: ToolHandleHistoHelper.h:35
ToolHandleHistoHelper
Definition: ToolHandleHistoHelper.h:22
lumiFormat.i
int i
Definition: lumiFormat.py:92
beamspotman.n
n
Definition: beamspotman.py:731
ToolHandleHistoHelper::HistoRetriever
Definition: ToolHandleHistoHelper.h:26
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:192
AtlCoolConsole.tool
tool
Definition: AtlCoolConsole.py:453
ToolHandleHistoHelper::HistoRetriever::build
T * build(const std::string &n)
Definition: ToolHandleHistoHelper.h:44
h
ToolHandleHistoHelper::HistoRetriever::afterlastdot
std::string afterlastdot(const std::string &s)
Definition: ToolHandleHistoHelper.h:28
HistoDefinitionTool
Definition: HistoDefinitionTool.h:31