// $Id$
#include "AliMUONTriggerCrateStore.h"
-
+#include "AliMpExMapIterator.h"
#include "AliMUONTriggerCrate.h"
#include "AliMUONLocalTriggerBoard.h"
#include "AliMUONRegionalTriggerBoard.h"
+#include "AliMUONRegionalTriggerConfig.h"
+#include "AliMUONGlobalCrateConfig.h"
+#include "AliMUONTriggerCrateConfig.h"
+#include "AliMUONCalibrationData.h"
+#include "AliMUONTriggerLut.h"
#include "AliMpTriggerCrate.h"
#include "AliMpLocalBoard.h"
#include <TSystem.h>
#include <Riostream.h>
+#include <cstdio>
//-----------------------------------------------------------------------------
/// \class AliMUONTriggerCrateStore
AliMUONTriggerCrateStore::AliMUONTriggerCrateStore()
: TObject(),
fCrates(0x0),
-fLocalBoards(0x0),
-fCrateIterator(0x0),
-fLBIterator(0x0),
-fCurrentCrate(0x0),
-fCurrentLocalBoard(-1)
+fLocalBoards(0x0)
{
/// Default constructor
}
AliMUONTriggerCrateStore::~AliMUONTriggerCrateStore()
{
/// Destructor
- delete fCrateIterator;
- delete fLBIterator;
delete fCrates;
delete fLocalBoards;
}
return static_cast<AliMUONLocalTriggerBoard*>(fLocalBoards->GetValue(boardNumber));
}
+//_____________________________________________________________________________
+TIterator*
+AliMUONTriggerCrateStore::CreateCrateIterator() const
+{
+ /// Create iterator over crates
+
+ return fCrates ? fCrates->CreateIterator() : 0x0;
+}
+
+//_____________________________________________________________________________
+TIterator*
+AliMUONTriggerCrateStore::CreateLocalBoardIterator() const
+{
+ /// Create iterator over local boards
+
+ return fLocalBoards ? fLocalBoards->CreateIterator() : 0x0;
+}
+
//_____________________________________________________________________________
AliMUONTriggerCrate*
AliMUONTriggerCrateStore::Crate(const char *name) const
switch(reg) {
case 0:
case 1:
- sprintf(name,"%d", reg+1);
+ snprintf(name,10,"%d", reg+1);
break;
case 2:
strcpy(name, "2-3");
case 5:
case 6:
case 7:
- sprintf(name,"%d", reg);
+ snprintf(name,10,"%d", reg);
break;
}
// crate Right for first DDL
if (ddl == 0)
- strcat(name, "R");
+ strncat(name, "R", 1);
else
- strcat(name, "L");
+ strncat(name, "L", 1);
return TString(name);
}
-//_____________________________________________________________________________
-void
-AliMUONTriggerCrateStore::FirstCrate()
-{
- /// initialize iteration
- if ( !fCrates )
- {
- AliError("Object not properly initialized");
- return;
- }
- if (!fCrateIterator)
- {
- fCrateIterator = new TExMapIter(fCrates->GetIterator());
- }
- fCrateIterator->Reset();
-}
-
-//_____________________________________________________________________________
-void
-AliMUONTriggerCrateStore::FirstLocalBoard()
-{
- /// Initialize iterator on local boards.
- /// Please note that we're not using directly the FirstCrate() and
- /// NextCrate() methods here to avoid mix and match between crate iterator
- /// and local board iterator
- fCurrentCrate = 0x0;
- fCurrentLocalBoard = 0;
-
- if ( !fLBIterator )
- {
- fLBIterator = new TExMapIter(fCrates->GetIterator());
- }
- fLBIterator->Reset();
- Long_t key, value;
- Bool_t ok = fLBIterator->Next(key,value);
- if ( ok )
- {
- fCurrentCrate = reinterpret_cast<AliMUONTriggerCrate*>(value);
- fCurrentLocalBoard = 1;
- }
-}
-
-//_____________________________________________________________________________
-AliMUONTriggerCrate*
-AliMUONTriggerCrateStore::NextCrate()
-{
- /// Return the next crate in iteration, or 0 if iteration is ended.
- if (!fCrateIterator) return 0x0;
-
- Long_t key, value;
- Bool_t ok = fCrateIterator->Next(key,value);
- if (ok)
- {
- return reinterpret_cast<AliMUONTriggerCrate*>(value);
- }
- else
- {
- return 0x0;
- }
-}
-
-//_____________________________________________________________________________
-AliMUONLocalTriggerBoard*
-AliMUONTriggerCrateStore::NextLocalBoard()
-{
- /// Return the next local board in iteration, or 0 if iteration is ended.
- if ( !fLBIterator ) return 0x0;
-
- if ( fCurrentLocalBoard >= fCurrentCrate->Boards()->GetLast() +1)
-// if ( fCurrentLocalBoard >= fCurrentCrate->Boards()->GetLast() )
- {
- // try to go to next crate, if some are left
- Long_t key, value;
- Bool_t ok = fLBIterator->Next(key,value);
- if ( ok )
- {
- fCurrentCrate = reinterpret_cast<AliMUONTriggerCrate*>(value);
- fCurrentLocalBoard = 1;
- }
- else
- {
- fCurrentLocalBoard = 0;
- return 0x0;
- }
- }
-
- AliMUONLocalTriggerBoard* lb = static_cast<AliMUONLocalTriggerBoard*>
- (fCurrentCrate->Boards()->At(fCurrentLocalBoard));
-
- ++fCurrentLocalBoard;
-
- return lb;
-}
-
//_____________________________________________________________________________
Int_t
AliMUONTriggerCrateStore::NumberOfCrates() const
//_____________________________________________________________________________
void
-AliMUONTriggerCrateStore::ReadFromFile(const char* /*file*/) // keep old name for the moment
+AliMUONTriggerCrateStore::ReadFromFile(AliMUONCalibrationData* calibData)
{
- /// create crate and local board objects from mapping (Ch.F)
- fCrates = new AliMpExMap(kTRUE);
+ /// create crate and local board objects from mapping & calib (Ch.F)
+ fCrates = new AliMpExMap;
fCrates->SetOwner(kTRUE);
- fLocalBoards = new AliMpExMap(kTRUE);
+ fLocalBoards = new AliMpExMap;
fLocalBoards->SetOwner(kFALSE);
- TExMapIter itr = AliMpDDLStore::Instance()->GetTriggerCrateItr();
-
- Long_t key, value;
+
+ AliMUONTriggerLut* lut = calibData->TriggerLut();
- while(itr.Next(key, value))
+ if (!lut)
+ AliWarning("No valid trigger LUT in CDB");
+
+ AliMUONRegionalTriggerConfig* regionalConfig = calibData->RegionalTriggerConfig();
+ if (!regionalConfig) {
+ AliError("No valid regional trigger configuration in CDB");
+ return;
+ }
+
+ TIter next(AliMpDDLStore::Instance()->GetRegionalTrigger()->CreateCrateIterator());
+ AliMpTriggerCrate* crateMapping;
+
+ while ( ( crateMapping = static_cast<AliMpTriggerCrate*>(next()) ) )
{
- AliMpTriggerCrate* crateMapping = reinterpret_cast<AliMpTriggerCrate*>(value);
-
+
TString crateName = crateMapping->GetName();
AliMUONTriggerCrate *crate = Crate(crateName.Data());
+
+ AliMUONTriggerCrateConfig* crateConfig = regionalConfig->FindTriggerCrate(crateName);
if (!crate)
{
}
for(Int_t iLocal = 0; iLocal < crateMapping->GetNofLocalBoards(); ++iLocal) {
-
+
Int_t localBoardId = crateMapping->GetLocalBoardId(iLocal);
if (!localBoardId) continue; //empty slot, should not happen
AliMpLocalBoard* localBoardMapping = AliMpDDLStore::Instance()->GetLocalBoard(localBoardId);
AliDebug(3, Form("local name %s id %d\n", localBoardMapping->GetName(), localBoardId));
-
+
Int_t slot = localBoardMapping->GetSlot();
- AliMUONLocalTriggerBoard *board =
- new AliMUONLocalTriggerBoard(localBoardMapping);
+ AliMUONLocalTriggerBoard *board = new AliMUONLocalTriggerBoard(localBoardMapping);
+ board->SetCoinc44(crateConfig->GetCoinc());
+ board->SetLUT(lut);
+
if (localBoardMapping->IsNotified()) {
fLocalBoards->Add(localBoardId, board);
}
-
+
crate->AddBoard(board, slot);
-
+
} // iLocal
} // while
}
+