AliRoot Core  v5-06-30 (35d6c57)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMUONCalibrationData.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: AliMUONCalibrationData.cxx 59486 2012-11-07 22:06:24Z laphecet $
17 
18 #include "AliMUONCalibrationData.h"
19 
20 #include "AliCDBEntry.h"
21 #include "AliCDBManager.h"
22 #include "AliCodeTimer.h"
23 #include "AliDCSValue.h"
24 #include "AliLog.h"
25 #include "AliMpDCSNamer.h"
26 #include "AliMpIntPair.h"
29 #include "AliMUONRejectList.h"
31 #include "AliMUONTriggerLut.h"
32 #include "AliMUONVCalibParam.h"
33 #include "AliMUONVStore.h"
34 #include "AliMUONVStore.h"
35 
36 #include <Riostream.h>
37 #include <TClass.h>
38 #include <TMap.h>
39 #include <TMath.h>
40 
41 //-----------------------------------------------------------------------------
55 //-----------------------------------------------------------------------------
56 
57 using std::cout;
58 using std::endl;
62 
63 AliMUONVStore* AliMUONCalibrationData::fgBypassPedestals(0x0);
64 AliMUONVStore* AliMUONCalibrationData::fgBypassGains(0x0);
65 
66 UInt_t AliMUONCalibrationData::fgkDCSSt1Flag(42);
67 
68 namespace
69 {
70  void MarkForDeletion(Int_t* indices, Int_t first, Int_t last)
71  {
72  for ( Int_t i = first; i <= last; ++i )
73  {
74  indices[i] = 1;
75  }
76  }
77 }
78 
79 //_____________________________________________________________________________
81  Bool_t deferredInitialization)
82 : TObject(),
83 fIsValid(kTRUE),
84 fRunNumber(runNumber),
85 fGains(0x0),
86 fPedestals(0x0),
87 fHV(0x0),
88 fTriggerDCS(0x0),
89 fLocalTriggerBoardMasks(0x0),
90 fRegionalTriggerConfig(0x0),
91 fGlobalTriggerCrateConfig(0x0),
92 fTriggerLut(0x0),
93 fTriggerEfficiency(0x0),
94 fCapacitances(0x0),
95 fNeighbours(0x0),
96 fOccupancyMap(0x0),
97 fRejectList(0x0),
98 fConfig(0x0)
99 {
101 
102  // If deferredInitialization is false, we read *all* calibrations
103  // at once.
104  // So when using this class to access only one kind of calibrations (e.g.
105  // only pedestals), you should put deferredInitialization to kTRUE, which
106  // will instruct this object to fetch the data only when neeeded.
107 
108  if ( deferredInitialization == kFALSE )
109  {
110  Gains();
111  Pedestals();
112  OccupancyMap();
113  RejectList();
114  HV();
115  TriggerDCS();
119  TriggerLut();
121  Capacitances();
122  Neighbours();
123  Config();
124  }
125 }
126 
127 //_____________________________________________________________________________
129 {
132  if (!(AliCDBManager::Instance()->GetCacheFlag())) Reset();
133 }
134 
135 //_____________________________________________________________________________
138 {
140 
141  if (!fCapacitances)
142  {
144  }
145  return fCapacitances;
146 }
147 
148 //_____________________________________________________________________________
150 AliMUONCalibrationData::CreateCapacitances(Int_t runNumber, Int_t* startOfValidity)
151 {
153 
154  return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Capacitances",startOfValidity));
155 }
156 
157 //_____________________________________________________________________________
159 AliMUONCalibrationData::CreateGains(Int_t runNumber, Int_t* startOfValidity)
160 {
162  return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Gains",startOfValidity));
163 }
164 
165 //_____________________________________________________________________________
167 AliMUONCalibrationData::CreateGlobalTriggerCrateConfig(Int_t runNumber, Int_t* startOfValidity)
168 {
170 
171  return dynamic_cast<AliMUONGlobalCrateConfig*>(CreateObject(runNumber,"MUON/Calib/GlobalTriggerCrateConfig",startOfValidity));
172 }
173 
174 
175 //______________________________________________________________________________
176 Bool_t AliMUONCalibrationData::CheckHVGroup(TObjArray& values, Int_t first, Int_t last, Double_t& value, Int_t& slope, TString* msg)
177 {
178  // Get the HV of the values between first and last indices
179  // return the HV slope (in Volt per second) and a message
180  // Return kFALSE if we must discard the group
181  //
182 
183  if (msg) *msg="";
184 
185  if ( last < first ) return kFALSE;
186  if ( last - first < 2 ) return kFALSE;
187 
188  Double_t a(0.0);
189  Double_t b(0.0);
190 
191  Float_t HVSAME(1); // 1 volts
192 
193  AliDCSValue* vfirst = static_cast<AliDCSValue*>(values.UncheckedAt(first));
194  AliDCSValue* vlast = static_cast<AliDCSValue*>(values.UncheckedAt(last));
195 
196  Int_t deltaHV = TMath::Nint(TMath::Abs(vfirst->GetFloat()-vlast->GetFloat()));
197 
198  if ( deltaHV < HVSAME ) return kFALSE;
199 
200  for ( Int_t i = first; i <= last; ++i )
201  {
202  AliDCSValue* v = static_cast<AliDCSValue*>(values.UncheckedAt(i));
203 
204  Double_t y = v->GetFloat() - vfirst->GetFloat();
205  Double_t x = v->GetTimeStamp() - vfirst->GetTimeStamp();
206 
207  a += x*y;
208  b += x*x;
209  }
210 
211  value = a/b;
212  slope = value > 0 ? 1 : -1;
213  value = TMath::Abs(value);
214 
215  UInt_t deltaTime = vlast->GetTimeStamp() - vfirst->GetTimeStamp();
216 
217  if (msg)
218  {
219  if (slope>0) (*msg) = Form("RU%d[%d:%d](%d)",TMath::Nint(value),first,last,deltaTime);
220  if (slope<0) (*msg) = Form("RD%d[%d:%d](%d)",TMath::Nint(value),first,last,deltaTime);
221 
222  if ( TMath::Nint(value) == 0 )
223  {
224  // this is to protect for the few cases
225  // (see e.g. MchHvLvLeft/Chamber00Left/Quad2Sect0.actual.vMon in run 134497)
226  // where we can have *lots* of values (2483 in this example) but that
227  // are more or less constant...
228  //
229  // or simply to remove small ramps
230  //
231  slope = 0;
232  value = (vfirst->GetFloat()+vlast->GetFloat())/2.0;
233  *msg = Form("FLUCT%d[%d:%d]",TMath::Nint(value),first,last);
234  }
235  }
236 
237  return kTRUE;
238 }
239 
240 //______________________________________________________________________________
242  TString* msg,
243  Bool_t dryRun)
244 {
259 
260  UInt_t DELTATIME(60); // in seconds
261  Int_t IENDRU(60); // in seconds
262 
263  // Start by finding groups of values which are not separated (each) by more than
264  // deltaTime
265 
266  Bool_t gather(kFALSE);
267  Int_t ifirst(0);
268  Int_t ilast(0);
269  TObjArray groups;
270  groups.SetOwner(kTRUE);
271 
272  for ( Int_t i = values.GetLast(); i > 0; --i )
273  {
274  AliDCSValue* vi = static_cast<AliDCSValue*>(values.UncheckedAt(i));
275  AliDCSValue* vj = static_cast<AliDCSValue*>(values.UncheckedAt(i-1));
276 
277  if ( vi->GetTimeStamp() - vj->GetTimeStamp() < DELTATIME )
278  {
279  if ( !gather )
280  {
281  gather = kTRUE;
282  ifirst = i;
283  }
284  ilast=i;
285  }
286  else
287  {
288  if ( gather )
289  {
290  ilast=i;
291 
292  groups.Add(new AliMpIntPair(ilast,ifirst));
293  }
294  gather = kFALSE;
295  }
296  }
297 
298  if (gather)
299  {
300  groups.Add(new AliMpIntPair(0,ifirst));
301  }
302 
303  TIter nextGroup(&groups,kIterBackward);
304  AliMpIntPair* p;
305  TString internalMsg;
306  Int_t ngroups(0);
307 
308  Int_t nRU(0);
309  Int_t nRD(0);
310  Int_t nStartRU(0);
311  Int_t nEndAndShortRU(0);
312  Int_t nEndRD(0);
313  Int_t nTripRD(0);
314  Int_t nFluct(0);
315  TObjArray trips;
316  trips.SetOwner(kTRUE);
317 
318  while ( ( p = static_cast<AliMpIntPair*>(nextGroup()) ) )
319  {
320  Double_t value;
321  Int_t slope;
322 
323  TString groupMsg;
324 
325  AliDebugClass(1,Form("group %d:%d",p->GetFirst(),p->GetSecond()));
326 
327  Bool_t ok = CheckHVGroup(values,p->GetFirst(),p->GetSecond(),value,slope,&groupMsg);
328 
329  if (!ok) continue;
330 
331  ++ngroups;
332 
333  if ( slope > 0 )
334  {
335  if ( p->GetFirst() == 0 )
336  {
337  // start with a ramp-up
338  ++nStartRU;
339  }
340  else if ( p->GetSecond() == values.GetLast() && TMath::Nint(value) < IENDRU )
341  {
342  ++nEndAndShortRU;
343  }
344  else
345  {
346  // ramp-up in the middle of nowhere...
347  ++nRU;
348  }
349  }
350  else if ( slope < 0 )
351  {
352  if ( p->GetSecond() == values.GetLast() )
353  {
354  // end with a ramp-down
355  ++nEndRD;
356  }
357  else
358  {
359  // ramp-down in the middle of nowhere
360  ++nRD;
361  }
362 
363  AliDCSValue* d = static_cast<AliDCSValue*>(values.At(p->GetSecond()));
364 
365  if ( d->GetFloat() < AliMpDCSNamer::TrackerHVOFF() )
366  {
367  ++nTripRD;
368  AliDCSValue* tripStart = static_cast<AliDCSValue*>(values.At(p->GetFirst()));
369  trips.Add(new AliMpIntPair(tripStart->GetTimeStamp(),TMath::Nint(tripStart->GetFloat())));
370  }
371  }
372  else
373  {
374  ++nFluct;
375  }
376 
377  internalMsg += groupMsg;
378  internalMsg += " ";
379  }
380 
381  /*
382 
383  Once we have "decoded" the groups we try to find out which of
384  the following cases we're facing :
385 
386  case A = -------- = OK(1)
387 
388  case B = ----
389  \
390  \ = OK, once we have removed the ramp-down (2)
391 
392  case C = -----
393  /
394  / = OK, once we have removed the ramp-up (3)
395 
396  case D = -----
397  / \
398  / \ = OK, once we have removed the ramp-down (2) and the ramp-up (3)
399 
400  case E = ----
401  \
402  \____ = TRIP = BAD (here the ramp-down slope should be bigger than in case C)
403 
404  case F = ----
405  \ ----- = BAD (trip + ramp-up at end of run)
406  \____/
407 
408  case G = fluctuations (within a range defined in CheckHVGroup...)
409 
410  case H =
411  /
412  / = ramp-up right at the end-of-run = OK (4)
413  ------
414 
415  (1) OK means the group is identified correctly, still the value can be below ready...
416  (2) ramp-down values will be removed if the ramp is indeed the last values in the serie
417  i.e. it's really an end-of-run problem (otherwise it's not case B)
418  (3) ramp-up values will be removed if the ramp is indeed the first values in the serie
419  i.e. it's really a start-of-run problem (otherwise it's not case C)
420  (4) OK if short enough...
421 
422  Any other case is unknown and we'll :
423  a) return kFALSE
424  b) assume the channel is OFF.
425 
426 
427  */
428 
429  AliDebugClass(1,Form("msg=%s ngroupds=%d",internalMsg.Data(),ngroups));
430  AliDebugClass(1,Form("nRU %d nRD %d nStartRU %d nEndRD %d nTripRD %d nFluct %d",
431  nRU,nRD,nStartRU,nEndRD,nTripRD,nFluct));
432 
433  TString hvCase("OTHER");
434  int dummy(0),a(-1),b(-1);
435  char r[81];
436  Int_t nvalues = values.GetSize();
437  Int_t* indices = new Int_t[nvalues];
438  memset(indices,0,nvalues*sizeof(Int_t));
439 
440  AliDCSValue* vfirst = static_cast<AliDCSValue*>(values.UncheckedAt(0));
441  AliDCSValue* vlast = static_cast<AliDCSValue*>(values.UncheckedAt(values.GetLast()));
442 
443  UInt_t meanTimeStamp = ( vfirst->GetTimeStamp() + vlast->GetTimeStamp() ) / 2;
444 
445  if ( ngroups == 0 )
446  {
447  hvCase = "A";
448  }
449  else if ( nTripRD > 0 )
450  {
451  const Double_t HVLOWTRIP(600); // a trip below this value is considered a "low trip"
452  // i.e. one starting for a non-operational voltage
453 
454  internalMsg += Form("NT:%d ",nTripRD);
455 
456  if ( nRU > 0 && nRD > 0 )
457  {
458  hvCase = "F";
459  }
460  else
461  {
462  hvCase = "E";
463  }
464 
465  for ( Int_t iTrip = 0; iTrip <= trips.GetLast(); ++iTrip )
466  {
467  AliMpIntPair* tripPair = static_cast<AliMpIntPair*>(trips.At(iTrip));
468  TString tripType("TRIP");
469  if ( tripPair->GetSecond() < HVLOWTRIP)
470  {
471  tripType = "LOWTRIP";
472  }
473 
474  internalMsg += Form("%s SV:%d TS:%d ",tripType.Data(),tripPair->GetSecond(),tripPair->GetFirst());
475  }
476 
477  // we put here the TRIP value as SV:value
478  // for cases where there's a drop in voltage but the starting point was
479  // below operational voltage, so strictly speaking it's *not* a trip, but
480  // more a big fluctuation
481  if ( !dryRun )
482  {
483  MarkForDeletion(indices,0,values.GetLast());
484  values.Add(new AliDCSValue(static_cast<Float_t>(0),meanTimeStamp));
485  }
486  }
487  else if ( nStartRU > 0 && nRU == 0 && nRD == 0 && nEndRD == 0 )
488  {
489  hvCase = "C";
490  if (!dryRun)
491  {
492  sscanf(internalMsg.Data(),"RU%10d[%10d:%10d]%80s",&dummy,&a,&b,r);
493  MarkForDeletion(indices,a,b);
494  }
495  }
496  else if ( nStartRU > 0 && nEndRD > 0 && nRD == 0 && nRU == 0 )
497  {
498  hvCase = "D";
499  if (!dryRun)
500  {
501  sscanf(internalMsg.Data(),"RU%10d[%10d:%10d]%80s",&dummy,&a,&b,r);
502  MarkForDeletion(indices,a,b-1);
503  Int_t i = internalMsg.Index("RD",strlen("RD"),0,TString::kExact);
504  sscanf(internalMsg(i,internalMsg.Length()-i).Data(),
505  "RD%10d[%10d:%10d]%80s",&dummy,&a,&b,r);
506  MarkForDeletion(indices,a+1,b);
507  }
508  }
509  else if ( nEndRD > 0 && nStartRU == 0 && nRU == 0 && nRD == 0 )
510  {
511  hvCase = "B";
512  if (!dryRun)
513  {
514  Int_t i = internalMsg.Index("RD",strlen("RD"),0,TString::kExact);
515  sscanf(internalMsg(i,internalMsg.Length()-i).Data(),
516  "RD%10d[%10d:%10d]%80s",&dummy,&a,&b,r);
517  MarkForDeletion(indices,a,b);
518  }
519  }
520  else if ( nFluct > 0 )
521  {
522  hvCase = "G";
523  if (!dryRun)
524  {
525  TObjArray* af = internalMsg.Tokenize(" ");
526  TIter next(af);
527  TObjString* str;
528  while ( ( str = static_cast<TObjString*>(next()) ) )
529  {
530  TString s(str->String());
531  if ( s.BeginsWith("FLUCT") )
532  {
533  sscanf(s.Data(),"FLUCT%d[%d:%d]",&dummy,&a,&b);
534  MarkForDeletion(indices,a,b);
535  }
536  }
537  delete af;
538  }
539  }
540  else if ( nEndAndShortRU > 0 && nStartRU == 0 && nRU == 0 && nRD == 0 && nEndRD == 0 )
541  {
542  hvCase = "H";
543  if (!dryRun)
544  {
545  sscanf(internalMsg.Data(),"RU%10d[%10d:%10d]%80s",&dummy,&a,&b,r);
546  MarkForDeletion(indices,a,b);
547  }
548  }
549  else
550  {
551  // last chance...
552  // here we know it's not a trip, so let's assume everything is OK
553  // if first and last value are in the same ballpark
554 
555  const Double_t HVFLUCT(20); // volts
556 
557  if ( TMath::Abs(vfirst->GetFloat() - vlast->GetFloat()) < HVFLUCT )
558  {
559  hvCase = "Z";
560  }
561  if (!dryRun)
562  {
563  MarkForDeletion(indices,1,nvalues-1);
564  }
565  }
566 
567  if (!dryRun)
568  {
569  for ( Int_t i = 0; i < nvalues; ++i )
570  {
571  if ( indices[i] )
572  {
573  values.RemoveAt(i);
574  }
575  }
576 
577  values.Compress();
578  }
579 
580  delete[] indices;
581 
582  if ( !values.GetEntries() )
583  {
584  AliErrorClass(Form("No value left after patch... Check that !!! initial # of values=%d msg=%s",
585  nvalues,internalMsg.Data()));
586  hvCase = "OTHER";
587  }
588 
589  if (!dryRun)
590  {
591  // take the max of the remaining values
592  TIter nextA(&values);
593  AliDCSValue* val;
594  Float_t maxval(-9999);
595 
596  while ( ( val = static_cast<AliDCSValue*>(nextA()) ) )
597  {
598  if ( val->GetFloat() > maxval )
599  {
600  maxval = val->GetFloat();
601  }
602  }
603 
604  values.Clear();
605 
606  values.Add(new AliDCSValue(maxval,meanTimeStamp));
607  }
608 
609  // once the case is inferred, add a "CASE:%10d",hvCase.Data()
610  // to the msg
611  // so we can them sum up for all channels and get a summary per run...
612 
613  internalMsg += Form("CASE:%s",hvCase.Data());
614 
615  if (msg) *msg = internalMsg.Data();
616 
617  return hvCase=="OTHER" ? kFALSE : kTRUE;
618 }
619 
620 //_____________________________________________________________________________
621 void AliMUONCalibrationData::AddToMap(const TMap& sourceMap,
622  TMap& destMap,
623  const TString& key,
624  const char* source,
625  const char* dest)
626 {
628 
629  TString newkey(key);
630 
631  newkey.ReplaceAll(source,dest);
632 
633  TPair* pair = static_cast<TPair*>(sourceMap.FindObject(key.Data()));
634 
635  destMap.Add(new TObjString(newkey.Data()),pair->Value());
636 }
637 
638 //_____________________________________________________________________________
640 {
649 
650  if ( hvMap.GetUniqueID() == fgkDCSSt1Flag )
651  {
652  // already clean object. Do nothing
653  return;
654  }
655 
656  TIter next(&hvMap);
657  TObjString* hvChannelName;
658 
659  TMap newmap;
660  newmap.SetOwnerKeyValue(kTRUE,kFALSE);
661 
662  while ( ( hvChannelName = static_cast<TObjString*>(next()) ) )
663  {
664  TString name(hvChannelName->String());
665  TString newname(name);
666 
667  // the problem is limited to St1 = ch1+ch2 (or, in DCS parlance, ch0+ch1)
668  // do it "by hand" as we "only" have 8 names to change
669 
670  if ( name.Contains("Chamber00Left") )
671  {
672  if (name.Contains("Quad1Sect0")) AddToMap(hvMap,newmap,name,"Quad1Sect0","Quad2Sect0"); // channel 0 of Board00 (alidcscae020)
673 
674  if (name.Contains("Quad1Sect1")) AddToMap(hvMap,newmap,name,"Quad1Sect1","Quad2Sect1"); // channel 1
675  if (name.Contains("Quad1Sect2")) AddToMap(hvMap,newmap,name,"Quad1Sect2","Quad2Sect2"); // channel 2
676 
677  if (name.Contains("Quad2Sect2")) AddToMap(hvMap,newmap,name,"Quad2Sect2","Quad1Sect0"); // channel 3
678  if (name.Contains("Quad2Sect1")) AddToMap(hvMap,newmap,name,"Quad2Sect1","Quad1Sect1"); // channel 4
679  if (name.Contains("Quad2Sect0")) AddToMap(hvMap,newmap,name,"Quad2Sect0","Quad1Sect2"); // channel 5
680  }
681  else if ( name.Contains("Chamber01Left"))
682  {
683  if (name.Contains("Quad2Sect2")) AddToMap(hvMap,newmap,name,"Quad2Sect2","Quad2Sect0"); // channel 9 of Board00 (alidcscae020)
684  if (name.Contains("Quad2Sect0")) AddToMap(hvMap,newmap,name,"Quad2Sect0","Quad2Sect2"); // channel 11
685  }
686  else
687  {
688  AddToMap(hvMap,newmap,name,name,name);
689  }
690  }
691 
692  // copy newmap to hvMap
693 
694  TIter nextNewMap(&newmap);
695  while ( ( hvChannelName = static_cast<TObjString*>(nextNewMap()) ) )
696  {
697  TPair* oldPair = static_cast<TPair*>(hvMap.FindObject(hvChannelName->String().Data()));
698  TPair* newPair = static_cast<TPair*>(newmap.FindObject(hvChannelName->String().Data()));
699 
700  TObjArray* newValues = static_cast<TObjArray*>(newPair->Value());
701 
702  oldPair->SetValue(newValues);
703  }
704 }
705 
706 //_____________________________________________________________________________
707 TMap*
709  Int_t* startOfValidity,
710  Bool_t patched,
711  TList* messages,
712  Bool_t dryRun)
713 {
720 
721  TMap* hvMap = dynamic_cast<TMap*>(CreateObject(runNumber,"MUON/Calib/HV",startOfValidity));
722 
723  if (!hvMap) return 0x0;
724 
725  PatchSt1DCSAliases(*hvMap);
726 
727  if (patched)
728  {
729  TIter next(hvMap);
730  TObjString* hvChannelName;
731 
732  while ( ( hvChannelName = static_cast<TObjString*>(next()) ) )
733  {
734  TString name(hvChannelName->String());
735 
736  if ( name.Contains("sw") ) continue; // skip switches
737 
738  if ( name.Contains("iMon") ) continue; // skip HV currents
739 
740  TPair* hvPair = static_cast<TPair*>(hvMap->FindObject(name.Data()));
741  TObjArray* values = static_cast<TObjArray*>(hvPair->Value());
742  if (!values)
743  {
744  AliErrorClass(Form("Could not get values for alias %s",name.Data()));
745  }
746  else
747  {
748  TString msg;
749 
750  AliDebugClass(1,Form("channel %s",name.Data()));
751  Bool_t ok = PatchHVValues(*values,&msg,dryRun);
752 
753  if ( messages )
754  {
755  messages->Add(new TObjString(Form("%s %s",hvChannelName->String().Data(),msg.Data())));
756  }
757 
758  if (!ok)
759  {
760  AliErrorClass(Form("PatchHVValue was not successfull ! This is serious ! "
761  "You'll have to check the logic for channel %s in run %09d",
762  name.Data(),runNumber));
763  }
764  }
765  }
766 
767  }
768 
769  if ( messages )
770  {
771  Int_t a(0),b(0),c(0),d(0),e(0),f(0),g(0),h(0),u(0),z(0);
772  TIter next(messages);
773  TObjString* msg;
774  char hvCase('u');
775 
776  while ( ( msg = static_cast<TObjString*>(next()) ) )
777  {
778  Int_t i = msg->String().Index("CASE",strlen("CASE"),0,TString::kExact);
779 
780  if ( i >= 0 )
781  {
782  sscanf(msg->String()(i,msg->String().Length()-i).Data(),"CASE:%10c",&hvCase);
783  }
784 
785  switch (hvCase)
786  {
787  case 'A': ++a; break;
788  case 'B': ++b; break;
789  case 'C': ++c; break;
790  case 'D': ++d; break;
791  case 'E': ++e; break;
792  case 'F': ++f; break;
793  case 'G': ++g; break;
794  case 'H': ++h; break;
795  case 'Z': ++z; break;
796  default: ++u; break;
797  }
798  }
799 
800  messages->Add(new TObjString(Form("SUMMARY : # of cases A(%3d) B(%3d) C(%3d) D(%3d) E(%3d) F(%3d) G(%3d) H(%3d) Z(%3d) OTHER(%3d)",
801  a,b,c,d,e,f,g,h,z,u)));
802  }
803 
804  return hvMap;
805 }
806 
807 //_____________________________________________________________________________
808 TMap*
809 AliMUONCalibrationData::CreateTriggerDCS(Int_t runNumber, Int_t* startOfValidity)
810 {
812  return dynamic_cast<TMap*>(CreateObject(runNumber,"MUON/Calib/TriggerDCS",startOfValidity));
813 }
814 
815 //_____________________________________________________________________________
817 AliMUONCalibrationData::CreateLocalTriggerBoardMasks(Int_t runNumber, Int_t* startOfValidity)
818 {
820 
821  return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/LocalTriggerBoardMasks",startOfValidity));
822 }
823 
824 //_____________________________________________________________________________
826 AliMUONCalibrationData::CreateNeighbours(Int_t runNumber, Int_t* startOfValidity)
827 {
829  return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Neighbours",startOfValidity));
830 }
831 
832 //_____________________________________________________________________________
833 TObject*
834 AliMUONCalibrationData::CreateObject(Int_t runNumber, const char* path, Int_t* startOfValidity)
835 {
838 
839  AliCodeTimerAutoClass(Form("%09d : %s",runNumber,path),0);
840 
841  AliCDBManager* man = AliCDBManager::Instance();
842 
843  AliCDBEntry* entry = man->Get(path,runNumber);
844 
845  if (entry)
846  {
847  if ( startOfValidity ) *startOfValidity = entry->GetId().GetFirstRun();
848 
849  TObject* object = entry->GetObject();
850  if (!(man->GetCacheFlag()))
851  {
852  entry->SetOwner(kFALSE);
853  delete entry;
854  }
855 // else
856 // {
857 // entry->SetOwner(kTRUE); //FIXME : this should be done but is causing problems with RecoParams at the end of the reco : investigate why...
858 // }
859  return object;
860  }
861  else
862  {
863  if ( startOfValidity ) *startOfValidity = AliCDBRunRange::Infinity();
864  }
865 
866  {
867 
868  AliCodeTimerAutoClass(Form("Failed to get %s for run %09d",path,runNumber),1);
869 
870  }
871 
872  return 0x0;
873 }
874 
875 //_____________________________________________________________________________
877 AliMUONCalibrationData::CreateOccupancyMap(Int_t runNumber, Int_t* startOfValidity)
878 {
880  return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/OccupancyMap",startOfValidity));
881 }
882 
883 //_____________________________________________________________________________
885 AliMUONCalibrationData::CreateRejectList(Int_t runNumber, Int_t* startOfValidity)
886 {
888  return dynamic_cast<AliMUONRejectList*>(CreateObject(runNumber,"MUON/Calib/RejectList",startOfValidity));
889 }
890 
891 //_____________________________________________________________________________
893 AliMUONCalibrationData::CreatePedestals(Int_t runNumber, Int_t* startOfValidity)
894 {
896  return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Pedestals",startOfValidity));
897 }
898 
899 //_____________________________________________________________________________
901 AliMUONCalibrationData::CreateConfig(Int_t runNumber, Int_t* startOfValidity)
902 {
904  return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Config",startOfValidity));
905 }
906 
907 
908 //_____________________________________________________________________________
910 AliMUONCalibrationData::CreateRegionalTriggerConfig(Int_t runNumber, Int_t* startOfValidity)
911 {
913 
914  return dynamic_cast<AliMUONRegionalTriggerConfig*>(CreateObject(runNumber,"MUON/Calib/RegionalTriggerConfig",startOfValidity));
915 }
916 
917 //_____________________________________________________________________________
919 AliMUONCalibrationData::CreateTriggerEfficiency(Int_t runNumber, Int_t* startOfValidity)
920 {
922 
923  return dynamic_cast<AliMUONTriggerEfficiencyCells*>(CreateObject(runNumber,"MUON/Calib/TriggerEfficiency",startOfValidity));
924 }
925 
926 //_____________________________________________________________________________
928 AliMUONCalibrationData::CreateTriggerLut(Int_t runNumber, Int_t* startOfValidity)
929 {
931 
932  return dynamic_cast<AliMUONTriggerLut*>(CreateObject(runNumber,"MUON/Calib/TriggerLut",startOfValidity));
933 }
934 
935 //_____________________________________________________________________________
938 {
940  if (fgBypassGains) return fgBypassGains;
941 
942  if (!fGains)
943  {
945  }
946  return fGains;
947 }
948 
949 //_____________________________________________________________________________
951 AliMUONCalibrationData::Gains(Int_t detElemId, Int_t manuId) const
952 {
956 
957  AliMUONVStore* gains = Gains();
958  if (!gains)
959  {
960  return 0x0;
961  }
962 
963  return static_cast<AliMUONVCalibParam*>(gains->FindObject(detElemId,manuId));
964 }
965 
966 //_____________________________________________________________________________
969 {
971 
973  {
975  }
977 }
978 
979 
980 //_____________________________________________________________________________
981 TMap*
982 AliMUONCalibrationData::HV(Bool_t patched) const
983 {
985 
986  if (!fHV)
987  {
988  fHV = CreateHV(fRunNumber,0,patched);
989  }
990  return fHV;
991 }
992 
993 //_____________________________________________________________________________
994 TMap*
996 {
998 
999  if (!fTriggerDCS)
1000  {
1002  }
1003  return fTriggerDCS;
1004 }
1005 
1006 //_____________________________________________________________________________
1009 {
1011  if (!fNeighbours)
1012  {
1014  }
1015  return fNeighbours;
1016 }
1017 
1018 //_____________________________________________________________________________
1021 {
1023 
1025  {
1027  }
1028 
1029  if ( fLocalTriggerBoardMasks )
1030  {
1031  AliMUONVCalibParam* ltbm =
1032  static_cast<AliMUONVCalibParam*>(fLocalTriggerBoardMasks->FindObject(localBoardNumber));
1033  if (!ltbm)
1034  {
1035  AliError(Form("Could not get mask for localBoardNumber=%d",localBoardNumber));
1036  }
1037  return ltbm;
1038  }
1039  return 0x0;
1040 }
1041 
1042 //_____________________________________________________________________________
1045 {
1047  if (!fOccupancyMap)
1048  {
1050  }
1051  return fOccupancyMap;
1052 }
1053 
1054 //_____________________________________________________________________________
1057 {
1059  if (!fRejectList)
1060  {
1062  }
1063  return fRejectList;
1064 }
1065 
1066 //_____________________________________________________________________________
1067 void
1069 {
1071  fgBypassPedestals = ped;
1072  fgBypassGains = gain;
1073 
1074 }
1075 
1076 //_____________________________________________________________________________
1079 {
1081 
1083 
1084  if (!fPedestals)
1085  {
1087  }
1088  return fPedestals;
1089 }
1090 
1091 //_____________________________________________________________________________
1094 {
1096 
1097  if (!fConfig)
1098  {
1100  }
1101  return fConfig;
1102 }
1103 
1104 //_____________________________________________________________________________
1106 AliMUONCalibrationData::Pedestals(Int_t detElemId, Int_t manuId) const
1107 {
1111 
1112  AliMUONVStore* pedestals = Pedestals();
1113  if (!pedestals)
1114  {
1115  return 0x0;
1116  }
1117 
1118  return static_cast<AliMUONVCalibParam*>(pedestals->FindObject(detElemId,manuId));
1119 }
1120 
1121 //_____________________________________________________________________________
1122 void
1124 {
1126 
1127  cout << "RunNumber " << RunNumber()
1128  << " fGains=" << fGains
1129  << " fPedestals=" << fPedestals
1130  << " fConfig=" << fConfig
1131  << " fHV=" << fHV
1132  << " fTriggerDCS=" << fTriggerDCS
1133  << " fLocalTriggerBoardMasks=" << fLocalTriggerBoardMasks
1134  << " fRegionalTriggerConfig=" << fRegionalTriggerConfig
1135  << " fGlobalTriggerCrateConfig=" << fGlobalTriggerCrateConfig
1136  << " fTriggerLut=" << fTriggerLut
1137  << endl;
1138 }
1139 
1140 
1141 //_____________________________________________________________________________
1144 {
1146 
1148  {
1150  }
1151  return fRegionalTriggerConfig;
1152 }
1153 
1154 
1155 //_____________________________________________________________________________
1158 {
1160 
1161  if (!fTriggerEfficiency)
1162  {
1164  }
1165  return fTriggerEfficiency;
1166 }
1167 
1168 
1169 //_____________________________________________________________________________
1172 {
1174 
1175  if (!fTriggerLut)
1176  {
1178  }
1179  return fTriggerLut;
1180 }
1181 
1182 //_____________________________________________________________________________
1183 void
1185 {
1187 
1188  AliCodeTimerAuto("",0);
1189 
1190  delete fConfig;
1191  fConfig = 0x0;
1192  delete fPedestals;
1193  fPedestals = 0x0;
1194  delete fGains;
1195  fGains = 0x0;
1196  delete fHV;
1197  fHV = 0x0;
1198  delete fTriggerDCS;
1199  fTriggerDCS = 0x0;
1200  delete fLocalTriggerBoardMasks;
1202  delete fRegionalTriggerConfig;
1203  fRegionalTriggerConfig = 0x0;
1206 
1207  delete fTriggerLut;
1208  fTriggerLut = 0x0;
1209  delete fTriggerEfficiency;
1210  fTriggerEfficiency = 0x0;
1211  delete fCapacitances;
1212  fCapacitances = 0x0;
1213  delete fNeighbours;
1214  fNeighbours = 0x0;
1215 }
1216 
1217 //_____________________________________________________________________________
1218 void
1220 {
1223 
1224  if ( ! CreateCapacitances(runNumber) )
1225  {
1226  AliErrorClass("Could not read capacitances");
1227  }
1228  else
1229  {
1230  AliInfoClass("Capacitances read OK");
1231  }
1232 
1233  if ( ! CreateGains(runNumber) )
1234  {
1235  AliErrorClass("Could not read gains");
1236  }
1237  else
1238  {
1239  AliInfoClass("Gains read OK");
1240  }
1241 
1242  if ( ! CreateGlobalTriggerCrateConfig(runNumber) )
1243  {
1244  AliErrorClass("Could not read Trigger Crate Config");
1245  }
1246  else
1247  {
1248  AliInfoClass("TriggerBoardMasks read OK");
1249  }
1250 
1251  if ( ! CreateHV(runNumber) )
1252  {
1253  AliErrorClass("Could not read HV");
1254  }
1255  else
1256  {
1257  AliInfoClass("HV read OK");
1258  }
1259 
1260  if ( ! CreateTriggerDCS(runNumber) )
1261  {
1262  AliErrorClass("Could not read Trigger HV and Currents");
1263  }
1264  else
1265  {
1266  AliInfoClass("Trigger HV and Currents read OK");
1267  }
1268 
1269  if ( ! CreateNeighbours(runNumber) )
1270  {
1271  AliErrorClass("Could not read Neighbours");
1272  }
1273  else
1274  {
1275  AliInfoClass("Neighbours read OK");
1276  }
1277 
1278  if ( ! CreateLocalTriggerBoardMasks(runNumber) )
1279  {
1280  AliErrorClass("Could not read LocalTriggerBoardMasks");
1281  }
1282  else
1283  {
1284  AliInfoClass("LocalTriggerBoardMasks read OK");
1285  }
1286 
1287  if ( ! CreatePedestals(runNumber) )
1288  {
1289  AliErrorClass("Could not read pedestals");
1290  }
1291  else
1292  {
1293  AliInfoClass("Pedestals read OK");
1294  }
1295 
1296  if ( ! CreateConfig(runNumber) )
1297  {
1298  AliErrorClass("Could not read config");
1299  }
1300  else
1301  {
1302  AliInfoClass("Config read OK");
1303  }
1304 
1305  if ( ! CreateRegionalTriggerConfig(runNumber) )
1306  {
1307  AliErrorClass("Could not read RegionalTriggerConfig");
1308  }
1309  else
1310  {
1311  AliInfoClass("RegionalTriggerBoardMasks read OK");
1312  }
1313 
1314  if ( ! CreateTriggerLut(runNumber) )
1315  {
1316  AliErrorClass("Could not read TriggerLut");
1317  }
1318  else
1319  {
1320  AliInfoClass("TriggerLut read OK");
1321  }
1322 
1323  if ( ! CreateTriggerEfficiency(runNumber) )
1324  {
1325  AliErrorClass("Could not read TriggerEfficiency");
1326  }
1327  else
1328  {
1329  AliInfoClass("TriggerEfficiency read OK");
1330  }
1331 }
TMap * TriggerDCS() const
Get the Trigger HV and current values.
Int_t GetFirst() const
Return first value.
Definition: AliMpIntPair.h:50
The class defines the configuration of global crate.
AliMUONRegionalTriggerConfig * RegionalTriggerConfig() const
Get the config for regional trigger.
AliMUONRejectList * fRejectList
! reject list
static AliMUONVStore * CreateOccupancyMap(Int_t runNumber, Int_t *startOfValidity=0)
Create an occupancy map store (which must be deleted) from OCDB for the given run.
static AliMUONVStore * CreateLocalTriggerBoardMasks(Int_t runNumber, Int_t *startOfValidity=0)
Create a local trigger mask store (which must be deleted) for a given run.
AliMUONVStore * fConfig
! configuration of the tracker
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...
AliMUONVStore * fLocalTriggerBoardMasks
! Local trigger board maska
#define TObjArray
AliMUONVStore * Neighbours() const
Get the neighbours store.
static void AddToMap(const TMap &sourceMap, TMap &destMap, const TString &key, const char *source, const char *dest)
static Float_t TrackerHVOFF()
Definition: AliMpDCSNamer.h:64
AliMUONVStore * fNeighbours
! list of neighbours for all channels
Int_t fRunNumber
The run number for which we hold calibrations.
TFile f("CalibObjects.root")
AliMUONCalibrationData(Int_t runNumber=-1, Bool_t deferredInitialization=kTRUE)
static void Check(Int_t runNumber)
AliMUONTriggerEfficiencyCells * fTriggerEfficiency
! Trigger efficiency cells
static AliMUONVStore * CreateCapacitances(Int_t runNumber, Int_t *startOfValidity=0)
Create a capa store (which must be deleted) from OCDB for the given run.
Store and give access to the trigger chamber efficiency.
static AliMUONTriggerEfficiencyCells * CreateTriggerEfficiency(Int_t runNumber, Int_t *startOfValidity=0)
Create a trigger efficiency map (which must be deleted) for a given run.
virtual void Print(Option_t *opt="") const
Dump to screen.
AliMUONVStore * Config() const
Get the config store.
static AliMUONVStore * CreateConfig(Int_t runNumber, Int_t *startOfValidity=0)
Create a configuration store (which must be deleted) from OCDB for the given run. ...
AliMUONVStore * fGains
! Gains
AliMUONVCalibParam * LocalTriggerBoardMasks(Int_t localBoardNumber) const
Get the mask for a given local trigger board.
static AliMUONVStore * fgBypassGains
Int_t RunNumber() const
The runnumber used by this object.
AliMUONGlobalCrateConfig * fGlobalTriggerCrateConfig
! Global trigger crate config
AliMUONTriggerLut * TriggerLut() const
Get the trigger Look Up Table.
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
static AliMUONVStore * CreateGains(Int_t runNumber, Int_t *startOfValidity=0)
Create a gain store (which must be deleted) from OCDB for the given run.
Container of calibration values for a given number of channels.
static AliMUONGlobalCrateConfig * CreateGlobalTriggerCrateConfig(Int_t runNumber, Int_t *startOfValidity=0)
Create a global trigger mask (which must be deleted) from OCDB for the given run. ...
AliMUONVStore * fPedestals
! Pedestals
AliMUONVStore * fOccupancyMap
! occupancy map
AliMUONGlobalCrateConfig * GlobalTriggerCrateConfig() const
Get the configuration for the global trigger board.
static AliMUONVStore * CreateNeighbours(Int_t runNumber, Int_t *startOfValidity=0)
Create a neighbours store (which must be deleted) from OCDB for the given run.
static Bool_t PatchHVValues(TObjArray &values, TString *msg=0x0, Bool_t dryRun=kFALSE)
static TMap * CreateTriggerDCS(Int_t runNumber, Int_t *startOfValidity=0)
Create a Trigger HV and current map (which must be deleted) from OCDB for the given run...
AliMUONVStore * Pedestals() const
Get the pedestal store.
static void BypassStores(AliMUONVStore *ped, AliMUONVStore *gain)
static Bool_t CheckHVGroup(TObjArray &values, Int_t first, Int_t last, Double_t &value, Int_t &slope, TString *msg)
AliMUONTriggerEfficiencyCells * TriggerEfficiency() const
Get the trigger efficiency map.
static AliMUONVStore * fgBypassPedestals
AliMUONTriggerLut * fTriggerLut
! TRigger LUTs
AliMUONRegionalTriggerConfig * fRegionalTriggerConfig
! Regional trigger config
static AliMUONRegionalTriggerConfig * CreateRegionalTriggerConfig(Int_t runNumber, Int_t *startOfValidity=0)
Create a regional trigger mask store (which must be deleted) for a given run.
Single entry point to access MUON calibration data.
static void PatchSt1DCSAliases(TMap &hvMap)
static TObject * CreateObject(Int_t runNumber, const char *path, Int_t *startOfValidity=0x0)
TMap * fTriggerDCS
! Trigger HV and Currents
static UInt_t fgkDCSSt1Flag
! flag to indicate that the DCS alias naming is not messed up in St1
Object to hold the list of elements we want to reject from the reconstruction.
AliMUONVStore * OccupancyMap() const
Get the occupancy map store.
A pair of integers.
Definition: AliMpIntPair.h:23
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.
Int_t GetSecond() const
Return second value.
Definition: AliMpIntPair.h:52
static AliMUONTriggerLut * CreateTriggerLut(Int_t runNumber, Int_t *startOfValidity=0)
Create a trigger Look Up Table (which must be deleted) for a given run.
Base class for MUON data stores.
Definition: AliMUONVStore.h:22
AliMUONRejectList * RejectList() const
Get the reject list store.
AliMUONVStore * Capacitances() const
AliMUONVStore * fCapacitances
! Manu capacitances
MUON trigger look up table class.
AliMUONVStore * Gains() const
Get all the gains.
The class defines the properties of regional trigger crate.
static AliMUONRejectList * CreateRejectList(Int_t runNumber, Int_t *startOfValidity=0)
Create a rejectlist store (which must be deleted) from OCDB for the given run.
static AliMUONVStore * CreatePedestals(Int_t runNumber, Int_t *startOfValidity=0)
Create a pedestal store (which must be deleted) from OCDB for the given run.
virtual TObject * FindObject(const char *name) const
Find an object by name.