//////////////////////////////////// // Chimera Event Unpacker // for the Asy-Eos experiment // November 2010 // revison 3/2011 // E.d.F ver 1.0 // defilippo@ct.infn.it //////////////////////////////////// #ifndef TCHIEVENT_H #define TCHIEVENT_H #include "global.h" /*####################paolo extern "C" { // #include "readpar_lex.c" // #include "readpar.tab.c" } ####################paolo*/ enum module {UNKNOWN=-1, TDC, QDC, ADC}; //enum egain {LG,HG}; enum eReadoutType {chimerastd, chimerastd_muse, genericstd}; /* masks for legacy caen codifiers */ const unsigned int mask[7] = {0x80000000,0x0000FFFF,0x007F0000,0x0F800000, 0x00000FFF,0x003F0000,0x00001000}; /* masks for new generation caen codifiers */ const unsigned int mask1[7] = {0x07000000,0x0000FFFF,0x00003F00,0xF8000000, 0x00000FFF,0x001F0000,0x00FF0000}; const int LENGTH = 32768; // max buffer length void warning(int, const char *, char *); int yylex(void); int yyparse(void); void yyerror(const char *); int ParseParFile(FILE *); // Chimera configuration and parameter's list class TCHIParam { public: char fname[32]; // parameter name module fmod; // codifier type int fnumtel; // telescope number int fpostel; // parameter position in telescope int faddr; // channel number int fboard; // board address int fcrate; // crate number float foffset; // offset QDC channel float fgain; // gain QDC channel int fvalue; // index of fired parameter int fpid; // parameter identificator (pid) float fpedestal; // the QDC pedestal if available float fpedsuppr; // pedestal suppression value TCHIParam() {ClearParam();} void ClearParam() {fmod = UNKNOWN; fnumtel=-1; faddr= -1; fboard = -1; fcrate=-1; fvalue=-1; fpid=-1; fpedestal=0.; fpedsuppr=0.;} }; // database for fired parameters struct TCHIFired { int fpid; // pid identificator int fnt; // telescope number int fval_lg; // data value Low Gain int fval_hg; // data value High Gain }; //Codifier header struct Cheadw { int counter; // header counter int mult; // board multiplicity int board; // board number Cheadw() {counter=0; mult=0; board=0;} }; //Codifier data struct Cdatumw { int valore; // channel value int channel; // channel number int range; // range bit int board; // board number Cdatumw() {valore=0; channel=0; range=1; board=0;} }; struct ChiGeom { float dist; float CsILen; float ThetaMin; float ThetaMax; float Theta, Phi; float DeltaPhi; }; class TCHIGeometry { private: string filename; ChiGeom fm[MAX_TELES]; bool fgeom; int fseed; public: TCHIGeometry(string ); ~TCHIGeometry() {} float Rndm(); bool IsGeomDefined() {return fgeom;} ChiGeom *GetGeom() {return fm;} }; class TCHITeles { friend class TCHIEvent; private: int fnumparam; // number of parameters in the telescope int fptel[MAX_PAR_TELES]; // pid of telescope members int flmulti; // number of parameters fired in the telescope public: TCHITeles() { fnumparam=1; flmulti = 0; for(int i=0; i fTelFired; //fired telescopes in a event int fpostel; //position of a element in a telescope map fpidnames; // map of pid-variable names int fevtlen; // current event length int *fstartevt; //pointer to the beginning of an event int *fendevt; //pointer to the end of an event int fvmenum; //total VME crates in the event int ftsl,ftsm,ftsh; //time stamp values in the event int ftotfired; //total parameter fired in a event; int fTDCmulti; //total multiplicy (TDC based) int fRawmulti; //raw multiplicity eReadoutType freadoutype; //data format (mainly affect event length format) bool fcorrectoffset; //Make offset and gain correction for //double gain codifiers public: static int fnumerrors; TCHIEvent(string filename, int); //constructor TCHIEvent(TCHIEvent &); //copy constructor virtual ~TCHIEvent(); //destructor void Copy(TCHIEvent &); int ProcessParFile(); void Clear_list_par(); void Gen_list_par(int, TCHIParam *); TCHIParam *Get_Par_List(int ); int pgetpid(int crate, int board, int addr); void SetPostel(int num) {fpostel = num;} int GetPidvalue(const char *name); int GetEvent(int *); int GetEvent(int *, int *, int); // int ProcessCurrentEvent(const int); int ProcessCurrentEventMBS(int *); int GetVMECrates() {return fvmenum;} void Clear_fired_param(int ); int Get_Fired_Parameters() {return ftotfired;} int Upgrade_ListTel(int, int ); char *GetTelesName(VAR, int ); int GetTelesPid(VAR par, int tel); int Get_Pedestal_Data(const char *); int Get_Offset_Data(const char *); ////////////////////////////////////////////////////////////////////// /////////////// Event Get-Information methods //////////////////////// ////////////////////////////////////////////////////////////////////// void GetTiMeStamp(int *, int *, int *); int GetRawMultiplicity() {return fRawmulti;} int GetTofMultiplicity(); int Get_Data_Telescope(int, VAR, VAR, egain, egain, int *, int *); int Get_PidFired(int ); void GetFired(vector &v) {v=fTelFired;} int Get_Value(int, egain ); int Get_Value(const char *, egain); void DisableOffset() {fcorrectoffset = false;} void EnableOffset() {fcorrectoffset = true;} void CheckRings(float *x, float *y); virtual void Init_Start_Run(const int, const string); virtual void AnalyseEvent(int ); }; extern TCHIEvent *gevent; // a global instance to TCHIEvent class #endif