1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
16 // $Id: AliMUONCalibrationData.cxx 59486 2012-11-07 22:06:24Z laphecet $
18 #include "AliMUONCalibrationData.h"
20 #include "AliCDBEntry.h"
21 #include "AliCDBManager.h"
22 #include "AliCodeTimer.h"
23 #include "AliDCSValue.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"
36 #include <Riostream.h>
41 //-----------------------------------------------------------------------------
42 /// \class AliMUONCalibrationData
44 /// For the moment, this class stores pedestals, gains, hv (for tracker)
45 /// and lut, masks and efficiencies (for trigger) that are fetched from the CDB.
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.
51 /// It acts as a "facade" to a bunch of underlying
52 /// containers/calibration classes.
54 /// \author Laurent Aphecetche
55 //-----------------------------------------------------------------------------
60 ClassImp(AliMUONCalibrationData)
63 AliMUONVStore* AliMUONCalibrationData::fgBypassPedestals(0x0);
64 AliMUONVStore* AliMUONCalibrationData::fgBypassGains(0x0);
66 UInt_t AliMUONCalibrationData::fgkDCSSt1Flag(42);
70 void MarkForDeletion(Int_t* indices, Int_t first, Int_t last)
72 for ( Int_t i = first; i <= last; ++i )
79 //_____________________________________________________________________________
80 AliMUONCalibrationData::AliMUONCalibrationData(Int_t runNumber,
81 Bool_t deferredInitialization)
84 fRunNumber(runNumber),
89 fLocalTriggerBoardMasks(0x0),
90 fRegionalTriggerConfig(0x0),
91 fGlobalTriggerCrateConfig(0x0),
93 fTriggerEfficiency(0x0),
102 // If deferredInitialization is false, we read *all* calibrations
104 // So when using this class to access only one kind of calibrations (e.g.
105 // only pedestals), you should put deferredInitialization to kTRUE, which
106 // will instruct this object to fetch the data only when neeeded.
108 if ( deferredInitialization == kFALSE )
116 LocalTriggerBoardMasks(0);
117 RegionalTriggerConfig();
118 GlobalTriggerCrateConfig();
127 //_____________________________________________________________________________
128 AliMUONCalibrationData::~AliMUONCalibrationData()
130 /// Destructor. Note that we're the owner of our pointers if the OCDB cache
131 /// is not set. Otherwise the cache is supposed to take care of them...
132 if (!(AliCDBManager::Instance()->GetCacheFlag())) Reset();
135 //_____________________________________________________________________________
137 AliMUONCalibrationData::Capacitances() const
139 /// Create (if needed) and return the internal store for capacitances.
143 fCapacitances = CreateCapacitances(fRunNumber);
145 return fCapacitances;
148 //_____________________________________________________________________________
150 AliMUONCalibrationData::CreateCapacitances(Int_t runNumber, Int_t* startOfValidity)
152 /// Create capa store from OCDB for a given run
154 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Capacitances",startOfValidity));
157 //_____________________________________________________________________________
159 AliMUONCalibrationData::CreateGains(Int_t runNumber, Int_t* startOfValidity)
161 /// Create a new gain store from the OCDB for a given run
162 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Gains",startOfValidity));
165 //_____________________________________________________________________________
166 AliMUONGlobalCrateConfig*
167 AliMUONCalibrationData::CreateGlobalTriggerCrateConfig(Int_t runNumber, Int_t* startOfValidity)
169 /// Create the internal store for GlobalTriggerCrateConfig from OCDB
171 return dynamic_cast<AliMUONGlobalCrateConfig*>(CreateObject(runNumber,"MUON/Calib/GlobalTriggerCrateConfig",startOfValidity));
175 //______________________________________________________________________________
176 Bool_t AliMUONCalibrationData::CheckHVGroup(TObjArray& values, Int_t first, Int_t last, Double_t& value, Int_t& slope, TString* msg)
178 // Get the HV of the values between first and last indices
179 // return the HV slope (in Volt per second) and a message
180 // Return kFALSE if we must discard the group
185 if ( last < first ) return kFALSE;
186 if ( last - first < 2 ) return kFALSE;
191 Float_t HVSAME(1); // 1 volts
193 AliDCSValue* vfirst = static_cast<AliDCSValue*>(values.UncheckedAt(first));
194 AliDCSValue* vlast = static_cast<AliDCSValue*>(values.UncheckedAt(last));
196 Int_t deltaHV = TMath::Nint(TMath::Abs(vfirst->GetFloat()-vlast->GetFloat()));
198 if ( deltaHV < HVSAME ) return kFALSE;
200 for ( Int_t i = first; i <= last; ++i )
202 AliDCSValue* v = static_cast<AliDCSValue*>(values.UncheckedAt(i));
204 Double_t y = v->GetFloat() - vfirst->GetFloat();
205 Double_t x = v->GetTimeStamp() - vfirst->GetTimeStamp();
212 slope = value > 0 ? 1 : -1;
213 value = TMath::Abs(value);
215 UInt_t deltaTime = vlast->GetTimeStamp() - vfirst->GetTimeStamp();
219 if (slope>0) (*msg) = Form("RU%d[%d:%d](%d)",TMath::Nint(value),first,last,deltaTime);
220 if (slope<0) (*msg) = Form("RD%d[%d:%d](%d)",TMath::Nint(value),first,last,deltaTime);
222 if ( TMath::Nint(value) == 0 )
224 // this is to protect for the few cases
225 // (see e.g. MchHvLvLeft/Chamber00Left/Quad2Sect0.actual.vMon in run 134497)
226 // where we can have *lots* of values (2483 in this example) but that
227 // are more or less constant...
229 // or simply to remove small ramps
232 value = (vfirst->GetFloat()+vlast->GetFloat())/2.0;
233 *msg = Form("FLUCT%d[%d:%d]",TMath::Nint(value),first,last);
240 //______________________________________________________________________________
241 Bool_t AliMUONCalibrationData::PatchHVValues(TObjArray& values,
245 /// We do here a little bit of massaging of the HV values, if needed.
247 /// The main point is to "gather" values that are within a given small amount
248 /// of time (typically 60 seconds) and infer a slope from those values
249 /// slope > 0 means it is a ramp-up, slope < 0 that's a ramp-down
251 /// This is to avoid both the "ramp-down-before-end-of-run" and the
252 /// "ramp-up-after-start-of-run" syndroms...
254 /// Use dryRun = kTRUE to fill the messages *without* altering the values
256 /// Return kFALSE is the kind of HV (trouble) case we have here
257 /// has not been identified...
260 UInt_t DELTATIME(60); // in seconds
261 Int_t IENDRU(60); // in seconds
263 // Start by finding groups of values which are not separated (each) by more than
266 Bool_t gather(kFALSE);
270 groups.SetOwner(kTRUE);
272 for ( Int_t i = values.GetLast(); i > 0; --i )
274 AliDCSValue* vi = static_cast<AliDCSValue*>(values.UncheckedAt(i));
275 AliDCSValue* vj = static_cast<AliDCSValue*>(values.UncheckedAt(i-1));
277 if ( vi->GetTimeStamp() - vj->GetTimeStamp() < DELTATIME )
292 groups.Add(new AliMpIntPair(ilast,ifirst));
300 groups.Add(new AliMpIntPair(0,ifirst));
303 TIter nextGroup(&groups,kIterBackward);
311 Int_t nEndAndShortRU(0);
316 trips.SetOwner(kTRUE);
318 while ( ( p = static_cast<AliMpIntPair*>(nextGroup()) ) )
325 AliDebugClass(1,Form("group %d:%d",p->GetFirst(),p->GetSecond()));
327 Bool_t ok = CheckHVGroup(values,p->GetFirst(),p->GetSecond(),value,slope,&groupMsg);
335 if ( p->GetFirst() == 0 )
337 // start with a ramp-up
340 else if ( p->GetSecond() == values.GetLast() && TMath::Nint(value) < IENDRU )
346 // ramp-up in the middle of nowhere...
350 else if ( slope < 0 )
352 if ( p->GetSecond() == values.GetLast() )
354 // end with a ramp-down
359 // ramp-down in the middle of nowhere
363 AliDCSValue* d = static_cast<AliDCSValue*>(values.At(p->GetSecond()));
365 if ( d->GetFloat() < AliMpDCSNamer::TrackerHVOFF() )
368 AliDCSValue* tripStart = static_cast<AliDCSValue*>(values.At(p->GetFirst()));
369 trips.Add(new AliMpIntPair(tripStart->GetTimeStamp(),TMath::Nint(tripStart->GetFloat())));
377 internalMsg += groupMsg;
383 Once we have "decoded" the groups we try to find out which of
384 the following cases we're facing :
386 case A = -------- = OK(1)
390 \ = OK, once we have removed the ramp-down (2)
394 / = OK, once we have removed the ramp-up (3)
398 / \ = OK, once we have removed the ramp-down (2) and the ramp-up (3)
402 \____ = TRIP = BAD (here the ramp-down slope should be bigger than in case C)
405 \ ----- = BAD (trip + ramp-up at end of run)
408 case G = fluctuations (within a range defined in CheckHVGroup...)
412 / = ramp-up right at the end-of-run = OK (4)
415 (1) OK means the group is identified correctly, still the value can be below ready...
416 (2) ramp-down values will be removed if the ramp is indeed the last values in the serie
417 i.e. it's really an end-of-run problem (otherwise it's not case B)
418 (3) ramp-up values will be removed if the ramp is indeed the first values in the serie
419 i.e. it's really a start-of-run problem (otherwise it's not case C)
420 (4) OK if short enough...
422 Any other case is unknown and we'll :
424 b) assume the channel is OFF.
429 AliDebugClass(1,Form("msg=%s ngroupds=%d",internalMsg.Data(),ngroups));
430 AliDebugClass(1,Form("nRU %d nRD %d nStartRU %d nEndRD %d nTripRD %d nFluct %d",
431 nRU,nRD,nStartRU,nEndRD,nTripRD,nFluct));
433 TString hvCase("OTHER");
434 int dummy(0),a(-1),b(-1);
436 Int_t nvalues = values.GetSize();
437 Int_t* indices = new Int_t[nvalues];
438 memset(indices,0,nvalues*sizeof(Int_t));
440 AliDCSValue* vfirst = static_cast<AliDCSValue*>(values.UncheckedAt(0));
441 AliDCSValue* vlast = static_cast<AliDCSValue*>(values.UncheckedAt(values.GetLast()));
443 UInt_t meanTimeStamp = ( vfirst->GetTimeStamp() + vlast->GetTimeStamp() ) / 2;
449 else if ( nTripRD > 0 )
451 const Double_t HVLOWTRIP(600); // a trip below this value is considered a "low trip"
452 // i.e. one starting for a non-operational voltage
454 internalMsg += Form("NT:%d ",nTripRD);
456 if ( nRU > 0 && nRD > 0 )
465 for ( Int_t iTrip = 0; iTrip <= trips.GetLast(); ++iTrip )
467 AliMpIntPair* tripPair = static_cast<AliMpIntPair*>(trips.At(iTrip));
468 TString tripType("TRIP");
469 if ( tripPair->GetSecond() < HVLOWTRIP)
471 tripType = "LOWTRIP";
474 internalMsg += Form("%s SV:%d TS:%d ",tripType.Data(),tripPair->GetSecond(),tripPair->GetFirst());
477 // we put here the TRIP value as SV:value
478 // for cases where there's a drop in voltage but the starting point was
479 // below operational voltage, so strictly speaking it's *not* a trip, but
480 // more a big fluctuation
483 MarkForDeletion(indices,0,values.GetLast());
484 values.Add(new AliDCSValue(static_cast<Float_t>(0),meanTimeStamp));
487 else if ( nStartRU > 0 && nRU == 0 && nRD == 0 && nEndRD == 0 )
492 sscanf(internalMsg.Data(),"RU%10d[%10d:%10d]%80s",&dummy,&a,&b,r);
493 MarkForDeletion(indices,a,b);
496 else if ( nStartRU > 0 && nEndRD > 0 && nRD == 0 && nRU == 0 )
501 sscanf(internalMsg.Data(),"RU%10d[%10d:%10d]%80s",&dummy,&a,&b,r);
502 MarkForDeletion(indices,a,b-1);
503 Int_t i = internalMsg.Index("RD",strlen("RD"),0,TString::kExact);
504 sscanf(internalMsg(i,internalMsg.Length()-i).Data(),
505 "RD%10d[%10d:%10d]%80s",&dummy,&a,&b,r);
506 MarkForDeletion(indices,a+1,b);
509 else if ( nEndRD > 0 && nStartRU == 0 && nRU == 0 && nRD == 0 )
514 Int_t i = internalMsg.Index("RD",strlen("RD"),0,TString::kExact);
515 sscanf(internalMsg(i,internalMsg.Length()-i).Data(),
516 "RD%10d[%10d:%10d]%80s",&dummy,&a,&b,r);
517 MarkForDeletion(indices,a,b);
520 else if ( nFluct > 0 )
525 TObjArray* af = internalMsg.Tokenize(" ");
528 while ( ( str = static_cast<TObjString*>(next()) ) )
530 TString s(str->String());
531 if ( s.BeginsWith("FLUCT") )
533 sscanf(s.Data(),"FLUCT%d[%d:%d]",&dummy,&a,&b);
534 MarkForDeletion(indices,a,b);
540 else if ( nEndAndShortRU > 0 && nStartRU == 0 && nRU == 0 && nRD == 0 && nEndRD == 0 )
545 sscanf(internalMsg.Data(),"RU%10d[%10d:%10d]%80s",&dummy,&a,&b,r);
546 MarkForDeletion(indices,a,b);
552 // here we know it's not a trip, so let's assume everything is OK
553 // if first and last value are in the same ballpark
555 const Double_t HVFLUCT(20); // volts
557 if ( TMath::Abs(vfirst->GetFloat() - vlast->GetFloat()) < HVFLUCT )
563 MarkForDeletion(indices,1,nvalues-1);
569 for ( Int_t i = 0; i < nvalues; ++i )
582 if ( !values.GetEntries() )
584 AliErrorClass(Form("No value left after patch... Check that !!! initial # of values=%d msg=%s",
585 nvalues,internalMsg.Data()));
591 // take the max of the remaining values
592 TIter nextA(&values);
594 Float_t maxval(-9999);
596 while ( ( val = static_cast<AliDCSValue*>(nextA()) ) )
598 if ( val->GetFloat() > maxval )
600 maxval = val->GetFloat();
606 values.Add(new AliDCSValue(maxval,meanTimeStamp));
609 // once the case is inferred, add a "CASE:%10d",hvCase.Data()
611 // so we can them sum up for all channels and get a summary per run...
613 internalMsg += Form("CASE:%s",hvCase.Data());
615 if (msg) *msg = internalMsg.Data();
617 return hvCase=="OTHER" ? kFALSE : kTRUE;
620 //_____________________________________________________________________________
621 void AliMUONCalibrationData::AddToMap(const TMap& sourceMap,
631 newkey.ReplaceAll(source,dest);
633 TPair* pair = static_cast<TPair*>(sourceMap.FindObject(key.Data()));
635 destMap.Add(new TObjString(newkey.Data()),pair->Value());
638 //_____________________________________________________________________________
639 void AliMUONCalibrationData::PatchSt1DCSAliases(TMap& hvMap)
641 /// It was discovered (in sept. 2013) that the DCS aliases for St1 was
642 /// wrongly assigned (in the hardware), so the correspondence between DCS channels
643 /// and actual HV channels is wrong for St1 in the DCS (and thus in the DCS archive,
644 /// and so in the OCDB HV object).
646 /// It affects all the OCDB object written in 2010-2013.
648 /// This method fixes that.
650 if ( hvMap.GetUniqueID() == fgkDCSSt1Flag )
652 // already clean object. Do nothing
657 TObjString* hvChannelName;
660 newmap.SetOwnerKeyValue(kTRUE,kFALSE);
662 while ( ( hvChannelName = static_cast<TObjString*>(next()) ) )
664 TString name(hvChannelName->String());
665 TString newname(name);
667 // the problem is limited to St1 = ch1+ch2 (or, in DCS parlance, ch0+ch1)
668 // do it "by hand" as we "only" have 8 names to change
670 if ( name.Contains("Chamber00Left") )
672 if (name.Contains("Quad1Sect0")) AddToMap(hvMap,newmap,name,"Quad1Sect0","Quad2Sect0"); // channel 0 of Board00 (alidcscae020)
674 if (name.Contains("Quad1Sect1")) AddToMap(hvMap,newmap,name,"Quad1Sect1","Quad2Sect1"); // channel 1
675 if (name.Contains("Quad1Sect2")) AddToMap(hvMap,newmap,name,"Quad1Sect2","Quad2Sect2"); // channel 2
677 if (name.Contains("Quad2Sect2")) AddToMap(hvMap,newmap,name,"Quad2Sect2","Quad1Sect0"); // channel 3
678 if (name.Contains("Quad2Sect1")) AddToMap(hvMap,newmap,name,"Quad2Sect1","Quad1Sect1"); // channel 4
679 if (name.Contains("Quad2Sect0")) AddToMap(hvMap,newmap,name,"Quad2Sect0","Quad1Sect2"); // channel 5
681 else if ( name.Contains("Chamber01Left"))
683 if (name.Contains("Quad2Sect2")) AddToMap(hvMap,newmap,name,"Quad2Sect2","Quad2Sect0"); // channel 9 of Board00 (alidcscae020)
684 if (name.Contains("Quad2Sect0")) AddToMap(hvMap,newmap,name,"Quad2Sect0","Quad2Sect2"); // channel 11
688 AddToMap(hvMap,newmap,name,name,name);
692 // copy newmap to hvMap
694 TIter nextNewMap(&newmap);
695 while ( ( hvChannelName = static_cast<TObjString*>(nextNewMap()) ) )
697 TPair* oldPair = static_cast<TPair*>(hvMap.FindObject(hvChannelName->String().Data()));
698 TPair* newPair = static_cast<TPair*>(newmap.FindObject(hvChannelName->String().Data()));
700 TObjArray* newValues = static_cast<TObjArray*>(newPair->Value());
702 oldPair->SetValue(newValues);
706 //_____________________________________________________________________________
708 AliMUONCalibrationData::CreateHV(Int_t runNumber,
709 Int_t* startOfValidity,
714 /// Create a new HV map from the OCDB for a given run
716 /// dryRun is only usefull with patched=kTRUE and non-empty messages) :
717 /// it allow to get the list of messages without altering the values at all
718 /// (A patch without a patch, so to speak...)
721 TMap* hvMap = dynamic_cast<TMap*>(CreateObject(runNumber,"MUON/Calib/HV",startOfValidity));
723 if (!hvMap) return 0x0;
725 PatchSt1DCSAliases(*hvMap);
730 TObjString* hvChannelName;
732 while ( ( hvChannelName = static_cast<TObjString*>(next()) ) )
734 TString name(hvChannelName->String());
736 if ( name.Contains("sw") ) continue; // skip switches
738 if ( name.Contains("iMon") ) continue; // skip HV currents
740 TPair* hvPair = static_cast<TPair*>(hvMap->FindObject(name.Data()));
741 TObjArray* values = static_cast<TObjArray*>(hvPair->Value());
744 AliErrorClass(Form("Could not get values for alias %s",name.Data()));
750 AliDebugClass(1,Form("channel %s",name.Data()));
751 Bool_t ok = PatchHVValues(*values,&msg,dryRun);
755 messages->Add(new TObjString(Form("%s %s",hvChannelName->String().Data(),msg.Data())));
760 AliErrorClass(Form("PatchHVValue was not successfull ! This is serious ! "
761 "You'll have to check the logic for channel %s in run %09d",
762 name.Data(),runNumber));
771 Int_t a(0),b(0),c(0),d(0),e(0),f(0),g(0),h(0),u(0),z(0);
772 TIter next(messages);
776 while ( ( msg = static_cast<TObjString*>(next()) ) )
778 Int_t i = msg->String().Index("CASE",strlen("CASE"),0,TString::kExact);
782 sscanf(msg->String()(i,msg->String().Length()-i).Data(),"CASE:%10c",&hvCase);
787 case 'A': ++a; break;
788 case 'B': ++b; break;
789 case 'C': ++c; break;
790 case 'D': ++d; break;
791 case 'E': ++e; break;
792 case 'F': ++f; break;
793 case 'G': ++g; break;
794 case 'H': ++h; break;
795 case 'Z': ++z; break;
800 messages->Add(new TObjString(Form("SUMMARY : # of cases A(%3d) B(%3d) C(%3d) D(%3d) E(%3d) F(%3d) G(%3d) H(%3d) Z(%3d) OTHER(%3d)",
801 a,b,c,d,e,f,g,h,z,u)));
807 //_____________________________________________________________________________
809 AliMUONCalibrationData::CreateTriggerDCS(Int_t runNumber, Int_t* startOfValidity)
811 /// Create a new Trigger HV and curent map from the OCDB for a given run
812 return dynamic_cast<TMap*>(CreateObject(runNumber,"MUON/Calib/TriggerDCS",startOfValidity));
815 //_____________________________________________________________________________
817 AliMUONCalibrationData::CreateLocalTriggerBoardMasks(Int_t runNumber, Int_t* startOfValidity)
819 /// Get the internal store for LocalTriggerBoardMasks from OCDB
821 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/LocalTriggerBoardMasks",startOfValidity));
824 //_____________________________________________________________________________
826 AliMUONCalibrationData::CreateNeighbours(Int_t runNumber, Int_t* startOfValidity)
828 /// Create a neighbour store from the OCDB for a given run
829 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Neighbours",startOfValidity));
832 //_____________________________________________________________________________
834 AliMUONCalibrationData::CreateObject(Int_t runNumber, const char* path, Int_t* startOfValidity)
836 /// Access the CDB for a given path (e.g. MUON/Calib/Pedestals),
837 /// and return the corresponding TObject.
839 AliCodeTimerAutoClass(Form("%09d : %s",runNumber,path),0);
841 AliCDBManager* man = AliCDBManager::Instance();
843 AliCDBEntry* entry = man->Get(path,runNumber);
847 if ( startOfValidity ) *startOfValidity = entry->GetId().GetFirstRun();
849 TObject* object = entry->GetObject();
850 if (!(man->GetCacheFlag()))
852 entry->SetOwner(kFALSE);
857 // entry->SetOwner(kTRUE); //FIXME : this should be done but is causing problems with RecoParams at the end of the reco : investigate why...
863 if ( startOfValidity ) *startOfValidity = AliCDBRunRange::Infinity();
868 AliCodeTimerAutoClass(Form("Failed to get %s for run %09d",path,runNumber),1);
875 //_____________________________________________________________________________
877 AliMUONCalibrationData::CreateOccupancyMap(Int_t runNumber, Int_t* startOfValidity)
879 /// Create a new occupancy map store from the OCDB for a given run
880 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/OccupancyMap",startOfValidity));
883 //_____________________________________________________________________________
885 AliMUONCalibrationData::CreateRejectList(Int_t runNumber, Int_t* startOfValidity)
887 /// Create a new rejectlist store from the OCDB for a given run
888 return dynamic_cast<AliMUONRejectList*>(CreateObject(runNumber,"MUON/Calib/RejectList",startOfValidity));
891 //_____________________________________________________________________________
893 AliMUONCalibrationData::CreatePedestals(Int_t runNumber, Int_t* startOfValidity)
895 /// Create a new pedestal store from the OCDB for a given run
896 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Pedestals",startOfValidity));
899 //_____________________________________________________________________________
901 AliMUONCalibrationData::CreateConfig(Int_t runNumber, Int_t* startOfValidity)
903 /// Create a new config store from the OCDB for a given run
904 return dynamic_cast<AliMUONVStore*>(CreateObject(runNumber,"MUON/Calib/Config",startOfValidity));
908 //_____________________________________________________________________________
909 AliMUONRegionalTriggerConfig*
910 AliMUONCalibrationData::CreateRegionalTriggerConfig(Int_t runNumber, Int_t* startOfValidity)
912 /// Create the internal store for RegionalTriggerConfig from OCDB
914 return dynamic_cast<AliMUONRegionalTriggerConfig*>(CreateObject(runNumber,"MUON/Calib/RegionalTriggerConfig",startOfValidity));
917 //_____________________________________________________________________________
918 AliMUONTriggerEfficiencyCells*
919 AliMUONCalibrationData::CreateTriggerEfficiency(Int_t runNumber, Int_t* startOfValidity)
921 /// Create trigger efficiency object from OCBD
923 return dynamic_cast<AliMUONTriggerEfficiencyCells*>(CreateObject(runNumber,"MUON/Calib/TriggerEfficiency",startOfValidity));
926 //_____________________________________________________________________________
928 AliMUONCalibrationData::CreateTriggerLut(Int_t runNumber, Int_t* startOfValidity)
930 /// Create trigger LUT from OCDB
932 return dynamic_cast<AliMUONTriggerLut*>(CreateObject(runNumber,"MUON/Calib/TriggerLut",startOfValidity));
935 //_____________________________________________________________________________
937 AliMUONCalibrationData::Gains() const
939 /// Create (if needed) and return the internal store for gains.
940 if (fgBypassGains) return fgBypassGains;
944 fGains = CreateGains(fRunNumber);
949 //_____________________________________________________________________________
951 AliMUONCalibrationData::Gains(Int_t detElemId, Int_t manuId) const
953 /// Return the gains for a given (detElemId, manuId) pair
954 /// Note that, unlike the DeadChannel case, if the result is 0x0, that's an
955 /// error (meaning that we should get gains for all channels).
957 AliMUONVStore* gains = Gains();
963 return static_cast<AliMUONVCalibParam*>(gains->FindObject(detElemId,manuId));
966 //_____________________________________________________________________________
967 AliMUONGlobalCrateConfig*
968 AliMUONCalibrationData::GlobalTriggerCrateConfig() const
970 /// Return the config for the global trigger board.
972 if (!fGlobalTriggerCrateConfig)
974 fGlobalTriggerCrateConfig = CreateGlobalTriggerCrateConfig(fRunNumber);
976 return fGlobalTriggerCrateConfig;
980 //_____________________________________________________________________________
982 AliMUONCalibrationData::HV(Bool_t patched) const
984 /// Return the calibration for a given (detElemId, manuId) pair
988 fHV = CreateHV(fRunNumber,0,patched);
993 //_____________________________________________________________________________
995 AliMUONCalibrationData::TriggerDCS() const
997 /// Return the calibration for a given (detElemId, manuId) pair
1001 fTriggerDCS = CreateTriggerDCS(fRunNumber);
1006 //_____________________________________________________________________________
1008 AliMUONCalibrationData::Neighbours() const
1010 /// Create (if needed) and return the internal store for neighbours.
1013 fNeighbours = CreateNeighbours(fRunNumber);
1018 //_____________________________________________________________________________
1020 AliMUONCalibrationData::LocalTriggerBoardMasks(Int_t localBoardNumber) const
1022 /// Return the masks for a given trigger local board.
1024 if (!fLocalTriggerBoardMasks)
1026 fLocalTriggerBoardMasks = CreateLocalTriggerBoardMasks(fRunNumber);
1029 if ( fLocalTriggerBoardMasks )
1031 AliMUONVCalibParam* ltbm =
1032 static_cast<AliMUONVCalibParam*>(fLocalTriggerBoardMasks->FindObject(localBoardNumber));
1035 AliError(Form("Could not get mask for localBoardNumber=%d",localBoardNumber));
1042 //_____________________________________________________________________________
1044 AliMUONCalibrationData::OccupancyMap() const
1046 /// Get occupancy map
1049 fOccupancyMap = CreateOccupancyMap(fRunNumber);
1051 return fOccupancyMap;
1054 //_____________________________________________________________________________
1056 AliMUONCalibrationData::RejectList() const
1061 fRejectList = CreateRejectList(fRunNumber);
1066 //_____________________________________________________________________________
1068 AliMUONCalibrationData::BypassStores(AliMUONVStore* ped, AliMUONVStore* gain)
1070 /// Force the use of those pedestals and gains
1071 fgBypassPedestals = ped;
1072 fgBypassGains = gain;
1076 //_____________________________________________________________________________
1078 AliMUONCalibrationData::Pedestals() const
1080 /// Return pedestals
1082 if (fgBypassPedestals) return fgBypassPedestals;
1086 fPedestals = CreatePedestals(fRunNumber);
1091 //_____________________________________________________________________________
1093 AliMUONCalibrationData::Config() const
1099 fConfig = CreateConfig(fRunNumber);
1104 //_____________________________________________________________________________
1106 AliMUONCalibrationData::Pedestals(Int_t detElemId, Int_t manuId) const
1108 /// Return the pedestals for a given (detElemId, manuId) pair.
1109 /// A return value of 0x0 is considered an error, meaning we should get
1110 /// pedestals for all channels.
1112 AliMUONVStore* pedestals = Pedestals();
1118 return static_cast<AliMUONVCalibParam*>(pedestals->FindObject(detElemId,manuId));
1121 //_____________________________________________________________________________
1123 AliMUONCalibrationData::Print(Option_t*) const
1125 /// A very basic dump of our guts.
1127 cout << "RunNumber " << RunNumber()
1128 << " fGains=" << fGains
1129 << " fPedestals=" << fPedestals
1130 << " fConfig=" << fConfig
1132 << " fTriggerDCS=" << fTriggerDCS
1133 << " fLocalTriggerBoardMasks=" << fLocalTriggerBoardMasks
1134 << " fRegionalTriggerConfig=" << fRegionalTriggerConfig
1135 << " fGlobalTriggerCrateConfig=" << fGlobalTriggerCrateConfig
1136 << " fTriggerLut=" << fTriggerLut
1141 //_____________________________________________________________________________
1142 AliMUONRegionalTriggerConfig*
1143 AliMUONCalibrationData::RegionalTriggerConfig() const
1145 /// Return the config for the regional trigger board.
1147 if (!fRegionalTriggerConfig)
1149 fRegionalTriggerConfig = CreateRegionalTriggerConfig(fRunNumber);
1151 return fRegionalTriggerConfig;
1155 //_____________________________________________________________________________
1156 AliMUONTriggerEfficiencyCells*
1157 AliMUONCalibrationData::TriggerEfficiency() const
1159 /// Return the trigger efficiency.
1161 if (!fTriggerEfficiency)
1163 fTriggerEfficiency = CreateTriggerEfficiency(fRunNumber);
1165 return fTriggerEfficiency;
1169 //_____________________________________________________________________________
1171 AliMUONCalibrationData::TriggerLut() const
1173 /// Return the trigger look up table.
1177 fTriggerLut = CreateTriggerLut(fRunNumber);
1182 //_____________________________________________________________________________
1184 AliMUONCalibrationData::Reset()
1188 AliCodeTimerAuto("",0);
1200 delete fLocalTriggerBoardMasks;
1201 fLocalTriggerBoardMasks = 0x0;
1202 delete fRegionalTriggerConfig;
1203 fRegionalTriggerConfig = 0x0;
1204 delete fGlobalTriggerCrateConfig;
1205 fGlobalTriggerCrateConfig = 0x0;
1209 delete fTriggerEfficiency;
1210 fTriggerEfficiency = 0x0;
1211 delete fCapacitances;
1212 fCapacitances = 0x0;
1217 //_____________________________________________________________________________
1219 AliMUONCalibrationData::Check(Int_t runNumber)
1221 /// Self-check to see if we can read all data for a given run
1222 /// from the current OCDB...
1224 if ( ! CreateCapacitances(runNumber) )
1226 AliErrorClass("Could not read capacitances");
1230 AliInfoClass("Capacitances read OK");
1233 if ( ! CreateGains(runNumber) )
1235 AliErrorClass("Could not read gains");
1239 AliInfoClass("Gains read OK");
1242 if ( ! CreateGlobalTriggerCrateConfig(runNumber) )
1244 AliErrorClass("Could not read Trigger Crate Config");
1248 AliInfoClass("TriggerBoardMasks read OK");
1251 if ( ! CreateHV(runNumber) )
1253 AliErrorClass("Could not read HV");
1257 AliInfoClass("HV read OK");
1260 if ( ! CreateTriggerDCS(runNumber) )
1262 AliErrorClass("Could not read Trigger HV and Currents");
1266 AliInfoClass("Trigger HV and Currents read OK");
1269 if ( ! CreateNeighbours(runNumber) )
1271 AliErrorClass("Could not read Neighbours");
1275 AliInfoClass("Neighbours read OK");
1278 if ( ! CreateLocalTriggerBoardMasks(runNumber) )
1280 AliErrorClass("Could not read LocalTriggerBoardMasks");
1284 AliInfoClass("LocalTriggerBoardMasks read OK");
1287 if ( ! CreatePedestals(runNumber) )
1289 AliErrorClass("Could not read pedestals");
1293 AliInfoClass("Pedestals read OK");
1296 if ( ! CreateConfig(runNumber) )
1298 AliErrorClass("Could not read config");
1302 AliInfoClass("Config read OK");
1305 if ( ! CreateRegionalTriggerConfig(runNumber) )
1307 AliErrorClass("Could not read RegionalTriggerConfig");
1311 AliInfoClass("RegionalTriggerBoardMasks read OK");
1314 if ( ! CreateTriggerLut(runNumber) )
1316 AliErrorClass("Could not read TriggerLut");
1320 AliInfoClass("TriggerLut read OK");
1323 if ( ! CreateTriggerEfficiency(runNumber) )
1325 AliErrorClass("Could not read TriggerEfficiency");
1329 AliInfoClass("TriggerEfficiency read OK");