00001 #include "TGet4v1Proc.h"
00002
00003 #include "TGo4Version.h"
00004 #if __GO4BUILDVERSION__ > 40502
00005 #include "go4iostream.h"
00006 #else
00007 #include "Riostream.h"
00008 #endif
00009
00010 #include "TH1.h"
00011 #include "TH2.h"
00012 #include "TTimeStamp.h"
00013 #include "TROOT.h"
00014 #include "TSystem.h"
00015 #include "TLatex.h"
00016
00017 #include "TGet4v1Param.h"
00018 #include "TGo4MbsEvent.h"
00019 #include "TGo4WinCond.h"
00020 #include "TGo4Log.h"
00021 #include "TGo4Version.h"
00022
00023 #include "roc/Message.h"
00024 #include "roc/Board.h"
00025
00026 #include <algorithm>
00027
00028
00029
00030 #define ROC_SINGLETRIGGERMODE 1
00031
00032 TGet4v1Proc::TGet4v1Proc() :
00033 TCBMBeamtimeProc(),
00034 fOutputEvent(0),
00035 fIsTimeSorted(kFALSE),
00036 fHasNewGlobalTrigger(kFALSE)
00037 {
00038 }
00039
00040
00041 TGet4v1Proc::~TGet4v1Proc()
00042 {
00043 TGo4Log::Info("TGet4v1Proc: Test ");
00044 ROC.clear();
00045 TGo4Log::Info("TGet4v1Proc: Delete instance ");
00046 }
00047
00048
00049
00050 TGet4v1Proc::TGet4v1Proc(const char* name) :
00051 TCBMBeamtimeProc(name),
00052 fOutputEvent(0),
00053 fIsTimeSorted(kFALSE),
00054 fHasNewGlobalTrigger(kFALSE)
00055 {
00056 TGo4Log::Info("TGet4v1Proc: Create instance %s", name);
00057
00058
00059 fParam = (TGet4v1Param *) MakeParameter("Get4v1Par", "TGet4v1Param" );
00060
00061 fLastRateTm = TTimeStamp().AsDouble();
00062 fTotaldatasize = 0;
00063 fRate = 0.;
00064
00065
00066 TString setupmacro = "set_Get4v1Par.C";
00067 if (!gSystem->AccessPathName(setupmacro.Data())) {
00068 TGo4Log::Info("Executing ROC parameter setup script %s", setupmacro.Data());
00069 gROOT->ProcessLine(Form(".x %s", setupmacro.Data()));
00070
00071
00072 fParam->SetConfigRocs();
00073 } else {
00074 TGo4Log::Info("NO ROC parameter setup script %s. Use previous values!", setupmacro.Data());
00075 }
00076
00077 fParam->PrintGet4Options();
00078 if (fParam->numRocs > MAX_ROC) fParam->numRocs = MAX_ROC;
00079 if (fParam->uNbGet4 > MAX_GET4) fParam->uNbGet4 = MAX_GET4;
00080
00081 for (unsigned n=0; n < fParam->numRocs;n++) {
00082 ROC.push_back(TGet4v1Rec());
00083 ROC[n].fRocId = n;
00084 }
00085 fEvntSize = MakeTH1('I', "ROCs/EvntSize", "Number of messages in event",
00086 250, 1., 2000.);
00087
00088 fMsgsPerRoc = MakeTH1('I', "ROCs/MsgsPerRoc", "Number of messages per ROC",
00089 fParam->numRocs, 0., fParam->numRocs);
00090
00091 fTriggerPerRoc = MakeTH1('I', "ROCs/TriggersPerRoc", "Number of Trigger messages per ROC",
00092 fParam->numRocs, 0., fParam->numRocs);
00093
00094 fDeltaTriggerTime = MakeTH1('I', "ROCs/TriggerDeltaTime", "Corrected hits time difference of all ROCs",
00095 5000, -5000., 5000., "Delta t");
00096
00097 for( UInt_t uRoc =0; uRoc<fParam->numRocs; uRoc++ )
00098 {
00099
00100 if (!fParam->IsActiveRoc(uRoc)) continue;
00101
00102 char folder[30];
00103 sprintf(folder,"ROC%u/",uRoc);
00104
00105 ROC[uRoc].fMsgTypes = MakeTH1('I', Form("%sMsgTypes%u", folder, uRoc),
00106 Form("ROC%u Distribution of messages types", uRoc),
00107 8, 0., 8.);
00108
00109 if (IsObjMade()) {
00110 ROC[uRoc].fMsgTypes->GetXaxis()->SetBinLabel(1 + roc::MSG_NOP, "NOP");
00111 ROC[uRoc].fMsgTypes->GetXaxis()->SetBinLabel(1 + roc::MSG_HIT, "HIT");
00112 ROC[uRoc].fMsgTypes->GetXaxis()->SetBinLabel(1 + roc::MSG_EPOCH, "EPOCH");
00113 ROC[uRoc].fMsgTypes->GetXaxis()->SetBinLabel(1 + roc::MSG_SYNC, "SYNC");
00114 ROC[uRoc].fMsgTypes->GetXaxis()->SetBinLabel(1 + roc::MSG_AUX, "AUX");
00115 ROC[uRoc].fMsgTypes->GetXaxis()->SetBinLabel(1 + roc::MSG_EPOCH2, "EPOCH2");
00116 ROC[uRoc].fMsgTypes->GetXaxis()->SetBinLabel(1 + roc::MSG_GET4, "GET4");
00117 ROC[uRoc].fMsgTypes->GetXaxis()->SetBinLabel(1 + roc::MSG_SYS, "SYS");
00118 }
00119
00120 ROC[uRoc].fSysTypes = MakeTH1('I', Form("%sSysTypes%u", folder, uRoc),
00121 Form("ROC%u Distribution of system messages", uRoc),
00122 roc::SYSMSG_GET4_EVENT+1, 0., roc::SYSMSG_GET4_EVENT+1);
00123
00124 if (IsObjMade()) {
00125 ROC[uRoc].fSysTypes->GetXaxis()->SetBinLabel(1 + roc::SYSMSG_DAQ_START, "DAQ_START");
00126 ROC[uRoc].fSysTypes->GetXaxis()->SetBinLabel(1 + roc::SYSMSG_DAQ_FINISH, "DAQ_FINISH");
00127 ROC[uRoc].fSysTypes->GetXaxis()->SetBinLabel(1 + roc::SYSMSG_NX_PARITY, "NX_PARITY");
00128 ROC[uRoc].fSysTypes->GetXaxis()->SetBinLabel(1 + roc::SYSMSG_SYNC_PARITY,"SYNC_PARITY");
00129 ROC[uRoc].fSysTypes->GetXaxis()->SetBinLabel(1 + roc::SYSMSG_DAQ_RESUME, "DAQ_RESUME");
00130 ROC[uRoc].fSysTypes->GetXaxis()->SetBinLabel(1 + roc::SYSMSG_FIFO_RESET, "FIFO_RESET");
00131 ROC[uRoc].fSysTypes->GetXaxis()->SetBinLabel(1 + roc::SYSMSG_USER, "USER_MSG");
00132 ROC[uRoc].fSysTypes->GetXaxis()->SetBinLabel(1 + roc::SYSMSG_PCTIME, "PCTIME");
00133 ROC[uRoc].fSysTypes->GetXaxis()->SetBinLabel(1 + roc::SYSMSG_ADC, "ADC");
00134 ROC[uRoc].fSysTypes->GetXaxis()->SetBinLabel(1 + roc::SYSMSG_PACKETLOST, "PACKETLOST");
00135 ROC[uRoc].fSysTypes->GetXaxis()->SetBinLabel(1 + roc::SYSMSG_GET4_EVENT, "GET4_EVENT");
00136 }
00137
00138 ROC[uRoc].fSysUserTypes = MakeTH1('I', Form("%sSysUserTypes%u", folder, uRoc),
00139 Form("ROC%u Distribution of user messages", uRoc),
00140 8, 7., 15.);
00141 if (IsObjMade()) {
00142 ROC[uRoc].fSysUserTypes->GetXaxis()->SetBinLabel(roc::SYSMSG_USER_CALIBR_ON - 6, "CALIBR_ON");
00143 ROC[uRoc].fSysUserTypes->GetXaxis()->SetBinLabel(roc::SYSMSG_USER_CALIBR_OFF - 6, "CALIBR_OFF");
00144 ROC[uRoc].fSysUserTypes->GetXaxis()->SetBinLabel(roc::SYSMSG_USER_RECONFIGURE - 6, "RECONFIGURE");
00145 }
00146
00147 ROC[uRoc].fAUXch = MakeTH1('I', Form("%sRoc%u_aux_chs", folder, uRoc),
00148 "Number events per aux channel",
00149 8, 0., 8.);
00150
00151 ROC[uRoc].fTrigger_All = MakeTH1('I', Form("%sRoc%u_Trigger", folder, uRoc),
00152 Form("Time difference between all hits and last trigger signal on ROC%u", uRoc),
00153 5000, -1000., 4000.);
00154 ROC[uRoc].fTrigger_All_100 = MakeTH1('I', Form("%sRoc%u_Trigger_100", folder, uRoc),
00155 Form("Time difference between all hits and last trigger signal on ROC%u", uRoc),
00156 50005, -100000., 1e6);
00157 ROC[uRoc].fTrigger_All_us = MakeTH1('I', Form("%sRoc%u_Trigger_us", folder, uRoc),
00158 Form("Time difference between all hits and last trigger signal on ROC%u", uRoc),
00159 1000, -1000., 999.*1e3);
00160 ROC[uRoc].fTrigger_All_ms = MakeTH1('I', Form("%sRoc%u_Trigger_ms", folder, uRoc),
00161 Form("Time difference between all hits and last trigger signal on ROC%u", uRoc),
00162 1000, -1e6, 999*1e6);
00163 ROC[uRoc].fTrigger_All_s = MakeTH1('I', Form("%sRoc%u_Trigger_s", folder, uRoc),
00164 Form("Time difference between all hits and last trigger signal on ROC%u", uRoc),
00165 1000, -1e9, 999*1e9);
00166
00167 ROC[uRoc].fTrigger_AUX = MakeTH1('I', Form("%sRoc%u_Trigger_AUX", folder, uRoc),
00168 Form("Time difference between all AUXs and last trigger signal on ROC%u", uRoc),
00169 5000, -5000., 5000.);
00170
00171 ROC[uRoc].fEvntMultipl = MakeTH1('I', Form("%sRoc%u_Multiplicity", folder, uRoc),
00172 Form("Event multiplicity for ROC%u in time window", uRoc),
00173 16, 0., 16.);
00174
00175 ROC[uRoc].fALLt = MakeTH1('I', Form("%sRoc%u_ALL_t", folder,uRoc), Form("Time distribution of ALL hits on ROC%u", uRoc),
00176 36000, 0., 3600.,"s");
00177
00178 ROC[uRoc].fDATAt = MakeTH1('I', Form("%sRoc%u_DATA_t", folder,uRoc), Form("Time distribution of DATA hits on ROC%u", uRoc),
00179 36000, 0., 3600.,"s");
00180
00181 ROC[uRoc].fSelfTriggT = MakeTH1('I', Form("%sRoc%u_SelfTrigg_t", folder,uRoc), Form("Time distribution of self triggers on ROC%u", uRoc),
00182 36000, 0., 3600.,"s");
00183
00184 for (unsigned nsync=0; nsync<MAX_SYNC; nsync++)
00185 ROC[uRoc].fSYNCt[nsync] = MakeTH1('I', Form("%sRoc%u_Sync%u_t", folder, uRoc, nsync),
00186 Form("Time distribution of SYNC%u signal on ROC%u", nsync, uRoc),
00187 36000, 0., 3600.,"s");
00188
00189 for (unsigned naux=0; naux<MAX_AUX; naux++)
00190 ROC[uRoc].fAUXt[naux] = MakeTH1('I', Form("%sRoc%u_Aux%u_t", folder, uRoc, naux),
00191 Form("Time distribution of AUX%u signal on ROC%u", naux, uRoc),
00192 36000, 0., 3600.,"s");
00193
00195 uNbEvents[uRoc] = 0;
00196 uFirstEventIndex[uRoc] = 0;
00197 uPrevEventIndex[uRoc] = 0;
00198
00199 ROC[uRoc].fTriggerWind = MakeWinCond(Form("Roc%u_EventWindow",uRoc),
00200 485., 885., ROC[uRoc].fTrigger_All->GetName());
00201
00202 ROC[uRoc].fAUXWind = MakeWinCond(Form("Roc%u_AUXWindow",uRoc),
00203 -100., 100., ROC[uRoc].fTrigger_AUX->GetName());
00204
00205 for( Int_t iGet4 = 0; iGet4 < MAX_GET4_PER_ROC; iGet4++)
00206 {
00207 char folderGet4[30];
00208 sprintf(folderGet4,"%sGet4_%u/",folder, iGet4);
00209 UInt_t uRemappedGet4Index = fParam->RemapGet4Chip(uRoc, iGet4);
00210 if( kTRUE == fParam->IsValidGet4Chip(uRemappedGet4Index) &&
00211 kTRUE == fParam->IsActiveGet4Chip(uRemappedGet4Index) )
00212 for( Int_t iGet4Chan = 0; iGet4Chan < NB_CHAN_GET4; iGet4Chan++)
00213 {
00214 ROC[uRoc].fTrigger_Get4Channel[iGet4][iGet4Chan] =
00215 MakeTH1('I', Form("%sRoc%u_Get%d_Ch%d_Trigger",
00216 folderGet4, uRoc, iGet4, iGet4Chan),
00217 Form("Time difference between all hits on GET4 %d Channel %d and last trigger signal on ROC%u; [ns]",
00218 iGet4, iGet4Chan, uRoc),
00219 10000, -5000., 5000.);
00220 ROC[uRoc].fTriggerMs_Get4Channel[iGet4][iGet4Chan] =
00221 MakeTH1('I', Form("%sRoc%u_Get%d_Ch%d_TriggerMs",
00222 folderGet4, uRoc, iGet4, iGet4Chan),
00223 Form("Time difference between all hits on GET4 %d Channel %d and last trigger signal on ROC%u; [ns]",
00224 iGet4, iGet4Chan, uRoc),
00225 20000, -100*1e3, 100*1e3);
00226 ROC[uRoc].fTriggerS_Get4Channel[iGet4][iGet4Chan] =
00227 MakeTH1('I', Form("%sRoc%u_Get%d_Ch%d_TriggerS",
00228 folderGet4, uRoc, iGet4, iGet4Chan),
00229 Form("Time difference between all hits on GET4 %d Channel %d and last trigger signal on ROC%u; [ns]",
00230 iGet4, iGet4Chan, uRoc),
00231 20000, -100*1e9, 1900*1e9);
00232
00233
00234
00235
00236 if( 1 == fParam->bTotHistoEnable )
00237 ROC[uRoc].fTot[iGet4][iGet4Chan] =
00238 MakeTH1('I', Form("%sTot/Roc%u_Get%d_Ch%d_Tot",
00239 folderGet4, uRoc, iGet4, iGet4Chan),
00240 Form("Tot for channel %d in chip %d on ROC %d", iGet4Chan, iGet4, uRoc),
00241 1200, -25, 59975, "Tot [ps]", "Counts [1]" );
00242 if( 1 == fParam->bDebugHistoEnable )
00243 {
00244 ROC[uRoc].fLeadingFTS[iGet4][iGet4Chan] =
00245 MakeTH1('I',
00246 Form("%sFTS_L/Roc%u_Get%d_Ch%d_FTS_Leading",
00247 folderGet4, uRoc, iGet4, iGet4Chan),
00248 Form("FTS of Leading edge of channel %d in chip %d on ROC %d",
00249 iGet4Chan, iGet4, uRoc),
00250 NB_BIN_GET4_FTS, 0., NB_BIN_GET4_FTS);
00251 ROC[uRoc].fTrailingFTS[iGet4][iGet4Chan] =
00252 MakeTH1('I',
00253 Form("%sFTS_T/Roc%u_Get%d_Ch%d_FTS_Trailing",
00254 folderGet4, uRoc, iGet4, iGet4Chan),
00255 Form("FTS of Trailing edge of channel %d in chip %d on ROC %d",
00256 iGet4Chan, iGet4, uRoc),
00257 NB_BIN_GET4_FTS, 0., NB_BIN_GET4_FTS);
00258 ROC[uRoc].fLeadingDnl[iGet4][iGet4Chan] =
00259 MakeTH1('D',
00260 Form("%sDnl_L/Roc%u_Get%d_Ch%d_Dnl_Leading",
00261 folderGet4, uRoc, iGet4, iGet4Chan),
00262 Form("DNL of Leading edge of channel %d in chip %d on ROC %d",
00263 iGet4Chan, iGet4, uRoc),
00264 NB_BIN_GET4_FTS, -0.5, NB_BIN_GET4_FTS-0.5);
00265 ROC[uRoc].fLeadingDnlSum[iGet4][iGet4Chan] =
00266 MakeTH1('D',
00267 Form("%sDnlInt_L/Roc%u_Get%d_Ch%d_DnlSum_Leading",
00268 folderGet4, uRoc, iGet4, iGet4Chan),
00269 Form("DNL Integral of Leading edge of channel %d in chip %d on ROC %d",
00270 iGet4Chan, iGet4, uRoc),
00271 NB_BIN_GET4_FTS, -0.5, NB_BIN_GET4_FTS-0.5);
00272 ROC[uRoc].fTrailingDnl[iGet4][iGet4Chan] =
00273 MakeTH1('D',
00274 Form("%sDnl_T/Roc%u_Get%d_Ch%d_Dnl_Trailing",
00275 folderGet4, uRoc, iGet4, iGet4Chan),
00276 Form("DNL of Trailing edge of channel %d in chip %d on ROC %d",
00277 iGet4Chan, iGet4, uRoc),
00278 NB_BIN_GET4_FTS, -0.5, NB_BIN_GET4_FTS-0.5);
00279 ROC[uRoc].fTrailingDnlSum[iGet4][iGet4Chan] =
00280 MakeTH1('D',
00281 Form("%sDnlInt_T/Roc%u_Get%d_Ch%d_DnlSum_Trailing",
00282 folderGet4, uRoc, iGet4, iGet4Chan),
00283 Form("DNL Integral of Trailing edge of channel %d in chip %d on ROC %d",
00284 iGet4Chan, iGet4, uRoc),
00285 NB_BIN_GET4_FTS, -0.5, NB_BIN_GET4_FTS-0.5);
00286 }
00287 }
00288 }
00289 ROC[uRoc].fDistribEpochs = MakeTH1( 'I', Form("%sRoc%u_DistribEpochs", folder, uRoc),
00290 "Distribution of epoch counter value for 250MHz epoch messages",
00291 2*MAIN_EPOCH_CYCLE_SIZE/10, 0, 2*MAIN_EPOCH_CYCLE_SIZE,
00292 "Value of Local Epoch Cnt []", "Counts []" );
00293 ROC[uRoc].fDistribEpochs2 = MakeTH2( 'I', Form("%sRoc%u_DistribEpochs2", folder, uRoc),
00294 "Distribution of epoch counter value for Roc epoch messages",
00295 MAX_GET4_PER_ROC, -0.5, MAX_GET4_PER_ROC -0.5,
00296 2*GET4_EPOCH_CYCLE_SIZE/1000, 0, 2*GET4_EPOCH_CYCLE_SIZE,
00297 "chip []", "Value of Roc Epoch Cnt []", "Counts []" );
00298 ROC[uRoc].fChannelsMapping = MakeTH2( 'I', Form("%sRoc%u_ChanMap", folder, uRoc),
00299 "Events with both channels present",
00300 NB_CHAN_GET4*MAX_GET4_PER_ROC, 0, MAX_GET4_PER_ROC ,
00301 NB_CHAN_GET4*MAX_GET4_PER_ROC, 0, MAX_GET4_PER_ROC ,
00302 "1st channel []", "2nd channel []", "Counts []" );
00303 ROC[uRoc].fChannelMultiplicity = MakeTH2( 'I', Form("%sRoc%u_ChanMul", folder, uRoc),
00304 "Channel multiplicity per event",
00305 NB_CHAN_GET4*MAX_GET4_PER_ROC, 0, MAX_GET4_PER_ROC ,
00306 20, 0, 20,
00307 "Channel []", "# Hits []", "events []" );
00308 ROC[uRoc].fChannelInputMessCount = MakeTH1( 'I', Form("%sRoc%u_ChanCounts", folder, uRoc),
00309 "Channel multiplicity per event",
00310 NB_CHAN_GET4*MAX_GET4_PER_ROC, 0, MAX_GET4_PER_ROC ,
00311 "Channel []", "# Mess []" );
00312
00313
00314 ROC[uRoc].fGet4ErrorChip = MakeTH1('I', Form("%sRoc%u_Get4ErrorChip", folder, uRoc),
00315 "Get4 chip sending Error message",
00316 fParam->uNbGet4, -0.5, fParam->uNbGet4 -0.5, "Error Chip","Entries [1]");
00317 ROC[uRoc].fGet4ErrorChan = MakeTH2('I', Form("%sRoc%u_Get4ErrorChan", folder, uRoc),
00318 "Get4 channel/edge sending Error message",
00319 2*(fParam->uNbGet4)*NB_CHAN_GET4, 0., (fParam->uNbGet4)*NB_CHAN_GET4, 6, 0, 6,
00320 "Error chan","","Entries [1]");
00321
00322 ROC[uRoc].fGet4ErrorChan->GetYaxis()->SetBinLabel(1, "0x04: FIFO Write ");
00323 ROC[uRoc].fGet4ErrorChan->GetYaxis()->SetBinLabel(2, "0x05: Lost event ");
00324 ROC[uRoc].fGet4ErrorChan->GetYaxis()->SetBinLabel(3, "0x06: Channel state ");
00325 ROC[uRoc].fGet4ErrorChan->GetYaxis()->SetBinLabel(4, "0x11: Overwrite ");
00326 ROC[uRoc].fGet4ErrorChan->GetYaxis()->SetBinLabel(5, "0x12: ToT out of range");
00327 ROC[uRoc].fGet4ErrorChan->GetYaxis()->SetBinLabel(6, "0x13: ToT + Overwrite ");
00328
00329 ROC[uRoc].fGet4ErrorPatt = MakeTH2('I', Form("%sRoc%u_Get4ErrorPatt", folder, uRoc),
00330 "Pattern of Get4 Error message",
00331 fParam->uNbGet4, -0.5, fParam->uNbGet4 -0.5, 128, 0., 128,
00332 "Error chip","","Entries [1]");
00333 ROC[uRoc].fGet4ErrorPatt->GetYaxis()->SetBinLabel(1, "0x00: Readout Init ");
00334 ROC[uRoc].fGet4ErrorPatt->GetYaxis()->SetBinLabel(2, "0x01: Sync ");
00335 ROC[uRoc].fGet4ErrorPatt->GetYaxis()->SetBinLabel(3, "0x02: Epoch count sync");
00336 ROC[uRoc].fGet4ErrorPatt->GetYaxis()->SetBinLabel(4, "0x03: Epoch ");
00337 ROC[uRoc].fGet4ErrorPatt->GetYaxis()->SetBinLabel(5, "0x04: FIFO Write ");
00338 ROC[uRoc].fGet4ErrorPatt->GetYaxis()->SetBinLabel(6, "0x05: Lost event ");
00339 ROC[uRoc].fGet4ErrorPatt->GetYaxis()->SetBinLabel(7, "0x06: Channel state ");
00340 ROC[uRoc].fGet4ErrorPatt->GetYaxis()->SetBinLabel(8, "0x07: Token Ring state");
00341 ROC[uRoc].fGet4ErrorPatt->GetYaxis()->SetBinLabel(9, "0x08: Token ");
00342 ROC[uRoc].fGet4ErrorPatt->GetYaxis()->SetBinLabel(10, "0x09: Error Readout ");
00343 ROC[uRoc].fGet4ErrorPatt->GetYaxis()->SetBinLabel(11, "0x0a: SPI ");
00344
00345
00346
00347
00348
00349
00350 ROC[uRoc].fGet4ErrorPatt->GetYaxis()->SetBinLabel(18, "0x11: Overwrite ");
00351 ROC[uRoc].fGet4ErrorPatt->GetYaxis()->SetBinLabel(19, "0x12: ToT out of range");
00352 ROC[uRoc].fGet4ErrorPatt->GetYaxis()->SetBinLabel(20, "0x13: ToT + Overwrite ");
00353 ROC[uRoc].fGet4ErrorPatt->GetYaxis()->SetBinLabel(128, "0x7f: Unknown ");
00354
00355
00356
00357
00358 if( 1 == fParam->bDebugHistoEnable )
00359 {
00360 UInt_t uHistosIndexSingleChip = 0;
00361 UInt_t uHistosIndexChipVsChip = 0;
00362 for(UInt_t uFirstGet4Channel = 0; uFirstGet4Channel < NB_CHAN_GET4; uFirstGet4Channel++)
00363 {
00364 for(UInt_t uSecondGet4Channel = 0; uSecondGet4Channel < NB_CHAN_GET4; uSecondGet4Channel++)
00365 {
00366 if( uFirstGet4Channel < uSecondGet4Channel )
00367 {
00368 ROC[uRoc].fTimeDiffInsideChip[0][uHistosIndexSingleChip] =
00369 MakeTH1('I',
00370 Form("%sDebug/Chip1/Roc%d_TimeDiff1_%d_%d",
00371 folder, uRoc, uFirstGet4Channel, uSecondGet4Channel),
00372 Form("Time difference between channel %d and %d in chip %d ROC %d",
00373 uFirstGet4Channel, uSecondGet4Channel, fParam->uGet4TimeDiffChip1, uRoc),
00374 601, -15025, 15025, "dT [ps]", "Counts [1]" );
00375 ROC[uRoc].fTimeDiffInsideChip[1][uHistosIndexSingleChip] =
00376 MakeTH1('I', Form("%sDebug/Chip2/Roc%d_TimeDiff2_%d_%d",
00377 folder, uRoc, uFirstGet4Channel, uSecondGet4Channel),
00378 Form("Time difference between channel %d and %d in chip %d ROC %d",
00379 uFirstGet4Channel, uSecondGet4Channel, fParam->uGet4TimeDiffChip2, uRoc),
00380 601, -15025, 15025, "dT [ps]", "Counts [1]" );
00381
00382
00383 ROC[uRoc].fFTCorrel[0][uHistosIndexSingleChip] =
00384 MakeTH1('I',
00385 Form("%sDebug/Chip1/Roc%d_FTCorrel1_%d_%d",
00386 folder, uRoc, uFirstGet4Channel, uSecondGet4Channel),
00387 Form("FTS Correlation between channels %d and %d in chip %d ROC %d",
00388 uFirstGet4Channel, uSecondGet4Channel, fParam->uGet4TimeDiffChip1, uRoc),
00389 2*NB_BIN_GET4_FTS + 1, -NB_BIN_GET4_FTS-0.5, NB_BIN_GET4_FTS+0.5);
00390 ROC[uRoc].fFTCorrel[1][uHistosIndexSingleChip] =
00391 MakeTH1('I',
00392 Form("%sDebug/Chip2/Roc%d_FTCorrel2_%d_%d",
00393 folder, uRoc, uFirstGet4Channel, uSecondGet4Channel),
00394 Form("FTS Correlation between channels %d and %d in chip %d ROC %d",
00395 uFirstGet4Channel, uSecondGet4Channel, fParam->uGet4TimeDiffChip2, uRoc),
00396 2*NB_BIN_GET4_FTS + 1, -NB_BIN_GET4_FTS-0.5, NB_BIN_GET4_FTS+0.5);
00397
00398
00399 ROC[uRoc].fFTCorrel2D[0][uHistosIndexSingleChip] =
00400 MakeTH2('I',
00401 Form("%sDebug/Chip1/Roc%d_2dFTCorr1_%d_%d",
00402 folder, uRoc, uFirstGet4Channel, uSecondGet4Channel),
00403 Form("FTS Correlation between channels %d and %d in chip %d ROC %d",
00404 uFirstGet4Channel, uSecondGet4Channel, fParam->uGet4TimeDiffChip1, uRoc),
00405 NB_BIN_GET4_FTS, -0.5, NB_BIN_GET4_FTS-0.5,
00406 NB_BIN_GET4_FTS, -0.5, NB_BIN_GET4_FTS-0.5);
00407 ROC[uRoc].fFTCorrel2D[1][uHistosIndexSingleChip] =
00408 MakeTH2('I',
00409 Form("%sDebug/Chip2/Roc%d_2dFTCorr2_%d_%d",
00410 folder, uRoc, uFirstGet4Channel, uSecondGet4Channel),
00411 Form("FTS Correlation between channels %d and %d in chip %d ROC %d",
00412 uFirstGet4Channel, uSecondGet4Channel, fParam->uGet4TimeDiffChip2, uRoc),
00413 NB_BIN_GET4_FTS, -0.5, NB_BIN_GET4_FTS-0.5,
00414 NB_BIN_GET4_FTS, -0.5, NB_BIN_GET4_FTS-0.5);
00415
00416 uHistosIndexSingleChip++;
00417 }
00418 ROC[uRoc].fTimeDiffBetweenChips[uHistosIndexChipVsChip] =
00419 MakeTH1('I',
00420 Form("%sDebug/ChipVsChip/Roc%d_dT_%d_%d_Vs_%d_%d",
00421 folder, uRoc,
00422 fParam->uGet4TimeDiffChip1, uFirstGet4Channel,
00423 fParam->uGet4TimeDiffChip2, uSecondGet4Channel),
00424 Form("Time difference between channel %d in chip %d and channel %d in chip %d",
00425 uFirstGet4Channel, fParam->uGet4TimeDiffChip1, uSecondGet4Channel, fParam->uGet4TimeDiffChip2),
00426 961, -24025, 24025, "dT [ps]", "Counts [1]" );
00427 ROC[uRoc].fFTCorrelChipToChip[uHistosIndexChipVsChip] =
00428 MakeTH1('I',
00429 Form("%sDebug/ChipVsChip/Roc%d_FTCorrel_%d_%d_Vs_%d_%d",
00430 folder, uRoc,
00431 fParam->uGet4TimeDiffChip1, uFirstGet4Channel,
00432 fParam->uGet4TimeDiffChip2, uSecondGet4Channel),
00433 Form("FTS Correlation between channel %d in chip %d and channel %d in chip %d",
00434 uFirstGet4Channel, fParam->uGet4TimeDiffChip1, uSecondGet4Channel, fParam->uGet4TimeDiffChip2),
00435 2*NB_BIN_GET4_FTS + 1, -NB_BIN_GET4_FTS-0.5, NB_BIN_GET4_FTS+0.5);
00436 uHistosIndexChipVsChip++;
00437 }
00438 }
00439 }
00440 }
00441 printData = 0;
00442 fCurrentGet4Event.Clear();
00443
00444
00445
00446
00447
00448 fGlobalTriggerWind = MakeWinCond("TriggerWindow", -100, 2000., fDeltaTriggerTime->GetName());
00449 fGlobalAUXWind = MakeWinCond("AUXWindow", -100, 100., fDeltaTriggerTime->GetName());
00450
00451 setupmacro = "set_Get4v1Cond.C";
00452 if (!gSystem->AccessPathName(setupmacro.Data())) {
00453 TGo4Log::Info("Executing ROC condition setup script %s", setupmacro.Data());
00454 gROOT->ProcessLine(Form(".x %s", setupmacro.Data()));
00455 } else {
00456 TGo4Log::Info("NO ROC condition setup script %s. Use previous values!", setupmacro.Data());
00457 }
00458
00459 ResetEndOfBuffer();
00460 }
00461
00462
00463 void TGet4v1Proc::InitEvent(TGo4EventElement* outevnt)
00464 {
00465
00466
00467 if(fOutputEvent==0)
00468 {
00469
00470 TCBMBeamtimeEvent* btevent=dynamic_cast<TCBMBeamtimeEvent*>(outevnt);
00471 if(btevent)
00472 {
00473
00474 fOutputEvent = dynamic_cast<TGet4v1Event*>(btevent->GetSubEvent("ROCGET4V10"));
00475 }
00476 else
00477 {
00478
00479 fOutputEvent= dynamic_cast<TGet4v1Event*>(outevnt);
00480 }
00481 if(fOutputEvent==0)
00482 {
00483 GO4_STOP_ANALYSIS_MESSAGE("**** TGet4v1Proc: Fatal error: output event is not a TGet4v1Event!!! STOP GO4");
00484 }
00485 }
00486
00487 fFirstSubEvent = true;
00488
00489
00490 }
00491
00492
00493
00494
00495
00496 void TGet4v1Proc::ProcessSubevent(TGo4MbsSubEvent* psubevt)
00497 {
00498 uint32_t g4id(0), auxid(0), syncid(0);
00499 uint64_t fulltm(0);
00500 uint32_t typ(0), rocid(0), lastevrocid(0);
00501 static int cnt=0;
00502 unsigned msgcount=0;
00503
00504
00505 bool is_dabc_evt = (psubevt->GetProcid() == roc::proc_RocEvent) ||
00506 (psubevt->GetProcid() == roc::proc_ErrEvent) ||
00507 (psubevt->GetProcid() == roc::proc_MergedEvent);
00508 bool is_raw_evt = (psubevt->GetProcid() == roc::proc_RawData);
00509
00510 if (!is_dabc_evt && !is_raw_evt)
00511 {
00512 cout << "Oups: Not DABC or RAW event"<< endl;
00513 return;
00514 }
00515
00516 unsigned rid = psubevt->GetSubcrate();
00517
00518
00519 int datasize = (psubevt->GetDlen() - 2) * 2;
00520 int msg_fmt = psubevt->GetControl();
00521 ROC[rid].fIter.setFormat(msg_fmt);
00522 ROC[rid].fIter.setRocNumber(rid);
00523
00525 if( -1 != fParam->FindGet4RocId( psubevt->GetSubcrate() ) )
00526 {
00527 Int_t iFeetRocIndex = fParam->FindGet4RocId( psubevt->GetSubcrate() );
00528 if(uNbEvents[iFeetRocIndex] == 0) {
00529 uFirstEventIndex[iFeetRocIndex] = GetEventNumber();
00530 TGo4Log::Info("***** First event on Get4 roc %d: %d ", iFeetRocIndex, uFirstEventIndex[iFeetRocIndex]);
00531 }
00532 else {
00533 if( 0 < fParam->iEventNbGap &&
00534 (Int_t)uPrevEventIndex[iFeetRocIndex] + fParam->iEventNbGap != GetEventNumber() ) {
00535 TGo4Log::Error("***** Missing event in file for Get4 roc %d: Event %d, Previous event index %d, Current event Index %d, expected %d",
00536 iFeetRocIndex, uNbEvents[iFeetRocIndex], uPrevEventIndex[iFeetRocIndex], GetEventNumber(),
00537 (Int_t)uPrevEventIndex[iFeetRocIndex] + fParam->iEventNbGap);
00538 }
00539 }
00540 uPrevEventIndex[iFeetRocIndex] = GetEventNumber();
00541 uNbEvents[iFeetRocIndex]++;
00542 }
00543
00544
00545
00546 if (is_dabc_evt)
00547 {
00548
00549 if (GetTriggerNumber()>8)
00550 {
00551 cout<<"OUPS, trigger too high: "<<GetTriggerNumber()<<endl;
00552 return;
00553 }
00554
00555 roc::Message msg1, msg2;
00556 roc::Message msgA, msgB;
00557
00558 char* ptr = (char*) psubevt->GetDataField();
00559 int msglen = roc::Message::RawSize(msg_fmt);
00560
00561 if (ROC[rid].fIter.assign(ptr + datasize - msglen, msglen)) {
00562 if (ROC[rid].fIter.next()) msg1.assign(ROC[rid].fIter.msg());
00563 }
00564
00565 if (!msg1.isSyncMsg()) {
00566 TGo4Log::Error("Non-SYNC message at the end of DABC-produced subevent");
00567 } else {
00568 rocid = msg1.getRocNumber();
00569
00570
00571
00572 UInt_t uSyncId = msg1.getSyncChNum();
00573 UInt_t uSyncTs = msg1.getSyncTs();
00574 UInt_t uSyncEpLsb = msg1.getSyncEpochLSB();
00575 UInt_t uSyncData = msg1.getSyncData();
00576 UInt_t uSyncFlag = msg1.getSyncStFlag();
00577 ULong64_t ulFulltime = msg1.getMsgFullTime( ROC[rocid].GetFullEpochNumber( ) );
00578
00579
00580
00581
00582
00583
00584
00585
00586
00587
00588
00589 if( kFALSE == fParam->bTriggerAfterData )
00590 datasize -= msglen;
00591 int shift = msglen;
00592 while (shift<=datasize) {
00593
00594 if (ROC[rid].fIter.assign(ptr + datasize - shift, msglen)) {
00595 if (ROC[rid].fIter.next())
00596 msg2.assign(ROC[rid].fIter.msg());
00597 else
00598 break;
00599
00600 if (msg2.isEpochMsg())
00601 {
00602
00603
00604
00605 break;
00606 }
00607 }
00608 shift+=msglen;
00609 }
00610
00611
00612
00613 if( kFALSE == fParam->bTriggerAfterData )
00614 if ((shift==msglen) && msg2.isEpochMsg()) datasize -= msglen;
00615 }
00616 }
00617
00618 fTotaldatasize += datasize;
00619
00620 if (!ROC[rid].fIter.assign(psubevt->GetDataField(), datasize))
00621 {
00622 cout<<"OUPS, probblem: "<<psubevt->GetDataField()<<" "<<datasize<<endl;
00623 return;
00624 }
00625
00626 fEvntSize->Fill(datasize);
00627
00628
00629
00630
00631
00632
00633
00634
00635
00636 roc::Message* data = & ROC[rid].fIter.msg();
00637 while (ROC[rid].fIter.next()) {
00638 msgcount++;
00639
00640 rocid = data->getRocNumber();
00641 fMsgsPerRoc->Fill(rocid);
00642
00643
00644 if( kFALSE == fParam->IsActiveRoc(rocid) )
00645 continue;
00646
00647 typ = data->getMessageType();
00648 if(typ==roc::MSG_GET4)
00649 fulltm = data->getMsgFullTime(
00650 ROC[rocid].GetFullEpoch2Number(
00651 fParam->RemapGet4Chip( data->getGet4Number() ) ));
00652 else
00653 fulltm = data->getMsgFullTime(
00654 ROC[rocid].GetFullEpochNumber() );
00655
00656 ROC[rocid].fMsgTypes->Fill(typ);
00657
00658 ULong64_t ulMsgTm = fulltm / 100000000L;
00659 ROC[rocid].fALLt->Fill( (ulMsgTm % 36000) * 0.1 );
00660
00661 TGet4v1MessageExtended exmess(*data,fulltm);
00662
00663 if(printData<fParam->uGet4Print )
00664 {
00665 exmess.Print(roc::msg_print_Human);
00666 printData++;
00667 }
00668 switch (typ)
00669 {
00670 case roc::MSG_NOP:
00671 {
00672 break;
00673 }
00674 case roc::MSG_HIT:
00675 {
00676 break;
00677 }
00678 case roc::MSG_GET4:
00679 {
00680 exmess.SetFullTimeD(
00681 data->getMsgFullTimeD(
00682 ROC[rocid].GetFullEpoch2Number(
00683 fParam->RemapGet4Chip( data->getGet4Number() ) )) );
00684 if( kTRUE == ProcessGet4DataMessage(rocid, exmess) )
00685 ProcessExtendedMessage(rocid, exmess);
00686 break;
00687 }
00688 case roc::MSG_EPOCH:
00689 {
00690
00691
00692
00693
00694
00695
00696 if( !is_dabc_evt || kFALSE == fParam->bTriggerAfterData ||
00697 2 < msgcount)
00698 ProcessRocEpochMessage(rocid, exmess);
00699 break;
00700 }
00701 case roc::MSG_EPOCH2:
00702 {
00703 exmess.SetFullTimeD(
00704 data->getMsgFullTimeD(
00705 ROC[rocid].GetFullEpochNumber() ) );
00706 ProcessGet4EpochMessage(rocid, exmess);
00707 break;
00708 }
00709 case roc::MSG_SYNC:
00710 {
00711 UInt_t uSyncId = data->getSyncChNum();
00712 UInt_t uSyncTs = data->getSyncTs();
00713 UInt_t uSyncEpLsb = data->getSyncEpochLSB();
00714 UInt_t uSyncData = data->getSyncData();
00715 UInt_t uSyncFlag = data->getSyncStFlag();
00716 ULong64_t ulFulltime = data->getMsgFullTime( ROC[rocid].GetFullEpochNumber( ) );
00717
00718
00719
00720
00721
00722
00723
00724
00725
00726 if( kFALSE == fParam->bTriggerAfterData )
00727 {
00728 if((msgcount<3) && !is_raw_evt)
00729 {
00730 ROC[rocid].fDabcSeparator = data->getSyncChNum()+10;
00731 }
00732
00733
00734
00735
00736
00737 ProcessRocSyncMessage(rocid, exmess);
00738 }
00739 else if( (2 < msgcount ) || !is_dabc_evt)
00740 {
00741 if( ( (datasize - 3 ) < msgcount) && !is_raw_evt)
00742 {
00743 ROC[rocid].fDabcSeparator = data->getSyncChNum()+10;
00744 }
00745
00746
00747
00748
00749
00750 ProcessRocSyncMessage(rocid, exmess);
00751 }
00752 break;
00753 }
00754 case roc::MSG_AUX:
00755 {
00756 auxid = data->getAuxChNum();
00757 ROC[rocid].fAUXch->Fill(auxid);
00758 if (auxid < MAX_AUX)
00759 {
00760 ROC[rocid].fLastAuxTm[auxid] = fulltm;
00761
00762
00763 ULong64_t ulFulltime ;
00764 ulFulltime = (exmess.GetRocMessage()).getMsgFullTime(
00765 ROC[rocid].GetFullEpochNumber( ));
00766 exmess.SetFullTime(ulFulltime);
00767
00768 ULong64_t auxtm = fulltm / 100000000L;
00769 ROC[rocid].fAUXt[auxid]->Fill((auxtm % 10000) * 0.1);
00770
00771 if (fParam->triggerSignal == (Int_t) auxid)
00772 {
00773 ProcessTriggerMessage(rocid, exmess);
00774 }
00775 }
00776
00777 break;
00778 }
00779 case roc::MSG_SYS:
00780 {
00781 ROC[rocid].fSysTypes->Fill(data->getSysMesType());
00782
00783 if (data->getSysMesType() == roc::SYSMSG_USER)
00784 {
00785 ROC[rocid].fSysUserTypes->Fill(data->getSysMesData());
00786
00787 switch (data->getSysMesData())
00788 {
00789 case roc::SYSMSG_USER_CALIBR_ON:
00790 ROC[rocid].bIgnoreData = kFALSE;
00791 break;
00792 case roc::SYSMSG_USER_CALIBR_OFF:
00793 ROC[rocid].bIgnoreData = kFALSE;
00794 break;
00795 case roc::SYSMSG_USER_RECONFIGURE:
00796 ROC[rocid].bIgnoreData = kTRUE;
00797 ROC[rocid].fIgnoreCnt = 0;
00798 ROC[rocid].fIgnoreTime = fulltm;
00799 break;
00800 default:
00801 break;
00802 }
00803 }
00804 else if( data->getSysMesType() == roc::SYSMSG_GET4_EVENT )
00805 {
00806 UInt_t uGet4SysMessType = (data->getSysMesData()>>6) & 0x1;
00807
00808
00809
00810
00811
00812
00813
00814 UInt_t uGet4IndexOffset = fParam->DefineGet4IndexOffset(rocid);
00815
00816 UInt_t uChip = data->getField(40, 8) + uGet4IndexOffset;
00817 uChip = fParam->RemapGet4Chip(uChip);
00818
00819 data->setField(40, 8, uChip);
00820
00821
00822 if (!fParam->IsActiveGet4Chip(uChip)) {
00823 cout << "Error: Bad chip nb in Epoch message = " << uChip << endl;
00824 cout << " => This message will be skipped!!!! "<<endl;
00825 continue;
00826 }
00827
00828
00829
00830
00831
00832
00833
00834 }
00835 else if( get4v10::SYSMSG_GET4V1_32BIT_0 <= data->getSysMesType() &&
00836 data->getSysMesType() <= get4v10::SYSMSG_GET4V1_32BIT_15 )
00837 {
00838 if( 3 == Process32BitGet4Message(rocid, exmess) )
00839 ProcessExtendedMessage(rocid, exmess);
00840 }
00841 break;
00842 }
00843 default:
00844 break;
00845 }
00846 }
00847
00848
00849
00850
00851 fFirstSubEvent = kFALSE;
00852 }
00853
00854
00855
00856 void TGet4v1Proc::FinalizeEvent()
00857 {
00858 fOutputEvent->fMbsEventNumber = GetEventNumber();
00859
00860
00861
00862
00863
00864
00865
00866
00867
00868
00869
00870
00871 }
00872
00873
00874 void TGet4v1Proc::ProcessTriggerMessage(UInt_t uRocId, TGet4v1MessageExtended& extMess)
00875 {
00876
00877
00878
00879
00880 if( kFALSE == fCurrentGet4Event.IsEmpty() )
00881 {
00882 (fOutputEvent->fEvents).push_back( fCurrentGet4Event );
00883
00884 for( UInt_t uRocTempId =0; uRocTempId<fParam->numRocs; uRocTempId++ )
00885 {
00886 for( Int_t iGet4 = 0; iGet4 < MAX_GET4_PER_ROC; iGet4++)
00887 for( Int_t iGet4Chan = 0; iGet4Chan < NB_CHAN_GET4; iGet4Chan++)
00888 {
00889 if( 0 < ( (fCurrentGet4Event.fGet4Boards[iGet4]).fHits[iGet4Chan]).size() )
00890 {
00891 for( Int_t iGet4Chan_2 = iGet4Chan+1; iGet4Chan_2 < NB_CHAN_GET4; iGet4Chan_2++)
00892 if( 0 < ( (fCurrentGet4Event.fGet4Boards[iGet4]).fHits[iGet4Chan_2]).size() )
00893 ROC[uRocTempId].fChannelsMapping->Fill( iGet4 + (Double_t)iGet4Chan/(Double_t)NB_CHAN_GET4,
00894 iGet4 + (Double_t)iGet4Chan_2/(Double_t)NB_CHAN_GET4 );
00895
00896 for( Int_t iGet4_2 = iGet4+1; iGet4_2 < MAX_GET4_PER_ROC; iGet4_2++)
00897 for( Int_t iGet4Chan_2 = 0; iGet4Chan_2 < NB_CHAN_GET4; iGet4Chan_2++)
00898 if( 0 < ( (fCurrentGet4Event.fGet4Boards[iGet4_2]).fHits[iGet4Chan_2]).size() )
00899 ROC[uRocTempId].fChannelsMapping->Fill( iGet4 + (Double_t)iGet4Chan/(Double_t)NB_CHAN_GET4,
00900 iGet4_2 + (Double_t)iGet4Chan_2/(Double_t)NB_CHAN_GET4 );
00901 }
00902 ROC[uRocTempId].fChannelMultiplicity->Fill( iGet4 + (Double_t)iGet4Chan/(Double_t)NB_CHAN_GET4,
00903 ( (fCurrentGet4Event.fGet4Boards[iGet4]).fHits[iGet4Chan]).size());
00904 }
00905 }
00906 }
00907
00908 fCurrentGet4Event.Clear();
00909
00910
00911 fCurrentGet4Event.fdTriggerFullTime[uRocId] = extMess.GetFullTimeD();
00912 if( fCurrentGet4Event.fdTriggerFullTime[uRocId] <= 0.0)
00913 TGo4Log::Error("Assigning 0 time as trigger time? event %d time %d", GetEventNumber(), extMess.GetFullTimeD());
00914
00915
00916
00917 ROC[uRocId].fbPastEpochsRocDone = kTRUE;
00918 ROC[uRocId].fbSelectionRocDone = kFALSE;
00919
00920 for( UInt_t uGet4Index = 0; uGet4Index < fParam->uNbGet4; uGet4Index++)
00921 if( fParam->IsActiveGet4Chip( uGet4Index ) )
00922 if( kTRUE == BuildHits(uRocId, uGet4Index) )
00923 {
00924 ROC[uRocId].fbPastEpochs2Done[uGet4Index] = kTRUE;
00925 ROC[uRocId].fbSelectionDone[uGet4Index] = kFALSE;
00926
00927
00928
00929
00930
00931 if( 0 < ROC[uRocId].fAfterTriggEpochs2Buffer[uGet4Index][0].size() )
00932 ROC[uRocId].fAfterTriggEpochs2Buffer[uGet4Index][0].clear();
00933 if( 0 < ROC[uRocId].fAfterTriggEpochs2Buffer[uGet4Index][1].size() )
00934 ROC[uRocId].fAfterTriggEpochs2Buffer[uGet4Index][1].clear();
00935 }
00936 }
00937
00938 void TGet4v1Proc::ProcessExtendedMessage(UInt_t uRocId, TGet4v1MessageExtended& extMess)
00939 {
00940
00941
00942
00943
00944
00945
00946 UInt_t uType = extMess.GetMessageType();
00947
00948
00949 if( roc::MSG_GET4 == uType )
00950 {
00951 UInt_t uGet4Id = extMess.GetGet4Number() ;
00952
00953
00954 if( fParam->IsActiveGet4Chip(uGet4Id) )
00955 {
00956
00957 ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][
00958 ROC[uRocId].fbBufferWithLastFullEpoch2[uGet4Id]].push_back(extMess);
00959
00960
00961 if( kTRUE == ROC[uRocId].fbPastEpochs2Done[uGet4Id] &&
00962 kFALSE == ROC[uRocId].fbSelectionDone[uGet4Id] )
00963 {
00964
00965
00966
00967
00968 ROC[uRocId].fAfterTriggEpochs2Buffer[uGet4Id][
00969 ROC[uRocId].fbEpoch2SinceTrigger[uGet4Id]].push_back(extMess);
00970 }
00971 }
00972 }
00973
00974 else if( roc::MSG_SYS == uType &&
00975 get4v10::SYSMSG_GET4V1_32BIT_0 <= extMess.GetSysMesType() &&
00976 extMess.GetSysMesType() <= get4v10::SYSMSG_GET4V1_32BIT_15 )
00977 {
00978 UInt_t uGet4Id = extMess.getGet4V10R32ChipId() ;
00979 uGet4Id = fParam->RemapGet4Chip( uRocId, uGet4Id);
00980
00981
00982 if( fParam->IsActiveGet4Chip(uGet4Id) )
00983 {
00984
00985 ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][
00986 ROC[uRocId].fbBufferWithLastFullEpoch2[uGet4Id]].push_back(extMess);
00987
00988
00989 if( kTRUE == ROC[uRocId].fbPastEpochs2Done[uGet4Id] &&
00990 kFALSE == ROC[uRocId].fbSelectionDone[uGet4Id] )
00991 {
00992
00993
00994
00995
00996
00997
00998
00999
01000
01001 ROC[uRocId].fAfterTriggEpochs2Buffer[uGet4Id][
01002 ROC[uRocId].fbEpoch2SinceTrigger[uGet4Id]].push_back(extMess);
01003 }
01004 }
01005 }
01006
01007 else
01008 {
01009
01010 }
01011 }
01012
01013 Bool_t TGet4v1Proc::BuildHits(UInt_t uRocId, UInt_t uGet4Id)
01014 {
01015
01016
01017
01018
01019
01020
01021
01022
01023
01024 for( UInt_t uChan = 0; uChan < NB_CHAN_GET4; uChan++)
01025 (ROC[uRocId].fHitTemp24[uGet4Id][uChan]).Clear();
01026
01027
01028
01029 Bool_t bOlderBuffer = kTRUE == ROC[uRocId].fbBufferWithLastFullEpoch2[uGet4Id] ? 0 : 1;
01030 std::sort( ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][bOlderBuffer].begin(),
01031 ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][bOlderBuffer].end() );
01032 for( UInt_t uMessageIndex = 0;
01033 uMessageIndex < ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][bOlderBuffer].size();
01034 uMessageIndex ++)
01035 {
01036 if( kTRUE == (ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][bOlderBuffer])[uMessageIndex].Is32Bit() )
01037 {
01038
01039 fHitTemp.Clear();
01040 fHitTemp.SetFullHit32Bits( (ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][bOlderBuffer])[uMessageIndex] );
01041 CheckHit( uRocId, uGet4Id, fHitTemp );
01042
01043 }
01044 else
01045 {
01046 UChar_t ucChan = (ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][bOlderBuffer])[uMessageIndex].GetGet4ChNum();
01047
01048 if( 1 == (ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][bOlderBuffer])[uMessageIndex].IsRisingGet4Edge() )
01049 {
01050
01051
01052
01053 if( kTRUE == (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]).IsTimeSet() )
01054 {
01055 (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]).SetTot24Bits(
01056 (ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][bOlderBuffer])[uMessageIndex] );
01057
01058
01059
01060 if( (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]).GetTot() < fParam->dMaxTot )
01061 CheckHit( uRocId, uGet4Id, (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]) );
01062 else (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]).Clear();
01063 }
01064 }
01065 else
01066 {
01067
01068
01069
01070 (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]).Clear();
01071 (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]).SetTime24Bits(
01072 (ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][bOlderBuffer])[uMessageIndex] );
01073 }
01074 }
01075 }
01076 Bool_t bCurrentBuffer = (ROC[uRocId].fbBufferWithLastFullEpoch2[uGet4Id]);
01077 std::sort( ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][bCurrentBuffer].begin(),
01078 ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][bCurrentBuffer].end() );
01079 for( UInt_t uMessageIndex = 0;
01080 uMessageIndex < ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][bCurrentBuffer].size();
01081 uMessageIndex ++)
01082 {
01083 if( kTRUE == (ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][bCurrentBuffer])[uMessageIndex].Is32Bit() )
01084 {
01085
01086 fHitTemp.Clear();
01087 fHitTemp.SetFullHit32Bits( (ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][bCurrentBuffer])[uMessageIndex] );
01088 CheckHit( uRocId, uGet4Id, fHitTemp );
01089 }
01090 else
01091 {
01092 UChar_t ucChan = (ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][bCurrentBuffer])[uMessageIndex].GetGet4ChNum();
01093
01094 if( 1 == (ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][bCurrentBuffer])[uMessageIndex].IsRisingGet4Edge() )
01095 {
01096
01097
01098
01099 if( kTRUE == (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]).IsTimeSet() )
01100 {
01101 (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]).SetTot24Bits(
01102 (ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][bCurrentBuffer])[uMessageIndex] );
01103
01104
01105
01106 if( (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]).GetTot() < fParam->dMaxTot )
01107 CheckHit( uRocId, uGet4Id, (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]) );
01108 else (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]).Clear();
01109 }
01110 }
01111 else
01112 {
01113
01114
01115
01116 (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]).Clear();
01117 (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]).SetTime24Bits(
01118 (ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][bCurrentBuffer])[uMessageIndex] );
01119 }
01120 }
01121 }
01122
01123
01124
01125
01126
01127 return kTRUE;
01128 }
01129 Bool_t TGet4v1Proc::BuildHitsAfterTrigg(UInt_t uRocId, UInt_t uGet4Id)
01130 {
01131
01132
01133
01134
01135
01136
01137
01138 Bool_t bCurrentBuffer = 0;
01139 std::sort( ROC[uRocId].fAfterTriggEpochs2Buffer[uGet4Id][bCurrentBuffer].begin(),
01140 ROC[uRocId].fAfterTriggEpochs2Buffer[uGet4Id][bCurrentBuffer].end() );
01141 for( UInt_t uMessageIndex = 0;
01142 uMessageIndex < ROC[uRocId].fAfterTriggEpochs2Buffer[uGet4Id][bCurrentBuffer].size();
01143 uMessageIndex ++)
01144 {
01145 if( kTRUE == (ROC[uRocId].fAfterTriggEpochs2Buffer[uGet4Id][bCurrentBuffer])[uMessageIndex].Is32Bit() )
01146 {
01147
01148 fHitTemp.Clear();
01149 fHitTemp.SetFullHit32Bits( (ROC[uRocId].fAfterTriggEpochs2Buffer[uGet4Id][bCurrentBuffer])[uMessageIndex] );
01150 CheckHit( uRocId, uGet4Id, fHitTemp );
01151 }
01152 else
01153 {
01154 UChar_t ucChan = (ROC[uRocId].fAfterTriggEpochs2Buffer[uGet4Id][bCurrentBuffer])[uMessageIndex].GetGet4ChNum();
01155
01156 if( 1 == (ROC[uRocId].fAfterTriggEpochs2Buffer[uGet4Id][bCurrentBuffer])[uMessageIndex].IsRisingGet4Edge() )
01157 {
01158
01159
01160
01161 if( kTRUE == (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]).IsTimeSet() )
01162 {
01163 (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]).SetTot24Bits(
01164 (ROC[uRocId].fAfterTriggEpochs2Buffer[uGet4Id][bCurrentBuffer])[uMessageIndex] );
01165
01166
01167
01168 if( (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]).GetTot() < fParam->dMaxTot )
01169 CheckHit( uRocId, uGet4Id, (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]) );
01170 else (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]).Clear();
01171 }
01172 }
01173 else
01174 {
01175
01176
01177
01178 (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]).Clear();
01179 (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]).SetTime24Bits(
01180 (ROC[uRocId].fAfterTriggEpochs2Buffer[uGet4Id][bCurrentBuffer])[uMessageIndex] );
01181 }
01182 }
01183 }
01184 Bool_t bNewerBuffer = 1;
01185 std::sort( ROC[uRocId].fAfterTriggEpochs2Buffer[uGet4Id][bNewerBuffer].begin(),
01186 ROC[uRocId].fAfterTriggEpochs2Buffer[uGet4Id][bNewerBuffer].end() );
01187 for( UInt_t uMessageIndex = 0;
01188 uMessageIndex < ROC[uRocId].fAfterTriggEpochs2Buffer[uGet4Id][bNewerBuffer].size();
01189 uMessageIndex ++)
01190 {
01191 if( kTRUE == (ROC[uRocId].fAfterTriggEpochs2Buffer[uGet4Id][bNewerBuffer])[uMessageIndex].Is32Bit() )
01192 {
01193
01194 fHitTemp.Clear();
01195 fHitTemp.SetFullHit32Bits( (ROC[uRocId].fAfterTriggEpochs2Buffer[uGet4Id][bNewerBuffer])[uMessageIndex] );
01196 CheckHit( uRocId, uGet4Id, fHitTemp );
01197 }
01198 else
01199 {
01200 UChar_t ucChan = (ROC[uRocId].fAfterTriggEpochs2Buffer[uGet4Id][bNewerBuffer])[uMessageIndex].GetGet4ChNum();
01201
01202 if( 1 == (ROC[uRocId].fAfterTriggEpochs2Buffer[uGet4Id][bNewerBuffer])[uMessageIndex].IsRisingGet4Edge() )
01203 {
01204
01205
01206
01207 if( kTRUE == (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]).IsTimeSet() )
01208 {
01209 (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]).SetTot24Bits(
01210 (ROC[uRocId].fAfterTriggEpochs2Buffer[uGet4Id][bNewerBuffer])[uMessageIndex] );
01211
01212
01213
01214 if( (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]).GetTot() < fParam->dMaxTot )
01215 CheckHit( uRocId, uGet4Id, (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]) );
01216 else (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]).Clear();
01217 }
01218 }
01219 else
01220 {
01221
01222
01223
01224 (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]).Clear();
01225 (ROC[uRocId].fHitTemp24[uGet4Id][ucChan]).SetTime24Bits(
01226 (ROC[uRocId].fAfterTriggEpochs2Buffer[uGet4Id][bNewerBuffer])[uMessageIndex] );
01227 }
01228 }
01229 }
01230
01231
01232
01233
01234
01235 ROC[uRocId].fAfterTriggEpochs2Buffer[uGet4Id][bCurrentBuffer].clear();
01236 ROC[uRocId].fAfterTriggEpochs2Buffer[uGet4Id][bNewerBuffer].clear();
01237
01238 return kTRUE;
01239 }
01240 void TGet4v1Proc::CheckHit(UInt_t uRocId, UInt_t uGet4Id, Get4v1Hit& hit)
01241 {
01242
01243
01244
01245
01246 Double_t dTimeToTrigger = 0.0;
01247
01248 if ( 0.0 < fCurrentGet4Event.fdTriggerFullTime[uRocId] )
01249 {
01250 dTimeToTrigger = hit.GetHitFullTimeD() - fCurrentGet4Event.fdTriggerFullTime[uRocId];
01251
01252 fDeltaTriggerTime->Fill( dTimeToTrigger );
01253 ROC[uRocId].fTrigger_All->Fill( dTimeToTrigger );
01254 ROC[uRocId].fTrigger_All_100->Fill( dTimeToTrigger );
01255 ROC[uRocId].fTrigger_All_us->Fill( dTimeToTrigger );
01256 ROC[uRocId].fTrigger_All_ms->Fill( dTimeToTrigger );
01257 ROC[uRocId].fTrigger_All_s->Fill( dTimeToTrigger );
01258
01259 UChar_t uGet4Chan = hit.GetChan();
01260 ROC[uRocId].fTrigger_Get4Channel[uGet4Id][uGet4Chan]->Fill( dTimeToTrigger );
01261 ROC[uRocId].fTriggerMs_Get4Channel[uGet4Id][uGet4Chan]->Fill( dTimeToTrigger );
01262 ROC[uRocId].fTriggerS_Get4Channel[uGet4Id][uGet4Chan]->Fill( dTimeToTrigger );
01263
01264 if( kTRUE == ROC[uRocId].fTriggerWind->Test( dTimeToTrigger) )
01265 {
01266
01267 ( ( fCurrentGet4Event.fGet4Boards[uGet4Id] ).fHits[ hit.GetChan() ]).push_back( hit );
01268
01269
01270 if( 1 == fParam->bTotHistoEnable )
01271 ROC[uRocId].fTot[uGet4Id][hit.GetChan()]->Fill( hit.GetTot() );
01272 if( 1 == fParam->bDebugHistoEnable )
01273 {
01274 ROC[uRocId].fLeadingFTS[uGet4Id][hit.GetChan()]->Fill( hit.GetHitLeadingFTS() );
01275 if( kFALSE == hit.Is32Bit() )
01276 ROC[uRocId].fTrailingFTS[uGet4Id][hit.GetChan()]->Fill( hit.GetHitTrailingFTS() );
01277 }
01278 }
01279 }
01280 else TGo4Log::Error("Trying to check a hit validity while no trigger found for current event");
01281
01282 }
01283 void TGet4v1Proc::CheckEventClosure()
01284 {
01285
01286
01287
01288
01289
01290
01291 if( kFALSE == fCurrentGet4Event.HasTrigger() )
01292 return;
01293
01294 Bool_t bAllFutureEpochsFinished = kTRUE;
01295
01296 for( UInt_t uRocId =0; uRocId<fParam->numRocs; uRocId++ )
01297 {
01298
01299 if (!fParam->IsActiveRoc(uRocId)) continue;
01300
01301 if( kFALSE == ROC[uRocId].fbSelectionRocDone )
01302 bAllFutureEpochsFinished = kFALSE;
01303
01304 for( UInt_t uGet4 = 0; uGet4 < MAX_GET4_PER_ROC; uGet4++)
01305 {
01306 UInt_t uRemappedGet4Index = fParam->RemapGet4Chip(uRocId, uGet4);
01307 if( kTRUE == fParam->IsValidGet4Chip(uRemappedGet4Index) &&
01308 kTRUE == fParam->IsActiveGet4Chip(uRemappedGet4Index) )
01309 if( kFALSE == ROC[uRocId].fbSelectionDone[uGet4] )
01310 bAllFutureEpochsFinished = kFALSE;
01311 }
01312 }
01313
01314
01315 if( kTRUE == bAllFutureEpochsFinished )
01316 {
01317 if( kFALSE == fCurrentGet4Event.IsEmpty() )
01318 {
01319 AnalyzeAllGet4Channels( fCurrentGet4Event );
01320 (fOutputEvent->fEvents).push_back( fCurrentGet4Event );
01321 }
01322
01323 fCurrentGet4Event.Clear();
01324 }
01325 }
01326
01327 void TGet4v1Proc::ResetTrigger()
01328 {
01329
01330
01331
01332 }
01333
01334
01335 void TGet4v1Proc::ResetEndOfBuffer()
01336 {
01337
01338
01339
01340 }
01341
01342
01343
01344
01345
01346 Bool_t TGet4v1Proc::ProcessRocSyncMessage( UInt_t uRocId, TGet4v1MessageExtended& extMess )
01347 {
01348
01349
01350
01351 UInt_t uSyncId = (extMess.GetRocMessage()).getSyncChNum();
01352 ULong64_t ulFulltime = extMess.GetFullTime();
01353
01354
01355 ulFulltime = (extMess.GetRocMessage()).getMsgFullTime(
01356 ROC[uRocId].GetFullEpochNumber( ));
01357 extMess.SetFullTime(ulFulltime);
01358
01359 if( uSyncId < MAX_SYNC )
01360 {
01361 ROC[uRocId].fLastSyncTm[uSyncId] = ulFulltime;
01362 ROC[uRocId].fLastSyncId[uSyncId] = (extMess.GetRocMessage()).getSyncData();
01363
01364
01365
01366
01367
01368
01369 ULong64_t ulSyncTm = ulFulltime / 100000000L;
01370 ROC[uRocId].fSYNCt[uSyncId]->Fill((ulSyncTm % 36000) * 0.1);
01371
01372 if( fParam->triggerSignal == (Int_t) (uSyncId + 10) )
01373 ProcessTriggerMessage( uRocId, extMess );
01374 }
01375 return kTRUE;
01376 }
01377
01378
01379
01380
01381 Bool_t TGet4v1Proc::ProcessRocEpochMessage( UInt_t uRocId, TGet4v1MessageExtended& extMess )
01382 {
01383
01384
01385
01386 if( ROC[uRocId].fuCurrEpoch > (extMess.GetRocMessage()).getEpochNumber() )
01387 ROC[uRocId].fuEpochCycle++;
01388 ROC[uRocId].fuCurrEpoch = (extMess.GetRocMessage()).getEpochNumber();
01389
01390 ROC[uRocId].fDistribEpochs->Fill( ROC[uRocId].fuCurrEpoch );
01391
01392 if( kTRUE == ROC[uRocId].fbPastEpochsRocDone &&
01393 kFALSE == ROC[uRocId].fbSelectionRocDone )
01394 {
01395
01396
01397
01398 if( kTRUE == ROC[uRocId].fbEpochSinceTrigger)
01399 {
01400 ROC[uRocId].fbPastEpochsRocDone = kFALSE;
01401 ROC[uRocId].fbSelectionRocDone = kTRUE;
01402 ROC[uRocId].fbEpochSinceTrigger = kFALSE;
01403 CheckEventClosure();
01404 }
01405 else ROC[uRocId].fbEpochSinceTrigger = kTRUE;
01406 }
01407
01408
01409 ROC[uRocId].fbBufferWithLastFullEpoch = ( kTRUE == ROC[uRocId].fbBufferWithLastFullEpoch ? kFALSE: kTRUE );
01410
01411 ROC[uRocId].fPrevEpochsBuffer[ ROC[uRocId].fbBufferWithLastFullEpoch ].clear();
01412
01413 return kTRUE;
01414 }
01415
01416
01417
01418
01419 Bool_t TGet4v1Proc::ProcessGet4EpochMessage( UInt_t uRocId, TGet4v1MessageExtended& extMess )
01420 {
01421
01422
01423
01424
01425 UInt_t uGet4Id(0);
01426
01427
01428 uGet4Id = (extMess.GetRocMessage()).getEpoch2ChipNumber();
01429 uGet4Id = fParam->RemapGet4Chip( fParam->DefineGet4IndexOffset(uRocId) + uGet4Id);
01430 extMess.SetEpoch2ChipNumber(uGet4Id);
01431
01432
01433 if( kFALSE == fParam->IsValidGet4Chip(uGet4Id) )
01434 {
01435 cout << "Error: Bad chip nb in Epoch message = " << uGet4Id << endl;
01436 cout << " => This message will be skipped!!!! "<<endl;
01437 return kFALSE;
01438 }
01439 if( kFALSE == fParam->IsActiveGet4Chip(uGet4Id) )
01440 {
01441
01442 return kFALSE;
01443 }
01444
01445 if( ROC[uRocId].fuCurrEpoch2[uGet4Id] > (extMess.GetRocMessage()).getEpoch2Number() )
01446 ROC[uRocId].fuEpoch2Cycle[uGet4Id]++;
01447 ROC[uRocId].fuCurrEpoch2[uGet4Id] = (extMess.GetRocMessage()).getEpoch2Number();
01448
01449 ROC[uRocId].fDistribEpochs2->Fill(uGet4Id, ROC[uRocId].fuCurrEpoch2[uGet4Id]);
01450
01451 if( kTRUE == ROC[uRocId].fbPastEpochs2Done[uGet4Id] &&
01452 kFALSE == ROC[uRocId].fbSelectionDone[uGet4Id] )
01453 {
01454
01455
01456
01457 if( kTRUE == ROC[uRocId].fbEpoch2SinceTrigger[uGet4Id])
01458 {
01459
01460
01461
01462 BuildHitsAfterTrigg( uRocId, uGet4Id);
01463
01464 ROC[uRocId].fbPastEpochs2Done[uGet4Id] = kFALSE;
01465 ROC[uRocId].fbSelectionDone[uGet4Id] = kTRUE;
01466 ROC[uRocId].fbEpoch2SinceTrigger[uGet4Id] = kFALSE;
01467 CheckEventClosure();
01468 }
01469 else ROC[uRocId].fbEpoch2SinceTrigger[uGet4Id] = kTRUE;
01470 }
01471
01472
01473 ROC[uRocId].fbBufferWithLastFullEpoch2[uGet4Id] = ( kTRUE == ROC[uRocId].fbBufferWithLastFullEpoch2[uGet4Id] ? kFALSE: kTRUE );
01474
01475 ROC[uRocId].fPrevEpochs2Buffer[uGet4Id][ ROC[uRocId].fbBufferWithLastFullEpoch2[uGet4Id] ].clear();
01476
01477 return kTRUE;
01478 }
01479
01480
01481
01482
01483 Bool_t TGet4v1Proc::ProcessGet4DataMessage( UInt_t uRocId, TGet4v1MessageExtended& extMess )
01484 {
01485
01486
01487
01488 if (ROC[uRocId].bIgnoreData) return kFALSE;
01489 UInt_t uGet4Id(0), uGet4Ch(0), uGet4Edge(0);
01490 ULong64_t ulFulltime(0);
01491 uGet4Id = (extMess.GetRocMessage()).getGet4Number();
01492 uGet4Ch = (extMess.GetRocMessage()).getGet4ChNum();
01493 uGet4Edge = (extMess.GetRocMessage()).getGet4Edge();
01494
01495
01496 uGet4Id = (extMess.GetRocMessage()).getGet4Number();
01497 uGet4Id = fParam->RemapGet4Chip( fParam->DefineGet4IndexOffset(uRocId) + uGet4Id);
01498 extMess.SetGet4Number(uGet4Id);
01499
01500 ULong64_t uFullTimeBins = ((ULong64_t) ROC[uRocId].GetFullEpoch2Number( uGet4Id ) << 19) |
01501 (ULong64_t)extMess.GetGet4Ts();
01502 ULong64_t uFullTime = uFullTimeBins/ 20 + 512;
01503 Double_t dFullTime = ((Double_t)uFullTimeBins)*0.05 + 512.;
01504 extMess.SetFullTime( uFullTime );
01505 extMess.SetFullTimeD( dFullTime );
01506
01507
01508 if( kFALSE == fParam->IsValidGet4Chip(uGet4Id) )
01509 {
01510 cout << "Error: Bad chip nb in Data message = " << uGet4Id << endl;
01511 cout << " => This message will be skipped!!!! "<<endl;
01512 return kFALSE;
01513 }
01514 if( kFALSE == fParam->IsActiveGet4Chip(uGet4Id) )
01515 {
01516
01517 return kFALSE;
01518 }
01519
01520
01521 ulFulltime = (extMess.GetRocMessage()).getMsgFullTime(
01522 ROC[uRocId].GetFullEpoch2Number( uGet4Id ));
01523 extMess.SetFullTime(ulFulltime);
01524
01525
01526 ULong64_t ulSyncTm = ulFulltime / 100000000L;
01527 ROC[uRocId].fDATAt->Fill((ulSyncTm % 36000) * 0.1);
01528
01529 return kTRUE;
01530 }
01531
01532
01533
01534
01535 Bool_t TGet4v1Proc::ProcessGet4ExtSyncMessage( UInt_t uRocId, TGet4v1MessageExtended& extMess )
01536 {
01537
01538
01539
01540 return kTRUE;
01541 }
01542
01543
01544 Int_t TGet4v1Proc::Process32BitGet4Message( UInt_t uRocId, TGet4v1MessageExtended& extMess )
01545 {
01546
01547
01548
01549
01550
01551
01552 UInt_t get4_index = extMess.getGet4V10R32ChipId() ;
01553 get4_index = fParam->RemapGet4Chip(get4_index);
01554
01555
01556 if( kFALSE == fParam->IsValidGet4Chip(get4_index) )
01557 {
01558 cout << "Error: Bad chip nb in 32b Data message = " << get4_index <<" < "<<fParam->uNbGet4<< endl;
01559 cout << " => This message will be skipped!!!! "<<endl;
01560 return -1;
01561 }
01562 if( kFALSE == fParam->IsActiveGet4Chip(get4_index) )
01563 {
01564
01565 return -1;
01566 }
01567
01568
01569 if( kFALSE == ROC[uRocId].fb32bitsReadoutDetected )
01570 {
01571 ROC[uRocId].fb32bitsReadoutDetected = kTRUE;
01572 fb32bitsReadoutDetected = kTRUE;
01573
01574
01575 char folder[30];
01576 sprintf(folder,"ROC%u/",uRocId);
01577
01578
01579
01580
01581
01582 ROC[uRocId].fGet4V1SlowControlType = MakeTH2('I', Form("%sRoc%u_Get4SlowControl", folder, uRocId),
01583 "SlowControl message type per Get4",
01584 fParam->uNbGet4, -0.5, fParam->uNbGet4 -0.5, 4, 0., 4,
01585 "Chip","","Entries [1]");
01586 ROC[uRocId].fGet4V1SlowControlType->GetYaxis()->SetBinLabel(1, "Scaler");
01587 ROC[uRocId].fGet4V1SlowControlType->GetYaxis()->SetBinLabel(2, "Dead time");
01588 ROC[uRocId].fGet4V1SlowControlType->GetYaxis()->SetBinLabel(3, "SPI");
01589 ROC[uRocId].fGet4V1SlowControlType->GetYaxis()->SetBinLabel(4, "Start");
01590 ROC[uRocId].fGet4V1SlowControlScaler = MakeTH2('I', Form("%sRoc%u_Get4SlScaler", folder, uRocId),
01591 "Scaler in Get4 slow control message",
01592 2*(fParam->uNbGet4)*NB_CHAN_GET4, 0., (fParam->uNbGet4)*NB_CHAN_GET4, 820, 0, 8200,
01593 "Channel","Scaler [hits]","Entries [1]");
01594 ROC[uRocId].fGet4V1SlowControlDeadTime = MakeTH2('I', Form("%sRoc%u_Get4SlDeadTime", folder, uRocId),
01595 "Dead time in Get4 slow control message",
01596 2*(fParam->uNbGet4)*NB_CHAN_GET4, 0., (fParam->uNbGet4)*NB_CHAN_GET4, 410, 0, 4100,
01597 "Channel","Dead Time [Clk cycle]","Entries [1]");
01598
01599 ROC[uRocId].fGet4V1DllLockBit =
01600 MakeTH2('I', Form("%sRoc%u_Get4V1DllLockBit", folder, uRocId),
01601 "Dll lock bit status per channel",
01602 fParam->uNbGet4*NB_CHAN_GET4, -0.5 , fParam->uNbGet4*NB_CHAN_GET4 -0.5,
01603 2, -0.5, 1.5,
01604 "Channel []", "Dll lock bit []", "Counts [1]" );
01605
01606 for( Int_t iGet4 = 0; iGet4 < MAX_GET4_PER_ROC; iGet4++)
01607 {
01608 char folderGet4[30];
01609 sprintf(folderGet4,"%sGet4_%u/",folder, iGet4);
01610 UInt_t uRemappedGet4Index = fParam->RemapGet4Chip(uRocId, iGet4);
01611 if( kTRUE == fParam->IsValidGet4Chip(uRemappedGet4Index) &&
01612 kTRUE == fParam->IsActiveGet4Chip(uRemappedGet4Index) )
01613 {
01614 ROC[uRocId].fGet4V1HitsDistanceNs[iGet4] =
01615 MakeTH2('I', Form("%sRoc%u_Get%d_HitDistNs",
01616 folderGet4, uRocId, iGet4),
01617 Form("Time difference since last hit on same channel in GET4 %d Channels on ROC%u; [ns]",
01618 iGet4, uRocId),
01619 1002, -2., 1000.,
01620 NB_CHAN_GET4, 0, NB_CHAN_GET4 );
01621 ROC[uRocId].fGet4V1HitsDistanceUs[iGet4] =
01622 MakeTH2('I', Form("%sRoc%u_Get%d_HitDistUs",
01623 folderGet4, uRocId, iGet4),
01624 Form("Time difference since last hit on same channel in GET4 %d Channels on ROC%u; [us]",
01625 iGet4, uRocId),
01626 999, 1., 1000.,
01627 NB_CHAN_GET4, 0, NB_CHAN_GET4 );
01628 ROC[uRocId].fGet4V1HitsDistanceMs[iGet4] =
01629 MakeTH2('I', Form("%sRoc%u_Get%d_HitDistMs",
01630 folderGet4, uRocId, iGet4),
01631 Form("Time difference since last hit on same channel in GET4 %d Channels on ROC%u; [ms]",
01632 iGet4, uRocId),
01633 999, 1., 1000.,
01634 NB_CHAN_GET4, 0, NB_CHAN_GET4 );
01635 ROC[uRocId].fGet4V1HitsDistanceS[iGet4] =
01636 MakeTH2('I', Form("%sRoc%u_Get%d_HitDistS",
01637 folderGet4, uRocId, iGet4),
01638 Form("Time difference since last hit on same channel in GET4 %d Channels on ROC%u; [s]",
01639 iGet4, uRocId),
01640 999, 1., 1000.,
01641 NB_CHAN_GET4, 0, NB_CHAN_GET4 );
01642 }
01643 }
01644 }
01645 extMess.Set32BitFlag();
01646
01647 UInt_t get4_32b_type = extMess.getGet4V10R32MessageType();
01648 switch(get4_32b_type)
01649 {
01650 case 0:
01651 {
01652 UInt_t get4_32b_ep_epoch = extMess.getGet4V10R32EpochNumber();
01653 UInt_t get4_32b_ep_sync = extMess.getGet4V10R32SyncFlag();
01654
01655
01656
01657
01658
01659
01660
01661
01662
01663
01664
01665
01666
01667
01668
01669
01670
01671
01672
01673
01674
01675
01676
01677
01678
01679
01680
01681
01682 if( 0 == get4_index)
01683 {
01684 if( ROC[uRocId].fuCurrEpoch2[get4_index] > get4_32b_ep_epoch )
01685 {
01686 ROC[uRocId].fuEpoch2Cycle[1]++;
01687 ROC[uRocId].fuEpoch2Cycle[5]++;
01688 }
01689 ROC[uRocId].fuCurrEpoch2[1] = get4_32b_ep_epoch;
01690 ROC[uRocId].fuCurrEpoch2[5] = get4_32b_ep_epoch;
01691 }
01692 if( 1 != get4_index && 5 != get4_index)
01693 {
01694 if( ROC[uRocId].fuCurrEpoch2[get4_index] > get4_32b_ep_epoch )
01695 ROC[uRocId].fuEpoch2Cycle[get4_index]++;
01696 ROC[uRocId].fuCurrEpoch2[get4_index] = get4_32b_ep_epoch;
01697 }
01698
01699 ROC[uRocId].fDistribEpochs2->Fill(get4_index, ROC[uRocId].fuCurrEpoch2[get4_index]);
01700
01701 ULong64_t uFullTimeBins = ((ULong64_t) ROC[uRocId].GetFullEpoch2Number( get4_index )) << 19;
01702 ULong64_t uFullTime = uFullTimeBins/ 20 + 512;
01703 Double_t dFullTime = uFullTimeBins / 20. + 512.;
01704 extMess.SetFullTime( uFullTime );
01705 extMess.SetFullTimeD( dFullTime );
01706
01707 if( kTRUE == ROC[uRocId].fbPastEpochs2Done[get4_index] &&
01708 kFALSE == ROC[uRocId].fbSelectionDone[get4_index] )
01709 {
01710
01711
01712
01713 if( kTRUE == ROC[uRocId].fbEpoch2SinceTrigger[get4_index])
01714 {
01715
01716
01717
01718 BuildHitsAfterTrigg( uRocId, get4_index);
01719
01720 ROC[uRocId].fbPastEpochs2Done[get4_index] = kFALSE;
01721 ROC[uRocId].fbSelectionDone[get4_index] = kTRUE;
01722 ROC[uRocId].fbEpoch2SinceTrigger[get4_index] = kFALSE;
01723 CheckEventClosure();
01724 }
01725 else ROC[uRocId].fbEpoch2SinceTrigger[get4_index] = kTRUE;
01726 }
01727
01728
01729 ROC[uRocId].fbBufferWithLastFullEpoch2[get4_index] = ( kTRUE == ROC[uRocId].fbBufferWithLastFullEpoch2[get4_index] ? kFALSE: kTRUE );
01730
01731 ROC[uRocId].fPrevEpochs2Buffer[get4_index][ ROC[uRocId].fbBufferWithLastFullEpoch2[get4_index] ].clear();
01732
01733 break;
01734 }
01735 case 1:
01736 {
01737 UInt_t get4_32b_sl_data = extMess.getGet4V10R32SlData();
01738 UInt_t get4_32b_sl_type = extMess.getGet4V10R32SlType();
01739 UInt_t get4_32b_sl_edge = extMess.getGet4V10R32SlEdge();
01740 UInt_t get4_32b_sl_chan = extMess.getGet4V10R32SlChan();
01741
01742 ROC[uRocId].fGet4V1SlowControlType->Fill(get4_index, get4_32b_sl_type);
01743
01744 ULong64_t uFullTimeBins = ((ULong64_t) ROC[uRocId].GetFullEpoch2Number( get4_index )) << 19;
01745 ULong64_t uFullTime = uFullTimeBins/ 20 + 512;
01746 Double_t dFullTime = uFullTimeBins / 20. + 512.;
01747 extMess.SetFullTime( uFullTime );
01748 extMess.SetFullTimeD( dFullTime );
01749
01750 switch(get4_32b_sl_type)
01751 {
01752 case 0:
01753 ROC[uRocId].fGet4V1SlowControlScaler->Fill(
01754 NB_CHAN_GET4*get4_index + get4_32b_sl_chan + 0.5*get4_32b_sl_edge, get4_32b_sl_data );
01755 break;
01756 case 1:
01757 ROC[uRocId].fGet4V1SlowControlDeadTime->Fill(
01758 NB_CHAN_GET4*get4_index + get4_32b_sl_chan + 0.5*get4_32b_sl_edge, get4_32b_sl_data );
01759 break;
01760 case 2:
01761 TGo4Log::Info("Get4 V1.0 32bit, chip %02d, SPI message: %06x", get4_index, get4_32b_sl_data);
01762 break;
01763 case 3:
01764 TGo4Log::Info("Get4 V1.0 32bit, chip %02d, Start message: %c%c%c (%6X)",
01765 get4_index,
01766 (get4_32b_sl_data>>16)&0xFF, (get4_32b_sl_data>>8)&0xFF,
01767 get4_32b_sl_data&0xFF, get4_32b_sl_data);
01768
01769 break;
01770 default:
01771 break;
01772 }
01773
01774 break;
01775 }
01776 case 2:
01777 {
01778 UInt_t get4_32b_er_code = extMess.getGet4V10R32ErrorData();
01779 UInt_t get4_32b_er_chan = extMess.getGet4V10R32ErrorChan();
01780 UInt_t get4_32b_er_edge = extMess.getGet4V10R32ErrorEdge();
01781
01782 ULong64_t uFullTimeBins = ((ULong64_t) ROC[uRocId].GetFullEpoch2Number( get4_index )) << 19;
01783 ULong64_t uFullTime = uFullTimeBins/ 20 + 512;
01784 Double_t dFullTime = uFullTimeBins / 20. + 512.;
01785 extMess.SetFullTime( uFullTime );
01786 extMess.SetFullTimeD( dFullTime );
01787
01788 ROC[uRocId].fGet4ErrorChip->Fill( get4_index );
01789 ROC[uRocId].fGet4ErrorPatt->Fill( get4_index, get4_32b_er_code);
01790 if( (0x03 < get4_32b_er_code && get4_32b_er_code < 0x07) )
01791 ROC[uRocId].fGet4ErrorChan->Fill(
01792 NB_CHAN_GET4*get4_index + get4_32b_er_chan + 0.5*get4_32b_er_edge,
01793 get4_32b_er_code - 0x04 );
01794 else if( 0x11 == get4_32b_er_code ||
01795 0x12 == get4_32b_er_code ||
01796 0x13 == get4_32b_er_code )
01797 ROC[uRocId].fGet4ErrorChan->Fill(
01798 NB_CHAN_GET4*get4_index + get4_32b_er_chan + 0.5*get4_32b_er_edge,
01799 get4_32b_er_code - 0x0e );
01800
01801 break;
01802 }
01803 case 3:
01804 {
01805 UInt_t get4_32b_dat_tot = extMess.getGet4V10R32HitTot();
01806 UInt_t get4_32b_dat_ft = extMess.getGet4V10R32HitFt();
01807 UInt_t get4_32b_dat_ts = extMess.getGet4V10R32HitTs();
01808 UInt_t get4_32b_dat_chan = extMess.getGet4V10R32HitChan();
01809 UInt_t get4_32b_dat_dll = extMess.getGet4V10R32HitDllFlag();
01810 if( NB_CHAN_GET4 <= get4_32b_dat_chan )
01811 return -1;
01812
01813 ULong64_t uFullTimeBins = ((ULong64_t) ROC[uRocId].GetFullEpoch2Number( get4_index ) << 19) |
01814 (ULong64_t)extMess.getGet4V10R32HitTimeBin();
01815 ULong64_t uFullTime = uFullTimeBins/ 20 + 512;
01816 Double_t dFullTime = ((Double_t)uFullTimeBins)*0.05 + 512.;
01817 extMess.SetFullTime( uFullTime );
01818 extMess.SetFullTimeD( dFullTime );
01819
01820 uFullTimeBins /= 20;
01821 uFullTimeBins += 512;
01822 uFullTimeBins /= 100000000L;
01823 ROC[uRocId].fDATAt->Fill( (uFullTimeBins % 36000) * 0.1 );
01824
01825 if( 0 < ROC[uRocId].fLastExtMess[get4_index][get4_32b_dat_chan].GetFullTimeD() )
01826 {
01827 ROC[uRocId].fGet4V1HitsDistanceNs[get4_index]->Fill( extMess.GetFullTimeD()
01828 - ROC[uRocId].fLastExtMess[get4_index][get4_32b_dat_chan].GetFullTimeD(),
01829 get4_32b_dat_chan);
01830 ROC[uRocId].fGet4V1HitsDistanceUs[get4_index]->Fill( ( extMess.GetFullTimeD()
01831 - ROC[uRocId].fLastExtMess[get4_index][get4_32b_dat_chan].GetFullTimeD() )/1e3,
01832 get4_32b_dat_chan);
01833 ROC[uRocId].fGet4V1HitsDistanceMs[get4_index]->Fill( ( extMess.GetFullTimeD()
01834 - ROC[uRocId].fLastExtMess[get4_index][get4_32b_dat_chan].GetFullTimeD() )/1e6,
01835 get4_32b_dat_chan);
01836 ROC[uRocId].fGet4V1HitsDistanceS[get4_index]->Fill( ( extMess.GetFullTimeD()
01837 - ROC[uRocId].fLastExtMess[get4_index][get4_32b_dat_chan].GetFullTimeD() )/1e9,
01838 get4_32b_dat_chan);
01839 }
01840 ROC[uRocId].fLastExtMess[get4_index][get4_32b_dat_chan] = extMess;
01841 ROC[uRocId].fChannelInputMessCount->Fill( get4_index + (Double_t)get4_32b_dat_chan/(Double_t)NB_CHAN_GET4 );
01842
01843 ROC[uRocId].fGet4V1DllLockBit->Fill( NB_CHAN_GET4*get4_index + get4_32b_dat_chan,
01844 get4_32b_dat_dll);
01845 if( kTRUE == ROC[uRocId].fbDllFlag[get4_index][get4_32b_dat_chan] && 1 == get4_32b_dat_dll)
01846 {
01847 ROC[uRocId].fbDllFlag[get4_index][get4_32b_dat_chan] = kFALSE;
01848 cout<<"DLL lock recovery, chip "<<get4_index<<" chan "<<get4_32b_dat_chan<<" at "<<(Double_t)uFullTimeBins*0.1<<" s"<<endl;
01849 }
01850 if( kFALSE == ROC[uRocId].fbDllFlag[get4_index][get4_32b_dat_chan] && 0 == get4_32b_dat_dll)
01851 {
01852 ROC[uRocId].fbDllFlag[get4_index][get4_32b_dat_chan] = kTRUE;
01853 cout<<"DLL lock loss, chip "<<get4_index<<" chan "<<get4_32b_dat_chan<<" at "<<(Double_t)uFullTimeBins*0.1<<" s"<<endl;
01854 }
01855
01856 break;
01857 }
01858 default:
01859 break;
01860 }
01861
01862 return get4_32b_type;
01863 }
01864
01865
01866 Bool_t TGet4v1Proc::AnalyzeAllGet4Channels( Get4v1Event &eventFull )
01867 {
01868
01869
01870
01871
01872 for( UInt_t uRocId =0; uRocId<fParam->numRocs; uRocId++ )
01873 {
01874 if( !fParam->IsActiveRoc(uRocId) ) continue;
01875
01876 for( Int_t iGet4 = 0; iGet4 < MAX_GET4_PER_ROC; iGet4++)
01877 for( Int_t iGet4Chan = 0; iGet4Chan < NB_CHAN_GET4; iGet4Chan++)
01878 {
01879 if( 0 < ( (eventFull.fGet4Boards[iGet4]).fHits[iGet4Chan]).size() )
01880 {
01881 for( Int_t iGet4Chan_2 = iGet4Chan+1; iGet4Chan_2 < NB_CHAN_GET4; iGet4Chan_2++)
01882 if( 0 < ( (eventFull.fGet4Boards[iGet4]).fHits[iGet4Chan_2]).size() )
01883 ROC[uRocId].fChannelsMapping->Fill( iGet4 + (Double_t)iGet4Chan/(Double_t)NB_CHAN_GET4,
01884 iGet4 + (Double_t)iGet4Chan_2/(Double_t)NB_CHAN_GET4 );
01885
01886 for( Int_t iGet4_2 = iGet4+1; iGet4_2 < MAX_GET4_PER_ROC; iGet4_2++)
01887 for( Int_t iGet4Chan_2 = 0; iGet4Chan_2 < NB_CHAN_GET4; iGet4Chan_2++)
01888 if( 0 < ( (eventFull.fGet4Boards[iGet4_2]).fHits[iGet4Chan_2]).size() )
01889 ROC[uRocId].fChannelsMapping->Fill( iGet4 + (Double_t)iGet4Chan/(Double_t)NB_CHAN_GET4,
01890 iGet4_2 + (Double_t)iGet4Chan_2/(Double_t)NB_CHAN_GET4 );
01891 }
01892
01893 ROC[uRocId].fChannelMultiplicity->Fill( iGet4 + (Double_t)iGet4Chan/(Double_t)NB_CHAN_GET4,
01894 ( (eventFull.fGet4Boards[iGet4]).fHits[iGet4Chan]).size());
01895 }
01896
01897 if( 1 == fParam->bDebugHistoEnable )
01898 {
01899 UInt_t uHistosIndexSingleChip = 0;
01900 UInt_t uHistosIndexChipVsChip = 0;
01901 for(UInt_t uFirstGet4Channel = 0; uFirstGet4Channel < NB_CHAN_GET4; uFirstGet4Channel++)
01902 {
01903 for(UInt_t uSecondGet4Channel = 0; uSecondGet4Channel < NB_CHAN_GET4; uSecondGet4Channel++)
01904 {
01905 if( uFirstGet4Channel < uSecondGet4Channel )
01906 {
01907 if( 1 == ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip1]).fHits[uFirstGet4Channel]).size() &&
01908 1 == ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip1]).fHits[uSecondGet4Channel]).size() )
01909 {
01910 ROC[uRocId].fTimeDiffInsideChip[0][uHistosIndexSingleChip]->Fill(
01911 ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip1]).fHits[uFirstGet4Channel])[0].GetTimeDiff(
01912 ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip1]).fHits[uSecondGet4Channel])[0]) );
01913
01914 ROC[uRocId].fFTCorrel[0][uHistosIndexSingleChip]->Fill(
01915 ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip1]).fHits[uSecondGet4Channel])[0].GetHitLeadingFTS()
01916 -( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip1]).fHits[uFirstGet4Channel])[0].GetHitLeadingFTS() );
01917
01918 ROC[uRocId].fFTCorrel2D[0][uHistosIndexSingleChip]->Fill(
01919 ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip1]).fHits[uFirstGet4Channel])[0].GetHitLeadingFTS(),
01920 ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip1]).fHits[uSecondGet4Channel])[0].GetHitLeadingFTS() );
01921 }
01922 if( 1 == ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip2]).fHits[uFirstGet4Channel]).size() &&
01923 1 == ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip2]).fHits[uSecondGet4Channel]).size() )
01924 {
01925 ROC[uRocId].fTimeDiffInsideChip[1][uHistosIndexSingleChip]->Fill(
01926 ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip2]).fHits[uFirstGet4Channel])[0].GetTimeDiff(
01927 ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip2]).fHits[uSecondGet4Channel])[0]) );
01928
01929 ROC[uRocId].fFTCorrel[1][uHistosIndexSingleChip]->Fill(
01930 ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip2]).fHits[uSecondGet4Channel])[0].GetHitLeadingFTS()
01931 -( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip2]).fHits[uFirstGet4Channel])[0].GetHitLeadingFTS() );
01932
01933 ROC[uRocId].fFTCorrel2D[1][uHistosIndexSingleChip]->Fill(
01934 ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip2]).fHits[uFirstGet4Channel])[0].GetHitLeadingFTS(),
01935 ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip2]).fHits[uSecondGet4Channel])[0].GetHitLeadingFTS() );
01936 }
01937 uHistosIndexSingleChip++;
01938 }
01939 if( 1 == ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip1]).fHits[uFirstGet4Channel]).size() &&
01940 1 == ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip2]).fHits[uSecondGet4Channel]).size() )
01941 {
01942 ROC[uRocId].fTimeDiffBetweenChips[uHistosIndexChipVsChip]->Fill(
01943 ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip1]).fHits[uFirstGet4Channel])[0].GetTimeDiff(
01944 ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip2]).fHits[uSecondGet4Channel])[0]) );
01945 ROC[uRocId].fFTCorrelChipToChip[uHistosIndexChipVsChip]->Fill(
01946 ( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip2]).fHits[uSecondGet4Channel])[0].GetHitLeadingFTS()
01947 -( (eventFull.fGet4Boards[fParam->uGet4TimeDiffChip1]).fHits[uFirstGet4Channel])[0].GetHitLeadingFTS() );
01948 }
01949 uHistosIndexChipVsChip++;
01950 }
01951 }
01952 }
01953 }
01954
01955 if( kTRUE == fb32bitsReadoutDetected )
01956 AnalyzeAllGet4Channels32Bits( fCurrentGet4Event );
01957 else AnalyzeAllGet4Channels24Bits( fCurrentGet4Event );
01958
01959 return kTRUE;
01960 }
01961 Bool_t TGet4v1Proc::AnalyzeAllGet4Channels24Bits( Get4v1Event &eventFull )
01962 {
01963
01964
01965
01966
01967
01968 if( 1 == fParam->bDebugHistoEnable )
01969 for( UInt_t uRoc =0; uRoc<fParam->numRocs; uRoc++ )
01970 if( fParam->IsActiveRoc(uRoc) )
01971 if( 0 == uNbEvents[uRoc]%fParam->uNbEventsDnlUpdate )
01972 {
01973 UpdateLeadingDnlHistograms( eventFull, uRoc );
01974 UpdateTrailingDnlHistograms( eventFull, uRoc );
01975 }
01976
01977 return kTRUE;
01978 }
01979 Bool_t TGet4v1Proc::AnalyzeAllGet4Channels32Bits( Get4v1Event &eventFull )
01980 {
01981
01982
01983
01984
01985
01986 if( 1 == fParam->bDebugHistoEnable )
01987 for( UInt_t uRoc =0; uRoc<fParam->numRocs; uRoc++ )
01988 if( fParam->IsActiveRoc(uRoc) )
01989 if( 0 == uNbEvents[uRoc]%fParam->uNbEventsDnlUpdate )
01990 UpdateLeadingDnlHistograms( eventFull, uRoc );
01991
01992 return kTRUE;
01993 }
01994
01995
01996 Bool_t TGet4v1Proc::PrintRocEpochIndexes(UInt_t uRocId, Int_t uMessagePriority )
01997 {
01998 TString sOutput = "";
01999
02000 for( UInt_t uGet4 = 0; uGet4 < fParam->uNbGet4; uGet4++)
02001 {
02002 sOutput += Form(" %7d", ROC[uRocId].fuCurrEpoch2[uGet4]);
02003 }
02004 Message(uMessagePriority,"Current ROC epoch indexes: %s ", sOutput.Data() );
02005
02006 return kTRUE;
02007 }
02008 Bool_t TGet4v1Proc::PrintRocEpochCycles(UInt_t uRocId, Int_t uMessagePriority )
02009 {
02010 TString sOutput = "";
02011
02012 for( UInt_t uGet4 = 0; uGet4 < fParam->uNbGet4; uGet4++)
02013 {
02014 sOutput += Form(" %6d", ROC[uRocId].fuEpoch2Cycle[uGet4]);
02015 }
02016 Message(uMessagePriority,"Current ROC cycle indexes: %s ", sOutput.Data() );
02017
02018 return kTRUE;
02019 }
02020
02021 void TGet4v1Proc::UpdateLeadingDnlHistograms( Get4v1Event &eventFull, UInt_t uRocId )
02022 {
02023 for( Int_t iGet4 = 0; iGet4 < MAX_GET4_PER_ROC; iGet4++)
02024 for( Int_t iGet4Chan = 0; iGet4Chan < NB_CHAN_GET4; iGet4Chan++)
02025 {
02026 UInt_t uRemappedGet4Index = fParam->RemapGet4Chip(uRocId, iGet4);
02027 if( kTRUE == fParam->IsValidGet4Chip(uRemappedGet4Index) &&
02028 kTRUE == fParam->IsActiveGet4Chip(uRemappedGet4Index) )
02029 {
02030 Double_t dDnlLeading = 0;
02031 Double_t dSumLeading = 0;
02032
02033
02034 ROC[uRocId].fLeadingDnl[iGet4][iGet4Chan]->Reset();
02035 ROC[uRocId].fLeadingDnlSum[iGet4][iGet4Chan]->Reset();
02036
02037
02038 dDnlLeading = ( ROC[uRocId].fLeadingFTS[iGet4][iGet4Chan]->GetBinContent(1)
02039 - (ROC[uRocId].fLeadingFTS[iGet4][iGet4Chan]->GetEntries()/(Double_t)NB_BIN_GET4_FTS) ) /
02040 (ROC[uRocId].fLeadingFTS[iGet4][iGet4Chan]->GetEntries()/(Double_t)NB_BIN_GET4_FTS);
02041 ROC[uRocId].fLeadingDnl[iGet4][iGet4Chan]->Fill( 0.0, dDnlLeading);
02042 dSumLeading += dDnlLeading;
02043 ROC[uRocId].fLeadingDnlSum[iGet4][iGet4Chan]->Fill( 0.0, dSumLeading );
02044
02045 for( int j = 2; j <= NB_BIN_GET4_FTS; j++)
02046 {
02047 dDnlLeading = ( ROC[uRocId].fLeadingFTS[iGet4][iGet4Chan]->GetBinContent(j)
02048 - (ROC[uRocId].fLeadingFTS[iGet4][iGet4Chan]->GetEntries()/(Double_t)NB_BIN_GET4_FTS) ) /
02049 (ROC[uRocId].fLeadingFTS[iGet4][iGet4Chan]->GetEntries()/(Double_t)NB_BIN_GET4_FTS);
02050 ROC[uRocId].fLeadingDnl[iGet4][iGet4Chan]->Fill( (Double_t)(j-1), dDnlLeading );
02051 dSumLeading += dDnlLeading;
02052 ROC[uRocId].fLeadingDnlSum[iGet4][iGet4Chan]->Fill( (Double_t)j-1, dSumLeading );
02053 }
02054 }
02055 }
02056 }
02057 void TGet4v1Proc::UpdateTrailingDnlHistograms( Get4v1Event &eventFull, UInt_t uRocId )
02058 {
02059 for( Int_t iGet4 = 0; iGet4 < MAX_GET4_PER_ROC; iGet4++)
02060 for( Int_t iGet4Chan = 0; iGet4Chan < NB_CHAN_GET4; iGet4Chan++)
02061 {
02062 UInt_t uRemappedGet4Index = fParam->RemapGet4Chip(uRocId, iGet4);
02063 if( kTRUE == fParam->IsValidGet4Chip(uRemappedGet4Index) &&
02064 kTRUE == fParam->IsActiveGet4Chip(uRemappedGet4Index) )
02065 {
02066 Double_t dDnlTrailing = 0;
02067 Double_t dSumTrailing = 0;
02068
02069
02070 ROC[uRocId].fTrailingDnl[iGet4][iGet4Chan]->Reset();
02071 ROC[uRocId].fTrailingDnlSum[iGet4][iGet4Chan]->Reset();
02072
02073
02074 dDnlTrailing = ( ROC[uRocId].fTrailingFTS[iGet4][iGet4Chan]->GetBinContent(1)
02075 - (ROC[uRocId].fTrailingFTS[iGet4][iGet4Chan]->GetEntries()/(Double_t)NB_BIN_GET4_FTS) ) /
02076 (ROC[uRocId].fTrailingFTS[iGet4][iGet4Chan]->GetEntries()/(Double_t)NB_BIN_GET4_FTS);
02077 ROC[uRocId].fTrailingDnl[iGet4][iGet4Chan]->Fill( 0.0, dDnlTrailing );
02078 dSumTrailing += dDnlTrailing;
02079 ROC[uRocId].fTrailingDnlSum[iGet4][iGet4Chan]->Fill( 0.0, dSumTrailing );
02080
02081 for( int j = 2; j <= NB_BIN_GET4_FTS; j++)
02082 {
02083 dDnlTrailing = ( ROC[uRocId].fTrailingFTS[iGet4][iGet4Chan]->GetBinContent(j)
02084 - (ROC[uRocId].fTrailingFTS[iGet4][iGet4Chan]->GetEntries()/(Double_t)NB_BIN_GET4_FTS) ) /
02085 (ROC[uRocId].fTrailingFTS[iGet4][iGet4Chan]->GetEntries()/(Double_t)NB_BIN_GET4_FTS);
02086 ROC[uRocId].fTrailingDnl[iGet4][iGet4Chan]->Fill( (Double_t)(j-1), dDnlTrailing );
02087 dSumTrailing += dDnlTrailing;
02088 ROC[uRocId].fTrailingDnlSum[iGet4][iGet4Chan]->Fill( (Double_t)(j-1), dSumTrailing );
02089 }
02090 }
02091 }
02092 }