1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 ////////////////////////////////////////////////////////////////////////////
20 // This class collects the DCS information and does an AliSplineFit //
24 // AliTRDDataDCS dataDcs; //
25 // dataDcs.ExtractDCS(dcs); //
26 // ->call a storeRef function //
27 // dataDcs.PerformFit(); //
28 // dataDcs.ClearGraphs(); //
29 // ->call a store function //
30 // dataDcs.ClearFits(); //
33 // W. Monange (wilfried.monange@free.fr) //
35 ////////////////////////////////////////////////////////////////////////////
38 #include <TObjArray.h>
41 #include "AliDCSValue.h"
42 #include "AliDCSValue.h"
44 #include "AliSplineFit.h"
46 #include "AliTRDDataDCS.h"
48 ClassImp(AliTRDDataDCS)
50 //_____________________________________________________________________________
51 AliTRDDataDCS::AliTRDDataDCS()
53 ,fGraphsAreIni(kFALSE)
58 // Default constructor
65 //_____________________________________________________________________________
66 AliTRDDataDCS::~AliTRDDataDCS()
77 //_____________________________________________________________________________
78 void AliTRDDataDCS::Init()
84 SetConf(kChamberByteStatus, "trd_chamberByteStatus%03d",'c', 540, kTRUE,kFALSE, 10,10,0,2);
85 SetConf(kPreTrigger, "trd_preTrigger", 'c', 1, kTRUE, kTRUE, 10,10,0,2);
86 SetConf(kGoofyHv, "trd_goofyHv", 'f', 1, kTRUE, kTRUE, 10,10,0,2);
87 SetConf(kGoofyPeakPos, "trd_goofyPeakPos%02d", 'f', 2, kTRUE, kTRUE, 10,10,0,2);
88 SetConf(kGoofyPeakArea, "trd_goofyPeakArea%02d", 'f', 2, kTRUE, kTRUE, 10,10,0,2);
89 SetConf(kGoofyTemp, "trd_goofyTemp%02d", 'f', 2, kTRUE, kTRUE, 10,10,0,2);
90 SetConf(kGoofyPressure, "trd_goofyPressure", 'f', 1, kTRUE, kTRUE, 10,10,0,2);
91 SetConf(kGoofyVelocity, "trd_goofyVelocity", 'f', 1, kTRUE, kTRUE, 10,10,0,2);
92 SetConf(kGoofyGain, "trd_goofyGain%02d", 'f', 2, kTRUE, kTRUE, 10,10,0,2);
93 SetConf(kGoofyCO2, "trd_goofyCO2", 'f', 1, kTRUE, kTRUE, 10,10,0,2);
94 SetConf(kGoofyN2, "trd_goofyN2", 'f', 1, kTRUE, kTRUE, 10,10,0,2);
95 SetConf(kGasO2, "trd_gasO2", 'f', 1, kTRUE, kTRUE, 10,10,0,2);
96 SetConf(kGasOverpressure, "trd_gasOverpressure", 'f', 1, kTRUE, kTRUE, 10,10,0,2);
97 SetConf(kEnvTemp, "trd_envTemp%03d", 'f', 540, kTRUE, kTRUE, 10,10,0,2);
98 SetConf(kHvAnodeImon, "trd_hvAnodeImon%03d", 'f', 540, kTRUE, kTRUE, 10,10,0,2);
99 SetConf(kHvDriftImon, "trd_hvDriftImon%03d", 'f', 540, kTRUE, kTRUE, 10,10,0,2);
100 SetConf(kHvAnodeUmon, "trd_hvAnodeUmon%03d", 'f', 540, kTRUE, kTRUE, 10,10,0,2);
101 SetConf(kHvDriftUmon, "trd_hvDriftUmon%03d", 'f', 540, kTRUE, kTRUE, 10,10,0,2);
102 SetConf(kAdcClkPhase, "trd_adcClkPhase", 'f', 1, kTRUE, kTRUE, 10,10,0,2);
103 SetConf(kAtmPressure, "trd_atmPressure", 'f', 1, kTRUE, kTRUE, 10,10,0,2);
104 SetConf(kLuminosity, "trd_luminosity", 'f', 1, kTRUE, kTRUE, 10,10,0,2);
105 SetConf(kMagneticField, "trd_magneticField", 'f', 1, kTRUE, kTRUE, 10,10,0,2);
107 for (UInt_t iAlias = 0; iAlias < fNAlias; iAlias++) {
108 fDatas[iAlias].GetGraph().SetOwner(1);
109 fDatas[iAlias].GetFit().SetOwner(1);
114 //_____________________________________________________________________________
115 void AliTRDDataDCS::SetConf(UInt_t iAlias, const char *amanda,
116 char dataType, UInt_t nChannel,
117 Bool_t enableGraph, Bool_t enableFit, Int_t minPoints,
118 Int_t iter, Double_t maxDelta, Int_t fitReq)
121 // Configure a DCS alias
124 if (iAlias >= fNAlias) {
125 AliWarning (Form("Alias %d is not correct", iAlias));
129 fConfs[iAlias].SetAmanda(amanda);
130 fConfs[iAlias].SetDataType(dataType);
131 fConfs[iAlias].SetNChannel(nChannel);
132 fConfs[iAlias].SetEnableGraph(enableGraph);
133 fConfs[iAlias].SetEnableFit(enableFit);
134 fConfs[iAlias].SetMinPoints(minPoints);
135 fConfs[iAlias].SetIter(iter);
136 fConfs[iAlias].SetMaxDelta(maxDelta);
137 fConfs[iAlias].SetFitReq(fitReq);
141 //_____________________________________________________________________________
142 void AliTRDDataDCS::InitFits()
145 // Initialize the fits
152 for (UInt_t iAlias = 0; iAlias < fNAlias; iAlias++) {
153 nChannel = fConfs[iAlias].GetEnableFit() ? fConfs[iAlias].GetNChannel() : 0;
154 fDatas[iAlias].GetFit().Expand(nChannel);
160 //_____________________________________________________________________________
161 void AliTRDDataDCS::InitGraphs()
164 // Initialize the graphs
171 for (UInt_t iAlias = 0; iAlias < fNAlias; iAlias++) {
172 nChannel = fConfs[iAlias].GetEnableGraph() ? fConfs[iAlias].GetNChannel() : 0;
173 fDatas[iAlias].GetGraph().Expand(nChannel);
176 fGraphsAreIni = kTRUE;
179 //_____________________________________________________________________________
180 void AliTRDDataDCS::ClearFits()
186 for (UInt_t iAlias = 0; iAlias < fNAlias; iAlias++) {
187 fDatas[iAlias].GetFit().Clear();
188 fDatas[iAlias].GetFit().Expand(0);
191 fFitsAreIni = kFALSE;
194 //_____________________________________________________________________________
195 void AliTRDDataDCS::ClearGraphs()
201 for (UInt_t iAlias = 0; iAlias < fNAlias; iAlias++) {
202 fDatas[iAlias].GetGraph().Clear();
203 fDatas[iAlias].GetGraph().Expand(0);
206 fGraphsAreIni = kFALSE;
209 //_____________________________________________________________________________
210 Bool_t AliTRDDataDCS::ExtractDCS (TMap *dcsAlias)
213 // Extract the DCS information
216 if (dcsAlias == 0x0) {
217 AliWarning ("No DCS Map");
227 for (UInt_t iAlias = 0; iAlias < fNAlias; iAlias++){
229 // extract dcs only when it is needed
230 nChannel = fDatas[iAlias].GetGraph().GetSize();
232 for (UInt_t iSensor=0; iSensor < nChannel; iSensor++) {
234 graphTemp = FindAndMakeGraph(dcsAlias,
235 Form(fConfs[iAlias].GetAmanda().Data(), iSensor),
236 fConfs[iAlias].GetDataType());
238 fDatas[iAlias].GetGraph().AddAt(graphTemp, iSensor);
245 //_____________________________________________________________________________
246 TGraph *AliTRDDataDCS::FindAndMakeGraph (TMap * const dcsMap
247 , const char *amandaStr
256 TPair *pair = (TPair *) dcsMap->FindObject(amandaStr);
258 AliWarning (Form("Can't find %s in dcsMap", amandaStr));
262 TObjArray *valueSet = (TObjArray *) pair->Value();
265 // Make graph of values read from DCS map
266 // (spline fit parameters will subsequently be obtained from this graph)
269 Int_t nEntries = valueSet->GetEntriesFast();
271 AliWarning (Form("Entry %s in dcsMap contain no datas", amandaStr));
275 Float_t * x = new Float_t[nEntries];
276 Float_t * y = new Float_t[nEntries];
281 for (iEntries = 0; iEntries< nEntries; iEntries++) {
283 AliDCSValue *val = (AliDCSValue *) valueSet->At(iEntries);
287 AliError(Form("Entry %s at %d contain no datas", amandaStr, iEntries));
292 time0 = val->GetTimeStamp();
295 x[iEntries] = (val->GetTimeStamp() - time0)/3600.0; // give times in fractions of hours
299 y[iEntries] = val->GetFloat();
303 y[iEntries] = (Float_t) val->GetChar();
308 AliError(Form("Bad type for entry %s", amandaStr));
314 graph = new TGraph(iEntries, x, y);
324 //_____________________________________________________________________________
325 Bool_t AliTRDDataDCS::PerformFit()
331 AliSplineFit *fitTemp;
338 for (UInt_t iAlias = 0; iAlias < fNAlias; iAlias++){
340 // perform fit only when it is needed
341 nChannel = fDatas[iAlias].GetFit().GetSize();
343 for (UInt_t iSensor=0; iSensor < nChannel; iSensor++) {
345 fitTemp = Fit((TGraph*)fDatas[iAlias].GetGraph(iSensor),
346 fConfs[iAlias].GetMinPoints(),
347 fConfs[iAlias].GetIter(),
348 fConfs[iAlias].GetMaxDelta(),
349 fConfs[iAlias].GetFitReq());
352 AliInfo(Form("Can't fit %s", Form(fConfs[iAlias].GetAmanda().Data(), iSensor)));
354 fDatas[iAlias].GetFit().AddAt(fitTemp, iSensor);
362 //_____________________________________________________________________________
363 AliSplineFit *AliTRDDataDCS::Fit(const TGraph * const graph,
364 Int_t minPoints, Int_t iter,
365 Double_t maxDelta, Int_t fitReq)
372 AliError("No graph for fit");
376 AliSplineFit *spline = new AliSplineFit();
377 spline->InitKnots(new TGraph (*graph), minPoints, iter, maxDelta);
378 spline->SplineFit(fitReq);
379 spline->Cleanup(); // delete also new TGraph (*graph)
384 //_____________________________________________________________________________
385 void AliTRDDataDCS::Print(const Option_t * const option) const
391 if (option[0]=='g' || option[0]=='\0'){
395 for (UInt_t iAlias = 0; iAlias < fNAlias; iAlias++){
397 for (Int_t iSensor = 0; iSensor < fDatas[iAlias].GetGraph().GetSize(); iSensor++) {
399 if (fDatas[iAlias].GetGraph(iSensor) != 0x0)
400 AliInfo(Form("Graph %s contain %d point(s)",
401 Form(fConfs[iAlias].GetAmanda(), iSensor),
402 ((TGraph*)(fDatas[iAlias].GetGraph(iSensor)))->GetN()));
407 AliInfo("Graphs don't exist");
412 if (option[0] == 'f' || option[0]=='\0'){
414 AliInfo("no print for fit");
420 //_____________________________________________________________________________
421 TGraph *AliTRDDataDCS::GetGraph(UInt_t iAlias, UInt_t iChannel) const
427 if (iAlias >= fNAlias) {
428 AliWarning(Form("Alias %d is not correct", iAlias));
432 if (iChannel >= (UInt_t) fDatas[iAlias].GetGraph().GetSize()) {
433 AliWarning(Form("Alias %s is not correct",
434 Form(fConfs[iAlias].GetAmanda().Data(), iChannel)));
438 return (TGraph *)fDatas[iAlias].GetGraph(iChannel);
441 //_____________________________________________________________________________
442 AliSplineFit *AliTRDDataDCS::GetFit(UInt_t iAlias, UInt_t iChannel) const
445 // Get the spline fit
448 if (iAlias >= fNAlias) {
449 AliWarning (Form("Alias %d is not correct", iAlias));
453 if (iChannel >= (UInt_t) fDatas[iAlias].GetFit().GetSize()) {
454 AliWarning(Form("Alias %s is not correct",
455 Form(fConfs[iAlias].GetAmanda().Data(), iChannel)));
459 return (AliSplineFit *) fDatas[iAlias].GetFit(iChannel);
462 //_____________________________________________________________________________
463 TString AliTRDDataDCS::GetAmandaStr (UInt_t iAlias) const
466 // Return the AMANDA string
469 if (iAlias < fNAlias)
470 return fConfs[iAlias].GetAmanda();
471 else return TString ();
474 //_____________________________________________________________________________
475 UInt_t AliTRDDataDCS::GetNChannel (UInt_t iAlias) const
478 // Get the channel number
481 if (iAlias < fNAlias)
482 return fConfs[iAlias].GetNChannel();