BOSS 6.6.4.p03
BESIII Offline Software System
Loading...
Searching...
No Matches
NeutralNCVisibleList.h
Go to the documentation of this file.
1#ifndef DCHAIN_NEUTRALNCVISIBLELIST_H
2#define DCHAIN_NEUTRALNCVISIBLELIST_H
3// -*- C++ -*-
4//
5// Package: DChain
6// Module: NeutralNCVisibleList
7//
8// Description: List to hold Candidate subclasses generated from VisibleEvidence
9//
10// Usage:
11// <usage>
12//
13// Author: Simon Patton
14// Created: Fri Oct 4 11:04:47 EDT 1996
15// $Id: NeutralNCVisibleList.h,v 1.2 2009/06/22 08:38:08 zoujh Exp $
16//
17// Revision history
18//
19// $Log: NeutralNCVisibleList.h,v $
20// Revision 1.2 2009/06/22 08:38:08 zoujh
21// See ChangeLog
22//
23// Revision 1.1.1.1 2009/03/03 06:06:56 maqm
24// first import of DecayChain
25//
26// Revision 1.1 2006/01/11 20:28:29 cdj
27// massive class renaming, addition of [] for selection and unit tests
28//
29//
30
31// system include files
32
33// user include files
34#include "DecayChain/List/CandidateList.h" // superclass declaration
35#include "DecayChain/List/ChosenConjugateList.h" // for return-by-value
37
39
44
45namespace dchain {
46template < class DecayClass > class MuteWholeItr ;
47template < class DecayClass > class WholeItr ;
48template < class DecayClass > class PartialItr ;
49
50
51 template<class T>
52 int is_bar(const T& iNeutralNC) {
53 return static_cast<int>(iNeutralNC.isBar());
54 }
55
56 template<class T>
57 int is_bar(const T* iNeutralNC) {
58 return static_cast<int>(iNeutralNC->isBar());
59 }
60
61 template<class T>
62 int is_bar(T* iNeutralNC) {
63 return static_cast<int>(iNeutralNC->isBar());
64 }
65
66 template<class TPtr,class TRef>
68 return is_bar(*iHolder);
69 }
70
71//
72// Note: To avoid a myriad of compiler flags it is easier to
73// have a two parameter template class. The instantiation
74// of this class must look like
75//
76// template class dchain::LabeledParticleList< A , A::CandidateClass > ;
77
78template < class NeutralNC , class CandidateClass = typename NeutralNC::CandidateClass >
79class NeutralNCVisibleList : public dchain::CandidateList< CandidateClass >
80{
81 // friend classses and functions
82
83 public:
84 // constants, enums and typedefs
88
89 typedef NeutralNC value_type ;
90
92
93 // Constructors and destructor
95 NeutralNCVisibleList( const self_type& aOtherList);
96 template< class TSelector>
97 NeutralNCVisibleList( const self_type& aOtherList,
98 const TSelector& aSel):
99 m_list( new LabeledParticleList<NeutralNC,CandidateClass> ),
100 m_ntBarList(0),
101 m_isBarList(0)
102 {
103 fill(*(aOtherList.m_list),
105 aSel);
106 }
107
108 virtual ~NeutralNCVisibleList() ;
109
110 // assignment operator(s)
111 //const NeutralNCVisibleList< NeutralNC , CandidateClass >& operator=( const NeutralNCVisibleList< NeutralNC , CandidateClass >& aOtherList ) ;
112
113 template<class Witness>
114 const self_type& operator=(const Witness& aWitnessList) {
116 fill(aWitnessList.begin(), aWitnessList.end(),
119 return ( *this ) ;
120 }
121
122 // member functions
123 template<class TSelector>
126 }
127
132
133 // const member functions
136
137// The two following redeclarations are required because of function hidding
138// ( See ARM p310 )
139
140
141 using CandidateList< CandidateClass >::iterate;
142 template<class TAnalyze>
143 void iterate( const TAnalyze& analyze) const {
144 const_iterator finished ( particle_end() ) ;
145 for ( const_iterator entry ( particle_begin() ) ;
146 entry != finished ;
147 ++entry ) {
148 analyze( (*entry)() ) ;
149 }
150 }
151
152 template<class TAnalyze>
153 void iterate( TAnalyze& analyze) const {
154 const_iterator finished ( particle_end() ) ;
155 for ( const_iterator entry ( particle_begin() ) ;
156 entry != finished ;
157 ++entry ) {
158 analyze( (*entry)() ) ;
159 }
160 }
161
162 ///creates an insert iterator that filters based on iSelect
163 template<class TSelect>
165 return SelectiveInserter<self_type,TSelect>(*this,iSelect); }
166
167 template <class THolder, class TSelect>
168 bool attempt_insert( THolder& pPossible,
169 const TSelect& aSelect) {
170 bool returnValue = (aSelect)(*pPossible);
171 if (returnValue) {
172 this->insert(pPossible);
173 }
174 return returnValue;
175 }
176
177 template <class THolder>
178 void insert(THolder& pPossible) {
179 if (is_bar(pPossible)) {
180 m_list->push_back( LabeledParticle< NeutralNC >( pPossible ,
181 kIsBar ) ) ;
182 }
183 else {
184 m_list->push_back( LabeledParticle< NeutralNC >( pPossible ,
185 kIsntBar ) ) ;
186 }
187 }
188
189 void eraseContents() ;
190 void erase() {
192 }
193
194 template<class TMaker, class TSelector>
196 const TMaker& aMaker,
197 const TSelector& aSel) {
198
199 for( const_iterator entry(aList.begin()); entry != aList.end(); ++entry){
200 //NOTE: even though this is really just calling the copy constructor
201 //it is best to use the maker since it allows further control
202 const NeutralNC& from((*entry)());
203 typename ResultTypeTrait<TMaker>::type localCopy( aMaker(from) );
204
205 attempt_insert(localCopy,aSel);
206 }
207
208 }
209 template<class Iterator, class TMaker, class TSelector>
210 void fill(Iterator first, Iterator last,
211 const TMaker& aMaker,
212 const TSelector& aSel = SelectAll<NeutralNC>() ) {
213 std::transform(first,last,
214 selectiveInserter(aSel),
215 aMaker);
216 }
217
218 // static member functions
219
220 protected:
221 // protected member functions
223
224 // protected const member functions
226
227 private:
228 // Constructors and destructor
229
230 // private member functions
232
233 // private const member functions
234
235 // data members
237
240
241 // static data members
244
245} ;
246
247// inline function definitions
248 template<class TIList, class TSelector, class T, class U>
249 void fill_using_selector(const TIList& iList,
250 const TSelector& iSel,
252 oList.fill(iList.begin(), iList.end(),
253 typename MakerTrait<T>::maker_type(),
254 iSel);
255 }
256
257}
258
259// function definitions
261
262#endif /* DCHAIN_NEUTRALNCVISIBLELIST_H */
263
dchain::PartialItr< NeutralNC > const_partial_iterator
SelectiveInserter< self_type, TSelect > selectiveInserter(const TSelect &iSelect)
creates an insert iterator that filters based on iSelect
bool attempt_insert(THolder &pPossible, const TSelect &aSelect)
NeutralNCVisibleList(const self_type &aOtherList, const TSelector &aSel)
ChosenConjugateList< NeutralNC, CandidateClass > & operator()()
virtual dchain::LabeledParticleList< NeutralNC, CandidateClass > & labeledCandidateList()
void fill(Iterator first, Iterator last, const TMaker &aMaker, const TSelector &aSel=SelectAll< NeutralNC >())
void insert(THolder &pPossible)
ChosenConjugateList< NeutralNC, CandidateClass > & bar()
void iterate(TAnalyze &analyze) const
const self_type & operator=(const Witness &aWitnessList)
void fill(const LabeledParticleList< NeutralNC, CandidateClass > &aList, const TMaker &aMaker, const TSelector &aSel)
void iterate(const TAnalyze &analyze) const
FillListWithSelection< self_type, TSelector > operator[](const TSelector &iSel)
dchain::WholeItr< NeutralNC > const_iterator
dchain::MuteWholeItr< NeutralNC > iterator
NeutralNCVisibleList< NeutralNC, CandidateClass > self_type
void fill_using_selector(const TIList &iList, const TSelector &iSel, ChargedVisibleList< T, U > &oList)
int is_bar(const T &iNeutralNC)
T::result_type type
Definition: MakerTrait.h:55