CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
CkfDebugger.h
Go to the documentation of this file.
1 #ifndef CkfDebugger_H
2 #define CkfDebugger_H
3 
8 
10 
14 
24 
25 #include <vector>
26 #include <iostream>
27 #include <TFile.h>
28 #include <TH1F.h>
29 #include <TH2F.h>
30 
31 class Trajectory;
33 class PSimHit;
34 class MeasurementTracker;
36 class MagneticField;
38 class Propagator;
40 
42 
43 class CkfDebugger {
44  public:
45  CkfDebugger( edm::EventSetup const & es );
46 
47  ~CkfDebugger();
48 
49  void printSimHits( const edm::Event& iEvent);
50 
51  void countSeed(){totSeeds++;}
52 
54  //edm::LogVerbatim("CkfDebugger") << "CkfDebugger::fillSeedHist";
55  hchi2seedAll->Fill( testSeed(h1,h2,t) );
56  }
57 
59  const std::vector<TrajectoryMeasurement>&,
60  const MeasurementTracker*,
61  const Propagator*,
64 
66  delete hitAssociator;
67  }
68 
69  private:
72 
73  class SimHit {
74  public:
75 
76  SimHit( const PSimHit* phit, const GeomDetUnit* gdu) : thePHit( phit), theDet(gdu) {}
79  const GeomDetUnit* det() const {return theDet;}
80  unsigned int trackId() const {return thePHit->trackId();}
84  float pabs() const {return thePHit->pabs();}
85  float timeOfFlight() const {return thePHit->timeOfFlight();}
86  float energyLoss() const {return thePHit->energyLoss();}
87  int particleType() const {return thePHit->particleType();}
88  unsigned int detUnitId() const {return thePHit->detUnitId();}
89  unsigned short processType() const {return thePHit->processType();}
90  const PSimHit& psimHit() const { return *thePHit;}
91 
92  private:
93 
94  const PSimHit* thePHit;
96 
97  };
98 
109 
110  std::map<unsigned int, std::vector<PSimHit*> > idHitsMap;
111 
112  void dumpSimHit( const SimHit& hit) const;
113 
114  bool correctTrajectory( const Trajectory&, unsigned int&) const;
115 
116  int assocTrackId(CTTRHp rechit) const;
117 
118  //const PSimHit* nextCorrectHit( const Trajectory&, unsigned int&) ;
119  std::vector<const PSimHit*> nextCorrectHits( const Trajectory&, unsigned int&) ;
120 
121  bool associated(CTTRHp rechit, const PSimHit& sh) const;
122 
123  bool goodSimHit(const PSimHit& sh) const;
124 
125  bool correctMeas( const TM& tm, const PSimHit* correctHit) const;
126 
127  std::pair<CTTRHp, double> analyseRecHitExistance( const PSimHit& sh, const TSOS& startingState);
128 
130 
132 
133  const PSimHit* pSimHit(unsigned int tkId, DetId detId);
134 
135  bool hasDelta(const PSimHit* correctHit){
136  bool delta = false;
137  for (std::vector<PSimHit>::iterator isim = hitAssociator->SimHitMap[correctHit->detUnitId()].begin();
138  isim != hitAssociator->SimHitMap[correctHit->detUnitId()].end(); ++isim){
139 /* edm::LogVerbatim("CkfDebugger") << "SimHit on this det at pos="<< position(&*isim) */
140 /* << " det=" << isim->detUnitId() << " process=" << isim->processType() ; */
141  if (isim->processType() == 9) delta = true;
142  }
143  return delta;
144  }
145 
146  Global3DPoint position(const PSimHit* sh) const {
148  };
149  const GeomDetUnit* det(const PSimHit* sh) const {return theTrackerGeom->idToDetUnit(DetId(sh->detUnitId()));};
150 
151  int layer(const GeomDet* det){
152  //return ((int)(((det->geographicalId().rawId() >>16) & 0xF)));
153  return theTopo->layer(det->geographicalId());
154  }
155 
156  template<unsigned int D>
157  std::pair<double,double> computePulls(CTTRHp recHit, TSOS startingState){
158  typedef typename AlgebraicROOTObject<D>::Vector VecD;
159  typedef typename AlgebraicROOTObject<D,D>::SymMatrix SMatDD;
160  TSOS detState = theForwardPropagator->propagate(startingState,recHit->det()->surface());
161  LogTrace("CkfDebugger") << "parameters=" << recHit->parameters() ;
162  LogTrace("CkfDebugger") << "parametersError=" << recHit->parametersError() ;
163  MeasurementExtractor me(detState);
164  VecD r = asSVector<D>(recHit->parameters()) - me.measuredParameters<D>(*recHit);
165  LogTrace("CkfDebugger") << "me.measuredParameters=" << me.measuredParameters<D>(*recHit) ;
166  LogTrace("CkfDebugger") << "me.measuredError=" << me.measuredError<D>(*recHit) ;
167  SMatDD R = asSMatrix<D>(recHit->parametersError()) + me.measuredError<D>(*recHit);
168  LogTrace("CkfDebugger") << "r=" << r ;
169  LogTrace("CkfDebugger") << "R=" << R ;
170  R.Invert();
171  LogTrace("CkfDebugger") << "R(-1)=" << R ;
172  LogTrace("CkfDebugger") << "chi2=" << ROOT::Math::Similarity(r,R) ;
173  double pullX=(-r[0])*sqrt(R(0,0));
174  double r_1 = 0;
175  if ( VecD::Dim() >= 2 )
176  {
177  r_1 = r[1];
178  }
179  double pullY=(-r_1)*sqrt(R(1,1));
180  LogTrace("CkfDebugger") << "pullX=" << pullX ;
181  LogTrace("CkfDebugger") << "pullY=" << pullY ;
182  return std::pair<double,double>(pullX,pullY);
183  }
184  std::pair<double,double> computePulls(CTTRHp recHit, TSOS startingState) {
185  switch (recHit->dimension()) {
186  case 1: return computePulls<1>(recHit,startingState);
187  case 2: return computePulls<2>(recHit,startingState);
188  case 3: return computePulls<3>(recHit,startingState);
189  case 4: return computePulls<4>(recHit,startingState);
190  case 5: return computePulls<5>(recHit,startingState);
191  }
192  throw cms::Exception("CkfDebugger error: rechit of dimension not 1,2,3,4,5");
193  }
194 
195  std::vector<int> dump;
196  std::map<std::pair<int,int>, int> dump2;
197  std::map<std::pair<int,int>, int> dump3;
198  std::map<std::pair<int,int>, int> dump4;
199  std::map<std::pair<int,int>, int> dump5;
200  std::map<std::pair<int,int>, int> dump6;
201 
202  TFile* file;
204 
205  std::map<std::string,TH1F*> hPullX_shrh;
206  std::map<std::string,TH1F*> hPullY_shrh;
207  std::map<std::string,TH1F*> hPullX_shst;
208  std::map<std::string,TH1F*> hPullY_shst;
209  std::map<std::string,TH1F*> hPullX_strh;
210  std::map<std::string,TH1F*> hPullY_strh;
211 
212  std::map<std::string,TH1F*> hPullM_shrh;
213  std::map<std::string,TH1F*> hPullS_shrh;
214  std::map<std::string,TH1F*> hPullM_shst;
215  std::map<std::string,TH1F*> hPullS_shst;
216  std::map<std::string,TH1F*> hPullM_strh;
217  std::map<std::string,TH1F*> hPullS_strh;
218 
219  std::map<std::string,TH1F*> hPullGP_X_shst;
220  std::map<std::string,TH1F*> hPullGP_Y_shst;
221  std::map<std::string,TH1F*> hPullGP_Z_shst;
222 
229 
231  int problems;
233  int no_layer;
236  int chi2gt30;
239  int chi2ls30;
248  int other;
250 
251  int totSeeds;
252 };
253 
254 class less_mag : public std::binary_function<PSimHit*, PSimHit*, bool> {
255  public:
256  less_mag(){ }
257  bool operator()(const PSimHit* a,const PSimHit* b) {
258  return
259  ( a->timeOfFlight()< b->timeOfFlight() );
260  }
261 };
262 
263 #endif
dbl * delta
Definition: mlp_gen.cc:36
unsigned short processType() const
Definition: CkfDebugger.h:89
virtual const TrackerGeomDet * idToDetUnit(DetId) const
Return the pointer to the GeomDetUnit corresponding to a given DetId.
GlobalPoint globalPosition() const
Definition: CkfDebugger.h:78
virtual FreeTrajectoryState propagate(const FreeTrajectoryState &ftsStart, const GlobalPoint &pDest) const final
Definition: Propagator.h:119
std::map< std::string, TH1F * > hPullS_shrh
Definition: CkfDebugger.h:213
const TrackerTopology * theTopo
Definition: CkfDebugger.h:107
bool hasDelta(const PSimHit *correctHit)
Definition: CkfDebugger.h:135
std::pair< CTTRHp, double > analyseRecHitExistance(const PSimHit &sh, const TSOS &startingState)
Definition: CkfDebugger.cc:680
std::map< std::string, TH1F * > hPullY_shst
Definition: CkfDebugger.h:208
bool correctMeas(const TM &tm, const PSimHit *correctHit) const
Definition: CkfDebugger.cc:634
void printSimHits(const edm::Event &iEvent)
Definition: CkfDebugger.cc:156
std::map< std::pair< int, int >, int > dump6
Definition: CkfDebugger.h:200
Geom::Theta< float > thetaAtEntry() const
fast and more accurate access to momentumAtEntry().theta()
Definition: PSimHit.h:57
ROOT::Math::SMatrix< double, D1, D1, ROOT::Math::MatRepSym< double, D1 > > SymMatrix
const MeasurementTracker * theMeasurementTracker
Definition: CkfDebugger.h:105
const PSimHit * thePHit
Definition: CkfDebugger.h:94
std::pair< double, double > computePulls(CTTRHp recHit, TSOS startingState)
Definition: CkfDebugger.h:157
TH2F * hPullGPXvsGPeta_shst
Definition: CkfDebugger.h:227
void dumpSimHit(const SimHit &hit) const
Definition: CkfDebugger.cc:185
const MagneticField * theMagField
Definition: CkfDebugger.h:100
unsigned int detUnitId() const
Definition: CkfDebugger.h:88
const TransientTrackingRecHitBuilder * theTTRHBuilder
Definition: CkfDebugger.h:106
GlobalPoint toGlobal(const Local2DPoint &lp) const
Conversion to the global R.F. from the R.F. of the GeomDet.
Definition: GeomDet.h:52
std::map< std::string, TH1F * > hPullGP_Z_shst
Definition: CkfDebugger.h:221
const GeometricSearchTracker * theGeomSearchTracker
Definition: CkfDebugger.h:101
AlgebraicVector measuredParameters(const TrackingRecHit &)
const PSimHit & psimHit() const
Definition: CkfDebugger.h:90
float timeOfFlight() const
Definition: CkfDebugger.h:85
std::map< std::string, TH1F * > hPullY_strh
Definition: CkfDebugger.h:210
std::map< std::string, TH1F * > hPullM_shrh
Definition: CkfDebugger.h:212
void deleteHitAssociator()
Definition: CkfDebugger.h:65
std::map< std::string, TH1F * > hPullX_shst
Definition: CkfDebugger.h:207
int partner_det_not_fuond
Definition: CkfDebugger.h:245
std::vector< const PSimHit * > nextCorrectHits(const Trajectory &, unsigned int &)
Definition: CkfDebugger.cc:529
void countSeed()
Definition: CkfDebugger.h:51
TrajectoryMeasurement TM
Definition: CkfDebugger.h:70
int det_not_found
Definition: CkfDebugger.h:235
Geom::Theta< float > thetaAtEntry() const
Definition: CkfDebugger.h:82
int seedWithDelta
Definition: CkfDebugger.h:230
std::map< std::string, TH1F * > hPullM_shst
Definition: CkfDebugger.h:214
const MeasurementEstimator * theChi2
Definition: CkfDebugger.h:102
int matched_not_found
Definition: CkfDebugger.h:243
unsigned int trackId() const
Definition: CkfDebugger.h:80
CkfDebugger(edm::EventSetup const &es)
Definition: CkfDebugger.cc:37
int analyseRecHitNotFound(const Trajectory &, CTTRHp)
Definition: CkfDebugger.cc:904
int iEvent
Definition: GenABIO.cc:230
const SurfaceType & surface() const
std::map< std::string, TH1F * > hPullGP_Y_shst
Definition: CkfDebugger.h:220
float timeOfFlight() const
Definition: PSimHit.h:69
double testSeed(CTTRHp, CTTRHp, TrajectoryStateOnSurface)
Definition: CkfDebugger.cc:989
int particleType() const
Definition: CkfDebugger.h:87
int matched_not_associated
Definition: CkfDebugger.h:244
Local3DPoint localPosition() const
Definition: PSimHit.h:44
const GeomDetUnit * theDet
Definition: CkfDebugger.h:95
bool associated(CTTRHp rechit, const PSimHit &sh) const
Definition: CkfDebugger.cc:614
std::shared_ptr< TrackingRecHit const > ConstRecHitPointer
int only_one_component
Definition: CkfDebugger.h:242
T sqrt(T t)
Definition: SSEVec.h:48
AlgebraicSymMatrix measuredError(const TrackingRecHit &)
int assocTrackId(CTTRHp rechit) const
Definition: CkfDebugger.cc:511
TH2F * hPullGPXvsGPr_shst
Definition: CkfDebugger.h:226
int glued_det_not_fuond
Definition: CkfDebugger.h:246
TH1F * hchi2seedAll
Definition: CkfDebugger.h:203
TrackerHitAssociator * hitAssociator
Definition: CkfDebugger.h:104
TH2F * hPullGPXvsGPY_shst
Definition: CkfDebugger.h:224
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:77
std::pair< double, double > computePulls(CTTRHp recHit, TSOS startingState)
Definition: CkfDebugger.h:184
TransientTrackingRecHit::ConstRecHitPointer CTTRHp
Definition: CkfDebugger.h:39
std::map< std::string, TH1F * > hPullX_shrh
Definition: CkfDebugger.h:205
float pabs() const
fast and more accurate access to momentumAtEntry().mag()
Definition: PSimHit.h:63
SimHit(const PSimHit *phit, const GeomDetUnit *gdu)
Definition: CkfDebugger.h:76
std::map< std::string, TH1F * > hPullGP_X_shst
Definition: CkfDebugger.h:219
#define LogTrace(id)
bool operator()(const PSimHit *a, const PSimHit *b)
Definition: CkfDebugger.h:257
void fillSeedHist(CTTRHp h1, CTTRHp h2, TrajectoryStateOnSurface t)
Definition: CkfDebugger.h:53
LocalVector localDirection() const
Obsolete. Same as momentumAtEntry().unit(), for backward compatibility.
Definition: PSimHit.h:52
const GeomDetUnit * det() const
Definition: CkfDebugger.h:79
const Propagator * theForwardPropagator
Definition: CkfDebugger.h:103
bool correctTrajectory(const Trajectory &, unsigned int &) const
Definition: CkfDebugger.cc:469
int chi2gt30deltaSeed
Definition: CkfDebugger.h:238
Definition: DetId.h:18
ROOT::Math::SVector< double, D1 > Vector
std::map< std::string, TH1F * > hPullM_strh
Definition: CkfDebugger.h:216
float pabs() const
Definition: CkfDebugger.h:84
std::map< std::string, TH1F * > hPullS_shst
Definition: CkfDebugger.h:215
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:150
int simple_hit_not_found
Definition: CkfDebugger.h:240
Geom::Phi< float > phiAtEntry() const
Definition: CkfDebugger.h:83
std::map< std::pair< int, int >, int > dump2
Definition: CkfDebugger.h:196
double b
Definition: hdecay.h:120
std::map< std::string, TH1F * > hPullS_strh
Definition: CkfDebugger.h:217
unsigned short processType() const
Definition: PSimHit.h:118
TFile * file
Definition: CkfDebugger.h:202
unsigned int layer(const DetId &id) const
const TrackerGeometry * theTrackerGeom
Definition: CkfDebugger.h:99
const GeomDetUnit * det(const PSimHit *sh) const
Definition: CkfDebugger.h:149
float energyLoss() const
The energy deposit in the PSimHit, in ???.
Definition: PSimHit.h:75
int particleType() const
Definition: PSimHit.h:85
NavigationSchool const * theNavSchool
Definition: CkfDebugger.h:108
bool goodSimHit(const PSimHit &sh) const
Definition: CkfDebugger.cc:607
double a
Definition: hdecay.h:121
float energyLoss() const
Definition: CkfDebugger.h:86
std::map< std::string, TH1F * > hPullY_shrh
Definition: CkfDebugger.h:206
TH2F * hPullGPXvsGPX_shst
Definition: CkfDebugger.h:223
unsigned int trackId() const
Definition: PSimHit.h:102
Geom::Phi< float > phiAtEntry() const
fast and more accurate access to momentumAtEntry().phi()
Definition: PSimHit.h:60
std::map< std::string, TH1F * > hPullX_strh
Definition: CkfDebugger.h:209
int layer_not_found
Definition: CkfDebugger.h:234
LocalPoint localPosition() const
Definition: CkfDebugger.h:77
int no_component
Definition: CkfDebugger.h:241
TH2F * hPullGPXvsGPZ_shst
Definition: CkfDebugger.h:225
std::vector< int > dump
Definition: CkfDebugger.h:195
const PSimHit * pSimHit(unsigned int tkId, DetId detId)
Definition: CkfDebugger.cc:892
int layer(const GeomDet *det)
Definition: CkfDebugger.h:151
std::map< std::pair< int, int >, int > dump5
Definition: CkfDebugger.h:199
Global3DPoint position(const PSimHit *sh) const
Definition: CkfDebugger.h:146
LocalVector localDirection() const
Definition: CkfDebugger.h:81
std::map< unsigned int, std::vector< PSimHit * > > idHitsMap
Definition: CkfDebugger.h:110
TrajectoryStateOnSurface TSOS
Definition: CkfDebugger.h:71
bool analyseCompatibleMeasurements(const Trajectory &, const std::vector< TrajectoryMeasurement > &, const MeasurementTracker *, const Propagator *, const Chi2MeasurementEstimatorBase *, const TransientTrackingRecHitBuilder *)
Definition: CkfDebugger.cc:197
TH1F * hchi2seedProb
Definition: CkfDebugger.h:203
unsigned int detUnitId() const
Definition: PSimHit.h:93
std::map< std::pair< int, int >, int > dump4
Definition: CkfDebugger.h:198
TH2F * hPullGPXvsGPphi_shst
Definition: CkfDebugger.h:228
int chi2gt30delta
Definition: CkfDebugger.h:237
std::map< std::pair< int, int >, int > dump3
Definition: CkfDebugger.h:197