#include <cstdlib>
#include <iostream>
#include <fstream>
#include <math.h>
#include <stdlib.h>
#include <stdio.h>
#include <string>
#include "CTDR_Signal.h"
using namespace std;
ClassImp(CTDR_Signal);
CTDR_Signal::CTDR_Signal(){};
CTDR_Signal::CTDR_Signal(TString nomFichier,int Channel)
{
sigx = new TGraph();
sigy= new TGraph();
ifstream Vin(nomFichier,ios::in);
int i=1;
double temps,Vxtemp,Vytemp;
Vin >> temps >> Vxtemp >> Vytemp;
double VY0=Vytemp;
double VX0=Vxtemp;
while(!Vin.eof())
{
Vin >> temps >> Vxtemp >> Vytemp;
sigx->SetPoint(i,temps,Vxtemp-VX0);
sigy->SetPoint(i,temps,Vytemp-VY0);
i++;
};
Vin.close();
N=i;
t=sigx->GetX();
Vx=sigx->GetY();
Vy=sigy->GetY();
this->Channel=Channel;
TString str;
str.Form("X Channel %i",Channel);
sigx->SetTitle(str);
sigx->GetXaxis()->SetTitle("Time (s)");
sigx->GetYaxis()->SetTitle("Collected Charge( keV)");
str.Form("Y Channel %i",Channel);
sigy->SetTitle(str);
sigy->GetXaxis()->SetTitle("Time (s)");
sigy->GetYaxis()->SetTitle("Collected Charge( keV)");
};
CTDR_Signal::CTDR_Signal(double *t,double *Vx,double *Vy,int N, int Channel){
this->t=t;
this->Vx=Vx;
this->Vy=Vy;
this->N=N;
this->Channel=Channel;
sigx = new TGraph(N-1,t,Vx);
sigy = new TGraph(N-1,t,Vy);
TString str;
str.Form("X Channel %i",Channel);
sigx->SetTitle(str);
sigx->GetXaxis()->SetTitle("Time (s)");
sigx->GetYaxis()->SetTitle("Collected Charge( keV)");
str.Form("Y Channel %i",Channel);
sigy->SetTitle(str);
sigy->GetXaxis()->SetTitle("Time (s)");
sigy->GetYaxis()->SetTitle("Collected Charge( keV)");
};
void CTDR_Signal::operator+=(CTDR_Signal another){
int Npas;
if(this->N < another.GetN()){Npas=another.GetN();}
else {Npas=this->N;};
double tmin1,tmin2,tmax1,tmax2,dt,temps;
tmin1=this->t[1];
tmax1=this->t[this->N];
tmin2=another.t[1];
tmax2=another.t[another.GetN()];
cout << tmin1 << " " << tmax1 << " " << tmin2 << " " << tmax2 << endl;
if(tmax1>tmax2)dt=tmax1/(Npas-1);
else dt=tmax2/(Npas-1);
temps=0;
this->t=new double[Npas];
this->Vx=new double[Npas];
this->Vy=new double[Npas];
for(int i=0;i<Npas;i++){
this->t[i]=temps;
this->Vx[i]=0;
this->Vy[i]=0;
if(temps<tmin1){
this->Vx[i]+=0;
this->Vy[i]+=0;
}
else if(temps>tmax1){
this->Vx[i]+=this->sigx->Eval(tmax1);
this->Vy[i]+=this->sigy->Eval(tmax1);
}
else{
this->Vx[i]+=this->sigx->Eval(temps);
this->Vy[i]+=this->sigy->Eval(temps);
};
if(temps<tmin2){
this->Vx[i]+=0;
this->Vy[i]+=0;
}
else if(temps>tmax2){
this->Vx[i]+=another.sigx->Eval(tmax2);
this->Vy[i]+=another.sigy->Eval(tmax2);
}
else{
this->Vx[i]+=another.sigx->Eval(temps);
this->Vy[i]+=another.sigy->Eval(temps);
};
temps+=dt;
};
this->sigx=new TGraph(Npas-1,t,Vx);
this->sigy=new TGraph(Npas-1,t,Vy);
this->N=Npas;
};
void CTDR_Signal::operator=(CTDR_Signal another){
this->Vx=another.GetVx();
this->Vy=another.GetVy();
this->t=another.Gett();
this->Channel=another.GetChannel();
this->N=another.GetN();
this->sigx=another.GetGraphX();
this->sigy=another.GetGraphY();
};
void CTDR_Signal::Trace(){
TCanvas *can=new TCanvas("Signal X");
TMultiGraph *multi=new TMultiGraph("multi","Signaux simul#acute{e}s");
sigx = new TGraph(N-1,t,Vx);
sigy = new TGraph(N-1,t,Vy);
multi->Add(sigx);
multi->Add(sigy);
multi->Draw("AL");
};
TGraph* CTDR_Signal::GetGraphX(){
return sigx;
};
TGraph* CTDR_Signal::GetGraphY(){
return sigy;
};
double* CTDR_Signal::GetVx(){
return Vx;
};
double* CTDR_Signal::GetVy(){
return Vy;
};
double* CTDR_Signal::Gett(){
return t;
};
int CTDR_Signal::GetN(){
return N;
};
int CTDR_Signal::GetChannel(){
return Channel;
};
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.