#include<iostream>
#include<iomanip>
using namespace std;

void create_geog_h_new(){

	ifstream f_in;
	f_in.open("bemcTower.dat");

	float x[4801],y[4801],z[4801],r;
	int id,N[4801],neib[4801][8],daq_neib[4801][8];
	float eta[4801],phi[4801];
	int temp_int;
	float temp_float;
	int to_daq[4801],to_soft[4800];

   ofstream ouf;
   ouf.open("value_eta.txt"); 
   ofstream ouf2;
   ouf2.open("value_phi.txt"); 
   ofstream ouf3;
   ouf3.open("value_x.txt"); 
   ofstream ouf4;
   ouf4.open("value_y.txt"); 
   ofstream ouf5;
   ouf5.open("value_z.txt"); 
   ofstream ouf6;
   ouf6.open("value_N.txt"); 
   ofstream ouf7;
   ouf7.open("value_bei.txt"); 
   ofstream ouf8;
   ouf8.open("value_to_daq.txt"); 
   ofstream ouf9;
   ouf9.open("value_to_soft.txt"); 


   for(int j=0;j<4800;j++){
	   int daq;
	   f_in>>daq>>id>>temp_int>>temp_int>>temp_float;
	   f_in>>x[id]>>y[id]>>z[id]>>eta[id]>>phi[id]>>N[id];
	   to_daq[id]=daq;
	   to_soft[daq]=id;
//	   cout<<"x[id]="<<x[id]<<endl;
	   for(int k=0;k<N[id];k++) 
		   f_in>>daq_neib[id][k];
   }
   for(int soft=1;soft<=4800;soft++)for(int k=0;k<N[soft];k++)
	   neib[soft][k]=to_soft[daq_neib[soft][k]];
	

	 for(int j=1;j<=4800;j++){
		r=sqrt(x[j]*x[j]+y[j]*y[j]+z[j]*z[j]);
		x[j]/=r;y[j]/=r;z[j]/=r;
	 }
   

   for(int j=1;j<=4800;j++){
     ouf<<", "<<eta[j];
	 if(j%30==0&&j>0) ouf<<endl;
   }
   ouf<<endl;
   for(int j=1;j<=4800;j++){
     ouf2<<", "<<phi[j];
	 if(j%30==0&&j>0) ouf2<<endl;
   }
   ouf2<<endl;
   for(int j=1;j<=4800;j++){
     ouf3<<", "<<x[j];
	 if(j%30==0&&j>0) ouf3<<endl;
   }
   ouf3<<endl;

   for(int j=1;j<=4800;j++){
     ouf4<<", "<<y[j];
	 if(j%30==0&&j>0) ouf4<<endl;
   }
   ouf4<<endl;

   for(int j=1;j<=4800;j++){
     ouf5<<", "<<z[j];
	 if(j%30==0&&j>0) ouf5<<endl;
   }
   ouf5<<endl;

   for(int j=1;j<=4800;j++){
     ouf6<<", "<<N[j];
	 if(j%30==0&&j>0) ouf6<<endl;
   }
   ouf6<<endl;

   for(int j=1;j<=4800;j++){
     ouf8<<", "<<to_daq[j];
	 if(j%30==0&&j>0) ouf8<<endl;
   }
   ouf8<<endl;

   for(int j=0;j<4800;j++){
     ouf9<<", "<<to_soft[j];
	 if(j%30==0&&j>0) ouf9<<endl;
   }
   ouf9<<endl;

   for(int j=1;j<=4800;j++){
	   ouf7<<",{";
	    ouf7<<neib[j][0]<<", "<<neib[j][1]<<", "<<neib[j][2]<<", "<<neib[j][3]<<", "<<neib[j][4]<<", "<<neib[j][5]<<", "<<neib[j][6]<<", "<<neib[j][7];
	   ouf7<<"}";
	 if(j%10==0&&j>0) ouf7<<endl;
   }
   ouf7<<endl;



}
