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