CollimatorPhysics.hh 2.51 KB
Newer Older
gsell's avatar
gsell committed
1 2 3 4 5 6 7 8
#ifndef COLLIMATORPHYSICS_HH
#define COLLIMATORPHYSICS_HH
//Class:CollimatorPhysics
//  Defines the collimator physics models
// ------------------------------------------------------------------------
// Class category:
// ------------------------------------------------------------------------
// $Date: 2009/07/20 09:32:31 $
adelmann's avatar
adelmann committed
9
// $Author: Bi, Yang, Stachel, Adelmann$
gsell's avatar
gsell committed
10 11
//-------------------------------------------------------------------------
#include <vector>
12
#include "Solvers/SurfacePhysicsHandler.hh"
13
#include "Algorithms/Vektor.h"
14
#include "AbsBeamline/Component.h"
15

adelmann's avatar
adelmann committed
16 17
#include <gsl/gsl_rng.h>

gsell's avatar
gsell committed
18
class ElementBase;
19 20
class PartBunch;
class LossDataSink;
kraus's avatar
kraus committed
21
class Inform;
gsell's avatar
gsell committed
22

23 24 25 26 27 28 29 30 31 32 33
typedef struct {
    int label;
    unsigned localID;
    Vector_t Rincol;
    Vector_t Pincol;
    long IDincol;
    int Binincol;
    double DTincol;
    double Qincol;
    long LastSecincol;
    Vector_t Bfincol;
kraus's avatar
kraus committed
34
    Vector_t Efincol;
35 36 37
} PART;


gsell's avatar
gsell committed
38 39
class CollimatorPhysics: public SurfacePhysicsHandler {
public:
adelmann's avatar
adelmann committed
40
    CollimatorPhysics(const std::string &name, ElementBase *element, std::string &mat);
gsell's avatar
gsell committed
41 42 43

    void apply(PartBunch &bunch);

44
    virtual const std::string getType() const;
gsell's avatar
gsell committed
45 46 47 48

    ~CollimatorPhysics();
    void Material();
    void EnergyLoss(double &Eng, bool &pdead);
Yuanjie Bi's avatar
Yuanjie Bi committed
49
    void CoulombScat(Vector_t &R, Vector_t &P, double &deltat);
gsell's avatar
gsell committed
50 51
    void CoulombScat();
    void EnergyLoss(double &Eng, bool &pdead, double &deltat);
adelmann's avatar
adelmann committed
52 53 54 55 56

    // Old Bi stuff
    // void  Rot(Vector_t &P, Vector_t Prot, double normP);
    // double Rot(double &p1, double &p2, double &scatang);
    void Rot(double &px, double &pz, double &x, double &z, double xplane, double Norm_P, double thetacou, double deltas, int coord);
57

58

gsell's avatar
gsell committed
59
private:
60

adelmann's avatar
adelmann committed
61
    gsl_rng *rGen_m;
kraus's avatar
kraus committed
62

63 64 65
    std::string material_m;
    std::string FN_m;
    std::string collshape_m;
gsell's avatar
gsell committed
66 67
    int Z_m;
    double A_m;
68 69 70 71
    double A2_c;
    double A3_c;
    double A4_c;
    double A5_c;
gsell's avatar
gsell committed
72 73 74 75 76
    double rho_m;
    double X0_m;
    double I_m;
    double n_m;

77 78 79 80
    unsigned bunchToMatStat_m;
    unsigned stoppedPartStat_m;
    unsigned redifusedStat_m;

81 82 83 84 85 86
    // some statistics

    double Eavg_m;
    double Emax_m;
    double Emin_m;

87 88 89 90 91
public:
    double dT_m;
    int N_m;

private:
gsell's avatar
gsell committed
92 93
    bool incoll_m;

94
    double time_m;
95 96

    std::vector<PART> locParts_m;
kraus's avatar
kraus committed
97

adelmann's avatar
adelmann committed
98
    std::unique_ptr<LossDataSink> lossDs_m;
99 100 101

    void copyFromBunch(PartBunch &bunch);

102
    void addBackToBunch(PartBunch &bunch, unsigned i);
103 104 105 106 107

    void deleteParticleFromLocalVector();

public:
    void print(Inform& os);
adelmann's avatar
adelmann committed
108 109

    bool stillActive() { return bunchToMatStat_m != 0;}
gsell's avatar
gsell committed
110 111 112
};

#endif //COLLIMATORPHYSICS_HH