CMS 3D CMS Logo

FinalBxSelector.cc
Go to the documentation of this file.
14 
15 #include <vector>
16 #include <set>
17 
18 /*
19  * Filter orbits that don't contain at least one selected BX
20  * from a BxSelector module and produce a vector of selected BXs
21  */
23 public:
24  explicit FinalBxSelector(const edm::ParameterSet&);
27 
28 private:
29  bool filter(edm::Event&, const edm::EventSetup&) override;
30 
31  // tokens for BX selected by each analysis
32  std::vector<edm::EDGetTokenT<std::vector<unsigned>>> selectedBxsToken_;
33 };
34 
36  // get the list of selected BXs
37  std::vector<edm::InputTag> bxLabels = iPSet.getParameter<std::vector<edm::InputTag>>("analysisLabels");
38  for (const auto& bxLabel : bxLabels) {
39  selectedBxsToken_.push_back(consumes<std::vector<unsigned>>(bxLabel));
40  }
41 
42  produces<std::vector<unsigned>>("SelBx").setBranchAlias("SelectedBxs");
43 }
44 
45 // ------------ method called for each ORBIT ------------
47  bool noBxSelected = true;
48  std::set<unsigned> uniqueBxs;
49 
50  for (const auto& token : selectedBxsToken_) {
52  iEvent.getByToken(token, bxList);
53 
54  for (const unsigned& bx : *bxList) {
55  uniqueBxs.insert(bx);
56  noBxSelected = false;
57  }
58  }
59 
60  auto selectedBxs = std::make_unique<std::vector<unsigned>>(uniqueBxs.begin(), uniqueBxs.end());
61  iEvent.put(std::move(selectedBxs), "SelBx");
62 
63  return !noBxSelected;
64 }
65 
68  desc.setUnknown();
69  descriptions.addDefault(desc);
70 }
71 
T getParameter(std::string const &) const
Definition: ParameterSet.h:307
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
bool filter(edm::Event &, const edm::EventSetup &) override
int iEvent
Definition: GenABIO.cc:224
void addDefault(ParameterSetDescription const &psetDescription)
static void fillDescriptions(edm::ConfigurationDescriptions &)
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
FinalBxSelector(const edm::ParameterSet &)
std::vector< edm::EDGetTokenT< std::vector< unsigned > > > selectedBxsToken_
def move(src, dest)
Definition: eostools.py:511