void CrossTimeCorrFunc::correlateFrames(int frame1, int frame2) { Snapshot* snapshot1 = bsMan_->getSnapshot(frame1); Snapshot* snapshot2 = bsMan_->getSnapshot(frame2); assert(snapshot1 && snapshot2); RealType time1 = snapshot1->getTime(); RealType time2 = snapshot2->getTime(); int timeBin = int ((time2 - time1) /deltaTime_ + 0.5); count_[timeBin] += nSelectedPairs_ ; int i; int j; StuntDouble* sd1; StuntDouble* sd2; for (sd1 = seleMan1_.beginSelected(i); sd1 != NULL; sd1 = seleMan1_.nextSelected(i)) { for (sd2 = seleMan2_.beginSelected(j); sd2 != NULL; sd2 = seleMan2_.nextSelected(j)) { RealType corrVal = calcCorrVal(frame1, frame2, sd1, sd2); histogram_[timeBin] += corrVal; } } }
void RCorrFuncZ::correlateFrames(int frame1, int frame2, int timeBin) { std::vector<int> s1; std::vector<int> s2; std::vector<int>::iterator i1; std::vector<int>::iterator i2; RealType corrVal(0.0); s1 = sele1ToIndex_[frame1]; if (uniqueSelections_) s2 = sele2ToIndex_[frame2]; else s2 = sele1ToIndex_[frame2]; for (i1 = s1.begin(), i2 = s2.begin(); i1 != s1.end() && i2 != s2.end(); ++i1, ++i2){ // If the selections are dynamic, they might not have the // same objects in both frames, so we need to roll either of // the selections until we have the same object to // correlate. while ( i1 != s1.end() && *i1 < *i2 ) { ++i1; } while ( i2 != s2.end() && *i2 < *i1 ) { ++i2; } if ( i1 == s1.end() || i2 == s2.end() ) break; corrVal = calcCorrVal(frame1, frame2, i1 - s1.begin(), i2 - s2.begin(), timeBin); } }