487 Warn(
"Current control in progress, but last received temperature older than 5min... switching voltage off.");
507 static const array<int, 14> inner0 =
509 62, 63, 130, 131, 132, 133, 134,
510 135, 222, 223, 292, 293, 294, 295,
513 static const array<int, 23> inner1 =
515 58, 59, 60, 61, 129, 138, 139, 140, 141, 142, 143, 218,
516 219, 220, 221, 290, 291, 298, 299, 300, 301, 302, 303,
519 static const array<int, 43> inner2 =
521 42, 43, 44, 45, 55, 56, 57, 70, 71, 78, 79,
522 96, 97, 98, 99, 102, 103, 128, 136, 137, 159, 202,
523 203, 204, 205, 214, 216, 217, 228, 230, 231, 256, 257,
524 258, 259, 262, 263, 288, 289, 296, 297, 310, 318
532 double avg[2] = { 0, 0 };
533 double min[2] = { 90, 90 };
534 double max[2] = { -90, -90 };
535 int num[3] = { 0, 0, 0 };
537 vector<double> med[3];
555 dim_data() { memset(
this, 0,
sizeof(dim_data)); }
558 int Ndev[3] = { 0, 0, 0 };
562 data.Unom = voltageoffset;
575 for (
int i=0;
i<320;
i++)
584 (
fMoonMode>0 && std::find(inner0.begin(), inner0.end(),
i)!=inner0.end()) ||
585 (
fMoonMode>1 && std::find(inner1.begin(), inner1.end(),
i)!=inner1.end()) ||
586 (
fMoonMode>2 && std::find(inner2.begin(), inner2.end(),
i)!=inner2.end()) ||
590 const int N = hv.
count();
595 const double adc = Imes[
i];
604 const double I9 =
fBiasDac[
i] * (1e-3/4096);
608 const double Iout = I8 - I9*100/
fCalibR8[
i];
618 const double R4 = 2000;
621 double R5 = 3900./N + 50;
625 R5 = 1./((N-1)/3900.+1/1000.);
627 R5 = 1./((N-1)/3900.+1/390.);
638 const double R = R4 + R5 + R8;
653 const double Udrp = Iout<0 ? 0 : R*Iout;
657 + (blocked ? -5 : 0);
661 const double Uov = (U9-Udrp)-Uop>-1.4 ? (U9-Udrp)-Uop : -1.4;
665 double Iapd = Iout/N;
716 Uop + voltageoffset + Udrp*exp(0.6*(voltageoffset-Uov))*pow((voltageoffset+1.4), 0.6) :
717 Uop + voltageoffset + Udrp*exp(0.6*(voltageoffset-Uov))*pow((voltageoffset+1.4)/(Uov+1.4), 0.6);
719 if (fabs(voltageoffset-Uov)>0.033)
721 if (fabs(voltageoffset-Uov)>0.022)
723 if (fabs(voltageoffset-Uov)>0.011)
729 const double iapd = Iapd*1e6;
736 const int g = hv.
group();
738 med[g][num[g]] = Uov;
748 data.Irms += iapd*iapd;
750 med[2][num[2]++] = iapd;
753 UdrpRms += Udrp*Udrp;
763 data.Irms -= data.Iavg*data.Iavg;
766 data.Irms = data.Irms<0 ? 0: sqrt(data.Irms);
769 sort(med[2].
data(), med[2].
data()+num[2]);
771 data.Imed = num[2]%2 ? med[2][num[2]/2] : (med[2][num[2]/2-1]+med[2][num[2]/2])/2;
774 for (
int i=0;
i<num[2];
i++)
775 med[2][
i] = fabs(med[2][
i]-data.Imed);
777 sort(med[2].
data(), med[2].
data()+num[2]);
779 data.Idev = med[2][uint32_t(0.682689477208650697*num[2])];
785 const double Uov = (avg[0]+avg[1])/(num[0]+num[1]);
802 float fAbsoluteMedianCurrentLimit = 85;
803 const double deltaU = (Uov+1.4)*(1-pow(fAbsoluteMedianCurrentLimit/data.Imed, 1./1.7));
811 for (
int i=0;
i<320;
i++)
832 UdrpRms -= UdrpAvg*UdrpAvg;
833 UdrpRms = UdrpRms<0 ? 0 : sqrt(UdrpRms);
837 msg << setprecision(2) <<
"dU(" <<
fTemp <<
"degC)=" 839 << UdrpAvg <<
"V+-" << UdrpRms;
840 msg.unsetf(ios_base::floatfield);
843 msg <<
" Unom=" << voltageoffset <<
"V";
847 msg <<
" Uov=" << Uov;
848 msg <<
" Imed=" << data.Imed <<
"uA [N=" << Ndev[0] <<
"/" << Ndev[1] <<
"/" << Ndev[2] <<
"]";
857 msg << setprecision(4) <<
"Current status: dU(" <<
fTemp <<
"degC)=" <<
fTempOffsetAvg <<
"V+-" <<
fTempOffsetRms <<
", Unom=" << voltageoffset <<
"V, Uov=" << (num[0]+num[1]>0?(avg[0]+avg[1])/(num[0]+num[1]):0) <<
" [N=" << Ndev[0] <<
"/" << Ndev[1] <<
"/" << Ndev[2] <<
"]";
874 msg <<
" Avg0=" << setw(7) << avg[0]/num[0] <<
" | Avg1=" << setw(7) << avg[1]/num[1];
878 msg <<
" Med0=" << setw(7) << med[0][num[0]/2] <<
" | Med1=" << setw(7) << med[1][num[1]/2];
882 msg <<
" Min0=" << setw(7) << min[0] <<
" | Min1=" << setw(7) << min[1];
886 msg <<
" Max0=" << setw(7) << max[0] <<
" | Max1=" << setw(7) << max[1];
DimDescribedState fDimBias
int CheckLimits(const float *I)
int GetCurrentState() const
return the current state of the machine
bool CheckEventSize(size_t has, const char *name, size_t size)
int HandleCalibration(const EventImp &evt)
int Debug(const std::string &str)
void setQuality(int quality)
Adds some functionality to boost::posix_time::ptime for our needs.
const int32_t & state() const
vector< double > fTempOffset
vector< int64_t > fCurrentsAvg
vector< float > fCalibDeltaI
pair< vector< float >, vector< float > > AverageCurrents(const int16_t *ptr, int n)
vector< float > fVoltGapd
vector< uint16_t > fBiasDac
void setData(const void *ptr, size_t sz)
virtual Time GetTime() const
static void sendCommandNB(const char *name, int data)
DimDescribedService fDimCurrents
vector< int64_t > fCurrentsRms
void SendCommandNB(const std::string &command)
int Warn(const std::string &str)
vector< double > fVoltOffset
int Info(const std::string &str)
vector< float > fBiasVolt
const T * Ptr(size_t offset=0) const
const PixelMapEntry & hv(int board, int channel) const
virtual size_t GetSize() const