#include "AliCDBEntry.h"
#include "AliCDBManager.h"
+#include "AliCodeTimer.h"
#include "AliDCSValue.h"
#include "AliLog.h"
#include "AliMUON2DMap.h"
#include "AliMUON2DStoreValidator.h"
#include "AliMUONCalibParamNI.h"
#include "AliMUONCalibrationData.h"
-#include "AliMUONHVNamer.h"
+#include "AliMUONStringIntMap.h"
#include "AliMUONVCalibParam.h"
#include "AliMpArea.h"
+#include "AliMpArrayI.h"
#include "AliMpConstants.h"
+#include "AliMpDDLStore.h"
#include "AliMpDEIterator.h"
#include "AliMpDEManager.h"
+#include "AliMpDetElement.h"
+#include "AliMpExMap.h"
+#include "AliMpHVNamer.h"
#include "AliMpIntPair.h"
-#include "AliMpManuList.h"
+#include "AliMpManuUID.h"
#include "AliMpMotifMap.h"
#include "AliMpMotifPosition.h"
#include "AliMpPCB.h"
#include "AliMpPad.h"
-#include "AliMpSector.h"
-#include "AliMpSectorSegmentation.h"
#include "AliMpSegmentation.h"
#include "AliMpSlat.h"
#include "AliMpSlatSegmentation.h"
#include "AliMpStationType.h"
#include "AliMpVPadIterator.h"
+#include "AliMpVSegmentation.h"
#include <Riostream.h>
+#include <TArrayI.h>
+#include <TExMap.h>
#include <TMap.h>
-#include <TStopwatch.h>
#include <TString.h>
-
/// \cond CLASSIMP
ClassImp(AliMUONPadStatusMaker)
/// \endcond
//_____________________________________________________________________________
AliMUONPadStatusMaker::AliMUONPadStatusMaker(const AliMUONCalibrationData& calibData)
: fCalibrationData(calibData),
+ fGainA0Limits(0,1E30),
+ fGainA1Limits(-1E-30,1E30),
+ fGainThresLimits(0,4095),
+ fHVSt12Limits(0,5000),
+ fHVSt345Limits(0,5000),
fPedMeanLimits(0,4095),
fPedSigmaLimits(0,4095),
- fHVSt12Limits(0,5000),
- fHVSt345Limits(0,5000)
+ fStatus(new AliMUON2DMap(true)),
+ fHV(new TExMap),
+ fPedestals(calibData.Pedestals()),
+ fGains(calibData.Gains())
{
/// ctor
+ AliInfo(Form("ped store %s gain store %s",
+ fPedestals->ClassName(),
+ fGains->ClassName()));
}
//_____________________________________________________________________________
AliMUONPadStatusMaker::~AliMUONPadStatusMaker()
{
/// dtor.
+ delete fStatus;
+ delete fHV;
}
//_____________________________________________________________________________
-AliMUONVStore*
-AliMUONPadStatusMaker::Combine(const AliMUONVStore& store1,
- const AliMUONVStore& store2,
- Int_t binShift) const
+TString
+AliMUONPadStatusMaker::AsString(Int_t status)
{
- /// Combine two status containers into one, shifting store2 status bits
- /// to the left by binShift before making an OR with store1.
-
- TStopwatch timer;
- timer.Start(kTRUE);
-
- AliMUONVStore* combined = static_cast<AliMUONVStore*>(store1.Clone());
-
- TIter next(store1.CreateIterator());
- AliMUONVCalibParam* param1;
-
- while ( ( param1 = static_cast<AliMUONVCalibParam*>(next()) ) )
- {
- Int_t detElemId = param1->ID0();
- Int_t manuId = param1->ID1();
- AliMUONVCalibParam* param2 = static_cast<AliMUONVCalibParam*>(store2.FindObject(detElemId,manuId));
- if (!param2)
- {
- AliWarning(Form("Could not get statuses for store2 for DE %d ManuId %d. Marking as missing.",
- detElemId,manuId));
- param2 = static_cast<AliMUONVCalibParam*>(param1->Clone());
- for ( Int_t manuChannel = 0; manuChannel < param2->Size(); ++manuChannel )
- {
- param2->SetValueAsInt(manuChannel,0,kMissing);
- }
- }
- AliMUONVCalibParam* paramCombined = static_cast<AliMUONVCalibParam*>(combined->FindObject(detElemId,manuId));
- if (!paramCombined)
- {
- paramCombined = static_cast<AliMUONVCalibParam*>(param2->Clone());
- combined->Add(paramCombined);
- }
-
- for ( Int_t manuChannel = 0; manuChannel < param1->Size(); ++manuChannel )
- {
- if ( AliMpManuList::DoesChannelExist(detElemId, manuId, manuChannel) )
- {
- Int_t status1(param1->ValueAsInt(manuChannel));
- Int_t status2(param2->ValueAsInt(manuChannel));
-
- Int_t status = status1 | (status2 << binShift);
-
- paramCombined->SetValueAsInt(manuChannel,0,status);
- }
- }
- }
-
- AliInfo("Timer:");
- StdoutToAliInfo(timer.Print(););
-
- return combined;
+ /// return a human readable version of the integer status
+ Int_t pedStatus;
+ Int_t gainStatus;
+ Int_t hvStatus;
+
+ DecodeStatus(status,pedStatus,hvStatus,gainStatus);
+
+// /// Gain status
+// enum EGainStatus
+// {
+// kGainOK = 0,
+// kGainA0TooLow = (1<<1),
+// kGainA0TooHigh = (1<<2),
+// kGainA1TooLow = (1<<3),
+// kGainA1TooHigh = (1<<4),
+// kGainThresTooLow = (1<<5),
+// kGainThresTooHigh = (1<<6),
+//
+// kGainMissing = kMissing // please always use last bit for meaning "missing"
+// };
+//
+// /// Pedestal status
+// enum EPedestalStatus
+// {
+// kPedOK = 0,
+// kPedMeanZero = (1<<1),
+// kPedMeanTooLow = (1<<2),
+// kPedMeanTooHigh = (1<<3),
+// kPedSigmaTooLow = (1<<4),
+// kPedSigmaTooHigh = (1<<5),
+//
+// kPedMissing = kMissing // please always use last bit for meaning "missing"
+// };
+//
+ TString s("PED ");
+
+ if ( pedStatus == 0 ) s+= " OK";
+ if ( pedStatus & kPedMeanZero ) s += " Mean is Zero. ";
+ if ( pedStatus & kPedMeanTooLow ) s += " Mean Too Low. ";
+ if ( pedStatus & kPedMeanTooHigh ) s += " Mean Too High. ";
+ if ( pedStatus & kPedSigmaTooLow ) s += " Sigma Too Low. ";
+ if ( pedStatus & kPedSigmaTooHigh ) s += " Sigma Too High. ";
+ if ( pedStatus & kPedMissing ) s += " is missing.";
+
+// /// HV Error
+// enum EHVError
+// {
+// kHVOK = 0,
+// kHVError = (1<<0),
+// kHVTooLow = (1<<1),
+// kHVTooHigh = (1<<2),
+// kHVChannelOFF = (1<<3),
+// kHVSwitchOFF = (1<<4),
+//
+// kHVMissing = kMissing // please always use last bit for meaning "missing"
+// };
+
+ return s;
}
//_____________________________________________________________________________
-AliMUONVStore*
-AliMUONPadStatusMaker::GeneratePadStatus(Int_t value)
+Int_t
+AliMUONPadStatusMaker::BuildStatus(Int_t pedStatus,
+ Int_t hvStatus,
+ Int_t gainStatus)
{
- /// Generate a "fake" store, with all (detElemId,manuId) present,
- /// and containing all the same value
-
- AliMUONVStore* store = new AliMUON2DMap(true);
-
- TList* list = AliMpManuList::ManuList();
-
- AliMpIntPair* pair;
-
- TIter next(list);
+ /// Build a complete status from specific parts (ped,hv,gain)
- while ( ( pair = static_cast<AliMpIntPair*>(next()) ) )
- {
- Int_t detElemId = pair->GetFirst();
- Int_t manuId = pair->GetSecond();
- AliMUONVCalibParam* param = new AliMUONCalibParamNI(1,AliMpConstants::ManuNofChannels(),detElemId,manuId,value);
- store->Add(param);
- }
-
- delete list;
+ return ( hvStatus & 0xFF ) | ( ( pedStatus & 0xFF ) << 8 ) |
+ ( ( gainStatus & 0xFF ) << 16 );
+}
+
+//_____________________________________________________________________________
+void
+AliMUONPadStatusMaker::DecodeStatus(Int_t status,
+ Int_t& pedStatus,
+ Int_t& hvStatus,
+ Int_t& gainStatus)
+{
+ /// Decode complete status into specific parts (ped,hv,gain)
- return store;
+ gainStatus = ( status & 0xFF0000 ) >> 16;
+ pedStatus = ( status & 0xFF00 ) >> 8;
+ hvStatus = (status & 0xFF);
}
//_____________________________________________________________________________
Bool_t
-AliMUONPadStatusMaker::GetSt12Status(const TMap& hvMap,
- Int_t detElemId, Int_t sector,
- Bool_t& hvChannelTooLow,
- Bool_t& hvChannelTooHigh,
- Bool_t& hvChannelON) const
+AliMUONPadStatusMaker::HVSt12Status(Int_t detElemId, Int_t sector,
+ Bool_t& hvChannelTooLow,
+ Bool_t& hvChannelTooHigh,
+ Bool_t& hvChannelON) const
{
/// Get HV status for one HV sector of St12
/// and the switch).
/// Returns false if hv switch changed during the run.
+ AliCodeTimerAuto("")
+
Bool_t error = kFALSE;
hvChannelTooLow = kFALSE;
hvChannelTooHigh = kFALSE;
hvChannelON = kTRUE;
-
- AliMUONHVNamer hvNamer;
+
+ AliMpHVNamer hvNamer;
TString hvChannel(hvNamer.DCSHVChannelName(detElemId,sector));
- TPair* hvPair = static_cast<TPair*>(hvMap.FindObject(hvChannel.Data()));
+ TMap* hvMap = fCalibrationData.HV();
+ TPair* hvPair = static_cast<TPair*>(hvMap->FindObject(hvChannel.Data()));
if (!hvPair)
{
AliError(Form("Did not find expected alias (%s) for DE %d",
//_____________________________________________________________________________
Bool_t
-AliMUONPadStatusMaker::GetSt345Status(const TMap& hvMap,
- Int_t detElemId, Int_t pcbIndex,
- Bool_t& hvChannelTooLow,
- Bool_t& hvChannelTooHigh,
- Bool_t& hvChannelON,
- Bool_t& hvSwitchON) const
+AliMUONPadStatusMaker::HVSt345Status(Int_t detElemId, Int_t pcbIndex,
+ Bool_t& hvChannelTooLow,
+ Bool_t& hvChannelTooHigh,
+ Bool_t& hvChannelON,
+ Bool_t& hvSwitchON) const
{
/// For a given PCB in a given DE, get the HV status (both the channel
/// and the switch).
/// Returns false if something goes wrong (in particular if
/// hv switch changed during the run).
+ AliCodeTimerAuto("")
+
Bool_t error = kFALSE;
hvChannelTooLow = kFALSE;
hvChannelTooHigh = kFALSE;
hvSwitchON = kTRUE;
hvChannelON = kTRUE;
- AliMUONHVNamer hvNamer;
+ AliMpHVNamer hvNamer;
TString hvChannel(hvNamer.DCSHVChannelName(detElemId));
- TPair* hvPair = static_cast<TPair*>(hvMap.FindObject(hvChannel.Data()));
+ TMap* hvMap = fCalibrationData.HV();
+
+ TPair* hvPair = static_cast<TPair*>(hvMap->FindObject(hvChannel.Data()));
if (!hvPair)
{
AliError(Form("Did not find expected alias (%s) for DE %d",
float highThreshold = fHVSt345Limits.Y();
if ( hvMin < lowThreshold ) hvChannelTooLow = kTRUE;
- if ( hvMax > highThreshold ) hvChannelTooHigh = kTRUE;
+ else if ( hvMax > highThreshold ) hvChannelTooHigh = kTRUE;
if ( hvMin < 1 ) hvChannelON = kFALSE;
}
}
TString hvSwitch(hvNamer.DCSHVSwitchName(detElemId,pcbIndex));
- TPair* switchPair = static_cast<TPair*>(hvMap.FindObject(hvSwitch.Data()));
+ TPair* switchPair = static_cast<TPair*>(hvMap->FindObject(hvSwitch.Data()));
if (!switchPair)
{
AliError(Form("Did not find expected alias (%s) for DE %d PCB %d",
}
//_____________________________________________________________________________
-AliMUONVStore*
-AliMUONPadStatusMaker::MakeGainStatus(const AliMUONVStore& /*gainValues*/) const
+Int_t
+AliMUONPadStatusMaker::HVStatus(Int_t detElemId, Int_t manuId) const
{
- /// FIXME: to be implemented
- AliWarning("Not implemented yet");
- return 0x0;
-}
-
-//_____________________________________________________________________________
-AliMUONVStore*
-AliMUONPadStatusMaker::MakeHVStatus(const TMap& hvValues) const
-{
- /// Scrutinize HV values and deduce an HV status for each pad
+ /// Get HV status of one manu
- TStopwatch timerSt12;
- TStopwatch timerSt345;
+ AliCodeTimerAuto("")
- timerSt12.Start(kTRUE);
- timerSt12.Stop();
- timerSt345.Start(kTRUE);
- timerSt345.Stop();
-
- AliMUONHVNamer hvNamer;
-
- AliMpDEIterator deIt;
+ if ( !fCalibrationData.HV() ) return kMissing;
+
+ Long_t lint = fHV->GetValue(AliMpManuUID::BuildUniqueID(detElemId,manuId));
- deIt.First();
+ if ( lint )
+ {
+ return (Int_t)(lint - 1);
+ }
+
+ Int_t status(0);
- AliMUONVStore* hv = new AliMUON2DMap(kTRUE);
+ AliMpHVNamer hvNamer;
- while ( !deIt.IsDone() )
+ switch ( AliMpDEManager::GetStationType(detElemId) )
{
- Int_t detElemId = deIt.CurrentDEId();
-
- switch ( AliMpDEManager::GetStationType(detElemId) )
+ case AliMp::kStation1:
+ case AliMp::kStation2:
{
- case AliMp::kStation1:
- case AliMp::kStation2:
- timerSt12.Start(kFALSE);
- for ( int sector = 0; sector < 3; ++sector)
- {
- AliDebug(1,Form("detElemId %5d sector %d",detElemId,sector));
-
- Bool_t hvChannelTooLow, hvChannelTooHigh, hvChannelON;
- Bool_t error = GetSt12Status(hvValues,
- detElemId,sector,
- hvChannelTooLow,hvChannelTooHigh,
- hvChannelON);
- Int_t status = 0;
- if ( error ) status |= kHVError;
- if ( hvChannelTooLow ) status |= kHVTooLow;
- if ( hvChannelTooHigh ) status |= kHVTooHigh;
- if ( !hvChannelON ) status |= kHVChannelOFF;
- SetStatusSt12(*hv,detElemId,sector,status);
-
- }
- timerSt12.Stop();
- break;
- case AliMp::kStation345:
+ int sector = hvNamer.ManuId2Sector(detElemId,manuId);
+ if ( sector >= 0 )
{
- timerSt345.Start(kFALSE);
- for ( Int_t pcbIndex = 0; pcbIndex < hvNamer.NumberOfPCBs(detElemId); ++pcbIndex)
- {
- AliDebug(1,Form("detElemId %5d pcbIndex %d",detElemId,pcbIndex));
- Bool_t hvChannelTooLow, hvChannelTooHigh, hvChannelON,hvSwitchON;
- Bool_t error = GetSt345Status(hvValues,
- detElemId,pcbIndex,
- hvChannelTooLow,hvChannelTooHigh,
- hvChannelON,hvSwitchON);
- Int_t status = 0;
- if ( error ) status |= kHVError;
- if ( hvChannelTooLow ) status |= kHVTooLow;
- if ( hvChannelTooHigh ) status |= kHVTooHigh;
- if ( !hvSwitchON ) status |= kHVSwitchOFF;
- if ( !hvChannelON) status |= kHVChannelOFF;
- SetStatusSt345(*hv,detElemId,pcbIndex,status);
- }
- timerSt345.Stop();
+ Bool_t hvChannelTooLow, hvChannelTooHigh, hvChannelON;
+ Bool_t error = HVSt12Status(detElemId,sector,
+ hvChannelTooLow,
+ hvChannelTooHigh,
+ hvChannelON);
+ if ( error ) status |= kHVError;
+ if ( hvChannelTooLow ) status |= kHVTooLow;
+ if ( hvChannelTooHigh ) status |= kHVTooHigh;
+ if ( !hvChannelON ) status |= kHVChannelOFF;
+ // assign this status to all the other manus handled by the same HV channel
+ SetHVStatus(detElemId,sector,status);
+ }
+ }
+ break;
+ case AliMp::kStation345:
+ {
+ int pcbIndex = hvNamer.ManuId2PCBIndex(detElemId,manuId);
+ if ( pcbIndex >= 0 )
+ {
+ Bool_t hvChannelTooLow, hvChannelTooHigh, hvChannelON,hvSwitchON;
+ Bool_t error = HVSt345Status(detElemId,pcbIndex,
+ hvChannelTooLow,hvChannelTooHigh,
+ hvChannelON,hvSwitchON);
+ if ( error ) status |= kHVError;
+ if ( hvChannelTooLow ) status |= kHVTooLow;
+ if ( hvChannelTooHigh ) status |= kHVTooHigh;
+ if ( !hvSwitchON ) status |= kHVSwitchOFF;
+ if ( !hvChannelON) status |= kHVChannelOFF;
+ // assign this status to all the other manus handled by the same HV channel
+ SetHVStatus(detElemId,pcbIndex,status);
}
- break;
- default:
- break;
}
- deIt.Next();
+ break;
+ default:
+ break;
}
- AliInfo("St12 timer:");
- StdoutToAliInfo(timerSt12.Print(););
- AliInfo("St345 timer:");
- StdoutToAliInfo(timerSt345.Print(););
-
- return hv;
+ return status;
+}
+
+//_____________________________________________________________________________
+AliMUONVCalibParam*
+AliMUONPadStatusMaker::Neighbours(Int_t detElemId, Int_t manuId) const
+{
+ /// Get the neighbours parameters for a given manu
+ AliMUONVStore* neighbourStore = fCalibrationData.Neighbours();
+ return static_cast<AliMUONVCalibParam*>(neighbourStore->FindObject(detElemId,manuId));
}
//_____________________________________________________________________________
AliMUONVStore*
-AliMUONPadStatusMaker::MakePedestalStatus(const AliMUONVStore& pedValues) const
+AliMUONPadStatusMaker::NeighboursStore() const
{
- /// Assign a pedestal status to each pad
+ /// Return the store containing all the neighbours
+ return fCalibrationData.Neighbours();
+}
+
+//_____________________________________________________________________________
+AliMUONVCalibParam*
+AliMUONPadStatusMaker::ComputeStatus(Int_t detElemId, Int_t manuId) const
+{
+ /// Compute the status of a given manu, using all available information,
+ /// i.e. pedestals, gains, and HV
- TStopwatch timer;
+// AliCodeTimerAuto("")
- timer.Start(kTRUE);
+// AliCodeTimerStart("Param creation");
+ AliMUONVCalibParam* param = new AliMUONCalibParamNI(1,AliMpConstants::ManuNofChannels(),detElemId,manuId,-1);
+ fStatus->Add(param);
+// AliCodeTimerStop("Param creation");
- AliMUONVStore* pedStatuses = new AliMUON2DMap(kTRUE);
+// AliCodeTimerStart("FindObject");
+ AliMUONVCalibParam* pedestals = static_cast<AliMUONVCalibParam*>(fPedestals->FindObject(detElemId,manuId));
+
+ AliMUONVCalibParam* gains = static_cast<AliMUONVCalibParam*>(fGains->FindObject(detElemId,manuId));
+// AliCodeTimerStop("FindObject");
- TIter next(pedValues.CreateIterator());
- AliMUONVCalibParam* pedestals;
- Int_t nofManus(0);
+ Int_t hvStatus = HVStatus(detElemId,manuId);
+
+// AliCodeTimerStart("Loop");
- while ( ( pedestals = static_cast<AliMUONVCalibParam*>(next() ) ) )
+ for ( Int_t manuChannel = 0; manuChannel < param->Size(); ++manuChannel )
{
- Int_t detElemId = pedestals->ID0();
- Int_t manuId = pedestals->ID1();
- ++nofManus;
- for ( Int_t manuChannel = 0; manuChannel < pedestals->Size(); ++manuChannel )
+ Int_t pedStatus(0);
+
+ if (pedestals)
{
- Int_t status(0);
- if ( AliMpManuList::DoesChannelExist(detElemId, manuId, manuChannel) )
- {
- Float_t pedMean = pedestals->ValueAsFloat(manuChannel,0);
- Float_t pedSigma = pedestals->ValueAsFloat(manuChannel,1);
- if ( pedMean < fPedMeanLimits.X() ) status |= kPedMeanTooLow;
- if ( pedMean > fPedMeanLimits.Y() ) status |= kPedMeanTooHigh;
- if ( pedSigma < fPedSigmaLimits.X() ) status |= kPedSigmaTooLow;
- if ( pedSigma > fPedSigmaLimits.Y() ) status |= kPedSigmaTooHigh;
- if ( pedMean == 0 ) status |= kPedMeanZero;
-
- AliMUONVCalibParam* vStatus =
- static_cast<AliMUONVCalibParam*>(pedStatuses->FindObject(detElemId,manuId));
- if ( !vStatus )
- {
- vStatus = new AliMUONCalibParamNI(1,AliMpConstants::ManuNofChannels(),detElemId,manuId,0);
- pedStatuses->Add(vStatus);
- }
- vStatus->SetValueAsInt(manuChannel,0,status);
- }
+ Float_t pedMean = pedestals->ValueAsFloatFast(manuChannel,0);
+ Float_t pedSigma = pedestals->ValueAsFloatFast(manuChannel,1);
+ if ( pedMean < fPedMeanLimits.X() ) pedStatus |= kPedMeanTooLow;
+ else if ( pedMean > fPedMeanLimits.Y() ) pedStatus |= kPedMeanTooHigh;
+ if ( pedSigma < fPedSigmaLimits.X() ) pedStatus |= kPedSigmaTooLow;
+ else if ( pedSigma > fPedSigmaLimits.Y() ) pedStatus |= kPedSigmaTooHigh;
+ if ( pedMean == 0 ) pedStatus |= kPedMeanZero;
+ }
+ else
+ {
+ pedStatus = kPedMissing;
+ }
+
+ Int_t gainStatus(0);
+
+ if ( gains )
+ {
+ Float_t a0 = gains->ValueAsFloatFast(manuChannel,0);
+ Float_t a1 = gains->ValueAsFloatFast(manuChannel,1);
+ Float_t thres = gains->ValueAsFloatFast(manuChannel,2);
+
+ if ( a0 < fGainA0Limits.X() ) gainStatus |= kGainA0TooLow;
+ else if ( a0 > fGainA0Limits.Y() ) gainStatus |= kGainA0TooHigh;
+ if ( a1 < fGainA1Limits.X() ) gainStatus |= kGainA1TooLow;
+ else if ( a1 > fGainA1Limits.Y() ) gainStatus |= kGainA1TooHigh;
+ if ( thres < fGainThresLimits.X() ) gainStatus |= kGainThresTooLow;
+ else if ( thres > fGainThresLimits.Y() ) gainStatus |= kGainThresTooHigh;
}
+ else
+ {
+ gainStatus = kGainMissing;
+ }
+
+ Int_t status = BuildStatus(pedStatus,hvStatus,gainStatus);
+
+ param->SetValueAsIntFast(manuChannel,0,status);
}
- AliInfo(Form("%d manus checked in :",nofManus));
- StdoutToAliInfo(timer.Print(););
- return pedStatuses;
+// AliCodeTimerStop("Loop");
+
+ return param;
}
//_____________________________________________________________________________
-AliMUONVStore*
-AliMUONPadStatusMaker::MakeStatus() const
+AliMUONVCalibParam*
+AliMUONPadStatusMaker::PadStatus(Int_t detElemId, Int_t manuId) const
{
- /// Read ped, gains and hv values from CDB, apply some Q&A and produces
- /// a combined status for each pad.
-
- TMap* hvValues = fCalibrationData.HV();
- AliMUONVStore* hvStatus(0x0);
-
- if (!hvValues)
- {
- AliError("Could not get HV values from CDB. Will create dummy ones and mark those as missing");
- hvStatus = GeneratePadStatus(kHVMissing);
- }
- else
- {
- hvStatus = MakeHVStatus(*hvValues);
- }
-
- AliMUONVStore* pedValues = fCalibrationData.Pedestals();
- AliMUONVStore* pedStatus(0x0);
-
- if (!pedValues)
- {
- AliError("Could not get pedestals values from CDB. Will create dummy ones and mark those as missing");
- pedStatus = GeneratePadStatus(kPedMissing);
- }
- else
- {
- pedStatus = MakePedestalStatus(*pedValues);
- }
-
- // FIXME: should do the same for gains as for hv and ped.
-
- AliMUONVStore* status = Combine(*hvStatus,*pedStatus,8);
+ /// Get the status for a given channel
- delete hvStatus;
- delete pedStatus;
-
- // Insure we get all channels there (some or even all can be bad, but they
- // must be there somehow).
-
- AliMUON2DStoreValidator validator;
-
- TObjArray* a = validator.Validate(*status);
-
- if (a)
+ AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(fStatus->FindObject(detElemId,manuId));
+ if (!param)
{
- // this should not happen.
- AliError("Status store not complete. Crash to follow soon...");
- StdoutToAliError(a->Print(););
- AliFatal("this should not happen at all!");
- delete status;
- status = 0x0;
+ // not already there, so compute it now
+ AliCodeTimerAuto("ComputeStatus");
+ param = ComputeStatus(detElemId,manuId);
}
-
- return status;
+ return param;
}
//_____________________________________________________________________________
-void
-AliMUONPadStatusMaker::SetStatusSt12(AliMUONVStore& hvStatus,
- Int_t detElemId,
- Int_t isector,
- Int_t status) const
+Int_t
+AliMUONPadStatusMaker::PadStatus(Int_t detElemId, Int_t manuId, Int_t manuChannel) const
{
- /// Flag all pads of detElemId (for St12) as bad.
-
- // FIXME: need a way to iterator on pads over a given HV sector for St12...
- // we currently suppose that one sector is about a third of the chamber...
- // FIXME !! This has to be checked very carefully...
+ /// Get the status for a given channel
- const AliMp::CathodType kCathodes[] = { AliMp::kCath0, AliMp::kCath1 };
-
- for ( Int_t icathode = 0; icathode < 2; ++icathode )
+ AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(fStatus->FindObject(detElemId,manuId));
+ if (!param)
{
- const AliMpSectorSegmentation* seg =
- static_cast<const AliMpSectorSegmentation*>(AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,kCathodes[icathode]));
- const AliMpSector* sector = seg->GetSector();
- AliMpMotifMap* mMap = sector->GetMotifMap();
- TArrayI a;
-
- mMap->GetAllMotifPositionsIDs(a);
-
- TVector2 dim = seg->Dimensions();
- Double_t x = dim.X()*2;
- Double_t xmin = isector*x/3.0;
- Double_t xmax = xmin + x/3.0;
-
- for ( Int_t i = 0; i < a.GetSize(); ++i )
- {
- AliMpMotifPosition* pos = mMap->FindMotifPosition(a[i]);
- Int_t manuId = pos->GetID();
- TVector2 position = pos->Position();
- if ( position.X() >= xmin && position.X() <= xmax)
- {
- AliMUONVCalibParam* dead =
- static_cast<AliMUONVCalibParam*>(hvStatus.FindObject(detElemId,manuId));
- if (!dead)
- {
- dead = new AliMUONCalibParamNI(1,AliMpConstants::ManuNofChannels(),detElemId,manuId,status);
- hvStatus.Add(dead);
- }
- else
- {
- // FIXME: this should really not happen, if we'd know really the
- // relationship between manuId and HV sector...
- // For the time being, let's leave it like that, for testing
- // purposes only. For production, this will have to be fixed.
- AliWarning("Please fixme.");
- }
- }
- }
- }
+ // not already there, so compute it now
+ param = ComputeStatus(detElemId,manuId);
+ }
+ return param->ValueAsInt(manuChannel,0);
}
//_____________________________________________________________________________
void
-AliMUONPadStatusMaker::SetStatusSt345(AliMUONVStore& hvStatus,
- Int_t detElemId, Int_t pcbIndex,
- Int_t status) const
+AliMUONPadStatusMaker::SetHVStatus(Int_t detElemId, Int_t index, Int_t status) const
{
- /// Flag all pads of pcbIndex-th PCB of detElemId (for St345) as bad.
+ /// Assign status to all manus in a given HV "zone" (defined by index, meaning
+ /// is different thing from St12 and St345)
+
+ AliCodeTimerAuto("")
+
+ AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
- const AliMp::CathodType kCathodes[] = { AliMp::kCath0, AliMp::kCath1 };
+ const AliMpArrayI* manus = de->ManusForHV(index);
- for ( Int_t icathode = 0; icathode < 2; ++icathode )
+ for ( Int_t i = 0; i < manus->GetSize(); ++ i )
{
- const AliMpSlatSegmentation* seg = static_cast<const AliMpSlatSegmentation*>
- (AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,kCathodes[icathode]));
- const AliMpSlat* slat = seg->Slat();
- const AliMpPCB* pcb = slat->GetPCB(pcbIndex);
-
- for ( Int_t i = 0; i < pcb->GetSize(); ++i )
- {
- AliMpMotifPosition* pos = pcb->GetMotifPosition(i);
- Int_t manuId = pos->GetID();
- AliMUONVCalibParam* dead =
- static_cast<AliMUONVCalibParam*>(hvStatus.FindObject(detElemId,manuId));
- if (dead)
- {
- AliError(Form("dead is not null as expected from DE %d manuId %d",
- detElemId,manuId));
- }
- if (!dead)
- {
- dead = new AliMUONCalibParamNI(1,AliMpConstants::ManuNofChannels(),detElemId,manuId,status);
- hvStatus.Add(dead);
- }
- }
+ Int_t manuId = manus->GetValue(i);
+ fHV->Add(AliMpManuUID::BuildUniqueID(detElemId,manuId),status + 1);
}
}
-
-
-
# include "TVector2.h"
#endif
+class TExMap;
class AliMUONCalibrationData;
+class AliMUONVCalibParam;
class AliMUONVStore;
-class TMap;
class AliMUONPadStatusMaker : public TObject
{
AliMUONPadStatusMaker(const AliMUONCalibrationData& calibData);
virtual ~AliMUONPadStatusMaker();
- AliMUONVStore* MakeGainStatus(const AliMUONVStore& gainValues) const;
+ /** Get access to internal status store (for debug only, as it may not be complete,
+ depending on whether you've already called PadStatus for all possible de,manu
+ combinations or not...
+ */
+ AliMUONVStore* StatusStore() const { return fStatus; }
- AliMUONVStore* MakeHVStatus(const TMap& hvMap) const;
-
- AliMUONVStore* MakePedestalStatus(const AliMUONVStore& pedValues) const;
-
- /// Produces a status store. Should not return 0x0.
- AliMUONVStore* MakeStatus() const;
-
- static AliMUONVStore* GeneratePadStatus(Int_t value);
+ AliMUONVCalibParam* PadStatus(Int_t detElemId, Int_t manuId) const;
+ Int_t PadStatus(Int_t detElemId, Int_t manuId, Int_t manuChannel) const;
+
+ AliMUONVStore* NeighboursStore() const;
+
+ AliMUONVCalibParam* Neighbours(Int_t detElemId, Int_t manuId) const;
+
+ static TString AsString(Int_t status);
+
+ /// Return Low and High limits for a0 parameter of gain (linear slope)
+ TVector2 GainA0Limits() const { return fGainA0Limits; }
+ /// Return Low and High limits for a1 parameter of gain (parabolic term)
+ TVector2 GainA1Limits() const { return fGainA1Limits; }
+ /// Return Low and High limits for thres parameter of gain
+ TVector2 GainThresLimits() const { return fGainThresLimits; }
+
/// Return Low and High threshold for St12 HV
TVector2 HVSt12Limits() const { return fHVSt12Limits; }
/// Return Low and High threshold for St345 HV
/// Return Low and High threshold for pedestal sigma
TVector2 PedSigmaLimits() const { return fPedSigmaLimits; }
+ /// Set Low and High limits for a0 parameter of gain (linear slope)
+ void GainA0Limits(float low, float high) { fGainA0Limits.Set(low,high); }
+ /// Set Low and High limits for a1 parameter of gain (parabolic term)
+ void GainA1Limits(float low, float high) { fGainA1Limits.Set(low,high); }
+ /// Set Low and High limits for thres parameter of gain
+ void GainThresLimits(float low, float high) { fGainThresLimits.Set(low,high); }
+
/// Set Low and High threshold for St12 HV
void SetHVSt12Limits(float low, float high) { fHVSt12Limits.Set(low,high); }
/// Set Low and High threshold for St345 HV
AliMUONPadStatusMaker(const AliMUONPadStatusMaker&);
/// Not implemented
AliMUONPadStatusMaker& operator=(const AliMUONPadStatusMaker&);
+
+ static void DecodeStatus(Int_t status, Int_t& pedStatus, Int_t& hvStatus, Int_t& gainStatus);
+ static Int_t BuildStatus(Int_t pedStatus, Int_t hvStatus, Int_t gainStatus);
-private:
-
- AliMUONVStore* Combine(const AliMUONVStore& store1,
- const AliMUONVStore& store2,
- Int_t binShift) const;
-
- Bool_t GetSt12Status(const TMap& hvMap, Int_t detElemId, Int_t sector,
- Bool_t& hvChannelTooLow,
- Bool_t& hvChannelTooHigh,
- Bool_t& hvChannelON) const;
-
+ AliMUONVCalibParam* ComputeStatus(Int_t detElemId, Int_t manuId) const;
+
+ Bool_t HVSt12Status(Int_t detElemId, Int_t sector,
+ Bool_t& hvChannelTooLow,
+ Bool_t& hvChannelTooHigh,
+ Bool_t& hvChannelON) const;
- Bool_t GetSt345Status(const TMap& hvMap, Int_t detElemId, Int_t pcbIndex,
- Bool_t& hvChannelTooLow,
- Bool_t& hvChannelTooHigh,
- Bool_t& hvChannelON,
- Bool_t& hvSwitchON) const;
- void SetStatusSt12(AliMUONVStore& hvStatus,
- Int_t detElemId, Int_t sector, Int_t status) const;
+ Bool_t HVSt345Status(Int_t detElemId, Int_t pcbIndex,
+ Bool_t& hvChannelTooLow,
+ Bool_t& hvChannelTooHigh,
+ Bool_t& hvChannelON,
+ Bool_t& hvSwitchON) const;
- void SetStatusSt345(AliMUONVStore& hvStatus,
- Int_t detElemId, Int_t pcbIndex, Int_t status) const;
+ Int_t HVStatus(Int_t detElemId, Int_t manuId) const;
+
+ void SetHVStatus(Int_t detElemId, Int_t index, Int_t status) const;
-
private:
/// General status
enum EGeneralStatus
{
kMissing = (1<<7)
};
+
+ /// Gain status
+ enum EGainStatus
+ {
+ kGainOK = 0,
+ kGainA0TooLow = (1<<1),
+ kGainA0TooHigh = (1<<2),
+ kGainA1TooLow = (1<<3),
+ kGainA1TooHigh = (1<<4),
+ kGainThresTooLow = (1<<5),
+ kGainThresTooHigh = (1<<6),
+
+ kGainMissing = kMissing // please always use last bit for meaning "missing"
+ };
/// Pedestal status
enum EPedestalStatus
};
const AliMUONCalibrationData& fCalibrationData; //!< helper class to get data access (not owner)
- TVector2 fPedMeanLimits; //!< Low and High threshold for pedestal mean
- TVector2 fPedSigmaLimits; //!< Low and High threshold for pedestal sigma
+ TVector2 fGainA0Limits; //!< Low and High threshold for gain a0 parameter
+ TVector2 fGainA1Limits; //!< Low and High threshold for gain a1 parameter
+ TVector2 fGainThresLimits; //!< Low and High threshold for gain threshold parameter
+
TVector2 fHVSt12Limits; //!< Low and High threshold for St12 HV
TVector2 fHVSt345Limits; //!< Low and High threshold for St345 HV
+
+ TVector2 fPedMeanLimits; //!< Low and High threshold for pedestal mean
+ TVector2 fPedSigmaLimits; //!< Low and High threshold for pedestal sigma
+
+ AliMUONVStore* fStatus; //!< statuses of the pads
+
+ mutable TExMap* fHV; //!< cache of hv statuses
+
+ AliMUONVStore* fPedestals; //!< pedestal values
+ AliMUONVStore* fGains; //!< gain values
ClassDef(AliMUONPadStatusMaker,0) // Creates pad statuses from ped,gain,hv
};
//-----------------------------------------------------------------------------
/// \class AliMUONPadStatusMapMaker
///
-/// Convert a pad status container into a pad status *map* container
+/// Convert a pad statuses into pad status maps.
///
/// A pad status is one 32-bits word describing whether this pad pedestal, gains
/// hv is correct or not.
#include "AliLog.h"
#include "AliMUON2DMap.h"
#include "AliMUONCalibParamNI.h"
-#include "AliMUONCalibrationData.h"
+#include "AliMUONPadStatusMaker.h"
#include "AliMUONVStore.h"
#include "AliMUONVCalibParam.h"
#include "AliMpConstants.h"
-#include "AliMpIntPair.h"
-#include "AliMpManuList.h"
#include <Riostream.h>
#include <TList.h>
-#include <TStopwatch.h>
+#include "AliCodeTimer.h"
/// \cond CLASSIMP
ClassImp(AliMUONPadStatusMapMaker)
Int_t AliMUONPadStatusMapMaker::fgkSelfDead = 1;
//_____________________________________________________________________________
-AliMUONPadStatusMapMaker::AliMUONPadStatusMapMaker(const AliMUONCalibrationData& calibData)
+AliMUONPadStatusMapMaker::AliMUONPadStatusMapMaker(const AliMUONPadStatusMaker& padStatusMaker,
+ Int_t mask,
+ Bool_t deferredInitialization)
: TObject(),
-fStatus(0x0),
-fMask(0),
-fCalibrationData(calibData)
+fStatusMaker(padStatusMaker),
+fMask(mask),
+fStatusMap(new AliMUON2DMap(true))
{
/// ctor
-}
-
-//_____________________________________________________________________________
-AliMUONPadStatusMapMaker::~AliMUONPadStatusMapMaker()
-{
- /// dtor
-}
-
-//_____________________________________________________________________________
-Int_t
-AliMUONPadStatusMapMaker::ComputeStatusMap(const AliMUONVCalibParam& neighbours,
- Int_t manuChannel,
- Int_t detElemId) const
-{
- /// Given a list of neighbours of one pad (which includes the pad itself)
- /// compute the status map (aka deadmap) for that pad.
-
- Int_t statusMap(0);
-
- //Compute the statusmap related to the status of neighbouring
- //pads. An invalid pad means "outside of edges".
-
- Int_t n = neighbours.Dimension();
- for ( Int_t i = 0; i < n; ++i )
+ if (!deferredInitialization)
{
- Int_t x = neighbours.ValueAsInt(manuChannel,i);
- Int_t m,c;
- neighbours.UnpackValue(x,m,c);
- if ( c < 0 ) continue;
- Int_t status = 0;
- if ( !m )
- {
- status = -1;
- }
- else
+ AliCodeTimerAuto("Computing complete status map at once");
+ AliMUONVStore* neighboursStore = padStatusMaker.NeighboursStore();
+ AliMUONVCalibParam* param;
+ TIter next(neighboursStore->CreateIterator());
+ while ( ( param = static_cast<AliMUONVCalibParam*>(next()) ) )
{
- status = GetPadStatus(detElemId,m,c);
- }
- if ( ( fMask==0 && status !=0 ) || ( (status & fMask) != 0 ) )
- {
- statusMap |= (1<<i);
+ Int_t detElemId = param->ID0();
+ Int_t manuId = param->ID1();
+ ComputeStatusMap(detElemId,manuId);
}
}
- return statusMap;
-}
-
-//_____________________________________________________________________________
-Int_t
-AliMUONPadStatusMapMaker::GetPadStatus(Int_t detElemId,
- Int_t manuId, Int_t manuChannel) const
-
-{
- /// Get the pad status
- AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(fStatus->FindObject(detElemId,manuId));
- return param->ValueAsInt(manuChannel);
}
//_____________________________________________________________________________
-AliMUONVStore*
-AliMUONPadStatusMapMaker::MakeEmptyPadStatusMap()
+AliMUONPadStatusMapMaker::~AliMUONPadStatusMapMaker()
{
- /// Make an empty (but complete) statusMap
-
- AliMUONVStore* store = new AliMUON2DMap(true);
-
- TList* list = AliMpManuList::ManuList();
-
- AliMpIntPair* pair;
-
- TIter next(list);
-
- while ( ( pair = static_cast<AliMpIntPair*>(next()) ) )
- {
- Int_t detElemId = pair->GetFirst();
- Int_t manuId = pair->GetSecond();
- AliMUONVCalibParam* param = new AliMUONCalibParamNI(1,AliMpConstants::ManuNofChannels(),
- detElemId,manuId,
- 0);
- store->Add(param);
- }
-
- delete list;
-
- return store;
+ /// dtor
+ delete fStatusMap;
}
//_____________________________________________________________________________
-AliMUONVStore*
-AliMUONPadStatusMapMaker::MakePadStatusMap(const AliMUONVStore& status,
- Int_t mask)
+AliMUONVCalibParam*
+AliMUONPadStatusMapMaker::ComputeStatusMap(Int_t detElemId, Int_t manuId) const
{
- /// Given the status store for all pads, compute a status map store
- /// for all pads.
- /// \param status
- /// \param mask is the status mask to be tested to tell if a pad is ok or not
+ /// Compute the status map for a given manu, and add it to our internal
+ /// fStatusMap internal storage
- fStatus = &status;
- fMask = mask;
-
- TStopwatch timer;
- timer.Start(kTRUE);
-
- AliMUONVStore* neighbourStore = fCalibrationData.Neighbours();
+ AliCodeTimerAuto("(Int_t,Int_t)")
+
+ AliMUONVCalibParam* param = new AliMUONCalibParamNI(1,AliMpConstants::ManuNofChannels(),
+ detElemId,manuId,-1);
+
+ Bool_t ok = fStatusMap->Add(param);
+ if (!ok)
+ {
+ AliFatal(Form("Could not add manu %d of de %d",manuId,detElemId));
+ }
+
+ AliMUONVCalibParam* neighbours = fStatusMaker.Neighbours(detElemId,manuId);
- AliMUONVStore* statusMap = status.Create();
+ AliMUONVCalibParam* statusParam = fStatusMaker.PadStatus(detElemId,manuId);
- TIter next(status.CreateIterator());
- AliMUONVCalibParam* statusEntry;
+ Int_t n = neighbours->Dimension();
- while ( ( statusEntry = static_cast<AliMUONVCalibParam*>(next()) ) )
+ for ( Int_t manuChannel = 0; manuChannel < param->Size(); ++manuChannel )
{
- Int_t detElemId = statusEntry->ID0();
- Int_t manuId = statusEntry->ID1();
-
- AliMUONVCalibParam* statusMapEntry = static_cast<AliMUONVCalibParam*>
- (statusMap->FindObject(detElemId,manuId));
-
- if (!statusMapEntry)
- {
- statusMapEntry = new AliMUONCalibParamNI(1,AliMpConstants::ManuNofChannels(),
- detElemId,manuId,0);
- statusMap->Add(statusMapEntry);
- }
-
- AliMUONVCalibParam* neighbours = static_cast<AliMUONVCalibParam*>
- (neighbourStore->FindObject(detElemId,manuId));
+ Int_t statusMap(0);
- if (!neighbours)
+ Int_t x = neighbours->ValueAsIntFast(manuChannel,0);
+ if ( x < 0 )
{
- AliFatal(Form("Could not find neighbours for DE %d manuId %d",
- detElemId,manuId));
+ // channel is not a valid one (i.e. (manuId,manuChannel) is not an existing pad)
+ statusMap = -1;//fgkSelfDead;
continue;
}
-
- for ( Int_t manuChannel = 0; manuChannel < statusEntry->Size(); ++manuChannel )
+
+ for ( Int_t i = 0; i < n; ++i )
{
- // Loop over channels and for each channel loop on its immediate neighbours
- // to produce a statusMap word for this channel.
-
- Int_t statusMapValue(0);
-
- Int_t x = neighbours->ValueAsInt(manuChannel,0);
-
- if ( x > 0 )
- {
- // channel is a valid one (i.e. (manuId,manuChannel) is an existing pad)
- statusMapValue = ComputeStatusMap(*neighbours,manuChannel,detElemId);
+ // Compute the statusmap related to the status of neighbouring
+ // pads. An invalid pad means "outside of edges".
+
+ Int_t x = neighbours->ValueAsIntFast(manuChannel,i);
+ Int_t m,c;
+ neighbours->UnpackValue(x,m,c);
+ if ( c < 0 ) continue;
+ Int_t status = 0;
+ if ( !m )
+ {
+ status = -1;
}
else
{
- statusMapValue = fgkSelfDead;
+ status = statusParam->ValueAsIntFast(c); //fStatusMaker.PadStatus(detElemId,m,c);
}
-
- statusMapEntry->SetValueAsInt(manuChannel,0,statusMapValue);
- }
+ if ( ( fMask==0 && status !=0 ) || ( (status & fMask) != 0 ) )
+ {
+ statusMap |= (1<<i);
+ }
+ }
+ param->SetValueAsIntFast(manuChannel,0,statusMap);
}
- timer.Stop();
-
- StdoutToAliInfo(
- cout << "MakePadStatusMap total timer : ";
- timer.Print();
- cout << endl;
- );
-
- return statusMap;
+ return param;
}
+//_____________________________________________________________________________
+Int_t
+AliMUONPadStatusMapMaker::StatusMap(Int_t detElemId, Int_t manuId,
+ Int_t manuChannel) const
+
+{
+ /// Get the pad status map
+
+ AliMUONVCalibParam* param = static_cast<AliMUONVCalibParam*>(fStatusMap->FindObject(detElemId,manuId));
+ if (!param)
+ {
+ // not yet computed, so do it now
+ param = ComputeStatusMap(detElemId,manuId);
+ }
+ return param->ValueAsInt(manuChannel);
+}