CMS 3D CMS Logo

List of all members | Public Member Functions | Private Member Functions | Private Attributes | Static Private Attributes
FWTrackResidualDetailView Class Reference

#include <FWTrackResidualDetailView.h>

Inheritance diagram for FWTrackResidualDetailView:
FWDetailViewCanvas< reco::Track > FWDetailView< reco::Track > FWDetailViewBase

Public Member Functions

 FWTrackResidualDetailView ()
 
 ~FWTrackResidualDetailView () override
 
- Public Member Functions inherited from FWDetailViewCanvas< reco::Track >
 FWDetailViewCanvas ()
 
void init (TEveWindowSlot *) override
 
 ~FWDetailViewCanvas () override
 
- Public Member Functions inherited from FWDetailView< reco::Track >
void build (const FWModelId &iID, const void *iData) override
 
 FWDetailView ()
 
- Public Member Functions inherited from FWDetailViewBase
void build (const FWModelId &)
 
const fireworks::Contextcontext () const
 
const FWEventItemitem ()
 
virtual void setBackgroundColor (Color_t col)
 
void setItem (const FWEventItem *x)
 
virtual ~FWDetailViewBase ()
 

Private Member Functions

void build (const FWModelId &id, const reco::Track *) override
 
 FWTrackResidualDetailView (const FWTrackResidualDetailView &)=delete
 
double getSignedResidual (const FWGeometry *geom, unsigned int id, double resX)
 
const FWTrackResidualDetailViewoperator= (const FWTrackResidualDetailView &)=delete
 
void prepareData (const FWModelId &id, const reco::Track *)
 
void printDebug ()
 
void setTextInfo (const FWModelId &id, const reco::Track *) override
 

Private Attributes

int hittype [64]
 
int m_det [64]
 
int m_detector [64]
 
Color_t m_invalidCol
 
Int_t m_invalidFill
 
int m_ndet
 
int m_nhits
 
Color_t m_resXCol
 
Int_t m_resXFill
 
Color_t m_resYCol
 
Int_t m_resYFill
 
Color_t m_stereoCol
 
Int_t m_stereoFill
 
float res [2][64]
 
int stereo [64]
 
int substruct [64]
 
int subsubstruct [64]
 

Static Private Attributes

static const char * m_det_tracker_str [] ={"PXB","PXF","TIB","TID","TOB","TEC"}
 

Additional Inherited Members

- Static Public Member Functions inherited from FWDetailView< reco::Track >
static std::string classRegisterTypeName ()
 
static std::string classTypeName ()
 
- Static Public Member Functions inherited from FWDetailViewBase
static void drawCanvasBox (Double_t *pos, Color_t fillCol, Int_t fillType=0, bool bg=kTRUE)
 
static void drawCanvasDot (Float_t x, Float_t y, Float_t r, Color_t)
 
- Protected Member Functions inherited from FWDetailViewBase
 FWDetailViewBase (const std::type_info &)
 
- Protected Attributes inherited from FWDetailViewCanvas< reco::Track >
TGCompositeFrame * m_guiFrame
 
TCanvas * m_infoCanvas
 
TCanvas * m_viewCanvas
 

Detailed Description

Definition at line 47 of file FWTrackResidualDetailView.h.

Constructor & Destructor Documentation

FWTrackResidualDetailView::FWTrackResidualDetailView ( )

Definition at line 28 of file FWTrackResidualDetailView.cc.

References hittype, m_det, m_detector, stereo, substruct, and subsubstruct.

28  :
29  m_ndet(0),
30  m_nhits(0),
31  m_resXFill(3007),
32  m_resXCol(kGreen-9),
33  m_resYFill(3006),
34  m_resYCol(kWhite),
35  m_stereoFill(3004),
36  m_stereoCol(kCyan-9),
37  m_invalidFill(3001),
38  m_invalidCol(kRed)
39 {
40  memset(m_det, 0, sizeof(m_det));
41  memset(res, 0, sizeof(res));
42  memset(hittype, 0, sizeof(hittype));
43  memset(stereo, 0, sizeof(stereo));
44  memset(substruct, 0, sizeof(substruct));
45  memset(subsubstruct, 0, sizeof(subsubstruct));
46  memset(m_detector, 0, sizeof(m_detector));
47 }
Definition: Electron.h:6
FWTrackResidualDetailView::~FWTrackResidualDetailView ( )
override

Definition at line 49 of file FWTrackResidualDetailView.cc.

50 {
51 }
FWTrackResidualDetailView::FWTrackResidualDetailView ( const FWTrackResidualDetailView )
privatedelete

Member Function Documentation

void FWTrackResidualDetailView::build ( const FWModelId id,
const reco::Track track 
)
overrideprivatevirtual

Implements FWDetailView< reco::Track >.

Definition at line 104 of file FWTrackResidualDetailView.cc.

References create_public_lumi_plots::color, diffTreeTool::diff, FWDetailViewBase::drawCanvasBox(), reco::Track::extra(), fwLog, h, hittype, edm::Ref< C, T, F >::isAvailable(), gen::k, fwlog::kError, checklumidiff::l, groupFilesInBlocks::lines, m_det, m_det_tracker_str, m_invalidCol, m_invalidFill, m_ndet, m_nhits, m_resXCol, m_resXFill, m_resYCol, m_resYFill, m_stereoCol, m_stereoFill, FWDetailViewCanvas< reco::Track >::m_viewCanvas, prepareData(), EnergyCorrector::pt, setTextInfo(), Validation_hcalonly_cfi::sign, stereo, substruct, subsubstruct, and ApeEstimator_cff::width.

105 {
106  if (!track->extra().isAvailable()) {
107  fwLog(fwlog::kError) << " no track extra information is available.\n";
108  m_viewCanvas->cd();
109  TLatex* latex = new TLatex();
110  latex->SetTextSize(0.1);
111  latex->DrawLatex(0.1, 0.5, "No track extra information");
112  return;
113  }
114  prepareData(id, track);
115 
116  // draw histogram
117  m_viewCanvas->cd();
118  m_viewCanvas->SetHighLightColor(-1);
119  TH2F* h_res = new TH2F("h_resx","h_resx",10,-5.5,5.5,m_ndet,0,m_ndet);
120  TPad* padX = new TPad("pad1","pad1", 0.2, 0., 0.8, 0.99);
121  padX->SetBorderMode(0);
122  padX->SetLeftMargin(0.2);
123  padX->Draw();
124  padX->cd();
125  padX->SetFrameLineWidth(0);
126  padX->Modified();
127  h_res->SetDirectory(nullptr);
128  h_res->SetStats(kFALSE);
129  h_res->SetTitle("");
130  h_res->SetXTitle("residual");
131  h_res->GetXaxis()->SetTickLength(0);
132  h_res->GetYaxis()->SetTickLength(0);
133  h_res->GetXaxis()->SetNdivisions(20);
134  h_res->GetYaxis()->SetLabelSize(0.06);
135  h_res->Draw();
136  padX->SetGridy();
137 
138  float larray[9]={0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.5, 4.5, 5.5};
139  float larray2[8];
140  for(int l=0; l<8; l++) {
141  float diff2=(larray[l+1]-larray[l])/2;
142  larray2[l]=larray[l]+diff2;
143  // printf("(%.1f,%.1f),",larray[i],larray[i+1]);
144  }
145 
146  int resi[2][64];
147  for(int l=0; l<m_nhits; l++) {
148  for(int k=0; k<8; k++) {
149  if(fabs(res[0][l])==larray2[k])
150  resi[0][l]=k;
151  if(fabs(res[1][l])==larray2[k])
152  resi[1][l]=k;
153  }
154  }
155 
156  TLine* lines[17];
157  for(int l=0; l<17; l++) {
158  int ix=l%9;
159  int sign=1;
160  sign = (l>8) ? -1 : 1;
161  lines[l] = new TLine(sign*larray[ix],0,sign*larray[ix],m_ndet);
162  if(l!=9)
163  lines[l]->SetLineStyle(3);
164  padX->cd();
165  lines[l]->Draw();
166  }
167 
168  float width=0.25;
169  int filltype;
170  Color_t color;
171  Double_t box[4];
172  padX->cd();
173 
174  for(int h=0; h<2; h++) {
175  float height1=0;
176  for(int j=0; j<m_ndet; j++) {
177  // take only X res and Y pixel residals
178  if (strcmp(m_det_tracker_str[substruct[m_det[j]]-1], "PXB") && h)
179  continue;
180 
181  char det_str2[256];
182  snprintf(det_str2, 255, "%s/%i",m_det_tracker_str[substruct[m_det[j]]-1],subsubstruct[m_det[j]]);
183  h_res->GetYaxis()->SetBinLabel(j+1, det_str2);
184 
185  int diff=m_det[j+1]-m_det[j];
186  int k=0;
187  width=1.0/diff;
188 
189  for(int l=m_det[j]; l<(m_det[j]+diff); l++) {
190  // g->SetPoint(l,resx[l],j+0.5);
191  // printf("%i, %f %f %f\n",l,resx[l],sign*larray[resxi[l]],sign*larray[resxi[l]+1]);
192  int sign = (res[h][l]<0) ? -1 : 1;
193  box[0] = (hittype[l]==0) ? sign*larray[resi[h][l]] : -5.5;
194  box[2] = (hittype[l]==0) ? sign*larray[resi[h][l]+1] : 5.5;
195  box[1] = height1+width*k;
196  box[3] = height1+width*(k+1);
197 
198  if(stereo[l]==1) {
199  color = m_stereoCol;
200  filltype = m_stereoFill;
201  }
202  else if(hittype[l]!=0) {
203  color = m_invalidCol;
204  filltype = m_invalidFill;
205  }
206  else {
207  filltype = h ? m_resYFill : m_resXFill;
208  color = h ? m_resYCol : m_resXCol;
209  }
210 
211  drawCanvasBox(box, color, filltype, h<1);
212  k++;
213  }
214  height1 +=1;
215  }
216  }
217 
218  // title
219  const char* res_str= "residuals in Si detector local x-y coord.";
220  TPaveText *pt = new TPaveText(0.0,0.91, 1,0.99,"blNDC");
221  pt->SetBorderSize(0);
222  pt->SetFillColor(kWhite);
223  pt->AddText(res_str);
224  pt->Draw();
225 
226  m_viewCanvas->cd();
227  m_viewCanvas->SetEditable(kFALSE);
228 
229  setTextInfo(id, track);
230 }
bool isAvailable() const
Definition: Ref.h:575
FWCore Framework interface EventSetupRecordImplementation h
Helper function to determine trigger accepts.
const TrackExtraRef & extra() const
reference to "extra" object
Definition: Track.h:194
void setTextInfo(const FWModelId &id, const reco::Track *) override
Definition: Electron.h:6
int k[5][pyjets_maxn]
#define fwLog(_level_)
Definition: fwLog.h:50
void prepareData(const FWModelId &id, const reco::Track *)
static const char * m_det_tracker_str[]
static void drawCanvasBox(Double_t *pos, Color_t fillCol, Int_t fillType=0, bool bg=kTRUE)
double FWTrackResidualDetailView::getSignedResidual ( const FWGeometry geom,
unsigned int  id,
double  resX 
)
private

Definition at line 233 of file FWTrackResidualDetailView.cc.

References diffTwoXMLs::g1, diffTwoXMLs::g2, FWGeometry::getMatrix(), and funct::m.

Referenced by prepareData().

234 {
235  double local1[3] = { 0, 0, 0 };
236  double local2[3] = { resX, 0, 0 };
237  double global1[3], global2[3];
238  const TGeoMatrix *m = geom->getMatrix(id);
239  assert(m != nullptr);
240  m->LocalToMaster(local1, global1);
241  m->LocalToMaster(local2, global2);
242  TVector3 g1 = global1;
243  TVector3 g2 = global2;
244  if (g2.DeltaPhi(g1) > 0)
245  return resX;
246  else return -resX;
247 }
const TGeoMatrix * getMatrix(unsigned int id) const
Definition: FWGeometry.cc:186
const FWTrackResidualDetailView& FWTrackResidualDetailView::operator= ( const FWTrackResidualDetailView )
privatedelete
void FWTrackResidualDetailView::prepareData ( const FWModelId id,
const reco::Track track 
)
private

Definition at line 54 of file FWTrackResidualDetailView.cc.

References relativeConstraints::geom, reco::HitPattern::getHitPattern(), getSignedResidual(), reco::TrackBase::hitPattern(), hittype, mps_fire::i, gen::k, m_det, m_detector, m_ndet, m_nhits, reco::HitPattern::numberOfAllHits(), listBenchmarks::pattern, reco::Track::recHitsBegin(), reco::Track::residuals(), stereo, substruct, subsubstruct, and reco::HitPattern::TRACK_HITS.

Referenced by build().

55 {
56  auto const & residuals = track->residuals();
57 
58  const FWGeometry *geom = id.item()->getGeom();
59  assert(geom != nullptr);
60 
61  const HitPattern &hitpat = track->hitPattern();
63  for (int i = 0; i < m_nhits; ++i) {
64  //printf("there are %d hits in the pattern, %d in the vector, this is %u\n",
65  // m_nhits, track->recHitsEnd() - track->recHitsBegin(), (*(track->recHitsBegin() + i))->geographicalId().rawId());
67  hittype[i] = HitPattern::getHitType(pattern);
68  stereo[i] = HitPattern::getSide(pattern);
69  subsubstruct[i] = HitPattern::getSubSubStructure(pattern);
70  substruct[i] = HitPattern::getSubStructure(pattern);
71  m_detector[i] = HitPattern::getSubDetector(pattern);
72  if ((*(track->recHitsBegin() + i))->isValid()) {
73  res[0][i] = getSignedResidual(geom,
74  (*(track->recHitsBegin() + i))->geographicalId().rawId(),
75  residuals.pullX(i));
76  } else {
77  res[0][i] = 0;
78  }
79  res[1][i] = residuals.pullY(i);
80  // printf("%s, %i\n",m_det_tracker_str[substruct[i]-1],subsubstruct[i]);
81  }
82 
83  m_det[0]=0;
84  for(int j=0; j < m_nhits-1;) {
85  int k=j+1;
86  for(; k<m_nhits ; k++) {
87  if(substruct[j]==substruct[k] && subsubstruct[j]==subsubstruct[k]) {
88  if(k==(m_nhits-1)) j=k;
89  }
90  else {
91  m_ndet++;
92  j=k;
93  m_det[m_ndet]=j;
94  break;
95  }
96  }
97  }
98  m_ndet++;
100  // printDebug();
101 }
double getSignedResidual(const FWGeometry *geom, unsigned int id, double resX)
Definition: Electron.h:6
int numberOfAllHits(HitCategory category) const
Definition: HitPattern.h:875
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:109
int k[5][pyjets_maxn]
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:485
const TrackResiduals & residuals() const
get the residuals
Definition: Track.h:223
uint16_t getHitPattern(HitCategory category, int position) const
Definition: HitPattern.h:553
void FWTrackResidualDetailView::printDebug ( )
private

Definition at line 250 of file FWTrackResidualDetailView.cc.

References gather_cfg::cout, mps_fire::i, m_det, m_det_tracker_str, m_ndet, substruct, and subsubstruct.

251 {
252  for(int i=0; i<m_ndet; i++)
253  {
254  std::cout <<"<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl;
255  std::cout << "idx " << i << " det[idx] " << m_det[i] << std::endl;
256  std::cout << "m_det idx " << m_det[i] << std::endl;
257  std::cout << "m_det_tracker_str idx " << substruct[m_det[i]]-1 << std::endl;
258  printf("m_det[idx] %i m_det_tracker_str %s substruct %i\n",m_det[i], m_det_tracker_str[substruct[m_det[i]]-1], subsubstruct[m_det[i]]);
259  }
260 }
static const char * m_det_tracker_str[]
void FWTrackResidualDetailView::setTextInfo ( const FWModelId id,
const reco::Track  
)
overrideprivatevirtual

Implements FWDetailView< reco::Track >.

Definition at line 263 of file FWTrackResidualDetailView.cc.

References FWDetailViewBase::drawCanvasBox(), create_public_lumi_plots::fontsize, hittype, mps_fire::i, FWDetailViewCanvas< reco::Track >::m_infoCanvas, m_invalidCol, m_invalidFill, m_ndet, m_nhits, m_resXCol, m_resXFill, m_resYCol, m_resYFill, m_stereoCol, m_stereoFill, REGISTER_FWDETAILVIEW, substruct, and y.

Referenced by build().

264 {
265  m_infoCanvas->cd();
266 
267  char mytext[256];
268  Double_t fontsize = 0.07;
269  TLatex* latex = new TLatex();
270  latex->SetTextSize(fontsize);
271  latex->Draw();
272  Double_t x0 = 0.02;
273  Double_t y = 0.95;
274 
275  // summary
276  int nvalid=0;
277  int npix=0;
278  int nstrip=0;
279  for(int i=0; i<m_nhits; i++)
280  {
281  if(hittype[i]==0) nvalid++;
282  if(substruct[i]<3) npix++;
283  else nstrip++;
284  }
285 
286  latex->SetTextSize(fontsize);
287  Double_t boxH = 0.25*fontsize;
288 
289  double yStep = 0.04;
290 
291  latex->DrawLatex(x0, y, "Residual:");
292  y-= yStep;
293  latex->DrawLatex(x0, y, "sgn(#hat{X}#bullet#hat{#phi}) #times #frac{X_{hit} - X_{traj}}{#sqrt{#sigma^{2}_{hit} + #sigma^{2}_{traj}}}" );
294  y-= 2.5*yStep;
295  snprintf(mytext, 255, "layers hit: %i", m_ndet);
296  latex->DrawLatex(x0, y, mytext);
297  y -= yStep;
298  snprintf(mytext, 255,"valid Si hits: %i", nvalid);
299  latex->DrawLatex(x0, y, mytext);
300  y -= yStep;
301  snprintf(mytext, 255,"total Si hits: %i", m_nhits);
302  latex->DrawLatex(x0, y, mytext);
303  y -= yStep;
304  snprintf(mytext, 255,"valid Si pixel hits: %i", npix);
305  latex->DrawLatex(x0, y, mytext);
306  y -= yStep;
307  snprintf(mytext, 255, "valid Si strip hits: %i", nstrip);
308  latex->DrawLatex(x0, y, mytext);
309 
310 
311  Double_t pos[4];
312  pos[0] = 0.4;
313  pos[2] = 0.55;
314 
315  y -= yStep*2;
316  latex->DrawLatex(x0, y, "X hit");
317  pos[1] = y; pos[3] = pos[1] + boxH;
319 
320  y -= yStep;
321  latex->DrawLatex(x0, y, "Y hit");
322  pos[1] = y; pos[3] = pos[1] + boxH;
323  drawCanvasBox(pos, m_resYCol, m_resYFill, false);
324 
325  y -= yStep;
326  latex->DrawLatex(x0, y, "stereo hit");
327  pos[1] = y; pos[3] = pos[1] + boxH;
329 
330  y -= yStep;
331  latex->DrawLatex(x0, y, "invalid hit");
332  pos[1] = y; pos[3] = pos[1] + boxH;
334 }
static void drawCanvasBox(Double_t *pos, Color_t fillCol, Int_t fillType=0, bool bg=kTRUE)

Member Data Documentation

int FWTrackResidualDetailView::hittype[64]
private
int FWTrackResidualDetailView::m_det[64]
private
const char * FWTrackResidualDetailView::m_det_tracker_str ={"PXB","PXF","TIB","TID","TOB","TEC"}
staticprivate

Definition at line 84 of file FWTrackResidualDetailView.h.

Referenced by build(), and printDebug().

int FWTrackResidualDetailView::m_detector[64]
private

Definition at line 73 of file FWTrackResidualDetailView.h.

Referenced by FWTrackResidualDetailView(), and prepareData().

Color_t FWTrackResidualDetailView::m_invalidCol
private

Definition at line 82 of file FWTrackResidualDetailView.h.

Referenced by build(), and setTextInfo().

Int_t FWTrackResidualDetailView::m_invalidFill
private

Definition at line 81 of file FWTrackResidualDetailView.h.

Referenced by build(), and setTextInfo().

int FWTrackResidualDetailView::m_ndet
private

Definition at line 65 of file FWTrackResidualDetailView.h.

Referenced by build(), prepareData(), printDebug(), and setTextInfo().

int FWTrackResidualDetailView::m_nhits
private

Definition at line 66 of file FWTrackResidualDetailView.h.

Referenced by build(), prepareData(), and setTextInfo().

Color_t FWTrackResidualDetailView::m_resXCol
private

Definition at line 76 of file FWTrackResidualDetailView.h.

Referenced by build(), and setTextInfo().

Int_t FWTrackResidualDetailView::m_resXFill
private

Definition at line 75 of file FWTrackResidualDetailView.h.

Referenced by build(), and setTextInfo().

Color_t FWTrackResidualDetailView::m_resYCol
private

Definition at line 78 of file FWTrackResidualDetailView.h.

Referenced by build(), and setTextInfo().

Int_t FWTrackResidualDetailView::m_resYFill
private

Definition at line 77 of file FWTrackResidualDetailView.h.

Referenced by build(), and setTextInfo().

Color_t FWTrackResidualDetailView::m_stereoCol
private

Definition at line 80 of file FWTrackResidualDetailView.h.

Referenced by build(), and setTextInfo().

Int_t FWTrackResidualDetailView::m_stereoFill
private

Definition at line 79 of file FWTrackResidualDetailView.h.

Referenced by build(), and setTextInfo().

float FWTrackResidualDetailView::res[2][64]
private

Definition at line 68 of file FWTrackResidualDetailView.h.

int FWTrackResidualDetailView::stereo[64]
private

Definition at line 70 of file FWTrackResidualDetailView.h.

Referenced by build(), FWTrackResidualDetailView(), and prepareData().

int FWTrackResidualDetailView::substruct[64]
private
int FWTrackResidualDetailView::subsubstruct[64]
private