Changeset 555 in Sophya for trunk/Poubelle/archTOI.old/toiproducer.cc
- Timestamp:
- Nov 9, 1999, 3:04:05 PM (26 years ago)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
trunk/Poubelle/archTOI.old/toiproducer.cc
r534 r555 57 57 // should be nothing left 58 58 if (!extraopts.empty()) return false; 59 59 60 60 return true; 61 61 } … … 129 129 130 130 class comp2nd { public:bool operator()(pair<long, double> const& a, long b) {return a.first<b;}}; 131 132 deque<pair<long, double> >::const_iterator TOIProducer::findHist(TOI const& toi,long sampleNum) { 131 class comp2ndI { public:bool operator()(long a, pair<long, double> const& b) {return a<b.first;}}; 132 133 deque<pair<long, double> >::const_iterator TOIProducer::findHistL(TOI const& toi,long sampleNum) { 133 134 CHKPROD 134 135 deque<pair<long, double> >& h = history[toi.ref]; … … 136 137 } 137 138 138 deque<pair<long, double> >::const_iterator TOIProducer::findHist (deque<pair<long, double> >& h,long sampleNum) {139 deque<pair<long, double> >::const_iterator TOIProducer::findHistL(deque<pair<long, double> >& h,long sampleNum) { 139 140 return lower_bound(h.begin(), h.end(), sampleNum, comp2nd()); 140 141 } 142 143 deque<pair<long, double> >::const_iterator TOIProducer::findHistH(TOI const& toi,long sampleNum) { 144 CHKPROD 145 deque<pair<long, double> >& h = history[toi.ref]; 146 return upper_bound(h.begin(), h.end(), sampleNum, comp2ndI()); 147 } 148 149 deque<pair<long, double> >::const_iterator TOIProducer::findHistH(deque<pair<long, double> >& h,long sampleNum) { 150 return upper_bound(h.begin(), h.end(), sampleNum, comp2ndI()); 151 } 152 141 153 142 154 bool TOIProducer::canGetValue(long sampleNum, TOI const& toi) { … … 145 157 if (h.empty()) return false; 146 158 if (sampleNum < h.front().first || sampleNum > h.back().first) return false; 147 deque<pair<long, double> >::const_iterator i = findHist (h, sampleNum);159 deque<pair<long, double> >::const_iterator i = findHistL(h, sampleNum); 148 160 if (i == h.end()) return false; 149 161 return ((*i).first == sampleNum); … … 163 175 deque<pair<long, double> >& h = history[toi.ref]; 164 176 if (h.empty()) return false; 165 return (sampleNum > h. back().first && sampleNum <= h.front().first);177 return (sampleNum > h.front().first && sampleNum <= h.back().first); 166 178 // Must be inside, otherwise we don't know if it is prev or simply past 167 179 } … … 171 183 deque<pair<long, double> >& h = history[toi.ref]; 172 184 if (h.empty()) return false; 173 return (sampleNum >= h. back().first && sampleNum < h.front().first);185 return (sampleNum >= h.front().first && sampleNum < h.back().first); 174 186 } 175 187 … … 179 191 // << h.front().first 180 192 // << " " << h.back().first << endl; 181 deque<pair<long, double> >::const_iterator i = findHist (h, sampleNum);193 deque<pair<long, double> >::const_iterator i = findHistL(h, sampleNum); 182 194 if (i == h.end()) return -999999; 183 195 // cout << "found " << (*i).first << endl; … … 189 201 double TOIProducer::getPrevValue(long& sampleNum, TOI const& toi) { 190 202 deque<pair<long, double> >& h = history[toi.ref]; 191 deque<pair<long, double> >::const_iterator i = findHist (h, sampleNum);203 deque<pair<long, double> >::const_iterator i = findHistH(h, sampleNum); 192 204 if (i == h.end()) return -999999; 193 if ((*i).first == sampleNum) { 205 pair<long, double> tstpair = *i; 206 while ((*i).first >= sampleNum) { 194 207 if (i == history[toi.ref].begin()) {sampleNum = -99999 ;return -9999;} 195 208 i--; 196 209 } 210 tstpair = *i; 197 211 sampleNum = (*i).first; 198 212 return (*i).second; … … 201 215 double TOIProducer::getNextValue(long& sampleNum, TOI const& toi) { 202 216 deque<pair<long, double> >& h = history[toi.ref]; 203 deque<pair<long, double> >::const_iterator i = findHist (h, sampleNum);217 deque<pair<long, double> >::const_iterator i = findHistL(h, sampleNum); 204 218 if (i == h.end()) return -999999; 205 if ((*i).first == sampleNum) { 219 pair<long, double> tstpair = *i; 220 while ((*i).first <= sampleNum) { 206 221 if (i == history[toi.ref].end()) {sampleNum = -99999 ;return -9999;} 207 222 i++; 208 223 } 224 tstpair=*i; 209 225 sampleNum = (*i).first; 210 226 return (*i).second; … … 212 228 213 229 void TOIProducer::computedValue(TOI const& toi, long sampleNum, double value) { 214 map<int, deque<pair<long, double> > >::iterator i = history.find(toi.ref); 215 if (i == history.end()) throw ArchExc("computedValue : bad TOI " + toi.name); 216 deque<pair<long, double> >& h = (*i).second; 230 //map<int, deque<pair<long, double> > >::iterator i = history.find(toi.ref); 231 //if (i == history.end()) throw ArchExc("computedValue : bad TOI " + toi.name); 232 //deque<pair<long, double> >& h = (*i).second; 233 deque<pair<long, double> >& h = history[toi.ref]; 217 234 if (!h.empty() && sampleNum <= h.back().first) 218 235 throw ArchExc("computedValue : sampleNum not in sequence for " + toi.name); 219 236 h.push_back(pair<long,double>(sampleNum,value)); 220 221 237 for (map<TOIAbsorber*, set<TOI> >::iterator j = clients.begin(); j != clients.end(); j++) { 222 238 set<TOI>& tois = (*j).second;
Note:
See TracChangeset
for help on using the changeset viewer.