#ifndef _TPCmapping_h_ #define _TPCmapping_h_ typedef unsigned short u_short ; typedef unsigned int u_int ; //#warning My comment:redifined u_short and u_int #define MAXTPCRCU 216 #define MAXTPCFECPERSECTOR 78 #define MAXTPCFEC 4356 #define MAXTPCFECPERRCU 32 #define MAXTPCFECCH 128 #define MAXTPCRCUPERSECTOR 4 #define MAXTPCSECTORS 72 #define MAXTPCROWS 96 #define MAXTPCCOLS 140 #define MAXTPCINDEXOROC 9984 #define MAXTPCINDEXIROC 5504 #define GetMAXTPCINDEX(x) ((x>0)? MAXTPCINDEXOROC : MAXTPCINDEXIROC ) #define MAXTPCINDEX MAXTPCINDEXOROC+1 // forward mappings //------------------------------------------------------------ class TPCHWChannel { public: TPCHWChannel(){}; ~TPCHWChannel(){}; float x,y,z,t; u_short pad; u_short row; u_short sector; u_short status; u_short index; }; class TPCSectorChannel { public: TPCSectorChannel(){}; ~TPCSectorChannel(){}; float x,y,z; u_short rcu; u_short fec; u_short altroch; u_short status; u_int index; void Print(){ fprintf(stderr, "TPCSectorChannel rcu=%3d fec=%3d altroch=%3d status=%3d index=%3d\n",rcu,fec,altroch,status,index); }; }; //------------------------------------------------------------ class TPCFEC2SECTOR { public: TPCFEC2SECTOR(){}; ~TPCFEC2SECTOR(){}; u_short sector; u_short sectorfecid; u_short rcurow; u_short fecsn; u_short status; }; class TPCSECTOR2FEC { public: TPCSECTOR2FEC(){}; ~TPCSECTOR2FEC(){}; u_short hwid; u_short fecsn; u_short status; }; //------------------------------------------------------------ class TPCRCU2SECTOR { public: TPCRCU2SECTOR(){}; ~TPCRCU2SECTOR(){}; u_short status; u_short sector; u_short rcurow; }; class TPCSECTOR2RCU { public: TPCSECTOR2RCU(){}; ~TPCSECTOR2RCU(){}; u_short hwid; u_short status; }; //------------------------------------------------------------ class TPCSECTOR { public: TPCSECTOR(){}; ~TPCSECTOR(){}; u_short type; u_short side; u_short count; u_short status; }; //------------------------------------------------------------ class TPCDataROC { /* COLUMN 0 -> INDEX (0 - 9983) COLUMN 1 -> PADROW (0 - 95) COLUMN 2 -> PAD (0 - (Np-1)) COLUMN 3 -> Connector (1 - 468) COLUMN 4 -> Pin (0 - 22) COLUMN 5 -> FEC (0 - 77) COLUMN 6 -> FEC Channel (0 - 127) COLUMN 7 -> FEC Connector (0 - 5) */ public: TPCDataROC(){}; ~TPCDataROC(){}; u_short irow; u_short ipad; u_short con; u_short pin; u_short fec; u_short fecch; u_short feccon; u_short status; void Print(){ fprintf(stderr, "TPCDataROC irow=%3d ipad=%3d con=%3d pin=%3d fec=%3d fecch=%3d feccon=%3d status=%3d\n",irow,ipad,con,pin,fec,fecch,feccon,status); }; }; //------------------------------------------------------------ class TPCMapping { public: // global lookup tables TPCHWChannel gTPCHWChannel[MAXTPCRCU][MAXTPCFECPERRCU][MAXTPCFECCH]; TPCRCU2SECTOR gTPCRCU2SECTOR[MAXTPCRCU]; TPCFEC2SECTOR gTPCFEC2SECTOR[MAXTPCRCU][MAXTPCFECPERRCU]; TPCSectorChannel gTPCSectorChannel[MAXTPCSECTORS][MAXTPCROWS][MAXTPCCOLS]; TPCSECTOR2RCU gTPCSECTOR2RCU[MAXTPCSECTORS][MAXTPCRCUPERSECTOR]; TPCSECTOR2FEC gTPCSECTOR2FEC[MAXTPCSECTORS][MAXTPCFECPERSECTOR]; unsigned int gALTRO2FEC[MAXTPCFECCH ]; unsigned int gFEC2ALTRO[MAXTPCFECCH ]; unsigned int gALTRO2PASA[MAXTPCFECCH ]; TPCDataROC gTPCDataROC[2][MAXTPCINDEX] ; // index 0 - IROC , 1 - OROC int gmaxTPCDataROC[2]; TPCSECTOR gTPCSECTOR[MAXTPCSECTORS]; float TPCr0[3]; ~TPCMapping(){}; int setIROCcon2fec(int i,char **val); int setOROCcon2fec(int i,char **val); int Process(); int setsector2rcu(int i,char **val); int GetRcuRow(u_short type, u_short fec, u_short *rcurow); int setsector2FECid(int i,char **val); int setaltro2fec(int i,char **val); int readMap(char *path, char *fname,int whichmap); TPCMapping(char *path); int Reset(); int testMapping(FILE *fp); u_short GetHWAddr(u_short sector, u_short row, u_short col, u_short *rcu, u_short *fec, u_short *altroch ); u_short GetInfo(u_short rcuid, u_short fecid, u_short *fecsn, u_short *sectorfecid, u_short *rcurow); u_short GetPhysAddr( u_short rcu, u_short fec, u_short altroch , u_short *sector, u_short *row, u_short *col ); u_short GetPhysAddr( u_short rcu, u_short chid ,u_short *sector, u_short *row, u_short *col ); int XY2IRIP(int local,int oroc,float x,float y,u_short &ir,u_short &ip); int RowPad2XY(int type,int ir, int ip, float *x, float *y); u_short GetSectorIDFromName(const char *); // inlines inline int GetNumberOfRCU(){ return MAXTPCRCU;}; inline int GetNumberOfFECPerRcu(){ return MAXTPCFECPERRCU;}; inline int GetNumberOfFECCh(){ return MAXTPCFECCH;}; inline int is_connected_sector(u_short sector){return gTPCSECTOR[sector].status; } inline int is_connected_rcu(u_short sector, u_short sub){ return gTPCSECTOR2RCU[sub][sub].status;}; inline int is_connected_rcu(u_short ircu){ return gTPCRCU2SECTOR[ircu].status; }; inline int is_connected_fec(u_short ircu,u_short ifec) { return gTPCFEC2SECTOR[ircu][ifec].status; }; }; #endif