CMS 3D CMS Logo

RawDataMapperByLabel.cc
Go to the documentation of this file.
1 
10 
20 
21 #include <iostream>
22 
23 using namespace edm;
24 
26 public:
27 
30 
32  ~RawDataMapperByLabel() override;
33 
34  void produce(edm::Event & e, const edm::EventSetup& c) override;
35 
37 private:
38 
39  typedef std::vector<edm::InputTag>::const_iterator tag_iterator_t;
40  typedef std::vector<edm::EDGetTokenT<FEDRawDataCollection> >::const_iterator tok_iterator_t;
41 
42  std::vector<edm::InputTag> inputTags_ ;
43  std::vector<edm::EDGetTokenT<FEDRawDataCollection> > inputTokens_;
44 
48 
49 
50 };
51 
52 
54  : inputTags_(pset.getParameter<std::vector<edm::InputTag>>("rawCollectionList")),
55  mainCollectionTag_(pset.getParameter<edm::InputTag>("mainCollection")),
56  filledCollectionName_(edm::InputTag("")),
57  firstEvent_(true)
58 {
59 
60  inputTokens_.reserve(inputTags_.size());
61  for(auto const& inputTag: inputTags_) {
62  inputTokens_.push_back(consumes<FEDRawDataCollection>(inputTag));
63  }
64 
65  produces<FEDRawDataCollection>();
66 
67 }
68 
69 
71 
72 }
73 
74 
76 
77  bool alreadyACollectionFilled= false;
79  for(tok_iterator_t inputTok = inputTokens_.begin(); inputTok != inputTokens_.end(); ++inputTok, ++inputTag ) {
81  if(e.getByToken(*inputTok,input)){
82  if(input.isValid()){
83  if(alreadyACollectionFilled) throw cms::Exception("BadInput") << "Two input collections are present." << std::endl
84  << "Please make sure that the input dataset has only one FEDRawDataCollector collection filled";
85 
86  if(firstEvent_){
88  alreadyACollectionFilled = true;
89  firstEvent_= false;
90  }
91 
92 
93  if(!(filledCollectionName_==*inputTag)) throw cms::Exception("BadInput") << "The filled collection has changed!";
94 
95  if(!(mainCollectionTag_==filledCollectionName_)) e.put(std::make_unique<FEDRawDataCollection>(*input.product()));
96 
97  }
98  }
99  }
100 }
101 
104 
105  desc.add<std::vector<edm::InputTag>>("rawCollectionList", {{"rawDataCollector","","@skipCurrentProcess"}, {"rawDataRepacker"}, {"rawDataReducedFormat"}});
106  desc.add<edm::InputTag>("mainCollection", edm::InputTag("rawDataCollector"));
107 
108  descriptions.add("rawDataMapperByLabel", desc);
109 }
110 
112 
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:125
edm::InputTag filledCollectionName_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:517
std::vector< edm::EDGetTokenT< FEDRawDataCollection > > inputTokens_
static void fillDescriptions(edm::ConfigurationDescriptions &)
void produce(edm::Event &e, const edm::EventSetup &c) override
~RawDataMapperByLabel() override
Destructor.
static std::string const input
Definition: EdmProvDump.cc:48
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
RawDataMapperByLabel(const edm::ParameterSet &pset)
Constructor.
std::vector< edm::EDGetTokenT< FEDRawDataCollection > >::const_iterator tok_iterator_t
ParameterDescriptionBase * add(U const &iLabel, T const &value)
bool isValid() const
Definition: HandleBase.h:74
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< edm::InputTag >::const_iterator tag_iterator_t
T const * product() const
Definition: Handle.h:74
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HLT enums.
edm::InputTag mainCollectionTag_
std::vector< edm::InputTag > inputTags_