CMS 3D CMS Logo

PixelJetPuId.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: PixelJetPuId
4 // Class: PixelJetPuId
5 //
15 //
16 // Original Author: Silvio DONATO
17 // Created: Wed Dec 18 10:05:40 CET 2013
18 //
19 //
20 
21 // system include files
22 #include <memory>
23 
24 // user include files
27 
31 
36 
42 
47 
51 //
52 // class declaration
53 //
54 
56 public:
58  ~PixelJetPuId() override;
59 
60  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
61 
62 private:
63  void produce(edm::StreamID sid, edm::Event&, const edm::EventSetup&) const override;
64 
65  // ----------member data ---------------------------
73 
74  double m_MinTrackPt;
77 
78  bool m_fwjets;
81 
84 };
85 
86 //
87 // constructors and destructor
88 //
90  //InputTag
91  m_tracks = iConfig.getParameter<edm::InputTag>("tracks");
92  tracksToken = consumes<std::vector<reco::Track> >(m_tracks);
93  m_jets = iConfig.getParameter<edm::InputTag>("jets");
94  jetsToken = consumes<edm::View<reco::CaloJet> >(m_jets);
95  generaljetsToken = consumes<edm::View<reco::Jet> >(m_jets);
96  m_primaryVertex = iConfig.getParameter<edm::InputTag>("primaryVertex");
97  primaryVertexToken = consumes<reco::VertexCollection>(m_primaryVertex);
98 
99  //Tracks Selection
100  m_MinTrackPt = iConfig.getParameter<double>("MinTrackPt");
101  m_MaxTrackDistanceToJet = iConfig.getParameter<double>("MaxTrackDistanceToJet");
102  m_MaxTrackChi2 = iConfig.getParameter<double>("MaxTrackChi2");
103 
104  //A jet is defined as a signal jet if Sum(trackPt) > minPt or Sum(comp.trackPt)/CaloJetPt > minPtRatio
105  m_MinGoodJetTrackPt = iConfig.getParameter<double>("MinGoodJetTrackPt");
106  m_MinGoodJetTrackPtRatio = iConfig.getParameter<double>("MinGoodJetTrackPtRatio");
107 
108  m_fwjets = iConfig.getParameter<bool>("UseForwardJetsAsNoPU");
109  m_mineta_fwjets = iConfig.getParameter<double>("MinEtaForwardJets");
110  m_minet_fwjets = iConfig.getParameter<double>("MinEtForwardJets");
111 
112  produces<std::vector<reco::CaloJet> >();
113  produces<std::vector<reco::CaloJet> >("PUjets");
114  produces<reco::JetTagCollection>();
115 }
116 
117 PixelJetPuId::~PixelJetPuId() = default;
118 
121  desc.add<edm::InputTag>("jets", edm::InputTag("hltCaloJetL1FastJetCorrected"));
122  desc.add<edm::InputTag>("tracks", edm::InputTag("hltPixelTracksNoPU"));
123  desc.add<edm::InputTag>("primaryVertex", edm::InputTag("hltFastPVPixelVertices"));
124  desc.add<double>("MinGoodJetTrackPtRatio", 0.045);
125  desc.add<double>("MinGoodJetTrackPt", 1.8);
126  desc.add<double>("MaxTrackDistanceToJet", 0.04);
127  desc.add<double>("MinTrackPt", 0.6);
128  desc.add<double>("MaxTrackChi2", 20.);
129  desc.add<bool>("UseForwardJetsAsNoPU", true);
130  desc.add<double>("MinEtaForwardJets", 2.4);
131  desc.add<double>("MinEtForwardJets", 40.);
132  descriptions.add("pixelJetPuId", desc);
133 }
134 
135 //
136 // member functions
137 //
138 
139 // ------------ method called on each new Event ------------
141  using namespace edm;
142  std::unique_ptr<std::vector<reco::CaloJet> > pOut(new std::vector<reco::CaloJet>);
143  std::unique_ptr<std::vector<reco::CaloJet> > pOut_PUjets(new std::vector<reco::CaloJet>);
144  std::unique_ptr<reco::JetTagCollection> pOut_jetTagCollection(new reco::JetTagCollection);
145 
146  //get tracks
148  iEvent.getByToken(tracksToken, tracks);
149  unsigned int tsize = tracks->size();
150  float teta[tsize], tphi[tsize];
151  unsigned int i = 0;
152  for (auto const& tr : *tracks) {
153  teta[i] = tr.eta();
154  tphi[i] = tr.phi();
155  ++i;
156  }
157 
158  //get jets
160  iEvent.getByToken(jetsToken, jets);
161 
162  Handle<edm::View<reco::Jet> > generaljets;
163  iEvent.getByToken(generaljetsToken, generaljets);
164 
165  //get primary vertices
168 
169  //get Transient Track Builder
171  iSetup.get<TransientTrackRecord>().get("TransientTrackBuilder", builder);
172 
173  //init JetTagCollection
174  if (!generaljets.product()->empty()) {
176  pOut_jetTagCollection.reset(new reco::JetTagCollection(edm::makeRefToBaseProdFrom(jj, iEvent)));
177  }
178 
179  //loop on trackIPTagInfos
180  if (!primaryVertex->empty()) {
181  const reco::Vertex* pv = &*primaryVertex->begin();
182  //loop on jets
183  for (edm::View<reco::CaloJet>::const_iterator itJet = jets->begin(); itJet != jets->end(); itJet++) {
184  math::XYZVector jetMomentum = itJet->momentum();
185  GlobalVector direction(jetMomentum.x(), jetMomentum.y(), jetMomentum.z());
186 
187  math::XYZVector trMomentum;
188 
189  if (fabs(itJet->eta()) > m_mineta_fwjets) {
190  if ((m_fwjets) && (itJet->et() > m_minet_fwjets))
191  pOut->push_back(*itJet); // fill forward jet as signal jet
192  } else {
193  //loop on tracks
194  auto itTrack = tracks->begin();
195  for (unsigned int i = 0; i < tsize; ++i) {
196  float deltaR2 = reco::deltaR2(itJet->eta(), itJet->phi(), teta[i], tphi[i]);
197  if (deltaR2 < 0.25) {
198  reco::TransientTrack transientTrack = builder->build(*itTrack);
199  float jetTrackDistance = -((IPTools::jetTrackDistance(transientTrack, direction, *pv)).second).value();
200 
201  //select the tracks compabible with the jet
202  if ((itTrack->pt() > m_MinTrackPt) && (itTrack->normalizedChi2() < m_MaxTrackChi2) &&
204  trMomentum += itTrack->momentum(); //calculate the Sum(trackPt)
205  }
206  }
207  itTrack++;
208  }
209  //if Sum(comp.trackPt)/CaloJetPt > minPtRatio or Sum(trackPt) > minPt the jet is a signal jet
210  if (trMomentum.rho() / jetMomentum.rho() > m_MinGoodJetTrackPtRatio || trMomentum.rho() > m_MinGoodJetTrackPt) {
211  pOut->push_back(*itJet); // fill it as signal jet
212  } else //else it is a PUjet
213  {
214  pOut_PUjets->push_back(*itJet); // fill it as PUjets
215  }
216  }
217  RefToBase<reco::Jet> jRef(generaljets, itJet - jets->begin());
218  (*pOut_jetTagCollection)[jRef] = trMomentum.rho(); // fill jetTagCollection
219  }
220  }
221  iEvent.put(std::move(pOut));
222  iEvent.put(std::move(pOut_PUjets), "PUjets");
223  iEvent.put(std::move(pOut_jetTagCollection));
224 }
225 
226 // declare this class as a framework plugin
Vector3DBase
Definition: Vector3DBase.h:8
ConfigurationDescriptions.h
edm::StreamID
Definition: StreamID.h:30
PixelJetPuId::primaryVertexToken
edm::EDGetTokenT< reco::VertexCollection > primaryVertexToken
Definition: PixelJetPuId.cc:72
CaloJetCollection.h
JetTag.h
PDWG_EXOHSCP_cff.tracks
tracks
Definition: PDWG_EXOHSCP_cff.py:28
CaloJet.h
mps_fire.i
i
Definition: mps_fire.py:355
edm::ParameterSetDescription::add
ParameterDescriptionBase * add(U const &iLabel, T const &value)
Definition: ParameterSetDescription.h:95
PixelJetPuId::m_jets
edm::InputTag m_jets
Definition: PixelJetPuId.cc:68
edm::Handle::product
T const * product() const
Definition: Handle.h:70
PixelJetPuId::PixelJetPuId
PixelJetPuId(const edm::ParameterSet &)
Definition: PixelJetPuId.cc:89
edm::EDGetTokenT
Definition: EDGetToken.h:33
edm
HLT enums.
Definition: AlignableModifier.h:19
PixelJetPuId::m_MaxTrackChi2
double m_MaxTrackChi2
Definition: PixelJetPuId.cc:75
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:215
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
TransientTrack.h
edm::Handle
Definition: AssociativeIterator.h:50
deltaR.h
BeamMonitor_cff.primaryVertex
primaryVertex
hltOfflineBeamSpot for HLTMON
Definition: BeamMonitor_cff.py:7
MakerMacros.h
PixelJetPuId::~PixelJetPuId
~PixelJetPuId() override
Track.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:73
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
edm::ConfigurationDescriptions::add
void add(std::string const &label, ParameterSetDescription const &psetDescription)
Definition: ConfigurationDescriptions.cc:57
PixelJetPuId::fillDescriptions
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
Definition: PixelJetPuId.cc:119
PixelJetPuId::m_MaxTrackDistanceToJet
double m_MaxTrackDistanceToJet
Definition: PixelJetPuId.cc:76
TransientTrackRecord
Definition: TransientTrackRecord.h:11
edm::ESHandle< TransientTrackBuilder >
ParameterSetDescription.h
RefToBase.h
PixelJetPuId
Definition: PixelJetPuId.cc:55
edm::global::EDProducer
Definition: EDProducer.h:32
edm::ConfigurationDescriptions
Definition: ConfigurationDescriptions.h:28
Vertex.h
IPTools::jetTrackDistance
std::pair< double, Measurement1D > jetTrackDistance(const reco::TransientTrack &track, const GlobalVector &direction, const reco::Vertex &vertex)
Definition: IPTools.cc:206
edm::AssociationVector
Definition: AssociationVector.h:67
PixelJetPuId::m_minet_fwjets
double m_minet_fwjets
Definition: PixelJetPuId.cc:80
TransientTrackBuilder.h
HLT_2018_cff.InputTag
InputTag
Definition: HLT_2018_cff.py:79016
edm::ParameterSet
Definition: ParameterSet.h:36
PixelJetPuId::m_MinGoodJetTrackPt
double m_MinGoodJetTrackPt
Definition: PixelJetPuId.cc:82
Event.h
edm::makeRefToBaseProdFrom
RefToBaseProd< T > makeRefToBaseProdFrom(RefToBase< T > const &iRef, Event const &iEvent)
Definition: makeRefToBaseProdFrom.h:34
reco::deltaR2
constexpr auto deltaR2(const T1 &t1, const T2 &t2) -> decltype(t1.eta())
Definition: deltaR.h:16
math::XYZVector
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
PixelJetPuId::m_tracks
edm::InputTag m_tracks
Definition: PixelJetPuId.cc:67
MetAnalyzer.pv
def pv(vc)
Definition: MetAnalyzer.py:7
iEvent
int iEvent
Definition: GenABIO.cc:224
edm::EventSetup
Definition: EventSetup.h:57
makeRefToBaseProdFrom.h
TransientTrackRecord.h
get
#define get
InputTag.h
PixelJetPuId::produce
void produce(edm::StreamID sid, edm::Event &, const edm::EventSetup &) const override
Definition: PixelJetPuId.cc:140
VertexFwd.h
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
PixelJetPuId::jetsToken
edm::EDGetTokenT< edm::View< reco::CaloJet > > jetsToken
Definition: PixelJetPuId.cc:70
eostools.move
def move(src, dest)
Definition: eostools.py:511
PixelJetPuId::m_MinTrackPt
double m_MinTrackPt
Definition: PixelJetPuId.cc:74
IPTools.h
reco::TransientTrack
Definition: TransientTrack.h:19
HLTMuonOfflineAnalyzer_cfi.deltaR2
deltaR2
Definition: HLTMuonOfflineAnalyzer_cfi.py:105
PixelJetPuId::m_mineta_fwjets
double m_mineta_fwjets
Definition: PixelJetPuId.cc:79
Frameworkfwd.h
PixelJetPuId::tracksToken
edm::EDGetTokenT< std::vector< reco::Track > > tracksToken
Definition: PixelJetPuId.cc:69
PixelJetPuId::generaljetsToken
edm::EDGetTokenT< edm::View< reco::Jet > > generaljetsToken
Definition: PixelJetPuId.cc:71
findQualityFiles.jj
string jj
Definition: findQualityFiles.py:188
edm::RefToBase< reco::Jet >
edm::View::const_iterator
boost::indirect_iterator< typename seq_t::const_iterator > const_iterator
Definition: View.h:86
TransientTrackBuilder::build
reco::TransientTrack build(const reco::Track *p) const
Definition: TransientTrackBuilder.cc:20
ParameterSet.h
EDProducer.h
PixelJetPuId::m_primaryVertex
edm::InputTag m_primaryVertex
Definition: PixelJetPuId.cc:66
edm::Event
Definition: Event.h:73
PixelJetPuId::m_fwjets
bool m_fwjets
Definition: PixelJetPuId.cc:78
PixelJetPuId::m_MinGoodJetTrackPtRatio
double m_MinGoodJetTrackPtRatio
Definition: PixelJetPuId.cc:83
edm::InputTag
Definition: InputTag.h:15
reco::Vertex
Definition: Vertex.h:35