1 |
bbetchar |
1.1 |
#include "TopQuarkAnalysis/TopRefTuple/interface/Tuple_Muon.h"
|
2 |
bbetchar |
1.2 |
#include "TopQuarkAnalysis/TopRefTuple/interface/fTypes.h"
|
3 |
bbetchar |
1.1 |
|
4 |
bbetchar |
1.2 |
#include <boost/foreach.hpp>
|
5 |
|
|
|
6 |
|
|
#include "DataFormats/PatCandidates/interface/Muon.h"
|
7 |
bbetchar |
1.3 |
#include "DataFormats/VertexReco/interface/VertexFwd.h"
|
8 |
|
|
#include "DataFormats/VertexReco/interface/Vertex.h"
|
9 |
bbetchar |
1.1 |
|
10 |
|
|
|
11 |
bbetchar |
1.2 |
Tuple_Muon::
|
12 |
|
|
Tuple_Muon(const edm::ParameterSet& conf)
|
13 |
|
|
: muonTag( conf.getParameter<edm::InputTag>("muonTag") ),
|
14 |
bbetchar |
1.3 |
vertexTag( conf.getParameter<edm::InputTag>("vertexTag") ),
|
15 |
bbetchar |
1.2 |
prefix( conf.getParameter<std::string>("prefix") )
|
16 |
bbetchar |
1.1 |
{
|
17 |
bbetchar |
1.2 |
produces <bool> ( prefix + "HandleValid");
|
18 |
|
|
produces <std::vector<fTypes::dPolarLorentzV> > ( prefix + "P4" );
|
19 |
|
|
produces <std::vector<int> > ( prefix + "Charge");
|
20 |
|
|
|
21 |
|
|
produces <std::vector<float> > ( prefix + "RelIso" );
|
22 |
|
|
produces <std::vector<float> > ( prefix + "ChIso" );
|
23 |
|
|
produces <std::vector<float> > ( prefix + "NhIso" );
|
24 |
|
|
produces <std::vector<float> > ( prefix + "PhIso" );
|
25 |
|
|
produces <std::vector<float> > ( prefix + "PuIso" );
|
26 |
bbetchar |
1.1 |
|
27 |
bbetchar |
1.3 |
produces <std::vector<bool> > ( prefix + "IsPFMuon" );
|
28 |
|
|
produces <std::vector<bool> > ( prefix + "IsGlobalMuon" );
|
29 |
|
|
produces <std::vector<bool> > ( prefix + "IsTrackerMuon" );
|
30 |
|
|
produces <std::vector<bool> > ( prefix + "IsStandAloneMuon" );
|
31 |
|
|
produces <std::vector<bool> > ( prefix + "IsGoodMuon" );
|
32 |
|
|
|
33 |
|
|
produces <std::vector<float> > ( prefix + "NormChi2" );
|
34 |
|
|
produces <std::vector<unsigned> > ( prefix + "TrackingLayers" );
|
35 |
|
|
produces <std::vector<unsigned> > ( prefix + "ValidMuonHits" );
|
36 |
|
|
produces <std::vector<unsigned> > ( prefix + "ValidPixelHits" );
|
37 |
|
|
produces <std::vector<unsigned> > ( prefix + "MatchedStations" );
|
38 |
|
|
|
39 |
|
|
produces <std::vector<float> > ( prefix + "Dxy");
|
40 |
|
|
produces <std::vector<float> > ( prefix + "Db");
|
41 |
|
|
produces <std::vector<float> > ( prefix + "Dz");
|
42 |
bbetchar |
1.1 |
}
|
43 |
|
|
|
44 |
bbetchar |
1.2 |
void Tuple_Muon::
|
45 |
|
|
produce(edm::Event &event, const edm::EventSetup&) {
|
46 |
|
|
std::auto_ptr<std::vector<fTypes::dPolarLorentzV> > p4 ( new std::vector<fTypes::dPolarLorentzV>() );
|
47 |
|
|
std::auto_ptr<std::vector<int> > charge ( new std::vector<int>() );
|
48 |
|
|
|
49 |
|
|
std::auto_ptr<std::vector<float> > relIso( new std::vector<float>() );
|
50 |
|
|
std::auto_ptr<std::vector<float> > chIso ( new std::vector<float>() );
|
51 |
|
|
std::auto_ptr<std::vector<float> > nhIso ( new std::vector<float>() );
|
52 |
|
|
std::auto_ptr<std::vector<float> > phIso ( new std::vector<float>() );
|
53 |
|
|
std::auto_ptr<std::vector<float> > puIso ( new std::vector<float>() );
|
54 |
|
|
|
55 |
bbetchar |
1.3 |
std::auto_ptr<std::vector<bool> > isGlobal (new std::vector<bool>() );
|
56 |
|
|
std::auto_ptr<std::vector<bool> > isTracker (new std::vector<bool>() );
|
57 |
|
|
std::auto_ptr<std::vector<bool> > isPF (new std::vector<bool>() );
|
58 |
|
|
std::auto_ptr<std::vector<bool> > isStandAlone (new std::vector<bool>() );
|
59 |
|
|
std::auto_ptr<std::vector<bool> > isGood (new std::vector<bool>() );
|
60 |
|
|
|
61 |
|
|
std::auto_ptr<std::vector<float> > normChi2 ( new std::vector<float>() );
|
62 |
|
|
std::auto_ptr<std::vector<unsigned> > trackLayers ( new std::vector<unsigned>() );
|
63 |
|
|
std::auto_ptr<std::vector<unsigned> > validMuonHits ( new std::vector<unsigned>() );
|
64 |
|
|
std::auto_ptr<std::vector<unsigned> > validPixelHits ( new std::vector<unsigned>() );
|
65 |
|
|
std::auto_ptr<std::vector<unsigned> > matchedStations ( new std::vector<unsigned>() );
|
66 |
|
|
|
67 |
|
|
std::auto_ptr<std::vector<float> > dxy ( new std::vector<float>() );
|
68 |
|
|
std::auto_ptr<std::vector<float> > dz ( new std::vector<float>() );
|
69 |
|
|
std::auto_ptr<std::vector<float> > dB ( new std::vector<float>() );
|
70 |
|
|
|
71 |
bbetchar |
1.2 |
typedef edm::View<pat::Muon> mus_t;
|
72 |
bbetchar |
1.3 |
edm::Handle<mus_t> muons; edm::Handle<reco::VertexCollection> vertices;
|
73 |
|
|
event.getByLabel(muonTag,muons); event.getByLabel(vertexTag, vertices);
|
74 |
|
|
|
75 |
|
|
const reco::Vertex* vertex = (vertices.isValid() && vertices->size() ) ? &vertices->at(0) : 0;
|
76 |
bbetchar |
1.2 |
|
77 |
|
|
if( muons.isValid() ) {
|
78 |
|
|
for(mus_t::const_iterator mu=muons->begin(); mu!=muons->end(); mu++) {
|
79 |
|
|
p4->push_back(fTypes::dPolarLorentzV(mu->pt(), mu->eta(), mu->phi(), mu->mass()));
|
80 |
|
|
charge->push_back(mu->charge());
|
81 |
|
|
chIso->push_back( mu->chargedHadronIso() );
|
82 |
|
|
nhIso->push_back( mu->neutralHadronIso() );
|
83 |
|
|
phIso->push_back( mu->photonIso() );
|
84 |
|
|
puIso->push_back( mu->puChargedHadronIso() );
|
85 |
bbetchar |
1.4 |
relIso->push_back( (chIso->back() + std::max(0., nhIso->back() + phIso->back() -0.5*puIso->back()) ) / mu->pt() );
|
86 |
bbetchar |
1.2 |
|
87 |
bbetchar |
1.3 |
isGlobal->push_back(mu->isGlobalMuon());
|
88 |
|
|
isTracker->push_back(mu->isTrackerMuon());
|
89 |
|
|
isPF->push_back(mu->isPFMuon());
|
90 |
|
|
isStandAlone->push_back(mu->isStandAloneMuon());
|
91 |
|
|
isGood->push_back(mu->isGood("TMOneStationTight"));
|
92 |
|
|
|
93 |
|
|
normChi2->push_back( isGlobal->back() ? mu->globalTrack()->normalizedChi2() : -9999.9 );
|
94 |
|
|
validMuonHits->push_back( isGlobal->back() ? mu->globalTrack()->hitPattern().numberOfValidMuonHits() : 0 );
|
95 |
|
|
trackLayers->push_back( isTracker->back() ? mu->track()->hitPattern().trackerLayersWithMeasurement() : 0 );
|
96 |
|
|
validPixelHits->push_back( mu->innerTrack().isNonnull() ? mu->innerTrack()->hitPattern().numberOfValidPixelHits() : 0 );
|
97 |
|
|
matchedStations->push_back( mu->numberOfMatchedStations() );
|
98 |
|
|
|
99 |
|
|
dxy->push_back( isGlobal->back() && vertex ? fabs(mu->muonBestTrack()->dxy(vertex->position())) : -9999.9 );
|
100 |
|
|
dz->push_back( isGlobal->back() && vertex ? fabs(mu->muonBestTrack()->dz(vertex->position())) : -9999.9 );
|
101 |
|
|
dB->push_back( mu->dB() );
|
102 |
bbetchar |
1.2 |
}
|
103 |
|
|
}
|
104 |
|
|
|
105 |
|
|
event.put( std::auto_ptr<bool> ( new bool(muons.isValid() ) ), prefix + "HandleValid" );
|
106 |
|
|
event.put( p4, prefix+"P4" );
|
107 |
|
|
event.put( charge, prefix+"Charge");
|
108 |
|
|
event.put( relIso, prefix+"RelIso");
|
109 |
|
|
event.put( chIso, prefix+"ChIso");
|
110 |
|
|
event.put( nhIso, prefix+"NhIso");
|
111 |
|
|
event.put( phIso, prefix+"PhIso");
|
112 |
|
|
event.put( puIso, prefix+"PuIso");
|
113 |
bbetchar |
1.3 |
|
114 |
|
|
event.put( isPF, prefix + "IsPFMuon" );
|
115 |
|
|
event.put( isGlobal, prefix + "IsGlobalMuon" );
|
116 |
|
|
event.put( isTracker, prefix + "IsTrackerMuon" );
|
117 |
|
|
event.put( isStandAlone, prefix + "IsStandAloneMuon" );
|
118 |
|
|
event.put( isGood, prefix + "IsGoodMuon" );
|
119 |
|
|
|
120 |
|
|
event.put( normChi2, prefix + "NormChi2" );
|
121 |
|
|
event.put( trackLayers, prefix + "TrackingLayers" );
|
122 |
|
|
event.put( validMuonHits, prefix + "ValidMuonHits" );
|
123 |
|
|
event.put( validPixelHits, prefix + "ValidPixelHits" );
|
124 |
|
|
event.put( matchedStations, prefix + "MatchedStations" );
|
125 |
|
|
|
126 |
|
|
event.put( dxy, prefix + "Dxy" );
|
127 |
|
|
event.put( dB, prefix + "Db" );
|
128 |
|
|
event.put( dz, prefix + "Dz" );
|
129 |
|
|
|
130 |
bbetchar |
1.1 |
}
|