Make it find libraries independently of location
[u/mrichter/AliRoot.git] / ZDC / AliZDCDataDCS.cxx
CommitLineData
5a8e8156 1///////////////////////////////////////////////////////////////////////////////
2// //
3// Class for ZDC DCS data //
4// //
5///////////////////////////////////////////////////////////////////////////////
6
64a7c78d 7#include "AliZDCDataDCS.h"
8
9#include "AliCDBMetaData.h"
10#include "AliDCSValue.h"
11#include "AliLog.h"
12
a1e17193 13#include <TCanvas.h>
64a7c78d 14#include <TDatime.h>
bf867209 15#include <TString.h>
a1e17193 16#include <TObjString.h>
64a7c78d 17#include <TStyle.h>
a1e17193 18#include <TTimeStamp.h>
64a7c78d 19
20ClassImp(AliZDCDataDCS)
21
22//---------------------------------------------------------------
23AliZDCDataDCS::AliZDCDataDCS():
5a8e8156 24 TObject(),
25 fRun(0),
26 fStartTime(0),
27 fEndTime(0),
e83c8d88 28 fStartTimeDCSQuery(0),
29 fEndTimeDCSQuery(0),
57c85e6e 30// fTimeStamp(0x0),
31// fHVData(0x0),
5a8e8156 32 fIsProcessed(kFALSE)
33{
34 // Default constructor
57c85e6e 35 for(Int_t i=0; i<kNAliases; i++) fAliasNames[i] = "";
36 for(Int_t i=0; i<kNAlignDet; i++) fAlignData[i] = 0.;
5a8e8156 37}
64a7c78d 38
39//---------------------------------------------------------------
e83c8d88 40AliZDCDataDCS::AliZDCDataDCS(Int_t nRun, UInt_t startTime, UInt_t endTime,
41 UInt_t startTimeDCSQuery, UInt_t endTimeDCSQuery):
5a8e8156 42 TObject(),
43 fRun(nRun),
44 fStartTime(startTime),
45 fEndTime(endTime),
e83c8d88 46 fStartTimeDCSQuery(startTimeDCSQuery),
47 fEndTimeDCSQuery(endTimeDCSQuery),
57c85e6e 48// fTimeStamp(0x0),
49// fHVData(0x0),
5a8e8156 50 fIsProcessed(kFALSE)
64a7c78d 51{
5a8e8156 52 // Standard constructor
53
e83c8d88 54 AliDebug(2,Form("\n\tRun %d \n\tStartTime %s \n\tEndTime %s \n\tStartTime DCS Query %s \n\tEndTime DCS Query %s", nRun,
5a8e8156 55 TTimeStamp(startTime).AsString(),
e83c8d88 56 TTimeStamp(endTime).AsString(),
57 TTimeStamp(startTimeDCSQuery).AsString(),
58 TTimeStamp(endTimeDCSQuery).AsString()));
64a7c78d 59
5a8e8156 60 Init();
64a7c78d 61
62}
63
64//---------------------------------------------------------------
e83c8d88 65AliZDCDataDCS::AliZDCDataDCS(const AliZDCDataDCS & data):
66 TObject(data),
67 fRun(data.fRun),
68 fStartTime(data.fStartTime),
69 fEndTime(data.fEndTime),
70 fStartTimeDCSQuery(data.fStartTimeDCSQuery),
71 fEndTimeDCSQuery(data.fEndTimeDCSQuery),
57c85e6e 72// fTimeStamp(data.fTimeStamp),
73// fHVData(data.fHVData),
e83c8d88 74 fIsProcessed(data.fIsProcessed)
75{
76
77 // copy constructor
78
57c85e6e 79 for(int i=0;i<kNAliases;i++) fAliasNames[i] = data.fAliasNames[i];
80 for(int i=0;i<kNAlignDet;i++) fAlignData[i] = data.fAlignData[i];
e83c8d88 81
82}
83
84//---------------------------------------------------------------
85AliZDCDataDCS& AliZDCDataDCS:: operator=(const AliZDCDataDCS & data) {
86
87 // assignment operator
88
89 if (this == &data)
90 return *this;
91
92 TObject::operator=(data);
93 fRun = data.GetRun();
94 fStartTime = data.GetStartTime();
95 fEndTime = data.GetEndTime();
96 fStartTimeDCSQuery = data.GetStartTimeDCSQuery();
97 fEndTimeDCSQuery = data.GetEndTimeDCSQuery();
57c85e6e 98// fTimeStamp = data.GetTimeStamp();
99// fHVData = data.GetHVData();
100 fIsProcessed = data.fIsProcessed;
e83c8d88 101
57c85e6e 102 for(int i=0;i<kNAliases;i++) fAliasNames[i] = data.GetAliasName(i);
103 for(int i=0;i<kNAlignDet;i++) fAlignData[i] = data.GetAlignData(i);
e83c8d88 104
105 return *this;
106}
107
108//---------------------------------------------------------------
5a8e8156 109AliZDCDataDCS::~AliZDCDataDCS()
110{
111 // Destructor
64a7c78d 112}
113
114//---------------------------------------------------------------
e83c8d88 115Bool_t AliZDCDataDCS::ProcessData(TMap& aliasMap)
5a8e8156 116{
117 // Data processing
e83c8d88 118
bf867209 119 if(!(fAliasNames[0])) Init();
e83c8d88 120
121 AliInfo(Form(" Start Time = %i",fStartTime));
122 AliInfo(Form(" End Time = %i",fEndTime));
123 AliInfo(Form(" Start Time DCS Query= %i",fStartTimeDCSQuery));
124 AliInfo(Form(" End Time DCS Query= %i",fEndTimeDCSQuery));
bf867209 125
126 if (fEndTime==fStartTime){
127 AliError(Form(" Run with null time length: start time = %i = end time = %i",fStartTime,fEndTime));
128 return kFALSE;
129 }
5a8e8156 130
bf867209 131 TObjArray *aliasArr;
132 AliDCSValue *aValue;
e83c8d88 133
aee13a2d 134 for(int j=0; j<kNAliases; j++){
57c85e6e 135 //printf(" Processing alias %d aliasName %s \n", j, fAliasNames[j].Data());
136
137 aliasArr = (TObjArray*) (aliasMap.GetValue(fAliasNames[j].Data()));
5a8e8156 138 if(!aliasArr){
396250bf 139 AliWarning(Form("Alias %s: data not found!", fAliasNames[j].Data()));
57c85e6e 140 continue;
5a8e8156 141 }
57c85e6e 142
5a8e8156 143 Introduce(j, aliasArr);
144
bf867209 145 Int_t nentries = aliasArr->GetEntries();
82d64f51 146/* if(nentries<=2){
57c85e6e 147 AliWarning(Form("Alias %s has just %d entries!", fAliasNames[j].Data(), nentries));
148// continue;
5a8e8156 149 }
82d64f51 150*/
bf867209 151 Float_t *time = new Float_t[nentries];
152 Float_t *val = new Float_t[nentries];
5a8e8156 153
57c85e6e 154 TIter iterarray(aliasArr);
155
5a8e8156 156 UInt_t ne=0;
57c85e6e 157 Float_t sum=0.;
158 Int_t nMeasures=0;
159 while((aValue = (AliDCSValue*) iterarray.Next())){
160 val[ne] = aValue->GetFloat();
161 time[ne] = (Float_t) (aValue->GetTimeStamp());
162 if(j<4){
163 sum += val[ne];
164 nMeasures++;
165 }
166 else{
167 //fHVData[ne] = val[ne];
168 //fTimeStamp[ne] = time[ne];
169 }
170 ne++;
5a8e8156 171 }
57c85e6e 172 //
173 if(j<4 && nMeasures!=0) fAlignData[j] = sum/nMeasures;
5a8e8156 174
5a8e8156 175 delete[] val;
57c85e6e 176 delete[] time;
5a8e8156 177 }
57c85e6e 178
5a8e8156 179 fIsProcessed=kTRUE;
e83c8d88 180 return kTRUE;
57c85e6e 181
64a7c78d 182}
183
184//---------------------------------------------------------------
5a8e8156 185void AliZDCDataDCS::Init()
186{
187 // Initialization
57c85e6e 188
c43e6d35 189 fAliasNames[0] = "ZDC_ZNA_POS.actual.position";
190 fAliasNames[1] = "ZDC_ZPA_POS.actual.position";
191 fAliasNames[2] = "ZDC_ZNC_POS.actual.position";
192 fAliasNames[3] = "ZDC_ZPC_POS.actual.position";
b39b8493 193 //
c43e6d35 194 fAliasNames[4] = "ZDC_ZNA_HV0.actual.vMon";
195 fAliasNames[5] = "ZDC_ZNA_HV1.actual.vMon";
196 fAliasNames[6] = "ZDC_ZNA_HV2.actual.vMon";
197 fAliasNames[7] = "ZDC_ZNA_HV3.actual.vMon";
198 fAliasNames[8] = "ZDC_ZNA_HV4.actual.vMon";
b39b8493 199 //
c43e6d35 200 fAliasNames[9] = "ZDC_ZPA_HV0.actual.vMon";
201 fAliasNames[10] = "ZDC_ZPA_HV1.actual.vMon";
202 fAliasNames[11] = "ZDC_ZPA_HV2.actual.vMon";
203 fAliasNames[12] = "ZDC_ZPA_HV3.actual.vMon";
204 fAliasNames[13] = "ZDC_ZPA_HV4.actual.vMon";
b39b8493 205 //
c43e6d35 206 fAliasNames[14] = "ZDC_ZNC_HV0.actual.vMon";
207 fAliasNames[15] = "ZDC_ZNC_HV1.actual.vMon";
208 fAliasNames[16] = "ZDC_ZNC_HV2.actual.vMon";
209 fAliasNames[17] = "ZDC_ZNC_HV3.actual.vMon";
210 fAliasNames[18] = "ZDC_ZNC_HV4.actual.vMon";
b39b8493 211 //
c43e6d35 212 fAliasNames[19] = "ZDC_ZPC_HV0.actual.vMon";
213 fAliasNames[20] = "ZDC_ZPC_HV1.actual.vMon";
214 fAliasNames[21] = "ZDC_ZPC_HV2.actual.vMon";
215 fAliasNames[22] = "ZDC_ZPC_HV3.actual.vMon";
216 fAliasNames[23] = "ZDC_ZPC_HV4.actual.vMon";
b39b8493 217 //
c43e6d35 218 fAliasNames[24] = "ZDC_ZEM_HV0.actual.vMon";
219 fAliasNames[25] = "ZDC_ZEM_HV1.actual.vMon";
c0aec6f6 220 //
20a3b76c 221 fAliasNames[26] = "ZDC_REFA_HV.actual.vMon";
222 fAliasNames[27] = "ZDC_REFC_HV.actual.vMon";
b39b8493 223
64a7c78d 224}
225
226//---------------------------------------------------------------
5a8e8156 227void AliZDCDataDCS::Introduce(UInt_t numAlias, const TObjArray* aliasArr)
228{
229 // Getting array of DCS aliases
230
457a440d 231 int entries = aliasArr->GetEntries();
57c85e6e 232 printf("************ Alias: %s has %d DP values collected\n",
233 fAliasNames[numAlias].Data(),entries);
64a7c78d 234
235}