source: Sophya/trunk/Poubelle/archTOI.old/toiboloproducer.cc@ 623

Last change on this file since 623 was 612, checked in by ansari, 26 years ago

fin de fichier, start

File size: 2.2 KB
RevLine 
[534]1// toiboloproducer.cc
2// Eric Aubourg CEA/DAPNIA/SPP septembre 1999
3
4#include "toiboloproducer.h"
5#include "archexc.h"
6#include "requesthandler.h"
[612]7#include "polfitclip.h"
[534]8
[612]9#define boloMuV "boloMuV"
[534]10
11
12TOIBoloProducer::TOIBoloProducer() {
[612]13 possibleTOIs.insert(TOI(boloMuV, TOI::all, "linfilt sqfilt", "microVolts"));
[534]14}
15
[612]16// No option == linfilt
17
[534]18string TOIBoloProducer::getName() {
[612]19 return("TOIBoloProducer 1.1");
[534]20}
21
[612]22int TOIBoloProducer::filtHalfRange = 20;
[534]23
[612]24
[534]25void TOIBoloProducer::dataFeed(TOIProducer* source, TOI const& toi, long sampleNum, double value) {
26 if (source->canGetValue(sampleNum-1, toi)) {
27 value = (value + source->getValue(sampleNum-1, toi))/2.;
[612]28
29 //TOI toi2 = toi;
30 //toi2.name = boloMuV;
31
32 TOI toi2(boloMuV, toi.index, "sqfilt", toi.unit);
[534]33 computedValue(toi2, sampleNum, value);
34 }
[612]35
36 // $CHECK$ possible optimization : keep fit for several successive values
37
38 if (source->canGetValue(sampleNum-2*filtHalfRange, toi)) {
39 PolFitClip fit(2*filtHalfRange,1);
40 int s = sampleNum % 2 ? 1 : -1;
41 for (int i=0; i<2*filtHalfRange-1; i++) {
42 fit.addData(sampleNum - i,
43 s*(source->getValue(sampleNum - i, toi) - source->getValue(sampleNum - i -1, toi))/2);
44 s = -s;
45 }
46 fit.doFit();
47 double y = source->getValue(sampleNum - filtHalfRange, toi);
48 s = sampleNum % 2 ? 1 : -1;
49 y =y - s*fit.value(sampleNum - filtHalfRange);
50 TOI toi2(boloMuV, toi.index, "linfilt", toi.unit);
51 if (isProducing(toi2))
52 computedValue(toi2, sampleNum - filtHalfRange, y);
53 TOI toi3(boloMuV, toi.index, "", toi.unit);
54 if (isProducing(toi3))
55 computedValue(toi3, sampleNum - filtHalfRange, y);
56 }
[534]57}
58
59set<TOI> TOIBoloProducer::reqTOIFor(TOI const& toi) {
60 set<TOI> t;
[612]61 if (toi.name == boloMuV) {
62 TOI toi2("boloRawMuV", toi.index);
63 //toi2.name = "boloRawMuV";
[534]64 t.insert(toi2);
65 } else {
66 throw ArchExc("Cannot produce "+toi.name);
67 }
68 return t;
69}
70
71
72void TOIBoloProducer::propagateLowBound(TOI const& toi, long sampleNum) {
73 CHKPROD
[555]74 map<TOI, TOIProducer*> & need = neededTOIs[toi];
[534]75 int hlen = 1;
76 for (map<TOI, TOIProducer*>::iterator i = need.begin(); i != need.end(); i++) {
77 (*i).second->wontNeedEarlier((*i).first, this, sampleNum-hlen);
78 }
79}
80
81
82
Note: See TracBrowser for help on using the repository browser.