CMS 3D CMS Logo

ClusterClusterMapping.cc
Go to the documentation of this file.
2 
3 // returns true as soon as the two clusters have one hit in common
5  const reco::CaloCluster &sc2,
6  float minfrac,
7  bool debug) {
8  const std::vector<std::pair<DetId, float> > &hits1 = sc1.hitsAndFractions();
9  const std::vector<std::pair<DetId, float> > &hits2 = sc2.hitsAndFractions();
10  unsigned nhits1 = hits1.size();
11  unsigned nhits2 = hits2.size();
12 
13  for (unsigned i1 = 0; i1 < nhits1; ++i1) {
14  // consider only with a minimum fraction of minfrac (default 1%) of the RecHit
15  if (hits1[i1].second < minfrac) {
16  if (debug)
17  std::cout << " Discarding " << hits1[i1].first << " with " << hits1[i1].second << std::endl;
18  continue;
19  }
20  for (unsigned i2 = 0; i2 < nhits2; ++i2) {
21  // consider only with a minimum fraction of minfract (default 1%) of the RecHit
22  if (hits2[i2].second < minfrac) {
23  if (debug)
24  std::cout << " Discarding " << hits2[i2].first << " with " << hits2[i2].second << std::endl;
25  continue;
26  }
27  if (hits1[i1].first == hits2[i2].first) {
28  if (debug) {
29  std::cout << " Matching hits " << hits1[i1].first << " with " << hits1[i1].second << " and "
30  << hits2[i2].first;
31  std::cout << " with " << hits2[i2].second << std::endl;
32  }
33  return true;
34  }
35  }
36  }
37  return false;
38 }
39 
41  const reco::SuperCluster &sc,
42  const edm::ValueMap<reco::CaloClusterPtr> &pfclusassoc) {
43  for (reco::CaloCluster_iterator caloclus = sc.clustersBegin(); caloclus != sc.clustersEnd(); ++caloclus) {
44  if (pfclusassoc.contains(caloclus->id())) {
45  const reco::CaloClusterPtr &pfclus = pfclusassoc[*caloclus];
46  //printf("pfclus prodidx = %i, key = %i, pfclustest prodidx = %i, key = %i\n",pfclus.id().productIndex(),int(pfclus.key()),pfclustest.id().productIndex(),int(pfclustest.key()));
47  if (pfclus.id() == pfclustest.id() && pfclus.key() == pfclustest.key())
48  return true;
49  }
50  }
51  return false;
52 }
53 
55  const std::vector<const reco::SuperCluster *> &sc,
56  float minfrac,
57  bool debug) {
58  int result = -1;
59  unsigned nsc = sc.size();
60 
61  for (unsigned isc = 0; isc < nsc; ++isc) {
62  if (overlap(pfc, *(sc[isc]), minfrac, debug))
63  return isc;
64  }
65  return result;
66 }
67 
69  const std::vector<reco::SuperClusterRef> &sc,
70  float minfrac,
71  bool debug) {
72  int result = -1;
73  unsigned nsc = sc.size();
74 
75  for (unsigned isc = 0; isc < nsc; ++isc) {
76  if (overlap(pfc, *sc[isc], minfrac, debug))
77  return isc;
78  }
79  return result;
80 }
81 
83  const std::vector<reco::SuperClusterRef> &sc,
84  const edm::ValueMap<reco::CaloClusterPtr> &pfclusassoc) {
85  int result = -1;
86  unsigned nsc = sc.size();
87 
88  for (unsigned isc = 0; isc < nsc; ++isc) {
89  if (overlap(pfc, *sc[isc], pfclusassoc))
90  return isc;
91  }
92  return result;
93 }
testProducerWithPsetDescEmpty_cfi.i2
i2
Definition: testProducerWithPsetDescEmpty_cfi.py:46
ClusterClusterMapping::checkOverlap
static int checkOverlap(const reco::PFCluster &pfc, const std::vector< const reco::SuperCluster * > &sc, float minfrac=0.01, bool debug=false)
Definition: ClusterClusterMapping.cc:54
reco::SuperCluster
Definition: SuperCluster.h:18
gather_cfg.cout
cout
Definition: gather_cfg.py:144
testProducerWithPsetDescEmpty_cfi.i1
i1
Definition: testProducerWithPsetDescEmpty_cfi.py:45
edm::PtrVectorItr
Definition: PtrVector.h:51
edm::second
U second(std::pair< T, U > const &p)
Definition: ParameterSet.cc:222
edm::Ptr::key
key_type key() const
Definition: Ptr.h:163
dqmdumpme.first
first
Definition: dqmdumpme.py:55
edm::Ref< PFClusterCollection >
debug
#define debug
Definition: HDRShower.cc:19
reco::CaloCluster
Definition: CaloCluster.h:31
ClusterClusterMapping::overlap
static bool overlap(const reco::CaloCluster &sc1, const reco::CaloCluster &sc, float minfrac=0.01, bool debug=false)
Definition: ClusterClusterMapping.cc:4
edm::Ptr::id
ProductID id() const
Accessor for product ID.
Definition: Ptr.h:158
reco::CaloCluster::hitsAndFractions
const std::vector< std::pair< DetId, float > > & hitsAndFractions() const
Definition: CaloCluster.h:210
reco::SuperCluster::clustersBegin
CaloCluster_iterator clustersBegin() const
fist iterator over BasicCluster constituents
Definition: SuperCluster.h:86
edm::Ptr< CaloCluster >
edm::Ref::id
ProductID id() const
Accessor for product ID.
Definition: Ref.h:244
ClusterClusterMapping.h
edm::ValueMap
Definition: ValueMap.h:107
reco::PFCluster
Particle flow cluster, see clustering algorithm in PFClusterAlgo.
Definition: PFCluster.h:42
edm::Ref::key
key_type key() const
Accessor for product key.
Definition: Ref.h:250
edm::ValueMap::contains
bool contains(ProductID id) const
Definition: ValueMap.h:155
mps_fire.result
result
Definition: mps_fire.py:311
reco::SuperCluster::clustersEnd
CaloCluster_iterator clustersEnd() const
last iterator over BasicCluster constituents
Definition: SuperCluster.h:89