/*************************************************************************** BocScanAnalysis - description ------------------- begin : Sun, 7 Dec 2005 author : Iris Rottlaender email : rottlaen@physik.uni-bonn.de *************************************************************************/ #include "BocScanAnalysis.h" void BocScanAnalysisResults::DumpResults() { if(seenError == false) { cout<<"+++ NO ERRORS FOUND - YOU CAN CHOOSE ANY PARAMETER SETTING. +++"<-1) cout<<" "<1)) { for(int zz = 0; zz1)) { for(int zz = 0; zz1)) { for(int yy = 0; yy1) { if(Z.pacman) { if(matrix[xx][yy][(zz+1)%Z.Bins]<0) { matrix[xx][yy][(zz+1)%Z.Bins] = distance; written = true; } int index; if ((zz-1)<0) index = Z.Bins-1; else index = zz-1; if(matrix[xx][yy][index]<0) { matrix[xx][yy][index] = distance; written = true; } } else { if(((zz+1)=0)&&(matrix[xx][yy][zz-1]<0)) { matrix[xx][yy][zz-1] = distance; written = true; } } } if(Y.Bins > 1) { if(Y.pacman) { if(matrix[xx][(yy+1)%Y.Bins][zz]<0) { matrix[xx][(yy+1)%Y.Bins][zz] = distance; written = true; } int index; if ((yy-1)<0) index = Y.Bins-1; else index = yy-1; if(matrix[xx][index][zz]<0) { matrix[xx][index][zz] = distance; written = true; } } else { if(((yy+1)=0)&&(matrix[xx][yy-1][zz]<0)) { matrix[xx][yy-1][zz] = distance; written = true; } } } if(X.Bins > 1) { if(X.pacman){ if(matrix[(xx+1)%X.Bins][yy][zz]<0) { matrix[(xx+1)%X.Bins][yy][zz] = distance; written=true; } int index; if ((xx-1)<0) index = X.Bins-1; else index = xx-1; if(matrix[index][yy][zz]<0) { matrix[index][yy][zz]=distance; written = true; } } else { if(((xx+1)=0)&&(matrix[xx-1][yy][zz]<0)) { matrix[xx-1][yy][zz] = distance; written = true; } } } } } } } } int maxdistance; BocScanAnalysisResults results; if(written) maxdistance = distance; else maxdistance = distance-1; results.maxdist = maxdistance; if(maxdistance >0) { for(int zz = 0; zz tmpvec; tmpvec = results.bestX; results.bestX = results.bestY; results.bestY = tmpvec; } // if the Rx-Threshold is one of the scanned parameters: look if the upmost scanned value for the threshold // shows only errors or also good regions. if only errors, the upper threshold is presumably visible in the scan, se t seeUpperThreshold accordingly. results.seeUpperThreshold = false; for(int i =0; i<3; i++) { if (results.param[i]=="BOC_RX_THR") { results.seeUpperThreshold = true; int starthelp[3] = {0,0,0}; starthelp[i] = Dim[i].Bins-1; for(int zz = starthelp[2]; zzDim[1].Bins) { RefineResults(&(results.bestX), &(results.modmaxdistX), &(results.bestY), &(results.modmaxdistY), Dim[0] ); RefineResults(&(results.bestY), &(results.modmaxdistY), &(results.bestX), &(results.modmaxdistX), Dim[1] ); } else { RefineResults(&(results.bestY), &(results.modmaxdistY), &(results.bestX), &(results.modmaxdistX), Dim[1] ); RefineResults(&(results.bestX), &(results.modmaxdistX), &(results.bestY), &(results.modmaxdistY), Dim[0] ); } } // shiftResults(&results); return results; } int BocScanAnalysis::InitializeAnalysis(PixDBData DataObj) { nevents = DataObj.getNevents(); Config &scanconf = DataObj.getScanConfig(); ConfList & outList0 = (ConfList&)scanconf["loops"]["paramLoop_0"]; Dim[0].ParamLoop = outList0.sValue(); cout<<"ParamLoop0 "<getMccBandwidth(); if (outlink[0] < 0) { if (outSpeed == "SINGLE_40" || outSpeed == "DOUBLE_40") { outlink[0] = fmtOff1[ol[0]/16] + ol[0]%16; } else { outlink[0] = fmtOff2[ol[0]/16] + (ol[0]%16)/2; } } if (outlink[1] < 0) { if (outSpeed == "SINGLE_40" || outSpeed == "DOUBLE_40") { outlink[1] = fmtOff1[ol[1]/16] + ol[1]%16; } else { outlink[1] = fmtOff2[ol[2]/16] + (ol[2]%16)/2; } } if (outSpeed == "SINGLE_40" || outSpeed == "SINGLE_80") { outlink[1] = -1; } cout<<"Boc Inlink "<= Dim[i].minpos) Dim[i].pacman=false; } } return 0; }; // looks for connected sequences in Longparam with equal values vor Shortparam. // optimizes results in a way that only the middle values of sequences are kept void BocScanAnalysis::RefineResults(vector* longParam, vector* longMaxDist, vector* shortParam, vector* shortMaxDist, ScanSpecs longSpecs) { vector tmpveclong; vector maxdistdiff; vector tmpvecshort; list tmplist; vector origVecLong = *(longParam); vector origVecShort = *(shortParam); tmplist.clear(); while(!origVecShort.empty()) { int param = origVecShort.at(0); // before RefineResults-Algorithm, modmaxdist should be the same for all cases. tmplist.clear(); for(unsigned int i = 0; i-1; i--) { if(origVecShort.at(i)==param) { vector::iterator tmpIt2 = origVecLong.begin(); vector::iterator tmpIt = origVecShort.begin(); for(int j = 1; j::iterator endIT2 = tmplist.end(); endIT2 --; if(*(tmplist.begin())==(((int)(*(endIT2)+ longSpecs.BinWidth))%(int)longSpecs.maxpos)) { tmplist.push_front(*endIT2); tmplist.pop_back(); counter2++; } else break; } } while(!tmplist.empty()) { // for( list::iterator listIt = tmplist.begin(); listIt !=tmplist.end(); listIt++) // { // cout<<(*listIt)<::iterator endIT = tmplist.end(); endIT --; for( list::iterator listIt = tmplist.begin(); listIt != endIT; listIt++) { list::iterator nextIt = listIt; nextIt++; if(longSpecs.pacman) { if( (((int)((*listIt)+longSpecs.BinWidth))%(int)longSpecs.maxpos) == *(nextIt)) counter++; else break; } else { if((*listIt)+longSpecs.BinWidth == *(nextIt)) counter++; else break; } } for(int j =0; j counter uneven if(!(counter%2==0)) { tmpveclong.push_back(*(tmplist.begin())); maxdistdiff.push_back(counter/2); tmpvecshort.push_back(param); } for(int j =counter/2+1; jsize()-1; i>-1; i--) { bool keep = false; int maxdiff = 0; for(unsigned int j =0; jat(i)) { if(tmpvecshort.at(j)==shortParam->at(i)) { keep=true; maxdiff=maxdistdiff.at(j); break; } } } // delete unwanted values if(keep==false) { vector::iterator tmpIt = shortParam->begin(); vector::iterator tmpIt2 = longParam->begin(); vector::iterator tmpIt3 = shortMaxDist->begin(); vector::iterator tmpIt4 = longMaxDist->begin(); for(int j = 1; jerase(tmpIt); longParam->erase(tmpIt2); shortMaxDist->erase(tmpIt3); longMaxDist->erase(tmpIt4); } // otherwise modify modmaxdist else { longMaxDist->at(i) += maxdiff; } } /* cout<<"shortParam:"<size(); z++) cout<at(z)<<" | "; cout<size(); z++) cout<at(z)<<" | "; cout<size(); z++) cout<at(z)<<" | "; cout<size(); z++) cout<at(z)<<" | "; cout<* DelayVec=0; vector* DelayDist=0; vector* ThresholdVec=0; vector* ThresholdDist=0; float BinWidth_Delay; float BinWidth_Threshold; if(results->param[0]=="BOC_RX_DELAY") { DelayVec=&(results->bestX); DelayDist=&(results->modmaxdistX); BinWidth_Delay = Dim[0].BinWidth; } else if(results->param[1]=="BOC_RX_DELAY") { DelayVec=&(results->bestY); DelayDist=&(results->modmaxdistY); BinWidth_Delay = Dim[1].BinWidth; } else if(results->param[2]=="BOC_RX_DELAY") { DelayVec=&(results->bestZ); DelayDist=&(results->modmaxdistZ); BinWidth_Delay = Dim[2].BinWidth; } if(results->param[0]=="BOC_RX_THR") { ThresholdVec=&(results->bestX); ThresholdDist=&(results->modmaxdistX); BinWidth_Threshold = Dim[0].BinWidth; } else if(results->param[1]=="BOC_RX_THR") { ThresholdVec=&(results->bestY); ThresholdDist=&(results->modmaxdistY); BinWidth_Threshold = Dim[1].BinWidth; } else if(results->param[2]=="BOC_RX_THR") { ThresholdVec=&(results->bestZ); ThresholdDist=&(results->modmaxdistZ); BinWidth_Threshold = Dim[2].BinWidth; } if(DelayVec!=0) { cout<<"Shifting RX-Delay values:"<size(); i++) { cout<<"shifting "<at(i); DelayVec->at(i) -= (int)((DelayDist->at(i)/3)*BinWidth_Delay); // for pacman if(DelayVec->at(i)<0) DelayVec->at(i) = 25+DelayVec->at(i); cout<<" to "<< DelayVec->at(i)<seeUpperThreshold==false)) { cout<<"Shifting RX-Threshold values:"<size(); i++) { cout<<"Shifting "<at(i); ThresholdVec->at(i) += (int)((ThresholdDist->at(i)/3)*BinWidth_Threshold); cout<<" to "<< ThresholdVec->at(i)<