#include #include using namespace std; int main(int argc, char *argv[]) { int SDId,AugerID,GPSSec,GPSNSec,BadPeriod,YYMMDD,HHMMSS; float MJD; int T4,T5; float LDFStat,Energy,EnergyErr,S1000,S1000Err,S1000Sys,Theta ,ThetaErr ,Phi ,PhiErr , ThetaSite ,PhiSite; int NCand, NAct, NWork; float Xcore , Ycore , Zcore, XcoreErr, YcoreErr, ZcoreErr, Easting, Northing, RA, Dec, RaErr, DecErr, GalLat, GalLong, GalLatErr, GalLongErr, PlaneChi2; int PlaneNdf; float Beta, BetaErr, Gamma, GammaErr, LDFchi2; int LDFNdf; float RCurv, RCurvErr, RiseTime, RiseTimeErr, TResMean, TResSpread ; //int Eye,Run,Event,TelEvtBits,TelDAQBits; //float MoonCycle; //int RecLevel,Npix; //float SDPTheta,SDPThetaErr,SDPPhi,SDPPhiErr,SDPChi2; //int SDPNdf; //float Rp,RpErr,Chi0,Chi0Err,T0,T0Err,TimeChi2,TimeChi2FD; //int TimeNdf; //float Easting,Northing,Altitude,NorthingErr,EastingErr,RhoNE,Theta,ThetaErr,Phi,PhiErr; //float RhoPT,RA,Dec,RAErr,DecErr,RhoRD,GalLong,GalLat,GalLongErr,GalLatErr,RhoLL; //float dEdXmax,dEdXmaxErr,Xmax,XmaxErr,X0,X0Err,Lambda,LambdaErr,GHChi2; //int GHNdf; //float LineFitChi2,EmEnergy,EmEnergyErr,Energy,EnergyErr,MinAngle,MaxAngle,MeanAngle,ChkovFrac; //int NTank,HottestTank; //int NTank,HottestTank; //float AxisDist,SDPDist,SDFDdt,XmaxEyeDist,EyeMaxAtt,XTrackMin,XTrackMax,XFOVMin,XFOVMax,XTrackObs,DegTrackObs,TTrackObs,MieDatabase; //float AxisDist,SDPDist,SDFDdt,XmaxEyeDist,EyeMaxAtt,XTrackMin,XTrackMax,XFOVMin,XFOVMax,XTrackObs,DegTrackObs,TTrackObs,MieDatabase char ArqName[50]; int ncols,nlines = 0; FILE * inputfile; //(void)printf("Entre com o nome do arquivo\n"); //scanf("%s",&ArqName); //inputfile=fopen(ArqName,"r"); inputfile=fopen("SDRec_v7r6_2004_generated_2013-1-10.dat","r"); //inputfile=fopen("GoldenRec_1.txt","r"); if (inputfile==NULL) { printf("Cant`t open inputfile\n"); system("PAUSE"); return 0; } FILE * outfile; /* */ outfile=fopen("outEnergy2004.txt","w"); if (outfile==NULL) { printf("Cant't open outputfile\n"); return(0); } while(1){ int ch; ch=fgetc(inputfile); if (ch==EOF) break; //printf ("%c\n",ch); char line[2000]; fgets(line,sizeof(line),inputfile); //(void)sscanf(line,"%d %d %d %d %d %d %d %d %d %d %d %d %f %d %d %f %f %f %f %f %d %f %f %f %f %f %f %f %f %d %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %d %f %f %f %f %f %f %f %f %f %d %d %f %f %f %f %f %f %f %f %f %f %f %f %f",&SDId,&AugerID,&GPSSec,&GPSNSec,&BadPeriod,&YYMMDD,&HHMMSS,&TelEvtBits,&TelDAQBits,&MoonCycle,&RecLevel,&Npix,&SDPTheta,&SDPThetaErr,&SDPPhi,&SDPPhiErr,&SDPChi2,&SDPNdf,&Rp,&RpErr,&Chi0,&Chi0Err,&T0,&T0Err,&TimeChi2,&TimeChi2FD,&TimeNdf,&Easting,&Northing,&Altitude,&NorthingErr,&EastingErr,&RhoNE,&Theta,&ThetaErr,&Phi,&PhiErr,&RhoPT,&RA,&Dec,&RAErr,&DecErr,&RhoRD,&GalLong,&GalLat,&GalLongErr,&GalLatErr,&RhoLL,&dEdXmax,&dEdXmaxErr,&Xmax,&XmaxErr,&X0,&X0Err,&Lambda,&LambdaErr,&GHChi2,&GHNdf,&LineFitChi2,&EmEnergy,&EmEnergyErr,&Energy,&EnergyErr,&MinAngle,&MaxAngle,&MeanAngle,&ChkovFrac,&NTank,&HottestTank,&AxisDist,&SDPDist,&SDFDdt,&XmaxEyeDist,&EyeMaxAtt,&XTrackMin,&XTrackMax,&XFOVMin,&XFOVMax,&XTrackObs,&DegTrackObs,&TTrackObs,&MieDatabase); (void)sscanf(line,"%d %d %d %d %d %d %d %f %d %d %f %f %f %f %f %f %f %f %f %f %f %f %d %d %d %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %d %f %f %f %f %f %d %f %f %f %f %f %f",&SDId,&AugerID,&GPSSec,&GPSNSec,&BadPeriod,&YYMMDD,&HHMMSS,&MJD,&T4,&T5,&LDFStat,&Energy,&EnergyErr,&S1000,&S1000Err,&S1000Sys,&Theta,&ThetaErr,&Phi,&PhiErr,&ThetaSite,&PhiSite,&NCand,&NAct,&NWork,&Xcore,&Ycore,&Zcore,&XcoreErr,&YcoreErr,&ZcoreErr,&Easting,&Northing,&RA,&Dec,&RaErr,&DecErr,&GalLat,&GalLong,&GalLatErr,&GalLongErr,&PlaneChi2,&PlaneNdf,&Beta,&BetaErr,&Gamma,&GammaErr,&LDFchi2,&LDFNdf,&RCurv,&RCurvErr,&RiseTime,&RiseTimeErr,&TResMean,&TResSpread); //sscanf(line,"%d %d %d %d %d %d %d %d %d %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f %f ",&Eye,&Run,&Event,&GPSSec,&GPSNSec,&YYMMDD,&HHMMSS,&SDId,&TelEvtbits,&TelDAQbits,&MoonCycle,&Easting,&Northing,&Altitude,&NorthingErr,&EastingErr,&RhoNE,&Theta,&ThetaErr,&Phi,&PhiErr,&RhoPT,&RA,&Dec,&RAErr,&DecErr,&RhoRD,&GalLong,&GalLat,&GalLongErr,&GalLatErr,&RhoLL); if((nlines > 2)&& (nlines < 10 )) { // Escrevendo no Terminal printf ("\nSDId=%7d \t %7d\n",SDId, GPSSec); printf ("GPSSec=%10d\t,GPSNSec=%10d\t,YYMMDD=%7d\t,HHMMSS=%7d\n",GPSSec,GPSNSec,YYMMDD,HHMMSS); //printf ("Easting=%9.2f+-%6.2f,\tNorthing=%9.2f+-%6.2f,\tAltitude=%7.2f\n",Easting,EastingErr,Northing,NorthingErr,Altitude); //printf ("Theta=%7.3f+-%5.3f,\tPhi=%7.3f+-%5.3f,\tRhoPT=%10.4e\n",Theta,ThetaErr,Phi,PhiErr,RhoPT); //printf ("RA=%7.3f+-%5.3f,\tDec=%7.3f+-%5.3f,\t,RhoRD=%10.4e\t,GalLong=%7.3f+-%5.3f,\tGalLat=%7.3f+-%5.3f,\tRhoLL=%10.4e\n",RA,RAErr,Dec,DecErr,RhoRD,GalLong,GalLongErr,GalLat,GalLatErr,RhoLL); printf ("Energy=%10.4e+-%10.4e\n",Energy,EnergyErr); //printf (" %f \t%f \t%f\n %f\n %d %d\n %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\t %f\n %f\n",MinAngle,MaxAngle,MeanAngle,ChkovFrac,NTank,HottestTank,AxisDist,SDPDist,SDFDdt,XmaxEyeDist,EyeMaxAtt,XTrackMin,XTrackMax,XFOVMin,XFOVMax,XTrackObs,DegTrackObs,TTrackObs,MieDatabase,BadPeriod); //printf ("Bad Period = %d\n",BadPeriod); } if (nlines > 2){ if (BadPeriod == 0){ // fprintf (outfile,"%d %d.%d %f %f %f %f %f %f %f %f %f %f %f %f \n", SDId, YYMMDD , HHMMSS , Energy , EnergyErr, Theta, ThetaErr, Phi, PhiErr, Easting, Northing, RA, Dec, RaErr, DecErr); fprintf (outfile,"%f %f\n", Energy , EnergyErr); } //(void)fprintf(outfile,"%f %f %f %f %e %f %f %f %f %e\n",RA,Dec,RAErr,DecErr,RhoRD,GalLong,GalLat,GalLongErr,GalLatErr,RhoLL); } nlines ++; } printf("\nI have found %d lines\n",nlines-3); system("PAUSE"); return EXIT_SUCCESS; }