CMS 3D CMS Logo

JVFJetIdProducer.cc
Go to the documentation of this file.
2 
5 
18 
20 
22  srcJets_ = consumes<reco::PFJetCollection>(cfg.getParameter<edm::InputTag>("srcJets"));
23 
24  srcPFCandidates_ = consumes<reco::PFCandidateCollection>(cfg.getParameter<edm::InputTag>("srcPFCandidates"));
26  consumes<PFCandToVertexAssMap>(cfg.getParameter<edm::InputTag>("srcPFCandToVertexAssociations"));
27  srcHardScatterVertex_ = consumes<reco::VertexCollection>(cfg.getParameter<edm::InputTag>("srcHardScatterVertex"));
28  minTrackPt_ = cfg.getParameter<double>("minTrackPt");
29  dZcut_ = cfg.getParameter<double>("dZcut");
30 
31  JVFcut_ = cfg.getParameter<double>("JVFcut");
32 
33  std::string neutralJetOption_string = cfg.getParameter<std::string>("neutralJetOption");
34  if (neutralJetOption_string == "PU")
36  else if (neutralJetOption_string == "noPU")
38  else
39  throw cms::Exception("JVFJetIdProducer")
40  << "Invalid Configuration Parameter 'neutralJetOption' = " << neutralJetOption_string << " !!\n";
41 
42  verbosity_ = (cfg.exists("verbosity")) ? cfg.getParameter<int>("verbosity") : 0;
43 
44  produces<edm::ValueMap<double>>("Discriminant");
45  produces<edm::ValueMap<int>>("Id");
46 }
47 
49  // nothing to be done yet...
50 }
51 
52 namespace {
53  double computeJVF(const reco::PFJet& jet,
54  const PFCandToVertexAssMap& pfCandToVertexAssociations,
56  double dZ,
57  double minTrackPt,
58  int verbosity) {
59  LogDebug("computeJVF") << "<computeJVF>:" << std::endl
60  << " jet: Pt = " << jet.pt() << ", eta = " << jet.eta() << ", phi = " << jet.phi()
61  << std::endl;
62 
63  double trackSum_isVtxAssociated = 0.;
64  double trackSum_isNotVtxAssociated = 0.;
65 
66  std::vector<reco::PFCandidatePtr> pfConsts = jet.getPFConstituents();
67  for (std::vector<reco::PFCandidatePtr>::const_iterator jetConstituent = pfConsts.begin();
68  jetConstituent != pfConsts.end();
69  ++jetConstituent) {
70  if ((*jetConstituent)->charge() == 0)
71  continue;
72 
73  double trackPt = 0.;
74  if ((*jetConstituent)->gsfTrackRef().isNonnull() && (*jetConstituent)->gsfTrackRef().isAvailable())
75  trackPt = (*jetConstituent)->gsfTrackRef()->pt();
76  else if ((*jetConstituent)->trackRef().isNonnull() && (*jetConstituent)->trackRef().isAvailable())
77  trackPt = (*jetConstituent)->trackRef()->pt();
78  else
79  trackPt = (*jetConstituent)->pt();
80 
81  if (trackPt > minTrackPt) {
82  int jetConstituent_vtxAssociationType =
83  noPuUtils::isVertexAssociated((*jetConstituent), pfCandToVertexAssociations, vertices, dZ);
84  //isVertexAssociated_fast(pfCandidateRef, pfCandToVertexAssociations_reversed, *hardScatterVertex, dZcut_, numWarnings_, maxWarnings_);
85  bool jetConstituent_isVtxAssociated = (jetConstituent_vtxAssociationType == noPuUtils::kChHSAssoc);
86  double jetConstituentPt = (*jetConstituent)->pt();
87  if (jetConstituent_isVtxAssociated) {
88  LogDebug("computeJVF") << "associated track: Pt = " << (*jetConstituent)->pt()
89  << ", eta = " << (*jetConstituent)->eta() << ", phi = " << (*jetConstituent)->phi()
90  << std::endl
91  << " (vtxAssociationType = " << jetConstituent_vtxAssociationType << ")" << std::endl;
92 
93  trackSum_isVtxAssociated += jetConstituentPt;
94  } else {
95  LogDebug("computeJVF") << "unassociated track: Pt = " << (*jetConstituent)->pt()
96  << ", eta = " << (*jetConstituent)->eta() << ", phi = " << (*jetConstituent)->phi()
97  << std::endl
98  << " (vtxAssociationType = " << jetConstituent_vtxAssociationType << ")" << std::endl;
99 
100  trackSum_isNotVtxAssociated += jetConstituentPt;
101  }
102  }
103  }
104 
105  double trackSum = trackSum_isVtxAssociated + trackSum_isNotVtxAssociated;
106 
107  double jvf = -1.;
108  if (std::abs(jet.eta()) < 2.5 && trackSum > 5.) {
109  jvf = trackSum_isVtxAssociated / trackSum;
110  }
111 
112  LogDebug("computeJVF") << "trackSum: associated = " << trackSum_isVtxAssociated
113  << ", unassociated = " << trackSum_isNotVtxAssociated << std::endl
114  << " --> JVF = " << jvf << std::endl;
115 
116  return jvf;
117  }
118 } // namespace
119 
121  // get jets
123  evt.getByToken(srcJets_, jets);
124 
125  // get PFCandidates
128 
129  // get PFCandidate-to-vertex associations and "the" hard-scatter vertex
130  edm::Handle<PFCandToVertexAssMap> pfCandToVertexAssociations;
131  evt.getByToken(srcPFCandToVertexAssociations_, pfCandToVertexAssociations);
132 
133  edm::Handle<reco::VertexCollection> hardScatterVertex;
134  evt.getByToken(srcHardScatterVertex_, hardScatterVertex);
135 
136  std::vector<double> jetIdDiscriminants;
137  std::vector<int> jetIdFlags;
138 
139  size_t numJets = jets->size();
140  for (size_t iJet = 0; iJet < numJets; ++iJet) {
141  reco::PFJetRef jet(jets, iJet);
142 
143  double jetJVF = computeJVF(
144  *jet, *pfCandToVertexAssociations, *hardScatterVertex, dZcut_, minTrackPt_, verbosity_ && jet->pt() > 20.);
145  jetIdDiscriminants.push_back(jetJVF);
146 
147  int jetIdFlag = 0;
148  if (jetJVF > JVFcut_)
149  jetIdFlag = 255;
150  else if (jetJVF < -0.5 && neutralJetOption_ == kNeutralJetNoPU)
151  jetIdFlag = 255;
152  jetIdFlags.push_back(jetIdFlag);
153  }
154 
155  auto jetIdDiscriminants_ptr = std::make_unique<edm::ValueMap<double>>();
156  edm::ValueMap<double>::Filler jetIdDiscriminantFiller(*jetIdDiscriminants_ptr);
157  jetIdDiscriminantFiller.insert(jets, jetIdDiscriminants.begin(), jetIdDiscriminants.end());
158  jetIdDiscriminantFiller.fill();
159 
160  auto jetIdFlags_ptr = std::make_unique<edm::ValueMap<int>>();
161  edm::ValueMap<int>::Filler jetIdFlagFiller(*jetIdFlags_ptr);
162  jetIdFlagFiller.insert(jets, jetIdFlags.begin(), jetIdFlags.end());
163  jetIdFlagFiller.fill();
164 
165  evt.put(std::move(jetIdDiscriminants_ptr), "Discriminant");
166  evt.put(std::move(jetIdFlags_ptr), "Id");
167 }
168 
170 
ctppsCommonDQMSource_cfi.verbosity
verbosity
Definition: ctppsCommonDQMSource_cfi.py:14
kNeutralJetPU
Definition: JVFJetIdProducer.cc:19
Handle.h
zmumugammaAnalyzer_cfi.pfCandidates
pfCandidates
Definition: zmumugammaAnalyzer_cfi.py:11
MessageLogger.h
JVFJetIdProducer::srcPFCandToVertexAssociations_
edm::EDGetTokenT< PFCandToVertexAssMap > srcPFCandToVertexAssociations_
Definition: JVFJetIdProducer.h:36
PFCandidate.h
reco::VertexCollection
std::vector< Vertex > VertexCollection
collection of Vertex objects
Definition: VertexFwd.h:9
PFJet.h
PFJetCollection.h
kNeutralJetNoPU
Definition: JVFJetIdProducer.cc:19
JVFJetIdProducer::minTrackPt_
double minTrackPt_
Definition: JVFJetIdProducer.h:38
JVFJetIdProducer::produce
void produce(edm::Event &, const edm::EventSetup &) override
Definition: JVFJetIdProducer.cc:120
singleTopDQM_cfi.jets
jets
Definition: singleTopDQM_cfi.py:42
JVFJetIdProducer::dZcut_
double dZcut_
Definition: JVFJetIdProducer.h:39
edm::Handle< reco::PFJetCollection >
JVFJetIdProducer::JVFcut_
double JVFcut_
Definition: JVFJetIdProducer.h:41
AlignmentTracksFromVertexSelector_cfi.vertices
vertices
Definition: AlignmentTracksFromVertexSelector_cfi.py:5
JVFJetIdProducer::srcPFCandidates_
edm::EDGetTokenT< reco::PFCandidateCollection > srcPFCandidates_
Definition: JVFJetIdProducer.h:35
edm::Ref< PFJetCollection >
MakerMacros.h
Track.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
JVFJetIdProducer
Definition: JVFJetIdProducer.h:25
JVFJetIdProducer::~JVFJetIdProducer
~JVFJetIdProducer() override
Definition: JVFJetIdProducer.cc:48
JVFJetIdProducer.h
noPuUtils::isVertexAssociated
int isVertexAssociated(const reco::PFCandidatePtr &, const PFCandToVertexAssMap &, const reco::VertexCollection &, double)
Definition: NoPileUpMEtAuxFunctions.cc:11
edm::Event::getByToken
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:539
JVFJetIdProducer::JVFJetIdProducer
JVFJetIdProducer(const edm::ParameterSet &)
Definition: JVFJetIdProducer.cc:21
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:233
edm::ParameterSet
Definition: ParameterSet.h:47
deltaR.h
edm::AssociationMap
Definition: AssociationMap.h:48
PackedCandidate.h
noPuUtils::kChHSAssoc
Definition: NoPileUpMEtAuxFunctions.h:22
align_cfg.minTrackPt
minTrackPt
Definition: align_cfg.py:22
GsfTrack.h
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition: Event.h:133
edm::EventSetup
Definition: EventSetup.h:58
AlCaHLTBitMon_QueryRunRegistry.string
string string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
looper.cfg
cfg
Definition: looper.py:296
ValueMap.h
VertexFwd.h
JVFJetIdProducer::verbosity_
int verbosity_
Definition: JVFJetIdProducer.h:45
eostools.move
def move(src, dest)
Definition: eostools.py:511
Vertex.h
metsig::jet
Definition: SignAlgoResolutions.h:47
Exception
Definition: hltDiff.cc:245
reco::PFJet
Jets made from PFObjects.
Definition: PFJet.h:20
Exception.h
JVFJetIdProducer::neutralJetOption_
int neutralJetOption_
Definition: JVFJetIdProducer.h:43
JVFJetIdProducer::srcHardScatterVertex_
edm::EDGetTokenT< reco::VertexCollection > srcHardScatterVertex_
Definition: JVFJetIdProducer.h:37
edm::helper::Filler
Definition: ValueMap.h:22
funct::abs
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
edm::Event
Definition: Event.h:73
listHistos.trackPt
trackPt
Definition: listHistos.py:120
edm::InputTag
Definition: InputTag.h:15
PFCandidateFwd.h
JVFJetIdProducer::srcJets_
edm::EDGetTokenT< reco::PFJetCollection > srcJets_
Definition: JVFJetIdProducer.h:33