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 GeomDetUnit* det){
152  //return ((int)(((det->geographicalId().rawId() >>16) & 0xF)));
153  return theTopo->layer(det->geographicalId());
154  }
155  int layer(const GeomDet* det){
156  //return ((int)(((det->geographicalId().rawId() >>16) & 0xF)));
157  return theTopo->layer(det->geographicalId());
158  }
159 
160  template<unsigned int D>
161  std::pair<double,double> computePulls(CTTRHp recHit, TSOS startingState){
162  typedef typename AlgebraicROOTObject<D>::Vector VecD;
163  typedef typename AlgebraicROOTObject<D,D>::SymMatrix SMatDD;
164  TSOS detState = theForwardPropagator->propagate(startingState,recHit->det()->surface());
165  LogTrace("CkfDebugger") << "parameters=" << recHit->parameters() ;
166  LogTrace("CkfDebugger") << "parametersError=" << recHit->parametersError() ;
167  MeasurementExtractor me(detState);
168  VecD r = asSVector<D>(recHit->parameters()) - me.measuredParameters<D>(*recHit);
169  LogTrace("CkfDebugger") << "me.measuredParameters=" << me.measuredParameters<D>(*recHit) ;
170  LogTrace("CkfDebugger") << "me.measuredError=" << me.measuredError<D>(*recHit) ;
171  SMatDD R = asSMatrix<D>(recHit->parametersError()) + me.measuredError<D>(*recHit);
172  LogTrace("CkfDebugger") << "r=" << r ;
173  LogTrace("CkfDebugger") << "R=" << R ;
174  R.Invert();
175  LogTrace("CkfDebugger") << "R(-1)=" << R ;
176  LogTrace("CkfDebugger") << "chi2=" << ROOT::Math::Similarity(r,R) ;
177  double pullX=(-r[0])*sqrt(R(0,0));
178  double r_1 = 0;
179  if ( VecD::Dim() >= 2 )
180  {
181  r_1 = r[1];
182  }
183  double pullY=(-r_1)*sqrt(R(1,1));
184  LogTrace("CkfDebugger") << "pullX=" << pullX ;
185  LogTrace("CkfDebugger") << "pullY=" << pullY ;
186  return std::pair<double,double>(pullX,pullY);
187  }
188  std::pair<double,double> computePulls(CTTRHp recHit, TSOS startingState) {
189  switch (recHit->dimension()) {
190  case 1: return computePulls<1>(recHit,startingState);
191  case 2: return computePulls<2>(recHit,startingState);
192  case 3: return computePulls<3>(recHit,startingState);
193  case 4: return computePulls<4>(recHit,startingState);
194  case 5: return computePulls<5>(recHit,startingState);
195  }
196  throw cms::Exception("CkfDebugger error: rechit of dimension not 1,2,3,4,5");
197  }
198 
199  std::vector<int> dump;
200  std::map<std::pair<int,int>, int> dump2;
201  std::map<std::pair<int,int>, int> dump3;
202  std::map<std::pair<int,int>, int> dump4;
203  std::map<std::pair<int,int>, int> dump5;
204  std::map<std::pair<int,int>, int> dump6;
205 
206  TFile* file;
208 
209  std::map<std::string,TH1F*> hPullX_shrh;
210  std::map<std::string,TH1F*> hPullY_shrh;
211  std::map<std::string,TH1F*> hPullX_shst;
212  std::map<std::string,TH1F*> hPullY_shst;
213  std::map<std::string,TH1F*> hPullX_strh;
214  std::map<std::string,TH1F*> hPullY_strh;
215 
216  std::map<std::string,TH1F*> hPullM_shrh;
217  std::map<std::string,TH1F*> hPullS_shrh;
218  std::map<std::string,TH1F*> hPullM_shst;
219  std::map<std::string,TH1F*> hPullS_shst;
220  std::map<std::string,TH1F*> hPullM_strh;
221  std::map<std::string,TH1F*> hPullS_strh;
222 
223  std::map<std::string,TH1F*> hPullGP_X_shst;
224  std::map<std::string,TH1F*> hPullGP_Y_shst;
225  std::map<std::string,TH1F*> hPullGP_Z_shst;
226 
233 
235  int problems;
237  int no_layer;
240  int chi2gt30;
243  int chi2ls30;
252  int other;
254 
255  int totSeeds;
256 };
257 
258 class less_mag : public std::binary_function<PSimHit*, PSimHit*, bool> {
259  public:
260  less_mag(){ }
261  bool operator()(const PSimHit* a,const PSimHit* b) {
262  return
263  ( a->timeOfFlight()< b->timeOfFlight() );
264  }
265 };
266 
267 #endif
dbl * delta
Definition: mlp_gen.cc:36
unsigned short processType() const
Definition: CkfDebugger.h:89
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:217
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:212
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:204
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:161
TH2F * hPullGPXvsGPeta_shst
Definition: CkfDebugger.h:231
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:47
std::map< std::string, TH1F * > hPullGP_Z_shst
Definition: CkfDebugger.h:225
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:214
std::map< std::string, TH1F * > hPullM_shrh
Definition: CkfDebugger.h:216
void deleteHitAssociator()
Definition: CkfDebugger.h:65
std::map< std::string, TH1F * > hPullX_shst
Definition: CkfDebugger.h:211
int partner_det_not_fuond
Definition: CkfDebugger.h:249
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:239
Geom::Theta< float > thetaAtEntry() const
Definition: CkfDebugger.h:82
int seedWithDelta
Definition: CkfDebugger.h:234
std::map< std::string, TH1F * > hPullM_shst
Definition: CkfDebugger.h:218
const MeasurementEstimator * theChi2
Definition: CkfDebugger.h:102
int matched_not_found
Definition: CkfDebugger.h:247
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:224
int layer(const GeomDetUnit *det)
Definition: CkfDebugger.h:151
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:248
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:246
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:230
int glued_det_not_fuond
Definition: CkfDebugger.h:250
TH1F * hchi2seedAll
Definition: CkfDebugger.h:207
TrackerHitAssociator * hitAssociator
Definition: CkfDebugger.h:104
TH2F * hPullGPXvsGPY_shst
Definition: CkfDebugger.h:228
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:72
std::pair< double, double > computePulls(CTTRHp recHit, TSOS startingState)
Definition: CkfDebugger.h:188
TransientTrackingRecHit::ConstRecHitPointer CTTRHp
Definition: CkfDebugger.h:39
std::map< std::string, TH1F * > hPullX_shrh
Definition: CkfDebugger.h:209
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:223
#define LogTrace(id)
bool operator()(const PSimHit *a, const PSimHit *b)
Definition: CkfDebugger.h:261
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:242
Definition: DetId.h:18
ROOT::Math::SVector< double, D1 > Vector
std::map< std::string, TH1F * > hPullM_strh
Definition: CkfDebugger.h:220
float pabs() const
Definition: CkfDebugger.h:84
std::map< std::string, TH1F * > hPullS_shst
Definition: CkfDebugger.h:219
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:150
int simple_hit_not_found
Definition: CkfDebugger.h:244
Geom::Phi< float > phiAtEntry() const
Definition: CkfDebugger.h:83
std::map< std::pair< int, int >, int > dump2
Definition: CkfDebugger.h:200
double b
Definition: hdecay.h:120
std::map< std::string, TH1F * > hPullS_strh
Definition: CkfDebugger.h:221
unsigned short processType() const
Definition: PSimHit.h:118
TFile * file
Definition: CkfDebugger.h:206
unsigned int layer(const DetId &id) const
virtual const GeomDetUnit * idToDetUnit(DetId) const
Return the pointer to the GeomDetUnit corresponding to a given DetId.
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:210
TH2F * hPullGPXvsGPX_shst
Definition: CkfDebugger.h:227
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:213
int layer_not_found
Definition: CkfDebugger.h:238
LocalPoint localPosition() const
Definition: CkfDebugger.h:77
int no_component
Definition: CkfDebugger.h:245
TH2F * hPullGPXvsGPZ_shst
Definition: CkfDebugger.h:229
std::vector< int > dump
Definition: CkfDebugger.h:199
const PSimHit * pSimHit(unsigned int tkId, DetId detId)
Definition: CkfDebugger.cc:892
int layer(const GeomDet *det)
Definition: CkfDebugger.h:155
std::map< std::pair< int, int >, int > dump5
Definition: CkfDebugger.h:203
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:207
unsigned int detUnitId() const
Definition: PSimHit.h:93
std::map< std::pair< int, int >, int > dump4
Definition: CkfDebugger.h:202
TH2F * hPullGPXvsGPphi_shst
Definition: CkfDebugger.h:232
int chi2gt30delta
Definition: CkfDebugger.h:241
std::map< std::pair< int, int >, int > dump3
Definition: CkfDebugger.h:201