-
Notifications
You must be signed in to change notification settings - Fork 16
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add an EmptyEventCreator data source for testing and examples
- Loading branch information
Showing
2 changed files
with
78 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
#ifndef EmptyEventCreator_h | ||
#define EmptyEventCreator_h 1 | ||
|
||
#include "marlin/DataSourceProcessor.h" | ||
|
||
namespace marlin { | ||
|
||
/** Creates empty LCIO Events that can then be populated by other processors. | ||
* Useful for testing purposes and examples, where having a dedicated input | ||
* just for "getting the event loop going" is not always practical. This needs | ||
* to be the first active processor and additionally requires that there are no | ||
* LCIO input collections present (i.e. make sure to not set the | ||
* LCIOInputFiles parameter). | ||
* | ||
* <h4>Input</h4> | ||
* None | ||
* | ||
* <h4>Output</4> | ||
* an empty LCEvent | ||
* | ||
* @author: T. Madlener, DESY | ||
*/ | ||
class EmptyEventCreator : public DataSourceProcessor { | ||
public: | ||
EmptyEventCreator(); | ||
|
||
marlin::Processor* newProcessor() override { return new EmptyEventCreator; } | ||
|
||
void readDataSource(int numEvents) override; | ||
void init() override; | ||
|
||
private: | ||
int m_eventNumber{0}; | ||
}; | ||
|
||
} | ||
|
||
#endif |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,40 @@ | ||
#include "marlin/EmptyEventCreator.h" | ||
|
||
#include "marlin/ProcessorMgr.h" | ||
|
||
#include "IMPL/LCEventImpl.h" | ||
#include "IMPL/LCRunHeaderImpl.h" | ||
|
||
#include <memory> | ||
|
||
namespace marlin { | ||
EmptyEventCreator anEmptyEventCreator; | ||
|
||
EmptyEventCreator::EmptyEventCreator() : DataSourceProcessor("EmptyEventCreator") { | ||
_description = "Creates empty events that can be filled by other processors"; | ||
} | ||
|
||
void EmptyEventCreator::init() { | ||
printParameters(); // Do we need to do anything at all? | ||
} | ||
|
||
void EmptyEventCreator::readDataSource(int numEvents) { | ||
while (m_eventNumber < numEvents) { | ||
if (isFirstEvent()) { | ||
auto* runHeader = new LCRunHeaderImpl; // who cleans this up? | ||
runHeader->setDescription("Empty events produced to be filled later"); | ||
runHeader->setRunNumber(0); | ||
|
||
ProcessorMgr::instance()->processRunHeader(runHeader); | ||
_isFirstEvent = false; | ||
} | ||
|
||
auto evt = std::make_unique<LCEventImpl>(); | ||
evt->setRunNumber(0); | ||
evt->setEventNumber(m_eventNumber++); | ||
|
||
ProcessorMgr::instance()->processEvent(evt.get()); | ||
} | ||
} | ||
|
||
} // namespace marlin |