YAP
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
ParticleCombinationCache.h
Go to the documentation of this file.
1 /* YAP - Yet another PWA toolkit
2  Copyright 2015, Technische Universitaet Muenchen,
3  Authors: Daniel Greenwald, Johannes Rauch
4 
5  This program is free software: you can redistribute it and/or modify
6  it under the terms of the GNU General Public License as published by
7  the Free Software Foundation, either version 3 of the License, or
8  (at your option) any later version.
9 
10  This program is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13  GNU General Public License for more details.
14 
15  You should have received a copy of the GNU General Public License
16  along with this program. If not, see <http://www.gnu.org/licenses/>.
17  */
18 
20 
21 #ifndef yap_ParticleCombinationCache_h
22 #define yap_ParticleCombinationCache_h
23 
24 #include "ParticleCombination.h"
25 #include "WeakPtrCache.h"
26 
27 #include <ostream>
28 #include <vector>
29 
30 namespace yap {
31 
35 
36 class ParticleCombinationCache : public WeakPtrCache<ParticleCombination>
37 {
38 public:
39 
41  bool equal(const shared_ptr_type& A, const shared_ptr_type& B) const override
42  { return equal_up_and_down(A, B); }
43 
46  shared_ptr_type fsp(unsigned index)
47  { return operator[](create_fsp(index)); }
48 
52  shared_ptr_type composite(const ParticleCombinationVector& D)
53  { return operator[](create_composite(D)); }
54 
55  using WeakPtrCache::find;
56 
60  weak_ptr_type find(unsigned index) const
61  { return find(create_fsp(index)); }
62 
63  /*
67  weak_ptr_type find(const ParticleCombination& other)
68  { return find(create_copy(other)); }
69  */
70 
75  weak_ptr_type find(const ParticleCombinationVector& D) const
76  { return find(create_composite(D)); }
77 
82  weak_ptr_type findByUnorderedContent(const std::vector<unsigned>& I) const;
83 
85  bool consistent() const;
86 
88  virtual std::ostream& print(std::ostream& os) const override;
89 
90 private:
91 
93  void addToCache(shared_ptr_type pc) override;
94 
96  shared_ptr_type create_fsp(unsigned index) const
97  { return shared_ptr_type(new ParticleCombination(index)); }
98 
100  shared_ptr_type create_copy(const ParticleCombination& other) const;
101 
103  shared_ptr_type create_composite(const ParticleCombinationVector& D) const;
104 
105 };
106 
107 }
108 
109 #endif
shared_ptr_type create_fsp(unsigned index) const
create final-state particle, it is not yet added to cache
Definition: ParticleCombinationCache.h:96
std::shared_ptr< ParticleCombination > shared_ptr_type
std::shared_ptr to T
Definition: WeakPtrCache.h:49
Template for a cache of weak_ptr's to objects.
Definition: WeakPtrCache.h:37
bool equal(const shared_ptr_type &A, const shared_ptr_type &B) const override
implements equality checking
Definition: ParticleCombinationCache.h:41
bool consistent() const
Check consistency of cache.
Definition: ParticleCombinationCache.cxx:70
Stores combinations of particle indices.
Definition: ParticleCombination.h:43
bool equal_up_and_down(const std::shared_ptr< const ParticleCombination > &A, const std::shared_ptr< const ParticleCombination > &B)
compare shared_ptr's to ParticleCombination by checking selves, daughters, and parents ...
Definition: ParticleCombination.cxx:236
virtual std::ostream & print(std::ostream &os) const override
stream the cache elements as a table
Definition: ParticleCombinationCache.cxx:103
weak_ptr_type find(unsigned index) const
Definition: ParticleCombinationCache.h:60
std::weak_ptr< ParticleCombination > weak_ptr_type
std::weak_ptr to T
Definition: WeakPtrCache.h:53
void addToCache(shared_ptr_type pc) override
add to cache
Definition: ParticleCombinationCache.cxx:54
weak_ptr_type find(const ParticleCombinationVector &D) const
Definition: ParticleCombinationCache.h:75
weak_ptr_type findByUnorderedContent(const std::vector< unsigned > &I) const
Definition: ParticleCombinationCache.cxx:39
shared_ptr_type fsp(unsigned index)
Definition: ParticleCombinationCache.h:46
Caches list of ParticleCombination's.
Definition: ParticleCombinationCache.h:36
shared_ptr_type operator[](shared_ptr_type t)
Definition: WeakPtrCache.h:110
shared_ptr_type create_copy(const ParticleCombination &other) const
create copy, it is not yet added to cache
Definition: ParticleCombinationCache.cxx:13
shared_ptr_type create_composite(const ParticleCombinationVector &D) const
create composite ParticleCombination, it is not yet added to cache
Definition: ParticleCombinationCache.cxx:28
weak_ptr_type find(shared_ptr_type t) const
Definition: WeakPtrCache.h:93
shared_ptr_type composite(const ParticleCombinationVector &D)
Definition: ParticleCombinationCache.h:52