20 #include "AliCDBEntry.h"
21 #include "AliCDBManager.h"
22 #include "AliCodeTimer.h"
23 #include "AliDCSValue.h"
36 #include <Riostream.h>
70 void MarkForDeletion(Int_t* indices, Int_t first, Int_t last)
72 for ( Int_t i = first; i <= last; ++i )
81 Bool_t deferredInitialization)
84 fRunNumber(runNumber),
88 fLocalTriggerBoardMasks(0x0),
89 fRegionalTriggerConfig(0x0),
90 fGlobalTriggerCrateConfig(0x0),
92 fTriggerEfficiency(0x0),
107 AliCodeTimerAuto(
"",0);
109 if ( deferredInitialization == kFALSE )
112 AliWarning(
"Using immediate initialization, which might cause some issue with old OCDBs...");
135 if (!(AliCDBManager::Instance()->GetCacheFlag()))
Reset();
158 if ( last < first )
return kFALSE;
159 if ( last - first < 2 )
return kFALSE;
166 AliDCSValue* vfirst =
static_cast<AliDCSValue*
>(values.UncheckedAt(first));
167 AliDCSValue* vlast =
static_cast<AliDCSValue*
>(values.UncheckedAt(last));
169 Int_t deltaHV = TMath::Nint(TMath::Abs(vfirst->GetFloat()-vlast->GetFloat()));
171 if ( deltaHV < HVSAME )
return kFALSE;
173 for ( Int_t i = first; i <= last; ++i )
175 AliDCSValue* v =
static_cast<AliDCSValue*
>(values.UncheckedAt(i));
177 Double_t y = v->GetFloat() - vfirst->GetFloat();
178 Double_t x = v->GetTimeStamp() - vfirst->GetTimeStamp();
185 slope = value > 0 ? 1 : -1;
186 value = TMath::Abs(value);
188 UInt_t deltaTime = vlast->GetTimeStamp() - vfirst->GetTimeStamp();
192 if (slope>0) (*msg) = Form(
"RU%d[%d:%d](%d)",TMath::Nint(value),first,last,deltaTime);
193 if (slope<0) (*msg) = Form(
"RD%d[%d:%d](%d)",TMath::Nint(value),first,last,deltaTime);
195 if ( TMath::Nint(value) == 0 )
205 value = (vfirst->GetFloat()+vlast->GetFloat())/2.0;
206 *msg = Form(
"FLUCT%d[%d:%d]",TMath::Nint(value),first,last);
233 UInt_t DELTATIME(60);
239 Bool_t gather(kFALSE);
243 groups.SetOwner(kTRUE);
245 for ( Int_t i = values.GetLast(); i > 0; --i )
247 AliDCSValue* vi =
static_cast<AliDCSValue*
>(values.UncheckedAt(i));
248 AliDCSValue* vj =
static_cast<AliDCSValue*
>(values.UncheckedAt(i-1));
250 if ( vi->GetTimeStamp() - vj->GetTimeStamp() < DELTATIME )
276 TIter nextGroup(&groups,kIterBackward);
284 Int_t nEndAndShortRU(0);
289 trips.SetOwner(kTRUE);
291 while ( ( p = static_cast<AliMpIntPair*>(nextGroup()) ) )
313 else if ( p->
GetSecond() == values.GetLast() && TMath::Nint(value) < IENDRU )
323 else if ( slope < 0 )
325 if ( p->
GetSecond() == values.GetLast() )
336 AliDCSValue* d =
static_cast<AliDCSValue*
>(values.At(p->
GetSecond()));
341 AliDCSValue* tripStart =
static_cast<AliDCSValue*
>(values.At(p->
GetFirst()));
342 trips.Add(
new AliMpIntPair(tripStart->GetTimeStamp(),TMath::Nint(tripStart->GetFloat())));
350 internalMsg += groupMsg;
402 AliDebugClass(1,Form(
"msg=%s ngroupds=%d",internalMsg.Data(),ngroups));
403 AliDebugClass(1,Form(
"nRU %d nRD %d nStartRU %d nEndRD %d nTripRD %d nFluct %d",
404 nRU,nRD,nStartRU,nEndRD,nTripRD,nFluct));
406 TString hvCase(
"OTHER");
407 int dummy(0),a(-1),b(-1);
409 Int_t nvalues = values.GetSize();
410 Int_t* indices =
new Int_t[nvalues];
411 memset(indices,0,nvalues*
sizeof(Int_t));
413 AliDCSValue* vfirst =
static_cast<AliDCSValue*
>(values.UncheckedAt(0));
414 AliDCSValue* vlast =
static_cast<AliDCSValue*
>(values.UncheckedAt(values.GetLast()));
416 UInt_t meanTimeStamp = ( vfirst->GetTimeStamp() + vlast->GetTimeStamp() ) / 2;
422 else if ( nTripRD > 0 )
424 const Double_t HVLOWTRIP(600);
427 internalMsg += Form(
"NT:%d ",nTripRD);
429 if ( nRU > 0 && nRD > 0 )
438 for ( Int_t iTrip = 0; iTrip <= trips.GetLast(); ++iTrip )
441 TString tripType(
"TRIP");
444 tripType =
"LOWTRIP";
447 internalMsg += Form(
"%s SV:%d TS:%d ",tripType.Data(),tripPair->
GetSecond(),tripPair->
GetFirst());
456 MarkForDeletion(indices,0,values.GetLast());
457 values.Add(
new AliDCSValue(static_cast<Float_t>(0),meanTimeStamp));
460 else if ( nStartRU > 0 && nRU == 0 && nRD == 0 && nEndRD == 0 )
465 sscanf(internalMsg.Data(),
"RU%10d[%10d:%10d]%80s",&dummy,&a,&b,r);
466 MarkForDeletion(indices,a,b);
469 else if ( nStartRU > 0 && nEndRD > 0 && nRD == 0 && nRU == 0 )
474 sscanf(internalMsg.Data(),
"RU%10d[%10d:%10d]%80s",&dummy,&a,&b,r);
475 MarkForDeletion(indices,a,b-1);
476 Int_t i = internalMsg.Index(
"RD",strlen(
"RD"),0,TString::kExact);
477 sscanf(internalMsg(i,internalMsg.Length()-i).Data(),
478 "RD%10d[%10d:%10d]%80s",&dummy,&a,&b,r);
479 MarkForDeletion(indices,a+1,b);
482 else if ( nEndRD > 0 && nStartRU == 0 && nRU == 0 && nRD == 0 )
487 Int_t i = internalMsg.Index(
"RD",strlen(
"RD"),0,TString::kExact);
488 sscanf(internalMsg(i,internalMsg.Length()-i).Data(),
489 "RD%10d[%10d:%10d]%80s",&dummy,&a,&b,r);
490 MarkForDeletion(indices,a,b);
493 else if ( nFluct > 0 )
498 TObjArray* af = internalMsg.Tokenize(
" ");
501 while ( ( str = static_cast<TObjString*>(next()) ) )
503 TString s(str->String());
504 if ( s.BeginsWith(
"FLUCT") )
506 sscanf(s.Data(),
"FLUCT%d[%d:%d]",&dummy,&a,&b);
507 MarkForDeletion(indices,a,b);
513 else if ( nEndAndShortRU > 0 && nStartRU == 0 && nRU == 0 && nRD == 0 && nEndRD == 0 )
518 sscanf(internalMsg.Data(),
"RU%10d[%10d:%10d]%80s",&dummy,&a,&b,r);
519 MarkForDeletion(indices,a,b);
528 const Double_t HVFLUCT(20);
530 if ( TMath::Abs(vfirst->GetFloat() - vlast->GetFloat()) < HVFLUCT )
536 MarkForDeletion(indices,1,nvalues-1);
542 for ( Int_t i = 0; i < nvalues; ++i )
555 if ( !values.GetEntries() )
557 AliErrorClass(Form(
"No value left after patch... Check that !!! initial # of values=%d msg=%s",
558 nvalues,internalMsg.Data()));
565 TIter nextA(&values);
567 Float_t maxval(-9999);
569 while ( ( val = static_cast<AliDCSValue*>(nextA()) ) )
571 if ( val->GetFloat() > maxval )
573 maxval = val->GetFloat();
579 values.Add(
new AliDCSValue(maxval,meanTimeStamp));
586 internalMsg += Form(
"CASE:%s",hvCase.Data());
588 if (msg) *msg = internalMsg.Data();
590 return hvCase==
"OTHER" ? kFALSE : kTRUE;
604 newkey.ReplaceAll(source,dest);
606 TPair* pair =
static_cast<TPair*
>(sourceMap.FindObject(key.Data()));
608 destMap.Add(
new TObjString(newkey.Data()),pair->Value());
626 AliWarningClass(
"Patching already done for St1 DCS aliases on this map. Not doing it again.");
630 AliCodeTimerAutoClass(Form(
"hvMap=%p",&hvMap),0);
633 TObjString* hvChannelName;
636 newmap.SetOwnerKeyValue(kTRUE,kFALSE);
638 while ( ( hvChannelName = static_cast<TObjString*>(next()) ) )
640 TString name(hvChannelName->String());
641 TString newname(name);
646 if ( name.Contains(
"Chamber00Left") )
648 if (name.Contains(
"Quad1Sect0"))
AddToMap(hvMap,newmap,name,
"Quad1Sect0",
"Quad2Sect0");
650 if (name.Contains(
"Quad1Sect1"))
AddToMap(hvMap,newmap,name,
"Quad1Sect1",
"Quad2Sect1");
651 if (name.Contains(
"Quad1Sect2"))
AddToMap(hvMap,newmap,name,
"Quad1Sect2",
"Quad2Sect2");
653 if (name.Contains(
"Quad2Sect2"))
AddToMap(hvMap,newmap,name,
"Quad2Sect2",
"Quad1Sect0");
654 if (name.Contains(
"Quad2Sect1"))
AddToMap(hvMap,newmap,name,
"Quad2Sect1",
"Quad1Sect1");
655 if (name.Contains(
"Quad2Sect0"))
AddToMap(hvMap,newmap,name,
"Quad2Sect0",
"Quad1Sect2");
657 else if ( name.Contains(
"Chamber01Left"))
659 if (name.Contains(
"Quad2Sect2"))
AddToMap(hvMap,newmap,name,
"Quad2Sect2",
"Quad2Sect0");
660 if (name.Contains(
"Quad2Sect0"))
AddToMap(hvMap,newmap,name,
"Quad2Sect0",
"Quad2Sect2");
664 AddToMap(hvMap,newmap,name,name,name);
670 TIter nextNewMap(&newmap);
671 while ( ( hvChannelName = static_cast<TObjString*>(nextNewMap()) ) )
673 TPair* oldPair =
static_cast<TPair*
>(hvMap.FindObject(hvChannelName->String().Data()));
674 TPair* newPair =
static_cast<TPair*
>(newmap.FindObject(hvChannelName->String().Data()));
678 oldPair->SetValue(newValues);
690 Int_t* startOfValidity,
702 TMap* hvMap =
dynamic_cast<TMap*
>(
CreateObject(runNumber,
"MUON/Calib/HV",startOfValidity));
704 if (!hvMap)
return 0x0;
706 AliCodeTimerAutoClass(Form(
"hvMap=%p",hvMap),0);
715 AliWarningClass(
"Patching already done for HV channels on this map. Not doing it again.");
720 TObjString* hvChannelName;
722 while ( ( hvChannelName = static_cast<TObjString*>(next()) ) )
724 TString name(hvChannelName->String());
726 if ( name.Contains(
"sw") )
continue;
728 if ( name.Contains(
"iMon") )
continue;
730 TPair* hvPair =
static_cast<TPair*
>(hvMap->FindObject(name.Data()));
734 AliErrorClass(Form(
"Could not get values for alias %s",name.Data()));
740 AliDebugClass(1,Form(
"channel %s",name.Data()));
745 messages->Add(
new TObjString(Form(
"%s %s",hvChannelName->String().Data(),msg.Data())));
750 AliErrorClass(Form(
"PatchHVValue was not successfull ! This is serious ! "
751 "You'll have to check the logic for channel %s in run %09d",
752 name.Data(),runNumber));
762 Int_t a(0),b(0),c(0),d(0),e(0),
f(0),g(0),h(0),u(0),z(0);
763 TIter next(messages);
767 while ( ( msg = static_cast<TObjString*>(next()) ) )
769 Int_t i = msg->String().Index(
"CASE",strlen(
"CASE"),0,TString::kExact);
773 sscanf(msg->String()(i,msg->String().Length()-i).Data(),
"CASE:%10c",&hvCase);
778 case 'A': ++a;
break;
779 case 'B': ++b;
break;
780 case 'C': ++c;
break;
781 case 'D': ++d;
break;
782 case 'E': ++e;
break;
783 case 'F': ++
f;
break;
784 case 'G': ++g;
break;
785 case 'H': ++h;
break;
786 case 'Z': ++z;
break;
791 messages->Add(
new TObjString(Form(
"SUMMARY : # of cases A(%3d) B(%3d) C(%3d) D(%3d) E(%3d) F(%3d) G(%3d) H(%3d) Z(%3d) OTHER(%3d)",
792 a,b,c,d,e,
f,g,h,z,u)));
803 return dynamic_cast<TMap*
>(
CreateObject(runNumber,
"MUON/Calib/LV",startOfValidity));
811 return dynamic_cast<TMap*
>(
CreateObject(runNumber,
"MUON/Calib/TriggerDCS",startOfValidity));
838 AliCodeTimerAutoClass(Form(
"%09d : %s",runNumber,path),0);
840 AliCDBManager* man = AliCDBManager::Instance();
842 AliCDBEntry* entry = man->Get(path,runNumber);
846 if ( startOfValidity ) *startOfValidity = entry->GetId().GetFirstRun();
848 TObject*
object = entry->GetObject();
849 if (!(man->GetCacheFlag()))
851 entry->SetOwner(kFALSE);
862 if ( startOfValidity ) *startOfValidity = AliCDBRunRange::Infinity();
867 AliCodeTimerAutoClass(Form(
"Failed to get %s for run %09d",path,runNumber),1);
1017 AliError(Form(
"Could not get mask for localBoardNumber=%d",localBoardNumber));
1169 AliCodeTimerAuto(
"",0);
1205 AliErrorClass(
"Could not read Trigger Crate Config");
1209 AliInfoClass(
"TriggerBoardMasks read OK");
1214 AliErrorClass(
"Could not read HV");
1218 AliInfoClass(
"HV read OK");
1223 AliErrorClass(
"Could not read LV");
1227 AliInfoClass(
"LV read OK");
1232 AliErrorClass(
"Could not read Trigger HV and Currents");
1236 AliInfoClass(
"Trigger HV and Currents read OK");
1241 AliErrorClass(
"Could not read Neighbours");
1245 AliInfoClass(
"Neighbours read OK");
1250 AliErrorClass(
"Could not read LocalTriggerBoardMasks");
1254 AliInfoClass(
"LocalTriggerBoardMasks read OK");
1259 AliErrorClass(
"Could not read pedestals");
1263 AliInfoClass(
"Pedestals read OK");
1268 AliErrorClass(
"Could not read config");
1272 AliInfoClass(
"Config read OK");
1277 AliErrorClass(
"Could not read RegionalTriggerConfig");
1281 AliInfoClass(
"RegionalTriggerBoardMasks read OK");
1286 AliErrorClass(
"Could not read TriggerLut");
1290 AliInfoClass(
"TriggerLut read OK");
1295 AliErrorClass(
"Could not read TriggerEfficiency");
1299 AliInfoClass(
"TriggerEfficiency read OK");
TMap * LV() const
Get the MCH LV.
static UInt_t PatchHVDCSAliasesSt1WasAppliedMask()
TMap * TriggerDCS() const
Get the Trigger HV and current values.
Int_t GetFirst() const
Return first value.
The class defines the configuration of global crate.
AliMUONRegionalTriggerConfig * RegionalTriggerConfig() const
Get the config for regional trigger.
AliMUONRejectList * fRejectList
! reject list
static AliMUONVStore * CreateOccupancyMap(Int_t runNumber, Int_t *startOfValidity=0)
Create an occupancy map store (which must be deleted) from OCDB for the given run.
static AliMUONVStore * CreateLocalTriggerBoardMasks(Int_t runNumber, Int_t *startOfValidity=0)
Create a local trigger mask store (which must be deleted) for a given run.
AliMUONVStore * fConfig
! configuration of the tracker
TMap * HV(Bool_t patched=kTRUE) const
Get the HV values. Use patched=kFALSE to get unprocessed (i.e. "raw") values as they are in the OCDB...
AliMUONVStore * fLocalTriggerBoardMasks
! Local trigger board maska
AliMUONVStore * Neighbours() const
Get the neighbours store.
static void AddToMap(const TMap &sourceMap, TMap &destMap, const TString &key, const char *source, const char *dest)
static Float_t TrackerHVOFF()
AliMUONVStore * fNeighbours
! list of neighbours for all channels
Int_t fRunNumber
The run number for which we hold calibrations.
TFile f("CalibObjects.root")
AliMUONCalibrationData(Int_t runNumber=-1, Bool_t deferredInitialization=kTRUE)
static void Check(Int_t runNumber)
AliMUONTriggerEfficiencyCells * fTriggerEfficiency
! Trigger efficiency cells
Store and give access to the trigger chamber efficiency.
static AliMUONTriggerEfficiencyCells * CreateTriggerEfficiency(Int_t runNumber, Int_t *startOfValidity=0)
Create a trigger efficiency map (which must be deleted) for a given run.
virtual void Print(Option_t *opt="") const
Dump to screen.
AliMUONVStore * Config() const
Get the config store.
static AliMUONVStore * CreateConfig(Int_t runNumber, Int_t *startOfValidity=0)
Create a configuration store (which must be deleted) from OCDB for the given run. ...
AliMUONVCalibParam * LocalTriggerBoardMasks(Int_t localBoardNumber) const
Get the mask for a given local trigger board.
static void BypassStores(AliMUONVStore *ped)
Int_t RunNumber() const
The runnumber used by this object.
virtual ~AliMUONCalibrationData()
AliMUONGlobalCrateConfig * fGlobalTriggerCrateConfig
! Global trigger crate config
AliMUONTriggerLut * TriggerLut() const
Get the trigger Look Up Table.
static UInt_t PatchHVAllWasAppliedMask()
Container of calibration values for a given number of channels.
static AliMUONGlobalCrateConfig * CreateGlobalTriggerCrateConfig(Int_t runNumber, Int_t *startOfValidity=0)
Create a global trigger mask (which must be deleted) from OCDB for the given run. ...
AliMUONVStore * fPedestals
! Pedestals
AliMUONVStore * fOccupancyMap
! occupancy map
AliMUONGlobalCrateConfig * GlobalTriggerCrateConfig() const
Get the configuration for the global trigger board.
static AliMUONVStore * CreateNeighbours(Int_t runNumber, Int_t *startOfValidity=0)
Create a neighbours store (which must be deleted) from OCDB for the given run.
static Bool_t PatchHVValues(TObjArray &values, TString *msg=0x0, Bool_t dryRun=kFALSE)
static TMap * CreateTriggerDCS(Int_t runNumber, Int_t *startOfValidity=0)
Create a Trigger HV and current map (which must be deleted) from OCDB for the given run...
AliMUONVStore * Pedestals() const
Get the pedestal store.
static Bool_t CheckHVGroup(TObjArray &values, Int_t first, Int_t last, Double_t &value, Int_t &slope, TString *msg)
AliMUONTriggerEfficiencyCells * TriggerEfficiency() const
Get the trigger efficiency map.
static AliMUONVStore * fgBypassPedestals
AliMUONTriggerLut * fTriggerLut
! TRigger LUTs
AliMUONRegionalTriggerConfig * fRegionalTriggerConfig
! Regional trigger config
static AliMUONRegionalTriggerConfig * CreateRegionalTriggerConfig(Int_t runNumber, Int_t *startOfValidity=0)
Create a regional trigger mask store (which must be deleted) for a given run.
Single entry point to access MUON calibration data.
static void PatchSt1DCSAliases(TMap &hvMap)
static TMap * CreateLV(Int_t runNumber, Int_t *startOfValidity=0)
Create a MCH LV map (which must be deleted) from OCDB for the given run.
static TObject * CreateObject(Int_t runNumber, const char *path, Int_t *startOfValidity=0x0)
TMap * fTriggerDCS
! Trigger HV and Currents
Object to hold the list of elements we want to reject from the reconstruction.
AliMUONVStore * OccupancyMap() const
Get the occupancy map store.
static TMap * CreateHV(Int_t runNumber, Int_t *startOfValidity=0, Bool_t patched=kTRUE, TList *messages=0x0, Bool_t dryRun=kFALSE)
Create a hv map (which must be deleted) from OCDB for the given run.
Int_t GetSecond() const
Return second value.
static AliMUONTriggerLut * CreateTriggerLut(Int_t runNumber, Int_t *startOfValidity=0)
Create a trigger Look Up Table (which must be deleted) for a given run.
Base class for MUON data stores.
AliMUONRejectList * RejectList() const
Get the reject list store.
MUON trigger look up table class.
The class defines the properties of regional trigger crate.
static AliMUONRejectList * CreateRejectList(Int_t runNumber, Int_t *startOfValidity=0)
Create a rejectlist store (which must be deleted) from OCDB for the given run.
static AliMUONVStore * CreatePedestals(Int_t runNumber, Int_t *startOfValidity=0)
Create a pedestal store (which must be deleted) from OCDB for the given run.
virtual TObject * FindObject(const char *name) const
Find an object by name.