CMS 3D CMS Logo

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