• Main Page
  • Related Pages
  • Namespaces
  • Data Structures
  • Files
  • File List
  • Globals

onlinemonitor/rocmonitor/TRocRec.cxx (r4864/r3423)

Go to the documentation of this file.
00001 #include "TRocRec.h"
00002 
00003 #include "TLatex.h"
00004 
00005 TRocRec::TRocRec()
00006 {
00007    fRocId = 0;
00008 
00009    fCurrEpoch = 0;
00010 
00011    fAUXch = 0;
00012    fMsgTypes = 0;
00013    fSysTypes = 0;
00014    fSysUserTypes = 0;
00015    fTrigger_AllNX = 0;
00016    fTrigger_AllNX_100 = 0;
00017    fTriggerWind = 0; // time window to assign hits to event
00018    fAUXWind = 0; // time window to assign AUX to event
00019    fEvntMultipl = 0; // event multiplicity in time window after trigger signal
00020 
00021    fLastTm = 0;  //
00022    fLastTriggerTm = 0;
00023 
00024    for (int n=0;n<MAX_AUX;n++) fLastAuxTm[n] = 0;  
00025    for (int n=0;n<MAX_SYNC;n++) {
00026       fLastSyncTm[n] = 0;
00027       fLastSyncId[n] = 0;
00028    }
00029    fStartSyncTm = 0;
00030    fStopSyncTm = 0;
00031 
00032    for (int nx=0;nx<MAX_NX;nx++) {
00033       fADCs[nx] = 0; // individual ADC histogram for each ROC/nxyter
00034       fTrigADCs[nx] = 0; // individual ADC histogram for each ROC/nxyter
00035       fBaseline[nx] = 0; // individual baseline histogram for each ROC/nxyter
00036       fADCs_wo_baseline[nx] = 0; // individual ADC wo baseline for each ROC/nxyter
00037       fChs[nx] = 0; // individual ADC histogram for each ROC/nxyter
00038       fTrigger_NX[nx] = 0; // time shift between last trigger and nXYTER hit
00039 
00040       for (int ch=0; ch<NUM_NXCHANNELS; ch++) fNxTm[nx][ch] = 0;
00041       for (int ndiff = 0; ndiff < NUM_DIFFS; ndiff++)
00042          fTmDiff[nx][ndiff] = 0;
00043    }
00044 
00045    for (int aux=0;aux<MAX_AUX;aux++)
00046       fAUXt[aux] = 0; // time distribution of aux signals
00047 
00048    fIsEventComplete = kFALSE;
00049    fHasNewData = kFALSE;
00050    fHasNewTrigger=kFALSE;
00051    fHasEndOfBuffer=kFALSE;
00052    fTriggersPerBuffer=0;
00053    fLoopsPerBuffer=0;
00054    fDabcSeparator=-1;
00055 
00056    bCollectBaseline = kFALSE;
00057    bIgnoreData = kFALSE;
00058    fIgnoreCnt = 0;
00059    fIgnoreTime = 0;       // time when ignore message was generated
00060    fCollectTime = 0;      // time when collect message was generated
00061 
00063    /*************************************/
00064 
00065    for (int n=0;n<MAX_GET4;n++) {
00066       fLastEpoch2[n] = 0; // last epoch2 time
00067       fLastEpoch2Sync[n] = 0; // last epoch2 time with sync=1
00068       fGet4Channels[n] = 0;
00069       fGet4Tm[n] = 0; // distribution of GET4 time stamps
00070       for(int k=0;k<MAX_GET4_CH;k++) {
00071          fGet4EdgeCnt[n][k] = 0;
00072          fGet4ErrCnt[n][k] = 0;
00073          fGet4ChangeCnt[n][k] = 0;
00074          fGet4SuspiciousCnt[n][k] = 0;
00075          for (int fl=0;fl<2;fl++) {
00076             fGet4TmCh[n][k][fl] = 0;
00077             fGet4ChCnt[n][k][fl] = 0;
00078             fLastGet4Tm[n][k][fl] = 0;
00079          }
00080       }
00081 
00082       fGet4DiffSync[n] = 0;
00083       fGet4Info[n] = 0;
00084       fGet4Trigger[n] = 0;
00085       fGet4Trigger100[n] = 0;
00086       fLastEpoch2Info[n] = 0;
00087       fEpoch2cnt[n] = 0;
00088    }
00089    fGet4SysTypes = 0; // Get4 System message type
00090    fGet4Chips = 0;
00091 
00092 }
00093 
00094 void TRocRec::ProcessEpoch2(unsigned g4id, uint32_t epoch2, uint32_t sync, Bool_t debug)
00095 {
00096    if (g4id>=MAX_GET4) return;
00097 
00098    uint32_t diff = epoch2 - fLastEpoch2[g4id];
00099 
00100    if ((fLastEpoch2[g4id]!=0) && (diff!=1) && (diff<10) && debug)
00101       printf("EPOCH2 JUMP ROC:%d epoch2:%u Get4:%u diff:%u\n", fRocId, epoch2, g4id, diff);
00102 
00103    if (sync && (epoch2 % 25 != 0) && debug)
00104       printf("ROC:%d Get4:%u EPOCH2 %u with sync mod 25 = %u \n", fRocId, g4id, epoch2, epoch2 % 25);
00105 
00106    // check about every 600 ms
00107    if (sync && (epoch2 % 25000 == 0)) {
00108       for (int nch=0;nch<MAX_GET4_CH;nch++) {
00109          if ((fGet4ChangeCnt[g4id][nch] > 10) &&
00110              (fGet4SuspiciousCnt[g4id][nch] > 0.2 * fGet4ChangeCnt[g4id][nch]) && debug)
00111                 printf("ROC:%d Get4:%u Channel:%u Has suspicious difference between edges fullcnt:%d suspiciouscnt:%d\n",fRocId, g4id, nch, fGet4ChangeCnt[g4id][nch], fGet4SuspiciousCnt[g4id][nch]);
00112          if ((fGet4ErrCnt[g4id][nch]>4) && debug)
00113              printf("ROC:%d Get4:%u Channel:%u has too many contigious edges errors cnt:%d\n",fRocId, g4id, nch, fGet4ErrCnt[g4id][nch]);
00114 
00115          fGet4ChangeCnt[g4id][nch]=0;
00116          fGet4SuspiciousCnt[g4id][nch]=0;
00117          fGet4ErrCnt[g4id][nch]=0;
00118       }
00119    }
00120 
00121    fLastEpoch2[g4id] = epoch2;
00122    fEpoch2cnt[g4id]++;
00123 
00124    if (sync) fLastEpoch2Sync[g4id] = epoch2;
00125 
00126    if (fGet4Info[g4id]==0) return;
00127 
00128    if (fLastEpoch2Info[g4id]!=0) {
00129 
00130 //      printf("Diff ROC:%d G4:%u %u %g \n", fRocId, g4id, fLastEpoch2[g4id] - fLastEpoch2Info[g4id], roc::Message::FullTimeStamp2(fLastEpoch2[g4id] - fLastEpoch2Info[g4id], 0) / 2e10);
00131 
00132       // 40000 GET4 epochs is about 1 sec
00133       if ((fLastEpoch2[g4id] > fLastEpoch2Info[g4id]) && (fLastEpoch2[g4id] < (fLastEpoch2Info[g4id]+40000))) return;
00134 
00135       if ((fLastEpoch2[g4id] >= (fLastEpoch2Info[g4id]+40000)) && (fEpoch2cnt[g4id]>0)) {
00136 
00137          // we take into account only effective time - excluding parts, skipped by streamserver
00138          double tm = roc::Message::FullTimeStamp2(fEpoch2cnt[g4id], 0) / 2e10;
00139 
00140          TString txt = "#splitline";
00141 
00142          txt+=Form("{#scale[1.0]{#color[2]{ROC%d GET4:%u}}}", fRocId, g4id);
00143 
00144          for(int k=0;k<MAX_GET4_CH;k++) {
00145             if ((fGet4ChCnt[g4id][k][0]==0) && (fGet4ChCnt[g4id][k][1]==0)) continue;
00146 
00147             double f0 = fGet4ChCnt[g4id][k][0]/tm;
00148             double f1 = fGet4ChCnt[g4id][k][1]/tm;
00149 
00150             // printf("Roc:%d Get4:%u Ch:%d %g %g\n", fRocId, g4id, k, f0,f1);
00151 
00152             txt+=Form("{#scale[0.8]{#color[4]{Ch%d fall:%6.1f Hz rise:%6.1f Hz diff:%4.1f}}}", k, f0, f1, f0-f1);
00153          }
00154 
00155          fGet4Info[g4id]->SetText(0.1, 0.7, txt.Data());
00156       }
00157    }
00158 
00159    fLastEpoch2Info[g4id] = fLastEpoch2[g4id];
00160 
00161    fEpoch2cnt[g4id] = 0;
00162    for(int k=0;k<MAX_GET4_CH;k++)
00163       for (int fl=0;fl<2;fl++)
00164          fGet4ChCnt[g4id][k][fl] = 0;
00165 }
00166 

Generated on Tue Dec 10 2013 04:52:23 for ROCsoft by  doxygen 1.7.1