#include "MultiVect.h"
ClassImp(MultiVect)


 MultiVect::MultiVect(Char_t *FileName,Int_t y,Int_t x)
{
  //Constructor :  Char *FileName    ; name of the file  example "foo.dat" 
  //		   Int_t y	     ; number of clomuns :1000 is default value
  //		   Int_t x           ; number of entries in a row: 9 is default
NumX=x;
NumY=y;
FILE *in;
mv=TArrayF(NumY*NumX);
if((in=fopen((const Char_t *)FileName,"r+"))==NULL) {printf("n Error opening file for readingn"); return;}
FDVError=0;
TimeError=0;
Eqv=0;
Read(in,0,0);
fclose(in);
}

 void MultiVect::ShiftPoints(Float_t start,Float_t end,Float_t shift,Float_t lowT, Float_t hiT)
{
  //Shift points between start and end in time for a value of shift
  //The following condition must be fullfilled  T<hiT and T>lowT
Int_t i;
Float_t temp;
Float_t time;
if(StartTime==-111111) {printf("Start Time not defined! Draw graphs first!!!n"); return;}
for(i=0;i<NumY;i++)
  {
    temp=GetT(i); time=GetTime(i,3600,Eqv)-StartTime;
    if(temp>lowT && temp<hiT)
      if(time>start && time<end) SetFDV(i,GetFDV(i)+shift);
    //    printf("T=%f Time=%fn",temp,time);
  }

}

 void MultiVect::ScalePoints(Float_t start,Float_t end,Float_t shift,Float_t lowT, Float_t hiT)
{
  //Shift points between start and end in time for a value of shift
  //The following condition must be fullfilled  T<hiT and T>lowT
Int_t i;
Float_t temp;
Float_t time;
if(StartTime==-111111) {printf("Start Time not defined! Draw graphs first!!!n"); return;}
for(i=0;i<NumY;i++)
  {
    temp=GetT(i); time=GetTime(i,3600,Eqv)-StartTime;
    if(temp>lowT && temp<hiT)
      if(time>start && time<end) SetFDV(i,GetFDV(i)*shift);
    //    printf("T=%f Time=%fn",temp,time);
  }

}

 void MultiVect::ReadEqvTime(Char_t *FileName)
{
  // Reads time file with information about elevated temperature time intervals
  //			Char_t *FileName   ;  file name (File should be ASCII)
  //		        Every line of the file looks like::  year month day hour minute second elevated_temperature normalization_temperature
  //					Example::  100 5 24 15 24 00 313 293
  //					May 24th 2000,  15:24:00  kept at T=313K; want time noramlized to T=293K 
  //
  //			To use the eqivalent time calculation Eqv has to be set to 1 and Ea - activation energy has
  //			to set to desired value.
Int_t i=0;
FILE *tin;
if((tin=fopen(FileName,"r+"))==NULL) {printf("n Error opening file for readingn"); return;}
while(!feof(tin))
  {
    fscanf(tin,"%f %f %f %f %f %f %f %fn",&ETime[i*9],&ETime[i*9+1],&ETime[i*9+2],&ETime[i*9+3],&ETime[i*9+4],&ETime[i*9+5],&ETime[i*9+6],&ETime[i*9+7]);
    ETime[i*9+8]=GetTime(&ETime[i*9],3600);    
    printf("%2.0f %2.0f %2.0f %2.0f %2.0f %2.0f %f %f %fn",ETime[i*9],ETime[i*9+1],ETime[i*9+2],ETime[i*9+3],ETime[i*9+4],ETime[i*9+5],ETime[i*9+6],ETime[i*9+7],ETime[i*9+8]);
    
    i++;
    NumETime=i;
  }
fclose(tin);
}

 MultiVect::~MultiVect()
{
  // Default destructor
}

 void  MultiVect::Read(FILE *in,Int_t where,Int_t show)
  {
    // Reads in the file:  FILE *in     ; stream pointer
    //                     Int_t where  ; position in the memory where it is read
    //			   Int_t show   ; show what has been read on the display
Float_t *temp=new Float_t [NumX];
Int_t i=0,j=0;
switch(where)
{
case 0:  j=0; break;
case 1:  j=NumY; break;
} 

while(!feof(in))
  {
    for(i=0;i<NumX;i++) {fscanf(in,"%f",&temp[i]); if(show) {printf("%f ",temp[i]); if(i==NumX-1) printf("n");}}
 AddVector(j,temp);  j++;
  }
 NumY=j;
}

 void  MultiVect::AddVector(Int_t pos,Float_t *temp)
{
//Add a vector in the memomory !! 
//			Int_t pos     ;       column number , 
//			Floa_t *temp  ;       vector to be written 
  Int_t i;
  if(pos > NumY) {mv.Set((NumY+1)*NumX); pos=NumY; NumY++;}
  for(i=0;i<NumX;i++) mv[pos*NumX+i]=temp[i];
} 

 void MultiVect::Print(Int_t step)
{
  // Prints information about the measurements!!
  //	Int step  ;  evrey step measurements is shown

Int_t i,j;
  for(j=0;j<NumY;j+=step)
    {
      printf("Line %d:: DATE: ",j);
	 for(i=0;i<NumX;i++)
	     { 
	       if(i<2) printf("%2.0f.",mv[j*NumX+i]);
	       if(i==2) printf("%2.0f TIME: ",mv[j*NumX+i]);
	       if(i>=3 && i<6) printf("%2.0f:",mv[j*NumX+i]);
	       if(i==6) printf(" :: FDV=%f",mv[j*NumX+i]);
	       if(i==7) printf(" I=%f uA",mv[j*NumX+i]*1e6);
	       if(i==8) printf(" T=%4.1fn",mv[j*NumX+i]);
	     }
    }

  printf("EQVIVALENT TIME CALCULATION:::n");
    for(i=0;i<NumETime;i++)
      {
    printf("%2.0f %2.0f %2.0f %2.0f %2.0f %2.0f %f %f %fn",ETime[i*9],ETime[i*9+1],ETime[i*9+2],ETime[i*9+3],ETime[i*9+4],ETime[i*9+5],ETime[i*9+6],ETime[i*9+7],ETime[i*9+8]);
      }
}


 TGraph *MultiVect::FDV(Int_t start, Int_t end,Float_t scale,Int_t vect,Float_t ST)
{
  // Draws a FDV vs. time plot: 
  //			Int_t start    ; index of the first point to be drawn
  //			Int_t end      ; index of the last point to be draw
  //			Float_t scale  ; factor in seconds to calculate time (default = 3600) example: 60 means scale in minutes
  //	The function returns a pointer to TGraph and stores the plot in the class variable TGraph *cg;
if(end==-1111) end=NumY;
Float_t *fdv=new Float_t[end-start+1];
Float_t *x=new Float_t[end-start+1];
Float_t *fdve=new Float_t[end-start+1];
Float_t *xe=new Float_t[end-start+1];
 if(ST!=-1111) StartTime=ST; else
StartTime=GetTime(0,scale);

for(Int_t i=start;i<end;i++)
  {
    fdv[i-start]=mv[i*NumX+vect];
    x[i-start]=GetTime(i,scale,Eqv)-StartTime;     
    xe[i-start]=TimeError/scale;
    fdve[i-start]=FDVError;
  }
TGraphErrors *it=new TGraphErrors(end-start,x,fdv,xe,fdve);
// it->SetLineWidth(4);    //zakomentirano zaradi jankove prosnje
// it->SetMarkerStyle(21); //zakomentirano zaradi jankove prosnje

TString title="FDV vs. Time    "+GrafName; 

it->SetTitle((const char *)title);
it->Draw("APL");
it->GetHistogram()->SetXTitle("time[h]");
it->GetHistogram()->SetYTitle("V_{FD} [V]");
it->GetHistogram()->Draw();
 it->Draw("APL");
cg=it;
return(it);


}


 TGraph *MultiVect::Neff(Float_t Fluence,Int_t start, Int_t end,Float_t scale,Float_t thickness)
{
  // Draws Neff vs. time plot!!!!
  //			Float_t Fluence    ; fluence to which the detector has been irradiated in 10^12
  //			Int_t start        ; index of the first point to be drawn  (defaulf = 0)
  //			Int_t end          ; index of the last point to be draw    (defaulf = last point in the graph)  
  //			Float_t scale 	   ; time scale (see FDV)                 (defaulf = 3600)
  //			Float_t thickness  ; thickness of the detector in microns (defaulf = 300)
  // The function returns a pointer to TGraph and stores the plot in the class variable TGraph *cg;
if(end==-1111) end=NumY;
Int_t i;
TGraphErrors *it;
Float_t cvalue;
Float_t *fdv=new Float_t[end-start+1];
Float_t *fdve=new Float_t[end-start+1];
Float_t *x=new Float_t[end-start+1];
Float_t *xe=new Float_t[end-start+1];
StartTime=GetTime(0,scale);
 for( i=start;i<end;i++)
  { 
    x[i-start]=GetTime(i,scale,Eqv)-StartTime;   
    xe[i-start]=TimeError;   
    fdv[i-start]=mv[i*NumX+6]*1.4369e-2/Fluence*TMath::Power(300/thickness,2)*1e2;
    fdve[i-start]=FDVError*1.4369e-2/Fluence*TMath::Power(300/thickness,2)*1e2;
  }
it=new TGraphErrors(end-start,x,fdv,xe,fdve); 
   
/// it->SetLineWidth(4); //zakomentirano zaradi Jankove prosnje
// it->SetMarkerStyle(21);


TString title="Neff  vs. Time    "+GrafName; 
 
it->SetTitle((const char *)title);
it->Draw("APL");
it->GetHistogram()->SetXTitle("time[h]");
it->GetHistogram()->SetYTitle("N_{eff}/#Phi_{eq} [10^{-2} cm^{-1}]");
it->GetHistogram()->Draw();
 it->Draw("APL");

delete [] fdve;
delete [] xe;
delete [] x;
delete [] fdv;
cg=it;
return(it);
}


 TGraph *MultiVect::Current(Int_t start, Int_t end, Float_t scale, Float_t NormTo)
{
  //Draw Leakage Current vs. time plot !!!
  //			Int_t start    ; index of the first point to be drawn
  //			Int_t end      ; index of the last point to be draw		
  //			Float_t scale  ; time scale (see FDV)(defaulf = 3600)
  //			Float_t NormTo ; Normalize Current to this temperature (default=0, meaning no normalization)
  // The function returns a pointer to TGraph
if(end==-1111) end=NumY;
Float_t *Cur=new Float_t[end-start+1];
Float_t *x=new Float_t[end-start+1];
StartTime=GetTime(0,scale);
Float_t factor;
for(Int_t i=start;i<end;i++)
  {
    if(NormTo!=0 && mv[i*NumX+8]!=0) { factor=TMath::Exp(1.21/(2*8.617385e-5)* (1/(mv[i*NumX+8]+273)-1/NormTo) );} else factor=1;
    Cur[i-start]=mv[i*NumX+7]*1e6*factor;
    x[i-start]=GetTime(i,scale,Eqv)-StartTime;     
  }
TGraph *it=new TGraph(end-start,x,Cur);
// it->SetLineWidth(4);    zakomentirano zaradi jankove prosnje
// it->SetMarkerStyle(21); zakomentirano zaradi jankove prosnje

TString title="Current vs. Time"; 

it->SetTitle((const char *)title);
it->Draw("APL");
it->GetHistogram()->SetXTitle("time[h]");
it->GetHistogram()->SetYTitle("I@FDV [#mu A]");
it->GetHistogram()->Draw();
 it->Draw("APL");

return(it);
}

 TGraph *MultiVect::T(Int_t start, Int_t end, Float_t scale)
{
 //Draw Temperature vs. time plot !!!
  //			Int_t start    ; index of the first point to be drawn
  //			Int_t end      ; index of the last point to be draw		
  //			Float_t scale  ; time scale (see FDV)(defaulf = 3600)
  // The function returns a pointer to TGraph
if(end==-1111) end=NumY;
Float_t *Temp=new Float_t[end-start+1];
Float_t *x=new Float_t[end-start+1];
StartTime=GetTime(0,scale);

for(Int_t i=start;i<end;i++)
  {
    Temp[i-start]=mv[i*NumX+8];
    x[i-start]=GetTime(i,scale)-StartTime;     
  }
TGraph *it=new TGraph(end-start,x,Temp);
// it->SetLineWidth(4); zakomentirano zaradi jankove prosnje
// it->SetMarkerStyle(21); zakomentirano zaradi jankove prosnje

TString title="Temperature vs. Time"; 

it->SetTitle((const char *)title);
it->Draw("APL");
it->GetHistogram()->SetXTitle("time[h]");
it->GetHistogram()->SetYTitle("T [C]");
it->GetHistogram()->Draw();
 it->Draw("APL");
return(it);
}

 TF1* MultiVect::Slope(Float_t start,Float_t end)
{
  // Fits the line to the section in the current graph (FDV or Neff) !!!
  //			Float_t start    ; start time of the fit
  //			Float_t end      ; end time of the fit
if(cg!=NULL)
  {
Float_t konst;
Float_t slope;
Float_t x,y;
TF1 *func=new TF1("premica","pol1",start,end); 
cg->Fit("premica","RN");
konst=func->GetParameter(0);
slope=func->GetParameter(1);
printf("slope=%f konst=%fn",slope,konst);
TLine *fitline=new TLine(start,slope*start+konst,(cg->GetXaxis()->GetXmax()),slope*(cg->GetXaxis()->GetXmax())+konst); 
fitline->SetLineColor(4);
fitline->SetLineWidth(3);
fitline->Draw();
return(func);
  }
 else 
   {
   printf("Currently no graph in the memory!n");
   return(NULL);
   }
}

 Float_t MultiVect::GetTime(Int_t y,Float_t scale,Int_t eqv)
{
// Returns the time of the single measurement
//			Int_t y        ; entry number
//			Float_t scale  ; see FDV
//			Int_t eqv      ; Calculate eqvivalent time (eqv=1); Only real time (eqv=0)
Float_t *Date=&mv[y*NumX];
return(GetTime(Date,scale,eqv));
}

 Float_t MultiVect::GetTime(Float_t *Date,Float_t scale,Int_t eqv)
{
  // Returns the time of the single measurement
  //			Float_t *Date  ; Date format array
  //			Float_t scale  ; see FDV
  //			Int_t eqv      ; Calculate eqvivalent time (eqv=1); Only real time (eqv=0)
Float_t RealTime;
Float_t MonthSec[12]={0,31,59,90,120,151,181,212,243,273,303,333};
if(Date[0]==0) Date[0]=100;
Float_t Year=(Date[0]-95)*31536000./scale;
if(((Int_t)Year)%4==0) for(Int_t i=2;i<12;i++) MonthSec[i]+=1;
Float_t Month=MonthSec[(Int_t) (Date[1]-1)]*86400./scale;
Float_t Day=Date[2]*86400./scale;;
Float_t Hour=Date[3]*3600./scale;
Float_t Min=Date[4]*60./scale;
Float_t Sec=Date[5]/scale;
//printf("%f %f %f %f %f %fn",Year,Month,Day,Hour,Min,Sec);

RealTime=Year+Month+Day+Hour+Min+Sec;
if(eqv==0) return(RealTime);  
else
  {
    Int_t i=0;
    Float_t Eqvtime=0;
    for(i=0;i<NumETime;i++) 
      {
	if(RealTime>ETime[i*9+8])
	   if(i+1>=NumETime || RealTime<ETime[(i+1)*9+8]) 
	     Eqvtime+=EqvTime(ETime[i*9+7],ETime[i*9+6],RealTime-ETime[i*9+8],Ea); else  
	     Eqvtime+=EqvTime(ETime[i*9+7],ETime[i*9+6],ETime[(i+1)*9+8]-ETime[i*9+8],Ea);  
      
      }
    if(RealTime>ETime[8]) Eqvtime+=ETime[8]; else Eqvtime=RealTime; 
    return(Eqvtime);
  }
}

 TF1* MultiVect::Fit(Char_t *fname,Double_t start, Double_t end,Double_t *par)
{
  // Fits the current graph with different  functions
  //			Char *fname     ; name of the function 
  //			Double_t start  ; start time
  //			Double_t end    ; end time
  //			Double_t par    ; initial parameters
  // Imena Funkcij:     	[] pomeni parameter, x je cas (neodvisna spremenljivka
  // 	     	"cre"    "[0]*(1-exp(-(x-[3])/[1]))+[2]"                 fiksna konstanta [2]
  // 	     	"crec"   "[0]*(1-exp(-(x-[3])/[1]))+[2]"                 
  // 		"crep"   "[0]*(1-exp(-(x-[4])/[1]))+[2]+[3]*x"           fiksna konstanta [2] [3]  
  // 		"crecp"  "[0]*(1-exp(-(x-[4])/[1]))+[2]+[3]*x"
  // 		"dec"    "[0]*exp(-(x-[3])/[1])+[2]"                     fiksna konstanta [2]
  // 		"decc"   "[0]*exp(-(x-[3])/[1])+[2]"                  
  // 		"decp"   "[0]*exp(-(x-[4])/[1])+[2]+[3]*x"               fiksna konstanta [2] [3] 
  // 		"deccp"  "[0]*exp(-(x-[4])/[1])+[2]+[3]*x"
  // 		"cre2"   "[0]*(1-exp(-(x-[5])/[1]))+[2]*(1-exp(-(x-[5])/[3]))+[4]+[5]*x"    fiksna konstanta [4] [5]
  // 		"cree"   "[0]*(1-exp(-(x-[8])/[1]))+[2]*(1-exp(-(x-[8])/[3]))+[4]+[5]*(1-exp(-(x-[6])/[7]))"  fiksna konstanta [4] [5] [6] [7]
  // 		"cree"   "[0]*(1-exp(-(x-[10])/[1]))+[2]*(1-exp(-(x-[10)/[3]))+[4]*(1-exp(-(x-[10)/[5]))+[6]+[7]*(1-exp(-(x-[10])/[9]))"  fiksna konstanta [6] [7] [8] [9]
  //		"crec2"  "[0]*(1-exp(-(x-[5])/[1]))+[2]*(1-exp(-(x-[5])/[3]))+[4]" 
  //		"crecp2" "[0]*(1-exp(-(x-[6])/[1]))+[2]*(1-exp(-(x-[6])/[3]))+[4]+[5]*x"
  // 		"dec2"   "[0]*exp(-(x-[6])/[1])+[2]*exp(-(x-[6])/[3])+[4]+[5]*x"            fiksna konstanta [4] [5]
  // 		"decc2"  "[0]*exp(-(x-[6])/[1])+[2]*exp(-(x-[6])/[3])+[4]"	
  //            "deccp2" "[0]*exp(-(x-[6])/[1])+[2]*exp(-(x-[6])/[3])+[4]+[5]*x"	  
Int_t found=0;
TF1 *func;
  if(!strcmp(fname,"cre")) { func=new TF1(fname,"[0]*(1-exp(-(x-[3])/[1]))+[2]",start,end); par[3]=start; func->SetParLimits(3,1,1); func->SetParLimits(2,par[2],par[2]);   found=1;} 
  if(!strcmp(fname,"crec")) { func=new TF1(fname,"[0]*(1-exp(-(x-[3])/[1]))+[2]",start,end); par[3]=start; func->SetParLimits(3,1,1);  found=1; } 
  if(!strcmp(fname,"crep")) { func=new TF1(fname,"[0]*(1-exp(-(x-[4])/[1]))+[2]+[3]*x",start,end); par[4]=start; func->SetParLimits(4,1,1); func->SetParLimits(2,par[2],par[2]); func->SetParLimits(3,par[3],par[3]); func->SetParLimits(4,par[4],par[4]); func->SetParLimits(5,par[5],par[5]);    found=1;} 
  if(!strcmp(fname,"crecp")) { func=new TF1(fname,"[0]*(1-exp(-(x-[4])/[1]))+[2]+[3]*x",start,end); par[4]=start; func->SetParLimits(4,1,1);  found=1; } 

  if(!strcmp(fname,"dec")) { func=new TF1(fname,"[0]*exp(-(x-[3])/[1])+[2]",start,end); par[3]=start; func->SetParLimits(3,1,1); func->SetParLimits(2,par[2],par[2]);  found=1; } 
  if(!strcmp(fname,"decc")) { func=new TF1(fname,"[0]*exp(-(x-[3])/[1])+[2]",start,end); par[3]=start; func->SetParLimits(3,1,1);  found=1; } 
  if(!strcmp(fname,"decp")) { func=new TF1(fname,"[0]*exp(-(x-[4])/[1])+[2]+[3]*x",start,end); par[4]=start; func->SetParLimits(4,1,1); func->SetParLimits(2,par[2],par[2]); func->SetParLimits(2,par[3],par[3]);  found=1; } 
  if(!strcmp(fname,"deccp")) { func=new TF1(fname,"[0]*exp(-(x-[4])/[1])+[2]+[3]*x",start,end); par[4]=start; func->SetParLimits(4,1,1);  found=1; } 


  if(!strcmp(fname,"cre2")) { func=new TF1(fname,"[0]*(1-exp(-(x-[6])/[1]))+[2]*(1-exp(-(x-[6])/[3]))+[4]+[5]*x",start,end); par[6]=start; func->SetParLimits(6,1,1); func->SetParLimits(4,par[4],par[4]); func->SetParLimits(5,par[5],par[5]);   found=1; } 
  if(!strcmp(fname,"cree")) { func=new TF1(fname,"[0]*(1-exp(-(x-[8])/[1]))+[2]*(1-exp(-(x-[8])/[3]))+[4]+[5]*(1-exp(-(x-[6])/[7]))",start,end); par[8]=start; func->SetParLimits(8,1,1); func->SetParLimits(4,par[4],par[4]); func->SetParLimits(5,par[5],par[5]); func->SetParLimits(6,par[6],par[6]); func->SetParLimits(7,par[7],par[7]);   found=1;} 
  if(!strcmp(fname,"crec2")) { func=new TF1(fname,"[0]*(1-exp(-(x-[5])/[1]))+[2]*(1-exp(-(x-[5])/[3]))+[4]",start,end); par[5]=start; func->SetParLimits(5,1,1);  found=1; } 
  if(!strcmp(fname,"cree3"))  { func=new TF1(fname,"[0]*(1-exp(-(x-[10])/[1]))+[2]*(1-exp(-(x-[10])/[3]))+[4]*(1-exp(-(x-[10])/[5]))+[6]+[7]*(1-exp(-(x-[8])/[9]))",start,end); par[10]=start; func->SetParLimits(10,1,1); func->SetParLimits(6,par[6],par[6]); func->SetParLimits(7,par[7],par[7]); func->SetParLimits(8,par[8],par[8]); func->SetParLimits(9,par[9],par[9]);   found=1;} 
  if(!strcmp(fname,"dec2")) { func=new TF1(fname,"[0]*exp(-(x-[6])/[1])+[2]*exp(-(x-[6])/[3])+[4]+[5]*x",start,end);  par[6]=start; func->SetParLimits(6,1,1); func->SetParLimits(4,par[4],par[4]); func->SetParLimits(5,par[5],par[5]);  found=1; } 
  if(!strcmp(fname,"decc2")) { func=new TF1(fname,"[0]*exp(-(x-[5])/[1])+[2]*exp(-(x-[5])/[3])+[4]",start,end);  par[5]=start; func->SetParLimits(5,1,1);  found=1; }
  if(!strcmp(fname,"deccp2")) { func=new TF1(fname,"[0]*exp(-(x-[6])/[1])+[2]*exp(-(x-[6])/[3])+[4]+[5]*x",start,end);  par[6]=start; func->SetParLimits(6,1,1);  found=1; }
  if(!strcmp(fname,"crecp2")) { func=new TF1(fname,"[0]*(1-exp(-(x-[6])/[1]))+[2]*(1-exp(-(x-[6])/[3]))+[4]+[5]*x",start,end); par[6]=start; func->SetParLimits(6,1,1);  found=1; } 
 
  if(found && cg!=NULL)
    {
      func->SetParameters(par);
      func->SetLineWidth(3);
      func->SetLineColor(2);
      cg->Fit(fname,"RB");            
    return (func);
    }
  else 
    {
      printf("Function name not found or no graph shown!!!!n");
      return (NULL);      
    }

}



 Float_t MultiVect::EqvTime(Float_t T,Float_t nT,Float_t time,Float_t Ea)
{
return( time*TMath::Exp(Ea*(1/(8.617385e-5*T)-1/(8.617385e-5*nT))));
}



//  TGraph *MultiVect::Neff(Float_t Fluence,Int_t start, Int_t end,Int_t corst, Int_t coren, Int_t opt,Float_t scale,Float_t thickness)
//  {
//  if(end==-1111) end=NumY;
//  Int_t i;
//  TGraphErrors *it;
//  Float_t cvalue;
//  Float_t slope=0;
//  Float_t konst=0;
//  Float_t *fdv=new Float_t[end-start+coren-corst+1];
//  Float_t *fdve=new Float_t[end-start+coren-corst+1];
//  Float_t *x=new Float_t[end-start+coren-corst+1];
//  Float_t *xe=new Float_t[end-start+coren-corst+1];
//  Float_t StartTime=GetTime(start,scale);

//  if(corst!=0 && coren!=0)
//    {
//  for(i=corst;i<=coren;i++)
//    {
//      fdv[i-corst]=mv[i*NumX+6]*1.4369e-2/Fluence*TMath::Power(300/thickness,2)*1e2;
//      fdve[i-corst]=FDVError*1.4369e-2/Fluence*TMath::Power(300/thickness,2)*1e2;
//      x[i-corst]=GetTime(i,scale)-StartTime;
//      xe[i-corst]=TimeError;
//    }
//  it=new TGraphErrors(coren-corst,x,fdv,xe,fdve);
//  switch(TMath::Abs(opt))
//    {
//    case 0: {slope=0; konst=0; break;}
//    case 1:  
//      {
//      TF1 *p0=new TF1("konstanta","pol0",GetTime(corst,scale)-StartTime,GetTime(coren,scale)-StartTime); 
//      it->Fit("konstanta","RN");
//      slope=0; konst=p0->GetParameter(0);
//      delete p0;
//      break;
//      }
//    case 2:  
//      {	
//      TF1 *p1=new TF1("premica","pol1",GetTime(corst,scale)-StartTime,GetTime(coren,scale)-StartTime);
//      it->Fit("premica","RN");
//      konst=p1->GetParameter(0);
//      slope=p1->GetParameter(1);
//      delete p1;
//      break;
//      }
//    }
//  delete it;
//    }
//  //printf("Start=%d,End=%d,Cstart=%d,Cend=%dn",start,end,corst,coren);
//  for( i=start;i<end;i++)
//    { 
//      x[i-start+coren]=GetTime(i,scale)-StartTime;   
//      xe[i-start+coren]=TimeError;   
//      cvalue=slope*x[i-start]+konst;
//      fdv[i-start+coren]=mv[i*NumX+6]*1.4369e-2/Fluence*TMath::Power(300/thickness,2)*1e2;
//      fdve[i-start+coren]=FDVError*1.4369e-2/Fluence*TMath::Power(300/thickness,2)*1e2;
//      if(opt>0) fdv[i-start+coren]-=cvalue;
//    }
//  if(opt>0) 
//    it=new TGraphErrors(end-start,&x[coren-corst+1],&fdv[coren-corst+1],&xe[coren-corst+1],&fdve[coren-corst+1]); else
//    it=new TGraphErrors(end-start+coren-corst,x,fdv,xe,fdve); 
   
//   it->SetLineWidth(4);
//   it->SetMarkerStyle(21);


//  TString title="Neff  vs. Time"; 
 
//  it->SetTitle((const char *)title);
//  it->Draw("APL");
//  it->GetHistogram()->SetXTitle("time[h]");
//  it->GetHistogram()->SetYTitle("Neff/Fluence [10^-2 1/cm]");
//  it->GetHistogram()->Draw();
//   it->Draw("APL");
//   if(opt<0) {
//     TLine *fitline=new TLine(x[0],slope*x[0]+konst,x[coren-corst+end-start],slope*x[coren-corst+end-start]+konst); 
//     fitline->SetLineColor(2);
//     fitline->SetLineWidth(3);
//     fitline->Draw();};
//  delete [] fdve;
//  delete [] xe;
//  delete [] x;
//  delete [] fdv;
//  cg=it;
//  return(it);
//  }



ROOT page - Class index - 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.