AliRoot Core  v5-06-30 (35d6c57)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMUONCDB.cxx
Go to the documentation of this file.
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 
18 //-----------------------------------------------------------------------------
32 //-----------------------------------------------------------------------------
33 
34 #include "AliMUONCDB.h"
35 
36 #include "AliMUON1DArray.h"
37 #include "AliMUON1DMap.h"
38 #include "AliMUON2DMap.h"
40 #include "AliMUONCalibParamND.h"
41 #include "AliMUONCalibParamNF.h"
42 #include "AliMUONCalibParamNI.h"
43 #include "AliMUONCalibrationData.h"
44 #include "AliMUONConstants.h"
46 #include "AliMUONLogger.h"
47 #include "AliMUONPadStatusMaker.h"
49 #include "AliMUONRecoParam.h"
51 #include "AliMUONRejectList.h"
52 #include "AliMUONTrackerData.h"
53 #include "AliMUONTrackerIO.h"
55 #include "AliMUONTriggerLut.h"
56 #include "AliMUONVCalibParam.h"
57 #include "AliMUONVCalibParam.h"
58 #include "AliMUONVStore.h"
59 
60 #include "AliMpCDB.h"
61 #include "AliMpConstants.h"
62 #include "AliMpDEStore.h"
63 #include "AliMpDDLStore.h"
64 #include "AliMpManuStore.h"
65 #include "AliMpDEManager.h"
66 #include "AliMpDetElement.h"
67 #include "AliMpFiles.h"
68 #include "AliMpDCSNamer.h"
69 #include "AliMpManuIterator.h"
70 #include "AliMpSegmentation.h"
71 #include "AliMpStationType.h"
72 #include "AliMpVSegmentation.h"
73 
74 #include "AliCodeTimer.h"
75 #include "AliCDBEntry.h"
76 #include "AliCDBManager.h"
77 #include "AliGRPManager.h"
78 #include "AliDCSValue.h"
79 #include "AliLog.h"
80 #include "AliMpBusPatch.h"
81 
82 #include <Riostream.h>
83 #include <TArrayI.h>
84 #include <TClass.h>
85 #include <TFile.h>
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>
94 #include <TMath.h>
95 #include <TGeoGlobalMagField.h>
96 #include <TClonesArray.h>
97 #include <sstream>
98 #include <set>
99 
100 using std::endl;
101 using std::cout;
102 using std::cerr;
103 using std::ostringstream;
104 using std::ifstream;
105 
106 namespace
107 {
108  //_____________________________________________________________________________
109 AliMUONVStore* Create2DMap()
110 {
111  return new AliMUON2DMap(true);
112 }
113 
114  //_____________________________________________________________________________
115 void getBoundaries(const AliMUONVStore& store, Int_t dim,
116  Float_t* xmin, Float_t* xmax)
117 {
121 
122  for ( Int_t i = 0; i < dim; ++i )
123  {
124  xmin[i]=1E30;
125  xmax[i]=-1E30;
126  }
127 
128  TIter next(store.CreateIterator());
129  AliMUONVCalibParam* value;
130 
131  while ( ( value = dynamic_cast<AliMUONVCalibParam*>(next() ) ) )
132  {
133  Int_t detElemId = value->ID0();
134  Int_t manuId = value->ID1();
135 
136  const AliMpVSegmentation* seg =
138 
139  if (!seg) continue;
140 
141  for ( Int_t manuChannel = 0; manuChannel < value->Size(); ++manuChannel )
142  {
143  AliMpPad pad = seg->PadByLocation(manuId,manuChannel,kFALSE);
144  if (!pad.IsValid()) continue;
145 
146  for ( Int_t i = 0; i < dim; ++i )
147  {
148  Float_t x0 = value->ValueAsFloat(manuChannel,i);
149 
150  xmin[i] = TMath::Min(xmin[i],x0);
151  xmax[i] = TMath::Max(xmax[i],x0);
152  }
153  }
154  }
155 
156  for ( Int_t i = 0; i < dim; ++i )
157  {
158  if ( TMath::Abs(xmin[i]-xmax[i]) < 1E-3 )
159  {
160  xmin[i] -= 1;
161  xmax[i] += 1;
162  }
163  }
164 }
165 
166 //_____________________________________________________________________________
167 Double_t GetRandom(Double_t mean, Double_t sigma, Bool_t mustBePositive)
168 {
169  Double_t x(-1);
170  if ( mustBePositive )
171  {
172  while ( x < 0 )
173  {
174  x = gRandom->Gaus(mean,sigma);
175  }
176  }
177  else
178  {
179  x = gRandom->Gaus(mean,sigma);
180  }
181  return x;
182 }
183 
184 }
185 
186 //_____________________________________________________________________________
187 Bool_t AliMUONCDB::CheckOCDB(Bool_t pathOnly)
188 {
190 
191  AliCDBManager* man = AliCDBManager::Instance();
192 
193  // first OCDB path
194  if (!man->IsDefaultStorageSet()) {
195  AliErrorGeneral("AliMUONCDB", "OCDB path must be properly set");
196  return kFALSE;
197  }
198 
199  // then run number if required
200  if (pathOnly) return kTRUE;
201  if (man->GetRun() < 0) {
202  AliErrorGeneral("AliMUONCDB", "Run number must be properly set");
203  return kFALSE;
204  }
205 
206  return kTRUE;
207 
208 }
209 
210 //_____________________________________________________________________________
211 Bool_t AliMUONCDB::CheckMapping(Bool_t segmentationOnly)
212 {
214 
215  // first the segmentation
216  if (!AliMpSegmentation::Instance(false)) {
217  AliErrorGeneral("AliMUONCDB", "Mapping segmentation must be loaded first");
218  return kFALSE;
219  }
220 
221  // then the others if required
222  if (segmentationOnly) return kTRUE;
223  if (!AliMpDDLStore::Instance(false) || !AliMpDEStore::Instance(false) || !AliMpManuStore::Instance(false)) {
224  AliErrorGeneral("AliMUONCDB", "Full mapping must be loaded first");
225  return kFALSE;
226  }
227 
228  return kTRUE;
229 
230 }
231 
232 //_____________________________________________________________________________
234 {
237 
238  AliInfoGeneral("AliMUONCDB","Loading field map from GRP...");
239 
240  if (!AliMUONCDB::CheckOCDB()) return kFALSE;
241 
242  AliGRPManager grpMan;
243 
244  // make sure the old field is deleted even if it is locked
245  if(TGeoGlobalMagField::Instance()->IsLocked()) delete TGeoGlobalMagField::Instance();
246 
247  if (!grpMan.ReadGRPEntry() || !grpMan.SetMagField()) {
248  AliErrorGeneral("AliMUONCDB", "failed to load magnetic field from OCDB");
249  return kFALSE;
250  }
251 
252  return kTRUE;
253 
254 }
255 
256 //_____________________________________________________________________________
257 Bool_t AliMUONCDB::LoadMapping(Bool_t segmentationOnly)
258 {
261 
262  AliInfoGeneral("AliMUONCDB", "Loading mapping from OCDB...");
263 
264  if (!AliMUONCDB::CheckOCDB()) return kFALSE;
265 
266  // in case it has already been set
268 
269  if (segmentationOnly) {
270 
271  if (!AliMpCDB::LoadMpSegmentation(kTRUE)){
272  AliErrorGeneral("AliMUONCDB", "failed to load segmentation from OCDB");
273  return kFALSE;
274  }
275 
276  } else {
277 
278  if (!AliMpCDB::LoadAll(kTRUE)) {
279  AliErrorGeneral("AliMUONCDB", "failed to load mapping from OCDB");
280  return kFALSE;
281  }
282 
283  }
284 
285  return kTRUE;
286 
287 }
288 
289 //_____________________________________________________________________________
291 {
294 
295  AliInfoGeneral("AliMUONCDB", "Loading RecoParam from OCDB...");
296 
297  if (!AliMUONCDB::CheckOCDB()) return 0x0;
298 
299  AliMUONRecoParam* recoParam = 0x0;
300  AliCDBEntry* entry = AliCDBManager::Instance()->Get("MUON/Calib/RecoParam");
301 
302  if(entry) {
303 
304  // load recoParam according OCDB content (single or array)
305  if (!(recoParam = dynamic_cast<AliMUONRecoParam*>(entry->GetObject()))) {
306 
307  TObjArray* recoParamArray = static_cast<TObjArray*>(entry->GetObject());
308 // recoParamArray->SetOwner(kTRUE); // FIXME: this should be done, but is causing a problem at the end of the reco... investigate why...
309 
310  for(Int_t i = 0; i < recoParamArray->GetEntriesFast(); i++) {
311  recoParam = static_cast<AliMUONRecoParam*>(recoParamArray->UncheckedAt(i));
312  if (recoParam->IsDefault()) break;
313  recoParam = 0x0;
314  }
315 
316  }
317 
318  }
319 
320  if (!recoParam) AliErrorGeneral("AliMUONCDB", "failed to load RecoParam from OCDB");
321 
322  return recoParam;
323 
324 }
325 
326 //_____________________________________________________________________________
328 {
330 
331  AliInfoGeneral("AliMUONCDB", "Loading Alignemnt from OCDB...");
332 
333  if (!AliMUONCDB::CheckOCDB()) return 0x0;
334 
335  TClonesArray* alignmentArray = 0x0;
336  AliCDBEntry* entry = AliCDBManager::Instance()->Get("MUON/Align/Data");
337 
338  if (entry) {
339  // load alignement array
340  alignmentArray = dynamic_cast<TClonesArray*>(entry->GetObject());
341  }
342 
343  if (!alignmentArray) {
344  AliErrorGeneral("AliMUONCDB", "failed to load Alignemnt from OCDB");
345  }
346 
347  return alignmentArray;
348 }
349 
350 //_____________________________________________________________________________
353  const char* opt)
354 {
361 
362  TString sopt(opt);
363  sopt.ToUpper();
364 
365  if ( !sopt.Contains("ABS") && !sopt.Contains("REL") && !sopt.Contains("PERCENT") )
366  {
367  AliErrorGeneral("AliMUONCDB", Form("opt %s not supported. Only ABS, REL, PERCENT are",opt));
368  return 0x0;
369  }
370 
371  AliMUONVStore* d = static_cast<AliMUONVStore*>(store1.Clone());
372 
373  TIter next(d->CreateIterator());
374 
375  AliMUONVCalibParam* param;
376 
377  while ( ( param = dynamic_cast<AliMUONVCalibParam*>(next() ) ) )
378  {
379  Int_t detElemId = param->ID0();
380  Int_t manuId = param->ID1();
381 
382  AliMUONVCalibParam* param2 = dynamic_cast<AliMUONVCalibParam*>(store2.FindObject(detElemId,manuId));
383  //FIXME: this might happen. Handle it.
384  if (!param2)
385  {
386  cerr << "param2 is null : FIXME : this might happen !" << endl;
387  delete d;
388  return 0;
389  }
390 
391  for ( Int_t i = 0; i < param->Size(); ++i )
392  {
393  for ( Int_t j = 0; j < param->Dimension(); ++j )
394  {
395  Float_t value(0);
396  if ( sopt.Contains("ABS") )
397  {
398  value = param->ValueAsFloat(i,j) - param2->ValueAsFloat(i,j);
399  }
400  else if ( sopt.Contains("REL") || sopt.Contains("PERCENT") )
401  {
402  if ( param->ValueAsFloat(i,j) )
403  {
404  value = (param->ValueAsFloat(i,j) - param2->ValueAsFloat(i,j))/param->ValueAsFloat(i,j);
405  }
406  else
407  {
408  continue;
409  }
410  if ( sopt.Contains("PERCENT") ) value *= 100.0;
411  }
412  param->SetValueAsFloat(i,j,value);
413  }
414  }
415  }
416  return d;
417 }
418 
419 //_____________________________________________________________________________
420 TH1**
421 AliMUONCDB::Plot(const AliMUONVStore& store, const char* name, Int_t nbins)
422 {
426 
427  if (!AliMUONCDB::CheckMapping(kTRUE)) return 0x0;
428 
429  TIter next(store.CreateIterator());
430  AliMUONVCalibParam* param;
431  Int_t n(0);
432  const Int_t kNStations = AliMpConstants::NofTrackingChambers()/2;
433  Int_t* nPerStation = new Int_t[kNStations];
434  TH1** h(0x0);
435 
436  for ( Int_t i = 0; i < kNStations; ++i ) nPerStation[i]=0;
437 
438  while ( ( param = static_cast<AliMUONVCalibParam*>(next()) ) )
439  {
440  if (!h)
441  {
442  Int_t dim = param->Dimension();
443  h = new TH1*[dim];
444  Float_t* xmin = new Float_t[dim];
445  Float_t* xmax = new Float_t[dim];
446  getBoundaries(store,dim,xmin,xmax);
447 
448  for ( Int_t i = 0; i < dim; ++i )
449  {
450  h[i] = new TH1F(Form("%s_%d",name,i),Form("%s_%d",name,i),
451  nbins,xmin[i],xmax[i]);
452  AliInfoGeneral("AliMUONCDB", Form("Created histogram %s",h[i]->GetName()));
453  }
454  delete [] xmin;
455  delete [] xmax;
456  }
457 
458  Int_t detElemId = param->ID0();
459  Int_t manuId = param->ID1();
460  Int_t station = AliMpDEManager::GetChamberId(detElemId)/2;
461 
462  const AliMpVSegmentation* seg =
464 
465  if (!seg) continue;
466 
467  for ( Int_t manuChannel = 0; manuChannel < param->Size(); ++manuChannel )
468  {
469  AliMpPad pad = seg->PadByLocation(manuId,manuChannel,kFALSE);
470  if (!pad.IsValid()) continue;
471 
472  ++n;
473  ++nPerStation[station];
474 
475  for ( Int_t dim = 0; dim < param->Dimension(); ++dim )
476  {
477  h[dim]->Fill(param->ValueAsFloat(manuChannel,dim));
478  }
479  }
480  }
481 
482  for ( Int_t i = 0; i < kNStations; ++i )
483  {
484  AliInfoGeneral("AliMUONCDB", Form("Station %d %d ",(i+1),nPerStation[i]));
485  }
486 
487  AliInfoGeneral("AliMUONCDB", Form("Number of channels = %d",n));
488 
489  delete[] nPerStation;
490 
491  return h;
492 }
493 
494 //_____________________________________________________________________________
495 Int_t
496 AliMUONCDB::MakeHVStore(TMap& aliasMap, Bool_t defaultValues)
497 {
499 
500  if (!AliMUONCDB::CheckMapping()) return 0;
501 
502  AliMpDCSNamer hvNamer("TRACKER");
503 
504  TObjArray* aliases = hvNamer.GenerateAliases();
505 
506  Int_t nSwitch(0);
507  Int_t nChannels(0);
508 
509  for ( Int_t i = 0; i < aliases->GetEntries(); ++i )
510  {
511  TObjString* alias = static_cast<TObjString*>(aliases->At(i));
512  TString& aliasName = alias->String();
513  if ( aliasName.Contains("sw") )
514  {
515  // HV Switch (St345 only)
516  TObjArray* valueSet = new TObjArray;
517  valueSet->SetOwner(kTRUE);
518 
519  Bool_t value = kTRUE;
520 
521  if (!defaultValues)
522  {
523  Float_t r = gRandom->Uniform();
524  if ( r < 0.007 ) value = kFALSE;
525  }
526 
527  for ( UInt_t timeStamp = 0; timeStamp < 60*3; timeStamp += 60 )
528  {
529  AliDCSValue* dcsValue = new AliDCSValue(value,timeStamp);
530  valueSet->Add(dcsValue);
531  }
532  aliasMap.Add(new TObjString(*alias),valueSet);
533  ++nSwitch;
534  }
535  else
536  {
537  TObjArray* valueSet = new TObjArray;
538  valueSet->SetOwner(kTRUE);
539  for ( UInt_t timeStamp = 0; timeStamp < 60*15; timeStamp += 120 )
540  {
541  Float_t value = 1500;
542  if (!defaultValues) value = GetRandom(1750,62.5,true);
543  AliDCSValue* dcsValue = new AliDCSValue(value,timeStamp);
544  valueSet->Add(dcsValue);
545  }
546  aliasMap.Add(new TObjString(*alias),valueSet);
547  ++nChannels;
548  }
549  }
550 
551  delete aliases;
552 
553  AliInfoGeneral("AliMUONCDB", Form("%d HV channels and %d switches",nChannels,nSwitch));
554 
555  return nChannels+nSwitch;
556 }
557 
558 //_____________________________________________________________________________
559 void AliMUONCDB::AddDCSValue ( TMap& aliasMap, Int_t imeas, const char* smt, const char* sInOut, Int_t rpc, Float_t value )
560 {
561  TString sMeasure = ( imeas == AliMpDCSNamer::kDCSHV ) ? "HV.vEff" : "HV.actual.iMon";
562  TString alias = Form("MTR_%s_%s_RPC%i_%s",sInOut,smt,rpc,sMeasure.Data());
563  TObjArray* valueSet = new TObjArray;
564  valueSet->SetOwner(kTRUE);
565 
566  for ( UInt_t timeStamp = 0; timeStamp < 60*2; timeStamp += 60 ) {
567  AliDCSValue* dcsValue = new AliDCSValue(value,timeStamp);
568  valueSet->Add(dcsValue);
569  }
570 
571  aliasMap.Add(new TObjString(alias),valueSet);
572 }
573 
574 //_____________________________________________________________________________
575 Int_t
577 {
579 
580 // if (!AliMUONCDB::CheckMapping()) return 0;
581 
582  Int_t nChannels[2] = {0, 0};
583 
584  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT11","INSIDE",1,10400.);
585  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT11","INSIDE",2,10351.);
586  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT11","INSIDE",3,10300.);
587  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT11","INSIDE",4,10450.);
588  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT11","INSIDE",5,10250.);
589  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT11","INSIDE",6,10100.);
590  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT11","INSIDE",7,10250.);
591  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT11","INSIDE",8,10350.);
592  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT11","INSIDE",9,10350.);
593 
594  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT11","OUTSIDE",1,10300.);
595  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT11","OUTSIDE",2,10350.);
596  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT11","OUTSIDE",3,10150.);
597  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT11","OUTSIDE",4,10350.);
598  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT11","OUTSIDE",5,10150.);
599  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT11","OUTSIDE",6,10350.);
600  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT11","OUTSIDE",7,10150.);
601  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT11","OUTSIDE",8,10150.);
602  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT11","OUTSIDE",9,10250.);
603 
604  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT12","INSIDE",1,10350.);
605  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT12","INSIDE",2,10350.);
606  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT12","INSIDE",3,10250.);
607  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT12","INSIDE",4,10250.);
608  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT12","INSIDE",5,10150.);
609  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT12","INSIDE",6,10350.);
610  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT12","INSIDE",7,10400.);
611  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT12","INSIDE",8,10200.);
612  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT12","INSIDE",9,10350.);
613 
614  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT12","OUTSIDE",1,10400.);
615  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT12","OUTSIDE",2,10250.);
616  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT12","OUTSIDE",3,10250.);
617  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT12","OUTSIDE",4,10300.);
618  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT12","OUTSIDE",5,10300.);
619  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT12","OUTSIDE",6,10200.);
620  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT12","OUTSIDE",7,10100.);
621  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT12","OUTSIDE",8,10400.);
622  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT12","OUTSIDE",9,10400.);
623 
624  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT21","INSIDE",1,10200.);
625  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT21","INSIDE",2,10250.);
626  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT21","INSIDE",3,10250.);
627  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT21","INSIDE",4,10150.);
628  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT21","INSIDE",5,10100.);
629  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT21","INSIDE",6,10100.);
630  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT21","INSIDE",7,10200.);
631  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT21","INSIDE",8,10150.);
632  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT21","INSIDE",9,10250.);
633 
634  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT21","OUTSIDE",1,10200.);
635  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT21","OUTSIDE",2,10350.);
636  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT21","OUTSIDE",3,10200.);
637  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT21","OUTSIDE",4,10100.);
638  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT21","OUTSIDE",5,10250.);
639  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT21","OUTSIDE",6,10101.);
640  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT21","OUTSIDE",7,10200.);
641  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT21","OUTSIDE",8,10300.);
642  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT21","OUTSIDE",9,10250.);
643 
644  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT22","INSIDE",1,10300.);
645  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT22","INSIDE",2,10300.);
646  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT22","INSIDE",3,9624.); // FEERIC
647  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT22","INSIDE",4,10150.);
648  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT22","INSIDE",5,10250.);
649  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT22","INSIDE",6,10150.);
650  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT22","INSIDE",7,10050.);
651  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT22","INSIDE",8,10050.);
652  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT22","INSIDE",9,10150.);
653 
654  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT22","OUTSIDE",1,10225.);
655  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT22","OUTSIDE",2,10250.);
656  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT22","OUTSIDE",3,10150.);
657  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT22","OUTSIDE",4,10100.);
658  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT22","OUTSIDE",5,10200.);
659  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT22","OUTSIDE",6,10200.);
660  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT22","OUTSIDE",7,10250.);
661  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT22","OUTSIDE",8,10225.);
662  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT22","OUTSIDE",9,10250.);
663 
664  nChannels[0] = 72;
665 
666  TString chName[4] = {"MT11","MT12","MT21","MT22"};
667 
668  for ( Int_t ich=0; ich<4; ich++ ) {
669  for ( Int_t iside=0; iside<2; iside++ ) {
670  TString sInOut = ( iside == 0 ) ? "INSIDE" : "OUTSIDE";
671  for ( Int_t irpc=1; irpc<=9; irpc++ ) {
672  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSI,chName[ich].Data(),sInOut.Data(),irpc,2.);
673  ++nChannels[1];
674  }
675  }
676  }
677 
678  AliInfoGeneral("AliMUONCDB", Form("Trigger channels I -> %i HV -> %i",nChannels[0], nChannels[1]));
679 
680  return nChannels[0] + nChannels[1];
681 }
682 
683 //_____________________________________________________________________________
684 Int_t
685 AliMUONCDB::MakePedestalStore(AliMUONVStore& pedestalStore, Bool_t defaultValues)
686 {
690 
691  AliCodeTimerAutoGeneral("",0);
692 
693  if (!AliMUONCDB::CheckMapping()) return 0;
694 
695  Int_t nchannels(0);
696  Int_t nmanus(0);
697 
698  const Int_t kChannels(AliMpConstants::ManuNofChannels());
699 
700  // bending
701  const Float_t kPedestalMeanMeanB(200.);
702  const Float_t kPedestalMeanSigmaB(10.);
703  const Float_t kPedestalSigmaMeanB(1.);
704  const Float_t kPedestalSigmaSigmaB(0.2);
705 
706  // non bending
707  const Float_t kPedestalMeanMeanNB(200.);
708  const Float_t kPedestalMeanSigmaNB(10.);
709  const Float_t kPedestalSigmaMeanNB(1.);
710  const Float_t kPedestalSigmaSigmaNB(0.2);
711 
712  const Float_t kFractionOfDeadManu(0.); // within [0.,1.]
713 
714  Int_t detElemId;
715  Int_t manuId;
716 
718 
719  while ( it.Next(detElemId,manuId) )
720  {
721  // skip a given fraction of manus
722  if (kFractionOfDeadManu > 0. && gRandom->Uniform() < kFractionOfDeadManu) continue;
723 
724  ++nmanus;
725 
726  AliMUONVCalibParam* ped =
727  new AliMUONCalibParamNF(2,kChannels,detElemId,manuId,AliMUONVCalibParam::InvalidFloatValue());
728 
730 
731  for ( Int_t manuChannel = 0; manuChannel < kChannels; ++manuChannel )
732  {
733  if ( ! de->IsConnectedChannel(manuId,manuChannel) ) continue;
734 
735  ++nchannels;
736 
737  Float_t meanPedestal;
738  Float_t sigmaPedestal;
739 
740  if ( defaultValues )
741  {
742  meanPedestal = 0.0;
743  sigmaPedestal = 1.0;
744  }
745  else
746  {
747  Bool_t positive(kTRUE);
748  meanPedestal = 0.0;
749 
750  if ( manuId & AliMpConstants::ManuMask(AliMp::kNonBendingPlane) ) { // manu in non bending plane
751 
752  while ( meanPedestal == 0.0 ) // avoid strict zero
753  {
754  meanPedestal = GetRandom(kPedestalMeanMeanNB,kPedestalMeanSigmaNB,positive);
755  }
756  sigmaPedestal = GetRandom(kPedestalSigmaMeanNB,kPedestalSigmaSigmaNB,positive);
757 
758  } else { // manu in bending plane
759 
760  while ( meanPedestal == 0.0 ) // avoid strict zero
761  {
762  meanPedestal = GetRandom(kPedestalMeanMeanB,kPedestalMeanSigmaB,positive);
763  }
764  sigmaPedestal = GetRandom(kPedestalSigmaMeanB,kPedestalSigmaSigmaB,positive);
765 
766  }
767 
768  }
769 
770  ped->SetValueAsFloat(manuChannel,0,meanPedestal);
771  ped->SetValueAsFloat(manuChannel,1,sigmaPedestal);
772 
773  }
774  Bool_t ok = pedestalStore.Add(ped);
775  if (!ok)
776  {
777  AliErrorGeneral("AliMUONCDB", Form("Could not set DetElemId=%d manuId=%d",detElemId,manuId));
778  }
779  }
780 
781  AliInfoGeneral("AliMUONCDB", Form("%d Manus and %d channels.",nmanus,nchannels));
782  return nchannels;
783 }
784 
785 //_____________________________________________________________________________
787 AliMUONCDB::MakeRejectListStore(Bool_t defaultValues)
788 {
790 
791  AliCodeTimerAutoGeneral("",0);
792 
794 
795  if (!defaultValues)
796  {
799  return rl;
800  }
801 
802  return rl;
803 }
804 
805 //_____________________________________________________________________________
806 Int_t
807 AliMUONCDB::MakeOccupancyMapStore(AliMUONVStore& occupancyMapStore, Bool_t defaultValues)
808 {
810 
811  AliCodeTimerAutoGeneral("",0);
812 
813  if (!AliMUONCDB::CheckMapping()) return 0;
814 
815  Int_t nmanus(0);
816 
817  Int_t detElemId;
818  Int_t manuId;
819 
821 
822  Int_t nevents(1000);
823 
824  while ( it.Next(detElemId,manuId) )
825  {
826  ++nmanus;
827 
828  AliMUONVCalibParam* occupancy = new AliMUONCalibParamND(5,1,detElemId,manuId,0);
829 
830  Double_t occ = 0.0;
831 
833 
834  Int_t numberOfChannelsInManu = de->NofChannelsInManu(manuId);
835 
836  if (!defaultValues) occ = gRandom->Rndm(1);
837 
838  Double_t sumn = occ*nevents;
839 
840  occupancy->SetValueAsFloat(0,0,sumn);
841  occupancy->SetValueAsFloat(0,1,sumn);
842  occupancy->SetValueAsFloat(0,2,sumn);
843  occupancy->SetValueAsInt(0,3,numberOfChannelsInManu);
844  occupancy->SetValueAsInt(0,4,nevents);
845 
846  Bool_t ok = occupancyMapStore.Add(occupancy);
847  if (!ok)
848  {
849  AliErrorGeneral("AliMUONCDB", Form("Could not set DetElemId=%d manuId=%d",detElemId,manuId));
850  }
851  }
852 
853  return nmanus;
854 }
855 
856 //_____________________________________________________________________________
857 Int_t
858 AliMUONCDB::MakeCapacitanceStore(AliMUONVStore& capaStore, const char* file)
859 {
861 
862  if (!AliMUONCDB::CheckMapping()) return 0;
863 
864  return AliMUONTrackerIO::ReadCapacitances(file,capaStore);
865 }
866 
867 //_____________________________________________________________________________
868 Int_t
869 AliMUONCDB::MakeCapacitanceStore(AliMUONVStore& capaStore, Bool_t defaultValues)
870 {
874 
875  AliCodeTimerAutoGeneral("",0);
876 
877  if (!AliMUONCDB::CheckMapping()) return 0;
878 
879  Int_t nchannels(0);
880  Int_t nmanus(0);
881  Int_t nmanusOK(0); // manus for which we got the serial number
882 
883  const Float_t kCapaMean(0.3);
884  const Float_t kCapaSigma(0.1);
885  const Float_t kInjectionGainMean(3);
886  const Float_t kInjectionGainSigma(1);
887 
888  Int_t detElemId;
889  Int_t manuId;
890 
892 
893  while ( it.Next(detElemId,manuId) )
894  {
895  ++nmanus;
896 
898  Int_t serialNumber = AliMpManuStore::Instance()->GetManuSerial(detElemId, manuId);
899 
900  if ( serialNumber <= 0 ) continue;
901 
902  ++nmanusOK;
903 
904  AliMUONVCalibParam* capa = static_cast<AliMUONVCalibParam*>(capaStore.FindObject(serialNumber));
905 
906  if (!capa)
907  {
908  capa = new AliMUONCalibParamNF(2,AliMpConstants::ManuNofChannels(),serialNumber,0,1.0);
909  Bool_t ok = capaStore.Add(capa);
910  if (!ok)
911  {
912  AliErrorGeneral("AliMUONCDB", Form("Could not set serialNumber=%d manuId=%d",serialNumber,manuId));
913  }
914  }
915 
916  for ( Int_t manuChannel = 0; manuChannel < capa->Size(); ++manuChannel )
917  {
918  if ( ! de->IsConnectedChannel(manuId,manuChannel) ) continue;
919 
920  ++nchannels;
921 
922  Float_t capaValue;
923  Float_t injectionGain;
924 
925  if ( defaultValues )
926  {
927  capaValue = 1.0;
928  injectionGain = 1.0;
929  }
930  else
931  {
932  capaValue = GetRandom(kCapaMean,kCapaSigma,kTRUE);
933  injectionGain = GetRandom(kInjectionGainMean,kInjectionGainSigma,kTRUE);
934  }
935  capa->SetValueAsFloat(manuChannel,0,capaValue);
936  capa->SetValueAsFloat(manuChannel,1,injectionGain);
937  }
938  }
939 
940  Float_t percent = 0;
941  if ( nmanus ) percent = 100*nmanusOK/nmanus;
942  AliInfoGeneral("AliMUONCDB", Form("%5d manus with serial number (out of %5d manus = %3.0f%%)",
943  nmanusOK,nmanus,percent));
944  AliInfoGeneral("AliMUONCDB", Form("%5d channels",nchannels));
945  if ( percent < 100 )
946  {
947  AliWarningGeneral("AliMUONCDB", "Did not get all serial numbers. capaStore is incomplete !!!!");
948  }
949  return nchannels;
950 
951 }
952 
953 //_____________________________________________________________________________
954 Int_t
955 AliMUONCDB::MakeGainStore(AliMUONVStore& gainStore, Bool_t defaultValues)
956 {
962 
963  AliCodeTimerAutoGeneral("",0);
964 
965  if (!AliMUONCDB::CheckMapping()) return 0;
966 
967  Int_t nchannels(0);
968  Int_t nmanus(0);
969 
970  const Int_t kSaturation(3000);
971  const Double_t kA0Mean(1.2);
972  const Double_t kA0Sigma(0.1);
973  const Double_t kA1Mean(1E-5);
974  const Double_t kA1Sigma(1E-6);
975  const Double_t kQualMean(0xFF);
976  const Double_t kQualSigma(0x10);
977  const Int_t kThresMean(1600);
978  const Int_t kThresSigma(100);
979 
980  Int_t detElemId;
981  Int_t manuId;
982 
984 
985  while ( it.Next(detElemId,manuId) )
986  {
987  ++nmanus;
988 
989  AliMUONVCalibParam* gain =
991  detElemId,
992  manuId,
994 
996 
997  for ( Int_t manuChannel = 0; manuChannel < gain->Size(); ++manuChannel )
998  {
999  if ( ! de->IsConnectedChannel(manuId,manuChannel) ) continue;
1000 
1001  ++nchannels;
1002 
1003  if ( defaultValues )
1004  {
1005  gain->SetValueAsFloat(manuChannel,0,1.0);
1006  gain->SetValueAsFloat(manuChannel,1,0.0);
1007  gain->SetValueAsInt(manuChannel,2,4095);
1008  gain->SetValueAsInt(manuChannel,3,1);
1009  gain->SetValueAsInt(manuChannel,4,kSaturation);
1010  }
1011  else
1012  {
1013  Bool_t positive(kTRUE);
1014  gain->SetValueAsFloat(manuChannel,0,GetRandom(kA0Mean,kA0Sigma,positive));
1015  gain->SetValueAsFloat(manuChannel,1,GetRandom(kA1Mean,kA1Sigma,!positive));
1016  gain->SetValueAsInt(manuChannel,2,(Int_t)TMath::Nint(GetRandom(kThresMean,kThresSigma,positive)));
1017  gain->SetValueAsInt(manuChannel,3,(Int_t)TMath::Nint(GetRandom(kQualMean,kQualSigma,positive)));
1018  gain->SetValueAsInt(manuChannel,4,kSaturation);
1019  }
1020 
1021  }
1022  Bool_t ok = gainStore.Add(gain);
1023  if (!ok)
1024  {
1025  AliErrorGeneral("AliMUONCDB", Form("Could not set DetElemId=%d manuId=%d",detElemId,manuId));
1026  }
1027  }
1028 
1029  AliInfoGeneral("AliMUONCDB", Form("%d Manus and %d channels.",nmanus,nchannels));
1030  return nchannels;
1031 }
1032 
1033 //_____________________________________________________________________________
1034 Int_t
1036 {
1038 
1039  AliCodeTimerAutoGeneral("",0);
1040 
1041  Int_t ngenerated(0);
1042  // Generate fake mask values for all localboards and put that into
1043  // one single container (localBoardMasks)
1044  for ( Int_t i = 1; i <= AliMpConstants::TotalNofLocalBoards(); ++i )
1045  {
1046  AliMUONVCalibParam* localBoard = new AliMUONCalibParamNI(1,8,i,0,0);
1047  for ( Int_t x = 0; x < 2; ++x )
1048  {
1049  for ( Int_t y = 0; y < 4; ++y )
1050  {
1051  Int_t index = x*4+y;
1052  localBoard->SetValueAsInt(index,0,0xFFFF);
1053  ++ngenerated;
1054  }
1055  }
1056  localBoardMasks.Add(localBoard);
1057  }
1058  return ngenerated;
1059 }
1060 
1061 //_____________________________________________________________________________
1062 Int_t
1064 {
1066 
1067  AliCodeTimerAutoGeneral("",0);
1068 
1070  AliErrorGeneral("AliMUONCDB", "Error when reading from mapping file");
1071  return 0;
1072  }
1073 
1074  return rtm.GetNofTriggerCrates();
1075 }
1076 
1077 
1078 //_____________________________________________________________________________
1079 Int_t
1081 {
1083 
1084  AliCodeTimerAutoGeneral("",0);
1085 
1087 }
1088 
1089 
1090 //_____________________________________________________________________________
1093 {
1095 
1096  AliCodeTimerAutoGeneral("",0);
1097 
1099  lut->ReadFromFile(file);
1100  return lut;
1101 }
1102 
1103 //_____________________________________________________________________________
1106 {
1108 
1109  AliCodeTimerAutoGeneral("",0);
1110 
1111  return new AliMUONTriggerEfficiencyCells(file);
1112 }
1113 
1114 //_____________________________________________________________________________
1115 void
1116 AliMUONCDB::WriteToCDB(const char* calibpath, TObject* object,
1117  Int_t startRun, Int_t endRun,
1118  const char* filename)
1119 {
1121 
1122  TString comment(gSystem->ExpandPathName(filename));
1123 
1124  WriteToCDB(object, calibpath, startRun, endRun, comment.Data());
1125 }
1126 
1127 //_____________________________________________________________________________
1128 void
1129 AliMUONCDB::WriteToCDB(const char* calibpath, TObject* object,
1130  Int_t startRun, Int_t endRun, Bool_t defaultValues)
1131 {
1133 
1134  TString comment;
1135  if ( defaultValues ) comment += "Test with default values";
1136  else comment += "Test with random values";
1137 
1138  WriteToCDB(object, calibpath, startRun, endRun, comment.Data());
1139 }
1140 
1141 //_____________________________________________________________________________
1142 void
1143 AliMUONCDB::WriteToCDB(TObject* object, const char* calibpath, Int_t startRun, Int_t endRun,
1144  const char* comment, const char* responsible)
1145 {
1147 
1148  if (!AliMUONCDB::CheckOCDB(kTRUE)) return;
1149 
1150  AliCDBId id(calibpath,startRun,endRun);
1151  AliCDBMetaData md;
1152  md.SetAliRootVersion(gROOT->GetVersion());
1153  md.SetComment(comment);
1154  md.SetResponsible(responsible);
1155  AliCDBManager::Instance()->Put(object,id,&md);
1156 }
1157 
1158 //_____________________________________________________________________________
1159 void
1160 AliMUONCDB::WriteLocalTriggerMasks(Int_t startRun, Int_t endRun)
1161 {
1163 
1165  Int_t ngenerated = MakeLocalTriggerMaskStore(*ltm);
1166  AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
1167  if (ngenerated>0)
1168  {
1169  WriteToCDB("MUON/Calib/LocalTriggerBoardMasks",ltm,startRun,endRun,true);
1170  }
1171  delete ltm;
1172 }
1173 
1174 //_____________________________________________________________________________
1175 void
1176 AliMUONCDB::WriteRegionalTriggerConfig(Int_t startRun, Int_t endRun)
1177 {
1179 
1181  Int_t ngenerated = MakeRegionalTriggerConfigStore(*rtm);
1182  AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
1183  if (ngenerated>0)
1184  {
1185  WriteToCDB("MUON/Calib/RegionalTriggerConfig",rtm,startRun,endRun,true);
1186  }
1187  delete rtm;
1188 }
1189 
1190 
1191 //_____________________________________________________________________________
1192 void
1193 AliMUONCDB::WriteGlobalTriggerConfig(Int_t startRun, Int_t endRun)
1194 {
1196 
1198 
1199  Int_t ngenerated = MakeGlobalTriggerConfigStore(*gtm);
1200  AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
1201  if (ngenerated>0)
1202  {
1203  WriteToCDB("MUON/Calib/GlobalTriggerCrateConfig",gtm,startRun,endRun,true);
1204  }
1205  delete gtm;
1206 }
1207 
1208 
1209 //_____________________________________________________________________________
1210 void
1211 AliMUONCDB::WriteTriggerLut(Int_t startRun, Int_t endRun)
1212 {
1214 
1216  if (lut)
1217  {
1218  WriteToCDB("MUON/Calib/TriggerLut",lut,startRun,endRun,true);
1219  }
1220  delete lut;
1221 }
1222 
1223 //_____________________________________________________________________________
1224 void
1225 AliMUONCDB::WriteTriggerEfficiency(Int_t startRun, Int_t endRun)
1226 {
1228 
1230  if (eff)
1231  {
1232  WriteToCDB("MUON/Calib/TriggerEfficiency",eff,startRun,endRun,true);
1233  }
1234  delete eff;
1235 }
1236 
1237 //_____________________________________________________________________________
1238 void
1239 AliMUONCDB::WriteHV(const char* inputFile, Int_t runNumber)
1240 {
1244 
1245  TFile* f = TFile::Open(gSystem->ExpandPathName(inputFile));
1246 
1247  if (!f->IsOpen()) return;
1248 
1249  TMap* hvStore = static_cast<TMap*>(f->Get("map"));
1250 
1251  WriteToCDB("MUON/Calib/HV",hvStore,runNumber,runNumber,kFALSE);
1252 
1253  delete hvStore;
1254 }
1255 //_____________________________________________________________________________
1256 void
1257 AliMUONCDB::WriteHV(Bool_t defaultValues,
1258  Int_t startRun, Int_t endRun)
1259 {
1264 
1265  TMap* hvStore = new TMap;
1266  Int_t ngenerated = MakeHVStore(*hvStore,defaultValues);
1267  AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
1268  if (ngenerated>0)
1269  {
1270  WriteToCDB("MUON/Calib/HV",hvStore,startRun,endRun,defaultValues);
1271  }
1272  delete hvStore;
1273 }
1274 
1275 //_____________________________________________________________________________
1276 void
1277 AliMUONCDB::WriteTriggerDCS(Int_t startRun, Int_t endRun)
1278 {
1282 
1283  TMap* triggerDCSStore = new TMap;
1284  Int_t ngenerated = MakeTriggerDCSStore(*triggerDCSStore);
1285  AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
1286  if (ngenerated>0)
1287  {
1288  WriteToCDB("MUON/Calib/TriggerDCS",triggerDCSStore,startRun,endRun,true);
1289  }
1290  delete triggerDCSStore;
1291 }
1292 
1293 //_____________________________________________________________________________
1294 void
1295 AliMUONCDB::WritePedestals(Bool_t defaultValues,
1296  Int_t startRun, Int_t endRun)
1297 {
1302 
1303  AliMUONVStore* pedestalStore = Create2DMap();
1304  Int_t ngenerated = MakePedestalStore(*pedestalStore,defaultValues);
1305  AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
1306  WriteToCDB("MUON/Calib/Pedestals",pedestalStore,startRun,endRun,defaultValues);
1307  delete pedestalStore;
1308 }
1309 
1310 //_____________________________________________________________________________
1311 void
1312 AliMUONCDB::WriteOccupancyMap(Bool_t defaultValues,
1313  Int_t startRun, Int_t endRun)
1314 {
1319 
1320  AliMUONVStore* occupancyMapStore = Create2DMap();
1321  Int_t ngenerated = MakeOccupancyMapStore(*occupancyMapStore,defaultValues);
1322  AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
1323  WriteToCDB("MUON/Calib/OccupancyMap",occupancyMapStore,startRun,endRun,defaultValues);
1324  delete occupancyMapStore;
1325 }
1326 
1327 //_____________________________________________________________________________
1328 void
1329 AliMUONCDB::WriteRejectList(Bool_t defaultValues,
1330  Int_t startRun, Int_t endRun)
1331 {
1336 
1337  AliMUONRejectList* rl = MakeRejectListStore(defaultValues);
1338  WriteToCDB("MUON/Calib/RejectList",rl,startRun,endRun,defaultValues);
1339  delete rl;
1340 }
1341 
1342 
1343 //_____________________________________________________________________________
1344 void
1345 AliMUONCDB::WriteGains(Bool_t defaultValues,
1346  Int_t startRun, Int_t endRun)
1347 {
1352 
1353  AliMUONVStore* gainStore = Create2DMap();
1354  Int_t ngenerated = MakeGainStore(*gainStore,defaultValues);
1355  AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
1356  WriteToCDB("MUON/Calib/Gains",gainStore,startRun,endRun,defaultValues);
1357  delete gainStore;
1358 }
1359 
1360 //_____________________________________________________________________________
1361 void
1362 AliMUONCDB::WriteCapacitances(const char* filename,
1363  Int_t startRun, Int_t endRun)
1364 {
1368 
1369  AliMUONVStore* capaStore = new AliMUON1DMap(16828);
1370  Int_t ngenerated = MakeCapacitanceStore(*capaStore,filename);
1371  AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
1372  if ( ngenerated > 0 )
1373  {
1374  WriteToCDB("MUON/Calib/Capacitances",capaStore,startRun,endRun,filename);
1375  }
1376  delete capaStore;
1377 }
1378 
1379 //_____________________________________________________________________________
1380 void
1381 AliMUONCDB::WriteCapacitances(Bool_t defaultValues,
1382  Int_t startRun, Int_t endRun)
1383 {
1388 
1389  AliMUONVStore* capaStore = new AliMUON1DMap(16828);
1390  Int_t ngenerated = MakeCapacitanceStore(*capaStore,defaultValues);
1391  AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
1392  WriteToCDB("MUON/Calib/Capacitances",capaStore,startRun,endRun,defaultValues);
1393  delete capaStore;
1394 }
1395 
1396 //_____________________________________________________________________________
1397 void AliMUONCDB::WriteMapping(Int_t startRun, Int_t endRun)
1398 {
1399  gSystem->Setenv("MINSTALL",gSystem->ExpandPathName("$ALICE_ROOT/MUON/mapping"));
1400  AliMpCDB::WriteMpData(startRun,endRun);
1401  AliMpCDB::WriteMpRunData(startRun,endRun);
1402 }
1403 
1404 //_____________________________________________________________________________
1405 void
1406 AliMUONCDB::WriteTrigger(Bool_t defaultValues, Int_t startRun, Int_t endRun)
1407 {
1409  WriteTriggerDCS(startRun,endRun);
1410  WriteLocalTriggerMasks(startRun,endRun);
1411  WriteRegionalTriggerConfig(startRun,endRun);
1412  WriteGlobalTriggerConfig(startRun,endRun);
1413  WriteTriggerLut(startRun,endRun);
1414  WriteTriggerEfficiency(startRun,endRun);
1415 }
1416 
1417 //_____________________________________________________________________________
1418 void
1419 AliMUONCDB::WriteConfig(Int_t startRun, Int_t endRun)
1420 {
1422  ostringstream lines;
1423  TIter next(AliMpDDLStore::Instance()->CreateBusPatchIterator());
1424  AliMpBusPatch* bp;
1425  while ( ( bp = static_cast<AliMpBusPatch*>(next()) ) )
1426  {
1427  for (Int_t imanu = 0; imanu < bp->GetNofManus(); ++imanu)
1428  {
1429  lines << bp->GetId() << " " << bp->GetManuId(imanu) << endl;
1430  }
1431  }
1432 
1433  AliMUON2DMap config(kTRUE);
1434 
1435  AliMUONTrackerIO::DecodeConfig(lines.str().c_str(),config);
1436 
1437  WriteToCDB("MUON/Calib/Config",&config,startRun,endRun,kTRUE);
1438 }
1439 
1440 //_____________________________________________________________________________
1441 void
1442 AliMUONCDB::WriteTracker(Bool_t defaultValues, Int_t startRun, Int_t endRun)
1443 {
1445  WriteMapping(startRun,endRun);
1446  WriteHV(defaultValues,startRun,endRun);
1447  WritePedestals(defaultValues,startRun,endRun);
1448  WriteGains(defaultValues,startRun,endRun);
1449  WriteCapacitances(defaultValues,startRun,endRun);
1450  WriteOccupancyMap(defaultValues,startRun,endRun);
1451  WriteRejectList(defaultValues,startRun,endRun);
1452  WriteConfig(startRun,endRun);
1453 }
1454 
1455 //_____________________________________________________________________________
1456 void
1458 {
1462 
1463  if (!AliMUONCDB::CheckOCDB()) return;
1464 
1466 
1467  if (!AliMUONCDB::CheckMapping()) return;
1468 
1469  AliCDBEntry* e = AliCDBManager::Instance()->Get("MUON/Calib/Config");
1470 
1471  if (!e) return ;
1472 
1473  AliMUONVStore* config = static_cast<AliMUONVStore*>(e->GetObject());
1474 
1475  e = AliCDBManager::Instance()->Get("MUON/Calib/Capacitances");
1476 
1477  if (!e) return;
1478 
1479  AliMUONVStore* capacitances = static_cast<AliMUONVStore*>(e->GetObject());
1480 
1481  AliInfoGeneral("ShowCapacitances",Form("%d capacitances are in OCDB",capacitances->GetSize()));
1482 
1483  TIter nextManu(config->CreateIterator());
1484  AliMUONVCalibParam* param;
1485 
1486  while ( ( param = static_cast<AliMUONVCalibParam*>(nextManu()) ) )
1487  {
1488  Int_t detElemId = param->ID0();
1489  Int_t manuId = param->ID1();
1490 
1491  Int_t serialNumber
1492  = AliMpManuStore::Instance()->GetManuSerial(detElemId, manuId);
1493 
1494  if (serialNumber<0)
1495  {
1496  AliErrorGeneral("ShowCapacitances",Form("Did not find serial for DE %04d MANUID %04d",detElemId,manuId));
1497  }
1498  else
1499  {
1500  AliMUONVCalibParam* capa = static_cast<AliMUONVCalibParam*>(capacitances->FindObject(serialNumber));
1501  if (!capa)
1502  {
1503  AliErrorGeneral("ShowCapacitances",Form("Did not find capacitance for DE %04d MANUID %04d SERIAL %d",detElemId,manuId,serialNumber));
1504  }
1505  }
1506  }
1507 
1508 }
1509 
1510 //_____________________________________________________________________________
1511 void
1512 AliMUONCDB::ShowConfig(Bool_t withStatusMap)
1513 {
1517 
1518  if (!AliMUONCDB::CheckOCDB()) return;
1519 
1521 
1522  if (!AliMUONCDB::CheckMapping()) return;
1523 
1524  AliCDBEntry* e = AliCDBManager::Instance()->Get("MUON/Calib/Config");
1525 
1526  if (!e) return ;
1527 
1528  AliMUONVStore* config = static_cast<AliMUONVStore*>(e->GetObject());
1529 
1530  AliMUONPadStatusMapMaker* statusMapMaker(0x0);
1531  AliMUONCalibrationData* cd(0x0);
1532  AliMUONPadStatusMaker* statusMaker(0x0);
1533 
1534  if ( withStatusMap )
1535  {
1536  cd = new AliMUONCalibrationData(AliCDBManager::Instance()->GetRun());
1537 
1538  statusMaker = new AliMUONPadStatusMaker(*cd);
1539 
1541 
1542  if (!recoParam)
1543  {
1544  AliErrorGeneral("AliMUONCDB::ShowConfig","Cannot get recoParams from OCDB !");
1545  return;
1546  }
1547 
1548  statusMaker->SetLimits(*recoParam);
1549 
1550  UInt_t mask = recoParam->PadGoodnessMask();
1551 
1552  delete recoParam;
1553 
1554  const Bool_t deferredInitialization = kFALSE;
1555 
1556  statusMapMaker = new AliMUONPadStatusMapMaker(*cd,mask,deferredInitialization);
1557  }
1558 
1559  TIter nextManu(config->CreateIterator());
1560  AliMUONVCalibParam* param;
1561 
1562  AliMpExMap buspatches;
1563 
1564  while ( ( param = static_cast<AliMUONVCalibParam*>(nextManu()) ) )
1565  {
1566  Int_t detElemId = param->ID0();
1567  Int_t manuId = param->ID1();
1568  Int_t busPatchId = AliMpDDLStore::Instance()->GetBusPatchId(detElemId,manuId);
1569  if ( buspatches.GetValue(busPatchId) == 0x0 )
1570  {
1571  buspatches.Add(busPatchId,new TObjString(Form("BP%04d",busPatchId)));
1572  }
1573  }
1574 
1575  TArrayI removed(buspatches.GetSize());
1576 
1577  TIter next(AliMpDDLStore::Instance()->CreateBusPatchIterator());
1578  AliMpBusPatch* bp;
1579  Int_t n(0);
1580  Int_t nok(0);
1581  Int_t nremoved(0);
1582 
1583  // accounting of bus patches first
1584 
1585  while ( ( bp = static_cast<AliMpBusPatch*>(next())))
1586  {
1587  if ( buspatches.GetValue(bp->GetId()) )
1588  {
1589  ++nok;
1590  }
1591  else
1592  {
1593  removed.SetAt(bp->GetId(),nremoved++);
1594  }
1595  }
1596 
1597  // accounting of channels
1598 
1599  AliMpManuIterator it;
1600 
1601  Int_t totalNumberOfChannels(0);
1602  Int_t removedChannels(0);
1603  Int_t badChannels(0);
1604  Int_t badAndRemovedChannels(0);
1605  Int_t badOrRemovedChannels(0);
1606 
1607  Int_t detElemId, manuId;
1608 
1609  while ( it.Next(detElemId,manuId) )
1610  {
1612  for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i )
1613  {
1614  Int_t busPatchId = AliMpDDLStore::Instance()->GetBusPatchId(detElemId,manuId);
1615 
1616  if ( de->IsConnectedChannel(manuId,i) )
1617  {
1618  ++totalNumberOfChannels;
1619  Bool_t badBusPatch = ( buspatches.GetValue(busPatchId) == 0x0 );
1620 
1621  if ( withStatusMap )
1622  {
1623  Bool_t badChannel = ( ( statusMapMaker->StatusMap(detElemId,manuId,i) & AliMUONPadStatusMapMaker::SelfDeadMask() ) != 0);
1624  if ( badChannel ) ++badChannels;
1625  if ( badBusPatch && badChannel ) ++badAndRemovedChannels;
1626  if ( badBusPatch || badChannel ) ++badOrRemovedChannels;
1627  }
1628 
1629  if ( badBusPatch) ++removedChannels;
1630  }
1631  }
1632  }
1633 
1634 
1635  Int_t* indices = new Int_t[nremoved];
1636 
1637  TMath::Sort(nremoved,removed.GetArray(),indices,kFALSE);
1638 
1639  for ( Int_t i = 0; i < nremoved; ++i )
1640  {
1641  Int_t busPatchId = removed[indices[i]];
1642  bp = AliMpDDLStore::Instance()->GetBusPatch(busPatchId);
1643  bp->Print();
1644  }
1645 
1646  delete[] indices;
1647 
1648  cout << endl;
1649  cout << Form("Bus patches n=%3d nok=%3d nremoved=%3d",n,nok,nremoved) << endl;
1650 
1651  cout << Form("Channels n=%6d nremoved=%6d bad=%6d bad and removed=%6d bad or removed=%6d",
1652  totalNumberOfChannels,removedChannels,badChannels,badAndRemovedChannels,badOrRemovedChannels) << endl;
1653 
1654  if (totalNumberOfChannels>0)
1655  {
1656  cout << Form("Percentage of readout channels %5.1f %%",removedChannels*100.0/totalNumberOfChannels) << endl;
1657  if ( withStatusMap )
1658  {
1659  cout << Form("Percentage of non useable channels (bad or removed) %5.1f %%",
1660  badOrRemovedChannels*100.0/totalNumberOfChannels) << endl;
1661  }
1662  }
1663 
1664 
1665  delete statusMapMaker;
1666  delete cd;
1667  delete statusMaker;
1668 }
1669 
1670 //______________________________________________________________________________
1671 void AliMUONCDB::ReadIntegers(const char* filename, std::vector<int>& integers)
1672 {
1675  ifstream in(gSystem->ExpandPathName(filename));
1676  int i;
1677 
1678  std::set<int> runset;
1679 
1680  char line[10000];
1681 
1682  in.getline(line,10000,'\n');
1683 
1684  TString sline(line);
1685 
1686  if (sline.Contains(","))
1687  {
1688  TObjArray* a = sline.Tokenize(",");
1689  TIter next(a);
1690  TObjString* s;
1691  while ( ( s = static_cast<TObjString*>(next()) ) )
1692  {
1693  runset.insert(s->String().Atoi());
1694  }
1695  delete a;
1696  }
1697  else
1698  {
1699  runset.insert(sline.Atoi());
1700 
1701  while ( in >> i )
1702  {
1703  runset.insert(i);
1704  }
1705  }
1706 
1707  for ( std::set<int>::const_iterator it = runset.begin(); it != runset.end(); ++it )
1708  {
1709  integers.push_back((*it));
1710  }
1711 
1712  std::sort(integers.begin(),integers.end());
1713 }
1714 
1715 //______________________________________________________________________________
1716 void AliMUONCDB::ShowFaultyBusPatches(const char* runlist, double occLimit,
1717  const char* outputBaseName,
1718  const char* ocdbPath)
1719 {
1722 
1723  AliLog::GetRootLogger()->SetGlobalLogLevel(AliLog::kError);
1724 
1725  // AliLog::SetPrintType(AliLog::kInfo,kFALSE);
1726  // AliLog::SetPrintType(AliLog::kWarning,kFALSE);
1727  // gErrorIgnoreLevel=kError; // to avoid all the TAlienFile::Open messages...
1728 
1729  AliCDBManager* man = AliCDBManager::Instance();
1730 
1731  man->SetDefaultStorage(ocdbPath);
1732 
1733  Bool_t first(kTRUE);
1734 
1735  std::vector<int> runnumbers;
1736 
1737  ReadIntegers(runlist,runnumbers);
1738 
1739  AliMUON2DMap bpValues(kFALSE);
1740 
1741  std::ofstream outfile(Form("%s.txt",outputBaseName));
1742 
1743  for ( unsigned int i = 0 ; i < runnumbers.size(); ++i )
1744  {
1745  int runNumber = runnumbers[i];
1746 
1747  man->SetRun(runNumber);
1748 
1749  if ( first )
1750  {
1751  AliMpCDB::LoadAll();
1752  first = kFALSE;
1753  }
1754 
1755  AliCDBEntry* e = man->Get("MUON/Calib/OccupancyMap",runNumber);
1756 
1757  if (!e)
1758  {
1759  AliErrorGeneral("AliMUONCDB::ShowFaultyBusPatches",
1760  Form("Could not get OccupancyMap for run %09d",runNumber));
1761  continue;
1762  }
1763 
1764  AliMUONVStore* occmap = static_cast<AliMUONVStore*>(e->GetObject());
1765 
1766  AliMUONTrackerData td("occ","occ",*occmap);
1767 
1768  TIter nextBP(AliMpDDLStore::Instance()->CreateBusPatchIterator());
1769  AliMpBusPatch* bp;
1770  std::set<int> buspatches;
1771  Double_t sumn = 1000.0;
1772 
1773  while ( ( bp = static_cast<AliMpBusPatch*>(nextBP()) ) )
1774  {
1775  Double_t occ = td.BusPatch(bp->GetId(),2);
1776 
1777  if (occ>occLimit)
1778  {
1779  buspatches.insert(bp->GetId());
1780 
1781  AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(bpValues.FindObject(bp->GetId()));
1782 
1783  if (!param)
1784  {
1785  param = new AliMUONCalibParamND(5, 1, bp->GetId(), 0);
1786  bpValues.Add(param);
1787 
1788  Int_t detElemId = AliMpDDLStore::Instance()->GetDEfromBus(bp->GetId());
1790 
1791  Int_t nchannels(0);
1792 
1793  for ( Int_t imanu = 0; imanu < bp->GetNofManus(); ++imanu )
1794  {
1795  Int_t manuId = bp->GetManuId(imanu);
1796  nchannels += de->NofChannelsInManu(manuId);
1797  }
1798 
1799  param->SetValueAsDouble(0,2,sumn);
1800  param->SetValueAsDouble(0,3,nchannels);
1801  param->SetValueAsDouble(0,4,1);
1802  }
1803 
1804  Double_t sumw = sumn*(param->ValueAsDouble(0)/sumn+1.0/runnumbers.size());
1805  Double_t sumw2 = 0.0; //(sumn-1)*ey*ey+sumw*sumw/sumn;
1806 
1807  param->SetValueAsDouble(0,0,sumw);
1808  param->SetValueAsDouble(0,1,sumw2);
1809 
1810  }
1811  }
1812 
1813  outfile << Form("RUN %09d",runNumber);
1814 
1815  for ( std::set<int>::const_iterator bit = buspatches.begin(); bit != buspatches.end(); ++bit )
1816  {
1817  outfile << Form(" %4d",*bit);
1818  }
1819  outfile << endl;
1820  }
1821 
1822  outfile.close();
1823 
1824  if ( bpValues.GetSize() == 0 )
1825  {
1826  cout << Form("Great. No faulty bus patch (at the %g occupancy limit) found.",occLimit) << endl;
1827  gSystem->Exec(Form("rm %s.txt",outputBaseName));
1828  }
1829  else
1830  {
1831  const char* name = "BPfailureRate";
1832 
1833  AliMUONTrackerData* mpData = new AliMUONTrackerData(name,name,bpValues,2);
1834  mpData->SetDimensionName(0,name);
1835 
1836  TFile f(Form("%s.root",outputBaseName),"recreate");
1837  mpData->Write();
1838  f.Close();
1839 
1840  cout << Form("Results are in %s.txt and %s.root",outputBaseName,outputBaseName) << endl;
1841 
1842  gSystem->Exec(Form("cat %s.txt",outputBaseName));
1843  }
1844 }
1845 
1846 //______________________________________________________________________________
1847 Double_t AliMUONCDB::MeanHVValueForDCSAlias(TMap& hvMap, const char* hvChannel)
1848 {
1849 
1850  TPair* hvPair = static_cast<TPair*>(hvMap.FindObject(hvChannel));
1851  if (!hvPair)
1852  {
1853  AliErrorGeneral("AliMUONCDB::MeanHVValueForDCSAlias",Form("Did not find expected alias (%s)",hvChannel));
1854  return 0.0;
1855  }
1856  else
1857  {
1858  TObjArray* values = static_cast<TObjArray*>(hvPair->Value());
1859  if (!values)
1860  {
1861  AliErrorGeneral("AliMUONCDB::MeanHVValueForDCSAlias",Form("Could not get values for alias %s",hvChannel));
1862  return 0.0;
1863  }
1864  else
1865  {
1866  // find out min value, and makes a cut
1867  Float_t hv(0.0);
1868  Float_t n(0.0);
1869  TIter next(values);
1870  AliDCSValue* val;
1871 
1872  while ( ( val = static_cast<AliDCSValue*>(next()) ) )
1873  {
1874  hv += val->GetFloat();
1875  n += 1.0;
1876  }
1877 
1878  if (n>0.0)
1879  {
1880  hv /= n;
1881  return hv;
1882  }
1883  }
1884  return 0.0;
1885  }
1886 }
1887 
1888 //______________________________________________________________________________
1889 void AliMUONCDB::CheckHV(Int_t runNumber, Int_t verbose)
1890 {
1892 
1893  TList messages;
1894  messages.SetOwner(kTRUE);
1895 
1896  Bool_t patched(kTRUE);
1897 
1898  if (!AliCDBManager::Instance()->IsDefaultStorageSet())
1899  {
1900  AliCDBManager::Instance()->SetDefaultStorage("raw://");
1901  }
1902 
1903  AliCDBManager::Instance()->SetRun(runNumber);
1904 
1905  LoadMapping();
1906 
1907  AliMUONCalibrationData::CreateHV(runNumber,0,patched,&messages);
1908 
1909  AliMUONCalibrationData cd(runNumber,true);
1910 
1911  AliMUONPadStatusMaker statusMaker(cd);
1912 
1914 
1915  if (!rp)
1916  {
1917  AliErrorGeneral("AliMUONCDB::CheckHV","Could not get RecoParam !!!");
1918  return;
1919  }
1920 
1921  statusMaker.SetLimits(*rp);
1922 
1923  TIter next(&messages);
1924  TObjString* s;
1925  AliMpDCSNamer hvNamer("TRACKER");
1926  AliMUONLogger log;
1927  Double_t meanHVValue(0.0);
1928  Double_t nofHVValues(0.0);
1929 
1930  while ( ( s = static_cast<TObjString*>(next()) ) )
1931  {
1932  TObjArray* a = s->String().Tokenize(":");
1933 
1934  TString name(static_cast<TObjString*>(a->At(0))->String());
1935 
1936  TObjArray* b = name.Tokenize(" ");
1937 
1938  name = static_cast<TObjString*>(b->At(0))->String();
1939 
1940  delete a;
1941  delete b;
1942 
1943  if ( name.Contains("sw") || name.Contains("SUMMARY") ) {continue;}
1944 
1945  Int_t index = hvNamer.DCSIndexFromDCSAlias(name.Data());
1946 
1947  Int_t detElemId = hvNamer.DetElemIdFromDCSAlias(name.Data());
1948 
1950 
1951  if (!de)
1952  {
1953  AliErrorGeneral("AliMUONCDB::CheckHV",Form("Could not get detElemId from dcsAlias %s",name.Data()));
1954  continue;
1955  }
1956 
1957  Int_t manuId;
1958 
1959  if ( index >= 0 )
1960  {
1961  const AliMpArrayI* array = de->ManusForHV(index);
1962  manuId = array->GetValue(0);
1963  }
1964  else
1965 
1966  {
1968  manuId = bp->GetManuId(0);
1969  }
1970 
1971  Int_t status = statusMaker.HVStatus(detElemId,manuId);
1972 
1973  log.Log(AliMUONPadStatusMaker::AsString(status).Data());
1974 
1975  meanHVValue += MeanHVValueForDCSAlias((*cd.HV()),name.Data());
1976 
1977  nofHVValues += 1.0;
1978 
1979  s->String() += Form(" (DE %4d) ",detElemId);
1980  s->String() += AliMUONPadStatusMaker::AsString(status).Data();
1981  }
1982 
1983  TIter nextMessage(&messages);
1984  TObjString* msg;
1985 
1986  while ( ( msg = static_cast<TObjString*>(nextMessage()) ) )
1987  {
1988  if ( verbose > 0 || msg->String().Contains("SUMMARY") )
1989  {
1990  AliInfoGeneral("AliMUONCDB::CheckHV",Form("RUN %09d HVchannel %s",runNumber,msg->String().Data()));
1991  }
1992  }
1993 
1994  TString lmsg;
1995  Int_t occurance;
1996  TString totalLog;
1997 
1998  while (log.Next(lmsg,occurance))
1999  {
2000  totalLog += Form("%s(%d)",lmsg.Data(),occurance);
2001  totalLog += " | ";
2002  }
2003 
2004  AliInfoGeneral("AliMUONCDB::CheckHV",Form("RUN %09d %s",runNumber,totalLog.Data()));
2005 
2006  // one last loop to get the list of problematic HV channels
2007  nextMessage.Reset();
2008 
2009  while ( ( msg = static_cast<TObjString*>(nextMessage()) ) )
2010  {
2011  if ( msg->String().Contains("HV ") )
2012  {
2013  AliInfoGeneral("AliMUONCDB::CheckHV",Form(" Problem at %s",msg->String().Data()));
2014  }
2015  }
2016 
2017  if (nofHVValues)
2018  {
2019  meanHVValue /= nofHVValues;
2020  AliInfoGeneral("AliMUONCDB::CheckHV",Form("Mean HV for run %09d was %7.2f",runNumber,meanHVValue));
2021  }
2022 
2023  AliCDBManager::Instance()->ClearCache();
2024 }
2025 
2026 
Int_t GetNofManus() const
Convert a pad status container into a pad status map container.
virtual TIterator * CreateIterator() const =0
Return an iterator to loop over the whole store.
Implementation of AliMUONVTrackerData.
The class defines the configuration of global crate.
static Float_t InvalidFloatValue()
Return 1E38 as invalid float value.
void WritePedestals(Bool_t defaultValues, Int_t startRun, Int_t endRun=AliCDBRunRange::Infinity())
void WriteHV(Bool_t defaultValues, Int_t startRun, Int_t endRun=AliCDBRunRange::Infinity())
AliMUONRejectList * MakeRejectListStore(Bool_t defaultValues)
Definition: AliMUONCDB.cxx:787
static AliMpDEStore * Instance(Bool_t warn=true)
static Bool_t WriteMpData()
Definition: AliMpCDB.cxx:364
void WriteTriggerEfficiency(Int_t startRun=0, Int_t endRun=AliCDBRunRange::Infinity())
void WriteTriggerLut(Int_t startRun=0, Int_t endRun=AliCDBRunRange::Infinity())
AliMUONTriggerLut * MakeTriggerLUT(const char *file="$(ALICE_ROOT)/MUON/data/lutAptLpt1Hpt1p7.root")
static TString AsString(Int_t status)
static AliMpSegmentation * Instance(Bool_t warn=true)
virtual Float_t ValueAsFloat(Int_t i, Int_t j=0) const =0
TMap * HV(Bool_t patched=kTRUE) const
Get the HV values. Use patched=kFALSE to get unprocessed (i.e. "raw") values as they are in the OCDB...
#define TObjArray
Implementation of AliMUONVCalibParam for tuples of floats.
virtual Int_t Size() const =0
The number of channels handled by this object.
virtual void SetValueAsFloat(Int_t i, Int_t j, Float_t value)=0
Set one value, for channel i, dimension j. Consider value is a float.
void WriteGains(Bool_t defaultValues, Int_t startRun, Int_t endRun=AliCDBRunRange::Infinity())
void CheckHV(Int_t runNumber, Int_t verbose=0)
TClonesArray * LoadAlignmentData()
Definition: AliMUONCDB.cxx:327
static TString comment
Definition: ConfigCosmic.C:131
TFile f("CalibObjects.root")
virtual Double_t BusPatch(Int_t busPatchId, Int_t dim=0) const
Get the value for a given buspatch and given dimension.
Int_t Log(const char *message)
virtual Int_t GetSize() const =0
The number of objects stored.
static Bool_t WriteMpRunData()
Definition: AliMpCDB.cxx:370
Int_t GetDEfromBus(Int_t busPatchId) const
Store and give access to the trigger chamber efficiency.
TROOT * gROOT
Int_t MakeLocalTriggerMaskStore(AliMUONVStore &ltm)
Collection of methods usefull to DCS handling for MUON TRK and TRG.
Definition: AliMpDCSNamer.h:21
void WriteGlobalTriggerConfig(Int_t startRun=0, Int_t endRun=AliCDBRunRange::Infinity())
Int_t MakePedestalStore(AliMUONVStore &pedestalStore, Bool_t defaultValues)
Definition: AliMUONCDB.cxx:685
const AliMpVSegmentation * GetMpSegmentationByElectronics(Int_t detElemId, Int_t elCardID, Bool_t warn=true) const
virtual void SetDimensionName(Int_t index, const char *value)
Set the name of a given dimension.
static Int_t DecodeConfig(const char *data, AliMUONVStore &confStore)
virtual void SetValueAsInt(Int_t i, Int_t j, Int_t value)=0
Set one value, for channel i, dimension j. Consider value is an integer.
Class with MUON reconstruction parameters.
AliMpDetElement * GetDetElement(Int_t detElemId, Bool_t warn=true) const
virtual Double_t ValueAsDouble(Int_t i, Int_t j=0) const
Int_t GetManuId(Int_t index) const
static AliMpManuStore * Instance(Bool_t warn=true)
The class defines the electronics properties of detection element.
TObjArray * GenerateAliases() const
Int_t MakeTriggerDCSStore(TMap &aliasMap)
Definition: AliMUONCDB.cxx:576
Bool_t Next(TString &msg, Int_t &occurance)
void WriteTriggerDCS(Int_t startRun, Int_t endRun=AliCDBRunRange::Infinity())
Bool_t LoadField()
Definition: AliMUONCDB.cxx:233
Bool_t Next(Int_t &detElemId, Int_t &manuId)
Class to loop over all manus of MUON Tracker.
TObjArray * array
Definition: AnalyzeLaser.C:12
static TString LocalTriggerBoardMapping()
Definition: AliMpFiles.cxx:337
Int_t GetSize() const
Definition: AliMpExMap.cxx:339
void ShowFaultyBusPatches(const char *runlist, double occLimit=0.1, const char *outputBaseName="faulty.buspatches", const char *ocdbPath="raw://")
static Int_t ReadCapacitances(const char *filename, AliMUONVStore &capaStore)
void SetDetectionElementProbability(Int_t detElemId, Float_t proba=1.0)
A logger that keeps track of the number of times a message appeared.
Definition: AliMUONLogger.h:29
void AddDCSValue(TMap &aliasMap, Int_t imeas, const char *smt, const char *sInOut, Int_t rpc, Float_t value)
Definition: AliMUONCDB.cxx:559
Container of calibration values for a given number of channels.
static AliMpDDLStore * Instance(Bool_t warn=true)
static Int_t GetChamberId(Int_t detElemId, Bool_t warn=true)
AliMUONVStore * StatusMap() const
static Int_t ManuNofChannels()
Max number of channels per manu.
Int_t MakeGainStore(AliMUONVStore &gainStore, Bool_t defaultValues)
Definition: AliMUONCDB.cxx:955
AliMUONTriggerEfficiencyCells * MakeTriggerEfficiency(const char *file="$ALICE_ROOT/MUON/data/efficiencyCells.dat")
void ReadFromFile(const char *filename)
Int_t GetBusPatchId(Int_t detElemId, Int_t manuId) const
Int_t GetManuSerial(Int_t detElemId, Int_t manuId) const
virtual TObject * FindObject(Int_t i, Int_t j) const
Find an object using 2 ids.
void WriteOccupancyMap(Bool_t defaultValues, Int_t startRun, Int_t endRun=AliCDBRunRange::Infinity())
Implementation of AliMUONVCalibParam for tuples of ints.
void WriteConfig(Int_t startRun, Int_t endRun=AliCDBRunRange::Infinity())
Int_t MakeRegionalTriggerConfigStore(AliMUONRegionalTriggerConfig &rtm)
Int_t MakeHVStore(TMap &aliasMap, Bool_t defaultValues)
Definition: AliMUONCDB.cxx:496
AliMUONVStore * Diff(AliMUONVStore &store1, AliMUONVStore &store2, const char *opt="abs")
Definition: AliMUONCDB.cxx:352
Int_t MakeCapacitanceStore(AliMUONVStore &capaStore, Bool_t defaultValues)
Definition: AliMUONCDB.cxx:869
virtual Int_t ID0() const
First id of this object.
non-bending plane
Implementation of AliMUONVCalibParam for tuples of double.
void ReadIntegers(const char *filename, std::vector< int > &integers)
Definition: MUONStatusMap.C:60
void ShowConfig(Bool_t withStatusMap=kFALSE)
AliMpBusPatch * GetBusPatch(Int_t busPatchId, Bool_t warn=true) const
TObject * GetValue(Int_t keyFirst, Int_t keySecond) const
Definition: AliMpExMap.cxx:364
TH1 ** Plot(const AliMUONVStore &store, const char *name, Int_t nbins=512)
Definition: AliMUONCDB.cxx:421
Int_t GetId() const
Return the unique Id.
Definition: AliMpBusPatch.h:89
void WriteTracker(Bool_t defaultValues=kTRUE, Int_t startRun=0, Int_t endRun=AliCDBRunRange::Infinity())
Int_t DCSIndexFromDCSAlias(const char *dcsAlias) const
static Int_t TotalNofLocalBoards()
Return total number of trigger local boards.
Int_t MakeGlobalTriggerConfigStore(AliMUONGlobalCrateConfig &gtm)
Int_t MakeOccupancyMapStore(AliMUONVStore &occupancyMap, Bool_t defaultValues)
Definition: AliMUONCDB.cxx:807
void Add(Int_t keyFirst, Int_t keySecond, TObject *object)
Definition: AliMpExMap.cxx:291
Helper class for sorted integer array.
Definition: AliMpArrayI.h:21
Implementation of AliMUONVStore.
static Int_t SelfDeadMask()
Return status bit map to tell a pad is bad.
void WriteTrigger(Bool_t defaultValues=kTRUE, Int_t startRun=0, Int_t endRun=AliCDBRunRange::Infinity())
Int_t NofChannelsInManu(Int_t manuId) const
void WriteMapping(Int_t startRun=0, Int_t endRun=AliCDBRunRange::Infinity())
Bool_t CheckMapping(Bool_t segmentationOnly=kFALSE)
Definition: AliMUONCDB.cxx:211
Basic implementation of AliMUONVStore container using AliMpExMap internally.
Definition: AliMUON2DMap.h:20
void WriteRejectList(Bool_t defaultValues, Int_t startRun, Int_t endRun=AliCDBRunRange::Infinity())
Bool_t IsValid() const
Return validity.
Definition: AliMpPad.h:89
virtual Bool_t Add(TObject *object)=0
Add an object to the store.
The class defines the properties of BusPatch.
Definition: AliMpBusPatch.h:21
Single entry point to access MUON calibration data.
virtual Bool_t Add(TObject *object)
Add an object to the store.
static void UnloadAll()
Definition: AliMpCDB.cxx:520
The abstract base class for the segmentation.
Implementation of AliMUONVStore.
Definition: AliMUON1DMap.h:21
Int_t GetBusPatchId(Int_t index) const
TArrayI runlist(10000)
static TString GlobalTriggerBoardMapping()
Definition: AliMpFiles.cxx:347
Object to hold the list of elements we want to reject from the reconstruction.
void WriteLocalTriggerMasks(Int_t startRun=0, Int_t endRun=AliCDBRunRange::Infinity())
void ReadIntegers(const char *filename, std::vector< int > &integers)
Class which encapsuate all information about a pad.
Definition: AliMpPad.h:22
Bool_t CheckOCDB(Bool_t pathOnly=kFALSE)
Definition: AliMUONCDB.cxx:187
Int_t HVStatus(Int_t detElemId, Int_t manuId) const
static TMap * CreateHV(Int_t runNumber, Int_t *startOfValidity=0, Bool_t patched=kTRUE, TList *messages=0x0, Bool_t dryRun=kFALSE)
Create a hv map (which must be deleted) from OCDB for the given run.
const AliMpArrayI * ManusForHV(Int_t hvIndex) const
Double_t MeanHVValueForDCSAlias(TMap &hvMap, const char *hvChannel)
UInt_t PadGoodnessMask() const
Get the goodness mask.
Int_t GetValue(Int_t index) const
Bool_t IsConnectedChannel(Int_t manuId, Int_t manuChannel) const
virtual AliMpPad PadByLocation(Int_t manuId, Int_t manuChannel, Bool_t warning=true) const =0
Find pad by location.
Int_t DetElemIdFromDCSAlias(const char *dcsAlias) const
Base class for MUON data stores.
Definition: AliMUONVStore.h:22
Bool_t LoadMapping(Bool_t segmentationOnly=kFALSE)
Definition: AliMUONCDB.cxx:257
void WriteCapacitances(Bool_t defaultValues, Int_t startRun=0, Int_t endRun=AliCDBRunRange::Infinity())
static Bool_t LoadAll(Bool_t warn=false)
Definition: AliMpCDB.cxx:196
void ShowCapacitances()
Int_t ReadData(const TString &fileName="")
virtual Int_t GetSize() const
The number of objects stored.
void WriteRegionalTriggerConfig(Int_t startRun=0, Int_t endRun=AliCDBRunRange::Infinity())
MUON trigger look up table class.
static Bool_t LoadMpSegmentation(Bool_t warn=false)
Definition: AliMpCDB.cxx:113
Int_t ReadData(const TString &fileName="")
High Voltage.
Definition: AliMpDCSNamer.h:68
static Int_t NofTrackingChambers()
Return number of tracking chambers.
The class defines the properties of regional trigger crate.
Make a 2DStore of pad statuses, using different sources of information.
void WriteToCDB(const char *calibpath, TObject *object, Int_t startRun, Int_t endRun, Bool_t defaultValues)
virtual TObject * FindObject(const char *name) const
Find an object by name.
Helper class making Root persistent TExMap.
Definition: AliMpExMap.h:28
static Int_t ManuMask(AliMp::PlaneType planeType)
AliMUONRecoParam * LoadRecoParam()
Definition: AliMUONCDB.cxx:290
virtual void SetValueAsDouble(Int_t i, Int_t j, Double_t value)
void SetLimits(const AliMUONRecoParam &recoParams)
virtual void Print(Option_t *opt="") const