#include "IElectronCloud.hxx" #include "IFieldManager.hxx" #include #include #include #include using namespace std; //*********************************************************** COMET::IElectronCloud::IElectronCloud(int nE, TVector3 pos, TVector3 vel, double t, int q) { //*********************************************************** //Save the start values fNbrEs = nE; fPos = pos; fStartPos = pos; fVel = vel; fT = t; fStartT = t; fCharge = q; Initialize(); } //*********************************************************** COMET::IElectronCloud::~IElectronCloud() { //*********************************************************** } //*********************************************************** void COMET:: IElectronCloud::Initialize() { //*********************************************************** fDrifted = false; fMeanDriftXVelocity = 0; //Sigma of dot is sqrt of (radius squared divided by 4) (in mm) fYInitialSigma = 2; fZInitialSigma = 2; fXInitialSigma = 0; fRDisk = 0; fCornersAreSet = false; //Do not initialize field manager here! That is done in IDriftVolume } //*********************************************************** int COMET::IElectronCloud::GetNumberElectrons() { //*********************************************************** return fNbrEs; } //*********************************************************** int COMET::IElectronCloud::GetCharge() { //*********************************************************** return fCharge; } //*********************************************************** void COMET::IElectronCloud::SetNumberElectrons(int nE) { //*********************************************************** fNbrEs = nE; } //*********************************************************** TVector3 COMET::IElectronCloud::GetPosition() { //*********************************************************** return fPos; } //*********************************************************** void COMET::IElectronCloud::SetPosition(TVector3 pos) { //*********************************************************** fPos = pos; } //*********************************************************** TVector3 COMET::IElectronCloud::GetVelocity() { //*********************************************************** return fVel; } //*********************************************************** void COMET::IElectronCloud::SetVelocity(TVector3 vel) { //*********************************************************** fVel = vel; } //*********************************************************** double COMET::IElectronCloud::GetMeanDriftXVelocity() { //*********************************************************** return fMeanDriftXVelocity; } //*********************************************************** void COMET::IElectronCloud::SetMeanDriftXVelocity(double vel) { //*********************************************************** fMeanDriftXVelocity = vel; } //*********************************************************** double COMET::IElectronCloud::GetTime() { //*********************************************************** return fT; } //*********************************************************** void COMET::IElectronCloud::SetTime(double time){ //*********************************************************** fT = time; } //*********************************************************** TVector3 COMET::IElectronCloud::GetStartPosition() { //*********************************************************** return fStartPos; } //*********************************************************** bool COMET::IElectronCloud::IsDrifted() { //*********************************************************** return fDrifted; } //*********************************************************** void COMET::IElectronCloud::SetIsDrifted(bool ok) { //*********************************************************** fDrifted = ok;; } //*********************************************************** int COMET::IElectronCloud::NumberDriftSteps() { //*********************************************************** return fNbrSteps; } //*********************************************************** void COMET::IElectronCloud::SetNumberDriftSteps(int steps) { //*********************************************************** fNbrSteps = steps; } //*********************************************************** double COMET::IElectronCloud::GetXDriftLength() { //*********************************************************** return fabs((fStartPos - fPos).X()); //returns 0.0 if not drifted } //*********************************************************** double COMET::IElectronCloud::GetTotDriftLength() { //*********************************************************** return (fStartPos - fPos).Mag(); //returns 0.0 if not drifted } //*********************************************************** double COMET::IElectronCloud::GetRandomArrivalTime(double longDiffCoef) { //*********************************************************** if (IsDrifted()) { //Get the x-displacement due to E-field double totalDx_E = GetXDriftLength(); if (totalDx_E > 0.000001) { //Standard deviation double sigma = longDiffCoef*sqrt( totalDx_E ); //Get dx displacemenent due to longitudinal diffusion double dx = gRandom->Gaus(0, sigma + fXInitialSigma); //cout<<"IElectronCloud: dx = "< 0.000000001) { return GetTime() + dx/fabs(fMeanDriftXVelocity); } } } cout<<"IElectronCloud::GetRandomArrivalTime; Returning -1"< 0.001)||(fabs(side2 - side4) > 0.001)) { cout<<"ERROR in IElectronCloud::GetRandomPositionOnFlatShape, FIXME: allow for arbitrary strips"< TVector3(fCorners[1]-fCorners[0]).Angle(TVector3(fCorners[3]-fCorners[0]))) { cout<<"ERROR in IElectronCloud::GetRandomPositionOnParallelogram, FIXME: allow for non consecutive corners"<Uniform()*(fCorners[1] - fCorners[0]).Mag()*(fCorners[1] - fCorners[0]).Unit(); //Then move along the side between corner 0 and 3 pos = pos + gRandom->Uniform()*(fCorners[3] - fCorners[0]).Mag()*(fCorners[3] - fCorners[0]).Unit(); //Now get the vector from corner 0 to the center in similar way TVector3 center = 0.5*(fCorners[1] - fCorners[0]).Mag()*(fCorners[1] - fCorners[0]).Unit(); center = center + 0.5*(fCorners[3] - fCorners[0]).Mag()*(fCorners[3] - fCorners[0]).Unit(); //Get the vector pointing from center (that we will now use as origo) to the position pos = (pos - center); //Return a local postion where center is origo return TVector2(pos.Z(), pos.Y()); } //*********************************************************** void COMET::IElectronCloud::UnDrift() { //*********************************************************** fPos = fStartPos; fT = fStartT; fVel = TVector3(0,0,0); fMeanDriftXVelocity = 0; fDrifted = false; }