CMS 3D CMS Logo

TtbarTrackProducer.cc
Go to the documentation of this file.
6 #include "TLorentzVector.h"
7 
10 #include "TH1.h"
11 
13 
14 using namespace std;
15 using namespace edm;
16 
18  : electronTag_(ps.getUntrackedParameter<edm::InputTag>("electronInputTag", edm::InputTag("gedGsfElectrons"))),
19  jetsTag_(ps.getUntrackedParameter<edm::InputTag>("jetsInputTag", edm::InputTag("ak4PFJetsCHS"))),
20 
21  bjetsTag_(ps.getUntrackedParameter<edm::InputTag>("bjetsInputTag", edm::InputTag("pfDeepCSVJetTags", "probb"))),
22  pfmetTag_(ps.getUntrackedParameter<edm::InputTag>("pfmetTag", edm::InputTag("pfMet"))), //("pfMetT1T2Txy"))),
23  muonTag_(ps.getUntrackedParameter<edm::InputTag>("muonInputTag", edm::InputTag("muons"))),
24  bsTag_(ps.getUntrackedParameter<edm::InputTag>("offlineBeamSpot", edm::InputTag("offlineBeamSpot"))),
25  electronToken_(consumes<reco::GsfElectronCollection>(electronTag_)),
26  jetsToken_(consumes<reco::PFJetCollection>(jetsTag_)),
27  bjetsToken_(consumes<reco::JetTagCollection>(bjetsTag_)),
28  pfmetToken_(consumes<reco::PFMETCollection>(pfmetTag_)),
29  muonToken_(consumes<reco::MuonCollection>(muonTag_)),
30  bsToken_(consumes<reco::BeamSpot>(bsTag_)),
31  maxEtaEle_(ps.getUntrackedParameter<double>("maxEta", 2.4)),
32  maxEtaMu_(ps.getUntrackedParameter<double>("maxEta", 2.1)),
33  minPt_(ps.getUntrackedParameter<double>("minPt", 5)),
34 
35  // for Electron only
36  maxDeltaPhiInEB_(ps.getUntrackedParameter<double>("maxDeltaPhiInEB", .15)),
37  maxDeltaEtaInEB_(ps.getUntrackedParameter<double>("maxDeltaEtaInEB", .007)),
38  maxHOEEB_(ps.getUntrackedParameter<double>("maxHOEEB", .12)),
39  maxSigmaiEiEEB_(ps.getUntrackedParameter<double>("maxSigmaiEiEEB", .01)),
40  maxDeltaPhiInEE_(ps.getUntrackedParameter<double>("maxDeltaPhiInEE", .1)),
41  maxDeltaEtaInEE_(ps.getUntrackedParameter<double>("maxDeltaEtaInEE", .009)),
42  maxHOEEE_(ps.getUntrackedParameter<double>("maxHOEEB_", .10)),
43  maxSigmaiEiEEE_(ps.getUntrackedParameter<double>("maxSigmaiEiEEE", .03)),
44 
45  // for Muon only
46  minChambers_(ps.getUntrackedParameter<uint32_t>("minChambers", 2)),
47 
48  // for Jets only
49  minEta_Jets_(ps.getUntrackedParameter<double>("minEta_Jets", 3.0)),
50 
51  // for b-tag only
52  btagFactor_(ps.getUntrackedParameter<double>("btagFactor", 0.6)),
53 
54  maxNormChi2_(ps.getUntrackedParameter<double>("maxNormChi2", 10)),
55  maxD0_(ps.getUntrackedParameter<double>("maxD0", 0.02)),
56  maxDz_(ps.getUntrackedParameter<double>("maxDz", 20.)),
57  minPixelHits_(ps.getUntrackedParameter<uint32_t>("minPixelHits", 1)),
58  minStripHits_(ps.getUntrackedParameter<uint32_t>("minStripHits", 8)),
59  maxIsoEle_(ps.getUntrackedParameter<double>("maxIso", 0.5)),
60  maxIsoMu_(ps.getUntrackedParameter<double>("maxIso", 0.3)),
61  minPtHighestMu_(ps.getUntrackedParameter<double>("minPtHighestMu", 24)),
62  minPtHighestEle_(ps.getUntrackedParameter<double>("minPtHighestEle", 32)),
63  minPtHighest_Jets_(ps.getUntrackedParameter<double>("minPtHighest_Jets", 30)),
64  minPt_Jets_(ps.getUntrackedParameter<double>("minPt_Jets", 20)),
65  minInvMass_(ps.getUntrackedParameter<double>("minInvMass", 140)),
66  maxInvMass_(ps.getUntrackedParameter<double>("maxInvMass", 200)),
67  minMet_(ps.getUntrackedParameter<double>("minMet", 50)),
68  maxMet_(ps.getUntrackedParameter<double>("maxMet", 80)),
69  minWmass_(ps.getUntrackedParameter<double>("minWmass", 50)),
70  maxWmass_(ps.getUntrackedParameter<double>("maxWmass", 130)) {
71  produces<reco::TrackCollection>("");
72 }
73 
75 
77  std::unique_ptr<reco::TrackCollection> outputTColl(new reco::TrackCollection());
78 
79  // beamspot
81  iEvent.getByToken(bsToken_, beamSpot);
82 
83  // Read Electron Collection
85  iEvent.getByToken(electronToken_, electronColl);
86  std::vector<TLorentzVector> list_ele;
87  std::vector<int> chrgeList_ele;
88 
89  // for Track jet collections
91  iEvent.getByToken(jetsToken_, jetColl);
93  std::vector<TLorentzVector> list_jets;
94 
95  if (jetColl.isValid()) {
96  for (const auto& jets : *jetColl) {
97  if (jets.pt() < minPt_Jets_)
98  continue;
99  if (std::fabs(jets.eta()) < minEta_Jets_)
100  continue;
101  TLorentzVector lv_jets; // lv_bJets;
102  lv_jets.SetPtEtaPhiE(jets.pt(), jets.eta(), jets.phi(), jets.energy());
103  list_jets.push_back(lv_jets);
104  Jets.push_back(jets);
105  }
106  }
107 
109  iEvent.getByToken(bjetsToken_, bTagHandle);
110  const reco::JetTagCollection& bTags = *(bTagHandle.product());
111  std::vector<TLorentzVector> list_bjets;
112 
113  if (!bTags.empty()) {
114  for (unsigned bj = 0; bj != bTags.size(); ++bj) {
115  TLorentzVector lv_bjets;
116  lv_bjets.SetPtEtaPhiE(
117  bTags[bj].first->pt(), bTags[bj].first->eta(), bTags[bj].first->phi(), bTags[bj].first->energy());
118  if (bTags[bj].second > btagFactor_)
119  list_bjets.push_back(lv_bjets);
120  }
121  }
122 
123  for (unsigned int i = 0; i != Jets.size(); i++) {
124  reco::TrackRefVector vector = Jets[i].getTrackRefs();
125  for (unsigned int j = 0; j != vector.size(); j++) {
126  outputTColl->push_back(*vector[j]);
127  }
128  }
129 
130  iEvent.put(std::move(outputTColl));
131 }
132 
133 // Define this as a plug-in
const edm::EDGetTokenT< reco::GsfElectronCollection > electronToken_
void produce(edm::StreamID streamID, edm::Event &iEvent, edm::EventSetup const &iSetup) const override
const double btagFactor_
const double minEta_Jets_
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:82
const edm::EDGetTokenT< reco::BeamSpot > bsToken_
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
U second(std::pair< T, U > const &p)
int iEvent
Definition: GenABIO.cc:224
~TtbarTrackProducer() override
const double minPt_Jets_
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
TtbarTrackProducer(const edm::ParameterSet &)
bool isValid() const
Definition: HandleBase.h:70
std::vector< PFJet > PFJetCollection
collection of PFJet objects
fixed size matrix
HLT enums.
def move(src, dest)
Definition: eostools.py:511
Collection of PF MET.