]>
Commit | Line | Data |
---|---|---|
de01cdf0 | 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 | /* $Id$ */ | |
17 | ||
3d1463c8 | 18 | //----------------------------------------------------------------------------- |
a99c3449 | 19 | /// \namespace AliMUONCDB |
de01cdf0 | 20 | /// |
a99c3449 | 21 | /// Helper functions to experience the OCDB |
22 | /// | |
23 | /// They allow to read magnetic field, mapping and recoParam from OCDB | |
24 | /// | |
25 | /// And also to generate dummy (but complete) containers for all the | |
de01cdf0 | 26 | /// calibration data types we have for tracker and trigger, and to write |
27 | /// them into OCDB. | |
28 | /// | |
a99c3449 | 29 | /// For more information, please see READMEcalib |
de01cdf0 | 30 | /// |
baf1a7a0 | 31 | /// \author Laurent Aphecetche |
3d1463c8 | 32 | //----------------------------------------------------------------------------- |
de01cdf0 | 33 | |
34 | #include "AliMUONCDB.h" | |
35 | ||
de01cdf0 | 36 | #include "AliMUON1DArray.h" |
37 | #include "AliMUON1DMap.h" | |
38 | #include "AliMUON2DMap.h" | |
39 | #include "AliMUON2DStoreValidator.h" | |
7eafe398 | 40 | #include "AliMUONCalibParamND.h" |
de01cdf0 | 41 | #include "AliMUONCalibParamNF.h" |
42 | #include "AliMUONCalibParamNI.h" | |
207947f7 | 43 | #include "AliMUONCalibrationData.h" |
de01cdf0 | 44 | #include "AliMUONConstants.h" |
207947f7 | 45 | #include "AliMUONGlobalCrateConfig.h" |
b37b9546 | 46 | #include "AliMUONLogger.h" |
207947f7 | 47 | #include "AliMUONPadStatusMaker.h" |
48 | #include "AliMUONPadStatusMapMaker.h" | |
49 | #include "AliMUONRecoParam.h" | |
50 | #include "AliMUONRegionalTriggerConfig.h" | |
0045b488 | 51 | #include "AliMUONRejectList.h" |
9e7c4517 | 52 | #include "AliMUONTrackerData.h" |
49419555 | 53 | #include "AliMUONTrackerIO.h" |
de01cdf0 | 54 | #include "AliMUONTriggerEfficiencyCells.h" |
55 | #include "AliMUONTriggerLut.h" | |
de01cdf0 | 56 | #include "AliMUONVCalibParam.h" |
57 | #include "AliMUONVCalibParam.h" | |
207947f7 | 58 | #include "AliMUONVStore.h" |
59 | ||
25e1df3e | 60 | #include "AliMpCDB.h" |
a0eca509 | 61 | #include "AliMpConstants.h" |
a99c3449 | 62 | #include "AliMpDEStore.h" |
de01cdf0 | 63 | #include "AliMpDDLStore.h" |
ab167304 | 64 | #include "AliMpManuStore.h" |
de01cdf0 | 65 | #include "AliMpDEManager.h" |
66 | #include "AliMpDetElement.h" | |
92c23b09 | 67 | #include "AliMpFiles.h" |
49e110ec | 68 | #include "AliMpDCSNamer.h" |
409de10f | 69 | #include "AliMpManuIterator.h" |
de01cdf0 | 70 | #include "AliMpSegmentation.h" |
71 | #include "AliMpStationType.h" | |
72 | #include "AliMpVSegmentation.h" | |
92e36663 | 73 | |
74 | #include "AliCodeTimer.h" | |
75 | #include "AliCDBEntry.h" | |
76 | #include "AliCDBManager.h" | |
a99c3449 | 77 | #include "AliGRPManager.h" |
92e36663 | 78 | #include "AliDCSValue.h" |
79 | #include "AliLog.h" | |
a31df857 | 80 | #include "AliMpBusPatch.h" |
92e36663 | 81 | |
de01cdf0 | 82 | #include <Riostream.h> |
83 | #include <TArrayI.h> | |
84 | #include <TClass.h> | |
9e7c4517 | 85 | #include <TFile.h> |
de01cdf0 | 86 | #include <TH1F.h> |
87 | #include <TList.h> | |
88 | #include <TMap.h> | |
89 | #include <TObjString.h> | |
90 | #include <TROOT.h> | |
91 | #include <TRandom.h> | |
92 | #include <TStopwatch.h> | |
93 | #include <TSystem.h> | |
cf27231a | 94 | #include <TMath.h> |
a99c3449 | 95 | #include <TGeoGlobalMagField.h> |
73d3aca5 | 96 | #include <TClonesArray.h> |
a31df857 | 97 | #include <sstream> |
9e7c4517 | 98 | #include <set> |
c05673c9 | 99 | |
de01cdf0 | 100 | namespace |
101 | { | |
409de10f | 102 | //_____________________________________________________________________________ |
103 | AliMUONVStore* Create2DMap() | |
104 | { | |
105 | return new AliMUON2DMap(true); | |
106 | } | |
107 | ||
108 | //_____________________________________________________________________________ | |
046e5fd4 | 109 | void getBoundaries(const AliMUONVStore& store, Int_t dim, |
110 | Float_t* xmin, Float_t* xmax) | |
de01cdf0 | 111 | { |
046e5fd4 | 112 | /// Assuming the store contains AliMUONVCalibParam objects, compute the |
113 | /// limits of the value contained in the VCalibParam, for each of its dimensions | |
114 | /// xmin and xmax must be of dimension dim | |
115 | ||
116 | for ( Int_t i = 0; i < dim; ++i ) | |
117 | { | |
118 | xmin[i]=1E30; | |
119 | xmax[i]=-1E30; | |
120 | } | |
de01cdf0 | 121 | |
a0eca509 | 122 | TIter next(store.CreateIterator()); |
123 | AliMUONVCalibParam* value; | |
de01cdf0 | 124 | |
a0eca509 | 125 | while ( ( value = dynamic_cast<AliMUONVCalibParam*>(next() ) ) ) |
de01cdf0 | 126 | { |
a0eca509 | 127 | Int_t detElemId = value->ID0(); |
128 | Int_t manuId = value->ID1(); | |
de01cdf0 | 129 | |
130 | const AliMpVSegmentation* seg = | |
131 | AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId,manuId); | |
132 | ||
b37b9546 | 133 | if (!seg) continue; |
134 | ||
de01cdf0 | 135 | for ( Int_t manuChannel = 0; manuChannel < value->Size(); ++manuChannel ) |
136 | { | |
168e9c4d | 137 | AliMpPad pad = seg->PadByLocation(manuId,manuChannel,kFALSE); |
de01cdf0 | 138 | if (!pad.IsValid()) continue; |
139 | ||
046e5fd4 | 140 | for ( Int_t i = 0; i < dim; ++i ) |
de01cdf0 | 141 | { |
046e5fd4 | 142 | Float_t x0 = value->ValueAsFloat(manuChannel,i); |
143 | ||
144 | xmin[i] = TMath::Min(xmin[i],x0); | |
145 | xmax[i] = TMath::Max(xmax[i],x0); | |
de01cdf0 | 146 | } |
147 | } | |
046e5fd4 | 148 | } |
149 | ||
150 | for ( Int_t i = 0; i < dim; ++i ) | |
151 | { | |
152 | if ( TMath::Abs(xmin[i]-xmax[i]) < 1E-3 ) | |
153 | { | |
154 | xmin[i] -= 1; | |
155 | xmax[i] += 1; | |
156 | } | |
157 | } | |
de01cdf0 | 158 | } |
159 | ||
cf27231a | 160 | //_____________________________________________________________________________ |
161 | Double_t GetRandom(Double_t mean, Double_t sigma, Bool_t mustBePositive) | |
162 | { | |
163 | Double_t x(-1); | |
164 | if ( mustBePositive ) | |
165 | { | |
166 | while ( x < 0 ) | |
167 | { | |
168 | x = gRandom->Gaus(mean,sigma); | |
169 | } | |
170 | } | |
171 | else | |
172 | { | |
173 | x = gRandom->Gaus(mean,sigma); | |
174 | } | |
175 | return x; | |
176 | } | |
177 | ||
de01cdf0 | 178 | } |
179 | ||
180 | //_____________________________________________________________________________ | |
a99c3449 | 181 | Bool_t AliMUONCDB::CheckOCDB(Bool_t pathOnly) |
de01cdf0 | 182 | { |
a99c3449 | 183 | /// Check that OCDB path and run number are properly set |
184 | ||
185 | AliCDBManager* man = AliCDBManager::Instance(); | |
186 | ||
187 | // first OCDB path | |
188 | if (!man->IsDefaultStorageSet()) { | |
189 | AliErrorGeneral("AliMUONCDB", "OCDB path must be properly set"); | |
190 | return kFALSE; | |
191 | } | |
192 | ||
193 | // then run number if required | |
194 | if (pathOnly) return kTRUE; | |
195 | if (man->GetRun() < 0) { | |
196 | AliErrorGeneral("AliMUONCDB", "Run number must be properly set"); | |
197 | return kFALSE; | |
198 | } | |
199 | ||
200 | return kTRUE; | |
201 | ||
202 | } | |
203 | ||
204 | //_____________________________________________________________________________ | |
205 | Bool_t AliMUONCDB::CheckMapping(Bool_t segmentationOnly) | |
206 | { | |
207 | /// Check that the mapping has been loaded | |
208 | ||
209 | // first the segmentation | |
210 | if (!AliMpSegmentation::Instance(false)) { | |
211 | AliErrorGeneral("AliMUONCDB", "Mapping segmentation must be loaded first"); | |
212 | return kFALSE; | |
213 | } | |
214 | ||
215 | // then the others if required | |
216 | if (segmentationOnly) return kTRUE; | |
217 | if (!AliMpDDLStore::Instance(false) || !AliMpDEStore::Instance(false) || !AliMpManuStore::Instance(false)) { | |
218 | AliErrorGeneral("AliMUONCDB", "Full mapping must be loaded first"); | |
219 | return kFALSE; | |
220 | } | |
221 | ||
222 | return kTRUE; | |
223 | ||
224 | } | |
225 | ||
226 | //_____________________________________________________________________________ | |
227 | Bool_t AliMUONCDB::LoadField() | |
228 | { | |
229 | /// Load magnetic field (existing field will be deleted). | |
230 | /// OCDB path and run number are supposed to be set. | |
231 | ||
232 | AliInfoGeneral("AliMUONCDB","Loading field map from GRP..."); | |
233 | ||
234 | if (!AliMUONCDB::CheckOCDB()) return kFALSE; | |
235 | ||
236 | AliGRPManager grpMan; | |
237 | ||
238 | // make sure the old field is deleted even if it is locked | |
239 | if(TGeoGlobalMagField::Instance()->IsLocked()) delete TGeoGlobalMagField::Instance(); | |
240 | ||
241 | if (!grpMan.ReadGRPEntry() || !grpMan.SetMagField()) { | |
242 | AliErrorGeneral("AliMUONCDB", "failed to load magnetic field from OCDB"); | |
243 | return kFALSE; | |
244 | } | |
245 | ||
246 | return kTRUE; | |
247 | ||
248 | } | |
ab167304 | 249 | |
a99c3449 | 250 | //_____________________________________________________________________________ |
251 | Bool_t AliMUONCDB::LoadMapping(Bool_t segmentationOnly) | |
252 | { | |
253 | /// Load mapping (existing mapping will be unloaded). | |
254 | /// OCDB path and run number are supposed to be set. | |
255 | ||
256 | AliInfoGeneral("AliMUONCDB", "Loading mapping from OCDB..."); | |
257 | ||
258 | if (!AliMUONCDB::CheckOCDB()) return kFALSE; | |
259 | ||
260 | // in case it has already been set | |
261 | AliMpCDB::UnloadAll(); | |
262 | ||
263 | if (segmentationOnly) { | |
264 | ||
265 | if (!AliMpCDB::LoadMpSegmentation(kTRUE)){ | |
266 | AliErrorGeneral("AliMUONCDB", "failed to load segmentation from OCDB"); | |
267 | return kFALSE; | |
268 | } | |
269 | ||
270 | } else { | |
271 | ||
272 | if (!AliMpCDB::LoadAll(kTRUE)) { | |
273 | AliErrorGeneral("AliMUONCDB", "failed to load mapping from OCDB"); | |
274 | return kFALSE; | |
ab167304 | 275 | } |
a99c3449 | 276 | |
277 | } | |
278 | ||
279 | return kTRUE; | |
280 | ||
de01cdf0 | 281 | } |
282 | ||
283 | //_____________________________________________________________________________ | |
a99c3449 | 284 | AliMUONRecoParam* AliMUONCDB::LoadRecoParam() |
de01cdf0 | 285 | { |
a99c3449 | 286 | /// Load and return reconstruction parameters. |
287 | /// OCDB path is supposed to be set. | |
288 | ||
289 | AliInfoGeneral("AliMUONCDB", "Loading RecoParam from OCDB..."); | |
290 | ||
291 | if (!AliMUONCDB::CheckOCDB()) return kFALSE; | |
292 | ||
293 | AliMUONRecoParam* recoParam = 0x0; | |
294 | AliCDBEntry* entry = AliCDBManager::Instance()->Get("MUON/Calib/RecoParam"); | |
295 | ||
296 | if(entry) { | |
297 | ||
298 | // load recoParam according OCDB content (single or array) | |
299 | if (!(recoParam = dynamic_cast<AliMUONRecoParam*>(entry->GetObject()))) { | |
300 | ||
301 | TObjArray* recoParamArray = static_cast<TObjArray*>(entry->GetObject()); | |
302 | ||
303 | for(Int_t i = 0; i < recoParamArray->GetEntriesFast(); i++) { | |
304 | recoParam = static_cast<AliMUONRecoParam*>(recoParamArray->UncheckedAt(i)); | |
305 | if (recoParam->IsDefault()) break; | |
306 | recoParam = 0x0; | |
307 | } | |
308 | ||
309 | } | |
310 | ||
311 | } | |
312 | ||
313 | if (!recoParam) AliErrorGeneral("AliMUONCDB", "failed to load RecoParam from OCDB"); | |
314 | ||
315 | return recoParam; | |
316 | ||
a0eca509 | 317 | } |
318 | ||
319 | //_____________________________________________________________________________ | |
73d3aca5 | 320 | TClonesArray* AliMUONCDB::LoadAlignmentData() |
321 | { | |
322 | /// Load and return the array of alignment objects. | |
323 | ||
324 | AliInfoGeneral("AliMUONCDB", "Loading Alignemnt from OCDB..."); | |
325 | ||
326 | if (!AliMUONCDB::CheckOCDB()) return kFALSE; | |
327 | ||
328 | TClonesArray* alignmentArray = 0x0; | |
329 | AliCDBEntry* entry = AliCDBManager::Instance()->Get("MUON/Align/Data"); | |
330 | ||
331 | if (entry) { | |
332 | // load alignement array | |
333 | alignmentArray = dynamic_cast<TClonesArray*>(entry->GetObject()); | |
334 | } | |
335 | ||
336 | if (!alignmentArray) { | |
337 | AliErrorGeneral("AliMUONCDB", "failed to load Alignemnt from OCDB"); | |
338 | } | |
339 | ||
340 | return alignmentArray; | |
341 | } | |
342 | ||
343 | //_____________________________________________________________________________ | |
a0eca509 | 344 | AliMUONVStore* |
345 | AliMUONCDB::Diff(AliMUONVStore& store1, AliMUONVStore& store2, | |
de01cdf0 | 346 | const char* opt) |
347 | { | |
348 | /// creates a store which contains store1-store2 | |
349 | /// if opt="abs" the difference is absolute one, | |
350 | /// if opt="rel" then what is stored is (store1-store2)/store1 | |
046e5fd4 | 351 | /// if opt="percent" then what is stored is rel*100 |
352 | /// | |
de01cdf0 | 353 | /// WARNING Works only for stores which holds AliMUONVCalibParam objects |
354 | ||
355 | TString sopt(opt); | |
356 | sopt.ToUpper(); | |
357 | ||
046e5fd4 | 358 | if ( !sopt.Contains("ABS") && !sopt.Contains("REL") && !sopt.Contains("PERCENT") ) |
de01cdf0 | 359 | { |
a99c3449 | 360 | AliErrorGeneral("AliMUONCDB", Form("opt %s not supported. Only ABS, REL, PERCENT are",opt)); |
de01cdf0 | 361 | return 0x0; |
362 | } | |
363 | ||
a0eca509 | 364 | AliMUONVStore* d = static_cast<AliMUONVStore*>(store1.Clone()); |
de01cdf0 | 365 | |
a0eca509 | 366 | TIter next(d->CreateIterator()); |
de01cdf0 | 367 | |
a0eca509 | 368 | AliMUONVCalibParam* param; |
de01cdf0 | 369 | |
a0eca509 | 370 | while ( ( param = dynamic_cast<AliMUONVCalibParam*>(next() ) ) ) |
de01cdf0 | 371 | { |
a0eca509 | 372 | Int_t detElemId = param->ID0(); |
373 | Int_t manuId = param->ID1(); | |
de01cdf0 | 374 | |
a0eca509 | 375 | AliMUONVCalibParam* param2 = dynamic_cast<AliMUONVCalibParam*>(store2.FindObject(detElemId,manuId)); |
de01cdf0 | 376 | //FIXME: this might happen. Handle it. |
377 | if (!param2) | |
378 | { | |
379 | cerr << "param2 is null : FIXME : this might happen !" << endl; | |
380 | delete d; | |
381 | return 0; | |
382 | } | |
383 | ||
384 | for ( Int_t i = 0; i < param->Size(); ++i ) | |
385 | { | |
386 | for ( Int_t j = 0; j < param->Dimension(); ++j ) | |
387 | { | |
388 | Float_t value(0); | |
389 | if ( sopt.Contains("ABS") ) | |
390 | { | |
391 | value = param->ValueAsFloat(i,j) - param2->ValueAsFloat(i,j); | |
392 | } | |
046e5fd4 | 393 | else if ( sopt.Contains("REL") || sopt.Contains("PERCENT") ) |
de01cdf0 | 394 | { |
395 | if ( param->ValueAsFloat(i,j) ) | |
396 | { | |
397 | value = (param->ValueAsFloat(i,j) - param2->ValueAsFloat(i,j))/param->ValueAsFloat(i,j); | |
398 | } | |
399 | else | |
400 | { | |
401 | continue; | |
402 | } | |
046e5fd4 | 403 | if ( sopt.Contains("PERCENT") ) value *= 100.0; |
de01cdf0 | 404 | } |
405 | param->SetValueAsFloat(i,j,value); | |
406 | } | |
407 | } | |
de01cdf0 | 408 | } |
409 | return d; | |
410 | } | |
411 | ||
412 | //_____________________________________________________________________________ | |
b37b9546 | 413 | TH1** |
a0eca509 | 414 | AliMUONCDB::Plot(const AliMUONVStore& store, const char* name, Int_t nbins) |
de01cdf0 | 415 | { |
046e5fd4 | 416 | /// Make histograms of each dimension of the AliMUONVCalibParam |
de01cdf0 | 417 | /// contained inside store. |
418 | /// It produces histograms named name_0, name_1, etc... | |
419 | ||
b37b9546 | 420 | if (!AliMUONCDB::CheckMapping(kTRUE)) return 0x0; |
a99c3449 | 421 | |
046e5fd4 | 422 | TIter next(store.CreateIterator()); |
423 | AliMUONVCalibParam* param; | |
de01cdf0 | 424 | Int_t n(0); |
046e5fd4 | 425 | const Int_t kNStations = AliMpConstants::NofTrackingChambers()/2; |
426 | Int_t* nPerStation = new Int_t[kNStations]; | |
427 | TH1** h(0x0); | |
de01cdf0 | 428 | |
046e5fd4 | 429 | for ( Int_t i = 0; i < kNStations; ++i ) nPerStation[i]=0; |
de01cdf0 | 430 | |
046e5fd4 | 431 | while ( ( param = static_cast<AliMUONVCalibParam*>(next()) ) ) |
de01cdf0 | 432 | { |
046e5fd4 | 433 | if (!h) |
434 | { | |
435 | Int_t dim = param->Dimension(); | |
436 | h = new TH1*[dim]; | |
437 | Float_t* xmin = new Float_t[dim]; | |
438 | Float_t* xmax = new Float_t[dim]; | |
439 | getBoundaries(store,dim,xmin,xmax); | |
440 | ||
441 | for ( Int_t i = 0; i < dim; ++i ) | |
442 | { | |
443 | h[i] = new TH1F(Form("%s_%d",name,i),Form("%s_%d",name,i), | |
444 | nbins,xmin[i],xmax[i]); | |
a99c3449 | 445 | AliInfoGeneral("AliMUONCDB", Form("Created histogram %s",h[i]->GetName())); |
046e5fd4 | 446 | } |
f1bf7efd | 447 | delete [] xmin; |
448 | delete [] xmax; | |
046e5fd4 | 449 | } |
450 | ||
451 | Int_t detElemId = param->ID0(); | |
452 | Int_t manuId = param->ID1(); | |
453 | Int_t station = AliMpDEManager::GetChamberId(detElemId)/2; | |
de01cdf0 | 454 | |
455 | const AliMpVSegmentation* seg = | |
456 | AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId,manuId); | |
457 | ||
b37b9546 | 458 | if (!seg) continue; |
459 | ||
046e5fd4 | 460 | for ( Int_t manuChannel = 0; manuChannel < param->Size(); ++manuChannel ) |
de01cdf0 | 461 | { |
168e9c4d | 462 | AliMpPad pad = seg->PadByLocation(manuId,manuChannel,kFALSE); |
046e5fd4 | 463 | if (!pad.IsValid()) continue; |
de01cdf0 | 464 | |
046e5fd4 | 465 | ++n; |
466 | ++nPerStation[station]; | |
467 | ||
468 | for ( Int_t dim = 0; dim < param->Dimension(); ++dim ) | |
469 | { | |
470 | h[dim]->Fill(param->ValueAsFloat(manuChannel,dim)); | |
de01cdf0 | 471 | } |
472 | } | |
046e5fd4 | 473 | } |
de01cdf0 | 474 | |
046e5fd4 | 475 | for ( Int_t i = 0; i < kNStations; ++i ) |
de01cdf0 | 476 | { |
a99c3449 | 477 | AliInfoGeneral("AliMUONCDB", Form("Station %d %d ",(i+1),nPerStation[i])); |
de01cdf0 | 478 | } |
046e5fd4 | 479 | |
a99c3449 | 480 | AliInfoGeneral("AliMUONCDB", Form("Number of channels = %d",n)); |
046e5fd4 | 481 | |
482 | delete[] nPerStation; | |
b37b9546 | 483 | |
484 | return h; | |
de01cdf0 | 485 | } |
486 | ||
487 | //_____________________________________________________________________________ | |
488 | Int_t | |
489 | AliMUONCDB::MakeHVStore(TMap& aliasMap, Bool_t defaultValues) | |
490 | { | |
491 | /// Create a HV store | |
492 | ||
a99c3449 | 493 | if (!AliMUONCDB::CheckMapping()) return 0; |
494 | ||
49e110ec | 495 | AliMpDCSNamer hvNamer("TRACKER"); |
de01cdf0 | 496 | |
497 | TObjArray* aliases = hvNamer.GenerateAliases(); | |
498 | ||
499 | Int_t nSwitch(0); | |
500 | Int_t nChannels(0); | |
501 | ||
502 | for ( Int_t i = 0; i < aliases->GetEntries(); ++i ) | |
503 | { | |
504 | TObjString* alias = static_cast<TObjString*>(aliases->At(i)); | |
505 | TString& aliasName = alias->String(); | |
506 | if ( aliasName.Contains("sw") ) | |
507 | { | |
508 | // HV Switch (St345 only) | |
509 | TObjArray* valueSet = new TObjArray; | |
510 | valueSet->SetOwner(kTRUE); | |
511 | ||
512 | Bool_t value = kTRUE; | |
513 | ||
514 | if (!defaultValues) | |
515 | { | |
a0eca509 | 516 | Float_t r = gRandom->Uniform(); |
de01cdf0 | 517 | if ( r < 0.007 ) value = kFALSE; |
518 | } | |
519 | ||
520 | for ( UInt_t timeStamp = 0; timeStamp < 60*3; timeStamp += 60 ) | |
521 | { | |
522 | AliDCSValue* dcsValue = new AliDCSValue(value,timeStamp); | |
523 | valueSet->Add(dcsValue); | |
524 | } | |
525 | aliasMap.Add(new TObjString(*alias),valueSet); | |
526 | ++nSwitch; | |
527 | } | |
528 | else | |
529 | { | |
530 | TObjArray* valueSet = new TObjArray; | |
531 | valueSet->SetOwner(kTRUE); | |
532 | for ( UInt_t timeStamp = 0; timeStamp < 60*15; timeStamp += 120 ) | |
533 | { | |
534 | Float_t value = 1500; | |
cf27231a | 535 | if (!defaultValues) value = GetRandom(1750,62.5,true); |
de01cdf0 | 536 | AliDCSValue* dcsValue = new AliDCSValue(value,timeStamp); |
537 | valueSet->Add(dcsValue); | |
538 | } | |
539 | aliasMap.Add(new TObjString(*alias),valueSet); | |
540 | ++nChannels; | |
541 | } | |
542 | } | |
543 | ||
544 | delete aliases; | |
545 | ||
a99c3449 | 546 | AliInfoGeneral("AliMUONCDB", Form("%d HV channels and %d switches",nChannels,nSwitch)); |
de01cdf0 | 547 | |
548 | return nChannels+nSwitch; | |
549 | } | |
550 | ||
49e110ec | 551 | //_____________________________________________________________________________ |
552 | Int_t | |
553 | AliMUONCDB::MakeTriggerDCSStore(TMap& aliasMap, Bool_t defaultValues) | |
554 | { | |
555 | /// Create a Trigger HV and Currents store | |
556 | ||
a99c3449 | 557 | if (!AliMUONCDB::CheckMapping()) return 0; |
558 | ||
49e110ec | 559 | AliMpDCSNamer triggerDCSNamer("TRIGGER"); |
560 | ||
561 | TObjArray* aliases = triggerDCSNamer.GenerateAliases(); | |
562 | ||
563 | Int_t nChannels[2] = {0, 0}; | |
564 | ||
565 | for ( Int_t i = 0; i < aliases->GetEntries(); ++i ) | |
566 | { | |
567 | TObjString* alias = static_cast<TObjString*>(aliases->At(i)); | |
568 | TString& aliasName = alias->String(); | |
569 | ||
570 | TObjArray* valueSet = new TObjArray; | |
571 | valueSet->SetOwner(kTRUE); | |
ad30b53f | 572 | |
49e110ec | 573 | Int_t measureType = triggerDCSNamer.DCSvariableFromDCSAlias(aliasName.Data()); |
ad30b53f | 574 | if ( measureType < 0 ) { |
575 | AliErrorGeneralStream("AliMUONCDB") | |
576 | << "Failed to get DCS variable from an alias (trigger): " | |
577 | << aliasName.Data() << endl; | |
578 | return 0; | |
579 | } | |
580 | ||
49e110ec | 581 | for ( UInt_t timeStamp = 0; timeStamp < 60*15; timeStamp += 120 ) |
582 | { | |
583 | Float_t value = | |
9b1e069f | 584 | (measureType == AliMpDCSNamer::kDCSI) ? 2. : 8000.; |
49e110ec | 585 | if (!defaultValues) { |
586 | switch (measureType){ | |
587 | case AliMpDCSNamer::kDCSI: | |
9b1e069f | 588 | value = GetRandom(2.,0.4,true); |
49e110ec | 589 | break; |
590 | case AliMpDCSNamer::kDCSHV: | |
9b1e069f | 591 | value = GetRandom(8000.,16.,true); |
49e110ec | 592 | break; |
593 | } | |
594 | } | |
595 | AliDCSValue* dcsValue = new AliDCSValue(value,timeStamp); | |
596 | valueSet->Add(dcsValue); | |
597 | } | |
598 | aliasMap.Add(new TObjString(*alias),valueSet); | |
599 | ++nChannels[measureType]; | |
600 | } | |
601 | ||
602 | delete aliases; | |
603 | ||
a99c3449 | 604 | AliInfoGeneral("AliMUONCDB", Form("Trigger channels I -> %i HV -> %i",nChannels[0], nChannels[1])); |
49e110ec | 605 | |
606 | return nChannels[0] + nChannels[1]; | |
607 | } | |
608 | ||
de01cdf0 | 609 | //_____________________________________________________________________________ |
610 | Int_t | |
a0eca509 | 611 | AliMUONCDB::MakePedestalStore(AliMUONVStore& pedestalStore, Bool_t defaultValues) |
de01cdf0 | 612 | { |
613 | /// Create a pedestal store. if defaultValues=true, ped.mean=ped.sigma=1, | |
614 | /// otherwise mean and sigma are from a gaussian (with parameters | |
615 | /// defined below by the kPedestal* constants) | |
409de10f | 616 | |
a99c3449 | 617 | AliCodeTimerAutoGeneral("",0); |
618 | ||
619 | if (!AliMUONCDB::CheckMapping()) return 0; | |
de01cdf0 | 620 | |
621 | Int_t nchannels(0); | |
622 | Int_t nmanus(0); | |
623 | ||
a0eca509 | 624 | const Int_t kChannels(AliMpConstants::ManuNofChannels()); |
e7ee8d13 | 625 | |
626 | // bending | |
627 | const Float_t kPedestalMeanMeanB(200.); | |
628 | const Float_t kPedestalMeanSigmaB(10.); | |
629 | const Float_t kPedestalSigmaMeanB(1.); | |
630 | const Float_t kPedestalSigmaSigmaB(0.2); | |
631 | ||
632 | // non bending | |
633 | const Float_t kPedestalMeanMeanNB(200.); | |
634 | const Float_t kPedestalMeanSigmaNB(10.); | |
635 | const Float_t kPedestalSigmaMeanNB(1.); | |
636 | const Float_t kPedestalSigmaSigmaNB(0.2); | |
637 | ||
638 | const Float_t kFractionOfDeadManu(0.); // within [0.,1.] | |
409de10f | 639 | |
640 | Int_t detElemId; | |
641 | Int_t manuId; | |
642 | ||
643 | AliMpManuIterator it; | |
de01cdf0 | 644 | |
409de10f | 645 | while ( it.Next(detElemId,manuId) ) |
de01cdf0 | 646 | { |
e7ee8d13 | 647 | // skip a given fraction of manus |
648 | if (kFractionOfDeadManu > 0. && gRandom->Uniform() < kFractionOfDeadManu) continue; | |
649 | ||
de01cdf0 | 650 | ++nmanus; |
a0eca509 | 651 | |
046e5fd4 | 652 | AliMUONVCalibParam* ped = |
653 | new AliMUONCalibParamNF(2,kChannels,detElemId,manuId,AliMUONVCalibParam::InvalidFloatValue()); | |
409de10f | 654 | |
655 | AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId); | |
de01cdf0 | 656 | |
657 | for ( Int_t manuChannel = 0; manuChannel < kChannels; ++manuChannel ) | |
658 | { | |
409de10f | 659 | if ( ! de->IsConnectedChannel(manuId,manuChannel) ) continue; |
de01cdf0 | 660 | |
661 | ++nchannels; | |
662 | ||
663 | Float_t meanPedestal; | |
664 | Float_t sigmaPedestal; | |
665 | ||
666 | if ( defaultValues ) | |
667 | { | |
668 | meanPedestal = 0.0; | |
669 | sigmaPedestal = 1.0; | |
670 | } | |
671 | else | |
672 | { | |
cf27231a | 673 | Bool_t positive(kTRUE); |
046e5fd4 | 674 | meanPedestal = 0.0; |
e7ee8d13 | 675 | |
676 | if ( manuId & AliMpConstants::ManuMask(AliMp::kNonBendingPlane) ) { // manu in non bending plane | |
677 | ||
678 | while ( meanPedestal == 0.0 ) // avoid strict zero | |
679 | { | |
680 | meanPedestal = GetRandom(kPedestalMeanMeanNB,kPedestalMeanSigmaNB,positive); | |
681 | } | |
682 | sigmaPedestal = GetRandom(kPedestalSigmaMeanNB,kPedestalSigmaSigmaNB,positive); | |
683 | ||
684 | } else { // manu in bending plane | |
685 | ||
686 | while ( meanPedestal == 0.0 ) // avoid strict zero | |
687 | { | |
688 | meanPedestal = GetRandom(kPedestalMeanMeanB,kPedestalMeanSigmaB,positive); | |
689 | } | |
690 | sigmaPedestal = GetRandom(kPedestalSigmaMeanB,kPedestalSigmaSigmaB,positive); | |
691 | ||
692 | } | |
693 | ||
de01cdf0 | 694 | } |
e7ee8d13 | 695 | |
de01cdf0 | 696 | ped->SetValueAsFloat(manuChannel,0,meanPedestal); |
697 | ped->SetValueAsFloat(manuChannel,1,sigmaPedestal); | |
698 | ||
699 | } | |
a0eca509 | 700 | Bool_t ok = pedestalStore.Add(ped); |
de01cdf0 | 701 | if (!ok) |
702 | { | |
a99c3449 | 703 | AliErrorGeneral("AliMUONCDB", Form("Could not set DetElemId=%d manuId=%d",detElemId,manuId)); |
de01cdf0 | 704 | } |
705 | } | |
706 | ||
a99c3449 | 707 | AliInfoGeneral("AliMUONCDB", Form("%d Manus and %d channels.",nmanus,nchannels)); |
de01cdf0 | 708 | return nchannels; |
de01cdf0 | 709 | } |
710 | ||
0045b488 | 711 | //_____________________________________________________________________________ |
712 | AliMUONRejectList* | |
713 | AliMUONCDB::MakeRejectListStore(Bool_t defaultValues) | |
714 | { | |
715 | /// Create a reject list | |
716 | ||
a99c3449 | 717 | AliCodeTimerAutoGeneral("",0); |
0045b488 | 718 | |
719 | AliMUONRejectList* rl = new AliMUONRejectList; | |
720 | ||
721 | if (!defaultValues) | |
722 | { | |
723 | rl->SetDetectionElementProbability(510); | |
724 | rl->SetDetectionElementProbability(508); | |
725 | return rl; | |
726 | } | |
727 | ||
728 | return rl; | |
729 | } | |
730 | ||
2b8a1212 | 731 | //_____________________________________________________________________________ |
732 | Int_t | |
7eafe398 | 733 | AliMUONCDB::MakeOccupancyMapStore(AliMUONVStore& occupancyMapStore, Bool_t defaultValues) |
2b8a1212 | 734 | { |
7eafe398 | 735 | /// Create an occupancy map. |
2b8a1212 | 736 | |
a99c3449 | 737 | AliCodeTimerAutoGeneral("",0); |
738 | ||
739 | if (!AliMUONCDB::CheckMapping()) return 0; | |
2b8a1212 | 740 | |
2b8a1212 | 741 | Int_t nmanus(0); |
742 | ||
2b8a1212 | 743 | Int_t detElemId; |
744 | Int_t manuId; | |
745 | ||
746 | AliMpManuIterator it; | |
747 | ||
7eafe398 | 748 | Int_t nevents(1000); |
749 | ||
2b8a1212 | 750 | while ( it.Next(detElemId,manuId) ) |
751 | { | |
2b8a1212 | 752 | ++nmanus; |
753 | ||
7eafe398 | 754 | AliMUONVCalibParam* occupancy = new AliMUONCalibParamND(5,1,detElemId,manuId,0); |
2b8a1212 | 755 | |
7eafe398 | 756 | Double_t occ = 0.0; |
757 | ||
2b8a1212 | 758 | AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId); |
759 | ||
7eafe398 | 760 | Int_t numberOfChannelsInManu = de->NofChannelsInManu(manuId); |
761 | ||
a99c3449 | 762 | if (!defaultValues) occ = gRandom->Rndm(1); |
7eafe398 | 763 | |
764 | Double_t sumn = occ*nevents; | |
765 | ||
766 | occupancy->SetValueAsFloat(0,0,sumn); | |
767 | occupancy->SetValueAsFloat(0,1,sumn); | |
768 | occupancy->SetValueAsFloat(0,2,sumn); | |
769 | occupancy->SetValueAsInt(0,3,numberOfChannelsInManu); | |
770 | occupancy->SetValueAsInt(0,4,nevents); | |
771 | ||
772 | Bool_t ok = occupancyMapStore.Add(occupancy); | |
2b8a1212 | 773 | if (!ok) |
774 | { | |
a99c3449 | 775 | AliErrorGeneral("AliMUONCDB", Form("Could not set DetElemId=%d manuId=%d",detElemId,manuId)); |
2b8a1212 | 776 | } |
2b8a1212 | 777 | } |
778 | ||
7eafe398 | 779 | return nmanus; |
2b8a1212 | 780 | } |
781 | ||
25e1df3e | 782 | //_____________________________________________________________________________ |
783 | Int_t | |
784 | AliMUONCDB::MakeCapacitanceStore(AliMUONVStore& capaStore, const char* file) | |
785 | { | |
6687de6d | 786 | /// Read the capacitance values from file and append them to the capaStore |
787 | ||
a99c3449 | 788 | if (!AliMUONCDB::CheckMapping()) return 0; |
789 | ||
49419555 | 790 | return AliMUONTrackerIO::ReadCapacitances(file,capaStore); |
25e1df3e | 791 | } |
792 | ||
de01cdf0 | 793 | //_____________________________________________________________________________ |
794 | Int_t | |
a0eca509 | 795 | AliMUONCDB::MakeCapacitanceStore(AliMUONVStore& capaStore, Bool_t defaultValues) |
de01cdf0 | 796 | { |
797 | /// Create a capacitance store. if defaultValues=true, all capa are 1.0, | |
798 | /// otherwise they are from a gaussian with parameters defined in the | |
799 | /// kCapa* constants below. | |
409de10f | 800 | |
a99c3449 | 801 | AliCodeTimerAutoGeneral("",0); |
802 | ||
803 | if (!AliMUONCDB::CheckMapping()) return 0; | |
de01cdf0 | 804 | |
805 | Int_t nchannels(0); | |
806 | Int_t nmanus(0); | |
807 | Int_t nmanusOK(0); // manus for which we got the serial number | |
a0eca509 | 808 | |
25e1df3e | 809 | const Float_t kCapaMean(0.3); |
810 | const Float_t kCapaSigma(0.1); | |
811 | const Float_t kInjectionGainMean(3); | |
812 | const Float_t kInjectionGainSigma(1); | |
409de10f | 813 | |
814 | Int_t detElemId; | |
815 | Int_t manuId; | |
816 | ||
817 | AliMpManuIterator it; | |
de01cdf0 | 818 | |
409de10f | 819 | while ( it.Next(detElemId,manuId) ) |
de01cdf0 | 820 | { |
821 | ++nmanus; | |
822 | ||
de01cdf0 | 823 | AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId); |
ab167304 | 824 | Int_t serialNumber = AliMpManuStore::Instance()->GetManuSerial(detElemId, manuId); |
de01cdf0 | 825 | |
a0eca509 | 826 | if ( serialNumber <= 0 ) continue; |
827 | ||
828 | ++nmanusOK; | |
de01cdf0 | 829 | |
a0eca509 | 830 | AliMUONVCalibParam* capa = static_cast<AliMUONVCalibParam*>(capaStore.FindObject(serialNumber)); |
de01cdf0 | 831 | |
832 | if (!capa) | |
833 | { | |
25e1df3e | 834 | capa = new AliMUONCalibParamNF(2,AliMpConstants::ManuNofChannels(),serialNumber,0,1.0); |
a0eca509 | 835 | Bool_t ok = capaStore.Add(capa); |
de01cdf0 | 836 | if (!ok) |
837 | { | |
a99c3449 | 838 | AliErrorGeneral("AliMUONCDB", Form("Could not set serialNumber=%d manuId=%d",serialNumber,manuId)); |
de01cdf0 | 839 | } |
840 | } | |
841 | ||
842 | for ( Int_t manuChannel = 0; manuChannel < capa->Size(); ++manuChannel ) | |
843 | { | |
409de10f | 844 | if ( ! de->IsConnectedChannel(manuId,manuChannel) ) continue; |
de01cdf0 | 845 | |
846 | ++nchannels; | |
847 | ||
848 | Float_t capaValue; | |
25e1df3e | 849 | Float_t injectionGain; |
de01cdf0 | 850 | |
851 | if ( defaultValues ) | |
852 | { | |
853 | capaValue = 1.0; | |
25e1df3e | 854 | injectionGain = 1.0; |
de01cdf0 | 855 | } |
856 | else | |
857 | { | |
cf27231a | 858 | capaValue = GetRandom(kCapaMean,kCapaSigma,kTRUE); |
25e1df3e | 859 | injectionGain = GetRandom(kInjectionGainMean,kInjectionGainSigma,kTRUE); |
de01cdf0 | 860 | } |
861 | capa->SetValueAsFloat(manuChannel,0,capaValue); | |
25e1df3e | 862 | capa->SetValueAsFloat(manuChannel,1,injectionGain); |
de01cdf0 | 863 | } |
864 | } | |
865 | ||
866 | Float_t percent = 0; | |
867 | if ( nmanus ) percent = 100*nmanusOK/nmanus; | |
a99c3449 | 868 | AliInfoGeneral("AliMUONCDB", Form("%5d manus with serial number (out of %5d manus = %3.0f%%)", |
de01cdf0 | 869 | nmanusOK,nmanus,percent)); |
a99c3449 | 870 | AliInfoGeneral("AliMUONCDB", Form("%5d channels",nchannels)); |
de01cdf0 | 871 | if ( percent < 100 ) |
872 | { | |
a99c3449 | 873 | AliWarningGeneral("AliMUONCDB", "Did not get all serial numbers. capaStore is incomplete !!!!"); |
de01cdf0 | 874 | } |
875 | return nchannels; | |
876 | ||
877 | } | |
878 | ||
879 | //_____________________________________________________________________________ | |
880 | Int_t | |
a0eca509 | 881 | AliMUONCDB::MakeGainStore(AliMUONVStore& gainStore, Bool_t defaultValues) |
de01cdf0 | 882 | { |
cf27231a | 883 | /// Create a gain store. if defaultValues=true, all gains set so that |
884 | /// charge = (adc-ped) | |
885 | /// | |
886 | /// otherwise parameters are taken from gaussians with parameters | |
887 | /// defined in the k* constants below. | |
de01cdf0 | 888 | |
a99c3449 | 889 | AliCodeTimerAutoGeneral("",0); |
890 | ||
891 | if (!AliMUONCDB::CheckMapping()) return 0; | |
de01cdf0 | 892 | |
893 | Int_t nchannels(0); | |
894 | Int_t nmanus(0); | |
a0eca509 | 895 | |
cf27231a | 896 | const Int_t kSaturation(3000); |
897 | const Double_t kA0Mean(1.2); | |
409de10f | 898 | const Double_t kA0Sigma(0.1); |
899 | const Double_t kA1Mean(1E-5); | |
900 | const Double_t kA1Sigma(1E-6); | |
cf27231a | 901 | const Double_t kQualMean(0xFF); |
902 | const Double_t kQualSigma(0x10); | |
903 | const Int_t kThresMean(1600); | |
409de10f | 904 | const Int_t kThresSigma(100); |
905 | ||
906 | Int_t detElemId; | |
907 | Int_t manuId; | |
de01cdf0 | 908 | |
409de10f | 909 | AliMpManuIterator it; |
910 | ||
911 | while ( it.Next(detElemId,manuId) ) | |
de01cdf0 | 912 | { |
913 | ++nmanus; | |
de01cdf0 | 914 | |
a0eca509 | 915 | AliMUONVCalibParam* gain = |
cf27231a | 916 | new AliMUONCalibParamNF(5,AliMpConstants::ManuNofChannels(), |
a0eca509 | 917 | detElemId, |
918 | manuId, | |
919 | AliMUONVCalibParam::InvalidFloatValue()); | |
920 | ||
409de10f | 921 | AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId); |
de01cdf0 | 922 | |
923 | for ( Int_t manuChannel = 0; manuChannel < gain->Size(); ++manuChannel ) | |
924 | { | |
409de10f | 925 | if ( ! de->IsConnectedChannel(manuId,manuChannel) ) continue; |
de01cdf0 | 926 | |
927 | ++nchannels; | |
928 | ||
de01cdf0 | 929 | if ( defaultValues ) |
930 | { | |
cf27231a | 931 | gain->SetValueAsFloat(manuChannel,0,1.0); |
932 | gain->SetValueAsFloat(manuChannel,1,0.0); | |
933 | gain->SetValueAsInt(manuChannel,2,4095); | |
934 | gain->SetValueAsInt(manuChannel,3,1); | |
935 | gain->SetValueAsInt(manuChannel,4,kSaturation); | |
de01cdf0 | 936 | } |
937 | else | |
938 | { | |
cf27231a | 939 | Bool_t positive(kTRUE); |
940 | gain->SetValueAsFloat(manuChannel,0,GetRandom(kA0Mean,kA0Sigma,positive)); | |
941 | gain->SetValueAsFloat(manuChannel,1,GetRandom(kA1Mean,kA1Sigma,!positive)); | |
942 | gain->SetValueAsInt(manuChannel,2,(Int_t)TMath::Nint(GetRandom(kThresMean,kThresSigma,positive))); | |
943 | gain->SetValueAsInt(manuChannel,3,(Int_t)TMath::Nint(GetRandom(kQualMean,kQualSigma,positive))); | |
944 | gain->SetValueAsInt(manuChannel,4,kSaturation); | |
de01cdf0 | 945 | } |
de01cdf0 | 946 | |
947 | } | |
a0eca509 | 948 | Bool_t ok = gainStore.Add(gain); |
de01cdf0 | 949 | if (!ok) |
950 | { | |
a99c3449 | 951 | AliErrorGeneral("AliMUONCDB", Form("Could not set DetElemId=%d manuId=%d",detElemId,manuId)); |
de01cdf0 | 952 | } |
953 | } | |
954 | ||
a99c3449 | 955 | AliInfoGeneral("AliMUONCDB", Form("%d Manus and %d channels.",nmanus,nchannels)); |
de01cdf0 | 956 | return nchannels; |
957 | } | |
958 | ||
959 | //_____________________________________________________________________________ | |
960 | Int_t | |
a99c3449 | 961 | AliMUONCDB::MakeLocalTriggerMaskStore(AliMUONVStore& localBoardMasks) |
de01cdf0 | 962 | { |
963 | /// Generate local trigger masks store. All masks are set to FFFF | |
964 | ||
a99c3449 | 965 | AliCodeTimerAutoGeneral("",0); |
409de10f | 966 | |
de01cdf0 | 967 | Int_t ngenerated(0); |
630711ed | 968 | // Generate fake mask values for all localboards and put that into |
de01cdf0 | 969 | // one single container (localBoardMasks) |
0145e89a | 970 | for ( Int_t i = 1; i <= AliMpConstants::TotalNofLocalBoards(); ++i ) |
de01cdf0 | 971 | { |
a0eca509 | 972 | AliMUONVCalibParam* localBoard = new AliMUONCalibParamNI(1,8,i,0,0); |
de01cdf0 | 973 | for ( Int_t x = 0; x < 2; ++x ) |
974 | { | |
975 | for ( Int_t y = 0; y < 4; ++y ) | |
976 | { | |
977 | Int_t index = x*4+y; | |
978 | localBoard->SetValueAsInt(index,0,0xFFFF); | |
979 | ++ngenerated; | |
980 | } | |
981 | } | |
a0eca509 | 982 | localBoardMasks.Add(localBoard); |
de01cdf0 | 983 | } |
984 | return ngenerated; | |
985 | } | |
986 | ||
987 | //_____________________________________________________________________________ | |
988 | Int_t | |
a99c3449 | 989 | AliMUONCDB::MakeRegionalTriggerConfigStore(AliMUONRegionalTriggerConfig& rtm) |
de01cdf0 | 990 | { |
92c23b09 | 991 | /// Make a regional trigger config store. Mask is set to FFFF for each local board (Ch.F.) |
de01cdf0 | 992 | |
a99c3449 | 993 | AliCodeTimerAutoGeneral("",0); |
409de10f | 994 | |
5cc125b2 | 995 | if ( ! rtm.ReadData(AliMpFiles::LocalTriggerBoardMapping()) ) { |
a99c3449 | 996 | AliErrorGeneral("AliMUONCDB", "Error when reading from mapping file"); |
5cc125b2 | 997 | return 0; |
998 | } | |
999 | ||
1000 | return rtm.GetNofTriggerCrates(); | |
de01cdf0 | 1001 | } |
1002 | ||
92c23b09 | 1003 | |
de01cdf0 | 1004 | //_____________________________________________________________________________ |
1005 | Int_t | |
a99c3449 | 1006 | AliMUONCDB::MakeGlobalTriggerConfigStore(AliMUONGlobalCrateConfig& gtm) |
de01cdf0 | 1007 | { |
92c23b09 | 1008 | /// Make a global trigger config store. All masks (disable) set to 0x00 for each Darc board (Ch.F.) |
de01cdf0 | 1009 | |
a99c3449 | 1010 | AliCodeTimerAutoGeneral("",0); |
913f1b43 | 1011 | |
1012 | return gtm.ReadData(AliMpFiles::GlobalTriggerBoardMapping()); | |
de01cdf0 | 1013 | } |
1014 | ||
92c23b09 | 1015 | |
de01cdf0 | 1016 | //_____________________________________________________________________________ |
1017 | AliMUONTriggerLut* | |
a99c3449 | 1018 | AliMUONCDB::MakeTriggerLUT(const char* file) |
de01cdf0 | 1019 | { |
1020 | /// Make a triggerlut object, from a file. | |
1021 | ||
a99c3449 | 1022 | AliCodeTimerAutoGeneral("",0); |
409de10f | 1023 | |
de01cdf0 | 1024 | AliMUONTriggerLut* lut = new AliMUONTriggerLut; |
1025 | lut->ReadFromFile(file); | |
1026 | return lut; | |
1027 | } | |
1028 | ||
1029 | //_____________________________________________________________________________ | |
1030 | AliMUONTriggerEfficiencyCells* | |
a99c3449 | 1031 | AliMUONCDB::MakeTriggerEfficiency(const char* file) |
de01cdf0 | 1032 | { |
1033 | /// Make a trigger efficiency object from a file. | |
1034 | ||
a99c3449 | 1035 | AliCodeTimerAutoGeneral("",0); |
409de10f | 1036 | |
de01cdf0 | 1037 | return new AliMUONTriggerEfficiencyCells(file); |
1038 | } | |
1039 | ||
25e1df3e | 1040 | //_____________________________________________________________________________ |
1041 | void | |
1042 | AliMUONCDB::WriteToCDB(const char* calibpath, TObject* object, | |
1043 | Int_t startRun, Int_t endRun, | |
1044 | const char* filename) | |
1045 | { | |
1046 | /// Write a given object to OCDB | |
1047 | ||
913f1b43 | 1048 | TString comment(gSystem->ExpandPathName(filename)); |
1049 | ||
1050 | WriteToCDB(object, calibpath, startRun, endRun, comment.Data()); | |
25e1df3e | 1051 | } |
1052 | ||
de01cdf0 | 1053 | //_____________________________________________________________________________ |
1054 | void | |
1055 | AliMUONCDB::WriteToCDB(const char* calibpath, TObject* object, | |
1056 | Int_t startRun, Int_t endRun, Bool_t defaultValues) | |
1057 | { | |
1058 | /// Write a given object to OCDB | |
1059 | ||
913f1b43 | 1060 | TString comment; |
1061 | if ( defaultValues ) comment += "Test with default values"; | |
1062 | else comment += "Test with random values"; | |
1063 | ||
1064 | WriteToCDB(object, calibpath, startRun, endRun, comment.Data()); | |
1065 | } | |
1066 | ||
1067 | //_____________________________________________________________________________ | |
1068 | void | |
1069 | AliMUONCDB::WriteToCDB(TObject* object, const char* calibpath, Int_t startRun, Int_t endRun, | |
1070 | const char* comment, const char* responsible) | |
1071 | { | |
1072 | /// Write a given object to OCDB | |
1073 | ||
a99c3449 | 1074 | if (!AliMUONCDB::CheckOCDB(kTRUE)) return; |
1075 | ||
de01cdf0 | 1076 | AliCDBId id(calibpath,startRun,endRun); |
1077 | AliCDBMetaData md; | |
1078 | md.SetAliRootVersion(gROOT->GetVersion()); | |
913f1b43 | 1079 | md.SetComment(comment); |
1080 | md.SetResponsible(responsible); | |
a99c3449 | 1081 | AliCDBManager::Instance()->Put(object,id,&md); |
de01cdf0 | 1082 | } |
1083 | ||
1084 | //_____________________________________________________________________________ | |
1085 | Int_t | |
a0eca509 | 1086 | AliMUONCDB::MakeNeighbourStore(AliMUONVStore& neighbourStore) |
de01cdf0 | 1087 | { |
1088 | /// Fill the neighbours store with, for each channel, a TObjArray of its | |
1089 | /// neighbouring pads (including itself) | |
1090 | ||
a99c3449 | 1091 | AliCodeTimerAutoGeneral("",0); |
1092 | ||
1093 | if (!AliMUONCDB::CheckMapping()) return 0; | |
de01cdf0 | 1094 | |
a99c3449 | 1095 | AliInfoGeneral("AliMUONCDB", "Generating NeighbourStore. This will take a while. Please be patient."); |
de01cdf0 | 1096 | |
1097 | Int_t nchannels(0); | |
1098 | ||
1099 | TObjArray tmp; | |
409de10f | 1100 | |
1101 | Int_t detElemId; | |
1102 | Int_t manuId; | |
de01cdf0 | 1103 | |
409de10f | 1104 | AliMpManuIterator it; |
1105 | ||
1106 | while ( it.Next(detElemId,manuId) ) | |
de01cdf0 | 1107 | { |
de01cdf0 | 1108 | const AliMpVSegmentation* seg = |
1109 | AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId,manuId); | |
1110 | ||
a0eca509 | 1111 | AliMUONVCalibParam* calibParam = static_cast<AliMUONVCalibParam*>(neighbourStore.FindObject(detElemId,manuId)); |
de01cdf0 | 1112 | if (!calibParam) |
1113 | { | |
1114 | Int_t dimension(11); | |
a0eca509 | 1115 | Int_t size(AliMpConstants::ManuNofChannels()); |
de01cdf0 | 1116 | Int_t defaultValue(-1); |
a0eca509 | 1117 | Int_t packingFactor(size); |
de01cdf0 | 1118 | |
a0eca509 | 1119 | calibParam = new AliMUONCalibParamNI(dimension,size,detElemId,manuId,defaultValue,packingFactor); |
1120 | Bool_t ok = neighbourStore.Add(calibParam); | |
de01cdf0 | 1121 | if (!ok) |
1122 | { | |
a99c3449 | 1123 | AliErrorGeneral("AliMUONCDB", Form("Could not set DetElemId=%d manuId=%d",detElemId,manuId)); |
de01cdf0 | 1124 | return -1; |
1125 | } | |
1126 | } | |
1127 | ||
a0eca509 | 1128 | for ( Int_t manuChannel = 0; manuChannel < AliMpConstants::ManuNofChannels(); ++manuChannel ) |
de01cdf0 | 1129 | { |
168e9c4d | 1130 | AliMpPad pad = seg->PadByLocation(manuId,manuChannel,kFALSE); |
de01cdf0 | 1131 | |
1132 | if (pad.IsValid()) | |
1133 | { | |
1134 | ++nchannels; | |
1135 | ||
1136 | seg->GetNeighbours(pad,tmp,true,true); | |
1137 | Int_t nofPadNeighbours = tmp.GetEntriesFast(); | |
1138 | ||
1139 | for ( Int_t i = 0; i < nofPadNeighbours; ++i ) | |
1140 | { | |
bf0d3528 | 1141 | AliMpPad* p = static_cast<AliMpPad*>(tmp.UncheckedAt(i)); |
de01cdf0 | 1142 | Int_t x; |
409de10f | 1143 | // Bool_t ok = |
6e97fbb8 | 1144 | calibParam->PackValues(p->GetManuId(),p->GetManuChannel(),x); |
409de10f | 1145 | // if (!ok) |
1146 | // { | |
1147 | // AliError("Could not pack value. Something is seriously wrong. Please check"); | |
1148 | // StdoutToAliError(pad->Print();); | |
1149 | // return -1; | |
1150 | // } | |
de01cdf0 | 1151 | calibParam->SetValueAsInt(manuChannel,i,x); |
1152 | } | |
1153 | } | |
1154 | } | |
1155 | } | |
1156 | ||
de01cdf0 | 1157 | return nchannels; |
1158 | } | |
1159 | ||
1160 | //_____________________________________________________________________________ | |
1161 | void | |
1162 | AliMUONCDB::WriteLocalTriggerMasks(Int_t startRun, Int_t endRun) | |
1163 | { | |
1164 | /// Write local trigger masks to OCDB | |
1165 | ||
630711ed | 1166 | AliMUONVStore* ltm = new AliMUON1DArray(AliMpConstants::TotalNofLocalBoards()+1); |
de01cdf0 | 1167 | Int_t ngenerated = MakeLocalTriggerMaskStore(*ltm); |
a99c3449 | 1168 | AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated)); |
de01cdf0 | 1169 | if (ngenerated>0) |
1170 | { | |
1171 | WriteToCDB("MUON/Calib/LocalTriggerBoardMasks",ltm,startRun,endRun,true); | |
1172 | } | |
1173 | delete ltm; | |
1174 | } | |
1175 | ||
1176 | //_____________________________________________________________________________ | |
1177 | void | |
92c23b09 | 1178 | AliMUONCDB::WriteRegionalTriggerConfig(Int_t startRun, Int_t endRun) |
de01cdf0 | 1179 | { |
1180 | /// Write regional trigger masks to OCDB | |
1181 | ||
92c23b09 | 1182 | AliMUONRegionalTriggerConfig* rtm = new AliMUONRegionalTriggerConfig(); |
1183 | Int_t ngenerated = MakeRegionalTriggerConfigStore(*rtm); | |
a99c3449 | 1184 | AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated)); |
de01cdf0 | 1185 | if (ngenerated>0) |
1186 | { | |
92c23b09 | 1187 | WriteToCDB("MUON/Calib/RegionalTriggerConfig",rtm,startRun,endRun,true); |
de01cdf0 | 1188 | } |
1189 | delete rtm; | |
1190 | } | |
1191 | ||
92c23b09 | 1192 | |
de01cdf0 | 1193 | //_____________________________________________________________________________ |
1194 | void | |
92c23b09 | 1195 | AliMUONCDB::WriteGlobalTriggerConfig(Int_t startRun, Int_t endRun) |
de01cdf0 | 1196 | { |
1197 | /// Write global trigger masks to OCDB | |
1198 | ||
92c23b09 | 1199 | AliMUONGlobalCrateConfig* gtm = new AliMUONGlobalCrateConfig(); |
de01cdf0 | 1200 | |
92c23b09 | 1201 | Int_t ngenerated = MakeGlobalTriggerConfigStore(*gtm); |
a99c3449 | 1202 | AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated)); |
de01cdf0 | 1203 | if (ngenerated>0) |
1204 | { | |
92c23b09 | 1205 | WriteToCDB("MUON/Calib/GlobalTriggerCrateConfig",gtm,startRun,endRun,true); |
de01cdf0 | 1206 | } |
1207 | delete gtm; | |
1208 | } | |
1209 | ||
92c23b09 | 1210 | |
de01cdf0 | 1211 | //_____________________________________________________________________________ |
1212 | void | |
1213 | AliMUONCDB::WriteTriggerLut(Int_t startRun, Int_t endRun) | |
1214 | { | |
1215 | /// Write trigger LUT to OCDB | |
1216 | ||
1217 | AliMUONTriggerLut* lut = MakeTriggerLUT(); | |
1218 | if (lut) | |
1219 | { | |
1220 | WriteToCDB("MUON/Calib/TriggerLut",lut,startRun,endRun,true); | |
1221 | } | |
1222 | delete lut; | |
1223 | } | |
1224 | ||
1225 | //_____________________________________________________________________________ | |
1226 | void | |
1227 | AliMUONCDB::WriteTriggerEfficiency(Int_t startRun, Int_t endRun) | |
1228 | { | |
1229 | /// Write trigger efficiency to OCDB | |
1230 | ||
1231 | AliMUONTriggerEfficiencyCells* eff = MakeTriggerEfficiency(); | |
1232 | if (eff) | |
1233 | { | |
1234 | WriteToCDB("MUON/Calib/TriggerEfficiency",eff,startRun,endRun,true); | |
1235 | } | |
1236 | delete eff; | |
1237 | } | |
1238 | ||
1239 | //_____________________________________________________________________________ | |
1240 | void | |
1241 | AliMUONCDB::WriteNeighbours(Int_t startRun, Int_t endRun) | |
1242 | { | |
1243 | /// Write neighbours to OCDB | |
1244 | ||
409de10f | 1245 | AliMUONVStore* neighbours = Create2DMap(); |
de01cdf0 | 1246 | Int_t ngenerated = MakeNeighbourStore(*neighbours); |
a99c3449 | 1247 | AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated)); |
de01cdf0 | 1248 | if (ngenerated>0) |
1249 | { | |
1250 | WriteToCDB("MUON/Calib/Neighbours",neighbours,startRun,endRun,true); | |
1251 | } | |
1252 | delete neighbours; | |
1253 | } | |
1254 | ||
1255 | //_____________________________________________________________________________ | |
1256 | void | |
1257 | AliMUONCDB::WriteHV(Bool_t defaultValues, | |
1258 | Int_t startRun, Int_t endRun) | |
1259 | { | |
1260 | /// generate HV values (either cste = 1500 V) if defaultValues=true or random | |
1261 | /// if defaultValues=false, see makeHVStore) and | |
1262 | /// store them into CDB located at cdbpath, with a validity period | |
1263 | /// ranging from startRun to endRun | |
1264 | ||
1265 | TMap* hvStore = new TMap; | |
1266 | Int_t ngenerated = MakeHVStore(*hvStore,defaultValues); | |
a99c3449 | 1267 | AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated)); |
de01cdf0 | 1268 | if (ngenerated>0) |
1269 | { | |
1270 | WriteToCDB("MUON/Calib/HV",hvStore,startRun,endRun,defaultValues); | |
1271 | } | |
1272 | delete hvStore; | |
1273 | } | |
1274 | ||
49e110ec | 1275 | //_____________________________________________________________________________ |
1276 | void | |
1277 | AliMUONCDB::WriteTriggerDCS(Bool_t defaultValues, | |
1278 | Int_t startRun, Int_t endRun) | |
1279 | { | |
1280 | /// generate Trigger HV and current values (either const if defaultValues=true or random | |
1281 | /// if defaultValues=false, see makeTriggerDCSStore) and | |
1282 | /// store them into CDB located at cdbpath, with a validity period | |
1283 | /// ranging from startRun to endRun | |
1284 | ||
1285 | TMap* triggerDCSStore = new TMap; | |
1286 | Int_t ngenerated = MakeTriggerDCSStore(*triggerDCSStore,defaultValues); | |
a99c3449 | 1287 | AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated)); |
49e110ec | 1288 | if (ngenerated>0) |
1289 | { | |
1290 | WriteToCDB("MUON/Calib/TriggerDCS",triggerDCSStore,startRun,endRun,defaultValues); | |
1291 | } | |
1292 | delete triggerDCSStore; | |
1293 | } | |
1294 | ||
de01cdf0 | 1295 | //_____________________________________________________________________________ |
1296 | void | |
1297 | AliMUONCDB::WritePedestals(Bool_t defaultValues, | |
1298 | Int_t startRun, Int_t endRun) | |
1299 | { | |
1300 | /// generate pedestal values (either 0 if defaultValues=true or random | |
1301 | /// if defaultValues=false, see makePedestalStore) and | |
1302 | /// store them into CDB located at cdbpath, with a validity period | |
1303 | /// ranging from startRun to endRun | |
1304 | ||
409de10f | 1305 | AliMUONVStore* pedestalStore = Create2DMap(); |
de01cdf0 | 1306 | Int_t ngenerated = MakePedestalStore(*pedestalStore,defaultValues); |
a99c3449 | 1307 | AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated)); |
de01cdf0 | 1308 | WriteToCDB("MUON/Calib/Pedestals",pedestalStore,startRun,endRun,defaultValues); |
1309 | delete pedestalStore; | |
1310 | } | |
1311 | ||
2b8a1212 | 1312 | //_____________________________________________________________________________ |
1313 | void | |
7eafe398 | 1314 | AliMUONCDB::WriteOccupancyMap(Bool_t defaultValues, |
1315 | Int_t startRun, Int_t endRun) | |
2b8a1212 | 1316 | { |
7eafe398 | 1317 | /// generate occupancy map values (either empty one if defaultValues=true, or |
1318 | /// random one, see MakeOccupancyMapStore) and | |
2b8a1212 | 1319 | /// store them into CDB located at cdbpath, with a validity period |
1320 | /// ranging from startRun to endRun | |
1321 | ||
7eafe398 | 1322 | AliMUONVStore* occupancyMapStore = Create2DMap(); |
1323 | Int_t ngenerated = MakeOccupancyMapStore(*occupancyMapStore,defaultValues); | |
a99c3449 | 1324 | AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated)); |
7eafe398 | 1325 | WriteToCDB("MUON/Calib/OccupancyMap",occupancyMapStore,startRun,endRun,defaultValues); |
1326 | delete occupancyMapStore; | |
2b8a1212 | 1327 | } |
1328 | ||
0045b488 | 1329 | //_____________________________________________________________________________ |
1330 | void | |
1331 | AliMUONCDB::WriteRejectList(Bool_t defaultValues, | |
1332 | Int_t startRun, Int_t endRun) | |
1333 | { | |
1334 | /// generate reject list values (either empty one if defaultValues=true, or | |
1335 | /// random one, see MakeRejectListStore) and | |
1336 | /// store them into CDB located at cdbpath, with a validity period | |
1337 | /// ranging from startRun to endRun | |
1338 | ||
1339 | AliMUONRejectList* rl = MakeRejectListStore(defaultValues); | |
1340 | WriteToCDB("MUON/Calib/RejectList",rl,startRun,endRun,defaultValues); | |
1341 | delete rl; | |
1342 | } | |
1343 | ||
de01cdf0 | 1344 | |
1345 | //_____________________________________________________________________________ | |
1346 | void | |
1347 | AliMUONCDB::WriteGains(Bool_t defaultValues, | |
1348 | Int_t startRun, Int_t endRun) | |
1349 | { | |
1350 | /// generate gain values (either 1 if defaultValues=true or random | |
1351 | /// if defaultValues=false, see makeGainStore) and | |
1352 | /// store them into CDB located at cdbpath, with a validity period | |
1353 | /// ranging from startRun to endRun | |
1354 | ||
409de10f | 1355 | AliMUONVStore* gainStore = Create2DMap(); |
de01cdf0 | 1356 | Int_t ngenerated = MakeGainStore(*gainStore,defaultValues); |
a99c3449 | 1357 | AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated)); |
de01cdf0 | 1358 | WriteToCDB("MUON/Calib/Gains",gainStore,startRun,endRun,defaultValues); |
1359 | delete gainStore; | |
1360 | } | |
1361 | ||
25e1df3e | 1362 | //_____________________________________________________________________________ |
1363 | void | |
1364 | AliMUONCDB::WriteCapacitances(const char* filename, | |
1365 | Int_t startRun, Int_t endRun) | |
1366 | { | |
1367 | /// read manu capacitance and injection gain values from file | |
1368 | /// and store them into CDB located at cdbpath, with a validity period | |
1369 | /// ranging from startRun to endRun | |
1370 | ||
1371 | AliMUONVStore* capaStore = new AliMUON1DMap(16828); | |
1372 | Int_t ngenerated = MakeCapacitanceStore(*capaStore,filename); | |
a99c3449 | 1373 | AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated)); |
25e1df3e | 1374 | if ( ngenerated > 0 ) |
1375 | { | |
1376 | WriteToCDB("MUON/Calib/Capacitances",capaStore,startRun,endRun,filename); | |
1377 | } | |
1378 | delete capaStore; | |
1379 | } | |
1380 | ||
de01cdf0 | 1381 | //_____________________________________________________________________________ |
1382 | void | |
1383 | AliMUONCDB::WriteCapacitances(Bool_t defaultValues, | |
1384 | Int_t startRun, Int_t endRun) | |
1385 | { | |
1386 | /// generate manu capacitance values (either 1 if defaultValues=true or random | |
1387 | /// if defaultValues=false, see makeCapacitanceStore) and | |
1388 | /// store them into CDB located at cdbpath, with a validity period | |
1389 | /// ranging from startRun to endRun | |
1390 | ||
a0eca509 | 1391 | AliMUONVStore* capaStore = new AliMUON1DMap(16828); |
de01cdf0 | 1392 | Int_t ngenerated = MakeCapacitanceStore(*capaStore,defaultValues); |
a99c3449 | 1393 | AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated)); |
de01cdf0 | 1394 | WriteToCDB("MUON/Calib/Capacitances",capaStore,startRun,endRun,defaultValues); |
1395 | delete capaStore; | |
1396 | } | |
1397 | ||
1398 | //_____________________________________________________________________________ | |
1399 | void | |
49e110ec | 1400 | AliMUONCDB::WriteTrigger(Bool_t defaultValues, Int_t startRun, Int_t endRun) |
de01cdf0 | 1401 | { |
1402 | /// Writes all Trigger related calibration to CDB | |
49e110ec | 1403 | WriteTriggerDCS(defaultValues,startRun,endRun); |
de01cdf0 | 1404 | WriteLocalTriggerMasks(startRun,endRun); |
92c23b09 | 1405 | WriteRegionalTriggerConfig(startRun,endRun); |
1406 | WriteGlobalTriggerConfig(startRun,endRun); | |
de01cdf0 | 1407 | WriteTriggerLut(startRun,endRun); |
1408 | WriteTriggerEfficiency(startRun,endRun); | |
1409 | } | |
1410 | ||
a31df857 | 1411 | //_____________________________________________________________________________ |
1412 | void | |
1413 | AliMUONCDB::WriteConfig(Int_t startRun, Int_t endRun) | |
1414 | { | |
1415 | /// Write complete tracker configuration to OCDB | |
1416 | ostringstream lines; | |
1417 | TIter next(AliMpDDLStore::Instance()->CreateBusPatchIterator()); | |
1418 | AliMpBusPatch* bp; | |
1419 | while ( ( bp = static_cast<AliMpBusPatch*>(next()) ) ) | |
1420 | { | |
1421 | for (Int_t imanu = 0; imanu < bp->GetNofManus(); ++imanu) | |
1422 | { | |
1423 | lines << bp->GetId() << " " << bp->GetManuId(imanu) << endl; | |
1424 | } | |
1425 | } | |
1426 | ||
1427 | AliMUON2DMap config(kTRUE); | |
a31df857 | 1428 | |
042cd64e | 1429 | AliMUONTrackerIO::DecodeConfig(lines.str().c_str(),config); |
a31df857 | 1430 | |
1431 | WriteToCDB("MUON/Calib/Config",&config,startRun,endRun,kTRUE); | |
1432 | } | |
1433 | ||
de01cdf0 | 1434 | //_____________________________________________________________________________ |
1435 | void | |
1436 | AliMUONCDB::WriteTracker(Bool_t defaultValues, Int_t startRun, Int_t endRun) | |
1437 | { | |
1438 | /// Writes all Tracker related calibration to CDB | |
1439 | WriteHV(defaultValues,startRun,endRun); | |
1440 | WritePedestals(defaultValues,startRun,endRun); | |
1441 | WriteGains(defaultValues,startRun,endRun); | |
1442 | WriteCapacitances(defaultValues,startRun,endRun); | |
1443 | WriteNeighbours(startRun,endRun); | |
c21c5694 | 1444 | WriteOccupancyMap(defaultValues,startRun,endRun); |
1445 | WriteRejectList(defaultValues,startRun,endRun); | |
a31df857 | 1446 | WriteConfig(startRun,endRun); |
de01cdf0 | 1447 | } |
913f1b43 | 1448 | |
c241bfaa | 1449 | //_____________________________________________________________________________ |
1450 | void | |
1451 | AliMUONCDB::ShowCapacitances() | |
1452 | { | |
1453 | /// Show briefly the number of capa values we have in the OCDB, | |
1454 | /// and the list of manu that are actually in the config and for which | |
1455 | /// we miss the capa (if any). | |
1456 | ||
1457 | if (!AliMUONCDB::CheckOCDB()) return; | |
1458 | ||
1459 | AliMUONCDB::LoadMapping(); | |
1460 | ||
1461 | if (!AliMUONCDB::CheckMapping()) return; | |
1462 | ||
1463 | AliCDBEntry* e = AliCDBManager::Instance()->Get("MUON/Calib/Config"); | |
1464 | ||
1465 | if (!e) return ; | |
1466 | ||
1467 | AliMUONVStore* config = static_cast<AliMUONVStore*>(e->GetObject()); | |
1468 | ||
1469 | e = AliCDBManager::Instance()->Get("MUON/Calib/Capacitances"); | |
1470 | ||
1471 | if (!e) return; | |
1472 | ||
1473 | AliMUONVStore* capacitances = static_cast<AliMUONVStore*>(e->GetObject()); | |
1474 | ||
1475 | AliInfoGeneral("ShowCapacitances",Form("%d capacitances are in OCDB",capacitances->GetSize())); | |
1476 | ||
1477 | TIter nextManu(config->CreateIterator()); | |
1478 | AliMUONVCalibParam* param; | |
1479 | ||
1480 | while ( ( param = static_cast<AliMUONVCalibParam*>(nextManu()) ) ) | |
1481 | { | |
1482 | Int_t detElemId = param->ID0(); | |
1483 | Int_t manuId = param->ID1(); | |
1484 | ||
1485 | Int_t serialNumber | |
1486 | = AliMpManuStore::Instance()->GetManuSerial(detElemId, manuId); | |
1487 | ||
1488 | if (serialNumber<0) | |
1489 | { | |
1490 | AliErrorGeneral("ShowCapacitances",Form("Did not find serial for DE %04d MANUID %04d",detElemId,manuId)); | |
1491 | } | |
1492 | else | |
1493 | { | |
1494 | AliMUONVCalibParam* capa = static_cast<AliMUONVCalibParam*>(capacitances->FindObject(serialNumber)); | |
1495 | if (!capa) | |
1496 | { | |
1497 | AliErrorGeneral("ShowCapacitances",Form("Did not find capacitance for DE %04d MANUID %04d SERIAL %d",detElemId,manuId,serialNumber)); | |
1498 | } | |
1499 | } | |
1500 | } | |
1501 | ||
1502 | } | |
1503 | ||
5148da98 | 1504 | //_____________________________________________________________________________ |
1505 | void | |
207947f7 | 1506 | AliMUONCDB::ShowConfig(Bool_t withStatusMap) |
5148da98 | 1507 | { |
1508 | /// Dumps the current tracker configuration, i.e. number and identity of missing buspatches | |
207947f7 | 1509 | /// If statusMap is true, will also take into account the status map to report the number |
1510 | /// of good channels | |
1511 | ||
5148da98 | 1512 | if (!AliMUONCDB::CheckOCDB()) return; |
1513 | ||
1514 | AliMUONCDB::LoadMapping(); | |
1515 | ||
1516 | if (!AliMUONCDB::CheckMapping()) return; | |
1517 | ||
1518 | AliCDBEntry* e = AliCDBManager::Instance()->Get("MUON/Calib/Config"); | |
1519 | ||
1520 | if (!e) return ; | |
1521 | ||
1522 | AliMUONVStore* config = static_cast<AliMUONVStore*>(e->GetObject()); | |
1523 | ||
207947f7 | 1524 | AliMUONPadStatusMapMaker* statusMapMaker(0x0); |
1525 | AliMUONCalibrationData* cd(0x0); | |
1526 | AliMUONPadStatusMaker* statusMaker(0x0); | |
1527 | ||
1528 | if ( withStatusMap ) | |
1529 | { | |
1530 | cd = new AliMUONCalibrationData(AliCDBManager::Instance()->GetRun()); | |
1531 | ||
1532 | statusMaker = new AliMUONPadStatusMaker(*cd); | |
1533 | ||
1534 | AliMUONRecoParam* recoParam = AliMUONCDB::LoadRecoParam(); | |
1535 | ||
1536 | statusMaker->SetLimits(*recoParam); | |
1537 | ||
207947f7 | 1538 | UInt_t mask = recoParam->PadGoodnessMask(); |
9b780418 | 1539 | |
1540 | delete recoParam; | |
1541 | ||
207947f7 | 1542 | const Bool_t deferredInitialization = kFALSE; |
1543 | ||
1544 | statusMapMaker = new AliMUONPadStatusMapMaker(*cd,mask,deferredInitialization); | |
1545 | } | |
1546 | ||
5148da98 | 1547 | TIter nextManu(config->CreateIterator()); |
1548 | AliMUONVCalibParam* param; | |
1549 | ||
1550 | AliMpExMap buspatches; | |
1551 | ||
1552 | while ( ( param = static_cast<AliMUONVCalibParam*>(nextManu()) ) ) | |
1553 | { | |
1554 | Int_t detElemId = param->ID0(); | |
1555 | Int_t manuId = param->ID1(); | |
1556 | Int_t busPatchId = AliMpDDLStore::Instance()->GetBusPatchId(detElemId,manuId); | |
1557 | if ( buspatches.GetValue(busPatchId) == 0x0 ) | |
1558 | { | |
1559 | buspatches.Add(busPatchId,new TObjString(Form("BP%04d",busPatchId))); | |
1560 | } | |
1561 | } | |
1562 | ||
1563 | TArrayI removed(buspatches.GetSize()); | |
1564 | ||
1565 | TIter next(AliMpDDLStore::Instance()->CreateBusPatchIterator()); | |
1566 | AliMpBusPatch* bp; | |
1567 | Int_t n(0); | |
1568 | Int_t nok(0); | |
1569 | Int_t nremoved(0); | |
1570 | ||
207947f7 | 1571 | // accounting of bus patches first |
1572 | ||
5148da98 | 1573 | while ( ( bp = static_cast<AliMpBusPatch*>(next()))) |
1574 | { | |
1575 | if ( buspatches.GetValue(bp->GetId()) ) | |
1576 | { | |
1577 | ++nok; | |
1578 | } | |
1579 | else | |
1580 | { | |
1581 | removed.SetAt(bp->GetId(),nremoved++); | |
1582 | } | |
5148da98 | 1583 | } |
1584 | ||
207947f7 | 1585 | // accounting of channels |
1586 | ||
1587 | AliMpManuIterator it; | |
1588 | ||
1589 | Int_t totalNumberOfChannels(0); | |
1590 | Int_t removedChannels(0); | |
1591 | Int_t badChannels(0); | |
1592 | Int_t badAndRemovedChannels(0); | |
1593 | Int_t badOrRemovedChannels(0); | |
1594 | ||
1595 | Int_t detElemId, manuId; | |
1596 | ||
1597 | while ( it.Next(detElemId,manuId) ) | |
1598 | { | |
1599 | AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId); | |
1600 | for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i ) | |
1601 | { | |
1602 | Int_t busPatchId = AliMpDDLStore::Instance()->GetBusPatchId(detElemId,manuId); | |
1603 | ||
1604 | if ( de->IsConnectedChannel(manuId,i) ) | |
1605 | { | |
1606 | ++totalNumberOfChannels; | |
1607 | Bool_t badBusPatch = ( buspatches.GetValue(busPatchId) == 0x0 ); | |
1608 | ||
1609 | if ( withStatusMap ) | |
1610 | { | |
47274b13 | 1611 | Bool_t badChannel = ( ( statusMapMaker->StatusMap(detElemId,manuId,i) & AliMUONPadStatusMapMaker::SelfDeadMask() ) != 0); |
207947f7 | 1612 | if ( badChannel ) ++badChannels; |
1613 | if ( badBusPatch && badChannel ) ++badAndRemovedChannels; | |
1614 | if ( badBusPatch || badChannel ) ++badOrRemovedChannels; | |
1615 | } | |
1616 | ||
1617 | if ( badBusPatch) ++removedChannels; | |
1618 | } | |
1619 | } | |
1620 | } | |
1621 | ||
5148da98 | 1622 | |
1623 | Int_t* indices = new Int_t[nremoved]; | |
1624 | ||
1625 | TMath::Sort(nremoved,removed.GetArray(),indices,kFALSE); | |
1626 | ||
1627 | for ( Int_t i = 0; i < nremoved; ++i ) | |
1628 | { | |
1629 | Int_t busPatchId = removed[indices[i]]; | |
1630 | bp = AliMpDDLStore::Instance()->GetBusPatch(busPatchId); | |
1631 | bp->Print(); | |
1632 | } | |
1633 | ||
1634 | delete[] indices; | |
207947f7 | 1635 | |
1636 | cout << endl; | |
1637 | cout << Form("Bus patches n=%3d nok=%3d nremoved=%3d",n,nok,nremoved) << endl; | |
1638 | ||
1639 | cout << Form("Channels n=%6d nremoved=%6d bad=%6d bad and removed=%6d bad or removed=%6d", | |
1640 | totalNumberOfChannels,removedChannels,badChannels,badAndRemovedChannels,badOrRemovedChannels) << endl; | |
1641 | ||
1642 | if (totalNumberOfChannels>0) | |
1643 | { | |
1644 | cout << Form("Percentage of readout channels %5.1f %%",removedChannels*100.0/totalNumberOfChannels) << endl; | |
1645 | if ( withStatusMap ) | |
1646 | { | |
1647 | cout << Form("Percentage of non useable channels (bad or removed) %5.1f %%", | |
1648 | badOrRemovedChannels*100.0/totalNumberOfChannels) << endl; | |
1649 | } | |
1650 | } | |
1651 | ||
1652 | ||
1653 | delete statusMapMaker; | |
1654 | delete cd; | |
1655 | delete statusMaker; | |
5148da98 | 1656 | } |
9e7c4517 | 1657 | |
1658 | //______________________________________________________________________________ | |
1659 | void AliMUONCDB::ReadIntegers(const char* filename, std::vector<int>& integers) | |
1660 | { | |
1661 | /// Read integers from filename, where integers are either | |
1662 | /// separated by "," or by return carriage | |
1663 | ifstream in(gSystem->ExpandPathName(filename)); | |
1664 | int i; | |
1665 | ||
1666 | std::set<int> runset; | |
1667 | ||
1668 | char line[10000]; | |
1669 | ||
1670 | in.getline(line,10000,'\n'); | |
1671 | ||
1672 | TString sline(line); | |
1673 | ||
1674 | if (sline.Contains(",")) | |
1675 | { | |
1676 | TObjArray* a = sline.Tokenize(","); | |
1677 | TIter next(a); | |
1678 | TObjString* s; | |
1679 | while ( ( s = static_cast<TObjString*>(next()) ) ) | |
1680 | { | |
1681 | runset.insert(s->String().Atoi()); | |
1682 | } | |
1683 | delete a; | |
1684 | } | |
1685 | else | |
1686 | { | |
1687 | runset.insert(sline.Atoi()); | |
1688 | ||
1689 | while ( in >> i ) | |
1690 | { | |
1691 | runset.insert(i); | |
1692 | } | |
1693 | } | |
1694 | ||
1695 | for ( std::set<int>::const_iterator it = runset.begin(); it != runset.end(); ++it ) | |
1696 | { | |
1697 | integers.push_back((*it)); | |
1698 | } | |
1699 | ||
1700 | std::sort(integers.begin(),integers.end()); | |
1701 | } | |
1702 | ||
1703 | //______________________________________________________________________________ | |
1704 | void AliMUONCDB::ShowFaultyBusPatches(const char* runlist, double occLimit, | |
1705 | const char* outputBaseName, | |
1706 | const char* ocdbPath) | |
1707 | { | |
1708 | /// Shows the list of bus patches above a given occupancy limit, | |
1709 | /// for each run in the runlist | |
1710 | ||
1711 | AliLog::GetRootLogger()->SetGlobalLogLevel(AliLog::kError); | |
1712 | ||
1713 | // AliLog::SetPrintType(AliLog::kInfo,kFALSE); | |
1714 | // AliLog::SetPrintType(AliLog::kWarning,kFALSE); | |
1715 | // gErrorIgnoreLevel=kError; // to avoid all the TAlienFile::Open messages... | |
1716 | ||
1717 | AliCDBManager* man = AliCDBManager::Instance(); | |
1718 | ||
1719 | man->SetDefaultStorage(ocdbPath); | |
1720 | ||
1721 | Bool_t first(kTRUE); | |
1722 | ||
1723 | std::vector<int> runnumbers; | |
1724 | ||
1725 | ReadIntegers(runlist,runnumbers); | |
1726 | ||
1727 | AliMUON2DMap bpValues(kFALSE); | |
1728 | ||
1729 | std::ofstream outfile(Form("%s.txt",outputBaseName)); | |
1730 | ||
1731 | for ( unsigned int i = 0 ; i < runnumbers.size(); ++i ) | |
1732 | { | |
1733 | int runNumber = runnumbers[i]; | |
1734 | ||
1735 | man->SetRun(runNumber); | |
1736 | ||
1737 | if ( first ) | |
1738 | { | |
1739 | AliMpCDB::LoadAll(); | |
1740 | first = kFALSE; | |
1741 | } | |
1742 | ||
1743 | AliCDBEntry* e = man->Get("MUON/Calib/OccupancyMap",runNumber); | |
1744 | ||
b37b9546 | 1745 | if (!e) |
1746 | { | |
1747 | AliErrorGeneral("AliMUONCDB::ShowFaultyBusPatches", | |
1748 | Form("Could not get OccupancyMap for run %09d",runNumber)); | |
1749 | continue; | |
1750 | } | |
1751 | ||
9e7c4517 | 1752 | AliMUONVStore* occmap = static_cast<AliMUONVStore*>(e->GetObject()); |
1753 | ||
1754 | AliMUONTrackerData td("occ","occ",*occmap); | |
1755 | ||
1756 | TIter nextBP(AliMpDDLStore::Instance()->CreateBusPatchIterator()); | |
1757 | AliMpBusPatch* bp; | |
1758 | std::set<int> buspatches; | |
1759 | Double_t sumn = 1000.0; | |
1760 | ||
1761 | while ( ( bp = static_cast<AliMpBusPatch*>(nextBP()) ) ) | |
1762 | { | |
1763 | Double_t occ = td.BusPatch(bp->GetId(),2); | |
1764 | ||
1765 | if (occ>occLimit) | |
1766 | { | |
1767 | buspatches.insert(bp->GetId()); | |
1768 | ||
1769 | AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(bpValues.FindObject(bp->GetId())); | |
1770 | ||
1771 | if (!param) | |
1772 | { | |
1773 | param = new AliMUONCalibParamND(5, 1, bp->GetId(), 0); | |
1774 | bpValues.Add(param); | |
1775 | ||
1776 | Int_t detElemId = AliMpDDLStore::Instance()->GetDEfromBus(bp->GetId()); | |
1777 | AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId); | |
1778 | ||
1779 | Int_t nchannels(0); | |
1780 | ||
1781 | for ( Int_t imanu = 0; imanu < bp->GetNofManus(); ++imanu ) | |
1782 | { | |
1783 | Int_t manuId = bp->GetManuId(imanu); | |
1784 | nchannels += de->NofChannelsInManu(manuId); | |
1785 | } | |
1786 | ||
1787 | param->SetValueAsDouble(0,2,sumn); | |
1788 | param->SetValueAsDouble(0,3,nchannels); | |
1789 | param->SetValueAsDouble(0,4,1); | |
1790 | } | |
1791 | ||
1792 | Double_t sumw = sumn*(param->ValueAsDouble(0)/sumn+1.0/runnumbers.size()); | |
1793 | Double_t sumw2 = 0.0; //(sumn-1)*ey*ey+sumw*sumw/sumn; | |
1794 | ||
1795 | param->SetValueAsDouble(0,0,sumw); | |
1796 | param->SetValueAsDouble(0,1,sumw2); | |
1797 | ||
1798 | } | |
1799 | } | |
1800 | ||
1801 | outfile << Form("RUN %09d",runNumber); | |
1802 | ||
1803 | for ( std::set<int>::const_iterator bit = buspatches.begin(); bit != buspatches.end(); ++bit ) | |
1804 | { | |
1805 | outfile << Form(" %4d",*bit); | |
1806 | } | |
1807 | outfile << endl; | |
1808 | } | |
1809 | ||
1810 | outfile.close(); | |
1811 | ||
1812 | const char* name = "BPfailureRate"; | |
1813 | ||
1814 | AliMUONTrackerData* mpData = new AliMUONTrackerData(name,name,bpValues,2); | |
1815 | mpData->SetDimensionName(0,name); | |
1816 | ||
1817 | TFile f(Form("%s.root",outputBaseName),"recreate"); | |
1818 | mpData->Write(); | |
1819 | f.Close(); | |
1820 | ||
1821 | cout << Form("Results are in %s.txt and %s.root",outputBaseName,outputBaseName) << endl; | |
1822 | ||
1823 | gSystem->Exec(Form("cat %s.txt",outputBaseName)); | |
1824 | ||
1825 | } | |
1826 | ||
b37b9546 | 1827 | //______________________________________________________________________________ |
1828 | void AliMUONCDB::CheckHV(Int_t runNumber, Int_t verbose) | |
1829 | { | |
1830 | /// Check the HV values in OCDB for a given run | |
1831 | ||
1832 | TList messages; | |
1833 | messages.SetOwner(kTRUE); | |
1834 | ||
1835 | Bool_t patched(kTRUE); | |
1836 | ||
1837 | if (!AliCDBManager::Instance()->IsDefaultStorageSet()) | |
1838 | { | |
1839 | AliCDBManager::Instance()->SetDefaultStorage("raw://"); | |
1840 | } | |
1841 | ||
1842 | AliCDBManager::Instance()->SetRun(runNumber); | |
1843 | ||
1844 | LoadMapping(); | |
1845 | ||
1846 | AliMUONCalibrationData::CreateHV(runNumber,0,patched,&messages); | |
1847 | ||
1848 | AliMUONCalibrationData cd(runNumber,true); | |
1849 | ||
1850 | AliMUONPadStatusMaker statusMaker(cd); | |
1851 | ||
1852 | AliMUONRecoParam* rp = AliMUONCDB::LoadRecoParam(); | |
1853 | ||
1854 | if (!rp) | |
1855 | { | |
1856 | AliErrorGeneral("AliMUONCDB::CheckHV","Could not get RecoParam !!!"); | |
1857 | return; | |
1858 | } | |
1859 | ||
1860 | statusMaker.SetLimits(*rp); | |
1861 | ||
1862 | TIter next(&messages); | |
1863 | TObjString* s; | |
1864 | AliMpDCSNamer hvNamer("TRACKER"); | |
1865 | AliMUONLogger log; | |
1866 | ||
1867 | while ( ( s = static_cast<TObjString*>(next()) ) ) | |
1868 | { | |
1869 | TObjArray* a = s->String().Tokenize(":"); | |
1870 | ||
1871 | TString name(static_cast<TObjString*>(a->At(0))->String()); | |
1872 | ||
1873 | if ( name.Contains("sw") || name.Contains("SUMMARY") ) continue; | |
1874 | ||
1875 | Int_t index = hvNamer.DCSIndexFromDCSAlias(name.Data()); | |
1876 | ||
1877 | Int_t detElemId = hvNamer.DetElemIdFromDCSAlias(name.Data()); | |
1878 | ||
1879 | AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId); | |
1880 | ||
1881 | if (!de) | |
1882 | { | |
1883 | AliErrorGeneral("AliMUONCDB::CheckHV",Form("Could not get detElemId from dcsAlias %s",name.Data())); | |
1884 | continue; | |
1885 | } | |
1886 | ||
1887 | Int_t manuId; | |
1888 | ||
1889 | if ( index >= 0 ) | |
1890 | { | |
1891 | const AliMpArrayI* array = de->ManusForHV(index); | |
1892 | manuId = array->GetValue(0); | |
1893 | } | |
1894 | else | |
1895 | ||
1896 | { | |
1897 | AliMpBusPatch* bp = AliMpDDLStore::Instance()->GetBusPatch(de->GetBusPatchId(0)); | |
1898 | ||
1899 | manuId = bp->GetManuId(0); | |
1900 | } | |
1901 | ||
1902 | Int_t status = statusMaker.HVStatus(detElemId,manuId); | |
1903 | ||
1904 | log.Log(AliMUONPadStatusMaker::AsString(status).Data()); | |
1905 | ||
1906 | s->String() += Form(" (DE %4d) ",detElemId); | |
1907 | s->String() += AliMUONPadStatusMaker::AsString(status).Data(); | |
1908 | ||
1909 | delete a; | |
1910 | } | |
1911 | ||
1912 | TIter nextMessage(&messages); | |
1913 | TObjString* msg; | |
1914 | ||
1915 | while ( ( msg = static_cast<TObjString*>(nextMessage()) ) ) | |
1916 | { | |
1917 | if ( verbose > 0 || msg->String().Contains("SUMMARY") ) | |
1918 | { | |
1919 | AliInfoGeneral("AliMUONCDB::CheckHV",Form("RUN %09d HVchannel %s",runNumber,msg->String().Data())); | |
1920 | } | |
1921 | } | |
1922 | ||
1923 | TString lmsg; | |
1924 | Int_t occurance; | |
1925 | TString totalLog; | |
1926 | ||
1927 | while (log.Next(lmsg,occurance)) | |
1928 | { | |
1929 | totalLog += Form("%s(%d)",lmsg.Data(),occurance); | |
1930 | totalLog += " | "; | |
1931 | } | |
1932 | ||
1933 | AliInfoGeneral("AliMUONCDB::CheckHV",Form("RUN %09d %s",runNumber,totalLog.Data())); | |
1934 | ||
1935 | // one last loop to get the list of problematic HV channels | |
1936 | nextMessage.Reset(); | |
1937 | ||
1938 | while ( ( msg = static_cast<TObjString*>(nextMessage()) ) ) | |
1939 | { | |
1940 | if ( msg->String().Contains("HV ") ) | |
1941 | { | |
1942 | AliInfoGeneral("AliMUONCDB::CheckHV",Form(" Problem at %s",msg->String().Data())); | |
1943 | } | |
1944 | } | |
1945 | ||
1946 | AliCDBManager::Instance()->ClearCache(); | |
1947 | } | |
1948 | ||
1949 |