CMS 3D CMS Logo

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