CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
82  if (!(filledCollectionName_ == *inputTag))
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>>(
96  "rawCollectionList",
97  {{"rawDataCollector", "", "@skipCurrentProcess"}, {"rawDataRepacker"}, {"rawDataReducedFormat"}});
98  desc.add<edm::InputTag>("mainCollection", edm::InputTag("rawDataCollector"));
99 
100  descriptions.add("rawDataMapperByLabel", desc);
101 }
102 
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
const edm::EventSetup & c
edm::InputTag filledCollectionName_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
std::vector< edm::EDGetTokenT< FEDRawDataCollection > > inputTokens_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
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:47
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:70
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
std::vector< edm::InputTag >::const_iterator tag_iterator_t
T const * product() const
Definition: Handle.h:70
void add(std::string const &label, ParameterSetDescription const &psetDescription)
edm::InputTag mainCollectionTag_
std::vector< edm::InputTag > inputTags_