CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
HiEgammaIsolationProducer.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: PatAlgos
4 // Class: HiEgammaIsolationProducer
5 //
13 //
14 // Original Author: Yen-Jie Lee
15 //
16 //
17 
18 
19 // system include files
20 #include <memory>
21 
22 // user include files
25 
28 
31 
32 
34 
38 
43 
44 #include <string>
45 
46 namespace edm { using ::std::advance; }
47 
48 //
49 // class decleration
50 //
51 
53  public:
56 
57 
58  private:
59  virtual void produce(edm::Event&, const edm::EventSetup&);
60 
61  // ----------member data ---------------------------
69 
70  std::string label_;
72  double x_;
73  double y_;
75  int mode_;
76 };
77 
78 //
79 // constructors and destructor
80 //
82  photons_(iConfig.getParameter<edm::InputTag>("photons")),
83  barrelBCLabel_(iConfig.getParameter<edm::InputTag>("barrelBasicCluster")),
84  endcapBCLabel_(iConfig.getParameter<edm::InputTag>("endcapBasicCluster")),
85  hfLabel_(iConfig.getParameter<edm::InputTag>("hfreco")),
86  hoLabel_(iConfig.getParameter<edm::InputTag>("horeco")),
87  hbheLabel_(iConfig.getParameter<edm::InputTag>("hbhereco")),
88  trackLabel_(iConfig.getParameter<edm::InputTag>("track")),
89  label_(iConfig.existsAs<std::string>("label") ? iConfig.getParameter<std::string>("label") : ""),
90  x_(iConfig.getParameter<double>("x")),
91  y_(iConfig.getParameter<double>("y")),
92  var_(iConfig.getParameter<std::string>("iso") == "Cx" ? calcCx :
93  iConfig.getParameter<std::string>("iso") == "Rx" ? calcRx :
94  iConfig.getParameter<std::string>("iso") == "Txy" ? calcTxy :
95  iConfig.getParameter<std::string>("iso") == "dRxy" ? calcDRxy : calcErr ),
96  mode_( iConfig.getParameter<std::string>("mode") == "BackgroundSubtracted" ? 1 : 0)
97 {
98  produces<edm::ValueMap<float> >();
99 }
100 
101 
103 {
104 }
105 
106 // ------------ method called to for each event ------------
107 void
109 {
110  using namespace edm;
111  using namespace std;
112 
113  Handle<View<reco::Photon> > recoPhotons;
114  iEvent.getByLabel(photons_, recoPhotons);
115  //std::cout << "Got " << recoPhotons->size() << " photons" << std::endl;
116  //std::cout << "mode "<<mode_<<std::endl;
117  vector<float> floats(recoPhotons->size(), -100);
118 
119  CxCalculator CxC(iEvent,iSetup,barrelBCLabel_,endcapBCLabel_);
120  RxCalculator RxC(iEvent,iSetup,hbheLabel_,hfLabel_,hoLabel_);
121  TxyCalculator TxyC(iEvent,iSetup,trackLabel_);
122  dRxyCalculator dRxyC(iEvent,iSetup,trackLabel_);
123 
124  for (size_t i = 0; i < recoPhotons->size(); ++i) {
125  if (var_ == calcRx) {
126  if (mode_ == 1) {
127  floats[i] = RxC.getCRx((*recoPhotons)[i].superCluster(),x_,0);
128  } else {
129  floats[i] = RxC.getRx((*recoPhotons)[i].superCluster(),x_,0);
130  }
131  } else if (var_ == calcCx) {
132  if (mode_ == 1) {
133  floats[i] = CxC.getCCx((*recoPhotons)[i].superCluster(),x_,0);
134  } else {
135  floats[i] = CxC.getCx((*recoPhotons)[i].superCluster(),x_,0);
136  }
137  } else if (var_ == calcTxy) {
138  if (mode_ == 1) {
139  // No background subtraction for the moment...
140  floats[i] = TxyC.getTxy((*recoPhotons)[i],x_,y_);
141  } else {
142  floats[i] = TxyC.getTxy((*recoPhotons)[i],x_,y_);
143  }
144  } else if (var_ == calcDRxy) {
145  if (mode_ == 1) {
146  // No background subtraction for the moment...
147  floats[i] = dRxyC.getDRxy((*recoPhotons)[i],x_,y_);
148  } else {
149  floats[i] = dRxyC.getDRxy((*recoPhotons)[i],x_,y_);
150  }
151  }
152  }
153 
154  auto_ptr<ValueMap<float> > pis(new ValueMap<float>());
155  ValueMap<float>::Filler floatfiller(*pis);
156  floatfiller.insert(recoPhotons, floats.begin(), floats.end());
157  floatfiller.fill();
158  iEvent.put(pis);
159 
160 
161 }
162 
163 //define this as a plug-in
int i
Definition: DBlmapReader.cc:9
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
double getRx(const reco::SuperClusterRef clus, double i, double threshold, double innerR=0.0)
Definition: RxCalculator.cc:53
HiEgammaIsolationProducer(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:243
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
double getDRxy(const reco::Photon cluster, double x, double y)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
double getTxy(const reco::Photon p, double x, double y)
virtual void produce(edm::Event &, const edm::EventSetup &)
double getCRx(const reco::SuperClusterRef clus, double i, double threshold, double innerR=0.0)