NSCL DDAS  12.1-001
Support for XIA DDAS at FRIB
Public Member Functions | List of all members
RootFileDataSink Class Reference

A ROOT file sink for DDAS data. More...

#include <RootFileDataSink.h>

Public Member Functions

 RootFileDataSink (ufmt::RingItemFactoryBase *pFactory, const char *fileName, const char *treeName="ddas")
 Constructor. More...
 
virtual ~RootFileDataSink ()
 Destructor. More...
 
virtual void putItem (const ufmt::CRingItem &item)
 Put a ring item to file. More...
 
virtual void put (const void *pData, size_t nBytes)
 Called to put arbitrary data to the file. More...
 

Detailed Description

A ROOT file sink for DDAS data.

Note
The put() method is not intended to be used by this class but is part of the mandatory interface of the CDataSink base class. If it's used, a warning will be output to stderr. The data will then be treated as a raw ring item, turned into a CRingItem and putItem() will be called from then on. The behavior in this case is likely undefined.

Constructor & Destructor Documentation

◆ RootFileDataSink()

RootFileDataSink::RootFileDataSink ( ufmt::RingItemFactoryBase *  pFactory,
const char *  fileName,
const char *  treeName = "ddas" 
)

Constructor.

Parameters
pFactoryFactory for creating ring items from hit bodies.
fileNameROOT file to open.
treeNameName of the tree to create in the root file. The tree name defaults to "DDASRootHit" if not provided.
Exceptions
Allexceptions back to the caller.

We're going to make this sink so it can be used in other programs. That implies preserving ROOT's concept of a current working directory across our operation.

◆ ~RootFileDataSink()

RootFileDataSink::~RootFileDataSink ( )
virtual

Destructor.

Flush the stuff to file and delete all the dynamic components which we own.

Note
The factory is owned by the caller and is the caller's responsibility.

Member Function Documentation

◆ put()

void RootFileDataSink::put ( const void *  pData,
size_t  nBytes 
)
virtual

Called to put arbitrary data to the file.

Parameters
pDataPointer to the data.
nBytesNumber of bytes of data to put; actually ignored.

We really don't know how to do this so:

  • First time we're called we'll emit a warning that users shouldn't really do this.
  • We'll treat the data pointer as a pointer to a raw ring item, turn it into a CRingItem and call putItem.

◆ putItem()

void RootFileDataSink::putItem ( const ufmt::CRingItem &  item)
virtual

Put a ring item to file.

Parameters
itemReference to a ring item object.
Exceptions
std::length_errorIf the event size is different than expected.

The ring item is assumed to consist of a set of fragments. Each fragment contains a hit. The hits are decoded and added to the tree event. Once that's done we can fill the tree and delete any dynamic storage we got.


The documentation for this class was generated from the following files: