BOSS 7.0.2
BESIII Offline Software System
Loading...
Searching...
No Matches
CDCandidate.cxx
Go to the documentation of this file.
1//
2// File: CDCandidate.cc
3// Author: Simon Patton
4// Package: Taxi - a prototype set of objects for Physics analysis
5// Contents: Definitions of the members of `CDCandidate' class.
6//
7// Class Description: See CDCandidate.h.
8//
9// $Id: CDCandidate.cxx,v 1.4 2011/10/27 06:15:12 zoujh Exp $
10//
11
12#include <stdlib.h> // For 'exit'
13#include <iostream>
14
15#include "EvtRecEvent/EvtRecTrack.h"
16#include "EvtRecEvent/EvtRecPi0.h"
17#include "EvtRecEvent/EvtRecEtaToGG.h"
18#include "EvtRecEvent/EvtRecVeeVertex.h"
19#include "DecayChain/Element/ReferenceHolder.h"
20
21#include "BesDChain/util/KinematicData.h"
22#include "BesDChain/CDCandidate.h"
23#include "BesDChain/CDDecay.h"
24
25using namespace dchain;
26
28
29#ifdef EXTEND
30 //for recover 4p after kinematic fit
31 void CDCandidate::recover() const { kinematicData()->recover(); }
32#endif
33//------ Constructor -----
34// copy constructor
35//
36CDCandidate::CDCandidate( const CDCandidate& aOtherCDCandidate ) :
38 m_kinematicDataPtr(0),
39 m_footPrint( aOtherCDCandidate.footPrint() )
40{
41 if ( 0 != aOtherCDCandidate.m_kinematicDataPtr ) {
42 setKinematicData( * (aOtherCDCandidate.kinematicData()) ) ;
43 }
44}
45
46
47//------ Constructor -----
48// constructor with just a footprint
49//
50CDCandidate::CDCandidate( const CDFootPrint& aCDFootPrint ) :
51 m_kinematicDataPtr( 0 ) ,
52 m_footPrint( aCDFootPrint )
53{
54}
55
56//------ Destructor -----
57//
59{
60 delete m_kinematicDataPtr ;
61}
62
63
64//------ assignment -----
65// fill an *empty* candidate with aother CDCandidate's information
66//
67const CDCandidate& CDCandidate::operator=( const CDCandidate& aOtherCDCandidate )
68{
69 if ( 0 == aOtherCDCandidate.m_kinematicDataPtr ) {
70 delete m_kinematicDataPtr ;
71 m_kinematicDataPtr = 0 ;
72 }
73 else {
74 setKinematicData( * (aOtherCDCandidate.kinematicData()) ) ;
75 }
76 m_footPrint = aOtherCDCandidate.footPrint() ;
77 return ( *this ) ;
78}
79
80
82{
83 this->modifiableKinematicData()->setUserTag( tag );
84}
85
86//------ setMomentum -----
87//
88CDCandidate& CDCandidate::setP4( const HepLorentzVector& aMomentum )
89{
90 this->modifiableKinematicData()->setP4( aMomentum ) ;
91 return( *this ) ;
92}
93
94
95//------ setKinematicData -----
96// set the KTKinematicData to a new values
97// Does not fill initial value with defaultKinematicData.
98//
99void CDCandidate::setKinematicData( const KinematicData& aKinematicData )
100{
101 if ( 0 == m_kinematicDataPtr ) {
102 m_kinematicDataPtr = new KinematicData( aKinematicData ) ;
103 if ( 0 == m_kinematicDataPtr ) {
104 std::cerr << "No memory to allocate another kinematicData" << std::endl ;
105 exit( 1 ) ;
106 }
107 return ;
108 }
109 (*(this->modifiableKinematicData())) = aKinematicData ;
110 return ;
111}
112
113
114//------ setCDFootPrint -----
115// set the CDFootPrint to a new value
116//
117void CDCandidate::setCDFootPrint( const CDFootPrint& aCDFootPrint )
118{
119 m_footPrint = aCDFootPrint ;
120}
121
122//------ modifiableKinematicData -----
123// get the non-const KTKinematicData for this candidate
124//
125KinematicData* CDCandidate::modifiableKinematicData()
126{
127 if ( 0 == m_kinematicDataPtr ) {
128 m_kinematicDataPtr = defaultKinematicData() ;
129 if ( 0 == m_kinematicDataPtr ) {
130 std::cerr << "No memory to allocate another kinematicData" << std::endl ;
131 exit( 1 ) ;
132 }
133 }
134 return m_kinematicDataPtr ;
135}
136
138{
139 return kinematicData()->userTag();
140}
141
142//------ mass -----
143// get the mass for this CDCandidate
144//
145double CDCandidate::mass() const
146{
147 return kinematicData()->mass();
148}
149
150
151//------ charge -----
152// get the charge for this CDCandidate
153//
155{
156 return kinematicData()->charge();
157}
158
159
160//------ energy -----
161// get the energy for this CDCandidate
162//
164{
165 return kinematicData()->energy();
166}
167
168
169//------ momentum -----
170// get the momentum for this CDCandidate
171//
172const Hep3Vector& CDCandidate::momentum() const
173{
174 return kinematicData()->p4();
175}
176
177const HepLorentzVector& CDCandidate::p4() const
178{
179 return kinematicData()->p4();
180}
181
182//------ kinematicData -----
183// get the kinematicData for this CDCandidate
184//
186{
187 // Cast away `const' to pick up the function.
188 // This is safe as the result is being returned as a `const'
189 return ( (*(CDCandidate*)this).modifiableKinematicData() );
190}
191
194{
195 TracksAndShowers blocks;
196 recurseNode(blocks, *this);
197 return blocks;
198}
199
200void
202 const CDCandidate& cand) const
203{
204 if(cand.builtFromTrack())
205 {
206 final.first.push_back( cand.track() );
207 return;
208 }
209 if(cand.builtFromCDPhoton())
210 {
211 final.second.push_back( cand.photon() );
212 return;
213 }
214 const DecayEvidence& decay = cand.decay();
215 const vector< ReferenceHolder<CDCandidate> >& children = decay.children();
216 vector< ReferenceHolder<CDCandidate> >::const_iterator lastChild = children.end();
217 for(vector<ReferenceHolder<CDCandidate> >::const_iterator child = children.begin();
218 child != lastChild; ++child)
219 {
220 recurseNode(final, **child);
221 }
222}
223
224//------ buildFromCDCharged -----
225// false is there in no CDChargedEvidence associated with this CDCandidate
226//
228{
229 return ( false ) ;
230}
231
232
233//------ chargedEvidence -----
234// return the CDChargedEvidence that is associated with this CDCandidate
235//
237{
238 std::cerr << "No navtrack for this CDCandidate" << std::endl ;
239 exit( 1 ) ;
240 return ( (EvtRecTrack*)0 ) ;
241}
242
243
244//------ builtFromCDPhoton -----
245// false is there in no CDNeutralEvidence associated with this CDCandidate
246//
248{
249 return ( false ) ;
250}
251
252
253//------ photon -----
254// return the NavShower that is associated with this CDCandidate
255//
257{
258 std::cerr << "No NavShower for this CDCandidate" << std::endl ;
259 exit( 1 ) ;
260 return ( (EvtRecTrack*)0 ) ;
261}
262
263
264//------ builtFromCDPi0 -----
265// false is there in no CDNeutralEvidence associated with this CDCandidate
266//
268{
269 return ( false ) ;
270}
271
272
273//------ pi0 -----
274// return the NavCDPi0 that is associated with this CDCandidate
275//
277{
278 std::cerr << "No NavCDPi0 for this CDCandidate" << std::endl ;
279 exit( 1 ) ;
280 return ( (EvtRecPi0*)0 ) ;
281}
282
283
284//------ builtFromCDEta -----
285// false is there in no CDNeutralEvidence associated with this CDCandidate
286//
288{
289 return ( false ) ;
290}
291
292
293//------ eta -----
294// return the NavCDEta that is associated with this CDCandidate
295//
297{
298 std::cerr << "No NavCDEta for this CDCandidate" << std::endl ;
299 exit( 1 ) ;
300 return ( (EvtRecEtaToGG*)0 ) ;
301}
302
303
304//------ builtFromCDKs -----
305// false is there in no CDNeutralEvidence associated with this CDCandidate
306//
308{
309 return ( false ) ;
310}
311
312
313//------ CDKs -----
314// return the NavKs that is associated with this CDCandidate
315//
317{
318 std::cerr << "No NavKs for this CDCandidate" << std::endl ;
319 exit( 1 ) ;
320 return ( (EvtRecVeeVertex*)0 ) ;
321}
322
323
324//------ builtFromCDLambda -----
325// false is there in no CDNeutralEvidence associated with this CDCandidate
326//
328{
329 return ( false ) ;
330}
331
332
333//------ CDLambda -----
334// return the NavLambda that is associated with this CDCandidate
335//
337{
338 std::cerr << "No NavLambda for this CDCandidate" << std::endl ;
339 exit( 1 ) ;
340 return ( (EvtRecVeeVertex*)0 ) ;
341}
342
343
344//------ builtFromCDDecay -----
345// false is there in no CDDecay associated with this CDCandidate
346//
348{
349 return ( false ) ;
350}
351
352
353//------ decay -----
354// return the decay that is associated with this CDCandidate
355//
357{
358 std::cerr << "No CDDecay for this CDCandidate" << std::endl ;
359 exit( 1 ) ;
360 return ( *(CDDecay*)0 ) ;
361}
362
363//------ overlap -----
364// returns false if this Candodate and OtherCDCandidate have no elements
365// in common
366//
367bool CDCandidate::overlap( const CDCandidate& aOtherCDCandidate ) const
368{
369 return ( m_footPrint.overlap( aOtherCDCandidate.footPrint() ) ) ;
370}
371
372//------ footPrint -----
373// get the CDFootPrint for this CDCandidate
374//
376{
377 return ( m_footPrint ) ;
378}
379
380
381//----------------------------------------------------------------------
382//
383// $Log: CDCandidate.cxx,v $
384// Revision 1.4 2011/10/27 06:15:12 zoujh
385// add user tag to particle data
386//
387// Revision 1.3 2009/09/22 08:24:41 hujf
388// see ChangeLog
389//
390// Revision 1.2 2009/06/22 14:55:48 zoujh
391// See ChangeLog
392//
393// Revision 1.1.1.1 2009/03/03 06:05:56 maqm
394// first import of BesDChain
395//
396// Revision 1.7 2006/06/05 16:14:58 gregor
397// Reordered constructor initializers to match .h file
398//
399// Revision 1.6 2006/01/11 20:37:25 cdj
400// work with renaming done in DChain package
401//
402// Revision 1.5 2004/03/05 22:01:43 chengp
403// implemented Monte Carlo matching
404//
405// Revision 1.4 2003/05/15 19:58:08 cdj
406// revamped memory handling so always use a ReferenceHolder to deal with the reference counting
407//
408// Revision 1.3 2001/09/12 19:10:32 ajm36
409// add lambda functions to CDCandidate
410//
411// Revision 1.2 2001/04/20 14:03:34 ajm36
412// add finalChildren function to return tracks and showers
413//
414// Revision 1.1 2001/04/11 13:19:00 urner
415// transition to files with CD prefix. Addition of new files
416//
417// Revision 1.3 2001/04/03 17:24:57 cdj
418// now always initialize m_kinematicDataPtr to 0
419//
420// Revision 1.2 2001/03/23 23:05:27 urner
421// added pi0 eta and CDKs decay lists
422//
423// Revision 1.1.1.1 2000/12/18 22:17:24 cdj
424// imported CleoDChain
425//
426// Revision 1.29 1998/05/04 19:10:41 sjp
427// Fixed access confusion for kinematicData
428//
429// Revision 1.28 1998/04/17 18:55:49 sjp
430// Modified to use latest types
431//
432// Revision 1.27 1997/09/03 14:58:30 sjp
433// Use new report.h and KTKinematicData
434//
435// Revision 1.26 1997/08/29 17:00:32 sjp
436// Modified to handle new Cairn Templated classes
437//
438// Revision 1.25 1997/08/25 02:50:34 sjp
439// empty returns now use typedef names
440//
441// Revision 1.24 1997/08/22 16:18:51 sjp
442// New name for access functions
443//
444// Revision 1.23 1997/08/20 12:45:36 sjp
445// Removed unnecessary <math.h>
446//
447// Revision 1.22 1997/08/19 23:02:44 sjp
448// Restructured package to be independent of CleoDChain
449//
450// Revision 1.21 1997/08/19 20:40:14 sjp
451// Updated to use <package>/<file>.h include structure.
452// (Note: This version of the code has not been compiled)
453//
454// Revision 1.20 1997/01/21 20:29:57 sjp
455// Changed CPP flags and include because of library reorganization
456//
457// Revision 1.19 1996/12/20 21:00:32 sjp
458// Request of non-existant reference is now and error
459//
460// Revision 1.18 1996/11/04 16:58:33 sjp
461// Separaqted of CDDecay part of CDCandidate into new class
462//
463// Revision 1.17 1996/07/16 19:05:28 sjp
464// Restructed Libraries
465// Put relative pathnames into all includes
466//
467// Revision 1.16 1996/06/21 21:21:19 sjp
468// Fixed bug, which was missing a return statment
469//
470// Revision 1.15 1996/06/19 19:30:13 sjp
471// Changed to use vector<> rather than deque<>
472//
473// Revision 1.14 1996/06/13 18:18:37 sjp
474// KTKinematicData is now a cached value
475//
476// Revision 1.13 1996/06/04 14:54:17 sjp
477// Coverted to use DB Classes
478//
479// Revision 1.12 1996/04/11 14:25:16 sjp
480// Set Z of missedDistance to Z0CD (a kludge)
481//
482// Revision 1.11 1996/04/05 20:05:12 sjp
483// Added function to get MCParticle, Track and Shower matches.
484// Reorganized the file.
485// Added a cobbled version of missedDistance.
486//
487// Revision 1.10 1996/02/27 15:50:15 sjp
488// Added functions to link CDCandidate with Track and Showers.
489// Allowed derived classes ability to addChild to children.
490//
491// Revision 1.9 1996/02/06 20:37:24 sjp
492// Added new functionality to map a CDCandidate onto its `truth'.
493//
494// Revision 1.8 1995/11/28 17:34:46 sjp
495// Changed `list' class to `deque' and added SJP_NOSTL switch.
496// Added child() and iterateChild() operations, and thus added Children
497// include file for enum.
498// Moved `Log' information.
499//
500// Revision 1.6 1995/11/25 23:26:43 sjp
501// Ammended to use KTKinematicData a basis for kinematic data.
502//
503// Revision 1.5 1995/11/22 02:49:59 sjp
504// list constructors no longer accept Size, now use set_max_size.
505//
506// Revision 1.4 1995/11/14 22:04:56 sjp
507// Updated to use `list' rather than SimpleList, and to use STL style
508// iterators.
509//
510// Revision 1.3 1995/11/14 21:24:01 sjp
511// Corrected bug, energy was not begin accumulated in constructor.
512//
513// Revision 1.2 1995/11/09 16:53:48 sjp
514// Move responsibility for mass, charge, momentum and energy into this class.
515//
516// Revision 1.1 1995/11/07 21:26:57 sjp
517// New base class for all CDCandidates.
518//
519//
const CDFootPrint & footPrint() const
double energy() const
void setKinematicData(const DecayChain::KinematicData &aKinematicData)
Definition: CDCandidate.cxx:99
virtual bool builtFromCDPi0() const
void setUserTag(int tag)
Definition: CDCandidate.cxx:81
virtual const DecayEvidence & decay() const
virtual bool builtFromCDEta() const
virtual const EvtRecTrack * photon() const
virtual DecayChain::KinematicData * defaultKinematicData() const =0
CDCandidate & setP4(const HepLorentzVector &aMomentum)
Definition: CDCandidate.cxx:88
virtual bool builtFromCDLambda() const
virtual const EvtRecVeeVertex * navLambda() const
CDCandidate(const CDCandidate &aOtherCDCandidate)
Definition: CDCandidate.cxx:36
virtual const EvtRecTrack * track() const
const Hep3Vector & momentum() const
int userTag() const
const CDCandidate & operator=(const CDCandidate &aOtherCDCandidate)
Definition: CDCandidate.cxx:67
virtual bool builtFromCDPhoton() const
virtual bool builtFromTrack() const
int charge() const
const HepLorentzVector & p4() const
virtual const EvtRecVeeVertex * navKshort() const
TracksAndShowers finalChildren() const
const DecayChain::KinematicData * kinematicData() const
virtual bool builtFromCDDecay() const
virtual ~CDCandidate()
Definition: CDCandidate.cxx:58
virtual bool builtFromCDKs() const
virtual const EvtRecPi0 * navPi0() const
void recurseNode(TracksAndShowers &final, const CDCandidate &cand) const
bool overlap(const CDCandidate &aOtherCDCandidate) const
virtual const EvtRecEtaToGG * navEta() const
double mass() const
std::pair< vector< const EvtRecTrack * >, vector< const EvtRecTrack * > > TracksAndShowers
void setCDFootPrint(const CDFootPrint &aCDFootPrint)
const std::vector< dchain::ReferenceHolder< CDCandidate > > & children() const
Definition: CDDecay.cxx:256
bool overlap(const CDFootPrint &aOtherPrint) const
void setP4(const HepLorentzVector &aMomentum)
void setUserTag(const int tag)
const HepLorentzVector & p4() const