Analysis Software
Documentation for sPHENIX simulation software
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AnaMvtxPrototype1.C
Go to the documentation of this file. Or view the newest version in sPHENIX GitHub for file AnaMvtxPrototype1.C
1 
7 #include "AnaMvtxPrototype1.h"
8 
9 #include <trackbase/TrkrDefUtil.h>
10 #include <trackbase/TrkrCluster.h>
12 
13 #include <mvtxprototype1/MvtxStandaloneTracking.h>
14 
15 #include <phool/getClass.h>
16 #include <phool/phool.h>
17 #include <phool/PHCompositeNode.h>
18 #include <phool/PHIODataNode.h>
19 #include <phool/PHNodeIterator.h>
20 
21 #include <fun4all/Fun4AllServer.h>
23 #include <fun4all/PHTFileServer.h>
24 
25 #include <TTree.h>
26 #include <TFile.h>
27 #include <TLorentzVector.h>
28 #include <TH1.h>
29 #include <TH2.h>
30 #include <TVectorD.h>
31 #include <TMatrixD.h>
32 #include <TDecompSVD.h>
33 
34 #include <iostream>
35 #include <map>
36 #include <utility>
37 #include <vector>
38 #include <memory>
39 
40 
41 
42 #define LogDebug(exp) std::cout<<"DEBUG: " <<__FILE__<<": "<<__LINE__<<": "<< exp <<"\n"
43 #define LogError(exp) std::cout<<"ERROR: " <<__FILE__<<": "<<__LINE__<<": "<< exp <<"\n"
44 #define LogWarning(exp) std::cout<<"WARNING: " <<__FILE__<<": "<<__LINE__<<": "<< exp <<"\n"
45 
46 
48  const std::string &ofName) :
49  SubsysReco(name),
50  clusters_(NULL),
51  _foutname(ofName),
52  _f(NULL),
53  _ievent(0)
54 {
55 
56  hlayer = NULL;
57  for (int il = 0; il < 4; il++)
58  {
59  hsize[il] = NULL;
60  hsize_phi[il] = NULL;
61  hsize_z[il] = NULL;
62  hxz[il] = NULL;
63  hdx[il] = NULL;
64  hdz[il] = NULL;
65  }
66 
71 }
72 
74 {
75 
76  //-- Open file
77  _f = new TFile(_foutname.c_str(), "RECREATE");
78 
79  //-- Initialize histograms
80  hlayer = new TH1D("hlayer", ";layer", 6, -0.5, 5.5);
81 
82  for (int il = 0; il < 4; il++)
83  {
84  hsize[il] = new TH1D(Form("hsize_l%i", il),
85  ";cluster size total [pixels]",
86  100, -0.5, 99.5);
87 
88  hsize_phi[il] = new TH1D(Form("hsize_phi_l%i", il),
89  ";cluster size #phi [pixels]",
90  100, -0.5, 99.5);
91 
92  hsize_z[il] = new TH1D(Form("hsize_z_l%i", il),
93  ";cluster size z [pixels]",
94  100, -0.5, 100.5);
95 
96  hxz[il] = new TH2D(Form("hxz_l%i", il),
97  ";z;x",
98  1024, -0.5, 1023.5,
99  512, -0.5, 511.5);
100 
101  hdx[il] = new TH1D(Form("hdx_l%i", il),
102  "; dx [pixels]",
103  2000, -500, 500);
104 
105  hdz[il] = new TH1D(Form("hdz_l%i", il),
106  "; dz [pixels]",
107  2000, -500, 500);
108  } // il
109 
110  //-- results from tracking
111  htrk = new TH1D("htrk", ";trks / event", 16, -0.5, 15.5);
112  htrk_cut = new TH1D("htrk_cut", ";trks / event", 16, -0.5, 15.5);
113 
114  for (int il = 0; il < 4; il++)
115  {
116  htrk_dx[il] = new TH1D(Form("htrk_dx_l%i", il),
117  ";track dx [pixels]",
118  500, -25, 25);
119 
120  htrk_dz[il] = new TH1D(Form("htrk_dz_l%i", il),
121  ";track dz [pixels]",
122  500, -25, 25);
123 
124  htrk_cut_dx[il] = new TH1D(Form("htrk_cut_dx_l%i", il),
125  ";track dx [pixels]",
126  500, -25, 25);
127 
128  htrk_cut_dz[il] = new TH1D(Form("htrk_cut_dz_l%i", il),
129  ";track dz [pixels]",
130  500, -25, 25);
131 
132  }
133  htrk_chi2xy = new TH1D("htrk_chi2xy",
134  ";track chi2/ndf in x vs y",
135  500, 0, 100);
136  htrk_chi2zy = new TH1D("htrk_chi2zy",
137  ";track chi2/ndf in z vs y",
138  500, 0, 100);
139 
140  htrk_cut_chi2xy = new TH1D("htrk_cut_chi2xy",
141  ";track chi2/ndf in x vs y",
142  500, 0, 100);
143  htrk_cut_chi2zy = new TH1D("htrk_cut_chi2zy",
144  ";track chi2/ndf in z vs y",
145  500, 0, 100);
146 
147  return 0;
148 
149 }
150 
152 {
153 
154  //-- set counters
155  _ievent = -1; // since we count at the beginning of the event, start at -1
156 
157 
158  return 0;
159 
160 }
161 
163 {
164 
165  if ( verbosity > VERBOSITY_MORE )
166  std::cout << "AnaMvtxPrototype1::process_event()" << std::endl;
167 
168  // count event
169  _ievent++;
170 
171  //------
172  //-- Get the nodes
173  //------
174  int retval = GetNodes(topNode);
175  if ( retval != Fun4AllReturnCodes::EVENT_OK )
176  return retval;
177 
178  if ( verbosity > VERBOSITY_MORE )
179  {
180  std::cout << "-- evnt:" << _ievent << std::endl;
181  std::cout << "-- Nclus:" << clusters_->size() << std::endl;
182  }
183 
184  //------
185  //-- Misalign clusters
186  //------
187  // Misalign();
188 
189  //------
190  //-- Loop over clusters
191  //------
192 
193  if ( verbosity > VERBOSITY_MORE )
194  std::cout << "-- Looping over clusters" << std::endl;
195 
196  LyrClusMap _mmap_lyr_clus;
197 
198  TrkrDefUtil trkrutil;
199 
200  TrkrClusterContainer::ConstRange clusrange = clusters_->GetClusters();
201  for (TrkrClusterContainer::ConstIterator iter = clusrange.first;
202  iter != clusrange.second;
203  ++iter)
204  {
205  TrkrCluster *clus = iter->second;
206  // clus->identify();
207 
208  TrkrDefs::cluskey ckey = clus->GetClusKey();
209 
210  int lyr = trkrutil.GetLayer(ckey);
211 
212  hlayer->Fill(lyr);
213 
214  if (lyr < 0 || lyr > 3)
215  continue;
216  hsize[lyr]->Fill(clus->GetAdc());
217  hsize_phi[lyr]->Fill(clus->GetPhiSize());
218  hsize_z[lyr]->Fill(clus->GetZSize());
219  hxz[lyr]->Fill(clus->GetZ(), clus->GetX());
220 
221  // insert into map
222  _mmap_lyr_clus.insert(std::make_pair(lyr, clus));
223  }
224 
225  if ( verbosity > VERBOSITY_MORE )
226  std::cout << "-- _mmap_lyr_clus.size():" << _mmap_lyr_clus.size() << std::endl;
227 
228  //------
229  //-- Simple tracking
230  //------
231 
232  if ( verbosity > VERBOSITY_MORE )
233  std::cout << "-- Performing simple tracking" << std::endl;
234 
235  static bool check_range = true;
236  if ( check_range )
237  {
238  TrkrDefs::cluskey mvtxl = trkrutil.GetClusKeyLo(TrkrDefs::TRKRID::mvtx_id);
239  TrkrDefs::cluskey mvtxh = trkrutil.GetClusKeyHi(TrkrDefs::TRKRID::mvtx_id);
240 
241  std::cout << PHWHERE << " Mvtx key range: 0x" << std::hex << mvtxl << " - 0x" << mvtxh << std::dec << std::endl;
242 
243  for (int i = 0; i < 4; i++)
244  {
245  TrkrDefs::cluskey lyrl = trkrutil.GetClusKeyLo(TrkrDefs::TRKRID::mvtx_id, i);
246  TrkrDefs::cluskey lyrh = trkrutil.GetClusKeyHi(TrkrDefs::TRKRID::mvtx_id, i);
247 
248  std::cout << PHWHERE << " Mvtx key range lyr " << i << ": 0x" << std::hex << lyrl << " - 0x" << lyrh << std::dec << std::endl;
249  }
250 
251  check_range = false;
252  }
253 
254 
255  // loop over clusters in layer 0
256  TrkrClusterContainer::ConstRange lyr0range = clusters_->GetClusters(TrkrDefs::TRKRID::mvtx_id, 0);
257  for ( TrkrClusterContainer::ConstIterator lyr0_itr = lyr0range.first;
258  lyr0_itr != lyr0range.second;
259  ++lyr0_itr)
260  {
261  TrkrCluster* clus0 = lyr0_itr->second;
262 
263  if ( !clus0 )
264  {
265  std::cout << "WARNING: clus0 not found" << std::endl;
266  continue;
267  }
268 
269  // check layer
270  int lyr = trkrutil.GetLayer(clus0->GetClusKey());
271  if ( lyr != 0 )
272  {
273  std::cout << PHWHERE << "ERRORL: Expected clusters from layer 0 only. Found lyr=" << lyr << std::endl;
274  continue;
275  }
276 
277 
278 
279  auto misiter = _misalign.find(0);
280  // get (x, y, z)
281  double x0 = misiter != _misalign.end() ? clus0->GetX() + (misiter->second).dx : clus0->GetX();
282  double y0 = misiter != _misalign.end() ? clus0->GetY() + (misiter->second).dy : clus0->GetY();
283  double z0 = misiter != _misalign.end() ? clus0->GetZ() + (misiter->second).dz : clus0->GetZ();
284 
285  if ( verbosity > VERBOSITY_MORE )
286  {
287  std::cout << "-- clus0:(" << x0 << ", " << y0 << ", " << z0 << ")" << std::endl;
288  }
289 
290  // loop over all clusters in the outer layer
291  TrkrClusterContainer::ConstRange lyr3range = clusters_->GetClusters(TrkrDefs::TRKRID::mvtx_id, 3);
292  for ( TrkrClusterContainer::ConstIterator lyr3_itr = lyr3range.first;
293  lyr3_itr != lyr3range.second;
294  ++lyr3_itr)
295  {
296  TrkrCluster* clus3 = lyr3_itr->second;
297 
298  if ( !clus3 )
299  {
300  std::cout << "WARNING: clus3 not found" << std::endl;
301  continue;
302  }
303 
304  auto misiter = _misalign.find(3);
305  // get (x, y, z)
306  double x3 = misiter != _misalign.end() ? clus3->GetX() + (misiter->second).dx : clus3->GetX();
307  double y3 = misiter != _misalign.end() ? clus3->GetY() + (misiter->second).dy : clus3->GetY();
308  double z3 = misiter != _misalign.end() ? clus3->GetZ() + (misiter->second).dz : clus3->GetZ();
309 
310 
311  // calc m, b in (phi, r) space
312  double mpr = CalcSlope(y0, x0, y3, x3);
313  double bpr = CalcIntecept(y0, x0, mpr);
314 
315  // calc m, b in (z, r) space
316  double mzr = CalcSlope(y0, z0, y3, z3);
317  double bzr = CalcIntecept(y0, z0, mzr);
318 
319 
320  if ( verbosity > VERBOSITY_MORE )
321  {
322  std::cout << "-- clus3:(" << x3 << ", " << y3 << ", " << z3 << ")" << std::endl;
323  std::cout << "-- mpr:" << mpr << " bpr:" << bpr << std::endl;
324  std::cout << "-- mzr:" << mzr << " bzr:" << bzr << std::endl;
325  }
326 
327 
328 
329  // loop over all clusters in layer 1 & 2 and calc displacement
330  for (int ilyr = 1; ilyr <= 2; ilyr++)
331  {
332  TrkrClusterContainer::ConstRange lyrrange = clusters_->GetClusters(TrkrDefs::TRKRID::mvtx_id, ilyr);
333  for ( TrkrClusterContainer::ConstIterator lyr_itr = lyrrange.first;
334  lyr_itr != lyrrange.second;
335  ++lyr_itr)
336  {
337  TrkrCluster* clus = lyr_itr->second;
338 
339  if ( !clus )
340  continue;
341 
342  auto misiter = _misalign.find(ilyr);
343  // get (x, y, z)
344  double x = misiter != _misalign.end() ? clus->GetX() + (misiter->second).dx : clus->GetX();
345  double y = misiter != _misalign.end() ? clus->GetY() + (misiter->second).dy : clus->GetY();
346  double z = misiter != _misalign.end() ? clus->GetZ() + (misiter->second).dz : clus->GetZ();
347 
348 
349  // calc track projection in phi, z
350  double x_proj = CalcProjection(y, mpr, bpr);
351  double z_proj = CalcProjection(y, mzr, bzr);
352 
353  // calc proj - true
354  double dx = (x_proj - x);
355  double dz = (z_proj - z);
356 
357  if ( !hdx[ilyr] || !hdz[ilyr] )
358  {
359  std::cout << "WARNING!! can't find hdphi or hdz for lyr:" << ilyr << std::endl;
360  }
361  else
362  {
363  hdx[ilyr]->Fill(dx);
364  hdz[ilyr]->Fill(dz);
365  }
366 
367  if ( verbosity > VERBOSITY_MORE )
368  {
369  std::cout << "------------------" << std::endl;
370  std::cout << "-- clus" << trkrutil.GetLayer(clus->GetClusKey()) << ":(" << x3 << ", " << y3 << ", " << z3 << ")" << std::endl;
371  std::cout << "-- proj:(" << x_proj << ", " << z_proj << ")" << std::endl;
372  std::cout << "-- dx [pixels]: " << dx << std::endl;
373  std::cout << "-- dz [pixels]: " << dz << std::endl;
374  std::cout << "------------------" << std::endl;
375  }
376 
377  } // lyr1_itr
378  } // ilyr;
379 
380  } // lyr3_itr
381 
382  } //lyr0_itr
383 
384  // // loop over clusters in layer 0
385  // LyrClusMap::iterator lyr0_itr;
386  // LyrClusMap::iterator lyr_itr;
387  // LyrClusMap::iterator lyr3_itr;
388  // for ( lyr0_itr = _mmap_lyr_clus.lower_bound(0);
389  // lyr0_itr != _mmap_lyr_clus.upper_bound(0);
390  // ++lyr0_itr)
391  // {
392  // TrkrCluster* clus0 = lyr0_itr->second;
393 
394  // if ( !clus0 )
395  // {
396  // std::cout << "WARNING: clus0 not found" << std::endl;
397  // continue;
398  // }
399  // auto misiter = _misalign.find(0);
400  // // get (x, y, z)
401  // double x0 = misiter != _misalign.end() ? clus0->GetX() + (misiter->second).dx : clus0->GetX();
402  // double y0 = misiter != _misalign.end() ? clus0->GetY() + (misiter->second).dy : clus0->GetY();
403  // double z0 = misiter != _misalign.end() ? clus0->GetZ() + (misiter->second).dz : clus0->GetZ();
404 
405  // if ( verbosity > VERBOSITY_MORE )
406  // {
407  // std::cout << "-- clus0:(" << x0 << ", " << y0 << ", " << z0 << ")" << std::endl;
408  // }
409 
410  // // loop over all clusters in the outer layer
411  // for ( lyr3_itr = _mmap_lyr_clus.lower_bound(3);
412  // lyr3_itr != _mmap_lyr_clus.upper_bound(3);
413  // ++lyr3_itr)
414  // {
415  // TrkrCluster* clus3 = lyr3_itr->second;
416 
417  // if ( !clus3 )
418  // {
419  // std::cout << "WARNING: clus3 not found" << std::endl;
420  // continue;
421  // }
422 
423  // auto misiter = _misalign.find(3);
424  // // get (x, y, z)
425  // double x3 = misiter != _misalign.end() ? clus3->GetX() + (misiter->second).dx : clus3->GetX();
426  // double y3 = misiter != _misalign.end() ? clus3->GetY() + (misiter->second).dy : clus3->GetY();
427  // double z3 = misiter != _misalign.end() ? clus3->GetZ() + (misiter->second).dz : clus3->GetZ();
428 
429 
430  // // calc m, b in (phi, r) space
431  // double mpr = CalcSlope(y0, x0, y3, x3);
432  // double bpr = CalcIntecept(y0, x0, mpr);
433 
434  // // calc m, b in (z, r) space
435  // double mzr = CalcSlope(y0, z0, y3, z3);
436  // double bzr = CalcIntecept(y0, z0, mzr);
437 
438 
439  // if ( verbosity > VERBOSITY_MORE )
440  // {
441  // std::cout << "-- clus3:(" << x3 << ", " << y3 << ", " << z3 << ")" << std::endl;
442  // std::cout << "-- mpr:" << mpr << " bpr:" << bpr << std::endl;
443  // std::cout << "-- mzr:" << mzr << " bzr:" << bzr << std::endl;
444  // }
445 
446 
447 
448  // // loop over all clusters in layer 1 & 2 and calc displacement
449  // for (int ilyr = 1; ilyr <= 2; ilyr++)
450  // {
451  // for ( lyr_itr = _mmap_lyr_clus.lower_bound(ilyr);
452  // lyr_itr != _mmap_lyr_clus.upper_bound(ilyr);
453  // ++lyr_itr)
454  // {
455  // TrkrCluster* clus = lyr_itr->second;
456 
457  // if ( !clus )
458  // continue;
459 
460  // auto misiter = _misalign.find(ilyr);
461  // // get (x, y, z)
462  // double x = misiter != _misalign.end() ? clus->GetX() + (misiter->second).dx : clus->GetX();
463  // double y = misiter != _misalign.end() ? clus->GetY() + (misiter->second).dy : clus->GetY();
464  // double z = misiter != _misalign.end() ? clus->GetZ() + (misiter->second).dz : clus->GetZ();
465 
466 
467  // // calc track projection in phi, z
468  // double x_proj = CalcProjection(y, mpr, bpr);
469  // double z_proj = CalcProjection(y, mzr, bzr);
470 
471  // // calc proj - true
472  // double dx = (x_proj - x);
473  // double dz = (z_proj - z);
474 
475  // if ( !hdx[ilyr] || !hdz[ilyr] )
476  // {
477  // std::cout << "WARNING!! can't find hdphi or hdz for lyr:" << ilyr << std::endl;
478  // }
479  // else
480  // {
481  // hdx[ilyr]->Fill(dx);
482  // hdz[ilyr]->Fill(dz);
483  // }
484 
485  // if ( verbosity > VERBOSITY_MORE )
486  // {
487  // std::cout << "------------------" << std::endl;
488  // std::cout << "-- clus" << trkrutil.GetLayer(clus->GetClusKey()) << ":(" << x3 << ", " << y3 << ", " << z3 << ")" << std::endl;
489  // std::cout << "-- proj:(" << x_proj << ", " << z_proj << ")" << std::endl;
490  // std::cout << "-- dx [pixels]: " << dx << std::endl;
491  // std::cout << "-- dz [pixels]: " << dz << std::endl;
492  // std::cout << "------------------" << std::endl;
493  // }
494 
495  // } // lyr1_itr
496  // } // ilyr;
497 
498  // } // lyr3_itr
499 
500  // } //lyr0_itr
501 
502 
503  if ( verbosity > VERBOSITY_MORE )
504  std::cout << "-- Done simple tracking" << std::endl;
505 
506 
507 
508  // //------
509  // //-- Track candidates using all layers
510  // //------
511 
512  // LyrClusMap::iterator lyr_itr;
513  // TrkVec _vec_trk;
514  // ClusVec _trk_candidate;
515 
516  // for ( lyr_itr = _mmap_lyr_clus.lower_bound(0);
517  // lyr_itr != _mmap_lyr_clus.upper_bound(0);
518  // ++lyr_itr)
519  // {
520  // TrkrCluster* clus0 = lyr_itr->second;
521 
522  // }
523 
524 
525  //------
526  // Try full tracking
527  //------
529 
530  std::vector<int> uselayers;
531  uselayers.push_back(0);
532  uselayers.push_back(1);
533  uselayers.push_back(2);
534  uselayers.push_back(3);
535 
536  mvtxtracking_->RunTracking(topNode, tracklist, uselayers);
537 
538  htrk->Fill(tracklist.size());
539 
540  int ncut = 0;
541  for ( unsigned int i = 0; i < tracklist.size(); i++)
542  {
543 
544  htrk_chi2xy->Fill(tracklist.at(i).chi2_xy);
545  htrk_chi2zy->Fill(tracklist.at(i).chi2_zy);
546 
547  if ( tracklist.at(i).chi2_xy < 5 && tracklist.at(i).chi2_zy < 5)
548  {
549  ncut++;
550  htrk_cut_chi2xy->Fill(tracklist.at(i).chi2_xy);
551  htrk_cut_chi2zy->Fill(tracklist.at(i).chi2_zy);
552  }
553 
554  for ( unsigned int j = 0; j < tracklist.at(i).ClusterList.size(); j++)
555  {
556  TrkrDefs::cluskey ckey = tracklist.at(i).ClusterList.at(j)->GetClusKey();
557 
558  int lyr = trkrutil.GetLayer(ckey);
559 
560  if ( lyr < 0 || lyr >= 4 )
561  {
562  std::cout << PHWHERE << " WARNING: bad layer from track cluster. lyr:" << lyr << std::endl;
563  continue;
564  }
565 
566  htrk_dx[lyr]->Fill(tracklist.at(i).dx.at(j));
567  htrk_dz[lyr]->Fill(tracklist.at(i).dz.at(j));
568 
569  if ( tracklist.at(i).chi2_xy < 5 && tracklist.at(i).chi2_zy < 5)
570  {
571  htrk_cut_dx[lyr]->Fill(tracklist.at(i).dx.at(j));
572  htrk_cut_dz[lyr]->Fill(tracklist.at(i).dz.at(j));
573  }
574  } // j
575 
576 
577  } // i
578 
579  htrk_cut->Fill(ncut);
580 
581  //-- Cleanup
582 
583 
584  //-- End
585  return 0;
586 
587 }
588 
590 {
591 
592  PrintMisalign();
593 
594  _f->Write();
595  _f->Close();
596 
597  return 0;
598 }
599 
600 /*
601  * Get all the necessary nodes from the node tree
602  */
604 {
605 
606  // Input Svtx Clusters
607  clusters_ = findNode::getClass<TrkrClusterContainer>(topNode, "TrkrClusterContainer");
608  if (!clusters_ && _ievent < 2)
609  {
610  std::cout << PHWHERE << " TrkrClusterContainer node not found on node tree"
611  << std::endl;
613  }
614 
616 
617 }
618 
619 /*
620  * Simple helper function for calculating the slope between two points
621  */
622 double
623 AnaMvtxPrototype1::CalcSlope(double x0, double y0, double x1, double y1)
624 {
625  return (y1 - y0) / (x1 - x0);
626 }
627 
628 /*
629  * Simple helper function for calculating intercept
630  */
631 double
632 AnaMvtxPrototype1::CalcIntecept(double x0, double y0, double m)
633 {
634  return y0 - x0 * m;
635 }
636 
637 /*
638  * Simple helper function for calculating projection
639  */
640 double
641 AnaMvtxPrototype1::CalcProjection(double x, double m, double b)
642 {
643  return m * x + b;
644 }
645 
646 /*
647  *
648  */
649 void
650 AnaMvtxPrototype1::MisalignLayer(int lyr, double dx, double dy, double dz)
651 {
652  mis align;
653  align.dx = dx;
654  align.dy = dy;
655  align.dz = dz;
656 
657  _misalign.insert( std::make_pair(lyr, align) );
658 }
659 
660 /*
661  * Misalign clusters for each layer
662  */
663 void
665 {
666  // only bother if we've set some misalignments to non-zero values
667  if ( _misalign.size() < 1 )
668  return;
669 
670  TrkrClusterContainer::ConstRange clusrange = clusters_->GetClusters();
671  for (TrkrClusterContainer::ConstIterator iter = clusrange.first;
672  iter != clusrange.second;
673  ++iter)
674  {
675  // TrkrCluster *clus = iter->second;
676  /*
677  // get misalignments
678  auto misitr = _misalign.find(clus->get_layer());
679  if ( misitr != _misalign.end() )
680  {
681  mis align = misitr->second;
682 
683  float x = clus->GetX();
684  float y = clus->GetY();
685  float z = clus->GetZ();
686  float r = TMath::Sqrt(x * x + y * y);
687  float phi = TMath::ATan2(y, x);
688  float s = r * phi;
689 
690  double zp = z;
691  double rp = r;
692  double sp = s;
693 
694  // --- pitch, yaw, roll
695  // pitch is dr(z)
696  rp += z * TMath::Sin(align.dpitch);
697 
698  // yaw is ds(z)
699  sp += z * TMath::Sin(align.dyaw);
700 
701  // roll is dr(s)
702  rp += s * TMath::Sin(align.droll);
703 
704  // --- translate (s, z, r)
705  rp += align.dr;
706  sp += align.ds;
707  zp += align.dz;
708 
709  // --- recalculat x', y', z'
710  float phip = sp / rp;
711  float xp = rp * TMath::Cos(phip);
712  float yp = rp * TMath::Sin(phip);
713 
714  // --- set new coordinates
715  clus->set_x(xp);
716  clus->set_y(yp);
717  clus->set_z(zp);
718 
719  if ( false )
720  {
721  std::cout << " lyr:" << clus->get_layer()
722  << " ds:" << align.ds
723  << " dz:" << align.dz
724  << " dr:" << align.dr
725  << " dpitch:" << align.dpitch
726  << " dyaw:" << align.dyaw
727  << " droll:" << align.droll
728  << " phi:" << phi << " phip:" << phip
729  << " z:" << z << " zp:" << zp
730  << " x:" << x << " xp:" << xp
731  << " y:" << y << " yp:" << yp
732  << std::endl;
733  }
734 
735  }
736  */
737  } // iter
738 }
739 
740 /*
741  *
742  */
743 void
745 {
746  std::cout << "================================" << std::endl;
747  std::cout << "== " << PHWHERE << std::endl;
748 
749  for (auto iter = _misalign.begin(); iter != _misalign.end(); ++iter)
750  {
751  std::cout << "== Lyr: " << iter->first
752  << " dx[cm]:" << (iter->second).dx
753  << " dy[cm]:" << (iter->second).dy
754  << " dz[cm]:" << (iter->second).dz
755  << std::endl;
756  } // iter
757 
758  std::cout << "================================" << std::endl;
759 }
760