4 #include "ClusterAnalysisHighPt.h"
6 #include "matchOneToOne.hh"
18 m_nEvent = cs.n_particles();
21 if ( m_nEvent > m_nEventSize ) {
22 m_nEventSize = m_nEvent;
23 m_event.resize(m_nEvent);
24 m_partMap.resize(m_nEvent);
25 m_cpStab.resize(m_nEvent);
29 for (
unsigned i=0; i != m_nEvent; i++ )
33 const Event & allJets = cs.jets();
34 for (
unsigned jp=0; jp != m_nEvent; jp++ ) {
35 const int jpHistIndex = allJets[jp].cluster_sequence_history_index();
36 assert(jpHistIndex >= 0);
37 m_event[jp] = allJets[jp];
38 assert( m_event[jp].pt() > 0. );
43 const Event & cluJets = fastjet::sorted_by_pt(cs.exclusive_jets(m_dCut));
46 m_nJets=cluJets.size();
47 m_nJetsInCycle = m_nJets;
48 if ( m_nJetSize < m_nJets ) {
49 m_jets.resize(m_nJets);
50 m_jetCycleMap.resize(m_nJets);
53 const std::vector<int> & histMap = cs.particle_jet_indices(cluJets);
54 assert(m_nEvent == histMap.size());
55 for (
unsigned p=0; p != m_nEvent; p++ ) {
56 const int index = histMap[p];
57 if ( index >= 0 && index < 2 ) m_partMap[p] = index;
58 else if ( m_useJunkJet && index > 1 ) m_partMap[p] = 2U;
60 m_partMap[p] = UINT_MAX;
72 const Event & cluJets = fastjet::sorted_by_pt(cs.exclusive_jets(m_dCut));
73 m_nJetsInCycle = cluJets.size();
76 if ( m_nJetsInCycle > m_nJetSize ) {
77 m_nJetSize = m_nJetsInCycle;
78 m_jets.resize(m_nJetSize);
79 m_jetCycleMap.resize(m_nJetSize);
83 for (
unsigned j=0; j != m_nJetsInCycle; j++ )
87 std::vector<int> matchIndex;
89 matchOneToOne(cluJets,m_jets,m_nJetsInCycle,m_nJets,calc,&matchIndex);
91 for (
unsigned j=0; j != m_nJetsInCycle; j++ ) {
92 const int index = matchIndex[j];
93 if ( index >=0 ) m_jetCycleMap[j] = index;
95 if ( m_nJetSize == m_nJets ) m_jets.resize(++m_nJetSize);
96 m_jets[m_nJets] = cluJets[j];
97 m_jetCycleMap[j] = m_nJets++;
102 std::vector<unsigned> partMap(m_nEvent);
103 const std::vector<int> & histMap = cs.particle_jet_indices(cluJets);
104 assert(m_nEvent == histMap.size());
105 for (
unsigned p=0; p != m_nEvent; p++ ) {
106 const int index = histMap[p];
107 if ( index >= 0 && index < 2 ) partMap[p] = index;
108 else if ( m_useJunkJet && index > 1 ) partMap[p] = 2U;
109 else partMap[p] = UINT_MAX;
111 m_partMapVec.push_back(partMap);
116 assert( m_nJetsInCycle );
124 for (
unsigned p=0; p != m_nEventSize; p++ ) {
125 m_event[p] = PseudoJet();
129 m_partMapVec.clear();
131 for (
unsigned j=0; j != m_nJetSize; j++ ) {
132 m_jets[j] = PseudoJet();
133 m_jetCycleMap[j] = 0U;
146 stab = pairwiseStability(index);
149 stab = exhaustiveStability(index);
152 stab = unsmearedStability(index);
155 stab = resampledStability(index);
166 long double stab=0.L;
168 for (
unsigned c=0; c != m_nCycle-1U; c++ ) {
169 std::vector<unsigned> & clustMap1 = m_partMapVec[c];
170 std::vector<unsigned> & clustMap2 = m_partMapVec[c+1U];
171 const double temp = index.
index(&m_event[0],&clustMap1[0],&clustMap2[0],m_nEvent,&m_cpStab[0]);
176 for (
unsigned i=0; i != m_nEvent; i++ )
177 m_cpStab[i] /= (m_nCycle-1U);
179 stab /= (m_nCycle-1);
186 double ClusterAnalysisHighPt::exhaustiveStability(
const ClusteringComparisonIndexCP &index)
191 for (
unsigned c1=0; c1 != m_nCycle-1U; c1++ ) {
192 std::vector<unsigned> & clustMap1 = m_partMapVec[c1];
193 for (
unsigned c2=c1+1; c2 != m_nCycle; c2++ ) {
194 std::vector<unsigned> & clustMap2 = m_partMapVec[c2];
195 stab += index.index(&m_event[0],&clustMap1[0],&clustMap2[0],m_nEvent,&m_cpStab[0]);
200 for (
unsigned i=0; i != m_nEvent; i++ )
201 m_cpStab[i] /= (
double)m_nCycle*((double)m_nCycle-1.)/2.;
203 stab /= (double)m_nCycle*((
double)m_nCycle-1.)/2.;
207 double ClusterAnalysisHighPt::unsmearedStability(
const ClusteringComparisonIndexCP &index)
211 for (
unsigned c=0; c != m_nCycle; c++ ) {
212 std::vector<unsigned> & clustMap = m_partMapVec[c];
213 stab += index.index(&m_event[0],&m_partMap[0],&clustMap[0],m_nEvent,&m_cpStab[0]);
217 for (
unsigned i=0; i != m_nEvent; i++ )
218 m_cpStab[i] /= m_nCycle;
224 double ClusterAnalysisHighPt::resampledStability(
const ClusteringComparisonIndexCP &index)
233 const unsigned weightSize = m_nJets*m_nEvent;
234 double weights[weightSize];
236 for (
unsigned i=0; i != weightSize; i++ )
241 for (
unsigned i=0; i != m_nJets; i++ ) {
242 for (
unsigned j=0; j != m_nEvent; j++ ) {
244 for (
unsigned k=0; k != m_nCycle; k++ )
245 if ( m_partMapVec[k][j] == i ) count++;
246 weights[i*m_nEvent+j] = (double)count/(
double)m_nCycle;
247 assert( weights[i*m_nEvent+j] >= 0. );
251 bool lastFinalJetIsUnclustered=
false;
252 const unsigned lenJetFuzziness = m_nJets;
253 double jetFuzziness[lenJetFuzziness];
255 return fuzzyCalc.calculate(m_event, m_jets, weights, m_nJets, m_nEvent, lastFinalJetIsUnclustered,
256 jetFuzziness, lenJetFuzziness);
void clear()
clear the contents
void fill(const fastjet::ClusterSequence &)
Add results of latest clustering to stability consideration.
double doStability(const ClusteringComparisonIndexCP &, const StabilityCalcMethod method=PAIRWISE)
perform the stability calculation
double doFuzziness(const AbsFuzzinessCalculator &)
perform the fuzziness calculation
void initialize(const fastjet::ClusterSequence &)
Initialize internal data from first clustering results.
virtual double index(const PseudoJet *inputParticles, const unsigned *clustering1, const unsigned *clustering2, unsigned size, double *constitStab) const =0