#include <cstdlib>
#include "AliMpDDLStore.h"
+#include "AliMpExMapIterator.h"
#include "AliMpConstants.h"
#include "AliMpDEStore.h"
+#include "AliMpFrtCrocusConstants.h"
#include "AliMpDDL.h"
#include "AliMpFiles.h"
+#include "AliMpDataStreams.h"
#include "AliMpHelper.h"
#include "AliMpDEManager.h"
+#include "AliMpManuStore.h"
#include "AliMpDetElement.h"
#include "AliMpBusPatch.h"
#include "AliMpTriggerCrate.h"
#include "AliMpSegmentation.h"
#include "AliMpVSegmentation.h"
#include "AliMpStringObjMap.h"
+#include "AliMpEncodePair.h"
+#include "AliMpIntPair.h"
#include "AliLog.h"
}
//______________________________________________________________________________
-AliMpDDLStore* AliMpDDLStore::ReadData(Bool_t warn)
+AliMpDDLStore* AliMpDDLStore::ReadData(const AliMpDataStreams& dataStreams,
+ Bool_t warn)
{
/// Load the DDL store from ASCII data files
/// and return its instance
return fgInstance;
}
- AliInfoClass("Reading DDL Store from ASCII files.");
+ if ( dataStreams.GetReadFromFiles() )
+ AliInfoClass("Reading Manu Store from ASCII files.");
- fgInstance = new AliMpDDLStore();
+ fgInstance = new AliMpDDLStore(dataStreams);
return fgInstance;
}
//
//______________________________________________________________________________
-AliMpDDLStore::AliMpDDLStore()
+AliMpDDLStore::AliMpDDLStore(const AliMpDataStreams& dataStreams)
: TObject(),
+ fkDataStreams(dataStreams),
fDDLs(fgkNofDDLs+fgkNofTriggerDDLs), // FIXEME
- fBusPatches(true),
+ fBusPatches(),
fManuList12(),
fManuBridge2(),
- fGlobalCrate(),
fRegionalTrigger()
{
- /// Standard constructor
-
- AliDebug(1,"");
- fDDLs.SetOwner(true);
- fBusPatches.SetOwner(true);
- fBusPatches.SetSize(900);
-
- // Load segmentation & DE store data
- if ( ! AliMpSegmentation::Instance(false) )
- AliMpSegmentation::ReadData(true);
-
- // Create all detection elements
- ReadDDLs();
- ReadTrigger();
- SetTriggerDDLs();
- SetManus();
- ReadBusPatchSpecial();
- SetPatchModules();
- SetBusPatchLength();
+ /// Standard constructor
+
+ AliDebug(1,"");
+ fDDLs.SetOwner(true);
+ fBusPatches.SetOwner(true);
+ fBusPatches.SetSize(900);
+
+ // Load segmentation & DE store data
+ if ( ! AliMpSegmentation::Instance(false) )
+ AliMpSegmentation::ReadData(dataStreams, true);
+
+ // Create all detection elements
+ ReadDDLs();
+ ReadTrigger();
+ SetTriggerDDLs();
+ SetManus();
+ ReadBusPatchSpecial();
+ SetPatchModules();
+ ReadBusPatchInfo();
}
//______________________________________________________________________________
AliMpDDLStore::AliMpDDLStore(TRootIOCtor* ioCtor)
: TObject(),
+ fkDataStreams(ioCtor),
fDDLs(),
- fBusPatches(),
- fGlobalCrate(ioCtor),
+ fBusPatches(ioCtor),
fRegionalTrigger(ioCtor)
{
/// Constructor for I0
{
/// Read ddl <-> bus patch file
- TString infile = AliMpFiles::BusPatchFilePath();
-
- ifstream in(infile, ios::in);
- if (!in) {
- AliErrorStream() << "Data file " << infile << " not found.";
- return false;
- }
+ istream& in
+ = fkDataStreams.
+ CreateDataStream(AliMpFiles::BusPatchFilePath());
char line[255];
TString sManu = ((TObjString*)stringList->At(3))->GetString();
AliMpHelper::DecodeName(sManu,',',fManuList12[GetManuListIndex(idDE)]);
- if(AliMpDEManager::GetStationType(idDE) == AliMp::kStation2) {
+ if(AliMpDEManager::GetStation12Type(idDE) == AliMq::kStation2) {
TString sManuBridge = ((TObjString*)stringList->At(4))->GetString();
AliMpHelper::DecodeName(sManuBridge,',',fManuBridge2[GetManuListIndex(idDE)]);
}
ddl->FillBusPatchIds();
}
- in.close();
+ delete ∈
return true;
}
{
/// create trigger DDL object and Global crate object
- if ( ! fGlobalCrate.ReadData() ) return false;
-
- if ( ! fRegionalTrigger.ReadData() ) return false;
+ if ( ! fRegionalTrigger.ReadData(fkDataStreams) ) return false;
return true;
}
//______________________________________________________________________________
-Bool_t AliMpDDLStore::SetTriggerDDLs()
+Bool_t
+AliMpDDLStore::SetTriggerDDLs()
{
-/// Create trigger DDLs and set DDL Ids in the regional trigger
-
+ /// Create trigger DDLs and set DDL Ids in the regional trigger
Int_t iDDL = -1;
-
- for ( Int_t i=0; i<fRegionalTrigger.GetNofTriggerCrates(); ++i ) {
+ TIter next(fRegionalTrigger.CreateCrateIterator());
+ AliMpTriggerCrate* crate;
- AliMpTriggerCrate* crate = fRegionalTrigger.GetTriggerCrateFast(i);
-
+ while ( ( crate = static_cast<AliMpTriggerCrate*>(next()) ) )
+ {
TString crateName = crate->GetName();
// determine ddl number vs crate side
}
//______________________________________________________________________________
-Bool_t AliMpDDLStore::SetManus() {
+Bool_t AliMpDDLStore::SetManus()
+{
/// Set manus for each bus patch
Int_t manuMask = AliMpConstants::ManuMask(AliMp::kNonBendingPlane) - 1;
/// Read file with bus patches with a special order of manus
/// and reset the manus arrays filled via SetManu function
- TString infile = AliMpFiles::BusPatchSpecialFilePath();
-
- ifstream in(infile, ios::in);
- if (!in) {
- AliErrorStream() << "Data file " << infile << " not found.";
- return false;
- }
+ istream& in
+ = fkDataStreams.
+ CreateDataStream(AliMpFiles::BusPatchSpecialFilePath());
char line[255];
}
}
+ delete ∈
+
return kTRUE;
}
//______________________________________________________________________________
-Bool_t AliMpDDLStore::SetPatchModules() {
+Bool_t AliMpDDLStore::SetPatchModules()
+{
/// Compute the number of manu per PCB for each buspatch
AliMpDEIterator it;
Bool_t newResult = false;
Int_t idDE = busPatch->GetDEId();
- if (AliMpDEManager::GetStationType(idDE) == AliMp::kStation2 )
+ if (AliMpDEManager::GetStation12Type(idDE) == AliMq::kStation2 )
newResult = busPatch->SetNofManusPerModule(fManuBridge2[GetManuListIndex(idDE)].At(i));
else
newResult = busPatch->SetNofManusPerModule();
}
//______________________________________________________________________________
-Bool_t AliMpDDLStore::SetBusPatchLength() {
- /// read the buspatch length file and set buspatch length
-
- TString infile = AliMpFiles::BusPatchLengthFilePath();
- ifstream in(infile, ios::in);
- if (!in) {
- AliErrorStream() << "Data file " << infile << " not found.";
- return false;
- }
+Bool_t AliMpDDLStore::ReadBusPatchInfo()
+{
+ /// read the buspatch info file and set buspatch info
+
+ istream& in
+ = fkDataStreams.
+ CreateDataStream(AliMpFiles::BusPatchInfoFilePath());
+
char line[255];
for (Int_t iDDL = 0; iDDL < fgkNofDDLs; ++iDDL ) {
TObjArray* stringList = tmp.Tokenize(TString(" "));
- TString sLocalBusId = ((TObjString*)stringList->At(0))->GetString();
- Int_t localBusId = sLocalBusId.Atoi();
-
- TString sLength = ((TObjString*)stringList->At(1))->GetString();
- Float_t length = sLength.Atof();
+ // Crocus label
+ TString crLabel = ((TObjString*)stringList->At(0))->GetString();
+ Int_t pos = crLabel.First('-');
+ tmp = crLabel(pos-2, crLabel.Length()-pos+2);
+ TArrayI list;
+ AliMpHelper::DecodeName(tmp.Data(), '-', list);
+
+ Int_t localDDLId = list[0];
+ Int_t frtId = list[1] - 1; // begin at zero !
+ Int_t localBusId = list[2];
+
+ // Add FRT number for given ddl if not present
+ if ( !ddl->HasFrtId(frtId) )
+ ddl->AddFrt(frtId);
+
+ // BP & translator label
+ TString label = ((TObjString*)stringList->At(1))->GetString();
+ TString transLabel = ((TObjString*)stringList->At(2))->GetString();
+
+ // BP length
+ TString sLength = ((TObjString*)stringList->At(3))->GetString();
+ Float_t length = sLength.Atof();
delete stringList;
-
+
if (localBusId != iBusPatch + 1)
- AliWarning(Form("Wrong local buspatch id %d instead of %d", iBusPatch+1, localBusId));
+ AliWarning(Form("Wrong local buspatch id %d instead of %d", iBusPatch+1, localBusId));
+
+ if(localDDLId != ddl->GetId()+1)
+ AliWarning(Form("Wrong local DDL id %d instead of %d", ddl->GetId()+1, localDDLId));
Int_t busPatchId = ddl->GetBusPatchId(iBusPatch);
AliMpBusPatch* busPatch = GetBusPatch(busPatchId);
busPatch->SetCableLength(length);
+ busPatch->SetCableLabel(label);
+ busPatch->SetTranslatorLabel(transLabel);
+ busPatch->SetFrtId(frtId);
+
}
}
+
+ delete ∈
return true;
}
Int_t AliMpDDLStore::GetLocalBoardId(TString name) const {
/// return the first board with a given side and line
-
- TExMapIter i = fRegionalTrigger.GetLocalBoardItr();
- Long_t key, value;
- while ( i.Next(key, value) ) {
- AliMpLocalBoard* local = (AliMpLocalBoard*)value;
-
+ TIter next(fRegionalTrigger.CreateLocalBoardIterator());
+ AliMpLocalBoard* local;
+
+ while ( ( local = static_cast<AliMpLocalBoard*>(next()) ) )
+ {
TString tmp(&local->GetName()[4], 2);
if (name.Contains(tmp))
if (name[0] == local->GetName()[0])
}
return 0;
-
}
//
return busPatch;
}
+
//______________________________________________________________________________
AliMpLocalBoard* AliMpDDLStore::GetLocalBoard(Int_t localBoardId, Bool_t warn) const {
/// Return bus patch with given Id
return detElement->GetBusPatchId(pos);
}
+
//______________________________________________________________________________
-AliMpIntPair AliMpDDLStore::GetDetElemIdManu(Int_t manuSerial) const {
- /// Return the detElemId and manuId for given serial manu number
+Long_t AliMpDDLStore::GetLinkPortId(Int_t busPatchId) const {
- if ( ! AliMpDEStore::Instance() ) {
- AliFatal("DE Store has not been loaded.");
- return AliMpIntPair::Invalid();
- }
+ /// Get link port and DSP from busPatch id.
+ /// Return -1 if the value is not valid
+ /// (the validity has to be tested in the client code)
+
+ AliMpBusPatch* busPatch = GetBusPatch(busPatchId);
+ Int_t ddlId = busPatch->GetDdlId();
+
+ Int_t localBusPatchId = AliMpBusPatch::GetLocalBusID(busPatchId, ddlId) - 1; // begin at zero
+
+ Int_t pos = (localBusPatchId % AliMpFrtCrocusConstants::GetNofBusPatches());
+
+ return AliMpFrtCrocusConstants::GetLinkPortId(pos);
- return AliMpDEStore::Instance()->GetDetElemIdManu(manuSerial);
}
//______________________________________________________________________________
}
cout << endl;
- cout << " Manu serial: ";
- for ( Int_t k=0; k<busPatch->GetNofManus(); ++k ) {
- cout << std::setw(6) << de->GetManuSerialFromId(busPatch->GetManuId(k)) << " ";
- }
- cout << endl;
+ if ( AliMpManuStore::Instance(kFALSE) ) {
+ cout << " Manu serial: ";
+ for ( Int_t k=0; k<busPatch->GetNofManus(); ++k ) {
+ cout << std::setw(6)
+ << AliMpManuStore::Instance()
+ ->GetManuSerial(de->GetId(), busPatch->GetManuId(k)) << " ";
+ }
+ cout << endl;
+ }
}
}
}
TString name(localBoard->GetName());
- Int_t line = localBoard->GetPosition().GetFirst();
+ Int_t line = AliMp::PairFirst(localBoard->GetPosition());
++line;
name.Replace(4,1,Form("%d", line));
TString name(localBoard->GetName());
- Int_t line = localBoard->GetPosition().GetFirst();
+ Int_t line = AliMp::PairFirst(localBoard->GetPosition());
--line;
name.Replace(4,1,Form("%d", line));
fRegionalTrigger = regionalTrigger;
- // Remove the existing trigger DDLs
+ // Remove the existing trigger DDLsf
fDDLs.RemoveAt(fgkNofDDLs+1);
fDDLs.RemoveAt(fgkNofDDLs);
// Set new trigger DDLs from new regional trigger
SetTriggerDDLs();
}
+
+
+//______________________________________________________________________________
+TIterator*
+AliMpDDLStore::CreateBusPatchIterator() const
+{
+/// Create the iterator over bus patches
+
+ return fBusPatches.CreateIterator();
+}