CMS 3D CMS Logo

ZtoEEElectronTrackProducer.cc
Go to the documentation of this file.
1 // system includes
2 #include <memory>
3 
4 // user includes
23 
24 // ROOT includes
25 #include "TLorentzVector.h"
26 
28 public:
30  ~ZtoEEElectronTrackProducer() override = default;
31  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
32 
33  void produce(edm::StreamID streamID, edm::Event& iEvent, edm::EventSetup const& iSetup) const override;
34 
35 private:
36  // ----------member data ---------------------------
41 
42  const double maxEta_;
43  const double minPt_;
44  const double maxDeltaPhiInEB_;
45  const double maxDeltaEtaInEB_;
46  const double maxHOEEB_;
47  const double maxSigmaiEiEEB_;
48  const double maxDeltaPhiInEE_;
49  const double maxDeltaEtaInEE_;
50  const double maxHOEEE_;
51  const double maxSigmaiEiEEE_;
52  const double maxNormChi2_;
53  const double maxD0_;
54  const double maxDz_;
55  const int minPixelHits_;
56  const int minStripHits_;
57  const double maxIso_;
58  const double minPtHighest_;
59  const double minInvMass_;
60  const double maxInvMass_;
61 };
62 
63 using namespace std;
64 using namespace edm;
65 
68  desc.addUntracked<edm::InputTag>("electronInputTag", edm::InputTag("gedGsfElectrons"));
69  desc.addUntracked<edm::InputTag>("offlineBeamSpot", edm::InputTag("offlineBeamSpot"));
70  desc.addUntracked<double>("maxEta", 2.4);
71  desc.addUntracked<double>("minPt", 5);
72  desc.addUntracked<double>("maxDeltaPhiInEB", 0.15);
73  desc.addUntracked<double>("maxDeltaEtaInEB", 0.007);
74  desc.addUntracked<double>("maxHOEEB", 0.12);
75  desc.addUntracked<double>("maxSigmaiEiEEB", 0.01);
76  desc.addUntracked<double>("maxDeltaPhiInEE", 0.1);
77  desc.addUntracked<double>("maxDeltaEtaInEE", 0.009);
78  desc.addUntracked<double>("maxHOEEB_", .10);
79  desc.addUntracked<double>("maxSigmaiEiEEE", 0.03);
80  desc.addUntracked<double>("maxNormChi2", 10);
81  desc.addUntracked<double>("maxD0", 0.02);
82  desc.addUntracked<double>("maxDz", 20.);
83  desc.addUntracked<unsigned int>("minPixelHits", 1);
84  desc.addUntracked<unsigned int>("minStripHits", 8);
85  desc.addUntracked<double>("maxIso", 0.3);
86  desc.addUntracked<double>("minPtHighest", 24);
87  desc.addUntracked<double>("minInvMass", 75);
88  desc.addUntracked<double>("maxInvMass", 105);
89  descriptions.addWithDefaultLabel(desc);
90 }
91 
93  : electronTag_(ps.getUntrackedParameter<edm::InputTag>("electronInputTag", edm::InputTag("gedGsfElectrons"))),
94  bsTag_(ps.getUntrackedParameter<edm::InputTag>("offlineBeamSpot", edm::InputTag("offlineBeamSpot"))),
95  electronToken_(consumes<reco::GsfElectronCollection>(electronTag_)),
96  bsToken_(consumes<reco::BeamSpot>(bsTag_)),
97  maxEta_(ps.getUntrackedParameter<double>("maxEta", 2.4)),
98  minPt_(ps.getUntrackedParameter<double>("minPt", 5)),
99  maxDeltaPhiInEB_(ps.getUntrackedParameter<double>("maxDeltaPhiInEB", 0.15)),
100  maxDeltaEtaInEB_(ps.getUntrackedParameter<double>("maxDeltaEtaInEB", 0.007)),
101  maxHOEEB_(ps.getUntrackedParameter<double>("maxHOEEB", 0.12)),
102  maxSigmaiEiEEB_(ps.getUntrackedParameter<double>("maxSigmaiEiEEB", 0.01)),
103  maxDeltaPhiInEE_(ps.getUntrackedParameter<double>("maxDeltaPhiInEE", 0.1)),
104  maxDeltaEtaInEE_(ps.getUntrackedParameter<double>("maxDeltaEtaInEE", 0.009)),
105  maxHOEEE_(ps.getUntrackedParameter<double>("maxHOEEB_", .10)),
106  maxSigmaiEiEEE_(ps.getUntrackedParameter<double>("maxSigmaiEiEEE", 0.03)),
107  maxNormChi2_(ps.getUntrackedParameter<double>("maxNormChi2", 10)),
108  maxD0_(ps.getUntrackedParameter<double>("maxD0", 0.02)),
109  maxDz_(ps.getUntrackedParameter<double>("maxDz", 20.)),
110  minPixelHits_(ps.getUntrackedParameter<uint32_t>("minPixelHits", 1)),
111  minStripHits_(ps.getUntrackedParameter<uint32_t>("minStripHits", 8)),
112  maxIso_(ps.getUntrackedParameter<double>("maxIso", 0.3)),
113  minPtHighest_(ps.getUntrackedParameter<double>("minPtHighest", 24)),
114  minInvMass_(ps.getUntrackedParameter<double>("minInvMass", 75)),
115  maxInvMass_(ps.getUntrackedParameter<double>("maxInvMass", 105)) {
116  produces<reco::TrackCollection>("");
117 }
118 
121  edm::EventSetup const& iSetup) const {
122  std::unique_ptr<reco::TrackCollection> outputTColl(new reco::TrackCollection());
123 
124  // Read Electron Collection
126  iEvent.getByToken(electronToken_, electronColl);
127 
129  iEvent.getByToken(bsToken_, beamSpot);
130 
131  if (electronColl.isValid()) {
132  for (auto const& ele : *electronColl) {
133  if (!ele.ecalDriven())
134  continue;
135  if (ele.pt() < minPt_)
136  continue;
137  // set a max Eta cut
138  if (!(ele.isEB() || ele.isEE()))
139  continue;
140 
141  double hOverE = ele.hadronicOverEm();
142  double sigmaee = ele.sigmaIetaIeta();
143  double deltaPhiIn = ele.deltaPhiSuperClusterTrackAtVtx();
144  double deltaEtaIn = ele.deltaEtaSuperClusterTrackAtVtx();
145 
146  // separate cut for barrel and endcap
147  if (ele.isEB()) {
148  if (fabs(deltaPhiIn) >= maxDeltaPhiInEB_ && fabs(deltaEtaIn) >= maxDeltaEtaInEB_ && hOverE >= maxHOEEB_ &&
149  sigmaee >= maxSigmaiEiEEB_)
150  continue;
151  } else if (ele.isEE()) {
152  if (fabs(deltaPhiIn) >= maxDeltaPhiInEE_ && fabs(deltaEtaIn) >= maxDeltaEtaInEE_ && hOverE >= maxHOEEE_ &&
153  sigmaee >= maxSigmaiEiEEE_)
154  continue;
155  }
156 
157  reco::GsfTrackRef trk = ele.gsfTrack();
158  reco::TrackRef tk = ele.closestCtfTrackRef();
159  if (!trk.isNonnull())
160  continue; // only electrons with tracks
161  if (!tk.isNonnull())
162  continue;
163  double chi2 = trk->chi2();
164  double ndof = trk->ndof();
165  double chbyndof = (ndof > 0) ? chi2 / ndof : 0;
166  if (chbyndof >= maxNormChi2_)
167  continue;
168 
169  double trkd0 = trk->d0();
170  if (beamSpot.isValid()) {
171  trkd0 = -(trk->dxy(beamSpot->position()));
172  } else {
173  edm::LogError("ZtoEEElectronTrackProducer") << "Error >> Failed to get BeamSpot for label: " << bsTag_;
174  }
175  if (std::abs(trkd0) >= maxD0_)
176  continue;
177 
178  const reco::HitPattern& hitp = trk->hitPattern();
179  int nPixelHits = hitp.numberOfValidPixelHits();
180  if (nPixelHits < minPixelHits_)
181  continue;
182 
183  int nStripHits = hitp.numberOfValidStripHits();
184  if (nStripHits < minStripHits_)
185  continue;
186 
187  // DB corrected PF Isolation
188  reco::GsfElectron::PflowIsolationVariables pfIso = ele.pfIsolationVariables();
189  const float eiso =
190  pfIso.sumChargedHadronPt + std::max(0.0, pfIso.sumNeutralHadronEt + pfIso.sumPhotonEt - 0.5 * pfIso.sumPUPt);
191  if (eiso > maxIso_ * ele.pt())
192  continue;
193 
194  outputTColl->push_back(*tk);
195  }
196  } else {
197  edm::LogError("ZtoEEElectronTrackProducer")
198  << "Error >> Failed to get ElectronCollection for label: " << electronTag_;
199  }
200 
201  iEvent.put(std::move(outputTColl));
202 }
203 
204 // Define this as a plug-in
int numberOfValidPixelHits() const
Definition: HitPattern.h:831
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
float sumPUPt
sum pt of charged Particles not from PV (for Pu corrections)
Definition: GsfElectron.h:670
const float maxD0_
Definition: Constants.h:82
bool isNonnull() const
Checks for non-null.
Definition: Ref.h:238
~ZtoEEElectronTrackProducer() override=default
Log< level::Error, false > LogError
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
int numberOfValidStripHits() const
Definition: HitPattern.h:843
const edm::EDGetTokenT< reco::BeamSpot > bsToken_
int iEvent
Definition: GenABIO.cc:224
float sumPhotonEt
sum pt of PF photons // old float photonIso ;
Definition: GsfElectron.h:665
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
float sumNeutralHadronEt
sum pt of neutral hadrons // old float neutralHadronIso ;
Definition: GsfElectron.h:664
void produce(edm::StreamID streamID, edm::Event &iEvent, edm::EventSetup const &iSetup) const override
ZtoEEElectronTrackProducer(const edm::ParameterSet &)
const edm::EDGetTokenT< reco::GsfElectronCollection > electronToken_
bool isValid() const
Definition: HandleBase.h:70
fixed size matrix
HLT enums.
float sumChargedHadronPt
sum-pt of charged Hadron // old float chargedHadronIso ;
Definition: GsfElectron.h:663
def move(src, dest)
Definition: eostools.py:511