- Double_t SMTemperature = GetTemperatureSM(iSM, timeStamp);
-
- Double_t TemperatureDiff = ReferenceTemperature - SMTemperature; // old vs new
- // if the new temperature is higher than the old/reference one, then the gain has gone down
- if (fabs(TemperatureDiff)>fTemperatureResolution) {
- // significant enough difference that we need to consider it
+ Double_t oldSMTemperature = dSMTemperature;
+ dSMTemperature = GetTemperatureSM(iSM, timeStamp);
+ if (j>0 && (dSMTemperature==kErrorCode)) {
+ // if we have previous values, and retrieval of values failed - use that instead (hopefully good)
+ dSMTemperature = oldSMTemperature;
+ }
+
+ Double_t temperatureDiff = referenceTemperature - dSMTemperature; // ref - new
+ if (fVerbosity > 0) {
+ cout << " referenceTemperature " << referenceTemperature
+ << " dSMTemperature " << dSMTemperature
+ << " temperatureDiff " << temperatureDiff
+ << endl;
+ }
+ // if the new temperature is higher than the old/reference one (diff<0), then the gain has gone down
+ // if the new temperature is lower than the old/reference one (diff>0), then the gain has gone up
+ // dTempCoeff is a (unsigned) factor describing how many % the gain
+ // changes with a degree change.
+ // i.e. the product temperatureDiff * dTempCoeff increase when the gain goes up
+ // The correction we want to keep is what we should multiply our ADC value with as a function
+ // of time, i.e. the inverse of the gain change..
+ if ( (TMath::Abs(temperatureDiff)>fTemperatureResolution)
+ && (TMath::Abs(temperatureDiff)<fMaxTemperatureDiff) ) {
+ // significant enough difference that we need to consider it, and also not unreasonably large