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