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 //
17 //
18 
19 
20 // system include files
21 #include <memory>
22 #include <vector>
23 
24 // user include files
27 
30 
37 #include <TH1.h>
38 #include <TH2.h>
39 #include <TFile.h>
52 
53 //
54 // class decleration
55 //
56 
57 class TestOutliers : public edm::EDAnalyzer {
58 public:
59  explicit TestOutliers(const edm::ParameterSet&);
60  ~TestOutliers();
61 
62 
63 private:
64  virtual void beginRun(edm::Run & run, const edm::EventSetup&) ;
65  virtual void analyze(const edm::Event&, const edm::EventSetup&) override;
66  virtual void endJob() override ;
67 
68  // ----------member data ---------------------------
69  edm::InputTag trackTagsOut_; //used to select what tracks to read from configuration file
70  edm::InputTag trackTagsOld_; //used to select what tracks to read from configuration file
71  edm::InputTag tpTags_; //used to select what tracks to read from configuration file
74  //RecoTrackSelector selectRecoTracks;
78  TFile * file;
89  TH2F *posxy, *poszr;
110 };
111 //
112 // constants, enums and typedefs
113 //
114 
115 //
116 // static data member definitions
117 //
118 
119 using namespace edm;
120 
121 //
122 // constructors and destructor
123 //
125  :
126  trackTagsOut_(iConfig.getUntrackedParameter<edm::InputTag>("tracksOut")),
127  trackTagsOld_(iConfig.getUntrackedParameter<edm::InputTag>("tracksOld")),
128  tpTags_(iConfig.getUntrackedParameter<edm::InputTag>("tp")),
129  out(iConfig.getParameter<std::string>("out"))
130 {
131  LogTrace("TestOutliers") <<"constructor";
132 // ParameterSet cuts = iConfig.getParameter<ParameterSet>("RecoTracksCuts");
133 // selectRecoTracks = RecoTrackSelector(cuts.getParameter<double>("ptMin"),
134 // cuts.getParameter<double>("minRapidity"),
135 // cuts.getParameter<double>("maxRapidity"),
136 // cuts.getParameter<double>("tip"),
137 // cuts.getParameter<double>("lip"),
138 // cuts.getParameter<int>("minHit"),
139 // cuts.getParameter<double>("maxChi2"));
140 
141  psetold = iConfig.getParameter<ParameterSet>("TrackAssociatorByHitsPSetOld");
142  psetout = iConfig.getParameter<ParameterSet>("TrackAssociatorByHitsPSetOut");
143  LogTrace("TestOutliers") <<"end constructor";
144 }
145 
146 
148 {
149 
150  // do anything here that needs to be done at desctruction time
151  // (e.g. close files, deallocate resources etc.)
152 
153 }
154 
155 
156 //
157 // member functions
158 //
159 
160 // ------------ method called to for each event ------------
161 void
163  //Retrieve tracker topology from geometry
165  iSetup.get<IdealGeometryRecord>().get(tTopo);
166 
167 
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,&iSetup);
189  reco::RecoToSimCollection recSimCollOld=theAssociatorOld->associateRecoToSim(tracksOld, tps, &iEvent,&iSetup);
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 
333  TrackingParticleRef tprOut;
334  TrackingParticleRef tprOld;
335  double fracOut;
336  std::vector<unsigned int> tpids;
337  std::vector<std::pair<TrackingParticleRef, double> > tpOut;
338  std::vector<pair<TrackingParticleRef, double> > tpOld;
339  //contare outliers delle tracce che erano associate e non lo sono piu!!!!
340 
341  if(outAssoc) {//save the ids od the tp associate to the out track
342  tpOut = recSimCollOut[trackOut];
343  if (tpOut.size()!=0) {
344  countOutA->Fill(1);
345  tprOut = tpOut.begin()->first;
346  fracOut = tpOut.begin()->second;
347  for (TrackingParticle::g4t_iterator g4T=tprOut->g4Track_begin(); g4T!=tprOut->g4Track_end(); ++g4T) {
348  tpids.push_back(g4T->trackId());
349  }
350  }
351  }
352 
353  if(oldAssoc){//save the ids od the tp associate to the old track
354  tpOld = recSimCollOld[trackOld];
355  if (tpOld.size()!=0) {
356  tprOld = tpOld.begin()->first;
357  // LogTrace("TestOutliers") <<"old associated and out not! old has #hits=" << trackOld->numberOfValidHits()
358  // << " and fraction=" << tpOld.begin()->second;
359  // if (tpOld.begin()->second>0.5) hitsPerTrackLost->Fill(trackOld->numberOfValidHits());//deve essere un plot diverso tipo LostAssoc
360  if (tpOut.size()==0) {
361  for (TrackingParticle::g4t_iterator g4T=tprOld->g4Track_begin(); g4T!=tprOld->g4Track_end(); ++g4T) {
362  tpids.push_back(g4T->trackId());
363  }
364  }
365  }
366  }
367 
368  if (tprOut.get()!=0 || tprOld.get()!=0) { //at least one of the tracks has to be associated
369 
370  tpr = tprOut.get()!=0 ? tprOut : tprOld;
371 
372  const SimTrack * assocTrack = &(*tpr->g4Track_begin());
373 
374  //if ( trackOut->numberOfValidHits() < trackOld->numberOfValidHits() ) {
375  if ( trackOut->numberOfValidHits() != trackOld->numberOfValidHits() ||
376  !trackOut->recHitsBegin()->get()->sharesInput(trackOld->recHitsBegin()->get(),TrackingRecHit::some) ||
377  !(trackOut->recHitsEnd()-1)->get()->sharesInput((trackOld->recHitsEnd()-1)->get(),TrackingRecHit::some) )
378  { //there are outliers if the number of valid hits is != or if the first and last hit does not match
379  LogTrace("TestOutliers") << "outliers for track with #hits=" << trackOut->numberOfValidHits();
380  tracks->Fill(1);
381  LogTrace("TestOutliers") << "Out->pt=" << trackOut->pt() << " Old->pt=" << trackOld->pt()
382  << " tp->pt=" << sqrt(tpr->momentum().perp2())
383  //<< " trackOut->ptError()=" << trackOut->ptError() << " trackOld->ptError()=" << trackOld->ptError()
384  << " Old->validHits=" << trackOld->numberOfValidHits() << " Out->validHits=" << trackOut->numberOfValidHits()
385  /*<< " fracOld=" << fracOld*/ << " fracOut=" << fracOut
386  << " deltaHits=" << trackOld->numberOfValidHits()-trackOut->numberOfValidHits();
387 
388  //compute all the track parameters
389  double PtPullOut = (trackOut->pt()-sqrt(tpr->momentum().perp2()))/trackOut->ptError();
390  double PtPullOld = (trackOld->pt()-sqrt(tpr->momentum().perp2()))/trackOld->ptError();
391  histoPtOut->Fill( PtPullOut );
392  histoPtOld->Fill( PtPullOld );
393 
394  //LogTrace("TestOutliers") << "MagneticField";
396  iSetup.get<IdealMagneticFieldRecord>().get(theMF);
398  ftsAtProduction(GlobalPoint(tpr->vertex().x(),tpr->vertex().y(),tpr->vertex().z()),
399  GlobalVector(assocTrack->momentum().x(),assocTrack->momentum().y(),assocTrack->momentum().z()),
400  TrackCharge(trackOld->charge()),
401  theMF.product());
402  TSCPBuilderNoMaterial tscpBuilder;
403  TrajectoryStateClosestToPoint tsAtClosestApproach
404  = tscpBuilder(ftsAtProduction,GlobalPoint(0,0,0));//as in TrackProducerAlgorithm
405  GlobalPoint v = tsAtClosestApproach.theState().position();
406  GlobalVector p = tsAtClosestApproach.theState().momentum();
407 
408  //LogTrace("TestOutliers") << "qoverpSim";
409  double qoverpSim = tsAtClosestApproach.charge()/p.mag();
410  double lambdaSim = M_PI/2-p.theta();
411  double phiSim = p.phi();
412  double dxySim = (-v.x()*sin(p.phi())+v.y()*cos(p.phi()));
413  double dszSim = v.z()*p.perp()/p.mag() - (v.x()*p.x()+v.y()*p.y())/p.perp() * p.z()/p.mag();
414  double d0Sim = -dxySim;
415  double dzSim = dszSim*p.mag()/p.perp();
416 
417  //LogTrace("TestOutliers") << "qoverpPullOut";
418  double qoverpPullOut=(trackOut->qoverp()-qoverpSim)/trackOut->qoverpError();
419  double qoverpPullOld=(trackOld->qoverp()-qoverpSim)/trackOld->qoverpError();
420  double lambdaPullOut=(trackOut->lambda()-lambdaSim)/trackOut->thetaError();
421  double lambdaPullOld=(trackOld->lambda()-lambdaSim)/trackOld->thetaError();
422  double phi0PullOut=(trackOut->phi()-phiSim)/trackOut->phiError();
423  double phi0PullOld=(trackOld->phi()-phiSim)/trackOld->phiError();
424  double d0PullOut=(trackOut->d0()-d0Sim)/trackOut->d0Error();
425  double d0PullOld=(trackOld->d0()-d0Sim)/trackOld->d0Error();
426  double dzPullOut=(trackOut->dz()-dzSim)/trackOut->dzError();
427  double dzPullOld=(trackOld->dz()-dzSim)/trackOld->dzError();
428 
429  //LogTrace("TestOutliers") << "histoQoverpOut";
430  histoQoverpOut->Fill(qoverpPullOut);
431  histoQoverpOld->Fill(qoverpPullOld);
432  histoPhiOut->Fill(phi0PullOut);
433  histoPhiOld->Fill(phi0PullOld);
434  histoD0Out->Fill(d0PullOut);
435  histoD0Old->Fill(d0PullOld);
436  histoDzOut->Fill(dzPullOut);
437  histoDzOld->Fill(dzPullOld);
438  histoLambdaOut->Fill(lambdaPullOut);
439  histoLambdaOld->Fill(lambdaPullOld);
440 
441  //delta number of valid hits
442  LogTrace("TestOutliers") << "deltahits=" << trackOld->numberOfValidHits()-trackOut->numberOfValidHits();
443  deltahits->Fill(trackOld->numberOfValidHits()-trackOut->numberOfValidHits());
444 
445  if(tprOut.get()!=0 && tprOld.get()==0) { //out associated and old not: gained track
446  if (tpOld.size()!=0 && tpOld.begin()->second<=0.5) {
447  deltahitsAssocGained->Fill(trackOld->numberOfValidHits()-trackOut->numberOfValidHits());
448  hitsPerTrackAssocGained->Fill(trackOut->numberOfValidHits());
449  LogTrace("TestOutliers") << "a) gained (assoc) track out #hits==" << trackOut->numberOfValidHits() << " old #hits=" << trackOld->numberOfValidHits();
450  } else {
451  deltahitsAssocGained->Fill(trackOld->numberOfValidHits()-trackOut->numberOfValidHits());
452  hitsPerTrackAssocGained->Fill(trackOut->numberOfValidHits());
453  LogTrace("TestOutliers") << "b) gained (assoc) track out #hits==" << trackOut->numberOfValidHits() << " old #hits=" << trackOld->numberOfValidHits();
454  }
455  } else if(tprOut.get()==0 && tprOld.get()!=0) { //old associated and out not: lost track
456  LogTrace("TestOutliers") <<"old associated and out not! old has #hits=" << trackOld->numberOfValidHits()
457  << " and fraction=" << tpOld.begin()->second;
458  if (tpOld.begin()->second>0.5) {
459  hitsPerTrackAssocLost->Fill(trackOld->numberOfValidHits());
460  deltahitsAssocLost->Fill(trackOld->numberOfValidHits()-trackOut->numberOfValidHits());
461  }
462  }
463 
464  if ( fabs(PtPullOut) < fabs(PtPullOld) )
465  deltahitsOK->Fill(trackOld->numberOfValidHits()-trackOut->numberOfValidHits());
466  else
467  deltahitsNO->Fill(trackOld->numberOfValidHits()-trackOut->numberOfValidHits());
468 
469  //LogTrace("TestOutliers") << "RecoTrackSelector";
470  //if (selectRecoTracks(*trackOut,beamSpot.product())) okcutsOut->Fill(1); else okcutsOut->Fill(0);
471  //if (selectRecoTracks(*trackOld,beamSpot.product())) okcutsOld->Fill(1); else okcutsOld->Fill(0);
472 
473  LogTrace("TestOutliers") << "track old";
474  for (trackingRecHit_iterator itOld = trackOld->recHitsBegin(); itOld!=trackOld->recHitsEnd() ; itOld++){
475  LogTrace("TestOutliers") << (*itOld)->isValid() << " " << (*itOld)->geographicalId().rawId();
476  }
477  LogTrace("TestOutliers") << "track out";
478  for (trackingRecHit_iterator itOut = trackOut->recHitsBegin(); itOut!=trackOut->recHitsEnd() ; itOut++){
479  LogTrace("TestOutliers") << (*itOut)->isValid() << " " << (*itOut)->geographicalId().rawId();
480  }
481  //LogTrace("TestOutliers") << "itOut";
482 
483 
484  vector<pair<int, trackingRecHit_iterator> > gainedlostoutliers;
485  //look for gained hits
486  for (trackingRecHit_iterator itOut = trackOut->recHitsBegin(); itOut!=trackOut->recHitsEnd(); itOut++){
487  bool gained = true;
488  if ((*itOut)->isValid()) {
489  for (trackingRecHit_iterator itOld = trackOld->recHitsBegin(); itOld!=trackOld->recHitsEnd() ; itOld++){
490  if ( (*itOld)->geographicalId().rawId()==(*itOut)->geographicalId().rawId() ) gained = false;
491  }
492  if (gained) {
493  gainedlostoutliers.push_back(pair<int, trackingRecHit_iterator>(1,itOut));
494  LogTrace("TestOutliers") << "broken trajectory during old fit... gained hit " << (*itOut)->geographicalId().rawId();
495  gainedhits->Fill(1);
496  }
497  }
498  }
499 
500  //look for outliers and lost hits
501  for (trackingRecHit_iterator itOld = trackOld->recHitsBegin(); itOld!=trackOld->recHitsEnd() ; itOld++){
502 
503  bool outlier = false;
504  bool lost = true;
505 
506  for (trackingRecHit_iterator itOut = trackOut->recHitsBegin(); itOut!=trackOut->recHitsEnd(); itOut++){
507  if ( (*itOld)->geographicalId().rawId()==(*itOut)->geographicalId().rawId() ) {
508  lost=false;
509  if ( (*itOld)->isValid() && !(*itOut)->isValid() && (*itOld)->geographicalId().rawId()==(*itOut)->geographicalId().rawId() ) {
510  LogTrace("TestOutliers") << (*itOld)->isValid() << " " << (*itOut)->isValid() << " "
511  << (*itOld)->geographicalId().rawId() << " " << (*itOut)->geographicalId().rawId();
512  outlier=true;
513  }
514  }
515  }
516  if (lost) gainedlostoutliers.push_back(pair<int, trackingRecHit_iterator>(2,itOld));
517  if (lost) LogTrace("TestOutliers") << "lost";
518  else if (outlier) gainedlostoutliers.push_back(pair<int, trackingRecHit_iterator>(3,itOld));
519  }
520 
521  for (std::vector<pair<int, trackingRecHit_iterator> >::iterator it = gainedlostoutliers.begin(); it!=gainedlostoutliers.end();++it) {
522  LogTrace("TestOutliers") << "type of processed hit:" <<it->first;
523  trackingRecHit_iterator itHit = it->second;
524  bool gained = false;
525  bool lost = false;
526  bool outlier = false;
527  if (it->first==1) gained = true;
528  else if (it->first==2) lost = true;
529  else if (it->first==3) outlier = true;
530 
531  if (outlier||lost||gained) {
532  //if (1) {
533 
534  if (lost && (*itHit)->isValid()==false) {
535  goodbadmergedLost->Fill(0);
536  LogTrace("TestOutliers") << "lost invalid";
537  continue;
538  }
539  else if (gained && (*itHit)->isValid()==false) {
540  goodbadmergedGained->Fill(0);
541  LogTrace("TestOutliers") << "gained invalid";
542  continue;
543  }
544 
545  //LogTrace("TestOutliers") << "vector<SimHitIdpr>";
546  //look if the hit comes from a correct sim track
547  std::vector<SimHitIdpr> simTrackIds = hitAssociator->associateHitId(**itHit);
548  bool goodhit = false;
549  for(size_t j=0; j<simTrackIds.size(); j++){
550  for (size_t jj=0; jj<tpids.size(); jj++){
551  if (simTrackIds[j].first == tpids[jj]) goodhit = true;
552  break;
553  }
554  }
555 
556  //find what kind of hit is it
557  int clustersize = 0;
558  int hittypeval = 0;
559  int layerval = 0 ;
560  if (dynamic_cast<const SiPixelRecHit*>(&**itHit)){
561  LogTrace("TestOutliers") << "SiPixelRecHit";
562  clustersize = ((const SiPixelRecHit*)(&**itHit))->cluster()->size() ;
563  hittypeval = 1;
564  }
565  else if (dynamic_cast<const SiStripRecHit2D*>(&**itHit)){
566  LogTrace("TestOutliers") << "SiStripRecHit2D";
567  clustersize = ((const SiStripRecHit2D*)(&**itHit))->cluster()->amplitudes().size() ;
568  hittypeval = 2;
569  }
570  else if (dynamic_cast<const SiStripMatchedRecHit2D*>(&**itHit)){
571  LogTrace("TestOutliers") << "SiStripMatchedRecHit2D";
572  int clsize1 = ((const SiStripMatchedRecHit2D*)(&**itHit))->monoCluster().amplitudes().size();
573  int clsize2 = ((const SiStripMatchedRecHit2D*)(&**itHit))->stereoCluster().amplitudes().size();
574  if (clsize1>clsize2) clustersize = clsize1;
575  else clustersize = clsize2;
576  hittypeval = 3;
577  }
578  else if (dynamic_cast<const ProjectedSiStripRecHit2D*>(&**itHit)){
579  LogTrace("TestOutliers") << "ProjectedSiStripRecHit2D";
580  clustersize = ((const ProjectedSiStripRecHit2D*)(&**itHit))->originalHit().cluster()->amplitudes().size();
581  hittypeval = 4;
582  }
583 
584  //find the layer of the hit
585  int subdetId = (*itHit)->geographicalId().subdetId();
586  DetId id = (*itHit)->geographicalId();
587  int layerId = tTopo->layer(id);
588  layerval = subdetId*10+layerId;
589 
590  //LogTrace("TestOutliers") << "gpos";
591  GlobalPoint gpos = theG->idToDet((*itHit)->geographicalId())->surface().toGlobal((*itHit)->localPosition());
592 
593 
594  //get the vector of sim hit associated and choose the one with the largest energy loss
595  //double delta = 99999;
596  //LocalPoint rhitLPv = (*itHit)->localPosition();
597  //vector<PSimHit> assSimHits = hitAssociator->associateHit(**itHit);
598  //if (assSimHits.size()==0) continue;
599  //PSimHit shit;
600  //for(std::vector<PSimHit>::const_iterator m=assSimHits.begin(); m<assSimHits.end(); m++){
601  //if ((m->localPosition()-rhitLPv).mag()<delta) {
602  // shit=*m;
603  // delta = (m->localPosition()-rhitLPv).mag();
604  // }
605  //}
606  //LogTrace("TestOutliers") << "energyLoss_";
607  double energyLoss_ = 0.;
608  unsigned int monoId = 0;
609  std::vector<double> energyLossM;
610  std::vector<double> energyLossS;
611  std::vector<PSimHit> assSimHits = hitAssociator->associateHit(**itHit);
612  if (assSimHits.size()==0) continue;
613  PSimHit shit;
614  std::vector<unsigned int> trackIds;
615  energyLossS.clear();
616  energyLossM.clear();
617  //LogTrace("TestOutliers") << "energyLossM";
618  for(std::vector<PSimHit>::const_iterator m=assSimHits.begin(); m<assSimHits.end(); m++){
619  if (outlier) energyLoss->Fill(m->energyLoss());
620  unsigned int tId = m->trackId();
621  if (find(trackIds.begin(),trackIds.end(),tId)==trackIds.end()) trackIds.push_back(tId);
622  LogTrace("TestOutliers") << "id=" << tId;
623  if (m->energyLoss()>energyLoss_) {
624  shit=*m;
625  energyLoss_ = m->energyLoss();
626  }
627  if (hittypeval==3) {
628  if (monoId==0) monoId = m->detUnitId();
629  if (monoId == m->detUnitId()){
630  energyLossM.push_back(m->energyLoss());
631  }
632  else {
633  energyLossS.push_back(m->energyLoss());
634  }
635  //std::cout << "detUnitId=" << m->detUnitId() << " trackId=" << m->trackId() << " energyLoss=" << m->energyLoss() << std::endl;
636  } else {
637  energyLossM.push_back(m->energyLoss());
638  }
639  }
640  unsigned int nIds = trackIds.size();
641 
642  if (outlier) {
643  goodbadhits->Fill(goodhit);
644  posxy->Fill(fabs(gpos.x()),fabs(gpos.y()));
645  poszr->Fill(fabs(gpos.z()),sqrt(gpos.x()*gpos.x()+gpos.y()*gpos.y()));
646  process->Fill(shit.processType());
647  energyLossMax->Fill(energyLoss_);
648  }
649 
650  //look if the hit is shared and if is produced only by ionization processes
651  bool shared = true;
652  bool ioniOnly = true;
653  unsigned int idc = 0;
654  for (size_t jj=0; jj<tpids.size(); jj++){
655  idc += std::count(trackIds.begin(),trackIds.end(),tpids[jj]);
656  }
657  if (idc==trackIds.size()) {
658  shared = false;
659  }
660  for(std::vector<PSimHit>::const_iterator m=assSimHits.begin()+1; m<assSimHits.end(); m++){
661  if ((m->processType()!=7&&m->processType()!=8&&m->processType()!=9)&&abs(m->particleType())!=11){
662  ioniOnly = false;
663  break;
664  }
665  }
666  if (ioniOnly&&!shared){
667  LogTrace("TestOutliers") << "delta";
668  }
669 
670  if (goodhit) {
671  if (outlier) {
672  goodprocess->Fill(shit.processType());
673  if (clustersize>=4) {
674  goodhittype_clgteq4->Fill(hittypeval);
675  goodlayer_clgteq4->Fill(layerval);
676  } else {
677  goodhittype_cllt4->Fill(hittypeval);
678  goodlayer_cllt4->Fill(layerval);
679  }
680  //LogTrace("TestOutliers") << "hittypeval && clustersize";
681  if (hittypeval==1 && clustersize>=4) goodpixgteq4_simvecsize->Fill(assSimHits.size());
682  if (hittypeval==1 && clustersize<4 ) goodpixlt4_simvecsize->Fill(assSimHits.size());
683  if (hittypeval==2 && clustersize>=4) goodst1gteq4_simvecsize->Fill(assSimHits.size());
684  if (hittypeval==2 && clustersize<4 ) goodst1lt4_simvecsize->Fill(assSimHits.size());
685  if (hittypeval==3 && clustersize>=4) goodst2gteq4_simvecsize->Fill(assSimHits.size());
686  if (hittypeval==3 && clustersize<4 ) goodst2lt4_simvecsize->Fill(assSimHits.size());
687  if (hittypeval==4 && clustersize>=4) goodprjgteq4_simvecsize->Fill(assSimHits.size());
688  if (hittypeval==4 && clustersize<4 ) goodprjlt4_simvecsize->Fill(assSimHits.size());
689 
690  //LogTrace("TestOutliers") << "hittypeval";
691  if (hittypeval==1) goodpix_clustersize->Fill(clustersize);
692  if (hittypeval==2) goodst1_clustersize->Fill(clustersize);
693  if (hittypeval==3) goodst2_clustersize->Fill(clustersize);
694  if (hittypeval==4) goodprj_clustersize->Fill(clustersize);
695  if (hittypeval==1) goodpix_simvecsize->Fill(assSimHits.size());
696  if (hittypeval==2) goodst1_simvecsize->Fill(assSimHits.size());
697  if (hittypeval==3) goodst2_simvecsize->Fill(assSimHits.size());
698  if (hittypeval==4) goodprj_simvecsize->Fill(assSimHits.size());
699 
700  //LogTrace("TestOutliers") << "nOfTrackIds";
701  nOfTrackIds->Fill(nIds);
702  if (hittypeval!=3) {
703  if (energyLossM.size()>1) {
704  sort(energyLossM.begin(),energyLossM.end(),greater<double>());
705  energyLossRatio->Fill(energyLossM[1]/energyLossM[0]);
706  }
707  } else {
708  //LogTrace("TestOutliers") << "hittypeval==3";
709  if (energyLossM.size()>1&&energyLossS.size()<=1) {
710  sort(energyLossM.begin(),energyLossM.end(),greater<double>());
711  energyLossRatio->Fill(energyLossM[1]/energyLossM[0]);
712  }
713  else if (energyLossS.size()>1&&energyLossM.size()<=1) {
714  sort(energyLossS.begin(),energyLossS.end(),greater<double>());
715  energyLossRatio->Fill(energyLossS[1]/energyLossS[0]);
716  }
717  else if (energyLossS.size()>1&&energyLossM.size()>1) {
718  sort(energyLossM.begin(),energyLossM.end(),greater<double>());
719  sort(energyLossS.begin(),energyLossS.end(),greater<double>());
720  energyLossM[1]/energyLossM[0] > energyLossS[1]/energyLossS[0]
721  ? energyLossRatio->Fill(energyLossM[1]/energyLossM[0])
722  : energyLossRatio->Fill(energyLossS[1]/energyLossS[0]);
723  }
724  }
725 
726  LogTrace("TestOutliers") << "before merged";
727  const SiStripMatchedRecHit2D* tmp = dynamic_cast<const SiStripMatchedRecHit2D*>(&**itHit);
728  LogTrace("TestOutliers") << "tmp=" << tmp;
729  LogTrace("TestOutliers") << "assSimHits.size()=" << assSimHits.size();
730  if ( (assSimHits.size()>1 && tmp==0) ||
731  (assSimHits.size()>2 && tmp!=0) ) {
732  //std::cout << "MERGED HIT" << std::endl;
733  //LogTrace("TestOutliers") << "merged";
734  mergedlayer->Fill(layerval);
735  mergedcluster->Fill(clustersize);
736  mergedhittype->Fill(hittypeval);
737 
738  for(std::vector<PSimHit>::const_iterator m=assSimHits.begin(); m<assSimHits.end(); m++){
739  unsigned int tId = m->trackId();
740  LogTrace("TestOutliers") << "component with id=" << tId << " eLoss=" << m->energyLoss()
741  << " proc=" << m->processType() << " part=" << m->particleType();
742  if (find(tpids.begin(),tpids.end(),tId)==tpids.end()) continue;
743  if (m->processType()==2) {
744  //GlobalPoint gpos = theG->idToDet((*itHit)->geographicalId())->surface().toGlobal((*itHit)->localPosition());
745  //GlobalPoint gpr = rhit->globalPosition();
746  AlgebraicSymMatrix33 ger =
747  ErrorFrameTransformer().transform((*itHit)->localPositionError(),theG->idToDet((*itHit)->geographicalId())->surface() ).matrix();
748  //AlgebraicSymMatrix ger = rhit->globalPositionError().matrix();
749  GlobalPoint gps = theG->idToDet((*itHit)->geographicalId())->surface().toGlobal(m->localPosition());
750  //LogTrace("TestOutliers") << gpr << " " << gps << " " << ger;
751  ROOT::Math::SVector<double,3> delta;
752  delta[0]=gpos.x()-gps.x();
753  delta[1]=gpos.y()-gps.y();
754  delta[2]=gpos.z()-gps.z();
755  LogTrace("TestOutliers") << delta << " " << ger ;
756  double mpull = sqrt(delta[0]*delta[0]/ger[0][0]+delta[1]*delta[1]/ger[1][1]+delta[2]*delta[2]/ger[2][2]);
757  LogTrace("TestOutliers") << "hit pull=" << mpull;//ger.similarity(delta);
758  mergedPull->Fill(mpull);
759  }
760  }
761  LogTrace("TestOutliers") << "end merged";
762  } else {//not merged=>good
763  //LogTrace("TestOutliers") << "goodlayer";
764  goodlayer->Fill(layerval);
765  goodcluster->Fill(clustersize);
766  goodhittype->Fill(hittypeval);
767  }
768  }//if (outlier)
769 
770  const SiPixelRecHit* pix = dynamic_cast<const SiPixelRecHit*>(&**itHit);
771  if ((hittypeval!=3 && assSimHits.size()<2)||(hittypeval==3 && assSimHits.size()<3)){
772  if (outlier) {
773  goodhittype_simvecsmall->Fill(hittypeval);
774  goodlayer_simvecsmall->Fill(layerval);
775  goodbadmerged->Fill(1);
776  if (pix) {
777  probXgood->Fill(pix->probabilityX());
778  probYgood->Fill(pix->probabilityY());
779  }
780  LogTrace("TestOutliers") << "out good";
781  }
782  else if (lost){
783  goodbadmergedLost->Fill(1);
784  LogTrace("TestOutliers") << "lost good";
785  }
786  else if (gained){
787  goodbadmergedGained->Fill(1);
788  LogTrace("TestOutliers") << "gained good";
789  }
790  LogTrace("TestOutliers") << "good";
791  } else {
792  if (outlier) {
793  goodhittype_simvecbig->Fill(hittypeval);
794  goodlayer_simvecbig->Fill(layerval);
795  if (ioniOnly&&!shared) {
796  goodbadmerged->Fill(3);
797  if (pix) {
798  probXdelta->Fill(pix->probabilityX());
799  probYdelta->Fill(pix->probabilityY());
800  }
801  } else if(!ioniOnly&&!shared) {
802  goodbadmerged->Fill(4);
803  if (pix) {
804  probXnoshare->Fill(pix->probabilityX());
805  probYnoshare->Fill(pix->probabilityY());
806  }
807  } else {
808  goodbadmerged->Fill(5);
809  if (pix) {
810  probXshared->Fill(pix->probabilityX());
811  probYshared->Fill(pix->probabilityY());
812  }
813  }
814  LogTrace("TestOutliers") << "out merged, ioniOnly=" << ioniOnly << " shared=" << shared;
815  }
816  else if (lost) {
817  if (ioniOnly&&!shared) goodbadmergedLost->Fill(3);
818  else if(!ioniOnly&&!shared) goodbadmergedLost->Fill(4);
819  else goodbadmergedLost->Fill(5);
820  LogTrace("TestOutliers") << "lost merged, ioniOnly=" << ioniOnly << " shared=" << shared;
821  }
822  else if (gained) {
823  if (ioniOnly&&!shared) goodbadmergedGained->Fill(3);
824  else if(!ioniOnly&&!shared) goodbadmergedGained->Fill(4);
825  else goodbadmergedGained->Fill(5);
826  LogTrace("TestOutliers") << "gained merged, ioniOnly=" << ioniOnly << " shared=" << shared;
827  }
828  LogTrace("TestOutliers") << "merged, ioniOnly=" << ioniOnly << " shared=" << shared;
829  }
830  } //if (goodhit)
831  else {//badhit
832  //LogTrace("TestOutliers") << "badhit";
833  if (outlier) {
834  badcluster->Fill(clustersize);
835  badhittype->Fill(hittypeval);
836  badlayer->Fill(layerval);
837  badprocess->Fill(shit.processType());
838  goodbadmerged->Fill(2);
839  const SiPixelRecHit* pix = dynamic_cast<const SiPixelRecHit*>(&**itHit);
840  if (pix) {
841  probXbad->Fill(pix->probabilityX());
842  probYbad->Fill(pix->probabilityY());
843  }
844  LogTrace("TestOutliers") << "out bad";
845  }
846  else if (lost) {
847  goodbadmergedLost->Fill(2);
848  LogTrace("TestOutliers") << "lost bad";
849  }
850  else if (gained) {
851  goodbadmergedGained->Fill(2);
852  LogTrace("TestOutliers") << "gained bad";
853  }
854  LogTrace("TestOutliers") << "bad";
855  }
856  }
857  }
858  }
859  //else if ( trackOut->numberOfValidHits() > trackOld->numberOfValidHits() ) {
860  else if ( 0 ) {
861  LogTrace("TestOutliers") << "outliers for track with #hits=" << trackOut->numberOfValidHits();
862  tracks->Fill(1);
863  LogTrace("TestOutliers") << "Out->pt=" << trackOut->pt() << " Old->pt=" << trackOld->pt()
864  << " tp->pt=" << sqrt(tpr->momentum().perp2())
865  //<< " trackOut->ptError()=" << trackOut->ptError() << " trackOld->ptError()=" << trackOld->ptError()
866  << " Old->validHits=" << trackOld->numberOfValidHits() << " Out->validHits=" << trackOut->numberOfValidHits()
867  /*<< " fracOld=" << fracOld*/ << " fracOut=" << fracOut
868  << " deltaHits=" << trackOld->numberOfValidHits()-trackOut->numberOfValidHits();
869  LogTrace("TestOutliers") << "track with gained hits";
870  gainedhits2->Fill(trackOut->numberOfValidHits()-trackOld->numberOfValidHits());
871  } else {
872  LogTrace("TestOutliers") << "no outliers for track with #hits=" << trackOut->numberOfValidHits();
873  }
874  }
875  LogTrace("TestOutliers") << "end track old #" << j;
876  }
877 
878  for (unsigned int k=0;k<tracksOut->size();++k) {
879  if ( find(outused.begin(),outused.end(),k)==outused.end() ) {
880  edm::RefToBase<reco::Track> trackOut(tracksOut, k);
881  bool outAssoc = recSimCollOut.find(trackOut) != recSimCollOut.end();
882  if (outAssoc) {
883  hitsPerTrackGained->Fill(trackOut->numberOfValidHits());
884  LogTrace("TestOutliers") << "gained track out id=" << k << " #hits==" << trackOut->numberOfValidHits();
885 
886  }
887  }
888  }
889  delete hitAssociator;
890  delete theAssociatorOld;
891  delete theAssociatorOut;
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:84
double qoverp() const
q/p
Definition: TrackBase.h:113
dbl * delta
Definition: mlp_gen.cc:36
T getParameter(std::string const &) const
TH1F * hitsPerTrackGained
Definition: TestOutliers.cc:85
static GlobalError transform(const LocalError &le, const Surface &surf)
double d0Error() const
error on d0
Definition: TrackBase.h:209
TH1F * goodhittype_cllt4
Definition: TestOutliers.cc:88
TH1F * mergedcluster
T perp() const
Definition: PV3DBase.h:72
TH1F * histoDzOld
Definition: TestOutliers.cc:83
TH1F * goodprj_clustersize
Definition: TestOutliers.cc:97
TH1F * probXshared
double d0() const
dxy parameter in perigee convention (d0 = - dxy)
Definition: TrackBase.h:121
TH1F * goodpixlt4_simvecsize
Definition: TestOutliers.cc:90
TH1F * goodhittype
Definition: TestOutliers.cc:88
TH1F * histoQoverpOut
Definition: TestOutliers.cc:80
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:109
TH1F * hitsPerTrackAssocLost
Definition: TestOutliers.cc:85
const FreeTrajectoryState & theState() const
TH1F * goodst1_simvecsize
Definition: TestOutliers.cc:99
#define DEFINE_FWK_MODULE(type)
Definition: MakerMacros.h:17
TH1F * goodst2lt4_simvecsize
Definition: TestOutliers.cc:92
TH1F * goodbadmergedLost
TH1F * goodst1gteq4_simvecsize
Definition: TestOutliers.cc:91
TH1F * goodprj_simvecsize
Sin< T >::type sin(const T &t)
Definition: Sin.h:22
TH1F * okcutsOut
Definition: TestOutliers.cc:86
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:10
T y() const
Definition: PV3DBase.h:63
TFile * file
Definition: TestOutliers.cc:78
TH1F * deltahitsNO
Definition: TestOutliers.cc:85
double phi() const
azimuthal angle of momentum vector
Definition: TrackBase.h:137
edm::ParameterSet psetold
TH1F * energyLossRatio
TH1F * histoPtOut
Definition: TestOutliers.cc:79
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:123
uint16_t size_type
TH1F * hitsPerTrackAssocGained
Definition: TestOutliers.cc:85
TH1F * process
Definition: TestOutliers.cc:87
TH1F * goodst2_simvecsize
TH1F * probYdelta
TH1F * energyLossMax
TH1F * probYgood
TH1F * badhittype
Definition: TestOutliers.cc:88
Geom::Theta< T > theta() const
Definition: PV3DBase.h:75
TH1F * goodlayer_clgteq4
Definition: TestOutliers.cc:88
TH1F * mergedhittype
int TrackCharge
Definition: TrackCharge.h:4
TH1F * energyLoss
TH1F * deltahits
Definition: TestOutliers.cc:85
TH1F * histoD0Old
Definition: TestOutliers.cc:82
TH1F * probYshared
TH1F * goodprocess
Definition: TestOutliers.cc:87
TH1F * goodhittype_simvecsmall
int iEvent
Definition: GenABIO.cc:230
TH1F * goodpix_clustersize
Definition: TestOutliers.cc:94
TH1F * goodprjgteq4_simvecsize
Definition: TestOutliers.cc:93
T mag() const
Definition: PV3DBase.h:67
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:139
TH1F * badlayer
Definition: TestOutliers.cc:88
TH1F * goodst1_clustersize
Definition: TestOutliers.cc:95
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
TH1F * goodpixgteq4_simvecsize
Definition: TestOutliers.cc:90
TH1F * histoPhiOld
Definition: TestOutliers.cc:81
TH1F * badcluster
Definition: TestOutliers.cc:87
TH1F * probXgood
TH1F * countOutA
TH1F * goodprjlt4_simvecsize
Definition: TestOutliers.cc:93
T sqrt(T t)
Definition: SSEVec.h:48
double pt() const
track transverse momentum
Definition: TrackBase.h:129
T z() const
Definition: PV3DBase.h:64
TH1F * goodpix_simvecsize
Definition: TestOutliers.cc:98
TH1F * goodlayer
Definition: TestOutliers.cc:88
Cos< T >::type cos(const T &t)
Definition: Cos.h:22
TH1F * badprocess
Definition: TestOutliers.cc:87
double ptError() const
error on Pt (set to 1000 TeV if charge==0 for safety)
Definition: TrackBase.h:192
TH1F * histoPhiOut
Definition: TestOutliers.cc:81
std::string out
Definition: TestOutliers.cc:77
double phiError() const
error on phi
Definition: TrackBase.h:205
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
int j
Definition: DBlmapReader.cc:9
double lambda() const
Lambda angle.
Definition: TrackBase.h:117
TH1F * goodlayer_simvecsmall
edm::ParameterSet psetout
TH1F * goodhittype_simvecbig
unsigned short numberOfValidHits() const
number of valid hits found
Definition: TrackBase.h:230
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:63
bool first
Definition: L1TdeRCT.cc:75
TestOutliers(const edm::ParameterSet &)
edm::InputTag trackTagsOut_
Definition: TestOutliers.cc:69
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:390
TH1F * probXnoshare
GlobalVector momentum() const
#define LogTrace(id)
#define M_PI
virtual reco::RecoToSimCollection associateRecoToSim(edm::Handle< edm::View< reco::Track > > &tCH, edm::Handle< TrackingParticleCollection > &tPCH, const edm::Event *event, const edm::EventSetup *setup) 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:190
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:125
double dzError() const
error on dz
Definition: TrackBase.h:213
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:85
Definition: DetId.h:18
GlobalPoint position() const
TH1F * goodst1lt4_simvecsize
Definition: TestOutliers.cc:91
TH1F * histoPtOld
Definition: TestOutliers.cc:79
TH1F * goodhittype_clgteq4
Definition: TestOutliers.cc:88
edm::RefToBase< TrajectorySeed > seedRef() const
Definition: Track.h:112
edm::InputTag tpTags_
Definition: TestOutliers.cc:71
TH1F * deltahitsAssocGained
Definition: TestOutliers.cc:85
const T & get() const
Definition: EventSetup.h:55
T const * product() const
Definition: ESHandle.h:62
TrackAssociatorBase * theAssociatorOld
Definition: TestOutliers.cc:72
TH1F * goodlayer_cllt4
Definition: TestOutliers.cc:88
TH1F * histoDzOut
Definition: TestOutliers.cc:83
TrackAssociatorBase * theAssociatorOut
Definition: TestOutliers.cc:73
TH1F * probXdelta
TH1F * goodst2_clustersize
Definition: TestOutliers.cc:96
unsigned short processType() const
Definition: PSimHit.h:118
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
edm::EventID id() const
Definition: EventBase.h:56
TH1F * histoLambdaOld
Definition: TestOutliers.cc:84
std::vector< SimHitIdpr > associateHitId(const TrackingRecHit &thit) const
TH1F * countOldT
TH1F * countOutT
const math::XYZTLorentzVectorD & momentum() const
particle info...
Definition: CoreSimTrack.h:36
TH1F * goodst2gteq4_simvecsize
Definition: TestOutliers.cc:92
TH1F * goodcluster
Definition: TestOutliers.cc:87
TH1F * histoD0Out
Definition: TestOutliers.cc:82
edm::ESHandle< TrackerGeometry > theG
Definition: TestOutliers.cc:76
std::vector< PSimHit > associateHit(const TrackingRecHit &thit) const
TH1F * okcutsOld
Definition: TestOutliers.cc:86
virtual void analyze(const edm::Event &, const edm::EventSetup &) override
int charge() const
track electric charge
Definition: TrackBase.h:111
TH1F * mergedPull
TH1F * goodbadmerged
TH1F * deltahitsAssocLost
Definition: TestOutliers.cc:85
TH1F * goodlayer_simvecbig
TH1F * histoQoverpOld
Definition: TestOutliers.cc:80
TH1F * nOfTrackIds
edm::InputTag trackTagsOld_
Definition: TestOutliers.cc:70
TH1F * hitsPerTrackLost
Definition: TestOutliers.cc:85
TH1F * gainedhits
T const * get() const
Returns C++ pointer to the item.
Definition: Ref.h:242
TrackerHitAssociator * hitAssociator
Definition: TestOutliers.cc:75
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:119
T x() const
Definition: PV3DBase.h:62
virtual void endJob() override
value_type const * get() const
Definition: RefToBase.h:212
TH1F * goodbadhits
Definition: TestOutliers.cc:87
Definition: Run.h:41
Global3DVector GlobalVector
Definition: GlobalVector.h:10
double thetaError() const
error on theta
Definition: TrackBase.h:199
TH1F * goodbadmergedGained
Pixel Reconstructed Hit.
TH1F * gainedhits2
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:65