Skip to content
Snippets Groups Projects
Commit aa439648 authored by Whitney Armstrong's avatar Whitney Armstrong
Browse files

Merge branch 'develop' of https://github.com/JeffersonLab/hcana

parents 6102e1c3 803ad821
No related branches found
No related tags found
No related merge requests found
......@@ -241,20 +241,30 @@ The ENGINE CTP support parameter "blocks" which were marked with
// If RunNumber>0 and first line we encounter is not a run range, need to
// print an error
if(RunNumber>0) {
if(line.find_first_not_of("0123456789-")==string::npos) { // Interpret as runnum range
if( (pos=line.find_first_of("-")) != string::npos) {
Int_t RangeStart=atoi(line.substr(0,pos).c_str());
Int_t RangeEnd=atoi(line.substr(pos+1,string::npos).c_str());
if(RunNumber >= RangeStart && RunNumber <= RangeEnd) {
InRunRange = 1;
} else {
if(line.find_first_not_of("0123456789-,")==string::npos) { // Interpret as runnum range
// Interpret line as a list of comma separated run numbers or ranges
TString runnums(line.c_str());
TObjArray *runnumarr = runnums.Tokenize(",");
Int_t nranges=runnumarr->GetLast()+1;
InRunRange = 0;
Int_t ind;
for(Int_t i=0;i<nranges;i++) {
TString runstr = ((TObjString *)runnumarr->At(i))->GetString();
if(runstr.IsDec()) { // A single run number
if(RunNumber == runstr.Atoi()) {
InRunRange = 1;
break;
}
} else { // A single number. Run
if(atoi(line.c_str()) == RunNumber) {
} else if ((ind=runstr.First('-'))>=0) { // A run range
TString start=runstr(0,ind);
TString end=runstr(ind+1,runstr.Length());
if(start.IsDec() && end.IsDec()) {
if((RunNumber >= start.Atoi()) && (RunNumber <= end.Atoi())) {
InRunRange = 1;
} else {
InRunRange = 0;
break;
}
}
}
}
continue; // Skip to next line
......
......@@ -168,9 +168,12 @@ Int_t THcTimeSyncEvtHandler::Analyze(THaEvData *evdata)
if(fSlippage) {
pslippedbank = p-2;
// cout << banklen << " " << pslippedbank[0] << endl;
if(AllTdcsPresent(pslippedbank) && (banklen > fBadSyncSizeTrigger)) {
cout << "Slippage detected at event " << evdata->GetEvNum() << " with size " << banklen << " but not corrected" << endl;
}
} else {
if(banklen > fBadSyncSizeTrigger) {
cout << "Slippage enabled at event " << evdata->GetEvNum() << endl;
if(AllTdcsPresent(p-2) && (banklen > fBadSyncSizeTrigger)) {
cout << "Slippage enabled at event " << evdata->GetEvNum() << " with size " << banklen << endl;
fSlippage = 1;
}
}
......@@ -502,6 +505,7 @@ THaAnalysisObject::EStatus THcTimeSyncEvtHandler::Init(const TDatime& date)
}
fFirstTime = kTRUE;
fFirstTdcCheck = kTRUE;
fMasterRoc = -1;
fNEvents = 0;
CrateTimeMap.clear();
......@@ -544,6 +548,48 @@ Int_t THcTimeSyncEvtHandler::SetRewriteFile(const char *filename) {
}
return(0);
}
Int_t THcTimeSyncEvtHandler::AllTdcsPresent(UInt_t *bank) {
/**
Check that all the 1190 TDCs that should be present are there.
Return codes:
0: All TDCs present
1: TDCs missing at high end of crate
2: TDCs missing at low end of crate
3: Other arrangement of missing
*/
UInt_t headermask=0;
UInt_t trailermask=0;
UInt_t *p=bank;
Int_t banklen = *p;
p++; // Header word
while(p++ < bank+banklen) {
if((*p & 0xf8000000) == 0x40000000) {
headermask |= (1<<(*p&0x1f));
} else if ((*p & 0xf8000000) == 0x80000000) {
trailermask |= (1<<(*p&0x1f));
}
}
if(fFirstTdcCheck) {
fFirstTdcCheck=kFALSE;
fTdcMask = headermask | trailermask;
return(0); // All TDC present by definition
} else {
if((fTdcMask == headermask) && (fTdcMask == trailermask)) {
return(0);
} else {
cout << hex << "Header mask " << headermask << " Trailer mask " << trailermask << dec << endl;
cout << "TDC1190 Bank" << endl;
for(Int_t i=0;i<=banklen;i++) {
if(i%5 == 0) cout<<endl<<dec<<i<<": ";
cout << hex << setw(10) << bank[i];
}
cout << dec << endl;
return(1); // Just return this for now
}
}
}
ClassImp(THcTimeSyncEvtHandler)
......@@ -33,7 +33,7 @@ public:
virtual void SetBadROC(Int_t roc) {fBadROC = roc;}
virtual void SetResync(Bool_t b) {fResync = b;}
virtual void SetBadSyncSizeTrigger(Int_t sizetrigger) {fBadSyncSizeTrigger = sizetrigger;}
virtual Int_t AllTdcsPresent(UInt_t *bank);
private:
virtual void InitStats();
......@@ -51,6 +51,8 @@ private:
Bool_t fResync; // If true, stop correcting events on sync
Int_t fBadSyncSizeTrigger;
Bool_t fLastEventWasSync; // True when last event was sync event
Bool_t fFirstTdcCheck;
UInt_t fTdcMask; // Bit Pattern of TDC in ROC being checked
Decoder::THaCodaFile* fCodaOut; // The CODA output file
Int_t handle;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment