LCOV - code coverage report
Current view: top level - MUON/MUONcalib - AliMUONCalibrationData.cxx (source / functions) Hit Total Coverage
Test: coverage.info Lines: 200 473 42.3 %
Date: 2016-06-14 17:26:59 Functions: 33 43 76.7 %

          Line data    Source code
       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"
      27             : #include "AliMUONGlobalCrateConfig.h"
      28             : #include "AliMUONRegionalTriggerConfig.h"
      29             : #include "AliMUONRejectList.h"
      30             : #include "AliMUONTriggerEfficiencyCells.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             : //-----------------------------------------------------------------------------
      42             : /// \class AliMUONCalibrationData
      43             : ///
      44             : /// For the moment, this class stores pedestals, hv (for tracker)
      45             : /// and lut, masks and efficiencies (for trigger) that are fetched from the CDB.
      46             : ///
      47             : /// This class is to be considered as a convenience class.
      48             : /// Its aim is to ease retrieval of calibration data from the
      49             : /// condition database.
      50             : ///
      51             : /// It acts as a "facade" to a bunch of underlying
      52             : /// containers/calibration classes.
      53             : ///
      54             : /// \author Laurent Aphecetche
      55             : //-----------------------------------------------------------------------------
      56             : 
      57             : using std::cout;
      58             : using std::endl;
      59             : /// \cond CLASSIMP
      60          18 : ClassImp(AliMUONCalibrationData)
      61             : /// \endcond
      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           0 :     for ( Int_t i = first; i <= last; ++i )
      73             :     {
      74           0 :       indices[i] = 1;
      75             :     }
      76           0 :   }
      77             : }
      78             : 
      79             : //_____________________________________________________________________________
      80             : AliMUONCalibrationData::AliMUONCalibrationData(Int_t runNumber,
      81             :                                                Bool_t deferredInitialization)
      82          17 : : TObject(),
      83          17 : fIsValid(kTRUE),
      84          17 : fRunNumber(runNumber),
      85          17 : fPedestals(0x0),
      86          17 : fHV(0x0),
      87          17 : fTriggerDCS(0x0),
      88          17 : fLocalTriggerBoardMasks(0x0),
      89          17 : fRegionalTriggerConfig(0x0),
      90          17 : fGlobalTriggerCrateConfig(0x0),
      91          17 : fTriggerLut(0x0),
      92          17 : fTriggerEfficiency(0x0),
      93          17 : fNeighbours(0x0),
      94          17 : fOccupancyMap(0x0),
      95          17 : fRejectList(0x0),
      96          17 : fConfig(0x0),
      97          17 : fLV(0x0)
      98          51 : {
      99             : /// Default ctor.
     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          34 :   AliCodeTimerAuto("",0);
     108             : 
     109          17 :   if ( deferredInitialization == kFALSE )
     110             :   {
     111             : 
     112           0 :     AliWarning("Using immediate initialization, which might cause some issue with old OCDBs...");
     113             : 
     114           0 :     Pedestals();
     115           0 :     OccupancyMap();
     116           0 :     RejectList();
     117           0 :     HV();
     118             : 
     119           0 :     TriggerDCS();
     120           0 :     LocalTriggerBoardMasks(0);
     121           0 :     RegionalTriggerConfig();
     122           0 :     GlobalTriggerCrateConfig();
     123           0 :     TriggerLut();
     124           0 :     TriggerEfficiency();
     125           0 :     Neighbours();
     126           0 :     Config();
     127             :   }
     128          34 : }
     129             : 
     130             : //_____________________________________________________________________________
     131             : AliMUONCalibrationData::~AliMUONCalibrationData()
     132          90 : {
     133             :   /// Destructor. Note that we're the owner of our pointers if the OCDB cache
     134             :   /// is not set. Otherwise the cache is supposed to take care of them...
     135          30 :   if (!(AliCDBManager::Instance()->GetCacheFlag())) Reset();
     136          45 : }
     137             : 
     138             : //_____________________________________________________________________________
     139             : AliMUONGlobalCrateConfig*
     140             : AliMUONCalibrationData::CreateGlobalTriggerCrateConfig(Int_t runNumber, Int_t* startOfValidity)
     141             : {
     142             :   /// Create the internal store for GlobalTriggerCrateConfig from OCDB
     143             : 
     144          12 :   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           0 :   if (msg) *msg="";
     157             : 
     158           0 :   if ( last < first ) return kFALSE;
     159           0 :   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           0 :   AliDCSValue* vfirst = static_cast<AliDCSValue*>(values.UncheckedAt(first));
     167           0 :   AliDCSValue* vlast = static_cast<AliDCSValue*>(values.UncheckedAt(last));
     168             : 
     169           0 :   Int_t deltaHV = TMath::Nint(TMath::Abs(vfirst->GetFloat()-vlast->GetFloat()));
     170             : 
     171           0 :   if ( deltaHV < HVSAME ) return kFALSE;
     172             : 
     173           0 :   for ( Int_t i = first; i <= last; ++i )
     174             :   {
     175           0 :     AliDCSValue* v = static_cast<AliDCSValue*>(values.UncheckedAt(i));
     176             : 
     177           0 :     Double_t y = v->GetFloat() - vfirst->GetFloat();
     178           0 :     Double_t x = v->GetTimeStamp() - vfirst->GetTimeStamp();
     179             : 
     180           0 :     a += x*y;
     181           0 :     b += x*x;
     182             :   }
     183             : 
     184           0 :   value = a/b;
     185           0 :   slope = value > 0 ? 1 : -1;
     186           0 :   value = TMath::Abs(value);
     187             : 
     188           0 :   UInt_t deltaTime = vlast->GetTimeStamp() - vfirst->GetTimeStamp();
     189             : 
     190           0 :   if (msg)
     191             :   {
     192           0 :     if (slope>0) (*msg) = Form("RU%d[%d:%d](%d)",TMath::Nint(value),first,last,deltaTime);
     193           0 :     if (slope<0) (*msg) = Form("RD%d[%d:%d](%d)",TMath::Nint(value),first,last,deltaTime);
     194             : 
     195           0 :     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           0 :       slope = 0;
     205           0 :       value = (vfirst->GetFloat()+vlast->GetFloat())/2.0;
     206           0 :       *msg = Form("FLUCT%d[%d:%d]",TMath::Nint(value),first,last);
     207           0 :     }
     208             :   }
     209             : 
     210             :   return kTRUE;
     211           0 : }
     212             : 
     213             : //______________________________________________________________________________
     214             : Bool_t AliMUONCalibrationData::PatchHVValues(TObjArray& values,
     215             :                                              TString* msg,
     216             :                                              Bool_t dryRun)
     217             : {
     218             :   /// We do here a little bit of massaging of the HV values, if needed.
     219             :   ///
     220             :   /// The main point is to "gather" values that are within a given small amount
     221             :   /// of time (typically 60 seconds) and infer a slope from those values
     222             :   /// slope > 0 means it is a ramp-up, slope < 0 that's a ramp-down
     223             :   ///
     224             :   /// This is to avoid both the "ramp-down-before-end-of-run" and the
     225             :   /// "ramp-up-after-start-of-run" syndroms...
     226             :   ///
     227             :   /// Use dryRun = kTRUE to fill the messages *without* altering the values
     228             :   ///
     229             :   /// Return kFALSE if the kind of HV (trouble) case we have here
     230             :   /// has not been identified...
     231             :   ///
     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         376 :   TObjArray groups;
     243         376 :   groups.SetOwner(kTRUE);
     244             : 
     245        6392 :   for ( Int_t i = values.GetLast(); i > 0; --i )
     246             :   {
     247        2632 :     AliDCSValue* vi = static_cast<AliDCSValue*>(values.UncheckedAt(i));
     248        2632 :     AliDCSValue* vj = static_cast<AliDCSValue*>(values.UncheckedAt(i-1));
     249             : 
     250        5264 :     if ( vi->GetTimeStamp() - vj->GetTimeStamp() < DELTATIME )
     251             :     {
     252        2632 :       if ( !gather )
     253             :       {
     254             :         gather = kTRUE;
     255             :         ifirst = i;
     256           0 :       }
     257             :       ilast=i;
     258           0 :     }
     259             :     else
     260             :     {
     261        2632 :       if ( gather )
     262             :       {
     263             :         ilast=i;
     264             : 
     265           0 :         groups.Add(new AliMpIntPair(ilast,ifirst));
     266             :       }
     267             :       gather = kFALSE;
     268             :     }
     269             :   }
     270             : 
     271         376 :   if (gather)
     272             :   {
     273           0 :     groups.Add(new AliMpIntPair(0,ifirst));
     274             :   }
     275             : 
     276         376 :   TIter nextGroup(&groups,kIterBackward);
     277             :   AliMpIntPair* p;
     278         376 :   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         376 :   TObjArray trips;
     289         376 :   trips.SetOwner(kTRUE);
     290             : 
     291         752 :   while ( ( p = static_cast<AliMpIntPair*>(nextGroup()) ) )
     292             :   {
     293           0 :     Double_t value;
     294           0 :     Int_t slope;
     295             : 
     296           0 :     TString groupMsg;
     297             : 
     298           0 :     AliDebugClass(1,Form("group %d:%d",p->GetFirst(),p->GetSecond()));
     299             : 
     300           0 :     Bool_t ok = CheckHVGroup(values,p->GetFirst(),p->GetSecond(),value,slope,&groupMsg);
     301             : 
     302           0 :     if (!ok) continue;
     303             : 
     304           0 :     ++ngroups;
     305             : 
     306           0 :     if ( slope > 0 )
     307             :     {
     308           0 :       if ( p->GetFirst() == 0 )
     309             :       {
     310             :         // start with a ramp-up
     311           0 :         ++nStartRU;
     312           0 :       }
     313           0 :       else if ( p->GetSecond() == values.GetLast() && TMath::Nint(value) < IENDRU )
     314             :       {
     315           0 :         ++nEndAndShortRU;
     316           0 :       }
     317             :       else
     318             :       {
     319             :         // ramp-up in the middle of nowhere...
     320           0 :         ++nRU;
     321             :       }
     322             :     }
     323           0 :     else if ( slope < 0 )
     324             :     {
     325           0 :       if ( p->GetSecond() == values.GetLast() )
     326             :       {
     327             :         // end with a ramp-down
     328           0 :         ++nEndRD;
     329           0 :       }
     330             :       else
     331             :       {
     332             :         // ramp-down in the middle of nowhere
     333           0 :         ++nRD;
     334             :       }
     335             : 
     336           0 :       AliDCSValue* d = static_cast<AliDCSValue*>(values.At(p->GetSecond()));
     337             : 
     338           0 :       if ( d->GetFloat() < AliMpDCSNamer::TrackerHVOFF() )
     339             :       {
     340           0 :         ++nTripRD;
     341           0 :         AliDCSValue* tripStart = static_cast<AliDCSValue*>(values.At(p->GetFirst()));
     342           0 :         trips.Add(new AliMpIntPair(tripStart->GetTimeStamp(),TMath::Nint(tripStart->GetFloat())));
     343           0 :       }
     344           0 :     }
     345             :     else
     346             :     {
     347           0 :       ++nFluct;
     348             :     }
     349             : 
     350           0 :     internalMsg += groupMsg;
     351           0 :     internalMsg += " ";
     352           0 :   }
     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        2256 :   AliDebugClass(1,Form("msg=%s ngroupds=%d",internalMsg.Data(),ngroups));
     403        2256 :   AliDebugClass(1,Form("nRU %d nRD %d nStartRU %d nEndRD %d nTripRD %d nFluct %d",
     404             :                        nRU,nRD,nStartRU,nEndRD,nTripRD,nFluct));
     405             : 
     406         376 :   TString hvCase("OTHER");
     407         376 :   int dummy(0),a(-1),b(-1);
     408         376 :   char r[81];
     409         376 :   Int_t nvalues = values.GetSize();
     410         752 :   Int_t* indices = new Int_t[nvalues];
     411         376 :   memset(indices,0,nvalues*sizeof(Int_t));
     412             : 
     413         376 :   AliDCSValue* vfirst = static_cast<AliDCSValue*>(values.UncheckedAt(0));
     414         752 :   AliDCSValue* vlast = static_cast<AliDCSValue*>(values.UncheckedAt(values.GetLast()));
     415             : 
     416         376 :   UInt_t meanTimeStamp = ( vfirst->GetTimeStamp() + vlast->GetTimeStamp() ) / 2;
     417             : 
     418         376 :   if ( ngroups == 0 )
     419             :   {
     420         376 :     hvCase = "A";
     421             :   }
     422           0 :   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           0 :     internalMsg += Form("NT:%d ",nTripRD);
     428             : 
     429           0 :     if ( nRU > 0 && nRD > 0 )
     430             :     {
     431           0 :       hvCase = "F";
     432             :     }
     433             :     else
     434             :     {
     435           0 :       hvCase = "E";
     436             :     }
     437             : 
     438           0 :     for ( Int_t iTrip = 0; iTrip <= trips.GetLast(); ++iTrip )
     439             :     {
     440           0 :       AliMpIntPair* tripPair = static_cast<AliMpIntPair*>(trips.At(iTrip));
     441           0 :       TString tripType("TRIP");
     442           0 :       if ( tripPair->GetSecond() < HVLOWTRIP)
     443             :       {
     444           0 :         tripType = "LOWTRIP";
     445             :       }
     446             : 
     447           0 :       internalMsg += Form("%s SV:%d TS:%d ",tripType.Data(),tripPair->GetSecond(),tripPair->GetFirst());
     448           0 :     }
     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           0 :     if ( !dryRun )
     455             :     {
     456           0 :       MarkForDeletion(indices,0,values.GetLast());
     457           0 :       values.Add(new AliDCSValue(static_cast<Float_t>(0),meanTimeStamp));
     458             :     }
     459           0 :   }
     460           0 :   else if ( nStartRU > 0 && nRU == 0 && nRD == 0 && nEndRD == 0 )
     461             :   {
     462           0 :     hvCase = "C";
     463           0 :     if (!dryRun)
     464             :     {
     465           0 :       sscanf(internalMsg.Data(),"RU%10d[%10d:%10d]%80s",&dummy,&a,&b,r);
     466           0 :       MarkForDeletion(indices,a,b);
     467           0 :     }
     468             :   }
     469           0 :   else if ( nStartRU > 0 && nEndRD > 0 && nRD == 0 && nRU == 0 )
     470             :   {
     471           0 :     hvCase = "D";
     472           0 :     if (!dryRun)
     473             :     {
     474           0 :       sscanf(internalMsg.Data(),"RU%10d[%10d:%10d]%80s",&dummy,&a,&b,r);
     475           0 :       MarkForDeletion(indices,a,b-1);
     476           0 :       Int_t i = internalMsg.Index("RD",strlen("RD"),0,TString::kExact);
     477           0 :       sscanf(internalMsg(i,internalMsg.Length()-i).Data(),
     478             :              "RD%10d[%10d:%10d]%80s",&dummy,&a,&b,r);
     479           0 :       MarkForDeletion(indices,a+1,b);
     480           0 :     }
     481             :   }
     482           0 :   else if ( nEndRD > 0 && nStartRU == 0 && nRU == 0 && nRD == 0 )
     483             :   {
     484           0 :     hvCase = "B";
     485           0 :     if  (!dryRun)
     486             :     {
     487           0 :       Int_t i = internalMsg.Index("RD",strlen("RD"),0,TString::kExact);
     488           0 :       sscanf(internalMsg(i,internalMsg.Length()-i).Data(),
     489           0 :              "RD%10d[%10d:%10d]%80s",&dummy,&a,&b,r);
     490           0 :       MarkForDeletion(indices,a,b);
     491           0 :     }
     492             :   }
     493           0 :   else if ( nFluct > 0 )
     494             :   {
     495           0 :     hvCase = "G";
     496           0 :     if (!dryRun)
     497             :     {
     498           0 :       TObjArray* af = internalMsg.Tokenize(" ");
     499           0 :       TIter next(af);
     500             :       TObjString* str;
     501           0 :       while ( ( str = static_cast<TObjString*>(next()) ) )
     502             :       {
     503           0 :         TString s(str->String());
     504           0 :         if ( s.BeginsWith("FLUCT") )
     505             :         {
     506           0 :           sscanf(s.Data(),"FLUCT%d[%d:%d]",&dummy,&a,&b);
     507           0 :           MarkForDeletion(indices,a,b);
     508           0 :         }
     509           0 :       }
     510           0 :       delete af;
     511           0 :     }
     512             :   }
     513           0 :   else if ( nEndAndShortRU > 0 && nStartRU == 0 && nRU == 0 && nRD == 0 && nEndRD == 0 )
     514             :   {
     515           0 :     hvCase = "H";
     516           0 :     if (!dryRun)
     517             :     {
     518           0 :       sscanf(internalMsg.Data(),"RU%10d[%10d:%10d]%80s",&dummy,&a,&b,r);
     519           0 :       MarkForDeletion(indices,a,b);
     520           0 :     }
     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           0 :     if ( TMath::Abs(vfirst->GetFloat() - vlast->GetFloat()) < HVFLUCT )
     531             :     {
     532           0 :       hvCase = "Z";
     533             :     }
     534           0 :     if (!dryRun)
     535             :     {
     536           0 :       MarkForDeletion(indices,1,nvalues-1);
     537           0 :     }
     538             :   }
     539             : 
     540         376 :   if (!dryRun)
     541             :   {
     542       12784 :     for ( Int_t i = 0; i < nvalues; ++i )
     543             :     {
     544        6016 :       if ( indices[i] )
     545             :       {
     546           0 :         values.RemoveAt(i);
     547             :       }
     548             :     }
     549             : 
     550         376 :     values.Compress();
     551             :   }
     552             : 
     553         752 :   delete[] indices;
     554             : 
     555         752 :   if ( !values.GetEntries() )
     556             :   {
     557           0 :     AliErrorClass(Form("No value left after patch... Check that !!! initial # of values=%d msg=%s",
     558             :                        nvalues,internalMsg.Data()));
     559           0 :     hvCase = "OTHER";
     560             :   }
     561             : 
     562         376 :   if (!dryRun)
     563             :   {
     564             :     // take the max of the remaining values
     565         376 :     TIter nextA(&values);
     566             :     AliDCSValue* val;
     567             :     Float_t maxval(-9999);
     568             : 
     569        7144 :     while ( ( val = static_cast<AliDCSValue*>(nextA()) ) )
     570             :     {
     571        6016 :       if ( val->GetFloat() > maxval )
     572             :       {
     573         376 :         maxval = val->GetFloat();
     574         376 :       }
     575             :     }
     576             : 
     577         376 :     values.Clear();
     578             : 
     579        1128 :     values.Add(new AliDCSValue(maxval,meanTimeStamp));
     580         376 :   }
     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        1128 :   internalMsg += Form("CASE:%s",hvCase.Data());
     587             : 
     588        1128 :   if (msg) *msg = internalMsg.Data();
     589             : 
     590         752 :   return hvCase=="OTHER" ? kFALSE : kTRUE;
     591         376 : }
     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             : {
     600             :   /// Remap
     601             : 
     602        3136 :   TString newkey(key);
     603             : 
     604        1568 :   newkey.ReplaceAll(source,dest);
     605             : 
     606        4704 :   TPair* pair = static_cast<TPair*>(sourceMap.FindObject(key.Data()));
     607             : 
     608        6272 :   destMap.Add(new TObjString(newkey.Data()),pair->Value());
     609        1568 : }
     610             : 
     611             : //_____________________________________________________________________________
     612             : void AliMUONCalibrationData::PatchSt1DCSAliases(TMap& hvMap)
     613             : {
     614             :   /// It was discovered (in sept. 2013) that the DCS aliases for St1 was
     615             :   /// wrongly assigned (in the hardware), so the correspondence between DCS channels
     616             :   /// and actual HV channels is wrong for St1 in the DCS (and thus in the DCS archive,
     617             :   /// and so in the OCDB HV object).
     618             :   ///
     619             :   /// It affects all the OCDB object written in 2010-2013.
     620             :   ///
     621             :   /// This method fixes that.
     622             : 
     623           6 :   if ( ( hvMap.GetUniqueID() & PatchHVDCSAliasesSt1WasAppliedMask() ) == PatchHVDCSAliasesSt1WasAppliedMask() || ( hvMap.GetUniqueID() == 42 ) )
     624             :   {
     625             :     // already clean object. Do nothing
     626           0 :     AliWarningClass("Patching already done for St1 DCS aliases on this map. Not doing it again.");
     627           0 :     return;
     628             :   }
     629             : 
     630           2 :   AliCodeTimerAutoClass(Form("hvMap=%p",&hvMap),0);
     631             : 
     632           2 :   TIter next(&hvMap);
     633             :   TObjString* hvChannelName;
     634             : 
     635           2 :   TMap newmap;
     636           2 :   newmap.SetOwnerKeyValue(kTRUE,kFALSE);
     637             : 
     638        4732 :   while ( ( hvChannelName = static_cast<TObjString*>(next()) ) )
     639             :   {
     640        1576 :     TString name(hvChannelName->String());
     641        1576 :     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        3152 :     if ( name.Contains("Chamber00Left") )
     647             :     {
     648          26 :       if (name.Contains("Quad1Sect0")) AddToMap(hvMap,newmap,name,"Quad1Sect0","Quad2Sect0"); // channel 0 of Board00 (alidcscae020)
     649             : 
     650          26 :       if (name.Contains("Quad1Sect1")) AddToMap(hvMap,newmap,name,"Quad1Sect1","Quad2Sect1"); // channel 1
     651          26 :       if (name.Contains("Quad1Sect2")) AddToMap(hvMap,newmap,name,"Quad1Sect2","Quad2Sect2"); // channel 2
     652             : 
     653          26 :       if (name.Contains("Quad2Sect2")) AddToMap(hvMap,newmap,name,"Quad2Sect2","Quad1Sect0"); // channel 3
     654          26 :       if (name.Contains("Quad2Sect1")) AddToMap(hvMap,newmap,name,"Quad2Sect1","Quad1Sect1"); // channel 4
     655          26 :       if (name.Contains("Quad2Sect0")) AddToMap(hvMap,newmap,name,"Quad2Sect0","Quad1Sect2"); // channel 5
     656             :     }
     657        3128 :     else if ( name.Contains("Chamber01Left"))
     658             :     {
     659          26 :       if (name.Contains("Quad2Sect2")) AddToMap(hvMap,newmap,name,"Quad2Sect2","Quad2Sect0"); // channel 9 of Board00 (alidcscae020)
     660          26 :       if (name.Contains("Quad2Sect0")) AddToMap(hvMap,newmap,name,"Quad2Sect0","Quad2Sect2"); // channel 11
     661             :     }
     662             :     else
     663             :     {
     664        4656 :       AddToMap(hvMap,newmap,name,name,name);
     665             :     }
     666        1576 :   }
     667             : 
     668             :   // copy newmap to hvMap
     669             : 
     670           2 :   TIter nextNewMap(&newmap);
     671        4708 :   while ( ( hvChannelName = static_cast<TObjString*>(nextNewMap()) ) )
     672             :   {
     673        4704 :     TPair* oldPair = static_cast<TPair*>(hvMap.FindObject(hvChannelName->String().Data()));
     674        4704 :     TPair* newPair = static_cast<TPair*>(newmap.FindObject(hvChannelName->String().Data()));
     675             : 
     676        1568 :     TObjArray* newValues = static_cast<TObjArray*>(newPair->Value());
     677             : 
     678        1568 :     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           4 :   hvMap.SetUniqueID( hvMap.GetUniqueID() | PatchHVDCSAliasesSt1WasAppliedMask() );
     685           4 : }
     686             : 
     687             : //_____________________________________________________________________________
     688             : TMap*
     689             : AliMUONCalibrationData::CreateHV(Int_t runNumber,
     690             :                                  Int_t* startOfValidity,
     691             :                                  Bool_t patched,
     692             :                                  TList* messages,
     693             :                                  Bool_t dryRun)
     694             : {
     695             :   /// Create a new HV map from the OCDB for a given run
     696             :   ///
     697             :   /// dryRun is only usefull with patched=kTRUE and non-empty messages) :
     698             :   /// it allow to get the list of messages without altering the values at all
     699             :   /// (A patch without a patch, so to speak...)
     700             :   ///
     701             : 
     702           6 :   TMap* hvMap = dynamic_cast<TMap*>(CreateObject(runNumber,"MUON/Calib/HV",startOfValidity));
     703             : 
     704           2 :   if (!hvMap) return 0x0;
     705             : 
     706           2 :   AliCodeTimerAutoClass(Form("hvMap=%p",hvMap),0);
     707             : 
     708           2 :   PatchSt1DCSAliases(*hvMap);
     709             : 
     710           2 :   if (patched)
     711             :   {
     712           4 :     if ( ( hvMap->GetUniqueID() & PatchHVAllWasAppliedMask() ) == PatchHVAllWasAppliedMask() )
     713             :     {
     714             :       // patch already applied on this object, don't do it again
     715           0 :       AliWarningClass("Patching already done for HV channels on this map. Not doing it again.");
     716           0 :       return hvMap;
     717             :     }
     718             : 
     719           2 :     TIter next(hvMap);
     720             :     TObjString* hvChannelName;
     721             : 
     722        3158 :     while ( ( hvChannelName = static_cast<TObjString*>(next()) ) )
     723             :     {
     724        1576 :       TString name(hvChannelName->String());
     725             : 
     726        4352 :       if ( name.Contains("sw") ) continue; // skip switches
     727             : 
     728         752 :       if ( name.Contains("iMon") ) continue; // skip HV currents
     729             : 
     730        1128 :       TPair* hvPair = static_cast<TPair*>(hvMap->FindObject(name.Data()));
     731         376 :       TObjArray* values = static_cast<TObjArray*>(hvPair->Value());
     732         376 :       if (!values)
     733             :       {
     734           0 :         AliErrorClass(Form("Could not get values for alias %s",name.Data()));
     735             :       }
     736             :       else
     737             :       {
     738         376 :         TString msg;
     739             : 
     740        2256 :         AliDebugClass(1,Form("channel %s",name.Data()));
     741         752 :         Bool_t ok = PatchHVValues(*values,&msg,dryRun);
     742             : 
     743         376 :         if ( messages )
     744             :         {
     745           0 :           messages->Add(new TObjString(Form("%s %s",hvChannelName->String().Data(),msg.Data())));
     746             :         }
     747             : 
     748         376 :         if (!ok)
     749             :         {
     750           0 :           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         376 :       }
     755        1952 :     }
     756             : 
     757           4 :     hvMap->SetUniqueID(hvMap->GetUniqueID() | PatchHVAllWasAppliedMask());
     758           2 :   }
     759             : 
     760           2 :   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           0 :     TIter next(messages);
     764             :     TObjString* msg;
     765           0 :     char hvCase('u');
     766             : 
     767           0 :     while ( ( msg = static_cast<TObjString*>(next()) ) )
     768             :     {
     769           0 :       Int_t i = msg->String().Index("CASE",strlen("CASE"),0,TString::kExact);
     770             : 
     771           0 :       if ( i >= 0 )
     772             :       {
     773           0 :         sscanf(msg->String()(i,msg->String().Length()-i).Data(),"CASE:%10c",&hvCase);
     774             :       }
     775             : 
     776           0 :       switch (hvCase)
     777             :       {
     778           0 :         case 'A': ++a; break;
     779           0 :         case 'B': ++b; break;
     780           0 :         case 'C': ++c; break;
     781           0 :         case 'D': ++d; break;
     782           0 :         case 'E': ++e; break;
     783           0 :         case 'F': ++f; break;
     784           0 :         case 'G': ++g; break;
     785           0 :         case 'H': ++h; break;
     786           0 :         case 'Z': ++z; break;
     787           0 :         default: ++u; break;
     788             :       }
     789             :     }
     790             : 
     791           0 :     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           0 :   }
     794             : 
     795           2 :   return hvMap;
     796           4 : }
     797             : 
     798             : //_____________________________________________________________________________
     799             : TMap*
     800             : AliMUONCalibrationData::CreateLV(Int_t runNumber, Int_t* startOfValidity)
     801             : {
     802             :   /// Create a new MCH LV map from the OCDB for a given run
     803           0 :   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             : {
     810             :   /// Create a new Trigger HV and curent map from the OCDB for a given run
     811           0 :   return dynamic_cast<TMap*>(CreateObject(runNumber,"MUON/Calib/TriggerDCS",startOfValidity));
     812             : }
     813             : 
     814             : //_____________________________________________________________________________
     815             : AliMUONVStore*
     816             : AliMUONCalibrationData::CreateLocalTriggerBoardMasks(Int_t runNumber, Int_t* startOfValidity)
     817             : {
     818             :   /// Get the internal store for LocalTriggerBoardMasks from OCDB
     819             : 
     820          12 :   return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/LocalTriggerBoardMasks",startOfValidity));
     821             : }
     822             : 
     823             : //_____________________________________________________________________________
     824             : AliMUONVStore*
     825             : AliMUONCalibrationData::CreateNeighbours(Int_t runNumber, Int_t* startOfValidity)
     826             : {
     827             :   /// Create a neighbour store from the OCDB for a given run
     828           8 :   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             : {
     835             :   /// Access the CDB for a given path (e.g. MUON/Calib/Pedestals),
     836             :   /// and return the corresponding TObject.
     837             : 
     838          52 :   AliCodeTimerAutoClass(Form("%09d : %s",runNumber,path),0);
     839             : 
     840          26 :   AliCDBManager* man = AliCDBManager::Instance();
     841             : 
     842          78 :   AliCDBEntry* entry =  man->Get(path,runNumber);
     843             : 
     844          52 :   if (entry)
     845             :   {
     846          52 :                 if ( startOfValidity ) *startOfValidity = entry->GetId().GetFirstRun();
     847             : 
     848          26 :     TObject* object = entry->GetObject();
     849          26 :     if (!(man->GetCacheFlag()))
     850             :     {
     851           0 :       entry->SetOwner(kFALSE);
     852           0 :       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           0 :                 if ( startOfValidity )  *startOfValidity = AliCDBRunRange::Infinity();
     863             :   }
     864             : 
     865             :   {
     866             : 
     867           0 :     AliCodeTimerAutoClass(Form("Failed to get %s for run %09d",path,runNumber),1);
     868             : 
     869           0 :   }
     870             : 
     871           0 :   return 0x0;
     872          26 : }
     873             : 
     874             : //_____________________________________________________________________________
     875             : AliMUONVStore*
     876             : AliMUONCalibrationData::CreateOccupancyMap(Int_t runNumber, Int_t* startOfValidity)
     877             : {
     878             :   /// Create a new occupancy map store from the OCDB for a given run
     879           8 :   return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/OccupancyMap",startOfValidity));
     880             : }
     881             : 
     882             : //_____________________________________________________________________________
     883             : AliMUONRejectList*
     884             : AliMUONCalibrationData::CreateRejectList(Int_t runNumber, Int_t* startOfValidity)
     885             : {
     886             :   /// Create a new rejectlist store from the OCDB for a given run
     887           8 :   return dynamic_cast<AliMUONRejectList*>(CreateObject(runNumber,"MUON/Calib/RejectList",startOfValidity));
     888             : }
     889             : 
     890             : //_____________________________________________________________________________
     891             : AliMUONVStore*
     892             : AliMUONCalibrationData::CreatePedestals(Int_t runNumber, Int_t* startOfValidity)
     893             : {
     894             :   /// Create a new pedestal store from the OCDB for a given run
     895          12 :   return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Pedestals",startOfValidity));
     896             : }
     897             : 
     898             : //_____________________________________________________________________________
     899             : AliMUONVStore*
     900             : AliMUONCalibrationData::CreateConfig(Int_t runNumber, Int_t* startOfValidity)
     901             : {
     902             :   /// Create a new config store from the OCDB for a given run
     903           8 :   return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Config",startOfValidity));
     904             : }
     905             : 
     906             : 
     907             : //_____________________________________________________________________________
     908             : AliMUONRegionalTriggerConfig*
     909             : AliMUONCalibrationData::CreateRegionalTriggerConfig(Int_t runNumber, Int_t* startOfValidity)
     910             : {
     911             :   /// Create the internal store for RegionalTriggerConfig from OCDB
     912             : 
     913          12 :   return dynamic_cast<AliMUONRegionalTriggerConfig*>(CreateObject(runNumber,"MUON/Calib/RegionalTriggerConfig",startOfValidity));
     914             : }
     915             : 
     916             : //_____________________________________________________________________________
     917             : AliMUONTriggerEfficiencyCells*
     918             : AliMUONCalibrationData::CreateTriggerEfficiency(Int_t runNumber, Int_t* startOfValidity)
     919             : {
     920             :   /// Create trigger efficiency object from OCBD
     921             : 
     922           4 :   return dynamic_cast<AliMUONTriggerEfficiencyCells*>(CreateObject(runNumber,"MUON/Calib/TriggerEfficiency",startOfValidity));
     923             : }
     924             : 
     925             : //_____________________________________________________________________________
     926             : AliMUONTriggerLut*
     927             : AliMUONCalibrationData::CreateTriggerLut(Int_t runNumber, Int_t* startOfValidity)
     928             : {
     929             :   /// Create trigger LUT from OCDB
     930             : 
     931          12 :   return dynamic_cast<AliMUONTriggerLut*>(CreateObject(runNumber,"MUON/Calib/TriggerLut",startOfValidity));
     932             : }
     933             : //_____________________________________________________________________________
     934             : AliMUONGlobalCrateConfig*
     935             : AliMUONCalibrationData::GlobalTriggerCrateConfig() const
     936             : {
     937             :   /// Return the config for the global trigger board.
     938             : 
     939          12 :   if (!fGlobalTriggerCrateConfig)
     940             :   {
     941           3 :     fGlobalTriggerCrateConfig = CreateGlobalTriggerCrateConfig(fRunNumber);
     942           3 :   }
     943           6 :   return fGlobalTriggerCrateConfig;
     944             : }
     945             : 
     946             : 
     947             : //_____________________________________________________________________________
     948             : TMap*
     949             : AliMUONCalibrationData::HV(Bool_t patched) const
     950             : {
     951             :   /// Return the calibration for a given (detElemId, manuId) pair
     952             : 
     953        1302 :   if (!fHV)
     954             :   {
     955           2 :     fHV = CreateHV(fRunNumber,0,patched);
     956           2 :   }
     957        1302 :   return fHV;
     958             : }
     959             : 
     960             : //_____________________________________________________________________________
     961             : TMap*
     962             : AliMUONCalibrationData::LV() const
     963             : {
     964             :   /// Return the LV map for a given (detElemId, manuId) pair
     965             : 
     966           0 :   if (!fLV && RunNumber() > 250127)
     967             :   {
     968             :     /// LV object was only introduced at the beginning of 2016 (march ...), so we
     969             :     /// can not require it for runs before that...
     970           0 :     fLV = CreateLV(fRunNumber);
     971           0 :   }
     972           0 :   return fLV;
     973             : }
     974             : 
     975             : //_____________________________________________________________________________
     976             : TMap*
     977             : AliMUONCalibrationData::TriggerDCS() const
     978             : {
     979             :   /// Return the calibration for a given (detElemId, manuId) pair
     980             : 
     981           0 :   if (!fTriggerDCS)
     982             :   {
     983           0 :     fTriggerDCS = CreateTriggerDCS(fRunNumber);
     984           0 :   }
     985           0 :   return fTriggerDCS;
     986             : }
     987             : 
     988             : //_____________________________________________________________________________
     989             : AliMUONVStore*
     990             : AliMUONCalibrationData::Neighbours() const
     991             : {
     992             :   /// Create (if needed) and return the internal store for neighbours.
     993         848 :   if (!fNeighbours)
     994             :   {
     995           2 :     fNeighbours = CreateNeighbours(fRunNumber);
     996           2 :   }
     997         424 :   return fNeighbours;
     998             : }
     999             : 
    1000             : //_____________________________________________________________________________
    1001             : AliMUONVCalibParam*
    1002             : AliMUONCalibrationData::LocalTriggerBoardMasks(Int_t localBoardNumber) const
    1003             : {
    1004             : /// Return the masks for a given trigger local board.
    1005             : 
    1006        2904 :   if (!fLocalTriggerBoardMasks)
    1007             :   {
    1008           3 :     fLocalTriggerBoardMasks = CreateLocalTriggerBoardMasks(fRunNumber);
    1009           3 :   }
    1010             : 
    1011        1452 :   if ( fLocalTriggerBoardMasks )
    1012             :   {
    1013             :     AliMUONVCalibParam* ltbm =
    1014        1452 :       static_cast<AliMUONVCalibParam*>(fLocalTriggerBoardMasks->FindObject(localBoardNumber));
    1015        1452 :     if (!ltbm)
    1016             :     {
    1017           0 :       AliError(Form("Could not get mask for localBoardNumber=%d",localBoardNumber));
    1018           0 :     }
    1019             :     return ltbm;
    1020             :   }
    1021           0 :   return 0x0;
    1022        1452 : }
    1023             : 
    1024             : //_____________________________________________________________________________
    1025             : AliMUONVStore*
    1026             : AliMUONCalibrationData::OccupancyMap() const
    1027             : {
    1028             :   /// Get occupancy map
    1029           8 :   if (!fOccupancyMap)
    1030             :   {
    1031           2 :     fOccupancyMap = CreateOccupancyMap(fRunNumber);
    1032           2 :   }
    1033           4 :   return fOccupancyMap;
    1034             : }
    1035             : 
    1036             : //_____________________________________________________________________________
    1037             : AliMUONRejectList*
    1038             : AliMUONCalibrationData::RejectList() const
    1039             : {
    1040             :   /// Get reject list
    1041           4 :   if (!fRejectList)
    1042             :   {
    1043           2 :     fRejectList = CreateRejectList(fRunNumber);
    1044           2 :   }
    1045           2 :   return fRejectList;
    1046             : }
    1047             : 
    1048             : //_____________________________________________________________________________
    1049             : void
    1050             : AliMUONCalibrationData::BypassStores(AliMUONVStore* ped)
    1051             : {
    1052             :   /// Force the use of those pedestals
    1053           0 :   fgBypassPedestals = ped;
    1054             : 
    1055           0 : }
    1056             : 
    1057             : //_____________________________________________________________________________
    1058             : AliMUONVStore*
    1059             : AliMUONCalibrationData::Pedestals() const
    1060             : {
    1061             :   /// Return pedestals
    1062             : 
    1063        1728 :   if (fgBypassPedestals) return fgBypassPedestals;
    1064             : 
    1065         864 :   if (!fPedestals)
    1066             :   {
    1067           3 :     fPedestals = CreatePedestals(fRunNumber);
    1068           3 :   }
    1069         864 :   return fPedestals;
    1070         864 : }
    1071             : 
    1072             : //_____________________________________________________________________________
    1073             : AliMUONVStore*
    1074             : AliMUONCalibrationData::Config() const
    1075             : {
    1076             :   /// Return config
    1077             : 
    1078           4 :   if (!fConfig)
    1079             :   {
    1080           2 :     fConfig = CreateConfig(fRunNumber);
    1081           2 :   }
    1082           2 :   return fConfig;
    1083             : }
    1084             : 
    1085             : //_____________________________________________________________________________
    1086             : AliMUONVCalibParam*
    1087             : AliMUONCalibrationData::Pedestals(Int_t detElemId, Int_t manuId) const
    1088             : {
    1089             :   /// Return the pedestals for a given (detElemId, manuId) pair.
    1090             :   /// A return value of 0x0 is considered an error, meaning we should get
    1091             :   /// pedestals for all channels.
    1092             : 
    1093        1714 :   AliMUONVStore* pedestals = Pedestals();
    1094         857 :   if (!pedestals)
    1095             :   {
    1096           0 :     return 0x0;
    1097             :   }
    1098             : 
    1099         857 :   return static_cast<AliMUONVCalibParam*>(pedestals->FindObject(detElemId,manuId));
    1100         857 : }
    1101             : 
    1102             : //_____________________________________________________________________________
    1103             : void
    1104             : AliMUONCalibrationData::Print(Option_t*) const
    1105             : {
    1106             :   /// A very basic dump of our guts.
    1107             : 
    1108           0 :   cout << "RunNumber " << RunNumber()
    1109           0 :   << " fPedestals=" << fPedestals
    1110           0 :   << " fConfig=" << fConfig
    1111           0 :   << " fHV=" << fHV
    1112           0 :   << " fLV=" << fLV
    1113           0 :   << " fTriggerDCS=" << fTriggerDCS
    1114           0 :   << " fLocalTriggerBoardMasks=" << fLocalTriggerBoardMasks
    1115           0 :   << " fRegionalTriggerConfig=" << fRegionalTriggerConfig
    1116           0 :   << " fGlobalTriggerCrateConfig=" << fGlobalTriggerCrateConfig
    1117           0 :   << " fTriggerLut=" << fTriggerLut
    1118           0 :   << endl;
    1119           0 : }
    1120             : 
    1121             : 
    1122             : //_____________________________________________________________________________
    1123             : AliMUONRegionalTriggerConfig*
    1124             : AliMUONCalibrationData::RegionalTriggerConfig() const
    1125             : {
    1126             :   /// Return the config for the regional trigger board.
    1127             : 
    1128          24 :   if (!fRegionalTriggerConfig)
    1129             :   {
    1130           3 :     fRegionalTriggerConfig = CreateRegionalTriggerConfig(fRunNumber);
    1131           3 :     }
    1132          12 :   return fRegionalTriggerConfig;
    1133             : }
    1134             : 
    1135             : 
    1136             : //_____________________________________________________________________________
    1137             : AliMUONTriggerEfficiencyCells*
    1138             : AliMUONCalibrationData::TriggerEfficiency() const
    1139             : {
    1140             : /// Return the trigger efficiency.
    1141             : 
    1142           2 :   if (!fTriggerEfficiency)
    1143             :   {
    1144           1 :     fTriggerEfficiency = CreateTriggerEfficiency(fRunNumber);
    1145           1 :   }
    1146           1 :   return fTriggerEfficiency;
    1147             : }
    1148             : 
    1149             : 
    1150             : //_____________________________________________________________________________
    1151             : AliMUONTriggerLut*
    1152             : AliMUONCalibrationData::TriggerLut() const
    1153             : {
    1154             : /// Return the trigger look up table.
    1155             : 
    1156          12 :   if (!fTriggerLut)
    1157             :   {
    1158           3 :     fTriggerLut = CreateTriggerLut(fRunNumber);
    1159           3 :   }
    1160           6 :   return fTriggerLut;
    1161             : }
    1162             : 
    1163             : //_____________________________________________________________________________
    1164             : void
    1165             : AliMUONCalibrationData::Reset()
    1166             : {
    1167             : /// Reset all data
    1168             : 
    1169           0 :   AliCodeTimerAuto("",0);
    1170             : 
    1171           0 :   delete fConfig;
    1172           0 :   fConfig = 0x0;
    1173           0 :   delete fPedestals;
    1174           0 :   fPedestals = 0x0;
    1175           0 :   delete fHV;
    1176           0 :   fHV = 0x0;
    1177           0 :   delete fLV;
    1178           0 :   fLV = 0x0;
    1179           0 :   delete fTriggerDCS;
    1180           0 :   fTriggerDCS = 0x0;
    1181           0 :   delete fLocalTriggerBoardMasks;
    1182           0 :   fLocalTriggerBoardMasks = 0x0;
    1183           0 :   delete fRegionalTriggerConfig;
    1184           0 :   fRegionalTriggerConfig = 0x0;
    1185           0 :   delete fGlobalTriggerCrateConfig;
    1186           0 :   fGlobalTriggerCrateConfig = 0x0;
    1187             : 
    1188           0 :   delete fTriggerLut;
    1189           0 :   fTriggerLut = 0x0;
    1190           0 :   delete fTriggerEfficiency;
    1191           0 :   fTriggerEfficiency = 0x0;
    1192           0 :   delete fNeighbours;
    1193           0 :   fNeighbours = 0x0;
    1194           0 : }
    1195             : 
    1196             : //_____________________________________________________________________________
    1197             : void
    1198             : AliMUONCalibrationData::Check(Int_t runNumber)
    1199             : {
    1200             :   /// Self-check to see if we can read all data for a given run
    1201             :   /// from the current OCDB...
    1202             : 
    1203           0 :   if ( ! CreateGlobalTriggerCrateConfig(runNumber) )
    1204             :   {
    1205           0 :     AliErrorClass("Could not read Trigger Crate Config");
    1206           0 :   }
    1207             :   else
    1208             :   {
    1209           0 :     AliInfoClass("TriggerBoardMasks read OK");
    1210             :   }
    1211             : 
    1212           0 :   if ( !  CreateHV(runNumber) )
    1213             :   {
    1214           0 :     AliErrorClass("Could not read HV");
    1215           0 :   }
    1216             :   else
    1217             :   {
    1218           0 :     AliInfoClass("HV read OK");
    1219             :   }
    1220             : 
    1221           0 :   if ( !  CreateLV(runNumber) )
    1222             :   {
    1223           0 :     AliErrorClass("Could not read LV");
    1224           0 :   }
    1225             :   else
    1226             :   {
    1227           0 :     AliInfoClass("LV read OK");
    1228             :   }
    1229             : 
    1230           0 :   if ( !  CreateTriggerDCS(runNumber) )
    1231             :   {
    1232           0 :     AliErrorClass("Could not read Trigger HV and Currents");
    1233           0 :   }
    1234             :   else
    1235             :   {
    1236           0 :     AliInfoClass("Trigger HV and Currents read OK");
    1237             :   }
    1238             : 
    1239           0 :   if ( ! CreateNeighbours(runNumber) )
    1240             :   {
    1241           0 :     AliErrorClass("Could not read Neighbours");
    1242           0 :   }
    1243             :   else
    1244             :   {
    1245           0 :     AliInfoClass("Neighbours read OK");
    1246             :   }
    1247             : 
    1248           0 :   if ( !  CreateLocalTriggerBoardMasks(runNumber) )
    1249             :   {
    1250           0 :     AliErrorClass("Could not read LocalTriggerBoardMasks");
    1251           0 :   }
    1252             :   else
    1253             :   {
    1254           0 :     AliInfoClass("LocalTriggerBoardMasks read OK");
    1255             :   }
    1256             : 
    1257           0 :   if ( ! CreatePedestals(runNumber) )
    1258             :   {
    1259           0 :     AliErrorClass("Could not read pedestals");
    1260           0 :   }
    1261             :   else
    1262             :   {
    1263           0 :     AliInfoClass("Pedestals read OK");
    1264             :   }
    1265             : 
    1266           0 :   if ( ! CreateConfig(runNumber) )
    1267             :   {
    1268           0 :     AliErrorClass("Could not read config");
    1269           0 :   }
    1270             :   else
    1271             :   {
    1272           0 :     AliInfoClass("Config read OK");
    1273             :   }
    1274             : 
    1275           0 :   if ( ! CreateRegionalTriggerConfig(runNumber) )
    1276             :   {
    1277           0 :     AliErrorClass("Could not read RegionalTriggerConfig");
    1278           0 :   }
    1279             :   else
    1280             :   {
    1281           0 :     AliInfoClass("RegionalTriggerBoardMasks read OK");
    1282             :   }
    1283             : 
    1284           0 :   if ( ! CreateTriggerLut(runNumber) )
    1285             :   {
    1286           0 :     AliErrorClass("Could not read TriggerLut");
    1287           0 :   }
    1288             :   else
    1289             :   {
    1290           0 :     AliInfoClass("TriggerLut read OK");
    1291             :   }
    1292             : 
    1293           0 :   if ( ! CreateTriggerEfficiency(runNumber) )
    1294             :   {
    1295           0 :     AliErrorClass("Could not read TriggerEfficiency");
    1296           0 :   }
    1297             :   else
    1298             :   {
    1299           0 :     AliInfoClass("TriggerEfficiency read OK");
    1300             :   }
    1301           0 : }

Generated by: LCOV version 1.11