80 likes | 167 Views
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!. edm::Event. MC data. Digi data. Unp. data. Data. Data-processors. MuoProcessor.
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