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