DPGAnalysis
SiStripTools
plugins
OverlapProblemTPAnalyzer.cc
Go to the documentation of this file.
1
// -*- C++ -*-
2
//
3
// Package: OverlapProblemTPAnalyzer
4
// Class: OverlapProblemTPAnalyzer
5
//
13
//
14
// Original Author: Andrea Venturi
15
// Created: Thu Dec 16 16:32:56 CEST 2010
16
// $Id: OverlapProblemTPAnalyzer.cc,v 1.1 2011/01/22 17:59:36 venturia Exp $
17
//
18
//
19
20
// system include files
21
#include <memory>
22
#include <numeric>
23
#include <vector>
24
25
// user include files
26
#include "
FWCore/Framework/interface/Frameworkfwd.h
"
27
#include "
FWCore/Framework/interface/EDAnalyzer.h
"
28
29
#include "
FWCore/Framework/interface/Event.h
"
30
#include "
FWCore/Framework/interface/ESHandle.h
"
31
#include "
FWCore/Framework/interface/Run.h
"
32
#include "
FWCore/Framework/interface/MakerMacros.h
"
33
34
#include "
FWCore/ParameterSet/interface/ParameterSet.h
"
35
36
#include "
FWCore/MessageLogger/interface/MessageLogger.h
"
37
38
#include "
FWCore/ServiceRegistry/interface/Service.h
"
39
#include "
CommonTools/UtilAlgos/interface/TFileService.h
"
40
41
#include "
FWCore/Utilities/interface/InputTag.h
"
42
43
#include "
SimDataFormats/TrackingAnalysis/interface/TrackingParticle.h
"
44
#include "
SimDataFormats/TrackingHit/interface/PSimHit.h
"
45
46
#include "
DataFormats/DetId/interface/DetId.h
"
47
#include "
DataFormats/TrackReco/interface/Track.h
"
48
#include "
DataFormats/TrackReco/interface/TrackFwd.h
"
49
50
#include "
SimDataFormats/Associations/interface/TrackToTrackingParticleAssociator.h
"
51
52
#include "TH1F.h"
53
#include "TH2F.h"
54
//
55
// class decleration
56
//
57
58
class
OverlapProblemTPAnalyzer
:
public
edm::EDAnalyzer
{
59
public
:
60
explicit
OverlapProblemTPAnalyzer
(
const
edm::ParameterSet
&);
61
~OverlapProblemTPAnalyzer
()
override
;
62
63
private
:
64
void
beginRun
(
const
edm::Run
&,
const
edm::EventSetup
&)
override
;
65
void
endRun
(
const
edm::Run
&,
const
edm::EventSetup
&)
override
;
66
void
analyze
(
const
edm::Event
&,
const
edm::EventSetup
&)
override
;
67
68
// ----------member data ---------------------------
69
70
TH1F*
m_ptp
;
71
TH1F*
m_etatp
;
72
TH1F*
m_nhits
;
73
TH1F*
m_nrechits
;
74
TH2F*
m_nrecvssimhits
;
75
TH1F*
m_nassotk
;
76
TH1F*
m_pdgid
;
77
TH1F*
m_llbit
;
78
TH1F*
m_statustp
;
79
80
std::vector<TH1F*>
m_simhitytecr
;
81
std::vector<TH1F*>
m_assosimhitytecr
;
82
83
edm::EDGetTokenT<TrackingParticleCollection>
m_tpcollToken
;
84
edm::EDGetTokenT<edm::View<reco::Track>
>
m_trkcollToken
;
85
edm::EDGetTokenT<reco::TrackToTrackingParticleAssociator>
m_associatorToken
;
86
};
87
88
//
89
// constants, enums and typedefs
90
//
91
92
//
93
// static data member definitions
94
//
95
96
//
97
// constructors and destructor
98
//
99
OverlapProblemTPAnalyzer::OverlapProblemTPAnalyzer
(
const
edm::ParameterSet
& iConfig)
100
: m_simhitytecr(),
101
m_assosimhitytecr(),
102
m_tpcollToken(
103
consumes<
TrackingParticleCollection
>(iConfig.getParameter<
edm
::
InputTag
>(
"trackingParticlesCollection"
))),
104
m_trkcollToken(consumes<
edm
::
View
<
reco
::Track> >(iConfig.getParameter<
edm
::
InputTag
>(
"trackCollection"
))),
105
m_associatorToken(consumes<
reco
::
TrackToTrackingParticleAssociator
>(
edm
::
InputTag
(
"trackAssociatorByHits"
))) {
106
//now do what ever initialization is needed
107
108
edm::Service<TFileService>
tfserv;
109
110
m_ptp
= tfserv->
make
<TH1F>(
"tpmomentum"
,
"Tracking Particle momentum"
, 100, 0., 200.);
111
m_etatp
= tfserv->
make
<TH1F>(
"tpeta"
,
"Tracking Particle pseudorapidity"
, 100, -4., 4.);
112
m_nhits
= tfserv->
make
<TH1F>(
"nhits"
,
"Tracking Particle associated hits"
, 100, -0.5, 99.5);
113
m_nrechits
= tfserv->
make
<TH1F>(
"nrechits"
,
"Tracking Particle associated rec hits"
, 100, -0.5, 99.5);
114
m_nrecvssimhits
= tfserv->
make
<TH2F>(
115
"nrecvssimhits"
,
"Tracking Particle associated rec hits vs sim hits"
, 100, -0.5, 99.5, 100, -0.5, 99.5);
116
m_nassotk
= tfserv->
make
<TH1F>(
"nassotk"
,
"Number of assocated reco tracks"
, 10, -0.5, 9.5);
117
118
m_pdgid
= tfserv->
make
<TH1F>(
"pdgid"
,
"Tracking Particle PDG id"
, 1000, -500.5, 499.5);
119
m_llbit
= tfserv->
make
<TH1F>(
"llbit"
,
"Tracking Particle LongLived bit"
, 2, -0.5, 1.5);
120
m_statustp
= tfserv->
make
<TH1F>(
"statustp"
,
"Tracking Particle status"
, 2000, -1000.5, 999.5);
121
122
for
(
unsigned
int
ring
= 0;
ring
< 7; ++
ring
) {
123
char
name
[100];
124
char
title
[100];
125
126
sprintf(
name
,
"simytecr_%d"
,
ring
+ 1);
127
sprintf(
title
,
"SimHit local Y TEC ring %d"
,
ring
+ 1);
128
129
m_simhitytecr
.push_back(tfserv->
make
<TH1F>(
name
,
title
, 200, -20., 20.));
130
131
sprintf(
name
,
"assosimytecr_%d"
,
ring
+ 1);
132
sprintf(
title
,
"SimHit local Y TEC ring %d with associated RecHit"
,
ring
+ 1);
133
134
m_assosimhitytecr
.push_back(tfserv->
make
<TH1F>(
name
,
title
, 200, -20., 20.));
135
}
136
}
137
138
OverlapProblemTPAnalyzer::~OverlapProblemTPAnalyzer
() {
139
// do anything here that needs to be done at desctruction time
140
// (e.g. close files, deallocate resources etc.)
141
}
142
143
//
144
// member functions
145
//
146
147
// ------------ method called to for each event ------------
148
void
OverlapProblemTPAnalyzer::analyze
(
const
edm::Event
&
iEvent
,
const
edm::EventSetup
& iSetup) {
149
using namespace
edm
;
150
151
// reco track Handle
152
153
// Handle<reco::TrackCollection> trkcoll;
154
Handle<edm::View<reco::Track>
> trkcoll;
155
iEvent
.getByToken(
m_trkcollToken
, trkcoll);
156
157
Handle<TrackingParticleCollection>
tpcoll;
158
iEvent
.getByToken(
m_tpcollToken
, tpcoll);
159
160
Handle<reco::TrackToTrackingParticleAssociator>
tahandle;
161
iEvent
.getByToken(
m_associatorToken
, tahandle);
162
163
// associate reco to sim tracks
164
165
reco::SimToRecoCollection
srcoll = tahandle->
associateSimToReco
(trkcoll, tpcoll);
166
167
// loop on Handle with index and use find
168
169
for
(
unsigned
int
index
= 0;
index
!= tpcoll->size(); ++
index
) {
170
// get TrackingParticleRef
171
172
const
TrackingParticleRef
tp
(tpcoll,
index
);
173
174
if
(
std::abs
(
tp
->pdgId()) != 13)
175
continue
;
176
177
// get the SimHIt from tracker only
178
179
// Commented since the new TP's do not have this method
180
// std::vector<PSimHit> tksimhits = tp->trackPSimHit(DetId::Tracker);
181
182
m_ptp
->Fill(
tp
->p());
183
m_etatp
->Fill(
tp
->eta());
184
// m_nhits->Fill(tp->matchedHit());
185
// With the new Tracking Particles I have to use a different method
186
// m_nhits->Fill(tksimhits.size());
187
m_nhits
->Fill(
tp
->numberOfTrackerHits());
188
189
m_pdgid
->Fill(
tp
->pdgId());
190
m_llbit
->Fill(
tp
->longLived());
191
m_statustp
->Fill(
tp
->status());
192
193
// prepare a vector of TrackingRecHit from the associated reco tracks
194
195
std::vector<DetId>
rechits
;
196
197
// look at associated tracks
198
199
if
(srcoll.
find
(
tp
) != srcoll.
end
()) {
200
reco::SimToRecoCollection::result_type
trks = srcoll[
tp
];
201
m_nassotk
->Fill(trks.size());
202
203
// loop on associated tracks and fill TrackingRecHit vector
204
for
(reco::SimToRecoCollection::result_type::const_iterator trk = trks.begin(); trk != trks.end(); ++trk) {
205
for
(
trackingRecHit_iterator
rh = trk->first->recHitsBegin(); rh != trk->first->recHitsEnd(); ++rh) {
206
rechits
.push_back((*rh)->geographicalId());
207
}
208
}
209
210
}
else
{
211
m_nassotk
->Fill(0.);
212
edm::LogInfo
(
"NoAssociatedRecoTrack"
)
213
<<
"No associated reco track for TP with p = "
<<
tp
->p() <<
" and eta = "
<<
tp
->eta();
214
}
215
216
m_nrechits
->Fill(
rechits
.size());
217
// new method used to be compliant with the new TP's
218
m_nrecvssimhits
->Fill(
tp
->numberOfTrackerHits(),
rechits
.size());
219
220
LogDebug
(
"RecHitDetId"
) <<
"List of "
<<
rechits
.size() <<
" rechits detid from muon with p = "
<<
tp
->p()
221
<<
"and eta = "
<<
tp
->eta();
222
for
(
unsigned
int
i
= 0;
i
<
rechits
.size(); ++
i
) {
223
LogTrace
(
"RecHitDetId"
) <<
rechits
[
i
].rawId();
224
}
225
226
// loop on sim hits
227
228
LogDebug
(
"SimHitDetId"
) <<
"List of "
<<
tp
->numberOfTrackerHits()
229
<<
" simhits detid from muon with p = "
<<
tp
->p() <<
"and eta = "
<<
tp
->eta();
230
}
231
}
232
233
void
OverlapProblemTPAnalyzer::beginRun
(
const
edm::Run
& iRun,
const
edm::EventSetup
&) {}
234
235
void
OverlapProblemTPAnalyzer::endRun
(
const
edm::Run
& iRun,
const
edm::EventSetup
&) {}
236
237
//define this as a plug-in
238
DEFINE_FWK_MODULE
(
OverlapProblemTPAnalyzer
);
OverlapProblemTPAnalyzer::m_assosimhitytecr
std::vector< TH1F * > m_assosimhitytecr
Definition:
OverlapProblemTPAnalyzer.cc:81
OverlapProblemTPAnalyzer::m_trkcollToken
edm::EDGetTokenT< edm::View< reco::Track > > m_trkcollToken
Definition:
OverlapProblemTPAnalyzer.cc:84
runGCPTkAlMap.title
string title
Definition:
runGCPTkAlMap.py:94
edm::AssociationMap::find
const_iterator find(const key_type &k) const
find element with specified reference key
Definition:
AssociationMap.h:173
mps_fire.i
i
Definition:
mps_fire.py:428
MessageLogger.h
OverlapProblemTPAnalyzer::m_etatp
TH1F * m_etatp
Definition:
OverlapProblemTPAnalyzer.cc:71
ESHandle.h
sistrip::View
View
Definition:
ConstantsForView.h:26
edm::Run
Definition:
Run.h:45
edm::EDGetTokenT< TrackingParticleCollection >
edm
HLT enums.
Definition:
AlignableModifier.h:19
HLT_FULL_cff.InputTag
InputTag
Definition:
HLT_FULL_cff.py:89287
EDAnalyzer.h
reco
fixed size matrix
Definition:
AlignmentAlgorithmBase.h:45
edm::LogInfo
Log< level::Info, false > LogInfo
Definition:
MessageLogger.h:125
edm::Handle
Definition:
AssociativeIterator.h:50
TrackToTrackingParticleAssociator
OverlapProblemTPAnalyzer::m_pdgid
TH1F * m_pdgid
Definition:
OverlapProblemTPAnalyzer.cc:76
edm::Ref< TrackingParticleCollection >
edm::EDAnalyzer
Definition:
EDAnalyzer.h:28
OverlapProblemTPAnalyzer::m_nhits
TH1F * m_nhits
Definition:
OverlapProblemTPAnalyzer.cc:72
OverlapProblemTPAnalyzer::OverlapProblemTPAnalyzer
OverlapProblemTPAnalyzer(const edm::ParameterSet &)
Definition:
OverlapProblemTPAnalyzer.cc:99
edm::AssociationMap::end
const_iterator end() const
last iterator over the map (read only)
Definition:
AssociationMap.h:171
MakerMacros.h
PSimHit.h
Track.h
TrackFwd.h
DEFINE_FWK_MODULE
#define DEFINE_FWK_MODULE(type)
Definition:
MakerMacros.h:16
Service.h
OverlapProblemTPAnalyzer::beginRun
void beginRun(const edm::Run &, const edm::EventSetup &) override
Definition:
OverlapProblemTPAnalyzer.cc:233
edm::AssociationMap< edm::OneToManyWithQualityGeneric< TrackingParticleCollection, edm::View< reco::Track >, double > >::result_type
value_type::value_type result_type
type return by operator[]
Definition:
AssociationMap.h:71
Run.h
HI_PhotonSkim_cff.rechits
rechits
Definition:
HI_PhotonSkim_cff.py:76
OverlapProblemTPAnalyzer::m_nrecvssimhits
TH2F * m_nrecvssimhits
Definition:
OverlapProblemTPAnalyzer.cc:74
cmsswSequenceInfo.tp
tp
Definition:
cmsswSequenceInfo.py:17
edm::OwnVector::const_iterator
Definition:
OwnVector.h:41
TFileService.h
TrackToTrackingParticleAssociator.h
LogDebug
#define LogDebug(id)
Definition:
MessageLogger.h:223
edm::ParameterSet
Definition:
ParameterSet.h:47
Event.h
edm::AssociationMap< edm::OneToManyWithQualityGeneric< TrackingParticleCollection, edm::View< reco::Track >, double > >
OverlapProblemTPAnalyzer::m_tpcollToken
edm::EDGetTokenT< TrackingParticleCollection > m_tpcollToken
Definition:
OverlapProblemTPAnalyzer.cc:83
edm::Service< TFileService >
iEvent
int iEvent
Definition:
GenABIO.cc:224
edm::EventSetup
Definition:
EventSetup.h:57
OverlapProblemTPAnalyzer::m_nassotk
TH1F * m_nassotk
Definition:
OverlapProblemTPAnalyzer.cc:75
OverlapProblemTPAnalyzer
Definition:
OverlapProblemTPAnalyzer.cc:58
InputTag.h
TrackingParticle.h
OverlapProblemTPAnalyzer::~OverlapProblemTPAnalyzer
~OverlapProblemTPAnalyzer() override
Definition:
OverlapProblemTPAnalyzer.cc:138
DetId.h
Frameworkfwd.h
OverlapProblemTPAnalyzer::analyze
void analyze(const edm::Event &, const edm::EventSetup &) override
Definition:
OverlapProblemTPAnalyzer.cc:148
OverlapProblemTPAnalyzer::m_nrechits
TH1F * m_nrechits
Definition:
OverlapProblemTPAnalyzer.cc:73
relativeConstraints.ring
ring
Definition:
relativeConstraints.py:68
Skims_PA_cff.name
name
Definition:
Skims_PA_cff.py:17
TrackingParticleCollection
std::vector< TrackingParticle > TrackingParticleCollection
Definition:
TrackingParticleFwd.h:8
OverlapProblemTPAnalyzer::m_statustp
TH1F * m_statustp
Definition:
OverlapProblemTPAnalyzer.cc:78
reco::TrackToTrackingParticleAssociator::associateSimToReco
reco::SimToRecoCollection associateSimToReco(const edm::Handle< edm::View< reco::Track >> &tCH, const edm::Handle< TrackingParticleCollection > &tPCH) const
Definition:
TrackToTrackingParticleAssociator.h:71
AlignmentPI::index
index
Definition:
AlignmentPayloadInspectorHelper.h:46
funct::abs
Abs< T >::type abs(const T &t)
Definition:
Abs.h:22
LogTrace
#define LogTrace(id)
Definition:
MessageLogger.h:224
ParameterSet.h
edm::Event
Definition:
Event.h:73
OverlapProblemTPAnalyzer::m_ptp
TH1F * m_ptp
Definition:
OverlapProblemTPAnalyzer.cc:70
OverlapProblemTPAnalyzer::endRun
void endRun(const edm::Run &, const edm::EventSetup &) override
Definition:
OverlapProblemTPAnalyzer.cc:235
TFileService::make
T * make(const Args &... args) const
make new ROOT object
Definition:
TFileService.h:64
OverlapProblemTPAnalyzer::m_associatorToken
edm::EDGetTokenT< reco::TrackToTrackingParticleAssociator > m_associatorToken
Definition:
OverlapProblemTPAnalyzer.cc:85
OverlapProblemTPAnalyzer::m_simhitytecr
std::vector< TH1F * > m_simhitytecr
Definition:
OverlapProblemTPAnalyzer.cc:80
OverlapProblemTPAnalyzer::m_llbit
TH1F * m_llbit
Definition:
OverlapProblemTPAnalyzer.cc:77
Generated for CMSSW Reference Manual by
1.8.16