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:
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 
110 
111  std::map<unsigned int, std::vector<PSimHit*> > idHitsMap;
112 
113  void dumpSimHit( const SimHit& hit) const;
114 
115  bool correctTrajectory( const Trajectory&, unsigned int&) const;
116 
117  int assocTrackId(CTTRHp rechit) const;
118 
119  //const PSimHit* nextCorrectHit( const Trajectory&, unsigned int&) ;
120  std::vector<const PSimHit*> nextCorrectHits( const Trajectory&, unsigned int&) ;
121 
122  bool associated(CTTRHp rechit, const PSimHit& sh) const;
123 
124  bool goodSimHit(const PSimHit& sh) const;
125 
126  bool correctMeas( const TM& tm, const PSimHit* correctHit) const;
127 
128  std::pair<CTTRHp, double> analyseRecHitExistance( const PSimHit& sh, const TSOS& startingState);
129 
131 
133 
134  const PSimHit* pSimHit(unsigned int tkId, DetId detId);
135 
136  bool hasDelta(const PSimHit* correctHit){
137  bool delta = false;
138  for (std::vector<PSimHit>::iterator isim = hitAssociator->SimHitMap[correctHit->detUnitId()].begin();
139  isim != hitAssociator->SimHitMap[correctHit->detUnitId()].end(); ++isim){
140 /* edm::LogVerbatim("CkfDebugger") << "SimHit on this det at pos="<< position(&*isim) */
141 /* << " det=" << isim->detUnitId() << " process=" << isim->processType() ; */
142  if (isim->processType() == 9) delta = true;
143  }
144  return delta;
145  }
146 
147  Global3DPoint position(const PSimHit* sh) const {
149  };
150  const GeomDetUnit* det(const PSimHit* sh) const {return theTrackerGeom->idToDetUnit(DetId(sh->detUnitId()));};
151 
152  int layer(const GeomDet* det){
153  //return ((int)(((det->geographicalId().rawId() >>16) & 0xF)));
154  return theTopo->layer(det->geographicalId());
155  }
156 
157  template<unsigned int D>
158  std::pair<double,double> computePulls(CTTRHp recHit, TSOS startingState){
159  typedef typename AlgebraicROOTObject<D>::Vector VecD;
160  typedef typename AlgebraicROOTObject<D,D>::SymMatrix SMatDD;
161  TSOS detState = theForwardPropagator->propagate(startingState,recHit->det()->surface());
162  LogTrace("CkfDebugger") << "parameters=" << recHit->parameters() ;
163  LogTrace("CkfDebugger") << "parametersError=" << recHit->parametersError() ;
164  MeasurementExtractor me(detState);
165  VecD r = asSVector<D>(recHit->parameters()) - me.measuredParameters<D>(*recHit);
166  LogTrace("CkfDebugger") << "me.measuredParameters=" << me.measuredParameters<D>(*recHit) ;
167  LogTrace("CkfDebugger") << "me.measuredError=" << me.measuredError<D>(*recHit) ;
168  SMatDD R = asSMatrix<D>(recHit->parametersError()) + me.measuredError<D>(*recHit);
169  LogTrace("CkfDebugger") << "r=" << r ;
170  LogTrace("CkfDebugger") << "R=" << R ;
171  R.Invert();
172  LogTrace("CkfDebugger") << "R(-1)=" << R ;
173  LogTrace("CkfDebugger") << "chi2=" << ROOT::Math::Similarity(r,R) ;
174  double pullX=(-r[0])*sqrt(R(0,0));
175  double r_1 = 0;
176  if ( VecD::Dim() >= 2 )
177  {
178  r_1 = r[1];
179  }
180  double pullY=(-r_1)*sqrt(R(1,1));
181  LogTrace("CkfDebugger") << "pullX=" << pullX ;
182  LogTrace("CkfDebugger") << "pullY=" << pullY ;
183  return std::pair<double,double>(pullX,pullY);
184  }
185  std::pair<double,double> computePulls(CTTRHp recHit, TSOS startingState) {
186  switch (recHit->dimension()) {
187  case 1: return computePulls<1>(recHit,startingState);
188  case 2: return computePulls<2>(recHit,startingState);
189  case 3: return computePulls<3>(recHit,startingState);
190  case 4: return computePulls<4>(recHit,startingState);
191  case 5: return computePulls<5>(recHit,startingState);
192  }
193  throw cms::Exception("CkfDebugger error: rechit of dimension not 1,2,3,4,5");
194  }
195 
196  std::vector<int> dump;
197  std::map<std::pair<int,int>, int> dump2;
198  std::map<std::pair<int,int>, int> dump3;
199  std::map<std::pair<int,int>, int> dump4;
200  std::map<std::pair<int,int>, int> dump5;
201  std::map<std::pair<int,int>, int> dump6;
202 
203  TFile* file;
205 
206  std::map<std::string,TH1F*> hPullX_shrh;
207  std::map<std::string,TH1F*> hPullY_shrh;
208  std::map<std::string,TH1F*> hPullX_shst;
209  std::map<std::string,TH1F*> hPullY_shst;
210  std::map<std::string,TH1F*> hPullX_strh;
211  std::map<std::string,TH1F*> hPullY_strh;
212 
213  std::map<std::string,TH1F*> hPullM_shrh;
214  std::map<std::string,TH1F*> hPullS_shrh;
215  std::map<std::string,TH1F*> hPullM_shst;
216  std::map<std::string,TH1F*> hPullS_shst;
217  std::map<std::string,TH1F*> hPullM_strh;
218  std::map<std::string,TH1F*> hPullS_strh;
219 
220  std::map<std::string,TH1F*> hPullGP_X_shst;
221  std::map<std::string,TH1F*> hPullGP_Y_shst;
222  std::map<std::string,TH1F*> hPullGP_Z_shst;
223 
230 
232  int problems;
234  int no_layer;
237  int chi2gt30;
240  int chi2ls30;
249  int other;
251 
252  int totSeeds;
253 };
254 
255 class less_mag : public std::binary_function<PSimHit*, PSimHit*, bool> {
256  public:
257  less_mag(){ }
258  bool operator()(const PSimHit* a,const PSimHit* b) {
259  return
260  ( a->timeOfFlight()< b->timeOfFlight() );
261  }
262 };
263 
264 #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
tuple t
Definition: tree.py:139
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:214
const TrackerTopology * theTopo
Definition: CkfDebugger.h:108
bool hasDelta(const PSimHit *correctHit)
Definition: CkfDebugger.h:136
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:209
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:201
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:106
TrackerHitAssociator::Config trackerHitAssociatorConfig_
Definition: CkfDebugger.h:104
const PSimHit * thePHit
Definition: CkfDebugger.h:94
std::pair< double, double > computePulls(CTTRHp recHit, TSOS startingState)
Definition: CkfDebugger.h:158
TH2F * hPullGPXvsGPeta_shst
Definition: CkfDebugger.h:228
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:107
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:222
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:211
std::map< std::string, TH1F * > hPullM_shrh
Definition: CkfDebugger.h:213
void deleteHitAssociator()
Definition: CkfDebugger.h:65
std::map< std::string, TH1F * > hPullX_shst
Definition: CkfDebugger.h:208
int partner_det_not_fuond
Definition: CkfDebugger.h:246
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:236
Geom::Theta< float > thetaAtEntry() const
Definition: CkfDebugger.h:82
int seedWithDelta
Definition: CkfDebugger.h:231
std::map< std::string, TH1F * > hPullM_shst
Definition: CkfDebugger.h:215
const MeasurementEstimator * theChi2
Definition: CkfDebugger.h:102
int matched_not_found
Definition: CkfDebugger.h:244
unsigned int trackId() const
Definition: CkfDebugger.h:80
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:221
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:245
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:243
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:227
int glued_det_not_fuond
Definition: CkfDebugger.h:247
TH1F * hchi2seedAll
Definition: CkfDebugger.h:204
TrackerHitAssociator * hitAssociator
Definition: CkfDebugger.h:105
TH2F * hPullGPXvsGPY_shst
Definition: CkfDebugger.h:225
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:77
CkfDebugger(edm::EventSetup const &es, edm::ConsumesCollector &&iC)
Definition: CkfDebugger.cc:37
std::pair< double, double > computePulls(CTTRHp recHit, TSOS startingState)
Definition: CkfDebugger.h:185
TransientTrackingRecHit::ConstRecHitPointer CTTRHp
Definition: CkfDebugger.h:39
std::map< std::string, TH1F * > hPullX_shrh
Definition: CkfDebugger.h:206
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:220
#define LogTrace(id)
bool operator()(const PSimHit *a, const PSimHit *b)
Definition: CkfDebugger.h:258
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:239
Definition: DetId.h:18
ROOT::Math::SVector< double, D1 > Vector
std::map< std::string, TH1F * > hPullM_strh
Definition: CkfDebugger.h:217
float pabs() const
Definition: CkfDebugger.h:84
std::map< std::string, TH1F * > hPullS_shst
Definition: CkfDebugger.h:216
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:150
int simple_hit_not_found
Definition: CkfDebugger.h:241
Geom::Phi< float > phiAtEntry() const
Definition: CkfDebugger.h:83
std::map< std::pair< int, int >, int > dump2
Definition: CkfDebugger.h:197
double b
Definition: hdecay.h:120
std::map< std::string, TH1F * > hPullS_strh
Definition: CkfDebugger.h:218
unsigned short processType() const
Definition: PSimHit.h:118
TFile * file
Definition: CkfDebugger.h:203
unsigned int layer(const DetId &id) const
const TrackerGeometry * theTrackerGeom
Definition: CkfDebugger.h:99
const GeomDetUnit * det(const PSimHit *sh) const
Definition: CkfDebugger.h:150
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:109
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:207
TH2F * hPullGPXvsGPX_shst
Definition: CkfDebugger.h:224
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:210
int layer_not_found
Definition: CkfDebugger.h:235
LocalPoint localPosition() const
Definition: CkfDebugger.h:77
int no_component
Definition: CkfDebugger.h:242
TH2F * hPullGPXvsGPZ_shst
Definition: CkfDebugger.h:226
std::vector< int > dump
Definition: CkfDebugger.h:196
const PSimHit * pSimHit(unsigned int tkId, DetId detId)
Definition: CkfDebugger.cc:892
int layer(const GeomDet *det)
Definition: CkfDebugger.h:152
std::map< std::pair< int, int >, int > dump5
Definition: CkfDebugger.h:200
Global3DPoint position(const PSimHit *sh) const
Definition: CkfDebugger.h:147
LocalVector localDirection() const
Definition: CkfDebugger.h:81
std::map< unsigned int, std::vector< PSimHit * > > idHitsMap
Definition: CkfDebugger.h:111
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:204
unsigned int detUnitId() const
Definition: PSimHit.h:93
std::map< std::pair< int, int >, int > dump4
Definition: CkfDebugger.h:199
TH2F * hPullGPXvsGPphi_shst
Definition: CkfDebugger.h:229
int chi2gt30delta
Definition: CkfDebugger.h:238
std::map< std::pair< int, int >, int > dump3
Definition: CkfDebugger.h:198