Cat
Options.cpp
Go to the documentation of this file.
1 // $Id: Options.cpp,v 1.10 2006/06/09 20:47:15 fmachefe Exp $
2 
3 // Include files
4 #include <unistd.h>
5 #include <algorithm>
6 
7 // local
8 #include "Options.h"
9 
10 //-----------------------------------------------------------------------------
11 // Implementation file for class : Options
12 //
13 // 2004-07-26 : Frederic Machefert
14 //-----------------------------------------------------------------------------
15 
16 //=============================================================================
17 // Standard constructor, initializes variables
18 //=============================================================================
20  m_logStream = 0;
21  m_logDefStream = 0;
22  m_stream = 0;
23 
24  setLogDefFile("session.log");
25  setStream();
26 
28 
29  setNEvtMax ( 100 );
30  setTimeMax ( 100 );
31  setNEvt ( 0 );
32  setNErrors ( 0 );
33  setRunNumber ( 0 );
34  setPrintFreq ( 0 );
35  setPlotFreq ( 0 );
36 
38 
39  setStorageDir("Run");
40 
41  m_storageDefault=std::string("run");
43  setDataStorage ( false );
44  setLogStorage ( false );
45 
46 #ifdef WIN32
47  char buffer[_MAX_PATH];
48  getcwd(buffer,_MAX_PATH);
49  setStoragePath( std::string(buffer) );
50 #else
51  char buffer[256];
52  getcwd(buffer,256);
53  setStoragePath( std::string(buffer)+std::string("/data") );
54 #endif
55 
56  setCurrentPath( std::string(buffer) );
57 
58 }
59 
60 //=============================================================================
61 // Destructor
62 //=============================================================================
64  if ( 0!=m_logDefStream){
65  m_logDefStream->close();
66  delete m_logDefStream;
68  }
69 }
70 
71 //=========================================================================
72 //
73 //=========================================================================
75  setRunNumber( runNumber()+1 );
76 }
77 
78 //=========================================================================
79 // Get Accessor to member m_dataFile
80 // Run Number insertion if required
81 //=========================================================================
82 
83 std::string Options::dataFile () {
84  std::string id;
85  id.append(std::string(".root"));
86  std::string file = m_storageFile+id;
87  return file;
88 }
89 
90 //=========================================================================
91 // Get Accessor to member m_logFile
92 // Run Number insertion if required
93 //=========================================================================
94 
95 std::string Options::logFile () {
96  std::string id;
97  id.append(std::string(".log"));
98  std::string file = m_storageFile+id;
99  return file;
100 }
101 
102 
103 //=========================================================================
104 //
105 //
106 //=========================================================================
108  char output[250];
109  sprintf(output,"Events to process : %ld",m_nEvtMax); m_log.msgSvc(MsgSvc::INFO,output,"Options::help");//< number of events to process
110  sprintf(output,"Current run number : %ld",m_runNumber); m_log.msgSvc(MsgSvc::INFO,output,"Options::help");//< Current Run Number
111  sprintf(output,"Events processed : %ld",m_nEvt); m_log.msgSvc(MsgSvc::INFO,output,"Options::help");//< number of events processed
112  sprintf(output,"Number of errors : %ld",m_nErrors); m_log.msgSvc(MsgSvc::INFO,output,"Options::help");//< number of errors in present process
113  sprintf(output,"Stop on error flag : %i",m_stopOnError); m_log.msgSvc(MsgSvc::INFO,output,"Options::help");
114  sprintf(output,"Printout frequency : %ld",m_printFreq); m_log.msgSvc(MsgSvc::INFO,output,"Options::help");//< Evt Number Output Frequency
115  sprintf(output,"Plot update frequency : %ld",m_plotFreq); m_log.msgSvc(MsgSvc::INFO,output,"Options::help");//< Evt Number plot Frequency
116  sprintf(output,"Automatic run number flag : %i",m_runNumberManagement); m_log.msgSvc(MsgSvc::INFO,output,"Options::help");//< Run Number Automatically Managed
117  sprintf(output,"Storage flag : %i",m_dataStorage); m_log.msgSvc(MsgSvc::INFO,output,"Options::help");
118  sprintf(output,"Storage filename : %s",m_storageFile.c_str()); m_log.msgSvc(MsgSvc::INFO,output,"Options::help");//< data & log file name for storage
119  sprintf(output,"Storage directory : %s",m_storageDir.c_str()); m_log.msgSvc(MsgSvc::INFO,output,"Options::help");//< data & log directory name for storage
120  sprintf(output,"Storage default filename : %s",m_storageDefault.c_str()); m_log.msgSvc(MsgSvc::INFO,output,"Options::help");//< data & log default file name for storage
121  sprintf(output,"Storage path : %s",m_storagePath.c_str()); m_log.msgSvc(MsgSvc::INFO,output,"Options::help");//< data & log file path for storage
122  sprintf(output,"Log Storage flag : %i",m_logStorage); m_log.msgSvc(MsgSvc::INFO,output,"Options::help");//< Log Storage boolean
123  sprintf(output,"Log default filename : %s",m_logDefFile.c_str()); m_log.msgSvc(MsgSvc::INFO,output,"Options::help");//< default log file name for storage
124  sprintf(output,"Application current path : %s",m_currentPath.c_str()); m_log.msgSvc(MsgSvc::INFO,output,"Options::help");
125  sprintf(output,"Current definition filename : %s",m_defFile.c_str()); m_log.msgSvc(MsgSvc::INFO,output,"Options::help");//< Definition file
126  sprintf(output,"Batch run flag : %i",m_batch); m_log.msgSvc(MsgSvc::INFO,output,"Options::help");//< batch mode
127 }
bool m_runNumberManagement
Definition: Options.h:455
std::ofstream * m_logStream
Definition: Options.h:459
void setPlotFreq(unsigned long plotFreq)
Definition: Options.h:66
void setStorageDir(std::string filename)
Definition: Options.h:172
bool m_dataStorage
Definition: Options.h:439
std::string m_storageDir
Definition: Options.h:441
void setNEvt(unsigned long nEvt)
Definition: Options.h:309
bool m_logStorage
Definition: Options.h:440
~Options()
Definition: Options.cpp:63
void incRunNumber()
Definition: Options.cpp:74
void setCurrentPath(std::string currentPath)
Definition: Options.h:127
std::ofstream * m_logDefStream
Definition: Options.h:460
unsigned long m_nEvt
Definition: Options.h:447
std::string m_storagePath
Definition: Options.h:444
void setLogDefFile(std::string defFile)
Definition: Options.h:276
void setLogOutputLevel(MsgSvc::MsgLevel logOutputLevel)
Definition: Options.h:34
unsigned long runNumber()
Definition: Options.h:107
unsigned long m_plotFreq
Definition: Options.h:450
std::string m_defFile
Definition: Options.h:445
unsigned long m_runNumber
Definition: Options.h:453
void setRunNumberManagement(bool runNumberManagement)
Definition: Options.h:115
std::string m_logDefFile
Definition: Options.h:461
int m_nEvtMax
Definition: Options.h:451
void setStoragePath(std::string storagePath)
Definition: Options.h:143
std::string m_currentPath
Definition: Options.h:438
std::string m_storageDefault
Definition: Options.h:443
std::string m_storageFile
Definition: Options.h:442
void setNEvtMax(int nEvtMax)
Definition: Options.h:325
void setLogStorage(bool logStorage)
Definition: Options.h:260
Options()
Definition: Options.cpp:19
void setPrintFreq(unsigned long printFreq)
Definition: Options.h:50
bool m_batch
Definition: Options.h:456
std::string logFile()
Definition: Options.cpp:95
void setNErrors(unsigned long nErrors)
Definition: Options.h:357
void setStorageFile(std::string filename=std::string(""))
Definition: Options.h:188
void print()
Definition: Options.cpp:107
void setRunNumber(unsigned long runNumber)
Definition: Options.h:99
void setDataStorage(bool dataStorage)
Definition: Options.h:244
void setStream(std::string file=std::string(""))
Definition: Options.h:400
unsigned long m_printFreq
Definition: Options.h:449
MsgSvc m_log
Definition: Options.h:435
std::ofstream * m_stream
Definition: Options.h:458
void setTimeMax(unsigned long timeMax)
Definition: Options.h:341
std::string dataFile()
Definition: Options.cpp:83
unsigned long m_nErrors
Definition: Options.h:448
void msgSvc(MsgSvc::MsgLevel, std::string, std::string call=std::string(""))
Definition: MsgSvc.cpp:42
bool m_stopOnError
Definition: Options.h:446