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

std::vector< int > hittype
 
std::vector< int > m_det
 
std::vector< int > m_detector
 
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
 
std::array< std::vector< float >, 2 > res
 
std::vector< int > stereo
 
std::vector< int > substruct
 
std::vector< int > subsubstruct
 

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

Constructor & Destructor Documentation

◆ FWTrackResidualDetailView() [1/2]

FWTrackResidualDetailView::FWTrackResidualDetailView ( )

◆ ~FWTrackResidualDetailView()

FWTrackResidualDetailView::~FWTrackResidualDetailView ( )
override

Definition at line 40 of file FWTrackResidualDetailView.cc.

40 {}

◆ 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 97 of file FWTrackResidualDetailView.cc.

References change_name::diff, FWDetailViewBase::drawCanvasBox(), fwLog, h, hittype, ALPAKA_ACCELERATOR_NAMESPACE::ecal::reconstruction::internal::endcap::ix(), dqmiolumiharvest::j, dqmdumpme::k, fwlog::kError, MainPageGenerator::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_2024v13_cff::track, and ApeEstimator_cff::width.

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

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

Referenced by prepareData().

222  {
223  double local1[3] = {0, 0, 0};
224  double local2[3] = {resX, 0, 0};
225  double global1[3], global2[3];
226  const TGeoMatrix* m = geom->getMatrix(id);
227  assert(m != nullptr);
228  m->LocalToMaster(local1, global1);
229  m->LocalToMaster(local2, global2);
230  TVector3 g1 = global1;
231  TVector3 g2 = global2;
232  if (g2.DeltaPhi(g1) > 0)
233  return resX;
234  else
235  return -resX;
236 }
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 42 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_2024v13_cff::track, and reco::HitPattern::TRACK_HITS.

Referenced by build().

42  {
43  auto const& residuals = track->residuals();
44 
45  const FWGeometry* geom = id.item()->getGeom();
46  assert(geom != nullptr);
47 
48  const HitPattern& hitpat = track->hitPattern();
50  hittype.reserve(m_nhits);
51  stereo.reserve(m_nhits);
52  subsubstruct.reserve(m_nhits);
53  substruct.reserve(m_nhits);
54  m_detector.reserve(m_nhits);
55  res[0].reserve(m_nhits);
56  res[1].reserve(m_nhits);
57 
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.push_back(HitPattern::getHitType(pattern));
63  stereo.push_back(HitPattern::getSide(pattern));
64  subsubstruct.push_back(HitPattern::getSubSubStructure(pattern));
65  substruct.push_back(HitPattern::getSubStructure(pattern));
66  m_detector.push_back(HitPattern::getSubDetector(pattern));
67  if ((*(track->recHitsBegin() + i))->isValid()) {
68  res[0].push_back(
69  getSignedResidual(geom, (*(track->recHitsBegin() + i))->geographicalId().rawId(), residuals.pullX(i)));
70  } else {
71  res[0].push_back(0);
72  }
73  res[1].push_back(residuals.pullY(i));
74  // printf("%s, %i\n",m_det_tracker_str[substruct[i]-1],subsubstruct[i]);
75  }
76 
77  m_det[0] = 0;
78  for (int j = 0; j < m_nhits - 1;) {
79  int k = j + 1;
80  for (; k < m_nhits; k++) {
81  if (substruct[j] == substruct[k] && subsubstruct[j] == subsubstruct[k]) {
82  if (k == (m_nhits - 1))
83  j = k;
84  } else {
85  m_ndet++;
86  j = k;
87  m_det[m_ndet] = j;
88  break;
89  }
90  }
91  }
92  m_ndet++;
93  m_det[m_ndet] = m_nhits;
94  // printDebug();
95 }
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 238 of file FWTrackResidualDetailView.cc.

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

238  {
239  for (int i = 0; i < m_ndet; i++) {
240  std::cout << "<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<" << std::endl;
241  std::cout << "idx " << i << " det[idx] " << m_det[i] << std::endl;
242  std::cout << "m_det idx " << m_det[i] << std::endl;
243  std::cout << "m_det_tracker_str idx " << substruct[m_det[i]] - 1 << std::endl;
244  printf("m_det[idx] %i m_det_tracker_str %s substruct %i\n",
245  m_det[i],
247  subsubstruct[m_det[i]]);
248  }
249 }
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 251 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().

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

Member Data Documentation

◆ hittype

std::vector<int> FWTrackResidualDetailView::hittype
private

Definition at line 71 of file FWTrackResidualDetailView.h.

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

◆ m_det

std::vector<int> FWTrackResidualDetailView::m_det
private

Definition at line 69 of file FWTrackResidualDetailView.h.

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

◆ m_det_tracker_str

const char * FWTrackResidualDetailView::m_det_tracker_str = {"PXB", "PXF", "TIB", "TID", "TOB", "TEC"}
staticprivate

Definition at line 86 of file FWTrackResidualDetailView.h.

Referenced by build(), and printDebug().

◆ m_detector

std::vector<int> FWTrackResidualDetailView::m_detector
private

Definition at line 75 of file FWTrackResidualDetailView.h.

Referenced by prepareData().

◆ m_invalidCol

Color_t FWTrackResidualDetailView::m_invalidCol
private

Definition at line 84 of file FWTrackResidualDetailView.h.

Referenced by build(), and setTextInfo().

◆ m_invalidFill

Int_t FWTrackResidualDetailView::m_invalidFill
private

Definition at line 83 of file FWTrackResidualDetailView.h.

Referenced by build(), and setTextInfo().

◆ m_ndet

int FWTrackResidualDetailView::m_ndet
private

Definition at line 67 of file FWTrackResidualDetailView.h.

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

◆ m_nhits

int FWTrackResidualDetailView::m_nhits
private

Definition at line 68 of file FWTrackResidualDetailView.h.

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

◆ m_resXCol

Color_t FWTrackResidualDetailView::m_resXCol
private

Definition at line 78 of file FWTrackResidualDetailView.h.

Referenced by build(), and setTextInfo().

◆ m_resXFill

Int_t FWTrackResidualDetailView::m_resXFill
private

Definition at line 77 of file FWTrackResidualDetailView.h.

Referenced by build(), and setTextInfo().

◆ m_resYCol

Color_t FWTrackResidualDetailView::m_resYCol
private

Definition at line 80 of file FWTrackResidualDetailView.h.

Referenced by build(), and setTextInfo().

◆ m_resYFill

Int_t FWTrackResidualDetailView::m_resYFill
private

Definition at line 79 of file FWTrackResidualDetailView.h.

Referenced by build(), and setTextInfo().

◆ m_stereoCol

Color_t FWTrackResidualDetailView::m_stereoCol
private

Definition at line 82 of file FWTrackResidualDetailView.h.

Referenced by build(), and setTextInfo().

◆ m_stereoFill

Int_t FWTrackResidualDetailView::m_stereoFill
private

Definition at line 81 of file FWTrackResidualDetailView.h.

Referenced by build(), and setTextInfo().

◆ res

std::array<std::vector<float>, 2> FWTrackResidualDetailView::res
private

Definition at line 70 of file FWTrackResidualDetailView.h.

◆ stereo

std::vector<int> FWTrackResidualDetailView::stereo
private

Definition at line 72 of file FWTrackResidualDetailView.h.

Referenced by build(), and prepareData().

◆ substruct

std::vector<int> FWTrackResidualDetailView::substruct
private

Definition at line 73 of file FWTrackResidualDetailView.h.

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

◆ subsubstruct

std::vector<int> FWTrackResidualDetailView::subsubstruct
private

Definition at line 74 of file FWTrackResidualDetailView.h.

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