180 lines
3.9 KiB
C++
180 lines
3.9 KiB
C++
//
|
|
// zylindric_cords.h
|
|
// mc_electron
|
|
//
|
|
// Created by Christian Reiling on 15.05.19.
|
|
// Copyright © 2019 Christian Reiling. All rights reserved.
|
|
//
|
|
|
|
#ifndef zylindric_cords_h
|
|
#define zylindric_cords_h
|
|
|
|
enum cordStyle{xyz, zrphi};
|
|
|
|
#include <vector>
|
|
|
|
#include "katrin_geo.h"
|
|
|
|
#include "kinematics.h"
|
|
#include "base_container.h"
|
|
|
|
|
|
class Zylindric_Cords {
|
|
double z_min_m;
|
|
double z_max_m;
|
|
double r_max_m;
|
|
vec3 zrphi_numBins;
|
|
|
|
double l_m;
|
|
dim1Map V_m3;
|
|
|
|
public:
|
|
Zylindric_Cords() {};
|
|
Zylindric_Cords(vec3 zrphi_numBins);
|
|
Zylindric_Cords(double z_min_m, double z_max_m, double r_max_m, vec3 zrphi_numBins);
|
|
|
|
private:
|
|
void set_fromKatrinGeo();
|
|
void set_l_m();
|
|
void set_V_m3();
|
|
|
|
public:
|
|
std::vector<vec3> get_bins() ;
|
|
|
|
double get_l_m () {return l_m;}
|
|
double get_V_m3(double r_m) ;
|
|
|
|
public:
|
|
void check_In_Container(vec3 Cords, cordStyle cordStyleIn = xyz);
|
|
bool in_Container(vec3 Cords, cordStyle cordStyleIn = xyz);
|
|
|
|
private:
|
|
bool in_zDimension (double z_m);
|
|
bool in_rDimension (double r_m);
|
|
|
|
protected:
|
|
vec3 transformTo_zrphiCords(vec3 Cords, cordStyle cordStyleIn);
|
|
};
|
|
|
|
|
|
inline Zylindric_Cords::Zylindric_Cords(vec3 zrphi_numBins) {
|
|
set_fromKatrinGeo();
|
|
this->zrphi_numBins = zrphi_numBins;
|
|
set_l_m();
|
|
set_V_m3();
|
|
}
|
|
|
|
inline Zylindric_Cords::Zylindric_Cords(double z_min_m, double z_max_m, double r_max_m, vec3 zrphi_numBins) {
|
|
this->z_min_m = z_min_m;
|
|
this->z_max_m = z_max_m;
|
|
this->r_max_m = r_max_m;
|
|
this->zrphi_numBins = zrphi_numBins;
|
|
set_l_m();
|
|
set_V_m3();
|
|
}
|
|
|
|
inline void Zylindric_Cords::set_fromKatrinGeo() {
|
|
this->z_min_m = z_RW_m;
|
|
this->z_max_m = z_WGTS_end_m;
|
|
this->r_max_m = r_WGTS_m;
|
|
}
|
|
|
|
inline void Zylindric_Cords::set_l_m() {
|
|
l_m = (z_max_m-z_min_m)/zrphi_numBins[0];
|
|
}
|
|
|
|
inline void Zylindric_Cords::set_V_m3() {
|
|
int n_r = zrphi_numBins[1];
|
|
int n_phi = zrphi_numBins[2];
|
|
double r_step_m = r_max_m/n_r;
|
|
double r_m, A_disc_m2, V_res_m3;
|
|
for (int i = 1; i <= n_r; i++) {
|
|
r_m = i * r_step_m;
|
|
A_disc_m2 = pi*(pow(r_m,2)-pow(r_m-r_step_m,2));
|
|
V_res_m3 = A_disc_m2/n_phi*l_m;
|
|
V_m3.insert( std::pair<double,double>(r_m, V_res_m3) );
|
|
}
|
|
}
|
|
|
|
|
|
inline std::vector<vec3> Zylindric_Cords::get_bins() {
|
|
std::vector<vec3> res;
|
|
int n_z = zrphi_numBins[0];
|
|
int n_r = zrphi_numBins[1];
|
|
int n_phi = zrphi_numBins[2];
|
|
double z_step_m = l_m;
|
|
double r_step_m = r_max_m/n_r;
|
|
double phi_step = 2*pi/n_phi;
|
|
double z_m, r_m, phi;
|
|
|
|
for (int i_z = 1; i_z<=n_z; i_z++) {
|
|
z_m = z_min_m + z_step_m * i_z;
|
|
for (int i_r = 1; i_r<=n_r; i_r++) {
|
|
r_m = r_step_m * i_r;
|
|
for (int i_phi = 1; i_phi<=n_phi; i_phi++) {
|
|
phi = phi_step * i_phi;
|
|
res.push_back( vec3(z_m, r_m, phi) );
|
|
}
|
|
}
|
|
}
|
|
return res;
|
|
}
|
|
|
|
inline double Zylindric_Cords::get_V_m3(double r_m) {
|
|
if (!in_rDimension(r_m)) {
|
|
std::stringstream ss;
|
|
ss<<"Zylindric_Cords::get_V_m3: r_m not in Container.\n";
|
|
throw MyException (ss.str());
|
|
}
|
|
return V_m3.lower_bound(r_m)->second;
|
|
|
|
}
|
|
|
|
inline void Zylindric_Cords::check_In_Container(vec3 Cords, cordStyle cordStyleIn) {
|
|
if (!in_Container(Cords, cordStyleIn)) {
|
|
std::stringstream ss;
|
|
ss<<"Zylindric_Cords::check_In_Container: Cords not in Container.\n";
|
|
throw MyException (ss.str());
|
|
}
|
|
}
|
|
|
|
inline bool Zylindric_Cords::in_Container(vec3 Cords, cordStyle cordStyleIn) {
|
|
Cords = transformTo_zrphiCords(Cords, cordStyleIn);
|
|
return in_zDimension(Cords[0]) && in_rDimension(Cords[1]);
|
|
}
|
|
|
|
inline bool Zylindric_Cords::in_zDimension (double z_m) {
|
|
if (z_m<z_min_m) {
|
|
return false;
|
|
}
|
|
if (z_m>z_max_m) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
inline bool Zylindric_Cords::in_rDimension (double r_m) {
|
|
if (r_m>r_max_m) {
|
|
return false;
|
|
}
|
|
return true;
|
|
}
|
|
|
|
inline vec3 Zylindric_Cords::transformTo_zrphiCords(vec3 Cords, cordStyle cordStyleIn) {
|
|
if (cordStyleIn == zrphi) {
|
|
return Cords;
|
|
}
|
|
double z = Cords[2];
|
|
double r = sqrt(Cords[0]*Cords[0] + Cords[1]*Cords[1]);
|
|
double phi;
|
|
if (Cords[0] >= 0) {
|
|
phi = acos(Cords[1]/r);
|
|
} else {
|
|
phi = 2*pi - acos(Cords[1]/r);
|
|
}
|
|
return vec3(z,r,phi);
|
|
}
|
|
|
|
|
|
#endif /* zylindric_cords_h */
|