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.14 2012/01/24 08:58:27 innocent 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 
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  int layerId = 0;
587  DetId id = (*itHit)->geographicalId();
588  if (id.subdetId()==3) layerId = ((TIBDetId)(id)).layer();
589  if (id.subdetId()==5) layerId = ((TOBDetId)(id)).layer();
590  if (id.subdetId()==1) layerId = ((PXBDetId)(id)).layer();
591  if (id.subdetId()==4) layerId = ((TIDDetId)(id)).wheel();
592  if (id.subdetId()==6) layerId = ((TECDetId)(id)).wheel();
593  if (id.subdetId()==2) layerId = ((PXFDetId)(id)).disk();
594  layerval = subdetId*10+layerId;
595 
596  //LogTrace("TestOutliers") << "gpos";
597  GlobalPoint gpos = theG->idToDet((*itHit)->geographicalId())->surface().toGlobal((*itHit)->localPosition());
598 
599 
600  //get the vector of sim hit associated and choose the one with the largest energy loss
601  //double delta = 99999;
602  //LocalPoint rhitLPv = (*itHit)->localPosition();
603  //vector<PSimHit> assSimHits = hitAssociator->associateHit(**itHit);
604  //if (assSimHits.size()==0) continue;
605  //PSimHit shit;
606  //for(std::vector<PSimHit>::const_iterator m=assSimHits.begin(); m<assSimHits.end(); m++){
607  //if ((m->localPosition()-rhitLPv).mag()<delta) {
608  // shit=*m;
609  // delta = (m->localPosition()-rhitLPv).mag();
610  // }
611  //}
612  //LogTrace("TestOutliers") << "energyLoss_";
613  double energyLoss_ = 0.;
614  unsigned int monoId = 0;
615  std::vector<double> energyLossM;
616  std::vector<double> energyLossS;
617  std::vector<PSimHit> assSimHits = hitAssociator->associateHit(**itHit);
618  if (assSimHits.size()==0) continue;
619  PSimHit shit;
620  std::vector<unsigned int> trackIds;
621  energyLossS.clear();
622  energyLossM.clear();
623  //LogTrace("TestOutliers") << "energyLossM";
624  for(std::vector<PSimHit>::const_iterator m=assSimHits.begin(); m<assSimHits.end(); m++){
625  if (outlier) energyLoss->Fill(m->energyLoss());
626  unsigned int tId = m->trackId();
627  if (find(trackIds.begin(),trackIds.end(),tId)==trackIds.end()) trackIds.push_back(tId);
628  LogTrace("TestOutliers") << "id=" << tId;
629  if (m->energyLoss()>energyLoss_) {
630  shit=*m;
631  energyLoss_ = m->energyLoss();
632  }
633  if (hittypeval==3) {
634  if (monoId==0) monoId = m->detUnitId();
635  if (monoId == m->detUnitId()){
636  energyLossM.push_back(m->energyLoss());
637  }
638  else {
639  energyLossS.push_back(m->energyLoss());
640  }
641  //std::cout << "detUnitId=" << m->detUnitId() << " trackId=" << m->trackId() << " energyLoss=" << m->energyLoss() << std::endl;
642  } else {
643  energyLossM.push_back(m->energyLoss());
644  }
645  }
646  unsigned int nIds = trackIds.size();
647 
648  if (outlier) {
649  goodbadhits->Fill(goodhit);
650  posxy->Fill(fabs(gpos.x()),fabs(gpos.y()));
651  poszr->Fill(fabs(gpos.z()),sqrt(gpos.x()*gpos.x()+gpos.y()*gpos.y()));
652  process->Fill(shit.processType());
653  energyLossMax->Fill(energyLoss_);
654  }
655 
656  //look if the hit is shared and if is produced only by ionization processes
657  bool shared = true;
658  bool ioniOnly = true;
659  unsigned int idc = 0;
660  for (size_t jj=0; jj<tpids.size(); jj++){
661  idc += std::count(trackIds.begin(),trackIds.end(),tpids[jj]);
662  }
663  if (idc==trackIds.size()) {
664  shared = false;
665  }
666  for(std::vector<PSimHit>::const_iterator m=assSimHits.begin()+1; m<assSimHits.end(); m++){
667  if ((m->processType()!=7&&m->processType()!=8&&m->processType()!=9)&&abs(m->particleType())!=11){
668  ioniOnly = false;
669  break;
670  }
671  }
672  if (ioniOnly&&!shared){
673  LogTrace("TestOutliers") << "delta";
674  }
675 
676  if (goodhit) {
677  if (outlier) {
678  goodprocess->Fill(shit.processType());
679  if (clustersize>=4) {
680  goodhittype_clgteq4->Fill(hittypeval);
681  goodlayer_clgteq4->Fill(layerval);
682  } else {
683  goodhittype_cllt4->Fill(hittypeval);
684  goodlayer_cllt4->Fill(layerval);
685  }
686  //LogTrace("TestOutliers") << "hittypeval && clustersize";
687  if (hittypeval==1 && clustersize>=4) goodpixgteq4_simvecsize->Fill(assSimHits.size());
688  if (hittypeval==1 && clustersize<4 ) goodpixlt4_simvecsize->Fill(assSimHits.size());
689  if (hittypeval==2 && clustersize>=4) goodst1gteq4_simvecsize->Fill(assSimHits.size());
690  if (hittypeval==2 && clustersize<4 ) goodst1lt4_simvecsize->Fill(assSimHits.size());
691  if (hittypeval==3 && clustersize>=4) goodst2gteq4_simvecsize->Fill(assSimHits.size());
692  if (hittypeval==3 && clustersize<4 ) goodst2lt4_simvecsize->Fill(assSimHits.size());
693  if (hittypeval==4 && clustersize>=4) goodprjgteq4_simvecsize->Fill(assSimHits.size());
694  if (hittypeval==4 && clustersize<4 ) goodprjlt4_simvecsize->Fill(assSimHits.size());
695 
696  //LogTrace("TestOutliers") << "hittypeval";
697  if (hittypeval==1) goodpix_clustersize->Fill(clustersize);
698  if (hittypeval==2) goodst1_clustersize->Fill(clustersize);
699  if (hittypeval==3) goodst2_clustersize->Fill(clustersize);
700  if (hittypeval==4) goodprj_clustersize->Fill(clustersize);
701  if (hittypeval==1) goodpix_simvecsize->Fill(assSimHits.size());
702  if (hittypeval==2) goodst1_simvecsize->Fill(assSimHits.size());
703  if (hittypeval==3) goodst2_simvecsize->Fill(assSimHits.size());
704  if (hittypeval==4) goodprj_simvecsize->Fill(assSimHits.size());
705 
706  //LogTrace("TestOutliers") << "nOfTrackIds";
707  nOfTrackIds->Fill(nIds);
708  if (hittypeval!=3) {
709  if (energyLossM.size()>1) {
710  sort(energyLossM.begin(),energyLossM.end(),greater<double>());
711  energyLossRatio->Fill(energyLossM[1]/energyLossM[0]);
712  }
713  } else {
714  //LogTrace("TestOutliers") << "hittypeval==3";
715  if (energyLossM.size()>1&&energyLossS.size()<=1) {
716  sort(energyLossM.begin(),energyLossM.end(),greater<double>());
717  energyLossRatio->Fill(energyLossM[1]/energyLossM[0]);
718  }
719  else if (energyLossS.size()>1&&energyLossM.size()<=1) {
720  sort(energyLossS.begin(),energyLossS.end(),greater<double>());
721  energyLossRatio->Fill(energyLossS[1]/energyLossS[0]);
722  }
723  else if (energyLossS.size()>1&&energyLossM.size()>1) {
724  sort(energyLossM.begin(),energyLossM.end(),greater<double>());
725  sort(energyLossS.begin(),energyLossS.end(),greater<double>());
726  energyLossM[1]/energyLossM[0] > energyLossS[1]/energyLossS[0]
727  ? energyLossRatio->Fill(energyLossM[1]/energyLossM[0])
728  : energyLossRatio->Fill(energyLossS[1]/energyLossS[0]);
729  }
730  }
731 
732  LogTrace("TestOutliers") << "before merged";
733  const SiStripMatchedRecHit2D* tmp = dynamic_cast<const SiStripMatchedRecHit2D*>(&**itHit);
734  LogTrace("TestOutliers") << "tmp=" << tmp;
735  LogTrace("TestOutliers") << "assSimHits.size()=" << assSimHits.size();
736  if ( (assSimHits.size()>1 && tmp==0) ||
737  (assSimHits.size()>2 && tmp!=0) ) {
738  //std::cout << "MERGED HIT" << std::endl;
739  //LogTrace("TestOutliers") << "merged";
740  mergedlayer->Fill(layerval);
741  mergedcluster->Fill(clustersize);
742  mergedhittype->Fill(hittypeval);
743 
744  for(std::vector<PSimHit>::const_iterator m=assSimHits.begin(); m<assSimHits.end(); m++){
745  unsigned int tId = m->trackId();
746  LogTrace("TestOutliers") << "component with id=" << tId << " eLoss=" << m->energyLoss()
747  << " proc=" << m->processType() << " part=" << m->particleType();
748  if (find(tpids.begin(),tpids.end(),tId)==tpids.end()) continue;
749  if (m->processType()==2) {
750  //GlobalPoint gpos = theG->idToDet((*itHit)->geographicalId())->surface().toGlobal((*itHit)->localPosition());
751  //GlobalPoint gpr = rhit->globalPosition();
752  AlgebraicSymMatrix33 ger =
753  ErrorFrameTransformer().transform((*itHit)->localPositionError(),theG->idToDet((*itHit)->geographicalId())->surface() ).matrix();
754  //AlgebraicSymMatrix ger = rhit->globalPositionError().matrix();
755  GlobalPoint gps = theG->idToDet((*itHit)->geographicalId())->surface().toGlobal(m->localPosition());
756  //LogTrace("TestOutliers") << gpr << " " << gps << " " << ger;
757  ROOT::Math::SVector<double,3> delta;
758  delta[0]=gpos.x()-gps.x();
759  delta[1]=gpos.y()-gps.y();
760  delta[2]=gpos.z()-gps.z();
761  LogTrace("TestOutliers") << delta << " " << ger ;
762  double mpull = sqrt(delta[0]*delta[0]/ger[0][0]+delta[1]*delta[1]/ger[1][1]+delta[2]*delta[2]/ger[2][2]);
763  LogTrace("TestOutliers") << "hit pull=" << mpull;//ger.similarity(delta);
764  mergedPull->Fill(mpull);
765  }
766  }
767  LogTrace("TestOutliers") << "end merged";
768  } else {//not merged=>good
769  //LogTrace("TestOutliers") << "goodlayer";
770  goodlayer->Fill(layerval);
771  goodcluster->Fill(clustersize);
772  goodhittype->Fill(hittypeval);
773  }
774  }//if (outlier)
775 
776  const SiPixelRecHit* pix = dynamic_cast<const SiPixelRecHit*>(&**itHit);
777  if ((hittypeval!=3 && assSimHits.size()<2)||(hittypeval==3 && assSimHits.size()<3)){
778  if (outlier) {
779  goodhittype_simvecsmall->Fill(hittypeval);
780  goodlayer_simvecsmall->Fill(layerval);
781  goodbadmerged->Fill(1);
782  if (pix) {
783  probXgood->Fill(pix->probabilityX());
784  probYgood->Fill(pix->probabilityY());
785  }
786  LogTrace("TestOutliers") << "out good";
787  }
788  else if (lost){
789  goodbadmergedLost->Fill(1);
790  LogTrace("TestOutliers") << "lost good";
791  }
792  else if (gained){
793  goodbadmergedGained->Fill(1);
794  LogTrace("TestOutliers") << "gained good";
795  }
796  LogTrace("TestOutliers") << "good";
797  } else {
798  if (outlier) {
799  goodhittype_simvecbig->Fill(hittypeval);
800  goodlayer_simvecbig->Fill(layerval);
801  if (ioniOnly&&!shared) {
802  goodbadmerged->Fill(3);
803  if (pix) {
804  probXdelta->Fill(pix->probabilityX());
805  probYdelta->Fill(pix->probabilityY());
806  }
807  } else if(!ioniOnly&&!shared) {
808  goodbadmerged->Fill(4);
809  if (pix) {
810  probXnoshare->Fill(pix->probabilityX());
811  probYnoshare->Fill(pix->probabilityY());
812  }
813  } else {
814  goodbadmerged->Fill(5);
815  if (pix) {
816  probXshared->Fill(pix->probabilityX());
817  probYshared->Fill(pix->probabilityY());
818  }
819  }
820  LogTrace("TestOutliers") << "out merged, ioniOnly=" << ioniOnly << " shared=" << shared;
821  }
822  else if (lost) {
823  if (ioniOnly&&!shared) goodbadmergedLost->Fill(3);
824  else if(!ioniOnly&&!shared) goodbadmergedLost->Fill(4);
825  else goodbadmergedLost->Fill(5);
826  LogTrace("TestOutliers") << "lost merged, ioniOnly=" << ioniOnly << " shared=" << shared;
827  }
828  else if (gained) {
829  if (ioniOnly&&!shared) goodbadmergedGained->Fill(3);
830  else if(!ioniOnly&&!shared) goodbadmergedGained->Fill(4);
831  else goodbadmergedGained->Fill(5);
832  LogTrace("TestOutliers") << "gained merged, ioniOnly=" << ioniOnly << " shared=" << shared;
833  }
834  LogTrace("TestOutliers") << "merged, ioniOnly=" << ioniOnly << " shared=" << shared;
835  }
836  } //if (goodhit)
837  else {//badhit
838  //LogTrace("TestOutliers") << "badhit";
839  if (outlier) {
840  badcluster->Fill(clustersize);
841  badhittype->Fill(hittypeval);
842  badlayer->Fill(layerval);
843  badprocess->Fill(shit.processType());
844  goodbadmerged->Fill(2);
845  const SiPixelRecHit* pix = dynamic_cast<const SiPixelRecHit*>(&**itHit);
846  if (pix) {
847  probXbad->Fill(pix->probabilityX());
848  probYbad->Fill(pix->probabilityY());
849  }
850  LogTrace("TestOutliers") << "out bad";
851  }
852  else if (lost) {
853  goodbadmergedLost->Fill(2);
854  LogTrace("TestOutliers") << "lost bad";
855  }
856  else if (gained) {
857  goodbadmergedGained->Fill(2);
858  LogTrace("TestOutliers") << "gained bad";
859  }
860  LogTrace("TestOutliers") << "bad";
861  }
862  }
863  }
864  }
865  //else if ( trackOut->numberOfValidHits() > trackOld->numberOfValidHits() ) {
866  else if ( 0 ) {
867  LogTrace("TestOutliers") << "outliers for track with #hits=" << trackOut->numberOfValidHits();
868  tracks->Fill(1);
869  LogTrace("TestOutliers") << "Out->pt=" << trackOut->pt() << " Old->pt=" << trackOld->pt()
870  << " tp->pt=" << sqrt(tpr->momentum().perp2())
871  //<< " trackOut->ptError()=" << trackOut->ptError() << " trackOld->ptError()=" << trackOld->ptError()
872  << " Old->validHits=" << trackOld->numberOfValidHits() << " Out->validHits=" << trackOut->numberOfValidHits()
873  /*<< " fracOld=" << fracOld*/ << " fracOut=" << fracOut
874  << " deltaHits=" << trackOld->numberOfValidHits()-trackOut->numberOfValidHits();
875  LogTrace("TestOutliers") << "track with gained hits";
876  gainedhits2->Fill(trackOut->numberOfValidHits()-trackOld->numberOfValidHits());
877  } else {
878  LogTrace("TestOutliers") << "no outliers for track with #hits=" << trackOut->numberOfValidHits();
879  }
880  }
881  LogTrace("TestOutliers") << "end track old #" << j;
882  }
883 
884  for (unsigned int k=0;k<tracksOut->size();++k) {
885  if ( find(outused.begin(),outused.end(),k)==outused.end() ) {
886  edm::RefToBase<reco::Track> trackOut(tracksOut, k);
887  bool outAssoc = recSimCollOut.find(trackOut) != recSimCollOut.end();
888  if (outAssoc) {
889  hitsPerTrackGained->Fill(trackOut->numberOfValidHits());
890  LogTrace("TestOutliers") << "gained track out id=" << k << " #hits==" << trackOut->numberOfValidHits();
891 
892  }
893  }
894  }
895  delete hitAssociator;
896  delete theAssociatorOld;
897  delete theAssociatorOut;
898 }
899 
900 
901 // ------------ method called once each job just before starting event loop ------------
902 void
904 {
906  const bool oldAddDir = TH1::AddDirectoryStatus();
907  TH1::AddDirectory(true);
908  file = new TFile(out.c_str(),"recreate");
909  histoPtOut = new TH1F("histoPtOut","histoPtOut",100,-10,10);
910  histoPtOld = new TH1F("histoPtOld","histoPtOld",100,-10,10);
911  histoQoverpOut = new TH1F("histoQoverpOut","histoQoverpOut",250,-25,25);
912  histoQoverpOld = new TH1F("histoQoverpOld","histoQoverpOld",250,-25,25);
913  histoPhiOut = new TH1F("histoPhiOut","histoPhiOut",250,-25,25);
914  histoPhiOld = new TH1F("histoPhiOld","histoPhiOld",250,-25,25);
915  histoD0Out = new TH1F("histoD0Out","histoD0Out",250,-25,25);
916  histoD0Old = new TH1F("histoD0Old","histoD0Old",250,-25,25);
917  histoDzOut = new TH1F("histoDzOut","histoDzOut",250,-25,25);
918  histoDzOld = new TH1F("histoDzOld","histoDzOld",250,-25,25);
919  histoLambdaOut = new TH1F("histoLambdaOut","histoLambdaOut",250,-25,25);
920  histoLambdaOld = new TH1F("histoLambdaOld","histoLambdaOld",250,-25,25);
921  deltahits = new TH1F("deltahits","deltahits",80,-40,40);
922  deltahitsOK = new TH1F("deltahitsOK","deltahitsOK",20,0,20);
923  deltahitsNO = new TH1F("deltahitsNO","deltahitsNO",20,0,20);
924  okcutsOut = new TH1F("okcutsOut","okcutsOut",2,-0.5,1.5);
925  okcutsOld = new TH1F("okcutsOld","okcutsOld",2,-0.5,1.5);
926  tracks = new TH1F("tracks_","tracks_",2,-0.5,1.5);
927  goodbadhits = new TH1F("goodbadhits","goodbadhits",2,-0.5,1.5);
928  process = new TH1F("process","process",20,-0.5,19.5);
929  goodcluster = new TH1F("goodcluster","goodcluster",40,-0.5,39.5);
930  goodprocess = new TH1F("goodprocess","goodprocess",20,-0.5,19.5);
931  badcluster = new TH1F("badcluster","badcluster",40,-0.5,39.5);
932  badprocess = new TH1F("badprocess","badprocess",20,-0.5,19.5);
933  goodhittype = new TH1F("goodhittype","goodhittype",5,-0.5,4.5);
934  goodlayer = new TH1F("goodlayer","goodlayer",70,-0.5,69.5);
935  goodhittype_clgteq4 = new TH1F("goodhittype_clgteq4","goodhittype_clgteq4",5,-0.5,4.5);
936  goodlayer_clgteq4 = new TH1F("goodlayer_clgteq4","goodlayer_clgteq4",70,-0.5,69.5);
937  goodhittype_cllt4 = new TH1F("goodhittype_cllt4","goodhittype_cllt4",5,-0.5,4.5);
938  goodlayer_cllt4 = new TH1F("goodlayer_cllt4","goodlayer_cllt4",70,-0.5,69.5);
939  badhittype = new TH1F("badhittype","badhittype",5,-0.5,4.5);
940  badlayer = new TH1F("badlayer","badlayer",70,-0.5,69.5);
941  posxy = new TH2F("posxy","posxy",1200,0,120,1200,0,120);
942  poszr = new TH2F("poszr","poszr",3000,0,300,1200,0,120);
943  goodpixgteq4_simvecsize = new TH1F("goodpixgteq4_simvecsize","goodpixgteq4_simvecsize",40,-0.5,39.5);
944  goodpixlt4_simvecsize = new TH1F("goodpixlt4_simvecsize","goodpixlt4_simvecsize",40,-0.5,39.5);
945  goodst1gteq4_simvecsize = new TH1F("goodst1gteq4_simvecsize","goodst1gteq4_simvecsize",40,-0.5,39.5);
946  goodst1lt4_simvecsize = new TH1F("goodst1lt4_simvecsize","goodst1lt4_simvecsize",40,-0.5,39.5);
947  goodst2gteq4_simvecsize = new TH1F("goodst2gteq4_simvecsize","goodst2gteq4_simvecsize",40,-0.5,39.5);
948  goodst2lt4_simvecsize = new TH1F("goodst2lt4_simvecsize","goodst2lt4_simvecsize",40,-0.5,39.5);
949  goodprjgteq4_simvecsize = new TH1F("goodprjgteq4_simvecsize","goodprjgteq4_simvecsize",40,-0.5,39.5);
950  goodprjlt4_simvecsize = new TH1F("goodprjlt4_simvecsize","goodprjlt4_simvecsize",40,-0.5,39.5);
951  goodpix_clustersize = new TH1F("goodpix_clustersize","goodpix_clustersize",40,-0.5,39.5);
952  goodst1_clustersize = new TH1F("goodst1_clustersize","goodst1_clustersize",40,-0.5,39.5);
953  goodst2_clustersize = new TH1F("goodst2_clustersize","goodst2_clustersize",40,-0.5,39.5);
954  goodprj_clustersize = new TH1F("goodprj_clustersize","goodprj_clustersize",40,-0.5,39.5);
955  goodpix_simvecsize = new TH1F("goodpix_simvecsize","goodpix_simvecsize",40,-0.5,39.5);
956  goodst1_simvecsize = new TH1F("goodst1_simvecsize","goodst1_simvecsize",40,-0.5,39.5);
957  goodst2_simvecsize = new TH1F("goodst2_simvecsize","goodst2_simvecsize",40,-0.5,39.5);
958  goodprj_simvecsize = new TH1F("goodprj_simvecsize","goodprj_simvecsize",40,-0.5,39.5);
959  goodhittype_simvecsmall = new TH1F("goodhittype_simvecsmall","goodhittype_simvecsmall",5,-0.5,4.5);
960  goodlayer_simvecsmall = new TH1F("goodlayer_simvecsmall","goodlayer_simvecsmall",70,-0.5,69.5);
961  goodhittype_simvecbig = new TH1F("goodhittype_simvecbig","goodhittype_simvecbig",5,-0.5,4.5);
962  goodlayer_simvecbig = new TH1F("goodlayer_simvecbig","goodlayer_simvecbig",70,-0.5,69.5);
963  goodbadmerged = new TH1F("goodbadmerged","goodbadmerged",5,0.5,5.5);
964  goodbadmergedLost = new TH1F("goodbadmergedLost","goodbadmergedLost",5,0.5,5.5);
965  goodbadmergedGained = new TH1F("goodbadmergedGained","goodbadmergedGained",5,0.5,5.5);
966  energyLoss = new TH1F("energyLoss","energyLoss",1000,0,0.1);
967  energyLossMax = new TH1F("energyLossMax","energyLossMax",1000,0,0.1);
968  energyLossRatio = new TH1F("energyLossRatio","energyLossRatio",100,0,1);
969  nOfTrackIds = new TH1F("nOfTrackIds","nOfTrackIds",10,0,10);
970  mergedPull = new TH1F("mergedPull","mergedPull",100,0,10);
971  mergedlayer = new TH1F("mergedlayer","mergedlayer",70,-0.5,69.5);
972  mergedhittype = new TH1F("mergedhittype","mergedhittype",5,-0.5,4.5);
973  mergedcluster = new TH1F("mergedcluster","mergedcluster",40,-0.5,39.5);
974  deltahitsAssocGained = new TH1F("deltahitsAssocGained","deltahitsAssocGained",80, -40, 40);
975  deltahitsAssocLost = new TH1F("deltahitsAssocLost","deltahitsAssocLost",80, -40, 40);
976  hitsPerTrackLost = new TH1F("hitsPerTrackLost","hitsPerTrackLost",40, -0.5, 39.5);
977  hitsPerTrackAssocLost = new TH1F("hitsPerTrackAssocLost","hitsPerTrackAssocLost",40, -0.5, 39.5);
978  hitsPerTrackGained = new TH1F("hitsPerTrackGained","hitsPerTrackGained",40, -0.5, 39.5);
979  hitsPerTrackAssocGained = new TH1F("hitsPerTrackAssocGained","hitsPerTrackAssocGained",40, -0.5, 39.5);
980  sizeOut = new TH1F("sizeOut","sizeOut",900,-0.5,899.5);
981  sizeOld = new TH1F("sizeOld","sizeOld",900,-0.5,899.5);
982  sizeOutT = new TH1F("sizeOutT","sizeOutT",900,-0.5,899.5);
983  sizeOldT = new TH1F("sizeOldT","sizeOldT",900,-0.5,899.5);
984  countOutA = new TH1F("countOutA","countOutA",2,0,2);
985  countOutT = new TH1F("countOutT","countOutT",2,0,2);
986  countOldT = new TH1F("countOldT","countOldT",2,0,2);
987  gainedhits = new TH1F("gainedhits","gainedhits",2,0,2);
988  gainedhits2 = new TH1F("gainedhits2","gainedhits2",30,-0.5,29.5);
989  probXgood = new TH1F("probXgood","probXgood",110,0,1.1);
990  probXbad = new TH1F("probXbad","probXbad",110,0,1.1);
991  probXdelta = new TH1F("probXdelta","probXdelta",110,0,1.1);
992  probXshared = new TH1F("probXshared","probXshared",110,0,1.1);
993  probXnoshare = new TH1F("probXnoshare","probXnoshare",110,0,1.1);
994  probYgood = new TH1F("probYgood","probYgood",110,0,1.1);
995  probYbad = new TH1F("probYbad","probYbad",110,0,1.1);
996  probYdelta = new TH1F("probYdelta","probYdelta",110,0,1.1);
997  probYshared = new TH1F("probYshared","probYshared",110,0,1.1);
998  probYnoshare = new TH1F("probYnoshare","probYnoshare",110,0,1.1);
999  TH1::AddDirectory(oldAddDir);
1000 }
1001 // ------------ method called once each job just after ending the event loop ------------
1002 void
1004  LogTrace("TestOutliers") << "TestOutliers::endJob";
1005  file->Write();
1006  LogTrace("TestOutliers") << "outfile written";
1007  file->Close();
1008  LogTrace("TestOutliers") << "oufile closed";
1009  LogTrace("TestOutliers") << "exiting TestOutliers::endJob";
1010 }
1011 
1012 //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
static GlobalError transform(const LocalError &le, const Surface &surf)
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:71
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
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:68
Global3DPoint GlobalPoint
Definition: GlobalPoint.h:10
std::vector< Track > TrackCollection
collection of Tracks
Definition: TrackFwd.h:10
T y() const
Definition: PV3DBase.h:62
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:74
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:66
double eta() const
pseudorapidity of momentum vector
Definition: TrackBase.h:141
TH1F * badlayer
Definition: TestOutliers.cc:93
TH1F * goodst1_clustersize
ROOT::Math::SMatrix< double, 3, 3, ROOT::Math::MatRepSym< double, 3 > > AlgebraicSymMatrix33
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:46
double pt() const
track transverse momentum
Definition: TrackBase.h:131
T z() const
Definition: PV3DBase.h:63
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:81
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:94
TestOutliers(const edm::ParameterSet &)
edm::InputTag trackTagsOut_
Definition: TestOutliers.cc:74
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
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
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:78
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:242
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:61
value_type const * get() const
Definition: RefToBase.h:212
mathSSE::Vec4< T > v
TH1F * goodbadhits
Definition: TestOutliers.cc:92
Definition: Run.h:33
Global3DVector GlobalVector
Definition: GlobalVector.h:10
double thetaError() const
error on theta
Definition: TrackBase.h:201
TH1F * goodbadmergedGained
Our base class.
Definition: SiPixelRecHit.h:22
TH1F * gainedhits2
trackingRecHit_iterator recHitsEnd() const
Iterator to last hit on the track.
Definition: Track.h:65