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 #include <iostream>
34 
35 using namespace std;
36 
37 //-------------------
38 // Initializations --
39 //-------------------
40 
41 
42 //----------------
43 // Constructors --
44 //----------------
46  evSetup( es ),
47  oldTracks( true ),
48  oldVertex( true ),
49  validTks( false ) {
50 }
51 
52 
54  const edm::EventSetup* es ):
55  evSetup( es ),
56  oldTracks( true ),
57  oldVertex( true ),
58  validTks( false ) {
59  map<const reco::Candidate*,const reco::Candidate*> iMap;
60  const vector<const reco::Candidate*>& daug = daughters();
61  const vector<Component>& list = ptr->componentList();
62  int i;
63  int n = daug.size();
64  for ( i = 0; i < n; ++i ) {
65  const reco::Candidate* cand = daug[i];
66  iMap[originalReco( cand )] = cand;
67  }
68  for ( i = 0; i < n; ++i ) {
69  const Component& c = list[i];
70  searchMap[iMap[c.cand]] = c.searchList;
71  }
72  const vector<BPHRecoConstCandPtr>& dComp = daughComp();
73  int j;
74  int m = dComp.size();
75  for ( j = 0; j < m; ++j ) {
76  const map<const reco::Candidate*,string>& dMap = dComp[j]->searchMap;
77  searchMap.insert( dMap.begin(), dMap.end() );
78  }
79 }
80 
81 //--------------
82 // Destructor --
83 //--------------
85 }
86 
87 //--------------
88 // Operations --
89 //--------------
91  if ( oldVertex ) fitVertex();
92  return validTks;
93 }
94 
95 
97  if ( oldVertex ) fitVertex();
98  return validTks && fittedVertex.isValid();
99 }
100 
101 
103  if ( oldVertex ) fitVertex();
104  return fittedVertex;
105 }
106 
107 
108 const vector<const reco::Track*>& BPHDecayVertex::tracks() const {
109  if ( oldTracks ) tTracks();
110  return rTracks;
111 }
112 
113 
115  const reco::Candidate* cand ) const {
116  if ( oldTracks ) tTracks();
117  map<const reco::Candidate*,
118  const reco::Track*>::const_iterator iter = tkMap.find( cand );
119  map<const reco::Candidate*,
120  const reco::Track*>::const_iterator iend = tkMap.end();
121  return ( iter != iend ? iter->second : nullptr );
122 }
123 
124 
125 const vector<reco::TransientTrack>& BPHDecayVertex::transientTracks() const {
126  if ( oldTracks ) tTracks();
127  return trTracks;
128 }
129 
130 
132  const reco::Candidate* cand ) const {
133  if ( oldTracks ) tTracks();
134  map<const reco::Candidate*,
135  reco::TransientTrack*>::const_iterator iter = ttMap.find( cand );
136  map<const reco::Candidate*,
137  reco::TransientTrack*>::const_iterator iend = ttMap.end();
138  return ( iter != iend ? iter->second : nullptr );
139 }
140 
141 
143  const reco::Candidate* cand ) const {
144  static string dum = "";
145  map<const reco::Candidate*,string>::const_iterator iter =
146  searchMap.find( cand );
147  if ( iter != searchMap.end() ) return iter->second;
148  return dum;
149 }
150 
151 
152 void BPHDecayVertex::addV( const string& name,
153  const reco::Candidate* daug,
154  const string& searchList,
155  double mass ) {
156  addP( name, daug, mass );
157  searchMap[daughters().back()] = searchList;
158  return;
159 }
160 
161 
162 void BPHDecayVertex::addV( const string& name,
163  const BPHRecoConstCandPtr& comp ) {
164  addP( name, comp );
165  const map<const reco::Candidate*,string>& dMap = comp->searchMap;
166  searchMap.insert( dMap.begin(), dMap.end() );
167  return;
168 }
169 
170 
173  oldTracks = oldVertex = true;
174  validTks = false;
175  return;
176 }
177 
178 
180  oldTracks = false;
181  rTracks.clear();
182  trTracks.clear();
183  tkMap.clear();
184  ttMap.clear();
186  evSetup->get<TransientTrackRecord>().get( "TransientTrackBuilder", ttB );
187  const vector<const reco::Candidate*>& dL = daughFull();
188  int n = dL.size();
189  trTracks.reserve( n );
190  validTks = true;
191  while ( n-- ) {
192  const reco::Candidate* rp = dL[n];
193  tkMap[rp] = nullptr;
194  ttMap[rp] = nullptr;
195  if ( !rp->charge() ) continue;
196  const reco::Track* tp;
197  const char* searchList = "cfhp";
198  map<const reco::Candidate*,string>::const_iterator iter =
199  searchMap.find( rp );
200  if ( iter != searchMap.end() ) searchList = iter->second.c_str();
201  tp = BPHTrackReference::getTrack( *rp, searchList );
202  if ( tp == nullptr ) {
203  edm::LogPrint( "DataNotFound" )
204  << "BPHDecayVertex::tTracks: "
205  << "no track for reco::(PF)Candidate";
206  validTks = false;
207  continue;
208  }
209  rTracks.push_back( tp );
210  trTracks.push_back( ttB->build( tp ) );
211  reco::TransientTrack* ttp = &trTracks.back();
212  tkMap[rp] = tp;
213  ttMap[rp] = ttp;
214  }
215  return;
216 }
217 
218 
220  oldVertex = false;
221  if ( oldTracks ) tTracks();
222  if ( trTracks.size() < 2 ) return;
223  KalmanVertexFitter kvf( true );
224  TransientVertex tv = kvf.vertex( trTracks );
225  fittedVertex = tv;
226  return;
227 }
228 
const reco::Candidate * cand
const reco::Track * getTrack(const reco::Candidate *cand) const
get Track for a daughter
BPHGenericPtr< const BPHRecoCandidate >::type BPHRecoConstCandPtr
reco::TransientTrack * getTransientTrack(const reco::Candidate *cand) const
get TransientTrack for a daughter
bool isValid() const
Tells whether the vertex is valid.
Definition: Vertex.h:68
virtual void setNotUpdated() const
virtual bool validVertex() const
reco::TransientTrack build(const reco::Track *p) const
virtual void tTracks() const
std::vector< reco::TransientTrack > trTracks
virtual const std::vector< const reco::Candidate * > & daughters() const
const std::string & getTrackSearchList(const reco::Candidate *cand) const
retrieve track search list
virtual void fitVertex() const
static const reco::Track * getTrack(const reco::Candidate &rc, const char *modeList="cfhbpmnigse", char *modeFlag=0)
virtual void addV(const std::string &name, const reco::Candidate *daug, const std::string &searchList, double mass)
const std::vector< Component > & componentList() const
CachingVertex< 5 > vertex(const std::vector< reco::TransientTrack > &tracks) const override
const std::vector< const reco::Track * > & tracks() const
get list of Tracks
virtual void addP(const std::string &name, const reco::Candidate *daug, double mass=-1.0)
virtual const reco::Candidate * originalReco(const reco::Candidate *daug) const
get the original particle from the clone
void setNotUpdated() const override
reco::Vertex fittedVertex
BPHDecayVertex(const edm::EventSetup *es)
std::map< const reco::Candidate *, std::string > searchMap
std::map< const reco::Candidate *, const reco::Track * > tkMap
std::map< std::string, const reco::Candidate * > dMap
const edm::EventSetup * evSetup
virtual bool validTracks() const
check for valid reconstructed vertex
std::map< const reco::Candidate *, reco::TransientTrack * > ttMap
virtual int charge() const =0
electric charge
virtual const std::vector< BPHRecoConstCandPtr > & daughComp() const
T get() const
Definition: EventSetup.h:71
const std::vector< reco::TransientTrack > & transientTracks() const
get list of TransientTracks
virtual const std::vector< const reco::Candidate * > & daughFull() const
std::vector< const reco::Track * > rTracks
~BPHDecayVertex() override
How EventSelector::AcceptEvent() decides whether to accept an event for output otherwise it is excluding the probing of A single or multiple positive and the trigger will pass if any such matching triggers are PASS or EXCEPTION[A criterion thatmatches no triggers at all is detected and causes a throw.] A single negative with an expectation of appropriate bit checking in the decision and the trigger will pass if any such matching triggers are FAIL or EXCEPTION A wildcarded negative criterion that matches more than one trigger in the trigger list("!*","!HLTx*"if it matches 2 triggers or more) will accept the event if all the matching triggers are FAIL.It will reject the event if any of the triggers are PASS or EXCEPTION(this matches the behavior of"!*"before the partial wildcard feature was incorporated).Triggers which are in the READY state are completely ignored.(READY should never be returned since the trigger paths have been run
virtual const reco::Vertex & vertex() const
get reconstructed vertex