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