Commit dfd0a503 authored by cvs2svn's avatar cvs2svn
Browse files

This commit was manufactured by cvs2svn to create tag

'GAUDI_v19r3-pre'.

git-svn-id: svn+ssh://svn.cern.ch/reps/gaudi/distribution/tags/GAUDI/GAUDI_v19r3-pre@3769 53ecefc3-a64d-0410-9bdf-b8581fa3287e
parent f4b2b8d8
include $(CMTROOT)/src/Makefile.header
include $(CMTROOT)/src/constituents.make
!include $(CMTROOT)\src\NMakefile.header
!include $(CMTROOT)\src\constituents.nmake
package RootHistCnv
version v9r11
branches doc cmt src
use GaudiKernel v*
use AIDA v* LCG_Interfaces -no_auto_imports
use ROOT v* LCG_Interfaces -no_auto_imports
# component library
library RootHistCnv -import=ROOT -import=AIDA ../src/*.cpp
apply_pattern component_library library=RootHistCnv
#apply_pattern library_Clinkopts library=RootHistCnv import=ROOT
#apply_pattern packageShr
#==============================================================
private
macro_append ROOT_linkopts " -lHist -lTree -lMatrix" \
WIN32 " libHist.lib libTree.lib libMatrix.lib"
#apply_pattern package_Cshlibflags
Package: RootHistCnv
Package manager : David Quarrie
================= RootHistCnv v9r11 =====================================
! 2007-01-08 Markus Frank
- Fix histogram converters to automatically convert THxF to THxD
when reading from file.
! 2006-11-30 - Pere Mato
Adpated package to the new PluginSvc
- Removed protected from constructor/destructors and fiendship of
Factory class
! 2006-11-13 Markus Frank -- patch #908
- Simplify histogram conversion. Take advantage of the fact that the
underlying implementation is realized using ROOT.
================= RootHistCnv v9r10 =====================================
! 2006-03-13 - Hubert Degaudenzi
- changed the default tile for trees form "Athena Trees" to "Gaudi
Trees".
================= RootHistCnv v9r9 =====================================
! 2006-03-13 - Hubert Degaudenzi
- fix for patches #691-694 by Markus Frank which allow support for
objects in Evt collections
================= RootHistCnv v9r8 =====================================
! 2006-01-10 - Hubert Degaudenzi
- use of the DECLARE_XXX_FACTORY macros. replacement of the
corresponding code.
================= RootHistCnv v9r7 =====================================
! 2005-12-20 - Hubert Degaudenzi
- PI has been replaced by GaudiPI.
================= RootHistCnv v9r6 =====================================
! 2005-10-27 - Hubert Degaudenzi
- modified requirements file for future use of the new package GaudiPI.
================= RootHistCnv v9r5 =====================================
! 2005-08-15 - Hubert Degaudenzi
- patch #506. Creating H2D and H3D histograms (function
createPersistent) was creating wrong values for weights in some
cases. This patch removes all the implementation code and calls the
Aida Root histogram converter (from pi) instead (Stephan Roiser).
Remarks:
-> this fix adds a dependency on PI in RootHistConv
-> it also calls the conversion routine for H1D (to be consistent)
- RFileCnv.cpp: Fixed small bug concerning checking output level
before printing (Leggett)
================= RootHistCnv v9r4 =====================================
! 2005-01-11 - Pere Mato
- Added profile histograms converters (Charles Leggett)
================= RootHistCnv v9r3 =====================================
! 2004-07-22 - Pere Mato
- HxDCnv.cpp, PersSvc.cpp, RConverter.*: added the option to prefix
histograms id with "h" when they are numerical (mandatoty for
HBOOK). This faciliates the interaction with them from the ROOT
application.
RootHistSvc.ForceAlphaIds = true;
================= RootHistCnv v9r2 =====================================
! 2004-07-05 - Pere Mato
- requirements: changed to use the new LCGCMT interface packages
================= RootHistCnv v9r1p1 =====================================
! 2004-05-07 - Pere Mato
- RConverter.cpp: Fixed a problem that affected reading histogram
files from Windows. Probably due to ":" or "\" in file
name. Replaced gDirectory->cd() by TFile::cd()
================= RootHistCnv v9r1 =====================================
! 2003-01-14 - Charles Leggett
- RNTuple.cpp deal with empty ntuples
================= RootHistCnv v9r0 =====================================
! 2003-11-28 - Pere Mato
- Fixed: [ Bug #1772 ] RootHistCnv produces too many INFO messages
Changed from INFO to DEBUG messages related to conversion of histograms
Changed names from YYY::XXXX to XXXX to allow easy control with job options
! 2003-10-28 - Grigori Rybkine
- Adapted for use with the version of HistogramSvc using (instead of HTL)
the ROOT based AIDA histograms implementation from the LCG PI project
This includes:
- change to the new AIDA version 3.0.0
- the modified histogram converter classes H1DCnv, H2DCnv, H3DCnv,
each responsible now for conversion of the corresponding fixed and
variable bin size histograms (classes H1DVarCnv, H2DVarCnv,
H3DVarCnv removed)
- Added setting of statistics for 1D, 2D, 3D histograms being made persistent
- Made changes (in particular, to RDirectoryCnv.cpp) so as to make
reading of 1D variable bin size histograms and 2D fixed bin size
histograms possible
- Added ability to read in 2D variable bin size histograms
! 2003-11-26 - Pere Mato
- Changes for Mac OSX (Guy Barrand)
! 2003-08-05 - Pere Mato
- Removed warnings produced by VC7
- Adapted to new version of GaudiKernel (POOL integration)
================= RootHistCnv v8r2p3 =====================================
! 2003-06-10 - Charles Leggett
- Added ability to read in Matrices, and fixed size Arrays
================= RootHistCnv v8r2p2 =====================================
! 2003-06-04 - Charles Leggett
- fixed bug in RCWNtupleCnv::book, where was setting range for
non integer TLeaf
- FIXME: when next version of ROOT appears, add TLeafI->SetMinimum() call
================= RootHistCnv v8r2p1 =====================================
! 2003-05-19 - Charles Leggett
- fixed bug in analyzeItem (Bug #576 Matrices in CWN not filled correctly)
================= RootHistCnv v8r2 =======================================
! 2003-03-10 - Charles Leggett
- Added ability to read H1D, H2D, H1DVar
- added direct accessor to TObject* in RootObjAddress (ipar[2])
- Added bool flag to PersSvc, so warning of "undefined output file name"
only gets printed once.
! 2003-02-13 - Charles Leggett
- Added ability to read in CWNT
- Added RootObjAddress to keep track of TObject* ptr (m_ipar[2])
- got rid of regNTuple as functionality is supplanted by RootObjAddress
- block names are part of full variable names, as BLK::var[size]/Type
- fix core dump on destruct of PersSvc if hist output file not set
- fix Write() so only one copy of ntuples gets written
================= RootHistCnv v8r1p2 =======================================
! 2002-11-29 - Pere Mato
- Corrections to support linking applications statically
================= v8r1p1 =======================================
! 2002-10-29 - Pere Mato
================= v8r0p2 =======================================
! 2002-10-10 - Pere Mato
- Corrected bug reported by Thomas Ruf concerning the filling of
underflow and overflow contents for 2D and 3D histograms.
================= v8r1 =========================================
================= v8r0p1 =======================================
! 2002-09-23 - Florence Ranjard
- requirements - use v*
===================v8r0==========================================
! 20020717 - Pere Mato
- Change of the ROOT version to v3.03 (3.03/06)
! 20020703 - Paolo Calafiura
- PersSvc.cpp: disambiguate method overload for SmartDataPtr
- RCWNtupleCnv.cpp: removed static parseName qualifier
===================v7r0==========================================
! 20020618 - Pere Mato
- Change of the ROOT version to v3.02 (v3.02.07)
===================v6r0==========================================
! 20020405 - Markus Frank
- Adapted to the new version of Gaudi
- Removal of all global static storage
- Major cleanup
! 20020327 - Pere Mato
- Adapted to use the new AIDA interfaces (2.2)
- Added converters for 3D histograms support
===================v5r0==========================================
! 20011122 - Pere Mato (v5)
- Adapted to use the new GaudiKernel and the re-design of the
data sore classes
! 20010626 - Pere Mato
- Changed to use AIDA interfaces
- Modified to not create a directory (/stat) if histograms are at top level
! 20010618 - v4 (Flr)
requirements - use ROOT v3r01
! 20010508 - Pere Mato
- Using GaudiKernel v10
! 20010315 - David Quarrie
Fix problems when using ROOT for both event and histogram persistency.
! 20010223 - David Quarrie
Tweaks to NTupleINfo.h for template handling on Solaris.
! 20010119 - Pere Mato
Accomodate to the changes in GaudiKernel. Removed the extern declarations to access
IIDs.
!20001128 RootHistCnv v1 (P.Mato)
Adapted to new version of CMT and NMake for NT
!20001106 RootHistCnv v1 Marco Cattaneo
- removed unneccessary dependence on CERNLIB, and explicit dependence on EXTLIB
(implicit through dependence on Gaudi)
!20001027 Pere Mato
- Removed compilations problems for NT
!20001020 Pere Mato
- Few changes needed to be compatible with current head revision of Gaudi
and fixes to compilation problems in Windows
!20001013 David Quarrie
- New package developed by Charles Leggett to support Histogram
Persistency based on ROOTsupport. As far as the user is concerned,
They need to add to their jobOptions.txt file the following lines:
// Specify Share Library for ROOT persistency support
ApplicationMgr.DLLs += "RootHistSvc";
// Specify ROOT or HBOOK persistency (HBOOK is default)
ApplicationMgr.HistogramPersistency = "ROOT";
// Specify Histogram Persistency Output File
HistogramPersistencySvc.OutputFile = "histo.rt"
// $Id: DirectoryCnv.cpp,v 1.6 2006/11/13 15:19:34 hmd Exp $
// Include files
#include "GaudiKernel/CnvFactory.h"
#include "DirectoryCnv.h"
//------------------------------------------------------------------------------
//
// Implementation of class : RootHistCnv::DirectoryCnv
//
// Author : Charles Leggett
//
//------------------------------------------------------------------------------
DECLARE_NAMESPACE_CONVERTER_FACTORY(RootHistCnv,DirectoryCnv)
//------------------------------------------------------------------------------
StatusCode RootHistCnv::DirectoryCnv::createObj(IOpaqueAddress* /* pAddress */,
DataObject*& refpObject)
{
refpObject = new DataObject();
return StatusCode::SUCCESS;
}
//------------------------------------------------------------------------------
StatusCode
RootHistCnv::DirectoryCnv::createRep(DataObject* pObj, IOpaqueAddress*& refpAddr) {
if ( changeDirectory(pObj) ) {
const char* d_nam = pObj->name().c_str()+1;
if (! gDirectory->GetKey(d_nam) ) {
gDirectory->mkdir(d_nam);
}
gDirectory->cd(d_nam);
return createAddress(pObj, gDirectory, 0, refpAddr);
}
refpAddr = 0;
return StatusCode::FAILURE;
}
#ifndef ROOTHISTCNV_DIRECTORYCNV_H
#define ROOTHISTCNV_DIRECTORYCNV_H 1
// Include files
#include "GaudiKernel/DataObject.h"
#include "RConverter.h"
//------------------------------------------------------------------------------
//
// ClassName: RootHistCnv::DirectoryCnv
//
// Description: Histogram directory converter
//
// Author: Charles Leggett
//
//------------------------------------------------------------------------------
namespace RootHistCnv {
class DirectoryCnv : public RConverter {
public:
/// Create the transient representation of an object.
virtual StatusCode createObj(IOpaqueAddress* pAddr, DataObject*& refpObj);
/// Convert the transient object to the requested representation.
virtual StatusCode createRep(DataObject* pObj, IOpaqueAddress*& refpAddr);
/// Inquire class type
static const CLID& classID() { return CLID_DataObject; }
/// Standard constructor
DirectoryCnv(ISvcLocator* svc) : RConverter(CLID_DataObject, svc) {}
/// Standard constructor
DirectoryCnv(const CLID& clid, ISvcLocator* svc) : RConverter(clid, svc) {}
/// Standard destructor
virtual ~DirectoryCnv() {}
};
} // namespace RootHistCnv
#endif // ROOTHISTCNV_DIRECTORYCNV_H
#ifdef __cplusplus
#ifndef HBOOKCNV_NTUPLEINFO_H
#define HBOOKCNV_NTUPLEINFO_H 1
#include "GaudiKernel/Kernel.h"
#include "GaudiKernel/NTuple.h"
class NTUPLEINFO {
public:
long id;
char title[128];
char rzdir[256];
long numEnt;
long numVar;
char block[32];
// struct _var {
char name[512][64];
long dim[512];
long theDim[512][5];
long hasIndex[512];
char index[512][64];
char type[512];
long size[512];
long hasRange[512];
long irange[512][2];
double frange[512][2];
template <class TYPE>
void getBounds(long i, TYPE& min, TYPE& max, TYPE& null) const {
if ( hasRange ) {
min = (type[i]=='R') ? TYPE(frange[i][0]) : TYPE(irange[i][0]);
max = (type[i]=='R') ? TYPE(frange[i][1]) : TYPE(irange[i][1]);
}
else {
min = NTuple::Range<TYPE>::min();
max = NTuple::Range<TYPE>::max();
}
null = TYPE(0);
}
TEMPLATE_SPECIALIZATION
void getBounds(long /*i*/, bool& min, bool& max, bool& null ) const {
min = null = false;
max = true;
}
template <class TYPE>
bool isRangeWithin(long i, TYPE min, TYPE max) const {
if ( hasRange[i] ) {
return min <= (TYPE)irange[i][0] && (TYPE)irange[i][1] <= max;
}
else if ( type[i] == 'I' || type[i] == 'U' ) {
return NTuple::Range<TYPE>::min() <= min && NTuple::Range<TYPE>::max() >= max;
}
return false;
}
TEMPLATE_SPECIALIZATION
bool isRangeWithin(long i, float /* min */, float /* max*/ ) const {
if ( size[i] == 32 ) return true;
return false;
}
TEMPLATE_SPECIALIZATION
bool isRangeWithin(long i, double /* min */, double /* max */ ) const {
if ( size[i] == 64 ) return true;
return false;
}
TEMPLATE_SPECIALIZATION
bool isRangeWithin(long /* i */ , bool min, bool max) const {
return min == false && max == true;
}
long idist(long i) const {
return irange[i][1] - irange[i][0];
}
double fdist(long i) const {
return frange[i][1] - frange[i][0];
}
// } var[512];
long getIndex(const char* nam) const {
if ( nam[0] != 0 ) {
for ( int i = 0; i < numVar; i++ ) {
if ( strncmp(name[i], nam, sizeof(name[i])) == 0 ) {
return i;
}
}
}
return -1;
}
};
#endif // HBOOKCNV_NTUPLEINFO_H
#else
#ifdef _WIN32
STRUCTURE /NTUPLEVAR/
CHARACTER*64 NAME
INTEGER NDIM
INTEGER THEDIM(5)
INTEGER HASINDEX
CHARACTER*64 INDEX
CHARACTER*1 TYPE
INTEGER SIZE
INTEGER HASRANGE
UNION
MAP
INTEGER IMIN, IMAX
END MAP
MAP
REAL*8 FMIN, FMAX
END MAP
END UNION
END STRUCTURE
STRUCTURE /NTUPLEINFO/
INTEGER ID
CHARACTER*128 TITLE
INTEGER NOENT
INTEGER NDIM
CHARACTER*8 BLOCK
RECORD /NTUPLEVAR/ VAR(512)
END STRUCTURE
#else
c TYPE NTUPLEVAR
CHARACTER*64 VNAME(512)
INTEGER VNDIM(512)
INTEGER VTHEDIM(512,5)
INTEGER VHASINDEX(512)
CHARACTER*64 VINDEX(512)
CHARACTER*1 VTYPE(512)
INTEGER VSIZE(512)
INTEGER VHASRANGE(512)
c UNION
c MAP
INTEGER VIMIN(512), VIMAX(512)
c END MAP
c MAP
REAL*8 VFMIN(512), VFMAX(512)
c END MAP
c END UNION
c END TYPE NTUPLEVAR
c TYPE NTUPLEINFO
INTEGER NTID
CHARACTER*128 NTTITLE
INTEGER NTNOENT
INTEGER NTNDIM
CHARACTER*8 NTBLOCK
c TYPE(NTUPLEVAR) VAR(512)
c END TYPE NTUPLEINFO
COMMON/NTUPLEINFO/VNAME,VNDIM,VTHEDIM,
& VHASINDEX,VINDEX,VTYPE,VSIZE,
& VHASRANGE, VIMIN, VIMAX, VFMIN, VFMAX,
& NTID, NTTITLE, NTNDIM, NTBLOCK
#endif
#endif
// $Id: PersSvc.cpp,v 1.14 2006/12/14 11:40:00 leggett Exp $
// Include files
#include "GaudiKernel/DataObject.h"
#include "GaudiKernel/SvcFactory.h"
#include "GaudiKernel/MsgStream.h"
#include "GaudiKernel/ISvcLocator.h"
#include "GaudiKernel/IRegistry.h"
#include "GaudiKernel/SmartDataPtr.h"
#include "RootObjAddress.h"
#include "RConverter.h"
#include "PersSvc.h"
#include "TFile.h"
//-----------------------------------------------------------------------------
//
// Implementation of class : RootHistCnv::PersSvc
//
// Author : Charles Leggett
//
//-----------------------------------------------------------------------------
// Instantiation of a static factory class used by clients to create
// instances of this service
DECLARE_NAMESPACE_SERVICE_FACTORY(RootHistCnv,PersSvc)
namespace RootHistCnv {
static std::string stat_dir = "/stat";
static std::string undefFileName = "UndefinedROOTOutputFileName";
};
//-----------------------------------------------------------------------------
StatusCode RootHistCnv::PersSvc::initialize()
//-----------------------------------------------------------------------------
{
MsgStream log( messageService(), name() );
StatusCode status = ConversionSvc::initialize();
if( status.isFailure() ) return status;
// Get my properties from the JobOptionsSvc
if (setProperties().isFailure()) {
log << MSG::ERROR << "Could not set my properties" << endreq;
return StatusCode::FAILURE;
}
// Initialize ROOT if output file name is defined
if( undefFileName != m_defFileName ) {
m_hfile = new TFile(m_defFileName.c_str(),"RECREATE","GAUDI Histograms");
} else {
m_hfile = 0;
}
log << MSG::INFO << "Writing ROOT histograms to: " << m_defFileName
<< endreq;
return StatusCode(StatusCode::SUCCESS,true);
}
//-----------------------------------------------------------------------------
StatusCode RootHistCnv::PersSvc::finalize()
//-----------------------------------------------------------------------------
{
// Close ROOT only if the output file name is defined
MsgStream log( messageService(), name() );
log << MSG::DEBUG << "RootHistCnv::PersSvc::finalize()" << endreq;
if( undefFileName != m_defFileName ) {
m_hfile->Write("",TObject::kOverwrite);
m_hfile->Close();
}
return ConversionSvc::finalize();
}
//-----------------------------------------------------------------------------
StatusCode RootHistCnv::PersSvc::createRep(DataObject* pObject,
IOpaqueAddress*& refpAddress)
//-----------------------------------------------------------------------------
{
// There are objects in the HDS to be stored
if( undefFileName != m_defFileName ) {
SmartDataPtr<DataObject> top(dataProvider(), stat_dir);
if ( 0 != top ) {
IRegistry* pReg = top->registry();
if ( pReg ) {
if ( top.ptr() == pObject ) {
TDirectory* pDir = m_hfile;
refpAddress = new RootObjAddress( repSvcType(),
CLID_DataObject,
stat_dir,
m_defFileName,
long(pDir),
long(0));
return StatusCode::SUCCESS;
}
else {
StatusCode sc = ConversionSvc::createRep(pObject, refpAddress);
if( sc.isFailure() ) {
MsgStream log( messageService(), name() );
log << MSG::ERROR
<< "Error while creating persistent Histogram:"
<< pReg->identifier()
<< endreq;
}
return sc;
}
}
}
MsgStream err( messageService(), name() );
err << MSG::ERROR
<< "Internal error while creating Histogram persistent representations"
<< endreq;
return StatusCode::FAILURE;
} else {
if (!m_prtWar) {
m_prtWar = true;
MsgStream log( messageService(), name() );
log << MSG::WARNING
<< "no ROOT output file name, "
<< "Histograms cannot be persistified" << endreq;
}
}
return StatusCode::SUCCESS;
}
//-----------------------------------------------------------------------------
RootHistCnv::PersSvc::PersSvc(const std::string& name, ISvcLocator* svc)
//-----------------------------------------------------------------------------
: ConversionSvc(name, svc, ROOT_StorageType), m_prtWar(false) {
declareProperty("OutputFile", m_defFileName = undefFileName);
declareProperty("ForceAlphaIds", m_alphaIds = false);