Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

migrate legacy DAQ modules to stream or global modules #6403

Merged
merged 2 commits into from Nov 19, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
41 changes: 20 additions & 21 deletions EventFilter/FEDInterface/plugins/EvFFEDSelector.cc
@@ -1,30 +1,29 @@
#include <memory>

#include "EvFFEDSelector.h"

namespace evf{
namespace evf {

EvFFEDSelector::EvFFEDSelector( const edm::ParameterSet& ps)
: label_(ps.getParameter<edm::InputTag>("inputTag"))
, fedlist_(ps.getParameter<std::vector<unsigned int> >("fedList"))
EvFFEDSelector::EvFFEDSelector(edm::ParameterSet const & config) :
token_( consumes<FEDRawDataCollection>( config.getParameter<edm::InputTag>("inputTag")) ),
fedlist_( config.getParameter<std::vector<unsigned int> >("fedList") )
{
token_ = consumes<FEDRawDataCollection>(label_);
produces<FEDRawDataCollection>();
}
void EvFFEDSelector::produce(edm::Event & e, const edm::EventSetup& c)


void EvFFEDSelector::produce(edm::StreamID sid, edm::Event & event, edm::EventSetup const & setup) const
{
edm::Handle<FEDRawDataCollection> rawdata;
FEDRawDataCollection *fedcoll = new FEDRawDataCollection();
e.getByToken(token_,rawdata);
std::vector<unsigned int>::iterator it = fedlist_.begin();
for(;it!=fedlist_.end();it++)
{
const FEDRawData& data = rawdata->FEDData(*it);
if(data.size()>0){
FEDRawData& fedData=fedcoll->FEDData(*it);
fedData.resize(data.size());
memcpy(fedData.data(),data.data(),data.size());
}
}
std::auto_ptr<FEDRawDataCollection> bare_product(fedcoll);
e.put(bare_product);
event.getByToken(token_, rawdata);

std::unique_ptr<FEDRawDataCollection> fedcoll( new FEDRawDataCollection() );

for (unsigned int i : fedlist_)
if (rawdata->FEDData(i).size() > 0)
fedcoll->FEDData(i) = rawdata->FEDData(i);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it should be fine to copy the FEDRawData in this way, instead of memcpy'ing by hand.
Does anyone know if there are counter indications for the simple approach ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Not that I could see any. Both FEDRawData::data() and FEDRawDataCollection::data() return the beginning of the buffer, i.e. there are no headers chopped off or added.


event.put(std::move(fedcoll));
}
}

} // namespace evf
41 changes: 20 additions & 21 deletions EventFilter/FEDInterface/plugins/EvFFEDSelector.h
@@ -1,32 +1,31 @@
#ifndef EVENTFILTER_FEDINTERFACE_PLUGINS_EVFFEDSELECTOR
#define EVENTFILTER_FEDINTERFACE_PLUGINS_EVFFEDSELECTOR

#include <FWCore/Framework/interface/MakerMacros.h>
#include <FWCore/Framework/interface/EDProducer.h>
#include <vector>

#include <FWCore/Framework/interface/global/EDProducer.h>
#include <FWCore/Framework/interface/Event.h>
#include <FWCore/ParameterSet/interface/ParameterSet.h>
#include <FWCore/Utilities/interface/InputTag.h>
#include <DataFormats/FEDRawData/interface/FEDRawDataCollection.h>

#include "FWCore/Utilities/interface/InputTag.h"

#include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
namespace evf {

#include <vector>
class EvFFEDSelector : public edm::global::EDProducer<> {
public:

explicit EvFFEDSelector(edm::ParameterSet const &);
~EvFFEDSelector() { }

void produce(edm::StreamID, edm::Event &, edm::EventSetup const &) const override final;

private:
edm::EDGetTokenT<FEDRawDataCollection> token_;
std::vector<unsigned int> fedlist_;

};

namespace evf{
class EvFFEDSelector : public edm::EDProducer
{
public:

explicit EvFFEDSelector( const edm::ParameterSet& );
~EvFFEDSelector(){};

void produce(edm::Event & e, const edm::EventSetup& c);

private:
edm::InputTag label_;
edm::EDGetTokenT<FEDRawDataCollection> token_;
std::vector<unsigned int> fedlist_;

};
}

#endif