CMS 3D CMS Logo

CaloTowerCandidateCreator.cc
Go to the documentation of this file.
1 
18 
19 #include <cmath>
20 #include <string>
21 
23 public:
27  ~CaloTowerCandidateCreator() override;
28 
29 private:
31  void produce(edm::Event& e, const edm::EventSetup&) override;
33  int mVerbose;
37  double mEtThreshold;
39  double mEThreshold;
40 };
41 
43 // remove following line after Jet/Met move to using
44 // exclusively CaloTowers
46 
47 using namespace edm;
48 using namespace reco;
49 using namespace std;
50 
52  : mVerbose(p.getUntrackedParameter<int>("verbose", 0)),
53  mEtThreshold(p.getParameter<double>("minimumEt")),
54  mEThreshold(p.getParameter<double>("minimumE")) {
55  tok_src_ = consumes<CaloTowerCollection>(p.getParameter<edm::InputTag>("src"));
56 
57  produces<CandidateCollection>();
58 }
59 
61 
65 
66  auto cands = std::make_unique<CandidateCollection>();
67  cands->reserve(caloTowers->size());
68  unsigned idx = 0;
69  for (; idx < caloTowers->size(); idx++) {
70  const CaloTower* cal = &((*caloTowers)[idx]);
71  if (mVerbose >= 2) {
72  std::cout << "CaloTowerCandidateCreator::produce-> " << idx << " tower et/eta/phi/e: " << cal->et() << '/'
73  << cal->eta() << '/' << cal->phi() << '/' << cal->energy() << " is...";
74  }
75  if (cal->et() >= mEtThreshold && cal->energy() >= mEThreshold) {
76  math::PtEtaPhiMLorentzVector p(cal->et(), cal->eta(), cal->phi(), 0);
78  c->setCaloTower(CaloTowerRef(caloTowers, idx));
79  cands->push_back(c);
80  if (mVerbose >= 2)
81  std::cout << "accepted: pT/eta/phi:" << c->pt() << '/' << c->eta() << '/' << c->phi() << std::endl;
82  } else {
83  if (mVerbose >= 2)
84  std::cout << "rejected" << std::endl;
85  }
86  }
87  if (mVerbose >= 1) {
88  std::cout << "CaloTowerCandidateCreator::produce-> " << cands->size() << " candidates created" << std::endl;
89  }
90  evt.put(std::move(cands));
91 }
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
CaloTowerCandidateCreator(const edm::ParameterSet &)
constructor from parameter set
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
void produce(edm::Event &e, const edm::EventSetup &) override
process one event
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
double et(double vtxZ) const
Definition: CaloTower.h:150
edm::EDGetTokenT< CaloTowerCollection > tok_src_
token of source collection
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:36
fixed size matrix
HLT enums.
edm::Ref< CaloTowerCollection > CaloTowerRef
Definition: CaloTowerDefs.h:17
~CaloTowerCandidateCreator() override
destructor
double phi() const final
momentum azimuthal angle
def move(src, dest)
Definition: eostools.py:511
double energy() const final
energy
double eta() const final
momentum pseudorapidity