CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_0/src/ElectroWeakAnalysis/ZMuMu/plugins/ZMuMuOverlapExclusion.cc

Go to the documentation of this file.
00001 #include "CommonTools/UtilAlgos/interface/OverlapExclusionSelector.h"
00002 #include "CommonTools/UtilAlgos/interface/SingleObjectSelector.h"
00003 #include "DataFormats/RecoCandidate/interface/RecoCandidate.h"
00004 #include <iostream>
00005 
00006 struct ZMuMuOverlap {
00007   ZMuMuOverlap(const edm::ParameterSet&) { }
00008   bool operator()(const reco::Candidate & zMuMu, const reco::Candidate & z) const {
00009     
00010     using namespace std;
00011     using namespace reco;
00012     // check if a candidate z is different from zMuMu  
00013     // (for example a Z can be done with two global muons, or with a global muon plus a standalone muon.
00014     // if the standalone muon is part of the second global muon in fact this is the same Z)
00015   
00016     unsigned int nd1 = zMuMu.numberOfDaughters();
00017     unsigned int nd2 = z.numberOfDaughters();
00018     
00019     assert(nd1==2 && nd2==2);
00020     const int maxd = 2;
00021     const Candidate * daughters1[maxd];
00022     const Candidate * daughters2[maxd];
00023     TrackRef trackerTrack1[maxd];
00024     TrackRef stAloneTrack1[maxd];
00025     TrackRef globalTrack1[maxd];
00026     TrackRef trackerTrack2[maxd];
00027     TrackRef stAloneTrack2[maxd];
00028     TrackRef globalTrack2[maxd];
00029     bool flag;
00030     unsigned int matched=0;
00031     
00032     for( unsigned int i = 0; i < nd1; ++ i ) {
00033       daughters1[i] = zMuMu.daughter( i );
00034       trackerTrack1[i] = daughters1[i]->get<TrackRef>();
00035       stAloneTrack1[i] = daughters1[i]->get<TrackRef,reco::StandAloneMuonTag>();
00036       globalTrack1[i]  = daughters1[i]->get<TrackRef,reco::CombinedMuonTag>();
00037       
00038       /*********************************************** just used for debug ********************
00039     if (trackerTrack1[i].isNull()) 
00040       cout << "in ZMuMu daughter " << i << " tracker ref non found " << endl;
00041     else
00042       cout << "in ZMuMu daughter " << i << " tracker ref FOUND" 
00043            << " id: " << trackerTrack1[i].id() << ", index: " << trackerTrack1[i].key() 
00044            << endl;
00045     if (stAloneTrack1[i].isNull()) 
00046       cout << "in ZMuMu daughter " << i << " stalone ref non found " << endl;
00047     else
00048       cout << "in ZMuMu daughter " << i << " stalone ref FOUND" 
00049            << " id: " << stAloneTrack1[i].id() << ", index: " << stAloneTrack1[i].key() 
00050            << endl;
00051     
00052     if (globalTrack1[i].isNull()) 
00053       cout << "in ZMuMu daughter " << i << " global ref non found " << endl;
00054     else
00055       cout << "in ZMuMu daughter " << i << " global ref FOUND"  
00056            << " id: " << globalTrack1[i].id() << ", index: " << globalTrack1[i].key() 
00057            << endl;
00058       */
00059     }
00060     for( unsigned int i = 0; i < nd2; ++ i ) {
00061       daughters2[i] = z.daughter( i );
00062       trackerTrack2[i] = daughters2[i]->get<TrackRef>();
00063       stAloneTrack2[i] = daughters2[i]->get<TrackRef,reco::StandAloneMuonTag>();
00064       globalTrack2[i]  = daughters2[i]->get<TrackRef,reco::CombinedMuonTag>();
00065       
00066       /******************************************** just used for debug ************
00067     if (trackerTrack2[i].isNull()) 
00068       cout << "in ZMuSta daughter " << i << " tracker ref non found " << endl;
00069     else
00070       cout << "in ZMuSta daughter " << i << " tracker ref FOUND"  
00071            << " id: " << trackerTrack2[i].id() << ", index: " << trackerTrack2[i].key() 
00072            << endl;
00073     if (stAloneTrack2[i].isNull()) 
00074       cout << "in ZMuSta daughter " << i << " standalone ref non found " << endl;
00075     else
00076       cout << "in ZMuSta daughter " << i << " standalone ref FOUND" 
00077            << " id: " << stAloneTrack2[i].id() << ", index: " << stAloneTrack2[i].key() 
00078            << endl;
00079     
00080     if (globalTrack2[i].isNull()) 
00081       cout << "in ZMuSta daughter " << i << " global ref non found " << endl;
00082     else
00083       cout << "in ZMuSta daughter " << i << " global ref FOUND" 
00084            << " id: " << globalTrack2[i].id() << ", index: " << globalTrack2[i].key() 
00085            << endl;
00086            
00087       */  
00088     }
00089     for (unsigned int i = 0; i < nd1; i++) {
00090       flag = false;
00091       for (unsigned int j = 0; j < nd2; j++) {           // if the obj2 is a standalone the trackref is alwais in the trackerTRack position
00092         if ( ((trackerTrack2[i].id()==trackerTrack1[j].id()) && (trackerTrack2[i].key()==trackerTrack1[j].key())) ||
00093              ((trackerTrack2[i].id()==stAloneTrack1[j].id()) && (trackerTrack2[i].key()==stAloneTrack1[j].key())) ) {
00094           flag = true;
00095         }
00096       }
00097       if (flag) matched++;
00098     }
00099     if (matched==nd1) // return true if all the childrens of the ZMuMu have a children matched in ZMuXX
00100       return true;
00101     else 
00102       return false;
00103   }
00104 };
00105 
00106 typedef SingleObjectSelector<
00107   edm::View<reco::Candidate>,
00108   OverlapExclusionSelector<reco::CandidateView, 
00109                            reco::Candidate, 
00110                            ZMuMuOverlap>
00111   > ZMuMuOverlapExclusionSelector;
00112 
00113 #include "FWCore/Framework/interface/MakerMacros.h"
00114 
00115 DEFINE_FWK_MODULE(ZMuMuOverlapExclusionSelector);
00116 
00117