Skip to content
Snippets Groups Projects
Commit 4136084d authored by Johnston's avatar Johnston
Browse files

FakeEvent processor progress

parent ecc8e166
No related branches found
No related tags found
No related merge requests found
#ifndef MarlinFakeEvent_h
#define MarlinFakeEvent_h 1
#include "marlin/Processor.h"
#include "lcio.h"
#include <string>
#include <EVENT/LCCollection.h>
#include <IMPL/LCCollectionVec.h>
#include <EVENT/TrackerHit.h>
#include <EVENT/SimTrackerHit.h>
#include <IMPL/TrackerHitImpl.h>
using namespace lcio ;
using namespace marlin ;
/** Based From Example processor for marlin.
*
* If compiled with MARLIN_USE_AIDA
*
*
*/
class MarlinFakeEvent : public Processor {
public:
virtual Processor* newProcessor() { return new MarlinFakeEvent ; }
MarlinFakeEvent() ;
/** Called at the begin of the job before anything is read.
* Use to initialize the processor, e.g. book histograms.
*/
virtual void init() ;
/** Called for every run.
*/
virtual void processRunHeader( LCRunHeader* run ) ;
/** Called for every event - the working horse.
*/
virtual void processEvent( LCEvent * evt ) ;
virtual void check( LCEvent * evt ) ;
/** Called after data processing for clean up.
*/
virtual void end() ;
protected:
/** Stored Collection Event*/
std::vector<EVENT::LCEvent*> _stored_events;
int _nCombinedEvents ;
/** Input collection name.
*/
std::string _colName ;
std::string _outColName ;
/** event and run info */
int _nRun ;
int _nEvt ;
} ;
#endif
#ifndef MarlinSeed_h
#define MarlinSeed_h 1
#include "marlin/Processor.h"
#include "lcio.h"
#include <string>
using namespace lcio ;
using namespace marlin ;
/** Based From Example processor for marlin.
*
* If compiled with MARLIN_USE_AIDA
*
* @author F. Gaede, DESY
*/
class MarlinSeed : public Processor {
public:
virtual Processor* newProcessor() { return new MarlinSeed ; }
MarlinSeed() ;
/** Called at the begin of the job before anything is read.
* Use to initialize the processor, e.g. book histograms.
*/
virtual void init() ;
/** Called for every run.
*/
virtual void processRunHeader( LCRunHeader* run ) ;
/** Called for every event - the working horse.
*/
virtual void processEvent( LCEvent * evt ) ;
virtual void check( LCEvent * evt ) ;
/** Called after data processing for clean up.
*/
virtual void end() ;
protected:
/** Input collection name.
*/
std::string _colName ;
std::string _SiTrackerColName ;
int _nRun ;
int _nEvt ;
} ;
#endif
// Root read test-- just read a simple file, and make a fake "combined event" using the information from one or more of the original events.
//This fake event, will then go to the MarlinSeed processor, which finds "seed tracks" in it-- i.e., success is reconstituting the original separated tracks in the event.
// seed track will go into actual MarlinGenFit-- which also is a placeholder right now
// NOT COMPLETE
#include "MarlinFakeEvent.h"
#include <iostream>
#include <EVENT/LCCollection.h>
#include <IMPL/LCCollectionVec.h>
#include <EVENT/TrackerHit.h>
#include <EVENT/SimTrackerHit.h>
#include <IMPL/TrackerHitImpl.h>
// ----- include for verbosity dependend logging ---------
#include "marlin/VerbosityLevels.h"
#ifdef MARLIN_USE_AIDA
#include <marlin/AIDAProcessor.h>
#include <AIDA/IHistogramFactory.h>
#include <AIDA/ICloud1D.h>
//#include <AIDA/IHistogram1D.h>
#endif // MARLIN_USE_AIDA
using namespace lcio ;
using namespace marlin ;
MarlinFakeEvent aMarlinFakeEvent ;
MarlinFakeEvent::MarlinFakeEvent() : Processor("MarlinFakeEvent")
{
// modify processor description
_description = "MarlinFakeEvent accesses FakeEvent Test inside Marlin Processor" ;
// register steering parameters: name, description, class-variable, default value
registerInputCollection(
LCIO::SIMTRACKERHIT,
"InputSimTrackerHits" ,
"Simulation output hits (pre digitization)" ,
_colName ,
std::string("SiTrackerBarrelHits")
);
registerOutputCollection(
LCIO::TRACKERHIT,
"OutputTrackerHits" ,
"Combined Tracker hits " ,
_outColName ,
std::string("outColName")
);
// registerNumberCombinedEvents(
// int,
// "NumberCombinedEvents" ,
// "Number of Events Combined " ,
// _nCombinedEvents ,
// std::string("nCombinedEvents")
// i); // eventually register it this way, dynamically, but to start with, hardcode = 2 in init()
}
void MarlinFakeEvent::init()
{
streamlog_out(DEBUG) << " init called " << std::endl ;
// usually a good idea to
printParameters() ;
_nRun = 0 ;
_nEvt = 0 ;
_nCombinedEvents = 2 ; // eventually REMOVE from here
}
void MarlinFakeEvent::processRunHeader( LCRunHeader* run)
{
_nRun++ ;
}
void MarlinFakeEvent::processEvent( LCEvent * evt )
{
std::cout << "processing an event \n";
//try using genfit function from fit_test? (doesn't work though, doesn't recognize genfit)
//genfit::FieldManager:getInstance()->init(new genfit::ConstField(0.,0., Bz*10.0));
//
//Check event number against the nCombinedEvents.
//if not enough events have been processed,
//do nothing but pushback the event # to the vector for stored_events.
//if sufficient event number is reached,
//read the information of the stored events, add all hits to the current collection to be written.
//Then push back the current event, and erase the first event in _stored_events.
//
//Problem is, I'm not sure this format actually allows subsequent processors to distinguish original event
//so it might be hard to debug finding functions, if can't compare to "truth value"
//Hack, just check whether they are "found" in hit order?
//There might be some relation map type I could write simultaneously.
//
LCCollectionVec* combinedVec = new LCCollectionVec( LCIO::TRACKERHIT ) ;
if ( _nEvt < _nCombinedEvents ){
//skip the first few events, just filling the stored event vector
std::cout << "pusing back event # " << _nEvt << "\n";
_stored_events.push_back( evt ) ;
} else {
//combine hits from all the stored events to a single hit vector
std::cout << "starting to combine the events \n";
for ( auto storeEvt : _stored_events ){
std::cout << "getting a stored event \n";
LCCollection* sim_col = storeEvt->getCollection( _colName ) ;
if( !sim_col ) std::cout << "no tracker hits collection \n" ;
int numHits = sim_col->getNumberOfElements() ;
SimTrackerHit* storedHit;
for (int i=0; i<numHits; i++){
storedHit = dynamic_cast<SimTrackerHit*>( sim_col->getElementAt( i ) ) ;
}
combinedVec->addElement ( storedHit ) ;
} // finished combining all the hits in all the events saved in the stored events vector
_stored_events.erase( _stored_events.begin() ); // erase the very first stored event
_stored_events.push_back( evt ) ; // push back this new event, ready for the subsequent event now
} // this leaves with a combinedVec that should have all the stored hits for #combinedEvents
evt->addCollection( combinedVec , _outColName ) ;
//-- note: this will not be printed if compiled w/o MARLINDEBUG=1 !
streamlog_out(DEBUG) << " processing event: " << evt->getEventNumber()
<< " in run: " << evt->getRunNumber() << std::endl ;
_nEvt ++ ;
}
void MarlinFakeEvent::check( LCEvent * evt ) {
// nothing to check here - could be used to fill checkplots in reconstruction processor
}
void MarlinFakeEvent::end(){
// std::cout << "MarlinFakeEvent::end() " << name()
// << " processed " << _nEvt << " events in " << _nRun << " runs "
// << std::endl ;
}
// Root read test-- just read a simple file, and make a fake "seed track"
// fake seed track will go into actual MarlinGenFit-- which also is a placeholder right now
// NOT COMPLETE
#include "MarlinSeed.h"
#include <iostream>
#include <EVENT/LCCollection.h>
#include <IMPL/LCCollectionVec.h>
#include <EVENT/TrackerHit.h>
#include <EVENT/SimTrackerHit.h>
#include <IMPL/TrackerHitImpl.h>
// ----- include for verbosity dependend logging ---------
#include "marlin/VerbosityLevels.h"
#ifdef MARLIN_USE_AIDA
#include <marlin/AIDAProcessor.h>
#include <AIDA/IHistogramFactory.h>
#include <AIDA/ICloud1D.h>
//#include <AIDA/IHistogram1D.h>
#endif // MARLIN_USE_AIDA
using namespace lcio ;
using namespace marlin ;
MarlinSeed aMarlinSeed ;
MarlinSeed::MarlinSeed() : Processor("MarlinSeed")
{
// modify processor description
_description = "MarlinSeed accesses Seed Test inside Marlin Processor" ;
// register steering parameters: name, description, class-variable, default value
registerInputCollection(
LCIO::SIMTRACKERHIT,
"InputSimTrackerHits" ,
"Simulation output hits (pre digitization)" ,
_colName ,
std::string("SiTrackerBarrelHits")
);
registerOutputCollection(
LCIO::TRACKERHIT,
"OutputTrackerHits" ,
"Digitized Tracker hits " ,
_SiTrackerColName ,
std::string("SiTrackerHits")
);
}
void MarlinSeed::init()
{
streamlog_out(DEBUG) << " init called " << std::endl ;
// usually a good idea to
printParameters() ;
_nRun = 0 ;
_nEvt = 0 ;
}
void MarlinSeed::processRunHeader( LCRunHeader* run)
{
_nRun++ ;
}
void MarlinSeed::processEvent( LCEvent * evt )
{
std::cout << "processing an event \n";
// just set BZ to something here, instead of reading it from the DD4hep geometry
double Bz= 3.0;
//try using genfit function from fit_test? (doesn't work though, doesn't recognize genfit)
//genfit::FieldManager:getInstance()->init(new genfit::ConstField(0.,0., Bz*10.0));
LCCollection* sim_hits_col = evt->getCollection( _colName ) ;
if( !sim_hits_col ) {
std::cout << "no tracker hits collection\n";
}
LCCollectionVec* _trkhitVec = new LCCollectionVec( LCIO::TRACKERHIT ) ;
evt->addCollection( _trkhitVec , _SiTrackerColName ) ;
// this gets called for every event
// usually the working horse ...
//-- note: this will not be printed if compiled w/o MARLINDEBUG=1 !
streamlog_out(DEBUG) << " processing event: " << evt->getEventNumber()
<< " in run: " << evt->getRunNumber() << std::endl ;
_nEvt ++ ;
}
void MarlinSeed::check( LCEvent * evt ) {
// nothing to check here - could be used to fill checkplots in reconstruction processor
}
void MarlinSeed::end(){
// std::cout << "MarlinSeed::end() " << name()
// << " processed " << _nEvt << " events in " << _nRun << " runs "
// << std::endl ;
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment