1 |
pharris |
1.42 |
// $Id: FillerMuons.cc,v 1.41 2011/05/20 16:52: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 |
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 |
bendavid |
1.28 |
#include "RecoVertex/KalmanVertexFit/interface/KalmanVertexTrackCompatibilityEstimator.h"
|
14 |
loizides |
1.22 |
#include "MitAna/DataTree/interface/Names.h"
|
15 |
|
|
#include "MitAna/DataTree/interface/MuonCol.h"
|
16 |
loizides |
1.1 |
#include "MitAna/DataTree/interface/Track.h"
|
17 |
loizides |
1.22 |
#include "MitProd/ObjectService/interface/ObjectService.h"
|
18 |
bendavid |
1.37 |
#include "RecoVertex/VertexTools/interface/LinearizedTrackStateFactory.h"
|
19 |
|
|
#include "RecoVertex/VertexTools/interface/VertexTrackFactory.h"
|
20 |
|
|
#include "RecoVertex/VertexPrimitives/interface/VertexTrack.h"
|
21 |
|
|
#include "RecoVertex/VertexPrimitives/interface/CachingVertex.h"
|
22 |
|
|
#include "RecoVertex/KalmanVertexFit/interface/KalmanVertexUpdator.h"
|
23 |
ksung |
1.40 |
#include "MitEdm/Tools/interface/VertexReProducer.h"
|
24 |
loizides |
1.1 |
|
25 |
|
|
using namespace std;
|
26 |
|
|
using namespace edm;
|
27 |
|
|
using namespace mithep;
|
28 |
|
|
|
29 |
loizides |
1.4 |
//--------------------------------------------------------------------------------------------------
|
30 |
loizides |
1.18 |
FillerMuons::FillerMuons(const edm::ParameterSet &cfg, const char *name, bool active) :
|
31 |
|
|
BaseFiller(cfg,name,active),
|
32 |
loizides |
1.1 |
edmName_(Conf().getUntrackedParameter<string>("edmName","muons")),
|
33 |
bendavid |
1.32 |
expectedHitsName_(Conf().getUntrackedParameter<string>("expectedHitsName","")),
|
34 |
loizides |
1.1 |
mitName_(Conf().getUntrackedParameter<string>("mitName",Names::gkMuonBrn)),
|
35 |
loizides |
1.9 |
globalTrackMapName_(Conf().getUntrackedParameter<string>("globalTrackMapName","")),
|
36 |
|
|
staTrackMapName_(Conf().getUntrackedParameter<string>("staTrackMapName","")),
|
37 |
|
|
staVtxTrackMapName_(Conf().getUntrackedParameter<string>("staVtxTrackMapName","")),
|
38 |
|
|
trackerTrackMapName_(Conf().getUntrackedParameter<string>("trackerTrackMapName","")),
|
39 |
bendavid |
1.19 |
muonMapName_(Conf().getUntrackedParameter<string>("muonMapName","")),
|
40 |
bendavid |
1.27 |
pvEdmName_(Conf().getUntrackedParameter<string>("pvEdmName","offlinePrimaryVertices")),
|
41 |
bendavid |
1.38 |
pvBSEdmName_(Conf().getUntrackedParameter<string>("pvBSEdmName","offlinePrimaryVerticesWithBS")),
|
42 |
pharris |
1.42 |
fitUnbiasedVertex_(Conf().getUntrackedParameter<bool>("fitUnbiasedVertex",true)),
|
43 |
bendavid |
1.19 |
globalTrackMap_(0),
|
44 |
|
|
standaloneTrackMap_(0),
|
45 |
|
|
standaloneVtxTrackMap_(0),
|
46 |
loizides |
1.9 |
trackerTrackMap_(0),
|
47 |
bendavid |
1.19 |
muonMap_(new mithep::MuonMap),
|
48 |
pharris |
1.12 |
muons_(new mithep::MuonArr(16))
|
49 |
loizides |
1.1 |
{
|
50 |
|
|
// Constructor.
|
51 |
|
|
}
|
52 |
|
|
|
53 |
loizides |
1.4 |
//--------------------------------------------------------------------------------------------------
|
54 |
loizides |
1.20 |
FillerMuons::~FillerMuons()
|
55 |
|
|
{
|
56 |
|
|
// Destructor.
|
57 |
|
|
|
58 |
loizides |
1.5 |
delete muons_;
|
59 |
bendavid |
1.19 |
delete muonMap_;
|
60 |
loizides |
1.1 |
}
|
61 |
|
|
|
62 |
loizides |
1.4 |
//--------------------------------------------------------------------------------------------------
|
63 |
bendavid |
1.24 |
void FillerMuons::BookDataBlock(TreeWriter &tws)
|
64 |
loizides |
1.20 |
{
|
65 |
loizides |
1.9 |
// Add muons branch to tree and get pointers to maps.
|
66 |
loizides |
1.1 |
|
67 |
loizides |
1.20 |
tws.AddBranch(mitName_,&muons_);
|
68 |
|
|
OS()->add<mithep::MuonArr>(muons_,mitName_);
|
69 |
bendavid |
1.19 |
|
70 |
loizides |
1.20 |
if (!globalTrackMapName_.empty()) {
|
71 |
|
|
globalTrackMap_ = OS()->get<TrackMap>(globalTrackMapName_);
|
72 |
|
|
if (globalTrackMap_)
|
73 |
|
|
AddBranchDep(mitName_,globalTrackMap_->GetBrName());
|
74 |
|
|
}
|
75 |
|
|
if (!staTrackMapName_.empty()) {
|
76 |
|
|
standaloneTrackMap_ = OS()->get<TrackMap>(staTrackMapName_);
|
77 |
|
|
if (standaloneTrackMap_)
|
78 |
|
|
AddBranchDep(mitName_,standaloneTrackMap_->GetBrName());
|
79 |
|
|
}
|
80 |
|
|
if (!staVtxTrackMapName_.empty()) {
|
81 |
|
|
standaloneVtxTrackMap_ = OS()->get<TrackMap>(staVtxTrackMapName_);
|
82 |
|
|
if (standaloneVtxTrackMap_)
|
83 |
|
|
AddBranchDep(mitName_,standaloneVtxTrackMap_->GetBrName());
|
84 |
|
|
}
|
85 |
|
|
if (!trackerTrackMapName_.empty()) {
|
86 |
|
|
trackerTrackMap_ = OS()->get<TrackMap>(trackerTrackMapName_);
|
87 |
|
|
if (trackerTrackMap_)
|
88 |
|
|
AddBranchDep(mitName_,trackerTrackMap_->GetBrName());
|
89 |
|
|
}
|
90 |
|
|
if (!muonMapName_.empty()) {
|
91 |
|
|
muonMap_->SetBrName(mitName_);
|
92 |
|
|
OS()->add<MuonMap>(muonMap_,muonMapName_);
|
93 |
|
|
}
|
94 |
loizides |
1.1 |
}
|
95 |
|
|
|
96 |
loizides |
1.4 |
//--------------------------------------------------------------------------------------------------
|
97 |
loizides |
1.1 |
void FillerMuons::FillDataBlock(const edm::Event &event,
|
98 |
loizides |
1.4 |
const edm::EventSetup &setup)
|
99 |
loizides |
1.1 |
{
|
100 |
|
|
// Fill muon information.
|
101 |
|
|
|
102 |
bendavid |
1.16 |
muons_->Delete();
|
103 |
bendavid |
1.19 |
muonMap_->Reset();
|
104 |
loizides |
1.1 |
|
105 |
loizides |
1.6 |
Handle<reco::MuonCollection> hMuonProduct;
|
106 |
sixie |
1.10 |
GetProduct(edmName_, hMuonProduct, event);
|
107 |
loizides |
1.6 |
const reco::MuonCollection inMuons = *(hMuonProduct.product());
|
108 |
loizides |
1.1 |
|
109 |
bendavid |
1.27 |
edm::Handle<reco::VertexCollection> hVertex;
|
110 |
|
|
event.getByLabel(pvEdmName_, hVertex);
|
111 |
|
|
const reco::VertexCollection *pvCol = hVertex.product();
|
112 |
|
|
|
113 |
|
|
edm::Handle<reco::VertexCollection> hVertexBS;
|
114 |
|
|
event.getByLabel(pvBSEdmName_, hVertexBS);
|
115 |
|
|
const reco::VertexCollection *pvBSCol = hVertexBS.product();
|
116 |
bendavid |
1.32 |
|
117 |
bendavid |
1.27 |
edm::ESHandle<TransientTrackBuilder> hTransientTrackBuilder;
|
118 |
|
|
setup.get<TransientTrackRecord>().get("TransientTrackBuilder",hTransientTrackBuilder);
|
119 |
|
|
const TransientTrackBuilder *transientTrackBuilder = hTransientTrackBuilder.product();
|
120 |
|
|
|
121 |
bendavid |
1.28 |
KalmanVertexTrackCompatibilityEstimator<5> kalmanEstimator;
|
122 |
|
|
|
123 |
bendavid |
1.37 |
LinearizedTrackStateFactory lTrackFactory;
|
124 |
|
|
VertexTrackFactory<5> vTrackFactory;
|
125 |
|
|
KalmanVertexUpdator<5> updator;
|
126 |
|
|
|
127 |
sixie |
1.10 |
for (reco::MuonCollection::const_iterator iM = inMuons.begin(); iM != inMuons.end(); ++iM) {
|
128 |
bendavid |
1.25 |
mithep::Muon* outMuon = muons_->AddNew();
|
129 |
|
|
|
130 |
|
|
outMuon->SetPtEtaPhi(iM->pt(),iM->eta(),iM->phi());
|
131 |
|
|
outMuon->SetCharge(iM->charge());
|
132 |
|
|
|
133 |
sixie |
1.10 |
outMuon->SetIsoR03SumPt(iM->isolationR03().sumPt);
|
134 |
|
|
outMuon->SetIsoR03EmEt(iM->isolationR03().emEt);
|
135 |
|
|
outMuon->SetIsoR03HadEt(iM->isolationR03().hadEt);
|
136 |
|
|
outMuon->SetIsoR03HoEt(iM->isolationR03().hoEt);
|
137 |
|
|
outMuon->SetIsoR03NTracks(iM->isolationR03().nTracks);
|
138 |
|
|
outMuon->SetIsoR03NJets(iM->isolationR03().nJets);
|
139 |
|
|
outMuon->SetIsoR05SumPt(iM->isolationR05().sumPt);
|
140 |
|
|
outMuon->SetIsoR05EmEt(iM->isolationR05().emEt);
|
141 |
|
|
outMuon->SetIsoR05HadEt(iM->isolationR05().hadEt);
|
142 |
|
|
outMuon->SetIsoR05HoEt(iM->isolationR05().hoEt);
|
143 |
|
|
outMuon->SetIsoR05NTracks(iM->isolationR05().nTracks);
|
144 |
|
|
outMuon->SetIsoR05NJets(iM->isolationR05().nJets);
|
145 |
|
|
outMuon->SetEmEnergy(iM->calEnergy().em);
|
146 |
|
|
outMuon->SetHadEnergy(iM->calEnergy().had);
|
147 |
|
|
outMuon->SetHoEnergy(iM->calEnergy().ho);
|
148 |
|
|
outMuon->SetEmS9Energy(iM->calEnergy().emS9);
|
149 |
|
|
outMuon->SetHadS9Energy(iM->calEnergy().hadS9);
|
150 |
|
|
outMuon->SetHoS9Energy(iM->calEnergy().hoS9);
|
151 |
bendavid |
1.17 |
outMuon->SetIsGlobalMuon(iM->isGlobalMuon());
|
152 |
|
|
outMuon->SetIsTrackerMuon(iM->isTrackerMuon());
|
153 |
|
|
outMuon->SetIsStandaloneMuon(iM->isStandAloneMuon());
|
154 |
|
|
outMuon->SetIsCaloMuon(iM->isCaloMuon());
|
155 |
pharris |
1.11 |
|
156 |
bendavid |
1.41 |
//kink algorithm
|
157 |
|
|
outMuon->SetTrkKink(iM->combinedQuality().trkKink);
|
158 |
|
|
outMuon->SetGlbKink(iM->combinedQuality().glbKink);
|
159 |
|
|
|
160 |
sixie |
1.26 |
//save results from the muon selector in the MuonQuality bitmask
|
161 |
|
|
outMuon->Quality().SetQuality(MuonQuality::All);
|
162 |
|
|
if (muon::isGoodMuon(*iM,muon::AllGlobalMuons))
|
163 |
|
|
outMuon->Quality().SetQuality(MuonQuality::AllGlobalMuons);
|
164 |
|
|
if (muon::isGoodMuon(*iM,muon::AllStandAloneMuons))
|
165 |
|
|
outMuon->Quality().SetQuality(MuonQuality::AllStandAloneMuons);
|
166 |
|
|
if (muon::isGoodMuon(*iM,muon::AllTrackerMuons))
|
167 |
|
|
outMuon->Quality().SetQuality(MuonQuality::AllTrackerMuons);
|
168 |
|
|
if (muon::isGoodMuon(*iM,muon::TrackerMuonArbitrated))
|
169 |
|
|
outMuon->Quality().SetQuality(MuonQuality::TrackerMuonArbitrated);
|
170 |
|
|
if (muon::isGoodMuon(*iM,muon::AllArbitrated))
|
171 |
|
|
outMuon->Quality().SetQuality(MuonQuality::AllArbitrated);
|
172 |
|
|
if (muon::isGoodMuon(*iM,muon::GlobalMuonPromptTight))
|
173 |
|
|
outMuon->Quality().SetQuality(MuonQuality::GlobalMuonPromptTight);
|
174 |
|
|
if (muon::isGoodMuon(*iM,muon::TMLastStationLoose))
|
175 |
|
|
outMuon->Quality().SetQuality(MuonQuality::TMLastStationLoose);
|
176 |
|
|
if (muon::isGoodMuon(*iM,muon::TMLastStationTight))
|
177 |
|
|
outMuon->Quality().SetQuality(MuonQuality::TMLastStationTight);
|
178 |
|
|
if (muon::isGoodMuon(*iM,muon::TM2DCompatibilityLoose))
|
179 |
|
|
outMuon->Quality().SetQuality(MuonQuality::TM2DCompatibilityLoose);
|
180 |
|
|
if (muon::isGoodMuon(*iM,muon::TM2DCompatibilityTight))
|
181 |
|
|
outMuon->Quality().SetQuality(MuonQuality::TM2DCompatibilityTight);
|
182 |
|
|
if (muon::isGoodMuon(*iM,muon::TMOneStationLoose))
|
183 |
|
|
outMuon->Quality().SetQuality(MuonQuality::TMOneStationLoose);
|
184 |
|
|
if (muon::isGoodMuon(*iM,muon::TMOneStationTight))
|
185 |
|
|
outMuon->Quality().SetQuality(MuonQuality::TMOneStationTight);
|
186 |
|
|
if (muon::isGoodMuon(*iM,muon::TMLastStationOptimizedLowPtLoose))
|
187 |
|
|
outMuon->Quality().SetQuality(MuonQuality::TMLastStationOptimizedLowPtLoose);
|
188 |
|
|
if (muon::isGoodMuon(*iM,muon::TMLastStationOptimizedLowPtTight))
|
189 |
|
|
outMuon->Quality().SetQuality(MuonQuality::TMLastStationOptimizedLowPtTight);
|
190 |
|
|
if (muon::isGoodMuon(*iM,muon::GMTkChiCompatibility))
|
191 |
|
|
outMuon->Quality().SetQuality(MuonQuality::GMTkChiCompatibility);
|
192 |
|
|
if (muon::isGoodMuon(*iM,muon::GMStaChiCompatibility))
|
193 |
|
|
outMuon->Quality().SetQuality(MuonQuality::GMStaChiCompatibility);
|
194 |
|
|
if (muon::isGoodMuon(*iM,muon::GMTkKinkTight))
|
195 |
|
|
outMuon->Quality().SetQuality(MuonQuality::GMTkKinkTight);
|
196 |
|
|
if (muon::isGoodMuon(*iM,muon::TMLastStationAngLoose))
|
197 |
|
|
outMuon->Quality().SetQuality(MuonQuality::TMLastStationAngLoose);
|
198 |
|
|
if (muon::isGoodMuon(*iM,muon::TMLastStationAngTight))
|
199 |
|
|
outMuon->Quality().SetQuality(MuonQuality::TMLastStationAngTight);
|
200 |
|
|
if (muon::isGoodMuon(*iM,muon::TMOneStationAngLoose))
|
201 |
|
|
outMuon->Quality().SetQuality(MuonQuality::TMOneStationAngLoose);
|
202 |
|
|
if (muon::isGoodMuon(*iM,muon::TMOneStationAngTight))
|
203 |
|
|
outMuon->Quality().SetQuality(MuonQuality::TMOneStationAngTight);
|
204 |
|
|
if (muon::isGoodMuon(*iM,muon::TMLastStationOptimizedBarrelLowPtLoose))
|
205 |
|
|
outMuon->Quality().SetQuality(MuonQuality::TMLastStationOptimizedBarrelLowPtLoose);
|
206 |
|
|
if (muon::isGoodMuon(*iM,muon::TMLastStationOptimizedBarrelLowPtTight))
|
207 |
|
|
outMuon->Quality().SetQuality(MuonQuality::TMLastStationOptimizedBarrelLowPtTight);
|
208 |
|
|
|
209 |
|
|
|
210 |
bendavid |
1.30 |
if (globalTrackMap_ && iM->combinedMuon().isNonnull()) {
|
211 |
bendavid |
1.15 |
outMuon->SetGlobalTrk(globalTrackMap_->GetMit(refToPtr(iM->combinedMuon())));
|
212 |
bendavid |
1.30 |
outMuon->SetNValidHits (iM->globalTrack()->hitPattern().numberOfValidMuonHits());
|
213 |
|
|
}
|
214 |
loizides |
1.1 |
if (standaloneTrackMap_ && standaloneVtxTrackMap_ && iM->standAloneMuon().isNonnull()) {
|
215 |
|
|
Int_t refProductId = iM->standAloneMuon().id().id();
|
216 |
|
|
if ( refProductId == standaloneVtxTrackMap_->GetEdmProductId())
|
217 |
bendavid |
1.15 |
outMuon->SetStandaloneTrk(standaloneVtxTrackMap_->GetMit(refToPtr(iM->standAloneMuon())));
|
218 |
loizides |
1.1 |
else if ( refProductId == standaloneTrackMap_->GetEdmProductId())
|
219 |
bendavid |
1.15 |
outMuon->SetStandaloneTrk(standaloneTrackMap_->GetMit(refToPtr(iM->standAloneMuon())));
|
220 |
loizides |
1.1 |
else throw edm::Exception(edm::errors::Configuration, "FillerMuons:FillDataBlock()\n")
|
221 |
loizides |
1.14 |
<< "Error! Track reference in unmapped collection " << edmName_ << endl;
|
222 |
loizides |
1.1 |
}
|
223 |
bendavid |
1.30 |
if (trackerTrackMap_ && iM->track().isNonnull()) {
|
224 |
bendavid |
1.15 |
outMuon->SetTrackerTrk(trackerTrackMap_->GetMit(refToPtr(iM->track())));
|
225 |
bendavid |
1.30 |
}
|
226 |
loizides |
1.14 |
|
227 |
bendavid |
1.27 |
//compute impact parameter with respect to PV
|
228 |
|
|
if (iM->track().isNonnull()) {
|
229 |
|
|
const reco::TransientTrack &tt = transientTrackBuilder->build(iM->track());
|
230 |
|
|
|
231 |
bendavid |
1.41 |
reco::Vertex thevtx = pvCol->at(0);
|
232 |
|
|
reco::Vertex thevtxbs = pvBSCol->at(0);
|
233 |
bendavid |
1.37 |
|
234 |
bendavid |
1.41 |
reco::Vertex thevtxub = pvCol->at(0);
|
235 |
|
|
reco::Vertex thevtxubbs = pvBSCol->at(0);
|
236 |
bendavid |
1.37 |
|
237 |
ksung |
1.40 |
reco::TrackCollection newTkCollection;
|
238 |
|
|
bool foundMatch = false;
|
239 |
|
|
for(reco::Vertex::trackRef_iterator itk = thevtx.tracks_begin(); itk!=thevtx.tracks_end(); itk++) {
|
240 |
|
|
if(itk->get() == &*(iM->innerTrack())) {
|
241 |
|
|
foundMatch = true;
|
242 |
|
|
continue;
|
243 |
|
|
}
|
244 |
|
|
newTkCollection.push_back(*itk->get());
|
245 |
|
|
}
|
246 |
|
|
|
247 |
pharris |
1.42 |
if(foundMatch && fitUnbiasedVertex_) {
|
248 |
ksung |
1.40 |
edm::Handle<reco::BeamSpot> bs;
|
249 |
|
|
event.getByLabel(edm::InputTag("offlineBeamSpot"),bs);
|
250 |
|
|
|
251 |
|
|
VertexReProducer revertex(hVertex,event);
|
252 |
|
|
edm::Handle<reco::BeamSpot> pvbeamspot;
|
253 |
|
|
event.getByLabel(revertex.inputBeamSpot(),pvbeamspot);
|
254 |
|
|
vector<TransientVertex> pvs = revertex.makeVertices(newTkCollection,*pvbeamspot,setup);
|
255 |
bendavid |
1.41 |
if(pvs.size()>0) {
|
256 |
|
|
thevtxub = pvs.front(); // take the first in the list
|
257 |
|
|
}
|
258 |
ksung |
1.40 |
|
259 |
|
|
VertexReProducer revertexbs(hVertexBS,event);
|
260 |
|
|
edm::Handle<reco::BeamSpot> pvbsbeamspot;
|
261 |
|
|
event.getByLabel(revertexbs.inputBeamSpot(),pvbsbeamspot);
|
262 |
|
|
vector<TransientVertex> pvbss = revertexbs.makeVertices(newTkCollection,*pvbsbeamspot,setup);
|
263 |
bendavid |
1.41 |
if(pvbss.size()>0) {
|
264 |
|
|
thevtxubbs = pvbss.front(); // take the first in the list
|
265 |
|
|
}
|
266 |
ksung |
1.40 |
}
|
267 |
|
|
|
268 |
|
|
|
269 |
bendavid |
1.37 |
//preserve sign of transverse impact parameter (cross-product definition from track, not lifetime-signing)
|
270 |
|
|
const double thesign = ( (-iM->track()->dxy(thevtx.position())) >=0 ) ? 1. : -1.;
|
271 |
|
|
const double thesignbs = ( (-iM->track()->dxy(thevtxbs.position())) >=0 ) ? 1. : -1.;
|
272 |
|
|
|
273 |
|
|
const std::pair<bool,Measurement1D> &d0pv = IPTools::absoluteTransverseImpactParameter(tt,thevtx);
|
274 |
bendavid |
1.27 |
if (d0pv.first) {
|
275 |
bendavid |
1.37 |
outMuon->SetD0PV(thesign*d0pv.second.value());
|
276 |
bendavid |
1.27 |
outMuon->SetD0PVErr(d0pv.second.error());
|
277 |
|
|
}
|
278 |
bendavid |
1.28 |
else {
|
279 |
|
|
outMuon->SetD0PV(-99.0);
|
280 |
|
|
}
|
281 |
bendavid |
1.27 |
|
282 |
bendavid |
1.37 |
const std::pair<bool,Measurement1D> &ip3dpv = IPTools::absoluteImpactParameter3D(tt,thevtx);
|
283 |
bendavid |
1.27 |
if (ip3dpv.first) {
|
284 |
bendavid |
1.37 |
outMuon->SetIp3dPV(thesign*ip3dpv.second.value());
|
285 |
bendavid |
1.27 |
outMuon->SetIp3dPVErr(ip3dpv.second.error());
|
286 |
|
|
}
|
287 |
bendavid |
1.28 |
else {
|
288 |
|
|
outMuon->SetIp3dPV(-99.0);
|
289 |
|
|
}
|
290 |
bendavid |
1.27 |
|
291 |
bendavid |
1.37 |
const std::pair<bool,Measurement1D> &d0pvbs = IPTools::absoluteTransverseImpactParameter(tt,thevtxbs);
|
292 |
bendavid |
1.27 |
if (d0pvbs.first) {
|
293 |
bendavid |
1.37 |
outMuon->SetD0PVBS(thesignbs*d0pvbs.second.value());
|
294 |
bendavid |
1.27 |
outMuon->SetD0PVBSErr(d0pvbs.second.error());
|
295 |
|
|
}
|
296 |
bendavid |
1.28 |
else {
|
297 |
|
|
outMuon->SetD0PVBS(-99.0);
|
298 |
|
|
}
|
299 |
bendavid |
1.27 |
|
300 |
bendavid |
1.37 |
const std::pair<bool,Measurement1D> &ip3dpvbs = IPTools::absoluteImpactParameter3D(tt,thevtxbs);
|
301 |
bendavid |
1.27 |
if (ip3dpvbs.first) {
|
302 |
bendavid |
1.37 |
outMuon->SetIp3dPVBS(thesignbs*ip3dpvbs.second.value());
|
303 |
bendavid |
1.27 |
outMuon->SetIp3dPVBSErr(ip3dpvbs.second.error());
|
304 |
|
|
}
|
305 |
bendavid |
1.28 |
else {
|
306 |
|
|
outMuon->SetIp3dPVBS(-99.0);
|
307 |
|
|
}
|
308 |
|
|
|
309 |
bendavid |
1.41 |
const std::pair<bool,Measurement1D> &d0pvub = IPTools::absoluteTransverseImpactParameter(tt,thevtxub);
|
310 |
|
|
if (d0pvub.first) {
|
311 |
|
|
outMuon->SetD0PVUB(thesign*d0pvub.second.value());
|
312 |
|
|
outMuon->SetD0PVUBErr(d0pvub.second.error());
|
313 |
|
|
}
|
314 |
|
|
else {
|
315 |
|
|
outMuon->SetD0PVUB(-99.0);
|
316 |
|
|
}
|
317 |
|
|
|
318 |
|
|
const std::pair<bool,Measurement1D> &ip3dpvub = IPTools::absoluteImpactParameter3D(tt,thevtxub);
|
319 |
|
|
if (ip3dpvub.first) {
|
320 |
|
|
outMuon->SetIp3dPVUB(thesign*ip3dpvub.second.value());
|
321 |
|
|
outMuon->SetIp3dPVUBErr(ip3dpvub.second.error());
|
322 |
|
|
}
|
323 |
|
|
else {
|
324 |
|
|
outMuon->SetIp3dPVUB(-99.0);
|
325 |
|
|
}
|
326 |
|
|
|
327 |
|
|
const std::pair<bool,Measurement1D> &d0pvubbs = IPTools::absoluteTransverseImpactParameter(tt,thevtxubbs);
|
328 |
|
|
if (d0pvubbs.first) {
|
329 |
|
|
outMuon->SetD0PVUBBS(thesignbs*d0pvubbs.second.value());
|
330 |
|
|
outMuon->SetD0PVUBBSErr(d0pvubbs.second.error());
|
331 |
|
|
}
|
332 |
|
|
else {
|
333 |
|
|
outMuon->SetD0PVUBBS(-99.0);
|
334 |
|
|
}
|
335 |
|
|
|
336 |
|
|
const std::pair<bool,Measurement1D> &ip3dpvubbs = IPTools::absoluteImpactParameter3D(tt,thevtxubbs);
|
337 |
|
|
if (ip3dpvubbs.first) {
|
338 |
|
|
outMuon->SetIp3dPVUBBS(thesignbs*ip3dpvubbs.second.value());
|
339 |
|
|
outMuon->SetIp3dPVUBBSErr(ip3dpvubbs.second.error());
|
340 |
|
|
}
|
341 |
|
|
else {
|
342 |
|
|
outMuon->SetIp3dPVUBBS(-99.0);
|
343 |
|
|
}
|
344 |
|
|
|
345 |
bendavid |
1.28 |
//compute compatibility with PV using taking into account also the case where muon track
|
346 |
|
|
//was included in the vertex fit
|
347 |
|
|
if (iM->track()->extra().isAvailable()) {
|
348 |
|
|
|
349 |
|
|
const std::pair<bool,double> &pvCompat = kalmanEstimator.estimate(pvCol->at(0),tt);
|
350 |
|
|
if (pvCompat.first) {
|
351 |
|
|
outMuon->SetPVCompatibility(pvCompat.second);
|
352 |
|
|
}
|
353 |
|
|
else {
|
354 |
|
|
outMuon->SetPVCompatibility(-99.0);
|
355 |
|
|
}
|
356 |
|
|
|
357 |
|
|
const std::pair<bool,double> &pvbsCompat = kalmanEstimator.estimate(pvBSCol->at(0),tt);
|
358 |
|
|
if (pvbsCompat.first) {
|
359 |
|
|
outMuon->SetPVBSCompatibility(pvbsCompat.second);
|
360 |
|
|
}
|
361 |
|
|
else {
|
362 |
|
|
outMuon->SetPVBSCompatibility(-99.0);
|
363 |
|
|
}
|
364 |
|
|
}
|
365 |
bendavid |
1.27 |
|
366 |
|
|
}
|
367 |
bendavid |
1.39 |
|
368 |
loizides |
1.14 |
outMuon->SetNChambers (iM->numberOfChambers());
|
369 |
pharris |
1.11 |
outMuon->SetStationMask(iM->stationMask(reco::Muon::SegmentAndTrackArbitration));
|
370 |
ceballos |
1.33 |
outMuon->SetNMatches (iM->numberOfMatches());
|
371 |
loizides |
1.14 |
for(int i0 = 0; i0 < 4; i0++) {
|
372 |
loizides |
1.20 |
// DTs
|
373 |
pharris |
1.11 |
outMuon->SetDX(i0, iM->dX(i0+1,1));
|
374 |
|
|
outMuon->SetDY(i0, iM->dY(i0+1,1));
|
375 |
|
|
outMuon->SetPullX(i0, iM->pullX(i0+1,1));
|
376 |
|
|
outMuon->SetPullY(i0, iM->pullY(i0+1,1));
|
377 |
|
|
outMuon->SetTrackDist(i0, iM->trackDist(i0+1,1));
|
378 |
|
|
outMuon->SetTrackDistErr(i0, iM->trackDistErr(i0+1,1));
|
379 |
pharris |
1.34 |
outMuon->SetNSegments(i0, NumberOfSegments(&(*iM),i0+1,1));
|
380 |
loizides |
1.20 |
// CSCs
|
381 |
pharris |
1.11 |
outMuon->SetDX(4+i0, iM->dX (i0+1,2));
|
382 |
|
|
outMuon->SetDY(4+i0, iM->dY (i0+1,2));
|
383 |
|
|
outMuon->SetPullX(4+i0, iM->pullX (i0+1,2));
|
384 |
|
|
outMuon->SetPullY(4+i0, iM->pullY (i0+1,2));
|
385 |
|
|
outMuon->SetTrackDist(4+i0, iM->trackDist(i0+1,2));
|
386 |
|
|
outMuon->SetTrackDistErr(4+i0,iM->trackDistErr(i0+1,2));
|
387 |
pharris |
1.34 |
outMuon->SetNSegments(4+i0, NumberOfSegments(&(*iM),i0+1,2));
|
388 |
pharris |
1.11 |
}
|
389 |
bendavid |
1.19 |
|
390 |
bendavid |
1.32 |
reco::MuonRef theRef(hMuonProduct, iM - inMuons.begin());
|
391 |
|
|
// fill corrected expected inner hits
|
392 |
bendavid |
1.36 |
if (iM->innerTrack().isNonnull()) {
|
393 |
|
|
outMuon->SetCorrectedNExpectedHitsInner(iM->innerTrack()->trackerExpectedHitsInner().numberOfHits());
|
394 |
bendavid |
1.32 |
}
|
395 |
bendavid |
1.36 |
|
396 |
loizides |
1.20 |
// add muon to map
|
397 |
bendavid |
1.19 |
edm::Ptr<reco::Muon> thePtr(hMuonProduct, iM - inMuons.begin());
|
398 |
|
|
muonMap_->Add(thePtr, outMuon);
|
399 |
bendavid |
1.21 |
|
400 |
|
|
if (verbose_>1) {
|
401 |
|
|
if (!outMuon->HasGlobalTrk() && !outMuon->HasStandaloneTrk()) {
|
402 |
|
|
printf("mithep::Muon, pt=%5f, eta=%5f, phi=%5f, mass=%5f\n",outMuon->Pt(),outMuon->Eta(),outMuon->Phi(), outMuon->Mass());
|
403 |
|
|
printf(" reco::Muon, pt=%5f, eta=%5f, phi=%5f, mass=%5f\n",iM->pt(),iM->eta(),iM->phi(),iM->mass());
|
404 |
|
|
}
|
405 |
|
|
}
|
406 |
bendavid |
1.19 |
|
407 |
pharris |
1.11 |
}
|
408 |
loizides |
1.1 |
muons_->Trim();
|
409 |
|
|
}
|
410 |
pharris |
1.34 |
|
411 |
|
|
int FillerMuons::NumberOfSegments(const reco::Muon *iM, int station, int muonSubdetId, reco::Muon::ArbitrationType type ) {
|
412 |
|
|
if(!iM->isMatchesValid()) return 0;
|
413 |
|
|
int segments(0);
|
414 |
|
|
|
415 |
|
|
for( std::vector<reco::MuonChamberMatch>::const_iterator chamberMatch = iM->matches().begin();
|
416 |
|
|
chamberMatch != iM->matches().end(); chamberMatch++ )
|
417 |
|
|
{
|
418 |
|
|
if(chamberMatch->segmentMatches.empty()) continue;
|
419 |
|
|
if(!(chamberMatch->station()==station && chamberMatch->detector()==muonSubdetId)) continue;
|
420 |
|
|
if(type == reco::Muon::NoArbitration) {
|
421 |
|
|
segments += chamberMatch->segmentMatches.size();
|
422 |
|
|
continue;
|
423 |
|
|
}
|
424 |
|
|
for( std::vector<reco::MuonSegmentMatch>::const_iterator segmentMatch = chamberMatch->segmentMatches.begin();
|
425 |
|
|
segmentMatch != chamberMatch->segmentMatches.end(); segmentMatch++ )
|
426 |
|
|
{
|
427 |
|
|
if(type == reco::Muon::SegmentArbitration)
|
428 |
pharris |
1.35 |
if(segmentMatch->isMask(reco::MuonSegmentMatch::BestInChamberByDR)) {
|
429 |
pharris |
1.34 |
segments++;
|
430 |
|
|
break;
|
431 |
|
|
}
|
432 |
|
|
if(type == reco::Muon::SegmentAndTrackArbitration)
|
433 |
pharris |
1.35 |
if(segmentMatch->isMask(reco::MuonSegmentMatch::BestInChamberByDR) &&
|
434 |
pharris |
1.34 |
segmentMatch->isMask(reco::MuonSegmentMatch::BelongsToTrackByDR)) {
|
435 |
|
|
segments++;
|
436 |
|
|
break;
|
437 |
|
|
}
|
438 |
|
|
if(type == reco::Muon::SegmentAndTrackArbitrationCleaned)
|
439 |
pharris |
1.35 |
if(segmentMatch->isMask(reco::MuonSegmentMatch::BestInChamberByDR) &&
|
440 |
pharris |
1.34 |
segmentMatch->isMask(reco::MuonSegmentMatch::BelongsToTrackByDR) &&
|
441 |
|
|
segmentMatch->isMask(reco::MuonSegmentMatch::BelongsToTrackByCleaning)) {
|
442 |
|
|
segments++;
|
443 |
|
|
break;
|
444 |
|
|
}
|
445 |
|
|
if(type > 1<<7)
|
446 |
|
|
if(segmentMatch->isMask(type)) {
|
447 |
|
|
segments++;
|
448 |
|
|
break;
|
449 |
|
|
}
|
450 |
|
|
}
|
451 |
|
|
}
|
452 |
|
|
return segments;
|
453 |
|
|
}
|
454 |
|
|
|