BOSS 7.0.9
BESIII Offline Software System
Loading...
Searching...
No Matches
LabeledParticleList.cc
Go to the documentation of this file.
1#ifndef DCHAIN_LABELEDPARTICLELIST_CC
2#define DCHAIN_LABELEDPARTICLELIST_CC
3// -*- C++ -*-
4//
5// Package: DChain
6// Module: LabeledParticleList
7//
8// Description: Container of `primary'/`conjugate' particle subclasses of Candidate
9//
10// Implimentation:
11// <Notes on implimentation>
12//
13// Author: Simon Patton
14// Created: Wed Sep 11 20:56:18 EDT 1996
15// $Id: LabeledParticleList.cc,v 1.1.1.1 2009/03/03 06:06:56 maqm Exp $
16//
17// Revision history
18//
19// $Log: LabeledParticleList.cc,v $
20// Revision 1.1.1.1 2009/03/03 06:06:56 maqm
21// first import of DecayChain
22//
23// Revision 1.1 2006/01/11 20:28:40 cdj
24// massive class renaming, addition of [] for selection and unit tests
25//
26// Revision 1.2 2003/03/13 20:19:16 cleo3
27// now compiles under Linux
28//
29// Revision 1.1.1.1 2000/12/18 22:16:56 cdj
30// imported DChain
31//
32// Revision 1.16 1998/08/28 05:19:17 sjp
33// Updated to subclass from IndexedLabeled class
34//
35// Revision 1.15 1998/08/21 00:51:55 sjp
36// Modifier to no longer use typedefs
37//
38// Revision 1.14 1998/08/20 20:00:13 sjp
39// Modified to use DChainBoolean
40//
41// Revision 1.13 1998/08/19 20:46:24 sjp
42// Fixed comments and removed report references
43//
44// Revision 1.12 1998/07/27 22:20:49 sjp
45// Did explicit \'count\' to avoid compiler problems
46//
47// Revision 1.11 1998/04/17 19:14:52 sjp
48// Modified to use latest type
49//
50// Revision 1.10 1997/09/03 14:58:25 sjp
51// Use new report.h and TBParticlePoint
52//
53// Revision 1.9 1997/08/28 07:00:20 sjp
54// Modified files to handle complete templating
55//
56// Revision 1.8 1997/08/26 04:14:26 sjp
57// Made Candidate handling objects into `CandidateClass' Templates
58//
59// Revision 1.7 1997/08/19 23:02:36 sjp
60// Restructured package to be independent of Rock
61//
62// Revision 1.6 1997/08/19 16:17:47 sjp
63// Improved handling of STL containers
64//
65// Revision 1.5 1997/08/15 21:33:09 sjp
66// Updated to use <package>/<file>.h include structure.
67// Updated to use bug flags specified in Experiement.h
68//
69// Revision 1.4 1997/01/31 20:17:31 sjp
70// Modified to use the new `bug' include files
71//
72// Revision 1.3 1997/01/21 20:34:33 sjp
73// Changed CPP flags and include because of library reorganization
74//
75// Revision 1.2 1997/01/19 20:28:49 sjp
76// Changed LargeCount to Count
77//
78// Revision 1.1 1996/11/04 19:36:45 sjp
79// New file for new `List' module
80//
81
82// system include files
83#include <algorithm>
84#include <stdlib.h> // required for 'exit'
85
86// user include files
91
93
94//
95// constants, enums and typedefs
96//
97namespace dchain {
98//
99// static data member definitions
100//
101
102//
103// constructors and destructor
104//
105template < class ParticleClass , class CandidateClass >
107 m_list( *(new _labeledparticlelist_vector_ ) )
108{
109}
110
111// template < class ParticleClass , class CandidateClass >
112// LabeledParticleList< ParticleClass , CandidateClass >::LabeledParticleList( const LabeledParticleList< ParticleClass , CandidateClass >& )
113// {
114// }
115
116template < class ParticleClass , class CandidateClass >
118{
119 delete( &m_list ) ;
120}
121
122//
123// assignment operators
125// template < class ParticleClass , class CandidateClass >
126// const LabeledParticleList< ParticleClass , CandidateClass >& LabeledParticleList< ParticleClass , CandidateClass >::operator=( const LabeledParticleList< ParticleClass , CandidateClass >& )
127// {
128// }
131// member functions
132//
133
134//------ operator[] ------
136template < class ParticleClass , class CandidateClass >
138 return ( labeledParticleClass( aIndex ) ) ;
141//------ begin ------
143template < class ParticleClass , class CandidateClass >
145{
146 return ( iterator( this , 0 ) ) ;
147}
148
149//------ end ------
151template < class ParticleClass , class CandidateClass >
154 return ( iterator( this , m_list.size() ) ) ;
155}
156
157//------ push_back ------
158//
159template < class ParticleClass , class CandidateClass >
161{
162 m_list.push_back( aEntry ) ;
163}
164
165//------ erase_elements ------
166//
167template < class ParticleClass , class CandidateClass >
169 int aFinish )
170{
171 m_list.erase( m_list.begin() + aStart ,
172 m_list.begin() + aFinish ) ;
173}
174
175//------ labeledCandidateClass ------
176//
177template < class ParticleClass , class CandidateClass >
179{
180 return ( labeledParticleClass( aIndex ) ) ;
181}
182
183//------ labeledParticleClass ------
184//
185template < class ParticleClass , class CandidateClass >
187{
188 return ( m_list[ aIndex ] ) ;
189}
190
191//
192// const member functions
193//
194
195//------ operator[] ------
196//
197template < class ParticleClass , class CandidateClass >
199{
200 return ( labeledParticleClass( aIndex ) ) ;
201}
202
203//------ empty ------
204//
205template < class ParticleClass , class CandidateClass >
207{
208 return ( m_list.empty() ) ;
209}
210
211//------ empty ------
212//
213template < class ParticleClass , class CandidateClass >
215{
216// for efficiency, check to see if the whole list is empty first
217 if ( m_list.empty() ) {
218 return ( !false ) ;
219 }
220 return ( const_partial_iterator( this , 0 , aLabel ) ==
221 const_partial_iterator( this , m_list.size() , aLabel ) ) ;
222}
223
224//------ size ------
225//
226template < class ParticleClass , class CandidateClass >
228{
229 return ( m_list.size() ) ;
230}
231
232//------ size ------
233//
234template < class ParticleClass , class CandidateClass >
236{
237// for efficiency, check to see if the whole list is empty first
238 if ( m_list.empty() ) {
239 return ( 0 ) ;
240 }
241 int result( 0 ) ;
242/* Currently the "count" is done explicilty because of deficiencies
243 in the SunOS5 compiler!
244 count( _labeledparticlelist_vector_::const_iterator( m_list.begin() ) ,
245 _labeledparticlelist_vector_::const_iterator( m_list.end() ) ,
246 aLabel ,
247 result ) ;
248 */
249 typename _labeledparticlelist_vector_::const_iterator first( m_list.begin() ) ;
250 typename _labeledparticlelist_vector_::const_iterator last( m_list.end() ) ;
251 while (first != last) {
252 if ( *first == aLabel ) {
253 first++ ;
254 result++ ;
255 }
256 }
257
258 return ( result ) ;
259}
260
261//------ begin ------
262//
263template < class ParticleClass , class CandidateClass >
265{
266 return ( const_iterator( this , 0 ) ) ;
267}
268
269//------ begin ------
270//
271template < class ParticleClass , class CandidateClass >
273{
274 return ( const_partial_iterator( this , 0 , aLabel ) ) ;
275}
276
277//------ end ------
278//
279template < class ParticleClass , class CandidateClass >
281{
282 return ( const_iterator( this , m_list.size() ) ) ;
283}
284
285//------ end ------
286//
287template < class ParticleClass , class CandidateClass >
289{
290 return ( const_partial_iterator( this , m_list.size() , aLabel ) ) ;
291}
292
293//------ labeledCandidateClass ------
294//
295template < class ParticleClass , class CandidateClass >
297{
298 return ( labeledParticleClass( aIndex ) ) ;
299}
300
301//------ labeledParticleClass ------
302//
303template < class ParticleClass , class CandidateClass >
305{
306 return ( m_list[ aIndex ] ) ;
307}
308
309//
310// static member functions
311//
312}
313#endif /* DCHAIN_LABELEDPARTICLELIST_CC */
#define _labeledparticlelist_vector_
virtual void erase_elements(int aStart, int aFinish)
virtual LabeledCandidate< CandidateClass > & labeledCandidateClass(const int aIndex)
LabeledParticle< ParticleClass > & operator[](const int aIndex)
virtual LabeledParticle< ParticleClass > & labeledParticleClass(const int aIndex)
void push_back(const LabeledParticle< ParticleClass > &aEntry)