#include #include #include #include #include using namespace std; //#include //#include //#include #include #include #include #include #include #include #include #include #include #include "TStyle.h" #include "TPaveLabel.h" #include "TLine.h" #include "TMarker.h" #include "shmem_roc.h" #define MAX_TREE_EVENTS 10000 #ifndef LSWAP #define LSWAP(x) ((((x) & 0x000000ff) << 24) | \ (((x) & 0x0000ff00) << 8) | \ (((x) & 0x00ff0000) >> 8) | \ (((x) & 0xff000000) >> 24)) #endif class Hist { public: //DRootSpy *rootspy; //--- global vars TH1D *h_px, *h_py, *h_pz, *h_E , *h_Mass; TFile *root_file; //--- DAQ -- TH1D *EventSize; TH1D *rol_1[10]; TH2D *size2time; TH1D *TrigTime; TH1I *RunInfo; TH1I *ErrorCounter; SHM_HIST *hrol1; roc_shmem *shmem_ptr; #define MAX_FIT 10 int Nfits; //-- max 10 -- TCanvas *canvas1; int FADC_DAC[MAX_FIT]; double FADC_mean[MAX_FIT][21*72]; double FADC_sigma[MAX_FIT][21*72]; double FADC_dac[MAX_FIT][21*72]; //-- PED monitor (also in shmem_roc.h) ---- /* typedef struct { int status; time_t updated; double mean; double sigma; int noent; } PedMon; */ PedMon pedmon[MAX_PED]; //--- F250 --- int MAXCHAN; //-- 16 int MAXSLOT; //-- 21 int MAXBIN; //-- 21*16 TH2 *F250scalers; TH1D *F250_adc_all[21][16]; TH1D *F250_adc[21][16]; TH1D *F250_ped[21][16]; TProfile *ped_f250_prof; TProfile *adc_f250_prof; TH2D *adc_f250_slots[21]; TH2D *ped_f250_slots[21]; TH1D *ped_f250_fit_m[MAX_FIT]; TH1D *ped_f250_fit_s[MAX_FIT]; TH1D *f250_pedmean; TH1D *f250_pedsigma; TH1D *f250_pulse; int f250_pulse_len; TH1D *f250_time; //--- F125 --- int MAXCHAN_f125; //-- 72 int MAXSLOT_f125; //-- 21 int MAXBIN_f125; //-- 21*72 TH1D *F125_adc[21][72]; TH1D *F125_tdc[21][72]; TProfile *ped_f125_prof; TH2D *ped_f125_slots[21]; TH1D *ped_f125_fit_m[MAX_FIT]; TH1D *ped_f125_fit_s[MAX_FIT]; TH1D *f125_pulse, *f125_gpulse, *f125_wpulse; int f125_pulse_len; TH1D *f125_time; TH1D *f125_fe55,*f125_stime; TH1D *f125_gem; TH1D *f125_gtime; TH1D *f125_wtime; TH2D *f125_occup2D; //-- vmeDIRC --- TH2 *DIRCscalers; TH2 *DIRCdata; //-- vmeDSC --- TH2 *DISCRscalers; TTree *Tdsc ; TTree *Trate ; int Nslots; int Dslots[21]; float DscRate[21][16]; float *pDscRate; //double DscRate[21][16]; double Dtime; int ResetFlag; //--- CAEN TDC --- int MAXCHAN_CAEN; // -- 32 int MAXSLOT_CAEN; //-- 21 int MAXBIN_CAEN; //-- 21*32 TH1D *CTDC[21][32]; TProfile *tdc_prof_caen; TH2D *tdc_occup2D_ctdc; //--- F1TDC --- int MAXCHAN_F1TDC; // -- 32 or 64 int MAXSLOT_F1TDC; //-- 21 int MAXBIN_F1TDC; //-- 21*32 or 21*64 TH1D *F1TDC[21][64]; TProfile *tdc_prof_f1tdc; TH1D *tdc_occup_f1tdc; TH2D *tdc_occup2D_f1tdc; TH1D *tdc_rf_f1tdc; //---------------------------------------- TList *ALL_1D_HIST; TList *ALL_2D_HIST; TList *ALL_FIT_HIST; TList *ALL_Prof_HIST; TList *ALL_NT_HIST; TList *ALL_RUN_HIST; TApplication *theApp; int ROOT_WRITE_LOCK; TTree *T; // Define some local variables double px,py,pz,E,Mass; float data[100]; bool DONE ; TRandom *rndm; TDirectory *main; char hist_name[80]; char host_name[80]; void sigHandler(int sig) { DONE = true; } Hist(); ~Hist() { cout << " Destructor Hist!!! " << "\n"; delete rndm; //rootspy->cMsgSys->stop(); cout << "=====> ROL_2 Dlete rootspy !!! " << "\n"; //delete rootspy; } int ped_fill(int ped); int f250_scalers_fill(int rate); int test_fill(); void Fill_F125(int slot, int chan, int adc); void Fill_F250_adc(int slot, int chan, int adc); void Fill_F250_ped(int slot, int chan, int ped); void Fill_F250_Scalers(int slot, int chan, double rate); void Fill_DISCR_Scalers(int slot, int chan, double rate); void Fill_DIRC_Scalers(int slot, int fiber, int chan, double rate); void Fill_DIRC_Data(int slot, int fiber, int chan, double data); void Reset_DIRC_Scalers(int slot); void Reset_DIRC_Data(int slot); void Fill_CAEN(int slot, int chan, unsigned int tdc); void Fill_F1TDC(int slot, int chan, int time); int Reset_Hist(int runnum, int flag); int Save_Hists(int flag, int DAC); int Fit_Hist(int RUN_NUM,int DAC, int FADC, int* new_dac, int *new_thr, int max_dac); int Fit_PedMon(); void FillPed(int bin,double ped,int FADC); void FillSigma(int bin,double sigma,int FADC); }; //------------------------------------------------------------------- int analyzeBank_F1TDC(unsigned int *buffer); int analyzeBank_CEAN_TDC(unsigned int *buffer); int analyzeBank_F250(unsigned int *buffer); int analyzeBank_F125(unsigned int *buffer); int scan_bank(unsigned int *bank, int size); unsigned int aswap(unsigned int *bank, int len); unsigned int bswap(unsigned int *bank); //------------------------------------------------------------------- class RocHeader { public: unsigned int Size; //: 32; unsigned short Stat; //: 4; unsigned short ID; //: 12; unsigned short Pad; //: 2; unsigned short BOB; //: 6; unsigned short Nev; //: 8; RocHeader(unsigned int *bank) { Size=bank[0]; Stat=(bank[1]>>28)&0xF; ID=(bank[1]>>16)&0xFF; BOB=(bank[1]>>8)&0x3F; Nev=(bank[1])&0xFF; } ~RocHeader() { //cout << " Destructor RocHeader!!! " << "\n"; } void print() { printf(" --> ROC Header: ROC: Stat=0x%X ID=0x%03X bob=0x%02X Nev=%d ::Evt_size=%6d \n" ,Stat ,ID ,BOB ,Nev ,Size ); } }; //------------------------------------------------------------------- class TriggerHeader { public: unsigned int Size; // :32; unsigned short Type; // :16; unsigned short Pad; // :2; unsigned short BOS; // :6; unsigned short Nev; // :8; unsigned short ID; // :8; unsigned short seg; // :8; unsigned short Len; // :16; TriggerHeader(unsigned int *bank) { Size=bank[0]; Type=(bank[1]>>16)&0xFFFF; BOS=(bank[1]>>8)&0x3F; Nev=(bank[1])&0xFF; ID=(bank[2]>>24)&0xFF; seg=(bank[2]>>16)&0xFF; Len=(bank[2])&0xFFFF; } ~TriggerHeader() { //cout << " Destructor TriggerHeader!!! " << "\n"; } void print() { printf(" --> Trigger Header: BankType=0x%04X bos=0x%02X Size=%6d Nev=%d ID=%3d seg=0x%02X Len=%4d\n" ,Type ,BOS ,Size ,Nev ,ID ,seg, Len); } }; //------------------------------------------------------------------- class BankHeader { public: unsigned Header[2]; unsigned int Size;//: 32; unsigned short Tag;//: 16; unsigned short Pad;//: 2; unsigned short Type;//: 6; unsigned short Num;//: 8; BankHeader(unsigned int *bank) { Header[0]=bank[0]; Header[1]=bank[1]; Size=bank[0]; Tag=(bank[1]>>16)&0xFFFF; Pad=(bank[1]>>14)&0x3; Type=(bank[1]>>8)&0x3F; Num=(bank[1])&0xFF; } ~BankHeader() { //cout << " Destructor BankHeader!!! " << "\n"; } void print() { printf(" Bank Header:: Tag=0x%04X Type=0x%02x Num=%3d Pad=%d ::Size=%6d Header:: 0x%X(%d) , 0x%X \n" ,Tag ,Type ,Num , Pad ,Size ,Header[0] ,Header[0] ,Header[1] ); } } ; //------------------------------------------------------------------- /** Defines the container bank types.*/ typedef enum { BANK = 0xe, /**<2-word header, 16-bit tag, 8-bit num, 8-bit type.*/ SEGMENT = 0xd, /**<1-word header, 8-bit tag, no num, 8-bit type.*/ TAGSEGMENT = 0xc /**<1-word header, 12-bit tag, no num, 4-bit type.*/ } DataType; //--------------------------------------------------------------------- int close_hist(); Hist* init_hist(roc_shmem *shmem_ptr); int reset_hist(int runnum, int flag); int fill_hist(); int fill_ped(int ped); int fill_fadc(int slot, int chan, int adc ); int fill_bank(unsigned int *bank, int size); int fill_f250_scalers(int slot, int chan, double rate ); int fill_discr_scalers(int slot, int chan, double rate ); int fill_discr_slots(int Nslots, int *Dslots); int save_hists(int flag, int DAC); int fit_hist(int RUN_NUM, int DAC, int FADC, int *new_dac, int *new_thr, int max_dac); int fill_discr_time(double time); // DIRC int fill_dirc_time(double time); int fill_dirc_scalers(int slot, int fiber, int chan, double rate ); int fill_dirc_data(int slot, int fiber, int chan, uint64_t data ); int reset_dirc_scalers(int slot); int reset_dirc_data(int slot);