CMS 3D CMS Logo

MultiVertexBSeeder.cc
Go to the documentation of this file.
2 // #include "RecoVertex/AdaptiveVertexFit/interface/AdaptiveVertexFitter.h"
4 // #include "RecoVertex/VertexTools/interface/BeamSpot.h"
8 // #include "CommonTools/Clustering1D/interface/MultiClusterizer1D.h"
12 
13 // #define MVBS_DEBUG
14 #ifdef MVBS_DEBUG
15 #include <map>
16 #include "RecoVertex/MultiVertexFit/interface/DebuggingHarvester.h"
17 #endif
18 
19 using namespace std;
20 
21 namespace {
22  vector<reco::TransientTrack> convert(const vector<const reco::TransientTrack*>& ptrs) {
23  vector<reco::TransientTrack> ret;
24  for (vector<const reco::TransientTrack*>::const_iterator i = ptrs.begin(); i != ptrs.end(); ++i) {
25  ret.push_back(**i);
26  }
27  return ret;
28  }
29 
30 #ifndef __clang__
31  inline GlobalPoint& operator+=(GlobalPoint& a, const GlobalPoint& b) {
32  a = GlobalPoint(a.x() + b.x(), a.y() + b.y(), a.z() + b.z());
33  return a;
34  }
35 #endif
36 
37  inline GlobalPoint& operator/=(GlobalPoint& a, float b) {
38  a = GlobalPoint(a.x() / b, a.y() / b, a.z() / b);
39  return a;
40  }
41 
42 #ifndef __clang__
43  inline bool element(const reco::TransientTrack& rt, const TransientVertex& rv) {
44  const vector<reco::TransientTrack> trks = rv.originalTracks();
45  for (vector<reco::TransientTrack>::const_iterator i = trks.begin(); i != trks.end(); ++i) {
46  if (rt == (*i))
47  return true;
48  };
49  return false;
50  }
51 #endif
52 
53  GlobalPoint toPoint(const GlobalVector& v) { return GlobalPoint(v.x(), v.y(), v.z()); }
54 
55  GlobalVector toVector(const GlobalPoint& v) { return GlobalVector(v.x(), v.y(), v.z()); }
56 
57  GlobalPoint computeJetOrigin(const vector<reco::TransientTrack>& trks) {
59  vector<ModeFinder3d::PointAndDistance> input;
60  for (vector<reco::TransientTrack>::const_iterator i = trks.begin(); i != trks.end(); ++i) {
61  input.push_back(ModeFinder3d::PointAndDistance(i->impactPointState().globalPosition(), 1.));
62  }
63  return f(input);
64  }
65 
66  GlobalVector computeJetDirection(const vector<reco::TransientTrack>& trks) {
68  vector<ModeFinder3d::PointAndDistance> input;
69  for (vector<reco::TransientTrack>::const_iterator i = trks.begin(); i != trks.end(); ++i) {
70  input.push_back(ModeFinder3d::PointAndDistance(toPoint(i->impactPointState().globalMomentum()), 1.));
71  }
73  pt /= pt.mag();
74  return toVector(pt);
75  }
76 
77  GlobalTrajectoryParameters computeJetTrajectory(const vector<reco::TransientTrack>& trks) {
84  if (trks.empty())
86 
87  GlobalVector mom = computeJetDirection(trks);
88  GlobalPoint pos = computeJetOrigin(trks);
89 
90  GlobalTrajectoryParameters ret(pos, mom, 0, &(trks[0].impactPointState().globalParameters().magneticField()));
91 #ifdef MVBS_DEBUG
92  DebuggingHarvester("out.txt").save(ret, "p<sub>tot</sub>");
93 #endif
94  return ret;
95  }
96 
97  vector<Cluster1D<reco::TransientTrack> > computeIPs(const vector<reco::TransientTrack>& trks) {
98  GlobalTrajectoryParameters jet = computeJetTrajectory(trks);
101  vector<Cluster1D<reco::TransientTrack> > pts;
102  for (vector<reco::TransientTrack>::const_iterator i = trks.begin(); i != trks.end(); ++i) {
103  bool status = ttmd.calculate(axis, *(i->impactPointState().freeState()));
104  if (status) {
105  pair<GlobalPoint, GlobalPoint> pt = ttmd.points();
106  double d = (pt.first - pt.second).mag();
107  double w = 1. / (0.002 + d); // hard coded weights
108  double s = (pt.first - axis.position()).mag();
109  Measurement1D ms(s, 1.0);
110  vector<const reco::TransientTrack*> trk;
111  trk.push_back(&(*i));
112  pts.push_back(Cluster1D<reco::TransientTrack>(ms, trk, w));
113  }
114  }
115  /*
116  #ifdef MVBS_DEBUG
117  map < string, harvest::MultiType > attrs;
118  attrs["point:mag"]=0.5;
119  attrs["point:color"]="khaki";
120  DebuggingHarvester("out.txt").save ( pts, jet, attrs, "ip" );
121  #endif
122  */
123  return pts;
124  }
125 
126 #ifndef __clang__
127  inline GlobalPoint computePos(const GlobalTrajectoryParameters& jet, double s) {
128  GlobalPoint ret = jet.position();
129  ret += s * jet.momentum();
130  return ret;
131  }
132 #endif
133 
134  TransientVertex pseudoVertexFit(const Cluster1D<reco::TransientTrack>& src,
135  bool ascending = false,
136  bool kalmanfit = false) {
137  // cout << "[MultiVertexBSeeder] debug: pseudoVertexFit with " << flush;
138  vector<const reco::TransientTrack*> trkptrs = src.tracks();
139  vector<reco::TransientTrack> trks = convert(trkptrs);
140  // cout << trks.size() << " tracks.";
141  GlobalPoint gp;
142  GlobalError ge;
143  if (kalmanfit) {
145  gp = v.position();
146  }
149  float w = 1.0;
150  float r = 0.5;
151  if (ascending) {
152  w = pow((float)0.5, (int)(trks.size() - 1));
153  r = 2.0;
154  };
155  for (vector<reco::TransientTrack>::const_iterator i = trks.begin(); i != trks.end(); ++i) {
156  mp[*i] = w;
157  w *= r;
158  }
159  ret.weightMap(mp);
160  // cout << "[MultiVertexBSeeder] debug: return pseudoVertexFit with " << endl;
161  return ret;
162  }
163 
164  /* TransientVertex kalmanVertexFit ( const Cluster1D < reco::TransientTrack > & src )
165  {
166  KalmanVertexFitter fitter;
167  vector < const reco::TransientTrack * > trkptrs=src.tracks();
168  vector < reco::TransientTrack > trks = convert ( trkptrs );
169  return fitter.vertex ( trks );
170  return TransientVertex();
171  }*/
172 } // namespace
173 
175 
177 
178 vector<TransientVertex> MultiVertexBSeeder::vertices(const vector<reco::TransientTrack>& trks,
179  const reco::BeamSpot& s) const {
180  return vertices(trks);
181 }
182 
183 vector<TransientVertex> MultiVertexBSeeder::vertices(const vector<reco::TransientTrack>& trks) const {
184  vector<Cluster1D<reco::TransientTrack> > ips = computeIPs(trks);
185  /*
186  FsmwClusterizer1D < reco::TransientTrack > fsmw ( .4, theNSigma );
187  MultiClusterizer1D<reco::TransientTrack> finder ( fsmw );
188  */
190 
191  pair<vector<Cluster1D<reco::TransientTrack> >, vector<const reco::TransientTrack*> > res;
192  res = finder(ips);
193 #ifdef MVBS_DEBUG
194  // need to compute jet trajectory again :-(
195  GlobalTrajectoryParameters jet = computeJetTrajectory(trks);
196  map<string, harvest::MultiType> attrs;
197  attrs["point:mag"] = 0.75;
198  attrs["point:color"] = "blue";
199  attrs["point:name"] = "mode";
200  DebuggingHarvester("out.txt").save(res.first, jet, attrs, "mode");
201 #endif
202 
203  vector<TransientVertex> ret;
204  for (vector<Cluster1D<reco::TransientTrack> >::const_iterator i = res.first.begin(); i != res.first.end(); ++i) {
205  ret.push_back(pseudoVertexFit(*i,
206  i != res.first.begin(),
207  /* kalman fit*/ true));
208  }
209  return ret;
210 }
211 
212 #ifdef MVBS_DEBUG
213 #undef MVBS_DEBUG
214 #endif
Vector3DBase
Definition: Vector3DBase.h:8
runTheMatrix.ret
ret
prodAgent to be discontinued
Definition: runTheMatrix.py:542
KalmanVertexFitter::vertex
CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &tracks) const override
Definition: KalmanVertexFitter.h:49
MultiVertexBSeeder
Definition: MultiVertexBSeeder.h:12
Measurement1D
Definition: Measurement1D.h:11
mps_fire.i
i
Definition: mps_fire.py:428
Cluster1D
Definition: Cluster1D.h:13
input
static const std::string input
Definition: EdmProvDump.cc:48
MessageLogger.h
KalmanVertexFitter.h
HLT_FULL_cff.finder
finder
Definition: HLT_FULL_cff.py:51931
f
double f[11][100]
Definition: MuScleFitUtils.cc:78
DiDispStaMuonMonitor_cfi.pt
pt
Definition: DiDispStaMuonMonitor_cfi.py:39
mps_update.status
status
Definition: mps_update.py:69
hcal_runs.rt
rt
Definition: hcal_runs.py:76
pos
Definition: PixelAliasList.h:18
TwoTrackMinimumDistance
Definition: TwoTrackMinimumDistance.h:20
FsmwModeFinder3d.h
OutermostClusterizer1D.h
GlobalVector
Global3DVector GlobalVector
Definition: GlobalVector.h:10
findQualityFiles.v
v
Definition: findQualityFiles.py:179
HLT_FULL_cff.magneticField
magneticField
Definition: HLT_FULL_cff.py:348
TwoTrackMinimumDistance.h
TwoTrackMinimumDistance::calculate
bool calculate(const TrajectoryStateOnSurface &sta, const TrajectoryStateOnSurface &stb) override
Definition: TwoTrackMinimumDistance.cc:83
MultiVertexBSeeder::clone
MultiVertexBSeeder * clone() const override
Definition: MultiVertexBSeeder.cc:174
alignCSCRings.s
s
Definition: alignCSCRings.py:92
createJobs.theNSigma
theNSigma
Definition: createJobs.py:313
w
const double w
Definition: UKUtility.cc:23
MultiVertexBSeeder.h
reco::BeamSpot
Definition: BeamSpot.h:21
GlobalTrajectoryParameters
Definition: GlobalTrajectoryParameters.h:15
GlobalPoint
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
Point3DBase< float, GlobalTag >
b
double b
Definition: hdecay.h:118
TwoTrackMinimumDistance::points
std::pair< GlobalPoint, GlobalPoint > points() const override
Definition: TwoTrackMinimumDistance.cc:75
cmspython3::toVector
std::vector< T > toVector(pybind11::list &l)
Definition: PyBind11Wrapper.h:24
fileCollector.convert
def convert(infile, ofile)
Definition: fileCollector.py:47
runTauDisplay.gp
gp
Definition: runTauDisplay.py:431
TransientVertex::TransientTrackToFloatMap
std::map< reco::TransientTrack, float > TransientTrackToFloatMap
Definition: TransientVertex.h:21
a
double a
Definition: hdecay.h:119
TrackRefitter_38T_cff.src
src
Definition: TrackRefitter_38T_cff.py:24
OutermostClusterizer1D
Definition: OutermostClusterizer1D.h:20
trackerHitRTTI::vector
Definition: trackerHitRTTI.h:21
GlobalError.h
GlobalErrorBase< double, ErrorMatrixTag >
TransientVertex
Definition: TransientVertex.h:18
res
Definition: Electron.h:6
RPCpg::pts
static const double pts[33]
Definition: Constants.h:30
ModeFinder3d::PointAndDistance
std::pair< GlobalPoint, float > PointAndDistance
Definition: ModeFinder3d.h:16
alignCSCRings.r
r
Definition: alignCSCRings.py:93
mag
T mag() const
The vector magnitude. Equivalent to sqrt(vec.mag2())
Definition: Basic3DVectorLD.h:127
std
Definition: JetResolutionObject.h:76
reco::TransientTrack
Definition: TransientTrack.h:19
FreeTrajectoryState
Definition: FreeTrajectoryState.h:27
metsig::jet
Definition: SignAlgoResolutions.h:47
MultiVertexBSeeder::MultiVertexBSeeder
MultiVertexBSeeder(double nsigma=50.)
Definition: MultiVertexBSeeder.cc:176
TransientVertex::originalTracks
std::vector< reco::TransientTrack > const & originalTracks() const
Definition: TransientVertex.h:200
operator/=
Basic3DVector & operator/=(T t)
Scaling by a scalar value (division)
Definition: Basic3DVectorLD.h:203
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
ztail.d
d
Definition: ztail.py:151
hltEgammaHLTExtra_cfi.trks
trks
Definition: hltEgammaHLTExtra_cfi.py:43
MultiVertexBSeeder::vertices
std::vector< TransientVertex > vertices(const std::vector< reco::TransientTrack > &) const override
Definition: MultiVertexBSeeder.cc:183
FsmwClusterizer1D.h
operator+=
Basic3DVector & operator+=(const Basic3DVector< U > &p)
Definition: Basic3DVectorLD.h:174
KalmanVertexFitter
Definition: KalmanVertexFitter.h:22
FsmwModeFinder3d
Definition: FsmwModeFinder3d.h:12