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