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

Raw data remapper #24891

Merged
merged 19 commits into from
Oct 17, 2018
12 changes: 6 additions & 6 deletions EventFilter/RawDataCollector/src/RawDataCollectorByLabel.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,17 +71,17 @@ void RawDataCollectorByLabel::produce(Event & e, const EventSetup& c){
if(verbose_ > 1) std::cout << "Copying data from FED #" << j << std::endl;
FEDRawData & fedDataProd = producedData->FEDData(j);
if ( fedDataProd.size() != 0 ) {
if(verbose_ > 1) {
std::cout << " More than one FEDRawDataCollection with data in FED ";
std::cout << j << " Skipping the 2nd\n";
}
continue;
if(verbose_ > 1) {
std::cout << " More than one FEDRawDataCollection with data in FED ";
std::cout << j << " Skipping the 2nd\n";
}
continue;
}
fedDataProd.resize(size);
unsigned char *dataProd=fedDataProd.data();
const unsigned char *data=fedData.data();
for ( unsigned int k=0; k<size; ++k ) {
dataProd[k]=data[k];
dataProd[k]=data[k];
}
}
}
Expand Down
112 changes: 112 additions & 0 deletions EventFilter/RawDataCollector/src/RawDataMapperByLabel.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,112 @@
/** \file
* Implementation of class RawDataMapperByLabel
*
*/

#include "DataFormats/Provenance/interface/ProcessHistory.h"
#include "DataFormats/Common/interface/Handle.h"
#include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
#include "DataFormats/Common/interface/Handle.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/MessageLogger/interface/MessageLogger.h"
#include "FWCore/ParameterSet/interface/ConfigurationDescriptions.h"
#include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "FWCore/Utilities/interface/InputTag.h"

#include <iostream>

using namespace edm;

class RawDataMapperByLabel: public edm::stream::EDProducer<> {
public:

///Constructor
RawDataMapperByLabel(const edm::ParameterSet& pset);

///Destructor
~RawDataMapperByLabel() override;

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

static void fillDescriptions(edm::ConfigurationDescriptions &);
private:

typedef std::vector<edm::InputTag>::const_iterator tag_iterator_t;
typedef std::vector<edm::EDGetTokenT<FEDRawDataCollection> >::const_iterator tok_iterator_t;

std::vector<edm::InputTag> inputTags_ ;
std::vector<edm::EDGetTokenT<FEDRawDataCollection> > inputTokens_;

edm::InputTag mainCollectionTag_ ;
edm::InputTag filledCollectionName_;
bool firstEvent_;


};


RawDataMapperByLabel::RawDataMapperByLabel(const edm::ParameterSet& pset)
: inputTags_(pset.getParameter<std::vector<edm::InputTag>>("rawCollectionList")),
mainCollectionTag_(pset.getParameter<edm::InputTag>("mainCollection")),
filledCollectionName_(edm::InputTag("")),
firstEvent_(true)
{

inputTokens_.reserve(inputTags_.size());
for(auto const& inputTag: inputTags_) {
inputTokens_.push_back(consumes<FEDRawDataCollection>(inputTag));
}

produces<FEDRawDataCollection>();

}


RawDataMapperByLabel::~RawDataMapperByLabel(){

}


void RawDataMapperByLabel::produce(Event & e, const EventSetup& c){

bool alreadyACollectionFilled= false;
tag_iterator_t inputTag = inputTags_.begin();
for(tok_iterator_t inputTok = inputTokens_.begin(); inputTok != inputTokens_.end(); ++inputTok, ++inputTag ) {
Handle<FEDRawDataCollection> input;
if(e.getByToken(*inputTok,input)){
if(input.isValid()){
if(alreadyACollectionFilled) throw cms::Exception("BadInput") << "Two input collections are present." << std::endl
<< "Please make sure that the input dataset has only one FEDRawDataCollector collection filled";

if(firstEvent_){
filledCollectionName_ = *inputTag;
alreadyACollectionFilled = true;
firstEvent_= false;
}


if(!(filledCollectionName_==*inputTag)) throw cms::Exception("BadInput") << "The filled collection has changed!";

if(!(mainCollectionTag_==filledCollectionName_)) e.put(std::make_unique<FEDRawDataCollection>(*input.product()));

}
}
}
}

void RawDataMapperByLabel::fillDescriptions(edm::ConfigurationDescriptions & descriptions) {
edm::ParameterSetDescription desc;

desc.add<std::vector<edm::InputTag>>("rawCollectionList", {{"rawDataCollector"}, {"rawDataRepacker"}, {"rawDataReducedFormat"}});
desc.add<edm::InputTag>("mainCollection", edm::InputTag("rawDataCollector"));

descriptions.add("rawDataMapperByLabel", desc);
}

DEFINE_FWK_MODULE(RawDataMapperByLabel);

1 change: 1 addition & 0 deletions EventFilter/RawDataCollector/src/SealModule.cc
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
#include "FWCore/ServiceRegistry/interface/ServiceMaker.h"
#include "EventFilter/RawDataCollector/src/RawDataCollectorByLabel.h"


using namespace edm::serviceregistry;

DEFINE_FWK_MODULE(RawDataCollectorByLabel);
Expand Down