ROOT logo
#include "TPolyLine3D.h"
#include "KDetector.h"
#include "TFile.h"

#define ABS(x) x>0?x:-x
#define PREDZNAK(x) x>0?1:-1

// Declaration of macros used to setup the solver of partial differential equations

// #define C1(x,y,z) y3[n]=-2./(x*x)-2./(y*y)-2./(z*z);

// #define L1(x) y2[n]=1./(x*x);
// #define R1(x) y4[n]=1./(x*x);
// #define U1(x) y5[n]=1./(x*x);
// #define D1(x) y6[n]=1./(x*x);
// #define I1(x) y7[n]=1./(x*x);
// #define O1(x) y8[n]=1./(x*x);

// #define L2(x) y2[n]=2./(x*x);
// #define R2(x) y4[n]=2./(x*x);
// #define U2(x) y5[n]=2./(x*x);
// #define D2(x) y6[n]=2./(x*x);
// #define I2(x) y7[n]=2./(x*x);
// #define O2(x) y8[n]=2./(x*x);


#define C1(x,y,z) y3[n]=x+y+z;

#define L1(x) y2[n]=x;
#define R1(x) y4[n]=x;
#define U1(x) y5[n]=x;
#define D1(x) y6[n]=x;
#define I1(x) y7[n]=x;
#define O1(x) y8[n]=x;

#define L2(x) y2[n]=2*x;
#define R2(x) y4[n]=2*x;
#define U2(x) y5[n]=2*x;
#define D2(x) y6[n]=2*x;
#define I2(x) y7[n]=2*x;
#define O2(x) y8[n]=2*x;

#define C0 y3[n]=1.;
#define U0 y5[n]=0.;
#define D0 y6[n]=0.;
#define R0 y4[n]=0.;
#define L0 y2[n]=0.;
#define I0 y7[n]=0.;
#define O0 y8[n]=0.;

#define  PI  3.1415927
#define EPS 1.0e-14
#define STEP_DET_CUR 25e-9

ClassImp(KDetector)
//////////////////////////////////////////////////////////////////////////
//                                                                      //
// KDetector                                                            //
//                                                                      //
// The base class for all detectors. It incorporates the calculation of //
// electric and weithing field as well as simulation of drift.          //
//                                                                      //
// Calculation of the drift:                                            //
// BEGIN_LATEX                                                          
//  #frac{d^{2}f(x)}{dx^{2}}=#frac{f(x+h1)-2*f(x+0.5(h1-h2))+f(x-h2)}{(0.5 h1+ 0.5 h2)^{2}}
//  h1=h2=h  
//  #frac{d^{2}f(x)}{dx^{2}}=#frac{f(x+h)-2*f(x)+f(x-h)}{h^{2}}
// END_LATEX                                                            
//////////////////////////////////////////////////////////////////////////



double **a,*b,*y6,*y2,*y3,*y4,*y5,*y7,*y8;
double *dvector(long, long);
void free_dvector(double*,long,long);
/**********************************************************
 snrm: Calculates the norm of vector 
 unsigned long n - dimension of the vector
 double sx[]     - components
 itol            - <=3 real norm , otherwise max component.
************************************************************/

double snrm(unsigned long n, double sx[], int itol)
{
	unsigned long i,isamax;
	double ans;

	if (itol <= 3) {
		ans = 0.0;
		for (i=1;i<=n;i++) ans += sx[i]*sx[i];
		return sqrt(ans);
	} else {
		isamax=1;
		for (i=1;i<=n;i++) {
			if (fabs(sx[i]) > fabs(sx[isamax])) isamax=i;
		}
		return fabs(sx[isamax]);
	}
}
/* (C) Copr. 1986-92 Numerical Recipes Software &c&):)+!. */
/**********************************************************
 linbcg: Solves linear eqution sparse system Ax=b
 unsigned long n - number of equations
 int nx - # of points in x direction
 int ny - # of points in y direction
 double b[] - right side vector
 double x[] - solution of the system
  int itol  - a way to calculte norm
 double tol
 int itmax  - max # of iterations
 int *iter -
 double *err -
************************************************************/


/***************************************************** 
atimes : How to multiply the vector with the matrices 
Modified in this form by GK 4.10.2012
******************************************************/

void atimes(unsigned long n,int dim[], double x[],double r[],int itrnsp)
{
  // This is a function used to multuply the vectors with matrices!
  // Used for calculation of the electric and ramo field
  int nx,ny,nz;
  int i,j,k,q=0;
  double C,L,D,O,R,U,I;

  nx=dim[0]; ny=dim[1]; nz=dim[2];

  for(k=1; k<=nz; k++)
   for(j=1; j<=ny; j++)          /*mnozenje po stolpcu*/ 
     for(i=1; i<=nx; i++)           /*mnozenje po vrstici*/ 
       { 
	 q++;
	                 C=y3[q]*x[q];
         if(q-1>1)       L=y2[q]*x[q-1]; else L=0;
         if(q-nx>1)      D=y6[q]*x[q-nx]; else D=0;
	 if((q-nx*ny)>1) I=y7[q]*x[q-ny*nx]; else I=0;

         if(q+1<=n)       R=y4[q]*x[q+1]; else R=0;
         if(q+nx<=n)      U=y5[q]*x[q+nx]; else U=0;
	 if((q+nx*ny)<=n) O=y8[q]*x[q+ny*nx]; else O=0;
	 
	 r[q]=C+L+D+O+R+U+I;
       }
   if(n!=q) printf("\n Error in matrix solving!");
  return;
}


/***************************************************
Solve a very simple system of equations 
with the diagonal elements to be the only ones 
****************************************************/
void asolve(unsigned long n, double b[], double x[], int itrnsp)
{
  //Solve a very simple system of n equations
  //with the diagonal elements to be the only ones!
	unsigned long i;

	for(i=1;i<=n;i++) x[i]=(y3[i] != 0.0 ? b[i]/y3[i] : b[i]);
}

void linbcg(unsigned long n, int dim[], double b[], double x[], int itol, double tol,
 	int itmax, int *iter, double *err)
{
  // The main function for electric field calcualtion
	void asolve(unsigned long n, double b[], double x[], int itrnsp);
	void atimes(unsigned long n, int dim[],double x[], double r[], int itrnsp);
	double snrm(unsigned long n, double sx[], int itol);
	double *dvector(long, long);
	void free_dvector(double *, long, long);
	void nrerror(char error_text[]);
	unsigned long j;
	double ak,akden,bk,bkden,bknum,bnrm,dxnrm,xnrm,zm1nrm,znrm;
	double *p,*pp,*r,*rr,*z,*zz;

	p=dvector(1,n);
	pp=dvector(1,n);
	r=dvector(1,n);
	rr=dvector(1,n);
	z=dvector(1,n);
	zz=dvector(1,n);

	*iter=0;
	atimes(n,dim,x,r,0);
	for (j=1;j<=n;j++) {
		r[j]=b[j]-r[j];
		rr[j]=r[j];
	}
	atimes(n,dim,r,rr,0); // minimal residual invariant
	znrm=1.0;
	if (itol == 1) bnrm=snrm(n,b,itol);
	else if (itol == 2) {
		asolve(n,b,z,0);
		bnrm=snrm(n,z,itol);
	}
	else if (itol == 3 || itol == 4) {
		asolve(n,b,z,0);
		bnrm=snrm(n,z,itol);
		asolve(n,r,z,0);
		znrm=snrm(n,z,itol);
	} else nrerror("illegal itol in linbcg");
	asolve(n,r,z,0);
	while (*iter <= itmax) {
		++(*iter);
		zm1nrm=znrm;
		asolve(n,rr,zz,1);
		for (bknum=0.0,j=1;j<=n;j++) bknum += z[j]*rr[j];
		if (*iter == 1) {
			for (j=1;j<=n;j++) {
				p[j]=z[j];
				pp[j]=zz[j];
			}
		}
		else {
			bk=bknum/bkden;
			for (j=1;j<=n;j++) {
				p[j]=bk*p[j]+z[j];
				pp[j]=bk*pp[j]+zz[j];
			}
		}
		bkden=bknum;
		atimes(n,dim,p,z,0);
		for (akden=0.0,j=1;j<=n;j++) akden += z[j]*pp[j];
		ak=bknum/akden;
		atimes(n,dim,pp,zz,1);
		for (j=1;j<=n;j++) {
			x[j] += ak*p[j];
			r[j] -= ak*z[j];
			rr[j] -= ak*zz[j];
		}
		asolve(n,r,z,0);
		if (itol == 1 || itol == 2) {
			znrm=1.0;
			*err=snrm(n,r,itol)/bnrm;
		} else if (itol == 3 || itol == 4) {
			znrm=snrm(n,z,itol);
			if (fabs(zm1nrm-znrm) > EPS*znrm) {
				dxnrm=fabs(ak)*snrm(n,p,itol);
				*err=znrm/fabs(zm1nrm-znrm)*dxnrm;
			} else {
				*err=znrm/bnrm;
				continue;
			}
			xnrm=snrm(n,x,itol);
			if (*err <= 0.5*xnrm) *err /= xnrm;
			else {
				*err=znrm/bnrm;
				continue;
			}
		}
		if(*iter==itmax) {printf("\n Number of iterations exceeded the max. value \n"); 
                                  printf("iter=%4d err=%12.6f\n",*iter,*err);}

	if (*err <= tol) break;
	}

	free_dvector(p,1,n);
	free_dvector(pp,1,n);
	free_dvector(r,1,n);
    	free_dvector(rr,1,n);
	free_dvector(z,1,n);
	free_dvector(zz,1,n);
}


double KDetector::V(int val, int dowhat)
{
double voltage;
int k=0;
  if(dowhat==0) 
    {
    if(val&1) voltage=0;  
    if(val&2) voltage=Voltage;
    if(val & 32768) 
    //if bit 15 is on - many voltages
    voltage=Voltages[val>>16];
    }
  else
    {
    // numerical calculation converges faster if 1000 is used instead of 1
    // therefore the potential is scaled after calculation to 1
    if(val&16384) voltage=10000; else voltage=0;
    }
  return voltage;
}


Double_t KDetector::kappa(int i,int j, int k,  int dowhat )
{
 //Sets the effective space charge values for given point in the mesh!
  Double_t x,y,z,ret;
 
  //  if(NeffF!=NULL && NeffH!=NULL) printf("Warning:: Histogram values will be taken for Neff!\n");

    //Position in space
    x=EG->GetXaxis()->GetBinCenter(i);
    y=EG->GetYaxis()->GetBinCenter(j);
    z=EG->GetZaxis()->GetBinCenter(k);

    if(DM!=NULL) KMaterial::Mat=DM->GetBinContent(i,j,k); else KMaterial::Mat=0;

 if (dowhat==0) 
   {
     if(NeffF!=NULL)  // Neff=v enotah [um-3]
       //            ret=(NeffF->Eval(x,y,z)*1e6*e_0)/(KMaterial::Perm()*perm0); /*printf("i=%d,j=%d,y=%e\n",i,j,y);*/
            ret=(NeffF->Eval(x,y,z)*1e6*e_0)/(perm0); /*printf("i=%d,j=%d,y=%e\n",i,j,y);*/

     if(NeffH!=NULL)
       //   ret=(NeffH->GetBinContent(i,j,k)*1e6*e_0)/(KMaterial::Perm()*perm0);
            ret=(NeffH->GetBinContent(i,j,k)*1e6*e_0)/(perm0);

   }

//if (dowhat==0) if(j>nc) y=(Step*Step*1e-12)/(Si_mue*Ro*perm*perm0); else y=-(Step*Step*1e-12)/(Si_mue*Ro*perm*perm0);
 else 
    ret=0.;
return ret;
}


void KDetector::Declaration(Int_t dowhat)
{
  // New declaration for a general detector class 
  Int_t i,j,k,val;
  Double_t Rd,Ld,Dd,Ud,Od,Id;
  Double_t PRd,PLd,PDd,PUd,POd,PId;

  Double_t Xr=0,Yr=0,Zr=0;
  Double_t Xc=0,Yc=0,Zc=0;
  Double_t Xl=0,Yl=0,Zl=0;
  Int_t ii,jj,kk;
  Double_t fac;

  long n=0;
  Int_t num=nx*ny*nz;

   for (k=1;k<=nz;k++)
        for (j=1;j<=ny;j++)
		for(i=1;i<=nx;i++)
		  {
 		    n=(k-1)*nx*ny+(j-1)*nx+i; //Get index of the matrix element
  		    if(j-1<1) jj=1;  else jj=j-1;
		    if(i-1<1) ii=1;  else ii=i-1; 
		    if(k-1<1) kk=1;  else kk=k-1; 
   
		 /////////// DEFINE STEPS IN X //////////////////////////////////////
		 Rd=fabs(EG->GetXaxis()->GetBinCenter(i+1)-EG->GetXaxis()->GetBinCenter(i));
		 Ld=fabs(EG->GetXaxis()->GetBinCenter(i)-EG->GetXaxis()->GetBinCenter(i-1));
		 if(i+1>nx) Rd=Ld; if(i-1<1) Ld=Rd;

		 ////////// DEFINE PEMITIVITY IN X - normal surface ////////////////////////////
		 PRd=Perm(DM->GetBinContent(i,j,k))+Perm(DM->GetBinContent(i,jj,k));

		 if(nz!=1) 
		   {
		   PRd+=Perm(DM->GetBinContent(i,j,kk))+Perm(DM->GetBinContent(i,jj,kk));
		   PRd/=4;
		   } else PRd/=2;

		 PLd=Perm(DM->GetBinContent(ii,j,k))+Perm(DM->GetBinContent(ii,jj,k));
		 if(nz!=1) 
		   {
		     PLd+=Perm(DM->GetBinContent(ii,j,kk))+Perm(DM->GetBinContent(ii,jj,kk));
		     PLd/=4;
		   } else PLd/=2;

		 /////////// DEFINE STEPS IN Y //////////////////////////////////////

		 Ud=fabs(EG->GetYaxis()->GetBinCenter(j+1)-EG->GetYaxis()->GetBinCenter(j));
		 Dd=fabs(EG->GetYaxis()->GetBinCenter(j)-EG->GetYaxis()->GetBinCenter(j-1));
		 if(j+1>ny) Ud=Dd; if(j-1<1) Dd=Ud;

		 ////////// DEFINE PEMITIVITY IN Y ////////////////////////////
		 PUd=Perm(DM->GetBinContent(i,j,k))  +Perm(DM->GetBinContent(ii,j,k));
		 if(nz!=1) 
		   {
		     PUd+=Perm(DM->GetBinContent(i,j,kk))+Perm(DM->GetBinContent(ii,j,kk));
		     PUd/=4;
		   } else PUd/=2;

		 PDd=Perm(DM->GetBinContent(i,jj,k))+Perm(DM->GetBinContent(ii,jj,k));
		   if(nz!=1) 
		   {
		     PDd+=Perm(DM->GetBinContent(i,jj,kk))+Perm(DM->GetBinContent(ii,jj,kk));
		     PDd/=4;
		   } else PDd/=2;

		 /////////// DEFINE STEPS IN Z //////////////////////////////////////

		 Od=fabs(EG->GetZaxis()->GetBinCenter(k+1)-EG->GetZaxis()->GetBinCenter(k));
		 Id=fabs(EG->GetZaxis()->GetBinCenter(k)-EG->GetZaxis()->GetBinCenter(k-1));
		 if(k+1>nz) Od=Id; if(k-1<1) Id=Od;

		 //////////DEFINE PEMITIVITY IN Z ////////////////////////////
		 if(nz!=1)
		   {
		 POd=Perm(DM->GetBinContent(i,jj,k))+Perm(DM->GetBinContent(i,j,k))+
		     Perm(DM->GetBinContent(ii,j,k))+Perm(DM->GetBinContent(ii,jj,k));

		 PId=Perm(DM->GetBinContent(i,jj,kk))+Perm(DM->GetBinContent(i,j,kk))+
		     Perm(DM->GetBinContent(ii,j,kk))+Perm(DM->GetBinContent(ii,jj,kk));

		 POd/=4;
		 PId/=4;

		   }
		 ///////////
		 
		 if(dowhat==1) {PRd=1; PLd=1; PUd=1; PDd=1; POd=1; PId=1;}
		 
		 Xr=PRd/(0.5*Rd*(Rd+Ld));
		 Xl=PLd/(0.5*Ld*(Rd+Ld));  Xc=-(Xr+Xl);
		 Yr=PUd/(0.5*Ud*(Ud+Dd));
		 Yl=PDd/(0.5*Dd*(Ud+Dd));  Yc=-(Yr+Yl);

		 if(nz!=1)
		   {
		 Zr=POd/(0.5*Od*(Od+Id));
		 Zl=PId/(0.5*Id*(Od+Id));  Zc=-(Zr+Zl);
		   } 
		 		 
		 //////////

       		    b[n]=0.;
		    val=EG->GetBinContent(i,j,k);

		    if(nz==1) { C1(Xc,Yc,0) I0 O0 } 
		    else      { C1(Xc,Yc,Zc) I1(Zl) O1(Zr) }

		    R1(Xr) U1(Yr) L1(Xl) D1(Yl) 
		      
		      
  	            if(val&4)            {D0 b[n]-=V(EG->GetBinContent(i,j-1,k),dowhat)*Yl;}
		    if(val&8)            {U0 b[n]-=V(EG->GetBinContent(i,j+1,k),dowhat)*Yr;}
		    if(val&16)           {L0 b[n]-=V(EG->GetBinContent(i-1,j,k),dowhat)*Xl;}
		    if(val&32)           {R0 b[n]-=V(EG->GetBinContent(i+1,j,k),dowhat)*Xr;}
		    if(val&1024)         {I0 b[n]-=V(EG->GetBinContent(i,j,k-1),dowhat)*Zl;}
		    if(val&2048)         {O0 b[n]-=V(EG->GetBinContent(i,j,k+1),dowhat)*Zr;}


		    if(val&64)           {U2(Yr) D0 if(val&8)    {U0 b[n]-=V(EG->GetBinContent(i,j+1,k),dowhat)*Yr;}}
		    if(val&128)          {D2(Yl) U0 if(val&4)    {D0 b[n]-=V(EG->GetBinContent(i,j-1,k),dowhat)*Yl;}}
		    if(val&256)          {R2(Xr) L0 if(val&32)   {R0 b[n]-=V(EG->GetBinContent(i+1,j,k),dowhat)*Xr;}}
		    if(val&512)          {L2(Xl) R0 if(val&16)   {L0 b[n]-=V(EG->GetBinContent(i-1,j,k),dowhat)*Xl;}}
		    if(val&4096)         {O2(Zr) I0 if(val&2048) {O0 b[n]-=V(EG->GetBinContent(i,j,k+1),dowhat)*Zr;}}
		    if(val&8192)         {I2(Zl) O0 if(val&1024) {I0 b[n]-=V(EG->GetBinContent(i,j,k-1),dowhat)*Zl;}}


		    b[n]-=kappa(i,j,k,dowhat);
		    if(val&1 || val&2 || val>=32768)   {U0 D0 L0 R0 C0 O0 I0 b[n]=V(val,dowhat);}   
		    //if(j<=2 && i<=2) printf("stevilki: i=%d, j=%d, k=%d X=(%f %f ::%f %f), Y(%f %f :: %f %f), Z(%f %f :: %f %f) y[2,3,4,5,6,7,8]=%f %f %f %f %f %f %f :: b[n]=%f :: %d\n",i,j,k,Xr,Xl,Ld,Rd,Yr,Yl,Dd,Ud,Zr,Zl,Id,Od,y2[n],y3[n],y4[n],y5[n],y6[n],y7[n],y8[n],b[n],Mat);
		    //      if(k==nz && (j==2 || j==ny-1)) printf("stevilki: i=%d, j=%d, k=%d X=(%f %f ::%f %f), Y(%f %f :: %f %f), Z(%f %f :: %f %f) y[2,3,4,5,6,7,8]=%f %f %f %f %f %f %f :: b[n]=%f\n",i,j,k,Xr,Xl,Ld,Rd,Yr,Yl,Dd,Ud,Zr,Zl,Id,Od,y2[n],y3[n],y4[n],y5[n],y6[n],y7[n],y8[n],b[n]);
		  }

}


// void KDetector::Declaration(Int_t dowhat)
// {
//   // New declaration for a general detector class 
//   Int_t i,j,k,val;
//   Double_t Rd,Ld,Dd,Ud,Od,Id;
//   Double_t Xr=0,Yr=0,Zr=0;
//   Double_t Xc=0,Yc=0,Zc=0;
//   Double_t Xl=0,Yl=0,Zl=0;
  
//   Double_t p1,p2,p3,p4;
//   long n=0;
//   Int_t num=nx*ny*nz;

//    for (k=1;k<=nz;k++)
//         for (j=1;j<=ny;j++)
// 		for(i=1;i<=nx;i++)
// 		  {
//  		    n=(k-1)*nx*ny+(j-1)*nx+i; //Get index of the matrix element

// 		 Rd=fabs(EG->GetXaxis()->GetBinCenter(i+1)-EG->GetXaxis()->GetBinCenter(i));
// 		 Ld=fabs(EG->GetXaxis()->GetBinCenter(i)-EG->GetXaxis()->GetBinCenter(i-1));
// 		 if(i+1>nx) Rd=Ld; if(i-1<1) Ld=Rd;
// 		 Ud=fabs(EG->GetYaxis()->GetBinCenter(j+1)-EG->GetYaxis()->GetBinCenter(j));
// 		 Dd=fabs(EG->GetYaxis()->GetBinCenter(j)-EG->GetYaxis()->GetBinCenter(j-1));
// 		 if(j+1>ny) Ud=Dd; if(j-1<1) Dd=Ud;
// 		 Od=fabs(EG->GetZaxis()->GetBinCenter(k+1)-EG->GetZaxis()->GetBinCenter(k));
// 		 Id=fabs(EG->GetZaxis()->GetBinCenter(k)-EG->GetZaxis()->GetBinCenter(k-1));
// 		 if(k+1>nz) Od=Id; if(k-1<1) Id=Od;
//                  // Rd*=0.1; Ld*=0.1;
// 		 // Ud*=0.1; Dd*=0.1;
		 		 
// 		 if(Rd>=Ld) { Xr=1/(Rd*Ld); Xl=1/(Ld*Ld); } else
//           		    { Xr=1/(Rd*Rd); Xl=1/(Rd*Ld); };  Xc=-(Xr+Xl);
// 		 if(Ud>=Dd) { Yr=1/(Ud*Dd); Yl=1/(Dd*Dd); } else
// 		            { Yr=1/(Ud*Ud); Yl=1/(Ud*Dd); };  Yc=-(Yr+Yl);
// 		 if(nz!=1)  {
// 		 if(Od>=Id) { Zr=1/(Od*Id); Zl=1/(Id*Id); } else
// 		            { Zr=1/(Od*Od); Zl=1/(Od*Id); }   Zc=-(Zr+Zl);
// 		            }
		 
// 		//  //epsilon
//   		 KMaterial::Mat=DM->GetBinContent(i,j,k); p1=KMaterial::Perm();
//  		 KMaterial::Mat=DM->GetBinContent(i,j-1,k); p2=KMaterial::Perm(); Xr*=0.5*(p1+p2);
   	        
//                  KMaterial::Mat=DM->GetBinContent(i-1,j,k); p1=KMaterial::Perm();
//  		 KMaterial::Mat=DM->GetBinContent(i-1,j-1,k); p2=KMaterial::Perm(); Xl*=0.5*(p1+p2);

//                  KMaterial::Mat=DM->GetBinContent(i,j,k); p1=KMaterial::Perm();
//  		 KMaterial::Mat=DM->GetBinContent(i-1,j,k); p2=KMaterial::Perm(); Yr*=0.5*(p1+p2);

//                  KMaterial::Mat=DM->GetBinContent(i-1,j-1,k); p1=KMaterial::Perm();
//  		 KMaterial::Mat=DM->GetBinContent(i,j-1,k); p2=KMaterial::Perm(); Yl*=0.5*(p1+p2);

//                  KMaterial::Mat=DM->GetBinContent(i-1,j-1,k); p1=KMaterial::Perm();
//  		 KMaterial::Mat=DM->GetBinContent(i,j-1,k); p2=KMaterial::Perm(); 
//  		 KMaterial::Mat=DM->GetBinContent(i-1,j,k); p3=KMaterial::Perm(); 
//  		 KMaterial::Mat=DM->GetBinContent(i,j,k); p4=KMaterial::Perm(); 


	      
//        		    b[n]=0.;
// 		    val=EG->GetBinContent(i,j,k);

// 		    if(nz==1) 
//                           { 
// 			    C1(Xc,Yc,0) I0 O0 
// 			    y3[n]=-1./(Ud*Dd)*(p1+p2+p3+p4);
// 		          } 
// 		    else  
// 		          { C1(Xc,Yc,Zc) I1(Zl) O1(Zr) }

// 		    R1(Xr) U1(Yr) L1(Xl) D1(Yl) 
		      
		      
//   	            if(val&4)            {D0 b[n]-=V(EG->GetBinContent(i,j-1,k),dowhat)*Yl;}
// 		    if(val&8)            {U0 b[n]-=V(EG->GetBinContent(i,j+1,k),dowhat)*Yr;}
// 		    if(val&16)           {L0 b[n]-=V(EG->GetBinContent(i-1,j,k),dowhat)*Xl;}
// 		    if(val&32)           {R0 b[n]-=V(EG->GetBinContent(i+1,j,k),dowhat)*Xr;}
// 		    if(val&1024)         {I0 b[n]-=V(EG->GetBinContent(i,j,k-1),dowhat)*Zl;}
// 		    if(val&2048)         {O0 b[n]-=V(EG->GetBinContent(i,j,k+1),dowhat)*Zr;}


// 		    if(val&64)           {U2(Yr) D0 if(val&8)    {U0 b[n]-=V(EG->GetBinContent(i,j+1,k),dowhat)*Yr;}}
// 		    if(val&128)          {D2(Yl) U0 if(val&4)    {D0 b[n]-=V(EG->GetBinContent(i,j-1,k),dowhat)*Yl;}}
// 		    if(val&256)          {R2(Xr) L0 if(val&32)   {R0 b[n]-=V(EG->GetBinContent(i+1,j,k),dowhat)*Xr;}}
// 		    if(val&512)          {L2(Xl) R0 if(val&16)   {L0 b[n]-=V(EG->GetBinContent(i-1,j,k),dowhat)*Xl;}}
// 		    if(val&4096)         {O2(Zr) I0 if(val&2048) {O0 b[n]-=V(EG->GetBinContent(i,j,k+1),dowhat)*Zr;}}
// 		    if(val&8192)         {I2(Zl) O0 if(val&1024) {I0 b[n]-=V(EG->GetBinContent(i,j,k-1),dowhat)*Zl;}}


// 		    b[n]-=kappa(i,j,k,dowhat);
// 		    if(val&1 || val&2)   {U0 D0 L0 R0 C0 O0 I0 b[n]=V(val,dowhat);}   
// 		    	    if(j>=79 && j<82) printf("stevilki: i=%d, j=%d, k=%d X=(%f %f ::%f %f), Y(%f %f :: %f %f), Z(%f %f :: %f %f) y[2,3,4,5,6,7,8]=%f %f %f %f %f %f %f :: b[n]=%f :: %d\n",i,j,k,Xr,Xl,Ld,Rd,Yr,Yl,Dd,Ud,Zr,Zl,Id,Od,y2[n],y3[n],y4[n],y5[n],y6[n],y7[n],y8[n],b[n],Mat);
// 		    //      if(k==nz && (j==2 || j==ny-1)) printf("stevilki: i=%d, j=%d, k=%d X=(%f %f ::%f %f), Y(%f %f :: %f %f), Z(%f %f :: %f %f) y[2,3,4,5,6,7,8]=%f %f %f %f %f %f %f :: b[n]=%f\n",i,j,k,Xr,Xl,Ld,Rd,Yr,Yl,Dd,Ud,Zr,Zl,Id,Od,y2[n],y3[n],y4[n],y5[n],y6[n],y7[n],y8[n],b[n]);
// 		  }

// }


void KDetector::CalField(Int_t what)
{
double err;
int iteracije,i;
int num=nx*ny*nz,dim[3];
Double_t *x;
//booking memory
 b=dvector(1,num); y6=dvector(1,num); y2=dvector(1,num); 
 y3=dvector(1,num); y4=dvector(1,num); y5=dvector(1,num);
 y7=dvector(1,num); y8=dvector(1,num);
 x=dvector(1,num);    
// Setting up the boundary conditions
 printf("Setting up matrix ... \n");
 Declaration(what);
 printf("Solving matrix ...\n");
// matrix solving
for(i=1;i<=num;i++) x[i]=1.;
dim[0]=nx; dim[1]=ny; dim[2]=nz;
linbcg(num,dim,b,x,1,CalErr,MaxIter,&iteracije,&err);
// Calculating the field
if(!what)
   {
Real->U=MapToGeometry(x);
Real->CalField();
   }
 else
   {
 // Scale back to 1 from 1000 when storing the potential
 Ramo->U=MapToGeometry(x,1e-4);

Ramo->CalField();
   }
// Freeing the memory
 free_dvector(x, 1,num);   free_dvector(b, 1,num);   free_dvector(y2, 1,num); 
 free_dvector(y3, 1,num);  free_dvector(y4, 1,num);  free_dvector(y5, 1,num); 
 free_dvector(y6, 1,num);  free_dvector(y7, 1,num);  free_dvector(y8, 1,num);
}


void KDetector::Drift(Double_t sx, Double_t sy, Double_t sz, Float_t charg, KStruct *seg, Double_t t0)
{
  //Drift simulation for a point charge (Float_t charg;)
  //starting from ( sx,sy, sz)
  //KStruct *seg is the structure where the  the drift paths, drift times and induced cahrges are stored
 
  Double_t Stime=0;                       // Step time
  Double_t difx=0,dify=0,difz=0;          // diffusion steps in all directions
  Double_t sigma;                         // sigma of the diffusion step  
  Float_t *xcv,*ycv,*zcv,*time,*charge;   // drift variables to be stored in KStruct
  Double_t cx=0,cy=0,cz=0;                // current position of the charge bucket
  Double_t vel=0;                         // drift velocity
  Double_t t=0;                           // drift time
  Double_t sumc=0;                        // total induced charge
  Double_t ncx=0,ncy=0,ncz=0;             // next position of the charge bucket   
  Double_t deltacx,deltacy,deltacz;       // drift step due to drift
  
  Int_t st=0;                             // current step
  Int_t ishit=0;                          // local counter of the step
  TVector3 *EE;                           // Set up electric field vector
  TVector3 *EEN;                          // Set up electric field vector
  TVector3 FF;                            // Combined drift field
  Float_t pathlen=0;                      // pathlength
  Float_t WPot;                           // current ramo potential

// Inclusion of Magnetic field 28.8.2001 - revised 15.10.2012
TVector3 BB(B);                           // Create a magnetic field vector
Float_t muhe=1650;                        // parametrization of the magnetic field 
Float_t muhh=310;	                  // is based on simply this mobility parameters

 // Start time in the  absolute domain (used for delayed charge generation in multiplication 
 
  t=t0;

// Intitialize KStruct class and its members 
 
  xcv=seg->Xtrack; 
  ycv=seg->Ytrack;  
  zcv=seg->Ztrack; 
  time=seg->Time; 
  charge=seg->Charge; 
  seg->Clear();
  seg->PCharge=(Int_t) charg;

// start drift

cx=sx; cy=sy; cz=sz;                   // set current coordinates
xcv[st]=cx; ycv[st]=cy; zcv[st]=cz;    // put the first point in the KStruct 
time[st]=t;  charge[st]=0; 
           
EE=Real->CalFieldXYZ(cx,cy,cz);         // Get the electric field vector 
seg->Efield[st]=EE->Mag();             // Store the magnitude of E field

//printf("%d %f : (%f %f %f)\n",st,charg,cx,cy,cz);

do 
    {
      //    printf("Calculate field\n");
      st++;
      if(charg>0)
	FF=(*EE)+muhh*EE->Cross(BB); else 
	FF=(*EE)-muhe*EE->Cross(BB); 
      // "-muhe" stands for the fact that at the same 
      // field the drift direction has changed due to different charge

      //printf("Field : %f %f %f (%f %f %f)  ---- ",FF[0],FF[1],FF[2],(*EE)[0],(*EE)[1],(*EE)[2]);
      if(FF.Mag()!=0)
	{
      deltacy=-SStep*charg*FF.y()/FF.Mag();   // deltay 
      deltacx=-SStep*charg*FF.x()/FF.Mag();   // deltax
      deltacz=-SStep*charg*FF.z()/FF.Mag();   // deltaz
	}
      else { deltacx=0; deltacy=0; deltacz=0; }
	
      //    printf("Calculate velocity \n");

      if(DM!=NULL)
	KMaterial::Mat=DM->GetBinContent(DM->FindBin(cx,cy,cz)); 
      else KMaterial::Mat=0;
      
      EEN=Real->CalFieldXYZ(cx+deltacx,cy+deltacy,cz+deltacz); // get field & velocity at new location
      vel=Real->DriftVelocity( (EEN->Mag()+EE->Mag())/2,charg,Temperature,TMath::Abs(NeffF->Eval(cx,cy,cz)),MobMod());

      //printf("Calculate vel: %e EEN = %e ::: ",vel, EEN->Mag());
      if(vel==0) {
	          deltacx=0; deltacy=0; deltacz=0; 
		  difx=0; dify=0; difz=0;
		  ishit=9;
                 } 
      else 
       if(diff)                      // is diffusion ON
	{
	  Stime=SStep*1e-4/vel; // calcualte step time  
	  sigma=TMath::Sqrt(2*Kboltz*Real->Mobility(EE->Mag(),Temperature,charg,TMath::Abs(NeffF->Eval(cx,cy,cz)),MobMod())*Temperature*Stime); 
	  dify=ran->Gaus(0,sigma)*1e4; 
	  difx=ran->Gaus(0,sigma)*1e4;
	  if(nz!=1) difz=ran->Gaus(0,sigma)*1e4; else difz=0;
	}

       if((cx+deltacx+difx)>=GetUpEdge(0)) ncx=GetUpEdge(0); else
       if((cx+deltacx+difx)<GetLowEdge(0)) ncx=GetLowEdge(0); else
	 ncx=cx+(deltacx+difx);;
 
       if((cy+deltacy+dify)>=GetUpEdge(1)) ncy=GetUpEdge(1); else
       if((cy+deltacy+dify)<GetLowEdge(1)) ncy=GetLowEdge(1); else
	 ncy=cy+(deltacy+dify);

       if((cz+deltacz+difz)>=GetUpEdge(2)) ncz=GetUpEdge(2); else
       if((cz+deltacz+difz)<GetLowEdge(2)) ncz=GetLowEdge(2); else
	 ncz=cz+(deltacz+difz);

       if(Debug) printf("%d %f E=%e: x:%f->%f y:%f->%f z:%f->%f (%f %f %f): Mat=%d :: ",st,charg,EEN->Mag(),cx,ncx,cy,ncy,cz,ncz,deltacx,deltacy,deltacz, KMaterial::Mat);

       charge[st]=charg*(Ramo->CalPotXYZ(ncx,ncy,ncz)-Ramo->CalPotXYZ(cx,cy,cz));
       cx=ncx; cy=ncy; cz=ncz;

    sumc+=charge[st];

    if(vel!=0) 
      {
	t=t+SStep*1e-4/vel; //else t+=Stime;
	pathlen+=SStep;
      }

    xcv[st]=cx;
    ycv[st]=cy;
    zcv[st]=cz;
    time[st]=t;

    EE=Real->CalFieldXYZ(cx,cy,cz);     
    seg->Efield[st]=EE->Mag();

    // Checking for termination of the drift //// 

    WPot=Ramo->CalPotXYZ(cx,cy,cz);
    if(WPot>(1-Deps)) ishit=1;
    // if(TMath::Abs(WPot)<Deps) ishit=2;
    if(cx<= GetLowEdge(0)) ishit=3;
    if(cx>=  GetUpEdge(0)) ishit=4;
    if(cy<= GetLowEdge(1)) ishit=5;
    if(cy>= GetUpEdge(1))  ishit=6;
    if(cz<= GetLowEdge(2)) ishit=7;
    if(cz>= GetUpEdge(2))  ishit=8;
    if(st>=MAXPOINT-1) ishit=10;   

    if(Debug) printf("(t=%e, vel=%e) [Ch=%f ChInt=%f] Ishit=%d \n",t,vel,charge[st],sumc,ishit);

    } while (!ishit); // Do until the end of drift

   
   (*seg).Xlenght=pathlen; (*seg).Ylenght=pathlen; 
   (*seg).TTime=t; (*seg).TCharge=sumc; (*seg).Steps=st;
   delete EE; delete EEN;

return;
  }

TH1F *KDetector::Draw1D(Char_t *option, Float_t proj,Int_t axis,Float_t pos)
{
  // Draws the 1D projection of the Field
  // Char_t option;  see ::Draw()
  // Char_t proj;    see ::Draw() 
  // Int_t axis;     0=x, 1=y, 2=z;
  // Float_t pos;    position along the missing coordinate if 2D z=0.5;
  TH2F *his=Draw(option,proj);
  Int_t iter,*x,*y,i,j;
  Float_t low,up;
  if(axis==0)
    {
      iter=his->GetNbinsX(); 
      up=his->GetXaxis()->GetBinUpEdge(iter);
      low=his->GetXaxis()->GetBinLowEdge(1);
    }
  else 
    {
      iter=his->GetNbinsY();
      up=his->GetYaxis()->GetBinUpEdge(iter);
      low=his->GetYaxis()->GetBinLowEdge(1);
    }
  TH1F *his1D=new TH1F("Projection","Projection",iter,low,up);

  
  for(i=1;i<=iter;i++)
    {
      if(axis==0) his1D->SetBinContent(i, his->GetBinContent(i,his->GetYaxis()->FindBin(pos)));
      else
	his1D->SetBinContent(i,  his->GetBinContent( his->GetXaxis()->FindBin(pos),i));
    }
  return his1D;

}



TH2F *KDetector::Draw(Char_t *option, Float_t proj)
{
  //The function draws weighting and electric field and also the event display
  // Float_t proj; position along the axis of projection
  // Char_t *option:
  //           Which field do you want to plot?
  //		  W -weighting  
  // 		  E -electric 
  //              G -geometry
  //              M -material  
  //              N -Neff = space charge
  //           What do do want to plot?
  //		  P - potential 
  // 		  F - |field|
  //              X - x component of the field
  //              Y - y component of the field
  //              Z - z component of the field
  //          In case of 3D which plane?
  //              yz - the cross section is along the x value of proj
  //              xz - the cross section is along the y value of proj  
  //              xy - the cross section is along the z value of proj


KField *cf;
TH3F   *ch;
TH2F *histo=new TH2F();
TString opt(option);

 Int_t i=0;
 Int_t iproj=0;
 Int_t What=1;      // default is E
 Int_t Which=0;     // default is potential
 Int_t Which3D=3;   // default is XY

 if(opt.Contains("N")) What=5;  
 if(opt.Contains("M")) What=4;  
 if(opt.Contains("G")) What=3;  
 if(opt.Contains("W")) What=2;  
 if(opt.Contains("E")) What=1;

 if(nz>1)
   {
     if(opt.Contains("xy")) Which3D=3;  
     if(opt.Contains("xz")) Which3D=2;
     if(opt.Contains("yz")) Which3D=1;
   }

   
  if(opt.Contains("P")) Which=0;
  if(opt.Contains("F")) Which=1;
  if(opt.Contains("X")) Which=2;
  if(opt.Contains("Y")) Which=3;
  if(opt.Contains("Z")) Which=4;
  
  if(What<=2) 
    {
    if(What==2) cf=Ramo; else cf=Real;    
       switch(Which)
	 {
	 case 0: ch=cf->U;  break;
	 case 1: ch=cf->E;  break;
	 case 2: ch=cf->Ex; break;
	 case 3: ch=cf->Ey; break;
	 case 4: ch=cf->Ez; break;
	 default: ch=cf->U;  break;
	 }
    } 
  else
    {
      if(What==3) ch=(TH3F *)EG;  
      if(What==4) ch=(TH3F *)DM;  
      if(What==5) ch=(TH3F *)NeffH;  
    }

 if(nz==1) histo=KHisProject(ch,3,1); 
 else
   {
     switch(Which3D)
       {
       case 3: iproj=ch->GetZaxis()->FindBin(proj); break;
       case 2: iproj=ch->GetYaxis()->FindBin(proj); break;
       case 1: iproj=ch->GetXaxis()->FindBin(proj); break;
       }
     histo=KHisProject(ch,Which3D,iproj);
   }

 //histo->Draw("COLZ");
return histo;
}

void KDetector::MipIR(Int_t div, Float_t lambda)
{
  // The simulation of the drift for the laser induced carriers - attenuation of the light. 
  // A track is devided into Int_ div buckets. Each bucket is drifted in the field. The
  // induced currents for each carrier is calculated as the sum  all buckets. 
  //	Int_t MobMod; mobility model
  //	Float_t B; magnetic field


Double_t data[4];
 Float_t sp[3];
 Float_t Io,len=0,lent=0,lenlam,scalef=0,pscalef=0,mule,mulh;
 int i,j,k,e;
 KStruct seg,segmul;

TH1F *histop  = new TH1F("ch-","charge+",pos->GetNbinsX(),pos->GetXaxis()->GetXmin(),pos->GetXaxis()->GetXmax()); //2.23 -> 3.0
TH1F *histon  = new TH1F("ch+","charge-",neg->GetNbinsX(),neg->GetXaxis()->GetXmin(),neg->GetXaxis()->GetXmax()); 
sum->Reset(); pos->Reset(); neg->Reset();

/////////////////////////////////////////////////////////////////
// If there is no attenuation coefficient we consider that as mip
/////////////////////////////////////////////////////////////////

 if(lambda!=0)
   {
     for(k=0;k<3;k++) lent+=TMath::Power(exp[k]-enp[k],2); lent=TMath::Sqrt(lent);
     lenlam=lent/lambda;
     Io=div/(lambda*(1-TMath::Exp(-lenlam)));
     
     //     if(Debug) printf("Calculated length=%f um, lenDIVlamda=%f, I0=%f \n", lent,lenlam,I0 ); 
   }
/////////////////////////////////////////////////////////////////


for(i=0;i<div;i++) 
  { 
    for(j=0;j<3;j++) {sp[j]=((exp[j]-enp[j])/div)*i+enp[j]+(exp[j]-enp[j])/(2*div);}
    //      printf("#i=%d div=%d, pointx=%f, pointy=%f pointz=%f \n",i,div,sp[0],sp[1],sp[2]); 
    for(j=0;j<average;j++)
      { 
      
      Drift(sp[0],sp[1],sp[2],1,&seg);
      seg.GetCH(histop,1,1,tauh); 
      Drift(sp[0],sp[1],sp[2],-1,&seg);

      if(MTresh>1)  
	{
	mule=seg.GetCHMult(histon,1,1,taue);  // performing multiplication
	//      if(Debug)  printf(":: Mstep = %f ::",mule);
	}
      else
	seg.GetCH(histon,1,1,taue); 
	
      if(mule>MTresh && MTresh>1) //if the multiplication is large enough then do the hole tracking
 	{
 	  for(e=1;e<seg.Steps+1;e++)
	    {
	      Drift(seg.Xtrack[e],seg.Ytrack[e],seg.Ztrack[e],1,&segmul,seg.Time[e]); 
	      mulh=segmul.GetCHMult(histop,1,seg.MulCar[e],tauh);
	      if(mulh>BDTresh) {printf("HOLE MULTIPLICATION - BREAKDOWN\n"); BreakDown=1;}
	    }
 	}
      }

    
      histop->Scale(1/((Float_t)average)); histon->Scale(1/((Float_t)average)); 

/////////////////////////////////////////////////////////////////
// If there is no attenuation coefficient we consider that as mip
/////////////////////////////////////////////////////////////////
      if(lambda!=0)
	{
      len=0; for(k=0;k<3;k++) len+=TMath::Power(sp[k]-enp[k],2); len=TMath::Sqrt(len); 
      scalef=Io*TMath::Exp(-len/lambda);
      //      printf("step=%d ::  len=%f um, scalef=%f pscalef=%f\n",i,len,scalef,pscalef); 
      histon->Scale(scalef); histop->Scale(scalef);
      pscalef+=scalef;
      histop->Scale(lent/div); histon->Scale(lent/div); 
	}
/////////////////////////////////////////////////////////////////////////////////

      pos->Add(histop);neg->Add(histon);
      histop->Reset();
      histon->Reset();
  
  }

sum->Add(neg);
sum->Add(pos);

delete histop;
delete histon;
}


void KDetector::ShowMipIR(Int_t div, Int_t color,Int_t how)
{
  // The simulation of the drift for the minimum ionizing particles. 
  // A track is devided into Int_ div buckets. Each bucket is drifted in the field. The
  // induced currents for each carrier is calculated as the sum  all buckets. 

TGraph *gr;
TPolyLine3D *gr3D;
Float_t sp[3];
int i,j;
KStruct seg;
TLine *line;

// Draw histograms 

 if(EG!=NULL) 
   { 
     if(nz==1) KHisProject(EG,3,how)->Draw("COL");
     else
       {
       TH3F *hh=GetGeom();
       hh->SetFillColor(color);
       hh->Draw("iso");
       }
   } 

 // Draw drift paths

for(i=0;i<div;i++) 
  {
    for(j=0;j<3;j++) {sp[j]=((exp[j]-enp[j])/div)*i+enp[j]+(exp[j]-enp[j])/(2*div);}

    // hole drift
    if(Debug)   printf("Entry Point: %f %f %f \n",sp[0],sp[1],sp[2]);
      Drift(sp[0],sp[1],sp[2],1,&seg);

      if(nz==1)
      gr=new TGraph(seg.Steps,&seg.Xtrack[1],&seg.Ytrack[1]); 
      else
      gr3D=new TPolyLine3D(seg.Steps,&seg.Xtrack[1],&seg.Ytrack[1],&seg.Ztrack[1]); 	

      if(nz==1)
	{
	  gr->SetLineColor(2);
	  gr->SetLineStyle(1);
	  gr->Draw("L");
	}
      else
	{
	 gr3D->SetLineStyle(1);  
	 gr3D->SetLineColor(2); 
	 gr3D->Draw("SAME"); 
	}

      // electron drift

      Drift(sp[0],sp[1],sp[2],-1,&seg);

      if(nz==1)
      gr=new TGraph(seg.Steps,&seg.Xtrack[1],&seg.Ytrack[1]); 
      else
      gr3D=new TPolyLine3D(seg.Steps,&seg.Xtrack[1],&seg.Ytrack[1],&seg.Ztrack[1]); 	

      if(nz==1)
	{
        gr->SetLineColor(4);
	gr->SetLineStyle(3); 
	gr->Draw("L");
	}
      else
	{
	 gr3D->SetLineStyle(1);  
	 gr3D->SetLineColor(4); 
	 gr3D->Draw("SAME"); 
	}

  }
}

KDetector::KDetector()
{
//////////////////////////////////////////////////////////////////////
// Author: Gregor Kramberger                                        //
// Default constructor for KDetector class                           //
// Default = no space charge -> default space charge is function     //
//////////////////////////////////////////////////////////////////////

NeffF=new TF3("Profile","x[0]*x[1]*x[2]*0+[0]",0,1000,0,1000,0,1000);
NeffF->SetParameter(0,0);
NeffH=NULL; //Neff histogram se to NULL

//set magnetic field to zero
for(Int_t i=0;i<3;i++) B[i]=0;

// setting up default random generator - diffusion
ran=new TRandom(33);  

// Calculation parameters
 CalErr=1e-6;
 MaxIter=2000;

// histograms for storing the drift
pos=NULL; neg=NULL; sum=NULL;
SetDriftHisto(25e-9);

// setting up general variables
// multiplication 
taue=-1;   //no electron trapping 
tauh=-1;   //no hole trapping 
MTresh=-1; //no multiplication 
BDTresh=-1;
// drift
Deps=1e-5; //precision of tracking
//MobMod=1;  //Mobility parametrization
average=1; //average over waveforms
diff=0;    //diffusion
SStep=1;   //Step size of simulation
Temperature=263; //temperature
BreakDown=0; // no breakdown
Debug=0;     // bo printing of debug information
Voltage2=0;
 Ramo=new KField();
 Real=new KField();

}


KDetector::~KDetector()
{
  //Destructor of the detector class

  if(NeffF!=NULL) delete NeffF;
  if(NeffH!=NULL) delete NeffH;
  if(ran!=NULL) delete ran;
  if(pos!=NULL) delete pos;
  if(neg!=NULL) delete neg;
  if(sum!=NULL) delete sum;
  
}


void KDetector::CalM(KStruct *seg, Double_t *data, Int_t CarrierType)
    { 

      Int_t i,j,numreg=0;
      Double_t *M=new Double_t [seg->Steps+1];
      Double_t *DIF=new Double_t [seg->Steps+1];
      Double_t dx,dy,sum=1.,sum2=0,sum1=0,dif,dif1,dif2;
      //      printf("Number of Steps=%d\n",seg->Steps);
    
      for(i=1; i<seg->Steps;i++)
	{
	  //	  if(i==seg->Steps) DIF[i]=0;
	  dx=TMath::Sqrt(TMath::Power((seg->Xtrack[i+1]-seg->Xtrack[i]),2)+TMath::Power((seg->Ytrack[i+1]-seg->Ytrack[i]),2));

	  if(CarrierType<0)
	  dif=Real->alpha(0.5*(seg->Efield[i+1]+seg->Efield[i]));
	  else
	  dif=Real->beta(0.5*(seg->Efield[i+1]+seg->Efield[i]));

	  sum*=(1+dif*dx);
	  DIF[i]=sum;
	}

      //      for(i=1;i<seg->Steps;i++) { printf("Step=%d [%f %f], E=%f , a[i]=%f M(i)=%f\n",i,seg->Xtrack[i],seg->Ytrack[i],seg->Efield[i],Real->alpha(seg->Efield[i]),DIF[i]); }

     
      data[0]=DIF[seg->Steps-1]; data[1]=0; data[2]=0; data[3]=0;
      // printf("KKK %f\n",data[0]);
      for(i=1;i<seg->Steps;i++) 
	{
	  if((DIF[i]-1)/(data[0]-1)>0.8 && DIF[i]>1.02) 
	    {
	      data[1]+=seg->Xtrack[i]; data[2]+=seg->Ytrack[i]; 
	      data[3]+=seg->Time[i]; numreg++;
	      //printf("MUL=%f (X=%3.1f Y=%3.1f)::::: %e %e %e %d\n",DIF[i],seg->Xtrack[i],seg->Ytrack[i],data[1],data[2],data[3],numreg); 	      
	    }
	}
      if(numreg!=0) {data[1]/=numreg; data[2]/=numreg; data[3]/=numreg;}
    }






// void KPad::Alpha(Float_t E, Float_t Angle, Float_t *enp)
// {
//   // The simulation of the drift for the minimum ionizing particles. 
//   // A track is devided into Int_ div buckets. Each bucket is drifted in the field. The
//   // induced currents for each carrier is calculated as the sum  all buckets. 
//   //	Int_t MobMod; mobility model
//   //	Float_t B; magnetic field

// TH1F trn[4],trp[4];
// Double_t x[1000],y[1000];
// Float_t sp[3];
// int i,j,div;
// KStruct seg;
// TH1F *histop  = new TH1F("ch-","charge+",pos->GetNbinsX(),pos->GetXaxis()->GetXmin(),pos->GetXaxis()->GetXmax());
// TH1F *histon  = new TH1F("ch+","charge-",neg->GetNbinsX(),neg->GetXaxis()->GetXmin(),neg->GetXaxis()->GetXmax()); 
// sum->Reset(); pos->Reset(); neg->Reset();

// div=(Int_t) KMaterial::dEX(E,x,y,1);

// for(i=0;i<=div;i++) 
//   {
//     for(j=0;j<3;j++) {if(j==0) sp[j]=enp[j]+TMath::Sin(Angle)*x[i]; if(j==1) sp[j]=enp[j]-TMath::Cos(Angle)*x[i];} 
//     //if(+enp[j]+(exp[j]-enp[j])/(2*div);}
//     //printf("#i=%d div=%d, pointx=%f, pointy=%f weight=%f\n",i,div,sp[0],sp[1],y[i]); 
//     for(j=0;j<average;j++){ 
//       Drift(sp[0],sp[1],1,&seg,MobMod);
//       seg.GetCH(histop,1); 
//       Drift(sp[0],sp[1],-1,&seg,MobMod);
//       seg.GetCH(histon,1); 
//                      }
//     histop->Scale(y[i]/((Float_t)average)); histon->Scale(y[i]/((Float_t)average)); 
//     //    histop->Scale(0.05); histon->Scale(0.05); 
//     if(trapping) {
//        ht->Trapping(histop,trp);  
//        et->Trapping(histon,trn);
//        pos->Add(&trp[3]); neg->Add(&trn[3]);     
//     } else {pos->Add(histop);neg->Add(histon);}
//       histop->Reset();
//       histon->Reset();
  
//   }
// sum->Add(neg);
// sum->Add(pos);
// delete histop;
// delete histon;
// }

void KDetector::SetDriftHisto(Float_t x, Int_t numbins)
{
  if(x<0 || x>10000e-9) 
    printf("Selected time range out of scope !\n"); 
  else
    {
    if(pos!=NULL) delete pos;
	pos  = new TH1F("charge+","Positive Charge",numbins,0,x);
    if(neg!=NULL) delete neg;
        neg  = new TH1F("charge-","Negative Charge",numbins,0,x); 	
    if(sum!=NULL) delete sum;
	sum  = new TH1F("charge","Total Charge",numbins,0,x); 
    
    sum->SetXTitle("t [s]");  neg->SetXTitle("t [s]"); pos->SetXTitle("t [s]");
    sum->SetYTitle("I [arb.]");neg->SetYTitle("I [arb.]");pos->SetYTitle("I [arb.]");
    sum->GetYaxis()->SetTitleOffset(1.4); neg->GetYaxis()->SetTitleOffset(1.4); pos->GetYaxis()->SetTitleOffset(1.4);
    pos->SetLineColor(2);
    neg->SetLineColor(4);
    sum->SetLineColor(1);	

    }
}


/////////////////////////////////////////////////////////
void  KDetector::Save(Char_t *name,Char_t *file)
{
  Char_t str[100];
  TFile *fn=new TFile(file,"UPDATE");
  sprintf(str,"E_%s",name);
  if(Real->U!=NULL) Real->U->Write(str); else {printf("Histogram U (Electric) does not exist!\n"); return;}
  sprintf(str,"W_%s",name);
  if(Ramo->U!=NULL) Ramo->U->Write(str); else {printf("Histogram U (Ramo) does not exist!\n"); return;}
  sprintf(str,"G_%s",name);
  if(EG!=NULL) EG->Write(str);         else {printf("Histogram Geometry does not exist!\n"); return;}
  sprintf(str,"M_%s",name);
  if(DM!=NULL) DM->Write(str);         else {printf("Histogram Material does not exist!\n"); return;}
  fn->Close();
}

TFile *KDetector::Read(Char_t *name,Char_t *file)
{
  Char_t str[100];
  TFile *fn=new TFile(file);
  if(Real->U==NULL) Real->U=new TH3F();
  if(Ramo->U==NULL) Ramo->U=new TH3F();
  if(EG==NULL) EG=new TH3I();
  if(DM==NULL) DM=new TH3I();
  sprintf(str,"E_%s",name); Real->U->Read(str);
  sprintf(str,"W_%s",name); Ramo->U->Read(str);
  sprintf(str,"G_%s",name); EG->Read(str);
  sprintf(str,"M_%s",name); DM->Read(str);

   nx=EG->GetNbinsX();
   ny=EG->GetNbinsY();
   nz=EG->GetNbinsZ();

   Real->CalField();
   Ramo->CalField();
  

  return fn;
}



void KDetector::GaussBeam(Int_t div, Float_t Lambda, Float_t w0, Float_t CellX, Float_t B, Float_t lambda)  //user manca
{
  ////////////////////////////////////////////////////////////////////////////////////////
  // The simulation of the drift for Gaussian Beam.                                     //
  // A track is divided into Int_ div buckets. Each bucket is drifted in the field.     //
  // The induced currents for each carrier is calculated as the sum all buckets.        //
  //                                                                                    //
  //	- Int_t MobMod; mobility model                                                  //
  //	- Float_t B; magnetic field                                                     //
  //                                                                                    //
  //    - Lambda [um]                                                                   //
  //    - w0 [um]                                                                       //
  //                                                                                    //
  ////////////////////////////////////////////////////////////////////////////////////////

Double_t data[4];
Float_t sp[3];
Float_t Io,len=0,lent=0,lenlam,scalef=0,pscalef=0,mule,mulh;
Int_t i,j,k,e,l,Kint,KAint;
KStruct seg,segmul;
Float_t pi,w,X,xr,K,KA,PenDepth;

PenDepth=1014; //um

 pi=TMath::Pi();
xr=pi/(Lambda/3.54)*TMath::Power(w0,2);
X=enp[0]-CellX*.5;
w=w0*TMath::Power(1+TMath::Power(X/xr,2),0.5);
K=2*w/(CellX/div);
Kint=int(K);
KAint=Kint;
//printf("K=%f\n",K);

TH1F *histop  = new TH1F("ch-","charge+",pos->GetNbinsX(),pos->GetXaxis()->GetXmin(),pos->GetXaxis()->GetXmax()); //2.23 -> 3.0
TH1F *histon  = new TH1F("ch+","charge-",neg->GetNbinsX(),neg->GetXaxis()->GetXmin(),neg->GetXaxis()->GetXmax()); 
sum->Reset(); pos->Reset(); neg->Reset();

if(lambda!=0)
{
  for(k=0;k<3;k++) lent+=TMath::Power(exp[k]-enp[k],2);
  lent=TMath::Sqrt(lent);
  lenlam=lent/lambda;
  Io=div/(lambda*(1-TMath::Exp(-lenlam)));
  //     printf("Calculated length=%f um, len/lamda=%f, I0=%f\n",lent,lenlam,I0); 
}

////////////////////////////////////////////////////////////////////////////////////

for(i=0;i<div;i++) 
  for(l=0;l<=KAint;l++) 
    { 
    for(j=0;j<3;j++) {
      if ((KAint>0) && ((j==0) || (j==2)) ) {sp[j]=((exp[j]-enp[j])/div)*i+enp[j]+(exp[j]-enp[j])/(2*div);}
      else if ((KAint>0) && (j==1)) 
      {
        KA=K*TMath::Exp(-sp[0]/PenDepth);
        KAint=int(KA);
        X=sp[0]-CellX*.5;
        w=w0*TMath::Power(1+TMath::Power(X/xr,2),0.5);
        if (KAint>0) {sp[j]=((exp[j]-enp[j])/div)*i+enp[j]+(exp[j]-enp[j])/(2*div)-w+w/(.5*KAint)*l;}
        //printf("i=%i,j=%i,sp[j]=%f,w=%f,KA=%f\n",i,j,sp[j],w,KA);
      }
    else { KAint=-1; div=-1; }
    }

    for(j=0;j<average;j++)
    { 
      Drift(sp[0],sp[1],sp[2],1,&seg);
      seg.GetCH(histop,1,1,tauh); 
      Drift(sp[0],sp[1],sp[2],-1,&seg);
  
      if(MTresh>1)  
      mule=seg.GetCHMult(histon,1,1,taue);  // performing multiplication
      else          
      seg.GetCH(histon,1,1,taue); 
	
      if(mule>MTresh && MTresh>1) //if the multiplication is large enough then do the hole tracking
 	    {
        for(e=1;e<seg.Steps+1;e++)
	      {
	        Drift(seg.Xtrack[e],seg.Ytrack[e],seg.Ztrack[e],1,&segmul,seg.Time[e]); 
	        mulh=segmul.GetCHMult(histop,1,seg.MulCar[e],tauh);
	        if(mulh>BDTresh) {printf("HOLE MULTIPLICATION - BREAKDOWN\n"); BreakDown=1;}
        }
      }
    }
    
    histop->Scale(1/((Float_t)average)); histon->Scale(1/((Float_t)average)); 

    if(lambda!=0)
    {
      len=0;
      for(k=0;k<3;k++) len+=TMath::Power(sp[k]-enp[k],2); len=TMath::Sqrt(len); 
      scalef=Io*TMath::Exp(-len/lambda);
      //      printf("step=%d ::  len=%f um, scalef=%f pscalef=%f\n",i,len,scalef,pscalef); 
      histon->Scale(scalef); histop->Scale(scalef);
      pscalef+=scalef;
      histop->Scale(lent/div); histon->Scale(lent/div); 
    }
  
////////////////////////////////////////////////////////////////////////////////////

  pos->Add(histop);neg->Add(histon);
  histop->Reset();
  histon->Reset();
  }

sum->Add(neg);
sum->Add(pos);

delete histop;
delete histon;
}



void KDetector::ShowGaussBeam(Int_t div, Float_t Lambda, Float_t w0, Float_t CellX, Int_t color,Int_t how) //user manca
{
  ///////////////////////////////////////////////////////////////////////////////////////
  // Gaussian Beam for strip detector                                                  //
  //                                                                                   //
  // A track is divided into Int_ div buckets. Each bucket is drifted in the field.    //
  // The induced currents for each carrier is calculated as the sum all buckets.       //
  //                                                                                   //
  //    - Lambda [um]                                                                  //
  //    - w0 [um]                                                                      //
  ///////////////////////////////////////////////////////////////////////////////////////

TGraph *gr;
TPolyLine3D *gr3D;
Float_t sp[3];
int i,j,Kint,KAint;
KStruct seg;
TLine *line;
Float_t pi,w,X,xr,l,K,KA,PenDepth;

PenDepth=1014;

 pi=TMath::Pi();
xr=pi/(Lambda/3.54)*TMath::Power(w0,2);
X=enp[0]-CellX*.5;
w=w0*TMath::Power(1+TMath::Power(X/xr,2),0.5);
K=2*w/(CellX/div);
Kint=int(K);
KAint=Kint;
//printf("K=%f\n",K);


// Draw histograms 

if(EG!=NULL) 
{ 
  if(nz==1) KHisProject(EG,3,how)->Draw("COL");
  else
  {
    TH3F *hh=GetGeom();
    hh->SetFillColor(color);
    hh->Draw("iso");
  }
} 

// Draw drift paths

for(i=0;i<div;i++) 
  for(l=0;l<=KAint;l++) 
    { 
    for(j=0;j<3;j++) {
      if ((KAint>0) && ((j==0) || (j==2)) ) {sp[j]=((exp[j]-enp[j])/div)*i+enp[j]+(exp[j]-enp[j])/(2*div);}
      else if ((KAint>0) && (j==1)) 
      {
        KA=K*TMath::Exp(-sp[0]/PenDepth);
        KAint=int(KA);
        X=sp[0]-CellX*.5;
        w=w0*TMath::Power(1+TMath::Power(X/xr,2),0.5);
        if (KAint>0) {sp[j]=((exp[j]-enp[j])/div)*i+enp[j]+(exp[j]-enp[j])/(2*div)-w+w/(.5*KAint)*l;}
       // printf("i=%i,j=%i,sp[j]=%f,w=%f,KA=%f\n",i,j,sp[j],w,KA);
      }
    else { KAint=-1; div=-1; }
    }

    // electron drift
    if(Debug)   printf("Entry Point: %f %f %f \n",sp[0],sp[1],sp[2]);
    Drift(sp[0],sp[1],sp[2],1,&seg);

    if(nz==1)
    gr=new TGraph(seg.Steps,&seg.Xtrack[1],&seg.Ytrack[1]); 
    else
    gr3D=new TPolyLine3D(seg.Steps,&seg.Xtrack[1],&seg.Ytrack[1],&seg.Ztrack[1]); 	
    if(nz==1)
    {
      gr->SetLineColor(2);
      gr->SetLineStyle(1);
      gr->Draw("L");
    }
    else
    {
      gr3D->SetLineStyle(1);  
      gr3D->SetLineColor(2); 
      gr3D->Draw("SAME"); 
    }

    // hole drift

    Drift(sp[0],sp[1],sp[2],-1,&seg);

    if(nz==1)
    gr=new TGraph(seg.Steps,&seg.Xtrack[1],&seg.Ytrack[1]); 
    else
    gr3D=new TPolyLine3D(seg.Steps,&seg.Xtrack[1],&seg.Ytrack[1],&seg.Ztrack[1]); 	
    if(nz==1)
    {
      gr->SetLineColor(4);
      gr->SetLineStyle(3); 
      gr->Draw("L");
    }
    else
    {
      gr3D->SetLineStyle(1);  
      gr3D->SetLineColor(4); 
      gr3D->Draw("SAME"); 
    }
  }
}



 KDetector.cxx:1
 KDetector.cxx:2
 KDetector.cxx:3
 KDetector.cxx:4
 KDetector.cxx:5
 KDetector.cxx:6
 KDetector.cxx:7
 KDetector.cxx:8
 KDetector.cxx:9
 KDetector.cxx:10
 KDetector.cxx:11
 KDetector.cxx:12
 KDetector.cxx:13
 KDetector.cxx:14
 KDetector.cxx:15
 KDetector.cxx:16
 KDetector.cxx:17
 KDetector.cxx:18
 KDetector.cxx:19
 KDetector.cxx:20
 KDetector.cxx:21
 KDetector.cxx:22
 KDetector.cxx:23
 KDetector.cxx:24
 KDetector.cxx:25
 KDetector.cxx:26
 KDetector.cxx:27
 KDetector.cxx:28
 KDetector.cxx:29
 KDetector.cxx:30
 KDetector.cxx:31
 KDetector.cxx:32
 KDetector.cxx:33
 KDetector.cxx:34
 KDetector.cxx:35
 KDetector.cxx:36
 KDetector.cxx:37
 KDetector.cxx:38
 KDetector.cxx:39
 KDetector.cxx:40
 KDetector.cxx:41
 KDetector.cxx:42
 KDetector.cxx:43
 KDetector.cxx:44
 KDetector.cxx:45
 KDetector.cxx:46
 KDetector.cxx:47
 KDetector.cxx:48
 KDetector.cxx:49
 KDetector.cxx:50
 KDetector.cxx:51
 KDetector.cxx:52
 KDetector.cxx:53
 KDetector.cxx:54
 KDetector.cxx:55
 KDetector.cxx:56
 KDetector.cxx:57
 KDetector.cxx:58
 KDetector.cxx:59
 KDetector.cxx:60
 KDetector.cxx:61
 KDetector.cxx:62
 KDetector.cxx:63
 KDetector.cxx:64
 KDetector.cxx:65
 KDetector.cxx:66
 KDetector.cxx:67
 KDetector.cxx:68
 KDetector.cxx:69
 KDetector.cxx:70
 KDetector.cxx:71
 KDetector.cxx:72
 KDetector.cxx:73
 KDetector.cxx:74
 KDetector.cxx:75
 KDetector.cxx:76
 KDetector.cxx:77
 KDetector.cxx:78
 KDetector.cxx:79
 KDetector.cxx:80
 KDetector.cxx:81
 KDetector.cxx:82
 KDetector.cxx:83
 KDetector.cxx:84
 KDetector.cxx:85
 KDetector.cxx:86
 KDetector.cxx:87
 KDetector.cxx:88
 KDetector.cxx:89
 KDetector.cxx:90
 KDetector.cxx:91
 KDetector.cxx:92
 KDetector.cxx:93
 KDetector.cxx:94
 KDetector.cxx:95
 KDetector.cxx:96
 KDetector.cxx:97
 KDetector.cxx:98
 KDetector.cxx:99
 KDetector.cxx:100
 KDetector.cxx:101
 KDetector.cxx:102
 KDetector.cxx:103
 KDetector.cxx:104
 KDetector.cxx:105
 KDetector.cxx:106
 KDetector.cxx:107
 KDetector.cxx:108
 KDetector.cxx:109
 KDetector.cxx:110
 KDetector.cxx:111
 KDetector.cxx:112
 KDetector.cxx:113
 KDetector.cxx:114
 KDetector.cxx:115
 KDetector.cxx:116
 KDetector.cxx:117
 KDetector.cxx:118
 KDetector.cxx:119
 KDetector.cxx:120
 KDetector.cxx:121
 KDetector.cxx:122
 KDetector.cxx:123
 KDetector.cxx:124
 KDetector.cxx:125
 KDetector.cxx:126
 KDetector.cxx:127
 KDetector.cxx:128
 KDetector.cxx:129
 KDetector.cxx:130
 KDetector.cxx:131
 KDetector.cxx:132
 KDetector.cxx:133
 KDetector.cxx:134
 KDetector.cxx:135
 KDetector.cxx:136
 KDetector.cxx:137
 KDetector.cxx:138
 KDetector.cxx:139
 KDetector.cxx:140
 KDetector.cxx:141
 KDetector.cxx:142
 KDetector.cxx:143
 KDetector.cxx:144
 KDetector.cxx:145
 KDetector.cxx:146
 KDetector.cxx:147
 KDetector.cxx:148
 KDetector.cxx:149
 KDetector.cxx:150
 KDetector.cxx:151
 KDetector.cxx:152
 KDetector.cxx:153
 KDetector.cxx:154
 KDetector.cxx:155
 KDetector.cxx:156
 KDetector.cxx:157
 KDetector.cxx:158
 KDetector.cxx:159
 KDetector.cxx:160
 KDetector.cxx:161
 KDetector.cxx:162
 KDetector.cxx:163
 KDetector.cxx:164
 KDetector.cxx:165
 KDetector.cxx:166
 KDetector.cxx:167
 KDetector.cxx:168
 KDetector.cxx:169
 KDetector.cxx:170
 KDetector.cxx:171
 KDetector.cxx:172
 KDetector.cxx:173
 KDetector.cxx:174
 KDetector.cxx:175
 KDetector.cxx:176
 KDetector.cxx:177
 KDetector.cxx:178
 KDetector.cxx:179
 KDetector.cxx:180
 KDetector.cxx:181
 KDetector.cxx:182
 KDetector.cxx:183
 KDetector.cxx:184
 KDetector.cxx:185
 KDetector.cxx:186
 KDetector.cxx:187
 KDetector.cxx:188
 KDetector.cxx:189
 KDetector.cxx:190
 KDetector.cxx:191
 KDetector.cxx:192
 KDetector.cxx:193
 KDetector.cxx:194
 KDetector.cxx:195
 KDetector.cxx:196
 KDetector.cxx:197
 KDetector.cxx:198
 KDetector.cxx:199
 KDetector.cxx:200
 KDetector.cxx:201
 KDetector.cxx:202
 KDetector.cxx:203
 KDetector.cxx:204
 KDetector.cxx:205
 KDetector.cxx:206
 KDetector.cxx:207
 KDetector.cxx:208
 KDetector.cxx:209
 KDetector.cxx:210
 KDetector.cxx:211
 KDetector.cxx:212
 KDetector.cxx:213
 KDetector.cxx:214
 KDetector.cxx:215
 KDetector.cxx:216
 KDetector.cxx:217
 KDetector.cxx:218
 KDetector.cxx:219
 KDetector.cxx:220
 KDetector.cxx:221
 KDetector.cxx:222
 KDetector.cxx:223
 KDetector.cxx:224
 KDetector.cxx:225
 KDetector.cxx:226
 KDetector.cxx:227
 KDetector.cxx:228
 KDetector.cxx:229
 KDetector.cxx:230
 KDetector.cxx:231
 KDetector.cxx:232
 KDetector.cxx:233
 KDetector.cxx:234
 KDetector.cxx:235
 KDetector.cxx:236
 KDetector.cxx:237
 KDetector.cxx:238
 KDetector.cxx:239
 KDetector.cxx:240
 KDetector.cxx:241
 KDetector.cxx:242
 KDetector.cxx:243
 KDetector.cxx:244
 KDetector.cxx:245
 KDetector.cxx:246
 KDetector.cxx:247
 KDetector.cxx:248
 KDetector.cxx:249
 KDetector.cxx:250
 KDetector.cxx:251
 KDetector.cxx:252
 KDetector.cxx:253
 KDetector.cxx:254
 KDetector.cxx:255
 KDetector.cxx:256
 KDetector.cxx:257
 KDetector.cxx:258
 KDetector.cxx:259
 KDetector.cxx:260
 KDetector.cxx:261
 KDetector.cxx:262
 KDetector.cxx:263
 KDetector.cxx:264
 KDetector.cxx:265
 KDetector.cxx:266
 KDetector.cxx:267
 KDetector.cxx:268
 KDetector.cxx:269
 KDetector.cxx:270
 KDetector.cxx:271
 KDetector.cxx:272
 KDetector.cxx:273
 KDetector.cxx:274
 KDetector.cxx:275
 KDetector.cxx:276
 KDetector.cxx:277
 KDetector.cxx:278
 KDetector.cxx:279
 KDetector.cxx:280
 KDetector.cxx:281
 KDetector.cxx:282
 KDetector.cxx:283
 KDetector.cxx:284
 KDetector.cxx:285
 KDetector.cxx:286
 KDetector.cxx:287
 KDetector.cxx:288
 KDetector.cxx:289
 KDetector.cxx:290
 KDetector.cxx:291
 KDetector.cxx:292
 KDetector.cxx:293
 KDetector.cxx:294
 KDetector.cxx:295
 KDetector.cxx:296
 KDetector.cxx:297
 KDetector.cxx:298
 KDetector.cxx:299
 KDetector.cxx:300
 KDetector.cxx:301
 KDetector.cxx:302
 KDetector.cxx:303
 KDetector.cxx:304
 KDetector.cxx:305
 KDetector.cxx:306
 KDetector.cxx:307
 KDetector.cxx:308
 KDetector.cxx:309
 KDetector.cxx:310
 KDetector.cxx:311
 KDetector.cxx:312
 KDetector.cxx:313
 KDetector.cxx:314
 KDetector.cxx:315
 KDetector.cxx:316
 KDetector.cxx:317
 KDetector.cxx:318
 KDetector.cxx:319
 KDetector.cxx:320
 KDetector.cxx:321
 KDetector.cxx:322
 KDetector.cxx:323
 KDetector.cxx:324
 KDetector.cxx:325
 KDetector.cxx:326
 KDetector.cxx:327
 KDetector.cxx:328
 KDetector.cxx:329
 KDetector.cxx:330
 KDetector.cxx:331
 KDetector.cxx:332
 KDetector.cxx:333
 KDetector.cxx:334
 KDetector.cxx:335
 KDetector.cxx:336
 KDetector.cxx:337
 KDetector.cxx:338
 KDetector.cxx:339
 KDetector.cxx:340
 KDetector.cxx:341
 KDetector.cxx:342
 KDetector.cxx:343
 KDetector.cxx:344
 KDetector.cxx:345
 KDetector.cxx:346
 KDetector.cxx:347
 KDetector.cxx:348
 KDetector.cxx:349
 KDetector.cxx:350
 KDetector.cxx:351
 KDetector.cxx:352
 KDetector.cxx:353
 KDetector.cxx:354
 KDetector.cxx:355
 KDetector.cxx:356
 KDetector.cxx:357
 KDetector.cxx:358
 KDetector.cxx:359
 KDetector.cxx:360
 KDetector.cxx:361
 KDetector.cxx:362
 KDetector.cxx:363
 KDetector.cxx:364
 KDetector.cxx:365
 KDetector.cxx:366
 KDetector.cxx:367
 KDetector.cxx:368
 KDetector.cxx:369
 KDetector.cxx:370
 KDetector.cxx:371
 KDetector.cxx:372
 KDetector.cxx:373
 KDetector.cxx:374
 KDetector.cxx:375
 KDetector.cxx:376
 KDetector.cxx:377
 KDetector.cxx:378
 KDetector.cxx:379
 KDetector.cxx:380
 KDetector.cxx:381
 KDetector.cxx:382
 KDetector.cxx:383
 KDetector.cxx:384
 KDetector.cxx:385
 KDetector.cxx:386
 KDetector.cxx:387
 KDetector.cxx:388
 KDetector.cxx:389
 KDetector.cxx:390
 KDetector.cxx:391
 KDetector.cxx:392
 KDetector.cxx:393
 KDetector.cxx:394
 KDetector.cxx:395
 KDetector.cxx:396
 KDetector.cxx:397
 KDetector.cxx:398
 KDetector.cxx:399
 KDetector.cxx:400
 KDetector.cxx:401
 KDetector.cxx:402
 KDetector.cxx:403
 KDetector.cxx:404
 KDetector.cxx:405
 KDetector.cxx:406
 KDetector.cxx:407
 KDetector.cxx:408
 KDetector.cxx:409
 KDetector.cxx:410
 KDetector.cxx:411
 KDetector.cxx:412
 KDetector.cxx:413
 KDetector.cxx:414
 KDetector.cxx:415
 KDetector.cxx:416
 KDetector.cxx:417
 KDetector.cxx:418
 KDetector.cxx:419
 KDetector.cxx:420
 KDetector.cxx:421
 KDetector.cxx:422
 KDetector.cxx:423
 KDetector.cxx:424
 KDetector.cxx:425
 KDetector.cxx:426
 KDetector.cxx:427
 KDetector.cxx:428
 KDetector.cxx:429
 KDetector.cxx:430
 KDetector.cxx:431
 KDetector.cxx:432
 KDetector.cxx:433
 KDetector.cxx:434
 KDetector.cxx:435
 KDetector.cxx:436
 KDetector.cxx:437
 KDetector.cxx:438
 KDetector.cxx:439
 KDetector.cxx:440
 KDetector.cxx:441
 KDetector.cxx:442
 KDetector.cxx:443
 KDetector.cxx:444
 KDetector.cxx:445
 KDetector.cxx:446
 KDetector.cxx:447
 KDetector.cxx:448
 KDetector.cxx:449
 KDetector.cxx:450
 KDetector.cxx:451
 KDetector.cxx:452
 KDetector.cxx:453
 KDetector.cxx:454
 KDetector.cxx:455
 KDetector.cxx:456
 KDetector.cxx:457
 KDetector.cxx:458
 KDetector.cxx:459
 KDetector.cxx:460
 KDetector.cxx:461
 KDetector.cxx:462
 KDetector.cxx:463
 KDetector.cxx:464
 KDetector.cxx:465
 KDetector.cxx:466
 KDetector.cxx:467
 KDetector.cxx:468
 KDetector.cxx:469
 KDetector.cxx:470
 KDetector.cxx:471
 KDetector.cxx:472
 KDetector.cxx:473
 KDetector.cxx:474
 KDetector.cxx:475
 KDetector.cxx:476
 KDetector.cxx:477
 KDetector.cxx:478
 KDetector.cxx:479
 KDetector.cxx:480
 KDetector.cxx:481
 KDetector.cxx:482
 KDetector.cxx:483
 KDetector.cxx:484
 KDetector.cxx:485
 KDetector.cxx:486
 KDetector.cxx:487
 KDetector.cxx:488
 KDetector.cxx:489
 KDetector.cxx:490
 KDetector.cxx:491
 KDetector.cxx:492
 KDetector.cxx:493
 KDetector.cxx:494
 KDetector.cxx:495
 KDetector.cxx:496
 KDetector.cxx:497
 KDetector.cxx:498
 KDetector.cxx:499
 KDetector.cxx:500
 KDetector.cxx:501
 KDetector.cxx:502
 KDetector.cxx:503
 KDetector.cxx:504
 KDetector.cxx:505
 KDetector.cxx:506
 KDetector.cxx:507
 KDetector.cxx:508
 KDetector.cxx:509
 KDetector.cxx:510
 KDetector.cxx:511
 KDetector.cxx:512
 KDetector.cxx:513
 KDetector.cxx:514
 KDetector.cxx:515
 KDetector.cxx:516
 KDetector.cxx:517
 KDetector.cxx:518
 KDetector.cxx:519
 KDetector.cxx:520
 KDetector.cxx:521
 KDetector.cxx:522
 KDetector.cxx:523
 KDetector.cxx:524
 KDetector.cxx:525
 KDetector.cxx:526
 KDetector.cxx:527
 KDetector.cxx:528
 KDetector.cxx:529
 KDetector.cxx:530
 KDetector.cxx:531
 KDetector.cxx:532
 KDetector.cxx:533
 KDetector.cxx:534
 KDetector.cxx:535
 KDetector.cxx:536
 KDetector.cxx:537
 KDetector.cxx:538
 KDetector.cxx:539
 KDetector.cxx:540
 KDetector.cxx:541
 KDetector.cxx:542
 KDetector.cxx:543
 KDetector.cxx:544
 KDetector.cxx:545
 KDetector.cxx:546
 KDetector.cxx:547
 KDetector.cxx:548
 KDetector.cxx:549
 KDetector.cxx:550
 KDetector.cxx:551
 KDetector.cxx:552
 KDetector.cxx:553
 KDetector.cxx:554
 KDetector.cxx:555
 KDetector.cxx:556
 KDetector.cxx:557
 KDetector.cxx:558
 KDetector.cxx:559
 KDetector.cxx:560
 KDetector.cxx:561
 KDetector.cxx:562
 KDetector.cxx:563
 KDetector.cxx:564
 KDetector.cxx:565
 KDetector.cxx:566
 KDetector.cxx:567
 KDetector.cxx:568
 KDetector.cxx:569
 KDetector.cxx:570
 KDetector.cxx:571
 KDetector.cxx:572
 KDetector.cxx:573
 KDetector.cxx:574
 KDetector.cxx:575
 KDetector.cxx:576
 KDetector.cxx:577
 KDetector.cxx:578
 KDetector.cxx:579
 KDetector.cxx:580
 KDetector.cxx:581
 KDetector.cxx:582
 KDetector.cxx:583
 KDetector.cxx:584
 KDetector.cxx:585
 KDetector.cxx:586
 KDetector.cxx:587
 KDetector.cxx:588
 KDetector.cxx:589
 KDetector.cxx:590
 KDetector.cxx:591
 KDetector.cxx:592
 KDetector.cxx:593
 KDetector.cxx:594
 KDetector.cxx:595
 KDetector.cxx:596
 KDetector.cxx:597
 KDetector.cxx:598
 KDetector.cxx:599
 KDetector.cxx:600
 KDetector.cxx:601
 KDetector.cxx:602
 KDetector.cxx:603
 KDetector.cxx:604
 KDetector.cxx:605
 KDetector.cxx:606
 KDetector.cxx:607
 KDetector.cxx:608
 KDetector.cxx:609
 KDetector.cxx:610
 KDetector.cxx:611
 KDetector.cxx:612
 KDetector.cxx:613
 KDetector.cxx:614
 KDetector.cxx:615
 KDetector.cxx:616
 KDetector.cxx:617
 KDetector.cxx:618
 KDetector.cxx:619
 KDetector.cxx:620
 KDetector.cxx:621
 KDetector.cxx:622
 KDetector.cxx:623
 KDetector.cxx:624
 KDetector.cxx:625
 KDetector.cxx:626
 KDetector.cxx:627
 KDetector.cxx:628
 KDetector.cxx:629
 KDetector.cxx:630
 KDetector.cxx:631
 KDetector.cxx:632
 KDetector.cxx:633
 KDetector.cxx:634
 KDetector.cxx:635
 KDetector.cxx:636
 KDetector.cxx:637
 KDetector.cxx:638
 KDetector.cxx:639
 KDetector.cxx:640
 KDetector.cxx:641
 KDetector.cxx:642
 KDetector.cxx:643
 KDetector.cxx:644
 KDetector.cxx:645
 KDetector.cxx:646
 KDetector.cxx:647
 KDetector.cxx:648
 KDetector.cxx:649
 KDetector.cxx:650
 KDetector.cxx:651
 KDetector.cxx:652
 KDetector.cxx:653
 KDetector.cxx:654
 KDetector.cxx:655
 KDetector.cxx:656
 KDetector.cxx:657
 KDetector.cxx:658
 KDetector.cxx:659
 KDetector.cxx:660
 KDetector.cxx:661
 KDetector.cxx:662
 KDetector.cxx:663
 KDetector.cxx:664
 KDetector.cxx:665
 KDetector.cxx:666
 KDetector.cxx:667
 KDetector.cxx:668
 KDetector.cxx:669
 KDetector.cxx:670
 KDetector.cxx:671
 KDetector.cxx:672
 KDetector.cxx:673
 KDetector.cxx:674
 KDetector.cxx:675
 KDetector.cxx:676
 KDetector.cxx:677
 KDetector.cxx:678
 KDetector.cxx:679
 KDetector.cxx:680
 KDetector.cxx:681
 KDetector.cxx:682
 KDetector.cxx:683
 KDetector.cxx:684
 KDetector.cxx:685
 KDetector.cxx:686
 KDetector.cxx:687
 KDetector.cxx:688
 KDetector.cxx:689
 KDetector.cxx:690
 KDetector.cxx:691
 KDetector.cxx:692
 KDetector.cxx:693
 KDetector.cxx:694
 KDetector.cxx:695
 KDetector.cxx:696
 KDetector.cxx:697
 KDetector.cxx:698
 KDetector.cxx:699
 KDetector.cxx:700
 KDetector.cxx:701
 KDetector.cxx:702
 KDetector.cxx:703
 KDetector.cxx:704
 KDetector.cxx:705
 KDetector.cxx:706
 KDetector.cxx:707
 KDetector.cxx:708
 KDetector.cxx:709
 KDetector.cxx:710
 KDetector.cxx:711
 KDetector.cxx:712
 KDetector.cxx:713
 KDetector.cxx:714
 KDetector.cxx:715
 KDetector.cxx:716
 KDetector.cxx:717
 KDetector.cxx:718
 KDetector.cxx:719
 KDetector.cxx:720
 KDetector.cxx:721
 KDetector.cxx:722
 KDetector.cxx:723
 KDetector.cxx:724
 KDetector.cxx:725
 KDetector.cxx:726
 KDetector.cxx:727
 KDetector.cxx:728
 KDetector.cxx:729
 KDetector.cxx:730
 KDetector.cxx:731
 KDetector.cxx:732
 KDetector.cxx:733
 KDetector.cxx:734
 KDetector.cxx:735
 KDetector.cxx:736
 KDetector.cxx:737
 KDetector.cxx:738
 KDetector.cxx:739
 KDetector.cxx:740
 KDetector.cxx:741
 KDetector.cxx:742
 KDetector.cxx:743
 KDetector.cxx:744
 KDetector.cxx:745
 KDetector.cxx:746
 KDetector.cxx:747
 KDetector.cxx:748
 KDetector.cxx:749
 KDetector.cxx:750
 KDetector.cxx:751
 KDetector.cxx:752
 KDetector.cxx:753
 KDetector.cxx:754
 KDetector.cxx:755
 KDetector.cxx:756
 KDetector.cxx:757
 KDetector.cxx:758
 KDetector.cxx:759
 KDetector.cxx:760
 KDetector.cxx:761
 KDetector.cxx:762
 KDetector.cxx:763
 KDetector.cxx:764
 KDetector.cxx:765
 KDetector.cxx:766
 KDetector.cxx:767
 KDetector.cxx:768
 KDetector.cxx:769
 KDetector.cxx:770
 KDetector.cxx:771
 KDetector.cxx:772
 KDetector.cxx:773
 KDetector.cxx:774
 KDetector.cxx:775
 KDetector.cxx:776
 KDetector.cxx:777
 KDetector.cxx:778
 KDetector.cxx:779
 KDetector.cxx:780
 KDetector.cxx:781
 KDetector.cxx:782
 KDetector.cxx:783
 KDetector.cxx:784
 KDetector.cxx:785
 KDetector.cxx:786
 KDetector.cxx:787
 KDetector.cxx:788
 KDetector.cxx:789
 KDetector.cxx:790
 KDetector.cxx:791
 KDetector.cxx:792
 KDetector.cxx:793
 KDetector.cxx:794
 KDetector.cxx:795
 KDetector.cxx:796
 KDetector.cxx:797
 KDetector.cxx:798
 KDetector.cxx:799
 KDetector.cxx:800
 KDetector.cxx:801
 KDetector.cxx:802
 KDetector.cxx:803
 KDetector.cxx:804
 KDetector.cxx:805
 KDetector.cxx:806
 KDetector.cxx:807
 KDetector.cxx:808
 KDetector.cxx:809
 KDetector.cxx:810
 KDetector.cxx:811
 KDetector.cxx:812
 KDetector.cxx:813
 KDetector.cxx:814
 KDetector.cxx:815
 KDetector.cxx:816
 KDetector.cxx:817
 KDetector.cxx:818
 KDetector.cxx:819
 KDetector.cxx:820
 KDetector.cxx:821
 KDetector.cxx:822
 KDetector.cxx:823
 KDetector.cxx:824
 KDetector.cxx:825
 KDetector.cxx:826
 KDetector.cxx:827
 KDetector.cxx:828
 KDetector.cxx:829
 KDetector.cxx:830
 KDetector.cxx:831
 KDetector.cxx:832
 KDetector.cxx:833
 KDetector.cxx:834
 KDetector.cxx:835
 KDetector.cxx:836
 KDetector.cxx:837
 KDetector.cxx:838
 KDetector.cxx:839
 KDetector.cxx:840
 KDetector.cxx:841
 KDetector.cxx:842
 KDetector.cxx:843
 KDetector.cxx:844
 KDetector.cxx:845
 KDetector.cxx:846
 KDetector.cxx:847
 KDetector.cxx:848
 KDetector.cxx:849
 KDetector.cxx:850
 KDetector.cxx:851
 KDetector.cxx:852
 KDetector.cxx:853
 KDetector.cxx:854
 KDetector.cxx:855
 KDetector.cxx:856
 KDetector.cxx:857
 KDetector.cxx:858
 KDetector.cxx:859
 KDetector.cxx:860
 KDetector.cxx:861
 KDetector.cxx:862
 KDetector.cxx:863
 KDetector.cxx:864
 KDetector.cxx:865
 KDetector.cxx:866
 KDetector.cxx:867
 KDetector.cxx:868
 KDetector.cxx:869
 KDetector.cxx:870
 KDetector.cxx:871
 KDetector.cxx:872
 KDetector.cxx:873
 KDetector.cxx:874
 KDetector.cxx:875
 KDetector.cxx:876
 KDetector.cxx:877
 KDetector.cxx:878
 KDetector.cxx:879
 KDetector.cxx:880
 KDetector.cxx:881
 KDetector.cxx:882
 KDetector.cxx:883
 KDetector.cxx:884
 KDetector.cxx:885
 KDetector.cxx:886
 KDetector.cxx:887
 KDetector.cxx:888
 KDetector.cxx:889
 KDetector.cxx:890
 KDetector.cxx:891
 KDetector.cxx:892
 KDetector.cxx:893
 KDetector.cxx:894
 KDetector.cxx:895
 KDetector.cxx:896
 KDetector.cxx:897
 KDetector.cxx:898
 KDetector.cxx:899
 KDetector.cxx:900
 KDetector.cxx:901
 KDetector.cxx:902
 KDetector.cxx:903
 KDetector.cxx:904
 KDetector.cxx:905
 KDetector.cxx:906
 KDetector.cxx:907
 KDetector.cxx:908
 KDetector.cxx:909
 KDetector.cxx:910
 KDetector.cxx:911
 KDetector.cxx:912
 KDetector.cxx:913
 KDetector.cxx:914
 KDetector.cxx:915
 KDetector.cxx:916
 KDetector.cxx:917
 KDetector.cxx:918
 KDetector.cxx:919
 KDetector.cxx:920
 KDetector.cxx:921
 KDetector.cxx:922
 KDetector.cxx:923
 KDetector.cxx:924
 KDetector.cxx:925
 KDetector.cxx:926
 KDetector.cxx:927
 KDetector.cxx:928
 KDetector.cxx:929
 KDetector.cxx:930
 KDetector.cxx:931
 KDetector.cxx:932
 KDetector.cxx:933
 KDetector.cxx:934
 KDetector.cxx:935
 KDetector.cxx:936
 KDetector.cxx:937
 KDetector.cxx:938
 KDetector.cxx:939
 KDetector.cxx:940
 KDetector.cxx:941
 KDetector.cxx:942
 KDetector.cxx:943
 KDetector.cxx:944
 KDetector.cxx:945
 KDetector.cxx:946
 KDetector.cxx:947
 KDetector.cxx:948
 KDetector.cxx:949
 KDetector.cxx:950
 KDetector.cxx:951
 KDetector.cxx:952
 KDetector.cxx:953
 KDetector.cxx:954
 KDetector.cxx:955
 KDetector.cxx:956
 KDetector.cxx:957
 KDetector.cxx:958
 KDetector.cxx:959
 KDetector.cxx:960
 KDetector.cxx:961
 KDetector.cxx:962
 KDetector.cxx:963
 KDetector.cxx:964
 KDetector.cxx:965
 KDetector.cxx:966
 KDetector.cxx:967
 KDetector.cxx:968
 KDetector.cxx:969
 KDetector.cxx:970
 KDetector.cxx:971
 KDetector.cxx:972
 KDetector.cxx:973
 KDetector.cxx:974
 KDetector.cxx:975
 KDetector.cxx:976
 KDetector.cxx:977
 KDetector.cxx:978
 KDetector.cxx:979
 KDetector.cxx:980
 KDetector.cxx:981
 KDetector.cxx:982
 KDetector.cxx:983
 KDetector.cxx:984
 KDetector.cxx:985
 KDetector.cxx:986
 KDetector.cxx:987
 KDetector.cxx:988
 KDetector.cxx:989
 KDetector.cxx:990
 KDetector.cxx:991
 KDetector.cxx:992
 KDetector.cxx:993
 KDetector.cxx:994
 KDetector.cxx:995
 KDetector.cxx:996
 KDetector.cxx:997
 KDetector.cxx:998
 KDetector.cxx:999
 KDetector.cxx:1000
 KDetector.cxx:1001
 KDetector.cxx:1002
 KDetector.cxx:1003
 KDetector.cxx:1004
 KDetector.cxx:1005
 KDetector.cxx:1006
 KDetector.cxx:1007
 KDetector.cxx:1008
 KDetector.cxx:1009
 KDetector.cxx:1010
 KDetector.cxx:1011
 KDetector.cxx:1012
 KDetector.cxx:1013
 KDetector.cxx:1014
 KDetector.cxx:1015
 KDetector.cxx:1016
 KDetector.cxx:1017
 KDetector.cxx:1018
 KDetector.cxx:1019
 KDetector.cxx:1020
 KDetector.cxx:1021
 KDetector.cxx:1022
 KDetector.cxx:1023
 KDetector.cxx:1024
 KDetector.cxx:1025
 KDetector.cxx:1026
 KDetector.cxx:1027
 KDetector.cxx:1028
 KDetector.cxx:1029
 KDetector.cxx:1030
 KDetector.cxx:1031
 KDetector.cxx:1032
 KDetector.cxx:1033
 KDetector.cxx:1034
 KDetector.cxx:1035
 KDetector.cxx:1036
 KDetector.cxx:1037
 KDetector.cxx:1038
 KDetector.cxx:1039
 KDetector.cxx:1040
 KDetector.cxx:1041
 KDetector.cxx:1042
 KDetector.cxx:1043
 KDetector.cxx:1044
 KDetector.cxx:1045
 KDetector.cxx:1046
 KDetector.cxx:1047
 KDetector.cxx:1048
 KDetector.cxx:1049
 KDetector.cxx:1050
 KDetector.cxx:1051
 KDetector.cxx:1052
 KDetector.cxx:1053
 KDetector.cxx:1054
 KDetector.cxx:1055
 KDetector.cxx:1056
 KDetector.cxx:1057
 KDetector.cxx:1058
 KDetector.cxx:1059
 KDetector.cxx:1060
 KDetector.cxx:1061
 KDetector.cxx:1062
 KDetector.cxx:1063
 KDetector.cxx:1064
 KDetector.cxx:1065
 KDetector.cxx:1066
 KDetector.cxx:1067
 KDetector.cxx:1068
 KDetector.cxx:1069
 KDetector.cxx:1070
 KDetector.cxx:1071
 KDetector.cxx:1072
 KDetector.cxx:1073
 KDetector.cxx:1074
 KDetector.cxx:1075
 KDetector.cxx:1076
 KDetector.cxx:1077
 KDetector.cxx:1078
 KDetector.cxx:1079
 KDetector.cxx:1080
 KDetector.cxx:1081
 KDetector.cxx:1082
 KDetector.cxx:1083
 KDetector.cxx:1084
 KDetector.cxx:1085
 KDetector.cxx:1086
 KDetector.cxx:1087
 KDetector.cxx:1088
 KDetector.cxx:1089
 KDetector.cxx:1090
 KDetector.cxx:1091
 KDetector.cxx:1092
 KDetector.cxx:1093
 KDetector.cxx:1094
 KDetector.cxx:1095
 KDetector.cxx:1096
 KDetector.cxx:1097
 KDetector.cxx:1098
 KDetector.cxx:1099
 KDetector.cxx:1100
 KDetector.cxx:1101
 KDetector.cxx:1102
 KDetector.cxx:1103
 KDetector.cxx:1104
 KDetector.cxx:1105
 KDetector.cxx:1106
 KDetector.cxx:1107
 KDetector.cxx:1108
 KDetector.cxx:1109
 KDetector.cxx:1110
 KDetector.cxx:1111
 KDetector.cxx:1112
 KDetector.cxx:1113
 KDetector.cxx:1114
 KDetector.cxx:1115
 KDetector.cxx:1116
 KDetector.cxx:1117
 KDetector.cxx:1118
 KDetector.cxx:1119
 KDetector.cxx:1120
 KDetector.cxx:1121
 KDetector.cxx:1122
 KDetector.cxx:1123
 KDetector.cxx:1124
 KDetector.cxx:1125
 KDetector.cxx:1126
 KDetector.cxx:1127
 KDetector.cxx:1128
 KDetector.cxx:1129
 KDetector.cxx:1130
 KDetector.cxx:1131
 KDetector.cxx:1132
 KDetector.cxx:1133
 KDetector.cxx:1134
 KDetector.cxx:1135
 KDetector.cxx:1136
 KDetector.cxx:1137
 KDetector.cxx:1138
 KDetector.cxx:1139
 KDetector.cxx:1140
 KDetector.cxx:1141
 KDetector.cxx:1142
 KDetector.cxx:1143
 KDetector.cxx:1144
 KDetector.cxx:1145
 KDetector.cxx:1146
 KDetector.cxx:1147
 KDetector.cxx:1148
 KDetector.cxx:1149
 KDetector.cxx:1150
 KDetector.cxx:1151
 KDetector.cxx:1152
 KDetector.cxx:1153
 KDetector.cxx:1154
 KDetector.cxx:1155
 KDetector.cxx:1156
 KDetector.cxx:1157
 KDetector.cxx:1158
 KDetector.cxx:1159
 KDetector.cxx:1160
 KDetector.cxx:1161
 KDetector.cxx:1162
 KDetector.cxx:1163
 KDetector.cxx:1164
 KDetector.cxx:1165
 KDetector.cxx:1166
 KDetector.cxx:1167
 KDetector.cxx:1168
 KDetector.cxx:1169
 KDetector.cxx:1170
 KDetector.cxx:1171
 KDetector.cxx:1172
 KDetector.cxx:1173
 KDetector.cxx:1174
 KDetector.cxx:1175
 KDetector.cxx:1176
 KDetector.cxx:1177
 KDetector.cxx:1178
 KDetector.cxx:1179
 KDetector.cxx:1180
 KDetector.cxx:1181
 KDetector.cxx:1182
 KDetector.cxx:1183
 KDetector.cxx:1184
 KDetector.cxx:1185
 KDetector.cxx:1186
 KDetector.cxx:1187
 KDetector.cxx:1188
 KDetector.cxx:1189
 KDetector.cxx:1190
 KDetector.cxx:1191
 KDetector.cxx:1192
 KDetector.cxx:1193
 KDetector.cxx:1194
 KDetector.cxx:1195
 KDetector.cxx:1196
 KDetector.cxx:1197
 KDetector.cxx:1198
 KDetector.cxx:1199
 KDetector.cxx:1200
 KDetector.cxx:1201
 KDetector.cxx:1202
 KDetector.cxx:1203
 KDetector.cxx:1204
 KDetector.cxx:1205
 KDetector.cxx:1206
 KDetector.cxx:1207
 KDetector.cxx:1208
 KDetector.cxx:1209
 KDetector.cxx:1210
 KDetector.cxx:1211
 KDetector.cxx:1212
 KDetector.cxx:1213
 KDetector.cxx:1214
 KDetector.cxx:1215
 KDetector.cxx:1216
 KDetector.cxx:1217
 KDetector.cxx:1218
 KDetector.cxx:1219
 KDetector.cxx:1220
 KDetector.cxx:1221
 KDetector.cxx:1222
 KDetector.cxx:1223
 KDetector.cxx:1224
 KDetector.cxx:1225
 KDetector.cxx:1226
 KDetector.cxx:1227
 KDetector.cxx:1228
 KDetector.cxx:1229
 KDetector.cxx:1230
 KDetector.cxx:1231
 KDetector.cxx:1232
 KDetector.cxx:1233
 KDetector.cxx:1234
 KDetector.cxx:1235
 KDetector.cxx:1236
 KDetector.cxx:1237
 KDetector.cxx:1238
 KDetector.cxx:1239
 KDetector.cxx:1240
 KDetector.cxx:1241
 KDetector.cxx:1242
 KDetector.cxx:1243
 KDetector.cxx:1244
 KDetector.cxx:1245
 KDetector.cxx:1246
 KDetector.cxx:1247
 KDetector.cxx:1248
 KDetector.cxx:1249
 KDetector.cxx:1250
 KDetector.cxx:1251
 KDetector.cxx:1252
 KDetector.cxx:1253
 KDetector.cxx:1254
 KDetector.cxx:1255
 KDetector.cxx:1256
 KDetector.cxx:1257
 KDetector.cxx:1258
 KDetector.cxx:1259
 KDetector.cxx:1260
 KDetector.cxx:1261
 KDetector.cxx:1262
 KDetector.cxx:1263
 KDetector.cxx:1264
 KDetector.cxx:1265
 KDetector.cxx:1266
 KDetector.cxx:1267
 KDetector.cxx:1268
 KDetector.cxx:1269
 KDetector.cxx:1270
 KDetector.cxx:1271
 KDetector.cxx:1272
 KDetector.cxx:1273
 KDetector.cxx:1274
 KDetector.cxx:1275
 KDetector.cxx:1276
 KDetector.cxx:1277
 KDetector.cxx:1278
 KDetector.cxx:1279
 KDetector.cxx:1280
 KDetector.cxx:1281
 KDetector.cxx:1282
 KDetector.cxx:1283
 KDetector.cxx:1284
 KDetector.cxx:1285
 KDetector.cxx:1286
 KDetector.cxx:1287
 KDetector.cxx:1288
 KDetector.cxx:1289
 KDetector.cxx:1290
 KDetector.cxx:1291
 KDetector.cxx:1292
 KDetector.cxx:1293
 KDetector.cxx:1294
 KDetector.cxx:1295
 KDetector.cxx:1296
 KDetector.cxx:1297
 KDetector.cxx:1298
 KDetector.cxx:1299
 KDetector.cxx:1300
 KDetector.cxx:1301
 KDetector.cxx:1302
 KDetector.cxx:1303
 KDetector.cxx:1304
 KDetector.cxx:1305
 KDetector.cxx:1306
 KDetector.cxx:1307
 KDetector.cxx:1308
 KDetector.cxx:1309
 KDetector.cxx:1310
 KDetector.cxx:1311
 KDetector.cxx:1312
 KDetector.cxx:1313
 KDetector.cxx:1314
 KDetector.cxx:1315
 KDetector.cxx:1316
 KDetector.cxx:1317
 KDetector.cxx:1318
 KDetector.cxx:1319
 KDetector.cxx:1320
 KDetector.cxx:1321
 KDetector.cxx:1322
 KDetector.cxx:1323
 KDetector.cxx:1324
 KDetector.cxx:1325
 KDetector.cxx:1326
 KDetector.cxx:1327
 KDetector.cxx:1328
 KDetector.cxx:1329
 KDetector.cxx:1330
 KDetector.cxx:1331
 KDetector.cxx:1332
 KDetector.cxx:1333
 KDetector.cxx:1334
 KDetector.cxx:1335
 KDetector.cxx:1336
 KDetector.cxx:1337
 KDetector.cxx:1338
 KDetector.cxx:1339
 KDetector.cxx:1340
 KDetector.cxx:1341
 KDetector.cxx:1342
 KDetector.cxx:1343
 KDetector.cxx:1344
 KDetector.cxx:1345
 KDetector.cxx:1346
 KDetector.cxx:1347
 KDetector.cxx:1348
 KDetector.cxx:1349
 KDetector.cxx:1350
 KDetector.cxx:1351
 KDetector.cxx:1352
 KDetector.cxx:1353
 KDetector.cxx:1354
 KDetector.cxx:1355
 KDetector.cxx:1356
 KDetector.cxx:1357
 KDetector.cxx:1358
 KDetector.cxx:1359
 KDetector.cxx:1360
 KDetector.cxx:1361
 KDetector.cxx:1362
 KDetector.cxx:1363
 KDetector.cxx:1364
 KDetector.cxx:1365
 KDetector.cxx:1366
 KDetector.cxx:1367
 KDetector.cxx:1368
 KDetector.cxx:1369
 KDetector.cxx:1370
 KDetector.cxx:1371
 KDetector.cxx:1372
 KDetector.cxx:1373
 KDetector.cxx:1374
 KDetector.cxx:1375
 KDetector.cxx:1376
 KDetector.cxx:1377
 KDetector.cxx:1378
 KDetector.cxx:1379
 KDetector.cxx:1380
 KDetector.cxx:1381
 KDetector.cxx:1382
 KDetector.cxx:1383
 KDetector.cxx:1384
 KDetector.cxx:1385
 KDetector.cxx:1386
 KDetector.cxx:1387
 KDetector.cxx:1388
 KDetector.cxx:1389
 KDetector.cxx:1390
 KDetector.cxx:1391
 KDetector.cxx:1392
 KDetector.cxx:1393
 KDetector.cxx:1394
 KDetector.cxx:1395
 KDetector.cxx:1396
 KDetector.cxx:1397
 KDetector.cxx:1398
 KDetector.cxx:1399
 KDetector.cxx:1400
 KDetector.cxx:1401
 KDetector.cxx:1402
 KDetector.cxx:1403
 KDetector.cxx:1404
 KDetector.cxx:1405
 KDetector.cxx:1406
 KDetector.cxx:1407
 KDetector.cxx:1408
 KDetector.cxx:1409
 KDetector.cxx:1410
 KDetector.cxx:1411
 KDetector.cxx:1412
 KDetector.cxx:1413
 KDetector.cxx:1414
 KDetector.cxx:1415
 KDetector.cxx:1416
 KDetector.cxx:1417
 KDetector.cxx:1418
 KDetector.cxx:1419
 KDetector.cxx:1420
 KDetector.cxx:1421
 KDetector.cxx:1422
 KDetector.cxx:1423
 KDetector.cxx:1424
 KDetector.cxx:1425
 KDetector.cxx:1426
 KDetector.cxx:1427
 KDetector.cxx:1428
 KDetector.cxx:1429
 KDetector.cxx:1430
 KDetector.cxx:1431
 KDetector.cxx:1432
 KDetector.cxx:1433
 KDetector.cxx:1434
 KDetector.cxx:1435
 KDetector.cxx:1436
 KDetector.cxx:1437
 KDetector.cxx:1438
 KDetector.cxx:1439
 KDetector.cxx:1440
 KDetector.cxx:1441
 KDetector.cxx:1442
 KDetector.cxx:1443
 KDetector.cxx:1444
 KDetector.cxx:1445
 KDetector.cxx:1446
 KDetector.cxx:1447
 KDetector.cxx:1448
 KDetector.cxx:1449
 KDetector.cxx:1450
 KDetector.cxx:1451
 KDetector.cxx:1452
 KDetector.cxx:1453
 KDetector.cxx:1454
 KDetector.cxx:1455
 KDetector.cxx:1456
 KDetector.cxx:1457
 KDetector.cxx:1458
 KDetector.cxx:1459
 KDetector.cxx:1460
 KDetector.cxx:1461
 KDetector.cxx:1462
 KDetector.cxx:1463
 KDetector.cxx:1464
 KDetector.cxx:1465
 KDetector.cxx:1466
 KDetector.cxx:1467
 KDetector.cxx:1468
 KDetector.cxx:1469
 KDetector.cxx:1470
 KDetector.cxx:1471
 KDetector.cxx:1472
 KDetector.cxx:1473
 KDetector.cxx:1474
 KDetector.cxx:1475
 KDetector.cxx:1476
 KDetector.cxx:1477
 KDetector.cxx:1478
 KDetector.cxx:1479
 KDetector.cxx:1480
 KDetector.cxx:1481
 KDetector.cxx:1482
 KDetector.cxx:1483
 KDetector.cxx:1484
 KDetector.cxx:1485
 KDetector.cxx:1486
 KDetector.cxx:1487
 KDetector.cxx:1488
 KDetector.cxx:1489
 KDetector.cxx:1490
 KDetector.cxx:1491
 KDetector.cxx:1492
 KDetector.cxx:1493
 KDetector.cxx:1494
 KDetector.cxx:1495
 KDetector.cxx:1496
 KDetector.cxx:1497
 KDetector.cxx:1498
 KDetector.cxx:1499
 KDetector.cxx:1500
 KDetector.cxx:1501
 KDetector.cxx:1502