#include "AliMUONPadStatusMaker.h"
-#include "AliQAv1.h"
-
#include "AliMUON2DMap.h"
#include "AliMUON2DStoreValidator.h"
#include "AliMUONCalibParamNI.h"
#include "AliMUONCalibrationData.h"
+#include "AliMUONLogger.h"
+#include "AliMUONRecoParam.h"
#include "AliMUONStringIntMap.h"
+#include "AliMUONTrackerData.h"
#include "AliMUONVCalibParam.h"
-#include "AliMUONVTrackerData.h"
#include "AliMpArea.h"
#include "AliMpArrayI.h"
+#include "AliMpCDB.h"
#include "AliMpConstants.h"
#include "AliMpDDLStore.h"
#include "AliMpDEManager.h"
#include "AliMpDetElement.h"
#include "AliMpDCSNamer.h"
+#include "AliMpManuIterator.h"
#include "AliMpManuUID.h"
#include "AliCDBEntry.h"
fHVSt345Limits(0,5000),
fPedMeanLimits(0,4095),
fPedSigmaLimits(0,4095),
-fManuOccupancyLimits(0,0.1),
+fManuOccupancyLimits(0,1.0),
+fBuspatchOccupancyLimits(0,1.0),
+fDEOccupancyLimits(0,1.0),
fStatus(new AliMUON2DMap(true)),
fHV(new TExMap),
fPedestals(calibData.Pedestals()),
fGains(calibData.Gains()),
-fTrackerData(0x0),
-fKillMap(calibData.KillMap())
+fTrackerData(0x0)
{
/// ctor
- AliDebug(1,Form("ped store %s gain store %s",
- fPedestals->ClassName(),
- fGains->ClassName()));
-
- TString qaFileName(AliQAv1::GetQADataFileName("MUON",calibData.RunNumber()));
-
- // search the QA file in memory first.
- TFile* f = static_cast<TFile*>(gROOT->GetListOfFiles()->FindObject(qaFileName.Data()));
-
- if (!f)
- {
- // then tries to open it
- if ( gSystem->AccessPathName(qaFileName.Data()) == kFALSE )
- {
- f = TFile::Open(qaFileName.Data());
- if ( f )
- {
- AliDebug(1,Form("Got %s from disk",qaFileName.Data()));
- }
- }
- }
- else
+ if ( calibData.OccupancyMap() )
{
- AliDebug(1,Form("Got %s from memory",qaFileName.Data()));
- }
+ /// create a tracker data from the occupancy map
+ fTrackerData = new AliMUONTrackerData("OCC","OCC",*(calibData.OccupancyMap()));
+ }
- if (f)
- {
- TDirectory* d = gDirectory;
-
- f->cd("MUON/Raws");
-
- TIter next(gDirectory->GetListOfKeys());
- TKey* key;
-
- while ( ( key = static_cast<TKey*>(next()) ) && !fTrackerData )
- {
- TString name(key->GetName());
-
- if ( name.Contains("CALZ") )
- {
- fTrackerData = dynamic_cast<AliMUONVTrackerData*>(key->ReadObj());
- }
-
- }
-
- gDirectory = d;
-
- if ( fTrackerData )
- {
- AliInfo(Form("Will make a cut on MANU occupancy from TrackerData=%s",fTrackerData->GetName()));
- }
- else
- {
- AliWarning(Form("Found a QA file = %s, but could not get the expected TrackerData in there... (probably not a serious problem though)",
- f->GetName()));
- }
- }
- else
- {
- AliWarning("Did not find QA file, so will not use manu occupancy as a criteria");
- }
}
//_____________________________________________________________________________
AliMUONPadStatusMaker::~AliMUONPadStatusMaker()
{
/// dtor.
+
delete fStatus;
delete fHV;
- delete fKillMap;
+ delete fTrackerData;
}
//_____________________________________________________________________________
Int_t pedStatus;
Int_t gainStatus;
Int_t hvStatus;
- Int_t otherStatus;
+ Int_t occStatus;
- DecodeStatus(status,pedStatus,hvStatus,gainStatus,otherStatus);
+ DecodeStatus(status,pedStatus,hvStatus,gainStatus,occStatus);
TString s;
if ( hvStatus & kHVSwitchOFF ) s+="& HV has switch OFF ";
if ( hvStatus & kHVMissing ) s+="& HV is missing ";
- if ( otherStatus & kManuOccupancyTooHigh ) s+="& manu occupancy too high ";
- if ( otherStatus & kManuOccupancyTooLow ) s+="& manu occupancy too low ";
- if ( otherStatus & kKilled ) s+="& killed";
+ if ( occStatus & kManuOccupancyTooHigh ) s+="& manu occupancy too high ";
+ if ( occStatus & kManuOccupancyTooLow ) s+="& manu occupancy too low ";
+ if ( occStatus & kBusPatchOccupancyTooHigh ) s+="& bus patch occupancy too high ";
+ if ( occStatus & kBusPatchOccupancyTooLow ) s+="& bus patch occupancy too low ";
+ if ( occStatus & kDEOccupancyTooHigh ) s+="& DE occupancy too high ";
+ if ( occStatus & kDEOccupancyTooLow ) s+="& DE occupancy too low ";
if ( s[0] == '&' ) s[0] = ' ';
AliMUONPadStatusMaker::BuildStatus(Int_t pedStatus,
Int_t hvStatus,
Int_t gainStatus,
- Int_t otherStatus)
+ Int_t occStatus)
{
/// Build a complete status from specific parts (ped,hv,gain)
return ( hvStatus & 0xFF ) | ( ( pedStatus & 0xFF ) << 8 ) |
( ( gainStatus & 0xFF ) << 16 ) |
- ( ( otherStatus & 0xFF ) << 24 ) ;
+ ( ( occStatus & 0xFF ) << 24 ) ;
}
//_____________________________________________________________________________
Int_t& pedStatus,
Int_t& hvStatus,
Int_t& gainStatus,
- Int_t& otherStatus)
+ Int_t& occStatus)
{
/// Decode complete status into specific parts (ped,hv,gain)
- otherStatus = ( status & 0xFF000000 ) >> 24;
+ occStatus = ( status & 0xFF000000 ) >> 24;
gainStatus = ( status & 0xFF0000 ) >> 16;
pedStatus = ( status & 0xFF00 ) >> 8;
hvStatus = (status & 0xFF);
AliMUONVCalibParam* gains = static_cast<AliMUONVCalibParam*>(fGains->FindObject(detElemId,manuId));
- AliMUONVCalibParam* kill(0x0);
-
- if ( fKillMap )
- {
- kill = static_cast<AliMUONVCalibParam*>(fKillMap->FindObject(detElemId,manuId));
- }
-
Int_t hvStatus = HVStatus(detElemId,manuId);
- Int_t otherStatus = OtherStatus(detElemId,manuId);
+ Int_t occStatus = OccupancyStatus(detElemId,manuId);
for ( Int_t manuChannel = 0; manuChannel < param->Size(); ++manuChannel )
{
gainStatus = kGainMissing;
}
- if ( kill && (kill->ValueAsInt(manuChannel,0) > 0) )
- {
- otherStatus |= kKilled;
- }
-
- Int_t status = BuildStatus(pedStatus,hvStatus,gainStatus,otherStatus);
+ Int_t status = BuildStatus(pedStatus,hvStatus,gainStatus,occStatus);
param->SetValueAsIntFast(manuChannel,0,status);
}
//_____________________________________________________________________________
Int_t
-AliMUONPadStatusMaker::OtherStatus(Int_t detElemId, Int_t manuId) const
+AliMUONPadStatusMaker::OccupancyStatus(Int_t detElemId, Int_t manuId) const
{
/// Get the "other" status for a given manu
+
+ Int_t rv(0);
+
if ( fTrackerData )
{
- Double_t occ = fTrackerData->Manu(detElemId,manuId,2);
- if ( occ < fManuOccupancyLimits.X() )
+ const Int_t occIndex = 2;
+
+ Double_t occ = fTrackerData->DetectionElement(detElemId,occIndex);
+
+ if ( occ <= fDEOccupancyLimits.X() )
+ {
+ rv |= kDEOccupancyTooLow;
+ }
+ else if ( occ > fDEOccupancyLimits.Y() )
+ {
+ rv |= kDEOccupancyTooHigh;
+ }
+
+ Int_t busPatchId = AliMpDDLStore::Instance()->GetBusPatchId(detElemId,manuId);
+
+ occ = fTrackerData->BusPatch(busPatchId,occIndex);
+
+ if ( occ <= fBuspatchOccupancyLimits.X() )
+ {
+ rv |= kBusPatchOccupancyTooLow;
+ }
+ else if ( occ > fBuspatchOccupancyLimits.Y() )
{
- return kManuOccupancyTooLow;
+ rv |= kBusPatchOccupancyTooHigh;
}
- if ( occ > fManuOccupancyLimits.Y() )
+
+ occ = fTrackerData->Manu(detElemId,manuId,occIndex);
+
+ if ( occ <= fManuOccupancyLimits.X() )
+ {
+ rv |= kManuOccupancyTooLow;
+ }
+ else if ( occ > fManuOccupancyLimits.Y() )
{
- return kManuOccupancyTooHigh;
+ rv |= kManuOccupancyTooHigh;
}
}
- return 0;
+ return rv;
}
//_____________________________________________________________________________
fHV->Add(AliMpManuUID::BuildUniqueID(detElemId,manuId),status + 1);
}
}
+
+//_____________________________________________________________________________
+void
+AliMUONPadStatusMaker::SetLimits(const AliMUONRecoParam& recoParams)
+{
+ /// Set the limits from the recoparam
+
+ SetHVSt12Limits(recoParams.HVSt12LowLimit(),recoParams.HVSt12HighLimit());
+ SetHVSt345Limits(recoParams.HVSt345LowLimit(),recoParams.HVSt345HighLimit());
+
+ SetPedMeanLimits(recoParams.PedMeanLowLimit(),recoParams.PedMeanHighLimit());
+ SetPedSigmaLimits(recoParams.PedSigmaLowLimit(),recoParams.PedSigmaHighLimit());
+
+ SetGainA1Limits(recoParams.GainA1LowLimit(),recoParams.GainA1HighLimit());
+ SetGainA2Limits(recoParams.GainA2LowLimit(),recoParams.GainA2HighLimit());
+ SetGainThresLimits(recoParams.GainThresLowLimit(),recoParams.GainThresHighLimit());
+
+ SetManuOccupancyLimits(recoParams.ManuOccupancyLowLimit(),recoParams.ManuOccupancyHighLimit());
+ SetBuspatchOccupancyLimits(recoParams.BuspatchOccupancyLowLimit(),recoParams.BuspatchOccupancyHighLimit());
+ SetDEOccupancyLimits(recoParams.DEOccupancyLowLimit(),recoParams.DEOccupancyHighLimit());
+}
+
+//_____________________________________________________________________________
+void
+AliMUONPadStatusMaker::Report(UInt_t mask)
+{
+ /// Report the number of bad pads, according to the mask,
+ /// and the various reasons why they are bad (with occurence rates)
+
+ AliInfo("");
+ AliCodeTimerAuto("");
+
+ AliMUONLogger log(1064008);
+
+ Int_t nBadPads(0);
+ Int_t nPads(0);
+
+ AliMpManuIterator it;
+
+ Int_t detElemId, manuId;
+
+ while ( it.Next(detElemId,manuId) )
+ {
+ AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
+
+ for ( Int_t i = 0; i < AliMpConstants::ManuNofChannels(); ++i )
+ {
+ if ( de->IsConnectedChannel(manuId,i) )
+ {
+ ++nPads;
+
+ Int_t status = PadStatus(detElemId,manuId,i);
+
+ if ( ( status & mask) || (!mask && status) )
+ {
+ ++nBadPads;
+ log.Log(AsString(status));
+ }
+ }
+ }
+ }
+
+ TString msg;
+ Int_t ntimes;
+
+ cout << Form("According to mask %x (human readable form below) %6d pads are bad (over a total of %6d, i.e. %7.2f %%)",
+ mask,nBadPads,nPads,nPads ? nBadPads*100.0/nPads : 0.0) << endl;
+ cout << AliMUONPadStatusMaker::AsCondition(mask) << endl;
+ cout << "--------" << endl;
+
+ while ( log.Next(msg,ntimes) )
+ {
+ cout << Form("The message (%120s) occured %15d times (%7.4f %%)",msg.Data(),ntimes,ntimes*100.0/nPads) << endl;
+ }
+
+}
+