1 |
sixie |
1.26 |
// $Id: FillerMuons.cc,v 1.25 2010/03/22 18:40:37 bendavid Exp $
|
2 |
loizides |
1.1 |
|
3 |
|
|
#include "MitProd/TreeFiller/interface/FillerMuons.h"
|
4 |
|
|
#include "DataFormats/MuonReco/interface/Muon.h"
|
5 |
sixie |
1.26 |
#include "DataFormats/MuonReco/interface/MuonQuality.h"
|
6 |
loizides |
1.1 |
#include "DataFormats/MuonReco/interface/MuonFwd.h"
|
7 |
sixie |
1.26 |
#include "DataFormats/MuonReco/interface/MuonSelectors.h"
|
8 |
bendavid |
1.15 |
#include "DataFormats/Common/interface/RefToPtr.h"
|
9 |
loizides |
1.22 |
#include "MitAna/DataTree/interface/Names.h"
|
10 |
|
|
#include "MitAna/DataTree/interface/MuonCol.h"
|
11 |
loizides |
1.1 |
#include "MitAna/DataTree/interface/Track.h"
|
12 |
loizides |
1.22 |
#include "MitProd/ObjectService/interface/ObjectService.h"
|
13 |
loizides |
1.1 |
|
14 |
|
|
using namespace std;
|
15 |
|
|
using namespace edm;
|
16 |
|
|
using namespace mithep;
|
17 |
|
|
|
18 |
loizides |
1.4 |
//--------------------------------------------------------------------------------------------------
|
19 |
loizides |
1.18 |
FillerMuons::FillerMuons(const edm::ParameterSet &cfg, const char *name, bool active) :
|
20 |
|
|
BaseFiller(cfg,name,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 |
bendavid |
1.19 |
muonMapName_(Conf().getUntrackedParameter<string>("muonMapName","")),
|
28 |
|
|
globalTrackMap_(0),
|
29 |
|
|
standaloneTrackMap_(0),
|
30 |
|
|
standaloneVtxTrackMap_(0),
|
31 |
loizides |
1.9 |
trackerTrackMap_(0),
|
32 |
bendavid |
1.19 |
muonMap_(new mithep::MuonMap),
|
33 |
pharris |
1.12 |
muons_(new mithep::MuonArr(16))
|
34 |
loizides |
1.1 |
{
|
35 |
|
|
// Constructor.
|
36 |
|
|
}
|
37 |
|
|
|
38 |
loizides |
1.4 |
//--------------------------------------------------------------------------------------------------
|
39 |
loizides |
1.20 |
FillerMuons::~FillerMuons()
|
40 |
|
|
{
|
41 |
|
|
// Destructor.
|
42 |
|
|
|
43 |
loizides |
1.5 |
delete muons_;
|
44 |
bendavid |
1.19 |
delete muonMap_;
|
45 |
loizides |
1.1 |
}
|
46 |
|
|
|
47 |
loizides |
1.4 |
//--------------------------------------------------------------------------------------------------
|
48 |
bendavid |
1.24 |
void FillerMuons::BookDataBlock(TreeWriter &tws)
|
49 |
loizides |
1.20 |
{
|
50 |
loizides |
1.9 |
// Add muons branch to tree and get pointers to maps.
|
51 |
loizides |
1.1 |
|
52 |
loizides |
1.20 |
tws.AddBranch(mitName_,&muons_);
|
53 |
|
|
OS()->add<mithep::MuonArr>(muons_,mitName_);
|
54 |
bendavid |
1.19 |
|
55 |
loizides |
1.20 |
if (!globalTrackMapName_.empty()) {
|
56 |
|
|
globalTrackMap_ = OS()->get<TrackMap>(globalTrackMapName_);
|
57 |
|
|
if (globalTrackMap_)
|
58 |
|
|
AddBranchDep(mitName_,globalTrackMap_->GetBrName());
|
59 |
|
|
}
|
60 |
|
|
if (!staTrackMapName_.empty()) {
|
61 |
|
|
standaloneTrackMap_ = OS()->get<TrackMap>(staTrackMapName_);
|
62 |
|
|
if (standaloneTrackMap_)
|
63 |
|
|
AddBranchDep(mitName_,standaloneTrackMap_->GetBrName());
|
64 |
|
|
}
|
65 |
|
|
if (!staVtxTrackMapName_.empty()) {
|
66 |
|
|
standaloneVtxTrackMap_ = OS()->get<TrackMap>(staVtxTrackMapName_);
|
67 |
|
|
if (standaloneVtxTrackMap_)
|
68 |
|
|
AddBranchDep(mitName_,standaloneVtxTrackMap_->GetBrName());
|
69 |
|
|
}
|
70 |
|
|
if (!trackerTrackMapName_.empty()) {
|
71 |
|
|
trackerTrackMap_ = OS()->get<TrackMap>(trackerTrackMapName_);
|
72 |
|
|
if (trackerTrackMap_)
|
73 |
|
|
AddBranchDep(mitName_,trackerTrackMap_->GetBrName());
|
74 |
|
|
}
|
75 |
|
|
if (!muonMapName_.empty()) {
|
76 |
|
|
muonMap_->SetBrName(mitName_);
|
77 |
|
|
OS()->add<MuonMap>(muonMap_,muonMapName_);
|
78 |
|
|
}
|
79 |
loizides |
1.1 |
}
|
80 |
|
|
|
81 |
loizides |
1.4 |
//--------------------------------------------------------------------------------------------------
|
82 |
loizides |
1.1 |
void FillerMuons::FillDataBlock(const edm::Event &event,
|
83 |
loizides |
1.4 |
const edm::EventSetup &setup)
|
84 |
loizides |
1.1 |
{
|
85 |
|
|
// Fill muon information.
|
86 |
|
|
|
87 |
bendavid |
1.16 |
muons_->Delete();
|
88 |
bendavid |
1.19 |
muonMap_->Reset();
|
89 |
loizides |
1.1 |
|
90 |
loizides |
1.6 |
Handle<reco::MuonCollection> hMuonProduct;
|
91 |
sixie |
1.10 |
GetProduct(edmName_, hMuonProduct, event);
|
92 |
loizides |
1.6 |
const reco::MuonCollection inMuons = *(hMuonProduct.product());
|
93 |
loizides |
1.1 |
|
94 |
sixie |
1.10 |
for (reco::MuonCollection::const_iterator iM = inMuons.begin(); iM != inMuons.end(); ++iM) {
|
95 |
bendavid |
1.25 |
mithep::Muon* outMuon = muons_->AddNew();
|
96 |
|
|
|
97 |
|
|
outMuon->SetPtEtaPhi(iM->pt(),iM->eta(),iM->phi());
|
98 |
|
|
outMuon->SetCharge(iM->charge());
|
99 |
|
|
|
100 |
sixie |
1.10 |
outMuon->SetIsoR03SumPt(iM->isolationR03().sumPt);
|
101 |
|
|
outMuon->SetIsoR03EmEt(iM->isolationR03().emEt);
|
102 |
|
|
outMuon->SetIsoR03HadEt(iM->isolationR03().hadEt);
|
103 |
|
|
outMuon->SetIsoR03HoEt(iM->isolationR03().hoEt);
|
104 |
|
|
outMuon->SetIsoR03NTracks(iM->isolationR03().nTracks);
|
105 |
|
|
outMuon->SetIsoR03NJets(iM->isolationR03().nJets);
|
106 |
|
|
outMuon->SetIsoR05SumPt(iM->isolationR05().sumPt);
|
107 |
|
|
outMuon->SetIsoR05EmEt(iM->isolationR05().emEt);
|
108 |
|
|
outMuon->SetIsoR05HadEt(iM->isolationR05().hadEt);
|
109 |
|
|
outMuon->SetIsoR05HoEt(iM->isolationR05().hoEt);
|
110 |
|
|
outMuon->SetIsoR05NTracks(iM->isolationR05().nTracks);
|
111 |
|
|
outMuon->SetIsoR05NJets(iM->isolationR05().nJets);
|
112 |
|
|
outMuon->SetEmEnergy(iM->calEnergy().em);
|
113 |
|
|
outMuon->SetHadEnergy(iM->calEnergy().had);
|
114 |
|
|
outMuon->SetHoEnergy(iM->calEnergy().ho);
|
115 |
|
|
outMuon->SetEmS9Energy(iM->calEnergy().emS9);
|
116 |
|
|
outMuon->SetHadS9Energy(iM->calEnergy().hadS9);
|
117 |
|
|
outMuon->SetHoS9Energy(iM->calEnergy().hoS9);
|
118 |
bendavid |
1.17 |
outMuon->SetIsGlobalMuon(iM->isGlobalMuon());
|
119 |
|
|
outMuon->SetIsTrackerMuon(iM->isTrackerMuon());
|
120 |
|
|
outMuon->SetIsStandaloneMuon(iM->isStandAloneMuon());
|
121 |
|
|
outMuon->SetIsCaloMuon(iM->isCaloMuon());
|
122 |
pharris |
1.11 |
|
123 |
sixie |
1.26 |
//save results from the muon selector in the MuonQuality bitmask
|
124 |
|
|
outMuon->Quality().SetQuality(MuonQuality::All);
|
125 |
|
|
if (muon::isGoodMuon(*iM,muon::AllGlobalMuons))
|
126 |
|
|
outMuon->Quality().SetQuality(MuonQuality::AllGlobalMuons);
|
127 |
|
|
if (muon::isGoodMuon(*iM,muon::AllStandAloneMuons))
|
128 |
|
|
outMuon->Quality().SetQuality(MuonQuality::AllStandAloneMuons);
|
129 |
|
|
if (muon::isGoodMuon(*iM,muon::AllTrackerMuons))
|
130 |
|
|
outMuon->Quality().SetQuality(MuonQuality::AllTrackerMuons);
|
131 |
|
|
if (muon::isGoodMuon(*iM,muon::TrackerMuonArbitrated))
|
132 |
|
|
outMuon->Quality().SetQuality(MuonQuality::TrackerMuonArbitrated);
|
133 |
|
|
if (muon::isGoodMuon(*iM,muon::AllArbitrated))
|
134 |
|
|
outMuon->Quality().SetQuality(MuonQuality::AllArbitrated);
|
135 |
|
|
if (muon::isGoodMuon(*iM,muon::GlobalMuonPromptTight))
|
136 |
|
|
outMuon->Quality().SetQuality(MuonQuality::GlobalMuonPromptTight);
|
137 |
|
|
if (muon::isGoodMuon(*iM,muon::TMLastStationLoose))
|
138 |
|
|
outMuon->Quality().SetQuality(MuonQuality::TMLastStationLoose);
|
139 |
|
|
if (muon::isGoodMuon(*iM,muon::TMLastStationTight))
|
140 |
|
|
outMuon->Quality().SetQuality(MuonQuality::TMLastStationTight);
|
141 |
|
|
if (muon::isGoodMuon(*iM,muon::TM2DCompatibilityLoose))
|
142 |
|
|
outMuon->Quality().SetQuality(MuonQuality::TM2DCompatibilityLoose);
|
143 |
|
|
if (muon::isGoodMuon(*iM,muon::TM2DCompatibilityTight))
|
144 |
|
|
outMuon->Quality().SetQuality(MuonQuality::TM2DCompatibilityTight);
|
145 |
|
|
if (muon::isGoodMuon(*iM,muon::TMOneStationLoose))
|
146 |
|
|
outMuon->Quality().SetQuality(MuonQuality::TMOneStationLoose);
|
147 |
|
|
if (muon::isGoodMuon(*iM,muon::TMOneStationTight))
|
148 |
|
|
outMuon->Quality().SetQuality(MuonQuality::TMOneStationTight);
|
149 |
|
|
if (muon::isGoodMuon(*iM,muon::TMLastStationOptimizedLowPtLoose))
|
150 |
|
|
outMuon->Quality().SetQuality(MuonQuality::TMLastStationOptimizedLowPtLoose);
|
151 |
|
|
if (muon::isGoodMuon(*iM,muon::TMLastStationOptimizedLowPtTight))
|
152 |
|
|
outMuon->Quality().SetQuality(MuonQuality::TMLastStationOptimizedLowPtTight);
|
153 |
|
|
if (muon::isGoodMuon(*iM,muon::GMTkChiCompatibility))
|
154 |
|
|
outMuon->Quality().SetQuality(MuonQuality::GMTkChiCompatibility);
|
155 |
|
|
if (muon::isGoodMuon(*iM,muon::GMStaChiCompatibility))
|
156 |
|
|
outMuon->Quality().SetQuality(MuonQuality::GMStaChiCompatibility);
|
157 |
|
|
if (muon::isGoodMuon(*iM,muon::GMTkKinkTight))
|
158 |
|
|
outMuon->Quality().SetQuality(MuonQuality::GMTkKinkTight);
|
159 |
|
|
if (muon::isGoodMuon(*iM,muon::TMLastStationAngLoose))
|
160 |
|
|
outMuon->Quality().SetQuality(MuonQuality::TMLastStationAngLoose);
|
161 |
|
|
if (muon::isGoodMuon(*iM,muon::TMLastStationAngTight))
|
162 |
|
|
outMuon->Quality().SetQuality(MuonQuality::TMLastStationAngTight);
|
163 |
|
|
if (muon::isGoodMuon(*iM,muon::TMOneStationAngLoose))
|
164 |
|
|
outMuon->Quality().SetQuality(MuonQuality::TMOneStationAngLoose);
|
165 |
|
|
if (muon::isGoodMuon(*iM,muon::TMOneStationAngTight))
|
166 |
|
|
outMuon->Quality().SetQuality(MuonQuality::TMOneStationAngTight);
|
167 |
|
|
if (muon::isGoodMuon(*iM,muon::TMLastStationOptimizedBarrelLowPtLoose))
|
168 |
|
|
outMuon->Quality().SetQuality(MuonQuality::TMLastStationOptimizedBarrelLowPtLoose);
|
169 |
|
|
if (muon::isGoodMuon(*iM,muon::TMLastStationOptimizedBarrelLowPtTight))
|
170 |
|
|
outMuon->Quality().SetQuality(MuonQuality::TMLastStationOptimizedBarrelLowPtTight);
|
171 |
|
|
|
172 |
|
|
|
173 |
loizides |
1.1 |
if (globalTrackMap_ && iM->combinedMuon().isNonnull())
|
174 |
bendavid |
1.15 |
outMuon->SetGlobalTrk(globalTrackMap_->GetMit(refToPtr(iM->combinedMuon())));
|
175 |
loizides |
1.1 |
if (standaloneTrackMap_ && standaloneVtxTrackMap_ && iM->standAloneMuon().isNonnull()) {
|
176 |
|
|
Int_t refProductId = iM->standAloneMuon().id().id();
|
177 |
|
|
if ( refProductId == standaloneVtxTrackMap_->GetEdmProductId())
|
178 |
bendavid |
1.15 |
outMuon->SetStandaloneTrk(standaloneVtxTrackMap_->GetMit(refToPtr(iM->standAloneMuon())));
|
179 |
loizides |
1.1 |
else if ( refProductId == standaloneTrackMap_->GetEdmProductId())
|
180 |
bendavid |
1.15 |
outMuon->SetStandaloneTrk(standaloneTrackMap_->GetMit(refToPtr(iM->standAloneMuon())));
|
181 |
loizides |
1.1 |
else throw edm::Exception(edm::errors::Configuration, "FillerMuons:FillDataBlock()\n")
|
182 |
loizides |
1.14 |
<< "Error! Track reference in unmapped collection " << edmName_ << endl;
|
183 |
loizides |
1.1 |
}
|
184 |
|
|
if (trackerTrackMap_ && iM->track().isNonnull())
|
185 |
bendavid |
1.15 |
outMuon->SetTrackerTrk(trackerTrackMap_->GetMit(refToPtr(iM->track())));
|
186 |
loizides |
1.14 |
|
187 |
|
|
outMuon->SetNChambers (iM->numberOfChambers());
|
188 |
pharris |
1.11 |
outMuon->SetStationMask(iM->stationMask(reco::Muon::SegmentAndTrackArbitration));
|
189 |
loizides |
1.14 |
for(int i0 = 0; i0 < 4; i0++) {
|
190 |
loizides |
1.20 |
// DTs
|
191 |
pharris |
1.11 |
outMuon->SetDX(i0, iM->dX(i0+1,1));
|
192 |
|
|
outMuon->SetDY(i0, iM->dY(i0+1,1));
|
193 |
|
|
outMuon->SetPullX(i0, iM->pullX(i0+1,1));
|
194 |
|
|
outMuon->SetPullY(i0, iM->pullY(i0+1,1));
|
195 |
|
|
outMuon->SetTrackDist(i0, iM->trackDist(i0+1,1));
|
196 |
|
|
outMuon->SetTrackDistErr(i0, iM->trackDistErr(i0+1,1));
|
197 |
loizides |
1.14 |
outMuon->SetNSegments(i0, iM->numberOfSegments(i0+1,1));
|
198 |
loizides |
1.20 |
// CSCs
|
199 |
pharris |
1.11 |
outMuon->SetDX(4+i0, iM->dX (i0+1,2));
|
200 |
|
|
outMuon->SetDY(4+i0, iM->dY (i0+1,2));
|
201 |
|
|
outMuon->SetPullX(4+i0, iM->pullX (i0+1,2));
|
202 |
|
|
outMuon->SetPullY(4+i0, iM->pullY (i0+1,2));
|
203 |
|
|
outMuon->SetTrackDist(4+i0, iM->trackDist(i0+1,2));
|
204 |
|
|
outMuon->SetTrackDistErr(4+i0,iM->trackDistErr(i0+1,2));
|
205 |
|
|
outMuon->SetNSegments(4+i0, iM->numberOfSegments(i0+1,2));
|
206 |
|
|
}
|
207 |
bendavid |
1.19 |
|
208 |
loizides |
1.20 |
// add muon to map
|
209 |
bendavid |
1.19 |
edm::Ptr<reco::Muon> thePtr(hMuonProduct, iM - inMuons.begin());
|
210 |
|
|
muonMap_->Add(thePtr, outMuon);
|
211 |
bendavid |
1.21 |
|
212 |
|
|
if (verbose_>1) {
|
213 |
|
|
if (!outMuon->HasGlobalTrk() && !outMuon->HasStandaloneTrk()) {
|
214 |
|
|
printf("mithep::Muon, pt=%5f, eta=%5f, phi=%5f, mass=%5f\n",outMuon->Pt(),outMuon->Eta(),outMuon->Phi(), outMuon->Mass());
|
215 |
|
|
printf(" reco::Muon, pt=%5f, eta=%5f, phi=%5f, mass=%5f\n",iM->pt(),iM->eta(),iM->phi(),iM->mass());
|
216 |
|
|
}
|
217 |
|
|
}
|
218 |
bendavid |
1.19 |
|
219 |
pharris |
1.11 |
}
|
220 |
loizides |
1.1 |
muons_->Trim();
|
221 |
|
|
}
|