2 template < typename T >
3 StatusCode PhysicsVariablePlots::defineHistogram( const std::string& variableName,
4 const std::string& title,
5 int nBinsX, double xMin, double xMax,
6 const std::string& path ) {
8 if ( m_Histograms1D.find( variableName.c_str() ) != m_Histograms1D.end() ) {
9 ATH_MSG_ERROR( "Trying to define histogram for variable '" << variableName << "' but this histogram already exists!" );
10 return StatusCode::FAILURE;
13 m_Histograms1D[ variableName.c_str() ] = new T( variableName.c_str(),
17 std::string subPath = "";
18 if ( not path.empty() ) subPath = path + "/";
20 const std::string histoPath = "/MYSTREAM/"+ subPath + variableName;
21 TH1* histoObj = m_Histograms1D.at( variableName.c_str() );
22 ATH_CHECK( m_histSvc->regHist( histoPath,histoObj ) );
24 return StatusCode::SUCCESS;
27 template < typename T >
28 StatusCode PhysicsVariablePlots::defineHistogram( const std::string& variableName,
29 const std::string& title,
30 int nBinsX, double xMin, double xMax,
31 int nBinsY, double yMin, double yMax,
32 const std::string& path ) {
34 if ( m_Histograms2D.find( variableName.c_str() ) != m_Histograms2D.end() ) {
35 ATH_MSG_ERROR( "Trying to define histogram for variable '" << variableName << "' but this histogram already exists!" );
36 return StatusCode::FAILURE;
39 m_Histograms2D[ variableName.c_str() ] = new T( variableName.c_str(),
44 std::string subPath = "";
45 if ( not path.empty() ) subPath = path + "/";
47 const std::string histoPath = "/MYSTREAM/" + subPath + variableName;
48 TH2* histoObj = m_Histograms2D.at( variableName.c_str() );
49 ATH_CHECK( m_histSvc->regHist( histoPath,histoObj ) );
51 return StatusCode::SUCCESS;
54 template < typename T >
55 StatusCode PhysicsVariablePlots::fillHistogram( const std::string& variableName,
58 if ( m_Histograms1D.find( variableName.c_str() ) == m_Histograms1D.end() ) {
59 ATH_MSG_ERROR( "Trying to fill histogram for variable '" << variableName << "' but this histogram has not been stored!" );
60 return StatusCode::FAILURE;
63 m_Histograms1D.at( variableName.c_str() )->Fill( value );
64 return StatusCode::SUCCESS;
67 template < typename T,typename U >
68 StatusCode PhysicsVariablePlots::fillHistogram( const std::string& variableName,
72 if ( m_Histograms2D.find( variableName.c_str() ) == m_Histograms2D.end() ) {
73 ATH_MSG_ERROR( "Trying to fill histogram for variable '" << variableName << "' but this histogram has not been stored!" );
74 return StatusCode::FAILURE;
77 m_Histograms2D.at( variableName.c_str() )->Fill( valueX,valueY );
78 return StatusCode::SUCCESS;