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

go4monitor/TRocProc.cxx (r4864/r3193)

Go to the documentation of this file.
00001 #include "TRocProc.h"
00002 
00003 #include "Riostream.h"
00004 
00005 #include "TH1.h"
00006 #include "TH2.h"
00007 #include "TTimeStamp.h"
00008 
00009 #include "TRocParam.h"
00010 #include "TPedestalExtractor.h"
00011 #include "TGo4MbsEvent.h"
00012 #include "TGo4WinCond.h"
00013 
00014 #include "roc/Message.h"
00015 #include "roc/Iterator.h"
00016 #include "roc/Board.h"
00017 
00018 TRocRec::TRocRec()
00019 {
00020    fCurrEpoch = 0;
00021    fCurrEvent[0] = 0; 
00022    fCurrEvent[1] = 0;
00023 
00024    fLastAUX = 0;
00025 
00026    fAUXch = 0;
00027    fMsgTypes = 0;
00028    fSysTypes = 0;
00029    fSysUserTypes = 0;
00030    fTrigger_AllNX = 0;
00031    fTrigger_AllNX_100 = 0;
00032    fTriggerWind = 0; // time window to assign hits to event
00033    fEvntMultipl_AllNX = 0; // event multiplicity in time window after trigger signal
00034 
00035    fLastTm = 0;  //
00036    fLastTriggerTm = 0;
00037    fNextTriggerTm = 0;
00038    fLastCh = 0;  //
00039    for (int n=0;n<MAX_AUX;n++) fLastAuxTm[n] = 0;  
00040    for (int n=0;n<MAX_SYNC;n++) fLastSyncTm[n] = 0; 
00041    fEvMultipl_AllNX = 0;   // event multiplicity
00042 
00043    for (int nx=0;nx<MAX_NX;nx++) {
00044       fADCs[nx] = 0; // individual ADC histogram for each ROC/nxyter
00045       fBaseline[nx] = 0; // individual baseline histogram for each ROC/nxyter
00046       fADCs_wo_baseline[nx] = 0; // individual ADC wo baseline for each ROC/nxyter
00047       fChs[nx] = 0; // individual ADC histogram for each ROC/nxyter
00048       fTrigger_NX[nx] = 0; // time shift between last trigger and nXYTER hit
00049       fEvntMultipl_NX[nx] = 0; // event multiplicity in time window after trigger signal
00050       fEvMultipl_NX[nx] = 0;   // event multiplicity
00051 
00052       for (int ch=0; ch<NUM_NXCHANNELS; ch++) fNxTm[nx][ch] = 0;
00053       for (int ndiff = 0; ndiff < NUM_DIFFS; ndiff++)
00054          fTmDiff[nx][ndiff] = 0;
00055    }
00056 
00057 
00058    for (int aux=0;aux<MAX_AUX;aux++)
00059       fAUXt[aux] = 0; // time distribution of aux signals
00060 
00061    bCollectBaseline = kFALSE;
00062    bIgnoreData = kFALSE;
00063    fPedestals = 0;
00064    fIgnoreTime = 0;       // time when ignore message was generated
00065    fCollectTime = 0;      // time when collect message was generated
00066 }
00067 
00068 
00069 
00070 //***********************************************************
00071 TRocProc::~TRocProc()
00072 {
00073   cout << "**** TRocProc: Delete instance " << endl;
00074 }
00075 
00076 //***********************************************************
00077 // this one is used in standard factory
00078 TRocProc::TRocProc(const char* name) : TGo4EventProcessor(name)
00079 {
00080    cout << "**** TRocProc: Create instance " << name << endl;
00081 
00082    fParam = (TRocParam *) MakeParameter("RocPar", "TRocParam");
00083 
00084    fNumRocs = 3;
00085 
00086    fLastRateTm = 0.;
00087    fRate = 0.;
00088 
00089    if (fParam->numRocs > 0) fNumRocs = (unsigned) fParam->numRocs;
00090 
00091    for (int nx=0;nx<MAX_NX;nx++)
00092       // nx_use_mask[nx] = (nx % 2) == 0; // show only even numbers
00093       nx_use_mask[nx] = true;
00094 
00095    for (unsigned n=0; n<fNumRocs;n++)
00096       ROC.push_back(TRocRec());
00097 
00098    fEvntSize = MakeTH1('I', "EvntSize", "Number of messages in event", 250, 1., 2000.);
00099 
00100    int hnumroc = fNumRocs > 8 ? fNumRocs : 8;
00101 
00102    fMsgsPerRoc = MakeTH1('I', "MsgsPerRoc", "Number of messages per ROC", hnumroc, 0., hnumroc);
00103 
00104    fTriggerPerRoc = MakeTH1('I', "TriggersPerRoc", "Number of Trigger messages per ROC", hnumroc, 0., hnumroc);
00105 
00106    for (unsigned n=0; n<fNumRocs;n++) {
00107       char folder[30];
00108       sprintf(folder,"ROC%u/",n);
00109 
00110       ROC[n].fMsgTypes = MakeTH1('I', Form("%sMsgTypes%u", folder, n), Form("ROC%u Distribution of messages types", n), 8, 0., 8.);
00111 
00112       if (IsObjMade()) {
00113          ROC[n].fMsgTypes->GetXaxis()->SetBinLabel(1 + roc::MSG_NOP, "NOP");
00114          ROC[n].fMsgTypes->GetXaxis()->SetBinLabel(1 + roc::MSG_HIT, "HIT");
00115          ROC[n].fMsgTypes->GetXaxis()->SetBinLabel(1 + roc::MSG_EPOCH, "EPOCH");
00116          ROC[n].fMsgTypes->GetXaxis()->SetBinLabel(1 + roc::MSG_SYNC, "SYNC");
00117          ROC[n].fMsgTypes->GetXaxis()->SetBinLabel(1 + roc::MSG_AUX, "AUX");
00118          ROC[n].fMsgTypes->GetXaxis()->SetBinLabel(1 + roc::MSG_EPOCH2, "EPOCH2");
00119          ROC[n].fMsgTypes->GetXaxis()->SetBinLabel(1 + roc::MSG_GET4, "GET4");
00120          ROC[n].fMsgTypes->GetXaxis()->SetBinLabel(1 + roc::MSG_SYS, "SYS");
00121       }
00122 
00123       ROC[n].fSysTypes = MakeTH1('I', Form("%sSysTypes%u", folder, n), Form("ROC%u Distribution of system messages", n), roc::SYSMSG_GET4_EVENT+1, 0., roc::SYSMSG_GET4_EVENT+1);
00124 
00125       if (IsObjMade()) {
00126          ROC[n].fSysTypes->GetXaxis()->SetBinLabel(1 + roc::SYSMSG_DAQ_START,  "DAQ_START");
00127          ROC[n].fSysTypes->GetXaxis()->SetBinLabel(1 + roc::SYSMSG_DAQ_FINISH, "DAQ_FINISH");
00128          ROC[n].fSysTypes->GetXaxis()->SetBinLabel(1 + roc::SYSMSG_NX_PARITY,  "NX_PARITY");
00129          ROC[n].fSysTypes->GetXaxis()->SetBinLabel(1 + roc::SYSMSG_SYNC_PARITY,"SYNC_PARITY");
00130          ROC[n].fSysTypes->GetXaxis()->SetBinLabel(1 + roc::SYSMSG_DAQ_RESUME, "DAQ_RESUME");
00131          ROC[n].fSysTypes->GetXaxis()->SetBinLabel(1 + roc::SYSMSG_FIFO_RESET, "FIFO_RESET");
00132          ROC[n].fSysTypes->GetXaxis()->SetBinLabel(1 + roc::SYSMSG_USER,       "USER_MSG");
00133          ROC[n].fSysTypes->GetXaxis()->SetBinLabel(1 + roc::SYSMSG_PCTIME,     "PCTIME");
00134          ROC[n].fSysTypes->GetXaxis()->SetBinLabel(1 + roc::SYSMSG_ADC,        "ADC");
00135          ROC[n].fSysTypes->GetXaxis()->SetBinLabel(1 + roc::SYSMSG_PACKETLOST, "PACKETLOST");
00136          ROC[n].fSysTypes->GetXaxis()->SetBinLabel(1 + roc::SYSMSG_GET4_EVENT, "GET4_EVENT");
00137       }
00138 
00139       ROC[n].fSysUserTypes = MakeTH1('I', Form("%sSysUserTypes%u", folder, n), Form("ROC%u Distribution of user messages", n), 8, 7., 15.);
00140       if (IsObjMade()) {
00141          ROC[n].fSysUserTypes->GetXaxis()->SetBinLabel(roc::SYSMSG_USER_CALIBR_ON - 6, "CALIBR_ON");
00142          ROC[n].fSysUserTypes->GetXaxis()->SetBinLabel(roc::SYSMSG_USER_CALIBR_OFF - 6, "CALIBR_OFF");
00143          ROC[n].fSysUserTypes->GetXaxis()->SetBinLabel(roc::SYSMSG_USER_RECONFIGURE - 6, "RECONFIGURE");
00144       }
00145 
00146       ROC[n].fAUXch = MakeTH1('I', Form("%sRoc%u_aux_chs", folder, n), "Number events per aux channel", 8, 0., 8.);
00147 
00148       ROC[n].fTrigger_AllNX = MakeTH1('I', Form("%sRoc%u_Trigger_AllNX", folder, n), Form("Time difference between all nXYTER hit and last trigger signal on ROC%u", n), 2500, -1000., 4000.);
00149       ROC[n].fTrigger_AllNX_100 = MakeTH1('I', Form("%sRoc%u_Trigger_AllNX_100", folder, n), Form("Time difference between all nXYTER hit and last trigger signal on ROC%u", n), 5005, -1000., 1e6);
00150 
00151       ROC[n].fTriggerWind = MakeWinCond(Form("Roc%u_EventWindow",n), 485., 885., ROC[n].fTrigger_AllNX->GetName());
00152 
00153       ROC[n].fEvntMultipl_AllNX = MakeTH1('I', Form("%sRoc%u_Multiplicity", folder, n), Form("Event multiplicity for ROC%u in time window", n), 16, 0., 16.);
00154 
00155       for (unsigned nsync=0; nsync<MAX_SYNC; nsync++)
00156          ROC[n].fSYNCt[nsync] = MakeTH1('I', Form("%sRoc%u_Sync%u_t", folder, n, nsync), Form("Time distribution of SYNC%u signal on ROC%u", nsync, n), 10000, 0., 1000.);
00157 
00158       for (unsigned naux=0; naux<MAX_AUX; naux++)
00159          ROC[n].fAUXt[naux] = MakeTH1('I', Form("%sRoc%u_Aux%u_t", folder, n, naux), Form("Time distribution of AUX%u signal on ROC%u", naux, n), 10000, 0., 1000.);
00160 
00161       for (int k=0;k<2;k++)
00162          ROC[n].fFebADC[k] = MakeTH1('I', Form("%sRoc%u_Feb%d_adcs", folder, n, k), Form("ADC values on ROC%u FEB%d", n, k), 4, 0., 4., "channel", "ADC");
00163 
00164       for(unsigned nx=0;nx<MAX_NX;nx++) if (nx_use_mask[nx]) {
00165 
00166          char nxfolder[30], nxinfo[30];
00167          sprintf(nxfolder,"%sNX%u/Roc%u_nx%u_", folder, nx, n, nx);
00168          sprintf(nxinfo,"ROC = %u NXYTER = %u", n, nx);
00169 
00170          ROC[n].fChs[nx] = MakeTH1('I', Form("%schannels", nxfolder), Form("Channels from %s", nxinfo), 128, 0., 128.);
00171          ROC[n].fTrigger_Chs[nx] = MakeTH1('I', Form("%schs_trigg", nxfolder), Form("Channels from %s under trigger cut", nxinfo), 128, 0., 128.);
00172          ROC[n].fADCs[nx] = MakeTH2('I', Form("%sadc", nxfolder), Form("ADC distribution for %s", nxinfo), 128, 0., 128., 1024, 0., 4096., "Channel number", "ADC values");
00173          ROC[n].fBaseline[nx] = MakeTH2('I', Form("%sBaseline", nxfolder), Form("Baseline for %s", nxinfo), 128, 0., 128., 4096, 0., 4096., "Channel number", "Baseline, ADC counts");
00174          if (fParam->baselineCalibr)
00175             ROC[n].fADCs_wo_baseline[nx] = MakeTH2('I', Form("%sadc_wo_baseline", nxfolder), Form("ADC - Baseline   for %s", nxinfo), 128, 0., 128., 1024, -200., 824., "Channel number", "ADC values (baseline subtracted)");
00176          ROC[n].fTrigger_NX[nx] = MakeTH1('I', Form("%sTrigger", nxfolder), Form("Time difference between hit and last trigger signal on %s", nxinfo), 2500, -1000., 4000.);
00177          ROC[n].fEvntMultipl_NX[nx] = MakeTH1('I', Form("%sMulyiplicity", nxfolder), Form("Hit multiplicity on %s", nxinfo), 16, 0., 16.);
00178 
00179          if (fParam->nxDiffCh>=0)
00180             for (int ndiff=0;ndiff<NUM_DIFFS; ndiff++) {
00181                int nch = ndiff * (MOD_DIFFS + 1) + MOD_DIFFS;
00182                ROC[n].fTmDiff[nx][ndiff] = MakeTH1('I', Form("%sDiff_%d_%d", nxfolder, fParam->nxDiffCh, nch), Form("Time difference between channels %d and %d from %s", fParam->nxDiffCh, nch, nxinfo), 2000, -1000., 1000.);
00183             }
00184       }
00185 
00186       if (fParam->baselineCalibr)
00187          ROC[n].fPedestals = new TPedestalExtractor(1, MAX_NX);
00188    }
00189 }
00190 
00191 void TRocProc::ProcessTriggerMessage(int rocid, uint64_t fulltm)
00192 {
00193    fTriggerPerRoc->Fill(rocid);
00194 
00195    ROC[rocid].fLastTriggerTm = fulltm;
00196 
00197    if (fulltm != 0) {
00198       ROC[rocid].fEvntMultipl_AllNX->Fill(ROC[rocid].fEvMultipl_AllNX);
00199       for (unsigned nx=0;nx<MAX_NX;nx++)
00200          if (nx_use_mask[nx])
00201             ROC[rocid].fEvntMultipl_NX[nx]->Fill(ROC[rocid].fEvMultipl_NX[nx]);
00202     }
00203 
00204     ROC[rocid].fEvMultipl_AllNX = 0;
00205     for (unsigned nx=0;nx<MAX_NX;nx++)
00206     if (nx_use_mask[nx])
00207       ROC[rocid].fEvMultipl_NX[nx] = 0;
00208 }
00209 
00210 int32_t TRocProc::CalcDistanceToTrigger(int rocid, uint64_t fulltm)
00211 {
00212    if (ROC[rocid].fNextTriggerTm && (ROC[rocid].fNextTriggerTm < fulltm))
00213       return fulltm - ROC[rocid].fNextTriggerTm;
00214    else
00215    if (ROC[rocid].fNextTriggerTm && (fulltm > ROC[rocid].fNextTriggerTm - 1000))
00216        return -1 * (ROC[rocid].fNextTriggerTm - fulltm);
00217    else
00218    if (ROC[rocid].fLastTriggerTm && (ROC[rocid].fLastTriggerTm < fulltm))
00219        return fulltm - ROC[rocid].fLastTriggerTm;
00220    else
00221    if (ROC[rocid].fLastTriggerTm && (fulltm > ROC[rocid].fLastTriggerTm - 1000 ))
00222        return -1 * (ROC[rocid].fLastTriggerTm - fulltm);
00223 
00224    return -10000000;
00225 }
00226 
00227 
00228 //-----------------------------------------------------------
00229 // event function
00230 Bool_t TRocProc::BuildEvent(TGo4EventElement* ev)
00231 {
00232   // called by framework from TRocFastEvent to fill it
00233 
00234   TGo4MbsEvent* fInput = (TGo4MbsEvent* ) GetInputEvent();
00235   if(fInput == 0) {
00236      cout << "AnlProc: no input event !"<< endl;
00237      return kFALSE;
00238   }
00239 
00240   if(fInput->GetTrigger() > 11) {
00241       cout << "**** TRocProc: Skip trigger event"<<endl;
00242       return kFALSE;
00243     }
00244 
00245   uint32_t nxid(0), nxch(0), nxadc(0), auxid(0), syncid(0);
00246   uint64_t fulltm(0);
00247   uint32_t typ(0), rocid(0);
00248   int32_t diff(0);
00249   bool is_beam_hit(false);
00250 
00251   Double_t nxadc_corr = 0.;
00252 
00253   TGo4MbsSubEvent* psubevt = 0;
00254 
00255   long totaldatasize = 0;
00256 
00257 //  cout << "Start processing" << endl;
00258 
00259   fInput->ResetIterator();
00260   while((psubevt = fInput->NextSubEvent()) != 0) { // loop over subevents
00261 
00262 
00263      ProcessSubevent(psubevt);
00264      
00265      bool is_dabc_evt = (psubevt->GetProcid() == roc::proc_RocEvent) ||
00266                         (psubevt->GetProcid() == roc::proc_ErrEvent) ||
00267                         (psubevt->GetProcid() == roc::proc_MergedEvent);
00268      bool is_raw_evt = (psubevt->GetProcid() == roc::proc_RawData);
00269 
00270      if (!is_dabc_evt && !is_raw_evt) continue;
00271      
00272      int msg_fmt = psubevt->GetControl();
00273 
00274      roc::Iterator iter(msg_fmt);
00275 
00276 //     cout << "RocID = " << (int) psubevt->GetSubcrate() << "  data kind = " << (int) psubevt->GetProcid() << endl;
00277 
00278      iter.setRocNumber(psubevt->GetSubcrate());
00279 
00280      int datasize = (psubevt->GetDlen() - 2) * 2;
00281 
00282 //     fParam->triggerSignal = 10;
00283      
00284      // this is special part to process hit which are in current event but belong to the 
00285      // next trigger. We have SYNC in the end of our data therefore we
00286      // can use it to compare hit time with next trigger event
00287      
00288      roc::Message msg1, msg2;
00289      
00290      if (is_dabc_evt) {
00291         char* ptr = (char*) psubevt->GetDataField();
00292         int msglen = roc::Message::RawSize(msg_fmt);
00293 
00294         if (iter.assign(ptr + datasize - msglen, msglen)) {
00295            if (iter.next()) msg1.assign(iter.msg());
00296         }
00297 
00298         if (msg1.isSyncMsg()) datasize -= msglen;
00299 
00300         int shift = msglen;
00301         while (shift<=datasize) {
00302 
00303            if (iter.assign(ptr + datasize - shift, msglen)) {
00304               if (iter.next())
00305                  msg2.assign(iter.msg());
00306               else
00307                  break;
00308 
00309               if (msg2.isEpochMsg()) break;
00310            }
00311            shift+=msglen;
00312         }
00313         // exclude special epoch message for sync only
00314         if ((shift==msglen) && msg2.isEpochMsg()) datasize -= msglen;
00315 
00316         for (unsigned rocid=0;rocid<fNumRocs; rocid++)
00317            ROC[rocid].fNextTriggerTm = 0;
00318      }
00319      
00320      if (msg1.isSyncMsg() && msg2.isEpochMsg() && 
00321           (msg1.getRocNumber()==msg2.getRocNumber()) &&
00322           (fParam->triggerSignal == (msg1.getSyncChNum() + 10))) {
00323         unsigned rocid = msg1.getRocNumber();
00324 
00325         fulltm = msg1.getMsgFullTime(msg2.getEpochNumber());
00326         if (rocid<fNumRocs)
00327            ROC[rocid].fNextTriggerTm = fulltm;
00328      }
00329 
00330      // end of special data processing
00331 
00332      totaldatasize += datasize;
00333 
00334      if (!iter.assign(psubevt->GetDataField(), datasize)) continue;
00335 
00336      roc::Message* data = & iter.msg();
00337 
00338 //     cout << "nummsgs = " << datasize << "  len = " << datasize*6 << endl;
00339 
00340      fEvntSize->Fill(datasize);
00341 
00342      //cout << "AnlProc: found subevent subcrate="<<(int) psubevt->GetSubcrate()<<", procid="<<(int)psubevt->GetProcid()<<", control="<<(int) psubevt->GetControl()<< endl;
00343 
00344      while (iter.next()) {
00345 
00346         rocid = data->getRocNumber();
00347 
00348         fMsgsPerRoc->Fill(rocid);
00349         if (rocid>=fNumRocs) continue;
00350 
00351         typ = data->getMessageType();
00352 
00353         fulltm = data->getMsgFullTime(ROC[rocid].fCurrEpoch);
00354 
00355         ROC[rocid].fMsgTypes->Fill(typ);
00356 
00357         ProcessRocMsg(data);
00358 
00359         if (ROC[rocid].bIgnoreData) {
00360            if ((fulltm < ROC[rocid].fIgnoreTime) || (fulltm - ROC[rocid].fIgnoreTime > 1e8)) {
00361               ROC[rocid].bIgnoreData = kFALSE;
00362               ROC[rocid].bCollectBaseline = kFALSE;
00363               if (ROC[rocid].fPedestals) ROC[rocid].fPedestals->Reset();
00364               printf("FOR A LONG TIME no reconfiguration message for ROC %u - dist:%ld, continue analysis\n", rocid, (long) (fulltm - ROC[rocid].fIgnoreTime));
00365            }
00366         }
00367 
00368         if (ROC[rocid].bCollectBaseline) {
00369            if ((fulltm < ROC[rocid].fCollectTime) || (fulltm - ROC[rocid].fCollectTime > 3e9)) {
00370               ROC[rocid].bIgnoreData = kFALSE;
00371               ROC[rocid].bCollectBaseline = kFALSE;
00372               if (ROC[rocid].fPedestals) ROC[rocid].fPedestals->Reset();
00373               printf("FOR A LONG TIME no calibr-off message for ROC %u - dist:%ld, continue analysis\n", rocid, (long) (fulltm - ROC[rocid].fCollectTime));
00374            }
00375         }
00376 
00377         switch (typ) {
00378            case roc::MSG_NOP:
00379               break;
00380            case roc::MSG_HIT:
00381 
00382               if (ROC[rocid].bIgnoreData) continue;
00383 
00384               nxid = data->getNxNumber();
00385               nxch = data->getNxChNum();
00386               nxadc = data->getNxAdcValue();
00387 
00388               if ((nxid>=MAX_NX) || !nx_use_mask[nxid]) continue;
00389 
00390               ROC[rocid].fNxTm[nxid][nxch] = fulltm;
00391 
00392               if (fParam->nxDiffCh>=0) {
00393                  if (nxch == (unsigned) fParam->nxDiffCh) {
00394                     for (int ndiff=0;ndiff<NUM_DIFFS; ndiff++) {
00395                        int ch2 = ndiff * (MOD_DIFFS + 1) + MOD_DIFFS;
00396                        double diff = 0. + ROC[rocid].fNxTm[nxid][fParam->nxDiffCh] - ROC[rocid].fNxTm[nxid][ch2];
00397                        if (TMath::Abs(diff) < 1e4)
00398                           ROC[rocid].fTmDiff[nxid][ndiff]->Fill(diff);
00399                     }
00400                  }
00401 
00402                  if (nxch % (MOD_DIFFS + 1) == MOD_DIFFS) {
00403                     int ndiff = nxch / (MOD_DIFFS + 1);
00404                     double diff = 0. + ROC[rocid].fNxTm[nxid][fParam->nxDiffCh] - ROC[rocid].fNxTm[nxid][nxch];
00405                     if (TMath::Abs(diff) < 1e4)
00406                        ROC[rocid].fTmDiff[nxid][ndiff]->Fill(diff);
00407                  }
00408               }
00409 
00410               if (ROC[rocid].bCollectBaseline) {
00411                  ROC[rocid].fBaseline[nxid]->Fill(nxch, nxadc);
00412                  if (ROC[rocid].fPedestals)
00413                     ROC[rocid].fPedestals->AddHit(0, nxid, nxch, nxadc);
00414               } else {
00415                  ROC[rocid].fChs[nxid]->Fill(nxch);
00416                  ROC[rocid].fADCs[nxid]->Fill(nxch, nxadc);
00417                  if (ROC[rocid].fPedestals) {
00418                     nxadc_corr = ROC[rocid].fPedestals->GetPedestal(0, nxid, nxch ) - nxadc;
00419                     ROC[rocid].fADCs_wo_baseline[nxid]->Fill(nxch, nxadc_corr);
00420                  } else
00421                     nxadc_corr = 4095 - nxadc;
00422 
00423                  ProcessNxHit(data, nxadc_corr);
00424               }
00425 
00426               diff = CalcDistanceToTrigger(rocid, fulltm);
00427 
00428               if (diff > -1000000) {
00429                  ROC[rocid].fTrigger_AllNX->Fill(diff);
00430                  ROC[rocid].fTrigger_AllNX_100->Fill(diff);
00431                  ROC[rocid].fTrigger_NX[nxid]->Fill(diff);
00432                  is_beam_hit = ROC[rocid].fTriggerWind->Test(diff);
00433                  if (is_beam_hit) {
00434                     ROC[rocid].fEvMultipl_AllNX++;
00435                     ROC[rocid].fEvMultipl_NX[nxid]++;
00436                     ROC[rocid].fTrigger_Chs[nxid]->Fill(nxch);
00437                  }
00438               }
00439               break;
00440 
00441            case roc::MSG_EPOCH:
00442               ROC[rocid].fCurrEpoch = data->getEpochNumber();
00443               break;
00444            case roc::MSG_SYNC: 
00445               syncid = data->getSyncChNum();
00446               if (syncid < MAX_SYNC) {
00447                  ROC[rocid].fCurrEvent[syncid] = data->getSyncData();
00448                  ROC[rocid].fLastSyncTm[syncid] = fulltm;
00449                  uint64_t synctm = fulltm / 100000000L;
00450                  ROC[rocid].fSYNCt[syncid]->Fill((synctm % 10000) * 0.1);
00451               }
00452               if (fParam->triggerSignal == (int)(syncid + 10)) ProcessTriggerMessage(rocid, fulltm);
00453               break;
00454            case roc::MSG_AUX:
00455               auxid = data->getAuxChNum();
00456 
00457               ROC[rocid].fAUXch->Fill(auxid);
00458 
00459               if (auxid < MAX_AUX) {
00460                  ROC[rocid].fLastAuxTm[auxid] = fulltm;
00461                  uint64_t auxtm = fulltm / 100000000L;
00462                  ROC[rocid].fAUXt[auxid]->Fill((auxtm % 10000) * 0.1);
00463               }
00464               
00465               if (fParam->triggerSignal == (int) auxid) ProcessTriggerMessage(rocid, fulltm);
00466 
00467               break;
00468            case roc::MSG_SYS:
00469 
00470               ROC[rocid].fSysTypes->Fill(data->getSysMesType());
00471 
00472               if (data->getSysMesType() == roc::SYSMSG_USER) {
00473                  ROC[rocid].fSysUserTypes->Fill(data->getSysMesData());
00474                  switch(data->getSysMesData()) {
00475                    case roc::SYSMSG_USER_CALIBR_ON:
00476 //                     printf ("FIND USER_CALIBR_ON!!!\n"); 
00477                      if (ROC[rocid].fPedestals) ROC[rocid].fPedestals->Reset();
00478                      ROC[rocid].bIgnoreData = kFALSE;
00479                      ROC[rocid].bCollectBaseline = kTRUE;
00480                      ROC[rocid].fCollectTime = fulltm;
00481                      break;
00482                    case roc::SYSMSG_USER_CALIBR_OFF:
00483 //                     printf ("FIND USER_CALIBR_OFF!!!\n"); 
00484                      if (ROC[rocid].fPedestals) ROC[rocid].fPedestals->Extract();
00485                      ROC[rocid].bCollectBaseline = kFALSE;
00486                      ROC[rocid].bIgnoreData = kFALSE;
00487                      break;
00488                    case roc::SYSMSG_USER_RECONFIGURE:
00489 //                     printf ("FIND USER_RECONFIGURE!!!\n"); 
00490                      ROC[rocid].bIgnoreData = kTRUE;
00491                      ROC[rocid].fIgnoreTime = fulltm;
00492                      break;
00493                  }
00494               } else
00495               if (data->getSysMesType() == roc::SYSMSG_ADC) {
00496                  int febid = (data->getSysMesData() >> 31) & 1;
00497                  int nch = (data->getSysMesData() >> 24) & 0x7f;
00498                  int val = data->getSysMesData() & 0xffff;
00499                  ROC[rocid].fFebADC[febid]->SetBinContent(nch+1, val);
00500               }
00501         }
00502      }
00503   }
00504 
00505 //  cout << "Stop processing" << endl;
00506 
00507   // calculation of the rate
00508 
00509   double tm = TTimeStamp().AsDouble();
00510   if (fLastRateTm>0.) {
00511      double diff = tm - fLastRateTm;
00512      if (diff > 0) {
00513         double rate = totaldatasize / diff;
00514         if (fRate==0.) fRate = rate;
00515         fRate = fRate * 0.9 + rate * 0.1;
00516         fEvntSize->SetTitle(Form("RATE %5.1f KB/s", fRate/1024.));
00517      }
00518   }
00519   fLastRateTm = tm;
00520 
00521   return kTRUE;
00522 }

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