CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 // $Id: TestOutliers.cc,v 1.10 2010/08/06 20:24:59 wmtan Exp $
17 //
18 //
19 
20 
21 // system include files
22 #include <memory>
23 #include <vector>
24 
25 // user include files
28 
31 
38 #include <TH1.h>
39 #include <TH2.h>
40 #include <TFile.h>
57 
58 //
59 // class decleration
60 //
61 
62 class TestOutliers : public edm::EDAnalyzer {
63 public:
64  explicit TestOutliers(const edm::ParameterSet&);
65  ~TestOutliers();
66 
67 
68 private:
69  virtual void beginRun(edm::Run & run, const edm::EventSetup&) ;
70  virtual void analyze(const edm::Event&, const edm::EventSetup&);
71  virtual void endJob() ;
72 
73  // ----------member data ---------------------------
74  edm::InputTag trackTagsOut_; //used to select what tracks to read from configuration file
75  edm::InputTag trackTagsOld_; //used to select what tracks to read from configuration file
76  edm::InputTag tpTags_; //used to select what tracks to read from configuration file
79  //RecoTrackSelector selectRecoTracks;
82  std::string out;
83  TFile * file;
94  TH2F *posxy, *poszr;
115 };
116 //
117 // constants, enums and typedefs
118 //
119 
120 //
121 // static data member definitions
122 //
123 
124 using namespace edm;
125 
126 //
127 // constructors and destructor
128 //
130  :
131  trackTagsOut_(iConfig.getUntrackedParameter<edm::InputTag>("tracksOut")),
132  trackTagsOld_(iConfig.getUntrackedParameter<edm::InputTag>("tracksOld")),
133  tpTags_(iConfig.getUntrackedParameter<edm::InputTag>("tp")),
134  out(iConfig.getParameter<std::string>("out"))
135 {
136  LogTrace("TestOutliers") <<"constructor";
137 // ParameterSet cuts = iConfig.getParameter<ParameterSet>("RecoTracksCuts");
138 // selectRecoTracks = RecoTrackSelector(cuts.getParameter<double>("ptMin"),
139 // cuts.getParameter<double>("minRapidity"),
140 // cuts.getParameter<double>("maxRapidity"),
141 // cuts.getParameter<double>("tip"),
142 // cuts.getParameter<double>("lip"),
143 // cuts.getParameter<int>("minHit"),
144 // cuts.getParameter<double>("maxChi2"));
145 
146  psetold = iConfig.getParameter<ParameterSet>("TrackAssociatorByHitsPSetOld");
147  psetout = iConfig.getParameter<ParameterSet>("TrackAssociatorByHitsPSetOut");
148  LogTrace("TestOutliers") <<"end constructor";
149 }
150 
151 
153 {
154 
155  // do anything here that needs to be done at desctruction time
156  // (e.g. close files, deallocate resources etc.)
157 
158 }
159 
160 
161 //
162 // member functions
163 //
164 
165 // ------------ method called to for each event ------------
166 void
168 
169  using namespace edm;
170  using namespace std;
171  using reco::TrackCollection;
172 
173  LogTrace("TestOutliers") <<"analyze event #" << iEvent.id();
174 
176  iEvent.getByLabel(trackTagsOut_,tracksOut);
178  iEvent.getByLabel(trackTagsOld_,tracksOld);
180  iEvent.getByLabel(tpTags_,tps);
182  iEvent.getByLabel("offlineBeamSpot",beamSpot);
183 
184  hitAssociator = new TrackerHitAssociator(iEvent);
185 
188  reco::RecoToSimCollection recSimCollOut=theAssociatorOut->associateRecoToSim(tracksOut, tps, &iEvent);
189  reco::RecoToSimCollection recSimCollOld=theAssociatorOld->associateRecoToSim(tracksOld, tps, &iEvent);
190  sizeOut->Fill(recSimCollOut.size());
191  sizeOld->Fill(recSimCollOld.size());
192  sizeOutT->Fill(tracksOut->size());
193  sizeOldT->Fill(tracksOld->size());
194 
195  LogTrace("TestOutliers") << "tOld size=" << tracksOld->size() << " tOut size=" << tracksOut->size()
196  << " aOld size=" << recSimCollOld.size() << " aOut size=" << recSimCollOut.size();
197 
198 #if 0
199  LogTrace("TestOutliers") << "recSimCollOld.size()=" << recSimCollOld.size() ;
200  for(reco::TrackCollection::size_type j=0; j<tracksOld->size(); ++j){
201  reco::TrackRef trackOld(tracksOld, j);
202  //if ( !selectRecoTracks( *trackOld,beamSpot.product() ) ) continue;
203  LogTrace("TestOutliers") << "trackOld->pt()=" << trackOld->pt() << " trackOld->numberOfValidHits()=" << trackOld->numberOfValidHits();
204  std::vector<pair<TrackingParticleRef, double> > tpOld;
205  if(recSimCollOld.find(trackOld) != recSimCollOld.end()){
206  tpOld = recSimCollOld[trackOld];
207  if (tpOld.size()!=0) LogTrace("TestOutliers") << " associated" ;
208  else LogTrace("TestOutliers") << " NOT associated" ;
209  } else LogTrace("TestOutliers") << " NOT associated" ;
210  }
211  LogTrace("TestOutliers") << "recSimCollOut.size()=" << recSimCollOut.size() ;
212  for(reco::TrackCollection::size_type j=0; j<tracksOut->size(); ++j){
213  reco::TrackRef trackOut(tracksOut, j);
214  //if ( !selectRecoTracks( *trackOut,beamSpot.product() ) ) continue;
215  LogTrace("TestOutliers") << "trackOut->pt()=" << trackOut->pt() << " trackOut->numberOfValidHits()=" << trackOut->numberOfValidHits();
216  std::vector<pair<TrackingParticleRef, double> > tpOut;
217  if(recSimCollOut.find(trackOut) != recSimCollOut.end()){
218  tpOut = recSimCollOut[trackOut];
219  if (tpOut.size()!=0) LogTrace("TestOutliers") << " associated" ;
220  else LogTrace("TestOutliers") << " NOT associated" ;
221  } else LogTrace("TestOutliers") << " NOT associated" ;
222  }
223 #endif
224 
225  LogTrace("TestOutliers") <<"tracksOut->size()="<<tracksOut->size();
226  LogTrace("TestOutliers") <<"tracksOld->size()="<<tracksOld->size();
227 
228  std::vector<unsigned int> outused;
229  for(unsigned int j=0; j<tracksOld->size(); ++j) {
230  countOldT->Fill(1);
231  edm::RefToBase<reco::Track> trackOld(tracksOld, j);
232  LogTrace("TestOutliers") << "now track old with id=" << j << " seed ref=" << trackOld->seedRef().get() << " pt=" << trackOld->pt()
233  << " eta=" << trackOld->eta() << " chi2=" << trackOld->normalizedChi2()
234  << " tip= " << fabs(trackOld->dxy(beamSpot->position()))
235  << " lip= " << fabs(trackOld->dsz(beamSpot->position()));
236 
237  // if (i==tracksOut->size()) {
238  // if(recSimCollOld.find(trackOld) != recSimCollOld.end()){
239  // vector<pair<TrackingParticleRef, double> > tpOld;
240  // tpOld = recSimCollOld[trackOld];
241  // if (tpOld.size()!=0) {
242  // LogTrace("TestOutliers") <<"no match: old associated and out lost! old has #hits=" << trackOld->numberOfValidHits()
243  // << " and fraction=" << tpOld.begin()->second;
244  // if (tpOld.begin()->second>0.5) hitsPerTrackLost->Fill(trackOld->numberOfValidHits());
245  // }
246  // }
247  // continue;
248  // }
249 
250  std::vector<unsigned int> outtest;//all the out tracks with the same seed ref
251  for(unsigned int k=0; k<tracksOut->size(); ++k) {
253  if ( tmpOut->seedRef() == trackOld->seedRef() ) {
254  outtest.push_back(k);
255  }
256  }
257 
259  if (outtest.size()==1) {// if only one that's it
260  trackOut = edm::RefToBase<reco::Track>(tracksOut, outtest[0]);
261  LogTrace("TestOutliers") << "now track out with id=" << outtest[0] << " seed ref=" << trackOut->seedRef().get() << " pt=" << trackOut->pt();
262  outused.push_back(outtest[0]);
263  } else if (outtest.size()>1) {//if > 1 take the one that shares all the hits with the old track
264  for(unsigned int p=0; p<outtest.size(); ++p) {
265  edm::RefToBase<reco::Track> tmpOut = edm::RefToBase<reco::Track>(tracksOut, outtest[p]);
266  bool allhits = true;
267  for (trackingRecHit_iterator itOut = tmpOut->recHitsBegin(); itOut!=tmpOut->recHitsEnd(); itOut++) {
268  if ((*itOut)->isValid()) {
269  bool thishit = false;
270  for (trackingRecHit_iterator itOld = trackOld->recHitsBegin(); itOld!=trackOld->recHitsEnd(); itOld++) {
271  if ((*itOld)->isValid()) {
272  const TrackingRecHit* kt = &(**itOld);
273  if ( (*itOut)->sharesInput(kt,TrackingRecHit::some) ) {
274  thishit = true;
275  break;
276  }
277  }
278  }
279  if (!thishit) 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] << " seed ref=" << trackOut->seedRef().get() << " pt=" << trackOut->pt();
285  outused.push_back(outtest[p]);
286  }
287  }
288  }
289 
290  if (outtest.size()==0 || trackOut.get()==0 ) {//no out track found for the old track
291  if(recSimCollOld.find(trackOld) != recSimCollOld.end()){
292  vector<pair<TrackingParticleRef, double> > tpOld;
293  tpOld = recSimCollOld[trackOld];
294  if (tpOld.size()!=0) {
295  LogTrace("TestOutliers") <<"no match: old associated and out lost! old has #hits=" << trackOld->numberOfValidHits()
296  << " and fraction=" << tpOld.begin()->second;
297  if (tpOld.begin()->second>0.5) hitsPerTrackLost->Fill(trackOld->numberOfValidHits());
298  }
299  }
300  LogTrace("TestOutliers") <<"...skip to next old track";
301  continue;
302  }
303 
304  //look if old and out are associated
305  LogTrace("TestOutliers") <<"trackOut->seedRef()=" << trackOut->seedRef().get() << " trackOld->seedRef()=" << trackOld->seedRef().get();
306  bool oldAssoc = recSimCollOld.find(trackOld) != recSimCollOld.end();
307  bool outAssoc = recSimCollOut.find(trackOut) != recSimCollOut.end();
308  LogTrace("TestOutliers") <<"outAssoc=" << outAssoc <<" oldAssoc=" << oldAssoc;
309 
310  // if ( trackOut->seedRef()!= trackOld->seedRef() ||
311  // (trackOut->seedRef() == trackOld->seedRef() && trackOut->numberOfValidHits()>trackOld->numberOfValidHits()) ) {
312  // LogTrace("TestOutliers") <<"out and old tracks does not match...";
313  // LogTrace("TestOutliers") <<"old has #hits=" << trackOld->numberOfValidHits();
314  // std::vector<pair<TrackingParticleRef, double> > tpOld;
315  // if(recSimCollOld.find(trackOld) != recSimCollOld.end()) {
316  // tpOld = recSimCollOld[trackOld];
317  // if (tpOld.size()!=0) {
318  // LogTrace("TestOutliers") <<"old was associated with fraction=" << tpOld.begin()->second;
319  // if (tpOld.begin()->second>0.5) hitsPerTrackLost->Fill(trackOld->numberOfValidHits());
320  // }
321  // }
322  // LogTrace("TestOutliers") <<"...skip to next old track";
323  // continue;
324  // }
325  // //++i;
326  countOutT->Fill(1);
327 
328  //if ( !selectRecoTracks( *trackOld,beamSpot.product() ) ) continue;//no more cuts
329 
330  tracks->Fill(0);//FIXME
331 
332  bool hasOut = false;
333 
335  TrackingParticleRef tprOut;
336  TrackingParticleRef tprOld;
337  double fracOut;
338  std::vector<unsigned int> tpids;
339  std::vector<std::pair<TrackingParticleRef, double> > tpOut;
340  std::vector<pair<TrackingParticleRef, double> > tpOld;
341  //contare outliers delle tracce che erano associate e non lo sono piu!!!!
342 
343  if(outAssoc) {//save the ids od the tp associate to the out track
344  tpOut = recSimCollOut[trackOut];
345  if (tpOut.size()!=0) {
346  countOutA->Fill(1);
347  tprOut = tpOut.begin()->first;
348  fracOut = tpOut.begin()->second;
349  for (TrackingParticle::g4t_iterator g4T=tprOut->g4Track_begin(); g4T!=tprOut->g4Track_end(); ++g4T) {
350  tpids.push_back(g4T->trackId());
351  }
352  }
353  }
354 
355  if(oldAssoc){//save the ids od the tp associate to the old track
356  tpOld = recSimCollOld[trackOld];
357  if (tpOld.size()!=0) {
358  tprOld = tpOld.begin()->first;
359  // LogTrace("TestOutliers") <<"old associated and out not! old has #hits=" << trackOld->numberOfValidHits()
360  // << " and fraction=" << tpOld.begin()->second;
361  // if (tpOld.begin()->second>0.5) hitsPerTrackLost->Fill(trackOld->numberOfValidHits());//deve essere un plot diverso tipo LostAssoc
362  if (tpOut.size()==0) {
363  for (TrackingParticle::g4t_iterator g4T=tprOld->g4Track_begin(); g4T!=tprOld->g4Track_end(); ++g4T) {
364  tpids.push_back(g4T->trackId());
365  }
366  }
367  }
368  }
369 
370  if (tprOut.get()!=0 || tprOld.get()!=0) { //at least one of the tracks has to be associated
371 
372  tpr = tprOut.get()!=0 ? tprOut : tprOld;
373 
374  const SimTrack * assocTrack = &(*tpr->g4Track_begin());
375 
376  //if ( trackOut->numberOfValidHits() < trackOld->numberOfValidHits() ) {
377  if ( trackOut->numberOfValidHits() != trackOld->numberOfValidHits() ||
378  !trackOut->recHitsBegin()->get()->sharesInput(trackOld->recHitsBegin()->get(),TrackingRecHit::some) ||
379  !(trackOut->recHitsEnd()-1)->get()->sharesInput((trackOld->recHitsEnd()-1)->get(),TrackingRecHit::some) )
380  { //there are outliers if the number of valid hits is != or if the first and last hit does not match
381  hasOut=true;
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()!=0 && tprOld.get()==0) { //out associated and old not: gained track
449  if (tpOld.size()!=0 && 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()==0 && tprOld.get()!=0) { //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))->monoHit()->cluster()->amplitudes().size();
576  int clsize2 = ((const SiStripMatchedRecHit2D*)(&**itHit))->stereoHit()->cluster()->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  int layerId = 0;
590  DetId id = (*itHit)->geographicalId();
591  if (id.subdetId()==3) layerId = ((TIBDetId)(id)).layer();
592  if (id.subdetId()==5) layerId = ((TOBDetId)(id)).layer();
593  if (id.subdetId()==1) layerId = ((PXBDetId)(id)).layer();
594  if (id.subdetId()==4) layerId = ((TIDDetId)(id)).wheel();
595  if (id.subdetId()==6) layerId = ((TECDetId)(id)).wheel();
596  if (id.subdetId()==2) layerId = ((PXFDetId)(id)).disk();
597  layerval = subdetId*10+layerId;
598 
599  //LogTrace("TestOutliers") << "gpos";
600  GlobalPoint gpos = theG->idToDet((*itHit)->geographicalId())->surface().toGlobal((*itHit)->localPosition());
601 
602 
603  //get the vector of sim hit associated and choose the one with the largest energy loss
604  //double delta = 99999;
605  //LocalPoint rhitLPv = (*itHit)->localPosition();
606  //vector<PSimHit> assSimHits = hitAssociator->associateHit(**itHit);
607  //if (assSimHits.size()==0) continue;
608  //PSimHit shit;
609  //for(std::vector<PSimHit>::const_iterator m=assSimHits.begin(); m<assSimHits.end(); m++){
610  //if ((m->localPosition()-rhitLPv).mag()<delta) {
611  // shit=*m;
612  // delta = (m->localPosition()-rhitLPv).mag();
613  // }
614  //}
615  //LogTrace("TestOutliers") << "energyLoss_";
616  double energyLoss_ = 0.;
617  unsigned int monoId = 0;
618  std::vector<double> energyLossM;
619  std::vector<double> energyLossS;
620  std::vector<PSimHit> assSimHits = hitAssociator->associateHit(**itHit);
621  if (assSimHits.size()==0) continue;
622  PSimHit shit;
623  std::vector<unsigned int> trackIds;
624  energyLossS.clear();
625  energyLossM.clear();
626  //LogTrace("TestOutliers") << "energyLossM";
627  for(std::vector<PSimHit>::const_iterator m=assSimHits.begin(); m<assSimHits.end(); m++){
628  if (outlier) energyLoss->Fill(m->energyLoss());
629  unsigned int tId = m->trackId();
630  if (find(trackIds.begin(),trackIds.end(),tId)==trackIds.end()) trackIds.push_back(tId);
631  LogTrace("TestOutliers") << "id=" << tId;
632  if (m->energyLoss()>energyLoss_) {
633  shit=*m;
634  energyLoss_ = m->energyLoss();
635  }
636  if (hittypeval==3) {
637  if (monoId==0) monoId = m->detUnitId();
638  if (monoId == m->detUnitId()){
639  energyLossM.push_back(m->energyLoss());
640  }
641  else {
642  energyLossS.push_back(m->energyLoss());
643  }
644  //std::cout << "detUnitId=" << m->detUnitId() << " trackId=" << m->trackId() << " energyLoss=" << m->energyLoss() << std::endl;
645  } else {
646  energyLossM.push_back(m->energyLoss());
647  }
648  }
649  unsigned int nIds = trackIds.size();
650 
651  if (outlier) {
652  goodbadhits->Fill(goodhit);
653  posxy->Fill(fabs(gpos.x()),fabs(gpos.y()));
654  poszr->Fill(fabs(gpos.z()),sqrt(gpos.x()*gpos.x()+gpos.y()*gpos.y()));
655  process->Fill(shit.processType());
656  energyLossMax->Fill(energyLoss_);
657  }
658 
659  //look if the hit is shared and if is produced only by ionization processes
660  bool shared = true;
661  bool ioniOnly = true;
662  unsigned int idc = 0;
663  for (size_t jj=0; jj<tpids.size(); jj++){
664  idc += std::count(trackIds.begin(),trackIds.end(),tpids[jj]);
665  }
666  if (idc==trackIds.size()) {
667  shared = false;
668  }
669  for(std::vector<PSimHit>::const_iterator m=assSimHits.begin()+1; m<assSimHits.end(); m++){
670  if ((m->processType()!=7&&m->processType()!=8&&m->processType()!=9)&&abs(m->particleType())!=11){
671  ioniOnly = false;
672  break;
673  }
674  }
675  if (ioniOnly&&!shared){
676  LogTrace("TestOutliers") << "delta";
677  }
678 
679  if (goodhit) {
680  if (outlier) {
681  goodprocess->Fill(shit.processType());
682  if (clustersize>=4) {
683  goodhittype_clgteq4->Fill(hittypeval);
684  goodlayer_clgteq4->Fill(layerval);
685  } else {
686  goodhittype_cllt4->Fill(hittypeval);
687  goodlayer_cllt4->Fill(layerval);
688  }
689  //LogTrace("TestOutliers") << "hittypeval && clustersize";
690  if (hittypeval==1 && clustersize>=4) goodpixgteq4_simvecsize->Fill(assSimHits.size());
691  if (hittypeval==1 && clustersize<4 ) goodpixlt4_simvecsize->Fill(assSimHits.size());
692  if (hittypeval==2 && clustersize>=4) goodst1gteq4_simvecsize->Fill(assSimHits.size());
693  if (hittypeval==2 && clustersize<4 ) goodst1lt4_simvecsize->Fill(assSimHits.size());
694  if (hittypeval==3 && clustersize>=4) goodst2gteq4_simvecsize->Fill(assSimHits.size());
695  if (hittypeval==3 && clustersize<4 ) goodst2lt4_simvecsize->Fill(assSimHits.size());
696  if (hittypeval==4 && clustersize>=4) goodprjgteq4_simvecsize->Fill(assSimHits.size());
697  if (hittypeval==4 && clustersize<4 ) goodprjlt4_simvecsize->Fill(assSimHits.size());
698 
699  //LogTrace("TestOutliers") << "hittypeval";
700  if (hittypeval==1) goodpix_clustersize->Fill(clustersize);
701  if (hittypeval==2) goodst1_clustersize->Fill(clustersize);
702  if (hittypeval==3) goodst2_clustersize->Fill(clustersize);
703  if (hittypeval==4) goodprj_clustersize->Fill(clustersize);
704  if (hittypeval==1) goodpix_simvecsize->Fill(assSimHits.size());
705  if (hittypeval==2) goodst1_simvecsize->Fill(assSimHits.size());
706  if (hittypeval==3) goodst2_simvecsize->Fill(assSimHits.size());
707  if (hittypeval==4) goodprj_simvecsize->Fill(assSimHits.size());
708 
709  //LogTrace("TestOutliers") << "nOfTrackIds";
710  nOfTrackIds->Fill(nIds);
711  if (hittypeval!=3) {
712  if (energyLossM.size()>1) {
713  sort(energyLossM.begin(),energyLossM.end(),greater<double>());
714  energyLossRatio->Fill(energyLossM[1]/energyLossM[0]);
715  }
716  } else {
717  //LogTrace("TestOutliers") << "hittypeval==3";
718  if (energyLossM.size()>1&&energyLossS.size()<=1) {
719  sort(energyLossM.begin(),energyLossM.end(),greater<double>());
720  energyLossRatio->Fill(energyLossM[1]/energyLossM[0]);
721  }
722  else if (energyLossS.size()>1&&energyLossM.size()<=1) {
723  sort(energyLossS.begin(),energyLossS.end(),greater<double>());
724  energyLossRatio->Fill(energyLossS[1]/energyLossS[0]);
725  }
726  else if (energyLossS.size()>1&&energyLossM.size()>1) {
727  sort(energyLossM.begin(),energyLossM.end(),greater<double>());
728  sort(energyLossS.begin(),energyLossS.end(),greater<double>());
729  energyLossM[1]/energyLossM[0] > energyLossS[1]/energyLossS[0]
730  ? energyLossRatio->Fill(energyLossM[1]/energyLossM[0])
731  : energyLossRatio->Fill(energyLossS[1]/energyLossS[0]);
732  }
733  }
734 
735  LogTrace("TestOutliers") << "before merged";
736  const SiStripMatchedRecHit2D* tmp = dynamic_cast<const SiStripMatchedRecHit2D*>(&**itHit);
737  LogTrace("TestOutliers") << "tmp=" << tmp;
738  LogTrace("TestOutliers") << "assSimHits.size()=" << assSimHits.size();
739  if ( (assSimHits.size()>1 && tmp==0) ||
740  (assSimHits.size()>2 && tmp!=0) ) {
741  //std::cout << "MERGED HIT" << std::endl;
742  //LogTrace("TestOutliers") << "merged";
743  mergedlayer->Fill(layerval);
744  mergedcluster->Fill(clustersize);
745  mergedhittype->Fill(hittypeval);
746 
747  for(std::vector<PSimHit>::const_iterator m=assSimHits.begin(); m<assSimHits.end(); m++){
748  unsigned int tId = m->trackId();
749  LogTrace("TestOutliers") << "component with id=" << tId << " eLoss=" << m->energyLoss()
750  << " proc=" << m->processType() << " part=" << m->particleType();
751  if (find(tpids.begin(),tpids.end(),tId)==tpids.end()) continue;
752  if (m->processType()==2) {
753  //GlobalPoint gpos = theG->idToDet((*itHit)->geographicalId())->surface().toGlobal((*itHit)->localPosition());
754  //GlobalPoint gpr = rhit->globalPosition();
755  AlgebraicSymMatrix ger =
756  ErrorFrameTransformer().transform((*itHit)->localPositionError(),theG->idToDet((*itHit)->geographicalId())->surface() ).matrix();
757  //AlgebraicSymMatrix ger = rhit->globalPositionError().matrix();
758  GlobalPoint gps = theG->idToDet((*itHit)->geographicalId())->surface().toGlobal(m->localPosition());
759  //LogTrace("TestOutliers") << gpr << " " << gps << " " << ger;
760  CLHEP::HepVector delta(3);
761  delta[0]=gpos.x()-gps.x();
762  delta[1]=gpos.y()-gps.y();
763  delta[2]=gpos.z()-gps.z();
764  LogTrace("TestOutliers") << delta << " " << ger ;
765  double mpull = sqrt(delta[0]*delta[0]/ger[0][0]+delta[1]*delta[1]/ger[1][1]+delta[2]*delta[2]/ger[2][2]);
766  LogTrace("TestOutliers") << "hit pull=" << mpull;//ger.similarity(delta);
767  mergedPull->Fill(mpull);
768  }
769  }
770  LogTrace("TestOutliers") << "end merged";
771  } else {//not merged=>good
772  //LogTrace("TestOutliers") << "goodlayer";
773  goodlayer->Fill(layerval);
774  goodcluster->Fill(clustersize);
775  goodhittype->Fill(hittypeval);
776  }
777  }//if (outlier)
778 
779  const SiPixelRecHit* pix = dynamic_cast<const SiPixelRecHit*>(&**itHit);
780  if ((hittypeval!=3 && assSimHits.size()<2)||(hittypeval==3 && assSimHits.size()<3)){
781  if (outlier) {
782  goodhittype_simvecsmall->Fill(hittypeval);
783  goodlayer_simvecsmall->Fill(layerval);
784  goodbadmerged->Fill(1);
785  if (pix) {
786  probXgood->Fill(pix->probabilityX());
787  probYgood->Fill(pix->probabilityY());
788  }
789  LogTrace("TestOutliers") << "out good";
790  }
791  else if (lost){
792  goodbadmergedLost->Fill(1);
793  LogTrace("TestOutliers") << "lost good";
794  }
795  else if (gained){
796  goodbadmergedGained->Fill(1);
797  LogTrace("TestOutliers") << "gained good";
798  }
799  LogTrace("TestOutliers") << "good";
800  } else {
801  if (outlier) {
802  goodhittype_simvecbig->Fill(hittypeval);
803  goodlayer_simvecbig->Fill(layerval);
804  if (ioniOnly&&!shared) {
805  goodbadmerged->Fill(3);
806  if (pix) {
807  probXdelta->Fill(pix->probabilityX());
808  probYdelta->Fill(pix->probabilityY());
809  }
810  } else if(!ioniOnly&&!shared) {
811  goodbadmerged->Fill(4);
812  if (pix) {
813  probXnoshare->Fill(pix->probabilityX());
814  probYnoshare->Fill(pix->probabilityY());
815  }
816  } else {
817  goodbadmerged->Fill(5);
818  if (pix) {
819  probXshared->Fill(pix->probabilityX());
820  probYshared->Fill(pix->probabilityY());
821  }
822  }
823  LogTrace("TestOutliers") << "out merged, ioniOnly=" << ioniOnly << " shared=" << shared;
824  }
825  else if (lost) {
826  if (ioniOnly&&!shared) goodbadmergedLost->Fill(3);
827  else if(!ioniOnly&&!shared) goodbadmergedLost->Fill(4);
828  else goodbadmergedLost->Fill(5);
829  LogTrace("TestOutliers") << "lost merged, ioniOnly=" << ioniOnly << " shared=" << shared;
830  }
831  else if (gained) {
832  if (ioniOnly&&!shared) goodbadmergedGained->Fill(3);
833  else if(!ioniOnly&&!shared) goodbadmergedGained->Fill(4);
834  else goodbadmergedGained->Fill(5);
835  LogTrace("TestOutliers") << "gained merged, ioniOnly=" << ioniOnly << " shared=" << shared;
836  }
837  LogTrace("TestOutliers") << "merged, ioniOnly=" << ioniOnly << " shared=" << shared;
838  }
839  } //if (goodhit)
840  else {//badhit
841  //LogTrace("TestOutliers") << "badhit";
842  if (outlier) {
843  badcluster->Fill(clustersize);
844  badhittype->Fill(hittypeval);
845  badlayer->Fill(layerval);
846  badprocess->Fill(shit.processType());
847  goodbadmerged->Fill(2);
848  const SiPixelRecHit* pix = dynamic_cast<const SiPixelRecHit*>(&**itHit);
849  if (pix) {
850  probXbad->Fill(pix->probabilityX());
851  probYbad->Fill(pix->probabilityY());
852  }
853  LogTrace("TestOutliers") << "out bad";
854  }
855  else if (lost) {
856  goodbadmergedLost->Fill(2);
857  LogTrace("TestOutliers") << "lost bad";
858  }
859  else if (gained) {
860  goodbadmergedGained->Fill(2);
861  LogTrace("TestOutliers") << "gained bad";
862  }
863  LogTrace("TestOutliers") << "bad";
864  }
865  }
866  }
867  }
868  //else if ( trackOut->numberOfValidHits() > trackOld->numberOfValidHits() ) {
869  else if ( 0 ) {
870  LogTrace("TestOutliers") << "outliers for track with #hits=" << trackOut->numberOfValidHits();
871  tracks->Fill(1);
872  LogTrace("TestOutliers") << "Out->pt=" << trackOut->pt() << " Old->pt=" << trackOld->pt()
873  << " tp->pt=" << sqrt(tpr->momentum().perp2())
874  //<< " trackOut->ptError()=" << trackOut->ptError() << " trackOld->ptError()=" << trackOld->ptError()
875  << " Old->validHits=" << trackOld->numberOfValidHits() << " Out->validHits=" << trackOut->numberOfValidHits()
876  /*<< " fracOld=" << fracOld*/ << " fracOut=" << fracOut
877  << " deltaHits=" << trackOld->numberOfValidHits()-trackOut->numberOfValidHits();
878  LogTrace("TestOutliers") << "track with gained hits";
879  gainedhits2->Fill(trackOut->numberOfValidHits()-trackOld->numberOfValidHits());
880  } else {
881  LogTrace("TestOutliers") << "no outliers for track with #hits=" << trackOut->numberOfValidHits();
882  }
883  }
884  LogTrace("TestOutliers") << "end track old #" << j;
885  }
886 
887  for (unsigned int k=0;k<tracksOut->size();++k) {
888  if ( find(outused.begin(),outused.end(),k)==outused.end() ) {
889  edm::RefToBase<reco::Track> trackOut(tracksOut, k);
890  bool outAssoc = recSimCollOut.find(trackOut) != recSimCollOut.end();
891  if (outAssoc) {
892  hitsPerTrackGained->Fill(trackOut->numberOfValidHits());
893  LogTrace("TestOutliers") << "gained track out id=" << k << " #hits==" << trackOut->numberOfValidHits();
894 
895  }
896  }
897  }
898  delete hitAssociator;
899  delete theAssociatorOld;
900  delete theAssociatorOut;
901 }
902 
903 
904 // ------------ method called once each job just before starting event loop ------------
905 void
907 {
909  const bool oldAddDir = TH1::AddDirectoryStatus();
910  TH1::AddDirectory(true);
911  file = new TFile(out.c_str(),"recreate");
912  histoPtOut = new TH1F("histoPtOut","histoPtOut",100,-10,10);
913  histoPtOld = new TH1F("histoPtOld","histoPtOld",100,-10,10);
914  histoQoverpOut = new TH1F("histoQoverpOut","histoQoverpOut",250,-25,25);
915  histoQoverpOld = new TH1F("histoQoverpOld","histoQoverpOld",250,-25,25);
916  histoPhiOut = new TH1F("histoPhiOut","histoPhiOut",250,-25,25);
917  histoPhiOld = new TH1F("histoPhiOld","histoPhiOld",250,-25,25);
918  histoD0Out = new TH1F("histoD0Out","histoD0Out",250,-25,25);
919  histoD0Old = new TH1F("histoD0Old","histoD0Old",250,-25,25);
920  histoDzOut = new TH1F("histoDzOut","histoDzOut",250,-25,25);
921  histoDzOld = new TH1F("histoDzOld","histoDzOld",250,-25,25);
922  histoLambdaOut = new TH1F("histoLambdaOut","histoLambdaOut",250,-25,25);
923  histoLambdaOld = new TH1F("histoLambdaOld","histoLambdaOld",250,-25,25);
924  deltahits = new TH1F("deltahits","deltahits",80,-40,40);
925  deltahitsOK = new TH1F("deltahitsOK","deltahitsOK",20,0,20);
926  deltahitsNO = new TH1F("deltahitsNO","deltahitsNO",20,0,20);
927  okcutsOut = new TH1F("okcutsOut","okcutsOut",2,-0.5,1.5);
928  okcutsOld = new TH1F("okcutsOld","okcutsOld",2,-0.5,1.5);
929  tracks = new TH1F("tracks_","tracks_",2,-0.5,1.5);
930  goodbadhits = new TH1F("goodbadhits","goodbadhits",2,-0.5,1.5);
931  process = new TH1F("process","process",20,-0.5,19.5);
932  goodcluster = new TH1F("goodcluster","goodcluster",40,-0.5,39.5);
933  goodprocess = new TH1F("goodprocess","goodprocess",20,-0.5,19.5);
934  badcluster = new TH1F("badcluster","badcluster",40,-0.5,39.5);
935  badprocess = new TH1F("badprocess","badprocess",20,-0.5,19.5);
936  goodhittype = new TH1F("goodhittype","goodhittype",5,-0.5,4.5);
937  goodlayer = new TH1F("goodlayer","goodlayer",70,-0.5,69.5);
938  goodhittype_clgteq4 = new TH1F("goodhittype_clgteq4","goodhittype_clgteq4",5,-0.5,4.5);
939  goodlayer_clgteq4 = new TH1F("goodlayer_clgteq4","goodlayer_clgteq4",70,-0.5,69.5);
940  goodhittype_cllt4 = new TH1F("goodhittype_cllt4","goodhittype_cllt4",5,-0.5,4.5);
941  goodlayer_cllt4 = new TH1F("goodlayer_cllt4","goodlayer_cllt4",70,-0.5,69.5);
942  badhittype = new TH1F("badhittype","badhittype",5,-0.5,4.5);
943  badlayer = new TH1F("badlayer","badlayer",70,-0.5,69.5);
944  posxy = new TH2F("posxy","posxy",1200,0,120,1200,0,120);
945  poszr = new TH2F("poszr","poszr",3000,0,300,1200,0,120);
946  goodpixgteq4_simvecsize = new TH1F("goodpixgteq4_simvecsize","goodpixgteq4_simvecsize",40,-0.5,39.5);
947  goodpixlt4_simvecsize = new TH1F("goodpixlt4_simvecsize","goodpixlt4_simvecsize",40,-0.5,39.5);
948  goodst1gteq4_simvecsize = new TH1F("goodst1gteq4_simvecsize","goodst1gteq4_simvecsize",40,-0.5,39.5);
949  goodst1lt4_simvecsize = new TH1F("goodst1lt4_simvecsize","goodst1lt4_simvecsize",40,-0.5,39.5);
950  goodst2gteq4_simvecsize = new TH1F("goodst2gteq4_simvecsize","goodst2gteq4_simvecsize",40,-0.5,39.5);
951  goodst2lt4_simvecsize = new TH1F("goodst2lt4_simvecsize","goodst2lt4_simvecsize",40,-0.5,39.5);
952  goodprjgteq4_simvecsize = new TH1F("goodprjgteq4_simvecsize","goodprjgteq4_simvecsize",40,-0.5,39.5);
953  goodprjlt4_simvecsize = new TH1F("goodprjlt4_simvecsize","goodprjlt4_simvecsize",40,-0.5,39.5);
954  goodpix_clustersize = new TH1F("goodpix_clustersize","goodpix_clustersize",40,-0.5,39.5);
955  goodst1_clustersize = new TH1F("goodst1_clustersize","goodst1_clustersize",40,-0.5,39.5);
956  goodst2_clustersize = new TH1F("goodst2_clustersize","goodst2_clustersize",40,-0.5,39.5);
957  goodprj_clustersize = new TH1F("goodprj_clustersize","goodprj_clustersize",40,-0.5,39.5);
958  goodpix_simvecsize = new TH1F("goodpix_simvecsize","goodpix_simvecsize",40,-0.5,39.5);
959  goodst1_simvecsize = new TH1F("goodst1_simvecsize","goodst1_simvecsize",40,-0.5,39.5);
960  goodst2_simvecsize = new TH1F("goodst2_simvecsize","goodst2_simvecsize",40,-0.5,39.5);
961  goodprj_simvecsize = new TH1F("goodprj_simvecsize","goodprj_simvecsize",40,-0.5,39.5);
962  goodhittype_simvecsmall = new TH1F("goodhittype_simvecsmall","goodhittype_simvecsmall",5,-0.5,4.5);
963  goodlayer_simvecsmall = new TH1F("goodlayer_simvecsmall","goodlayer_simvecsmall",70,-0.5,69.5);
964  goodhittype_simvecbig = new TH1F("goodhittype_simvecbig","goodhittype_simvecbig",5,-0.5,4.5);
965  goodlayer_simvecbig = new TH1F("goodlayer_simvecbig","goodlayer_simvecbig",70,-0.5,69.5);
966  goodbadmerged = new TH1F("goodbadmerged","goodbadmerged",5,0.5,5.5);
967  goodbadmergedLost = new TH1F("goodbadmergedLost","goodbadmergedLost",5,0.5,5.5);
968  goodbadmergedGained = new TH1F("goodbadmergedGained","goodbadmergedGained",5,0.5,5.5);
969  energyLoss = new TH1F("energyLoss","energyLoss",1000,0,0.1);
970  energyLossMax = new TH1F("energyLossMax","energyLossMax",1000,0,0.1);
971  energyLossRatio = new TH1F("energyLossRatio","energyLossRatio",100,0,1);
972  nOfTrackIds = new TH1F("nOfTrackIds","nOfTrackIds",10,0,10);
973  mergedPull = new TH1F("mergedPull","mergedPull",100,0,10);
974  mergedlayer = new TH1F("mergedlayer","mergedlayer",70,-0.5,69.5);
975  mergedhittype = new TH1F("mergedhittype","mergedhittype",5,-0.5,4.5);
976  mergedcluster = new TH1F("mergedcluster","mergedcluster",40,-0.5,39.5);
977  deltahitsAssocGained = new TH1F("deltahitsAssocGained","deltahitsAssocGained",80, -40, 40);
978  deltahitsAssocLost = new TH1F("deltahitsAssocLost","deltahitsAssocLost",80, -40, 40);
979  hitsPerTrackLost = new TH1F("hitsPerTrackLost","hitsPerTrackLost",40, -0.5, 39.5);
980  hitsPerTrackAssocLost = new TH1F("hitsPerTrackAssocLost","hitsPerTrackAssocLost",40, -0.5, 39.5);
981  hitsPerTrackGained = new TH1F("hitsPerTrackGained","hitsPerTrackGained",40, -0.5, 39.5);
982  hitsPerTrackAssocGained = new TH1F("hitsPerTrackAssocGained","hitsPerTrackAssocGained",40, -0.5, 39.5);
983  sizeOut = new TH1F("sizeOut","sizeOut",900,-0.5,899.5);
984  sizeOld = new TH1F("sizeOld","sizeOld",900,-0.5,899.5);
985  sizeOutT = new TH1F("sizeOutT","sizeOutT",900,-0.5,899.5);
986  sizeOldT = new TH1F("sizeOldT","sizeOldT",900,-0.5,899.5);
987  countOutA = new TH1F("countOutA","countOutA",2,0,2);
988  countOutT = new TH1F("countOutT","countOutT",2,0,2);
989  countOldT = new TH1F("countOldT","countOldT",2,0,2);
990  gainedhits = new TH1F("gainedhits","gainedhits",2,0,2);
991  gainedhits2 = new TH1F("gainedhits2","gainedhits2",30,-0.5,29.5);
992  probXgood = new TH1F("probXgood","probXgood",110,0,1.1);
993  probXbad = new TH1F("probXbad","probXbad",110,0,1.1);
994  probXdelta = new TH1F("probXdelta","probXdelta",110,0,1.1);
995  probXshared = new TH1F("probXshared","probXshared",110,0,1.1);
996  probXnoshare = new TH1F("probXnoshare","probXnoshare",110,0,1.1);
997  probYgood = new TH1F("probYgood","probYgood",110,0,1.1);
998  probYbad = new TH1F("probYbad","probYbad",110,0,1.1);
999  probYdelta = new TH1F("probYdelta","probYdelta",110,0,1.1);
1000  probYshared = new TH1F("probYshared","probYshared",110,0,1.1);
1001  probYnoshare = new TH1F("probYnoshare","probYnoshare",110,0,1.1);
1002  TH1::AddDirectory(oldAddDir);
1003 }
1004 // ------------ method called once each job just after ending the event loop ------------
1005 void
1007  LogTrace("TestOutliers") << "TestOutliers::endJob";
1008  file->Write();
1009  LogTrace("TestOutliers") << "outfile written";
1010  file->Close();
1011  LogTrace("TestOutliers") << "oufile closed";
1012  LogTrace("TestOutliers") << "exiting TestOutliers::endJob";
1013 }
1014 
1015 //define this as a plug-in
TH1F * histoLambdaOut
Definition: TestOutliers.cc:89
double qoverp() const
q/p
Definition: TrackBase.h:115
dbl * delta
Definition: mlp_gen.cc:36
T getParameter(std::string const &) const
TH1F * hitsPerTrackGained
Definition: TestOutliers.cc:90
double d0Error() const
error on d0
Definition: TrackBase.h:211
TH1F * goodhittype_cllt4
Definition: TestOutliers.cc:93
TH1F * mergedcluster
T perp() const
Definition: PV3DBase.h:66
TH1F * histoDzOld
Definition: TestOutliers.cc:88
TH1F * goodprj_clustersize
TH1F * probXshared
double d0() const
dxy parameter in perigee convention (d0 = - dxy)
Definition: TrackBase.h:123
TH1F * goodpixlt4_simvecsize
Definition: TestOutliers.cc:95
GlobalError transform(const LocalError &le, const Surface &surf) const
TH1F * goodhittype
Definition: TestOutliers.cc:93
TH1F * histoQoverpOut
Definition: TestOutliers.cc:85
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:111
TH1F * hitsPerTrackAssocLost
Definition: TestOutliers.cc:90
const FreeTrajectoryState & theState() const
virtual void analyze(const edm::Event &, const edm::EventSetup &)
TH1F * goodst1_simvecsize
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
TH1F * goodst2lt4_simvecsize
Definition: TestOutliers.cc:97
TH1F * goodbadmergedLost
TH1F * goodst1gteq4_simvecsize
Definition: TestOutliers.cc:96
TH1F * goodprj_simvecsize
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
TH1F * okcutsOut
Definition: TestOutliers.cc:91
Geom::Phi< T > phi() const
Definition: PV3DBase.h:63
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
T y() const
Definition: PV3DBase.h:57
TFile * file
Definition: TestOutliers.cc:83
#define abs(x)
Definition: mlp_lapack.h:159
TH1F * deltahitsNO
Definition: TestOutliers.cc:90
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:139
edm::ParameterSet psetold
TH1F * energyLossRatio
TH1F * histoPtOut
Definition: TestOutliers.cc:84
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
Definition: FindCaloHit.cc:7
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:125
uint16_t size_type
std::vector< SimHitIdpr > associateHitId(const TrackingRecHit &thit)
TH1F * hitsPerTrackAssocGained
Definition: TestOutliers.cc:90
TH1F * process
Definition: TestOutliers.cc:92
TH1F * goodst2_simvecsize
TH1F * probYdelta
TH1F * energyLossMax
TH1F * probYgood
TH1F * badhittype
Definition: TestOutliers.cc:93
Geom::Theta< T > theta() const
Definition: PV3DBase.h:69
TH1F * goodlayer_clgteq4
Definition: TestOutliers.cc:93
TH1F * mergedhittype
int TrackCharge
Definition: TrackCharge.h:4
TH1F * energyLoss
TH1F * deltahits
Definition: TestOutliers.cc:90
TH1F * histoD0Old
Definition: TestOutliers.cc:87
TH1F * probYshared
TH1F * goodprocess
Definition: TestOutliers.cc:92
TH1F * goodhittype_simvecsmall
int iEvent
Definition: GenABIO.cc:243
TH1F * goodpix_clustersize
Definition: TestOutliers.cc:99
TH1F * goodprjgteq4_simvecsize
Definition: TestOutliers.cc:98
T mag() const
Definition: PV3DBase.h:61
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:141
TH1F * badlayer
Definition: TestOutliers.cc:93
TH1F * goodst1_clustersize
TH1F * goodpixgteq4_simvecsize
Definition: TestOutliers.cc:95
TH1F * histoPhiOld
Definition: TestOutliers.cc:86
TH1F * badcluster
Definition: TestOutliers.cc:92
TH1F * probXgood
TH1F * countOutA
TH1F * goodprjlt4_simvecsize
Definition: TestOutliers.cc:98
T sqrt(T t)
Definition: SSEVec.h:28
double pt() const
track transverse momentum
Definition: TrackBase.h:131
T z() const
Definition: PV3DBase.h:58
TH1F * goodpix_simvecsize
TH1F * goodlayer
Definition: TestOutliers.cc:93
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
TH1F * badprocess
Definition: TestOutliers.cc:92
double ptError() const
error on Pt (set to 1000 TeV if charge==0 for safety)
Definition: TrackBase.h:194
TH1F * histoPhiOut
Definition: TestOutliers.cc:86
std::string out
Definition: TestOutliers.cc:82
double phiError() const
error on phi
Definition: TrackBase.h:207
int j
Definition: DBlmapReader.cc:9
double lambda() const
Lambda angle.
Definition: TrackBase.h:119
TH1F * goodlayer_simvecsmall
edm::ParameterSet psetout
TH1F * goodhittype_simvecbig
float probabilityY() const
Definition: SiPixelRecHit.h:82
unsigned short numberOfValidHits() const
number of valid hits found
Definition: TrackBase.h:232
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:63
bool first
Definition: L1TdeRCT.cc:79
TestOutliers(const edm::ParameterSet &)
edm::InputTag trackTagsOut_
Definition: TestOutliers.cc:74
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:355
TH1F * probXnoshare
GlobalVector momentum() const
#define LogTrace(id)
virtual reco::RecoToSimCollection associateRecoToSim(edm::Handle< edm::View< reco::Track > > &tCH, edm::Handle< TrackingParticleCollection > &tPCH, const edm::Event *event=0, const edm::EventSetup *setup=0) const
compare reco to sim the handle of reco::Track and TrackingParticle collections
TH1F * probYnoshare
int k[5][pyjets_maxn]
double qoverpError() const
error on signed transverse curvature
Definition: TrackBase.h:192
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:127
double dzError() const
error on dz
Definition: TrackBase.h:215
tuple out
Definition: dbtoconf.py:99
std::vector< SimTrack >::const_iterator g4t_iterator
virtual void beginRun(edm::Run &run, const edm::EventSetup &)
TH1F * deltahitsOK
Definition: TestOutliers.cc:90
Definition: DetId.h:20
GlobalPoint position() const
TH1F * goodst1lt4_simvecsize
Definition: TestOutliers.cc:96
TH1F * histoPtOld
Definition: TestOutliers.cc:84
TH1F * goodhittype_clgteq4
Definition: TestOutliers.cc:93
edm::RefToBase< TrajectorySeed > seedRef() const
Definition: Track.h:112
#define M_PI
Definition: BFit3D.cc:3
edm::InputTag tpTags_
Definition: TestOutliers.cc:76
TH1F * deltahitsAssocGained
Definition: TestOutliers.cc:90
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
TrackAssociatorBase * theAssociatorOld
Definition: TestOutliers.cc:77
TH1F * goodlayer_cllt4
Definition: TestOutliers.cc:93
TH1F * histoDzOut
Definition: TestOutliers.cc:88
TrackAssociatorBase * theAssociatorOut
Definition: TestOutliers.cc:78
TH1F * probXdelta
TH1F * goodst2_clustersize
unsigned short processType() const
Definition: PSimHit.h:118
virtual void endJob()
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
edm::EventID id() const
Definition: EventBase.h:56
TH1F * histoLambdaOld
Definition: TestOutliers.cc:89
TH1F * countOldT
TH1F * countOutT
const math::XYZTLorentzVectorD & momentum() const
particle info...
Definition: CoreSimTrack.h:36
TH1F * goodst2gteq4_simvecsize
Definition: TestOutliers.cc:97
TH1F * goodcluster
Definition: TestOutliers.cc:92
TH1F * histoD0Out
Definition: TestOutliers.cc:87
edm::ESHandle< TrackerGeometry > theG
Definition: TestOutliers.cc:81
CLHEP::HepSymMatrix AlgebraicSymMatrix
std::vector< PSimHit > associateHit(const TrackingRecHit &thit)
TH1F * okcutsOld
Definition: TestOutliers.cc:91
int charge() const
track electric charge
Definition: TrackBase.h:113
TH1F * mergedPull
TH1F * goodbadmerged
TH1F * deltahitsAssocLost
Definition: TestOutliers.cc:90
TH1F * goodlayer_simvecbig
TH1F * histoQoverpOld
Definition: TestOutliers.cc:85
float probabilityX() const
Definition: SiPixelRecHit.h:79
TH1F * nOfTrackIds
edm::InputTag trackTagsOld_
Definition: TestOutliers.cc:75
TH1F * hitsPerTrackLost
Definition: TestOutliers.cc:90
TH1F * gainedhits
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:241
TrackerHitAssociator * hitAssociator
Definition: TestOutliers.cc:80
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:121
T x() const
Definition: PV3DBase.h:56
value_type const * get() const
Definition: RefToBase.h:212
mathSSE::Vec4< T > v
TH1F * goodbadhits
Definition: TestOutliers.cc:92
Definition: Run.h:32
Global3DVector GlobalVector
Definition: GlobalVector.h:10
double thetaError() const
error on theta
Definition: TrackBase.h:201
TH1F * goodbadmergedGained
Our base class.
Definition: SiPixelRecHit.h:27
TH1F * gainedhits2
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:65