1 #include "marlin/MarlinConfig.h"
11 #include <AIDA/IAnalysisFactory.h>
12 #include <AIDA/ITreeFactory.h>
13 #include <AIDA/ITree.h>
14 #include <AIDA/IHistogramFactory.h>
15 #include <AIDA/ITupleFactory.h>
16 #include <AIDA/IDataPointSetFactory.h>
18 #include <AIDA/ICloud1D.h>
23 AIDAProcessor aAIDAProcessor ;
26 AIDAProcessor::AIDAProcessor() : Processor(
"AIDAProcessor"),
27 _analysisFactory(NULL),
32 _dataPointSetFactory(NULL),
37 _description =
"Processor that handles AIDA files. Creates on directory per processor. "
38 " Processors only need to create and fill the histograms, clouds and tuples. Needs to be the first ActiveProcessor" ;
40 registerProcessorParameter(
"FileType" ,
41 " type of output file root (default) or xml )" ,
45 registerProcessorParameter(
"FileName" ,
46 " filename without extension" ,
50 registerProcessorParameter(
"Compress" ,
51 " compression of output file 0: false >0: true (default) " ,
57 AIDAProcessor* AIDAProcessor::_me ;
61 Processor* AIDAProcessor::newProcessor() {
63 _me =
new AIDAProcessor ;
67 void AIDAProcessor::init() {
74 bool compress = false ;
80 _analysisFactory = AIDA_createAnalysisFactory() ;
82 assert( _analysisFactory != 0 ) ;
84 _treeFactory = _analysisFactory->createTreeFactory();
86 assert( _treeFactory != 0 ) ;
93 option += compress ?
"compress=yes" :
"compress=no";
95 if( _fileType ==
"root" ) {
97 _fileName +=
".root" ;
100 }
else if( _fileType ==
"xml" ) {
102 _fileName +=
".aida";
105 _tree = _treeFactory->create( _fileName, _fileType,
false,
true , option );
107 assert( _tree != 0 ) ;
110 _histoFactory = _analysisFactory->createHistogramFactory( *_tree ) ;
112 assert( _histoFactory != 0 ) ;
114 _tupleFactory = _analysisFactory->createTupleFactory( *_tree ) ;
116 assert( _tupleFactory != 0 ) ;
118 _dataPointSetFactory = _analysisFactory->createDataPointSetFactory( *_tree ) ;
120 assert( _dataPointSetFactory != 0 ) ;
125 void AIDAProcessor::processRunHeader( LCRunHeader* ) {
129 void AIDAProcessor::processEvent( LCEvent* ) {
133 void AIDAProcessor::check( LCEvent* ) {
135 static AIDA::ICloud1D* hEvtTime ;
136 static clock_t eventTime =
clock () ;
140 if( isFirstEvent() ) {
142 assert( _tree->mkdir( name() ) ) ;
144 _tree->cd(
"/" + name() ) ;
146 hEvtTime = _histoFactory->createCloud1D(
"hEvtProcessingTime",
"event processing time [s] ", 100 ) ;
153 clock_t now =
clock () ;
155 hEvtTime->fill(
double(now - eventTime) /
double(CLOCKS_PER_SEC) ) ;
161 void AIDAProcessor::end(){
166 delete _treeFactory ;
167 delete _analysisFactory ;
168 delete _histoFactory ;
169 delete _tupleFactory ;
170 delete _dataPointSetFactory ;
175 AIDA::IAnalysisFactory* AIDAProcessor::GetIAnalysisFactory(
const Processor* proc )
178 return _me->_analysisFactory;
182 AIDA::IHistogramFactory* AIDAProcessor::histogramFactory(
const Processor* proc ){
189 return _me->_histoFactory ;
192 AIDA::ITupleFactory* AIDAProcessor::tupleFactory(
const Processor* proc ) {
194 return _me->_tupleFactory ;
197 AIDA::IDataPointSetFactory* AIDAProcessor::dataPointSetFactory(
const Processor* proc ) {
199 return _me->_dataPointSetFactory ;
202 AIDA::ITree* AIDAProcessor::tree(
const Processor* proc ) {
205 throw Exception(
" AIDA is not properly initialized - you need to have the AIDAProcessor as"
206 " first processor in your execute section !" ) ;
209 if( !_me->_tree->cd(
"/" + proc->name() ) ) {
210 _me->_tree->mkdir(
"/" + proc->name() ) ;
211 _me->_tree->cd(
"/" + proc->name() ) ;
218 #endif // MARLIN_AIDA