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 // $Id: EcalZmassTask.cc,v 1.5 2012/02/28 16:39:18 yiiyama Exp $
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 
24 // user include files
25 
26 #include "DQM/Physics/src/EwkDQM.h"
35 #include "TLorentzVector.h"
36 #include "TMath.h"
37 #include <string>
38 #include <cmath>
39 #include "TH1.h"
45 #include <iostream>
48 
49 class DQMStore;
50 class MonitorElement;
51 
53 
54 public:
55  explicit EcalZmassTask (const edm::ParameterSet &);
56  ~EcalZmassTask ();
57 
58  static void fillDescriptions (edm::ConfigurationDescriptions & descriptions);
59 
60 private:
61  virtual void beginJob ();
62  virtual void analyze (const edm::Event &, const edm::EventSetup &);
63  virtual void endJob ();
64 
65  virtual void beginRun (edm::Run const &, edm::EventSetup const &);
66  virtual void endRun (edm::Run const &, edm::EventSetup const &);
67  virtual void beginLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &);
68  virtual void endLuminosityBlock (edm::LuminosityBlock const &, edm::EventSetup const &);
69 
71 
72  const std::string prefixME_;
73 
87 
88 };
89 
91  theElectronCollectionLabel(parameters.getParameter < edm::InputTag > ("electronCollection")),
92  prefixME_(parameters.getUntrackedParameter < std::string > ("prefixME", ""))
93 {
94 }
95 
97 {
98 }
99 
100 // ------------ method called for each event ------------
101 void
103  const edm::EventSetup & iSetup)
104 {
105  using namespace edm;
106  Handle < reco::GsfElectronCollection > electronCollection;
107  iEvent.getByLabel (theElectronCollectionLabel, electronCollection);
108  if (!electronCollection.isValid ()) return;
109 
110  //get GSF Tracks
112  iEvent.getByLabel ("electronGsfTracks", gsftracks_h);
113 
114  bool isIsolatedBarrel;
115  bool isIDBarrel;
116  bool isConvertedBarrel;
117  bool isIsolatedEndcap;
118  bool isIDEndcap;
119  bool isConvertedEndcap;
120 
121  int elIsAccepted=0;
122  int elIsAcceptedEB=0;
123  int elIsAcceptedEE=0;
124 
125  std::vector<TLorentzVector> LV;
126 
127  for (reco::GsfElectronCollection::const_iterator recoElectron =
128  electronCollection->begin ();
129  recoElectron != electronCollection->end (); recoElectron++)
130  {
131 
132  if (recoElectron->et () <= 25)
133  continue;
134 
135  // Define Isolation variables
136  double IsoTrk = (recoElectron->dr03TkSumPt () / recoElectron->et ());
137  double IsoEcal =
138  (recoElectron->dr03EcalRecHitSumEt () / recoElectron->et ());
139  double IsoHcal =
140  (recoElectron->dr03HcalTowerSumEt () / recoElectron->et ());
141  double HE = (recoElectron->hcalOverEcal ());
142 
143  //Define ID variables
144 
145  float DeltaPhiTkClu = recoElectron->deltaPhiSuperClusterTrackAtVtx ();
146  float DeltaEtaTkClu = recoElectron->deltaEtaSuperClusterTrackAtVtx ();
147  float sigmaIeIe = recoElectron->sigmaIetaIeta ();
148 
149  //Define Conversion Rejection Variables
150 
151  float Dcot = recoElectron->convDcot ();
152  float Dist = recoElectron->convDist ();
153  int NumberOfExpectedInnerHits =
154  recoElectron->gsfTrack ()->trackerExpectedHitsInner ().
155  numberOfHits ();
156 
157  //quality flags
158 
159  isIsolatedBarrel = false;
160  isIDBarrel = false;
161  isConvertedBarrel = false;
162  isIsolatedEndcap = false;
163  isIDEndcap = false;
164  isConvertedEndcap = false;
165 
166 
167  /***** Barrel WP80 Cuts *****/
168 
169  if (fabs (recoElectron->eta ()) <= 1.4442)
170  {
171 
172  /* Isolation */
173  if (IsoTrk < 0.09 && IsoEcal < 0.07 && IsoHcal < 0.10)
174  {
175  isIsolatedBarrel = true;
176  }
177 
178  /* Identification */
179  if (fabs (DeltaEtaTkClu) < 0.004 && fabs (DeltaPhiTkClu) < 0.06
180  && sigmaIeIe < 0.01 && HE < 0.04)
181  {
182  isIDBarrel = true;
183  }
184 
185  /* Conversion Rejection */
186  if ((fabs (Dist) >= 0.02 || fabs (Dcot) >= 0.02)
187  && NumberOfExpectedInnerHits <= 1.0)
188  {
189  isConvertedBarrel = true;
190  }
191  }
192 
193  if (isIsolatedBarrel && isIDBarrel && isConvertedBarrel) {
194  elIsAccepted++;
195  elIsAcceptedEB++;
196  TLorentzVector b_e2(recoElectron->momentum ().x (),recoElectron->momentum ().y (),recoElectron->momentum ().z (), recoElectron->p ());
197  LV.push_back(b_e2);
198  }
199 
200  /***** Endcap WP80 Cuts *****/
201 
202  if (fabs (recoElectron->eta ()) >= 1.5660
203  && fabs (recoElectron->eta ()) <= 2.5000)
204  {
205 
206  /* Isolation */
207  if (IsoTrk < 0.04 && IsoEcal < 0.05 && IsoHcal < 0.025)
208  {
209  isIsolatedEndcap = true;
210  }
211 
212  /* Identification */
213  if (fabs (DeltaEtaTkClu) < 0.007 && fabs (DeltaPhiTkClu) < 0.03
214  && sigmaIeIe < 0.031 && HE < 0.15)
215  {
216  isIDEndcap = true;
217  }
218 
219  /* Conversion Rejection */
220  if ((fabs (Dcot) > 0.02 || fabs (Dist) > 0.02)
221  && NumberOfExpectedInnerHits <= 1.0)
222  {
223  isConvertedEndcap = true;
224  }
225  }
226  if (isIsolatedEndcap && isIDEndcap && isConvertedEndcap) {
227  elIsAccepted++;
228  elIsAcceptedEE++;
229  TLorentzVector e_e2(recoElectron->momentum ().x (),recoElectron->momentum ().y (),recoElectron->momentum ().z (), recoElectron->p ());
230  LV.push_back(e_e2);
231  }
232 
233  }
234 
235  // Calculate the Z invariant masses
236 
237  if (elIsAccepted>1){
238  double e_ee_invMass=0;
239  if (elIsAccepted>2) edm::LogWarning("EcalZmassTask") << "WARNING: In this events we have more than two electrons accpeted!!!!!!!";
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
virtual void endLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
MonitorElement * h_ee_invMass_EB
dictionary parameters
Definition: Parameters.py:2
const std::string prefixME_
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:717
virtual void beginJob()
MonitorElement * h_95_ee_invMass_EB
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
MonitorElement * h_e2_et
MonitorElement * h_e1_et
void Fill(long long x)
virtual void analyze(const edm::Event &, const edm::EventSetup &)
EcalZmassTask(const edm::ParameterSet &)
math::XYZTLorentzVectorD LV
int iEvent
Definition: GenABIO.cc:243
const edm::InputTag theElectronCollectionLabel
virtual void beginRun(edm::Run const &, edm::EventSetup const &)
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
MonitorElement * h_ee_invMass_EE
virtual void endRun(edm::Run const &, edm::EventSetup const &)
#define LogTrace(id)
MonitorElement * h_ee_invMass
MonitorElement * h_95_ee_invMass_BB
MonitorElement * h_ee_invMass_BB
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
virtual void endJob()
virtual void beginLuminosityBlock(edm::LuminosityBlock const &, edm::EventSetup const &)
MonitorElement * h_e2_phi
MonitorElement * h_e1_eta
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:429
Definition: Run.h:33