95 if (
fDebug) cout <<
"------------------\n Time Syncronization Checker"<<endl;
114 *
fDebugFile <<
"Bank: " << hex << *
p << dec <<
" len: " << banklen << endl;
116 if((*
p & 0xff00) == 0x1000) {
117 if(evlen-*(
p-1) > 1) {
118 roc = (*
p>>16) & 0xf;
119 if(
fDebug) cout <<
"ROC: " << roc <<
" " << evlen <<
" " << *(
p-1) << hex <<
" " << *
p << dec << endl;
123 }
else if (((*
p & 0xff00) == 0x100) && (*
p != 0xC0000100)) {
128 UInt_t tag = (*
p>>16) & 0xffff;
135 Int_t ifill = ((((*p)>>27)&0x1F) == 0x1F) ? 1 : 0;
142 if(
fDebug) cout << roc <<
": TItime " << titime << endl;
146 }
else if (tag==3801) {
150 }
else if (tag==250) {
151 if(
fDebug) cout << roc <<
": FADC" << endl;
155 UInt_t code = (*
p >> 27) & 0x1F;
158 slot = (*
p >> 22) & 0x1F;
163 UInt_t fadctime = ((*p)&0xFFFFFF) + (((*(
p+1))&0xFF)<<24);
164 if(
fDebug) cout <<
" " << slot <<
": " << fadctime << endl;
174 }
else if (tag==1190) {
180 cout <<
"Slippage detected at event " << evdata->
GetEvNum() <<
" with size " << banklen <<
" but not corrected" << endl;
184 cout <<
"Slippage enabled at event " << evdata->
GetEvNum() <<
" with size " << banklen << endl;
189 if(
fDebug) cout << roc <<
": 1190" << endl;
192 if((*
p & 0xf8000000) == 0x40000000) {
194 Int_t evcount = (*
p >> 5) & 0x3fffff;
212 if(issyncevent) cout <<
"SYNC event" << endl;
223 cout <<
"Skipping event " << evdata->
GetEvNum() << endl;
251 Int_t replacementlen;
260 if((*
p & 0xff00) == 0x1000) {
262 roc = (*
p>>16) & 0xf;
266 }
else if (((*
p & 0xff00) == 0x100) && (*
p != 0xC0000100)) {
271 UInt_t tag = (*
p>>16) & 0xffff;
274 if(tag==1190 && roc==
fBadROC) {
275 replacementlen=pslippedbank[0];
276 roc3banklenp=rocbanklenp;
288 if(replacementlen < banklen) {
289 p = poverwrite+banklen+1;
293 *(
p + replacementlen - banklen) = *
p;
297 }
else if (replacementlen > banklen) {
300 UInt_t *pfirst = poverwrite + banklen + 1;
304 *(
p+replacementlen-banklen) = *
p;
310 *roc3banklenp += replacementlen-banklen;
312 for(
Int_t i=0;i<=replacementlen;i++) {
313 poverwrite[i] = pslippedbank[i];
328 cout <<
"Run back in sync at event " << evdata->
GetEvNum() << endl;
337 for(
UInt_t i=0;i<=rdata[0];i++) {
357 if(
fDebug) cout <<
"master_ttime " << master_ttime << endl;
361 std::map<Int_t, struct RocTimes *>::iterator it =
CrateTimeMap.begin();
363 Int_t roc = it->first;
364 struct RocTimes *roctimes = it->second;
369 if(
fDebug) cout << endl <<
" FADC";
370 std::map<Int_t, UInt_t>::iterator itt = roctimes->
fadcTimesMap.begin();
372 Int_t expected_offset = 0;
375 use_expected_offset =
kTRUE;
378 Int_t slot = itt->first;
379 UInt_t fadctime = itt->second;
381 if(use_expected_offset) {
384 CrateStatsMap[roc]->fadcOffsetMap[slot] = fadctime - master_ttime;
391 if(
fDebug) cout << endl <<
" 1190";
392 std::map<Int_t, UInt_t>::iterator itt = roctimes->
ftdcEvCountMap.begin();
394 Int_t slot = itt->first;
406 std::map<Int_t, RocStats_t *>::iterator it =
CrateStatsMap.begin();
408 Int_t roc = it->first;
411 if(
CrateTimeMap[roc]->ti_ttime < master_ttime + rocstats->ti_ttime_offset) {
417 std::map<Int_t, Int_t>::iterator itt = rocstats->
fadcOffsetMap.begin();
419 Int_t slot = itt->first;
420 Int_t fadcoffset = itt->second;
422 if(
CrateTimeMap[roc]->fadcTimesMap[slot] < master_ttime+fadcoffset) {
424 }
else if(
CrateTimeMap[roc]->fadcTimesMap[slot] > master_ttime+fadcoffset) {
432 Int_t slot = itt->first;
441 cout <<
"ROC/Slot " << roc <<
"/" << slot <<
" count diff correction " << cdiff << endl;
458 cout <<
"-------------------------------------------------------------------" << endl;
459 cout <<
"------ TI and FADC250 trigger time synchronization statitics ------" << endl;
460 cout <<
"-------------------------------------------------------------------" << endl;
461 cout <<
" " <<
fNEvents <<
" events analyzed" << endl;
463 std::map<Int_t, RocStats_t *>::iterator it =
CrateStatsMap.begin();
465 Int_t roc = it->first;
466 struct RocStats *rocstats = it->second;
471 Int_t slot = itt->first;
472 Int_t earlyslips = itt->second;
475 if(earlyslips+lateslips > 0) {
476 cout <<
" " << slot <<
" " << rocstats->
fadcOffsetMap[slot] <<
" " << earlyslips <<
" " << lateslips << endl;
481 Int_t slot = itw->first;
482 Int_t wrongcount = itw->second;
485 cout <<
" " << slot <<
" " << wrongcount << endl;
490 cout <<
"-------------------------------------------------------------------" << endl;
503 cout <<
"Howdy ! We are initializing THcTimeSyncEvtHandler !! name = "<<
fName<<endl;
525 Warning(
Here(
"Init"),
"Sync filtering requested, but bad ROC not specified");
542 cout <<
"THcTimeSyncEvtHandler sync filtering disabled" << endl;
547 Error(
Here(
"SetRewriteFile"),
"Cannot create CODA output file object. "
548 "Something is very wrong." );
552 Error(
Here(
"SetRewriteFile"),
"Cannot open CODA file %s for writing.",ts.
Data());
555 cout <<
"THcTimeSYncEvtHandler writing sync filtered coda file to " << ts <<endl;
575 while(
p++ < bank+banklen) {
576 if((*
p & 0xf8000000) == 0x40000000) {
577 headermask |= (1<<(*
p&0x1f));
578 }
else if ((*
p & 0xf8000000) == 0x80000000) {
579 trailermask |= (1<<(*
p&0x1f));
585 fTdcMask = headermask | trailermask;
591 cout << hex <<
"Header mask " << headermask <<
" Trailer mask " << trailermask << dec << endl;
592 cout <<
"TDC1190 Bank" << endl;
593 for(
Int_t i=0;i<=banklen;i++) {
594 if(i%5 == 0) cout<<endl<<dec<<i<<
": ";
595 cout << hex << setw(10) << bank[i];
winID h TVirtualViewer3D TVirtualGLPainter p
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char filename
Option_t Option_t TPoint TPoint const char GetTextMagnitude GetFillStyle GetLineColor GetLineWidth GetMarkerStyle GetTextAlign GetTextColor GetTextSize void char Point_t Rectangle_t WindowAttributes_t Float_t Float_t Float_t Int_t Int_t UInt_t UInt_t Rectangle_t Int_t Int_t Window_t TString Int_t GCValues_t GetPrimarySelectionOwner GetDisplay GetScreen GetColormap GetNativeEvent const char const char dpyName wid window const char font_name cursor keysym reg const char only_if_exist regb h Point_t winding char text const char depth char const char Int_t count const char ColorStruct_t color const char Pixmap_t Pixmap_t PictureAttributes_t attr const char char ret_data h unsigned char height h offset
ClassImp(VDC::AnalyticTTDConv) using namespace std
virtual Int_t codaClose()
virtual Int_t codaOpen(const char *filename, const char *rw, Int_t mode=1)
Int_t codaWrite(const UInt_t *evbuffer)
virtual const char * Here(const char *) const
const UInt_t * GetRawDataBuffer() const
UInt_t GetEvLength() const
std::vector< UInt_t > eventtypes
virtual Bool_t IsMyEvent(UInt_t type) const
std::ofstream * fDebugFile
Event handler to check TI and FADC synchronization.
std::map< Int_t, Int_t > ExpectedOffsetMap
virtual Int_t SetRewriteFile(const char *filename)
virtual void PrintStats()
struct THcTimeSyncEvtHandler::RocStats RocStats_t
virtual Int_t Analyze(THaEvData *evdata)
Decoder::THaCodaFile * fCodaOut
struct THcTimeSyncEvtHandler::RocTimes RocTimes_t
virtual Int_t AllTdcsPresent(UInt_t *bank)
std::map< Int_t, RocStats_t * > CrateStatsMap
virtual ~THcTimeSyncEvtHandler()
virtual void AccumulateStats(Bool_t sync)
std::map< Int_t, RocTimes_t * > CrateTimeMap
virtual void SetExpectedOffset(Int_t roc, Int_t offset)
virtual Int_t End(THaRunBase *r=0)
Int_t fBadSyncSizeTrigger
THcTimeSyncEvtHandler(const char *name, const char *description)
virtual void AddExpectedOffset(Int_t roc, Int_t offset)
virtual void Warning(const char *method, const char *msgfmt,...) const
virtual void Error(const char *method, const char *msgfmt,...) const
const char * Data() const
std::map< Int_t, Int_t > fadcLateSlipCountMap
std::map< Int_t, Int_t > ftdcEvCountOffsetMap
std::map< Int_t, Int_t > ftdcEvCountWrongMap
std::map< Int_t, Int_t > fadcEarlySlipCountMap
std::map< Int_t, Int_t > fadcOffsetMap
std::map< Int_t, UInt_t > fadcTimesMap
std::map< Int_t, UInt_t > ftdcEvCountMap