#include <DybOutputFileRoller.h>
Inheritance diagram for DybOutputFileRoller:
Public Member Functions | |
DybOutputFileRoller (const std::string &name, ISvcLocator *svcloc) | |
virtual | ~DybOutputFileRoller () |
StatusCode | initialize () |
StatusCode | execute () |
StatusCode | finalize () |
virtual StatusCode | sysExecute () |
void | put (IDataProviderSvc *svc, DataObject *object, const std::string &address, const bool useRootInTES=true) const |
void | put (DataObject *object, const std::string &address, const bool useRootInTES=true) const |
Gaudi::Utils::GetData< TYPE >::return_type | get (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const |
Gaudi::Utils::GetData< TYPE >::return_type | get (const std::string &location, const bool useRootInTES=true) const |
TYPE * | getDet (IDataProviderSvc *svc, const std::string &location) const |
TYPE * | getDet (const std::string &location) const |
bool | exist (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const |
bool | exist (const std::string &location, const bool useRootInTES=true) const |
bool | existDet (IDataProviderSvc *svc, const std::string &location) const |
bool | existDet (const std::string &location) const |
TYPE * | getOrCreate (IDataProviderSvc *svc, const std::string &location, const bool useRootInTES=true) const |
TYPE * | getOrCreate (const std::string &location, const bool useRootInTES=true) const |
bool | registerContext () const |
INTupleSvc * | evtColSvc () const |
IAlgContextSvc * | contextSvc () const |
TOOL * | tool (const std::string &type, const std::string &name, const IInterface *parent=0, bool create=true) const |
TOOL * | tool (const std::string &type, const IInterface *parent=0, bool create=true) const |
SERVICE * | svc (const std::string &name, const bool create=true) const |
IUpdateManagerSvc * | updMgrSvc () const |
IDataProviderSvc * | fastContainersSvc () const |
StatusCode | Error (const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const |
StatusCode | Warning (const std::string &msg, const StatusCode st=StatusCode::FAILURE, const size_t mx=10) const |
StatusCode | Print (const std::string &msg, const StatusCode st=StatusCode::SUCCESS, const MSG::Level lev=MSG::INFO) const |
StatusCode | Assert (const bool ok, const std::string &message="", const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const |
StatusCode | Assert (const bool ok, const char *message, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const |
StatusCode | Exception (const std::string &msg, const GaudiException &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const |
StatusCode | Exception (const std::string &msg, const std::exception &exc, const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const |
StatusCode | Exception (const std::string &msg="no message", const StatusCode sc=StatusCode(StatusCode::FAILURE, true)) const |
MsgStream & | msgStream (const MSG::Level level) const |
MsgStream & | always () const |
MsgStream & | fatal () const |
MsgStream & | err () const |
MsgStream & | error () const |
MsgStream & | warning () const |
MsgStream & | info () const |
MsgStream & | debug () const |
MsgStream & | verbose () const |
MsgStream & | msg () const |
const Statistics & | counters () const |
StatEntity & | counter (const std::string &tag) const |
MSG::Level | msgLevel () const |
bool | msgLevel (const MSG::Level level) const |
void | resetMsgStream () const |
bool | typePrint () const |
bool | propsPrint () const |
bool | statPrint () const |
bool | errorsPrint () const |
long | printStat (const MSG::Level level=MSG::ALWAYS) const |
long | printErrors (const MSG::Level level=MSG::ALWAYS) const |
long | printProps (const MSG::Level level=MSG::ALWAYS) const |
void | registerCondition (const std::string &condition, StatusCode(CallerClass::*mf)()=NULL) |
void | registerCondition (const std::string &condition, CondType *&condPtrDest, StatusCode(CallerClass::*mf)()=NULL) |
void | registerCondition (char *condition, StatusCode(CallerClass::*mf)()=NULL) |
void | registerCondition (TargetClass *condition, StatusCode(CallerClass::*mf)()=NULL) |
StatusCode | runUpdate () |
TransientFastContainer< T > * | getFastContainer (const std::string &location, typename TransientFastContainer< T >::size_type initial=0) |
StatusCode | release (const IInterface *interface) const |
unsigned long | release () |
const std::string & | context () const |
const std::string & | rootInTES () const |
double | globalTimeOffset () const |
virtual StatusCode | sysStart () |
virtual StatusCode | sysInitialize () |
virtual StatusCode | sysReinitialize () |
virtual StatusCode | sysRestart () |
virtual StatusCode | sysStop () |
virtual StatusCode | sysFinalize () |
virtual StatusCode | sysBeginRun () |
virtual StatusCode | sysEndRun () |
virtual const std::string & | name () const |
virtual const std::string & | version () const |
virtual StatusCode | configure () |
virtual StatusCode | terminate () |
virtual StatusCode | start () |
virtual StatusCode | stop () |
virtual StatusCode | reinitialize () |
virtual StatusCode | restart () |
virtual bool | isExecuted () const |
virtual void | setExecuted (bool state) |
virtual void | resetExecuted () |
virtual StatusCode | beginRun () |
virtual StatusCode | endRun () |
virtual Gaudi::StateMachine::State | FSMState () const |
virtual Gaudi::StateMachine::State | targetFSMState () const |
virtual bool | isEnabled () const |
virtual bool | filterPassed () const |
virtual void | setFilterPassed (bool state) |
StatusCode | service (const std::string &name, T *&psvc, bool createIf=true) const |
StatusCode | service (const std::string &svcType, const std::string &svcName, T *&psvc) const |
void | setOutputLevel (int level) |
IAuditorSvc * | auditorSvc () const |
IChronoStatSvc * | chronoSvc () const |
IChronoStatSvc * | chronoStatService () const |
IDataProviderSvc * | detSvc () const |
IDataProviderSvc * | detDataService () const |
IConversionSvc * | detCnvSvc () const |
IConversionSvc * | detDataCnvService () const |
IDataProviderSvc * | eventSvc () const |
IDataProviderSvc * | evtSvc () const |
IDataProviderSvc * | eventDataService () const |
IConversionSvc * | eventCnvSvc () const |
IConversionSvc * | eventDataCnvService () const |
IHistogramSvc * | histoSvc () const |
IHistogramSvc * | histogramDataService () const |
IMessageSvc * | msgSvc () const |
IMessageSvc * | messageService () const |
INTupleSvc * | ntupleSvc () const |
INTupleSvc * | ntupleService () const |
IRndmGenSvc * | randSvc () const |
IToolSvc * | toolSvc () const |
IExceptionSvc * | exceptionSvc () const |
ISvcLocator * | serviceLocator () const |
ISvcLocator * | svcLoc () const |
StatusCode | createSubAlgorithm (const std::string &type, const std::string &name, Algorithm *&pSubAlg) |
std::vector< Algorithm * > * | subAlgorithms () const |
virtual StatusCode | setProperty (const Property &p) |
virtual StatusCode | setProperty (const std::string &s) |
virtual StatusCode | setProperty (const std::string &n, const std::string &v) |
StatusCode | setProperty (const std::string &name, const TYPE &value) |
virtual StatusCode | getProperty (Property *p) const |
virtual const Property & | getProperty (const std::string &name) const |
virtual StatusCode | getProperty (const std::string &n, std::string &v) const |
virtual const std::vector< Property * > & | getProperties () const |
StatusCode | setProperties () |
Property * | declareProperty (const std::string &name, T &property, const std::string &doc="none") const |
Property * | declareRemoteProperty (const std::string &name, IProperty *rsvc, const std::string &rname="") const |
IMonitorSvc * | monitorSvc () const |
void | declareInfo (const std::string &name, const T &var, const std::string &desc) const |
void | declareInfo (const std::string &name, const std::string &format, const void *var, int size, const std::string &desc) const |
unsigned long | addRef () |
StatusCode | queryInterface (const InterfaceID &riid, void **) |
Static Public Member Functions | |
static const InterfaceID & | interfaceID () |
static const InterfaceID & | interfaceID () |
static const InterfaceID & | interfaceID () |
Public Attributes | |
SUCCESS | |
NO_INTERFACE | |
VERSMISMATCH | |
LAST_ERROR | |
Protected Types | |
typedef std::map< std::string, StatEntity > | Statistics |
typedef std::map< std::string, unsigned int > | Counter |
typedef std::vector< IAlgTool * > | AlgTools |
typedef std::pair< IInterface *, std::string > | ServiceEntry |
typedef std::vector< ServiceEntry > | Services |
Protected Member Functions | |
StatusCode | releaseTool (const IAlgTool *tool) const |
StatusCode | releaseSvc (const IInterface *svc) const |
bool | isInitialized () const |
bool | isFinalized () const |
int | outputLevel () const |
IntegerProperty & | outputLevelProperty () |
void | initOutputLevel (Property &prop) |
Static Protected Attributes | |
static const bool | IgnoreRootInTES |
static const bool | UseRootInTES |
Private Types | |
typedef std::map< std::string, std::string > | ConditionPropertyMap_t |
Note: this is not a property. | |
typedef std::map< std::string, ConditionData > | CDMap_t |
Private Member Functions | |
StatusCode | roll (std::string stream, ConditionData &cd) |
StatusCode | check_e (std::string stream, ConditionData &cd) |
StatusCode | check_m (std::string stream, ConditionData &cd) |
StatusCode | check_s (std::string stream, ConditionData &cd) |
Private Attributes | |
std::string | m_condition |
Property Condition: set the default size of output files for any streams not explicitly listed in the ConditionMap. | |
ConditionPropertyMap_t | m_condpropmap |
int | m_current_execnum |
IRootIOSvc * | m_rio |
IRootIOSvc::FileMap | m_filemap |
CDMap_t | m_cdmap |
Classes | |
struct | ConditionData |
This works by modifying the RootIOCnvSvc's output file map when a condition is met. If no output files are specified this algorithm quietly does nothing.
The condition is set with the Condition properties, eg 15S will produce files with fifteen seconds worth of data.
The output file map specified on the nuwa.py command line can contain a format code like "%d" (or variants like "%04d"). If so, it will be expanded to hold a count, starting from 1, of the file. If no "%d" code is found then the file names will be modified to change ".root" to "_%04d.root".
This algorithm will roll output file names based on a given condition which consists of integer number followed by a character code:
E: execution cycles M: mebibytes (10^6 bytes) S: seconds period of time as measured by the RegistrationSequences
Note, current RootIO requires all output files to be split on common boundaries in order to be read in correctly.
Brett Viren <bv@bnl.gov> Fri Jan 14 15:30:36 2011
Definition at line 45 of file DybOutputFileRoller.h.
typedef std::map<std::string,std::string> DybOutputFileRoller::ConditionPropertyMap_t [private] |
Note: this is not a property.
I can be turned on when/if RootIO can handle input streams that do not have common file boundaries. See #671.
ConditionMap: explicitly set condition to split specific output stream. A special stream named "default" can be set which will have the behavior of the Condition property (which overides if set). The map key is a stream name (like "/Event/Gen/GenEvent") and the map value is a condition as described in the Condition property's documentation. Note: for a non-default condition to be applied the stream->file mapping must be explicitly defined in RootIOCnvSvc (via nuwa.py's -O/--output-streams option).
Definition at line 82 of file DybOutputFileRoller.h.
typedef std::map<std::string,ConditionData> DybOutputFileRoller::CDMap_t [private] |
Definition at line 105 of file DybOutputFileRoller.h.
DybOutputFileRoller::DybOutputFileRoller | ( | const std::string & | name, | |
ISvcLocator * | svcloc | |||
) |
Definition at line 14 of file DybOutputFileRoller.cc.
00016 : GaudiAlgorithm(name,svcloc) 00017 , m_current_execnum(0) 00018 , m_rio(0) 00019 { 00020 declareProperty("Condition",m_condition="", 00021 "Set the default condition for rolling to a new output file"); 00022 00023 // This condition map will be a trivial one just containing 00024 // "default" as set by the global condition above. It can be made 00025 // non-trivial when/if RootIO can handle reading input streams 00026 // with non-common boundaries. See #671. 00027 00028 //declareProperty("ConditionMap",m_condpropmap, 00029 // "Set the condition map for rolling each stream to a new output file"); 00030 }
DybOutputFileRoller::~DybOutputFileRoller | ( | ) | [virtual] |
StatusCode DybOutputFileRoller::initialize | ( | ) | [virtual] |
Reimplemented from GaudiAlgorithm.
Definition at line 36 of file DybOutputFileRoller.cc.
00037 { 00038 StatusCode sc = this->GaudiAlgorithm::initialize(); 00039 if (sc.isFailure()) return sc; 00040 00041 // Get IRootIOSvc 00042 sc = this->service("RootIOCnvSvc",m_rio); 00043 if (sc.isFailure()) return sc; 00044 00045 m_filemap = m_rio->fileMap(); 00046 if (!m_filemap.size()) { 00047 return StatusCode::SUCCESS; // we just won't play this time 00048 } 00049 00050 // munge the output filenames where needed 00051 { 00052 IRootIOSvc::FileMap::iterator it, done = m_filemap.end(); 00053 for (it = m_filemap.begin(); it != done; ++it) { 00054 string fname = Form(it->second.c_str(),0); 00055 if (fname != it->second) { 00056 continue; // already has a %d code that does something 00057 } 00058 00059 string::size_type ind = it->second.rfind("."); 00060 // shouldn't happen, but whatevs, we'll roll with it 00061 if (string::npos == ind) { 00062 ind = it->second.size(); 00063 } 00064 00065 // replace filename with one that has a %d code. 00066 fname = it->second.substr(0,ind) + "_%04d" + it->second.substr(ind); 00067 it->second = fname; 00068 } 00069 } 00070 00071 // specifically set default condition if one is given 00072 if (m_condition.size()) { 00073 m_condpropmap["default"] = m_condition; 00074 } 00075 00076 { // parse conditions map and strip out any explicit conditions 00077 // with no matching entry in output file map 00078 ConditionPropertyMap_t::iterator it, done = m_condpropmap.end(); 00079 for (it=m_condpropmap.begin(); it != done; ++it) { 00080 string stream = it->first; 00081 string condition = it->second; 00082 00083 if (stream != "default") { 00084 IRootIOSvc::FileMap::iterator fit = m_filemap.find(stream); 00085 if (fit == m_filemap.end()) { 00086 error() << "Condition \"" << condition 00087 << "\" for stream \"" << stream 00088 << "\" has no output file. " 00089 << "An entry can be specified with nuwa.py's" 00090 << " -O/--output-stream option" 00091 << endreq; 00092 return StatusCode::FAILURE; 00093 } 00094 } 00095 00096 string::size_type clen = condition.size(); 00097 if (!clen) { 00098 error() << "Given a null condition for stream \"" 00099 << stream << "\"" << endreq; 00100 return StatusCode::FAILURE; 00101 } 00102 int size = atoi(condition.substr(0,clen-1).c_str()); 00103 char unit = condition[clen-1]; 00104 ConditionData cd = ConditionData(size,unit); 00105 cd.cycles = size; // special init, count down on this if an E condition 00106 m_cdmap[stream] = cd; 00107 info() << "Condition for stream " << stream << ": " << size << unit << endreq; 00108 sc = this->roll(stream,m_cdmap[stream]); 00109 if (sc.isFailure()) return sc; 00110 } 00111 } 00112 00113 return StatusCode::SUCCESS; 00114 }
StatusCode DybOutputFileRoller::execute | ( | ) | [virtual] |
Reimplemented from GaudiAlgorithm.
Definition at line 205 of file DybOutputFileRoller.cc.
00206 { 00207 if (!m_filemap.size()) { // no output files, bail blissfully 00208 return StatusCode::SUCCESS; 00209 } 00210 00211 RegistrationSequence* rs = get<RegistrationSequence>(RegistrationSequence::defaultLocation()); 00212 TimeStamp now = rs->earliest(); 00213 ++m_current_execnum; 00214 info() << "Execution #" << m_current_execnum << " @ " << now << endreq; 00215 00216 CDMap_t::iterator it, done = m_cdmap.end(); 00217 for (it=m_cdmap.begin(); it != done; ++it) { 00218 string stream = it->first; 00219 ConditionData& cd = it->second; 00220 00221 StatusCode sc; 00222 00223 switch (cd.unit) { 00224 case 'M': 00225 sc = check_m(stream,cd); 00226 break; 00227 case 'E': 00228 sc = check_e(stream,cd); 00229 break; 00230 case 'S': 00231 sc = check_s(stream,cd); 00232 break; 00233 default: 00234 error() << "Unknown condition unit '" << cd.unit << "'" 00235 << " for stream \"" << stream << "\"" 00236 << endreq; 00237 sc = StatusCode::FAILURE; 00238 } 00239 if (sc.isFailure()) return sc; 00240 } 00241 return StatusCode::SUCCESS; 00242 }
StatusCode DybOutputFileRoller::finalize | ( | ) | [virtual] |
Reimplemented from GaudiAlgorithm.
Definition at line 244 of file DybOutputFileRoller.cc.
00245 { 00246 return this->GaudiAlgorithm::finalize(); 00247 }
StatusCode DybOutputFileRoller::roll | ( | std::string | stream, | |
ConditionData & | cd | |||
) | [private] |
Definition at line 115 of file DybOutputFileRoller.cc.
00116 { 00117 ++cd.count; 00118 00119 IRootIOSvc::FileMap::iterator fit = m_filemap.find(stream); 00120 if (fit == m_filemap.end()) { 00121 error() << "Failed to find output filespec for \"" << stream << "\"" << endreq; 00122 return StatusCode::FAILURE; 00123 } 00124 00125 string fname = Form(fit->second.c_str(),cd.count); 00126 m_rio->associateOutput(fname.c_str(),stream.c_str()); 00127 00128 info() << "Rolled " << stream << " to file " << fname << endreq; 00129 00130 return StatusCode::SUCCESS; 00131 }
StatusCode DybOutputFileRoller::check_e | ( | std::string | stream, | |
ConditionData & | cd | |||
) | [private] |
Definition at line 161 of file DybOutputFileRoller.cc.
00162 { 00163 info() << "check_e " << stream << " " << cd.cycles << " " << (void*)&cd << endreq; 00164 00165 // check for first time 00166 if (cd.cycles < 0) { 00167 cd.cycles = cd.size; 00168 } 00169 00170 if (cd.cycles>0) { 00171 --cd.cycles; 00172 return StatusCode::SUCCESS; 00173 } 00174 cd.cycles = cd.size-1; // reset countdown 00175 info () << "Reached " << cd.size << " execution cycles" << endreq; 00176 return this->roll(stream,cd); 00177 }
StatusCode DybOutputFileRoller::check_m | ( | std::string | stream, | |
ConditionData & | cd | |||
) | [private] |
Definition at line 133 of file DybOutputFileRoller.cc.
00134 { 00135 IRootIOSvc::FileMap fm = m_rio->fileMap(); 00136 IRootIOSvc::FileMap::iterator fit = fm.find(stream); 00137 if (fit == fm.end()) { 00138 error() << "Failed to find an output file for stream \"" << stream << "\"" 00139 << endreq; 00140 return StatusCode::FAILURE; 00141 } 00142 string fname = fit->second; 00143 struct stat si; 00144 int err = stat(fname.c_str(), &si); 00145 if (err) { 00146 warning() << "Failed to stat " << fname 00147 << ". Maybe no output yet? Letting it go." 00148 << endreq; 00149 return StatusCode::SUCCESS; 00150 } 00151 00152 if (si.st_size/1000000 < cd.size) { // bytes to mibibytes 00153 return StatusCode::SUCCESS; 00154 } 00155 info () << "Reached " << cd.size << " MiB size" << endreq; 00156 return this->roll(stream,cd); 00157 }
StatusCode DybOutputFileRoller::check_s | ( | std::string | stream, | |
ConditionData & | cd | |||
) | [private] |
Definition at line 181 of file DybOutputFileRoller.cc.
00182 { 00183 RegistrationSequence* rs = 00184 get<RegistrationSequence>(RegistrationSequence::defaultLocation()); 00185 00186 TimeStamp now = rs->earliest(); 00187 00188 // check for first time 00189 if (cd.timestamp == TimeStamp::GetBOT()) { 00190 cd.timestamp = now; 00191 return StatusCode::SUCCESS; 00192 } 00193 00194 TimeStamp dt = now - cd.timestamp; 00195 int deltat = (int)((double)dt); 00196 if (deltat < cd.size) { // not yet 00197 return StatusCode::SUCCESS; 00198 } 00199 00200 cd.timestamp = now; 00201 info () << "Reached " << cd.size << " seconds at " << now << endreq; 00202 return this->roll(stream,cd); 00203 }
std::string DybOutputFileRoller::m_condition [private] |
Property Condition: set the default size of output files for any streams not explicitly listed in the ConditionMap.
This should be an integer followed by a unit code. The unit code can be one of:
E: execution cycles M: mebibytes (10^6 bytes) S: seconds period of time as measured by the RegistrationSequences
A special condition "None" will leave the stream untouched.
Definition at line 67 of file DybOutputFileRoller.h.
Definition at line 83 of file DybOutputFileRoller.h.
int DybOutputFileRoller::m_current_execnum [private] |
Definition at line 86 of file DybOutputFileRoller.h.
IRootIOSvc* DybOutputFileRoller::m_rio [private] |
Definition at line 87 of file DybOutputFileRoller.h.
Definition at line 88 of file DybOutputFileRoller.h.
CDMap_t DybOutputFileRoller::m_cdmap [private] |
Definition at line 106 of file DybOutputFileRoller.h.