80 likes | 170 Views
Explore how MuoProcessor streamlines data processing for muon software by decoupling data, framework, and processors in a single package. Easy to implement, no need to change source code. Enjoy seamless data processing across different packages.
E N D
MuoProcessor • Decouple data and processor • Decouple data and framework • processors more general • only one processor for all muon software • Preferably, put all processors in one package • circular dependencies! Onne Peters, NIKHEF
edm::Event MC data Digi data Unp. data Data Data-processors MuoProcessor Data-users muo_segment L3 Onne Peters, NIKHEF
Dependencies Reconstructor class dummy MuoProcessor unpack_evt edm identifiers muon_index simpp framework muon_geometry CLHEP d0om rcp muo_digi Onne Peters, NIKHEF
// MuoProcessor.hpp // This is the implementation with a template for the return type // and a template for the data type #include "util/Data.hpp" #include <iostream> namespace Muon { template< class From, class To > class MuoProcessor { public: static To* processData(From& unProcData); }; } // namespace Muon Onne Peters, NIKHEF
// MuoDigiProcessor.cpp // This is the implementation with a template for the return type // and a template for the data type for a MuoDigiChunk #include "MuoProcessor_T2/MuoProcessor.hpp" #include <iostream> using namespace Muon; using namespace std; MuoDigiChunk* MuoProcessor<Event, MuoDigiChunk>::processData(Event& event) { cout << "Processing an Event to a MuoDigiChunk" << endl; MuoDigiChunk *chunk = new MuoDigiChunk(); return chunk; }; MuoDigiChunk* MuoProcessor<UnpDataChunk,MuoDigiChunk >::processData(UnpDataChunk& unpdatachunk) { cout << "Processing an UnpDataChunk to a MuoDigiChunk" << endl; MuoDigiChunk *chunk = new MuoDigiChunk(); return chunk; }; MuoDigiChunk* MuoProcessor<MuoDigiChunk, MuoDigiChunk>::processData(MuoDigiChunk& muodigichunk) { cout << "Processing a MuoDigiChunk to a MuoDigiChunk ?????” << endl; return &muodigichunk; } Onne Peters, NIKHEF
// MuoDigiProcessor.cpp // This is the implementation with a template for the return type // and a template for the data type for a MuoDigiChunk #include "MuoProcessor_T2/MuoProcessor.hpp" #include <iostream> using namespace Muon; using namespace std; UnpDataChunk* MuoProcessor<Event, UnpDataChunk>::processData(Event& event) { cout << "Processing an Event to a UnpDataChunk" << endl; UnpDataChunk *chunk = new UnpDataChunk(); return chunk; }; UnpDataChunk* MuoProcessor<UnpDataChunk, UnpDataChunk>::processData(UnpDataChunk& unpdatachunk) { cout << "Processing an UnpDataChunk to a UnpDataChunk ?????" << endl; return &unpdatachunk; }; UnpDataChunk* MuoProcessor<MuoDigiChunk, UnpDataChunk>::processData(MuoDigiChunk& muodigichunk) { cout << "Processing a MuoDigiChunk to a UnpDataChunk " << endl; UnpDataChunk *chunk = new UnpDataChunk(); return chunk; } Onne Peters, NIKHEF
How to use it #include “MuoProcessor/MuoProcessor.hpp” Result processEvent( Event &evt ) { UnpDataChunk *chunk; chunk = MuoProcessor<Event, UnpDataChunk >:: processData(evt); // Do something with the chunk return Result::success; } Onne Peters, NIKHEF
If a certain processor is not implemented, linker will give an error • Easy to implement new data types • Requires no change of source! • Easy to use • Only have to include header MuoProcessor.hpp • Processors can be in different packages • Not preferable Onne Peters, NIKHEF