CMS 3D CMS Logo

ZMuMuOverlapExclusion.cc
Go to the documentation of this file.
4 #include <iostream>
5 
6 struct ZMuMuOverlap {
8  bool operator()(const reco::Candidate & zMuMu, const reco::Candidate & z) const {
9 
10  using namespace std;
11  using namespace reco;
12  // check if a candidate z is different from zMuMu
13  // (for example a Z can be done with two global muons, or with a global muon plus a standalone muon.
14  // if the standalone muon is part of the second global muon in fact this is the same Z)
15 
16  unsigned int nd1 = zMuMu.numberOfDaughters();
17  unsigned int nd2 = z.numberOfDaughters();
18 
19  assert(nd1==2 && nd2==2);
20  const int maxd = 2;
21  const Candidate * daughters1[maxd];
22  const Candidate * daughters2[maxd];
23  TrackRef trackerTrack1[maxd];
24  TrackRef stAloneTrack1[maxd];
25  TrackRef globalTrack1[maxd];
26  TrackRef trackerTrack2[maxd];
27  TrackRef stAloneTrack2[maxd];
28  TrackRef globalTrack2[maxd];
29  bool flag;
30  unsigned int matched=0;
31 
32  for( unsigned int i = 0; i < nd1; ++ i ) {
33  daughters1[i] = zMuMu.daughter( i );
34  trackerTrack1[i] = daughters1[i]->get<TrackRef>();
35  stAloneTrack1[i] = daughters1[i]->get<TrackRef,reco::StandAloneMuonTag>();
36  globalTrack1[i] = daughters1[i]->get<TrackRef,reco::CombinedMuonTag>();
37 
38  /*********************************************** just used for debug ********************
39  if (trackerTrack1[i].isNull())
40  cout << "in ZMuMu daughter " << i << " tracker ref non found " << endl;
41  else
42  cout << "in ZMuMu daughter " << i << " tracker ref FOUND"
43  << " id: " << trackerTrack1[i].id() << ", index: " << trackerTrack1[i].key()
44  << endl;
45  if (stAloneTrack1[i].isNull())
46  cout << "in ZMuMu daughter " << i << " stalone ref non found " << endl;
47  else
48  cout << "in ZMuMu daughter " << i << " stalone ref FOUND"
49  << " id: " << stAloneTrack1[i].id() << ", index: " << stAloneTrack1[i].key()
50  << endl;
51 
52  if (globalTrack1[i].isNull())
53  cout << "in ZMuMu daughter " << i << " global ref non found " << endl;
54  else
55  cout << "in ZMuMu daughter " << i << " global ref FOUND"
56  << " id: " << globalTrack1[i].id() << ", index: " << globalTrack1[i].key()
57  << endl;
58  */
59  }
60  for( unsigned int i = 0; i < nd2; ++ i ) {
61  daughters2[i] = z.daughter( i );
62  trackerTrack2[i] = daughters2[i]->get<TrackRef>();
63  stAloneTrack2[i] = daughters2[i]->get<TrackRef,reco::StandAloneMuonTag>();
64  globalTrack2[i] = daughters2[i]->get<TrackRef,reco::CombinedMuonTag>();
65 
66  /******************************************** just used for debug ************
67  if (trackerTrack2[i].isNull())
68  cout << "in ZMuSta daughter " << i << " tracker ref non found " << endl;
69  else
70  cout << "in ZMuSta daughter " << i << " tracker ref FOUND"
71  << " id: " << trackerTrack2[i].id() << ", index: " << trackerTrack2[i].key()
72  << endl;
73  if (stAloneTrack2[i].isNull())
74  cout << "in ZMuSta daughter " << i << " standalone ref non found " << endl;
75  else
76  cout << "in ZMuSta daughter " << i << " standalone ref FOUND"
77  << " id: " << stAloneTrack2[i].id() << ", index: " << stAloneTrack2[i].key()
78  << endl;
79 
80  if (globalTrack2[i].isNull())
81  cout << "in ZMuSta daughter " << i << " global ref non found " << endl;
82  else
83  cout << "in ZMuSta daughter " << i << " global ref FOUND"
84  << " id: " << globalTrack2[i].id() << ", index: " << globalTrack2[i].key()
85  << endl;
86 
87  */
88  }
89  for (unsigned int i = 0; i < nd1; i++) {
90  flag = false;
91  for (unsigned int j = 0; j < nd2; j++) { // if the obj2 is a standalone the trackref is alwais in the trackerTRack position
92  if ( ((trackerTrack2[i].id()==trackerTrack1[j].id()) && (trackerTrack2[i].key()==trackerTrack1[j].key())) ||
93  ((trackerTrack2[i].id()==stAloneTrack1[j].id()) && (trackerTrack2[i].key()==stAloneTrack1[j].key())) ) {
94  flag = true;
95  }
96  }
97  if (flag) matched++;
98  }
99  if (matched==nd1) // return true if all the childrens of the ZMuMu have a children matched in ZMuXX
100  return true;
101  else
102  return false;
103  }
104 };
105 
106 typedef SingleObjectSelector<
110  ZMuMuOverlap>
112 
114 
116 
117 
virtual const Candidate * daughter(size_type i) const =0
return daughter at a given position, i = 0, ... numberOfDaughters() - 1 (read only mode) ...
ZMuMuOverlap(const edm::ParameterSet &)
stand alone muon component tag
Definition: RecoCandidate.h:78
bool operator()(const reco::Candidate &zMuMu, const reco::Candidate &z) const
key_type key() const
Accessor for product key.
Definition: Ref.h:263
ProductID id() const
Accessor for product ID.
Definition: Ref.h:257
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
conbined muon component tag
Definition: RecoCandidate.h:80
edm::Ref< TrackCollection > TrackRef
persistent reference to a Track
Definition: TrackFwd.h:21
SingleObjectSelector< edm::View< reco::Candidate >, OverlapExclusionSelector< reco::CandidateView, reco::Candidate, ZMuMuOverlap > > ZMuMuOverlapExclusionSelector
fixed size matrix
T get() const
get a component
Definition: Candidate.h:217
virtual size_type numberOfDaughters() const =0
number of daughters
edm::View< Candidate > CandidateView
view of a collection containing candidates
Definition: CandidateFwd.h:23