CMS 3D CMS Logo

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