* provided "as is" without express or implied warranty. *
**************************************************************************/
+// $Id$
+
+//-----------------------------------------------------------------------------
/// \class AliMUONDigitMaker
/// MUON Digit maker from rawdata.
///
/// and for trigger. Create trigger inverse mapping.
///
/// \author Ch. Finck, oct 06
+//-----------------------------------------------------------------------------
#include "AliMUONDigitMaker.h"
-#include "AliLog.h"
#include "AliMUONDDLTrigger.h"
#include "AliMUONDarcHeader.h"
#include "AliMUONVDigit.h"
#include "AliMUONGlobalTrigger.h"
#include "AliMUONLocalStruct.h"
#include "AliMUONLocalTrigger.h"
-#include "AliMUONRawStreamTracker.h"
-#include "AliMUONRawStreamTrigger.h"
+#include "AliMUONLogger.h"
+#include "AliMUONRawStreamTrackerHP.h"
+#include "AliMUONRawStreamTriggerHP.h"
#include "AliMUONRegHeader.h"
-#include "AliMUONTriggerCircuit.h"
+#include "AliMUONVTriggerStore.h"
+#include "AliMpCDB.h"
+#include "AliMpDetElement.h"
#include "AliMpTriggerCrate.h"
#include "AliMpLocalBoard.h"
-#include "AliMUONVTriggerStore.h"
#include "AliMpCathodType.h"
#include "AliMpDDLStore.h"
#include "AliMpDEManager.h"
#include "AliMpPad.h"
#include "AliMpSegmentation.h"
#include "AliMpVSegmentation.h"
+#include "AliCodeTimer.h"
+#include "AliLog.h"
#include "AliRawReader.h"
#include <TArrayS.h>
/// \endcond
//__________________________________________________________________________
-AliMUONDigitMaker::AliMUONDigitMaker()
- : TObject(),
+AliMUONDigitMaker::AliMUONDigitMaker(Bool_t enableErrorLogger, Bool_t a, Bool_t b) :
+TObject(),
+fScalerEvent(kFALSE),
+fMakeTriggerDigits(kFALSE),
+fRawStreamTracker(new AliMUONRawStreamTrackerHP),
+fRawStreamTrigger(new AliMUONRawStreamTriggerHP),
+fDigitStore(0x0),
+fTriggerStore(0x0),
+fLogger(new AliMUONLogger(10000)){
+ /// ctor
+
+ if ( !a || !b ) AliFatal("no longer supported");
+
+ AliDebug(1,"");
+
+ // Standard Constructor
+ if (enableErrorLogger)
+ {
+ fRawStreamTracker->EnabbleErrorLogger();
+ fRawStreamTrigger->EnabbleErrorLogger();
+ }
+ else
+ {
+ fRawStreamTracker->DisableWarnings();
+ }
+
+ SetMakeTriggerDigits();
+
+ // Load mapping
+ if ( ! AliMpCDB::LoadDDLStore() ) {
+ AliFatal("Could not access mapping from OCDB !");
+ }
+}
+
+//__________________________________________________________________________
+AliMUONDigitMaker::AliMUONDigitMaker(Bool_t enableErrorLogger) :
+TObject(),
fScalerEvent(kFALSE),
fMakeTriggerDigits(kFALSE),
- fRawStreamTracker(new AliMUONRawStreamTracker()),
- fRawStreamTrigger(new AliMUONRawStreamTrigger()),
- fTrackerTimer(),
- fTriggerTimer(),
- fMappingTimer(),
+ fRawStreamTracker(new AliMUONRawStreamTrackerHP),
+ fRawStreamTrigger(new AliMUONRawStreamTriggerHP),
fDigitStore(0x0),
- fTriggerStore(0x0)
+ fTriggerStore(0x0),
+ fLogger(new AliMUONLogger(10000))
{
/// ctor
AliDebug(1,"");
-
+
// Standard Constructor
+ if (enableErrorLogger)
+ {
+ fRawStreamTracker->EnabbleErrorLogger();
+ fRawStreamTrigger->EnabbleErrorLogger();
+ }
+ else
+ {
+ fRawStreamTracker->DisableWarnings();
+ }
- fTrackerTimer.Start(kTRUE); fTrackerTimer.Stop();
- fTriggerTimer.Start(kTRUE); fTriggerTimer.Stop();
- fMappingTimer.Start(kTRUE); fMappingTimer.Stop();
-
SetMakeTriggerDigits();
+ // Load mapping
+ if ( ! AliMpCDB::LoadDDLStore() ) {
+ AliFatal("Could not access mapping from OCDB !");
+ }
}
//__________________________________________________________________________
delete fRawStreamTracker;
delete fRawStreamTrigger;
+ delete fLogger;
+}
- AliDebug(1, Form("Execution time for MUON tracker : R:%.2fs C:%.2fs",
- fTrackerTimer.RealTime(),fTrackerTimer.CpuTime()));
- AliDebug(1, Form(" Execution time for MUON tracker (mapping calls part) "
- ": R:%.2fs C:%.2fs",
- fMappingTimer.RealTime(),fMappingTimer.CpuTime()));
- AliDebug(1, Form("Execution time for MUON trigger : R:%.2fs C:%.2fs",
- fTriggerTimer.RealTime(),fTriggerTimer.CpuTime()));
+//____________________________________________________________________
+void
+AliMUONDigitMaker::Print(Option_t*) const
+{
+ /// Printout
+
+ cout << "RawStreamerTracker class=" << fRawStreamTracker->ClassName()
+ << " MakeTriggerDigits=" << fMakeTriggerDigits
+ << " ScalerEvent=" << fScalerEvent
+ << " DigitStore=" << fDigitStore
+ << " TriggerStore=" << fTriggerStore << endl;
+ if ( fLogger ) fLogger->Print();
}
//____________________________________________________________________
-Int_t AliMUONDigitMaker::Raw2Digits(AliRawReader* rawReader,
- AliMUONVDigitStore* digitStore,
- AliMUONVTriggerStore* triggerStore)
+Int_t
+AliMUONDigitMaker::Raw2Digits(AliRawReader* rawReader,
+ AliMUONVDigitStore* digitStore,
+ AliMUONVTriggerStore* triggerStore)
{
/// Main method to creates digit
/// for tracker
if (!fDigitStore && !fTriggerStore)
{
- AliError("No digit or trigger store given. Nothing to do...");
- return kFALSE;
+ fLogger->Log("No digit or trigger store given. Nothing to do...");
+ return kTriggerBAD & kTrackerBAD;
}
+ Int_t tracker(kOK);
+ Int_t trigger(kOK);
+
if ( fDigitStore )
{
fDigitStore->Clear(); // insure we start with an empty container
- ReadTrackerDDL(rawReader);
+ tracker = ReadTrackerDDL(rawReader);
}
if ( fTriggerStore || fMakeTriggerDigits )
if ( fTriggerStore ) fTriggerStore->Clear();
if ( fMakeTriggerDigits && !fDigitStore )
{
- AliError("Asking for trigger digits but digitStore is null");
+ fLogger->Log("Asking for trigger digits but digitStore is null");
}
else
{
- ReadTriggerDDL(rawReader);
+ trigger = ReadTriggerDDL(rawReader);
}
}
- return kTRUE;
+ return tracker | trigger;
}
//____________________________________________________________________
-Int_t AliMUONDigitMaker::ReadTrackerDDL(AliRawReader* rawReader)
+Int_t
+AliMUONDigitMaker::ReadTrackerDDL(AliRawReader* rawReader)
{
/// Reading tracker DDL
/// filling the fDigitStore container, which must not be null
AliDebug(1,"");
- fTrackerTimer.Start(kFALSE);
+ AliCodeTimerAuto("",0);
// elex info
Int_t buspatchId;
fRawStreamTracker->SetReader(rawReader);
fRawStreamTracker->First();
- while ( fRawStreamTracker->Next(buspatchId,manuId,channelId,charge) )
+ while ( fRawStreamTracker->Next(buspatchId,manuId,channelId,charge,kTRUE) )
{
// getting DE from buspatch
Int_t detElemId = AliMpDDLStore::Instance()->GetDEfromBus(buspatchId);
+ AliMpDetElement* de = AliMpDDLStore::Instance()->GetDetElement(detElemId);
+
+ if (!de)
+ {
+ fLogger->Log(Form("DE %04d does not exist !", detElemId));
+ continue;
+ }
+
+ if (!de->IsConnectedChannel(manuId,channelId))
+ {
+ // non connected pad, do nothing (this is not an error !)
+ continue;
+ }
+
const AliMpVSegmentation* seg
= AliMpSegmentation::Instance()->GetMpSegmentationByElectronics(detElemId,
manuId);
- AliMp::CathodType cathodeType = AliMpDEManager::GetCathod(detElemId,
- seg->PlaneType());
-
- AliMpPad pad = seg->PadByLocation(AliMpIntPair(manuId,channelId),kFALSE);
+ if (!seg)
+ {
+ fLogger->Log(Form("(DE,MANUID)=(%04d,%04d) is not valid",detElemId,manuId));
+ continue;
+ }
+ AliMp::CathodType cathodeType = de->GetCathodType(seg->PlaneType());
+
+ AliMpPad pad = seg->PadByLocation(manuId,channelId,kFALSE);
+
if (!pad.IsValid())
{
- AliError(Form("No pad for detElemId: %d, manuId: %d, channelId: %d",
+ fLogger->Log(Form("No pad for detElemId: %d, manuId: %d, channelId: %d",
detElemId, manuId, channelId));
continue;
}
-
+
AliMUONVDigit* digit = fDigitStore->Add(detElemId,manuId,channelId,cathodeType,
AliMUONVDigitStore::kDeny);
+
if (!digit)
{
- AliError(Form("Digit DE %04d Manu %04d Channel %02d could not be added",
+ fLogger->Log(Form("Digit DE %04d Manu %04d Channel %02d could not be added",
detElemId, manuId, channelId));
continue;
}
- digit->SetPadXY(pad.GetIndices().GetFirst(),
- pad.GetIndices().GetSecond());
+ digit->SetPadXY(pad.GetIx(),pad.GetIy());
- digit->SetADC(charge);
+ digit->SetADC(charge);
}
- fTrackerTimer.Stop();
-
- return kTRUE;
+ if ( fRawStreamTracker->IsErrorMessage() )
+ {
+ return kTrackerBAD;
+ }
+
+ return kOK;
}
//____________________________________________________________________
-Int_t AliMUONDigitMaker::ReadTriggerDDL(AliRawReader* rawReader)
+Int_t
+AliMUONDigitMaker::ReadTriggerDDL(AliRawReader* rawReader)
{
- /// reading tracker DDL
+ /// reading tracker DDL like ReadTriggerDDL but with fast decoder interface.
/// filling the fTriggerStore container, which must not be null
- AliDebug(1,"");
-
- AliMUONDDLTrigger* ddlTrigger = 0x0;
- AliMUONDarcHeader* darcHeader = 0x0;
- AliMUONRegHeader* regHeader = 0x0;
- AliMUONLocalStruct* localStruct = 0x0;
+ const AliMUONRawStreamTriggerHP::AliHeader* darcHeader = 0x0;
+ const AliMUONRawStreamTriggerHP::AliRegionalHeader* regHeader = 0x0;
+ const AliMUONRawStreamTriggerHP::AliLocalStruct* localStruct = 0x0;
Int_t loCircuit;
- fTriggerTimer.Start(kFALSE);
-
fRawStreamTrigger->SetReader(rawReader);
- while (fRawStreamTrigger->NextDDL())
+ while (fRawStreamTrigger->NextDDL())
{
- ddlTrigger = fRawStreamTrigger->GetDDLTrigger();
- darcHeader = ddlTrigger->GetDarcHeader();
+ darcHeader = fRawStreamTrigger->GetHeaders();
// fill global trigger information
if (fTriggerStore)
{
AliMUONGlobalTrigger globalTrigger;
globalTrigger.SetFromGlobalResponse(darcHeader->GetGlobalOutput());
+ globalTrigger.SetFromGlobalInput(darcHeader->GetGlobalHeader()->fInput);
fTriggerStore->SetGlobal(globalTrigger);
}
}
- Int_t nReg = darcHeader->GetRegHeaderEntries();
+ Int_t nReg = fRawStreamTrigger->GetRegionalHeaderCount();
for(Int_t iReg = 0; iReg < nReg ;iReg++)
{ //reg loop
GetTriggerCrate(fRawStreamTrigger->GetDDL(), iReg);
if (!crate)
- AliWarning(Form("Missing crate number %d in DDL %d\n", iReg, fRawStreamTrigger->GetDDL()));
+ fLogger->Log(Form("Missing crate number %d in DDL %d\n", iReg, fRawStreamTrigger->GetDDL()));
- regHeader = darcHeader->GetRegHeaderEntry(iReg);
+ regHeader = fRawStreamTrigger->GetRegionalHeader(iReg);
- Int_t nLocal = regHeader->GetLocalEntries();
+ Int_t nLocal = regHeader->GetLocalStructCount();
for(Int_t iLocal = 0; iLocal < nLocal; iLocal++)
- {
+ {
- localStruct = regHeader->GetLocalEntry(iLocal);
+ localStruct = regHeader->GetLocalStruct(iLocal);
// if card exist
if (localStruct) {
if ( !loCircuit ) continue; // empty slot
- AliMpLocalBoard* localBoard = AliMpDDLStore::Instance()->GetLocalBoard(loCircuit, false);
+ AliMpLocalBoard* localBoard = AliMpDDLStore::Instance()->GetLocalBoard(loCircuit, kTRUE);
// skip copy cards
if( !localBoard->IsNotified())
continue;
- if (fTriggerStore)
+ if (fTriggerStore)
{
// fill local trigger
AliMUONLocalTrigger localTrigger;
- localTrigger.SetLocalStruct(loCircuit, *localStruct);
+ localTrigger.SetLocalStruct(loCircuit, *localStruct);
fTriggerStore->Add(localTrigger);
- }
+ }
if ( fMakeTriggerDigits )
{
localStruct->GetYPattern(xyPattern[1]);
TriggerDigits(loCircuit, xyPattern, *fDigitStore);
- }
+ }
} // if triggerY
} // iLocal
} // iReg
} // NextDDL
- fTriggerTimer.Stop();
-
- return kTRUE;
-
+ return kOK;
}
//____________________________________________________________________
Int_t AliMUONDigitMaker::TriggerDigits(Int_t nBoard,
- TArrayS* xyPattern,
+ const TArrayS* xyPattern,
AliMUONVDigitStore& digitStore) const
{
/// make digits for trigger from pattern, and add them to digitStore
+ AliCodeTimerAuto("",0);
+
Int_t detElemId;
AliMpLocalBoard* localBoard = AliMpDDLStore::Instance()->GetLocalBoard(nBoard);
+ Int_t n,b;
+
// loop over x1-4 and y1-4
for (Int_t iChamber = 0; iChamber < 4; ++iChamber)
{
{
// not quite sure about this
Int_t offset = 0;
- if (iCath && localBoard->GetSwitch(6)) offset = -8;
+ if (iCath && localBoard->GetSwitch(AliMpLocalBoard::kZeroAllYLSB)) offset = -8;
- AliMpPad pad = seg->PadByLocation(AliMpIntPair(nBoard,ibitxy+offset),kTRUE);
+ AliMpPad pad = seg->PadByLocation(nBoard,ibitxy+offset,kTRUE);
if (!pad.IsValid())
{
- AliWarning(Form("No pad for detElemId: %d, nboard %d, ibitxy: %d\n",
+ fLogger->Log(Form("No pad for detElemId: %d, nboard %d, ibitxy: %d\n",
detElemId, nBoard, ibitxy));
continue;
}
-
- AliMUONVDigit* digit = digitStore.Add(detElemId,nBoard,ibitxy,iCath,AliMUONVDigitStore::kDeny);
+
+ n = pad.GetLocalBoardId(0); // always take first location so that digits are not inserted several times
+ b = pad.GetLocalBoardChannel(0);
+
+ AliDebug(1,Form("Using localBoard %d ixy %d instead of %d,%d",
+ n,b,nBoard,ibitxy));
+
+ AliMUONVDigit* digit = digitStore.Add(detElemId,n,b,iCath,AliMUONVDigitStore::kDeny);
if (!digit)
{
- AliError(Form("Could not add digit DE %04d LocalBoard %03d ibitxy %02d cath %d",
- detElemId,nBoard,ibitxy,iCath));
- continue;
+ AliDebug(1, Form("Digit DE %04d LocalBoard %03d ibitxy %02d cath %d already in store",
+ detElemId,nBoard,ibitxy,iCath));
+ continue;
}
- Int_t padX = pad.GetIndices().GetFirst();
- Int_t padY = pad.GetIndices().GetSecond();
+ Int_t padX = pad.GetIx();
+ Int_t padY = pad.GetIy();
// fill digit
digit->SetPadXY(padX,padY);
} // ichamber
return kTRUE;
-}
+}
+
+//______________________________________________________________________________
+Bool_t
+AliMUONDigitMaker::TriggerToDigitsStore(const AliMUONVTriggerStore& triggerStore,
+ AliMUONVDigitStore& digitStore) const
+{
+ //
+ /// make (S)Digit for trigger
+ //
+
+ digitStore.Clear();
+
+ AliMUONLocalTrigger* locTrg;
+ TIter next(triggerStore.CreateLocalIterator());
+
+ while ( ( locTrg = static_cast<AliMUONLocalTrigger*>(next()) ) )
+ {
+ if (locTrg->IsNull()) continue;
+
+ TArrayS xyPattern[2];
+ locTrg->GetXPattern(xyPattern[0]);
+ locTrg->GetYPattern(xyPattern[1]);
+
+ Int_t nBoard = locTrg->LoCircuit();
+ TriggerDigits(nBoard, xyPattern, digitStore);
+ }
+ return kTRUE;
+}
+
+//______________________________________________________________________________
+void
+AliMUONDigitMaker::SetTryRecover(Bool_t flag)
+{
+ /// Instruct the decoder to try to recover corrupted raw data.
+ /// Only use for specific cases for which you know it will work...
+ fRawStreamTracker->TryRecover(flag);
+}