stablejet is hosted by Hepforge, IPPP Durham
StableJet
ClusteringComparisonCP.cc
1 #include <cassert>
2 #include "ClusteringComparisonCP.h"
3 
4 namespace stab {
5 
6 double TransversePairwiseIndexCP::index(const PseudoJet * inputParticles,
7  const unsigned * clustering1,
8  const unsigned * clustering2,
9  const unsigned len,
10  double * constitStab ) const
11 {
12 
13  assert(inputParticles);
14  assert(clustering1);
15  assert(clustering2);
16  assert(len);
17  assert(constitStab);
18 
19  long double c1 = 0.0L, c2 = 0.0L, c3 = 0.0L, c4 = 0.0L;
20 
21  for ( unsigned i=0; i<len; i++ ) {
22  const double pt_i = inputParticles[i].pt();
23  const unsigned cl_i_1 = clustering1[i];
24  const unsigned cl_i_2 = clustering2[i];
25 
26  // weights associated to only pairs involving a particular candidate.
27  long double ci1 = 0.L, ci2 = 0.L, ci3 = 0.L, ci4 = 0.L;
28 
29  for ( unsigned j=0; j<len; ++j ) {
30  if ( j == i ) continue; // skip ith particle
31 
32  const double weight = inputParticles[j].pt()*pt_i;
33  const bool same_in_1 = (cl_i_1 == clustering1[j]);
34  const bool same_in_2 = (cl_i_2 == clustering2[j]);
35 
36  if ( same_in_1 && same_in_2)
37  ci1 += weight;
38  else if ( same_in_1 && ! same_in_2)
39  ci3 += weight;
40  else if ( !same_in_1 && same_in_2)
41  ci4 += weight;
42  else
43  ci2 += weight;
44  }
45 
46  assert( ci1 + ci2 + ci3 + ci4 > 0.L );
47  constitStab[i] += combineCounts(ci1,ci2,ci3,ci4);
48 
49  c1 += ci1;
50  c2 += ci2;
51  c3 += ci3;
52  c4 += ci4;
53  }
54 
55  assert(c1 + c2 + c3 + c4 > 0.L);
56 
57  // weights are divided by two because of the double counting
58  // in the double cycle of i and j. Pairs are counted twice since
59  // i and j both run over the entire collection input particles.
60  return combineCounts(c1/2.,c2/2.,c3/2.,c4/2.);
61 
62 } // end index
63 
64 } // end stab namespace
double index(const PseudoJet *inputParticles, const unsigned *clustering1, const unsigned *clustering2, unsigned size, double *constitStab) const