The Gaudi Framework  master (e68eea06)
Loading...
Searching...
No Matches
RRWNTupleCnv.cpp
Go to the documentation of this file.
1/***********************************************************************************\
2* (c) Copyright 1998-2024 CERN for the benefit of the LHCb and ATLAS collaborations *
3* *
4* This software is distributed under the terms of the Apache version 2 licence, *
5* copied verbatim in the file "LICENSE". *
6* *
7* In applying this licence, CERN does not waive the privileges and immunities *
8* granted to it by virtue of its status as an Intergovernmental Organization *
9* or submit itself to any jurisdiction. *
10\***********************************************************************************/
11#define ALLOW_ALL_TYPES
12
13// Compiler include files
16#include <GaudiKernel/NTuple.h>
17
18#include "RRWNTupleCnv.h"
19#include <TTree.h>
20
21// Instantiation of a static factory class used by clients to create
22// instances of this service
24
25// FIXME - leak sanitizers generate a number of warnings here
26//
27// clang-format off
28// Indirect leak of 160 byte(s) in 2 object(s) allocated from:
29// #0 0x7ff846fbbec8 in operator new[](unsigned long) /afs/cern.ch/cms/CAF/CMSCOMM/COMM_ECAL/dkonst/GCC/build/contrib/gcc-8.2.0/src/gcc/8.2.0/libsanitizer/lsan/lsan_interceptors.cc:231
30// #1 0x7ff8336e7653 in TBranch::Init(char const*, char const*, int) /mnt/build/jenkins/workspace/lcg_release_tar/BUILDTYPE/Debug/COMPILER/gcc8binutils/LABEL/centos7/build/projects/ROOT-6.18.00/src/ROOT/6.18.00/tree/tree/src/TBranch.cxx:309
31// #2 0x7ff8336e7039 in TBranch::TBranch(TTree*, char const*, void*, char const*, int, int) /mnt/build/jenkins/workspace/lcg_release_tar/BUILDTYPE/Debug/COMPILER/gcc8binutils/LABEL/centos7/build/projects/ROOT-6.18.00/src/ROOT/6.18.00/tree/tree/src/TBranch.cxx:239
32// #3 0x7ff833773ceb in TTree::Branch(char const*, void*, char const*, int) /mnt/build/jenkins/workspace/lcg_release_tar/BUILDTYPE/Debug/COMPILER/gcc8binutils/LABEL/centos7/build/projects/ROOT-6.18.00/src/ROOT/6.18.00/tree/tree/src/TTree.cxx:1893
33// #4 0x7ff831763748 in RootHistCnv::RRWNTupleCnv::book(std::__cxx11::basic_string<char, std::char_traits<char>, std::allocator<char> > const&, INTuple*, TTree*&) ../RootHistCnv/src/RRWNTupleCnv.cpp:27
34// clang-format on
35//
36// These leaks are currently suppressed in Gaudi/job/Gaudi-LSan.supp - remove entry there to reactivate
37
38//------------------------------------------------------------------------------
39StatusCode RootHistCnv::RRWNTupleCnv::book( const std::string& desc, INTuple* nt, TTree*& rtree )
40//------------------------------------------------------------------------------
41{
42 MsgStream log( msgSvc(), "RRWNTupleCnv" );
43 // Book the tree
44 rtree = new TTree( desc.c_str(), nt->title().c_str() );
45 // Add the branches
46 for ( const auto& i : nt->items() ) {
47 std::string tag = i->name() + rootVarType( i->type() );
48 // add the branch
49 log << MSG::INFO << "ID " << desc << ": added branch: " << i->name() << " / " << tag << endmsg;
50 rtree->Branch( i->name().c_str(), const_cast<void*>( i->buffer() ), tag.c_str() );
51 }
52 log << MSG::INFO << "Booked TTree with ID:" << desc << " \"" << nt->title() << "\"" << endmsg;
54}
55
56//------------------------------------------------------------------------------
58//------------------------------------------------------------------------------
59{
60 if ( rtree ) {
61 // Fill the tree;
62 rtree->Fill();
63 // Reset the NTuple
64 nt->reset();
66 }
67 MsgStream log( msgSvc(), "RRWNTupleCnv" );
68 log << MSG::ERROR << "Attempt to write invalid N-tuple.";
69 if ( nt ) log << nt->title();
70 log << endmsg;
72}
73
74//------------------------------------------------------------------------------
75StatusCode RootHistCnv::RRWNTupleCnv::readData( TTree* /* tree */, INTuple* /* nt */, long /* ievt */ )
76//------------------------------------------------------------------------------
77{
79}
80
81//------------------------------------------------------------------------------
82StatusCode RootHistCnv::RRWNTupleCnv::load( TTree* /* tree */, INTuple*& /* refpObject */ )
83//------------------------------------------------------------------------------
84{
86}
#define DECLARE_CONVERTER(x)
Definition Converter.h:142
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
Definition MsgStream.h:198
SmartIF< IMessageSvc > & msgSvc() const
Retrieve pointer to message service.
NTuple interface class definition.
Definition INTuple.h:86
virtual void reset()=0
Reset all entries to their default values.
virtual const std::string & title() const =0
Object title.
Definition of the MsgStream class used to transmit messages.
Definition MsgStream.h:29
virtual std::string rootVarType(int)
Return ROOT type info:
Row wise NTuple converter class definition.
StatusCode book(const std::string &desc, INTuple *pObject, TTree *&tree) override
Book the N tuple.
StatusCode readData(TTree *rtree, INTuple *pObject, long ievt) override
Read N tuple data.
RRWNTupleCnv(ISvcLocator *svc)
Standard constructor.
StatusCode writeData(TTree *rtree, INTuple *pObject) override
Write N tuple data.
StatusCode load(TTree *tree, INTuple *&refpObject) override
Create the transient representation of an object.
This class is used for returning status codes from appropriate routines.
Definition StatusCode.h:64
constexpr static const auto SUCCESS
Definition StatusCode.h:99
constexpr static const auto FAILURE
Definition StatusCode.h:100
@ ERROR
Definition IMessageSvc.h:22
@ INFO
Definition IMessageSvc.h:22
STL namespace.