void DelayDetection::process(SFLDataFormat *inputData, int nbSamples) { if (internalState_ != WaitForMic) return; if ((nbMicSampleStored_ + nbSamples) > DELAY_BUFF_SIZE) nbSamples = DELAY_BUFF_SIZE - nbMicSampleStored_; if (nbSamples) { float tmp[nbSamples]; float down[nbSamples]; convertInt16ToFloat32(inputData, tmp, nbSamples); memcpy(capturedData_ + nbMicSampleStored_, tmp, nbSamples); downsampleData(tmp, down, nbSamples, downsamplingFactor_); memcpy(captureDataDown_ + (nbMicSampleStored_ / downsamplingFactor_), down, (nbSamples / downsamplingFactor_) * sizeof(float)); nbMicSampleStored_ += nbSamples; } if (nbMicSampleStored_ == DELAY_BUFF_SIZE) internalState_ = ComputeCorrelation; else return; crossCorrelate(spkrReferenceDown_, captureDataDown_, correlationResult_, micDownSize_, spkrDownSize_); }
PivPointData PivEngine::velocity(int topLeftRow, int topLeftColumn) { PivPointData pointData; if (crossCorrelate(topLeftRow, topLeftColumn)) { switch (_detector) { case OpenPIV::GaussianSubPixel: pointData = gaussianSubPixel(_cmap,_intLengthX,_intLengthY); break; default: break; } } else { pointData.u = 0.0; pointData.v = 0.0; pointData.snr = 0.0; } pointData.filtered = false; pointData.x = topLeftColumn; pointData.y = topLeftRow; return pointData; }
void startCorrelation(int run,int eventNumber){ //int entry=65000; char runRootDirectory[FILENAME_MAX]; sprintf(runRootDirectory,"/unix/anita3/flight0809/root/"); char headName[FILENAME_MAX]; char eventName[FILENAME_MAX]; char gpsName[FILENAME_MAX]; RawAnitaEvent *evPtr = 0; RawAnitaHeader *hdPtr = 0; Adu5Pat *patPtr =0; sprintf(headName,"%s/run%d/headFile%d.root",runRootDirectory,run,run); sprintf(eventName,"%s/run%d/eventFile%d.root",runRootDirectory,run,run); sprintf(gpsName,"%s/run%d/gpsFile%d.root",runRootDirectory,run,run); TFile *eventFile = new TFile(eventName); TFile *headFile = new TFile(headName); TFile *fpGps = new TFile(gpsName); if(!fpGps){ std::cout << "no GPS file\n"; return; } TTree *adu5PatTree = (TTree*) fpGps->Get("adu5PatTree"); TTree *eventTree = (TTree*)eventFile->Get("eventTree"); TTree *headTree = (TTree*)headFile->Get("headTree"); eventTree->SetBranchAddress("event",&evPtr); headTree->SetBranchAddress("header",&hdPtr); headTree->BuildIndex("eventNumber"); adu5PatTree->SetBranchAddress("pat",&patPtr); adu5PatTree->BuildIndex("realTime"); int entry=headTree->GetEntryNumberWithBestIndex(eventNumber); eventTree->GetEntry(entry); headTree->GetEntry(entry); /* //for(int phi=0;phi<16;phi++){ while(hdPtr->triggerTimeNs<349.99e6 || hdPtr->triggerTimeNs>350.005e6 || hdPtr->l3TrigPattern==0){ if(lastEvent==hdPtr->eventNumber){ std::cout << "no more entries in run" << std::endl; return; } std::cout << "opened entry " << entry << " (event " << hdPtr->eventNumber << ") with triggerTimeNs " << hdPtr->triggerTimeNs << std::endl; lastEvent=hdPtr->eventNumber; entry++; eventTree->GetEntry(entry); headTree->GetEntry(entry); adu5PatTree->GetEntry(entry); } //} */ std::cout << "opened entry " << entry << " (event " << hdPtr->eventNumber << ") with triggerTimeNs " << hdPtr->triggerTimeNs << std::endl; //get the pat ptr that corresponds to the timing of the event Int_t patEntry; patEntry = adu5PatTree->GetEntryNumberWithBestIndex(hdPtr->realTime); adu5PatTree->GetEntry(patEntry); std::cout << patPtr->realTime << " " << hdPtr->realTime << std::endl; if(patPtr->realTime != hdPtr->realTime){ std:: cout << "pat time doesn't match head time, pat realTime: " << patPtr->realTime << " head realTime: " << hdPtr->realTime << std::endl; //return; } for(int chan=0;chan<90;chan++){ if(evPtr->xMax[chan]>130 || evPtr->xMin[chan]<-130){ saturatedChannel[chan]=1; std::cout << "saturated " << chan << std::endl; } else saturatedChannel[chan]=0; } //entry++; TH2D *crossCorrelation = crossCorrelate(evPtr,hdPtr,patPtr); sprintf(headName,"crossCorrCan"); TCanvas *crossCorrCan = (TCanvas*)gROOT->FindObject(headName); if(!crossCorrCan) crossCorrCan = new TCanvas(headName,headName,800,400); crossCorrCan->Clear(); //sumCrossCorrs->Draw("aitoff"); crossCorrelation->Draw("colz"); TAxis *phiSectors = new TAxis(16,1,16); phiSectors->Draw(); //std::cout << "event " << hdPtr->eventNumber << " time " << double theta,phi; getSignalDirection(crossCorrelation,phi,theta); std::cout << "phi " << phi << " theta " << theta << std::endl; plotAnitaEventMap(patPtr,phi,theta); }