#include <cstdlib>
#include <iostream>
#include <fstream>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include "TString.h"
#include "CTDR_Detecteur.h"
using namespace std;
const double Pi=M_PI;
ClassImp(CTDR_Detecteur)
CTDR_Detecteur::CTDR_Detecteur(TFile &Fichier, int NdivX, int NdivY, int NdivZ,double LX,double LY, double LZ,double periode)
{
char hash[100];
NDivx=NdivX;
NDivy=NdivY;
NDivz=NdivZ;
Lx=LX;
Ly=LY;
Lz=LZ;
this->periode=periode;
TVx=(TTree*)Fichier.Get("Vx");
TVy=(TTree*)Fichier.Get("Vy");
TVx->BuildIndex("I","0");
TVx->SetBranchAddress("x",&x_Vx);
TVx->SetBranchAddress("y",&y_Vx);
TVx->SetBranchAddress("z",&z_Vx);
TVx->SetBranchAddress("V",&V_Vx);
TVy->BuildIndex("I","0");
TVy->SetBranchAddress("x",&x_Vy);
TVy->SetBranchAddress("y",&y_Vy);
TVy->SetBranchAddress("z",&z_Vy);
TVy->SetBranchAddress("V",&V_Vy);
};
void CTDR_Detecteur::Potentiel(double x , double y ,double z)
{
if(z>(Lz-1e-6)){
Interpole2D(x,y);
}
else if(z<0 | fabs(x)>Lx | fabs(y)>Ly){
Vx=0;
Vy=0;
}
else{
Interpole3D(x,y,z);
};
};
void CTDR_Detecteur::Interpole3D(double x, double y , double z)
{
double V000,V010,V100,V110,V001,V011,V101,V111;
double t,u,v;
SetPoints(x,y,z);
Long64_t Adresse=Hash(lowx,lowy,lowz);
TVx->GetEntryWithIndex(Adresse,0);
V000=V_Vx;
Adresse=Hash(lowx,highy,lowz);
TVx->GetEntryWithIndex(Adresse,0);
V010=V_Vx;
Adresse=Hash(highx,lowy,lowz);
TVx->GetEntryWithIndex(Adresse,0);
V100=V_Vx;
Adresse=Hash(highx,highy,lowz);
TVx->GetEntryWithIndex(Adresse,0);
V110=V_Vx;
Adresse=Hash(lowx,lowy,highz);
TVx->GetEntryWithIndex(Adresse,0);
V001=V_Vx;
Adresse=Hash(lowx,highy,highz);
TVx->GetEntryWithIndex(Adresse,0);
V011=V_Vx;
Adresse=Hash(highx,lowy,highz);
TVx->GetEntryWithIndex(Adresse,0);
V101=V_Vx;
Adresse=Hash(highx,highy,highz);
TVx->GetEntryWithIndex(Adresse,0);
V111=V_Vx;
if(highx!=lowx){t=(x-Lx*(lowx/NDivx-0.5))/(Lx*(highx/NDivx-0.5)-Lx*(lowx/NDivx-0.5));}
else{t=0;};
if(highy!=lowy){u=(y-Ly*(lowy/NDivy-0.5))/(Ly*(highy/NDivy-0.5)-Ly*(lowy/NDivy-0.5));}
else{u=0;};
if(highz!=lowz){v=(z-Lz*(lowz/NDivz))/(Lz*(highz/NDivz)-Lz*(lowz/NDivz));}
else{v=0;};
Vx=V000*(1 - t)*(1 - u)*(1 - v) +V100*t*(1 - u)*(1 - v) +
V010*(1 - t)* u *(1 - v) + V001*(1 - t)*(1 - u)*v +
V101*t*(1 - u)*v + V011*(1 - t)*u*v + V110*t*u*(1 - v) + V111*t*u*v;
Adresse=Hash(lowx,lowy,lowz);
TVy->GetEntryWithIndex(Adresse,0);
V000=V_Vy;
Adresse=Hash(lowx,-highy,lowz);
TVy->GetEntryWithIndex(Adresse,0);
V010=V_Vy;
Adresse=Hash(highx,lowy,lowz);
TVy->GetEntryWithIndex(Adresse,0);
V100=V_Vy;
Adresse=Hash(highx,-highy,lowz);
TVy->GetEntryWithIndex(Adresse,0);
V110=V_Vy;
Adresse=Hash(lowx,lowy,highz);
TVy->GetEntryWithIndex(Adresse,0);
V001=V_Vy;
Adresse=Hash(lowx,highy,highz);
TVy->GetEntryWithIndex(Adresse,0);
V011=V_Vy;
Adresse=Hash(highx,lowy,highz);
TVy->GetEntryWithIndex(Adresse,0);
V101=V_Vy;
Adresse=Hash(highx,highy,highz);
TVy->GetEntryWithIndex(Adresse,0);
V111=V_Vy;
Vy=V000*(1 - t)*(1 - u)*(1 - v) +V100*t*(1 - u)*(1 - v) +
V010*(1 - t)* u *(1 - v) + V001*(1 - t)*(1 - u)*v +
V101*t*(1 - u)*v + V011*(1 - t)*u*v + V110*t*u*(1 - v) + V111*t*u*v;
};
void CTDR_Detecteur::Interpole2D(double x, double y)
{
double t,u;
double V00,V01,V10,V11;
SetPoints(x,y,Lz);
if(highx!=lowx){t=(x-Lx*(lowx/NDivx-0.5))/(Lx*(highx/NDivx-0.5)-Lx*(lowx/NDivx-0.5));}
else{t=0;};
if(highy!=lowy){u=(y-Ly*(lowy/NDivy-0.5))/(Ly*(highy/NDivy-0.5)-Ly*(lowy/NDivy-0.5));}
else{u=0;};
Long64_t Adresse=0;
Adresse= Hash(lowx,lowy,NDivz);
TVx->GetEntryWithIndex(Adresse,0);
V00=V_Vx;
Adresse=Hash(lowx,highy,NDivz);
TVx->GetEntryWithIndex(Adresse,0);
V01=V_Vx;
Adresse=Hash(highx,lowy,NDivz);
TVx->GetEntryWithIndex(Adresse,0);
V10=V_Vx;
Adresse=Hash(highx,highy,NDivz);
TVx->GetEntryWithIndex(Adresse,0);
V11=V_Vx;
Vx=V00*(1-t)*(1-u) + V10*t*(1-u) + V01*(1-t)*u +V11*t*u;
Adresse=Hash(lowx,lowy,NDivz);
TVy->GetEntryWithIndex(Adresse,0);
V00=V_Vy;
Adresse=Hash(lowx,highy,NDivz);
TVy->GetEntryWithIndex(Adresse,0);
V01=V_Vy;
Adresse=Hash(highx,lowy,NDivz);
TVy->GetEntryWithIndex(Adresse,0);
V10=V_Vy;
Adresse=Hash(highx,highy,NDivz);
TVy->GetEntryWithIndex(Adresse,0);
V11=V_Vy;
Vy=V00*(1-t)*(1-u) + V10*t*(1-u) + V01*(1-t)*u +V11*t*u;
};
void CTDR_Detecteur::Detecte(CTDR_Interaction &inter)
{
Vxf=0;
Vyf=0;
for(int i=0;i<inter.GetN();i++){
if(fabs(inter.GetCharge(i).GetX())>Lx/2 | fabs(inter.GetCharge(i).GetY())>Ly/2 )
{Vxf+=0;
Vyf+=0;}
else{ Potentiel(inter.GetCharge(i).GetX(),inter.GetCharge(i).GetY(),inter.GetCharge(i).GetZ());
Vxf+=Vx*inter.GetCharge(i).GetQ();
Vyf+=Vy*inter.GetCharge(i).GetQ();
};
};
inter.SetQx(Vxf);
inter.SetQy(Vyf);
};
void CTDR_Detecteur::Detecte(CTDR_Interaction &inter,ofstream &off)
{
Vxf=0;
Vyf=0;
for(int i=0;i<inter.GetN();i++){
if(fabs(inter.GetCharge(i).GetX())>Lx/2 | fabs(inter.GetCharge(i).GetY())>Ly/2 )
{Vxf+=0;
Vyf+=0;}
else if(inter.GetCharge(i).GetZ()>=Lz){Potentiel(inter.GetCharge(i).GetX(),inter.GetCharge(i).GetY(),Lz);
Vxf+=Vx*inter.GetCharge(i).GetQ();
Vyf+=Vy*inter.GetCharge(i).GetQ();
}
else{ Potentiel(inter.GetCharge(i).GetX(),inter.GetCharge(i).GetY(),inter.GetCharge(i).GetZ());
Vxf+=Vx*inter.GetCharge(i).GetQ();
Vyf+=Vy*inter.GetCharge(i).GetQ();
};
};
Vxf-=inter.GetQx();
Vyf-=inter.GetQy();
off << inter.Gett() << " " << Vxf << " " << Vyf << endl;
cout <<"(t,Vx,Vy): " << inter.Gett() << " " << Vxf << " " << Vyf << endl;
};
void CTDR_Detecteur::Detecte(CTDR_Interaction &inter,ofstream &off,int N_canaux)
{
double *Vxt=new double[2*N_canaux+1];
double *Vyt=new double[2*N_canaux+1];
for(int canal=-N_canaux;canal<=N_canaux;canal++)
{
Vyt[canal+N_canaux]=0;
Vxt[canal+N_canaux]=0;
};
for(int canalx=-N_canaux;canalx<=N_canaux;canalx++)
{
for(int canaly=-N_canaux;canaly<=N_canaux;canaly++)
{
for(int i=0;i<inter.GetN();i++){
if(fabs(inter.GetCharge(i).GetX()-canalx*periode)>Lx/2 | fabs(inter.GetCharge(i).GetY()-canaly*periode)>Ly/2 )
{
Vxt[canalx+N_canaux]+=0;
Vyt[canaly+N_canaux]+=0;
}
else if(inter.GetCharge(i).GetZ()>=Lz){Potentiel(inter.GetCharge(i).GetX()-canalx*periode,inter.GetCharge(i).GetY()-canaly*periode,Lz);
Vxt[canalx+N_canaux]+=Vx*inter.GetCharge(i).GetQ();
Vyt[canaly+N_canaux]+=Vy*inter.GetCharge(i).GetQ();
}
else{ Potentiel(inter.GetCharge(i).GetX()-canalx*periode,inter.GetCharge(i).GetY()-canaly*periode,inter.GetCharge(i).GetZ());
Vxt[canalx+N_canaux]+=Vx*inter.GetCharge(i).GetQ();
Vyt[canaly+N_canaux]+=Vy*inter.GetCharge(i).GetQ();
};
};
};};
off << inter.Gett();
cout << inter.Gett();
TString str , str2;
for(int canal=0;canal<=2*N_canaux;canal++)
{
str.Form(" %6.4f ",Vxt[canal]);
str2.Form(" %6.4f ",Vyt[canal]);
off << str << str2;
cout << str << str2;
};
off << endl;
cout << endl;
delete Vxt;
delete Vyt;
};
void CTDR_Detecteur::Detectef(CTDR_Interaction &inter,ofstream &off)
{
Vxf=0;
Vyf=0;
for(int i=0;i<inter.GetN();i++){
if(fabs(inter.GetCharge(i).GetX())>Lx/2 | fabs(inter.GetCharge(i).GetY())>Ly/2 )
{ off << inter.GetCharge(i).GetX() << " " << inter.GetCharge(i).GetY() << " " << inter.GetCharge(i).GetZ() << " " << 0 << " " << 0 << ' ' << inter.GetCharge(i).GetQ()<< endl;
cout << "hors pixel " <<endl;
}
else{ if(inter.GetCharge(i).GetZ()>=Lz){Potentiel(inter.GetCharge(i).GetX(),inter.GetCharge(i).GetY(),Lz);
off << inter.GetCharge(i).GetX() << " " << inter.GetCharge(i).GetY() << " " << inter.GetCharge(i).GetZ() << " " << Vx << " " << Vy << ' ' << inter.GetCharge(i).GetQ()<< endl;
Vxf+=Vx*inter.GetCharge(i).GetQ();
Vyf+=Vy*inter.GetCharge(i).GetQ();
cout << "collecte " <<endl;
}
else{Potentiel(inter.GetCharge(i).GetX(),inter.GetCharge(i).GetY(),inter.GetCharge(i).GetZ());
off << inter.GetCharge(i).GetX() << " " << inter.GetCharge(i).GetY() << " " << inter.GetCharge(i).GetZ() << " " << Vx << " " << Vy << ' ' << inter.GetCharge(i).GetQ()<< endl;
Vxf+=Vx*inter.GetCharge(i).GetQ();
Vyf+=Vy*inter.GetCharge(i).GetQ();
cout << "piege " <<endl; };};
};
Vxf-=inter.GetQx();
Vyf-=inter.GetQy();
};
double CTDR_Detecteur::GetVx()
{
return Vxf;
};
double CTDR_Detecteur::GetVy()
{
return Vyf;
};
void CTDR_Detecteur::Test(double x , double y ,double z )
{
Potentiel(x,y,z);
cout << "(z,Vx,Vy): " << z << ' ' << Vx << ' ' << Vy << endl;
};
ROOT page - Class index - Class Hierarchy - Top of the page
This page has been automatically generated. If you have any comments or suggestions about the page layout send a mail to ROOT support, or contact the developers with any questions or problems regarding ROOT.