CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
EcalZmassTask.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: Zanalyzer
4 // Class: Zanalyzer
5 //
13 //
14 // Original Author: Vieri Candelise
15 // Created: Wed May 11 14:53:26 CEST 2011
16 //
17 //
18 
19 
20 // system include files
21 #include <memory>
22 
23 // user include files
24 
25 #include "DQM/Physics/src/EwkDQM.h"
34 #include "TLorentzVector.h"
35 #include "TMath.h"
36 #include <string>
37 #include <cmath>
38 #include "TH1.h"
44 #include <iostream>
47 
48 class DQMStore;
49 class MonitorElement;
50 
52 
53 public:
54  explicit EcalZmassTask (const edm::ParameterSet &);
55  ~EcalZmassTask ();
56 
57  static void fillDescriptions (edm::ConfigurationDescriptions & descriptions);
58 
59 private:
60  virtual void beginJob () override;
61  virtual void analyze (const edm::Event &, const edm::EventSetup &) override;
62  virtual void endJob () override;
63 
64  virtual void beginRun (edm::Run const &, edm::EventSetup const &) override;
65  virtual void endRun (edm::Run const &, edm::EventSetup const &) override;
66  virtual void beginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) override;
67  virtual void endLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &) override;
68 
71 
73 
87 
88 };
89 
91  electronCollectionToken_(consumes<reco::GsfElectronCollection>(parameters.getParameter < edm::InputTag > ("electronCollection"))),
92  trackCollectionToken_(consumes<reco::GsfTrackCollection>(parameters.getParameter<edm::InputTag>("trackCollection"))),
93  prefixME_(parameters.getUntrackedParameter < std::string > ("prefixME", ""))
94 {
95 }
96 
98 {
99 }
100 
101 // ------------ method called for each event ------------
102 void
104  const edm::EventSetup & iSetup)
105 {
106  using namespace edm;
107  Handle < reco::GsfElectronCollection > electronCollection;
108  iEvent.getByToken (electronCollectionToken_, electronCollection);
109  if (!electronCollection.isValid ()) return;
110 
111  //get GSF Tracks
113  iEvent.getByToken (trackCollectionToken_, gsftracks_h);
114 
115  bool isIsolatedBarrel;
116  bool isIDBarrel;
117  bool isConvertedBarrel;
118  bool isIsolatedEndcap;
119  bool isIDEndcap;
120  bool isConvertedEndcap;
121 
122  int elIsAccepted=0;
123  int elIsAcceptedEB=0;
124  int elIsAcceptedEE=0;
125 
126  std::vector<TLorentzVector> LV;
127 
128  for (reco::GsfElectronCollection::const_iterator recoElectron =
129  electronCollection->begin ();
130  recoElectron != electronCollection->end (); recoElectron++)
131  {
132 
133  if (recoElectron->et () <= 25)
134  continue;
135 
136  // Define Isolation variables
137  double IsoTrk = (recoElectron->dr03TkSumPt () / recoElectron->et ());
138  double IsoEcal =
139  (recoElectron->dr03EcalRecHitSumEt () / recoElectron->et ());
140  double IsoHcal =
141  (recoElectron->dr03HcalTowerSumEt () / recoElectron->et ());
142  double HE = (recoElectron->hcalOverEcal ());
143 
144  //Define ID variables
145 
146  float DeltaPhiTkClu = recoElectron->deltaPhiSuperClusterTrackAtVtx ();
147  float DeltaEtaTkClu = recoElectron->deltaEtaSuperClusterTrackAtVtx ();
148  float sigmaIeIe = recoElectron->sigmaIetaIeta ();
149 
150  //Define Conversion Rejection Variables
151 
152  float Dcot = recoElectron->convDcot ();
153  float Dist = recoElectron->convDist ();
154  int NumberOfExpectedInnerHits =
155  recoElectron->gsfTrack ()->trackerExpectedHitsInner ().
156  numberOfHits ();
157 
158  //quality flags
159 
160  isIsolatedBarrel = false;
161  isIDBarrel = false;
162  isConvertedBarrel = false;
163  isIsolatedEndcap = false;
164  isIDEndcap = false;
165  isConvertedEndcap = false;
166 
167 
168  /***** Barrel WP80 Cuts *****/
169 
170  if (fabs (recoElectron->eta ()) <= 1.4442)
171  {
172 
173  /* Isolation */
174  if (IsoTrk < 0.09 && IsoEcal < 0.07 && IsoHcal < 0.10)
175  {
176  isIsolatedBarrel = true;
177  }
178 
179  /* Identification */
180  if (fabs (DeltaEtaTkClu) < 0.004 && fabs (DeltaPhiTkClu) < 0.06
181  && sigmaIeIe < 0.01 && HE < 0.04)
182  {
183  isIDBarrel = true;
184  }
185 
186  /* Conversion Rejection */
187  if ((fabs (Dist) >= 0.02 || fabs (Dcot) >= 0.02)
188  && NumberOfExpectedInnerHits <= 1.0)
189  {
190  isConvertedBarrel = true;
191  }
192  }
193 
194  if (isIsolatedBarrel && isIDBarrel && isConvertedBarrel) {
195  elIsAccepted++;
196  elIsAcceptedEB++;
197  TLorentzVector b_e2(recoElectron->momentum ().x (),recoElectron->momentum ().y (),recoElectron->momentum ().z (), recoElectron->p ());
198  LV.push_back(b_e2);
199  }
200 
201  /***** Endcap WP80 Cuts *****/
202 
203  if (fabs (recoElectron->eta ()) >= 1.5660
204  && fabs (recoElectron->eta ()) <= 2.5000)
205  {
206 
207  /* Isolation */
208  if (IsoTrk < 0.04 && IsoEcal < 0.05 && IsoHcal < 0.025)
209  {
210  isIsolatedEndcap = true;
211  }
212 
213  /* Identification */
214  if (fabs (DeltaEtaTkClu) < 0.007 && fabs (DeltaPhiTkClu) < 0.03
215  && sigmaIeIe < 0.031 && HE < 0.15)
216  {
217  isIDEndcap = true;
218  }
219 
220  /* Conversion Rejection */
221  if ((fabs (Dcot) > 0.02 || fabs (Dist) > 0.02)
222  && NumberOfExpectedInnerHits <= 1.0)
223  {
224  isConvertedEndcap = true;
225  }
226  }
227  if (isIsolatedEndcap && isIDEndcap && isConvertedEndcap) {
228  elIsAccepted++;
229  elIsAcceptedEE++;
230  TLorentzVector e_e2(recoElectron->momentum ().x (),recoElectron->momentum ().y (),recoElectron->momentum ().z (), recoElectron->p ());
231  LV.push_back(e_e2);
232  }
233 
234  }
235 
236  // Calculate the Z invariant masses
237 
238  if (elIsAccepted>1){
239  double e_ee_invMass=0;
240  if (LV.size()==2){
241  TLorentzVector e_pair = LV[0] + LV[1];
242  e_ee_invMass = e_pair.M ();
243  }
244 
245  if (elIsAcceptedEB==2){
246  h_ee_invMass_BB->Fill(e_ee_invMass);
247  }
248  if (elIsAcceptedEE==2){
249  h_ee_invMass_EE->Fill(e_ee_invMass);
250  }
251  if (elIsAcceptedEB==1 && elIsAcceptedEE==1){
252  h_ee_invMass_EB->Fill(e_ee_invMass);
253  }
254 
255  LV.clear();
256 
257  }
258 }
259 
260 // ------------ method called once each job just before starting event loop ------------
261 void
263 {
264 
265  DQMStore *theDbe;
266  std::string logTraceName("EcalZmassTask");
267 
268  h_ee_invMass_EB = 0;
269  h_ee_invMass_EE = 0;
270  h_ee_invMass_BB = 0;
271 
272  LogTrace (logTraceName) << "Parameters initialization";
273  theDbe = edm::Service < DQMStore > ().operator-> ();
274 
275  if (theDbe != 0)
276  {
277  theDbe->setCurrentFolder (prefixME_ + "/Zmass"); // Use folder with name of PAG
278 
279 
281  theDbe->book1D ("Z peak - WP80 EB-EE",
282  "Z peak - WP80 EB-EE;InvMass (GeV)", 60, 60.0, 120.0);
284  theDbe->book1D ("Z peak - WP80 EE-EE",
285  "Z peak - WP80 EE-EE;InvMass (Gev)", 60, 60.0, 120.0);
287  theDbe->book1D ("Z peak - WP80 EB-EB",
288  "Z peak - WP80 EB-EB;InvMass (Gev)", 60, 60.0, 120.0);
289  }
290 }
291 
292 // ------------ method called once each job just after ending the event loop ------------
293 void
295 {
296 }
297 
298 // ------------ method called when starting to processes a run ------------
299 void
301 {
302 
303 }
304 
305 // ------------ method called when ending the processing of a run ------------
306 void
308 {
309 }
310 
311 // ------------ method called when starting to processes a luminosity block ------------
312 void
314  edm::EventSetup const &)
315 {
316 }
317 
318 // ------------ method called when ending the processing of a luminosity block ------------
319 void
321  edm::EventSetup const &)
322 {
323 }
324 
325 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
326 void
328  ConfigurationDescriptions & descriptions)
329 {
330  //The following says we do not know what parameters are allowed so do no validation
331  // Please change this to state exactly what you do use, even if it is no parameters
333  desc.setUnknown ();
334  descriptions.addDefault (desc);
335 }
336 
337 //define this as a plug-in
MonitorElement * h_e2_eta
MonitorElement * h_ee_invMass_EB
dictionary parameters
Definition: Parameters.py:2
const std::string prefixME_
virtual void beginJob() override
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
MonitorElement * h_e1_phi
MonitorElement * h_95_ee_invMass_EE
MonitorElement * book1D(const char *name, const char *title, int nchX, double lowX, double highX)
Book 1D histogram.
Definition: DQMStore.cc:872
MonitorElement * h_95_ee_invMass_EB
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:434
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
MonitorElement * h_e2_et
virtual void beginRun(edm::Run const &, edm::EventSetup const &) override
virtual void endRun(edm::Run const &, edm::EventSetup const &) override
const edm::EDGetTokenT< reco::GsfElectronCollection > electronCollectionToken_
virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &) override
MonitorElement * h_e1_et
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
void Fill(long long x)
EcalZmassTask(const edm::ParameterSet &)
math::XYZTLorentzVectorD LV
int iEvent
Definition: GenABIO.cc:243
std::vector< GsfTrack > GsfTrackCollection
collection of GsfTracks
Definition: GsfTrackFwd.h:9
MonitorElement * h_ee_invMass_EE
#define LogTrace(id)
virtual void endJob() override
MonitorElement * h_ee_invMass
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
MonitorElement * h_95_ee_invMass_BB
MonitorElement * h_ee_invMass_BB
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const edm::EDGetTokenT< reco::GsfTrackCollection > trackCollectionToken_
MonitorElement * h_e2_phi
MonitorElement * h_e1_eta
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:584
Definition: Run.h:41