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