CMS 3D CMS Logo

TtbarTrackProducer.cc
Go to the documentation of this file.
1 // system includes
2 #include <memory>
3 
4 // user includes
18 
19 // Electron selector
25 
26 // Muon Selector
30 
31 // Jet Selector
36 
37 // b-jet Selector
39 
40 // Met Selector
43 
44 // ROOT includes
45 #include "TLorentzVector.h"
46 
48 public:
49  explicit TtbarTrackProducer(const edm::ParameterSet&);
50  ~TtbarTrackProducer() override = default;
51  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
52 
53  void produce(edm::StreamID streamID, edm::Event& iEvent, edm::EventSetup const& iSetup) const override;
54 
55 private:
56  // ----------member data ---------------------------
57 
70 
71  const double maxEtaEle_;
72  const double maxEtaMu_;
73  const double minPt_;
74  const double maxDeltaPhiInEB_;
75  const double maxDeltaEtaInEB_;
76  const double maxHOEEB_;
77  const double maxSigmaiEiEEB_;
78  const double maxDeltaPhiInEE_;
79  const double maxDeltaEtaInEE_;
80  const double maxHOEEE_;
81  const double maxSigmaiEiEEE_;
82 
83  const double minChambers_;
84 
85  const double minEta_Jets_;
86 
87  const double btagFactor_;
88 
89  const double maxNormChi2_;
90  const double maxD0_;
91  const double maxDz_;
92  const int minPixelHits_;
93  const int minStripHits_;
94  const double maxIsoEle_;
95  const double maxIsoMu_;
96  const double minPtHighestMu_;
97  const double minPtHighestEle_;
98  const double minPtHighest_Jets_;
99  const double minPt_Jets_;
100  const double minInvMass_;
101  const double maxInvMass_;
102  const double minMet_;
103  const double maxMet_;
104  const double minWmass_;
105  const double maxWmass_;
106 };
107 
110  desc.addUntracked<edm::InputTag>("electronInputTag", edm::InputTag("gedGsfElectrons"));
111  desc.addUntracked<edm::InputTag>("jetsInputTag", edm::InputTag("ak4PFJetsCHS"));
112  desc.addUntracked<edm::InputTag>("bjetsInputTag", edm::InputTag("pfDeepCSVJetTags", "probb"));
113  desc.addUntracked<edm::InputTag>("pfmetTag", edm::InputTag("pfMet"));
114  desc.addUntracked<edm::InputTag>("muonInputTag", edm::InputTag("muons"));
115  desc.addUntracked<edm::InputTag>("offlineBeamSpot", edm::InputTag("offlineBeamSpot"));
116  desc.addUntracked<double>("maxEtaEle", 2.4);
117  desc.addUntracked<double>("maxEtaMu", 2.1);
118  desc.addUntracked<double>("minPt", 5);
119 
120  // for Electron only
121  desc.addUntracked<double>("maxDeltaPhiInEB", .15);
122  desc.addUntracked<double>("maxDeltaEtaInEB", .007);
123  desc.addUntracked<double>("maxHOEEB", .12);
124  desc.addUntracked<double>("maxSigmaiEiEEB", .01);
125  desc.addUntracked<double>("maxDeltaPhiInEE", .1);
126  desc.addUntracked<double>("maxDeltaEtaInEE", .009);
127  desc.addUntracked<double>("maxHOEEB_", .10);
128  desc.addUntracked<double>("maxSigmaiEiEEE", .03);
129 
130  // for Muon only
131  desc.addUntracked<uint32_t>("minChambers", 2);
132 
133  // for Jets only
134  desc.addUntracked<double>("minEta_Jets", 3.0);
135 
136  // for b-tag only
137  desc.addUntracked<double>("btagFactor", 0.6);
138 
139  desc.addUntracked<double>("maxNormChi2", 10);
140  desc.addUntracked<double>("maxD0", 0.02);
141  desc.addUntracked<double>("maxDz", 20.);
142  desc.addUntracked<uint32_t>("minPixelHits", 1);
143  desc.addUntracked<uint32_t>("minStripHits", 8);
144  desc.addUntracked<double>("maxIsoEle", 0.5);
145  desc.addUntracked<double>("maxIsoMu", 0.3);
146  desc.addUntracked<double>("minPtHighestMu", 24);
147  desc.addUntracked<double>("minPtHighestEle", 32);
148  desc.addUntracked<double>("minPtHighest_Jets", 30);
149  desc.addUntracked<double>("minPt_Jets", 20);
150  desc.addUntracked<double>("minInvMass", 140);
151  desc.addUntracked<double>("maxInvMass", 200);
152  desc.addUntracked<double>("minMet", 50);
153  desc.addUntracked<double>("maxMet", 80);
154  desc.addUntracked<double>("minWmass", 50);
155  desc.addUntracked<double>("maxWmass", 130);
156  descriptions.addWithDefaultLabel(desc);
157 }
158 
159 using namespace std;
160 using namespace edm;
161 
163  : electronTag_(ps.getUntrackedParameter<edm::InputTag>("electronInputTag", edm::InputTag("gedGsfElectrons"))),
164  jetsTag_(ps.getUntrackedParameter<edm::InputTag>("jetsInputTag", edm::InputTag("ak4PFJetsCHS"))),
165 
166  bjetsTag_(ps.getUntrackedParameter<edm::InputTag>("bjetsInputTag", edm::InputTag("pfDeepCSVJetTags", "probb"))),
167  pfmetTag_(ps.getUntrackedParameter<edm::InputTag>("pfmetTag", edm::InputTag("pfMet"))), //("pfMetT1T2Txy"))),
168  muonTag_(ps.getUntrackedParameter<edm::InputTag>("muonInputTag", edm::InputTag("muons"))),
169  bsTag_(ps.getUntrackedParameter<edm::InputTag>("offlineBeamSpot", edm::InputTag("offlineBeamSpot"))),
170  electronToken_(consumes<reco::GsfElectronCollection>(electronTag_)),
171  jetsToken_(consumes<reco::PFJetCollection>(jetsTag_)),
172  bjetsToken_(consumes<reco::JetTagCollection>(bjetsTag_)),
173  pfmetToken_(consumes<reco::PFMETCollection>(pfmetTag_)),
174  muonToken_(consumes<reco::MuonCollection>(muonTag_)),
175  bsToken_(consumes<reco::BeamSpot>(bsTag_)),
176  maxEtaEle_(ps.getUntrackedParameter<double>("maxEtaEle", 2.4)),
177  maxEtaMu_(ps.getUntrackedParameter<double>("maxEtaMu", 2.1)),
178  minPt_(ps.getUntrackedParameter<double>("minPt", 5)),
179 
180  // for Electron only
181  maxDeltaPhiInEB_(ps.getUntrackedParameter<double>("maxDeltaPhiInEB", .15)),
182  maxDeltaEtaInEB_(ps.getUntrackedParameter<double>("maxDeltaEtaInEB", .007)),
183  maxHOEEB_(ps.getUntrackedParameter<double>("maxHOEEB", .12)),
184  maxSigmaiEiEEB_(ps.getUntrackedParameter<double>("maxSigmaiEiEEB", .01)),
185  maxDeltaPhiInEE_(ps.getUntrackedParameter<double>("maxDeltaPhiInEE", .1)),
186  maxDeltaEtaInEE_(ps.getUntrackedParameter<double>("maxDeltaEtaInEE", .009)),
187  maxHOEEE_(ps.getUntrackedParameter<double>("maxHOEEB_", .10)),
188  maxSigmaiEiEEE_(ps.getUntrackedParameter<double>("maxSigmaiEiEEE", .03)),
189 
190  // for Muon only
191  minChambers_(ps.getUntrackedParameter<uint32_t>("minChambers", 2)),
192 
193  // for Jets only
194  minEta_Jets_(ps.getUntrackedParameter<double>("minEta_Jets", 3.0)),
195 
196  // for b-tag only
197  btagFactor_(ps.getUntrackedParameter<double>("btagFactor", 0.6)),
198 
199  maxNormChi2_(ps.getUntrackedParameter<double>("maxNormChi2", 10)),
200  maxD0_(ps.getUntrackedParameter<double>("maxD0", 0.02)),
201  maxDz_(ps.getUntrackedParameter<double>("maxDz", 20.)),
202  minPixelHits_(ps.getUntrackedParameter<uint32_t>("minPixelHits", 1)),
203  minStripHits_(ps.getUntrackedParameter<uint32_t>("minStripHits", 8)),
204  maxIsoEle_(ps.getUntrackedParameter<double>("maxIsoEle", 0.5)),
205  maxIsoMu_(ps.getUntrackedParameter<double>("maxIsoMu", 0.3)),
206  minPtHighestMu_(ps.getUntrackedParameter<double>("minPtHighestMu", 24)),
207  minPtHighestEle_(ps.getUntrackedParameter<double>("minPtHighestEle", 32)),
208  minPtHighest_Jets_(ps.getUntrackedParameter<double>("minPtHighest_Jets", 30)),
209  minPt_Jets_(ps.getUntrackedParameter<double>("minPt_Jets", 20)),
210  minInvMass_(ps.getUntrackedParameter<double>("minInvMass", 140)),
211  maxInvMass_(ps.getUntrackedParameter<double>("maxInvMass", 200)),
212  minMet_(ps.getUntrackedParameter<double>("minMet", 50)),
213  maxMet_(ps.getUntrackedParameter<double>("maxMet", 80)),
214  minWmass_(ps.getUntrackedParameter<double>("minWmass", 50)),
215  maxWmass_(ps.getUntrackedParameter<double>("maxWmass", 130)) {
216  produces<reco::TrackCollection>("");
217 }
218 
220  std::unique_ptr<reco::TrackCollection> outputTColl(new reco::TrackCollection());
221 
222  // beamspot
224  iEvent.getByToken(bsToken_, beamSpot);
225 
226  // Read Electron Collection
228  iEvent.getByToken(electronToken_, electronColl);
229  std::vector<TLorentzVector> list_ele;
230  std::vector<int> chrgeList_ele;
231 
232  // for Track jet collections
234  iEvent.getByToken(jetsToken_, jetColl);
236  std::vector<TLorentzVector> list_jets;
237 
238  if (jetColl.isValid()) {
239  for (const auto& jets : *jetColl) {
240  if (jets.pt() < minPt_Jets_)
241  continue;
242  if (std::fabs(jets.eta()) < minEta_Jets_)
243  continue;
244  TLorentzVector lv_jets; // lv_bJets;
245  lv_jets.SetPtEtaPhiE(jets.pt(), jets.eta(), jets.phi(), jets.energy());
246  list_jets.push_back(lv_jets);
247  Jets.push_back(jets);
248  }
249  }
250 
252  iEvent.getByToken(bjetsToken_, bTagHandle);
253 
254  if (bTagHandle.isValid()) {
255  const reco::JetTagCollection& bTags = *(bTagHandle.product());
256  std::vector<TLorentzVector> list_bjets;
257 
258  if (!bTags.empty()) {
259  for (unsigned bj = 0; bj != bTags.size(); ++bj) {
260  TLorentzVector lv_bjets;
261  lv_bjets.SetPtEtaPhiE(
262  bTags[bj].first->pt(), bTags[bj].first->eta(), bTags[bj].first->phi(), bTags[bj].first->energy());
263  if (bTags[bj].second > btagFactor_)
264  list_bjets.push_back(lv_bjets);
265  }
266  }
267  }
268 
269  for (unsigned int i = 0; i != Jets.size(); i++) {
270  reco::TrackRefVector vector = Jets[i].getTrackRefs();
271  for (unsigned int j = 0; j != vector.size(); j++) {
272  outputTColl->push_back(*vector[j]);
273  }
274  }
275 
276  iEvent.put(std::move(outputTColl));
277 }
278 
279 // Define this as a plug-in
const double maxSigmaiEiEEE_
void addWithDefaultLabel(ParameterSetDescription const &psetDescription)
const edm::EDGetTokenT< reco::GsfElectronCollection > electronToken_
const double maxSigmaiEiEEB_
void produce(edm::StreamID streamID, edm::Event &iEvent, edm::EventSetup const &iSetup) const override
const double maxDeltaPhiInEE_
const edm::InputTag electronTag_
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
const edm::EDGetTokenT< reco::PFJetCollection > jetsToken_
T const * product() const
Definition: Handle.h:70
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
const float maxD0_
Definition: Constants.h:83
const edm::InputTag bsTag_
const edm::EDGetTokenT< reco::BeamSpot > bsToken_
const edm::InputTag pfmetTag_
JetFloatAssociation::Container JetTagCollection
Definition: JetTag.h:17
std::vector< GsfElectron > GsfElectronCollection
collection of GsfElectron objects
const edm::EDGetTokenT< reco::JetTagCollection > bjetsToken_
std::vector< Muon > MuonCollection
collection of Muon objects
Definition: MuonFwd.h:9
const double minPtHighestEle_
U second(std::pair< T, U > const &p)
int iEvent
Definition: GenABIO.cc:224
const double minPtHighestMu_
const edm::InputTag jetsTag_
~TtbarTrackProducer() override=default
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
const double maxDeltaPhiInEB_
const edm::InputTag muonTag_
const double minPtHighest_Jets_
const edm::InputTag bjetsTag_
const double maxDeltaEtaInEE_
TtbarTrackProducer(const edm::ParameterSet &)
bool isValid() const
Definition: HandleBase.h:70
std::vector< PFJet > PFJetCollection
collection of PFJet objects
fixed size matrix
HLT enums.
const edm::EDGetTokenT< reco::MuonCollection > muonToken_
def move(src, dest)
Definition: eostools.py:511
const edm::EDGetTokenT< reco::PFMETCollection > pfmetToken_
const double maxDeltaEtaInEB_
Collection of PF MET.