CMS 3D CMS Logo

BPHDecayVertex.cc
Go to the documentation of this file.
1 /*
2  * See header file for a description of this class.
3  *
4  * \author Paolo Ronchese INFN Padova
5  *
6  */
7 
8 //-----------------------
9 // This Class' Header --
10 //-----------------------
12 
13 //-------------------------------
14 // Collaborating Class Headers --
15 //-------------------------------
29 
30 //---------------
31 // C++ Headers --
32 //---------------
33 using namespace std;
34 
35 //-------------------
36 // Initializations --
37 //-------------------
38 
39 //----------------
40 // Constructors --
41 //----------------
43  : evSetup(es),
44  oldTracks(true),
45  oldVertex(true),
46  validTks(false),
47  savedFitter(nullptr),
48  savedBS(nullptr),
49  savedPP(nullptr),
50  savedPE(nullptr) {}
51 
53  : evSetup(es),
54  oldTracks(true),
55  oldVertex(true),
56  validTks(false),
57  savedFitter(nullptr),
58  savedBS(nullptr),
59  savedPP(nullptr),
60  savedPE(nullptr) {
61  map<const reco::Candidate*, const reco::Candidate*> iMap;
62  const vector<const reco::Candidate*>& daug = daughters();
63  const vector<Component>& list = ptr->componentList();
64  int i;
65  int n = daug.size();
66  for (i = 0; i < n; ++i) {
67  const reco::Candidate* cand = daug[i];
68  iMap[originalReco(cand)] = cand;
69  }
70  for (i = 0; i < n; ++i) {
71  const Component& c = list[i];
72  searchMap[iMap[c.cand]] = c.searchList;
73  }
74  const vector<BPHRecoConstCandPtr>& dComp = daughComp();
75  int j;
76  int m = dComp.size();
77  for (j = 0; j < m; ++j) {
78  const map<const reco::Candidate*, string>& dMap = dComp[j]->searchMap;
79  searchMap.insert(dMap.begin(), dMap.end());
80  }
81 }
82 
83 //--------------
84 // Destructor --
85 //--------------
87 
88 //--------------
89 // Operations --
90 //--------------
92  if (oldTracks)
93  tTracks();
94  return validTks;
95 }
96 
98  vertex();
99  return validTks && fittedVertex.isValid();
100 }
101 
103  const reco::BeamSpot* bs,
104  const GlobalPoint* priorPos,
105  const GlobalError* priorError) const {
106  if ((fitter == nullptr) && (bs == nullptr) && (priorPos == nullptr) && (priorError == nullptr)) {
107  fitter = savedFitter;
108  bs = savedBS;
109  priorPos = savedPP;
110  priorError = savedPE;
111  }
112  if (oldVertex || (fitter != savedFitter) || (bs != savedBS) || (priorPos != savedPP) || (priorError != savedPE)) {
113  if (fitter != nullptr) {
114  fitVertex(fitter, bs, priorPos, priorError);
115  } else {
116  KalmanVertexFitter kvf(true);
117  fitVertex(&kvf, bs, priorPos, priorError);
118  }
119  }
120  return fittedVertex;
121 }
122 
123 const vector<const reco::Track*>& BPHDecayVertex::tracks() const {
124  if (oldTracks)
125  tTracks();
126  return rTracks;
127 }
128 
130  if (oldTracks)
131  tTracks();
132  map<const reco::Candidate*, const reco::Track*>::const_iterator iter = tkMap.find(cand);
133  map<const reco::Candidate*, const reco::Track*>::const_iterator iend = tkMap.end();
134  return (iter != iend ? iter->second : nullptr);
135 }
136 
137 const vector<reco::TransientTrack>& BPHDecayVertex::transientTracks() const {
138  if (oldTracks)
139  tTracks();
140  return trTracks;
141 }
142 
144  if (oldTracks)
145  tTracks();
146  map<const reco::Candidate*, reco::TransientTrack*>::const_iterator iter = ttMap.find(cand);
147  map<const reco::Candidate*, reco::TransientTrack*>::const_iterator iend = ttMap.end();
148  return (iter != iend ? iter->second : nullptr);
149 }
150 
153 
155  static string dum = "";
156  map<const reco::Candidate*, string>::const_iterator iter = searchMap.find(cand);
157  if (iter != searchMap.end())
158  return iter->second;
159  return dum;
160 }
161 
162 void BPHDecayVertex::addV(const string& name, const reco::Candidate* daug, const string& searchList, double mass) {
163  addP(name, daug, mass);
164  searchMap[daughters().back()] = searchList;
165  return;
166 }
167 
168 void BPHDecayVertex::addV(const string& name, const BPHRecoConstCandPtr& comp) {
169  addP(name, comp);
170  const map<const reco::Candidate*, string>& dMap = comp->searchMap;
171  searchMap.insert(dMap.begin(), dMap.end());
172  return;
173 }
174 
177  oldTracks = oldVertex = true;
178  validTks = false;
179  return;
180 }
181 
183  oldTracks = false;
184  rTracks.clear();
185  trTracks.clear();
186  tkMap.clear();
187  ttMap.clear();
189  evSetup->get<TransientTrackRecord>().get("TransientTrackBuilder", ttB);
190  const vector<const reco::Candidate*>& dL = daughFull();
191  int n = dL.size();
192  trTracks.reserve(n);
193  validTks = true;
194  while (n--) {
195  const reco::Candidate* rp = dL[n];
196  tkMap[rp] = nullptr;
197  ttMap[rp] = nullptr;
198  if (!rp->charge())
199  continue;
200  const reco::Track* tp;
201  const char* searchList = "cfhp";
202  map<const reco::Candidate*, string>::const_iterator iter = searchMap.find(rp);
203  if (iter != searchMap.end())
204  searchList = iter->second.c_str();
206  if (tp == nullptr) {
207  edm::LogPrint("DataNotFound") << "BPHDecayVertex::tTracks: "
208  << "no track for reco::(PF)Candidate";
209  validTks = false;
210  continue;
211  }
212  rTracks.push_back(tp);
213  trTracks.push_back(ttB->build(tp));
214  reco::TransientTrack* ttp = &trTracks.back();
215  tkMap[rp] = tp;
216  ttMap[rp] = ttp;
217  }
218  return;
219 }
220 
222  const reco::BeamSpot* bs,
223  const GlobalPoint* priorPos,
224  const GlobalError* priorError) const {
225  oldVertex = false;
226  savedFitter = fitter;
227  savedBS = bs;
228  savedPP = priorPos;
229  savedPE = priorError;
230  if (oldTracks)
231  tTracks();
232  if (trTracks.size() < 2)
233  return;
234  try {
235  if (bs == nullptr) {
236  if (priorPos == nullptr) {
237  TransientVertex tv = fitter->vertex(trTracks);
238  fittedVertex = tv;
239  } else {
240  if (priorError == nullptr) {
241  TransientVertex tv = fitter->vertex(trTracks, *priorPos);
242  fittedVertex = tv;
243  } else {
244  TransientVertex tv = fitter->vertex(trTracks, *priorPos, *priorError);
245  fittedVertex = tv;
246  }
247  }
248  } else {
249  TransientVertex tv = fitter->vertex(trTracks, *bs);
250  fittedVertex = tv;
251  }
252  } catch (std::exception const&) {
253  reco::Vertex tv;
254  fittedVertex = tv;
255  edm::LogPrint("FitFailed") << "BPHDecayVertex::fitVertex: "
256  << "vertex fit failed";
257  }
258  return;
259 }
reco::Vertex::isValid
bool isValid() const
Tells whether the vertex is valid.
Definition: Vertex.h:72
BPHDecayMomentum::daughComp
virtual const std::vector< BPHRecoConstCandPtr > & daughComp() const
Definition: BPHDecayMomentum.cc:89
BPHDecayVertex::getTrackSearchList
const std::string & getTrackSearchList(const reco::Candidate *cand) const
retrieve track search list
Definition: BPHDecayVertex.cc:154
BPHDecayMomentum::addP
virtual void addP(const std::string &name, const reco::Candidate *daug, double mass=-1.0)
BPHTrackReference.h
mps_fire.i
i
Definition: mps_fire.py:428
MessageLogger.h
funct::false
false
Definition: Factorize.h:29
dqmiodumpmetadata.n
n
Definition: dqmiodumpmetadata.py:28
KalmanVertexFitter.h
BPHDecayVertex::addV
virtual void addV(const std::string &name, const reco::Candidate *daug, const std::string &searchList, double mass)
PFCandidate.h
BPHDecayVertex::getTrack
const reco::Track * getTrack(const reco::Candidate *cand) const
get Track for a daughter
Definition: BPHDecayVertex.cc:129
BPHDecayVertex::getTransientTrack
reco::TransientTrack * getTransientTrack(const reco::Candidate *cand) const
get TransientTrack for a daughter
Definition: BPHDecayVertex.cc:143
edm::LogPrint
Log< level::Warning, true > LogPrint
Definition: MessageLogger.h:130
BPHDecayVertex::getEventSetup
const edm::EventSetup * getEventSetup() const
retrieve EventSetup
Definition: BPHDecayVertex.cc:152
BPHDecayVertex::tTracks
virtual void tTracks() const
Definition: BPHDecayVertex.cc:182
BPHDecayVertex::~BPHDecayVertex
~BPHDecayVertex() override
Definition: BPHDecayVertex.cc:86
TransientTrack.h
BPHDecayVertex::validVertex
virtual bool validVertex() const
Definition: BPHDecayVertex.cc:97
AlCaHLTBitMon_QueryRunRegistry.comp
comp
Definition: AlCaHLTBitMon_QueryRunRegistry.py:249
BPHDecayVertex::BPHDecayVertex
BPHDecayVertex(const BPHDecayVertex &x)=delete
BPHDecayVertex::oldVertex
bool oldVertex
Definition: BPHDecayVertex.h:111
VertexFitter< 5 >
BPHDecayVertex::fittedVertex
reco::Vertex fittedVertex
Definition: BPHDecayVertex.h:117
BPHDecayVertex::vertex
virtual const reco::Vertex & vertex(VertexFitter< 5 > *fitter=nullptr, const reco::BeamSpot *bs=nullptr, const GlobalPoint *priorPos=nullptr, const GlobalError *priorError=nullptr) const
get reconstructed vertex
Definition: BPHDecayVertex.cc:102
cms::cuda::bs
bs
Definition: HistoContainer.h:127
BPHTrackReference::getTrack
static const reco::Track * getTrack(const reco::Candidate &rc, const char *modeList="cfhbpmnigset", char *modeFlag=nullptr)
Definition: BPHTrackReference.h:60
Track.h
edm::EventSetup::get
T get() const
Definition: EventSetup.h:80
TrackFwd.h
reco::Candidate::charge
virtual int charge() const =0
electric charge
BPHDecayVertex::savedPE
GlobalError const * savedPE
Definition: BPHDecayVertex.h:121
visualization-live-secondInstance_cfg.m
m
Definition: visualization-live-secondInstance_cfg.py:72
reco::BeamSpot
Definition: BeamSpot.h:21
TransientTrackRecord
Definition: TransientTrackRecord.h:11
BPHDecayVertex::tkMap
std::map< const reco::Candidate *, const reco::Track * > tkMap
Definition: BPHDecayVertex.h:115
reco::Track
Definition: Track.h:27
edm::ESHandle< TransientTrackBuilder >
BPHDecayVertex::transientTracks
const std::vector< reco::TransientTrack > & transientTracks() const
get list of TransientTracks
Definition: BPHDecayVertex.cc:137
Point3DBase< float, GlobalTag >
BPHDecayVertex::setNotUpdated
void setNotUpdated() const override
Definition: BPHDecayVertex.cc:175
cmsswSequenceInfo.tp
tp
Definition: cmsswSequenceInfo.py:17
BPHDecayVertex::validTracks
virtual bool validTracks() const
check for valid reconstructed vertex
Definition: BPHDecayVertex.cc:91
BPHDecayVertex
Definition: BPHDecayVertex.h:43
BPHDecayVertex::oldTracks
bool oldTracks
Definition: BPHDecayVertex.h:110
cppFunctionSkipper.exception
exception
Definition: cppFunctionSkipper.py:10
funct::true
true
Definition: Factorize.h:173
TransientTrackBuilder.h
VertexFitter::vertex
virtual CachingVertex< N > vertex(const std::vector< reco::TransientTrack > &tracks) const =0
BPHDecayVertex::evSetup
const edm::EventSetup * evSetup
Definition: BPHDecayVertex.h:104
cand
Definition: decayParser.h:32
BPHDecayVertex::validTks
bool validTks
Definition: BPHDecayVertex.h:112
BPHDecayVertex::trTracks
std::vector< reco::TransientTrack > trTracks
Definition: BPHDecayVertex.h:114
newFWLiteAna.searchList
searchList
Definition: newFWLiteAna.py:119
BPHDecayMomentum::Component
Definition: BPHDecayMomentum.h:101
BPHDecayVertex::rTracks
std::vector< const reco::Track * > rTracks
Definition: BPHDecayVertex.h:113
GlobalErrorBase< double, ErrorMatrixTag >
TransientVertex
Definition: TransientVertex.h:18
edm::EventSetup
Definition: EventSetup.h:57
BPHDecayMomentum::setNotUpdated
virtual void setNotUpdated() const
Definition: BPHDecayMomentum.cc:149
BPHRecoBuilder.h
HltBtagPostValidation_cff.c
c
Definition: HltBtagPostValidation_cff.py:31
TransientTrackRecord.h
get
#define get
BPHDecayVertex::ttMap
std::map< const reco::Candidate *, reco::TransientTrack * > ttMap
Definition: BPHDecayVertex.h:116
reco::Candidate
Definition: Candidate.h:27
TransientVertex.h
std
Definition: JetResolutionObject.h:76
BPHDecayMomentum::originalReco
virtual const reco::Candidate * originalReco(const reco::Candidate *daug) const
get the original particle from the clone
Definition: BPHDecayMomentum.cc:82
reco::TransientTrack
Definition: TransientTrack.h:19
BPHDecayVertex::tracks
const std::vector< const reco::Track * > & tracks() const
get list of Tracks
Definition: BPHDecayVertex.cc:123
BPHDecayVertex::fitVertex
virtual void fitVertex(VertexFitter< 5 > *fitter, const reco::BeamSpot *bs, const GlobalPoint *priorPos, const GlobalError *priorError) const
Definition: BPHDecayVertex.cc:221
BPHDecayMomentum::daughFull
virtual const std::vector< const reco::Candidate * > & daughFull() const
Definition: BPHDecayMomentum.cc:75
BPHRecoCandidate.h
EgHLTOffHistBins_cfi.mass
mass
Definition: EgHLTOffHistBins_cfi.py:34
Skims_PA_cff.name
name
Definition: Skims_PA_cff.py:17
EventSetup.h
BPHDecayVertex::savedFitter
VertexFitter< 5 > * savedFitter
Definition: BPHDecayVertex.h:118
BPHDecayVertex.h
TransientTrackBuilder::build
reco::TransientTrack build(const reco::Track *p) const
Definition: TransientTrackBuilder.cc:20
BPHDecayMomentum::daughters
virtual const std::vector< const reco::Candidate * > & daughters() const
Definition: BPHDecayMomentum.cc:73
dqmiolumiharvest.j
j
Definition: dqmiolumiharvest.py:66
BPHDecayMomentum::componentList
const std::vector< Component > & componentList() const
Definition: BPHDecayMomentum.cc:118
BPHDecayVertex::savedBS
reco::BeamSpot const * savedBS
Definition: BPHDecayVertex.h:119
BPHDecayMomentum::dMap
std::map< std::string, const reco::Candidate * > dMap
Definition: BPHDecayMomentum.h:147
BPHDecayVertex::savedPP
GlobalPoint const * savedPP
Definition: BPHDecayVertex.h:120
reco::Vertex
Definition: Vertex.h:35
BPHRecoConstCandPtr
BPHGenericPtr< const BPHRecoCandidate >::type BPHRecoConstCandPtr
Definition: BPHRecoCandidatePtr.h:9
KalmanVertexFitter
Definition: KalmanVertexFitter.h:22
BPHDecayVertex::searchMap
std::map< const reco::Candidate *, std::string > searchMap
Definition: BPHDecayVertex.h:107