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
40 changes: 40 additions & 0 deletions EventFilter/RawDataCollector/interface/RawDataMapperByLabel.h
@@ -0,0 +1,40 @@
#ifndef RawDataMapperByLabel_H
#define RawDataMapperByLabel_H


icali marked this conversation as resolved.
Show resolved Hide resolved
/** \class RawDataMapperByLabel
*
*/

#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Utilities/interface/InputTag.h"

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;

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_ ;

};

#endif
@@ -0,0 +1,9 @@
import FWCore.ParameterSet.Config as cms

rawDataCollector = cms.EDProducer("RawDataMapperByLabel",
RawCollectionList = cms.VInputTag( cms.InputTag('rawDataReducedFormat'),
icali marked this conversation as resolved.
Show resolved Hide resolved
cms.InputTag('rawDataRepacker'),
cms.InputTag('rawDataCollector')),
icali marked this conversation as resolved.
Show resolved Hide resolved
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) {
std::cout << " More than one FEDRawDataCollection with data in FED ";
std::cout << j << " Skipping the 2nd\n";
}
icali marked this conversation as resolved.
Show resolved Hide resolved
continue;
}
fedDataProd.resize(size);
Expand Down
66 changes: 66 additions & 0 deletions EventFilter/RawDataCollector/src/RawDataMapperByLabel.cc
@@ -0,0 +1,66 @@
/** \file
* Implementation of class RawDataMapperByLabel
*
*/

#include "EventFilter/RawDataCollector/interface/RawDataMapperByLabel.h"
#include "DataFormats/FEDRawData/interface/FEDRawDataCollection.h"
#include "DataFormats/FEDRawData/interface/FEDRawData.h"
#include "DataFormats/FEDRawData/interface/FEDNumbering.h"
icali marked this conversation as resolved.
Show resolved Hide resolved

#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Framework/interface/Event.h"
#include "DataFormats/Provenance/interface/ProcessHistory.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/EventSetup.h"

#include "FWCore/MessageLogger/interface/MessageLogger.h"

#include <iostream>

using namespace edm;

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>("MainCollection");
Copy link
Contributor

Choose a reason for hiding this comment

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

please move these as well as the firstEvent_ and the filledCollectionName_ to the initializer list

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not sure I understood where I should move the code. They are initialized in the class constructor. Do you mean the fillDescription method?



inputTokens_.reserve(inputTags_.size());
for(tag_iterator_t inputTag = inputTags_.begin(); inputTag != inputTags_.end(); ++inputTag ) {
icali marked this conversation as resolved.
Show resolved Hide resolved
inputTokens_.push_back(consumes<FEDRawDataCollection>(*inputTag));
}
produces<FEDRawDataCollection>();
firstEvent_= true;
filledCollectionName_= InputTag("");
}

RawDataMapperByLabel::~RawDataMapperByLabel(){

}


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


bool AlreadyACollectionFilled= false;
icali marked this conversation as resolved.
Show resolved Hide resolved
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_){
if(mainCollectionTag_==*inputTag) continue;
Copy link
Contributor

Choose a reason for hiding this comment

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

I suspect that this continue will introduce problems downstream to get the FED collection by token.
With this continue this module will still declare that it produces rawDataCollection, but will not put it in the event.

Copy link
Contributor

Choose a reason for hiding this comment

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

@icali could you please address this comment?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The only way that I have to don't include a double loop is to remove the condition: if(mainCollectionTag_==*inputTag) continue;
and add:
if(!(mainCollectionTag_==filledCollectionName_)) e.put(std::make_unique(*input.product()));

Not sure however if this feature makes sense as it would be enough to don't include the rawDataCollector original collection in the input of this module.
Please advise.

filledCollectionName_ = *inputTag;
}
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
e.put(std::make_unique<FEDRawDataCollection>(*input.product()));
AlreadyACollectionFilled = true;
firstEvent_= false;
Copy link
Contributor

Choose a reason for hiding this comment

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

it's enough to add this at the end of the if(firstEvent_){

Copy link
Contributor Author

Choose a reason for hiding this comment

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

if(firstEvent_){
if(mainCollectionTag_==*inputTag) continue;
filledCollectionName_ = *inputTag;
AlreadyACollectionFilled = true;
firstEvent_= false;
std::cout << "Here1 " << std::endl;
}
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";
if(!(filledCollectionName_==*inputTag)) throw cms::Exception("Unknown input type") << "The filled collection has changed!";

The exception is kept outside of the if(firstEvent_) to protect from the case in which in the event N another collection is filled instead of the original one. If this protection is not needed I can change it as requested. Please let me know.

}
}
}
}


2 changes: 2 additions & 0 deletions EventFilter/RawDataCollector/src/SealModule.cc
Expand Up @@ -2,8 +2,10 @@
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ServiceRegistry/interface/ServiceMaker.h"
#include "EventFilter/RawDataCollector/src/RawDataCollectorByLabel.h"
#include "EventFilter/RawDataCollector/interface/RawDataMapperByLabel.h"

using namespace edm::serviceregistry;

DEFINE_FWK_MODULE(RawDataCollectorByLabel);
DEFINE_FWK_MODULE(RawDataMapperByLabel);
icali marked this conversation as resolved.
Show resolved Hide resolved