2021-08-23 10:00:36 -04:00
|
|
|
#ifndef __STRIP_DETECTOR_H
|
|
|
|
#define __STRIP_DETECTOR_H
|
|
|
|
|
|
|
|
// +z is along beam axis
|
2021-12-06 13:19:54 -05:00
|
|
|
// +y is vertically "downward" in the lab frame
|
2021-08-23 10:00:36 -04:00
|
|
|
|
|
|
|
//angles must be in radians, but distances can be whatever
|
|
|
|
//PROVIDED all input distances are the same
|
|
|
|
|
2021-12-06 13:19:54 -05:00
|
|
|
//Front strips from largest y to smallest y
|
2021-08-23 10:00:36 -04:00
|
|
|
|
|
|
|
//Back strips from lowest z to highest z
|
|
|
|
|
|
|
|
#include <cmath>
|
|
|
|
#include <vector>
|
2021-09-03 17:03:41 -04:00
|
|
|
#include <random>
|
2021-08-23 10:00:36 -04:00
|
|
|
|
|
|
|
#include "Vec3.h"
|
|
|
|
#include "Rotation.h"
|
2021-09-23 11:42:14 -04:00
|
|
|
#include "RandomGenerator.h"
|
2021-08-23 10:00:36 -04:00
|
|
|
|
2021-12-06 13:19:54 -05:00
|
|
|
struct StripHit
|
|
|
|
{
|
|
|
|
int front_strip_index=-1;
|
|
|
|
int back_strip_index=-1;
|
|
|
|
double front_ratio=0.0;
|
|
|
|
};
|
|
|
|
|
2021-08-23 10:00:36 -04:00
|
|
|
class StripDetector {
|
|
|
|
public:
|
|
|
|
|
|
|
|
StripDetector(int ns, double len, double wid, double cphi, double cz, double crho);
|
|
|
|
~StripDetector();
|
2021-09-23 11:42:14 -04:00
|
|
|
inline Mask::Vec3 GetFrontStripCoordinates(int stripch, int corner) { return front_strip_coords[stripch][corner]; }
|
|
|
|
inline Mask::Vec3 GetBackStripCoordinates(int stripch, int corner) { return back_strip_coords[stripch][corner]; }
|
|
|
|
inline Mask::Vec3 GetRotatedFrontStripCoordinates(int stripch, int corner) { return rotated_front_strip_coords[stripch][corner]; }
|
|
|
|
inline Mask::Vec3 GetRotatedBackStripCoordinates(int stripch, int corner) { return rotated_back_strip_coords[stripch][corner]; }
|
|
|
|
inline Mask::Vec3 GetNormRotated() { return zRot*m_norm_unrot; }
|
|
|
|
|
|
|
|
inline void TurnOnRandomizedCoordinates() { rndmFlag = true; }
|
|
|
|
inline void TurnOffRandomizedCoordinates() { rndmFlag = false; }
|
|
|
|
|
2021-08-23 10:00:36 -04:00
|
|
|
Mask::Vec3 GetHitCoordinates(int front_stripch, double front_strip_ratio);
|
2021-12-06 13:19:54 -05:00
|
|
|
StripHit GetChannelRatio(double theta, double phi);
|
2021-08-23 10:00:36 -04:00
|
|
|
|
|
|
|
private:
|
2021-09-23 11:42:14 -04:00
|
|
|
inline bool ValidChannel(int f) { return ((f >= 0 && f < num_strips) ? true : false); };
|
|
|
|
inline bool ValidRatio(double r) { return ((r >= -1 && r <= 1) ? true : false); };
|
2021-08-23 10:00:36 -04:00
|
|
|
void CalculateCorners();
|
|
|
|
|
|
|
|
int num_strips;
|
|
|
|
static constexpr int num_corners = 4;
|
|
|
|
|
|
|
|
double length; //common to all strips, hence total
|
|
|
|
double total_width;
|
|
|
|
double front_strip_width; //assuming equal widths
|
|
|
|
double back_strip_length; //assuming equal widths
|
|
|
|
|
|
|
|
double center_phi; //assuming det centered above x-axis (corresponds to zero phi)
|
|
|
|
double center_z;
|
|
|
|
double center_rho; //perpendicular radius from axis
|
|
|
|
|
|
|
|
std::vector<std::vector<Mask::Vec3>> front_strip_coords, back_strip_coords;
|
|
|
|
std::vector<std::vector<Mask::Vec3>> rotated_front_strip_coords, rotated_back_strip_coords;
|
|
|
|
|
2021-09-23 11:42:14 -04:00
|
|
|
Mask::Vec3 m_norm_unrot;
|
|
|
|
|
2021-08-23 10:00:36 -04:00
|
|
|
Mask::ZRotation zRot;
|
|
|
|
|
2021-09-03 17:03:41 -04:00
|
|
|
std::uniform_real_distribution<double> m_uniform_fraction;
|
|
|
|
|
2021-09-23 11:42:14 -04:00
|
|
|
bool rndmFlag;
|
2021-08-23 10:00:36 -04:00
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
#endif
|