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