end-of-line normalization
[u/mrichter/AliRoot.git] / TRD / Macros / AliTRDcheckConfig.C
CommitLineData
a65a7e70 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// This is a macro to analyze TRD/Calib/DCS OCDB objects either
18// from the grid for a given run number or from a local object.
19//
20// Arguments:
21// Either provide a run number as the first argument to access the
22// corresponding file on the grid
23// or the path + filename as the second argument (and an arbitrary number as the first)
24// to access a local file.
25//
26// Please note that leading zeros in the run number are not supported.
27//
28// Examples:
29// .x AliTRDcheckConfig.C (60111)
30// .x AliTRDcheckConfig.C (0, "$ALICE_ROOT/TRD/Calib/DCS/Run0_999999999_v0_s0.root")
31//
32// Original author:
33// Frederick Kramer
34// Current maintainer:
35// Hans Beck
36//===================================================================================
37
38// Make the macro compile.
39#if !defined(__CINT__) || defined(__MAKECINT__)
40// Compile me in aliroot with .L AliTRDcheckConfig.C+ or with
41// clang -lXMLParser -lGui -lProof -lRAWDatabase -lVMC -lMinuit -lSTEERbase -lANALYSIS -lSTEER -lESD -L$ALICE_BUILD/lib/tgt_`root-config --arch` -lTRDbase -lCDB -lstdc++ `root-config --libs` -I`root-config --incdir` -I$ALICE_ROOT/include AliTRDcheckConfig.C
42#include <iostream>
43#include <fstream>
44#include <TMath.h>
45#include <TFile.h>
46#include <TGrid.h>
47#include <TEnv.h>
48#include "../../STEER/CDB/AliCDBEntry.h"
49#include "../../STEER/CDB/AliCDBManager.h"
50#include "../Cal/AliTRDCalDCS.h"
51#include "../Cal/AliTRDCalDCSv2.h"
52#include "../Cal/AliTRDCalDCSFEE.h"
53#include "../Cal/AliTRDCalDCSFEEv2.h"
54
55// Not sure where to put it?
56using namespace std;
57#endif
58
59const Int_t nROC = 540;
60const Int_t nROB = 8;
61const Int_t nMCM = 18;
62const Int_t cArraySize = 1000;
63
64Bool_t errors;
65Int_t calVer;
66//______________________________________________________________________
67Int_t AnalyzeArray(Int_t states[cArraySize], Int_t occur[cArraySize]) {
68 Int_t srtIndx[cArraySize] = {0};
69
70 TMath::Sort(cArraySize, occur, srtIndx);
71
72 Int_t totalSum = 0, subSum = 0, iIndex = 0;
73 for (Int_t i=0; i<cArraySize; i++) totalSum += occur[i];
74
75 cout << " The majority ("<< occur[srtIndx[0]] << " of "
76 << totalSum <<") is: " << states[srtIndx[0]] << endl;
77 subSum = occur[srtIndx[0]];
78 while (totalSum != subSum) {
79 if (++iIndex > 999) {
80 cout << "E : out of bounds." << endl;
81 break;
82 }
83 Printf(" Next: %7d (%d)", states[srtIndx[iIndex]], occur[srtIndx[iIndex]]);
84 subSum += occur[srtIndx[iIndex]];
85 }
86 return states[srtIndx[0]];
87}
88//______________________________________________________________________
89void FillItemInArray(Int_t states[cArraySize], Int_t occur[cArraySize], Int_t item, Bool_t allowNeg) {
90 for (Int_t iArrPos=0; iArrPos<cArraySize; iArrPos++) {
91 // if allowNeg is set then we change the number indicating that the item ws not set from -1 to -100
92 // so that small negative numbers can be sorted too
93 if ((allowNeg && item == -100000) || (!allowNeg && item == -1)) break; // value not set
94 if (states[iArrPos] == item) {
95 occur[iArrPos]++;
96 break;
97 } else if (occur[iArrPos] == 0) {
98 states[iArrPos] = item;
99 occur[iArrPos]++;
100 break;
101 }
102 }
103}
104//______________________________________________________________________
105void GetMajoritys(TObject* calDCSObj) {
106
107 // Initializes full array with zeros
108 Int_t gsmStates[cArraySize] = {0}, gsmOccur[cArraySize] = {0};
109 Int_t nimStates[cArraySize] = {0}, nimOccur[cArraySize] = {0};
110 Int_t nevStates[cArraySize] = {0}, nevOccur[cArraySize] = {0};
111 Int_t nptStates[cArraySize] = {0}, nptOccur[cArraySize] = {0};
112
113
114 { // Scoped declaration
115 Int_t feeArrSiz = 0;
116 if (calVer == 1) {
117 if(((AliTRDCalDCS*)calDCSObj)->GetFEEArr())
118 feeArrSiz = ((AliTRDCalDCS*)calDCSObj)->GetFEEArr()->GetSize();
119 }
120 else if (calVer == 2) {
121 if(((AliTRDCalDCSv2*)calDCSObj)->GetFEEArr())
122 feeArrSiz = ((AliTRDCalDCSv2*)calDCSObj)->GetFEEArr()->GetSize();
123 }
124
125 TObject* idcsfee;
126 for (Int_t i=0; i<nROC && i<feeArrSiz; i++) {
127 if (calVer == 1) idcsfee = ((AliTRDCalDCS*)calDCSObj)->GetCalDCSFEEObj(i);
128 else if (calVer == 2) idcsfee = ((AliTRDCalDCSv2*)calDCSObj)->GetCalDCSFEEObj(i);
129
130 if (idcsfee == NULL) continue;
131
132 Int_t sbit(-9999);
133 if (calVer == 1) sbit = ((AliTRDCalDCSFEE*)idcsfee)->GetStatusBit();
134 else if (calVer == 2) sbit = ((AliTRDCalDCSFEEv2*)idcsfee)->GetStatusBit();
135 if (sbit != 0) continue;
136
137 for (Int_t j=0; j<nROB; j++) {
138 for (Int_t k=0; k<nMCM; k++) {
139 Int_t igsm = 0;
140 Int_t inim = 0;
141 Int_t inev = 0;
142 Int_t inpt = 0;
143 if (calVer == 1) {
144 igsm = ((AliTRDCalDCSFEE*)idcsfee)->GetMCMGlobalState(j,k);
145 inim = ((AliTRDCalDCSFEE*)idcsfee)->GetMCMStateNI(j,k);
146 inev = ((AliTRDCalDCSFEE*)idcsfee)->GetMCMEventCnt(j,k);
147 inpt = ((AliTRDCalDCSFEE*)idcsfee)->GetMCMPtCnt(j,k);
148 }
149 else if (calVer == 2) {
150 igsm = ((AliTRDCalDCSFEEv2*)idcsfee)->GetMCMGlobalState(j,k);
151 inim = ((AliTRDCalDCSFEEv2*)idcsfee)->GetMCMStateNI(j,k);
152 inev = ((AliTRDCalDCSFEEv2*)idcsfee)->GetMCMEventCnt(j,k);
153 inpt = ((AliTRDCalDCSFEEv2*)idcsfee)->GetMCMPtCnt(j,k);
154 }
155
156 FillItemInArray(gsmStates, gsmOccur, igsm, false);
157 FillItemInArray(nimStates, nimOccur, inim, false);
158 FillItemInArray(nevStates, nevOccur, inev, false);
159 FillItemInArray(nptStates, nptOccur, inpt, false);
160 } // End of loop over MCMs
161 } // End of loop over ROBs
162 } // End of loop over ROCs
163 } // End of scoped declaration
164
165 cout << "I : Global MCM state statistics:" << endl;
166 AnalyzeArray(gsmStates, gsmOccur);
167 cout << "I : Network interface state statistics:" << endl;
168 AnalyzeArray(nimStates, nimOccur);
169 cout << "I : MCM Event counter reading statistics:" << endl;
170 AnalyzeArray(nevStates, nevOccur);
171 cout << "I : MCM PreTrigger counter reading statistics:" << endl;
172 AnalyzeArray(nptStates, nptOccur);
173
174 return;
175}
176//______________________________________________________________________
177void GetMajorityDifferences(TObject* calDCSObj, TObject* calDCSObj2) {
178
179 // Initializes full array with zeros
180 Int_t gsmStates[cArraySize] = {0}, gsmOccur[cArraySize] = {0};
181 Int_t nimStates[cArraySize] = {0}, nimOccur[cArraySize] = {0};
182 Int_t nevStates[cArraySize] = {0}, nevOccur[cArraySize] = {0};
183 Int_t nptStates[cArraySize] = {0}, nptOccur[cArraySize] = {0};
184
185
186 { // Scoped declaration
187 Int_t feeArrSiz1 = 0;
188 Int_t feeArrSiz2 = 0;
189 if (calVer == 1) {
190 if(((AliTRDCalDCS*)calDCSObj)->GetFEEArr())
191 feeArrSiz1 = ((AliTRDCalDCS*)calDCSObj)->GetFEEArr()->GetSize();
192 if(((AliTRDCalDCS*)calDCSObj2)->GetFEEArr())
193 feeArrSiz2 = ((AliTRDCalDCS*)calDCSObj2)->GetFEEArr()->GetSize();
194 }
195 else if (calVer == 2) {
196 if(((AliTRDCalDCSv2*)calDCSObj)->GetFEEArr())
197 feeArrSiz1 = ((AliTRDCalDCSv2*)calDCSObj)->GetFEEArr()->GetSize();
198 if(((AliTRDCalDCSv2*)calDCSObj2)->GetFEEArr())
199 feeArrSiz2 = ((AliTRDCalDCSv2*)calDCSObj2)->GetFEEArr()->GetSize();
200 }
201
202 TObject* idcsfee;
203 TObject* idcsfee2;
204 for (Int_t i=0; i<nROC && i<feeArrSiz1 && i<feeArrSiz2; i++) {
205 if (calVer == 1) {
206 idcsfee = ((AliTRDCalDCS*)calDCSObj)->GetCalDCSFEEObj(i);
207 idcsfee2 = ((AliTRDCalDCS*)calDCSObj2)->GetCalDCSFEEObj(i);
208 }
209 else if (calVer == 2) {
210 idcsfee = ((AliTRDCalDCSv2*)calDCSObj)->GetCalDCSFEEObj(i);
211 idcsfee2 = ((AliTRDCalDCSv2*)calDCSObj2)->GetCalDCSFEEObj(i);
212 }
213 if ((idcsfee == NULL) || (idcsfee2 == NULL)) continue;
214
215 Int_t sbit(-9999);
216 if (calVer == 1) sbit = ((AliTRDCalDCSFEE*)idcsfee)->GetStatusBit();
217 else if (calVer == 2) sbit = ((AliTRDCalDCSFEEv2*)idcsfee)->GetStatusBit();
218 if (sbit != 0) continue;
219
220 for (Int_t j=0; j<nROB; j++) {
221 for (Int_t k=0; k<nMCM; k++) {
222 Int_t igsm, inim, inev, inpt, igsm1, inim1, inev1, inpt1, igsm2, inim2, inev2, inpt2;
223 if (calVer == 1) {
224 igsm1 = ((AliTRDCalDCSFEE*)idcsfee)->GetMCMGlobalState(j,k);
225 inim1 = ((AliTRDCalDCSFEE*)idcsfee)->GetMCMStateNI(j,k);
226 inev1 = ((AliTRDCalDCSFEE*)idcsfee)->GetMCMEventCnt(j,k);
227 inpt1 = ((AliTRDCalDCSFEE*)idcsfee)->GetMCMPtCnt(j,k);
228 igsm2 = ((AliTRDCalDCSFEE*)idcsfee2)->GetMCMGlobalState(j,k);
229 inim2 = ((AliTRDCalDCSFEE*)idcsfee2)->GetMCMStateNI(j,k);
230 inev2 = ((AliTRDCalDCSFEE*)idcsfee2)->GetMCMEventCnt(j,k);
231 inpt2 = ((AliTRDCalDCSFEE*)idcsfee2)->GetMCMPtCnt(j,k);
232 }
233 else if (calVer == 2) {
234 igsm1 = ((AliTRDCalDCSFEEv2*)idcsfee)->GetMCMGlobalState(j,k);
235 inim1 = ((AliTRDCalDCSFEEv2*)idcsfee)->GetMCMStateNI(j,k);
236 inev1 = ((AliTRDCalDCSFEEv2*)idcsfee)->GetMCMEventCnt(j,k);
237 inpt1 = ((AliTRDCalDCSFEEv2*)idcsfee)->GetMCMPtCnt(j,k);
238 igsm2 = ((AliTRDCalDCSFEEv2*)idcsfee2)->GetMCMGlobalState(j,k);
239 inim2 = ((AliTRDCalDCSFEEv2*)idcsfee2)->GetMCMStateNI(j,k);
240 inev2 = ((AliTRDCalDCSFEEv2*)idcsfee2)->GetMCMEventCnt(j,k);
241 inpt2 = ((AliTRDCalDCSFEEv2*)idcsfee2)->GetMCMPtCnt(j,k);
242 }
243
244 igsm = igsm1 - igsm2;
245 inim = inim1 - inim2;
246 inev = inev2 - inev1;
247 inpt = inpt2 - inpt1;
248
249 // if they were set to -1, it means they were not actauuly set
250 // change -1 to -100 to mean they werent set since the above
251 // can give negatives
252 if (igsm1 == -1 && igsm == 0) igsm =-100000;
253 if (inim1 == -1 && inim == 0) inim =-100000;
254 if (inev1 == -1 && inev == 0) inev =-100000;
255 if (inpt1 == -1 && inpt == 0) inpt =-100000;
256
257 FillItemInArray(gsmStates, gsmOccur, igsm, true);
258 FillItemInArray(nimStates, nimOccur, inim, true);
259 FillItemInArray(nevStates, nevOccur, inev, true);
260 FillItemInArray(nptStates, nptOccur, inpt, true);
261 } // End of loop over MCMs
262 } // End of loop over ROBs
263 } // End of loop over ROCs
264 } // End of scoped declaration
265
266 cout << "I : Global MCM state difference statistics:" << endl;
267 AnalyzeArray(gsmStates, gsmOccur);
268 cout << "I : Network interface state difference statistics:" << endl;
269 AnalyzeArray(nimStates, nimOccur);
270 cout << "I : MCM Event counter difference statistics:" << endl;
271 if (AnalyzeArray(nevStates, nevOccur) < 1) {
272 cout << "E : There should have been some events recorded, but there weren't" << endl;
273 errors = true;
274 }
275 cout << "I : MCM PreTrigger counter difference statistics:" << endl;
276 if (AnalyzeArray(nptStates, nptOccur) < 1) {
277 cout << "E : There should have been some events recorded, but there weren't" << endl;
278 errors = true;
279 }
280
281 return;
282}
283//______________________________________________________________________
284void WrappedAliTRDcheckConfig(Int_t runNr, const char *pathfile,TFile *f){
285 // Reset the 'errors occured' bool as it's global
286 errors=false;
287
288 AliCDBEntry *entry=0;
289 TString pathfilets(pathfile);
290
291 // get the source
292 if(pathfilets.Contains("nopathgiven")) {
293 cout << "I : Accessing grid storage for run number " << runNr << endl;
294 cout << "I : Get CDBManager instance." << endl;
295 AliCDBManager *man = AliCDBManager::Instance();
296 cout << "I : SetDefaultStorage." << endl;
297 man->SetDefaultStorageFromRun(runNr);
298
299 cout << "I : Get OCDB Entry." << endl;
300 entry = man->Get("TRD/Calib/DCS", runNr);
301 if (entry == NULL) {
302 cout << endl << "ERROR: Unable to get the AliTRDCalDCS object"
303 << "from the OCDB for run number " << runNr << "." << endl;
304 return;
305 }
306 } else {
307 cout << "I : Accessing file directly" << endl;
308 // Might be we want to check a file on the grid
309 if(pathfilets.BeginsWith("alien://"))
310 TGrid::Connect("alien://");
311 f = TFile::Open(pathfile);
312 if(f != NULL) {
313 entry = (AliCDBEntry*) f->Get("AliCDBEntry");
314 if(!entry){
315 cout << "E : Can not get the OCDB entry"<<endl;
316 return;
317 }
318 }
319 else {
320 cout << "E : Cannot open file" << endl;
321 return;
322 }
323 }
324
325 TObjArray *objArrayCDB = (TObjArray*)entry->GetObject();
326 if(!objArrayCDB){
327 cout << "E : Can not get the OCDB object"<<endl;
328 return;
329 }
330
331 Int_t iesor=0;
332 for (iesor=0; iesor<3; iesor++) if(objArrayCDB->At(iesor)) break;
333 if (iesor > 1) {
334 cout << "E : Neither the start or end of run objects were in the root file.";
335 return;
336 }
337
338 Bool_t hasSOR = (objArrayCDB->At(0));
339 Bool_t hasEOR = (objArrayCDB->At(1));
340 printf("SOR entry: %d, EOR entry: %d\n", hasSOR, hasEOR);
341
342 if (!strcmp(objArrayCDB->At(iesor)->ClassName(),"AliTRDCalDCS")) calVer = 1;
343 else if (!strcmp(objArrayCDB->At(iesor)->ClassName(),"AliTRDCalDCSv2")) calVer = 2;
344 else {
345 cout << "E : Object types undefined.";
346 return;
347 }
348
349 Bool_t sorandeor = true;
350 TObject *caldcs = objArrayCDB->At(0);
351 TObject *caldcs2 = objArrayCDB->At(1);
352
353 if (caldcs == NULL && caldcs2 == NULL) {
354 cout << "E : Neither the start or end of run objects were in the root file.";
355 return;
356 } else if (caldcs != NULL && caldcs2 == NULL) {
357 cout << "E : The EOR file was not in the root file.";
358 errors = true;
359 sorandeor = false;
360 } else if (caldcs == NULL && caldcs2 != NULL) {
361 cout << "E : The SOR file was not in the root file.";
362 errors = true;
363 sorandeor = false;
364 caldcs = caldcs2;
365 }
366
367 cout << endl << "============ Non responding ROC Summary: ============" << endl;
368 TString bitfivestr = " ROCs with status bit 5. These havn't responded to communication\nattempts over DIM. Most probably they just were off this is ok.\n DCS IDs: ";
369 Int_t lengthfive = bitfivestr.Length();
370 TString bitfourstr = " ROCs with status bit 4! BAD! This might be due to a communication problem between fxsproxy and the feeserver(s) \n DCS IDs: ";
371 Int_t lengthfour = bitfourstr.Length();
372 TString bitthreestr = " ROCs with status bit 3! BAD! data from fee server was old or corrupt.\n DCS IDs: ";
373 Int_t lengththree = bitthreestr.Length();
374 TString bittwostr = " ROCs with status bit 2. These have been in states in which they cannot be read out, e.g. Standby.\n DCS IDs: ";
375 Int_t lengthtwo = bittwostr.Length();
376 TString bitonestr = " ROCs with status bit 1! BAD! This means the chamber(s) didn't respont even though is should have been in a good state.\n DCS IDs: ";
377 Int_t lengthone = bitonestr.Length();
378
379
380 Int_t nSB1=0, nSB2=0, nSB3=0, nSB4=0, nSB5=0, nTot=0, nChanged=0;
381 { // Scoped declaration
382
383 // Determine the size of the array
384 Int_t feeArrSiz = 0;
385 if (calVer == 1) {
386 if(((AliTRDCalDCS*)caldcs)->GetFEEArr())
387 feeArrSiz = ((AliTRDCalDCS*)caldcs)->GetFEEArr()->GetSize();
388 }
389 else if (calVer == 2) {
390 if(((AliTRDCalDCSv2*)caldcs)->GetFEEArr())
391 feeArrSiz = ((AliTRDCalDCSv2*)caldcs)->GetFEEArr()->GetSize();
392 }
393
394 // Check the status/error bist for each ROC
395 TObject* idcsfee;
396 TObject* idcsfee2;
397 // Loop over the ROCs / the array
398 for (Int_t i=0; i<nROC && i<feeArrSiz; i++) {
399 if (calVer == 1) idcsfee = ((AliTRDCalDCS*)caldcs)->GetCalDCSFEEObj(i);
400 else if (calVer == 2) idcsfee = ((AliTRDCalDCSv2*)caldcs)->GetCalDCSFEEObj(i);
401 if (idcsfee != NULL) {
402 Int_t sb;
403 if (calVer == 1) sb = ((AliTRDCalDCSFEE*)idcsfee)->GetStatusBit();
404 else if (calVer == 2) sb = ((AliTRDCalDCSFEEv2*)idcsfee)->GetStatusBit();
405 if (sb == 5) { bitfivestr += i; bitfivestr += " "; nSB5++; }
406 else if (sb == 4) { bitfourstr += i; bitfourstr += " "; nSB4++; errors = true; }
407 else if (sb == 3) { bitthreestr += i; bitthreestr += " "; nSB3++; errors = true; }
408 else if (sb == 2) { bittwostr += i; bittwostr += " "; nSB2++; }
409 else if (sb == 1) { bitonestr += i; bitonestr += " "; nSB1++; errors = true; }
410 nTot += 1;
411 }
412 } // End of loop over ROCs
413
414 // Print the statistcs for the status/error bits
415 if (lengthfive < bitfivestr.Length()) cout << nSB5 << bitfivestr.Data() << endl << endl;
416 if (lengthfour < bitfourstr.Length()) cout << nSB4 << bitfourstr.Data() << endl << endl;
417 if (lengththree < bitthreestr.Length()) cout << nSB3 << bitthreestr.Data() << endl << endl;
418 if (lengthtwo < bittwostr.Length()) cout << nSB2 << bittwostr.Data() << endl << endl;
419 if (lengthone < bitonestr.Length()) cout << nSB1 << bitonestr.Data() << endl << endl;
420
421 cout << "The remaining " << nTot-(nSB1+nSB2+nSB3+nSB4+nSB5) << " ROCs responded correctly in the start of run."<<endl;
422
423 // Reusing nTot
424 nTot=0;
425 for (Int_t i=0; i<nROC && i<feeArrSiz; i++) {
426 if (calVer == 1) {
427 if (caldcs) idcsfee = ((AliTRDCalDCS*)caldcs)->GetCalDCSFEEObj(i);
428 if (caldcs2) idcsfee2 = ((AliTRDCalDCS*)caldcs2)->GetCalDCSFEEObj(i);
429 }
430 else if (calVer == 2) {
431 if (caldcs) idcsfee = ((AliTRDCalDCSv2*)caldcs)->GetCalDCSFEEObj(i);
432 if (caldcs2) idcsfee2 = ((AliTRDCalDCSv2*)caldcs2)->GetCalDCSFEEObj(i);
433 }
434 if (idcsfee != NULL && idcsfee2 != NULL) {
435 Int_t sbd1 = 0;
436 Int_t sbd2 = 0;
437 if (calVer == 1) {
438 sbd1 = ((AliTRDCalDCSFEE*)idcsfee)->GetStatusBit();
439 sbd2 = ((AliTRDCalDCSFEE*)idcsfee2)->GetStatusBit();
440 }
441 if (calVer == 2) {
442 sbd1 = ((AliTRDCalDCSFEEv2*)idcsfee)->GetStatusBit();
443 sbd2 = ((AliTRDCalDCSFEEv2*)idcsfee2)->GetStatusBit();
444 }
445 Int_t sbd = sbd1 - sbd2;
446 if (sbd != 0) {
447 cout << "ROC " << i << " changed from state " << sbd1 << " at start of the run to " << sbd2 << " at the end of the run." << endl;
448 cout << "ROC " << i << " changed from state " << sbd1 << " at start of the run to " << sbd2 << " at the end of the run." << endl;
449 nChanged++;
450 }
451 nTot += 1;
452 }
453 } // End of loop over ROCs
454 } // End of scoped declaration
455 if (nChanged == 0) {
456 cout << "No ROCs changed state between the start and end of the run" << endl;
457 } else {
458 cout << "E : " << nChanged << " out of " << nTot << " ROCs changed state during the run" << endl;
459 errors = true;
460 }
461
462 cout << endl << "============ Statistics from RSTATE: ============" << endl;
463 cout<<"I : The majority entry is given as well as all other values," << endl;
464 cout<<" sorted according to their occurrence." << endl << endl;
465 GetMajoritys(caldcs);
466 if (sorandeor) GetMajorityDifferences(caldcs,caldcs2);
467
468 cout << endl << "============ Global Configuraton: ============" << endl;
469 cout<<"I : Anything not listed is not set, mixed numbers are indicated with a" << endl;
470 cout<<" value of -2 and strings are set to 'mixed' if they're mixed." << endl << endl;
471
472 Int_t gtb, gct, gsh, gtc, gsz, gfw, gfs, gfl, gsn;
473 TString gcv, gcn, gft, grp, gtp, gtm, gtd, gts, gao;
474
475 if (calVer == 1) {
476 gtb = ((AliTRDCalDCS*)caldcs)->GetGlobalNumberOfTimeBins();
477 gct = ((AliTRDCalDCS*)caldcs)->GetGlobalConfigTag();
478 gsh = ((AliTRDCalDCS*)caldcs)->GetGlobalSingleHitThres();
479 gtc = ((AliTRDCalDCS*)caldcs)->GetGlobalThreePadClustThres();
480 gsz = ((AliTRDCalDCS*)caldcs)->GetGlobalSelectiveNoZS();
481 gfw = ((AliTRDCalDCS*)caldcs)->GetGlobalTCFilterWeight();
482 gfs = ((AliTRDCalDCS*)caldcs)->GetGlobalTCFilterShortDecPar();
483 gfl = ((AliTRDCalDCS*)caldcs)->GetGlobalTCFilterLongDecPar();
484 gsn = ((AliTRDCalDCS*)caldcs)->GetGlobalModeFastStatNoise();
485 gcv = ((AliTRDCalDCS*)caldcs)->GetGlobalConfigVersion();
486 gcn = ((AliTRDCalDCS*)caldcs)->GetGlobalConfigName();
487 gft = ((AliTRDCalDCS*)caldcs)->GetGlobalFilterType();
488 grp = ((AliTRDCalDCS*)caldcs)->GetGlobalReadoutParam();
489 gtp = ((AliTRDCalDCS*)caldcs)->GetGlobalTestPattern();
490 gtm = ((AliTRDCalDCS*)caldcs)->GetGlobalTrackletMode();
491 gtd = ((AliTRDCalDCS*)caldcs)->GetGlobalTrackletDef();
492 gts = ((AliTRDCalDCS*)caldcs)->GetGlobalTriggerSetup();
493 gao = ((AliTRDCalDCS*)caldcs)->GetGlobalAddOptions();
494 }
495 else if (calVer == 2) {
496 gtb = ((AliTRDCalDCSv2*)caldcs)->GetGlobalNumberOfTimeBins();
497 gct = ((AliTRDCalDCSv2*)caldcs)->GetGlobalConfigTag();
498 gsh = ((AliTRDCalDCSv2*)caldcs)->GetGlobalSingleHitThres();
499 gtc = ((AliTRDCalDCSv2*)caldcs)->GetGlobalThreePadClustThres();
500 gsz = ((AliTRDCalDCSv2*)caldcs)->GetGlobalSelectiveNoZS();
501 gfw = ((AliTRDCalDCSv2*)caldcs)->GetGlobalTCFilterWeight();
502 gfs = ((AliTRDCalDCSv2*)caldcs)->GetGlobalTCFilterShortDecPar();
503 gfl = ((AliTRDCalDCSv2*)caldcs)->GetGlobalTCFilterLongDecPar();
504 gsn = ((AliTRDCalDCSv2*)caldcs)->GetGlobalModeFastStatNoise();
505 gcv = ((AliTRDCalDCSv2*)caldcs)->GetGlobalConfigVersion();
506 gcn = ((AliTRDCalDCSv2*)caldcs)->GetGlobalConfigName();
507 gft = ((AliTRDCalDCSv2*)caldcs)->GetGlobalFilterType();
508 grp = ((AliTRDCalDCSv2*)caldcs)->GetGlobalReadoutParam();
509 gtp = ((AliTRDCalDCSv2*)caldcs)->GetGlobalTestPattern();
510 gtm = ((AliTRDCalDCSv2*)caldcs)->GetGlobalTrackletMode();
511 gtd = ((AliTRDCalDCSv2*)caldcs)->GetGlobalTrackletDef();
512 gts = ((AliTRDCalDCSv2*)caldcs)->GetGlobalTriggerSetup();
513 gao = ((AliTRDCalDCSv2*)caldcs)->GetGlobalAddOptions();
514 }
515
516
517 if (gtb != -1) cout<<"Global number of time bins.........................: "<< gtb << endl;
518 if (gct != -1) cout<<"Global configuration tag...........................: "<< gct << endl;
519 if (gsh != -1) cout<<"Global single hit threshold........................: "<< gsh << endl;
520 if (gtc != -1) cout<<"Global three pad cluster threshold.................: "<< gtc << endl;
521 if (gsz != -1) cout<<"Global selective ZS (every i'th event).............: "<< gsz << endl;
522 if (gfw != -1) cout<<"Global tail cancellation filter weight.............: "<< gfs << endl;
523 if (gfs != -1) cout<<"Global tail cancellat. filter short decay parameter: "<< gfs << endl;
524 if (gfl != -1) cout<<"Global tail cancellation filt. long decay parameter: "<< gfl << endl;
525 if (gsn != -1) cout<<"Global fast statistics mode?.......................: "<< gsn << endl;
526 if (gcv != "") cout<<"Global configuration tag version...................: "<< gcv << endl;
527 if (gcn != "") cout<<"Global configuration tag name......................: "<< gcn << endl;
528 if (gft != "") cout<<"Global filter type.................................: "<< gft << endl;
529 if (grp != "") cout<<"Global readout parameter...........................: "<< grp << endl;
530 if (gtp != "") cout<<"Global test pattern................................: "<< gtp << endl;
531 if (gtm != "") cout<<"Global tracklet mode...............................: "<< gtm << endl;
532 if (gtd != "") cout<<"Global tracklet definition.........................: "<< gtd << endl;
533 if (gts != "") cout<<"Global trigger setup...............................: "<< gts << endl;
534 if (gao != "") cout<<"Global additional options..........................: "<< gao << endl;
535
536 cout << endl << "============ Error Summary: ============" << endl;
537 if (errors) {
538 cout<<" I noticed some errors, please see above for the specifics." << endl;
539 } else {
540 cout<<" I didn't notice any errors, but that doesn't mean there weren't any!" << endl;
541 }
542//______________________________________________________________________
543}
544void AliTRDcheckConfig(Int_t runNr=0, const char *pathfile="nopathgiven"){
545 // Wrapping the function to be able to clean up
546 TFile *f=0;
547 WrappedAliTRDcheckConfig(runNr,pathfile,f);
548 AliCDBManager::Destroy();
549 if(f){
550 delete f; // Destructor calls TFile::Close()
551 f=0;
552 }
553}
554//______________________________________________________________________
555//
556// The stuff below is only for compiling a standalone program,
557// i.e., without root / aliroot
558//
559#if !defined(__CINT__)
560//______________________________________________________________________
561void reduceTimeOuts(){
562 // Reduces the grid timeouts
563 gEnv->SetValue("XNet.ConnectTimeout" , 20);
564 gEnv->SetValue("XNet.RequestTimeout" , 40);
565 gEnv->SetValue("XNet.MaxRedirectCount" , 2);
566 gEnv->SetValue("XNet.ReconnectWait" , 2);
567 gEnv->SetValue("XNet.FirstConnectMaxCnt", 3);
568 gEnv->SetValue("XNet.TransactionTimeout",300);
569}
570//______________________________________________________________________
571void printHelp(const char* argv0){
572 cout <<"Usuage: "<<argv0<< " [arg1 [arg2]]"<<endl
573 <<"Where arg1 can be:"<<endl
574 <<" of type int-> gets treated as run number"<<endl
575 <<" *.txt -> gets treated as list of run numbers"<<endl
576 <<" *.root -> gets treated as OCDB entry"<<endl
577 <<" -h,--help -> displays this help"<<endl
578 <<"and arg2 can be"<<endl
579 <<" -f, --fast -> reduces grid timeouts"<<endl;
580}
581//______________________________________________________________________
582int main(int argc,char** argv){
583 // This macro is a standalone program.
584
585 // We change the meaning of the input
586 // parameters a bit. See the help message
587
588 // Error if too many arguments
589 if(argc>3){
590 cout << "Too many arguments!"<<endl;
591 printHelp(argv[0]);
592 return 1;
593 }
594
595 // Check the argument two if any
596 if(argc>2){
597 if( (!strcmp("-f",argv[2])) ||
598 (!strcmp("--fast",argv[2])) ){
599 reduceTimeOuts();
600 }
601 else {
602 cout <<"Couldn't recognize your argument "
603 <<argv[2]<<endl;
604 printHelp(argv[0]);
605 return 1;
606 }
607 }
608
609 // Check argument one
610 if(argc>1){
611 // Convert to TString for easier handling
612 TString input(argv[1]);
613 // Help message
614 if( (!strcmp("-h",argv[1])) ||
615 (!strcmp("--help",argv[1])) ) {
616 printHelp(argv[0]);
617 return 0;
618 }
619 // int aka run number provided
620 else if(input.IsDigit()){
621 AliTRDcheckConfig(input.Atoi());
622 return 0;
623 }
624 // .root aka OCDB file provided
625 else if(input.EndsWith(".root")){
626 AliTRDcheckConfig(0,input.Data());
627 return 0;
628 }
629 // .txt aka list of root files provided
630 else if(input.EndsWith(".txt")){
631 // Open the text file
632 ifstream in;
633 in.open(Form("%s",input.Data()));
634 if (!in.is_open()){
635 cout << "F: Could not open file "<<input.Data()<<endl;
636 return 1;
637 }
638 // Loop over entries
639 string line;
640 TString Line;
641 while(in.good()) {
642 // Reading the line in the .txt file works fine
643 if(!getline(in,line)) break;
644 Line=line.data();
645 if(Line.IsNull()) continue;
646 // Run number provided
647 if(Line.IsDigit()){
648 AliTRDcheckConfig(Line.Atoi());
649 }
650 // .root file provided
651 else if(Line.EndsWith(".root")){
652 AliTRDcheckConfig(0,Line.Data());
653 }
654 else {
655 cout <<"Bad line in .txt file: "
656 <<Line.Data()<<endl;
657 }
658 } // End of loop over .txt file lines
659 return 0;
660 }
661 // Bad input, neither .root nor .txt nor int
662 else {
663 cout <<"Cannot recognize your input"
664 <<input.Data()<<endl;
665 printHelp(argv[0]);
666 return 1;
667 }
668 } // End of argc>1
669
670 // Without arguments
671 AliTRDcheckConfig();
672 return 0;
673}// End of main
674
675// End of the non-root part
676#endif