2 #include <boost/numeric/conversion/bounds.hpp>
3 #include <boost/filesystem.hpp>
4 #include <boost/foreach.hpp>
5 #include <boost/lexical_cast.hpp>
8 #include "GaudiKernel/IRegistry.h"
9 #include "GaudiKernel/IDataManagerSvc.h"
10 #include "GaudiKernel/IDataProviderSvc.h"
11 #include "GaudiKernel/IOpaqueAddress.h"
12 #include "GaudiKernel/DataStoreItem.h"
13 #include "GaudiKernel/DataObject.h"
14 #include "GaudiKernel/MsgStream.h"
21 namespace bf =
boost::filesystem;
22 using
boost::lexical_cast;
23 using
boost::bad_lexical_cast;
30 declareProperty(
"EventsPerFile", m_eventsPerFile
31 = boost::numeric::bounds< unsigned int>::highest() );
32 declareProperty(
"NumericFilename", m_numericFilename =
false );
33 declareProperty(
"NumbersAdded", m_nNumbersAdded = 6 );
70 string filename = outputPath.filename().string();
71 bf::path dir = outputPath.parent_path();
72 string stem = outputPath.stem().string();
73 string extension = outputPath.extension().string();
76 if ( !bf::exists( dir ) ) {
78 stream <<
"Directory " << dir <<
" does not exist.";
86 m_iFile = lexical_cast<
unsigned int >( stem );
87 }
catch(
const bad_lexical_cast& ) {
89 stream <<
"Filename " << filename
90 <<
" is not a number, which was needed.";
94 stringstream iFileStream;
96 string iFile( iFileStream.str() );
97 unsigned int length = 0;
99 if ( stem.length() > iFile.length() ) {
100 length = stem.length() - iFile.length();
104 if ( !dir.empty() ) {
107 for (
unsigned int i = 0;
i < length; ++
i ) {
110 name << iFile << extension;
114 size_t pos = stem.rfind(
"_" );
115 stem = stem.substr( 0, pos );
118 stringstream iFileStream;
120 string iFile( iFileStream.str() );
122 unsigned int length = 0;
128 name << dir <<
"/" << stem;
129 for (
unsigned int i = 0;
i < length; ++
i ) {
130 if (
i == 0 ) name <<
"_";
133 name << iFile << extension;
bool isEventAccepted() const
Test whether this event should be output.
virtual const std::string & message() const
error message to be printed
Definition of the MsgStream class used to transmit messages.
Define general base for Gaudi exception.
The ISvcLocator is the interface implemented by the Service Factory in the Application Manager to loc...
virtual StatusCode writeObjects()
OutputStream override: Select the different objects and write them to file.
MsgStream & endmsg(MsgStream &s)
MsgStream Modifier: endmsg. Calls the output method of the MsgStream.
std::string m_outputName
Name of the output file.
A small to stream Data I/O.
virtual StatusCode writeObjects()
Select the different objects and write them to file.
#define DECLARE_COMPONENT(type)
This class is used for returning status codes from appropriate routines.
virtual const std::string & name() const
The identifying name of the algorithm object.
SmartIF< IMessageSvc > & msgSvc() const
The standard message service.
void clearSelection()
Clear list of selected objects.
Extension of OutputStream to write run records after last event.
virtual StatusCode execute()
Working entry point.
unsigned int m_nNumbersAdded
unsigned int m_eventsPerFile