]> git.uio.no Git - u/mrichter/AliRoot.git/blob - VZERO/AliVZERODataDCS.cxx
Changes for PbPb RAA analysis (Zaida)
[u/mrichter/AliRoot.git] / VZERO / AliVZERODataDCS.cxx
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  *                                                                        *
4  * Author: The ALICE Off-line Project.                                    *
5  * Contributors are mentioned in the code where appropriate.              *
6  *                                                                        *
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  **************************************************************************/
15
16
17 #include "AliVZERODataDCS.h"
18
19 #include "AliDCSValue.h"
20 #include "AliLog.h"
21
22 #include <TGraph.h>
23 #include <TAxis.h>
24 #include <TCanvas.h>
25 #include <TTimeStamp.h>
26 #include <TMap.h>
27 #include <TString.h>
28 #include <TObjString.h>
29 #include <TH1F.h>
30
31 class TH2;
32 class AliCDBMetaData;
33 class TDatime;
34
35 // AliVZERODataDCS class
36 // main aim to introduce the aliases for the VZERO DCS
37 // data points to be then
38 // stored in the OCDB, and to process them. 
39 // ProcessData() method called by VZEROPreprocessor
40
41 ClassImp(AliVZERODataDCS)
42
43 //_____________________________________________________________________________
44 AliVZERODataDCS::AliVZERODataDCS():
45         TObject(),
46         fRun(0),
47         fStartTime(0),
48         fEndTime(0),
49         fDaqStartTime(0),
50         fDaqEndTime(0),
51     fGraphs("TGraph",kNGraphs),
52         fFEEParameters(NULL),
53         fIsProcessed(kFALSE)
54
55 {
56   // Default constructor
57         for(int i=0;i<kNHvChannel;i++) {
58                 fDeadChannel[i] = kFALSE;
59                 fMeanHV[i]      = 100.0;
60                 fWidthHV[i]     = 0.0; 
61                 fHv[i]          = NULL;
62         }
63 }
64
65 //_____________________________________________________________________________
66 AliVZERODataDCS::AliVZERODataDCS(Int_t nRun, UInt_t startTime, UInt_t endTime, UInt_t daqStartTime, UInt_t daqEndTime):
67         TObject(),
68         fRun(nRun),
69         fStartTime(startTime),
70         fEndTime(endTime),
71         fDaqStartTime(daqStartTime),
72         fDaqEndTime(daqEndTime),
73         fGraphs("TGraph",kNGraphs),
74         fFEEParameters(new TMap()),
75         fIsProcessed(kFALSE)
76
77 {
78
79   // constructor with arguments
80         for(int i=0;i<kNHvChannel;i++) {
81          fDeadChannel[i] = kFALSE;        
82          fMeanHV[i]      = 100.0;
83      fWidthHV[i]     = 0.0; 
84         }
85         AliInfo(Form("\n\tRun %d \n\tTime Created %s \n\tTime Completed %s \n\tDAQ start %s \n\tDAQ end %s  ", nRun,
86                 TTimeStamp(startTime).AsString(),
87                 TTimeStamp(endTime).AsString(),
88                 TTimeStamp(daqStartTime).AsString(),
89                 TTimeStamp(daqEndTime).AsString()));
90         
91         fFEEParameters->SetOwnerValue();
92         Init();
93
94 }
95
96 //_____________________________________________________________________________
97 AliVZERODataDCS::~AliVZERODataDCS() {
98
99   // destructor
100   fGraphs.Clear("C");
101   delete fFEEParameters;
102
103 }
104
105 //_____________________________________________________________________________
106 void AliVZERODataDCS::ProcessData(TMap& aliasMap){
107
108   // method to process the data
109
110   if(!(fAliasNames[0])) Init();
111
112   TObjArray *aliasArr;
113   AliDCSValue* aValue;
114
115   // starting loop on aliases
116   for(int iAlias=0; iAlias<kNAliases; iAlias++){
117
118     aliasArr = (TObjArray*) aliasMap.GetValue(fAliasNames[iAlias].Data());
119     if(!aliasArr){
120       AliError(Form("Alias %s not found!", fAliasNames[iAlias].Data()));
121       continue;
122     }
123
124     //Introduce(iAlias, aliasArr);
125     
126     if(aliasArr->GetEntries()<2){
127       AliWarning(Form("Alias %s has just %d entries!",
128                     fAliasNames[iAlias].Data(),aliasArr->GetEntries()));
129     }
130     
131     TIter iterarray(aliasArr);
132         
133     if(iAlias<kNHvChannel){ // Treating HV values
134         Int_t nentries = aliasArr->GetEntries();
135
136         Double_t *times = new Double_t[nentries];
137         Double_t *values = new Double_t[nentries];
138
139         UInt_t iValue=0;
140         Float_t variation = 0.0;
141
142         while((aValue = (AliDCSValue*) iterarray.Next())) {
143                         UInt_t currentTime = aValue->GetTimeStamp();
144                         if(currentTime>fDaqEndTime) break;
145
146                         values[iValue] = aValue->GetFloat();
147                         times[iValue] = (Double_t) (currentTime);
148                         
149                         if(iValue>0) {
150                                 if(values[iValue-1]>0.) variation = TMath::Abs(values[iValue]-values[iValue-1])/values[iValue-1];
151                                 if(variation > 0.01) fDeadChannel[GetOfflineChannel(iAlias)] = kTRUE;
152                         }
153                         fHv[iAlias]->Fill(values[iValue]);
154                         printf("%s %f Dead=%d\n",fAliasNames[iAlias].Data(),values[iValue],fDeadChannel[GetOfflineChannel(iAlias)]);
155                         iValue++;
156         }      
157         CreateGraph(iAlias, aliasArr->GetEntries(), times, values); // fill graphs 
158
159         // calculate mean and rms of the first two histos
160         // and convert index to aliroot channel
161         Int_t iChannel     = GetOfflineChannel(iAlias); 
162         fMeanHV[iChannel]  = fHv[iAlias]->GetMean();
163         fWidthHV[iChannel] = fHv[iAlias]->GetRMS();
164
165         delete[] values;
166         delete[] times; 
167         } else { // Treating FEE Parameters
168                 AliDCSValue * lastVal = NULL;
169                 while((aValue = (AliDCSValue*) iterarray.Next())) lastVal = aValue; // Take only the last value
170                 fFEEParameters->Add(new TObjString(fAliasNames[iAlias].Data()),lastVal);
171         }      
172   }
173   
174   fIsProcessed=kTRUE;
175 }
176
177 //_____________________________________________________________________________
178 void AliVZERODataDCS::Init(){
179
180   // initialization of aliases and DCS data
181
182   TString sindex;
183   int iAlias = 0;
184   
185   for(int iSide = 0; iSide<2 ; iSide++){
186         for(int iRing = 0; iRing<4 ; iRing++){
187                 for(int iSector = 0; iSector<8 ; iSector++){
188                         if(iSide == 0) fAliasNames[iAlias] = "V00/HV/V0A/SECTOR";
189                         else fAliasNames[iAlias] = "V00/HV/V0C/SECTOR";
190                         sindex.Form("%d/RING%d",iSector,iRing);
191                         fAliasNames[iAlias] += sindex;
192                         
193                         fHv[iAlias] = new TH1F(fAliasNames[iAlias].Data(),fAliasNames[iAlias].Data(), 3000, kHvMin, kHvMax);
194                         fHv[iAlias]->GetXaxis()->SetTitle("Hv");
195                         iAlias++;
196                 }
197         }
198   }
199
200  // Time Resolution Parameters
201         
202         for(int iCIU = 0; iCIU<8 ; iCIU++){
203                 fAliasNames[iAlias++] = Form("V00/FEE/CIU%d/TimeResolution",iCIU);
204                 fAliasNames[iAlias++] = Form("V00/FEE/CIU%d/WidthResolution",iCIU);
205         }
206
207         // HPTDC parameters
208         for(int iCIU = 0; iCIU<8 ; iCIU++){
209           fAliasNames[iAlias++] = Form("V00/FEE/CIU%d/MatchWindow",iCIU);
210           fAliasNames[iAlias++] = Form("V00/FEE/CIU%d/SearchWindow",iCIU);
211           fAliasNames[iAlias++] = Form("V00/FEE/CIU%d/TriggerCountOffset",iCIU);
212           fAliasNames[iAlias++] = Form("V00/FEE/CIU%d/RollOver",iCIU);
213         }
214
215         for(int iCIU = 0; iCIU<8 ; iCIU++){
216           for(int iCh=1;iCh<=8;iCh++){
217             fAliasNames[iAlias++] = Form("V00/FEE/CIU%d/DelayHit%d",iCIU,iCh);
218           }
219         }
220
221         for(int iCIU = 0; iCIU<8 ; iCIU++){
222           for(int iCh=1;iCh<=8;iCh++){
223             fAliasNames[iAlias++] = Form("V00/FEE/CIU%d/DiscriThr%d",iCIU,iCh);
224           }
225         }
226
227   if(iAlias!=kNAliases) 
228               AliError(Form("Number of DCS Aliases defined not correct"));
229
230 }
231
232 //_____________________________________________________________________________
233 void AliVZERODataDCS::Introduce(UInt_t numAlias, const TObjArray* aliasArr)const
234 {
235
236   // method to introduce new aliases
237
238   int entries=aliasArr->GetEntries();
239   AliInfo(Form("************ Alias: %s **********",fAliasNames[numAlias].Data()));
240   AliInfo(Form("        %d DP values collected",entries));
241
242 }
243
244 //_____________________________________________________________________________
245 void AliVZERODataDCS::CreateGraph(int i, int dim, const Double_t *x, const Double_t *y)
246 {
247
248    // Create graphics
249    
250    TGraph *gr = new(fGraphs[fGraphs.GetEntriesFast()]) TGraph(dim, x, y);
251
252    gr->GetXaxis()->SetTimeDisplay(1);
253    gr->SetTitle(fAliasNames[i].Data());
254
255    AliInfo(Form("Array entries: %d",fGraphs.GetEntriesFast()));
256
257 }
258
259
260 //_____________________________________________________________________________
261 void AliVZERODataDCS::Draw(const Option_t* /*option*/)
262 {
263 // Draw all histos and graphs
264
265   if(!fIsProcessed) return;
266
267   if(fGraphs.GetEntries()==0)  return;
268   
269   TString canvasName;
270   TCanvas *cHV[8];
271   
272   for(int iSide = 0 ;iSide<2;iSide++){
273         for(int iRing=0;iRing<4;iRing++){
274                 if(iSide == 0)  canvasName = "V0A_Ring";
275                 else  canvasName = "V0C_Ring";
276                 canvasName += iRing;
277                 int iCanvas = iSide*4 + iRing;
278                 cHV[iCanvas] = new TCanvas(canvasName,canvasName);
279                 cHV[iCanvas]->Divide(3,3);
280                 for(int iSector=0;iSector<8;iSector++){
281                         cHV[iCanvas]->cd(iSector+1);
282                         int iChannel = iSide*32 + iRing*8 + iSector; 
283                         ((TGraph*) fGraphs.UncheckedAt(iChannel))->SetMarkerStyle(20);
284                         ((TGraph*) fGraphs.UncheckedAt(iChannel))->Draw("ALP");
285
286                 }
287                                 
288         }
289   }
290
291 }
292