BOSS 7.0.4
BESIII Offline Software System
Loading...
Searching...
No Matches
CDDecay.cxx
Go to the documentation of this file.
1// -*- C++ -*-
2//
3// Package: DChain
4// Module: CDDecay
5//
6// Description: CDDecay candidate built from other candidates
7//
8// Implimentation:
9// <Notes on implimentation>
10//
11// Author: Simon Patton
12// Created: Sat Oct 26 11:09:11 EDT 1996
13// $Id: CDDecay.cxx,v 1.5 2011/12/08 15:28:10 zoujh Exp $
14//
15// Revision history
16//
17// $Log: CDDecay.cxx,v $
18// Revision 1.5 2011/12/08 15:28:10 zoujh
19// change the rule of tag calculation
20//
21// Revision 1.4 2011/10/27 06:15:12 zoujh
22// add user tag to particle data
23//
24// Revision 1.3 2009/09/22 08:24:41 hujf
25// see ChangeLog
26//
27// Revision 1.2 2009/06/22 14:55:48 zoujh
28// See ChangeLog
29//
30// Revision 1.1.1.1 2009/03/03 06:05:56 maqm
31// first import of BesDChain
32//
33// Revision 1.9 2006/03/17 19:36:31 ponyisi
34// Fix mcParticle() to use gammaFSR when available while doing matching
35//
36// Revision 1.8 2006/01/11 20:37:25 cdj
37// work with renaming done in DChain package
38//
39// Revision 1.7 2004/06/30 16:43:08 chengp
40// deleted redundant lines
41//
42// Revision 1.6 2004/06/29 17:51:22 chengp
43// modified to match Monte Carlo decay with FSR
44//
45// Revision 1.5 2004/03/12 15:22:41 cdj
46// protect against case where get negative mass squared (sets it to 0)
47//
48// Revision 1.4 2004/03/05 22:01:43 chengp
49// implemented Monte Carlo matching
50//
51// Revision 1.3 2003/05/15 19:58:08 cdj
52// revamped memory handling so always use a ReferenceHolder to deal with the reference counting
53//
54// Revision 1.2 2002/04/09 20:54:16 lyon
55// Added CDDecay::setKinematicData
56//
57// Revision 1.1 2001/04/11 13:19:01 urner
58// transition to files with CD prefix. Addition of new files
59//
60// Revision 1.4 2001/04/04 15:16:55 cdj
61// added a protected default constructor (used for storage)
62//
63// Revision 1.3 2001/04/03 17:25:55 cdj
64// changed isCDDecay to builtFromCDDecay
65//
66// Revision 1.2 2001/03/30 19:41:33 cdj
67// addChild now adds to footprint
68//
69// Revision 1.1.1.1 2000/12/18 22:17:25 cdj
70// imported CleoDChain
71//
72// Revision 1.13 1998/05/04 19:11:26 sjp
73// Corrected order of arguments in KinematicData ctor
74//
75// Revision 1.12 1998/04/17 18:55:51 sjp
76// Modified to use latest types
77//
78// Revision 1.11 1997/09/03 14:58:32 sjp
79// Use new report.h and KTKinematicData
80//
81// Revision 1.10 1997/08/29 17:00:34 sjp
82// Modified to handle new Cairn Templated classes
83//
84// Revision 1.9 1997/08/28 07:00:31 sjp
85// Modified files to handle complete templating
86//
87// Revision 1.8 1997/08/20 12:49:29 sjp
88// Fudged up work around for <math.h>
89//
90// Revision 1.7 1997/08/19 23:02:46 sjp
91// Restructured package to be independent of CleoDChain
92//
93// Revision 1.6 1997/08/19 20:40:15 sjp
94// Updated to use <package>/<file>.h include structure.
95// (Note: This version of the code has not been compiled)
96//
97// Revision 1.5 1997/01/31 20:10:12 sjp
98// Modified to use the new `bug' include files
99//
100// Revision 1.4 1997/01/21 20:29:59 sjp
101// Changed CPP flags and include because of library reorganization
102//
103// Revision 1.3 1997/01/19 20:32:11 sjp
104// Changed LargeCount to Count
105//
106// Revision 1.2 1996/12/20 21:00:50 sjp
107// Request of non-existant reference is now and error
108//
109// Revision 1.1 1996/11/04 16:55:10 sjp
110// New class for CDDecay CDCandidate
111//
112
113// system include files
114#include <stdlib.h> // required for 'exit'
115#include <cmath> // required for trigonometry and fabs
116
117// user include files
118#include "BesDChain/util/KinematicData.h"
119#include "DecayChain/Function/DCAnalysisFunction.h"
120#include "BesDChain/CDDecay.h"
121
122using namespace dchain;
123using std::vector;
125
126CDDecay::CDDecay( const CDDecay& aOtherCDDecay ) :
127#ifdef EXTEND
128 m_kmfit_chisq(aOtherCDDecay.chisq()),
129 m_vxfit_chisq(aOtherCDDecay.vchisq()),
130#endif
131 CDCandidate( aOtherCDDecay ) ,
132 m_children( *new vector< ReferenceHolder< CDCandidate > >( aOtherCDDecay.children() ) )
133{
134}
135
136CDDecay::CDDecay( const CDCandidate& aProduct ) :
137#ifdef EXTEND
138 m_kmfit_chisq(500000.),
139 m_vxfit_chisq(500000.),
140#endif
141 CDCandidate( aProduct.footPrint() ) ,
142 m_children( *new vector< ReferenceHolder<CDCandidate> >
143 ( 1, ReferenceHolder<CDCandidate>(&aProduct ) ) )
144{
145}
146
147CDDecay::CDDecay( const CDDecay& aProducts, const CDCandidate& aAdditionalProduct ) :
148#ifdef EXTEND
149 m_kmfit_chisq(500000.),
150 m_vxfit_chisq(500000.),
151#endif
152 CDCandidate( aProducts.footPrint() + aAdditionalProduct.footPrint() ) ,
153 m_children( *new vector< ReferenceHolder<CDCandidate> >( aProducts.children() ) )
154{
155 m_children.push_back( ReferenceHolder<CDCandidate>(&aAdditionalProduct) ) ;
156}
157
159{
160 delete &m_children ;
161}
162
164#ifdef EXTEND
165 m_kmfit_chisq(500000.),
166 m_vxfit_chisq(500000.),
167#endif
169 m_children( *new vector< ReferenceHolder<CDCandidate> > )
170{
171}
172//
173// assignment operators
174//
175/*
176 const CDDecay& CDDecay::operator=( const CDDecay& aOtherCDDecay )
177 {
178 *this = *(new CDDecay(aOtherCDDecay));
179 return *this;
180 }
181 */
182
183//
184// member functions
185//
186
187void CDDecay::addChild( const CDCandidate& aAdditionalProduct )
188{
189 setCDFootPrint( footPrint() + aAdditionalProduct.footPrint() );
190 m_children.push_back( ReferenceHolder<CDCandidate>(&aAdditionalProduct) ) ;
191}
192
193void CDDecay::setKinematicData( const KinematicData& aKinematicData )
194{
195 // Call setKinematicData of my super-class
196 CDCandidate::setKinematicData( aKinematicData );
197}
198
199//
200// const member functions
201//
202
204{
205 return ( !false ) ;
206}
207
209{
210 return ( *this ) ;
211}
212
213//------ numberChildren -----
214// return the number of DCChildren a candidate has
215//
217{
218 return ( m_children.size() ) ;
219}
220
221//------ iterateChildern -----
222// execute given function over all DCChildren
223//
224void CDDecay::iterateChildren( void ( * analyze )( const CDCandidate& ) ) const
225{
226 vector< ReferenceHolder<CDCandidate> >::const_iterator finished( m_children.end() ) ;
227 for ( vector< ReferenceHolder<CDCandidate> >::const_iterator child( m_children.begin() ) ;
228 child != finished ;
229 ++child ) {
230 analyze( (*(*child)) ) ;
231 }
232}
233
234//------ iterateChildern -----
235// execute given function over all DCChildren
236//
238{
239 vector< ReferenceHolder<CDCandidate> >::const_iterator finished ( m_children.end() ) ;
240 for ( vector< ReferenceHolder<CDCandidate> >::const_iterator child ( m_children.begin() ) ;
241 child != finished ;
242 ++child ) {
243 analyze( (*(*child)) ) ;
244 }
245}
246
247const CDCandidate& CDDecay::child( unsigned int aPosition ) const
248{
249 if ( aPosition >= m_children.size() ) {
250 std::cerr << "Trying to access an invalid Child" << std::endl ;
251 return ( *(m_children[ 0 ]) ) ;
252 }
253 return ( *(m_children[ aPosition ]) ) ;
254}
255
256const vector< ReferenceHolder<CDCandidate> >& CDDecay::children() const
257{
258 return ( m_children ) ;
259}
260
263{
264 int userTag = 1 ;
265 double energySum = 0 ;
266 int chargeSum = 0 ;
267 HepLorentzVector p4( 0.0 , 0.0 , 0.0, 0.0 ) ;
268 vector< ReferenceHolder<CDCandidate> >::const_iterator finished( m_children.end() ) ;
269 for ( vector< ReferenceHolder<CDCandidate> >::const_iterator child( m_children.begin() ) ;
270 child != finished ;
271 ++child ) {
272 userTag &= (*(*child)).userTag();
273 chargeSum += (*(*child)).charge() ;
274 p4 += (*(*child)).p4() ;
275 }
276
277 KinematicData* tmp = new KinematicData();
278
279 tmp->setUserTag( userTag );
280 tmp->setCharge( chargeSum );
281 tmp->setP4( p4 );
282
283 return tmp;
284}
285//
286// static member functions
287//
const CDFootPrint & footPrint() const
void setKinematicData(const DecayChain::KinematicData &aKinematicData)
Definition: CDCandidate.cxx:99
int userTag() const
int charge() const
const HepLorentzVector & p4() const
void setCDFootPrint(const CDFootPrint &aCDFootPrint)
CDDecay()
Definition: CDDecay.cxx:163
virtual DecayChain::KinematicData * defaultKinematicData() const
Definition: CDDecay.cxx:262
virtual bool builtFromCDDecay(void) const
Definition: CDDecay.cxx:203
void addChild(const CDCandidate &aAdditionalProduct)
Definition: CDDecay.cxx:187
void setKinematicData(const DecayChain::KinematicData &aKinematicData)
Definition: CDDecay.cxx:193
const CDCandidate & child(unsigned int aPosition) const
Definition: CDDecay.cxx:247
uint32_t numberChildren() const
Definition: CDDecay.cxx:216
void iterateChildren(void(*analyze)(const CDCandidate &)) const
Definition: CDDecay.cxx:224
virtual ~CDDecay()
Definition: CDDecay.cxx:158
virtual const CDDecay & decay(void) const
Definition: CDDecay.cxx:208
const std::vector< dchain::ReferenceHolder< CDCandidate > > & children() const
Definition: CDDecay.cxx:256
void setCharge(const int aCharge)
void setP4(const HepLorentzVector &aMomentum)
void setUserTag(const int tag)