main() { int hid=1,istat=0,icycle=0; int i,i1,j; int nvar; float r[3]; char chtag_in[3][6]={"X","Y","Z"}; char chtag_out[5][8],chtitl[80]; float rmin[5],rmax[5]; int record_size=1024; HLIMIT(PAWC_SIZE); HROPEN(1,"example","ntuple-example.hbook","N",record_size,istat); HBOOKN(hid," An Ntuple",3," ",5000,chtag_in); for (i=0;i<10000;i++){ for(i1=0;i1<3;i1++) for (j=0,r[i1]=0.;j<10;r[i1] += rand()/32768. -0.5 ,j++); HFN(hid,r); } nvar=5; HGIVEN(hid,chtitl,nvar,chtag_out,rmin,rmax); printf(" title obtained:%s\n variables %d\ntags:>%s< >%s< >%s<\n", chtitl,nvar,chtag_out[0],chtag_out[1],chtag_out[2]); printf(" rmin: %e %e %e\n",rmin[0],rmin[1],rmin[2]); printf(" rmax: %e %e %e\n",rmax[0],rmax[1],rmax[2]); HROUT(0,icycle," "); HREND("example"); KUCLOS(1," ",1); }
void convert (int begin, int end,char file[]){ ifstream fin; // CAS static integer count=0; uinteger length; CASblock buffer; ShuttlePar block; if(begin==0){ HBNT(1,"CAS Data"," "); HBNAME(1,"CASData",(int*)(&block),"StationR,StationTheta,StationPhi,GrMedPhi,StationYaw,StationPitch,StationRoll,StationSpeed,SunR,SunTheta,SunPhi,Time:I"); } // open fin; AString fname(CAS_dir); fname+="/"; fname+=file; fin.open(fname); if(fin){ cout <<"convert-I-Openfile "<<fname<<" ("<<++count<<")"<<endl; while(!fin.eof()){ fin.read((char*)(&length),sizeof(integer)); fin.seekg(fin.tellg()+20*sizeof(integer)); fin.read((char*)(&(buffer.CASmsg)),length-20*sizeof(integer)); int ret=Cas2Shuttle(buffer,block); if(ret>0){ if(updShuttle(block,0))HFNT(1); } else cerr<<"Error no "<< ret <<" decoding block in file "<<fname<<endl; } fin.close(); } else{ cerr <<"convert-E-UnableToOpenfile "<<fname<<endl; return; } if(end==0){ // last file // close everything updShuttle(block,1); int ntuple_entries; HNOENT(1, ntuple_entries); cout << " Closing CAS ntuple with "<< ntuple_entries << " events" << endl; char hpawc[256]="//PAWC"; HCDIR (hpawc, " "); char houtput[9]="//output"; HCDIR (houtput, " "); integer ICYCL=0; HROUT (1, ICYCL, " "); HREND ("output"); CLOSEF(1); } }