CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
PhotonIDProducer.cc
Go to the documentation of this file.
4 
6  photonToken_ = consumes<reco::PhotonCollection>(
7  edm::InputTag(conf_.getParameter<std::string>("photonProducer"), conf_.getParameter<std::string>("photonLabel")));
8 
9  photonCutBasedIDLooseLabel_ = conf.getParameter<std::string>("photonCutBasedIDLooseLabel");
10  photonCutBasedIDTightLabel_ = conf.getParameter<std::string>("photonCutBasedIDTightLabel");
11  photonCutBasedIDLooseEMLabel_ = conf.getParameter<std::string>("photonCutBasedIDLooseEMLabel");
12 
13  doCutBased_ = conf_.getParameter<bool>("doCutBased");
15  cutBasedAlgo_->setup(conf);
16  produces<edm::ValueMap<bool>>(photonCutBasedIDLooseLabel_);
17  produces<edm::ValueMap<bool>>(photonCutBasedIDTightLabel_);
18  produces<edm::ValueMap<bool>>(photonCutBasedIDLooseEMLabel_);
19 }
20 
22  //if (doCutBased_)
23  delete cutBasedAlgo_;
24 }
25 
27  // Read in photons
29  e.getByToken(photonToken_, photons);
30 
31  // Loop over photons and calculate photon ID using specified technique(s)
32  reco::PhotonCollection::const_iterator photon;
33  std::vector<bool> Loose;
34  std::vector<bool> Tight;
35  std::vector<bool> LooseEM;
36  for (photon = (*photons).begin(); photon != (*photons).end(); ++photon) {
37  bool LooseQual;
38  bool TightQual;
39  bool LooseEMQual;
40  if (photon->isEB())
41  cutBasedAlgo_->decideEB(&(*photon), LooseEMQual, LooseQual, TightQual);
42  else
43  cutBasedAlgo_->decideEE(&(*photon), LooseEMQual, LooseQual, TightQual);
44  LooseEM.push_back(LooseEMQual);
45  Loose.push_back(LooseQual);
46  Tight.push_back(TightQual);
47  }
48 
49  auto outlooseEM = std::make_unique<edm::ValueMap<bool>>();
50  edm::ValueMap<bool>::Filler fillerlooseEM(*outlooseEM);
51  fillerlooseEM.insert(photons, LooseEM.begin(), LooseEM.end());
52  fillerlooseEM.fill();
53  // and put it into the event
55 
56  auto outloose = std::make_unique<edm::ValueMap<bool>>();
57  edm::ValueMap<bool>::Filler fillerloose(*outloose);
58  fillerloose.insert(photons, Loose.begin(), Loose.end());
59  fillerloose.fill();
60  // and put it into the event
62 
63  auto outtight = std::make_unique<edm::ValueMap<bool>>();
64  edm::ValueMap<bool>::Filler fillertight(*outtight);
65  fillertight.insert(photons, Tight.begin(), Tight.end());
66  fillertight.fill();
67  // and put it into the event
69 }
void decideEE(const reco::Photon *pho, bool &LooseEM, bool &LoosePhoton, bool &TightPhoton)
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
const edm::EventSetup & c
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
PhotonIDProducer(const edm::ParameterSet &conf)
void decideEB(const reco::Photon *pho, bool &LooseEM, bool &LoosePhoton, bool &TightPhoton)
CutBasedPhotonIDAlgo * cutBasedAlgo_
def move
Definition: eostools.py:511
void produce(edm::Event &e, const edm::EventSetup &c) override
std::string photonCutBasedIDLooseLabel_
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
std::string photonCutBasedIDLooseEMLabel_
std::string photonCutBasedIDTightLabel_
~PhotonIDProducer() override
edm::ParameterSet conf_
edm::EDGetTokenT< reco::PhotonCollection > photonToken_