#include "get4/Processor.h" #include #include #include #include "base/ProcMgr.h" #include "get4/SubEvent.h" get4::Get4Rec::Get4Rec() : used(false), fChannels(nullptr) { for(unsigned n=0;nRegisterProc(this, base::proc_RocEvent, rocid); mgr()->RegisterProc(this, base::proc_RawData, rocid); } // printf("Start histo creation\n"); fMsgsKind = MakeH1("MsgKind", "kind of messages", 12, 0, 12, "xbin:NOP,-,EPOCH,SYNC,AUX,EPOCH2,GET4,SYS,EP32,SL32,ERR32,HIT32;kind"); fSysTypes = MakeH1("SysTypes", "Distribution of system messages", 16, 0, 16, "systype"); fMsgPerGet4 = MakeH1("PerGet4", "Distribution of hits between Get4", 16, 0, 16, "get4"); fSlMsgPerGet4 = MakeH2("SlPerGet4", "Distribution of Slow control messages between Get4", 16, 0, 16, 4, 0, 4, "get4; SL type"); fScalerPerGet4 = MakeH2("ScalerGet4", "Distribution of SL Scaler values between Get4", 16, 0, 16, 4096, 0, 8192, "get4"); fDeadPerGet4 = MakeH2("DeadTmGet4", "Distribution of Dead Time values between Get4", 16, 0, 16, 2048, 0, 4096, "get4"); fSpiPerGet4 = MakeH2("SpiOutGet4", "Distribution of SPI Out between Get4", 16, 0, 16, 820, 0, 8200, "get4"); fSeuPerGet4 = MakeH2("SeuScaGet4", "Distribution of SEU scaler values between Get4", 16, 0, 16, 410, 0, 410, "get4; SEU"); fDllPerGet4 = MakeH2("DllPerGet4", "DLL flag values for all hits, Get4 as unit, ch as sub-unit", 4*16, 0, 16, 2, 0, 2, "get4.ch; DLL Flag"); CreateBasicHistograms(); // printf("Histo creation done\n"); for (unsigned get4=0; (get4<16) && (get4mask!=0); get4++) { GET4.emplace_back(); GET4[get4].used = (get4mask & 1) == 1; get4mask = get4mask >> 1; if (!GET4[get4].used) continue; SetSubPrefix("GET4_", get4); GET4[get4].fChannels = MakeH1("Channels", "GET4 channels", 8, 0, 4., "ch"); for(unsigned n=0;n 11798000) exit(11); // marker.globaltm = 0.; // will be filled by the StreamProc // marker.bufid = 0; // will be filled by the StreamProc AddSyncMarker(marker); } if (fTriggerSignal == (10 + sync_ch)) { base::LocalTimeMarker marker; marker.localid = 10 + sync_ch; marker.localtm = localtm; AddTriggerMarker(marker); } break; } case base::MSG_AUX: { unsigned auxid = msg.getAuxChNum(); FillH1(fAUXt[auxid], msgtm); ignoremsg = fIgnore250Mhz; if (fIgnore250Mhz) break; if (fTriggerSignal == auxid) { base::LocalTimeMarker marker; marker.localid = auxid; marker.localtm = localtm; AddTriggerMarker(marker); } break; } case base::MSG_SYS: { if (msg.isGet4V10R32()) { FillH1(fMsgsKind, 8 + msg.getGet4V10R32MessageType()); if (msg.is32bitHit()) { FillH1(fHITt, msgtm); unsigned get4 = msg.getGet4V10R32ChipId(); FillH1(fMsgPerGet4, get4); if (!get4_in_use(get4)) break; unsigned ch = msg.getGet4V10R32HitChan(); unsigned edge = 0; unsigned ts = msg.getGet4V10R32HitTimeBin(); unsigned tot = msg.getGet4V10R32HitTot(); // fill rising and falling edges together FillH1(GET4[get4].fChannels, ch + edge*0.5); // DLL lock FillH2(fDllPerGet4, get4 + ch*0.25, msg.getGet4V10R32HitDllFlag() ); if (fRefChannelId == get4 * 100 + ch*10 + edge) { base::LocalTimeMarker marker; marker.localid = (get4+1) * 100 + ch*10 + edge; marker.localtm = localtm; // printf("GET4 TRIGGER: %10.9f\n", marker.localtm); AddTriggerMarker(marker); } FillH1(GET4[get4].fRisCoarseTm[ch], ts / 128); FillH1(GET4[get4].fRisFineTm[ch], ts % 128); FillH1(GET4[get4].fTotTm[ch], tot); FillH1(GET4[get4].fFalCoarseTm[ch], (ts+tot) / 128); FillH1(GET4[get4].fFalFineTm[ch], (ts+tot) % 128); } else if (msg.is32bitSlow()) { unsigned get4 = msg.getGet4V10R32ChipId(); FillH2( (base::H1handle)fSlMsgPerGet4, get4, msg.getGet4V10R32SlType() ); switch( msg.getGet4V10R32SlType() ) { case 0: FillH2(fScalerPerGet4, get4, msg.getGet4V10R32SlData()); break; case 1: FillH2(fDeadPerGet4, get4, msg.getGet4V10R32SlData()); break; case 2: FillH2(fSpiPerGet4, get4, msg.getGet4V10R32SlData()); break; case 3: FillH2(fSeuPerGet4, get4, msg.getGet4V10R32SlData()); break; default: break; } } } else { FillH1(fMsgsKind, base::MSG_SYS); FillH1(fSysTypes, msg.getSysMesType()); } break; } } // switch // keep time of first non-epoch message as start point of the buffer if (first && !ignoremsg && !msg.isEpochMsg()) { first = false; buf().local_tm = localtm; } } FillMsgPerBrdHist(msgcnt); return true; } bool get4::Processor::SecondBufferScan(const base::Buffer& buf) { if (buf.null()) return false; // printf("get4::Processor::SecondBufferScan left %u right %u totalsize %u max disorder %f\n", // fGlobalTrigScanIndex, fGlobalTrigRightIndex, (unsigned) fGlobalMarks.size(), MaximumDisorderTm()); // printf("Start second buffer scan left %u right %u size %u\n", lefttrig, righttrig, fGlobalTrig.size()); // for (unsigned n=0;n