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 
22 
29 
30 #include <vector>
31 #include <iostream>
32 #include <TFile.h>
33 #include <TH1F.h>
34 #include <TH2F.h>
35 
36 class Trajectory;
38 class PSimHit;
40 class MeasurementTracker;
42 class MagneticField;
44 class Propagator;
45 
47 
48 class CkfDebugger {
49  public:
50  CkfDebugger( edm::EventSetup const & es );
51 
52  ~CkfDebugger();
53 
54  void printSimHits( const edm::Event& iEvent);
55 
56  void countSeed(){totSeeds++;}
57 
59  //edm::LogVerbatim("CkfDebugger") << "CkfDebugger::fillSeedHist";
60  hchi2seedAll->Fill( testSeed(h1,h2,t) );
61  }
62 
64  const std::vector<TrajectoryMeasurement>&,
65  const MeasurementTracker*,
66  const Propagator*,
69 
71  delete hitAssociator;
72  }
73 
74  private:
77 
78  class SimHit {
79  public:
80 
81  SimHit( const PSimHit* phit, const GeomDetUnit* gdu) : thePHit( phit), theDet(gdu) {}
84  const GeomDetUnit* det() const {return theDet;}
85  unsigned int trackId() const {return thePHit->trackId();}
89  float pabs() const {return thePHit->pabs();}
90  float timeOfFlight() const {return thePHit->timeOfFlight();}
91  float energyLoss() const {return thePHit->energyLoss();}
92  int particleType() const {return thePHit->particleType();}
93  unsigned int detUnitId() const {return thePHit->detUnitId();}
94  unsigned short processType() const {return thePHit->processType();}
95  const PSimHit& psimHit() const { return *thePHit;}
96 
97  private:
98 
99  const PSimHit* thePHit;
101 
102  };
103 
112 
113  std::map<unsigned int, std::vector<PSimHit*> > idHitsMap;
114 
115  void dumpSimHit( const SimHit& hit) const;
116 
117  bool correctTrajectory( const Trajectory&, unsigned int&) const;
118 
119  int assocTrackId(CTTRHp rechit) const;
120 
121  //const PSimHit* nextCorrectHit( const Trajectory&, unsigned int&) ;
122  std::vector<const PSimHit*> nextCorrectHits( const Trajectory&, unsigned int&) ;
123 
124  bool associated(CTTRHp rechit, const PSimHit& sh) const;
125 
126  bool goodSimHit(const PSimHit& sh) const;
127 
128  bool correctMeas( const TM& tm, const PSimHit* correctHit) const;
129 
130  std::pair<CTTRHp, double> analyseRecHitExistance( const PSimHit& sh, const TSOS& startingState);
131 
133 
135 
136  const PSimHit* pSimHit(unsigned int tkId, DetId detId);
137 
138  bool hasDelta(const PSimHit* correctHit){
139  bool delta = false;
140  for (std::vector<PSimHit>::iterator isim = hitAssociator->SimHitMap[correctHit->detUnitId()].begin();
141  isim != hitAssociator->SimHitMap[correctHit->detUnitId()].end(); ++isim){
142 /* edm::LogVerbatim("CkfDebugger") << "SimHit on this det at pos="<< position(&*isim) */
143 /* << " det=" << isim->detUnitId() << " process=" << isim->processType() ; */
144  if (isim->processType() == 9) delta = true;
145  }
146  return delta;
147  }
148 
149  Global3DPoint position(const PSimHit* sh) const {
151  };
152  const GeomDetUnit* det(const PSimHit* sh) const {return theTrackerGeom->idToDetUnit(DetId(sh->detUnitId()));};
153 
154  int layer(const GeomDetUnit* det){
155  //return ((int)(((det->geographicalId().rawId() >>16) & 0xF)));
156  DetId id=det->geographicalId();
157  if (id.subdetId()==3) return ((TIBDetId)(id)).layer();
158  if (id.subdetId()==5) return ((TOBDetId)(id)).layer();
159  if (id.subdetId()==1) return ((PXBDetId)(id)).layer();
160  if (id.subdetId()==4) return ((TIDDetId)(id)).wheel();
161  if (id.subdetId()==6) return ((TECDetId)(id)).wheel();
162  if (id.subdetId()==2) return ((PXFDetId)(id)).disk();
163  return 0;
164  }
165  int layer(const GeomDet* det){
166  //return ((int)(((det->geographicalId().rawId() >>16) & 0xF)));
167  DetId id=det->geographicalId();
168  if (id.subdetId()==3) return ((TIBDetId)(id)).layer();
169  if (id.subdetId()==5) return ((TOBDetId)(id)).layer();
170  if (id.subdetId()==1) return ((PXBDetId)(id)).layer();
171  if (id.subdetId()==4) return ((TIDDetId)(id)).wheel();
172  if (id.subdetId()==6) return ((TECDetId)(id)).wheel();
173  if (id.subdetId()==2) return ((PXFDetId)(id)).disk();
174  return 0;
175  }
176 
177  template<unsigned int D>
178  std::pair<double,double> computePulls(CTTRHp recHit, TSOS startingState){
179  typedef typename AlgebraicROOTObject<D>::Vector VecD;
180  typedef typename AlgebraicROOTObject<D,D>::SymMatrix SMatDD;
181  TSOS detState = theForwardPropagator->propagate(startingState,recHit->det()->surface());
182  LogTrace("CkfDebugger") << "parameters=" << recHit->parameters() ;
183  LogTrace("CkfDebugger") << "parametersError=" << recHit->parametersError() ;
184  MeasurementExtractor me(detState);
185  VecD r = asSVector<D>(recHit->parameters()) - me.measuredParameters<D>(*recHit);
186  LogTrace("CkfDebugger") << "me.measuredParameters=" << me.measuredParameters<D>(*recHit) ;
187  LogTrace("CkfDebugger") << "me.measuredError=" << me.measuredError<D>(*recHit) ;
188  SMatDD R = asSMatrix<D>(recHit->parametersError()) + me.measuredError<D>(*recHit);
189  LogTrace("CkfDebugger") << "r=" << r ;
190  LogTrace("CkfDebugger") << "R=" << R ;
191  R.Invert();
192  LogTrace("CkfDebugger") << "R(-1)=" << R ;
193  LogTrace("CkfDebugger") << "chi2=" << ROOT::Math::Similarity(r,R) ;
194  double pullX=(-r[0])*sqrt(R(0,0));
195  double r_1 = 0;
196  if ( VecD::Dim() >= 2 )
197  {
198  r_1 = r[1];
199  }
200  double pullY=(-r_1)*sqrt(R(1,1));
201  LogTrace("CkfDebugger") << "pullX=" << pullX ;
202  LogTrace("CkfDebugger") << "pullY=" << pullY ;
203  return std::pair<double,double>(pullX,pullY);
204  }
205  std::pair<double,double> computePulls(CTTRHp recHit, TSOS startingState) {
206  switch (recHit->dimension()) {
207  case 1: return computePulls<1>(recHit,startingState);
208  case 2: return computePulls<2>(recHit,startingState);
209  case 3: return computePulls<3>(recHit,startingState);
210  case 4: return computePulls<4>(recHit,startingState);
211  case 5: return computePulls<5>(recHit,startingState);
212  }
213  throw cms::Exception("CkfDebugger error: rechit of dimension not 1,2,3,4,5");
214  }
215 
216  std::vector<int> dump;
217  std::map<std::pair<int,int>, int> dump2;
218  std::map<std::pair<int,int>, int> dump3;
219  std::map<std::pair<int,int>, int> dump4;
220  std::map<std::pair<int,int>, int> dump5;
221  std::map<std::pair<int,int>, int> dump6;
222 
223  TFile* file;
225 
226  std::map<std::string,TH1F*> hPullX_shrh;
227  std::map<std::string,TH1F*> hPullY_shrh;
228  std::map<std::string,TH1F*> hPullX_shst;
229  std::map<std::string,TH1F*> hPullY_shst;
230  std::map<std::string,TH1F*> hPullX_strh;
231  std::map<std::string,TH1F*> hPullY_strh;
232 
233  std::map<std::string,TH1F*> hPullM_shrh;
234  std::map<std::string,TH1F*> hPullS_shrh;
235  std::map<std::string,TH1F*> hPullM_shst;
236  std::map<std::string,TH1F*> hPullS_shst;
237  std::map<std::string,TH1F*> hPullM_strh;
238  std::map<std::string,TH1F*> hPullS_strh;
239 
240  std::map<std::string,TH1F*> hPullGP_X_shst;
241  std::map<std::string,TH1F*> hPullGP_Y_shst;
242  std::map<std::string,TH1F*> hPullGP_Z_shst;
243 
250 
252  int problems;
254  int no_layer;
257  int chi2gt30;
260  int chi2ls30;
269  int other;
271 
272  int totSeeds;
273 };
274 
275 class less_mag : public std::binary_function<PSimHit*, PSimHit*, bool> {
276  public:
277  less_mag(){ }
278  bool operator()(const PSimHit* a,const PSimHit* b) {
279  return
280  ( a->timeOfFlight()< b->timeOfFlight() );
281  }
282 };
283 
284 #endif
AlgebraicSymMatrix measuredError(const TransientTrackingRecHit &)
dbl * delta
Definition: mlp_gen.cc:36
unsigned short processType() const
Definition: CkfDebugger.h:94
GlobalPoint globalPosition() const
Definition: CkfDebugger.h:83
std::map< std::string, TH1F * > hPullS_shrh
Definition: CkfDebugger.h:234
bool hasDelta(const PSimHit *correctHit)
Definition: CkfDebugger.h:138
std::pair< CTTRHp, double > analyseRecHitExistance(const PSimHit &sh, const TSOS &startingState)
Definition: CkfDebugger.cc:669
std::map< std::string, TH1F * > hPullY_shst
Definition: CkfDebugger.h:229
bool correctMeas(const TM &tm, const PSimHit *correctHit) const
Definition: CkfDebugger.cc:623
void printSimHits(const edm::Event &iEvent)
Definition: CkfDebugger.cc:145
std::map< std::pair< int, int >, int > dump6
Definition: CkfDebugger.h:221
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:110
const PSimHit * thePHit
Definition: CkfDebugger.h:99
std::pair< double, double > computePulls(CTTRHp recHit, TSOS startingState)
Definition: CkfDebugger.h:178
TH2F * hPullGPXvsGPeta_shst
Definition: CkfDebugger.h:248
void dumpSimHit(const SimHit &hit) const
Definition: CkfDebugger.cc:174
const MagneticField * theMagField
Definition: CkfDebugger.h:105
unsigned int detUnitId() const
Definition: CkfDebugger.h:93
const TransientTrackingRecHitBuilder * theTTRHBuilder
Definition: CkfDebugger.h:111
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:242
const GeometricSearchTracker * theGeomSearchTracker
Definition: CkfDebugger.h:106
const PSimHit & psimHit() const
Definition: CkfDebugger.h:95
float timeOfFlight() const
Definition: CkfDebugger.h:90
std::map< std::string, TH1F * > hPullY_strh
Definition: CkfDebugger.h:231
std::map< std::string, TH1F * > hPullM_shrh
Definition: CkfDebugger.h:233
void deleteHitAssociator()
Definition: CkfDebugger.h:70
std::map< std::string, TH1F * > hPullX_shst
Definition: CkfDebugger.h:228
int partner_det_not_fuond
Definition: CkfDebugger.h:266
std::vector< const PSimHit * > nextCorrectHits(const Trajectory &, unsigned int &)
Definition: CkfDebugger.cc:518
void countSeed()
Definition: CkfDebugger.h:56
TrajectoryMeasurement TM
Definition: CkfDebugger.h:75
int det_not_found
Definition: CkfDebugger.h:256
Geom::Theta< float > thetaAtEntry() const
Definition: CkfDebugger.h:87
int seedWithDelta
Definition: CkfDebugger.h:251
std::map< std::string, TH1F * > hPullM_shst
Definition: CkfDebugger.h:235
const MeasurementEstimator * theChi2
Definition: CkfDebugger.h:107
int matched_not_found
Definition: CkfDebugger.h:264
unsigned int trackId() const
Definition: CkfDebugger.h:85
CkfDebugger(edm::EventSetup const &es)
Definition: CkfDebugger.cc:35
int analyseRecHitNotFound(const Trajectory &, CTTRHp)
Definition: CkfDebugger.cc:891
int iEvent
Definition: GenABIO.cc:243
std::map< std::string, TH1F * > hPullGP_Y_shst
Definition: CkfDebugger.h:241
int layer(const GeomDetUnit *det)
Definition: CkfDebugger.h:154
float timeOfFlight() const
Definition: PSimHit.h:69
double testSeed(CTTRHp, CTTRHp, TrajectoryStateOnSurface)
Definition: CkfDebugger.cc:976
int particleType() const
Definition: CkfDebugger.h:92
int matched_not_associated
Definition: CkfDebugger.h:265
Local3DPoint localPosition() const
Definition: PSimHit.h:44
const GeomDetUnit * theDet
Definition: CkfDebugger.h:100
bool associated(CTTRHp rechit, const PSimHit &sh) const
Definition: CkfDebugger.cc:603
int only_one_component
Definition: CkfDebugger.h:263
T sqrt(T t)
Definition: SSEVec.h:46
int assocTrackId(CTTRHp rechit) const
Definition: CkfDebugger.cc:500
TH2F * hPullGPXvsGPr_shst
Definition: CkfDebugger.h:247
int glued_det_not_fuond
Definition: CkfDebugger.h:267
TH1F * hchi2seedAll
Definition: CkfDebugger.h:224
TrackerHitAssociator * hitAssociator
Definition: CkfDebugger.h:109
TH2F * hPullGPXvsGPY_shst
Definition: CkfDebugger.h:245
DetId geographicalId() const
The label of this GeomDet.
Definition: GeomDet.h:72
std::pair< double, double > computePulls(CTTRHp recHit, TSOS startingState)
Definition: CkfDebugger.h:205
TransientTrackingRecHit::ConstRecHitPointer CTTRHp
Definition: CkfDebugger.h:44
std::map< std::string, TH1F * > hPullX_shrh
Definition: CkfDebugger.h:226
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:81
std::map< std::string, TH1F * > hPullGP_X_shst
Definition: CkfDebugger.h:240
#define LogTrace(id)
bool operator()(const PSimHit *a, const PSimHit *b)
Definition: CkfDebugger.h:278
void fillSeedHist(CTTRHp h1, CTTRHp h2, TrajectoryStateOnSurface t)
Definition: CkfDebugger.h:58
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:84
const Propagator * theForwardPropagator
Definition: CkfDebugger.h:108
bool correctTrajectory(const Trajectory &, unsigned int &) const
Definition: CkfDebugger.cc:458
int chi2gt30deltaSeed
Definition: CkfDebugger.h:259
Definition: DetId.h:20
ROOT::Math::SVector< double, D1 > Vector
std::map< std::string, TH1F * > hPullM_strh
Definition: CkfDebugger.h:237
float pabs() const
Definition: CkfDebugger.h:89
std::map< std::string, TH1F * > hPullS_shst
Definition: CkfDebugger.h:236
DecomposeProduct< arg, typename Div::arg > D
Definition: Factorize.h:150
int simple_hit_not_found
Definition: CkfDebugger.h:261
Geom::Phi< float > phiAtEntry() const
Definition: CkfDebugger.h:88
AlgebraicVector measuredParameters(const TransientTrackingRecHit &)
std::map< std::pair< int, int >, int > dump2
Definition: CkfDebugger.h:217
double b
Definition: hdecay.h:120
std::map< std::string, TH1F * > hPullS_strh
Definition: CkfDebugger.h:238
unsigned short processType() const
Definition: PSimHit.h:118
TFile * file
Definition: CkfDebugger.h:223
virtual const GeomDetUnit * idToDetUnit(DetId) const
Return the pointer to the GeomDetUnit corresponding to a given DetId.
const TrackerGeometry * theTrackerGeom
Definition: CkfDebugger.h:104
const GeomDetUnit * det(const PSimHit *sh) const
Definition: CkfDebugger.h:152
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:596
double a
Definition: hdecay.h:121
float energyLoss() const
Definition: CkfDebugger.h:91
std::map< std::string, TH1F * > hPullY_shrh
Definition: CkfDebugger.h:227
TH2F * hPullGPXvsGPX_shst
Definition: CkfDebugger.h:244
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:230
int layer_not_found
Definition: CkfDebugger.h:255
LocalPoint localPosition() const
Definition: CkfDebugger.h:82
int no_component
Definition: CkfDebugger.h:262
TH2F * hPullGPXvsGPZ_shst
Definition: CkfDebugger.h:246
std::vector< int > dump
Definition: CkfDebugger.h:216
const PSimHit * pSimHit(unsigned int tkId, DetId detId)
Definition: CkfDebugger.cc:879
int layer(const GeomDet *det)
Definition: CkfDebugger.h:165
std::map< std::pair< int, int >, int > dump5
Definition: CkfDebugger.h:220
Global3DPoint position(const PSimHit *sh) const
Definition: CkfDebugger.h:149
LocalVector localDirection() const
Definition: CkfDebugger.h:86
std::map< unsigned int, std::vector< PSimHit * > > idHitsMap
Definition: CkfDebugger.h:113
TrajectoryStateOnSurface TSOS
Definition: CkfDebugger.h:76
bool analyseCompatibleMeasurements(const Trajectory &, const std::vector< TrajectoryMeasurement > &, const MeasurementTracker *, const Propagator *, const Chi2MeasurementEstimatorBase *, const TransientTrackingRecHitBuilder *)
Definition: CkfDebugger.cc:186
TH1F * hchi2seedProb
Definition: CkfDebugger.h:224
unsigned int detUnitId() const
Definition: PSimHit.h:93
std::map< std::pair< int, int >, int > dump4
Definition: CkfDebugger.h:219
TH2F * hPullGPXvsGPphi_shst
Definition: CkfDebugger.h:249
int chi2gt30delta
Definition: CkfDebugger.h:258
std::map< std::pair< int, int >, int > dump3
Definition: CkfDebugger.h:218