CMS 3D CMS Logo

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