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.6 2013/04/02 10:46:16 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 
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 (LV.size()==2){
240  TLorentzVector e_pair = LV[0] + LV[1];
241  e_ee_invMass = e_pair.M ();
242  }
243 
244  if (elIsAcceptedEB==2){
245  h_ee_invMass_BB->Fill(e_ee_invMass);
246  }
247  if (elIsAcceptedEE==2){
248  h_ee_invMass_EE->Fill(e_ee_invMass);
249  }
250  if (elIsAcceptedEB==1 && elIsAcceptedEE==1){
251  h_ee_invMass_EB->Fill(e_ee_invMass);
252  }
253 
254  LV.clear();
255 
256  }
257 }
258 
259 // ------------ method called once each job just before starting event loop ------------
260 void
262 {
263 
264  DQMStore *theDbe;
265  std::string logTraceName("EcalZmassTask");
266 
267  h_ee_invMass_EB = 0;
268  h_ee_invMass_EE = 0;
269  h_ee_invMass_BB = 0;
270 
271  LogTrace (logTraceName) << "Parameters initialization";
272  theDbe = edm::Service < DQMStore > ().operator-> ();
273 
274  if (theDbe != 0)
275  {
276  theDbe->setCurrentFolder (prefixME_ + "/Zmass"); // Use folder with name of PAG
277 
278 
280  theDbe->book1D ("Z peak - WP80 EB-EE",
281  "Z peak - WP80 EB-EE;InvMass (GeV)", 60, 60.0, 120.0);
283  theDbe->book1D ("Z peak - WP80 EE-EE",
284  "Z peak - WP80 EE-EE;InvMass (Gev)", 60, 60.0, 120.0);
286  theDbe->book1D ("Z peak - WP80 EB-EB",
287  "Z peak - WP80 EB-EB;InvMass (Gev)", 60, 60.0, 120.0);
288  }
289 }
290 
291 // ------------ method called once each job just after ending the event loop ------------
292 void
294 {
295 }
296 
297 // ------------ method called when starting to processes a run ------------
298 void
300 {
301 
302 }
303 
304 // ------------ method called when ending the processing of a run ------------
305 void
307 {
308 }
309 
310 // ------------ method called when starting to processes a luminosity block ------------
311 void
313  edm::EventSetup const &)
314 {
315 }
316 
317 // ------------ method called when ending the processing of a luminosity block ------------
318 void
320  edm::EventSetup const &)
321 {
322 }
323 
324 // ------------ method fills 'descriptions' with the allowed parameters for the module ------------
325 void
327  ConfigurationDescriptions & descriptions)
328 {
329  //The following says we do not know what parameters are allowed so do no validation
330  // Please change this to state exactly what you do use, even if it is no parameters
332  desc.setUnknown ();
333  descriptions.addDefault (desc);
334 }
335 
336 //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:722
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:361
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:434
Definition: Run.h:36