CMS 3D CMS Logo

TestOutliers.cc
Go to the documentation of this file.
1 // -*- C++ -*-
2 //
3 // Package: TestOutliers
4 // Class: TestOutliers
5 //
13 //
14 // Original Author: Giuseppe Cerati
15 // Created: Mon Sep 17 10:31:30 CEST 2007
16 //
17 //
18 
19 // system include files
20 #include <memory>
21 #include <vector>
22 
23 // user include files
26 
29 
35 #include <TH1.h>
36 #include <TH2.h>
37 #include <TFile.h>
49 
50 //
51 // class decleration
52 //
53 
54 class TestOutliers : public edm::one::EDAnalyzer<edm::one::WatchRuns> {
55 public:
56  explicit TestOutliers(const edm::ParameterSet &);
57  ~TestOutliers() override;
58 
59 private:
60  void beginRun(edm::Run const &run, const edm::EventSetup &) override;
61  void analyze(const edm::Event &, const edm::EventSetup &) override;
62  void endRun(edm::Run const &run, const edm::EventSetup &) override {}
63  void endJob() override;
64 
65  // ----------member data ---------------------------
66  edm::InputTag trackTagsOut_; //used to select what tracks to read from configuration file
67  edm::InputTag trackTagsOld_; //used to select what tracks to read from configuration file
68  edm::InputTag tpTags_; //used to select what tracks to read from configuration file
77  TFile *file;
90  TH2F *posxy, *poszr;
106  *mergedhittype;
112 };
113 //
114 // constants, enums and typedefs
115 //
116 
117 //
118 // static data member definitions
119 //
120 
121 using namespace edm;
122 
123 //
124 // constructors and destructor
125 //
127  : trackTagsOut_(iConfig.getUntrackedParameter<edm::InputTag>("tracksOut")),
128  trackTagsOld_(iConfig.getUntrackedParameter<edm::InputTag>("tracksOld")),
129  tpTags_(iConfig.getUntrackedParameter<edm::InputTag>("tp")),
130  trackerHitAssociatorConfig_(consumesCollector()),
131  theAssociatorOldToken(consumes<reco::TrackToTrackingParticleAssociator>(
132  iConfig.getUntrackedParameter<edm::InputTag>("TrackAssociatorByHitsOld"))),
133  theAssociatorOutToken(consumes<reco::TrackToTrackingParticleAssociator>(
134  iConfig.getUntrackedParameter<edm::InputTag>("TrackAssociatorByHitsOut"))),
135  theGToken(esConsumes<edm::Transition::BeginRun>()),
136  theTopoToken(esConsumes()),
137  theMFToken(esConsumes()),
138  out(iConfig.getParameter<std::string>("out")) {
139  LogTrace("TestOutliers") << "constructor";
140  // ParameterSet cuts = iConfig.getParameter<ParameterSet>("RecoTracksCuts");
141  // selectRecoTracks = RecoTrackSelector(cuts.getParameter<double>("ptMin"),
142  // cuts.getParameter<double>("minRapidity"),
143  // cuts.getParameter<double>("maxRapidity"),
144  // cuts.getParameter<double>("tip"),
145  // cuts.getParameter<double>("lip"),
146  // cuts.getParameter<int>("minHit"),
147  // cuts.getParameter<double>("maxChi2"));
148 
149  LogTrace("TestOutliers") << "end constructor";
150 }
151 
153  // do anything here that needs to be done at desctruction time
154  // (e.g. close files, deallocate resources etc.)
155 }
156 
157 //
158 // member functions
159 //
160 
161 // ------------ method called to for each event ------------
163  //Retrieve tracker topology from geometry
165 
166  theG = iSetup.getHandle(theGToken);
168 
169  using namespace edm;
170  using namespace std;
171  using reco::TrackCollection;
172 
173  LogTrace("TestOutliers") << "analyze event #" << iEvent.id();
174 
176  iEvent.getByLabel(trackTagsOut_, tracksOut);
178  iEvent.getByLabel(trackTagsOld_, tracksOld);
180  iEvent.getByLabel(tpTags_, tps);
182  iEvent.getByLabel("offlineBeamSpot", beamSpot);
183 
185 
187  iEvent.getByToken(theAssociatorOldToken, hAssociatorOld);
188  const reco::TrackToTrackingParticleAssociator *theAssociatorOld = hAssociatorOld.product();
189 
191  iEvent.getByToken(theAssociatorOutToken, hAssociatorOut);
192  const reco::TrackToTrackingParticleAssociator *theAssociatorOut = hAssociatorOut.product();
193 
194  reco::RecoToSimCollection recSimCollOut = theAssociatorOut->associateRecoToSim(tracksOut, tps);
195  reco::RecoToSimCollection recSimCollOld = theAssociatorOld->associateRecoToSim(tracksOld, tps);
196  sizeOut->Fill(recSimCollOut.size());
197  sizeOld->Fill(recSimCollOld.size());
198  sizeOutT->Fill(tracksOut->size());
199  sizeOldT->Fill(tracksOld->size());
200 
201  LogTrace("TestOutliers") << "tOld size=" << tracksOld->size() << " tOut size=" << tracksOut->size()
202  << " aOld size=" << recSimCollOld.size() << " aOut size=" << recSimCollOut.size();
203 
204 #if 0
205  LogTrace("TestOutliers") << "recSimCollOld.size()=" << recSimCollOld.size() ;
206  for(reco::TrackCollection::size_type j=0; j<tracksOld->size(); ++j){
207  reco::TrackRef trackOld(tracksOld, j);
208  //if ( !selectRecoTracks( *trackOld,beamSpot.product() ) ) continue;
209  LogTrace("TestOutliers") << "trackOld->pt()=" << trackOld->pt() << " trackOld->numberOfValidHits()=" << trackOld->numberOfValidHits();
210  std::vector<pair<TrackingParticleRef, double> > tpOld;
211  if(recSimCollOld.find(trackOld) != recSimCollOld.end()){
212  tpOld = recSimCollOld[trackOld];
213  if (tpOld.size()!=0) LogTrace("TestOutliers") << " associated" ;
214  else LogTrace("TestOutliers") << " NOT associated" ;
215  } else LogTrace("TestOutliers") << " NOT associated" ;
216  }
217  LogTrace("TestOutliers") << "recSimCollOut.size()=" << recSimCollOut.size() ;
218  for(reco::TrackCollection::size_type j=0; j<tracksOut->size(); ++j){
219  reco::TrackRef trackOut(tracksOut, j);
220  //if ( !selectRecoTracks( *trackOut,beamSpot.product() ) ) continue;
221  LogTrace("TestOutliers") << "trackOut->pt()=" << trackOut->pt() << " trackOut->numberOfValidHits()=" << trackOut->numberOfValidHits();
222  std::vector<pair<TrackingParticleRef, double> > tpOut;
223  if(recSimCollOut.find(trackOut) != recSimCollOut.end()){
224  tpOut = recSimCollOut[trackOut];
225  if (tpOut.size()!=0) LogTrace("TestOutliers") << " associated" ;
226  else LogTrace("TestOutliers") << " NOT associated" ;
227  } else LogTrace("TestOutliers") << " NOT associated" ;
228  }
229 #endif
230 
231  LogTrace("TestOutliers") << "tracksOut->size()=" << tracksOut->size();
232  LogTrace("TestOutliers") << "tracksOld->size()=" << tracksOld->size();
233 
234  std::vector<unsigned int> outused;
235  for (unsigned int j = 0; j < tracksOld->size(); ++j) {
236  countOldT->Fill(1);
237  edm::RefToBase<reco::Track> trackOld(tracksOld, j);
238  LogTrace("TestOutliers") << "now track old with id=" << j << " seed ref=" << trackOld->seedRef().get()
239  << " pt=" << trackOld->pt() << " eta=" << trackOld->eta()
240  << " chi2=" << trackOld->normalizedChi2()
241  << " tip= " << fabs(trackOld->dxy(beamSpot->position()))
242  << " lip= " << fabs(trackOld->dsz(beamSpot->position()));
243 
244  // if (i==tracksOut->size()) {
245  // if(recSimCollOld.find(trackOld) != recSimCollOld.end()){
246  // vector<pair<TrackingParticleRef, double> > tpOld;
247  // tpOld = recSimCollOld[trackOld];
248  // if (tpOld.size()!=0) {
249  // LogTrace("TestOutliers") <<"no match: old associated and out lost! old has #hits=" << trackOld->numberOfValidHits()
250  // << " and fraction=" << tpOld.begin()->second;
251  // if (tpOld.begin()->second>0.5) hitsPerTrackLost->Fill(trackOld->numberOfValidHits());
252  // }
253  // }
254  // continue;
255  // }
256 
257  std::vector<unsigned int> outtest; //all the out tracks with the same seed ref
258  for (unsigned int k = 0; k < tracksOut->size(); ++k) {
260  if (tmpOut->seedRef() == trackOld->seedRef()) {
261  outtest.push_back(k);
262  }
263  }
264 
266  if (outtest.size() == 1) { // if only one that's it
267  trackOut = edm::RefToBase<reco::Track>(tracksOut, outtest[0]);
268  LogTrace("TestOutliers") << "now track out with id=" << outtest[0] << " seed ref=" << trackOut->seedRef().get()
269  << " pt=" << trackOut->pt();
270  outused.push_back(outtest[0]);
271  } else if (outtest.size() > 1) { //if > 1 take the one that shares all the hits with the old track
272  for (unsigned int p = 0; p < outtest.size(); ++p) {
273  edm::RefToBase<reco::Track> tmpOut = edm::RefToBase<reco::Track>(tracksOut, outtest[p]);
274  bool allhits = true;
275  for (trackingRecHit_iterator itOut = tmpOut->recHitsBegin(); itOut != tmpOut->recHitsEnd(); itOut++) {
276  if ((*itOut)->isValid()) {
277  bool thishit = false;
278  for (trackingRecHit_iterator itOld = trackOld->recHitsBegin(); itOld != trackOld->recHitsEnd(); itOld++) {
279  if ((*itOld)->isValid()) {
280  const TrackingRecHit *kt = &(**itOld);
281  if ((*itOut)->sharesInput(kt, TrackingRecHit::some)) {
282  thishit = true;
283  break;
284  }
285  }
286  }
287  if (!thishit)
288  allhits = false;
289  }
290  }
291  if (allhits) {
292  trackOut = edm::RefToBase<reco::Track>(tracksOut, outtest[p]);
293  LogTrace("TestOutliers") << "now track out with id=" << outtest[p]
294  << " seed ref=" << trackOut->seedRef().get() << " pt=" << trackOut->pt();
295  outused.push_back(outtest[p]);
296  }
297  }
298  }
299 
300  if (outtest.empty() || trackOut.get() == nullptr) { //no out track found for the old track
301  if (recSimCollOld.find(trackOld) != recSimCollOld.end()) {
302  vector<pair<TrackingParticleRef, double> > tpOld;
303  tpOld = recSimCollOld[trackOld];
304  if (!tpOld.empty()) {
305  LogTrace("TestOutliers") << "no match: old associated and out lost! old has #hits="
306  << trackOld->numberOfValidHits() << " and fraction=" << tpOld.begin()->second;
307  if (tpOld.begin()->second > 0.5)
308  hitsPerTrackLost->Fill(trackOld->numberOfValidHits());
309  }
310  }
311  LogTrace("TestOutliers") << "...skip to next old track";
312  continue;
313  }
314 
315  //look if old and out are associated
316  LogTrace("TestOutliers") << "trackOut->seedRef()=" << trackOut->seedRef().get()
317  << " trackOld->seedRef()=" << trackOld->seedRef().get();
318  bool oldAssoc = recSimCollOld.find(trackOld) != recSimCollOld.end();
319  bool outAssoc = recSimCollOut.find(trackOut) != recSimCollOut.end();
320  LogTrace("TestOutliers") << "outAssoc=" << outAssoc << " oldAssoc=" << oldAssoc;
321 
322  // if ( trackOut->seedRef()!= trackOld->seedRef() ||
323  // (trackOut->seedRef() == trackOld->seedRef() && trackOut->numberOfValidHits()>trackOld->numberOfValidHits()) ) {
324  // LogTrace("TestOutliers") <<"out and old tracks does not match...";
325  // LogTrace("TestOutliers") <<"old has #hits=" << trackOld->numberOfValidHits();
326  // std::vector<pair<TrackingParticleRef, double> > tpOld;
327  // if(recSimCollOld.find(trackOld) != recSimCollOld.end()) {
328  // tpOld = recSimCollOld[trackOld];
329  // if (tpOld.size()!=0) {
330  // LogTrace("TestOutliers") <<"old was associated with fraction=" << tpOld.begin()->second;
331  // if (tpOld.begin()->second>0.5) hitsPerTrackLost->Fill(trackOld->numberOfValidHits());
332  // }
333  // }
334  // LogTrace("TestOutliers") <<"...skip to next old track";
335  // continue;
336  // }
337  // //++i;
338  countOutT->Fill(1);
339 
340  //if ( !selectRecoTracks( *trackOld,beamSpot.product() ) ) continue;//no more cuts
341 
342  tracks->Fill(0); //FIXME
343 
345  TrackingParticleRef tprOut;
346  TrackingParticleRef tprOld;
347  double fracOut;
348  std::vector<unsigned int> tpids;
349  std::vector<std::pair<TrackingParticleRef, double> > tpOut;
350  std::vector<pair<TrackingParticleRef, double> > tpOld;
351  //contare outliers delle tracce che erano associate e non lo sono piu!!!!
352 
353  if (outAssoc) { //save the ids od the tp associate to the out track
354  tpOut = recSimCollOut[trackOut];
355  if (!tpOut.empty()) {
356  countOutA->Fill(1);
357  tprOut = tpOut.begin()->first;
358  fracOut = tpOut.begin()->second;
359  for (TrackingParticle::g4t_iterator g4T = tprOut->g4Track_begin(); g4T != tprOut->g4Track_end(); ++g4T) {
360  tpids.push_back(g4T->trackId());
361  }
362  }
363  }
364 
365  if (oldAssoc) { //save the ids od the tp associate to the old track
366  tpOld = recSimCollOld[trackOld];
367  if (!tpOld.empty()) {
368  tprOld = tpOld.begin()->first;
369  // LogTrace("TestOutliers") <<"old associated and out not! old has #hits=" << trackOld->numberOfValidHits()
370  // << " and fraction=" << tpOld.begin()->second;
371  // if (tpOld.begin()->second>0.5) hitsPerTrackLost->Fill(trackOld->numberOfValidHits());//deve essere un plot diverso tipo LostAssoc
372  if (tpOut.empty()) {
373  for (TrackingParticle::g4t_iterator g4T = tprOld->g4Track_begin(); g4T != tprOld->g4Track_end(); ++g4T) {
374  tpids.push_back(g4T->trackId());
375  }
376  }
377  }
378  }
379 
380  if (tprOut.get() != nullptr || tprOld.get() != nullptr) { //at least one of the tracks has to be associated
381 
382  tpr = tprOut.get() != nullptr ? tprOut : tprOld;
383 
384  const SimTrack *assocTrack = &(*tpr->g4Track_begin());
385 
386  //if ( trackOut->numberOfValidHits() < trackOld->numberOfValidHits() ) {
387  if (trackOut->numberOfValidHits() != trackOld->numberOfValidHits() ||
388  !(*trackOut->recHitsBegin())->sharesInput((*trackOld->recHitsBegin()), TrackingRecHit::some) ||
389  !(*(trackOut->recHitsEnd() - 1))
390  ->sharesInput(
391  (*(trackOld->recHitsEnd() - 1)),
393  some)) { //there are outliers if the number of valid hits is != or if the first and last hit does not match
394  LogTrace("TestOutliers") << "outliers for track with #hits=" << trackOut->numberOfValidHits();
395  tracks->Fill(1);
396  LogTrace("TestOutliers")
397  << "Out->pt=" << trackOut->pt() << " Old->pt=" << trackOld->pt() << " tp->pt="
398  << sqrt(tpr->momentum().perp2())
399  //<< " trackOut->ptError()=" << trackOut->ptError() << " trackOld->ptError()=" << trackOld->ptError()
400  << " Old->validHits=" << trackOld->numberOfValidHits() << " Out->validHits="
401  << trackOut->numberOfValidHits()
402  /*<< " fracOld=" << fracOld*/
403  << " fracOut=" << fracOut << " deltaHits=" << trackOld->numberOfValidHits() - trackOut->numberOfValidHits();
404 
405  //compute all the track parameters
406  double PtPullOut = (trackOut->pt() - sqrt(tpr->momentum().perp2())) / trackOut->ptError();
407  double PtPullOld = (trackOld->pt() - sqrt(tpr->momentum().perp2())) / trackOld->ptError();
408  histoPtOut->Fill(PtPullOut);
409  histoPtOld->Fill(PtPullOld);
410 
411  //LogTrace("TestOutliers") << "MagneticField";
412  FreeTrajectoryState ftsAtProduction(
413  GlobalPoint(tpr->vertex().x(), tpr->vertex().y(), tpr->vertex().z()),
414  GlobalVector(assocTrack->momentum().x(), assocTrack->momentum().y(), assocTrack->momentum().z()),
415  TrackCharge(trackOld->charge()),
416  theMF.product());
417  TSCPBuilderNoMaterial tscpBuilder;
418  TrajectoryStateClosestToPoint tsAtClosestApproach =
419  tscpBuilder(ftsAtProduction, GlobalPoint(0, 0, 0)); //as in TrackProducerAlgorithm
420  GlobalPoint v = tsAtClosestApproach.theState().position();
421  GlobalVector p = tsAtClosestApproach.theState().momentum();
422 
423  //LogTrace("TestOutliers") << "qoverpSim";
424  double qoverpSim = tsAtClosestApproach.charge() / p.mag();
425  double lambdaSim = M_PI / 2 - p.theta();
426  double phiSim = p.phi();
427  double dxySim = (-v.x() * sin(p.phi()) + v.y() * cos(p.phi()));
428  double dszSim = v.z() * p.perp() / p.mag() - (v.x() * p.x() + v.y() * p.y()) / p.perp() * p.z() / p.mag();
429  double d0Sim = -dxySim;
430  double dzSim = dszSim * p.mag() / p.perp();
431 
432  //LogTrace("TestOutliers") << "qoverpPullOut";
433  double qoverpPullOut = (trackOut->qoverp() - qoverpSim) / trackOut->qoverpError();
434  double qoverpPullOld = (trackOld->qoverp() - qoverpSim) / trackOld->qoverpError();
435  double lambdaPullOut = (trackOut->lambda() - lambdaSim) / trackOut->thetaError();
436  double lambdaPullOld = (trackOld->lambda() - lambdaSim) / trackOld->thetaError();
437  double phi0PullOut = (trackOut->phi() - phiSim) / trackOut->phiError();
438  double phi0PullOld = (trackOld->phi() - phiSim) / trackOld->phiError();
439  double d0PullOut = (trackOut->d0() - d0Sim) / trackOut->d0Error();
440  double d0PullOld = (trackOld->d0() - d0Sim) / trackOld->d0Error();
441  double dzPullOut = (trackOut->dz() - dzSim) / trackOut->dzError();
442  double dzPullOld = (trackOld->dz() - dzSim) / trackOld->dzError();
443 
444  //LogTrace("TestOutliers") << "histoQoverpOut";
445  histoQoverpOut->Fill(qoverpPullOut);
446  histoQoverpOld->Fill(qoverpPullOld);
447  histoPhiOut->Fill(phi0PullOut);
448  histoPhiOld->Fill(phi0PullOld);
449  histoD0Out->Fill(d0PullOut);
450  histoD0Old->Fill(d0PullOld);
451  histoDzOut->Fill(dzPullOut);
452  histoDzOld->Fill(dzPullOld);
453  histoLambdaOut->Fill(lambdaPullOut);
454  histoLambdaOld->Fill(lambdaPullOld);
455 
456  //delta number of valid hits
457  LogTrace("TestOutliers") << "deltahits=" << trackOld->numberOfValidHits() - trackOut->numberOfValidHits();
458  deltahits->Fill(trackOld->numberOfValidHits() - trackOut->numberOfValidHits());
459 
460  if (tprOut.get() != nullptr && tprOld.get() == nullptr) { //out associated and old not: gained track
461  if (!tpOld.empty() && tpOld.begin()->second <= 0.5) {
462  deltahitsAssocGained->Fill(trackOld->numberOfValidHits() - trackOut->numberOfValidHits());
463  hitsPerTrackAssocGained->Fill(trackOut->numberOfValidHits());
464  LogTrace("TestOutliers") << "a) gained (assoc) track out #hits==" << trackOut->numberOfValidHits()
465  << " old #hits=" << trackOld->numberOfValidHits();
466  } else {
467  deltahitsAssocGained->Fill(trackOld->numberOfValidHits() - trackOut->numberOfValidHits());
468  hitsPerTrackAssocGained->Fill(trackOut->numberOfValidHits());
469  LogTrace("TestOutliers") << "b) gained (assoc) track out #hits==" << trackOut->numberOfValidHits()
470  << " old #hits=" << trackOld->numberOfValidHits();
471  }
472  } else if (tprOut.get() == nullptr && tprOld.get() != nullptr) { //old associated and out not: lost track
473  LogTrace("TestOutliers") << "old associated and out not! old has #hits=" << trackOld->numberOfValidHits()
474  << " and fraction=" << tpOld.begin()->second;
475  if (tpOld.begin()->second > 0.5) {
476  hitsPerTrackAssocLost->Fill(trackOld->numberOfValidHits());
477  deltahitsAssocLost->Fill(trackOld->numberOfValidHits() - trackOut->numberOfValidHits());
478  }
479  }
480 
481  if (fabs(PtPullOut) < fabs(PtPullOld))
482  deltahitsOK->Fill(trackOld->numberOfValidHits() - trackOut->numberOfValidHits());
483  else
484  deltahitsNO->Fill(trackOld->numberOfValidHits() - trackOut->numberOfValidHits());
485 
486  //LogTrace("TestOutliers") << "RecoTrackSelector";
487  //if (selectRecoTracks(*trackOut,beamSpot.product())) okcutsOut->Fill(1); else okcutsOut->Fill(0);
488  //if (selectRecoTracks(*trackOld,beamSpot.product())) okcutsOld->Fill(1); else okcutsOld->Fill(0);
489 
490  LogTrace("TestOutliers") << "track old";
491  for (trackingRecHit_iterator itOld = trackOld->recHitsBegin(); itOld != trackOld->recHitsEnd(); itOld++) {
492  LogTrace("TestOutliers") << (*itOld)->isValid() << " " << (*itOld)->geographicalId().rawId();
493  }
494  LogTrace("TestOutliers") << "track out";
495  for (trackingRecHit_iterator itOut = trackOut->recHitsBegin(); itOut != trackOut->recHitsEnd(); itOut++) {
496  LogTrace("TestOutliers") << (*itOut)->isValid() << " " << (*itOut)->geographicalId().rawId();
497  }
498  //LogTrace("TestOutliers") << "itOut";
499 
500  vector<pair<int, trackingRecHit_iterator> > gainedlostoutliers;
501  //look for gained hits
502  for (trackingRecHit_iterator itOut = trackOut->recHitsBegin(); itOut != trackOut->recHitsEnd(); itOut++) {
503  bool gained = true;
504  if ((*itOut)->isValid()) {
505  for (trackingRecHit_iterator itOld = trackOld->recHitsBegin(); itOld != trackOld->recHitsEnd(); itOld++) {
506  if ((*itOld)->geographicalId().rawId() == (*itOut)->geographicalId().rawId())
507  gained = false;
508  }
509  if (gained) {
510  gainedlostoutliers.push_back(pair<int, trackingRecHit_iterator>(1, itOut));
511  LogTrace("TestOutliers") << "broken trajectory during old fit... gained hit "
512  << (*itOut)->geographicalId().rawId();
513  gainedhits->Fill(1);
514  }
515  }
516  }
517 
518  //look for outliers and lost hits
519  for (trackingRecHit_iterator itOld = trackOld->recHitsBegin(); itOld != trackOld->recHitsEnd(); itOld++) {
520  bool outlier = false;
521  bool lost = true;
522 
523  for (trackingRecHit_iterator itOut = trackOut->recHitsBegin(); itOut != trackOut->recHitsEnd(); itOut++) {
524  if ((*itOld)->geographicalId().rawId() == (*itOut)->geographicalId().rawId()) {
525  lost = false;
526  if ((*itOld)->isValid() && !(*itOut)->isValid() &&
527  (*itOld)->geographicalId().rawId() == (*itOut)->geographicalId().rawId()) {
528  LogTrace("TestOutliers") << (*itOld)->isValid() << " " << (*itOut)->isValid() << " "
529  << (*itOld)->geographicalId().rawId() << " "
530  << (*itOut)->geographicalId().rawId();
531  outlier = true;
532  }
533  }
534  }
535  if (lost)
536  gainedlostoutliers.push_back(pair<int, trackingRecHit_iterator>(2, itOld));
537  if (lost)
538  LogTrace("TestOutliers") << "lost";
539  else if (outlier)
540  gainedlostoutliers.push_back(pair<int, trackingRecHit_iterator>(3, itOld));
541  }
542 
543  for (std::vector<pair<int, trackingRecHit_iterator> >::iterator it = gainedlostoutliers.begin();
544  it != gainedlostoutliers.end();
545  ++it) {
546  LogTrace("TestOutliers") << "type of processed hit:" << it->first;
547  trackingRecHit_iterator itHit = it->second;
548  bool gained = false;
549  bool lost = false;
550  bool outlier = false;
551  if (it->first == 1)
552  gained = true;
553  else if (it->first == 2)
554  lost = true;
555  else if (it->first == 3)
556  outlier = true;
557 
558  if (outlier || lost || gained) {
559  //if (1) {
560 
561  if (lost && (*itHit)->isValid() == false) {
562  goodbadmergedLost->Fill(0);
563  LogTrace("TestOutliers") << "lost invalid";
564  continue;
565  } else if (gained && (*itHit)->isValid() == false) {
566  goodbadmergedGained->Fill(0);
567  LogTrace("TestOutliers") << "gained invalid";
568  continue;
569  }
570 
571  //LogTrace("TestOutliers") << "vector<SimHitIdpr>";
572  //look if the hit comes from a correct sim track
573  std::vector<SimHitIdpr> simTrackIds = hitAssociator.associateHitId(**itHit);
574  bool goodhit = false;
575  for (size_t j = 0; j < simTrackIds.size(); j++) {
576  for (size_t jj = 0; jj < tpids.size(); jj++) {
577  if (simTrackIds[j].first == tpids[jj])
578  goodhit = true;
579  break;
580  }
581  }
582 
583  //find what kind of hit is it
584  int clustersize = 0;
585  int hittypeval = 0;
586  int layerval = 0;
587  if (dynamic_cast<const SiPixelRecHit *>(&**itHit)) {
588  LogTrace("TestOutliers") << "SiPixelRecHit";
589  clustersize = ((const SiPixelRecHit *)(&**itHit))->cluster()->size();
590  hittypeval = 1;
591  } else if (dynamic_cast<const SiStripRecHit2D *>(&**itHit)) {
592  LogTrace("TestOutliers") << "SiStripRecHit2D";
593  clustersize = ((const SiStripRecHit2D *)(&**itHit))->cluster()->amplitudes().size();
594  hittypeval = 2;
595  } else if (dynamic_cast<const SiStripMatchedRecHit2D *>(&**itHit)) {
596  LogTrace("TestOutliers") << "SiStripMatchedRecHit2D";
597  int clsize1 = ((const SiStripMatchedRecHit2D *)(&**itHit))->monoCluster().amplitudes().size();
598  int clsize2 = ((const SiStripMatchedRecHit2D *)(&**itHit))->stereoCluster().amplitudes().size();
599  if (clsize1 > clsize2)
600  clustersize = clsize1;
601  else
602  clustersize = clsize2;
603  hittypeval = 3;
604  } else if (dynamic_cast<const ProjectedSiStripRecHit2D *>(&**itHit)) {
605  LogTrace("TestOutliers") << "ProjectedSiStripRecHit2D";
606  clustersize =
607  ((const ProjectedSiStripRecHit2D *)(&**itHit))->originalHit().cluster()->amplitudes().size();
608  hittypeval = 4;
609  }
610 
611  //find the layer of the hit
612  int subdetId = (*itHit)->geographicalId().subdetId();
613  DetId id = (*itHit)->geographicalId();
614  int layerId = tTopo->layer(id);
615  layerval = subdetId * 10 + layerId;
616 
617  //LogTrace("TestOutliers") << "gpos";
618  GlobalPoint gpos = theG->idToDet((*itHit)->geographicalId())->surface().toGlobal((*itHit)->localPosition());
619 
620  //get the vector of sim hit associated and choose the one with the largest energy loss
621  //double delta = 99999;
622  //LocalPoint rhitLPv = (*itHit)->localPosition();
623  //vector<PSimHit> assSimHits = hitAssociator.associateHit(**itHit);
624  //if (assSimHits.size()==0) continue;
625  //PSimHit shit;
626  //for(std::vector<PSimHit>::const_iterator m=assSimHits.begin(); m<assSimHits.end(); m++){
627  //if ((m->localPosition()-rhitLPv).mag()<delta) {
628  // shit=*m;
629  // delta = (m->localPosition()-rhitLPv).mag();
630  // }
631  //}
632  //LogTrace("TestOutliers") << "energyLoss_";
633  double energyLoss_ = 0.;
634  unsigned int monoId = 0;
635  std::vector<double> energyLossM;
636  std::vector<double> energyLossS;
637  std::vector<PSimHit> assSimHits = hitAssociator.associateHit(**itHit);
638  if (assSimHits.empty())
639  continue;
640  PSimHit shit;
641  std::vector<unsigned int> trackIds;
642  energyLossS.clear();
643  energyLossM.clear();
644  //LogTrace("TestOutliers") << "energyLossM";
645  for (std::vector<PSimHit>::const_iterator m = assSimHits.begin(); m < assSimHits.end(); m++) {
646  if (outlier)
647  energyLoss->Fill(m->energyLoss());
648  unsigned int tId = m->trackId();
649  if (find(trackIds.begin(), trackIds.end(), tId) == trackIds.end())
650  trackIds.push_back(tId);
651  LogTrace("TestOutliers") << "id=" << tId;
652  if (m->energyLoss() > energyLoss_) {
653  shit = *m;
654  energyLoss_ = m->energyLoss();
655  }
656  if (hittypeval == 3) {
657  if (monoId == 0)
658  monoId = m->detUnitId();
659  if (monoId == m->detUnitId()) {
660  energyLossM.push_back(m->energyLoss());
661  } else {
662  energyLossS.push_back(m->energyLoss());
663  }
664  //std::cout << "detUnitId=" << m->detUnitId() << " trackId=" << m->trackId() << " energyLoss=" << m->energyLoss() << std::endl;
665  } else {
666  energyLossM.push_back(m->energyLoss());
667  }
668  }
669  unsigned int nIds = trackIds.size();
670 
671  if (outlier) {
672  goodbadhits->Fill(goodhit);
673  posxy->Fill(fabs(gpos.x()), fabs(gpos.y()));
674  poszr->Fill(fabs(gpos.z()), sqrt(gpos.x() * gpos.x() + gpos.y() * gpos.y()));
675  process->Fill(shit.processType());
676  energyLossMax->Fill(energyLoss_);
677  }
678 
679  //look if the hit is shared and if is produced only by ionization processes
680  bool shared = true;
681  bool ioniOnly = true;
682  unsigned int idc = 0;
683  for (size_t jj = 0; jj < tpids.size(); jj++) {
684  idc += std::count(trackIds.begin(), trackIds.end(), tpids[jj]);
685  }
686  if (idc == trackIds.size()) {
687  shared = false;
688  }
689  for (std::vector<PSimHit>::const_iterator m = assSimHits.begin() + 1; m < assSimHits.end(); m++) {
690  if ((m->processType() != 7 && m->processType() != 8 && m->processType() != 9) &&
691  abs(m->particleType()) != 11) {
692  ioniOnly = false;
693  break;
694  }
695  }
696  if (ioniOnly && !shared) {
697  LogTrace("TestOutliers") << "delta";
698  }
699 
700  if (goodhit) {
701  if (outlier) {
702  goodprocess->Fill(shit.processType());
703  if (clustersize >= 4) {
704  goodhittype_clgteq4->Fill(hittypeval);
705  goodlayer_clgteq4->Fill(layerval);
706  } else {
707  goodhittype_cllt4->Fill(hittypeval);
708  goodlayer_cllt4->Fill(layerval);
709  }
710  //LogTrace("TestOutliers") << "hittypeval && clustersize";
711  if (hittypeval == 1 && clustersize >= 4)
712  goodpixgteq4_simvecsize->Fill(assSimHits.size());
713  if (hittypeval == 1 && clustersize < 4)
714  goodpixlt4_simvecsize->Fill(assSimHits.size());
715  if (hittypeval == 2 && clustersize >= 4)
716  goodst1gteq4_simvecsize->Fill(assSimHits.size());
717  if (hittypeval == 2 && clustersize < 4)
718  goodst1lt4_simvecsize->Fill(assSimHits.size());
719  if (hittypeval == 3 && clustersize >= 4)
720  goodst2gteq4_simvecsize->Fill(assSimHits.size());
721  if (hittypeval == 3 && clustersize < 4)
722  goodst2lt4_simvecsize->Fill(assSimHits.size());
723  if (hittypeval == 4 && clustersize >= 4)
724  goodprjgteq4_simvecsize->Fill(assSimHits.size());
725  if (hittypeval == 4 && clustersize < 4)
726  goodprjlt4_simvecsize->Fill(assSimHits.size());
727 
728  //LogTrace("TestOutliers") << "hittypeval";
729  if (hittypeval == 1)
730  goodpix_clustersize->Fill(clustersize);
731  if (hittypeval == 2)
732  goodst1_clustersize->Fill(clustersize);
733  if (hittypeval == 3)
734  goodst2_clustersize->Fill(clustersize);
735  if (hittypeval == 4)
736  goodprj_clustersize->Fill(clustersize);
737  if (hittypeval == 1)
738  goodpix_simvecsize->Fill(assSimHits.size());
739  if (hittypeval == 2)
740  goodst1_simvecsize->Fill(assSimHits.size());
741  if (hittypeval == 3)
742  goodst2_simvecsize->Fill(assSimHits.size());
743  if (hittypeval == 4)
744  goodprj_simvecsize->Fill(assSimHits.size());
745 
746  //LogTrace("TestOutliers") << "nOfTrackIds";
747  nOfTrackIds->Fill(nIds);
748  if (hittypeval != 3) {
749  if (energyLossM.size() > 1) {
750  sort(energyLossM.begin(), energyLossM.end(), greater<double>());
751  energyLossRatio->Fill(energyLossM[1] / energyLossM[0]);
752  }
753  } else {
754  //LogTrace("TestOutliers") << "hittypeval==3";
755  if (energyLossM.size() > 1 && energyLossS.size() <= 1) {
756  sort(energyLossM.begin(), energyLossM.end(), greater<double>());
757  energyLossRatio->Fill(energyLossM[1] / energyLossM[0]);
758  } else if (energyLossS.size() > 1 && energyLossM.size() <= 1) {
759  sort(energyLossS.begin(), energyLossS.end(), greater<double>());
760  energyLossRatio->Fill(energyLossS[1] / energyLossS[0]);
761  } else if (energyLossS.size() > 1 && energyLossM.size() > 1) {
762  sort(energyLossM.begin(), energyLossM.end(), greater<double>());
763  sort(energyLossS.begin(), energyLossS.end(), greater<double>());
764  energyLossM[1] / energyLossM[0] > energyLossS[1] / energyLossS[0]
765  ? energyLossRatio->Fill(energyLossM[1] / energyLossM[0])
766  : energyLossRatio->Fill(energyLossS[1] / energyLossS[0]);
767  }
768  }
769 
770  LogTrace("TestOutliers") << "before merged";
771  const SiStripMatchedRecHit2D *tmp = dynamic_cast<const SiStripMatchedRecHit2D *>(&**itHit);
772  LogTrace("TestOutliers") << "tmp=" << tmp;
773  LogTrace("TestOutliers") << "assSimHits.size()=" << assSimHits.size();
774  if ((assSimHits.size() > 1 && tmp == nullptr) || (assSimHits.size() > 2 && tmp != nullptr)) {
775  //std::cout << "MERGED HIT" << std::endl;
776  //LogTrace("TestOutliers") << "merged";
777  mergedlayer->Fill(layerval);
778  mergedcluster->Fill(clustersize);
779  mergedhittype->Fill(hittypeval);
780 
781  for (std::vector<PSimHit>::const_iterator m = assSimHits.begin(); m < assSimHits.end(); m++) {
782  unsigned int tId = m->trackId();
783  LogTrace("TestOutliers") << "component with id=" << tId << " eLoss=" << m->energyLoss()
784  << " proc=" << m->processType() << " part=" << m->particleType();
785  if (find(tpids.begin(), tpids.end(), tId) == tpids.end())
786  continue;
787  if (m->processType() == 2) {
788  //GlobalPoint gpos = theG->idToDet((*itHit)->geographicalId())->surface().toGlobal((*itHit)->localPosition());
789  //GlobalPoint gpr = rhit->globalPosition();
791  .transform((*itHit)->localPositionError(),
792  theG->idToDet((*itHit)->geographicalId())->surface())
793  .matrix();
794  //AlgebraicSymMatrix ger = rhit->globalPositionError().matrix();
795  GlobalPoint gps =
796  theG->idToDet((*itHit)->geographicalId())->surface().toGlobal(m->localPosition());
797  //LogTrace("TestOutliers") << gpr << " " << gps << " " << ger;
798  ROOT::Math::SVector<double, 3> delta;
799  delta[0] = gpos.x() - gps.x();
800  delta[1] = gpos.y() - gps.y();
801  delta[2] = gpos.z() - gps.z();
802  LogTrace("TestOutliers") << delta << " " << ger;
803  double mpull = sqrt(delta[0] * delta[0] / ger[0][0] + delta[1] * delta[1] / ger[1][1] +
804  delta[2] * delta[2] / ger[2][2]);
805  LogTrace("TestOutliers") << "hit pull=" << mpull; //ger.similarity(delta);
806  mergedPull->Fill(mpull);
807  }
808  }
809  LogTrace("TestOutliers") << "end merged";
810  } else { //not merged=>good
811  //LogTrace("TestOutliers") << "goodlayer";
812  goodlayer->Fill(layerval);
813  goodcluster->Fill(clustersize);
814  goodhittype->Fill(hittypeval);
815  }
816  } //if (outlier)
817 
818  const SiPixelRecHit *pix = dynamic_cast<const SiPixelRecHit *>(&**itHit);
819  if ((hittypeval != 3 && assSimHits.size() < 2) || (hittypeval == 3 && assSimHits.size() < 3)) {
820  if (outlier) {
821  goodhittype_simvecsmall->Fill(hittypeval);
822  goodlayer_simvecsmall->Fill(layerval);
823  goodbadmerged->Fill(1);
824  if (pix) {
825  probXgood->Fill(pix->probabilityX());
826  probYgood->Fill(pix->probabilityY());
827  }
828  LogTrace("TestOutliers") << "out good";
829  } else if (lost) {
830  goodbadmergedLost->Fill(1);
831  LogTrace("TestOutliers") << "lost good";
832  } else if (gained) {
833  goodbadmergedGained->Fill(1);
834  LogTrace("TestOutliers") << "gained good";
835  }
836  LogTrace("TestOutliers") << "good";
837  } else {
838  if (outlier) {
839  goodhittype_simvecbig->Fill(hittypeval);
840  goodlayer_simvecbig->Fill(layerval);
841  if (ioniOnly && !shared) {
842  goodbadmerged->Fill(3);
843  if (pix) {
844  probXdelta->Fill(pix->probabilityX());
845  probYdelta->Fill(pix->probabilityY());
846  }
847  } else if (!ioniOnly && !shared) {
848  goodbadmerged->Fill(4);
849  if (pix) {
850  probXnoshare->Fill(pix->probabilityX());
851  probYnoshare->Fill(pix->probabilityY());
852  }
853  } else {
854  goodbadmerged->Fill(5);
855  if (pix) {
856  probXshared->Fill(pix->probabilityX());
857  probYshared->Fill(pix->probabilityY());
858  }
859  }
860  LogTrace("TestOutliers") << "out merged, ioniOnly=" << ioniOnly << " shared=" << shared;
861  } else if (lost) {
862  if (ioniOnly && !shared)
863  goodbadmergedLost->Fill(3);
864  else if (!ioniOnly && !shared)
865  goodbadmergedLost->Fill(4);
866  else
867  goodbadmergedLost->Fill(5);
868  LogTrace("TestOutliers") << "lost merged, ioniOnly=" << ioniOnly << " shared=" << shared;
869  } else if (gained) {
870  if (ioniOnly && !shared)
871  goodbadmergedGained->Fill(3);
872  else if (!ioniOnly && !shared)
873  goodbadmergedGained->Fill(4);
874  else
875  goodbadmergedGained->Fill(5);
876  LogTrace("TestOutliers") << "gained merged, ioniOnly=" << ioniOnly << " shared=" << shared;
877  }
878  LogTrace("TestOutliers") << "merged, ioniOnly=" << ioniOnly << " shared=" << shared;
879  }
880  } //if (goodhit)
881  else { //badhit
882  //LogTrace("TestOutliers") << "badhit";
883  if (outlier) {
884  badcluster->Fill(clustersize);
885  badhittype->Fill(hittypeval);
886  badlayer->Fill(layerval);
887  badprocess->Fill(shit.processType());
888  goodbadmerged->Fill(2);
889  const SiPixelRecHit *pix = dynamic_cast<const SiPixelRecHit *>(&**itHit);
890  if (pix) {
891  probXbad->Fill(pix->probabilityX());
892  probYbad->Fill(pix->probabilityY());
893  }
894  LogTrace("TestOutliers") << "out bad";
895  } else if (lost) {
896  goodbadmergedLost->Fill(2);
897  LogTrace("TestOutliers") << "lost bad";
898  } else if (gained) {
899  goodbadmergedGained->Fill(2);
900  LogTrace("TestOutliers") << "gained bad";
901  }
902  LogTrace("TestOutliers") << "bad";
903  }
904  }
905  }
906  }
907  //else if ( trackOut->numberOfValidHits() > trackOld->numberOfValidHits() ) {
908  else if (false) {
909  LogTrace("TestOutliers") << "outliers for track with #hits=" << trackOut->numberOfValidHits();
910  tracks->Fill(1);
911  LogTrace("TestOutliers")
912  << "Out->pt=" << trackOut->pt() << " Old->pt=" << trackOld->pt() << " tp->pt="
913  << sqrt(tpr->momentum().perp2())
914  //<< " trackOut->ptError()=" << trackOut->ptError() << " trackOld->ptError()=" << trackOld->ptError()
915  << " Old->validHits=" << trackOld->numberOfValidHits() << " Out->validHits="
916  << trackOut->numberOfValidHits()
917  /*<< " fracOld=" << fracOld*/
918  << " fracOut=" << fracOut << " deltaHits=" << trackOld->numberOfValidHits() - trackOut->numberOfValidHits();
919  LogTrace("TestOutliers") << "track with gained hits";
920  gainedhits2->Fill(trackOut->numberOfValidHits() - trackOld->numberOfValidHits());
921  } else {
922  LogTrace("TestOutliers") << "no outliers for track with #hits=" << trackOut->numberOfValidHits();
923  }
924  }
925  LogTrace("TestOutliers") << "end track old #" << j;
926  }
927 
928  for (unsigned int k = 0; k < tracksOut->size(); ++k) {
929  if (find(outused.begin(), outused.end(), k) == outused.end()) {
930  edm::RefToBase<reco::Track> trackOut(tracksOut, k);
931  bool outAssoc = recSimCollOut.find(trackOut) != recSimCollOut.end();
932  if (outAssoc) {
933  hitsPerTrackGained->Fill(trackOut->numberOfValidHits());
934  LogTrace("TestOutliers") << "gained track out id=" << k << " #hits==" << trackOut->numberOfValidHits();
935  }
936  }
937  }
938 }
939 
940 // ------------ method called once each job just before starting event loop ------------
942  const bool oldAddDir = TH1::AddDirectoryStatus();
943  TH1::AddDirectory(true);
944  file = new TFile(out.c_str(), "recreate");
945  histoPtOut = new TH1F("histoPtOut", "histoPtOut", 100, -10, 10);
946  histoPtOld = new TH1F("histoPtOld", "histoPtOld", 100, -10, 10);
947  histoQoverpOut = new TH1F("histoQoverpOut", "histoQoverpOut", 250, -25, 25);
948  histoQoverpOld = new TH1F("histoQoverpOld", "histoQoverpOld", 250, -25, 25);
949  histoPhiOut = new TH1F("histoPhiOut", "histoPhiOut", 250, -25, 25);
950  histoPhiOld = new TH1F("histoPhiOld", "histoPhiOld", 250, -25, 25);
951  histoD0Out = new TH1F("histoD0Out", "histoD0Out", 250, -25, 25);
952  histoD0Old = new TH1F("histoD0Old", "histoD0Old", 250, -25, 25);
953  histoDzOut = new TH1F("histoDzOut", "histoDzOut", 250, -25, 25);
954  histoDzOld = new TH1F("histoDzOld", "histoDzOld", 250, -25, 25);
955  histoLambdaOut = new TH1F("histoLambdaOut", "histoLambdaOut", 250, -25, 25);
956  histoLambdaOld = new TH1F("histoLambdaOld", "histoLambdaOld", 250, -25, 25);
957  deltahits = new TH1F("deltahits", "deltahits", 80, -40, 40);
958  deltahitsOK = new TH1F("deltahitsOK", "deltahitsOK", 20, 0, 20);
959  deltahitsNO = new TH1F("deltahitsNO", "deltahitsNO", 20, 0, 20);
960  okcutsOut = new TH1F("okcutsOut", "okcutsOut", 2, -0.5, 1.5);
961  okcutsOld = new TH1F("okcutsOld", "okcutsOld", 2, -0.5, 1.5);
962  tracks = new TH1F("tracks_", "tracks_", 2, -0.5, 1.5);
963  goodbadhits = new TH1F("goodbadhits", "goodbadhits", 2, -0.5, 1.5);
964  process = new TH1F("process", "process", 20, -0.5, 19.5);
965  goodcluster = new TH1F("goodcluster", "goodcluster", 40, -0.5, 39.5);
966  goodprocess = new TH1F("goodprocess", "goodprocess", 20, -0.5, 19.5);
967  badcluster = new TH1F("badcluster", "badcluster", 40, -0.5, 39.5);
968  badprocess = new TH1F("badprocess", "badprocess", 20, -0.5, 19.5);
969  goodhittype = new TH1F("goodhittype", "goodhittype", 5, -0.5, 4.5);
970  goodlayer = new TH1F("goodlayer", "goodlayer", 70, -0.5, 69.5);
971  goodhittype_clgteq4 = new TH1F("goodhittype_clgteq4", "goodhittype_clgteq4", 5, -0.5, 4.5);
972  goodlayer_clgteq4 = new TH1F("goodlayer_clgteq4", "goodlayer_clgteq4", 70, -0.5, 69.5);
973  goodhittype_cllt4 = new TH1F("goodhittype_cllt4", "goodhittype_cllt4", 5, -0.5, 4.5);
974  goodlayer_cllt4 = new TH1F("goodlayer_cllt4", "goodlayer_cllt4", 70, -0.5, 69.5);
975  badhittype = new TH1F("badhittype", "badhittype", 5, -0.5, 4.5);
976  badlayer = new TH1F("badlayer", "badlayer", 70, -0.5, 69.5);
977  posxy = new TH2F("posxy", "posxy", 1200, 0, 120, 1200, 0, 120);
978  poszr = new TH2F("poszr", "poszr", 3000, 0, 300, 1200, 0, 120);
979  goodpixgteq4_simvecsize = new TH1F("goodpixgteq4_simvecsize", "goodpixgteq4_simvecsize", 40, -0.5, 39.5);
980  goodpixlt4_simvecsize = new TH1F("goodpixlt4_simvecsize", "goodpixlt4_simvecsize", 40, -0.5, 39.5);
981  goodst1gteq4_simvecsize = new TH1F("goodst1gteq4_simvecsize", "goodst1gteq4_simvecsize", 40, -0.5, 39.5);
982  goodst1lt4_simvecsize = new TH1F("goodst1lt4_simvecsize", "goodst1lt4_simvecsize", 40, -0.5, 39.5);
983  goodst2gteq4_simvecsize = new TH1F("goodst2gteq4_simvecsize", "goodst2gteq4_simvecsize", 40, -0.5, 39.5);
984  goodst2lt4_simvecsize = new TH1F("goodst2lt4_simvecsize", "goodst2lt4_simvecsize", 40, -0.5, 39.5);
985  goodprjgteq4_simvecsize = new TH1F("goodprjgteq4_simvecsize", "goodprjgteq4_simvecsize", 40, -0.5, 39.5);
986  goodprjlt4_simvecsize = new TH1F("goodprjlt4_simvecsize", "goodprjlt4_simvecsize", 40, -0.5, 39.5);
987  goodpix_clustersize = new TH1F("goodpix_clustersize", "goodpix_clustersize", 40, -0.5, 39.5);
988  goodst1_clustersize = new TH1F("goodst1_clustersize", "goodst1_clustersize", 40, -0.5, 39.5);
989  goodst2_clustersize = new TH1F("goodst2_clustersize", "goodst2_clustersize", 40, -0.5, 39.5);
990  goodprj_clustersize = new TH1F("goodprj_clustersize", "goodprj_clustersize", 40, -0.5, 39.5);
991  goodpix_simvecsize = new TH1F("goodpix_simvecsize", "goodpix_simvecsize", 40, -0.5, 39.5);
992  goodst1_simvecsize = new TH1F("goodst1_simvecsize", "goodst1_simvecsize", 40, -0.5, 39.5);
993  goodst2_simvecsize = new TH1F("goodst2_simvecsize", "goodst2_simvecsize", 40, -0.5, 39.5);
994  goodprj_simvecsize = new TH1F("goodprj_simvecsize", "goodprj_simvecsize", 40, -0.5, 39.5);
995  goodhittype_simvecsmall = new TH1F("goodhittype_simvecsmall", "goodhittype_simvecsmall", 5, -0.5, 4.5);
996  goodlayer_simvecsmall = new TH1F("goodlayer_simvecsmall", "goodlayer_simvecsmall", 70, -0.5, 69.5);
997  goodhittype_simvecbig = new TH1F("goodhittype_simvecbig", "goodhittype_simvecbig", 5, -0.5, 4.5);
998  goodlayer_simvecbig = new TH1F("goodlayer_simvecbig", "goodlayer_simvecbig", 70, -0.5, 69.5);
999  goodbadmerged = new TH1F("goodbadmerged", "goodbadmerged", 5, 0.5, 5.5);
1000  goodbadmergedLost = new TH1F("goodbadmergedLost", "goodbadmergedLost", 5, 0.5, 5.5);
1001  goodbadmergedGained = new TH1F("goodbadmergedGained", "goodbadmergedGained", 5, 0.5, 5.5);
1002  energyLoss = new TH1F("energyLoss", "energyLoss", 1000, 0, 0.1);
1003  energyLossMax = new TH1F("energyLossMax", "energyLossMax", 1000, 0, 0.1);
1004  energyLossRatio = new TH1F("energyLossRatio", "energyLossRatio", 100, 0, 1);
1005  nOfTrackIds = new TH1F("nOfTrackIds", "nOfTrackIds", 10, 0, 10);
1006  mergedPull = new TH1F("mergedPull", "mergedPull", 100, 0, 10);
1007  mergedlayer = new TH1F("mergedlayer", "mergedlayer", 70, -0.5, 69.5);
1008  mergedhittype = new TH1F("mergedhittype", "mergedhittype", 5, -0.5, 4.5);
1009  mergedcluster = new TH1F("mergedcluster", "mergedcluster", 40, -0.5, 39.5);
1010  deltahitsAssocGained = new TH1F("deltahitsAssocGained", "deltahitsAssocGained", 80, -40, 40);
1011  deltahitsAssocLost = new TH1F("deltahitsAssocLost", "deltahitsAssocLost", 80, -40, 40);
1012  hitsPerTrackLost = new TH1F("hitsPerTrackLost", "hitsPerTrackLost", 40, -0.5, 39.5);
1013  hitsPerTrackAssocLost = new TH1F("hitsPerTrackAssocLost", "hitsPerTrackAssocLost", 40, -0.5, 39.5);
1014  hitsPerTrackGained = new TH1F("hitsPerTrackGained", "hitsPerTrackGained", 40, -0.5, 39.5);
1015  hitsPerTrackAssocGained = new TH1F("hitsPerTrackAssocGained", "hitsPerTrackAssocGained", 40, -0.5, 39.5);
1016  sizeOut = new TH1F("sizeOut", "sizeOut", 900, -0.5, 899.5);
1017  sizeOld = new TH1F("sizeOld", "sizeOld", 900, -0.5, 899.5);
1018  sizeOutT = new TH1F("sizeOutT", "sizeOutT", 900, -0.5, 899.5);
1019  sizeOldT = new TH1F("sizeOldT", "sizeOldT", 900, -0.5, 899.5);
1020  countOutA = new TH1F("countOutA", "countOutA", 2, 0, 2);
1021  countOutT = new TH1F("countOutT", "countOutT", 2, 0, 2);
1022  countOldT = new TH1F("countOldT", "countOldT", 2, 0, 2);
1023  gainedhits = new TH1F("gainedhits", "gainedhits", 2, 0, 2);
1024  gainedhits2 = new TH1F("gainedhits2", "gainedhits2", 30, -0.5, 29.5);
1025  probXgood = new TH1F("probXgood", "probXgood", 110, 0, 1.1);
1026  probXbad = new TH1F("probXbad", "probXbad", 110, 0, 1.1);
1027  probXdelta = new TH1F("probXdelta", "probXdelta", 110, 0, 1.1);
1028  probXshared = new TH1F("probXshared", "probXshared", 110, 0, 1.1);
1029  probXnoshare = new TH1F("probXnoshare", "probXnoshare", 110, 0, 1.1);
1030  probYgood = new TH1F("probYgood", "probYgood", 110, 0, 1.1);
1031  probYbad = new TH1F("probYbad", "probYbad", 110, 0, 1.1);
1032  probYdelta = new TH1F("probYdelta", "probYdelta", 110, 0, 1.1);
1033  probYshared = new TH1F("probYshared", "probYshared", 110, 0, 1.1);
1034  probYnoshare = new TH1F("probYnoshare", "probYnoshare", 110, 0, 1.1);
1035  TH1::AddDirectory(oldAddDir);
1036 }
1037 // ------------ method called once each job just after ending the event loop ------------
1039  LogTrace("TestOutliers") << "TestOutliers::endJob";
1040  file->Write();
1041  LogTrace("TestOutliers") << "outfile written";
1042  file->Close();
1043  LogTrace("TestOutliers") << "oufile closed";
1044  LogTrace("TestOutliers") << "exiting TestOutliers::endJob";
1045 }
1046 
1047 //define this as a plug-in
TH1F * histoLambdaOut
Definition: TestOutliers.cc:83
double qoverp() const
q / p
Definition: TrackBase.h:600
TH1F * hitsPerTrackGained
Definition: TestOutliers.cc:84
static GlobalError transform(const LocalError &le, const Surface &surf)
edm::EDGetTokenT< reco::TrackToTrackingParticleAssociator > theAssociatorOutToken
Definition: TestOutliers.cc:71
ESGetTokenH3DDVariant esConsumes(std::string const &Record, edm::ConsumesCollector &)
Definition: DeDxTools.cc:283
TH1F * goodhittype_cllt4
Definition: TestOutliers.cc:88
TH1F * mergedcluster
double lambda() const
Lambda angle.
Definition: TrackBase.h:606
TH1F * histoDzOld
Definition: TestOutliers.cc:82
TH1F * goodprj_clustersize
Definition: TestOutliers.cc:98
TH1F * probXshared
reco::RecoToSimCollection associateRecoToSim(const edm::Handle< edm::View< reco::Track >> &tCH, const edm::Handle< TrackingParticleCollection > &tPCH) const
double qoverpError() const
error on signed transverse curvature
Definition: TrackBase.h:733
TH1F * goodpixlt4_simvecsize
Definition: TestOutliers.cc:91
double ptError() const
error on Pt (set to 1000 TeV if charge==0 for safety)
Definition: TrackBase.h:755
unsigned short numberOfValidHits() const
number of valid hits found
Definition: TrackBase.h:799
TH1F * goodhittype
Definition: TestOutliers.cc:88
TH1F * histoQoverpOut
Definition: TestOutliers.cc:79
T z() const
Definition: PV3DBase.h:61
float probabilityX() const
Definition: SiPixelRecHit.h:82
TH1F * hitsPerTrackAssocLost
Definition: TestOutliers.cc:84
TH1F * goodst1_simvecsize
TH1F * goodst2lt4_simvecsize
Definition: TestOutliers.cc:93
TH1F * goodbadmergedLost
TH1F * goodst1gteq4_simvecsize
Definition: TestOutliers.cc:92
TH1F * goodprj_simvecsize
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
TH1F * okcutsOut
Definition: TestOutliers.cc:86
T const * product() const
Definition: Handle.h:70
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:14
TFile * file
Definition: TestOutliers.cc:77
double thetaError() const
error on theta
Definition: TrackBase.h:758
TH1F * deltahitsNO
Definition: TestOutliers.cc:84
TH1F * energyLossRatio
void endRun(edm::Run const &run, const edm::EventSetup &) override
Definition: TestOutliers.cc:62
const edm::RefToBase< TrajectorySeed > & seedRef() const
Definition: Track.h:155
TH1F * histoPtOut
Definition: TestOutliers.cc:78
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:19
const edm::ESGetToken< TrackerGeometry, TrackerDigiGeometryRecord > theGToken
Definition: TestOutliers.cc:72
uint16_t size_type
TH1F * hitsPerTrackAssocGained
Definition: TestOutliers.cc:84
const math::XYZTLorentzVectorD & momentum() const
Definition: CoreSimTrack.h:19
const_iterator find(const key_type &k) const
find element with specified reference key
TH1F * process
Definition: TestOutliers.cc:87
TH1F * goodst2_simvecsize
unsigned int layer(const DetId &id) const
#define LogTrace(id)
TH1F * probYdelta
edm::EDGetTokenT< reco::TrackToTrackingParticleAssociator > theAssociatorOldToken
Definition: TestOutliers.cc:70
TH1F * energyLossMax
double dsz() const
dsz parameter (THIS IS NOT the SZ impact parameter to (0,0,0) if refPoint is far from (0...
Definition: TrackBase.h:615
TH1F * probYgood
TH1F * badhittype
Definition: TestOutliers.cc:88
const_iterator end() const
last iterator over the map (read only)
GlobalPoint position() const
TH1F * goodlayer_clgteq4
Definition: TestOutliers.cc:88
size_type size() const
map size
TH1F * mergedhittype
double pt() const
track transverse momentum
Definition: TrackBase.h:638
int TrackCharge
Definition: TrackCharge.h:4
~TestOutliers() override
TH1F * energyLoss
T x() const
Definition: PV3DBase.h:59
T y() const
Definition: PV3DBase.h:60
TH1F * deltahits
Definition: TestOutliers.cc:84
TH1F * histoD0Old
Definition: TestOutliers.cc:81
TH1F * probYshared
TH1F * goodprocess
Definition: TestOutliers.cc:87
TH1F * goodhittype_simvecsmall
int charge() const
track electric charge
Definition: TrackBase.h:597
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:623
int iEvent
Definition: GenABIO.cc:224
T const * product() const
Definition: ESHandle.h:86
TH1F * goodpix_clustersize
Definition: TestOutliers.cc:95
TH1F * goodprjgteq4_simvecsize
Definition: TestOutliers.cc:94
TH1F * badlayer
Definition: TestOutliers.cc:88
TH1F * goodst1_clustersize
Definition: TestOutliers.cc:96
TH1F * goodpixgteq4_simvecsize
Definition: TestOutliers.cc:91
TH1F * histoPhiOld
Definition: TestOutliers.cc:80
TH1F * badcluster
Definition: TestOutliers.cc:87
TH1F * probXgood
TH1F * countOutA
double dzError() const
error on dz
Definition: TrackBase.h:779
TH1F * goodprjlt4_simvecsize
Definition: TestOutliers.cc:94
T sqrt(T t)
Definition: SSEVec.h:19
const edm::ESGetToken< TrackerTopology, TrackerTopologyRcd > theTopoToken
Definition: TestOutliers.cc:74
unsigned short processType() const
Definition: PSimHit.h:120
TH1F * goodpix_simvecsize
Definition: TestOutliers.cc:99
TH1F * goodlayer
Definition: TestOutliers.cc:88
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
TH1F * badprocess
Definition: TestOutliers.cc:87
TH1F * histoPhiOut
Definition: TestOutliers.cc:80
std::string out
Definition: TestOutliers.cc:76
GlobalVector momentum() const
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
Transition
Definition: Transition.h:12
TH1F * goodlayer_simvecsmall
TH1F * goodhittype_simvecbig
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:91
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:650
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:16
TestOutliers(const edm::ParameterSet &)
edm::InputTag trackTagsOut_
Definition: TestOutliers.cc:66
ESHandle< T > getHandle(const ESGetToken< T, R > &iToken) const
Definition: EventSetup.h:130
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:88
TH1F * probXnoshare
const TrackerGeomDet * idToDet(DetId) const override
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:49
#define M_PI
TH1F * probYnoshare
TH1F * mergedlayer
std::vector< SimTrack >::const_iterator g4t_iterator
TH1F * deltahitsOK
Definition: TestOutliers.cc:84
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:653
Definition: DetId.h:17
TH1F * goodst1lt4_simvecsize
Definition: TestOutliers.cc:92
TH1F * histoPtOld
Definition: TestOutliers.cc:78
TH1F * goodhittype_clgteq4
Definition: TestOutliers.cc:88
edm::InputTag tpTags_
Definition: TestOutliers.cc:68
double d0() const
dxy parameter in perigee convention (d0 = -dxy)
Definition: TrackBase.h:612
TH1F * deltahitsAssocGained
Definition: TestOutliers.cc:84
void beginRun(edm::Run const &run, const edm::EventSetup &) override
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:594
TH1F * goodlayer_cllt4
Definition: TestOutliers.cc:88
const FreeTrajectoryState & theState() const
TH1F * histoDzOut
Definition: TestOutliers.cc:82
TH1F * probXdelta
TH1F * goodst2_clustersize
Definition: TestOutliers.cc:97
float probabilityY() const
Definition: SiPixelRecHit.h:83
TrackerHitAssociator::Config trackerHitAssociatorConfig_
Definition: TestOutliers.cc:69
TH1F * histoLambdaOld
Definition: TestOutliers.cc:83
fixed size matrix
HLT enums.
TH1F * countOldT
TH1F * countOutT
TH1F * goodst2gteq4_simvecsize
Definition: TestOutliers.cc:93
TH1F * goodcluster
Definition: TestOutliers.cc:87
TH1F * histoD0Out
Definition: TestOutliers.cc:81
edm::ESHandle< TrackerGeometry > theG
Definition: TestOutliers.cc:73
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:232
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
TH1F * okcutsOld
Definition: TestOutliers.cc:86
void analyze(const edm::Event &, const edm::EventSetup &) override
TH1F * mergedPull
TH1F * goodbadmerged
TH1F * deltahitsAssocLost
Definition: TestOutliers.cc:84
TH1F * goodlayer_simvecbig
TH1F * histoQoverpOld
Definition: TestOutliers.cc:79
TH1F * nOfTrackIds
edm::InputTag trackTagsOld_
Definition: TestOutliers.cc:67
TH1F * hitsPerTrackLost
Definition: TestOutliers.cc:84
TH1F * gainedhits
double d0Error() const
error on d0
Definition: TrackBase.h:773
double phiError() const
error on phi
Definition: TrackBase.h:767
tmp
align.sh
Definition: createJobs.py:716
void endJob() override
const edm::ESGetToken< MagneticField, IdealMagneticFieldRecord > theMFToken
Definition: TestOutliers.cc:75
value_type const * get() const
Definition: RefToBase.h:209
TH1F * goodbadhits
Definition: TestOutliers.cc:87
Definition: Run.h:45
Global3DVector GlobalVector
Definition: GlobalVector.h:10
TH1F * goodbadmergedGained
Our base class.
Definition: SiPixelRecHit.h:23
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:609
TH1F * gainedhits2