#include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include extern eventNode *ev; bool erpFilter=true, lipFilter=true, citFilter=true; bool fmtFilter=true, hipFilter=true, wfdFilter=true; bool wfdCheck_histo=false; //external functions in wfdLibrary.cc extern unsigned int citWfdMap(int SM, int BIT); extern unsigned int lipWfdMap(int SM, int BIT); extern unsigned int cspamWfdMap(int SM, int channel); extern unsigned int getWfdAddress(short calmodbox); // forward declarations void fillLipList(compList& lipList); void fillCitList(compList& citList); void fillErpList(compList& erpList); void fillCspamLists(compList& hipList,compList& fmtList); void fillWfdList(compList& wfdList); wfdCheckEvent() { compList wfdList,erpList,citList,hipList,fmtList,lipList; fillLipList(lipList); fillCitList(citList); fillErpList(erpList); fillWfdList(wfdList); fillCspamLists(hipList,fmtList); if(dash_pri_lev_()==2) { cout << hex; cout << "Erp List" << endl; erpList.print(cout); cout << "Lip List" << endl; lipList.print(cout); cout << "Cit List" << endl; citList.print(cout); cout << "Hip List" << endl; hipList.print(cout); cout << "FMT List" << endl; fmtList.print(cout); cout << "WFD List" << endl; wfdList.print(cout); cout << dec; } compList allList; allList.exAppend(erpList); allList.exAppend(citList); allList.exAppend(hipList); allList.exAppend(fmtList); allList.exAppend(lipList); compList wfdExtra, erpMiss, citMiss, hipMiss, fmtMiss, lipMiss; wfdList.diff(allList,wfdExtra); // store wfd banks in wfd child // that weren't asked for to wfdExtra erpList.diff(wfdList,erpMiss); lipList.diff(wfdList,lipMiss); citList.diff(wfdList,citMiss); hipList.diff(wfdList,hipMiss); fmtList.diff(wfdList,fmtMiss); int erpSize=erpMiss.size(); int lipSize=lipMiss.size(); int citSize=citMiss.size(); int fmtSize=fmtMiss.size(); int hipSize=hipMiss.size(); int wfdSize=wfdExtra.size(); dash_pass_evt_(); if(erpSize!=0 && erpFilter) { dash_fail_evt_(); if(dash_pri_lev_()>0) { cout << "ERP WFD channels missing from readout" << hex << endl; erpMiss.print(cout); cout << dec << endl; } } if(citSize!=0 && citFilter) { dash_fail_evt_(); if(dash_pri_lev_()>0) { cout << "CIT WFD channels missing from readout" << hex << endl; citMiss.print(cout); cout << dec << endl; } } if(lipSize!=0 && lipFilter) { dash_fail_evt_(); if(dash_pri_lev_()>0) { cout << "LIP WFD channels missing from readout" << hex << endl; lipMiss.print(cout); cout << dec << endl; } } if(fmtSize!=0 && fmtFilter) { dash_fail_evt_(); if(dash_pri_lev_()>0) { cout << "FMT WFD channels missing from readout" << hex << endl; fmtMiss.print(cout); cout << dec << endl; } } if(hipSize!=0 && hipFilter) { dash_fail_evt_(); if(dash_pri_lev_()>0) { cout << "HIP WFD channels missing from readout" << hex << endl; hipMiss.print(cout); cout << dec << endl; } } if(wfdSize!=0 && wfdFilter) { dash_fail_evt_(); if(dash_pri_lev_()>0) { cout << "Extra WFD channels in readout" << hex << endl; wfdExtra.print(cout); cout << dec << endl; } } if(wfdCheck_histo) { int i; for(i=0; inumChildren(lipType)!=0) { F_getChild(ev,lipBank,0); } else { return; } int SM; int WORD; int BIT; for(SM=0; SM<6; SM++) { for(WORD=0; WORD<5; WORD++) { BitString planePattern=shorttoBitString(lipBank->pattern[SM][WORD]); for(BIT=0; BIT<16; BIT++) { if(planePattern.test(BIT) && !((BIT==7||BIT==15)&&(WORD==3||WORD==4))) { unsigned int wfdAddress = lipWfdMap(SM, WORD*16+BIT); if(wfdAddress!=0) { lipList.exAppend(wfdAddress); lipList.exAppend(wfdAddress + 0x10000); } } } } } } void fillCitList(compList& citList) { citNode* citBank; if(ev->numChildren(citType)!=0) { F_getChild(ev,citBank,0); } else { return; } int SM; int WORD; int BIT; for(SM=0; SM<6; SM++) { for(WORD=0; WORD<3; WORD++) { BitString citString=shorttoBitString(citBank->trigger[SM][WORD]); for(BIT=0; BIT<16; BIT++) { if(citString.test(BIT)) { unsigned int wfdAddress = citWfdMap(SM,WORD*16+BIT); if(wfdAddress!=0) { citList.exAppend((int) (wfdAddress)); citList.exAppend((int) (wfdAddress + 0x10000)); } } } } } } void fillErpList(compList& erpList) { erpNode* erpBank; int i; for(i=0; inumChildren(erpType); i++) { F_getChild(ev,erpBank,i); unsigned int wfdAddress = getWfdAddress(erpBank->boxnum); if(wfdAddress!=0) { erpList.exAppend((int) (wfdAddress)); erpList.exAppend((int) (wfdAddress + 0x10000)); } } } void fillWfdList(compList& wfdList) { vmeWfdNode* wfdBank; int i; for(i=0; inumChildren(vmeWfdType); i++) { F_getChild(ev,wfdBank,i); wfdList.exAppend((int)(wfdBank->chanAddr)); // wfdList.exAppend((int)(wfdBank->chanAddr + 0x10000)); } } void fillCspamLists(compList& hipList,compList& fmtList) { cspamNode* cspamBank; trigNode* trigBank; bool fmtTrig[3],hipTrig[3]; if(ev->numChildren(trigType)==0) { cout << "Can't decode CSPAM without trigger node" << endl; return; } F_getChild(ev,trigBank,0); if(ev->numChildren(cspamType)==0) { return; } F_getChild(ev,cspamBank,0); // find out where the fmt and hipt triggers are BitString t1=shorttoBitString(trigBank->trig[0]); BitString t2=shorttoBitString(trigBank->trig[1]); BitString t3=shorttoBitString(trigBank->trig[2]); fmtTrig[0]=t1.test(11); //fmt is trigger number 12 fmtTrig[1]=t2.test(11); fmtTrig[2]=t3.test(11); hipTrig[0]=t1.test(13); //hipt is trigger number 14 hipTrig[1]=t2.test(13); hipTrig[2]=t3.test(13); // if there are no hip or fmt triggers, bail if(!(fmtTrig[0] || fmtTrig[1] || fmtTrig[2] || hipTrig[0] || hipTrig[1] || hipTrig[2])) return; // the rest is a snap int mVax; unsigned int wfdAddress; for (mVax=0; mVax<3; mVax++) { if(fmtTrig[mVax]) { // fmt triggers are low threshold so readout the lows. int bit; for(bit=0; bit<11; bit++) { if(cspamBank->patternLo1[2*mVax].test(bit) || cspamBank->patternLo0[2*mVax].test(bit)) { wfdAddress=cspamWfdMap(2*mVax,bit); if(wfdAddress!=0) { fmtList.exAppend(wfdAddress); fmtList.exAppend(wfdAddress+0x10000); fmtList.exAppend(wfdAddress+0x20000); fmtList.exAppend(wfdAddress+0x30000); } } if(cspamBank->patternLo1[2*mVax+1].test(bit) || cspamBank->patternLo0[2*mVax+1].test(bit)) { // fmt is low threshold (vetoed by the cspam) wfdAddress=cspamWfdMap(2*mVax+1,bit); if(wfdAddress!=0) { fmtList.exAppend(wfdAddress); fmtList.exAppend(wfdAddress+0x10000); fmtList.exAppend(wfdAddress+0x20000); fmtList.exAppend(wfdAddress+0x30000); } } } } if(hipTrig[mVax]) { int bit; for(bit=0; bit < 11; bit++) { if(cspamBank->patternHi1[2*mVax].test(bit) || cspamBank->patternHi0[2*mVax].test(bit)) { // hipt is high threshold wfdAddress=cspamWfdMap(2*mVax,bit); hipList.exAppend(wfdAddress); hipList.exAppend(wfdAddress+0x10000); hipList.exAppend(wfdAddress+0x20000); hipList.exAppend(wfdAddress+0x30000); } if(cspamBank->patternHi1[2*mVax+1].test(bit) || cspamBank->patternHi0[2*mVax+1].test(bit)) { // hipt is high threshold wfdAddress=cspamWfdMap(2*mVax+1,bit); hipList.exAppend(wfdAddress); hipList.exAppend(wfdAddress+0x10000); hipList.exAppend(wfdAddress+0x20000); hipList.exAppend(wfdAddress+0x30000); } } } } }