X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=blobdiff_plain;f=MUON%2FAliMUONPadStatusMapMaker.cxx;h=0d5904e6813ccf5608c7b97d47099a28f6ed3515;hp=3159b978a656d296314e180e7b470ade7684329b;hb=49e396d9109191e3a28de80f762436d150157334;hpb=a25ae7b508e27a40dfba750452e097b56c080de5 diff --git a/MUON/AliMUONPadStatusMapMaker.cxx b/MUON/AliMUONPadStatusMapMaker.cxx index 3159b978a65..0d5904e6813 100644 --- a/MUON/AliMUONPadStatusMapMaker.cxx +++ b/MUON/AliMUONPadStatusMapMaker.cxx @@ -18,7 +18,7 @@ //----------------------------------------------------------------------------- /// \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. @@ -55,15 +55,13 @@ #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 #include -#include +#include "AliCodeTimer.h" /// \cond CLASSIMP ClassImp(AliMUONPadStatusMapMaker) @@ -72,177 +70,114 @@ 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(next()) ) ) { - status = GetPadStatus(detElemId,m,c); - } - if ( ( fMask==0 && status !=0 ) || ( (status & fMask) != 0 ) ) - { - statusMap |= (1<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(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(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(next()) ) ) + for ( Int_t manuChannel = 0; manuChannel < param->Size(); ++manuChannel ) { - Int_t detElemId = statusEntry->ID0(); - Int_t manuId = statusEntry->ID1(); - - AliMUONVCalibParam* statusMapEntry = static_cast - (statusMap->FindObject(detElemId,manuId)); - - if (!statusMapEntry) - { - statusMapEntry = new AliMUONCalibParamNI(1,AliMpConstants::ManuNofChannels(), - detElemId,manuId,0); - statusMap->Add(statusMapEntry); - } - - AliMUONVCalibParam* neighbours = static_cast - (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<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(fStatusMap->FindObject(detElemId,manuId)); + if (!param) + { + // not yet computed, so do it now + param = ComputeStatusMap(detElemId,manuId); + } + return param->ValueAsInt(manuChannel); +}