CMS 3D CMS Logo

ZtoEEElectronTrackProducer.cc
Go to the documentation of this file.
4 
8 
13 #include "TLorentzVector.h"
14 
16 
17 using namespace std;
18 using namespace edm;
19 
21  : electronTag_(ps.getUntrackedParameter<edm::InputTag>("electronInputTag", edm::InputTag("gedGsfElectrons"))),
22  bsTag_(ps.getUntrackedParameter<edm::InputTag>("offlineBeamSpot", edm::InputTag("offlineBeamSpot"))),
23  electronToken_(consumes<reco::GsfElectronCollection>(electronTag_)),
24  bsToken_(consumes<reco::BeamSpot>(bsTag_)),
25  maxEta_(ps.getUntrackedParameter<double>("maxEta", 2.4)),
26  minPt_(ps.getUntrackedParameter<double>("minPt", 5)),
27  maxDeltaPhiInEB_(ps.getUntrackedParameter<double>("maxDeltaPhiInEB", 0.15)),
28  maxDeltaEtaInEB_(ps.getUntrackedParameter<double>("maxDeltaEtaInEB", 0.007)),
29  maxHOEEB_(ps.getUntrackedParameter<double>("maxHOEEB", 0.12)),
30  maxSigmaiEiEEB_(ps.getUntrackedParameter<double>("maxSigmaiEiEEB", 0.01)),
31  maxDeltaPhiInEE_(ps.getUntrackedParameter<double>("maxDeltaPhiInEE", 0.1)),
32  maxDeltaEtaInEE_(ps.getUntrackedParameter<double>("maxDeltaEtaInEE", 0.009)),
33  maxHOEEE_(ps.getUntrackedParameter<double>("maxHOEEB_", .10)),
34  maxSigmaiEiEEE_(ps.getUntrackedParameter<double>("maxSigmaiEiEEE", 0.03)),
35  maxNormChi2_(ps.getUntrackedParameter<double>("maxNormChi2", 10)),
36  maxD0_(ps.getUntrackedParameter<double>("maxD0", 0.02)),
37  maxDz_(ps.getUntrackedParameter<double>("maxDz", 20.)),
38  minPixelHits_(ps.getUntrackedParameter<uint32_t>("minPixelHits", 1)),
39  minStripHits_(ps.getUntrackedParameter<uint32_t>("minStripHits", 8)),
40  maxIso_(ps.getUntrackedParameter<double>("maxIso", 0.3)),
41  minPtHighest_(ps.getUntrackedParameter<double>("minPtHighest", 24)),
42  minInvMass_(ps.getUntrackedParameter<double>("minInvMass", 60)),
43  maxInvMass_(ps.getUntrackedParameter<double>("maxInvMass", 120)) {
44  produces<reco::TrackCollection>("");
45 }
46 
48 
51  edm::EventSetup const& iSetup) const {
52  std::unique_ptr<reco::TrackCollection> outputTColl(new reco::TrackCollection());
53 
54  // Read Electron Collection
56  iEvent.getByToken(electronToken_, electronColl);
57 
59  iEvent.getByToken(bsToken_, beamSpot);
60 
61  if (electronColl.isValid()) {
62  for (auto const& ele : *electronColl) {
63  if (!ele.ecalDriven())
64  continue;
65  if (ele.pt() < minPt_)
66  continue;
67  // set a max Eta cut
68  if (!(ele.isEB() || ele.isEE()))
69  continue;
70 
71  double hOverE = ele.hadronicOverEm();
72  double sigmaee = ele.sigmaIetaIeta();
73  double deltaPhiIn = ele.deltaPhiSuperClusterTrackAtVtx();
74  double deltaEtaIn = ele.deltaEtaSuperClusterTrackAtVtx();
75 
76  // separate cut for barrel and endcap
77  if (ele.isEB()) {
78  if (fabs(deltaPhiIn) >= maxDeltaPhiInEB_ && fabs(deltaEtaIn) >= maxDeltaEtaInEB_ && hOverE >= maxHOEEB_ &&
79  sigmaee >= maxSigmaiEiEEB_)
80  continue;
81  } else if (ele.isEE()) {
82  if (fabs(deltaPhiIn) >= maxDeltaPhiInEE_ && fabs(deltaEtaIn) >= maxDeltaEtaInEE_ && hOverE >= maxHOEEE_ &&
83  sigmaee >= maxSigmaiEiEEE_)
84  continue;
85  }
86 
87  reco::GsfTrackRef trk = ele.gsfTrack();
88  reco::TrackRef tk = ele.closestCtfTrackRef();
89  if (!trk.isNonnull())
90  continue; // only electrons with tracks
91  if (!tk.isNonnull())
92  continue;
93  double chi2 = trk->chi2();
94  double ndof = trk->ndof();
95  double chbyndof = (ndof > 0) ? chi2 / ndof : 0;
96  if (chbyndof >= maxNormChi2_)
97  continue;
98 
99  double trkd0 = trk->d0();
100  if (beamSpot.isValid()) {
101  trkd0 = -(trk->dxy(beamSpot->position()));
102  } else {
103  edm::LogError("ZtoEEElectronTrackProducer") << "Error >> Failed to get BeamSpot for label: " << bsTag_;
104  }
105  if (std::fabs(trkd0) >= maxD0_)
106  continue;
107 
108  const reco::HitPattern& hitp = trk->hitPattern();
109  int nPixelHits = hitp.numberOfValidPixelHits();
110  if (nPixelHits < minPixelHits_)
111  continue;
112 
113  int nStripHits = hitp.numberOfValidStripHits();
114  if (nStripHits < minStripHits_)
115  continue;
116 
117  // DB corrected PF Isolation
118  reco::GsfElectron::PflowIsolationVariables pfIso = ele.pfIsolationVariables();
119  const float eiso =
120  pfIso.sumChargedHadronPt + std::max(0.0, pfIso.sumNeutralHadronEt + pfIso.sumPhotonEt - 0.5 * pfIso.sumPUPt);
121  if (eiso > maxIso_ * ele.pt())
122  continue;
123 
124  outputTColl->push_back(*tk);
125  }
126  } else {
127  edm::LogError("ZtoEEElectronTrackProducer")
128  << "Error >> Failed to get ElectronCollection for label: " << electronTag_;
129  }
130 
131  iEvent.put(std::move(outputTColl));
132 }
133 
134 // Define this as a plug-in
int numberOfValidPixelHits() const
Definition: HitPattern.h:831
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
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
#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