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 (const FWTrackResidualDetailView &)=delete
 
const FWTrackResidualDetailViewoperator= (const FWTrackResidualDetailView &)=delete
 
 ~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
 
 FWDetailViewBase (const FWDetailViewBase &)=delete
 
const FWEventItemitem ()
 
const FWDetailViewBaseoperator= (const FWDetailViewBase &)=delete
 
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
 
double getSignedResidual (const FWGeometry *geom, unsigned int id, double resX)
 
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() [1/2]

FWTrackResidualDetailView::FWTrackResidualDetailView ( )

Definition at line 28 of file FWTrackResidualDetailView.cc.

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

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  memset(m_det, 0, sizeof(m_det));
40  memset(res, 0, sizeof(res));
41  memset(hittype, 0, sizeof(hittype));
42  memset(stereo, 0, sizeof(stereo));
43  memset(substruct, 0, sizeof(substruct));
44  memset(subsubstruct, 0, sizeof(subsubstruct));
45  memset(m_detector, 0, sizeof(m_detector));
46 }
Definition: Electron.h:6

◆ ~FWTrackResidualDetailView()

FWTrackResidualDetailView::~FWTrackResidualDetailView ( )
override

Definition at line 48 of file FWTrackResidualDetailView.cc.

48 {}

◆ FWTrackResidualDetailView() [2/2]

FWTrackResidualDetailView::FWTrackResidualDetailView ( const FWTrackResidualDetailView )
delete

Member Function Documentation

◆ build()

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

Implements FWDetailView< reco::Track >.

Definition at line 96 of file FWTrackResidualDetailView.cc.

References change_name::diff, FWDetailViewBase::drawCanvasBox(), fwLog, h, hittype, dqmiolumiharvest::j, dqmdumpme::k, fwlog::kError, cmsLHEtoEOSManager::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(), DiDispStaMuonMonitor_cfi::pt, setTextInfo(), Validation_hcalonly_cfi::sign, stereo, substruct, subsubstruct, HLT_2022v11_cff::track, and ApeEstimator_cff::width.

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

◆ getSignedResidual()

double FWTrackResidualDetailView::getSignedResidual ( const FWGeometry geom,
unsigned int  id,
double  resX 
)
private

Definition at line 221 of file FWTrackResidualDetailView.cc.

References cms::cuda::assert(), diffTwoXMLs::g1, diffTwoXMLs::g2, relativeConstraints::geom, and visualization-live-secondInstance_cfg::m.

Referenced by prepareData().

221  {
222  double local1[3] = {0, 0, 0};
223  double local2[3] = {resX, 0, 0};
224  double global1[3], global2[3];
225  const TGeoMatrix* m = geom->getMatrix(id);
226  assert(m != nullptr);
227  m->LocalToMaster(local1, global1);
228  m->LocalToMaster(local2, global2);
229  TVector3 g1 = global1;
230  TVector3 g2 = global2;
231  if (g2.DeltaPhi(g1) > 0)
232  return resX;
233  else
234  return -resX;
235 }
assert(be >=bs)

◆ operator=()

const FWTrackResidualDetailView& FWTrackResidualDetailView::operator= ( const FWTrackResidualDetailView )
delete

◆ prepareData()

void FWTrackResidualDetailView::prepareData ( const FWModelId id,
const reco::Track track 
)
private

Definition at line 50 of file FWTrackResidualDetailView.cc.

References cms::cuda::assert(), relativeConstraints::geom, reco::HitPattern::getHitPattern(), getSignedResidual(), hittype, mps_fire::i, dqmiolumiharvest::j, dqmdumpme::k, m_det, m_detector, m_ndet, m_nhits, reco::HitPattern::numberOfAllHits(), topSingleLeptonDQM_PU_cfi::pattern, stereo, substruct, subsubstruct, HLT_2022v11_cff::track, and reco::HitPattern::TRACK_HITS.

Referenced by build().

50  {
51  auto const& residuals = track->residuals();
52 
53  const FWGeometry* geom = id.item()->getGeom();
54  assert(geom != nullptr);
55 
56  const HitPattern& hitpat = track->hitPattern();
58  for (int i = 0; i < m_nhits; ++i) {
59  //printf("there are %d hits in the pattern, %d in the vector, this is %u\n",
60  // m_nhits, track->recHitsEnd() - track->recHitsBegin(), (*(track->recHitsBegin() + i))->geographicalId().rawId());
62  hittype[i] = HitPattern::getHitType(pattern);
63  stereo[i] = HitPattern::getSide(pattern);
64  subsubstruct[i] = HitPattern::getSubSubStructure(pattern);
65  substruct[i] = HitPattern::getSubStructure(pattern);
66  m_detector[i] = HitPattern::getSubDetector(pattern);
67  if ((*(track->recHitsBegin() + i))->isValid()) {
68  res[0][i] = getSignedResidual(geom, (*(track->recHitsBegin() + i))->geographicalId().rawId(), residuals.pullX(i));
69  } else {
70  res[0][i] = 0;
71  }
72  res[1][i] = residuals.pullY(i);
73  // printf("%s, %i\n",m_det_tracker_str[substruct[i]-1],subsubstruct[i]);
74  }
75 
76  m_det[0] = 0;
77  for (int j = 0; j < m_nhits - 1;) {
78  int k = j + 1;
79  for (; k < m_nhits; k++) {
80  if (substruct[j] == substruct[k] && subsubstruct[j] == subsubstruct[k]) {
81  if (k == (m_nhits - 1))
82  j = k;
83  } else {
84  m_ndet++;
85  j = k;
86  m_det[m_ndet] = j;
87  break;
88  }
89  }
90  }
91  m_ndet++;
92  m_det[m_ndet] = m_nhits;
93  // printDebug();
94 }
int numberOfAllHits(HitCategory category) const
Definition: HitPattern.h:804
double getSignedResidual(const FWGeometry *geom, unsigned int id, double resX)
assert(be >=bs)
Definition: Electron.h:6
uint16_t getHitPattern(HitCategory category, int position) const
Definition: HitPattern.h:537

◆ printDebug()

void FWTrackResidualDetailView::printDebug ( )
private

Definition at line 237 of file FWTrackResidualDetailView.cc.

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

237  {
238  for (int i = 0; i < m_ndet; i++) {
239  std::cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl;
240  std::cout << "idx " << i << " det[idx] " << m_det[i] << std::endl;
241  std::cout << "m_det idx " << m_det[i] << std::endl;
242  std::cout << "m_det_tracker_str idx " << substruct[m_det[i]] - 1 << std::endl;
243  printf("m_det[idx] %i m_det_tracker_str %s substruct %i\n",
244  m_det[i],
246  subsubstruct[m_det[i]]);
247  }
248 }
static const char * m_det_tracker_str[]

◆ setTextInfo()

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

Implements FWDetailView< reco::Track >.

Definition at line 250 of file FWTrackResidualDetailView.cc.

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

Referenced by build().

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

Member Data Documentation

◆ hittype

int FWTrackResidualDetailView::hittype[64]
private

◆ m_det

int FWTrackResidualDetailView::m_det[64]
private

◆ m_det_tracker_str

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().

◆ m_detector

int FWTrackResidualDetailView::m_detector[64]
private

Definition at line 73 of file FWTrackResidualDetailView.h.

Referenced by FWTrackResidualDetailView(), and prepareData().

◆ m_invalidCol

Color_t FWTrackResidualDetailView::m_invalidCol
private

Definition at line 82 of file FWTrackResidualDetailView.h.

Referenced by build(), and setTextInfo().

◆ m_invalidFill

Int_t FWTrackResidualDetailView::m_invalidFill
private

Definition at line 81 of file FWTrackResidualDetailView.h.

Referenced by build(), and setTextInfo().

◆ m_ndet

int FWTrackResidualDetailView::m_ndet
private

Definition at line 65 of file FWTrackResidualDetailView.h.

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

◆ m_nhits

int FWTrackResidualDetailView::m_nhits
private

Definition at line 66 of file FWTrackResidualDetailView.h.

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

◆ m_resXCol

Color_t FWTrackResidualDetailView::m_resXCol
private

Definition at line 76 of file FWTrackResidualDetailView.h.

Referenced by build(), and setTextInfo().

◆ m_resXFill

Int_t FWTrackResidualDetailView::m_resXFill
private

Definition at line 75 of file FWTrackResidualDetailView.h.

Referenced by build(), and setTextInfo().

◆ m_resYCol

Color_t FWTrackResidualDetailView::m_resYCol
private

Definition at line 78 of file FWTrackResidualDetailView.h.

Referenced by build(), and setTextInfo().

◆ m_resYFill

Int_t FWTrackResidualDetailView::m_resYFill
private

Definition at line 77 of file FWTrackResidualDetailView.h.

Referenced by build(), and setTextInfo().

◆ m_stereoCol

Color_t FWTrackResidualDetailView::m_stereoCol
private

Definition at line 80 of file FWTrackResidualDetailView.h.

Referenced by build(), and setTextInfo().

◆ m_stereoFill

Int_t FWTrackResidualDetailView::m_stereoFill
private

Definition at line 79 of file FWTrackResidualDetailView.h.

Referenced by build(), and setTextInfo().

◆ res

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

Definition at line 68 of file FWTrackResidualDetailView.h.

◆ stereo

int FWTrackResidualDetailView::stereo[64]
private

Definition at line 70 of file FWTrackResidualDetailView.h.

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

◆ substruct

int FWTrackResidualDetailView::substruct[64]
private

◆ subsubstruct

int FWTrackResidualDetailView::subsubstruct[64]
private