AliRoot Core  3abf5b4 (3abf5b4)
 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 #include "AliMergeableCollection.h"
82 
83 #include <Riostream.h>
84 #include <TArrayI.h>
85 #include <TClass.h>
86 #include "TF1.h"
87 #include <TFile.h>
88 #include <TH1F.h>
89 #include <TList.h>
90 #include <TMap.h>
91 #include <TObjString.h>
92 #include <TROOT.h>
93 #include <TRandom.h>
94 #include <TStopwatch.h>
95 #include <TSystem.h>
96 #include <TMath.h>
97 #include <TGeoGlobalMagField.h>
98 #include <TClonesArray.h>
99 #include <sstream>
100 #include <set>
101 
102 using std::endl;
103 using std::cout;
104 using std::cerr;
105 using std::ostringstream;
106 using std::ifstream;
107 
108 namespace
109 {
110  //_____________________________________________________________________________
111 AliMUONVStore* Create2DMap()
112 {
113  return new AliMUON2DMap(true);
114 }
115 
116  //_____________________________________________________________________________
117 void getBoundaries(const AliMUONVStore& store, Int_t dim,
118  Float_t* xmin, Float_t* xmax)
119 {
123 
124  for ( Int_t i = 0; i < dim; ++i )
125  {
126  xmin[i]=1E30;
127  xmax[i]=-1E30;
128  }
129 
130  TIter next(store.CreateIterator());
131  AliMUONVCalibParam* value;
132 
133  while ( ( value = dynamic_cast<AliMUONVCalibParam*>(next() ) ) )
134  {
135  Int_t detElemId = value->ID0();
136  Int_t manuId = value->ID1();
137 
138  const AliMpVSegmentation* seg =
140 
141  if (!seg) continue;
142 
143  for ( Int_t manuChannel = 0; manuChannel < value->Size(); ++manuChannel )
144  {
145  AliMpPad pad = seg->PadByLocation(manuId,manuChannel,kFALSE);
146  if (!pad.IsValid()) continue;
147 
148  for ( Int_t i = 0; i < dim; ++i )
149  {
150  Float_t x0 = value->ValueAsFloat(manuChannel,i);
151 
152  xmin[i] = TMath::Min(xmin[i],x0);
153  xmax[i] = TMath::Max(xmax[i],x0);
154  }
155  }
156  }
157 
158  for ( Int_t i = 0; i < dim; ++i )
159  {
160  if ( TMath::Abs(xmin[i]-xmax[i]) < 1E-3 )
161  {
162  xmin[i] -= 1;
163  xmax[i] += 1;
164  }
165  }
166 }
167 
168 //_____________________________________________________________________________
169 Double_t GetRandom(Double_t mean, Double_t sigma, Bool_t mustBePositive)
170 {
171  Double_t x(-1);
172  if ( mustBePositive )
173  {
174  while ( x < 0 )
175  {
176  x = gRandom->Gaus(mean,sigma);
177  }
178  }
179  else
180  {
181  x = gRandom->Gaus(mean,sigma);
182  }
183  return x;
184 }
185 
186 }
187 
188 //_____________________________________________________________________________
189 Bool_t AliMUONCDB::CheckOCDB(Bool_t pathOnly)
190 {
192 
193  AliCDBManager* man = AliCDBManager::Instance();
194 
195  // first OCDB path
196  if (!man->IsDefaultStorageSet()) {
197  AliErrorGeneral("AliMUONCDB", "OCDB path must be properly set");
198  return kFALSE;
199  }
200 
201  // then run number if required
202  if (pathOnly) return kTRUE;
203  if (man->GetRun() < 0) {
204  AliErrorGeneral("AliMUONCDB", "Run number must be properly set");
205  return kFALSE;
206  }
207 
208  return kTRUE;
209 
210 }
211 
212 //______________________________________________________________________________
213 void AliMUONCDB::CheckHV(Int_t runNumber, Int_t verbose)
214 {
216 
217  TList messages;
218  messages.SetOwner(kTRUE);
219 
220  Bool_t patched(kTRUE);
221 
222  if (!AliCDBManager::Instance()->IsDefaultStorageSet())
223  {
224  AliCDBManager::Instance()->SetDefaultStorage("raw://");
225  }
226 
227  AliCDBManager::Instance()->SetRun(runNumber);
228 
229  LoadMapping();
230 
231  AliMUONCalibrationData::CreateHV(runNumber,0,patched,&messages);
232 
233  AliMUONCalibrationData cd(runNumber,true);
234 
235  AliMUONPadStatusMaker statusMaker(cd);
236 
238 
239  if (!rp)
240  {
241  AliErrorGeneral("AliMUONCDB::CheckHV","Could not get RecoParam !!!");
242  return;
243  }
244 
245  statusMaker.SetLimits(*rp);
246 
247  TIter next(&messages);
248  TObjString* s;
249  AliMpDCSNamer hvNamer("TRACKER");
250  AliMUONLogger log;
251  Double_t meanHVValue(0.0);
252  Double_t nofHVValues(0.0);
253 
254  while ( ( s = static_cast<TObjString*>(next()) ) )
255  {
256  TObjArray* a = s->String().Tokenize(":");
257 
258  TString name(static_cast<TObjString*>(a->At(0))->String());
259 
260  TObjArray* b = name.Tokenize(" ");
261 
262  name = static_cast<TObjString*>(b->At(0))->String();
263 
264  delete a;
265  delete b;
266 
267  if ( name.Contains("sw") || name.Contains("SUMMARY") ) {continue;}
268 
269  Int_t index = hvNamer.DCSIndexFromDCSAlias(name.Data());
270 
271  Int_t detElemId = hvNamer.DetElemIdFromDCSAlias(name.Data());
272 
274 
275  if (!de)
276  {
277  AliErrorGeneral("AliMUONCDB::CheckHV",Form("Could not get detElemId from dcsAlias %s",name.Data()));
278  continue;
279  }
280 
281  Int_t manuId;
282 
283  if ( index >= 0 )
284  {
285  const AliMpArrayI* array = de->ManusForHV(index);
286  manuId = array->GetValue(0);
287  }
288  else
289 
290  {
292  manuId = bp->GetManuId(0);
293  }
294 
295  Int_t status = statusMaker.HVStatus(detElemId,manuId);
296 
297  log.Log(AliMUONPadStatusMaker::AsString(status).Data());
298 
299  meanHVValue += MeanHVValueForDCSAlias((*cd.HV()),name.Data());
300 
301  nofHVValues += 1.0;
302 
303  s->String() += Form(" (DE %4d) ",detElemId);
304  s->String() += AliMUONPadStatusMaker::AsString(status).Data();
305  }
306 
307  TIter nextMessage(&messages);
308  TObjString* msg;
309 
310  while ( ( msg = static_cast<TObjString*>(nextMessage()) ) )
311  {
312  if ( verbose > 0 || msg->String().Contains("SUMMARY") )
313  {
314  AliInfoGeneral("AliMUONCDB::CheckHV",Form("RUN %09d HVchannel %s",runNumber,msg->String().Data()));
315  }
316  }
317 
318  TString lmsg;
319  Int_t occurance;
320  TString totalLog;
321 
322  while (log.Next(lmsg,occurance))
323  {
324  totalLog += Form("%s(%d)",lmsg.Data(),occurance);
325  totalLog += " | ";
326  }
327 
328  AliInfoGeneral("AliMUONCDB::CheckHV",Form("RUN %09d %s",runNumber,totalLog.Data()));
329 
330  // one last loop to get the list of problematic HV channels
331  nextMessage.Reset();
332 
333  while ( ( msg = static_cast<TObjString*>(nextMessage()) ) )
334  {
335  if ( msg->String().Contains("HV ") )
336  {
337  AliInfoGeneral("AliMUONCDB::CheckHV",Form(" Problem at %s",msg->String().Data()));
338  }
339  }
340 
341  if (nofHVValues)
342  {
343  meanHVValue /= nofHVValues;
344  AliInfoGeneral("AliMUONCDB::CheckHV",Form("Mean HV for run %09d was %7.2f",runNumber,meanHVValue));
345  }
346 
347  AliCDBManager::Instance()->ClearCache();
348 }
349 
350 //______________________________________________________________________________
351 void AliMUONCDB::CheckHV_ALIROOT_6402(const char* runlist, Bool_t verbose)
352 {
356 
357  std::vector<int> runnumbers;
358 
359  ReadIntegers(runlist,runnumbers);
360 
361  std::vector<int> affectedRuns;
362 
363  for ( unsigned int i = 0 ; i < runnumbers.size(); ++i )
364  {
365  int runNumber = runnumbers[i];
366 
367  Bool_t affected = CheckHV_ALIROOT_6402(runNumber,verbose);
368 
369  std::cout << Form("RUN %09d is potentially affected by bug ALIROOT-6402 : %s",runNumber,affected ? "YES":"NO") << std::endl;
370 
371  if (affected)
372  {
373  affectedRuns.push_back(runNumber);
374  }
375  }
376 
377  std::cout << Form("%4lu runs affected in the list of %4lu runs : ",affectedRuns.size(),runnumbers.size());
378  for ( unsigned int i = 0 ; i < affectedRuns.size(); ++i )
379  {
380  std::cout << affectedRuns[i] << ",";
381  }
382  std::cout << std::endl;
383 }
384 
385 //______________________________________________________________________________
386 Bool_t AliMUONCDB::CheckHV_ALIROOT_6402(Int_t runNumber, Bool_t verbose)
387 {
394 
395  AliLog::GetRootLogger()->SetGlobalLogLevel(AliLog::kError);
396 
397  TList messages;
398  messages.SetOwner(kTRUE);
399 
400  if (!AliCDBManager::Instance()->IsDefaultStorageSet())
401  {
402  AliCDBManager::Instance()->SetDefaultStorage("raw://");
403  }
404 
405  AliCDBManager::Instance()->SetRun(runNumber);
406 
407  LoadMapping();
408 
409  TMap* hvMap = dynamic_cast<TMap*>(AliMUONCalibrationData::CreateObject(runNumber,"MUON/Calib/HV"));
410 
411  PatchHV(*hvMap,&messages,kTRUE);
412 
413  if (verbose)
414  {
415  TIter next(&messages);
416  TObjString* msg;
417  while ( ( msg = static_cast<TObjString*>(next())))
418  {
419  std::cout << Form("RUN %09d %s",runNumber,msg->String().Data()) << std::endl;
420  }
421  }
422 
423  TIter next(hvMap);
424  TObjString* hvChannelName;
425 
426  Bool_t affected(kFALSE);
427 
428  while ( ( hvChannelName = static_cast<TObjString*>(next()) ) )
429  {
430  TString name(hvChannelName->String());
431  if ( IsSt1DCSAliasRemapped(name) )
432  {
433  Float_t hvvalue = MeanHVValueForDCSAlias(*hvMap,name.Data());
434  if ( hvvalue < 1590.0 )
435  {
436  affected = kTRUE;
437  if ( verbose )
438  {
439  std::cout << Form("RUN %09d %40s HV VALUE %7.2f",runNumber,name.Data(),hvvalue) << std::endl;
440  }
441  }
442  }
443  }
444 
445  AliCDBManager::Instance()->ClearCache();
446 
447  return affected;
448 }
449 
450 //_____________________________________________________________________________
451 Bool_t AliMUONCDB::CheckMapping(Bool_t segmentationOnly)
452 {
454 
455  // first the segmentation
456  if (!AliMpSegmentation::Instance(false)) {
457  AliErrorGeneral("AliMUONCDB", "Mapping segmentation must be loaded first");
458  return kFALSE;
459  }
460 
461  // then the others if required
462  if (segmentationOnly) return kTRUE;
463  if (!AliMpDDLStore::Instance(false) || !AliMpDEStore::Instance(false) || !AliMpManuStore::Instance(false)) {
464  AliErrorGeneral("AliMUONCDB", "Full mapping must be loaded first");
465  return kFALSE;
466  }
467 
468  return kTRUE;
469 
470 }
471 
472 //______________________________________________________________________________
473 Bool_t AliMUONCDB::IsSt1DCSAliasRemapped(const TString& name)
474 {
475  Bool_t isit(kFALSE);
476 
477  if ( name.Contains("Chamber00Left") )
478  {
479  if (name.Contains("Quad1Sect0")) isit = kTRUE;
480 
481  if (name.Contains("Quad1Sect1")) isit = kTRUE;
482  if (name.Contains("Quad1Sect2")) isit = kTRUE;
483 
484  if (name.Contains("Quad2Sect2")) isit = kTRUE;
485  if (name.Contains("Quad2Sect1")) isit = kTRUE;
486  if (name.Contains("Quad2Sect0")) isit = kTRUE;
487  }
488  else if ( name.Contains("Chamber01Left"))
489  {
490  if (name.Contains("Quad2Sect2")) isit = kTRUE;
491  if (name.Contains("Quad2Sect0")) isit = kTRUE;
492  }
493 
494  return isit;
495 }
496 
497 //_____________________________________________________________________________
499 {
502 
503  AliInfoGeneral("AliMUONCDB","Loading field map from GRP...");
504 
505  if (!AliMUONCDB::CheckOCDB()) return kFALSE;
506 
507  AliGRPManager grpMan;
508 
509  // make sure the old field is deleted even if it is locked
510  if(TGeoGlobalMagField::Instance()->IsLocked()) delete TGeoGlobalMagField::Instance();
511 
512  if (!grpMan.ReadGRPEntry() || !grpMan.SetMagField()) {
513  AliErrorGeneral("AliMUONCDB", "failed to load magnetic field from OCDB");
514  return kFALSE;
515  }
516 
517  return kTRUE;
518 
519 }
520 
521 //_____________________________________________________________________________
522 Bool_t AliMUONCDB::LoadMapping(Bool_t segmentationOnly)
523 {
526 
527  AliInfoGeneral("AliMUONCDB", "Loading mapping from OCDB...");
528 
529  if (!AliMUONCDB::CheckOCDB()) return kFALSE;
530 
531  // in case it has already been set
533 
534  if (segmentationOnly) {
535 
536  if (!AliMpCDB::LoadMpSegmentation(kTRUE)){
537  AliErrorGeneral("AliMUONCDB", "failed to load segmentation from OCDB");
538  return kFALSE;
539  }
540 
541  } else {
542 
543  if (!AliMpCDB::LoadAll(kTRUE)) {
544  AliErrorGeneral("AliMUONCDB", "failed to load mapping from OCDB");
545  return kFALSE;
546  }
547 
548  }
549 
550  return kTRUE;
551 
552 }
553 
554 //_____________________________________________________________________________
556 {
559 
560  AliInfoGeneral("AliMUONCDB", "Loading RecoParam from OCDB...");
561 
562  if (!AliMUONCDB::CheckOCDB()) return 0x0;
563 
564  AliMUONRecoParam* recoParam = 0x0;
565  AliCDBEntry* entry = AliCDBManager::Instance()->Get("MUON/Calib/RecoParam");
566 
567  if(entry) {
568 
569  // load recoParam according OCDB content (single or array)
570  if (!(recoParam = dynamic_cast<AliMUONRecoParam*>(entry->GetObject()))) {
571 
572  TObjArray* recoParamArray = static_cast<TObjArray*>(entry->GetObject());
573 // recoParamArray->SetOwner(kTRUE); // FIXME: this should be done, but is causing a problem at the end of the reco... investigate why...
574 
575  for(Int_t i = 0; i < recoParamArray->GetEntriesFast(); i++) {
576  recoParam = static_cast<AliMUONRecoParam*>(recoParamArray->UncheckedAt(i));
577  if (recoParam->IsDefault()) break;
578  recoParam = 0x0;
579  }
580 
581  }
582 
583  }
584 
585  if (!recoParam) AliErrorGeneral("AliMUONCDB", "failed to load RecoParam from OCDB");
586 
587  return recoParam;
588 
589 }
590 
591 //_____________________________________________________________________________
593 {
595 
596  AliInfoGeneral("AliMUONCDB", "Loading Alignemnt from OCDB...");
597 
598  if (!AliMUONCDB::CheckOCDB()) return 0x0;
599 
600  TClonesArray* alignmentArray = 0x0;
601  AliCDBEntry* entry = AliCDBManager::Instance()->Get("MUON/Align/Data");
602 
603  if (entry) {
604  // load alignement array
605  alignmentArray = dynamic_cast<TClonesArray*>(entry->GetObject());
606  }
607 
608  if (!alignmentArray) {
609  AliErrorGeneral("AliMUONCDB", "failed to load Alignemnt from OCDB");
610  }
611 
612  return alignmentArray;
613 }
614 
615 //_____________________________________________________________________________
618  const char* opt)
619 {
626 
627  TString sopt(opt);
628  sopt.ToUpper();
629 
630  if ( !sopt.Contains("ABS") && !sopt.Contains("REL") && !sopt.Contains("PERCENT") )
631  {
632  AliErrorGeneral("AliMUONCDB", Form("opt %s not supported. Only ABS, REL, PERCENT are",opt));
633  return 0x0;
634  }
635 
636  AliMUONVStore* d = static_cast<AliMUONVStore*>(store1.Clone());
637 
638  TIter next(d->CreateIterator());
639 
640  AliMUONVCalibParam* param;
641 
642  while ( ( param = dynamic_cast<AliMUONVCalibParam*>(next() ) ) )
643  {
644  Int_t detElemId = param->ID0();
645  Int_t manuId = param->ID1();
646 
647  AliMUONVCalibParam* param2 = dynamic_cast<AliMUONVCalibParam*>(store2.FindObject(detElemId,manuId));
648  //FIXME: this might happen. Handle it.
649  if (!param2)
650  {
651  cerr << "param2 is null : FIXME : this might happen !" << endl;
652  delete d;
653  return 0;
654  }
655 
656  for ( Int_t i = 0; i < param->Size(); ++i )
657  {
658  for ( Int_t j = 0; j < param->Dimension(); ++j )
659  {
660  Float_t value(0);
661  if ( sopt.Contains("ABS") )
662  {
663  value = param->ValueAsFloat(i,j) - param2->ValueAsFloat(i,j);
664  }
665  else if ( sopt.Contains("REL") || sopt.Contains("PERCENT") )
666  {
667  if ( param->ValueAsFloat(i,j) )
668  {
669  value = (param->ValueAsFloat(i,j) - param2->ValueAsFloat(i,j))/param->ValueAsFloat(i,j);
670  }
671  else
672  {
673  continue;
674  }
675  if ( sopt.Contains("PERCENT") ) value *= 100.0;
676  }
677  param->SetValueAsFloat(i,j,value);
678  }
679  }
680  }
681  return d;
682 }
683 
684 //_____________________________________________________________________________
685 TH1**
686 AliMUONCDB::Plot(const AliMUONVStore& store, const char* name, Int_t nbins)
687 {
691 
692  if (!AliMUONCDB::CheckMapping(kTRUE)) return 0x0;
693 
694  TIter next(store.CreateIterator());
695  AliMUONVCalibParam* param;
696  Int_t n(0);
697  const Int_t kNStations = AliMpConstants::NofTrackingChambers()/2;
698  Int_t* nPerStation = new Int_t[kNStations];
699  TH1** h(0x0);
700 
701  for ( Int_t i = 0; i < kNStations; ++i ) nPerStation[i]=0;
702 
703  while ( ( param = static_cast<AliMUONVCalibParam*>(next()) ) )
704  {
705  if (!h)
706  {
707  Int_t dim = param->Dimension();
708  h = new TH1*[dim];
709  Float_t* xmin = new Float_t[dim];
710  Float_t* xmax = new Float_t[dim];
711  getBoundaries(store,dim,xmin,xmax);
712 
713  for ( Int_t i = 0; i < dim; ++i )
714  {
715  h[i] = new TH1F(Form("%s_%d",name,i),Form("%s_%d",name,i),
716  nbins,xmin[i],xmax[i]);
717  AliInfoGeneral("AliMUONCDB", Form("Created histogram %s",h[i]->GetName()));
718  }
719  delete [] xmin;
720  delete [] xmax;
721  }
722 
723  Int_t detElemId = param->ID0();
724  Int_t manuId = param->ID1();
725  Int_t station = AliMpDEManager::GetChamberId(detElemId)/2;
726 
727  const AliMpVSegmentation* seg =
729 
730  if (!seg) continue;
731 
732  for ( Int_t manuChannel = 0; manuChannel < param->Size(); ++manuChannel )
733  {
734  AliMpPad pad = seg->PadByLocation(manuId,manuChannel,kFALSE);
735  if (!pad.IsValid()) continue;
736 
737  ++n;
738  ++nPerStation[station];
739 
740  for ( Int_t dim = 0; dim < param->Dimension(); ++dim )
741  {
742  h[dim]->Fill(param->ValueAsFloat(manuChannel,dim));
743  }
744  }
745  }
746 
747  for ( Int_t i = 0; i < kNStations; ++i )
748  {
749  AliInfoGeneral("AliMUONCDB", Form("Station %d %d ",(i+1),nPerStation[i]));
750  }
751 
752  AliInfoGeneral("AliMUONCDB", Form("Number of channels = %d",n));
753 
754  delete[] nPerStation;
755 
756  return h;
757 }
758 
759 //_____________________________________________________________________________
760 Int_t AliMUONCDB::MakeBusPatchEvolution(AliMergeableCollection& hc, int timeResolution)
761 {
764 
765  if (!AliMUONCDB::CheckMapping()) return 0;
766 
767  TDatime origin;
768 
769  double xmin = 0;
770  double xmax = xmin + 3600;
771 
772  int nbins = TMath::Nint((xmax-xmin)/timeResolution);
773 
774  TIter next(AliMpDDLStore::Instance()->CreateBusPatchIterator());
775  AliMpBusPatch* bp;
776 
777  Int_t total(0);
778 
779  TF1 f1("f1","pol0",xmin,xmax);
780 
781  while ((bp = static_cast<AliMpBusPatch*>(next())))
782  {
783  ++total;
784  TH1* h = new TH1F(Form("BP%04d",bp->GetId()),Form("Number of hits in %d s bins",timeResolution),nbins,xmin,xmax);
785  f1.SetParameter(0,bp->GetId());
786  h->FillRandom("f1",10000);
787  h->GetXaxis()->SetTimeDisplay(1);
788  h->GetXaxis()->SetTimeFormat("%d/%m/%y %H:%M");
789  h->GetXaxis()->SetTimeOffset(origin.Convert());
790  hc.Adopt(Form("/BUSPATCH/HITS/%ds",timeResolution),h);
791  }
792 
793  // number of events needed for normalization
794 
795  TH1* h = new TH1F(Form("Nevents%ds",timeResolution),Form("Number of events %d s bins",timeResolution),nbins,xmin,xmax);
796 
797  f1.SetParameter(0,4200);
798 
799  h->FillRandom("f1",10000);
800 
801  h->GetXaxis()->SetTimeDisplay(1);
802  h->GetXaxis()->SetTimeFormat("%d/%m/%y %H:%M");
803  h->GetXaxis()->SetTimeOffset(origin.Convert());
804 
805  hc.Adopt("",h);
806 
807  return (total == 888);
808 }
809 
810 //_____________________________________________________________________________
811 Int_t
812 AliMUONCDB::MakeHVStore(TMap& aliasMap, Bool_t defaultValues)
813 {
815 
816  if (!AliMUONCDB::CheckMapping()) return 0;
817 
818  AliMpDCSNamer hvNamer("TRACKER");
819 
820  TObjArray* aliases = hvNamer.GenerateAliases();
821 
822  Int_t nSwitch(0);
823  Int_t nChannels(0);
824 
825  for ( Int_t i = 0; i < aliases->GetEntries(); ++i )
826  {
827  TObjString* alias = static_cast<TObjString*>(aliases->At(i));
828  TString& aliasName = alias->String();
829  if ( aliasName.Contains("sw") )
830  {
831  // HV Switch (St345 only)
832  TObjArray* valueSet = new TObjArray;
833  valueSet->SetOwner(kTRUE);
834 
835  Bool_t value = kTRUE;
836 
837  if (!defaultValues)
838  {
839  Float_t r = gRandom->Uniform();
840  if ( r < 0.007 ) value = kFALSE;
841  }
842 
843  for ( UInt_t timeStamp = 0; timeStamp < 60*3; timeStamp += 60 )
844  {
845  AliDCSValue* dcsValue = new AliDCSValue(value,timeStamp);
846  valueSet->Add(dcsValue);
847  }
848  aliasMap.Add(new TObjString(*alias),valueSet);
849  ++nSwitch;
850  }
851  else if (aliasName.Contains("Mon") )
852  {
853  TObjArray* valueSet = new TObjArray;
854  valueSet->SetOwner(kTRUE);
855  for ( UInt_t timeStamp = 0; timeStamp < 60*15; timeStamp += 120 )
856  {
857  Float_t value = 1500;
858  if (!defaultValues) value = GetRandom(1750,62.5,true);
859  AliDCSValue* dcsValue = new AliDCSValue(value,timeStamp);
860  valueSet->Add(dcsValue);
861  }
862  aliasMap.Add(new TObjString(*alias),valueSet);
863  ++nChannels;
864  }
865  }
866 
867  delete aliases;
868 
869  AliInfoGeneral("AliMUONCDB", Form("%d HV channels and %d switches",nChannels,nSwitch));
870 
871  return nChannels+nSwitch;
872 }
873 
874 //_____________________________________________________________________________
875 Int_t
876 AliMUONCDB::MakeLVStore(TMap& aliasMap, Bool_t defaultValues, time_t refTime)
877 {
879 
880  if (!AliMUONCDB::CheckMapping()) return 0;
881 
882  AliMpDCSNamer hvNamer("TRACKER");
883 
884  TObjArray* aliases = hvNamer.GenerateAliases("Group");
885 
886  Int_t npos(0), nneg(0), ndig(0);
887 
888  for ( Int_t i = 0; i < aliases->GetEntries(); ++i )
889  {
890  TObjString* alias = static_cast<TObjString*>(aliases->At(i));
891  TString& aliasName = alias->String();
892  Float_t refValue = 0;
893 
894  if ( aliasName.Contains("anp") )
895  {
896  refValue = 2.5;
897  ++npos;
898  }
899  else if ( aliasName.Contains("dig") )
900  {
901  refValue = 3.3;
902  ++ndig;
903  }
904  else if ( aliasName.Contains("ann") )
905  {
906  refValue = 2.5; // that's not a bug : even though we're describing
907  // a negative value, the DCS data point is positive.
908  ++nneg;
909  }
910  else
911  {
912  AliErrorGeneral("AliMUONCDB","Should not be here ! CHECK ME !");
913  continue;
914  }
915 
916  TObjArray* valueSet = new TObjArray;
917  valueSet->SetOwner(kTRUE);
918 
919  Float_t value = refValue;
920 
921  for ( UInt_t timeStamp = 0; timeStamp < 60*15; timeStamp += 120 )
922  {
923  if (!defaultValues) value = GetRandom(refValue,0.05,false);
924  AliDCSValue* dcsValue = new AliDCSValue(value,refTime+timeStamp);
925  valueSet->Add(dcsValue);
926  }
927  aliasMap.Add(new TObjString(*alias),valueSet);
928  }
929 
930  Bool_t ok = (npos==nneg) && (npos==ndig) && (ndig==nneg);
931 
932  if (!ok) {
933  AliErrorGeneral("AliMUONCDB",Form("Wrong number of LV channels : npos=%d nneg=%d ndig=%d",npos,nneg,ndig));
934  }
935  else {
936  AliInfoGeneral("AliMUONCDB", Form("%d LV groups - %d aliases",npos,aliasMap.GetEntries()));
937  }
938 
939  delete aliases;
940 
941  return npos;
942 }
943 
944 //_____________________________________________________________________________
945 void AliMUONCDB::AddDCSValue ( TMap& aliasMap, Int_t imeas, const char* smt, const char* sInOut, Int_t rpc, Float_t value )
946 {
947  TString sMeasure = ( imeas == AliMpDCSNamer::kDCSHV ) ? "HV.vEff" : "HV.actual.iMon";
948  TString alias = Form("MTR_%s_%s_RPC%i_%s",sInOut,smt,rpc,sMeasure.Data());
949  TObjArray* valueSet = new TObjArray;
950  valueSet->SetOwner(kTRUE);
951 
952  for ( UInt_t timeStamp = 0; timeStamp < 60*2; timeStamp += 60 ) {
953  AliDCSValue* dcsValue = new AliDCSValue(value,timeStamp);
954  valueSet->Add(dcsValue);
955  }
956 
957  aliasMap.Add(new TObjString(alias),valueSet);
958 }
959 
960 //_____________________________________________________________________________
961 Int_t
963 {
965 
966 // if (!AliMUONCDB::CheckMapping()) return 0;
967 
968  Int_t nChannels[2] = {0, 0};
969 
970  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT11","INSIDE",1,10400.);
971  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT11","INSIDE",2,10351.);
972  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT11","INSIDE",3,10300.);
973  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT11","INSIDE",4,10450.);
974  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT11","INSIDE",5,10250.);
975  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT11","INSIDE",6,10100.);
976  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT11","INSIDE",7,10250.);
977  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT11","INSIDE",8,10350.);
978  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT11","INSIDE",9,10350.);
979 
980  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT11","OUTSIDE",1,10300.);
981  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT11","OUTSIDE",2,10350.);
982  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT11","OUTSIDE",3,10150.);
983  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT11","OUTSIDE",4,10350.);
984  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT11","OUTSIDE",5,10150.);
985  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT11","OUTSIDE",6,10350.);
986  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT11","OUTSIDE",7,10150.);
987  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT11","OUTSIDE",8,10150.);
988  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT11","OUTSIDE",9,10250.);
989 
990  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT12","INSIDE",1,10350.);
991  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT12","INSIDE",2,10350.);
992  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT12","INSIDE",3,10250.);
993  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT12","INSIDE",4,10250.);
994  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT12","INSIDE",5,10150.);
995  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT12","INSIDE",6,10350.);
996  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT12","INSIDE",7,10400.);
997  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT12","INSIDE",8,10200.);
998  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT12","INSIDE",9,10350.);
999 
1000  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT12","OUTSIDE",1,10400.);
1001  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT12","OUTSIDE",2,10250.);
1002  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT12","OUTSIDE",3,10250.);
1003  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT12","OUTSIDE",4,10300.);
1004  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT12","OUTSIDE",5,10300.);
1005  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT12","OUTSIDE",6,10200.);
1006  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT12","OUTSIDE",7,10100.);
1007  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT12","OUTSIDE",8,10400.);
1008  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT12","OUTSIDE",9,10400.);
1009 
1010  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT21","INSIDE",1,10200.);
1011  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT21","INSIDE",2,10250.);
1012  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT21","INSIDE",3,10250.);
1013  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT21","INSIDE",4,10150.);
1014  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT21","INSIDE",5,10100.);
1015  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT21","INSIDE",6,10100.);
1016  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT21","INSIDE",7,10200.);
1017  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT21","INSIDE",8,10150.);
1018  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT21","INSIDE",9,10250.);
1019 
1020  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT21","OUTSIDE",1,10200.);
1021  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT21","OUTSIDE",2,10350.);
1022  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT21","OUTSIDE",3,10200.);
1023  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT21","OUTSIDE",4,10100.);
1024  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT21","OUTSIDE",5,10250.);
1025  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT21","OUTSIDE",6,10101.);
1026  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT21","OUTSIDE",7,10200.);
1027  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT21","OUTSIDE",8,10300.);
1028  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT21","OUTSIDE",9,10250.);
1029 
1030  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT22","INSIDE",1,10300.);
1031  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT22","INSIDE",2,10300.);
1032  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT22","INSIDE",3,9624.); // FEERIC
1033  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT22","INSIDE",4,10150.);
1034  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT22","INSIDE",5,10250.);
1035  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT22","INSIDE",6,10150.);
1036  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT22","INSIDE",7,10050.);
1037  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT22","INSIDE",8,10050.);
1038  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT22","INSIDE",9,10150.);
1039 
1040  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT22","OUTSIDE",1,10225.);
1041  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT22","OUTSIDE",2,10250.);
1042  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT22","OUTSIDE",3,10150.);
1043  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT22","OUTSIDE",4,10100.);
1044  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT22","OUTSIDE",5,10200.);
1045  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT22","OUTSIDE",6,10200.);
1046  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT22","OUTSIDE",7,10250.);
1047  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT22","OUTSIDE",8,10225.);
1048  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSHV,"MT22","OUTSIDE",9,10250.);
1049 
1050  nChannels[0] = 72;
1051 
1052  TString chName[4] = {"MT11","MT12","MT21","MT22"};
1053 
1054  for ( Int_t ich=0; ich<4; ich++ ) {
1055  for ( Int_t iside=0; iside<2; iside++ ) {
1056  TString sInOut = ( iside == 0 ) ? "INSIDE" : "OUTSIDE";
1057  for ( Int_t irpc=1; irpc<=9; irpc++ ) {
1058  AddDCSValue(aliasMap,AliMpDCSNamer::kDCSI,chName[ich].Data(),sInOut.Data(),irpc,2.);
1059  ++nChannels[1];
1060  }
1061  }
1062  }
1063 
1064  AliInfoGeneral("AliMUONCDB", Form("Trigger channels I -> %i HV -> %i",nChannels[0], nChannels[1]));
1065 
1066  return nChannels[0] + nChannels[1];
1067 }
1068 
1069 //_____________________________________________________________________________
1070 Int_t
1071 AliMUONCDB::MakePedestalStore(AliMUONVStore& pedestalStore, Bool_t defaultValues)
1072 {
1076 
1077  AliCodeTimerAutoGeneral("",0);
1078 
1079  if (!AliMUONCDB::CheckMapping()) return 0;
1080 
1081  Int_t nchannels(0);
1082  Int_t nmanus(0);
1083 
1084  const Int_t kChannels(AliMpConstants::ManuNofChannels());
1085 
1086  // bending
1087  const Float_t kPedestalMeanMeanB(200.);
1088  const Float_t kPedestalMeanSigmaB(10.);
1089  const Float_t kPedestalSigmaMeanB(1.);
1090  const Float_t kPedestalSigmaSigmaB(0.2);
1091 
1092  // non bending
1093  const Float_t kPedestalMeanMeanNB(200.);
1094  const Float_t kPedestalMeanSigmaNB(10.);
1095  const Float_t kPedestalSigmaMeanNB(1.);
1096  const Float_t kPedestalSigmaSigmaNB(0.2);
1097 
1098  const Float_t kFractionOfDeadManu(0.); // within [0.,1.]
1099 
1100  Int_t detElemId;
1101  Int_t manuId;
1102 
1103  AliMpManuIterator it;
1104 
1105  while ( it.Next(detElemId,manuId) )
1106  {
1107  // skip a given fraction of manus
1108  if (kFractionOfDeadManu > 0. && gRandom->Uniform() < kFractionOfDeadManu) continue;
1109 
1110  ++nmanus;
1111 
1112  AliMUONVCalibParam* ped =
1113  new AliMUONCalibParamNF(2,kChannels,detElemId,manuId,AliMUONVCalibParam::InvalidFloatValue());
1114 
1116 
1117  for ( Int_t manuChannel = 0; manuChannel < kChannels; ++manuChannel )
1118  {
1119  if ( ! de->IsConnectedChannel(manuId,manuChannel) ) continue;
1120 
1121  ++nchannels;
1122 
1123  Float_t meanPedestal;
1124  Float_t sigmaPedestal;
1125 
1126  if ( defaultValues )
1127  {
1128  meanPedestal = 0.0;
1129  sigmaPedestal = 1.0;
1130  }
1131  else
1132  {
1133  Bool_t positive(kTRUE);
1134  meanPedestal = 0.0;
1135 
1136  if ( manuId & AliMpConstants::ManuMask(AliMp::kNonBendingPlane) ) { // manu in non bending plane
1137 
1138  while ( meanPedestal == 0.0 ) // avoid strict zero
1139  {
1140  meanPedestal = GetRandom(kPedestalMeanMeanNB,kPedestalMeanSigmaNB,positive);
1141  }
1142  sigmaPedestal = GetRandom(kPedestalSigmaMeanNB,kPedestalSigmaSigmaNB,positive);
1143 
1144  } else { // manu in bending plane
1145 
1146  while ( meanPedestal == 0.0 ) // avoid strict zero
1147  {
1148  meanPedestal = GetRandom(kPedestalMeanMeanB,kPedestalMeanSigmaB,positive);
1149  }
1150  sigmaPedestal = GetRandom(kPedestalSigmaMeanB,kPedestalSigmaSigmaB,positive);
1151 
1152  }
1153 
1154  }
1155 
1156  ped->SetValueAsFloat(manuChannel,0,meanPedestal);
1157  ped->SetValueAsFloat(manuChannel,1,sigmaPedestal);
1158 
1159  }
1160  Bool_t ok = pedestalStore.Add(ped);
1161  if (!ok)
1162  {
1163  AliErrorGeneral("AliMUONCDB", Form("Could not set DetElemId=%d manuId=%d",detElemId,manuId));
1164  }
1165  }
1166 
1167  AliInfoGeneral("AliMUONCDB", Form("%d Manus and %d channels.",nmanus,nchannels));
1168  return nchannels;
1169 }
1170 
1171 //_____________________________________________________________________________
1173 AliMUONCDB::MakeRejectListStore(Bool_t defaultValues)
1174 {
1176 
1177  AliCodeTimerAutoGeneral("",0);
1178 
1180 
1181  if (!defaultValues)
1182  {
1185  return rl;
1186  }
1187 
1188  return rl;
1189 }
1190 
1191 //_____________________________________________________________________________
1192 Int_t
1193 AliMUONCDB::MakeOccupancyMapStore(AliMUONVStore& occupancyMapStore, Bool_t defaultValues)
1194 {
1196 
1197  AliCodeTimerAutoGeneral("",0);
1198 
1199  if (!AliMUONCDB::CheckMapping()) return 0;
1200 
1201  Int_t nmanus(0);
1202 
1203  Int_t detElemId;
1204  Int_t manuId;
1205 
1206  AliMpManuIterator it;
1207 
1208  Int_t nevents(1000);
1209 
1210  while ( it.Next(detElemId,manuId) )
1211  {
1212  ++nmanus;
1213 
1214  AliMUONVCalibParam* occupancy = new AliMUONCalibParamND(5,1,detElemId,manuId,0);
1215 
1216  Double_t occ = 0.0;
1217 
1219 
1220  Int_t numberOfChannelsInManu = de->NofChannelsInManu(manuId);
1221 
1222  if (!defaultValues) occ = gRandom->Rndm(1);
1223 
1224  Double_t sumn = occ*nevents;
1225 
1226  occupancy->SetValueAsFloat(0,0,sumn);
1227  occupancy->SetValueAsFloat(0,1,sumn);
1228  occupancy->SetValueAsFloat(0,2,sumn);
1229  occupancy->SetValueAsInt(0,3,numberOfChannelsInManu);
1230  occupancy->SetValueAsInt(0,4,nevents);
1231 
1232  Bool_t ok = occupancyMapStore.Add(occupancy);
1233  if (!ok)
1234  {
1235  AliErrorGeneral("AliMUONCDB", Form("Could not set DetElemId=%d manuId=%d",detElemId,manuId));
1236  }
1237  }
1238 
1239  return nmanus;
1240 }
1241 
1242 //_____________________________________________________________________________
1243 Int_t
1245 {
1247 
1248  AliCodeTimerAutoGeneral("",0);
1249 
1250  Int_t ngenerated(0);
1251  // Generate fake mask values for all localboards and put that into
1252  // one single container (localBoardMasks)
1253  for ( Int_t i = 1; i <= AliMpConstants::TotalNofLocalBoards(); ++i )
1254  {
1255  AliMUONVCalibParam* localBoard = new AliMUONCalibParamNI(1,8,i,0,0);
1256  for ( Int_t x = 0; x < 2; ++x )
1257  {
1258  for ( Int_t y = 0; y < 4; ++y )
1259  {
1260  Int_t index = x*4+y;
1261  localBoard->SetValueAsInt(index,0,0xFFFF);
1262  ++ngenerated;
1263  }
1264  }
1265  localBoardMasks.Add(localBoard);
1266  }
1267  return ngenerated;
1268 }
1269 
1270 //_____________________________________________________________________________
1271 Int_t
1273 {
1275 
1276  AliCodeTimerAutoGeneral("",0);
1277 
1279  AliErrorGeneral("AliMUONCDB", "Error when reading from mapping file");
1280  return 0;
1281  }
1282 
1283  return rtm.GetNofTriggerCrates();
1284 }
1285 
1286 
1287 //_____________________________________________________________________________
1288 Int_t
1290 {
1292 
1293  AliCodeTimerAutoGeneral("",0);
1294 
1296 }
1297 
1298 
1299 //_____________________________________________________________________________
1302 {
1304 
1305  AliCodeTimerAutoGeneral("",0);
1306 
1308  lut->ReadFromFile(file);
1309  return lut;
1310 }
1311 
1312 //_____________________________________________________________________________
1315 {
1317 
1318  AliCodeTimerAutoGeneral("",0);
1319 
1320  return new AliMUONTriggerEfficiencyCells(file);
1321 }
1322 
1323 //______________________________________________________________________________
1324 void AliMUONCDB::PatchHV(TMap& hvMap, TList* messages, Bool_t onlySt1remapped)
1325 {
1326  TIter next(&hvMap);
1327  TObjString* hvChannelName;
1328 
1329  while ( ( hvChannelName = static_cast<TObjString*>(next()) ) )
1330  {
1331  TString name(hvChannelName->String());
1332 
1333  if ( name.Contains("sw") ) continue; // skip switches
1334 
1335  if ( name.Contains("iMon") ) continue; // skip HV currents
1336 
1337  if ( onlySt1remapped )
1338  {
1339  if (!IsSt1DCSAliasRemapped(name))
1340  {
1341  continue;
1342  }
1343  }
1344 
1345  TPair* hvPair = static_cast<TPair*>(hvMap.FindObject(name.Data()));
1346  TObjArray* values = static_cast<TObjArray*>(hvPair->Value());
1347  if (!values)
1348  {
1349  AliErrorGeneral("PatchHV",Form("Could not get values for alias %s",name.Data()));
1350  }
1351  else
1352  {
1353  TString msg;
1354 
1355  Bool_t ok = AliMUONCalibrationData::PatchHVValues(*values,&msg,kFALSE);
1356 
1357  if ( messages )
1358  {
1359  messages->Add(new TObjString(Form("%s %s",hvChannelName->String().Data(),msg.Data())));
1360  }
1361 
1362  if (!ok)
1363  {
1364  AliErrorGeneral("PatchHV",Form("PatchHVValue was not successfull ! This is serious ! "
1365  "You'll have to check the logic for channel %s",hvChannelName->String().Data()));
1366  }
1367  }
1368  }
1369 }
1370 
1371 
1372 //_____________________________________________________________________________
1373 void
1374 AliMUONCDB::WriteToCDB(const char* calibpath, TObject* object,
1375  Int_t startRun, Int_t endRun,
1376  const char* filename)
1377 {
1379 
1380  TString comment(gSystem->ExpandPathName(filename));
1381 
1382  WriteToCDB(object, calibpath, startRun, endRun, comment.Data());
1383 }
1384 
1385 //_____________________________________________________________________________
1386 void
1387 AliMUONCDB::WriteToCDB(const char* calibpath, TObject* object,
1388  Int_t startRun, Int_t endRun, Bool_t defaultValues)
1389 {
1391 
1392  TString comment;
1393  if ( defaultValues ) comment += "Test with default values";
1394  else comment += "Test with random values";
1395 
1396  WriteToCDB(object, calibpath, startRun, endRun, comment.Data());
1397 }
1398 
1399 //_____________________________________________________________________________
1400 void
1401 AliMUONCDB::WriteToCDB(TObject* object, const char* calibpath, Int_t startRun, Int_t endRun,
1402  const char* comment, const char* responsible)
1403 {
1405 
1406  if (!AliMUONCDB::CheckOCDB(kTRUE)) return;
1407 
1408  AliCDBId id(calibpath,startRun,endRun);
1409  AliCDBMetaData md;
1410  md.SetAliRootVersion(gROOT->GetVersion());
1411  md.SetComment(comment);
1412  md.SetResponsible(responsible);
1413  AliCDBManager::Instance()->Put(object,id,&md);
1414 }
1415 
1416 //_____________________________________________________________________________
1417 void
1418 AliMUONCDB::WriteLocalTriggerMasks(Int_t startRun, Int_t endRun)
1419 {
1421 
1423  Int_t ngenerated = MakeLocalTriggerMaskStore(*ltm);
1424  AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
1425  if (ngenerated>0)
1426  {
1427  WriteToCDB("MUON/Calib/LocalTriggerBoardMasks",ltm,startRun,endRun,true);
1428  }
1429  delete ltm;
1430 }
1431 
1432 //_____________________________________________________________________________
1433 void
1434 AliMUONCDB::WriteRegionalTriggerConfig(Int_t startRun, Int_t endRun)
1435 {
1437 
1439  Int_t ngenerated = MakeRegionalTriggerConfigStore(*rtm);
1440  AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
1441  if (ngenerated>0)
1442  {
1443  WriteToCDB("MUON/Calib/RegionalTriggerConfig",rtm,startRun,endRun,true);
1444  }
1445  delete rtm;
1446 }
1447 
1448 
1449 //_____________________________________________________________________________
1450 void
1451 AliMUONCDB::WriteGlobalTriggerConfig(Int_t startRun, Int_t endRun)
1452 {
1454 
1456 
1457  Int_t ngenerated = MakeGlobalTriggerConfigStore(*gtm);
1458  AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
1459  if (ngenerated>0)
1460  {
1461  WriteToCDB("MUON/Calib/GlobalTriggerCrateConfig",gtm,startRun,endRun,true);
1462  }
1463  delete gtm;
1464 }
1465 
1466 
1467 //_____________________________________________________________________________
1468 void
1469 AliMUONCDB::WriteTriggerLut(Int_t startRun, Int_t endRun)
1470 {
1472 
1474  if (lut)
1475  {
1476  WriteToCDB("MUON/Calib/TriggerLut",lut,startRun,endRun,true);
1477  }
1478  delete lut;
1479 }
1480 
1481 //_____________________________________________________________________________
1482 void
1483 AliMUONCDB::WriteTriggerEfficiency(Int_t startRun, Int_t endRun)
1484 {
1486 
1488  if (eff)
1489  {
1490  WriteToCDB("MUON/Calib/TriggerEfficiency",eff,startRun,endRun,true);
1491  }
1492  delete eff;
1493 }
1494 
1495 //_____________________________________________________________________________
1496 void
1497 AliMUONCDB::WriteHV(const char* inputFile, Int_t runNumber)
1498 {
1502 
1503  TFile* f = TFile::Open(gSystem->ExpandPathName(inputFile));
1504 
1505  if (!f->IsOpen()) return;
1506 
1507  TMap* hvStore = static_cast<TMap*>(f->Get("map"));
1508 
1509  WriteToCDB("MUON/Calib/HV",hvStore,runNumber,runNumber,kFALSE);
1510 
1511  delete hvStore;
1512 }
1513 
1514 //_____________________________________________________________________________
1515 void
1516 AliMUONCDB::WriteHV(Bool_t defaultValues,
1517  Int_t startRun, Int_t endRun)
1518 {
1523 
1524  TMap* hvStore = new TMap;
1525  Int_t ngenerated = MakeHVStore(*hvStore,defaultValues);
1526  AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
1527  if (ngenerated>0)
1528  {
1529  WriteToCDB("MUON/Calib/HV",hvStore,startRun,endRun,defaultValues);
1530  }
1531  delete hvStore;
1532 }
1533 
1534 //_____________________________________________________________________________
1535 void
1536 AliMUONCDB::WriteLV(Bool_t defaultValues,
1537  Int_t startRun, Int_t endRun,
1538  time_t refTime)
1539 {
1544 
1545  TMap* lvStore = new TMap;
1546  Int_t ngenerated = MakeLVStore(*lvStore,defaultValues,refTime);
1547  AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
1548  if (ngenerated>0)
1549  {
1550  WriteToCDB("MUON/Calib/LV",lvStore,startRun,endRun,defaultValues);
1551  }
1552  delete lvStore;
1553 }
1554 
1555 //_____________________________________________________________________________
1556 void
1557 AliMUONCDB::WriteTriggerDCS(Int_t startRun, Int_t endRun)
1558 {
1562 
1563  TMap* triggerDCSStore = new TMap;
1564  Int_t ngenerated = MakeTriggerDCSStore(*triggerDCSStore);
1565  AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
1566  if (ngenerated>0)
1567  {
1568  WriteToCDB("MUON/Calib/TriggerDCS",triggerDCSStore,startRun,endRun,true);
1569  }
1570  delete triggerDCSStore;
1571 }
1572 
1573 //_____________________________________________________________________________
1574 void
1575 AliMUONCDB::WritePedestals(Bool_t defaultValues,
1576  Int_t startRun, Int_t endRun)
1577 {
1582 
1583  AliMUONVStore* pedestalStore = Create2DMap();
1584  Int_t ngenerated = MakePedestalStore(*pedestalStore,defaultValues);
1585  AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
1586  WriteToCDB("MUON/Calib/Pedestals",pedestalStore,startRun,endRun,defaultValues);
1587  delete pedestalStore;
1588 }
1589 
1590 //_____________________________________________________________________________
1591 void
1592 AliMUONCDB::WriteOccupancyMap(Bool_t defaultValues,
1593  Int_t startRun, Int_t endRun)
1594 {
1599 
1600  AliMUONVStore* occupancyMapStore = Create2DMap();
1601  Int_t ngenerated = MakeOccupancyMapStore(*occupancyMapStore,defaultValues);
1602  AliInfoGeneral("AliMUONCDB", Form("Ngenerated = %d",ngenerated));
1603  WriteToCDB("MUON/Calib/OccupancyMap",occupancyMapStore,startRun,endRun,defaultValues);
1604  delete occupancyMapStore;
1605 }
1606 
1607 //_____________________________________________________________________________
1608 void
1609 AliMUONCDB::WriteRejectList(Bool_t defaultValues,
1610  Int_t startRun, Int_t endRun)
1611 {
1616 
1617  AliMUONRejectList* rl = MakeRejectListStore(defaultValues);
1618  WriteToCDB("MUON/Calib/RejectList",rl,startRun,endRun,defaultValues);
1619  delete rl;
1620 }
1621 
1622 //_____________________________________________________________________________
1623 void AliMUONCDB::WriteMapping(Int_t startRun, Int_t endRun)
1624 {
1625  gSystem->Setenv("MINSTALL",gSystem->ExpandPathName("$ALICE_ROOT/MUON/mapping"));
1626  AliMpCDB::WriteMpData(startRun,endRun);
1627  AliMpCDB::WriteMpRunData(startRun,endRun);
1628 }
1629 
1630 //_____________________________________________________________________________
1631 void
1632 AliMUONCDB::WriteTrigger(Bool_t defaultValues, Int_t startRun, Int_t endRun)
1633 {
1635  WriteTriggerDCS(startRun,endRun);
1636  WriteLocalTriggerMasks(startRun,endRun);
1637  WriteRegionalTriggerConfig(startRun,endRun);
1638  WriteGlobalTriggerConfig(startRun,endRun);
1639  WriteTriggerLut(startRun,endRun);
1640  WriteTriggerEfficiency(startRun,endRun);
1641 }
1642 
1643 //_____________________________________________________________________________
1644 void
1645 AliMUONCDB::WriteConfig(Int_t startRun, Int_t endRun)
1646 {
1648  ostringstream lines;
1649  TIter next(AliMpDDLStore::Instance()->CreateBusPatchIterator());
1650  AliMpBusPatch* bp;
1651  while ( ( bp = static_cast<AliMpBusPatch*>(next()) ) )
1652  {
1653  for (Int_t imanu = 0; imanu < bp->GetNofManus(); ++imanu)
1654  {
1655  lines << bp->GetId() << " " << bp->GetManuId(imanu) << endl;
1656  }
1657  }
1658 
1659  AliMUON2DMap config(kTRUE);
1660 
1661  AliMUONTrackerIO::DecodeConfig(lines.str().c_str(),config);
1662 
1663  WriteToCDB("MUON/Calib/Config",&config,startRun,endRun,kTRUE);
1664 }
1665 
1666 //_____________________________________________________________________________
1667 void
1668 AliMUONCDB::WriteBPEVO(Int_t startRun, Int_t endRun)
1669 {
1671 
1672  AliMergeableCollection bpevo("BPEVO");
1673 
1674  if (MakeBusPatchEvolution(bpevo,60))
1675  {
1676  WriteToCDB("MUON/Calib/BPEVO",&bpevo,startRun,endRun,kTRUE);
1677  }
1678  }
1679 
1680 //_____________________________________________________________________________
1681 void
1682 AliMUONCDB::WriteTracker(Bool_t defaultValues, Int_t startRun, Int_t endRun)
1683 {
1685  WriteMapping(startRun,endRun);
1686  WriteHV(defaultValues,startRun,endRun);
1687  WriteLV(defaultValues,startRun,endRun);
1688  WritePedestals(defaultValues,startRun,endRun);
1689  WriteOccupancyMap(defaultValues,startRun,endRun);
1690  WriteRejectList(defaultValues,startRun,endRun);
1691  WriteConfig(startRun,endRun);
1692  WriteBPEVO(startRun,endRun);
1693 }
1694 
1695 //_____________________________________________________________________________
1696 void
1697 AliMUONCDB::ShowConfig(Bool_t withStatusMap)
1698 {
1702 
1703  if (!AliMUONCDB::CheckOCDB()) return;
1704 
1706 
1707  if (!AliMUONCDB::CheckMapping()) return;
1708 
1709  AliCDBEntry* e = AliCDBManager::Instance()->Get("MUON/Calib/Config");
1710 
1711  if (!e) return ;
1712 
1713  AliMUONVStore* config = static_cast<AliMUONVStore*>(e->GetObject());
1714 
1715  AliMUONPadStatusMapMaker* statusMapMaker(0x0);
1716  AliMUONCalibrationData* cd(0x0);
1717  AliMUONPadStatusMaker* statusMaker(0x0);
1718 
1719  if ( withStatusMap )
1720  {
1721  cd = new AliMUONCalibrationData(AliCDBManager::Instance()->GetRun());
1722 
1723  statusMaker = new AliMUONPadStatusMaker(*cd);
1724 
1726 
1727  if (!recoParam)
1728  {
1729  AliErrorGeneral("AliMUONCDB::ShowConfig","Cannot get recoParams from OCDB !");
1730  return;
1731  }
1732 
1733  statusMaker->SetLimits(*recoParam);
1734 
1735  UInt_t mask = recoParam->PadGoodnessMask();
1736 
1737  delete recoParam;
1738 
1739  const Bool_t deferredInitialization = kFALSE;
1740 
1741  statusMapMaker = new AliMUONPadStatusMapMaker(*cd,mask,deferredInitialization);
1742  }
1743 
1744  TIter nextManu(config->CreateIterator());
1745  AliMUONVCalibParam* param;
1746 
1747  AliMpExMap buspatches;
1748 
1749  while ( ( param = static_cast<AliMUONVCalibParam*>(nextManu()) ) )
1750  {
1751  Int_t detElemId = param->ID0();
1752  Int_t manuId = param->ID1();
1753  Int_t busPatchId = AliMpDDLStore::Instance()->GetBusPatchId(detElemId,manuId);
1754  if ( buspatches.GetValue(busPatchId) == 0x0 )
1755  {
1756  buspatches.Add(busPatchId,new TObjString(Form("BP%04d",busPatchId)));
1757  }
1758  }
1759 
1760  TArrayI removed(buspatches.GetSize());
1761 
1762  TIter next(AliMpDDLStore::Instance()->CreateBusPatchIterator());
1763  AliMpBusPatch* bp;
1764  Int_t n(0);
1765  Int_t nok(0);
1766  Int_t nremoved(0);
1767 
1768  // accounting of bus patches first
1769 
1770  while ( ( bp = static_cast<AliMpBusPatch*>(next())))
1771  {
1772  if ( buspatches.GetValue(bp->GetId()) )
1773  {
1774  ++nok;
1775  }
1776  else
1777  {
1778  removed.SetAt(bp->GetId(),nremoved++);
1779  }
1780  }
1781 
1782  // accounting of channels
1783 
1784  AliMpManuIterator it;
1785 
1786  Int_t totalNumberOfChannels(0);
1787  Int_t removedChannels(0);
1788  Int_t badChannels(0);
1789  Int_t badAndRemovedChannels(0);
1790  Int_t badOrRemovedChannels(0);
1791 
1792  Int_t detElemId, manuId;
1793 
1794  while ( it.Next(detElemId,manuId) )
1795  {
1797  for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i )
1798  {
1799  Int_t busPatchId = AliMpDDLStore::Instance()->GetBusPatchId(detElemId,manuId);
1800 
1801  if ( de->IsConnectedChannel(manuId,i) )
1802  {
1803  ++totalNumberOfChannels;
1804  Bool_t badBusPatch = ( buspatches.GetValue(busPatchId) == 0x0 );
1805 
1806  if ( withStatusMap )
1807  {
1808  Bool_t badChannel = ( ( statusMapMaker->StatusMap(detElemId,manuId,i) & AliMUONPadStatusMapMaker::SelfDeadMask() ) != 0);
1809  if ( badChannel ) ++badChannels;
1810  if ( badBusPatch && badChannel ) ++badAndRemovedChannels;
1811  if ( badBusPatch || badChannel ) ++badOrRemovedChannels;
1812  }
1813 
1814  if ( badBusPatch) ++removedChannels;
1815  }
1816  }
1817  }
1818 
1819 
1820  Int_t* indices = new Int_t[nremoved];
1821 
1822  TMath::Sort(nremoved,removed.GetArray(),indices,kFALSE);
1823 
1824  for ( Int_t i = 0; i < nremoved; ++i )
1825  {
1826  Int_t busPatchId = removed[indices[i]];
1827  bp = AliMpDDLStore::Instance()->GetBusPatch(busPatchId);
1828  bp->Print();
1829  }
1830 
1831  delete[] indices;
1832 
1833  cout << endl;
1834  cout << Form("Bus patches n=%3d nok=%3d nremoved=%3d",n,nok,nremoved) << endl;
1835 
1836  cout << Form("Channels n=%6d nremoved=%6d bad=%6d bad and removed=%6d bad or removed=%6d",
1837  totalNumberOfChannels,removedChannels,badChannels,badAndRemovedChannels,badOrRemovedChannels) << endl;
1838 
1839  if (totalNumberOfChannels>0)
1840  {
1841  cout << Form("Percentage of readout channels %5.1f %%",removedChannels*100.0/totalNumberOfChannels) << endl;
1842  if ( withStatusMap )
1843  {
1844  cout << Form("Percentage of non useable channels (bad or removed) %5.1f %%",
1845  badOrRemovedChannels*100.0/totalNumberOfChannels) << endl;
1846  }
1847  }
1848 
1849 
1850  delete statusMapMaker;
1851  delete cd;
1852  delete statusMaker;
1853 }
1854 
1855 //______________________________________________________________________________
1856 void AliMUONCDB::ReadIntegers(const char* filename, std::vector<int>& integers)
1857 {
1860  ifstream in(gSystem->ExpandPathName(filename));
1861  int i;
1862 
1863  std::set<int> runset;
1864 
1865  char line[10000];
1866 
1867  in.getline(line,10000,'\n');
1868 
1869  TString sline(line);
1870 
1871  if (sline.Contains(","))
1872  {
1873  TObjArray* a = sline.Tokenize(",");
1874  TIter next(a);
1875  TObjString* s;
1876  while ( ( s = static_cast<TObjString*>(next()) ) )
1877  {
1878  runset.insert(s->String().Atoi());
1879  }
1880  delete a;
1881  }
1882  else
1883  {
1884  runset.insert(sline.Atoi());
1885 
1886  while ( in >> i )
1887  {
1888  runset.insert(i);
1889  }
1890  }
1891 
1892  for ( std::set<int>::const_iterator it = runset.begin(); it != runset.end(); ++it )
1893  {
1894  integers.push_back((*it));
1895  }
1896 
1897  std::sort(integers.begin(),integers.end());
1898 }
1899 
1900 //______________________________________________________________________________
1901 void AliMUONCDB::ShowFaultyBusPatches(const char* runlist, double occLimit,
1902  const char* outputBaseName,
1903  const char* ocdbPath)
1904 {
1907 
1908  AliLog::GetRootLogger()->SetGlobalLogLevel(AliLog::kError);
1909 
1910  // AliLog::SetPrintType(AliLog::kInfo,kFALSE);
1911  // AliLog::SetPrintType(AliLog::kWarning,kFALSE);
1912  // gErrorIgnoreLevel=kError; // to avoid all the TAlienFile::Open messages...
1913 
1914  AliCDBManager* man = AliCDBManager::Instance();
1915 
1916  man->SetDefaultStorage(ocdbPath);
1917 
1918  Bool_t first(kTRUE);
1919 
1920  std::vector<int> runnumbers;
1921 
1922  ReadIntegers(runlist,runnumbers);
1923 
1924  AliMUON2DMap bpValues(kFALSE);
1925 
1926  std::ofstream outfile(Form("%s.txt",outputBaseName));
1927 
1928  for ( unsigned int i = 0 ; i < runnumbers.size(); ++i )
1929  {
1930  int runNumber = runnumbers[i];
1931 
1932  man->SetRun(runNumber);
1933 
1934  if ( first )
1935  {
1937  first = kFALSE;
1938  }
1939 
1940  AliCDBEntry* e = man->Get("MUON/Calib/OccupancyMap",runNumber);
1941 
1942  if (!e)
1943  {
1944  AliErrorGeneral("AliMUONCDB::ShowFaultyBusPatches",
1945  Form("Could not get OccupancyMap for run %09d",runNumber));
1946  continue;
1947  }
1948 
1949  AliMUONVStore* occmap = static_cast<AliMUONVStore*>(e->GetObject());
1950 
1951  AliMUONTrackerData td("occ","occ",*occmap);
1952 
1953  TIter nextBP(AliMpDDLStore::Instance()->CreateBusPatchIterator());
1954  AliMpBusPatch* bp;
1955  std::set<int> buspatches;
1956  Double_t sumn = 1000.0;
1957 
1958  while ( ( bp = static_cast<AliMpBusPatch*>(nextBP()) ) )
1959  {
1960  Double_t occ = td.BusPatch(bp->GetId(),2);
1961 
1962  if (occ>occLimit)
1963  {
1964  buspatches.insert(bp->GetId());
1965 
1966  AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(bpValues.FindObject(bp->GetId()));
1967 
1968  if (!param)
1969  {
1970  param = new AliMUONCalibParamND(5, 1, bp->GetId(), 0);
1971  bpValues.Add(param);
1972 
1973  Int_t detElemId = AliMpDDLStore::Instance()->GetDEfromBus(bp->GetId());
1975 
1976  Int_t nchannels(0);
1977 
1978  for ( Int_t imanu = 0; imanu < bp->GetNofManus(); ++imanu )
1979  {
1980  Int_t manuId = bp->GetManuId(imanu);
1981  nchannels += de->NofChannelsInManu(manuId);
1982  }
1983 
1984  param->SetValueAsDouble(0,2,sumn);
1985  param->SetValueAsDouble(0,3,nchannels);
1986  param->SetValueAsDouble(0,4,1);
1987  }
1988 
1989  Double_t sumw = sumn*(param->ValueAsDouble(0)/sumn+1.0/runnumbers.size());
1990  Double_t sumw2 = 0.0; //(sumn-1)*ey*ey+sumw*sumw/sumn;
1991 
1992  param->SetValueAsDouble(0,0,sumw);
1993  param->SetValueAsDouble(0,1,sumw2);
1994 
1995  }
1996  }
1997 
1998  outfile << Form("RUN %09d",runNumber);
1999 
2000  for ( std::set<int>::const_iterator bit = buspatches.begin(); bit != buspatches.end(); ++bit )
2001  {
2002  outfile << Form(" %4d",*bit);
2003  }
2004  outfile << endl;
2005  }
2006 
2007  outfile.close();
2008 
2009  if ( bpValues.GetSize() == 0 )
2010  {
2011  cout << Form("Great. No faulty bus patch (at the %g occupancy limit) found.",occLimit) << endl;
2012  gSystem->Exec(Form("rm %s.txt",outputBaseName));
2013  }
2014  else
2015  {
2016  const char* name = "BPfailureRate";
2017 
2018  AliMUONTrackerData* mpData = new AliMUONTrackerData(name,name,bpValues,2);
2019  mpData->SetDimensionName(0,name);
2020 
2021  TFile f(Form("%s.root",outputBaseName),"recreate");
2022  mpData->Write();
2023  f.Close();
2024 
2025  cout << Form("Results are in %s.txt and %s.root",outputBaseName,outputBaseName) << endl;
2026 
2027  gSystem->Exec(Form("cat %s.txt",outputBaseName));
2028  }
2029 }
2030 
2031 //______________________________________________________________________________
2032 Double_t AliMUONCDB::MeanHVValueForDCSAlias(TMap& hvMap, const char* hvChannel)
2033 {
2034 
2035  TPair* hvPair = static_cast<TPair*>(hvMap.FindObject(hvChannel));
2036  if (!hvPair)
2037  {
2038  AliErrorGeneral("AliMUONCDB::MeanHVValueForDCSAlias",Form("Did not find expected alias (%s)",hvChannel));
2039  return 0.0;
2040  }
2041  else
2042  {
2043  TObjArray* values = static_cast<TObjArray*>(hvPair->Value());
2044  if (!values)
2045  {
2046  AliErrorGeneral("AliMUONCDB::MeanHVValueForDCSAlias",Form("Could not get values for alias %s",hvChannel));
2047  return 0.0;
2048  }
2049  else
2050  {
2051  // find out min value, and makes a cut
2052  Float_t hv(0.0);
2053  Float_t n(0.0);
2054  TIter next(values);
2055  AliDCSValue* val;
2056 
2057  while ( ( val = static_cast<AliDCSValue*>(next()) ) )
2058  {
2059  hv += val->GetFloat();
2060  n += 1.0;
2061  }
2062 
2063  if (n>0.0)
2064  {
2065  hv /= n;
2066  return hv;
2067  }
2068  }
2069  return 0.0;
2070  }
2071 }
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.
High Voltage.
Definition: AliMpDCSNamer.h:79
Implementation of AliMUONVTrackerData.
void WriteLV(Bool_t defaultValues, Int_t startRun, Int_t endRun=AliCDBRunRange::Infinity(), time_t refTime=1449969676)
TFile * Open(const char *filename, Long64_t &nevents)
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)
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.
Bool_t IsSt1DCSAliasRemapped(const TString &name)
Definition: AliMUONCDB.cxx:473
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 CheckHV(Int_t runNumber, Int_t verbose=0)
Definition: AliMUONCDB.cxx:213
TClonesArray * LoadAlignmentData()
Definition: AliMUONCDB.cxx:592
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 MakeLVStore(TMap &aliasMap, Bool_t defaultValues, time_t refTime)
Definition: AliMUONCDB.cxx:876
Int_t Log(const char *message)
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:22
void WriteGlobalTriggerConfig(Int_t startRun=0, Int_t endRun=AliCDBRunRange::Infinity())
Int_t MakePedestalStore(AliMUONVStore &pedestalStore, Bool_t defaultValues)
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.
void CheckHV_ALIROOT_6402(const char *runlist, Bool_t verbose=kFALSE)
Definition: AliMUONCDB.cxx:351
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.
Int_t MakeTriggerDCSStore(TMap &aliasMap)
Definition: AliMUONCDB.cxx:962
Bool_t Next(TString &msg, Int_t &occurance)
void WriteTriggerDCS(Int_t startRun, Int_t endRun=AliCDBRunRange::Infinity())
Bool_t LoadField()
Definition: AliMUONCDB.cxx:498
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:340
void ShowFaultyBusPatches(const char *runlist, double occLimit=0.1, const char *outputBaseName="faulty.buspatches", const char *ocdbPath="raw://")
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:24
void AddDCSValue(TMap &aliasMap, Int_t imeas, const char *smt, const char *sInOut, Int_t rpc, Float_t value)
Definition: AliMUONCDB.cxx:945
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.
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
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:812
AliMUONVStore * Diff(AliMUONVStore &store1, AliMUONVStore &store2, const char *opt="abs")
Definition: AliMUONCDB.cxx:617
virtual Int_t ID0() const
First id of this object.
non-bending plane
static Bool_t PatchHVValues(TObjArray &values, TString *msg=0x0, Bool_t dryRun=kFALSE)
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:365
TH1 ** Plot(const AliMUONVStore &store, const char *name, Int_t nbins=512)
Definition: AliMUONCDB.cxx:686
Int_t MakeBusPatchEvolution(AliMergeableCollection &bpevo, int timeResolution=60)
Definition: AliMUONCDB.cxx:760
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)
void Add(Int_t keyFirst, Int_t keySecond, TObject *object)
Definition: AliMpExMap.cxx:292
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:451
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.
static TObject * CreateObject(Int_t runNumber, const char *path, Int_t *startOfValidity=0x0)
Int_t GetBusPatchId(Int_t index) const
TArrayI runlist(10000)
static TString GlobalTriggerBoardMapping()
Definition: AliMpFiles.cxx:347
TObjArray * GenerateAliases(const char *pattern="") const
Object to hold the list of elements we want to reject from the reconstruction.
void WriteBPEVO(Int_t startRun, Int_t endRun=AliCDBRunRange::Infinity())
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:189
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:522
static Bool_t LoadAll(Bool_t warn=false)
Definition: AliMpCDB.cxx:196
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="")
static Int_t NofTrackingChambers()
Return number of tracking chambers.
void PatchHV(TMap &hvMap, TList *messages, Bool_t onlySt1remapped=kFALSE)
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:555
virtual void SetValueAsDouble(Int_t i, Int_t j, Double_t value)
void SetLimits(const AliMUONRecoParam &recoParams)
virtual void Print(Option_t *opt="") const