CMS 3D CMS Logo

CaloTowerCandidateCreator.cc
Go to the documentation of this file.
1 // makes CaloTowerCandidates from CaloTowers
2 // original author: L.Lista INFN
3 // modifyed by: F.Ratnikov UMd
4 #include <cmath>
10 using namespace edm;
11 using namespace reco;
12 using namespace std;
13 
15  : mVerbose(p.getUntrackedParameter<int>("verbose", 0)),
16  mEtThreshold(p.getParameter<double>("minimumEt")),
17  mEThreshold(p.getParameter<double>("minimumE")) {
18  tok_src_ = consumes<CaloTowerCollection>(p.getParameter<edm::InputTag>("src"));
19 
20  produces<CandidateCollection>();
21 }
22 
24 
27  evt.getByToken(tok_src_, caloTowers);
28 
29  auto cands = std::make_unique<CandidateCollection>();
30  cands->reserve(caloTowers->size());
31  unsigned idx = 0;
32  for (; idx < caloTowers->size(); idx++) {
33  const CaloTower* cal = &((*caloTowers)[idx]);
34  if (mVerbose >= 2) {
35  std::cout << "CaloTowerCandidateCreator::produce-> " << idx << " tower et/eta/phi/e: " << cal->et() << '/'
36  << cal->eta() << '/' << cal->phi() << '/' << cal->energy() << " is...";
37  }
38  if (cal->et() >= mEtThreshold && cal->energy() >= mEThreshold) {
39  math::PtEtaPhiMLorentzVector p(cal->et(), cal->eta(), cal->phi(), 0);
41  c->setCaloTower(CaloTowerRef(caloTowers, idx));
42  cands->push_back(c);
43  if (mVerbose >= 2)
44  std::cout << "accepted: pT/eta/phi:" << c->pt() << '/' << c->eta() << '/' << c->phi() << std::endl;
45  } else {
46  if (mVerbose >= 2)
47  std::cout << "rejected" << std::endl;
48  }
49  }
50  if (mVerbose >= 1) {
51  std::cout << "CaloTowerCandidateCreator::produce-> " << cands->size() << " candidates created" << std::endl;
52  }
53  evt.put(std::move(cands));
54 }
T getParameter(std::string const &) const
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:131
double eta() const final
momentum pseudorapidity
CaloTowerCandidateCreator(const edm::ParameterSet &)
constructor from parameter set
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:525
void produce(edm::Event &e, const edm::EventSetup &) override
process one event
PtEtaPhiMLorentzVectorD PtEtaPhiMLorentzVector
Lorentz vector with cartesian internal representation.
Definition: LorentzVector.h:25
edm::EDGetTokenT< CaloTowerCollection > tok_src_
token of source collection
double energy() const final
energy
math::XYZTLorentzVector LorentzVector
Lorentz vector.
Definition: Candidate.h:37
fixed size matrix
HLT enums.
size_type size() const
double et(double vtxZ) const
Definition: CaloTower.h:154
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