X-Git-Url: http://git.uio.no/git/?p=u%2Fmrichter%2FAliRoot.git;a=blobdiff_plain;f=MUON%2Fmapping%2FAliMpDDLStore.cxx;h=e60a73331872265fba9d351db22a9097fd689834;hp=b4b692031fefba4946faa234231b46124a63b53d;hb=42d368d0397f5fc8ab30fe024e60664a87b00fb1;hpb=f0c620510552ddd9cffe86d72bc9779e44287267 diff --git a/MUON/mapping/AliMpDDLStore.cxx b/MUON/mapping/AliMpDDLStore.cxx index b4b692031fe..e60a7333187 100644 --- a/MUON/mapping/AliMpDDLStore.cxx +++ b/MUON/mapping/AliMpDDLStore.cxx @@ -24,7 +24,7 @@ // via various characteristics. // Authors: Ivana Hrivnacova, IPN Orsay // Christian Finck, SUBATECH Nantes - +#include "AliMpConstants.h" #include "AliMpDDLStore.h" #include "AliMpDEStore.h" #include "AliMpDDL.h" @@ -33,10 +33,13 @@ #include "AliMpDEManager.h" #include "AliMpDetElement.h" #include "AliMpBusPatch.h" +#include "AliMpSegmentation.h" +#include "AliMpVSegmentation.h" #include "AliLog.h" #include +#include /// \cond CLASSIMP ClassImp(AliMpDDLStore) @@ -70,7 +73,8 @@ AliMpDDLStore::AliMpDDLStore() : TObject(), fDDLs(fgkNofDDLs), fDetElements(AliMpDEStore::Instance()), - fBusPatches(true) + fBusPatches(true), + fManuList12() { /// Standard constructor @@ -81,6 +85,7 @@ AliMpDDLStore::AliMpDDLStore() // Create all detection elements ReadDDLs(); + SetManus(); } //______________________________________________________________________________ @@ -117,11 +122,44 @@ AliMpDDLStore::~AliMpDDLStore() // private methods // +//______________________________________________________________________________ +Int_t AliMpDDLStore::GetManuListIndex(Int_t detElemId) const +{ +/// Return the index of the manu list for given detElemId + + return AliMpDEManager::GetChamberId(detElemId)*4 + (detElemId % 100); +} + + +//______________________________________________________________________________ +Int_t AliMpDDLStore::GetBusPatchIndex(Int_t detElemId, Int_t manuId) const +{ +/// Calculate the index of the buspatch from manuId + + Int_t pos = 0; + AliMp::StationType stationType = AliMpDEManager::GetStationType(detElemId); + static Int_t manuMask = AliMpConstants::ManuMask(AliMp::kNonBendingPlane) - 1; + + if( stationType == AliMp::kStation345) { + pos = (manuId & manuMask)/100; + } else { + Int_t idx = GetManuListIndex(detElemId); + + // using array defined from DetElemIdToBusPatch.dat file + for (pos = fManuList12[idx].GetSize()-1; pos >= 0; --pos) + if ( manuId >= fManuList12[idx].At(pos)) break; + } + + return pos; +} + + //______________________________________________________________________________ Bool_t AliMpDDLStore::ReadDDLs() { /// Read ddl <-> bus patch file + TString infile = AliMpFiles::BusPatchFilePath(); ifstream in(infile, ios::in); @@ -130,9 +168,9 @@ Bool_t AliMpDDLStore::ReadDDLs() return false; } - char line[80]; + char line[255]; - while ( in.getline(line,80) ) { + while ( in.getline(line,255) ) { if ( line[0] == '#' ) continue; @@ -140,27 +178,35 @@ Bool_t AliMpDDLStore::ReadDDLs() Int_t blankPos = tmp.First(' '); Int_t blankPos1 = tmp.Last(' '); + Int_t length = 0; TString sDE(tmp(0, blankPos)); Int_t idDE = atoi(sDE.Data()); - TString sDDL(tmp(blankPos1 + 1, tmp.Length()-blankPos1)); + // reading 1st manu Id for each bus patch (station 1 & 2) + if(AliMpDEManager::GetStationType(idDE) != AliMp::kStation345) { - Int_t iDDL = atoi(sDDL.Data()); + TString sManu(tmp(blankPos1 + 1, tmp.Length()-blankPos1)); + AliMpHelper::DecodeName(sManu,',',fManuList12[GetManuListIndex(idDE)]); - // always working local DDL number... for the moment. + TString tmp1(tmp(blankPos + 1, blankPos1 - blankPos)); + blankPos1 = blankPos + tmp1.First(' ') + 1; + length = tmp.Last(' ') - blankPos1; - // not really needed remove for stand alone purpose (Ch.F) - // if (iDDL >= AliDAQ::DdlIDOffset("MUONTRK")) - // iDDL -= AliDAQ::DdlIDOffset("MUONTRK"); + } else { + length = tmp.Length()-blankPos1; + } + TString sDDL(tmp(blankPos1 + 1, length)); + Int_t iDDL = atoi(sDDL.Data()); + TString busPatch(tmp(blankPos + 1,blankPos1-blankPos-1)); AliDebugStream(3) - << "idDE " << idDE << " buspatch " << busPatch.Data() << " iDDL " << iDDL - << endl; - + << "idDE " << idDE << " buspatch " << busPatch.Data() << " iDDL " << iDDL + << endl; + if ( iDDL < 0 || iDDL >= fgkNofDDLs ) { AliErrorStream() << "DDL id "<< iDDL << " outside limits." << endl; return false; @@ -170,7 +216,6 @@ Bool_t AliMpDDLStore::ReadDDLs() AliErrorStream() << "DetElemId "<< idDE << " not valid." << endl; return false; } - AliMpDDL* ddl = GetDDL(iDDL, false); if ( !ddl) { @@ -179,7 +224,6 @@ Bool_t AliMpDDLStore::ReadDDLs() } ddl->AddDE(idDE); - TArrayI busPatchList; // decoding range of buspatch AliMpHelper::DecodeName(busPatch,';',busPatchList); @@ -204,6 +248,107 @@ Bool_t AliMpDDLStore::ReadDDLs() in.close(); return true; } +//______________________________________________________________________________ +Bool_t AliMpDDLStore::SetManus() +{ +/// Set manus for each bus patch + + Int_t manuMask = AliMpConstants::ManuMask(AliMp::kNonBendingPlane) - 1; + + // loop over DDL + for (Int_t iDDL = 0; iDDL < fgkNofDDLs; ++iDDL) { + + AliDebug(3, Form("DDL # %d\n", iDDL)); + + AliMpDDL* ddl = GetDDL(iDDL); + + // loop over DE in the given DDL + for (Int_t detElemIdx = 0; detElemIdx < ddl->GetNofDEs(); ++detElemIdx) { + + Int_t detElemId = ddl->GetDEId(detElemIdx); + + AliMpDetElement* detElement = GetDetElement(detElemId); + + AliMp::StationType stationType = AliMpDEManager::GetStationType(detElemId); + + + // list of manu per DE on both cathode + TList manuList; + for ( Int_t cath = 0; cath < 2 ; ++cath ) { + const AliMpVSegmentation* seg + = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::GetCathodType(cath)); + + AliMp::PlaneType planeType = detElement->GetPlaneType(AliMp::GetCathodType(cath)); + + TArrayI manus; + seg->GetAllElectronicCardIDs(manus); + + // filling TList manu + for ( Int_t im = 0; im < manus.GetSize(); ++im ) { + + AliMpIntPair* manu = 0x0; + if( stationType == AliMp::kStation345) + manu = new AliMpIntPair((manus[im] & manuMask), planeType, kTRUE); //remove offset for NB + else + manu = new AliMpIntPair(manus[im], planeType, kTRUE); //keep offset for NB + + manuList.Add(manu); + } + }// cathode + + manuList.Sort(); // sort regardless B or NB plane + + // filling manu to the corresponding buspatch + for (Int_t iEntry = 0; iEntry < manuList.GetEntries(); ++iEntry) { + + AliMpIntPair* manuPtr = (AliMpIntPair*)manuList.At(iEntry); + + Int_t manuId = manuPtr->GetFirst(); + Int_t pos = GetBusPatchIndex(detElemId, manuId); + + if (pos > detElement->GetNofBusPatches()) { + AliError(Form("pos greater %d than size %d manuId %d detElemId %d \n", + pos, detElement->GetNofBusPatches(), manuId, detElemId)); + return false; + } + + // get buspatch and fill manus + Int_t busPatchId = detElement->GetBusPatchId(pos); + AliMpBusPatch* busPatch = GetBusPatch(busPatchId); + + if( stationType == AliMp::kStation345) { + + if (manuPtr->GetSecond()) + busPatch->AddManu(manuId+manuMask+1); // add offset again after sorted + else + busPatch->AddManu(manuId); + + } else { + + busPatch->AddManu(manuId); + + } + } + + manuList.Delete(); + + if (AliDebugLevel() == 3) { + + // print out for checking + for(Int_t pos = 0; pos < detElement->GetNofBusPatches(); ++pos) { + Int_t busPatchId = detElement->GetBusPatchId(pos); + AliMpBusPatch* busPatch = GetBusPatch(busPatchId); + printf("BusPatch: %d\n", busPatch->GetId()); + for (Int_t iEntry = 0; iEntry < busPatch->GetNofManus(); ++iEntry) + printf("manu Id: %d\n", busPatch->GetManuId(iEntry)); + } + } + + } // detection element loop + }// DDL loop + + return true; +} // // public methods @@ -282,6 +427,26 @@ Int_t AliMpDDLStore::GetDDLfromBus(Int_t busPatchId) const return busPatch->GetDdlId(); } +//______________________________________________________________________________ +Int_t AliMpDDLStore::GetBusPatchId(Int_t detElemId, Int_t manuId) const +{ +/// Return bus patch for a given manuId + + AliMpDetElement* detElement = GetDetElement(detElemId); + Int_t pos = GetBusPatchIndex(detElemId, manuId); + + if ( pos > detElement->GetNofBusPatches() ) { + AliErrorStream() + << "Pos = " << pos + << " greater than the size = " << detElement->GetNofBusPatches() + << " for detElemId = " << detElemId + << " manuId = " << manuId << endl; + return -1; + } + + return detElement->GetBusPatchId(pos); +} + //______________________________________________________________________________ AliMpIntPair AliMpDDLStore::GetDetElemIdManu(Int_t manuSerial) const {