1#ifndef G_COMPONENT_ANALYTIC_FIELD_H
2#define G_COMPONENT_ANALYTIC_FIELD_H
23 void ElectricField(
const double x,
const double y,
const double z,
double& ex,
24 double& ey,
double& ez,
Medium*& m,
int& status) {
29 status = Field(x, y, z, ex, ey, ez, v,
false);
41 void ElectricField(
const double x,
const double y,
const double z,
double& ex,
42 double& ey,
double& ez,
double& v,
Medium*& m,
46 status = Field(x, y, z, ex, ey, ez, v,
true);
61 double& wx,
double& wy,
double& wz,
62 const std::string& label) {
65 if (!m_sigset) PrepareSignals();
66 Wfield(x, y, z, wx, wy, wz, volt, label,
false);
69 const std::string& label) {
70 double wx = 0., wy = 0., wz = 0.;
72 if (!m_sigset) PrepareSignals();
73 Wfield(x, y, z, wx, wy, wz, volt, label,
true);
77 bool GetBoundingBox(
double& x0,
double& y0,
double& z0,
double& x1,
78 double& y1,
double& z1);
80 bool IsWireCrossed(
const double x0,
const double y0,
const double z0,
81 const double x1,
const double y1,
const double z1,
82 double& xc,
double& yc,
double& zc);
84 bool IsInTrapRadius(
const double q0,
const double x0,
const double y0,
85 const double z0,
double& xw,
double& yx,
double& rw);
88 void AddWire(
const double x,
const double y,
const double diameter,
89 const double voltage,
const std::string& label,
90 const double length = 100.,
const double tension = 50.,
91 const double rho = 19.3,
const int ntrap = 5);
93 void AddTube(
const double radius,
const double voltage,
const int nEdges,
94 const std::string& label);
96 void AddPlaneX(
const double x,
const double voltage,
97 const std::string& label);
99 void AddPlaneY(
const double y,
const double voltage,
100 const std::string& label);
102 void AddStripOnPlaneX(
const char direction,
const double x,
const double smin,
103 const double smax,
const std::string& label,
104 const double gap = -1.);
105 void AddStripOnPlaneY(
const char direction,
const double y,
const double smin,
106 const double smax,
const std::string& label,
107 const double gap = -1.);
109 const double zmin,
const double zmax,
110 const std::string& label,
const double gap = -1.);
112 const double zmin,
const double zmax,
113 const std::string& label,
const double gap = -1.);
123 void AddCharge(
const double x,
const double y,
const double z,
149 if (CellCheck()) CellType();
161 bool GetWire(
const unsigned int i,
double& x,
double& y,
double& diameter,
162 double& voltage, std::string& label,
double& length,
163 double& charge,
int& ntrap)
const;
167 bool GetPlaneX(
const unsigned int i,
double& x,
double& voltage,
168 std::string& label)
const;
169 bool GetPlaneY(
const unsigned int i,
double& y,
double& voltage,
170 std::string& label)
const;
172 bool GetTube(
double& r,
double& voltage,
int& nEdges, std::string& label)
const;
200 std::string m_scellType;
204 double m_xmin, m_xmax;
205 double m_ymin, m_ymax;
206 double m_zmin, m_zmax;
217 std::string m_scellTypeFourier;
219 int mxmin, mxmax, mymin, mymax;
222 std::vector<std::string> m_readout;
225 unsigned int m_nWires;
237 std::vector<wire> m_w;
240 std::vector<double> weight;
242 std::vector<double> dens;
244 std::vector<double> cnalso;
249 std::vector<double> cosph2;
250 std::vector<double> sinph2;
251 std::vector<double> amp2;
254 std::vector<double> m_b2sin;
257 std::complex<double> m_zmult;
258 double m_p1, m_p2, m_c1;
261 std::vector<std::complex<double> > wmap;
264 std::vector<std::vector<double> > m_cc1;
265 std::vector<std::vector<double> > m_cc2;
269 double m_corvta, m_corvtb, m_corvtc;
274 bool m_ynplax, m_ynplay;
277 double m_coplax, m_coplay;
299 double ewxcor, ewycor;
300 std::vector<strip> strips1;
301 std::vector<strip> strips2;
302 std::vector<pixel> pixels;
305 std::vector<plane> planes;
309 int m_mtube, m_ntube;
315 std::vector<std::vector<double> > m_a;
317 std::vector<std::vector<std::complex<double> > > m_sigmat;
319 std::vector<std::vector<double> > m_qplane;
326 std::vector<charge3d> m_ch3d;
327 unsigned int m_nTermBessel;
328 unsigned int m_nTermPoly;
333 void UpdatePeriodicity();
334 void Reset() { CellInit(); }
340 bool PrepareStrips();
342 bool PrepareSignals();
343 bool SetupWireSignals();
344 bool SetupPlaneSignals();
361 bool IprA00(
const int mx,
const int my);
362 bool IprB2X(
const int my);
363 bool IprB2Y(
const int mx);
370 bool SetupDipole() {
return true; }
376 int Field(
const double xin,
const double yin,
const double zin,
double& ex,
377 double& ey,
double& ez,
double& volt,
const bool opt);
378 void FieldA00(
const double xpos,
const double ypos,
double& ex,
double& ey,
379 double& volt,
const bool opt)
const;
380 void FieldB1X(
const double xpos,
const double ypos,
double& ex,
double& ey,
381 double& volt,
const bool opt)
const;
382 void FieldB1Y(
const double xpos,
const double ypos,
double& ex,
double& ey,
383 double& volt,
const bool opt)
const;
384 void FieldB2X(
const double xpos,
const double ypos,
double& ex,
double& ey,
385 double& volt,
const bool opt)
const;
386 void FieldB2Y(
const double xpos,
const double ypos,
double& ex,
double& ey,
387 double& volt,
const bool opt)
const;
388 void FieldC10(
const double xpos,
const double ypos,
double& ex,
double& ey,
389 double& volt,
const bool opt)
const;
390 void FieldC2X(
const double xpos,
const double ypos,
double& ex,
double& ey,
391 double& volt,
const bool opt)
const;
392 void FieldC2Y(
const double xpos,
const double ypos,
double& ex,
double& ey,
393 double& volt,
const bool opt)
const;
394 void FieldC30(
const double xpos,
const double ypos,
double& ex,
double& ey,
395 double& volt,
const bool opt)
const;
396 void FieldD10(
const double xpos,
const double ypos,
double& ex,
double& ey,
397 double& volt,
const bool opt)
const;
398 void FieldD20(
const double xpos,
const double ypos,
double& ex,
double& ey,
399 double& volt,
const bool opt)
const;
400 void FieldD30(
const double xpos,
const double ypos,
double& ex,
double& ey,
401 double& volt,
const bool opt)
const;
404 void Field3dA00(
const double x,
const double y,
const double z,
double& ex,
405 double& ey,
double& ez,
double& volt);
406 void Field3dB2X(
const double x,
const double y,
const double z,
double& ex,
407 double& ey,
double& ez,
double& volt);
408 void Field3dB2Y(
const double x,
const double y,
const double z,
double& ex,
409 double& ey,
double& ez,
double& volt);
410 void Field3dD10(
const double x,
const double y,
const double z,
double& ex,
411 double& ey,
double& ez,
double& volt);
413 bool Wfield(
const double xpos,
const double ypos,
const double zpos,
414 double& ex,
double& ey,
double& ez,
double& volt,
415 const std::string& label,
const bool opt)
const;
416 void WfieldWireA00(
const double xpos,
const double ypos,
double& ex,
417 double& ey,
double& volt,
const int mx,
const int my,
418 const int sw,
const bool opt)
const;
419 void WfieldWireB2X(
const double xpos,
const double ypos,
double& ex,
420 double& ey,
double& volt,
const int my,
const int sw,
421 const bool opt)
const;
422 void WfieldWireB2Y(
const double xpos,
const double ypos,
double& ex,
423 double& ey,
double& volt,
const int mx,
const int sw,
424 const bool opt)
const;
425 void WfieldWireC2X(
const double xpos,
const double ypos,
double& ex,
426 double& ey,
double& volt,
const int sw,
427 const bool opt)
const;
428 void WfieldWireC2Y(
const double xpos,
const double ypos,
double& ex,
429 double& ey,
double& volt,
const int sw,
430 const bool opt)
const;
431 void WfieldWireC30(
const double xpos,
const double ypos,
double& ex,
432 double& ey,
double& volt,
const int sw,
433 const bool opt)
const;
434 void WfieldWireD10(
const double xpos,
const double ypos,
double& ex,
435 double& ey,
double& volt,
const int sw,
436 const bool opt)
const;
437 void WfieldWireD30(
const double xpos,
const double ypos,
double& ex,
438 double& ey,
double& volt,
const int sw,
439 const bool opt)
const;
440 void WfieldPlaneA00(
const double xpos,
const double ypos,
double& ex,
441 double& ey,
double& volt,
const int mx,
const int my,
442 const int iplane,
const bool opt)
const;
443 void WfieldPlaneB2X(
const double xpos,
const double ypos,
double& ex,
444 double& ey,
double& volt,
const int my,
const int iplane,
445 const bool opt)
const;
446 void WfieldPlaneB2Y(
const double xpos,
const double ypos,
double& ex,
447 double& ey,
double& volt,
const int mx,
const int iplane,
448 const bool opt)
const;
449 void WfieldPlaneC2X(
const double xpos,
const double ypos,
double& ex,
450 double& ey,
double& volt,
const int iplane,
451 const bool opt)
const;
452 void WfieldPlaneC2Y(
const double xpos,
const double ypos,
double& ex,
453 double& ey,
double& volt,
const int iplane,
454 const bool opt)
const;
455 void WfieldPlaneC30(
const double xpos,
const double ypos,
double& ex,
456 double& ey,
double& volt,
const int iplane,
457 const bool opt)
const;
458 void WfieldPlaneD10(
const double xpos,
const double ypos,
double& ex,
459 double& ey,
double& volt,
const int iplane,
460 const bool opt)
const;
461 void WfieldPlaneD30(
const double xpos,
const double ypos,
double& ex,
462 double& ey,
double& volt,
const int iplane,
463 const bool opt)
const;
464 void WfieldStripZ(
const double xpos,
const double ypos,
double& ex,
465 double& ey,
double& volt,
const int ip,
const int is,
466 const bool opt)
const;
467 void WfieldStripXy(
const double xpos,
const double ypos,
const double zpos,
468 double& ex,
double& ey,
double& ez,
double& volt,
469 const int ip,
const int is,
const bool opt)
const;
470 void WfieldPixel(
const double xpos,
const double ypos,
const double zpos,
471 double& ex,
double& ey,
double& ez,
double& volt,
472 const int ip,
const int is,
const bool opt)
const;
475 double Ph2(
const double xpos,
const double ypos)
const;
476 double Ph2Lim(
const double radius)
const {
477 return -log(abs(m_zmult) * radius * (1. - 3. * m_p1 + 5. * m_p2));
479 void E2Sum(
const double xpos,
const double ypos,
480 double& ex,
double& ey)
const;
483 void ConformalMap(
const std::complex<double>& z, std::complex<double>& ww,
484 std::complex<double>& wd)
const;
485 void InitializeCoefficientTables();
487 bool InTube(
const double x0,
const double y0,
const double a,
491 void Cartesian2Polar(
const double x0,
const double y0,
double& r,
494 if (x0 == 0. && y0 == 0.) {
498 r =
sqrt(x0 * x0 + y0 * y0);
499 theta = atan2(y0, x0) * RadToDegree;
502 void Polar2Cartesian(
const double r,
const double theta,
503 double& x0,
double& y0)
const {
505 const double thetap =
theta * DegreeToRad;
506 x0 = r *
cos(thetap);
507 y0 = r *
sin(thetap);
512 void RTheta2RhoPhi(
const double rho,
const double phi,
double& r,
513 double& theta)
const {
bool GetVoltageRange(double &pmin, double &pmax)
Calculate the voltage range [V].
double WeightingPotential(const double x, const double y, const double z, const std::string &label)
void SetPeriodicityX(const double s)
Set the periodic length [cm] in the x-direction.
bool GetPeriodicityY(double &s)
void ElectricField(const double x, const double y, const double z, double &ex, double &ey, double &ez, double &v, Medium *&m, int &status)
void AddTube(const double radius, const double voltage, const int nEdges, const std::string &label)
Add a tube.
void AddPlaneX(const double x, const double voltage, const std::string &label)
Add a plane at constant x.
void EnableChargeCheck(const bool on=true)
bool IsInTrapRadius(const double q0, const double x0, const double y0, const double z0, double &xw, double &yx, double &rw)
void AddPixelOnPlaneY(const double y, const double xmin, const double xmax, const double zmin, const double zmax, const std::string &label, const double gap=-1.)
void AddCharge(const double x, const double y, const double z, const double q)
Add a point charge.
unsigned int GetNumberOfWires() const
void WeightingField(const double x, const double y, const double z, double &wx, double &wy, double &wz, const std::string &label)
std::string GetCellType()
bool GetWire(const unsigned int i, double &x, double &y, double &diameter, double &voltage, std::string &label, double &length, double &charge, int &ntrap) const
ComponentAnalyticField()
Constructor.
void AddStripOnPlaneX(const char direction, const double x, const double smin, const double smax, const std::string &label, const double gap=-1.)
unsigned int GetNumberOfPlanesY() const
void AddWire(const double x, const double y, const double diameter, const double voltage, const std::string &label, const double length=100., const double tension=50., const double rho=19.3, const int ntrap=5)
Add a wire at (x, y) .
unsigned int GetNumberOfPlanesX() const
bool GetPeriodicityX(double &s)
bool GetTube(double &r, double &voltage, int &nEdges, std::string &label) const
bool GetPlaneX(const unsigned int i, double &x, double &voltage, std::string &label) const
void AddPlaneY(const double y, const double voltage, const std::string &label)
Add a plane at constant y.
void AddPixelOnPlaneX(const double x, const double ymin, const double ymax, const double zmin, const double zmax, const std::string &label, const double gap=-1.)
bool GetBoundingBox(double &x0, double &y0, double &z0, double &x1, double &y1, double &z1)
Get the bounding box coordinates.
void AddStripOnPlaneY(const char direction, const double y, const double smin, const double smax, const std::string &label, const double gap=-1.)
~ComponentAnalyticField()
Destructor.
void AddReadout(const std::string &label)
Setup the weighting field for a given group of wires or planes.
void ElectricField(const double x, const double y, const double z, double &ex, double &ey, double &ez, Medium *&m, int &status)
void DisableChargeCheck()
void SetPeriodicityY(const double s)
Set the periodic length [cm] in the y-direction.
bool IsWireCrossed(const double x0, const double y0, const double z0, const double x1, const double y1, const double z1, double &xc, double &yc, double &zc)
void PrintCharges() const
bool GetPlaneY(const unsigned int i, double &y, double &voltage, std::string &label) const
Abstract base class for components.
virtual Medium * GetMedium(const double x, const double y, const double z)
Get the medium at a given location (x, y, z).
Abstract base class for media.
DoubleAc cos(const DoubleAc &f)
DoubleAc exp(const DoubleAc &f)
DoubleAc sin(const DoubleAc &f)
DoubleAc sqrt(const DoubleAc &f)