AliRoot Core  3abf5b4 (3abf5b4)
 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 
65 UInt_t AliMUONCalibrationData::fgkPatchHVDCSAliasesSt1WasAppliedMask = static_cast<UInt_t>( 1 << 4 );
66 UInt_t AliMUONCalibrationData::fgkPatchHVAllWasAppliedMask = static_cast<UInt_t>( 1 << 8 );
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 fPedestals(0x0),
86 fHV(0x0),
87 fTriggerDCS(0x0),
88 fLocalTriggerBoardMasks(0x0),
89 fRegionalTriggerConfig(0x0),
90 fGlobalTriggerCrateConfig(0x0),
91 fTriggerLut(0x0),
92 fTriggerEfficiency(0x0),
93 fNeighbours(0x0),
94 fOccupancyMap(0x0),
95 fRejectList(0x0),
96 fConfig(0x0),
97 fLV(0x0)
98 {
100 
101  // If deferredInitialization is false, we read *all* calibrations
102  // at once.
103  // So when using this class to access only one kind of calibrations (e.g.
104  // only pedestals), you should put deferredInitialization to kTRUE, which
105  // will instruct this object to fetch the data only when neeeded.
106 
107  AliCodeTimerAuto("",0);
108 
109  if ( deferredInitialization == kFALSE )
110  {
111 
112  AliWarning("Using immediate initialization, which might cause some issue with old OCDBs...");
113 
114  Pedestals();
115  OccupancyMap();
116  RejectList();
117  HV();
118 
119  TriggerDCS();
123  TriggerLut();
125  Neighbours();
126  Config();
127  }
128 }
129 
130 //_____________________________________________________________________________
132 {
135  if (!(AliCDBManager::Instance()->GetCacheFlag())) Reset();
136 }
137 
138 //_____________________________________________________________________________
140 AliMUONCalibrationData::CreateGlobalTriggerCrateConfig(Int_t runNumber, Int_t* startOfValidity)
141 {
143 
144  return dynamic_cast<AliMUONGlobalCrateConfig*>(CreateObject(runNumber,"MUON/Calib/GlobalTriggerCrateConfig",startOfValidity));
145 }
146 
147 
148 //______________________________________________________________________________
149 Bool_t AliMUONCalibrationData::CheckHVGroup(TObjArray& values, Int_t first, Int_t last, Double_t& value, Int_t& slope, TString* msg)
150 {
151  // Get the HV of the values between first and last indices
152  // return the HV slope (in Volt per second) and a message
153  // Return kFALSE if we must discard the group
154  //
155 
156  if (msg) *msg="";
157 
158  if ( last < first ) return kFALSE;
159  if ( last - first < 2 ) return kFALSE;
160 
161  Double_t a(0.0);
162  Double_t b(0.0);
163 
164  Float_t HVSAME(1); // 1 volts
165 
166  AliDCSValue* vfirst = static_cast<AliDCSValue*>(values.UncheckedAt(first));
167  AliDCSValue* vlast = static_cast<AliDCSValue*>(values.UncheckedAt(last));
168 
169  Int_t deltaHV = TMath::Nint(TMath::Abs(vfirst->GetFloat()-vlast->GetFloat()));
170 
171  if ( deltaHV < HVSAME ) return kFALSE;
172 
173  for ( Int_t i = first; i <= last; ++i )
174  {
175  AliDCSValue* v = static_cast<AliDCSValue*>(values.UncheckedAt(i));
176 
177  Double_t y = v->GetFloat() - vfirst->GetFloat();
178  Double_t x = v->GetTimeStamp() - vfirst->GetTimeStamp();
179 
180  a += x*y;
181  b += x*x;
182  }
183 
184  value = a/b;
185  slope = value > 0 ? 1 : -1;
186  value = TMath::Abs(value);
187 
188  UInt_t deltaTime = vlast->GetTimeStamp() - vfirst->GetTimeStamp();
189 
190  if (msg)
191  {
192  if (slope>0) (*msg) = Form("RU%d[%d:%d](%d)",TMath::Nint(value),first,last,deltaTime);
193  if (slope<0) (*msg) = Form("RD%d[%d:%d](%d)",TMath::Nint(value),first,last,deltaTime);
194 
195  if ( TMath::Nint(value) == 0 )
196  {
197  // this is to protect for the few cases
198  // (see e.g. MchHvLvLeft/Chamber00Left/Quad2Sect0.actual.vMon in run 134497)
199  // where we can have *lots* of values (2483 in this example) but that
200  // are more or less constant...
201  //
202  // or simply to remove small ramps
203  //
204  slope = 0;
205  value = (vfirst->GetFloat()+vlast->GetFloat())/2.0;
206  *msg = Form("FLUCT%d[%d:%d]",TMath::Nint(value),first,last);
207  }
208  }
209 
210  return kTRUE;
211 }
212 
213 //______________________________________________________________________________
215  TString* msg,
216  Bool_t dryRun)
217 {
232 
233  UInt_t DELTATIME(60); // in seconds
234  Int_t IENDRU(60); // in seconds
235 
236  // Start by finding groups of values which are not separated (each) by more than
237  // deltaTime
238 
239  Bool_t gather(kFALSE);
240  Int_t ifirst(0);
241  Int_t ilast(0);
242  TObjArray groups;
243  groups.SetOwner(kTRUE);
244 
245  for ( Int_t i = values.GetLast(); i > 0; --i )
246  {
247  AliDCSValue* vi = static_cast<AliDCSValue*>(values.UncheckedAt(i));
248  AliDCSValue* vj = static_cast<AliDCSValue*>(values.UncheckedAt(i-1));
249 
250  if ( vi->GetTimeStamp() - vj->GetTimeStamp() < DELTATIME )
251  {
252  if ( !gather )
253  {
254  gather = kTRUE;
255  ifirst = i;
256  }
257  ilast=i;
258  }
259  else
260  {
261  if ( gather )
262  {
263  ilast=i;
264 
265  groups.Add(new AliMpIntPair(ilast,ifirst));
266  }
267  gather = kFALSE;
268  }
269  }
270 
271  if (gather)
272  {
273  groups.Add(new AliMpIntPair(0,ifirst));
274  }
275 
276  TIter nextGroup(&groups,kIterBackward);
277  AliMpIntPair* p;
278  TString internalMsg;
279  Int_t ngroups(0);
280 
281  Int_t nRU(0);
282  Int_t nRD(0);
283  Int_t nStartRU(0);
284  Int_t nEndAndShortRU(0);
285  Int_t nEndRD(0);
286  Int_t nTripRD(0);
287  Int_t nFluct(0);
288  TObjArray trips;
289  trips.SetOwner(kTRUE);
290 
291  while ( ( p = static_cast<AliMpIntPair*>(nextGroup()) ) )
292  {
293  Double_t value;
294  Int_t slope;
295 
296  TString groupMsg;
297 
298  AliDebugClass(1,Form("group %d:%d",p->GetFirst(),p->GetSecond()));
299 
300  Bool_t ok = CheckHVGroup(values,p->GetFirst(),p->GetSecond(),value,slope,&groupMsg);
301 
302  if (!ok) continue;
303 
304  ++ngroups;
305 
306  if ( slope > 0 )
307  {
308  if ( p->GetFirst() == 0 )
309  {
310  // start with a ramp-up
311  ++nStartRU;
312  }
313  else if ( p->GetSecond() == values.GetLast() && TMath::Nint(value) < IENDRU )
314  {
315  ++nEndAndShortRU;
316  }
317  else
318  {
319  // ramp-up in the middle of nowhere...
320  ++nRU;
321  }
322  }
323  else if ( slope < 0 )
324  {
325  if ( p->GetSecond() == values.GetLast() )
326  {
327  // end with a ramp-down
328  ++nEndRD;
329  }
330  else
331  {
332  // ramp-down in the middle of nowhere
333  ++nRD;
334  }
335 
336  AliDCSValue* d = static_cast<AliDCSValue*>(values.At(p->GetSecond()));
337 
338  if ( d->GetFloat() < AliMpDCSNamer::TrackerHVOFF() )
339  {
340  ++nTripRD;
341  AliDCSValue* tripStart = static_cast<AliDCSValue*>(values.At(p->GetFirst()));
342  trips.Add(new AliMpIntPair(tripStart->GetTimeStamp(),TMath::Nint(tripStart->GetFloat())));
343  }
344  }
345  else
346  {
347  ++nFluct;
348  }
349 
350  internalMsg += groupMsg;
351  internalMsg += " ";
352  }
353 
354  /*
355 
356  Once we have "decoded" the groups we try to find out which of
357  the following cases we're facing :
358 
359  case A = -------- = OK(1)
360 
361  case B = ----
362  \
363  \ = OK, once we have removed the ramp-down (2)
364 
365  case C = -----
366  /
367  / = OK, once we have removed the ramp-up (3)
368 
369  case D = -----
370  / \
371  / \ = OK, once we have removed the ramp-down (2) and the ramp-up (3)
372 
373  case E = ----
374  \
375  \____ = TRIP = BAD (here the ramp-down slope should be bigger than in case C)
376 
377  case F = ----
378  \ ----- = BAD (trip + ramp-up at end of run)
379  \____/
380 
381  case G = fluctuations (within a range defined in CheckHVGroup...)
382 
383  case H =
384  /
385  / = ramp-up right at the end-of-run = OK (4)
386  ------
387 
388  (1) OK means the group is identified correctly, still the value can be below ready...
389  (2) ramp-down values will be removed if the ramp is indeed the last values in the serie
390  i.e. it's really an end-of-run problem (otherwise it's not case B)
391  (3) ramp-up values will be removed if the ramp is indeed the first values in the serie
392  i.e. it's really a start-of-run problem (otherwise it's not case C)
393  (4) OK if short enough...
394 
395  Any other case is unknown and we'll :
396  a) return kFALSE
397  b) assume the channel is OFF.
398 
399 
400  */
401 
402  AliDebugClass(1,Form("msg=%s ngroupds=%d",internalMsg.Data(),ngroups));
403  AliDebugClass(1,Form("nRU %d nRD %d nStartRU %d nEndRD %d nTripRD %d nFluct %d",
404  nRU,nRD,nStartRU,nEndRD,nTripRD,nFluct));
405 
406  TString hvCase("OTHER");
407  int dummy(0),a(-1),b(-1);
408  char r[81];
409  Int_t nvalues = values.GetSize();
410  Int_t* indices = new Int_t[nvalues];
411  memset(indices,0,nvalues*sizeof(Int_t));
412 
413  AliDCSValue* vfirst = static_cast<AliDCSValue*>(values.UncheckedAt(0));
414  AliDCSValue* vlast = static_cast<AliDCSValue*>(values.UncheckedAt(values.GetLast()));
415 
416  UInt_t meanTimeStamp = ( vfirst->GetTimeStamp() + vlast->GetTimeStamp() ) / 2;
417 
418  if ( ngroups == 0 )
419  {
420  hvCase = "A";
421  }
422  else if ( nTripRD > 0 )
423  {
424  const Double_t HVLOWTRIP(600); // a trip below this value is considered a "low trip"
425  // i.e. one starting for a non-operational voltage
426 
427  internalMsg += Form("NT:%d ",nTripRD);
428 
429  if ( nRU > 0 && nRD > 0 )
430  {
431  hvCase = "F";
432  }
433  else
434  {
435  hvCase = "E";
436  }
437 
438  for ( Int_t iTrip = 0; iTrip <= trips.GetLast(); ++iTrip )
439  {
440  AliMpIntPair* tripPair = static_cast<AliMpIntPair*>(trips.At(iTrip));
441  TString tripType("TRIP");
442  if ( tripPair->GetSecond() < HVLOWTRIP)
443  {
444  tripType = "LOWTRIP";
445  }
446 
447  internalMsg += Form("%s SV:%d TS:%d ",tripType.Data(),tripPair->GetSecond(),tripPair->GetFirst());
448  }
449 
450  // we put here the TRIP value as SV:value
451  // for cases where there's a drop in voltage but the starting point was
452  // below operational voltage, so strictly speaking it's *not* a trip, but
453  // more a big fluctuation
454  if ( !dryRun )
455  {
456  MarkForDeletion(indices,0,values.GetLast());
457  values.Add(new AliDCSValue(static_cast<Float_t>(0),meanTimeStamp));
458  }
459  }
460  else if ( nStartRU > 0 && nRU == 0 && nRD == 0 && nEndRD == 0 )
461  {
462  hvCase = "C";
463  if (!dryRun)
464  {
465  sscanf(internalMsg.Data(),"RU%10d[%10d:%10d]%80s",&dummy,&a,&b,r);
466  MarkForDeletion(indices,a,b);
467  }
468  }
469  else if ( nStartRU > 0 && nEndRD > 0 && nRD == 0 && nRU == 0 )
470  {
471  hvCase = "D";
472  if (!dryRun)
473  {
474  sscanf(internalMsg.Data(),"RU%10d[%10d:%10d]%80s",&dummy,&a,&b,r);
475  MarkForDeletion(indices,a,b-1);
476  Int_t i = internalMsg.Index("RD",strlen("RD"),0,TString::kExact);
477  sscanf(internalMsg(i,internalMsg.Length()-i).Data(),
478  "RD%10d[%10d:%10d]%80s",&dummy,&a,&b,r);
479  MarkForDeletion(indices,a+1,b);
480  }
481  }
482  else if ( nEndRD > 0 && nStartRU == 0 && nRU == 0 && nRD == 0 )
483  {
484  hvCase = "B";
485  if (!dryRun)
486  {
487  Int_t i = internalMsg.Index("RD",strlen("RD"),0,TString::kExact);
488  sscanf(internalMsg(i,internalMsg.Length()-i).Data(),
489  "RD%10d[%10d:%10d]%80s",&dummy,&a,&b,r);
490  MarkForDeletion(indices,a,b);
491  }
492  }
493  else if ( nFluct > 0 )
494  {
495  hvCase = "G";
496  if (!dryRun)
497  {
498  TObjArray* af = internalMsg.Tokenize(" ");
499  TIter next(af);
500  TObjString* str;
501  while ( ( str = static_cast<TObjString*>(next()) ) )
502  {
503  TString s(str->String());
504  if ( s.BeginsWith("FLUCT") )
505  {
506  sscanf(s.Data(),"FLUCT%d[%d:%d]",&dummy,&a,&b);
507  MarkForDeletion(indices,a,b);
508  }
509  }
510  delete af;
511  }
512  }
513  else if ( nEndAndShortRU > 0 && nStartRU == 0 && nRU == 0 && nRD == 0 && nEndRD == 0 )
514  {
515  hvCase = "H";
516  if (!dryRun)
517  {
518  sscanf(internalMsg.Data(),"RU%10d[%10d:%10d]%80s",&dummy,&a,&b,r);
519  MarkForDeletion(indices,a,b);
520  }
521  }
522  else
523  {
524  // last chance...
525  // here we know it's not a trip, so let's assume everything is OK
526  // if first and last value are in the same ballpark
527 
528  const Double_t HVFLUCT(20); // volts
529 
530  if ( TMath::Abs(vfirst->GetFloat() - vlast->GetFloat()) < HVFLUCT )
531  {
532  hvCase = "Z";
533  }
534  if (!dryRun)
535  {
536  MarkForDeletion(indices,1,nvalues-1);
537  }
538  }
539 
540  if (!dryRun)
541  {
542  for ( Int_t i = 0; i < nvalues; ++i )
543  {
544  if ( indices[i] )
545  {
546  values.RemoveAt(i);
547  }
548  }
549 
550  values.Compress();
551  }
552 
553  delete[] indices;
554 
555  if ( !values.GetEntries() )
556  {
557  AliErrorClass(Form("No value left after patch... Check that !!! initial # of values=%d msg=%s",
558  nvalues,internalMsg.Data()));
559  hvCase = "OTHER";
560  }
561 
562  if (!dryRun)
563  {
564  // take the max of the remaining values
565  TIter nextA(&values);
566  AliDCSValue* val;
567  Float_t maxval(-9999);
568 
569  while ( ( val = static_cast<AliDCSValue*>(nextA()) ) )
570  {
571  if ( val->GetFloat() > maxval )
572  {
573  maxval = val->GetFloat();
574  }
575  }
576 
577  values.Clear();
578 
579  values.Add(new AliDCSValue(maxval,meanTimeStamp));
580  }
581 
582  // once the case is inferred, add a "CASE:%10d",hvCase.Data()
583  // to the msg
584  // so we can them sum up for all channels and get a summary per run...
585 
586  internalMsg += Form("CASE:%s",hvCase.Data());
587 
588  if (msg) *msg = internalMsg.Data();
589 
590  return hvCase=="OTHER" ? kFALSE : kTRUE;
591 }
592 
593 //_____________________________________________________________________________
594 void AliMUONCalibrationData::AddToMap(const TMap& sourceMap,
595  TMap& destMap,
596  const TString& key,
597  const char* source,
598  const char* dest)
599 {
601 
602  TString newkey(key);
603 
604  newkey.ReplaceAll(source,dest);
605 
606  TPair* pair = static_cast<TPair*>(sourceMap.FindObject(key.Data()));
607 
608  destMap.Add(new TObjString(newkey.Data()),pair->Value());
609 }
610 
611 //_____________________________________________________________________________
613 {
622 
623  if ( ( hvMap.GetUniqueID() & PatchHVDCSAliasesSt1WasAppliedMask() ) == PatchHVDCSAliasesSt1WasAppliedMask() || ( hvMap.GetUniqueID() == 42 ) )
624  {
625  // already clean object. Do nothing
626  AliWarningClass("Patching already done for St1 DCS aliases on this map. Not doing it again.");
627  return;
628  }
629 
630  AliCodeTimerAutoClass(Form("hvMap=%p",&hvMap),0);
631 
632  TIter next(&hvMap);
633  TObjString* hvChannelName;
634 
635  TMap newmap;
636  newmap.SetOwnerKeyValue(kTRUE,kFALSE);
637 
638  while ( ( hvChannelName = static_cast<TObjString*>(next()) ) )
639  {
640  TString name(hvChannelName->String());
641  TString newname(name);
642 
643  // the problem is limited to St1 = ch1+ch2 (or, in DCS parlance, ch0+ch1)
644  // do it "by hand" as we "only" have 8 names to change
645 
646  if ( name.Contains("Chamber00Left") )
647  {
648  if (name.Contains("Quad1Sect0")) AddToMap(hvMap,newmap,name,"Quad1Sect0","Quad2Sect0"); // channel 0 of Board00 (alidcscae020)
649 
650  if (name.Contains("Quad1Sect1")) AddToMap(hvMap,newmap,name,"Quad1Sect1","Quad2Sect1"); // channel 1
651  if (name.Contains("Quad1Sect2")) AddToMap(hvMap,newmap,name,"Quad1Sect2","Quad2Sect2"); // channel 2
652 
653  if (name.Contains("Quad2Sect2")) AddToMap(hvMap,newmap,name,"Quad2Sect2","Quad1Sect0"); // channel 3
654  if (name.Contains("Quad2Sect1")) AddToMap(hvMap,newmap,name,"Quad2Sect1","Quad1Sect1"); // channel 4
655  if (name.Contains("Quad2Sect0")) AddToMap(hvMap,newmap,name,"Quad2Sect0","Quad1Sect2"); // channel 5
656  }
657  else if ( name.Contains("Chamber01Left"))
658  {
659  if (name.Contains("Quad2Sect2")) AddToMap(hvMap,newmap,name,"Quad2Sect2","Quad2Sect0"); // channel 9 of Board00 (alidcscae020)
660  if (name.Contains("Quad2Sect0")) AddToMap(hvMap,newmap,name,"Quad2Sect0","Quad2Sect2"); // channel 11
661  }
662  else
663  {
664  AddToMap(hvMap,newmap,name,name,name);
665  }
666  }
667 
668  // copy newmap to hvMap
669 
670  TIter nextNewMap(&newmap);
671  while ( ( hvChannelName = static_cast<TObjString*>(nextNewMap()) ) )
672  {
673  TPair* oldPair = static_cast<TPair*>(hvMap.FindObject(hvChannelName->String().Data()));
674  TPair* newPair = static_cast<TPair*>(newmap.FindObject(hvChannelName->String().Data()));
675 
676  TObjArray* newValues = static_cast<TObjArray*>(newPair->Value());
677 
678  oldPair->SetValue(newValues);
679  }
680 
681  // Flag the object as being clean as of now, so
682  // it won't be patched a second time in that method
683  // is called again...
684  hvMap.SetUniqueID( hvMap.GetUniqueID() | PatchHVDCSAliasesSt1WasAppliedMask() );
685 }
686 
687 //_____________________________________________________________________________
688 TMap*
690  Int_t* startOfValidity,
691  Bool_t patched,
692  TList* messages,
693  Bool_t dryRun)
694 {
701 
702  TMap* hvMap = dynamic_cast<TMap*>(CreateObject(runNumber,"MUON/Calib/HV",startOfValidity));
703 
704  if (!hvMap) return 0x0;
705 
706  AliCodeTimerAutoClass(Form("hvMap=%p",hvMap),0);
707 
708  PatchSt1DCSAliases(*hvMap);
709 
710  if (patched)
711  {
712  if ( ( hvMap->GetUniqueID() & PatchHVAllWasAppliedMask() ) == PatchHVAllWasAppliedMask() )
713  {
714  // patch already applied on this object, don't do it again
715  AliWarningClass("Patching already done for HV channels on this map. Not doing it again.");
716  return hvMap;
717  }
718 
719  TIter next(hvMap);
720  TObjString* hvChannelName;
721 
722  while ( ( hvChannelName = static_cast<TObjString*>(next()) ) )
723  {
724  TString name(hvChannelName->String());
725 
726  if ( name.Contains("sw") ) continue; // skip switches
727 
728  if ( name.Contains("iMon") ) continue; // skip HV currents
729 
730  TPair* hvPair = static_cast<TPair*>(hvMap->FindObject(name.Data()));
731  TObjArray* values = static_cast<TObjArray*>(hvPair->Value());
732  if (!values)
733  {
734  AliErrorClass(Form("Could not get values for alias %s",name.Data()));
735  }
736  else
737  {
738  TString msg;
739 
740  AliDebugClass(1,Form("channel %s",name.Data()));
741  Bool_t ok = PatchHVValues(*values,&msg,dryRun);
742 
743  if ( messages )
744  {
745  messages->Add(new TObjString(Form("%s %s",hvChannelName->String().Data(),msg.Data())));
746  }
747 
748  if (!ok)
749  {
750  AliErrorClass(Form("PatchHVValue was not successfull ! This is serious ! "
751  "You'll have to check the logic for channel %s in run %09d",
752  name.Data(),runNumber));
753  }
754  }
755  }
756 
757  hvMap->SetUniqueID(hvMap->GetUniqueID() | PatchHVAllWasAppliedMask());
758  }
759 
760  if ( messages )
761  {
762  Int_t a(0),b(0),c(0),d(0),e(0),f(0),g(0),h(0),u(0),z(0);
763  TIter next(messages);
764  TObjString* msg;
765  char hvCase('u');
766 
767  while ( ( msg = static_cast<TObjString*>(next()) ) )
768  {
769  Int_t i = msg->String().Index("CASE",strlen("CASE"),0,TString::kExact);
770 
771  if ( i >= 0 )
772  {
773  sscanf(msg->String()(i,msg->String().Length()-i).Data(),"CASE:%10c",&hvCase);
774  }
775 
776  switch (hvCase)
777  {
778  case 'A': ++a; break;
779  case 'B': ++b; break;
780  case 'C': ++c; break;
781  case 'D': ++d; break;
782  case 'E': ++e; break;
783  case 'F': ++f; break;
784  case 'G': ++g; break;
785  case 'H': ++h; break;
786  case 'Z': ++z; break;
787  default: ++u; break;
788  }
789  }
790 
791  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)",
792  a,b,c,d,e,f,g,h,z,u)));
793  }
794 
795  return hvMap;
796 }
797 
798 //_____________________________________________________________________________
799 TMap*
800 AliMUONCalibrationData::CreateLV(Int_t runNumber, Int_t* startOfValidity)
801 {
803  return dynamic_cast<TMap*>(CreateObject(runNumber,"MUON/Calib/LV",startOfValidity));
804 }
805 
806 //_____________________________________________________________________________
807 TMap*
808 AliMUONCalibrationData::CreateTriggerDCS(Int_t runNumber, Int_t* startOfValidity)
809 {
811  return dynamic_cast<TMap*>(CreateObject(runNumber,"MUON/Calib/TriggerDCS",startOfValidity));
812 }
813 
814 //_____________________________________________________________________________
816 AliMUONCalibrationData::CreateLocalTriggerBoardMasks(Int_t runNumber, Int_t* startOfValidity)
817 {
819 
820  return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/LocalTriggerBoardMasks",startOfValidity));
821 }
822 
823 //_____________________________________________________________________________
825 AliMUONCalibrationData::CreateNeighbours(Int_t runNumber, Int_t* startOfValidity)
826 {
828  return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Neighbours",startOfValidity));
829 }
830 
831 //_____________________________________________________________________________
832 TObject*
833 AliMUONCalibrationData::CreateObject(Int_t runNumber, const char* path, Int_t* startOfValidity)
834 {
837 
838  AliCodeTimerAutoClass(Form("%09d : %s",runNumber,path),0);
839 
840  AliCDBManager* man = AliCDBManager::Instance();
841 
842  AliCDBEntry* entry = man->Get(path,runNumber);
843 
844  if (entry)
845  {
846  if ( startOfValidity ) *startOfValidity = entry->GetId().GetFirstRun();
847 
848  TObject* object = entry->GetObject();
849  if (!(man->GetCacheFlag()))
850  {
851  entry->SetOwner(kFALSE);
852  delete entry;
853  }
854 // else
855 // {
856 // entry->SetOwner(kTRUE); //FIXME : this should be done but is causing problems with RecoParams at the end of the reco : investigate why...
857 // }
858  return object;
859  }
860  else
861  {
862  if ( startOfValidity ) *startOfValidity = AliCDBRunRange::Infinity();
863  }
864 
865  {
866 
867  AliCodeTimerAutoClass(Form("Failed to get %s for run %09d",path,runNumber),1);
868 
869  }
870 
871  return 0x0;
872 }
873 
874 //_____________________________________________________________________________
876 AliMUONCalibrationData::CreateOccupancyMap(Int_t runNumber, Int_t* startOfValidity)
877 {
879  return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/OccupancyMap",startOfValidity));
880 }
881 
882 //_____________________________________________________________________________
884 AliMUONCalibrationData::CreateRejectList(Int_t runNumber, Int_t* startOfValidity)
885 {
887  return dynamic_cast<AliMUONRejectList*>(CreateObject(runNumber,"MUON/Calib/RejectList",startOfValidity));
888 }
889 
890 //_____________________________________________________________________________
892 AliMUONCalibrationData::CreatePedestals(Int_t runNumber, Int_t* startOfValidity)
893 {
895  return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Pedestals",startOfValidity));
896 }
897 
898 //_____________________________________________________________________________
900 AliMUONCalibrationData::CreateConfig(Int_t runNumber, Int_t* startOfValidity)
901 {
903  return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Config",startOfValidity));
904 }
905 
906 
907 //_____________________________________________________________________________
909 AliMUONCalibrationData::CreateRegionalTriggerConfig(Int_t runNumber, Int_t* startOfValidity)
910 {
912 
913  return dynamic_cast<AliMUONRegionalTriggerConfig*>(CreateObject(runNumber,"MUON/Calib/RegionalTriggerConfig",startOfValidity));
914 }
915 
916 //_____________________________________________________________________________
918 AliMUONCalibrationData::CreateTriggerEfficiency(Int_t runNumber, Int_t* startOfValidity)
919 {
921 
922  return dynamic_cast<AliMUONTriggerEfficiencyCells*>(CreateObject(runNumber,"MUON/Calib/TriggerEfficiency",startOfValidity));
923 }
924 
925 //_____________________________________________________________________________
927 AliMUONCalibrationData::CreateTriggerLut(Int_t runNumber, Int_t* startOfValidity)
928 {
930 
931  return dynamic_cast<AliMUONTriggerLut*>(CreateObject(runNumber,"MUON/Calib/TriggerLut",startOfValidity));
932 }
933 //_____________________________________________________________________________
936 {
938 
940  {
942  }
944 }
945 
946 
947 //_____________________________________________________________________________
948 TMap*
949 AliMUONCalibrationData::HV(Bool_t patched) const
950 {
952 
953  if (!fHV)
954  {
955  fHV = CreateHV(fRunNumber,0,patched);
956  }
957  return fHV;
958 }
959 
960 //_____________________________________________________________________________
961 TMap*
963 {
965 
966  if (!fLV && RunNumber() > 250127)
967  {
971  }
972  return fLV;
973 }
974 
975 //_____________________________________________________________________________
976 TMap*
978 {
980 
981  if (!fTriggerDCS)
982  {
984  }
985  return fTriggerDCS;
986 }
987 
988 //_____________________________________________________________________________
991 {
993  if (!fNeighbours)
994  {
996  }
997  return fNeighbours;
998 }
999 
1000 //_____________________________________________________________________________
1003 {
1005 
1007  {
1009  }
1010 
1012  {
1013  AliMUONVCalibParam* ltbm =
1014  static_cast<AliMUONVCalibParam*>(fLocalTriggerBoardMasks->FindObject(localBoardNumber));
1015  if (!ltbm)
1016  {
1017  AliError(Form("Could not get mask for localBoardNumber=%d",localBoardNumber));
1018  }
1019  return ltbm;
1020  }
1021  return 0x0;
1022 }
1023 
1024 //_____________________________________________________________________________
1027 {
1029  if (!fOccupancyMap)
1030  {
1032  }
1033  return fOccupancyMap;
1034 }
1035 
1036 //_____________________________________________________________________________
1039 {
1041  if (!fRejectList)
1042  {
1044  }
1045  return fRejectList;
1046 }
1047 
1048 //_____________________________________________________________________________
1049 void
1051 {
1053  fgBypassPedestals = ped;
1054 
1055 }
1056 
1057 //_____________________________________________________________________________
1060 {
1062 
1064 
1065  if (!fPedestals)
1066  {
1068  }
1069  return fPedestals;
1070 }
1071 
1072 //_____________________________________________________________________________
1075 {
1077 
1078  if (!fConfig)
1079  {
1081  }
1082  return fConfig;
1083 }
1084 
1085 //_____________________________________________________________________________
1087 AliMUONCalibrationData::Pedestals(Int_t detElemId, Int_t manuId) const
1088 {
1092 
1093  AliMUONVStore* pedestals = Pedestals();
1094  if (!pedestals)
1095  {
1096  return 0x0;
1097  }
1098 
1099  return static_cast<AliMUONVCalibParam*>(pedestals->FindObject(detElemId,manuId));
1100 }
1101 
1102 //_____________________________________________________________________________
1103 void
1105 {
1107 
1108  cout << "RunNumber " << RunNumber()
1109  << " fPedestals=" << fPedestals
1110  << " fConfig=" << fConfig
1111  << " fHV=" << fHV
1112  << " fLV=" << fLV
1113  << " fTriggerDCS=" << fTriggerDCS
1114  << " fLocalTriggerBoardMasks=" << fLocalTriggerBoardMasks
1115  << " fRegionalTriggerConfig=" << fRegionalTriggerConfig
1116  << " fGlobalTriggerCrateConfig=" << fGlobalTriggerCrateConfig
1117  << " fTriggerLut=" << fTriggerLut
1118  << endl;
1119 }
1120 
1121 
1122 //_____________________________________________________________________________
1125 {
1127 
1129  {
1131  }
1132  return fRegionalTriggerConfig;
1133 }
1134 
1135 
1136 //_____________________________________________________________________________
1139 {
1141 
1142  if (!fTriggerEfficiency)
1143  {
1145  }
1146  return fTriggerEfficiency;
1147 }
1148 
1149 
1150 //_____________________________________________________________________________
1153 {
1155 
1156  if (!fTriggerLut)
1157  {
1159  }
1160  return fTriggerLut;
1161 }
1162 
1163 //_____________________________________________________________________________
1164 void
1166 {
1168 
1169  AliCodeTimerAuto("",0);
1170 
1171  delete fConfig;
1172  fConfig = 0x0;
1173  delete fPedestals;
1174  fPedestals = 0x0;
1175  delete fHV;
1176  fHV = 0x0;
1177  delete fLV;
1178  fLV = 0x0;
1179  delete fTriggerDCS;
1180  fTriggerDCS = 0x0;
1181  delete fLocalTriggerBoardMasks;
1183  delete fRegionalTriggerConfig;
1184  fRegionalTriggerConfig = 0x0;
1187 
1188  delete fTriggerLut;
1189  fTriggerLut = 0x0;
1190  delete fTriggerEfficiency;
1191  fTriggerEfficiency = 0x0;
1192  delete fNeighbours;
1193  fNeighbours = 0x0;
1194 }
1195 
1196 //_____________________________________________________________________________
1197 void
1199 {
1202 
1203  if ( ! CreateGlobalTriggerCrateConfig(runNumber) )
1204  {
1205  AliErrorClass("Could not read Trigger Crate Config");
1206  }
1207  else
1208  {
1209  AliInfoClass("TriggerBoardMasks read OK");
1210  }
1211 
1212  if ( ! CreateHV(runNumber) )
1213  {
1214  AliErrorClass("Could not read HV");
1215  }
1216  else
1217  {
1218  AliInfoClass("HV read OK");
1219  }
1220 
1221  if ( ! CreateLV(runNumber) )
1222  {
1223  AliErrorClass("Could not read LV");
1224  }
1225  else
1226  {
1227  AliInfoClass("LV read OK");
1228  }
1229 
1230  if ( ! CreateTriggerDCS(runNumber) )
1231  {
1232  AliErrorClass("Could not read Trigger HV and Currents");
1233  }
1234  else
1235  {
1236  AliInfoClass("Trigger HV and Currents read OK");
1237  }
1238 
1239  if ( ! CreateNeighbours(runNumber) )
1240  {
1241  AliErrorClass("Could not read Neighbours");
1242  }
1243  else
1244  {
1245  AliInfoClass("Neighbours read OK");
1246  }
1247 
1248  if ( ! CreateLocalTriggerBoardMasks(runNumber) )
1249  {
1250  AliErrorClass("Could not read LocalTriggerBoardMasks");
1251  }
1252  else
1253  {
1254  AliInfoClass("LocalTriggerBoardMasks read OK");
1255  }
1256 
1257  if ( ! CreatePedestals(runNumber) )
1258  {
1259  AliErrorClass("Could not read pedestals");
1260  }
1261  else
1262  {
1263  AliInfoClass("Pedestals read OK");
1264  }
1265 
1266  if ( ! CreateConfig(runNumber) )
1267  {
1268  AliErrorClass("Could not read config");
1269  }
1270  else
1271  {
1272  AliInfoClass("Config read OK");
1273  }
1274 
1275  if ( ! CreateRegionalTriggerConfig(runNumber) )
1276  {
1277  AliErrorClass("Could not read RegionalTriggerConfig");
1278  }
1279  else
1280  {
1281  AliInfoClass("RegionalTriggerBoardMasks read OK");
1282  }
1283 
1284  if ( ! CreateTriggerLut(runNumber) )
1285  {
1286  AliErrorClass("Could not read TriggerLut");
1287  }
1288  else
1289  {
1290  AliInfoClass("TriggerLut read OK");
1291  }
1292 
1293  if ( ! CreateTriggerEfficiency(runNumber) )
1294  {
1295  AliErrorClass("Could not read TriggerEfficiency");
1296  }
1297  else
1298  {
1299  AliInfoClass("TriggerEfficiency read OK");
1300  }
1301 }
TMap * LV() const
Get the MCH LV.
static UInt_t PatchHVDCSAliasesSt1WasAppliedMask()
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:70
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
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. ...
AliMUONVCalibParam * LocalTriggerBoardMasks(Int_t localBoardNumber) const
Get the mask for a given local trigger board.
static void BypassStores(AliMUONVStore *ped)
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 UInt_t PatchHVAllWasAppliedMask()
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 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 TMap * CreateLV(Int_t runNumber, Int_t *startOfValidity=0)
Create a MCH LV map (which must be deleted) from OCDB for the given run.
static TObject * CreateObject(Int_t runNumber, const char *path, Int_t *startOfValidity=0x0)
TMap * fTriggerDCS
! Trigger HV and Currents
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.
MUON trigger look up table class.
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.