CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PackedCandidateTrackValidator.cc
Go to the documentation of this file.
5 
8 
12 
14  public:
17 
18  void bookHistograms(DQMStore::IBooker&, edm::Run const&, edm::EventSetup const&) override;
19  void analyze(const edm::Event&, const edm::EventSetup& ) override;
20 
21  static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);
22 
23  private:
24 
27 
29 
31 
35 
39 
42 
45 
53 
61 
65 
70 };
71 
73  tracksToken_(consumes<edm::View<reco::Track>>(iConfig.getUntrackedParameter<edm::InputTag>("tracks"))),
74  trackToPackedCandidateToken_(consumes<edm::Association<pat::PackedCandidateCollection>>(iConfig.getUntrackedParameter<edm::InputTag>("trackToPackedCandiadteAssociation"))),
75  rootFolder_(iConfig.getUntrackedParameter<std::string>("rootFolder"))
76 {}
77 
79 
82 
83  desc.addUntracked<edm::InputTag>("tracks", edm::InputTag("generalTracks"));
84  desc.addUntracked<edm::InputTag>("trackToPackedCandiadteAssociation", edm::InputTag("packedPFCandidates"));
85  desc.addUntracked<std::string>("rootFolder", "Tracking/PackedCandidate");
86 
87  descriptions.add("packedCandidateTrackValidator", desc);
88 }
89 
92 
93  h_selectionFlow = iBooker.book1D("selectionFlow", "Track selection flow", 5, 0, 5);
94  h_selectionFlow->setBinLabel(1, "All tracks");
95  h_selectionFlow->setBinLabel(2, "Associated to PackedCandidate");
96  h_selectionFlow->setBinLabel(3, "PackedCandidate has track");
97  h_selectionFlow->setBinLabel(4, "PackedCandidate is not electron");
98  h_selectionFlow->setBinLabel(5, "PackedCandidate has hits");
99 
100  constexpr int diffBins = 50;
101  constexpr float diff = 1e-4;
102  constexpr float diffP = 5e-3;
103 
104  h_diffPx = iBooker.book1D("diffPx", "PackedCandidate::bestTrack() - reco::Track in px()", diffBins, -diffP, diffP);
105  h_diffPy = iBooker.book1D("diffPy", "PackedCandidate::bestTrack() - reco::Track in py()", diffBins, -diffP, diffP);
106  h_diffPz = iBooker.book1D("diffPz", "PackedCandidate::bestTrack() - reco::Track in pz()", diffBins, -diffP, diffP);
107 
108  h_diffVx = iBooker.book1D("diffVx", "PackedCandidate::bestTrack() - reco::Track in vx()", diffBins, -diffP, diffP);
109  h_diffVy = iBooker.book1D("diffVy", "PackedCandidate::bestTrack() - reco::Track in vy()", diffBins, -diffP, diffP);
110  h_diffVz = iBooker.book1D("diffVz", "PackedCandidate::bestTrack() - reco::Track in vz()", diffBins, -diffP, diffP);
111 
112  h_diffNormalizedChi2 = iBooker.book1D("diffNormalizedChi2", "PackedCandidate::bestTrack() - reco::Track in normalizedChi2()", 30, -1.5, 1.5);
113  h_diffNdof = iBooker.book1D("diffNdof", "PackedCandidate::bestTrack() - reco::Track in ndof()", 33, -30.5, 2.5);
114 
115  h_diffCharge = iBooker.book1D("diffCharge", "PackedCandidate::bestTrack() - reco::Track in charge()", 5, -2.5, 2.5);
116  h_diffIsHighPurity = iBooker.book1D("diffIsHighPurity", "PackedCandidate::bestTrack() - reco::Track in quality(highPurity)", 3, -1.5, 1.5);
117 
118  h_diffQoverp = iBooker.book1D("diffQoverp", "PackedCandidate::bestTrack() - reco::Track in qoverp()", diffBins, -1e-3, 1e-3);
119  h_diffPt = iBooker.book1D("diffPt", "PackedCandidate::bestTrack() - reco::Track in pt()", diffBins, -diffP, diffP);
120  h_diffEta = iBooker.book1D("diffEta", "PackedCandidate::bestTrack() - reco::Track in eta()", diffBins, -diff, diff);
121  h_diffTheta = iBooker.book1D("diffTheta", "PackedCandidate::bestTrack() - reco::Track in theta()", diffBins, -diff, diff);
122  h_diffPhi = iBooker.book1D("diffPhi", "PackedCandidate::bestTrack() - reco::Track in phi()", diffBins, -diff, diff);
123  h_diffDxy = iBooker.book1D("diffDxy", "PackedCandidate::bestTrack() - reco::Track in dxy()", diffBins, -2e-5, 2e-5);
124  h_diffDz = iBooker.book1D("diffDz", "PackedCandidate::bestTrack() - reco::Track in dz()", diffBins, -4e-5, 4e-5);
125 
126  h_diffQoverpError = iBooker.book1D("diffQoverpError", "PackedCandidate::bestTrack() - reco::Track in qoverpError()", diffBins, -1e-3, 1e-3);
127  h_diffPtError = iBooker.book1D("diffPtError", "PackedCandidate::bestTrack() - reco::Track in ptError()", diffBins, -diffP, diffP);
128  h_diffEtaError = iBooker.book1D("diffEtaError", "PackedCandidate::bestTrack() - reco::Track in etaError()", diffBins, -diff, diff);
129  h_diffThetaError = iBooker.book1D("diffThetaError", "PackedCandidate::bestTrack() - reco::Track in thetaError()", diffBins, -diff, diff);
130  h_diffPhiError = iBooker.book1D("diffPhiError", "PackedCandidate::bestTrack() - reco::Track in phiError()", diffBins, -diff, diff);
131  h_diffDxyError = iBooker.book1D("diffDxyError", "PackedCandidate::bestTrack() - reco::Track in dxyError()", diffBins, -2e-5, 2e-5);
132  h_diffDzError = iBooker.book1D("diffDzError", "PackedCandidate::bestTrack() - reco::Track in dzError()", diffBins, -4e-5, 4e-5);
133 
134  h_diffNumberOfPixelHits = iBooker.book1D("diffNumberOfPixelHits", "PackedCandidate::numberOfPixelHits() - reco::Track::hitPattern::numberOfValidPixelHits()", 5, -2.5, 2.5);
135  h_diffNumberOfHits = iBooker.book1D("diffNumberOfHits", "PackedCandidate::numberHits() - reco::Track::hitPattern::numberOfValidHits()", 5, -2.5, 2.5);
136  h_diffLostInnerHits = iBooker.book1D("diffLostInnerHits", "PackedCandidate::lostInnerHits() - reco::Track::hitPattern::numberOfLostHits(MISSING_INNER_HITS)", 5, -2.5, 2.5);
137 
138  h_diffHitPatternNumberOfValidPixelHits = iBooker.book1D("diffHitPatternNumberOfValidPixelHits", "PackedCandidate::bestTrack() - reco::Track in hitPattern::numberOfValidPixelHits()", 5, -2.5, 2.5);
139  h_diffHitPatternNumberOfValidHits = iBooker.book1D("diffHitPatternNumberOfValidHits", "PackedCandidate::bestTrack() - reco::Track in hitPattern::numberOfValidHits()", 5, -2.5, 2.5);
140  h_diffHitPatternNumberOfLostInnerHits = iBooker.book1D("diffHitPatternNumberOfLostPixelHits", "PackedCandidate::bestTrack() - reco::Track in hitPattern::numberOfLostHits(MISSING_INNER_HITS)", 13, -10.5, 2.5);
141  h_diffHitPatternHasValidHitInFirstPixelBarrel = iBooker.book1D("diffHitPatternHasValidHitInFirstPixelBarrel", "PackedCandidate::bestTrack() - reco::Track in hitPattern::hasValidHitInFirstPixelBarrel", 3, -1.5, 1.5);
142 
143 }
144 
145 namespace {
146  template<typename T> void fillNoFlow(MonitorElement* h, T val){
147  h->Fill(std::min(std::max(val,((T) h->getTH1()->GetXaxis()->GetXmin())),((T) h->getTH1()->GetXaxis()->GetXmax())));
148  }
149 }
150 
153  iEvent.getByToken(tracksToken_, htracks);
154  const auto& tracks = *htracks;
155 
158  const auto& trackToPackedCandidate = *hassoc;
159 
160  for(size_t i=0; i<tracks.size(); ++i) {
161  auto trackPtr = tracks.ptrAt(i);
162  const reco::Track& track = *trackPtr;
163  h_selectionFlow->Fill(0.5);
164 
165  pat::PackedCandidateRef pcRef = trackToPackedCandidate[trackPtr];
166  if(pcRef.isNull()) {
167  continue;
168  }
169  h_selectionFlow->Fill(1.5);
170 
171  const reco::Track *trackPcPtr = pcRef->bestTrack();
172  if(!trackPcPtr) {
173  continue;
174  }
175  h_selectionFlow->Fill(2.5);
176 
177  // Filter out electrons to avoid comparisons to PackedCandidates with GsfTrack
178  if(std::abs(pcRef->pdgId()) == 11) {
179  continue;
180  }
181  h_selectionFlow->Fill(3.5);
182 
183  // Filter out PackedCandidate-tracks with no hits, as they won't have their details filled
184  const reco::Track& trackPc = *trackPcPtr;
185  if(trackPc.hitPattern().numberOfValidHits() == 0) {
186  continue;
187  }
188  h_selectionFlow->Fill(4.5);
189 
190 
191  fillNoFlow(h_diffPx, trackPc.px() - track.px());
192  fillNoFlow(h_diffPy, trackPc.py() - track.py());
193  fillNoFlow(h_diffPz, trackPc.pz() - track.pz());
194 
195  fillNoFlow(h_diffVx, trackPc.vx() - track.vx());
196  fillNoFlow(h_diffVy, trackPc.vy() - track.vy());
197  fillNoFlow(h_diffVz, trackPc.vz() - track.vz());
198 
199  fillNoFlow(h_diffNormalizedChi2, trackPc.normalizedChi2() - track.normalizedChi2());
200  fillNoFlow(h_diffNdof, trackPc.ndof() - track.ndof());
201 
202  fillNoFlow(h_diffCharge, trackPc.charge() - track.charge());
204 
205  fillNoFlow(h_diffQoverp, trackPc.qoverp() - track.qoverp());
206  fillNoFlow(h_diffPt , trackPc.pt() - track.pt() );
207  fillNoFlow(h_diffEta , trackPc.eta() - track.eta() );
208  fillNoFlow(h_diffTheta , trackPc.theta() - track.theta() );
209  fillNoFlow(h_diffPhi , trackPc.phi() - track.phi() );
210  fillNoFlow(h_diffDxy , trackPc.dxy() - track.dxy() );
211  fillNoFlow(h_diffDz , trackPc.dz() - track.dz() );
212 
213  fillNoFlow(h_diffQoverpError, trackPc.qoverpError() - track.qoverpError());
214  fillNoFlow(h_diffPtError , trackPc.ptError() - track.ptError() );
215  fillNoFlow(h_diffEtaError , trackPc.etaError() - track.etaError() );
216  fillNoFlow(h_diffThetaError , trackPc.thetaError() - track.thetaError() );
217  fillNoFlow(h_diffPhiError , trackPc.phiError() - track.phiError() );
218  fillNoFlow(h_diffDxyError , trackPc.dxyError() - track.dxyError() );
219  fillNoFlow(h_diffDzError , trackPc.dzError() - track.dzError() );
220 
221  fillNoFlow(h_diffNumberOfPixelHits, pcRef->numberOfPixelHits() - track.hitPattern().numberOfValidPixelHits());
222  fillNoFlow(h_diffNumberOfHits, pcRef->numberOfHits() - track.hitPattern().numberOfValidHits());
223 
224  int diffLostInnerHits = 0;
225  const auto trackLostInnerHits = track.hitPattern().numberOfLostHits(reco::HitPattern::MISSING_INNER_HITS);
226  switch(pcRef->lostInnerHits()) {
229  diffLostInnerHits = -trackLostInnerHits;
230  break;
232  diffLostInnerHits = 1-trackLostInnerHits;
233  break;
235  diffLostInnerHits = trackLostInnerHits>=2 ? 0 : 2-trackLostInnerHits;
236  break;
237  }
238  fillNoFlow(h_diffLostInnerHits, diffLostInnerHits);
239 
243 
245  }
246 }
247 
double qoverp() const
q / p
Definition: TrackBase.h:536
int i
Definition: DBlmapReader.cc:9
ParameterDescriptionBase * addUntracked(U const &iLabel, T const &value)
double normalizedChi2() const
chi-squared divided by n.d.o.f. (or chi-squared * 1e6 if n.d.o.f. is zero)
Definition: TrackBase.h:524
edm::EDGetTokenT< edm::View< reco::Track > > tracksToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:457
double theta() const
polar angle
Definition: TrackBase.h:542
double dxyError() const
error on dxy
Definition: TrackBase.h:759
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
int numberOfValidHits() const
Definition: HitPattern.h:734
PackedCandidateTrackValidator(const edm::ParameterSet &pset)
std::vector< pat::PackedCandidate > PackedCandidateCollection
edm::EDGetTokenT< edm::Association< pat::PackedCandidateCollection > > trackToPackedCandidateToken_
double etaError() const
error on eta
Definition: TrackBase.h:747
void setBinLabel(int bin, const std::string &label, int axis=1)
set bin label for x, y or z axis (axis=1, 2, 3 respectively)
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:608
double px() const
x coordinate of momentum vector
Definition: TrackBase.h:590
static void fillDescriptions(edm::ConfigurationDescriptions &descriptions)
#define constexpr
void Fill(long long x)
int iEvent
Definition: GenABIO.cc:230
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:614
double ndof() const
number of degrees of freedom of the fit
Definition: TrackBase.h:518
double pt() const
track transverse momentum
Definition: TrackBase.h:584
double ptError() const
error on Pt (set to 1000 TeV if charge==0 for safety)
Definition: TrackBase.h:726
double phiError() const
error on phi
Definition: TrackBase.h:753
MonitorElement * h_diffHitPatternHasValidHitInFirstPixelBarrel
MonitorElement * book1D(Args &&...args)
Definition: DQMStore.h:115
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
TH1 * getTH1(void) const
The Signals That Services Can Subscribe To This is based on ActivityRegistry h
Helper function to determine trigger accepts.
Definition: Activities.doc:4
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
T min(T a, T b)
Definition: MathUtil.h:58
bool isNull() const
Checks for null.
Definition: Ref.h:249
double pz() const
z coordinate of momentum vector
Definition: TrackBase.h:602
double qoverpError() const
error on signed transverse curvature
Definition: TrackBase.h:720
double dz() const
dz parameter (= dsz/cos(lambda)). This is the track z0 w.r.t (0,0,0) only if the refPoint is close to...
Definition: TrackBase.h:572
double dzError() const
error on dz
Definition: TrackBase.h:777
double vz() const
z coordinate of the reference point on track
Definition: TrackBase.h:632
void setCurrentFolder(const std::string &fullpath)
Definition: DQMStore.cc:274
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:421
tuple tracks
Definition: testEve_cfg.py:39
void add(std::string const &label, ParameterSetDescription const &psetDescription)
bool quality(const TrackQuality) const
Track quality.
Definition: TrackBase.h:473
int numberOfLostHits(HitCategory category) const
Definition: HitPattern.h:804
double vy() const
y coordinate of the reference point on track
Definition: TrackBase.h:626
void analyze(const edm::Event &, const edm::EventSetup &) override
int numberOfValidPixelHits() const
Definition: HitPattern.h:749
int charge() const
track electric charge
Definition: TrackBase.h:530
bool hasValidHitInFirstPixelBarrel() const
Definition: HitPattern.cc:276
double dxy() const
dxy parameter. (This is the transverse impact parameter w.r.t. to (0,0,0) ONLY if refPoint is close t...
Definition: TrackBase.h:554
long double T
double py() const
y coordinate of momentum vector
Definition: TrackBase.h:596
Definition: Run.h:41
double vx() const
x coordinate of the reference point on track
Definition: TrackBase.h:620
double thetaError() const
error on theta
Definition: TrackBase.h:735