Jpp test-rotations-new
the software that should make you happy
Loading...
Searching...
No Matches
JClusterBuilder.hh
Go to the documentation of this file.
1#ifndef __JCLUSTERBUILDER__
2#define __JCLUSTERBUILDER__
3
4#include<vector>
5#include<algorithm>
6#include<set>
7#include<iterator>
8
10#include "JTrigger/JHitL0.hh"
11#include "JTrigger/JHitL1.hh"
14#include "JDetector/JModule.hh"
16#include "JMonitor/JCluster.hh"
17
18/**
19 * \author mjongen
20 */
21
22namespace JMONITOR {}
23namespace JPP { using namespace JMONITOR; }
24
25namespace JMONITOR {
26 using namespace std ;
27 using namespace JTRIGGER ;
28 using JDETECTOR::JModule ;
30
31 /**
32 Local coincidence cluster builder.
33
34 A coincidence cluster is defined as two or more hits on the same DOM
35 within the defined time window.
36
37 Given a JDAQSuperframe (for the hits) and the corresponding JModule
38 (for the timing) all the coincidence clusters are extracted and sorted
39 by multiplicity.
40
41 Internally, the clusters are stored as a vector of JClusters
42
43 \param frame JDAQSuperframe containing the hits
44 \param module module corresponding to the JDAQSuperframe
45 \param window time window used for clustering
46 **/
47 class JClusterBuilder : public JBuildL1<JHitL1>, public vector<JCluster>, public JModule {
48
49 public :
50
51 /// default constructor
53 // order using std::partition
55 }
56
57 /// constructor
58 JClusterBuilder( const JDAQSuperFrame& frame, const JModule& module, const double window, const bool combine ) : JBuildL1<JHitL1>(JBuildL1Parameters(window,combine)), JModule(module), max_multiplicity(31), end_iterators(max_multiplicity+2) {
59 // use the () operator of JBuildL1 to build L1s
60 (*this)(frame,module,back_inserter( *( (vector<JCluster>*)this) ) ) ;
61
62 // order using std::partition
64 }
65
66 /**
67 This is a way to re-use the allocated memory.
68
69 It behaves like the constructor, but new memory does not
70 have to be allocated for vector<JCluster> all the time.
71 **/
72 void reset( const JDAQSuperFrame& frame, const JModule& module ) {
73 static_cast<JModule>(*this) = module ;
74
75 vector<JCluster>::clear() ; // vector is emptied, but memory stays allocated
76 (*this)(frame,module,back_inserter( *( (vector<JCluster>*)this) ) ) ;
77
79 }
80
81 /// returns begin iterator for clusters with exactly the given multiplicity
82 vector<JCluster>::const_iterator begin_m( unsigned int multiplicity ) const {
83 // restrict to allowed range
84 multiplicity = max( (unsigned int)0,multiplicity) ;
85 multiplicity = min(max_multiplicity,multiplicity) ;
86 return end_iterators[multiplicity+1] ;
87 }
88
89 /// returns end iterator for clusters with exactly the given multiplicity
90 vector<JCluster>::const_iterator end_m( unsigned int multiplicity ) const {
91 // restrict to allowed range
92 multiplicity = max( (unsigned int)0,multiplicity) ;
93 multiplicity = min(max_multiplicity,multiplicity) ;
94 return end_iterators[multiplicity] ;
95 }
96
97 /// returns begin iterator for clusters with at least the given multiplicity
98 vector<JCluster>::const_iterator begin_inclusive_m( unsigned int multiplicity ) const {
100 }
101
102 /// returns end iterator for clusters with at least the given multiplicity
103 vector<JCluster>::const_iterator end_inclusive_m( unsigned int multiplicity ) const {
104 return end_m(multiplicity) ;
105 }
106
107 /// return the number of clusters with exactly the given multiplicity
108 unsigned int getNclusters( const unsigned int multiplicity ) const {
109 return distance( begin_m(multiplicity), end_m(multiplicity) ) ;
110 }
111
112 /// return the number of clusters with at least the given multiplicity
113 unsigned int getInclusiveNclusters( const unsigned int multiplicity ) const {
114 return distance( begin_inclusive_m(multiplicity), end_inclusive_m(multiplicity) ) ;
115 }
116
117 protected :
118
119 /**
120 Use std::partition to sort the clusters in order of decreasing multiplicity.
121 The end_iterators denote the boundaries.
122 **/
130
131 /**
132 functor that compares the multiplicity of a JCluster to some fixed given
133 multiplicity.
134 **/
136 public :
137
138 MinimalMultiplicityFunctor( const unsigned int _m ) : m(_m) {}
139
140 bool operator()(const JCluster& cluster) const {
141 return cluster.getMultiplicity() >= m ;
142 }
143
144 protected :
145
146 const unsigned int m ;
147 } ;
148
149 /// the highest allowed value for the multiplicity
150 const unsigned int max_multiplicity ;
151
152 /**
153 iterators pointing to the first element whose multiplicity is
154 lower than the index
155 **/
157 } ;
158
159}
160
161#endif
Basic data structure for L0 hit.
Basic data structure for L1 hit.
Tools for handling different hit types.
Data structure for optical module.
std::vector< T >::difference_type distance(typename std::vector< T >::const_iterator first, typename PhysicsEvent::const_iterator< T > second)
Specialisation of STL distance.
Data structure for a composite optical module.
Definition JModule.hh:75
functor that compares the multiplicity of a JCluster to some fixed given multiplicity.
Local coincidence cluster builder.
vector< vector< JCluster >::iterator > end_iterators
iterators pointing to the first element whose multiplicity is lower than the index
const unsigned int max_multiplicity
the highest allowed value for the multiplicity
vector< JCluster >::const_iterator end_m(unsigned int multiplicity) const
returns end iterator for clusters with exactly the given multiplicity
vector< JCluster >::const_iterator end_inclusive_m(unsigned int multiplicity) const
returns end iterator for clusters with at least the given multiplicity
vector< JCluster >::const_iterator begin_inclusive_m(unsigned int multiplicity) const
returns begin iterator for clusters with at least the given multiplicity
JClusterBuilder(const double window, const bool combine)
default constructor
void setEndIterators()
Use std::partition to sort the clusters in order of decreasing multiplicity.
void reset(const JDAQSuperFrame &frame, const JModule &module)
This is a way to re-use the allocated memory.
vector< JCluster >::const_iterator begin_m(unsigned int multiplicity) const
returns begin iterator for clusters with exactly the given multiplicity
unsigned int getInclusiveNclusters(const unsigned int multiplicity) const
return the number of clusters with at least the given multiplicity
JClusterBuilder(const JDAQSuperFrame &frame, const JModule &module, const double window, const bool combine)
constructor
unsigned int getNclusters(const unsigned int multiplicity) const
return the number of clusters with exactly the given multiplicity
A JHitL1 with a multiplicity.
Definition JCluster.hh:34
unsigned int getMultiplicity() const
Returns the multiplicity evaluated at the last call to setMultiplicity.
Definition JCluster.hh:50
Template L1 hit builder.
Definition JBuildL1.hh:90
Data structure for L1 hit.
Definition JHitL1.hh:37
Data frame of one optical module.
This name space includes all other name spaces (except KM3NETDAQ, KM3NET and ANTARES).
Auxiliary classes and methods for triggering.
Auxiliary data structure for L1 build parameters.
Definition JBuildL1.hh:38