]>
Commit | Line | Data |
---|---|---|
1 | //=================================================================================== | |
2 | // This is a macro to analyze TRD/Calib/DCS OCDB objects either | |
3 | // from the grid for a given run number or from a local object. | |
4 | // If you want to analyze data from the grid, please don't forget to | |
5 | // have a valid alien token initialized and the file /tmp/gclient_env_$UID source'd. | |
6 | // | |
7 | // Arguments: | |
8 | // The first argument is the runnumber (this is ignored in case of a local file), | |
9 | // the second is a string that needs to contain either "grid" or "local". Further | |
10 | // you can add either verbose or quiet to that string. If you don't, you'll be asked | |
11 | // for all stuff individually wether you want to see it or not | |
12 | // the thrid argument is the number of the ROC you (eventually) want to dump its data | |
13 | // member of. | |
14 | // The fourth one is the path and name of the local file you might want to look at. | |
15 | // | |
16 | // So the simplest way to use this macro is if you want to check the output of a given | |
17 | // run from the OCDB: | |
18 | // .x AliTRDcheckConfig.C(60111) | |
19 | // | |
20 | // An example for quickly checking a local file: | |
21 | // .x AliTRDcheckConfig.C(0, "local quiet", 533, "$ALICE_ROOT/TRD/Calib/DCS/Run0_999999999_v0_s0.root") | |
22 | // | |
23 | // Please contact Frederick Kramer in case of problems | |
24 | //=================================================================================== | |
25 | ||
26 | // This is the path one needs to change if the year is no longer 2009 | |
27 | // and the runnumber cannot be found | |
28 | TString alienOcdbPath("alien://folder=/alice/data/2009/OCDB/"); | |
29 | ||
30 | // Do not make changes below here unless you know what your doing | |
31 | ||
32 | const Int_t nROC = 540; | |
33 | const Int_t nROB = 8; | |
34 | const Int_t nMCM = 18; | |
35 | const Int_t cArraySize = 1000; | |
36 | ||
37 | Bool_t errors = false; | |
38 | ||
39 | Int_t AnalyzeArray(Int_t states[cArraySize], Int_t occur[cArraySize]) { | |
40 | long long srtIndx[cArraySize] = 0; | |
41 | ||
42 | TMath::Sort(cArraySize, occur, srtIndx); | |
43 | ||
44 | Int_t totalSum = 0, subSum = 0, iIndex = 0; | |
45 | for (Int_t i=0; i<cArraySize; i++) totalSum += occur[i]; | |
46 | ||
47 | cout << " The majority ("<< occur[srtIndx[0]] << " of " | |
48 | << totalSum <<") is: " << states[srtIndx[0]] << endl; | |
49 | subSum = occur[srtIndx[0]]; | |
50 | while (totalSum != subSum) { | |
51 | if (++iIndex > 999) { | |
52 | cout << "E : out of bounds." << endl; | |
53 | break; | |
54 | } | |
55 | Printf(" Next: %7d (%d)", states[srtIndx[iIndex]], occur[srtIndx[iIndex]]); | |
56 | subSum += occur[srtIndx[iIndex]]; | |
57 | } | |
58 | return states[srtIndx[0]]; | |
59 | } | |
60 | ||
61 | ||
62 | ||
63 | void FillItemInArray(Int_t states[cArraySize], Int_t occur[cArraySize], Int_t item, Bool_t allowNeg) { | |
64 | for (Int_t iArrPos=0; iArrPos<cArraySize; iArrPos++) { | |
65 | // if allowNeg is set then we change the number indicating that the item ws not set from -1 to -100 | |
66 | // so that small negitive numbers can be sorted too | |
67 | if ((allowNeg && item == -100000) || (!allowNeg && item == -1)) break; // value not set | |
68 | if (states[iArrPos] == item) { | |
69 | occur[iArrPos]++; | |
70 | break; | |
71 | } else if (occur[iArrPos] == 0) { | |
72 | states[iArrPos] = item; | |
73 | occur[iArrPos]++; | |
74 | break; | |
75 | } | |
76 | } | |
77 | } | |
78 | ||
79 | void GetMajoritys(AliTRDCalDCS* calDCSObj) { | |
80 | ||
81 | Int_t gsmStates[cArraySize] = {0}, gsmOccur[cArraySize] = {0}; | |
82 | Int_t nimStates[cArraySize] = {0}, nimOccur[cArraySize] = {0}; | |
83 | Int_t nevStates[cArraySize] = {0}, nevOccur[cArraySize] = {0}; | |
84 | Int_t nptStates[cArraySize] = {0}, nptOccur[cArraySize] = {0}; | |
85 | ||
86 | for (Int_t i=0; i<cArraySize; i++) { | |
87 | gsmStates[i] = 0; gsmOccur[i] = 0; | |
88 | nimStates[i] = 0; nimOccur[i] = 0; | |
89 | nevStates[i] = 0; nevOccur[i] = 0; | |
90 | nptStates[i] = 0; nptOccur[i] = 0; | |
91 | } | |
92 | ||
93 | for (Int_t i=0; i<nROC && i<calDCSObj->GetFEEArr()->GetSize(); i++) { | |
94 | AliTRDCalDCSFEE *idcsfee = calDCSObj->GetCalDCSFEEObj(i); | |
95 | if ((idcsfee == NULL) || (idcsfee->GetStatusBit() != 0)) continue; | |
96 | for (Int_t j=0; j<nROB; j++) { | |
97 | for (Int_t k=0; k<nMCM; k++) { | |
98 | Int_t igsm = idcsfee->GetMCMGlobalState(j,k); | |
99 | Int_t inim = idcsfee->GetMCMStateNI(j,k); | |
100 | Int_t inev = idcsfee->GetMCMEventCnt(j,k); | |
101 | Int_t inpt = idcsfee->GetMCMPtCnt(j,k); | |
102 | ||
103 | FillItemInArray(gsmStates, gsmOccur, igsm, false); | |
104 | FillItemInArray(nimStates, nimOccur, inim, false); | |
105 | FillItemInArray(nevStates, nevOccur, inev, false); | |
106 | FillItemInArray(nptStates, nptOccur, inpt, false); | |
107 | } | |
108 | } | |
109 | } | |
110 | ||
111 | cout << "I : Global MCM state statistics:" << endl; | |
112 | AnalyzeArray(gsmStates, gsmOccur); | |
113 | cout << "I : Network interface state statistics:" << endl; | |
114 | AnalyzeArray(nimStates, nimOccur); | |
115 | cout << "I : MCM Event counter reading statistics:" << endl; | |
116 | AnalyzeArray(nevStates, nevOccur); | |
117 | cout << "I : MCM PreTrigger counter reading statistics:" << endl; | |
118 | AnalyzeArray(nptStates, nptOccur); | |
119 | ||
120 | return; | |
121 | } | |
122 | ||
123 | ||
124 | ||
125 | void GetMajorityDifferences(AliTRDCalDCS* calDCSObj, AliTRDCalDCS* calDCSObj2) { | |
126 | ||
127 | Int_t gsmStates[cArraySize] = {0}, gsmOccur[cArraySize] = {0}; | |
128 | Int_t nimStates[cArraySize] = {0}, nimOccur[cArraySize] = {0}; | |
129 | Int_t nevStates[cArraySize] = {0}, nevOccur[cArraySize] = {0}; | |
130 | Int_t nptStates[cArraySize] = {0}, nptOccur[cArraySize] = {0}; | |
131 | ||
132 | for (Int_t i=0; i<cArraySize; i++) { | |
133 | gsmStates[i] = 0; gsmOccur[i] = 0; | |
134 | nimStates[i] = 0; nimOccur[i] = 0; | |
135 | nevStates[i] = 0; nevOccur[i] = 0; | |
136 | nptStates[i] = 0; nptOccur[i] = 0; | |
137 | } | |
138 | ||
139 | for (Int_t i=0; i<nROC && i<calDCSObj->GetFEEArr()->GetSize() && i<calDCSObj2->GetFEEArr()->GetSize(); i++) { | |
140 | AliTRDCalDCSFEE *idcsfee = calDCSObj->GetCalDCSFEEObj(i); | |
141 | AliTRDCalDCSFEE *idcsfee2 = calDCSObj2->GetCalDCSFEEObj(i); | |
142 | if ((idcsfee == NULL) || (idcsfee2 == NULL) || | |
143 | (idcsfee->GetStatusBit() != 0) /*|| (idcsfee2->GetStatusBit() != 0)*/) continue; | |
144 | for (Int_t j=0; j<nROB; j++) { | |
145 | for (Int_t k=0; k<nMCM; k++) { | |
146 | Int_t igsm = idcsfee->GetMCMGlobalState(j,k)-idcsfee2->GetMCMGlobalState(j,k); | |
147 | Int_t inim = idcsfee->GetMCMStateNI(j,k)-idcsfee2->GetMCMStateNI(j,k); | |
148 | Int_t inev = idcsfee->GetMCMEventCnt(j,k)-idcsfee2->GetMCMEventCnt(j,k); | |
149 | Int_t inpt = idcsfee->GetMCMPtCnt(j,k)-idcsfee2->GetMCMPtCnt(j,k); | |
150 | ||
151 | // if they were set to -1, it means they were not actauuly set | |
152 | // change -1 to -100 to mean they werent set since the above | |
153 | // can give negitives | |
154 | if (idcsfee->GetMCMGlobalState(j,k) == -1 && igsm == 0) igsm =-100000; | |
155 | if (idcsfee->GetMCMStateNI(j,k) == -1 && inim == 0) inim =-100000; | |
156 | if (idcsfee->GetMCMEventCnt(j,k) == -1 && inev == 0) inev =-100000; | |
157 | if (idcsfee->GetMCMPtCnt(j,k) == -1 && inpt == 0) inpt =-100000; | |
158 | ||
159 | FillItemInArray(gsmStates, gsmOccur, igsm, true); | |
160 | FillItemInArray(nimStates, nimOccur, inim, true); | |
161 | FillItemInArray(nevStates, nevOccur, inev, true); | |
162 | FillItemInArray(nptStates, nptOccur, inpt, true); | |
163 | } | |
164 | } | |
165 | } | |
166 | ||
167 | cout << "I : Global MCM state difference statistics:" << endl; | |
168 | AnalyzeArray(gsmStates, gsmOccur); | |
169 | cout << "I : Network interface state difference statistics:" << endl; | |
170 | AnalyzeArray(nimStates, nimOccur); | |
171 | cout << "I : MCM Event counter difference statistics:" << endl; | |
172 | if (AnalyzeArray(nevStates, nevOccur) < 1) { | |
173 | cout << "E : There should have been some events recorded, but there weren't" << endl; | |
174 | errors = true; | |
175 | } | |
176 | cout << "I : MCM PreTrigger counter difference statistics:" << endl; | |
177 | if (AnalyzeArray(nptStates, nptOccur) < 1) { | |
178 | cout << "E : There should have been some events recorded, but there weren't" << endl; | |
179 | errors = true; | |
180 | } | |
181 | ||
182 | return; | |
183 | } | |
184 | ||
185 | ||
186 | void AliTRDcheckConfig(Int_t runNr=0, char *pathfile="nopathgiven"){ | |
187 | ||
188 | AliCDBEntry *entry=0; | |
189 | TString pathfilets(pathfile); | |
190 | ||
191 | // get the source | |
192 | if(pathfilets.Contains("nopathgiven")) { | |
193 | cout << "I : Accessing grid storage for run number " << runNr << endl; | |
194 | cout << "I : Get CDBManager instance." << endl; | |
195 | AliCDBManager *man = AliCDBManager::Instance(); | |
196 | cout << "I : SetDefaultStorage." << endl; | |
197 | man->SetDefaultStorage(alienOcdbPath); | |
198 | cout << "I : Get OCDB Entry." << endl; | |
199 | entry = man->Get("TRD/Calib/DCS", runNr); | |
200 | if (entry == NULL) { | |
201 | cout << endl << "ERROR: Unable to get the AliTRDCalDCS object from the OCDB for run number " << runNr << endl << endl; | |
202 | cout << "If the run number is correct, it could be that the year is no longer 2009 and" << endl; | |
203 | cout << "the path where the objects is stored has changed, check the top of this macro " << endl; | |
204 | cout << "to change the path." << endl; | |
205 | return; | |
206 | } | |
207 | } else { | |
208 | cout << "I : Accessing local storage" << endl; | |
209 | TFile *f = new TFile(pathfile); | |
210 | if(f != NULL) { | |
211 | entry = (AliCDBEntry*) f->Get("AliCDBEntry"); | |
212 | } | |
213 | else { | |
214 | cout << "E : Cannot open file" << endl; | |
215 | return; | |
216 | } | |
217 | } | |
218 | ||
219 | TObject *objectCDB = (TObject*)entry->GetObject(); | |
220 | if (objectCDB->IsA()->InheritsFrom("TObjArray")) { | |
221 | TObjArray *objArrayCDB = (TObjArray*)entry->GetObject(); | |
222 | } | |
223 | ||
224 | // the CalDCS object | |
225 | AliTRDCalDCS *caldcs; | |
226 | AliTRDCalDCS *caldcs2; | |
227 | ||
228 | Bool_t sorandeor = true; | |
229 | ||
230 | caldcs = (AliTRDCalDCS*) objArrayCDB->At(0); | |
231 | caldcs2 = (AliTRDCalDCS*) objArrayCDB->At(1); | |
232 | ||
233 | if (caldcs == NULL && caldcs2 == NULL) { | |
234 | cout << "E : Niether the start or end of run files were in the root file."; | |
235 | return; | |
236 | } else if (caldcs != NULL && caldcs2 == NULL) { | |
237 | cout << "E : The EOR file was not in the root file."; | |
238 | errors = true; | |
239 | sorandeor = false; | |
240 | } else if (caldcs == NULL && caldcs2 != NULL) { | |
241 | cout << "E : The SOR file was not in the root file."; | |
242 | errors = true; | |
243 | sorandeor = false; | |
244 | caldcs = caldcs2; | |
245 | } | |
246 | ||
247 | cout << endl << "============ Non responding ROC Summary: ============" << endl; | |
248 | 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: "; | |
249 | Int_t lengthfive = bitfivestr.Length(); | |
250 | 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: "; | |
251 | Int_t lengthfour = bitfourstr.Length(); | |
252 | TString bitthreestr = " ROCs with status bit 3! BAD! data from fee server was old or corrupt.\n DCS IDs: "; | |
253 | Int_t lengththree = bitthreestr.Length(); | |
254 | 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: "; | |
255 | Int_t lengthtwo = bittwostr.Length(); | |
256 | 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: "; | |
257 | Int_t lengthone = bitonestr.Length(); | |
258 | ||
259 | Int_t nSB1=0, nSB2=0, nSB3=0, nSB4=0, nSB5=0, nTot=0; | |
260 | for (Int_t i=0; i<nROC && i<caldcs->GetFEEArr()->GetSize(); i++) { | |
261 | AliTRDCalDCSFEE *idcsfee; | |
262 | idcsfee = caldcs->GetCalDCSFEEObj(i); | |
263 | if (idcsfee != NULL) { | |
264 | Int_t sb = idcsfee->GetStatusBit(); | |
265 | if (sb == 5) { bitfivestr += i; bitfivestr += " "; nSB5++; } | |
266 | if (sb == 4) { bitfourstr += i; bitfourstr += " "; nSB4++; errors = true; } | |
267 | if (sb == 3) { bitthreestr += i; bitthreestr += " "; nSB3++; errors = true; } | |
268 | if (sb == 2) { bittwostr += i; bittwostr += " "; nSB2++; } | |
269 | if (sb == 1) { bitonestr += i; bitonestr += " "; nSB1++; errors = true; } | |
270 | nTot += 1; | |
271 | } | |
272 | } | |
273 | ||
274 | if (lengthfive < bitfivestr.Length()) cout << nSB5 << bitfivestr.Data() << endl << endl; | |
275 | if (lengthfour < bitfourstr.Length()) cout << nSB4 << bitfourstr.Data() << endl << endl; | |
276 | if (lengththree < bitthreestr.Length()) cout << nSB3 << bitthreestr.Data() << endl << endl; | |
277 | if (lengthtwo < bittwostr.Length()) cout << nSB2 << bittwostr.Data() << endl << endl; | |
278 | if (lengthone < bitonestr.Length()) cout << nSB1 << bitonestr.Data() << endl << endl; | |
279 | ||
280 | cout << "The remaining " << nTot-(nSB1+nSB2+nSB3+nSB4+nSB5) << " ROCs responded correctly in the start of run."<<endl; | |
281 | ||
282 | Int_t nChanged=0, nTot=0; | |
283 | for (Int_t i=0; i<nROC && i<caldcs->GetFEEArr()->GetSize(); i++) { | |
284 | AliTRDCalDCSFEE *idcsfee; | |
285 | idcsfee = caldcs->GetCalDCSFEEObj(i); | |
286 | idcsfee2 = caldcs2->GetCalDCSFEEObj(i); | |
287 | if (idcsfee != NULL && idcsfee2 != NULL) { | |
288 | Int_t sbd = idcsfee->GetStatusBit() - idcsfee2->GetStatusBit(); | |
289 | if (sbd != 0) { | |
290 | cout << "ROC " << i << " changed from state " << idcsfee->GetStatusBit() << " at start of the run to " << idcsfee2->GetStatusBit() << " at the end of the run." << endl; | |
291 | nChanged++; | |
292 | } | |
293 | nTot += 1; | |
294 | } | |
295 | } | |
296 | ||
297 | if (nChanged == 0) { | |
298 | cout << "No ROCs changed state between the start and end of the run" << endl; | |
299 | } else { | |
300 | cout << "E : " << nChanged << " out of " << nTot << " ROCs changed state during the run" << endl; | |
301 | errors = true; | |
302 | } | |
303 | ||
304 | cout << endl << "============ Statistics from RSTATE: ============" << endl; | |
305 | cout<<"I : The majority entry is given as well as all other values," << endl; | |
306 | cout<<" sorted according to their occurrence." << endl << endl; | |
307 | GetMajoritys(caldcs); | |
308 | if (sorandeor) GetMajorityDifferences(caldcs,caldcs2); | |
309 | ||
310 | cout << endl << "============ Global Configuraton: ============" << endl; | |
311 | cout<<"I : Anything not listed is not set, mixed numbers are indicated with a" << endl; | |
312 | cout<<" value of -2 and strings are set to 'mixed' if they're mixed." << endl << endl; | |
313 | if (caldcs->GetGlobalNumberOfTimeBins() != -1) | |
314 | cout<<"Global number of time bins.........................: "<<caldcs->GetGlobalNumberOfTimeBins() << endl; | |
315 | if (caldcs->GetGlobalConfigTag() != -1) | |
316 | cout<<"Global configuration tag...........................: "<<caldcs->GetGlobalConfigTag() << endl; | |
317 | if (caldcs->GetGlobalSingleHitThres() != -1) | |
318 | cout<<"Global single hit threshold........................: "<<caldcs->GetGlobalSingleHitThres() << endl; | |
319 | if (caldcs->GetGlobalThreePadClustThres() != -1) | |
320 | cout<<"Global three pad cluster threshold.................: "<<caldcs->GetGlobalThreePadClustThres()<<endl; | |
321 | if (caldcs->GetGlobalSelectiveNoZS() != -1) | |
322 | cout<<"Global selective ZS (every i'th event).............: "<<caldcs->GetGlobalSelectiveNoZS() << endl; | |
323 | if (caldcs->GetGlobalTCFilterWeight() != -1) | |
324 | cout<<"Global tail cancellation filter weight.............: "<<caldcs->GetGlobalTCFilterWeight() << endl; | |
325 | if (caldcs->GetGlobalTCFilterShortDecPar() != -1) | |
326 | cout<<"Global tail cancellat. filter short decay parameter: "<<caldcs->GetGlobalTCFilterShortDecPar()<<endl; | |
327 | if (caldcs->GetGlobalTCFilterLongDecPar() != -1) | |
328 | cout<<"Global tail cancellation filt. long decay parameter: "<<caldcs->GetGlobalTCFilterLongDecPar()<<endl; | |
329 | if (caldcs->GetGlobalModeFastStatNoise() != -1) | |
330 | cout<<"Global fast statistics mode?.......................: "<<caldcs->GetGlobalModeFastStatNoise() << endl; | |
331 | if (caldcs->GetGlobalConfigVersion() != "") | |
332 | cout<<"Global configuration tag version...................: "<<caldcs->GetGlobalConfigVersion() << endl; | |
333 | if (caldcs->GetGlobalConfigName() != "") | |
334 | cout<<"Global configuration tag name......................: "<<caldcs->GetGlobalConfigName() << endl; | |
335 | if (caldcs->GetGlobalFilterType() != "") | |
336 | cout<<"Global filter type.................................: "<<caldcs->GetGlobalFilterType() << endl; | |
337 | if (caldcs->GetGlobalReadoutParam() != "") | |
338 | cout<<"Global readout parameter...........................: "<<caldcs->GetGlobalReadoutParam() << endl; | |
339 | if (caldcs->GetGlobalTestPattern() != "") | |
340 | cout<<"Global test pattern................................: "<<caldcs->GetGlobalTestPattern() << endl; | |
341 | if (caldcs->GetGlobalTrackletMode() != "") | |
342 | cout<<"Global tracklet mode...............................: "<<caldcs->GetGlobalTrackletMode() << endl; | |
343 | if (caldcs->GetGlobalTrackletDef() != "") | |
344 | cout<<"Global tracklet definition.........................: "<<caldcs->GetGlobalTrackletDef() << endl; | |
345 | if (caldcs->GetGlobalTriggerSetup() != "") | |
346 | cout<<"Global trigger setup...............................: "<<caldcs->GetGlobalTriggerSetup() << endl; | |
347 | if (caldcs->GetGlobalAddOptions() != "") | |
348 | cout<<"Global additional options..........................: "<<caldcs->GetGlobalAddOptions() << endl; | |
349 | ||
350 | cout << endl << "============ Error Summary: ============" << endl; | |
351 | if (errors) { | |
352 | cout<<" I noticed some errors, please see above for the specifics." << endl; | |
353 | } else { | |
354 | cout<<" I didn't notice any errors, but that doesn't mean there weren't any!" << endl; | |
355 | } | |
356 | ||
357 | ||
358 | } |