BOSS 8.0.0
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 <cmath> // required for trigonometry and fabs
115#include <stdlib.h> // required for 'exit'
116
117// user include files
118#include "BesDChain/CDDecay.h"
119#include "BesDChain/util/KinematicData.h"
120#include "DecayChain/Function/DCAnalysisFunction.h"
121
122using namespace dchain;
124using std::vector;
125
126CDDecay::CDDecay( const CDDecay& aOtherCDDecay )
127 :
128#ifdef EXTEND
129 m_kmfit_chisq( aOtherCDDecay.chisq() )
130 , m_vxfit_chisq( aOtherCDDecay.vchisq() )
131 ,
132#endif
133 CDCandidate( aOtherCDDecay )
134 , m_children( *new vector<ReferenceHolder<CDCandidate>>( aOtherCDDecay.children() ) ) {
135}
136
138 :
139#ifdef EXTEND
140 m_kmfit_chisq( 500000. )
141 , m_vxfit_chisq( 500000. )
142 ,
143#endif
144 CDCandidate( aProduct.footPrint() )
145 , m_children( *new vector<ReferenceHolder<CDCandidate>>(
146 1, ReferenceHolder<CDCandidate>( &aProduct ) ) ) {
147}
148
149CDDecay::CDDecay( const CDDecay& aProducts, const CDCandidate& aAdditionalProduct )
150 :
151#ifdef EXTEND
152 m_kmfit_chisq( 500000. )
153 , m_vxfit_chisq( 500000. )
154 ,
155#endif
156 CDCandidate( aProducts.footPrint() + aAdditionalProduct.footPrint() )
157 , m_children( *new vector<ReferenceHolder<CDCandidate>>( aProducts.children() ) ) {
158 m_children.push_back( ReferenceHolder<CDCandidate>( &aAdditionalProduct ) );
159}
160
161CDDecay::~CDDecay() { delete &m_children; }
162
164 :
165#ifdef EXTEND
166 m_kmfit_chisq( 500000. )
167 , m_vxfit_chisq( 500000. )
168 ,
169#endif
171 , m_children( *new vector<ReferenceHolder<CDCandidate>> ) {
172}
173//
174// assignment operators
175//
176/*
177 const CDDecay& CDDecay::operator=( const CDDecay& aOtherCDDecay )
178 {
179 *this = *(new CDDecay(aOtherCDDecay));
180 return *this;
181 }
182 */
183
184//
185// member functions
186//
187
188void CDDecay::addChild( const CDCandidate& aAdditionalProduct ) {
189 setCDFootPrint( footPrint() + aAdditionalProduct.footPrint() );
190 m_children.push_back( ReferenceHolder<CDCandidate>( &aAdditionalProduct ) );
191}
192
193void CDDecay::setKinematicData( const KinematicData& aKinematicData ) {
194 // Call setKinematicData of my super-class
195 CDCandidate::setKinematicData( aKinematicData );
196}
197
198//
199// const member functions
200//
201
202bool CDDecay::builtFromCDDecay() const { return ( !false ); }
203
204const CDDecay& CDDecay::decay() const { return ( *this ); }
205
206//------ numberChildren -----
207// return the number of DCChildren a candidate has
208//
209uint32_t CDDecay::numberChildren() const { return ( m_children.size() ); }
210
211//------ iterateChildern -----
212// execute given function over all DCChildren
213//
214void CDDecay::iterateChildren( void ( *analyze )( const CDCandidate& ) ) const {
215 vector<ReferenceHolder<CDCandidate>>::const_iterator finished( m_children.end() );
216 for ( vector<ReferenceHolder<CDCandidate>>::const_iterator child( m_children.begin() );
217 child != finished; ++child )
218 { analyze( ( *( *child ) ) ); }
219}
220
221//------ iterateChildern -----
222// execute given function over all DCChildren
223//
225 vector<ReferenceHolder<CDCandidate>>::const_iterator finished( m_children.end() );
226 for ( vector<ReferenceHolder<CDCandidate>>::const_iterator child( m_children.begin() );
227 child != finished; ++child )
228 { analyze( ( *( *child ) ) ); }
229}
230
231const CDCandidate& CDDecay::child( unsigned int aPosition ) const {
232 if ( aPosition >= m_children.size() )
233 {
234 std::cerr << "Trying to access an invalid Child" << std::endl;
235 return ( *( m_children[0] ) );
236 }
237 return ( *( m_children[aPosition] ) );
238}
239
240const vector<ReferenceHolder<CDCandidate>>& CDDecay::children() const {
241 return ( m_children );
242}
243
245 int userTag = 1;
246 double energySum = 0;
247 int chargeSum = 0;
248 HepLorentzVector p4( 0.0, 0.0, 0.0, 0.0 );
249 vector<ReferenceHolder<CDCandidate>>::const_iterator finished( m_children.end() );
250 for ( vector<ReferenceHolder<CDCandidate>>::const_iterator child( m_children.begin() );
251 child != finished; ++child )
252 {
253 userTag &= ( *( *child ) ).userTag();
254 chargeSum += ( *( *child ) ).charge();
255 p4 += ( *( *child ) ).p4();
256 }
257
258 KinematicData* tmp = new KinematicData();
259
260 tmp->setUserTag( userTag );
261 tmp->setCharge( chargeSum );
262 tmp->setP4( p4 );
263
264 return tmp;
265}
266//
267// static member functions
268//
const CDFootPrint & footPrint() const
void setKinematicData(const DecayChain::KinematicData &aKinematicData)
CDCandidate(const CDCandidate &aOtherCDCandidate)
int userTag() const
int charge() const
const HepLorentzVector & p4() const
void setCDFootPrint(const CDFootPrint &aCDFootPrint)
virtual DecayChain::KinematicData * defaultKinematicData() const
Definition CDDecay.cxx:244
virtual bool builtFromCDDecay(void) const
Definition CDDecay.cxx:202
void addChild(const CDCandidate &aAdditionalProduct)
Definition CDDecay.cxx:188
void setKinematicData(const DecayChain::KinematicData &aKinematicData)
Definition CDDecay.cxx:193
const CDCandidate & child(unsigned int aPosition) const
Definition CDDecay.cxx:231
uint32_t numberChildren() const
Definition CDDecay.cxx:209
void iterateChildren(void(*analyze)(const CDCandidate &)) const
Definition CDDecay.cxx:214
virtual ~CDDecay()
Definition CDDecay.cxx:161
virtual const CDDecay & decay(void) const
Definition CDDecay.cxx:204
CDDecay(const CDDecay &aOtherCDDecay)
Definition CDDecay.cxx:126
const std::vector< dchain::ReferenceHolder< CDCandidate > > & children() const
Definition CDDecay.cxx:240
void setCharge(const int aCharge)
void setP4(const HepLorentzVector &aMomentum)
void setUserTag(const int tag)