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 #24819

Merged
merged 19 commits into from Oct 16, 2018
@@ -0,0 +1,9 @@
import FWCore.ParameterSet.Config as cms

rawDataCollector = cms.EDProducer("RawDataMapperByLabel",
rawCollectionList = cms.VInputTag( cms.InputTag('rawDataCollector'),
cms.InputTag('rawDataRepacker'),
cms.InputTag('rawDataReducedFormat')),
mainCollection= cms.InputTag('rawDataCollector')
)

8 changes: 4 additions & 4 deletions EventFilter/RawDataCollector/src/RawDataCollectorByLabel.cc
Expand Up @@ -71,10 +71,10 @@ 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";
}
if(verbose_ > 1) {
icali marked this conversation as resolved.
Show resolved Hide resolved
icali marked this conversation as resolved.
Show resolved Hide resolved
std::cout << " More than one FEDRawDataCollection with data in FED ";
std::cout << j << " Skipping the 2nd\n";
}
continue;
}
fedDataProd.resize(size);
Expand Down
113 changes: 113 additions & 0 deletions EventFilter/RawDataCollector/src/RawDataMapperByLabel.cc
@@ -0,0 +1,113 @@
/** \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_;

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



};


RawDataMapperByLabel::RawDataMapperByLabel(const edm::ParameterSet& pset) {
icali marked this conversation as resolved.
Show resolved Hide resolved

inputTags_ = pset.getParameter<std::vector<InputTag> >("rawCollectionList");
mainCollectionTag_ = pset.getParameter<InputTag>("rainCollection");
firstEvent_= true;
filledCollectionName_= InputTag("");
icali marked this conversation as resolved.
Show resolved Hide resolved

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(firstEvent_){
filledCollectionName_ = *inputTag;
alreadyACollectionFilled = true;
firstEvent_= false;
icali marked this conversation as resolved.
Show resolved Hide resolved
}

if(alreadyACollectionFilled) throw cms::Exception("Unknown input type") << "Two input collections are present. Please make sure that the input dataset has only one FEDRawDataCollector collection filled";
icali marked this conversation as resolved.
Show resolved Hide resolved
if(!(filledCollectionName_==*inputTag)) throw cms::Exception("Unknown input type") << "The filled collection has changed!";
icali marked this conversation as resolved.
Show resolved Hide resolved

if(!(mainCollectionTag_==filledCollectionName_)) e.put(std::make_unique<FEDRawDataCollection>(*input.product()));
icali marked this conversation as resolved.
Show resolved Hide resolved

}
}
}
}

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

std::vector<edm::InputTag> tmp_itvect;
tmp_itvect.push_back( edm::InputTag("rawDataCollector"));
tmp_itvect.push_back( edm::InputTag("rawDataRepacker"));
tmp_itvect.push_back( edm::InputTag("rawDataReducedFormat"));

desc.add<std::vector<edm::InputTag>>("rawCollectionList", tmp_itvect);
icali marked this conversation as resolved.
Show resolved Hide resolved
desc.add<edm::InputTag>("mainCollection", edm::InputTag("rawDataCollector"));

descriptions.add("rawDataCollector", desc);
icali marked this conversation as resolved.
Show resolved Hide resolved
}

DEFINE_FWK_MODULE(RawDataMapperByLabel);

1 change: 1 addition & 0 deletions EventFilter/RawDataCollector/src/SealModule.cc
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