#include "AliDCSSensor.h"
-ClassImp(AliDCSSensor)
+ClassImp(AliDCSSensor);
+
+const Double_t kSmall = -9e99; // invalid small value
+const Double_t kLarge = 9e99; // invalid large value
+const Double_t kSecInHour = 3600.; // seconds in one hour
+
AliDCSSensor::AliDCSSensor():
fId(),
fIdDCS(0),
fStartTime(0),
+ fEndTime(0),
fGraph(0),
fFit(0),
fX(0),
fId(source.fId),
fIdDCS(source.fIdDCS),
fStartTime(source.fStartTime),
+ fEndTime(source.fEndTime),
fGraph(source.fGraph),
fFit(source.fFit),
fX(source.fX),
// Get temperature value for actual sensor
// timeSec given as offset from start-of-run measured in seconds
//
- Double_t timeHrs = timeSec/3600.0;
- return fFit->Eval(timeHrs,0);
+ Double_t timeHrs = timeSec/kSecInHour;
+ if (fFit) {
+ return fFit->Eval(timeHrs,0);
+ } else {
+ return kSmall;
+ }
}
//_____________________________________________________________________________
Double_t AliDCSSensor::GetValue(TTimeStamp time)
// Get temperature value for actual sensor
// time given as absolute TTimeStamp
//
- Double_t timeHrs = (time.GetSec() - fStartTime)/3600.0;
- return fFit->Eval(timeHrs,0);
+ Double_t timeHrs = (time.GetSec() - fStartTime)/kSecInHour;
+ if (fFit) {
+ return fFit->Eval(timeHrs,0);
+ } else {
+ return kSmall;
+ }
+}
+
+//_____________________________________________________________________________
+
+Double_t AliDCSSensor::Eval(const TTimeStamp& time) const
+{
+ //
+ // Return temperature at given time
+ // If time < start of map return kSmall
+ // If time > end of map return kLarge
+
+ UInt_t timeSec = time.GetSec();
+ UInt_t diff = timeSec-fStartTime;
+
+ if ( timeSec < fStartTime ) return kSmall;
+ if ( timeSec > fEndTime ) return kLarge;
+
+ Double_t timeHour = diff/kSecInHour;
+ if ( fFit ) {
+ return fFit->Eval(timeHour);
+ } else {
+ return kSmall;
+ }
+}
+
+TGraph* AliDCSSensor::MakeGraph(Int_t nPoints) const
+{
+ //
+ // Make graph from start time to end time of DCS values
+ //
+
+ UInt_t stepTime = (fEndTime-fStartTime)/nPoints;
+
+ if ( !fFit ) return 0;
+
+ Double_t *x = new Double_t[nPoints+1];
+ Double_t *y = new Double_t[nPoints+1];
+ for (Int_t ip=0; ip<nPoints; ip++) {
+ x[ip] = fStartTime+ip*stepTime;
+ y[ip] = fFit->Eval(ip*stepTime/kSecInHour);
+ }
+
+ TGraph *graph = new TGraph(nPoints,x,y);
+ delete [] x;
+ delete [] y;
+
+ graph->GetXaxis()->SetTimeDisplay(1);
+ graph->GetXaxis()->SetLabelOffset(0.02);
+ graph->GetXaxis()->SetTimeFormat("#splitline{%d/%m}{%H:%M}");
+
+ return graph;
}
Double_t GetR() const {return TMath::Sqrt(fX*fX+fY*fY);}
Double_t GetPhi() const {return TMath::ATan2(fY,fX); }
- UInt_t GetStartTime() const {return fStartTime;}
+ UInt_t GetStartTime() const {return fStartTime;}
+ UInt_t GetEndTime() const { return fEndTime; }
TGraph* GetGraph() const {return fGraph; }
AliSplineFit* GetFit() const {return fFit; }
void SetFit (AliSplineFit *f) {fFit = f; }
void SetStartTime (UInt_t stime) {fStartTime = stime; }
void SetStartTime (TTimeStamp time) {fStartTime = time.GetSec(); }
+ void SetEndTime (UInt_t stime) {fEndTime = stime; }
+ void SetEndTime (TTimeStamp time) {fEndTime = time.GetSec(); }
Double_t GetValue(UInt_t timeSec);
Double_t GetValue(TTimeStamp time);
+ Double_t Eval(const TTimeStamp& time) const;
+ TGraph *MakeGraph (Int_t nPoints=100) const;
+
+
// static TClonesArray * ReadList(const char *fname);
// static TClonesArray * ReadListInd(const char *fname,
// Int_t& firstSensor, Int_t& lastSensor);
protected:
Int_t fId; // Internal number of sensor id (array index)
Int_t fIdDCS; // ID number in DCS
- UInt_t fStartTime; // starting time
+ UInt_t fStartTime; // start time for DCS map/fit
+ UInt_t fEndTime; // end time for DCS map/fit
TGraph * fGraph; // graph with values
AliSplineFit *fFit; // fit to graph values
Double_t fX; //X-position of the sensor
Double_t fY; //Y-position of the sensor
Double_t fZ; //Z-position of the sensor
- ClassDef(AliDCSSensor,1);
+ ClassDef(AliDCSSensor,2);
};
#endif
const Int_t kIter = 10; // number of iterations for spline fit
const Double_t kMaxDelta = 0.00; // precision parameter for spline fit
const Int_t kFitReq = 2; // fit requirement, 2 = continuous 2nd derivative
+const Double_t kSecInHour = 3600.; // seconds in one hour
//_____________________________________________________________________________
AliDCSSensorArray::AliDCSSensorArray():TNamed(),
- fFirstSensor(0),
- fLastSensor(0),
fStartTime (2000,1,1,0,0,0),
fEndTime (2000,1,1,0,0,0),
fSensors(0)
//_____________________________________________________________________________
AliDCSSensorArray::AliDCSSensorArray(Int_t prevRun, const char* dbEntry) :
TNamed(),
- fFirstSensor(0),
- fLastSensor(0),
fStartTime (2000,1,1,0,0,0),
fEndTime (2000,1,1,0,0,0),
fSensors(0)
//_____________________________________________________________________________
AliDCSSensorArray::AliDCSSensorArray(const AliDCSSensorArray &c):TNamed(c),
- fFirstSensor(c.fFirstSensor),
- fLastSensor(c.fLastSensor),
fStartTime (c.fStartTime),
fEndTime (c.fEndTime),
fSensors(0)
}
}
//_____________________________________________________________________________
-void AliDCSSensorArray::MakeSplineFit(TMap *map, const char *amandaString)
+void AliDCSSensorArray::MakeSplineFit(TMap *map, const char *amandaString,
+ Bool_t keepMap)
{
//
// Make spline fits from DCS maps
fit->InitKnots(gr,kMinPoints,kIter,kMaxDelta);
fit->SplineFit(kFitReq);
entry->SetStartTime(fStartTime);
+ entry->SetEndTime(fEndTime);
fit->Cleanup();
entry->SetFit(fit);
+ if (keepMap) entry->SetGraph(gr);
}
}
}
skipped=0;
if (val->GetTimeStamp()-time0>1000000) continue;
- x[out] = (val->GetTimeStamp()-time0)/3600.0; // give times in fractions of hours
+ x[out] = (val->GetTimeStamp()-time0)/kSecInHour; // give times in fractions of hours
y[out] = val->GetFloat();
out++;
return 0;
}
}
+
+AliDCSSensor* AliDCSSensorArray::GetSensorNum(Int_t ind)
+{
+ //
+ // Return sensor given by array index
+ //
+ return (AliDCSSensor*)fSensors->At(ind);
+}
+
+Int_t AliDCSSensorArray::GetFirstIdDCS() const
+{
+ //
+ // Return DCS Id of first sensor
+ //
+ if ( fSensors != 0 ) {
+ return ((AliDCSSensor*)fSensors->At(0))->GetIdDCS();
+ } else {
+ return 0;
+ }
+}
+
+Int_t AliDCSSensorArray::GetLastIdDCS() const
+{
+ //
+ // Return DCS Id of last sensor
+ //
+ if ( fSensors != 0 ) {
+ Int_t last = fSensors->GetEntries();
+ return ((AliDCSSensor*)fSensors->At(last-1))->GetIdDCS();
+ } else {
+ return 0;
+ }
+}
TTimeStamp GetStartTime () const { return fStartTime; }
TTimeStamp GetEndTime () const { return fEndTime; }
void SetGraph (TMap *map, const char* amandaString);
- void MakeSplineFit(TMap *map, const char* amandaString);
+ void MakeSplineFit(TMap *map, const char* amandaString, Bool_t keepMap=kFALSE);
TMap* ExtractDCS (TMap *dcsMap, const char* amandaString);
TGraph* MakeGraph (TObjArray *valueSet);
Double_t GetValue (UInt_t timeSec, Int_t sensor);
AliDCSSensor* GetSensor (Int_t IdDCS);
AliDCSSensor* GetSensor (Double_t x, Double_t y, Double_t z);
+ AliDCSSensor* GetSensorNum (Int_t ind);
+ Int_t NumSensors() const { return fSensors->GetEntries(); }
+
+ Int_t GetFirstIdDCS() const;
+ Int_t GetLastIdDCS() const;
protected:
- Int_t fFirstSensor; // DCS ID of first sensor
- Int_t fLastSensor; // DCS ID of last sensor
TTimeStamp fStartTime; // start time for measurements in this entry
TTimeStamp fEndTime; // end time for measurements in this entry
TClonesArray *fSensors; // Array of sensors
- ClassDef(AliDCSSensorArray,1) // TPC calibration class for parameters which are saved per pad
+ ClassDef(AliDCSSensorArray,2) // TPC calibration class for parameters which are saved per pad
};