CMS 3D CMS Logo

CombinedSVComputer.cc
Go to the documentation of this file.
2 
3 using namespace reco;
4 
6  edm::ParameterSet psetCopy(pset);
7  psetCopy.addParameter<double>("jetDeltaRMax", 99999.0);
8  return psetCopy;
9 }
10 
12  : trackFlip(params.getParameter<bool>("trackFlip")),
13  vertexFlip(params.getParameter<bool>("vertexFlip")),
14  charmCut(params.getParameter<double>("charmCut")),
15  sortCriterium(TrackSorting::getCriterium(params.getParameter<std::string>("trackSort"))),
16  trackSelector(params.getParameter<edm::ParameterSet>("trackSelection")),
17  trackNoDeltaRSelector(dropDeltaR(params.getParameter<edm::ParameterSet>("trackSelection"))),
18  trackPseudoSelector(params.getParameter<edm::ParameterSet>("trackPseudoSelection")),
19  pseudoMultiplicityMin(params.getParameter<unsigned int>("pseudoMultiplicityMin")),
20  trackMultiplicityMin(params.getParameter<unsigned int>("trackMultiplicityMin")),
21  minTrackWeight(params.getParameter<double>("minimumTrackWeight")),
22  useTrackWeights(params.getParameter<bool>("useTrackWeights")),
23  vertexMassCorrection(params.getParameter<bool>("correctVertexMass")),
24  pseudoVertexV0Filter(params.getParameter<edm::ParameterSet>("pseudoVertexV0Filter")),
25  trackPairV0Filter(params.getParameter<edm::ParameterSet>("trackPairV0Filter")) {}
26 
27 inline double CombinedSVComputer::flipValue(double value, bool vertex) const {
28  return (vertex ? vertexFlip : trackFlip) ? -value : value;
29 }
30 
33  if (vertex ? vertexFlip : trackFlip) {
34  range.begin = size - 1;
35  range.end = -1;
36  range.increment = -1;
37  } else {
38  range.begin = 0;
39  range.end = size;
40  range.increment = +1;
41  }
42 
43  return range;
44 }
45 
46 const btag::TrackIPData &CombinedSVComputer::threshTrack(const CandIPTagInfo &trackIPTagInfo,
47  const btag::SortCriteria sort,
48  const reco::Jet &jet,
49  const GlobalPoint &pv) const {
50  const CandIPTagInfo::input_container &tracks = trackIPTagInfo.selectedTracks();
51  const std::vector<btag::TrackIPData> &ipData = trackIPTagInfo.impactParameterData();
52  std::vector<std::size_t> indices = trackIPTagInfo.sortedIndexes(sort);
53 
54  IterationRange range = flipIterate(indices.size(), false);
55  TrackKinematics kin;
56  range_for(i, range) {
57  std::size_t idx = indices[i];
58  const btag::TrackIPData &data = ipData[idx];
59  const CandidatePtr &track = tracks[idx];
60 
61  if (!trackNoDeltaRSelector(track, data, jet, pv))
62  continue;
63 
64  kin.add(track);
65  if (kin.vectorSum().M() > charmCut)
66  return data;
67  }
68  if (trackFlip) {
69  static const btag::TrackIPData dummy = {GlobalPoint(),
70  GlobalPoint(),
71  Measurement1D(1.0, 1.0),
72  Measurement1D(1.0, 1.0),
73  Measurement1D(1.0, 1.0),
74  Measurement1D(1.0, 1.0),
75  0.};
76  return dummy;
77  } else {
78  static const btag::TrackIPData dummy = {GlobalPoint(),
79  GlobalPoint(),
80  Measurement1D(-1.0, 1.0),
81  Measurement1D(-1.0, 1.0),
82  Measurement1D(-1.0, 1.0),
83  Measurement1D(-1.0, 1.0),
84  0.};
85  return dummy;
86  }
87 }
88 
89 const btag::TrackIPData &CombinedSVComputer::threshTrack(const TrackIPTagInfo &trackIPTagInfo,
90  const btag::SortCriteria sort,
91  const reco::Jet &jet,
92  const GlobalPoint &pv) const {
93  const edm::RefVector<TrackCollection> &tracks = trackIPTagInfo.selectedTracks();
94  const std::vector<btag::TrackIPData> &ipData = trackIPTagInfo.impactParameterData();
95  std::vector<std::size_t> indices = trackIPTagInfo.sortedIndexes(sort);
96 
97  IterationRange range = flipIterate(indices.size(), false);
98  TrackKinematics kin;
99  range_for(i, range) {
100  std::size_t idx = indices[i];
101  const btag::TrackIPData &data = ipData[idx];
102  const Track &track = *tracks[idx];
103 
104  if (!trackNoDeltaRSelector(track, data, jet, pv))
105  continue;
106 
107  kin.add(track);
108  if (kin.vectorSum().M() > charmCut)
109  return data;
110  }
111 
112  if (trackFlip) {
113  static const btag::TrackIPData dummy = {GlobalPoint(),
114  GlobalPoint(),
115  Measurement1D(1.0, 1.0),
116  Measurement1D(1.0, 1.0),
117  Measurement1D(1.0, 1.0),
118  Measurement1D(1.0, 1.0),
119  0.};
120  return dummy;
121  } else {
122  static const btag::TrackIPData dummy = {GlobalPoint(),
123  GlobalPoint(),
124  Measurement1D(-1.0, 1.0),
125  Measurement1D(-1.0, 1.0),
126  Measurement1D(-1.0, 1.0),
127  Measurement1D(-1.0, 1.0),
128  0.};
129  return dummy;
130  }
131 }
132 
134  const SecondaryVertexTagInfo &svInfo) const {
135  using namespace ROOT::Math;
136 
137  edm::RefToBase<Jet> jet = ipInfo.jet();
138  math::XYZVector jetDir = jet->momentum().Unit();
140 
141  TrackKinematics vertexKinematics;
142 
143  double vtx_track_ptSum = 0.;
144  double vtx_track_ESum = 0.;
145 
146  // the following is specific depending on the type of vertex
147  int vtx = -1;
148  unsigned int numberofvertextracks = 0;
149 
150  IterationRange range = flipIterate(svInfo.nVertices(), true);
151  range_for(i, range) {
152  numberofvertextracks = numberofvertextracks + (svInfo.secondaryVertex(i)).nTracks();
153 
154  const Vertex &vertex = svInfo.secondaryVertex(i);
155  bool hasRefittedTracks = vertex.hasRefittedTracks();
156  for (reco::Vertex::trackRef_iterator track = vertex.tracks_begin(); track != vertex.tracks_end(); track++) {
157  double w = vertex.trackWeight(*track);
158  if (w < minTrackWeight)
159  continue;
160  if (hasRefittedTracks) {
161  const Track actualTrack = vertex.refittedTrack(*track);
162  vertexKinematics.add(actualTrack, w);
163  vars.insert(btau::trackEtaRel, reco::btau::etaRel(jetDir, actualTrack.momentum()), true);
164  if (vtx < 0) // calculate this only for the first vertex
165  {
166  vtx_track_ptSum += std::sqrt(actualTrack.momentum().Perp2());
167  vtx_track_ESum += std::sqrt(actualTrack.momentum().Mag2() + ROOT::Math::Square(ParticleMasses::piPlus));
168  }
169  } else {
170  vertexKinematics.add(**track, w);
171  vars.insert(btau::trackEtaRel, reco::btau::etaRel(jetDir, (*track)->momentum()), true);
172  if (vtx < 0) // calculate this only for the first vertex
173  {
174  vtx_track_ptSum += std::sqrt((*track)->momentum().Perp2());
175  vtx_track_ESum += std::sqrt((*track)->momentum().Mag2() + ROOT::Math::Square(ParticleMasses::piPlus));
176  }
177  }
178  }
179 
180  if (vtx < 0)
181  vtx = i;
182  }
183  if (vtx >= 0) {
184  vars.insert(btau::vertexNTracks, numberofvertextracks, true);
185  vars.insert(btau::vertexFitProb, (svInfo.secondaryVertex(vtx)).normalizedChi2(), true);
186  }
187 
188  // after we collected vertex information we let the common code complete the job
189  fillCommonVariables(vars, vertexKinematics, ipInfo, svInfo, vtx_track_ptSum, vtx_track_ESum);
190 
191  vars.finalize();
192  return vars;
193 }
194 
196  const CandSecondaryVertexTagInfo &svInfo) const {
197  using namespace ROOT::Math;
198 
199  edm::RefToBase<Jet> jet = ipInfo.jet();
200  math::XYZVector jetDir = jet->momentum().Unit();
202 
203  TrackKinematics vertexKinematics;
204 
205  double vtx_track_ptSum = 0.;
206  double vtx_track_ESum = 0.;
207 
208  // the following is specific depending on the type of vertex
209  int vtx = -1;
210  unsigned int numberofvertextracks = 0;
211 
212  IterationRange range = flipIterate(svInfo.nVertices(), true);
213  range_for(i, range) {
214  numberofvertextracks = numberofvertextracks + (svInfo.secondaryVertex(i)).numberOfSourceCandidatePtrs();
215 
217  const std::vector<CandidatePtr> &tracks = vertex.daughterPtrVector();
218  for (std::vector<CandidatePtr>::const_iterator track = tracks.begin(); track != tracks.end(); ++track) {
219  vertexKinematics.add(*track);
220  vars.insert(btau::trackEtaRel, reco::btau::etaRel(jetDir, (*track)->momentum()), true);
221  if (vtx < 0) // calculate this only for the first vertex
222  {
223  vtx_track_ptSum += std::sqrt((*track)->momentum().Perp2());
224  vtx_track_ESum += std::sqrt((*track)->momentum().Mag2() + ROOT::Math::Square(ParticleMasses::piPlus));
225  }
226  }
227 
228  if (vtx < 0)
229  vtx = i;
230  }
231  if (vtx >= 0) {
232  vars.insert(btau::vertexNTracks, numberofvertextracks, true);
233  vars.insert(btau::vertexFitProb, (svInfo.secondaryVertex(vtx)).vertexNormalizedChi2(), true);
234  }
235 
236  // after we collected vertex information we let the common code complete the job
237  fillCommonVariables(vars, vertexKinematics, ipInfo, svInfo, vtx_track_ptSum, vtx_track_ESum);
238 
239  vars.finalize();
240  return vars;
241 }
size
Write out results.
const double piPlus
Definition: ParticleMasses.h:9
reco::btag::SortCriteria getCriterium(const std::string &name)
Definition: TrackSorting.cc:11
const unsigned int nTracks(const reco::Vertex &sv)
trackSelector
Tracks selection.
const double w
Definition: UKUtility.cc:23
trackRef_iterator tracks_end() const
last iterator over tracks
Definition: Vertex.cc:73
void add(const reco::Track &track, double weight=1.0)
const VTX & secondaryVertex(unsigned int index) const
Base class for all types of Jets.
Definition: Jet.h:20
double etaRel(const math::XYZVector &dir, const math::XYZVector &track)
reco::TrackSelector trackNoDeltaRSelector
bool hasRefittedTracks() const
Checks whether refitted tracks are stored.
Definition: Vertex.h:167
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
const Container & selectedTracks() const
Definition: IPTagInfo.h:99
static edm::ParameterSet dropDeltaR(const edm::ParameterSet &pset)
virtual reco::TaggingVariableList operator()(const reco::TrackIPTagInfo &ipInfo, const reco::SecondaryVertexTagInfo &svInfo) const
CombinedSVComputer(const edm::ParameterSet &params)
const Vector & momentum() const
track momentum vector
Definition: TrackBase.h:629
virtual const daughters & daughterPtrVector() const
references to daughtes
T sqrt(T t)
Definition: SSEVec.h:19
void addParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:124
def pv(vc)
Definition: MetAnalyzer.py:7
float trackWeight(const TREF &r) const
returns the weight with which a Track has contributed to the vertex-fit.
Definition: Vertex.h:84
Definition: value.py:1
std::vector< size_t > sortedIndexes(btag::SortCriteria mode=reco::btag::IP3DSig) const
Definition: IPTagInfo.h:231
IterationRange flipIterate(int size, bool vertex) const
const std::vector< btag::TrackIPData > & impactParameterData() const
Definition: IPTagInfo.h:90
#define range_for(i, x)
XYZVectorD XYZVector
spatial vector with cartesian internal representation
Definition: Vector3D.h:31
double flipValue(double value, bool vertex) const
edm::ParameterSet dropDeltaR(const edm::ParameterSet &pset) const
const reco::btag::TrackIPData & threshTrack(const reco::CandIPTagInfo &trackIPTagInfo, const reco::btag::SortCriteria sort, const reco::Jet &jet, const GlobalPoint &pv) const
void fillCommonVariables(reco::TaggingVariableList &vars, reco::TrackKinematics &vertexKinematics, const IPTI &ipInfo, const SVTI &svInfo, double &vtx_track_ptSum, double &vtx_track_ESum) const
fixed size matrix
HLT enums.
char data[epos_bytes_allocation]
Definition: EPOS_Wrapper.h:79
Track refittedTrack(const TrackBaseRef &track) const
Definition: Vertex.cc:106
Container input_container
Definition: IPTagInfo.h:50
vars
Definition: DeepTauId.cc:158
trackRef_iterator tracks_begin() const
first iterator over tracks
Definition: Vertex.cc:71
tuple useTrackWeights
Definition: alignBH_cfg.py:24
std::vector< TrackBaseRef >::const_iterator trackRef_iterator
The iteratator for the vector<TrackRef>
Definition: Vertex.h:37
void insert(const TaggingVariable &variable, bool delayed=false)