Skip to content
Snippets Groups Projects

Revert some interface changes of THistSvc

Merged Martin Errenst requested to merge merrenst/Gaudi:THistSvc-180131 into master
Compare and Show latest version
8 files
+ 604
286
Compare changes
  • Side-by-side
  • Inline
Files
8
@@ -4,6 +4,7 @@
#include "GaudiKernel/ITHistSvc.h"
#include "GaudiKernel/MsgStream.h"
#include "GaudiKernel/RndmGenerators.h"
#include "GaudiKernel/LockedHandle.h"
#include <math.h>
#include "TDirectory.h"
@@ -69,6 +70,23 @@ StatusCode THistWrite::initialize()
error() << "Couldn't register gauss3d" << endmsg;
}
TH1F* h5 = new TH1F( "TempHist5", "Temporary Tree 5", 100, 0., 100. );
if ( m_ths->regHist( "TempHist5", std::unique_ptr<TH1F>( h5 ) ).isFailure() ) {
error() << "Couldn't register TempHist5" << endmsg;
}
if( strcmp( h5->GetName(), "TempHist5" ) ){
error() << "Couldn't use TempHist5 afterwards. getName = " << h5->GetName() << endmsg;
}
TH1D* h6 = new TH1D( "TempHist6", "Temporary Tree 6", 100, 0., 100. );
if ( m_ths->regHist( "TempHist6", std::unique_ptr<TH1D>( h6 ), h6 ).isFailure() ) {
error() << "Couldn't register TempHist6" << endmsg;
}
if( strcmp( h6->GetName(), "TempHist6" ) ){
error() << "Couldn't use TempHist6 afterwards. getName = " << h6->GetName() << endmsg;
}
// Profile in "/"
std::unique_ptr<TH1> tp = std::make_unique<TProfile>( "profile", "profile", 100, -50., -50. );
if ( m_ths->regHist( "/rec/prof", std::move( tp ) ).isFailure() ) {
@@ -81,6 +99,29 @@ StatusCode THistWrite::initialize()
error() << "Couldn't register tr" << endmsg;
}
// Update to stream "upd", dir "/xxx"
std::unique_ptr<TH1F> h3s = std::make_unique<TH1F>( "1Dgauss_shared", "1D Gaussian", 100, -50., 50. );
LockedHandle<TH1> lh1;
if ( m_ths->regShared( "/upd/xxx/gauss1d_shared", std::move ( h3s ), lh1 ).isFailure() ) {
error() << "Couldn't register gauss1d_shared" << endmsg;
}
// Recreate 2D tree in "/"
std::unique_ptr<TH2F> h3sa = std::make_unique<TH2F>( "2Dgauss_shared", "2D Gaussian", 100, -50., 50., 100, -50, 50 );
LockedHandle<TH2> lh2;
if ( m_ths->regShared( "/rec/gauss2d_shared", std::move( h3sa ), lh2 ).isFailure() ) {
error() << "Couldn't register gauss2d_shared" << endmsg;
}
// 3D tree in "/"
std::unique_ptr<TH3F> h4s =
std::make_unique<TH3F>( "3Dgauss_shared", "3D Gaussian", 100, -50., 50., 100, -50, 50, 100, -50, 50 );
LockedHandle<TH3> lh3;
if ( m_ths->regShared( "/rec/gauss3d_shared", std::move( h4s ), lh3 ).isFailure() ) {
error() << "Couldn't register gauss3d_shared" << endmsg;
}
return StatusCode::SUCCESS;
}
@@ -139,6 +180,46 @@ StatusCode THistWrite::execute()
error() << "Couldn't retrieve 3Dgauss" << endmsg;
}
if ( m_ths->getHist( "TempHist5", h ).isSuccess() ) {
h->Fill( x );
} else {
error() << "Couldn't retrieve TempHist 5" << endmsg;
}
if ( m_ths->getHist( "TempHist6", h ).isSuccess() ) {
h->Fill( x );
} else {
error() << "Couldn't retrieve TempHist 6" << endmsg;
}
LockedHandle<TH1> lh1;
if ( m_ths->getShared( "/upd/xxx/gauss1d_shared", lh1 ).isSuccess() ) {
for ( int i = 0; i < 1000; ++i ) {
lh1->Fill( gauss(), 1. );
}
} else {
error() << "Couldn't retrieve 1Dgauss_shared" << endmsg;
}
LockedHandle<TH2> lh2;
if ( m_ths->getShared( "/rec/gauss2d_shared", lh2 ).isSuccess() ) {
for ( int i = 0; i < 1000; ++i ) {
lh2->Fill( gauss(), gauss(), 1. );
}
} else {
error() << "Couldn't retrieve 2Dgauss_shared" << endmsg;
}
LockedHandle<TH3> lh3;
if ( m_ths->getShared( "/rec/gauss3d_shared", lh3 ).isSuccess() ) {
for ( int i = 0; i < 1000; ++i ) {
lh3->Fill( gauss(), gauss(), gauss(), 1. );
}
} else {
error() << "Couldn't retrieve 3Dgauss_shared" << endmsg;
}
TTree* tr;
if ( m_ths->getTree( "/rec/trees/stuff/tree1", tr ).isFailure() ) {
error() << "Couldn't retrieve tree tree1" << endmsg;
Loading