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