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:
29 
31  ~RawDataMapperByLabel() override;
32 
33  void produce(edm::Event& e, const edm::EventSetup& c) override;
34 
36 
37 private:
38  typedef std::vector<edm::InputTag>::const_iterator tag_iterator_t;
39  typedef std::vector<edm::EDGetTokenT<FEDRawDataCollection>>::const_iterator tok_iterator_t;
40 
41  std::vector<edm::InputTag> inputTags_;
42  std::vector<edm::EDGetTokenT<FEDRawDataCollection>> inputTokens_;
43 
47 };
48 
50  : inputTags_(pset.getParameter<std::vector<edm::InputTag>>("rawCollectionList")),
51  mainCollectionTag_(pset.getParameter<edm::InputTag>("mainCollection")),
52  filledCollectionName_(edm::InputTag("")),
53  firstEvent_(true) {
54  inputTokens_.reserve(inputTags_.size());
55  for (auto const& inputTag : inputTags_) {
56  inputTokens_.push_back(consumes<FEDRawDataCollection>(inputTag));
57  }
58 
59  produces<FEDRawDataCollection>();
60 }
61 
63 
65  bool alreadyACollectionFilled = false;
67  for (tok_iterator_t inputTok = inputTokens_.begin(); inputTok != inputTokens_.end(); ++inputTok, ++inputTag) {
69  if (e.getByToken(*inputTok, input)) {
70  if (input.isValid()) {
71  if (alreadyACollectionFilled)
72  throw cms::Exception("BadInput")
73  << "Two input collections are present." << std::endl
74  << "Please make sure that the input dataset has only one FEDRawDataCollector collection filled";
75 
76  if (firstEvent_) {
78  alreadyACollectionFilled = true;
79  firstEvent_ = false;
80  }
81 
83  throw cms::Exception("BadInput") << "The filled collection has changed!";
84 
86  e.put(std::make_unique<FEDRawDataCollection>(*input.product()));
87  }
88  }
89  }
90 }
91 
94 
95  desc.add<std::vector<edm::InputTag>>("rawCollectionList",
96  {{"rawDataCollector", "", "@skipCurrentProcess"},
97  {"rawDataRepacker"},
98  {"rawPrimeDataRepacker"},
99  {"rawDataReducedFormat"}});
100  desc.add<edm::InputTag>("mainCollection", edm::InputTag("rawDataCollector"));
101 
102  descriptions.add("rawDataMapperByLabel", desc);
103 }
104 
edm::InputTag filledCollectionName_
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:50
RawDataMapperByLabel(const edm::ParameterSet &pset)
Constructor.
std::vector< edm::EDGetTokenT< FEDRawDataCollection > >::const_iterator tok_iterator_t
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< edm::InputTag >::const_iterator tag_iterator_t
void add(std::string const &label, ParameterSetDescription const &psetDescription)
HLT enums.
edm::InputTag mainCollectionTag_
std::vector< edm::InputTag > inputTags_