ATLAS Offline Software
Loading...
Searching...
No Matches
HistoDefinitionTool.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3*/
4
6
7#include "TH1.h"
8#include "TH2.h"
9#include "TProfile.h"
10
12 , m_attname("")
13 , m_htitle("")
14{
15 declareInterface<HistoDefinitionTool>(this);
16
17 // Kepp lower case property names so they match the ROOT variable names
18 // in TH1 constructors.
19 declareProperty("hname", m_attname); // can't use 'name' because of incompatilbility in python
20 declareProperty("title", m_htitle);
21
22 declareProperty("nbinsx", m_nbinsx);
23 declareProperty("xlow", m_xlow);
24 declareProperty("xup", m_xup);
25
26 declareProperty("nbinsy", m_nbinsy);
27 declareProperty("ylow", m_ylow);
28 declareProperty("yup", m_yup);
29
30}
31
33
34 // Use the name of the tool by default. Extract "Something.Var" -> "Var"
35 if(m_attname.empty()) {
36 auto found = name().rfind('.');
37 if(found != std::string::npos) m_attname = name().substr(++found);
38 else m_attname= name();
39 ATH_MSG_INFO("Built "<< name() << " -> "<< m_attname ) ;
40
41 }
42
43 return StatusCode::SUCCESS;
44}
45
47 return new TH1F(m_attname.c_str(), m_htitle.c_str(), m_nbinsx, m_xlow, m_xup);
48}
49
51 return new TH2F(m_attname.c_str(), m_htitle.c_str(), m_nbinsx, m_xlow, m_xup, m_nbinsy, m_ylow, m_yup);
52}
53
54TProfile* HistoDefinitionTool::buildTProfile(bool useYLimits){
55
56 if(useYLimits) return new TProfile(m_attname.c_str(), m_htitle.c_str(), m_nbinsx, m_xlow, m_xup, m_ylow, m_yup);
57 else return new TProfile(m_attname.c_str(), m_htitle.c_str(), m_nbinsx, m_xlow, m_xup);
58}
59
60
61template<> TH1F* HistoDefinitionTool::build<TH1F>(){return buildTH1F();}
62template<> TH2F* HistoDefinitionTool::build<TH2F>(){return buildTH2F();}
63template<> TProfile* HistoDefinitionTool::build<TProfile>(){return buildTProfile();}
#define ATH_MSG_INFO(x)
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
HistoDefinitionTool(const std::string &t)
TH1F * buildTH1F()
Build histos according to properties.
virtual StatusCode initialize()
Dummy implementation of the initialisation function.
TProfile * buildTProfile(bool useYLimits=false)
AsgTool(const std::string &name)
Constructor specifying the tool instance's name.
Definition AsgTool.cxx:58