CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 ()
 
virtual ~FWTrackResidualDetailView ()
 
- Public Member Functions inherited from FWDetailViewCanvas< reco::Track >
 FWDetailViewCanvas ()
 
virtual void init (TEveWindowSlot *)
 
virtual ~FWDetailViewCanvas ()
 
- Public Member Functions inherited from FWDetailView< reco::Track >
virtual void build (const FWModelId &iID, const void *iData)
 
 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

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

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 46 of file FWTrackResidualDetailView.h.

Constructor & Destructor Documentation

FWTrackResidualDetailView::FWTrackResidualDetailView ( )

Definition at line 28 of file FWTrackResidualDetailView.cc.

References hittype, m_det, m_detector, res, 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 }
FWTrackResidualDetailView::~FWTrackResidualDetailView ( )
virtual

Definition at line 49 of file FWTrackResidualDetailView.cc.

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

Member Function Documentation

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

Implements FWDetailView< reco::Track >.

Definition at line 102 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(), j, gen::k, fwlog::kError, prof2calltree::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(), RecoTauCleanerPlugins::pt, res, setTextInfo(), stereo, substruct, subsubstruct, and create_public_lumi_plots::width.

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

Definition at line 231 of file FWTrackResidualDetailView.cc.

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

Referenced by prepareData().

232 {
233  double local1[3] = { 0, 0, 0 };
234  double local2[3] = { resX, 0, 0 };
235  double global1[3], global2[3];
236  const TGeoMatrix *m = geom->getMatrix(id);
237  assert(m != 0);
238  m->LocalToMaster(local1, global1);
239  m->LocalToMaster(local2, global2);
240  TVector3 g1 = global1;
241  TVector3 g2 = global2;
242  if (g2.DeltaPhi(g1) > 0)
243  return resX;
244  else return -resX;
245 }
const TGeoMatrix * getMatrix(unsigned int id) const
Definition: FWGeometry.cc:166
const FWTrackResidualDetailView& FWTrackResidualDetailView::operator= ( const FWTrackResidualDetailView )
private
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, i, j, gen::k, m_det, m_detector, m_ndet, m_nhits, reco::HitPattern::numberOfHits(), reco::Track::recHitsBegin(), res, reco::Track::residuals(), reco::TrackResiduals::residualX(), reco::TrackResiduals::residualY(), stereo, substruct, and subsubstruct.

Referenced by build().

55 {
56  HitPattern hitpat = track->hitPattern();
57  TrackResiduals residuals = track->residuals();
58 
59  const FWGeometry *geom = id.item()->getGeom();
60  assert(geom != 0);
61  m_nhits=hitpat.numberOfHits();
62  for (int i = 0; i < m_nhits; ++i) {
63  // printf("there are %d hits in the pattern, %d in the vector, this is %u\n",
64  // m_nhits, track->recHitsEnd() - track->recHitsBegin(), (*(track->recHitsBegin() + i))->geographicalId().rawId());
65  hittype[i] = 0x3 & hitpat.getHitPattern(i);
66  stereo[i] = 0x1 & hitpat.getHitPattern(i) >> 2;
67  subsubstruct[i] = 0xf & hitpat.getHitPattern(i) >> 3;
68  substruct[i] = 0x7 & hitpat.getHitPattern(i) >> 7;
69  m_detector[i] = 0x01 & hitpat.getHitPattern(i) >> 10;
70  if ((*(track->recHitsBegin() + i))->isValid()) {
71  res[0][i] = getSignedResidual(geom,
72  (*(track->recHitsBegin() + i))->geographicalId().rawId(),
73  residuals.residualX(i, hitpat));
74  } else {
75  res[0][i] = 0;
76  }
77  res[1][i] = residuals.residualY(i, hitpat);
78  // printf("%s, %i\n",m_det_tracker_str[substruct[i]-1],subsubstruct[i]);
79  }
80 
81  m_det[0]=0;
82  for(int j=0; j < m_nhits-1;) {
83  int k=j+1;
84  for(; k<m_nhits ; k++) {
85  if(substruct[j]==substruct[k] && subsubstruct[j]==subsubstruct[k]) {
86  if(k==(m_nhits-1)) j=k;
87  }
88  else {
89  m_ndet++;
90  j=k;
91  m_det[m_ndet]=j;
92  break;
93  }
94  }
95  }
96  m_ndet++;
98  // printDebug();
99 }
int i
Definition: DBlmapReader.cc:9
double getSignedResidual(const FWGeometry *geom, unsigned int id, double resX)
double residualY(int i, const HitPattern &) const
int numberOfHits() const
Definition: HitPattern.cc:211
int j
Definition: DBlmapReader.cc:9
trackingRecHit_iterator recHitsBegin() const
Iterator to first hit on the track.
Definition: Track.h:63
const HitPattern & hitPattern() const
Access the hit pattern, indicating in which Tracker layers the track has hits.
Definition: TrackBase.h:221
int k[5][pyjets_maxn]
double residualX(int i, const HitPattern &) const
const TrackResiduals & residuals() const
Definition: Track.h:117
uint32_t getHitPattern(int position) const
Definition: HitPattern.cc:142
void FWTrackResidualDetailView::printDebug ( )
private

Definition at line 248 of file FWTrackResidualDetailView.cc.

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

249 {
250  for(int i=0; i<m_ndet; i++)
251  {
252  std::cout <<"<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl;
253  std::cout << "idx " << i << " det[idx] " << m_det[i] << std::endl;
254  std::cout << "m_det idx " << m_det[i] << std::endl;
255  std::cout << "m_det_tracker_str idx " << substruct[m_det[i]]-1 << std::endl;
256  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]]);
257  }
258 }
int i
Definition: DBlmapReader.cc:9
tuple cout
Definition: gather_cfg.py:121
static const char * m_det_tracker_str[]
void FWTrackResidualDetailView::setTextInfo ( const FWModelId id,
const reco::Track  
)
privatevirtual

Implements FWDetailView< reco::Track >.

Definition at line 261 of file FWTrackResidualDetailView.cc.

References FWDetailViewBase::drawCanvasBox(), hittype, 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, substruct, detailsBasic3DVector::y, and beampixel_dqm_sourceclient-live_cfg::yStep.

Referenced by build().

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

Referenced by build(), and printDebug().

int FWTrackResidualDetailView::m_detector[64]
private

Definition at line 72 of file FWTrackResidualDetailView.h.

Referenced by FWTrackResidualDetailView(), and prepareData().

Color_t FWTrackResidualDetailView::m_invalidCol
private

Definition at line 81 of file FWTrackResidualDetailView.h.

Referenced by build(), and setTextInfo().

Int_t FWTrackResidualDetailView::m_invalidFill
private

Definition at line 80 of file FWTrackResidualDetailView.h.

Referenced by build(), and setTextInfo().

int FWTrackResidualDetailView::m_ndet
private

Definition at line 64 of file FWTrackResidualDetailView.h.

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

int FWTrackResidualDetailView::m_nhits
private

Definition at line 65 of file FWTrackResidualDetailView.h.

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

Color_t FWTrackResidualDetailView::m_resXCol
private

Definition at line 75 of file FWTrackResidualDetailView.h.

Referenced by build(), and setTextInfo().

Int_t FWTrackResidualDetailView::m_resXFill
private

Definition at line 74 of file FWTrackResidualDetailView.h.

Referenced by build(), and setTextInfo().

Color_t FWTrackResidualDetailView::m_resYCol
private

Definition at line 77 of file FWTrackResidualDetailView.h.

Referenced by build(), and setTextInfo().

Int_t FWTrackResidualDetailView::m_resYFill
private

Definition at line 76 of file FWTrackResidualDetailView.h.

Referenced by build(), and setTextInfo().

Color_t FWTrackResidualDetailView::m_stereoCol
private

Definition at line 79 of file FWTrackResidualDetailView.h.

Referenced by build(), and setTextInfo().

Int_t FWTrackResidualDetailView::m_stereoFill
private

Definition at line 78 of file FWTrackResidualDetailView.h.

Referenced by build(), and setTextInfo().

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

Definition at line 67 of file FWTrackResidualDetailView.h.

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

int FWTrackResidualDetailView::stereo[64]
private

Definition at line 69 of file FWTrackResidualDetailView.h.

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

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