CMS 3D CMS Logo

PFClusterProducerFromL1EGClusters.cc
Go to the documentation of this file.
6 
12 
13 namespace l1tpf {
15  public:
18 
19  private:
21  double etCut_;
22  std::vector<double> const etaBounds_;
23  std::vector<double> const phiBounds_;
24  std::vector<unsigned int> const maxClustersEtaPhi_;
27 
28  void produce(edm::Event &, const edm::EventSetup &) override;
29 
30  }; // class
31 } // namespace l1tpf
32 
34  : src_(consumes<BXVector<l1t::EGamma>>(iConfig.getParameter<edm::InputTag>("src"))),
35  etCut_(iConfig.getParameter<double>("etMin")),
36  etaBounds_(iConfig.getParameter<std::vector<double>>("etaBounds")),
37  phiBounds_(iConfig.getParameter<std::vector<double>>("phiBounds")),
38  maxClustersEtaPhi_(iConfig.getParameter<std::vector<unsigned int>>("maxClustersEtaPhi")),
39  corrector_(iConfig.getParameter<std::string>("corrector"), -1),
40  resol_(iConfig.getParameter<edm::ParameterSet>("resol")) {
41  produces<l1t::PFClusterCollection>("all");
42  produces<l1t::PFClusterCollection>("selected");
43  if ((etaBounds_.size() - 1) * (phiBounds_.size() - 1) != maxClustersEtaPhi_.size()) {
44  throw cms::Exception("Configuration")
45  << "Size mismatch between eta/phi bounds and max clusters: " << (etaBounds_.size() - 1) << " x "
46  << (phiBounds_.size() - 1) << " != " << maxClustersEtaPhi_.size() << "\n";
47  }
48  if (!std::is_sorted(etaBounds_.begin(), etaBounds_.end())) {
49  throw cms::Exception("Configuration") << "etaBounds is not sorted\n";
50  }
51  if (!std::is_sorted(phiBounds_.begin(), phiBounds_.end())) {
52  throw cms::Exception("Configuration") << "phiBounds is not sorted\n";
53  }
54 }
55 
57  std::unique_ptr<l1t::PFClusterCollection> out(new l1t::PFClusterCollection());
58  std::unique_ptr<l1t::PFClusterCollection> out_sel(new l1t::PFClusterCollection());
60  iEvent.getByToken(src_, clusters);
61 
62  l1tpf_calo::GridSelector selector = l1tpf_calo::GridSelector(etaBounds_, phiBounds_, maxClustersEtaPhi_);
63 
64  unsigned int index = 0;
65  for (auto it = clusters->begin(), ed = clusters->end(); it != ed; ++it, ++index) {
66  if (it->pt() <= etCut_)
67  continue;
68 
69  l1t::PFCluster cluster(
70  it->pt(), it->eta(), it->phi(), /*hOverE=*/0., /*isEM=*/true); // it->hovere() seems to return random values
71  if (corrector_.valid())
72  corrector_.correctPt(cluster);
73  cluster.setPtError(resol_(cluster.pt(), std::abs(cluster.eta())));
74  cluster.setHwQual(it->hwQual());
75  out->push_back(cluster);
76  out->back().addConstituent(edm::Ptr<l1t::L1Candidate>(clusters, index));
77  selector.fill(cluster.pt(), cluster.eta(), cluster.phi(), index);
78  }
79  std::vector<unsigned int> indices = selector.returnSorted();
80  for (unsigned int ii = 0; ii < indices.size(); ii++) {
81  unsigned int theIndex = indices[ii];
82  l1t::PFCluster cluster((clusters->begin() + theIndex)->pt(),
83  (clusters->begin() + theIndex)->eta(),
84  (clusters->begin() + theIndex)->phi(),
85  /*hOverE=*/0.,
86  /*isEM=*/true); // it->hovere() seems to return random values
87  if (corrector_.valid())
88  corrector_.correctPt(cluster);
89  cluster.setPtError(resol_(cluster.pt(), std::abs(cluster.eta())));
90  cluster.setHwQual((clusters->begin() + theIndex)->hwQual());
91  out_sel->push_back(cluster);
92  out_sel->back().addConstituent(edm::Ptr<l1t::L1Candidate>(clusters, theIndex));
93  }
94 
95  iEvent.put(std::move(out), "all");
96  iEvent.put(std::move(out_sel), "selected");
97 }
void fill(float pt, float eta, float phi, unsigned int index)
delete x;
Definition: CaloConfig.h:22
int iEvent
Definition: GenABIO.cc:224
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
std::vector< unsigned int > returnSorted()
ii
Definition: cuy.py:589
std::vector< l1t::PFCluster > PFClusterCollection
Definition: PFCluster.h:87
HLT enums.
void setPtError(float ptError)
Definition: PFCluster.h:67
void produce(edm::Event &, const edm::EventSetup &) override
def move(src, dest)
Definition: eostools.py:511
edm::EDGetTokenT< BXVector< l1t::EGamma > > src_