Public Member Functions | Public Attributes | List of all members
evd::HitTower Class Reference

Allow for rendering of detector hits as towers on the detector. More...

#include "/cvmfs/nova-development.opensciencegrid.org/novasoft/releases/N21-01-21/EventDisplay/HitTower.h"

Public Member Functions

void AddHit (int v, int p, int c, float tp, float zp, float q, float t)
 
void Draw (evdb::View3D *view)
 

Public Attributes

double fQscale
 Charge scale factor. More...
 
std::vector< HitDatafHitData
 

Detailed Description

Allow for rendering of detector hits as towers on the detector.

Definition at line 30 of file HitTower.h.

Member Function Documentation

void evd::HitTower::AddHit ( int  v,
int  p,
int  c,
float  tp,
float  zp,
float  q,
float  t 
)

Definition at line 46 of file HitTower.cxx.

References evd::HitData::HitData().

48  {
49  fHitData.push_back(HitData(v,p,c,tp,zp,q,t));
50  }
const char * p
Definition: xmltok.h:285
std::vector< HitData > fHitData
Definition: HitTower.h:37
void evd::HitTower::Draw ( evdb::View3D view)

Definition at line 54 of file HitTower.cxx.

References abs(), evdb::View3D::AddPolyLine3D(), plot_validation_datamc::c, geo::GeometryBase::CellInfo(), om::cerr, evd::comp_hitdata(), geo::GeometryBase::DetHalfHeight(), geo::GeometryBase::DetHalfWidth(), allTimeWatchdog::endl, stan::math::fabs(), evd::HitData::fCell, evd::HitData::fPlane, evd::HitData::fQ, evd::HitData::fT, evd::HitData::fTpos, evd::HitData::fView, evd::HitData::fZpos, geom(), MECModelEnuComparisons::i, kRed, geo::kX, geo::kXorY, geo::kY, registry_explorer::v, w, x1, and y1.

55  {
56  unsigned int i;
57 
59 
60  // Sort hits by view, plane, cell, time
61  std::sort(fHitData.begin(), fHitData.end(), comp_hitdata);
62 
63  // _
64  // Render hits in this style: _| |_
65  // _| |_
66  //
67  TPolyLine3D* polyline = 0;
68  int ipoint = 0;
69  for (i=0; i<fHitData.size(); ++i) {
70  // Get information about the current cell in the list
71  const HitData& hit0 = fHitData[i];
72  double pos0[3] = {0,0,0};
73  double pos1[3] = {0,0,0};
74  double dpos[3] = {0,0,0};
76  geom->CellInfo(hit0.fPlane, hit0.fCell, &v, pos0, dpos);
77  if (hit0.fView == geo::kX) {
78  pos0[0] = hit0.fTpos - dpos[0];
79  pos0[1] = geom->DetHalfHeight()+fQscale*hit0.fQ;
80  pos0[2] = hit0.fZpos;
81 
82  pos1[0] = hit0.fTpos + dpos[0];
83  pos1[1] = pos0[1];
84  pos1[2] = pos0[2];
85  }
86  else if (hit0.fView == geo::kY) {
87  pos0[0] = geom->DetHalfWidth()+fQscale*hit0.fQ;
88  pos0[1] = hit0.fTpos-dpos[1];
89  pos0[2] = hit0.fZpos;
90 
91  pos1[0] = pos0[0];
92  pos1[1] = hit0.fTpos+dpos[1];
93  pos1[2] = pos0[2];
94  }
95  else abort();
96 
97  // Get information about the previous hit in the list
98  bool connectL = false;
99  if (i>0) {
100  const HitData& hitL = fHitData[i-1];
101  double tcut = 9E9;
102  bool samePlane = (hit0.fPlane==hitL.fPlane);
103  bool adjaCell = (abs(hit0.fCell-hitL.fCell)==1);
104  bool sameTime = (fabs(hit0.fT-hitL.fT)<tcut);
105  if (samePlane && adjaCell && sameTime) connectL = true;
106  }
107 
108  // Get information about the next hit in the list
109  bool connectR = false;
110  if (i+1<fHitData.size()) {
111  const HitData& hitR = fHitData[i+1];
112  double tcut = 9E9;
113  bool samePlane = (hit0.fPlane==hitR.fPlane);
114  bool adjaCell = (abs(hit0.fCell-hitR.fCell)==1);
115  bool sameTime = (fabs(hit0.fT-hitR.fT)<tcut);
116  if (samePlane && adjaCell && sameTime) connectR = true;
117  }
118 
119  // If we don't have a left connection, then we need to start a new
120  // line
121  if (connectL == false) {
122  // How long a lead in stub to draw? 2.0 would fill the whole
123  // adjacent cell
124  double stubfrac = 1.90;
125 
126  // The coordinates for the two points on the stub
127  double x0, y0, z0;
128  double x1, y1, z1;
129  if (hit0.fView == geo::kX) {
130  x1 = pos0[0];
131  y1 = geom->DetHalfHeight();
132  z1 = pos0[2];
133 
134  x0 = x1 - stubfrac*dpos[0];
135  y0 = y1;
136  z0 = z1;
137  }
138  else if (hit0.fView == geo::kY) {
139  x1 = geom->DetHalfWidth();
140  y1 = pos0[1];
141  z1 = pos0[2];
142 
143  x0 = x1;
144  y0 = y1 - stubfrac*dpos[1];
145  z0 = z1;
146  }
147  else abort();
148 
149  // Make a new line and add two points to the left of the first hit
150  ipoint = 0;
151  int c = kRed-9;
152  int w = 1;
153  int s = 1;
154  polyline = &view->AddPolyLine3D(0,c,w,s);
155  polyline->SetPoint(ipoint,x0,y0,z0); ++ipoint;
156  polyline->SetPoint(ipoint,x1,y1,z1); ++ipoint;
157  }
158 
159  // At this point in the code we better have a polyline or
160  // something has gone wrong...
161  if (polyline==0) {
162  std::cerr << __FILE__ ":" << __LINE__
163  << " Polyline=0? connectL=" << connectL << std::endl;
164  }
165 
166  // Always add two points to the line for the current hit
167  polyline->SetPoint(ipoint, pos0[0], pos0[1], pos0[2]); ++ipoint;
168  polyline->SetPoint(ipoint, pos1[0], pos1[1], pos1[2]); ++ipoint;
169 
170  // If we don't have a right connection, then we need to end this
171  // line
172  if (connectR == false) {
173  // How long a lead in stub to draw? 2 would fill the whole
174  // adjact cell
175  double stubfrac = 1.90;
176 
177  // The coordinates on the two ends of the stub
178  double x0, y0, z0;
179  double x1, y1, z1;
180  if (hit0.fView == geo::kX) {
181  x0 = pos1[0];
182  y0 = geom->DetHalfHeight();
183  z0 = pos1[2];
184 
185  x1 = x0 + stubfrac*dpos[0];
186  y1 = y0;
187  z1 = z0;
188  }
189  else if (hit0.fView == geo::kY) {
190  x0 = geom->DetHalfWidth();
191  y0 = pos1[1];
192  z0 = pos1[2];
193 
194  x1 = x0;
195  y1 = y0 + stubfrac*dpos[1];
196  z1 = z0;
197  }
198  else abort();
199  polyline->SetPoint(ipoint, x0, y0, z0); ++ipoint;
200  polyline->SetPoint(ipoint, x1, y1, z1); ++ipoint;
201  }
202  } // loop on i in fHitData
203  }
enum BeamMode kRed
fvar< T > fabs(const fvar< T > &x)
Definition: fabs.hpp:15
Float_t y1[n_points_granero]
Definition: compare.C:5
X or Y views.
Definition: PlaneGeo.h:30
enum geo::_plane_proj View_t
Enumerate the possible plane projections.
bool comp_hitdata(const HitData &h1, const HitData &h2)
Definition: HitTower.cxx:22
Float_t x1[n_points_granero]
Definition: compare.C:5
Vertical planes which measure X.
Definition: PlaneGeo.h:28
OStream cerr
Definition: OStream.cxx:7
void abs(TH1 *hist)
Horizontal planes which measure Y.
Definition: PlaneGeo.h:29
void CellInfo(unsigned int ip, unsigned int ic, View_t *view=0, double *pos=0, double *dpos=0) const
TPolyLine3D & AddPolyLine3D(int n, int c, int w, int s)
Definition: View3D.cxx:105
const XML_Char * s
Definition: expat.h:262
double DetHalfHeight() const
std::vector< HitData > fHitData
Definition: HitTower.h:37
double fQscale
Charge scale factor.
Definition: HitTower.h:36
double DetHalfWidth() const
void geom(int which=0)
Definition: geom.C:163
Float_t w
Definition: plot.C:20

Member Data Documentation

std::vector<HitData> evd::HitTower::fHitData

Definition at line 37 of file HitTower.h.

double evd::HitTower::fQscale

Charge scale factor.

Definition at line 36 of file HitTower.h.


The documentation for this class was generated from the following files: