1 |
pharris |
1.11 |
// $Id: FillerMuons.cc,v 1.10 2008/08/08 11:21:08 sixie Exp $
|
2 |
loizides |
1.1 |
|
3 |
|
|
#include "MitProd/TreeFiller/interface/FillerMuons.h"
|
4 |
|
|
#include "FWCore/MessageLogger/interface/MessageLogger.h"
|
5 |
|
|
#include "DataFormats/Common/interface/Handle.h"
|
6 |
|
|
#include "DataFormats/MuonReco/interface/Muon.h"
|
7 |
|
|
#include "DataFormats/MuonReco/interface/MuonFwd.h"
|
8 |
pharris |
1.11 |
#include "RecoMuon/MuonIdentification/interface/IdGlobalFunctions.h"
|
9 |
|
|
#include "DataFormats/MuonReco/interface/MuonSelectors.h"
|
10 |
loizides |
1.1 |
#include "MitAna/DataTree/interface/Muon.h"
|
11 |
|
|
#include "MitAna/DataTree/interface/Track.h"
|
12 |
|
|
#include "MitAna/DataTree/interface/Names.h"
|
13 |
|
|
|
14 |
|
|
using namespace std;
|
15 |
|
|
using namespace edm;
|
16 |
|
|
using namespace mithep;
|
17 |
|
|
|
18 |
loizides |
1.4 |
//--------------------------------------------------------------------------------------------------
|
19 |
loizides |
1.9 |
FillerMuons::FillerMuons(const edm::ParameterSet &cfg, bool active) :
|
20 |
loizides |
1.7 |
BaseFiller(cfg,"Muons",active),
|
21 |
loizides |
1.1 |
edmName_(Conf().getUntrackedParameter<string>("edmName","muons")),
|
22 |
|
|
mitName_(Conf().getUntrackedParameter<string>("mitName",Names::gkMuonBrn)),
|
23 |
loizides |
1.9 |
globalTrackMapName_(Conf().getUntrackedParameter<string>("globalTrackMapName","")),
|
24 |
|
|
staTrackMapName_(Conf().getUntrackedParameter<string>("staTrackMapName","")),
|
25 |
|
|
staVtxTrackMapName_(Conf().getUntrackedParameter<string>("staVtxTrackMapName","")),
|
26 |
|
|
trackerTrackMapName_(Conf().getUntrackedParameter<string>("trackerTrackMapName","")),
|
27 |
|
|
globalTrackMap_(0),
|
28 |
|
|
standaloneTrackMap_(0),
|
29 |
|
|
standaloneVtxTrackMap_(0),
|
30 |
|
|
trackerTrackMap_(0),
|
31 |
pharris |
1.11 |
muons_(new mithep::MuonArr(16)),
|
32 |
|
|
fGMAllArbitrated(0), // all muons with the tracker muon arbitrated
|
33 |
|
|
fGMGlobalMuonPromptTight(0), // global muons with tighter fit requirements
|
34 |
|
|
fGMTMLastStationLoose(0), // penetration depth loose selector
|
35 |
|
|
fGMTMLastStationTight(0), // penetration depth tight selector
|
36 |
|
|
fGMTM2DCompatibilityLoose(0), // likelihood based loose selector
|
37 |
|
|
fGMTM2DCompatibilityTight(0) // likelihood based tight selector
|
38 |
loizides |
1.1 |
{
|
39 |
|
|
// Constructor.
|
40 |
|
|
}
|
41 |
|
|
|
42 |
loizides |
1.4 |
//--------------------------------------------------------------------------------------------------
|
43 |
loizides |
1.1 |
FillerMuons::~FillerMuons()
|
44 |
|
|
{
|
45 |
|
|
// Destructor.
|
46 |
pharris |
1.11 |
cout << "ALL Muons : " << fAll << endl;
|
47 |
|
|
cout << "ALL Arbitrated : " << fGMAllArbitrated << endl;
|
48 |
|
|
cout << "ALL Prompt Tight : " << fGMGlobalMuonPromptTight << endl;
|
49 |
|
|
cout << "ALL LastLoose : " << fGMTMLastStationLoose << endl;
|
50 |
|
|
cout << "ALL LastTight : " << fGMTMLastStationTight << endl;
|
51 |
|
|
cout << "ALL TMCOMPatLoose: " << fGMTM2DCompatibilityLoose << endl;
|
52 |
|
|
cout << "ALL TMCOMPatTIght: " << fGMTM2DCompatibilityTight << endl;
|
53 |
loizides |
1.5 |
|
54 |
|
|
delete muons_;
|
55 |
loizides |
1.1 |
}
|
56 |
|
|
|
57 |
loizides |
1.4 |
//--------------------------------------------------------------------------------------------------
|
58 |
loizides |
1.1 |
void FillerMuons::BookDataBlock(TreeWriter &tws)
|
59 |
pharris |
1.11 |
{ vector<string> lCuts; lCuts.push_back("test");
|
60 |
|
|
fTest = new AnaMuon("M",lCuts);
|
61 |
loizides |
1.9 |
// Add muons branch to tree and get pointers to maps.
|
62 |
loizides |
1.1 |
|
63 |
|
|
tws.AddBranch(mitName_.c_str(),&muons_);
|
64 |
loizides |
1.9 |
|
65 |
|
|
if (!globalTrackMapName_.empty())
|
66 |
|
|
globalTrackMap_ = OS()->get<TrackMap>(globalTrackMapName_.c_str());
|
67 |
|
|
if (!staTrackMapName_.empty())
|
68 |
|
|
standaloneTrackMap_ = OS()->get<TrackMap>(staTrackMapName_.c_str());
|
69 |
|
|
if (!staVtxTrackMapName_.empty())
|
70 |
|
|
standaloneVtxTrackMap_ = OS()->get<TrackMap>(staVtxTrackMapName_.c_str());
|
71 |
|
|
if (!trackerTrackMapName_.empty())
|
72 |
|
|
trackerTrackMap_ = OS()->get<TrackMap>(trackerTrackMapName_.c_str());
|
73 |
loizides |
1.1 |
}
|
74 |
|
|
|
75 |
loizides |
1.9 |
|
76 |
|
|
|
77 |
loizides |
1.4 |
//--------------------------------------------------------------------------------------------------
|
78 |
loizides |
1.1 |
void FillerMuons::FillDataBlock(const edm::Event &event,
|
79 |
loizides |
1.4 |
const edm::EventSetup &setup)
|
80 |
loizides |
1.1 |
{
|
81 |
|
|
// Fill muon information.
|
82 |
|
|
|
83 |
|
|
muons_->Reset();
|
84 |
|
|
|
85 |
loizides |
1.6 |
Handle<reco::MuonCollection> hMuonProduct;
|
86 |
sixie |
1.10 |
GetProduct(edmName_, hMuonProduct, event);
|
87 |
loizides |
1.6 |
const reco::MuonCollection inMuons = *(hMuonProduct.product());
|
88 |
loizides |
1.1 |
|
89 |
sixie |
1.10 |
for (reco::MuonCollection::const_iterator iM = inMuons.begin(); iM != inMuons.end(); ++iM) {
|
90 |
pharris |
1.11 |
fAll++;
|
91 |
|
|
if(iM->isGood(reco::Muon::AllArbitrated)) fGMAllArbitrated++;
|
92 |
|
|
if(iM->isGood(reco::Muon::GlobalMuonPromptTight)) fGMGlobalMuonPromptTight++;
|
93 |
|
|
if(iM->isGood(reco::Muon::TMLastStationLoose)) fGMTMLastStationLoose++;
|
94 |
|
|
if(iM->isGood(reco::Muon::TMLastStationTight)) fGMTMLastStationTight++;
|
95 |
|
|
if(iM->isGood(reco::Muon::TM2DCompatibilityLoose)) fGMTM2DCompatibilityLoose++;
|
96 |
|
|
if(iM->isGood(reco::Muon::TM2DCompatibilityTight)) fGMTM2DCompatibilityTight++;
|
97 |
|
|
|
98 |
sixie |
1.10 |
mithep::Muon* outMuon = muons_->AddNew();
|
99 |
|
|
outMuon->SetIsoR03SumPt(iM->isolationR03().sumPt);
|
100 |
|
|
outMuon->SetIsoR03EmEt(iM->isolationR03().emEt);
|
101 |
|
|
outMuon->SetIsoR03HadEt(iM->isolationR03().hadEt);
|
102 |
|
|
outMuon->SetIsoR03HoEt(iM->isolationR03().hoEt);
|
103 |
|
|
outMuon->SetIsoR03NTracks(iM->isolationR03().nTracks);
|
104 |
|
|
outMuon->SetIsoR03NJets(iM->isolationR03().nJets);
|
105 |
|
|
outMuon->SetIsoR05SumPt(iM->isolationR05().sumPt);
|
106 |
|
|
outMuon->SetIsoR05EmEt(iM->isolationR05().emEt);
|
107 |
|
|
outMuon->SetIsoR05HadEt(iM->isolationR05().hadEt);
|
108 |
|
|
outMuon->SetIsoR05HoEt(iM->isolationR05().hoEt);
|
109 |
|
|
outMuon->SetIsoR05NTracks(iM->isolationR05().nTracks);
|
110 |
|
|
outMuon->SetIsoR05NJets(iM->isolationR05().nJets);
|
111 |
|
|
outMuon->SetEmEnergy(iM->calEnergy().em);
|
112 |
|
|
outMuon->SetHadEnergy(iM->calEnergy().had);
|
113 |
|
|
outMuon->SetHoEnergy(iM->calEnergy().ho);
|
114 |
|
|
outMuon->SetEmS9Energy(iM->calEnergy().emS9);
|
115 |
|
|
outMuon->SetHadS9Energy(iM->calEnergy().hadS9);
|
116 |
|
|
outMuon->SetHoS9Energy(iM->calEnergy().hoS9);
|
117 |
pharris |
1.11 |
|
118 |
loizides |
1.1 |
if (globalTrackMap_ && iM->combinedMuon().isNonnull())
|
119 |
sixie |
1.10 |
outMuon->SetGlobalTrk(globalTrackMap_->GetMit(iM->combinedMuon()));
|
120 |
loizides |
1.1 |
if (standaloneTrackMap_ && standaloneVtxTrackMap_ && iM->standAloneMuon().isNonnull()) {
|
121 |
|
|
Int_t refProductId = iM->standAloneMuon().id().id();
|
122 |
|
|
if ( refProductId == standaloneVtxTrackMap_->GetEdmProductId())
|
123 |
sixie |
1.10 |
outMuon->SetStandaloneTrk(standaloneVtxTrackMap_->GetMit(iM->standAloneMuon()));
|
124 |
loizides |
1.1 |
else if ( refProductId == standaloneTrackMap_->GetEdmProductId())
|
125 |
sixie |
1.10 |
outMuon->SetStandaloneTrk(standaloneTrackMap_->GetMit(iM->standAloneMuon()));
|
126 |
loizides |
1.1 |
else throw edm::Exception(edm::errors::Configuration, "FillerMuons:FillDataBlock()\n")
|
127 |
sixie |
1.10 |
<< "Error! Track reference in unmapped collection " << edmName_ << endl;
|
128 |
loizides |
1.1 |
}
|
129 |
|
|
if (trackerTrackMap_ && iM->track().isNonnull())
|
130 |
loizides |
1.8 |
outMuon->SetTrackerTrk(trackerTrackMap_->GetMit(iM->track()));
|
131 |
pharris |
1.11 |
//PCH
|
132 |
|
|
//outMuon->SetNHits (iM->numberOfValidHits());
|
133 |
|
|
outMuon->SetNChambers (iM->numberOfChambers());
|
134 |
|
|
outMuon->SetStationMask(iM->stationMask(reco::Muon::SegmentAndTrackArbitration));
|
135 |
|
|
//outMuon->SetTrackStationMask(iM->stationMask(reco::Muon::TrackandSegment));
|
136 |
|
|
for(int i0 = 0; i0 < 4; i0++) {
|
137 |
|
|
//DTs
|
138 |
|
|
outMuon->SetDX(i0, iM->dX(i0+1,1));
|
139 |
|
|
outMuon->SetDY(i0, iM->dY(i0+1,1));
|
140 |
|
|
outMuon->SetPullX(i0, iM->pullX(i0+1,1));
|
141 |
|
|
outMuon->SetPullY(i0, iM->pullY(i0+1,1));
|
142 |
|
|
outMuon->SetTrackDist(i0, iM->trackDist(i0+1,1));
|
143 |
|
|
outMuon->SetTrackDistErr(i0, iM->trackDistErr(i0+1,1));
|
144 |
|
|
outMuon->SetNSegments(i0, iM->numberOfSegments(i0+1, 1));
|
145 |
|
|
//CSCs
|
146 |
|
|
outMuon->SetDX(4+i0, iM->dX (i0+1,2));
|
147 |
|
|
outMuon->SetDY(4+i0, iM->dY (i0+1,2));
|
148 |
|
|
outMuon->SetPullX(4+i0, iM->pullX (i0+1,2));
|
149 |
|
|
outMuon->SetPullY(4+i0, iM->pullY (i0+1,2));
|
150 |
|
|
outMuon->SetTrackDist(4+i0, iM->trackDist(i0+1,2));
|
151 |
|
|
outMuon->SetTrackDistErr(4+i0,iM->trackDistErr(i0+1,2));
|
152 |
|
|
outMuon->SetNSegments(4+i0, iM->numberOfSegments(i0+1,2));
|
153 |
|
|
//cout << "Dist 1 " << i0 << " -- "<< iM->trackDist(i0+1,1) << " -- " << endl;
|
154 |
|
|
}
|
155 |
|
|
// if (iM->isMatchesValid()) {
|
156 |
|
|
// std::vector<reco::MuonChamberMatch> lMatches = iM->matches();
|
157 |
|
|
// for( unsigned int i0 = 0; i0 < lSegments.size(); i0++) {
|
158 |
|
|
// std::vector<reco::MuonSegmentMatch> lSegements = lMatches[i0]->segmentMatches();
|
159 |
|
|
// for( unsigned int i1 = 0; i1 < lMatches.size(); i1++ ) {
|
160 |
|
|
// outMuon->SetSegmentMask(i1, lMatches[i1].mask);
|
161 |
|
|
// }
|
162 |
|
|
// }
|
163 |
|
|
// if(double(iM->caloCompatibility()) != double(fTest->getCaloCompatability(outMuon,true,true))) {
|
164 |
|
|
// cout << " Calo Compat ---> " << iM->caloCompatibility() << " -- " << fTest->getCaloCompatability (outMuon,true,true) << endl;
|
165 |
|
|
// cout << "----------> " << outMuon->Eta() << " -- " << outMuon->P() << " -- " << outMuon->EmEnergy() << " -- " << outMuon->HadEnergy() << " -- " << outMuon->HoEnergy() << endl;
|
166 |
|
|
// cout << "----------> " << iM->eta() << " -- " << iM->p() << " -- " << iM->calEnergy().em << " -- " << iM->calEnergy().had << " -- " << iM->calEnergy().ho << endl;
|
167 |
|
|
// }
|
168 |
|
|
|
169 |
|
|
if(muon::isGoodMuon(*iM,reco::Muon::TMLastStationTight) != fTest->isGoodMuon(outMuon,AnaMuon::TMLastStationTight) ||
|
170 |
|
|
muon::isGoodMuon(*iM,reco::Muon::TM2DCompatibilityLoose) != fTest->isGoodMuon(outMuon,AnaMuon::TM2DCompatibilityLoose) ||
|
171 |
|
|
muon::isGoodMuon(*iM,reco::Muon::TM2DCompatibilityTight) != fTest->isGoodMuon(outMuon,AnaMuon::TM2DCompatibilityTight)) {
|
172 |
|
|
|
173 |
|
|
if(muon::isGoodMuon(*iM,reco::Muon::TMLastStationTight)) cout << "Last---> Reco is True " << endl;
|
174 |
|
|
if(fTest->isGoodMuon(outMuon,AnaMuon::TMLastStationTight)) cout << "Last---> Ana is True " << endl;
|
175 |
|
|
|
176 |
|
|
|
177 |
|
|
if(muon::isGoodMuon(*iM,reco::Muon::TM2DCompatibilityLoose))
|
178 |
|
|
cout << "TMLoose---> Reco is True " << fTest->getCaloCompatability(outMuon,true,true) << " : " << iM->caloCompatibility() << " : "
|
179 |
|
|
<< fTest->getSegmentCompatability(outMuon) << " : " << muonid::getSegmentCompatibility(*iM) << endl;
|
180 |
|
|
if(fTest->isGoodMuon(outMuon,AnaMuon::TM2DCompatibilityLoose))
|
181 |
|
|
cout << "TMLoose---> Ana is True " << fTest->getCaloCompatability(outMuon,true,true) << " : " << iM->caloCompatibility() << " : "
|
182 |
|
|
<< fTest->getSegmentCompatability(outMuon) << " : " << muonid::getSegmentCompatibility(*iM) << endl;
|
183 |
|
|
if(muon::isGoodMuon(*iM,reco::Muon::TM2DCompatibilityTight))
|
184 |
|
|
cout << "TMTight---> Reco is True " << fTest->getCaloCompatability(outMuon,true,true) << " : " << iM->caloCompatibility() << " : "
|
185 |
|
|
<< fTest->getSegmentCompatability(outMuon) << " : " << muonid::getSegmentCompatibility(*iM) << endl;
|
186 |
|
|
if(fTest->isGoodMuon(outMuon,AnaMuon::TM2DCompatibilityTight))
|
187 |
|
|
cout << "TMTight---> Ana is True " << fTest->getCaloCompatability(outMuon,true,true) << " : " << iM->caloCompatibility() << " : "
|
188 |
|
|
<< fTest->getSegmentCompatability(outMuon) << " : " << muonid::getSegmentCompatibility(*iM) << endl;
|
189 |
|
|
|
190 |
|
|
cout << "Size --- > " << outMuon->NSegments() << " - " << iM->numberOfMatches(reco::Muon::SegmentArbitration) << endl;
|
191 |
|
|
|
192 |
|
|
for(int i0 = 0; i0 < 4; i0++) {
|
193 |
|
|
cout << "A---------> " << outMuon->GetDX(i0) << " -- " << outMuon->GetDY(i0) << " -- " << outMuon->GetPullX(i0) << " -- " << outMuon->GetPullY(i0) << " -- " << outMuon->GetTrackDist(i0) << " -- " << outMuon->GetTrackDistErr(i0) << " -- " << outMuon->GetNSegments(i0) << endl;
|
194 |
|
|
cout << "A1--------> " << iM->dX(i0+1,1) << " -- " << iM->dY(i0+1,1) << " -- " << iM->pullX(i0+1,1) << " -- " << iM->pullY(i0+1,1) << " -- " << iM->trackDist(i0+1,1) << " -- " << iM->trackDistErr(i0+1,1) << " -- " << iM->segmentX(i0+1,1) << " -- " << endl;
|
195 |
|
|
cout << "B---------> " << outMuon->GetDX(i0+4) << " -- " << outMuon->GetDY(i0+4) << " -- " << outMuon->GetPullX(i0+4) << " -- " << outMuon->GetPullY(i0+4) << " -- " << outMuon->GetTrackDist(i0+4) << " -- " << outMuon->GetTrackDistErr(i0+4) << " -- " << outMuon->GetNSegments(i0) << endl;
|
196 |
|
|
cout << "B1--------> " << iM->dX(i0+1,2) << " -- " << iM->dY(i0+1,2) << " -- " << iM->pullX(i0+1,2) << " -- " << iM->pullY(i0+1,2) << " -- " << iM->trackDist(i0+1,2) << " -- " << iM->trackDistErr(i0+1,2) << " -- " << iM->segmentX(i0+1,2) << endl;
|
197 |
|
|
}
|
198 |
|
|
}
|
199 |
|
|
|
200 |
|
|
if(fTest->isGoodMuon(outMuon,AnaMuon::AllArbitrated) != muon::isGoodMuon(*iM,reco::Muon::AllArbitrated)) {
|
201 |
|
|
if(muon::isGoodMuon(*iM,reco::Muon::AllArbitrated)) cout << "---> Reco is True " << endl;
|
202 |
|
|
if(fTest->isGoodMuon(outMuon,AnaMuon::AllArbitrated)) cout << "---> Ana is True " << endl;
|
203 |
|
|
cout << "All Arbitrated --- " << outMuon->NSegments() << " - " << iM->numberOfMatches(reco::Muon::SegmentAndTrackArbitration) << endl;
|
204 |
|
|
cout << "SA : " << outMuon->StandaloneTrk() << " GM: " << outMuon->GlobalTrk() << " : " << outMuon->TrackerTrk() << endl;
|
205 |
|
|
//if(outMuon->StandaloneTrk() != 0) cout << "S Eta : " << -log(tan(outMuon->StandaloneTrk()->Theta()/2.)) << endl;
|
206 |
|
|
//if(outMuon->TrackerTrk() != 0) cout << "T Eta : " << -log(tan(outMuon->TrackerTrk()->Theta()/2.)) << endl;
|
207 |
|
|
if(iM->isTrackerMuon()) cout << "Not Tracker Muon : ";
|
208 |
|
|
if(iM->isStandAloneMuon()) cout << "StandAlone Muon : ";
|
209 |
|
|
if(iM->isGlobalMuon()) cout << "Global Muon : ";
|
210 |
|
|
cout << endl;
|
211 |
|
|
}
|
212 |
|
|
}
|
213 |
loizides |
1.1 |
muons_->Trim();
|
214 |
|
|
}
|