CMS 3D CMS Logo

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 // system include files
20 #include <memory>
21 
22 // user include files
23 
34 #include "TLorentzVector.h"
35 #include "TMath.h"
36 #include <cmath>
37 #include <iostream>
38 #include <string>
39 
42 
43 class EcalZmassTask : public DQMEDAnalyzer {
44 public:
45  explicit EcalZmassTask(const edm::ParameterSet &);
46  ~EcalZmassTask() override {}
47 
48 private:
49  void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override;
50  void analyze(const edm::Event &, const edm::EventSetup &) override;
51 
54 
56 
70 };
71 
73  : electronCollectionToken_(
74  consumes<reco::GsfElectronCollection>(parameters.getParameter<edm::InputTag>("electronCollection"))),
75  trackCollectionToken_(
76  consumes<reco::GsfTrackCollection>(parameters.getParameter<edm::InputTag>("trackCollection"))),
77  prefixME_(parameters.getUntrackedParameter<std::string>("prefixME", "")) {}
78 
79 // ------------ method called for each event ------------
81  using namespace edm;
84  if (!electronCollection.isValid())
85  return;
86 
87  // get GSF Tracks
89  iEvent.getByToken(trackCollectionToken_, gsftracks_h);
90 
91  bool isIsolatedBarrel;
92  bool isIDBarrel;
93  bool isConvertedBarrel;
94  bool isIsolatedEndcap;
95  bool isIDEndcap;
96  bool isConvertedEndcap;
97 
98  int elIsAccepted = 0;
99  int elIsAcceptedEB = 0;
100  int elIsAcceptedEE = 0;
101 
102  std::vector<TLorentzVector> LV;
103 
104  for (reco::GsfElectronCollection::const_iterator recoElectron = electronCollection->begin();
105  recoElectron != electronCollection->end();
106  recoElectron++) {
107  if (recoElectron->et() <= 25)
108  continue;
109 
110  // Define Isolation variables
111  double IsoTrk = (recoElectron->dr03TkSumPt() / recoElectron->et());
112  double IsoEcal = (recoElectron->dr03EcalRecHitSumEt() / recoElectron->et());
113  double IsoHcal = (recoElectron->dr03HcalTowerSumEt() / recoElectron->et());
114  double HE = (recoElectron->hcalOverEcal());
115 
116  // Define ID variables
117 
118  float DeltaPhiTkClu = recoElectron->deltaPhiSuperClusterTrackAtVtx();
119  float DeltaEtaTkClu = recoElectron->deltaEtaSuperClusterTrackAtVtx();
120  float sigmaIeIe = recoElectron->sigmaIetaIeta();
121 
122  // Define Conversion Rejection Variables
123 
124  float Dcot = recoElectron->convDcot();
125  float Dist = recoElectron->convDist();
126  int NumberOfExpectedInnerHits =
127  recoElectron->gsfTrack()->hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS);
128 
129  // quality flags
130 
131  isIsolatedBarrel = false;
132  isIDBarrel = false;
133  isConvertedBarrel = false;
134  isIsolatedEndcap = false;
135  isIDEndcap = false;
136  isConvertedEndcap = false;
137 
138  /***** Barrel WP80 Cuts *****/
139 
140  if (fabs(recoElectron->eta()) <= 1.4442) {
141  /* Isolation */
142  if (IsoTrk < 0.09 && IsoEcal < 0.07 && IsoHcal < 0.10) {
143  isIsolatedBarrel = true;
144  }
145 
146  /* Identification */
147  if (fabs(DeltaEtaTkClu) < 0.004 && fabs(DeltaPhiTkClu) < 0.06 && sigmaIeIe < 0.01 && HE < 0.04) {
148  isIDBarrel = true;
149  }
150 
151  /* Conversion Rejection */
152  if ((fabs(Dist) >= 0.02 || fabs(Dcot) >= 0.02) && NumberOfExpectedInnerHits <= 1.0) {
153  isConvertedBarrel = true;
154  }
155  }
156 
157  if (isIsolatedBarrel && isIDBarrel && isConvertedBarrel) {
158  elIsAccepted++;
159  elIsAcceptedEB++;
160  TLorentzVector b_e2(
161  recoElectron->momentum().x(), recoElectron->momentum().y(), recoElectron->momentum().z(), recoElectron->p());
162  LV.push_back(b_e2);
163  }
164 
165  /***** Endcap WP80 Cuts *****/
166 
167  if (fabs(recoElectron->eta()) >= 1.5660 && fabs(recoElectron->eta()) <= 2.5000) {
168  /* Isolation */
169  if (IsoTrk < 0.04 && IsoEcal < 0.05 && IsoHcal < 0.025) {
170  isIsolatedEndcap = true;
171  }
172 
173  /* Identification */
174  if (fabs(DeltaEtaTkClu) < 0.007 && fabs(DeltaPhiTkClu) < 0.03 && sigmaIeIe < 0.031 && HE < 0.15) {
175  isIDEndcap = true;
176  }
177 
178  /* Conversion Rejection */
179  if ((fabs(Dcot) > 0.02 || fabs(Dist) > 0.02) && NumberOfExpectedInnerHits <= 1.0) {
180  isConvertedEndcap = true;
181  }
182  }
183  if (isIsolatedEndcap && isIDEndcap && isConvertedEndcap) {
184  elIsAccepted++;
185  elIsAcceptedEE++;
186  TLorentzVector e_e2(
187  recoElectron->momentum().x(), recoElectron->momentum().y(), recoElectron->momentum().z(), recoElectron->p());
188  LV.push_back(e_e2);
189  }
190  }
191 
192  // Calculate the Z invariant masses
193 
194  if (elIsAccepted > 1) {
195  double e_ee_invMass = 0;
196  if (LV.size() == 2) {
197  TLorentzVector e_pair = LV[0] + LV[1];
198  e_ee_invMass = e_pair.M();
199  }
200 
201  if (elIsAcceptedEB == 2) {
202  h_ee_invMass_BB->Fill(e_ee_invMass);
203  }
204  if (elIsAcceptedEE == 2) {
205  h_ee_invMass_EE->Fill(e_ee_invMass);
206  }
207  if (elIsAcceptedEB == 1 && elIsAcceptedEE == 1) {
208  h_ee_invMass_EB->Fill(e_ee_invMass);
209  }
210 
211  LV.clear();
212  }
213 }
214 
216  std::string logTraceName("EcalZmassTask");
217 
218  h_ee_invMass_EB = nullptr;
219  h_ee_invMass_EE = nullptr;
220  h_ee_invMass_BB = nullptr;
221 
222  LogTrace(logTraceName) << "Parameters initialization";
223 
224  iBooker.setCurrentFolder(prefixME_ + "/Zmass"); // Use folder with name of PAG
225 
226  h_ee_invMass_EB = iBooker.book1D("Z peak - WP80 EB-EE", "Z peak - WP80 EB-EE;InvMass (GeV)", 60, 60.0, 120.0);
227  h_ee_invMass_EE = iBooker.book1D("Z peak - WP80 EE-EE", "Z peak - WP80 EE-EE;InvMass (Gev)", 60, 60.0, 120.0);
228  h_ee_invMass_BB = iBooker.book1D("Z peak - WP80 EB-EB", "Z peak - WP80 EB-EB;InvMass (Gev)", 60, 60.0, 120.0);
229 }
230 
231 // define this as a plug-in
MonitorElement * h_e2_eta
MonitorElement * h_ee_invMass_EB
const std::string prefixME_
MonitorElement * h_e1_phi
MonitorElement * h_95_ee_invMass_EE
virtual void setCurrentFolder(std::string const &fullpath)
Definition: DQMStore.cc:36
MonitorElement * h_95_ee_invMass_EB
math::XYZTLorentzVectorD LV
MonitorElement * h_e2_et
const edm::EDGetTokenT< reco::GsfElectronCollection > electronCollectionToken_
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
MonitorElement * h_e1_et
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
#define LogTrace(id)
void Fill(long long x)
EcalZmassTask(const edm::ParameterSet &)
int iEvent
Definition: GenABIO.cc:224
std::vector< GsfTrack > GsfTrackCollection
collection of GsfTracks
Definition: GsfTrackFwd.h:9
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
MonitorElement * h_ee_invMass_EE
MonitorElement * h_ee_invMass
void analyze(const edm::Event &, const edm::EventSetup &) override
~EcalZmassTask() override
MonitorElement * h_95_ee_invMass_BB
MonitorElement * h_ee_invMass_BB
fixed size matrix
HLT enums.
const edm::EDGetTokenT< reco::GsfTrackCollection > trackCollectionToken_
MonitorElement * book1D(TString const &name, TString const &title, int const nchX, double const lowX, double const highX, FUNC onbooking=NOOP())
Definition: DQMStore.h:98
MonitorElement * h_e2_phi
MonitorElement * h_e1_eta
Definition: Run.h:45