1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
7 * Permission to use, copy, modify and distribute this software and its *
8 * documentation strictly for non-commercial purposes is hereby granted *
9 * without fee, provided that the above copyright notice appears in all *
10 * copies and that both the copyright notice and this permission notice *
11 * appear in the supporting documentation. The authors make no claims *
12 * about the suitability of this software for any purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
17 // $MpId: AliMpDDLStore.cxx,v 1.4 2006/05/24 13:58:34 ivana Exp $
18 // Category: management
20 //-----------------------------------------------------------------------------
21 // Class AliMpDDLStore
22 // --------------------
23 // The top container class for DDLs, det elements and bus patched
24 // It provides acces to DDL, det element and bus patches objects
25 // via various characteristics.
26 // Authors: Ivana Hrivnacova, IPN Orsay
27 // Christian Finck, SUBATECH Nantes
28 //-----------------------------------------------------------------------------
30 #include "AliMpDDLStore.h"
31 #include "AliMpConstants.h"
32 #include "AliMpDEStore.h"
34 #include "AliMpFiles.h"
35 #include "AliMpHelper.h"
36 #include "AliMpDEManager.h"
37 #include "AliMpDetElement.h"
38 #include "AliMpBusPatch.h"
39 #include "AliMpTriggerCrate.h"
40 #include "AliMpLocalBoard.h"
41 #include "AliMpSegmentation.h"
42 #include "AliMpVSegmentation.h"
43 #include "AliMpStringObjMap.h"
46 #include <Riostream.h>
48 #include <TObjArray.h>
50 #include <TObjString.h>
54 ClassImp(AliMpDDLStore)
57 AliMpDDLStore* AliMpDDLStore::fgInstance = 0;
58 const Int_t AliMpDDLStore::fgkNofDDLs = 20;
59 const Int_t AliMpDDLStore::fgkNofTriggerDDLs = 2;
65 //______________________________________________________________________________
66 AliMpDDLStore* AliMpDDLStore::Instance(Bool_t warn)
68 /// Create the DDL store if it does not yet exist
69 /// and return its instance
71 if ( ! fgInstance && warn ) {
72 AliWarningClass("DDL Store has not been loaded");
78 //______________________________________________________________________________
79 AliMpDDLStore* AliMpDDLStore::ReadData(Bool_t warn)
81 /// Load the DDL store from ASCII data files
82 /// and return its instance
86 AliWarningClass("DDL Store has been already loaded");
90 AliInfoClass("Reading DDL Store from ASCII files.");
92 fgInstance = new AliMpDDLStore();
100 //______________________________________________________________________________
101 AliMpDDLStore::AliMpDDLStore()
103 fDDLs(fgkNofDDLs+fgkNofTriggerDDLs), // FIXEME
105 fTriggerCrates(true),
110 /// Standard constructor
113 fDDLs.SetOwner(true);
114 fBusPatches.SetOwner(true);
115 fBusPatches.SetSize(900);
117 fTriggerCrates.SetOwner(true);
118 fTriggerCrates.SetSize(16);
120 fLocalBoards.SetOwner(true);
121 fLocalBoards.SetSize(242); // included non-identied board
124 // Load segmentation & DE store data
125 if ( ! AliMpSegmentation::Instance(false) )
126 AliMpSegmentation::ReadData(true);
128 // Create all detection elements
136 //______________________________________________________________________________
137 AliMpDDLStore::AliMpDDLStore(TRootIOCtor* /*ioCtor*/)
141 fTriggerCrates(true),
144 /// Constructor for IO
152 //______________________________________________________________________________
153 AliMpDDLStore::~AliMpDDLStore()
159 // DDL objects are deleted with fDDLs
160 // Bus patches objects are deleted with fBusPatches
169 //______________________________________________________________________________
170 Int_t AliMpDDLStore::GetManuListIndex(Int_t detElemId) const
172 /// Return the index of the manu list for given detElemId
174 return AliMpDEManager::GetChamberId(detElemId)*4 + (detElemId % 100);
178 //______________________________________________________________________________
179 Int_t AliMpDDLStore::GetBusPatchIndex(Int_t detElemId, Int_t manuId) const
181 /// Calculate the index of the buspatch from manuId
184 AliMp::StationType stationType = AliMpDEManager::GetStationType(detElemId);
185 static Int_t manuMask = AliMpConstants::ManuMask(AliMp::kNonBendingPlane) - 1;
187 if( stationType == AliMp::kStation345) {
188 pos = (manuId & manuMask)/100;
190 Int_t idx = GetManuListIndex(detElemId);
192 // using array defined from DetElemIdToBusPatch.dat file
193 for (pos = fManuList12[idx].GetSize()-1; pos >= 0; --pos)
194 if ( manuId >= fManuList12[idx].At(pos)) break;
201 //______________________________________________________________________________
202 Bool_t AliMpDDLStore::ReadDDLs()
204 /// Read ddl <-> bus patch file
207 TString infile = AliMpFiles::BusPatchFilePath();
209 ifstream in(infile, ios::in);
211 AliErrorStream() << "Data file " << infile << " not found.";
217 while ( in.getline(line,255) ) {
219 if ( line[0] == '#' ) continue;
221 TString tmp(AliMpHelper::Normalize(line));
223 TObjArray* stringList = tmp.Tokenize(TString(" "));
225 TString sDE = ((TObjString*)stringList->At(0))->GetString();
226 Int_t idDE = atoi(sDE.Data());
228 if ( ! AliMpDEManager::IsValidDetElemId(idDE, false) ) {
229 AliErrorStream() << "DetElemId "<< idDE << " not valid." << endl;
233 TString busPatch = ((TObjString*)stringList->At(1))->GetString();
236 TString sDDL = ((TObjString*)stringList->At(2))->GetString();
237 Int_t iDDL = atoi(sDDL.Data());
239 if ( iDDL < 0 || iDDL >= fgkNofDDLs ) {
240 AliErrorStream() << "DDL id "<< iDDL << " outside limits." << endl;
245 << "idDE " << idDE << " buspatch " << busPatch.Data() << " iDDL " << iDDL
248 // reading 1st manu Id for each bus patch (station 1 & 2)
249 if(AliMpDEManager::GetStationType(idDE) != AliMp::kStation345) {
251 TString sManu = ((TObjString*)stringList->At(3))->GetString();
252 AliMpHelper::DecodeName(sManu,',',fManuList12[GetManuListIndex(idDE)]);
254 if(AliMpDEManager::GetStationType(idDE) == AliMp::kStation2) {
255 TString sManuBridge = ((TObjString*)stringList->At(4))->GetString();
256 AliMpHelper::DecodeName(sManuBridge,',',fManuBridge2[GetManuListIndex(idDE)]);
263 AliMpDDL* ddl = GetDDL(iDDL, false);
265 ddl = new AliMpDDL(iDDL);
266 fDDLs.AddAt(ddl, iDDL);
270 TArrayI busPatchList;
271 // decoding range of buspatch
272 AliMpHelper::DecodeName(busPatch,';',busPatchList);
275 AliMpDetElement* de = AliMpDEManager::GetDetElement(idDE);
277 // filling buspatch -> idDE
278 for (Int_t i = 0; i < busPatchList.GetSize(); i++) {
279 fBusPatches.Add(busPatchList[i],
280 new AliMpBusPatch(busPatchList[i], idDE, iDDL));
281 de->AddBusPatch(busPatchList[i]);
285 // Fill bus patch Ids array in DDLs now
286 for ( Int_t i=0; i<fDDLs.GetEntriesFast(); i++ ) {
287 AliMpDDL* ddl = (AliMpDDL*) fDDLs.At(i);
288 ddl->FillBusPatchIds();
295 //______________________________________________________________________________
296 Bool_t AliMpDDLStore::ReadTriggerDDLs()
298 /// create trigger DDL object ddl<->Crate<->local board
300 AliMpStringObjMap inputXfromMap;
301 AliMpStringObjMap inputXtoMap;
302 AliMpStringObjMap inputYfromMap;
303 AliMpStringObjMap inputYtoMap;
305 Int_t nonNotified = 0;
309 TString infile = AliMpFiles::LocalTriggerBoardMapping();
311 ifstream in(infile, ios::in);
314 AliError(Form("Local Trigger Board Mapping File %s not found", infile.Data()));
318 AliMpLocalBoard* board = 0x0;
319 AliMpTriggerCrate* crate = 0x0;
322 Int_t localNumberId = 0;
326 while (in.getline(line, 255))
329 // files contains lines with some blank caracters ???
330 if (line[0] == ' ' && strlen(line) < 12) continue;
332 TString tmp(AliMpHelper::Normalize(line));
333 if (tmp.IsNull()) continue; // Ignore empty lines
335 if (tmp.Contains("Board"))
337 // extract id, name, slot & crate name
338 TObjArray* stringList = tmp.Tokenize(TString(" "));
340 TString localNumber = ((TObjString*)stringList->At(1))->GetString();
342 if (localNumber.CompareTo("nn") != 0) // Notified cards
343 localNumberId = localNumber.Atoi();
345 localNumberId = AliMpConstants::NofLocalBoards() + (++nonNotified);
347 TString localName = ((TObjString*)stringList->At(4))->GetString();
348 TString slotName = ((TObjString*)stringList->At(10))->GetString();
350 AliDebug(3, Form("%d %s %d\n", localNumberId, localName.Data(), slotName.Atoi()));
352 board = new AliMpLocalBoard(localNumberId, localName.Data(), slotName.Atoi());
354 // not notified board
355 if (localNumber.CompareTo("nn") == 0)
356 board->SetNotified(false);
358 // compose name with number and side (Right or Left)
359 TString crateNumber = ((TObjString*)stringList->At(6))->GetString();
360 TString crateSide = ((TObjString*)stringList->At(7))->GetString();
361 TString crateName = crateNumber + crateSide;
364 board->SetCrate(crateName);
366 // determine ddl number vs crate side
367 if (crateName.Contains("R"))
368 iDDL = fgkNofDDLs; // starts where tracker ends
370 iDDL = fgkNofDDLs + 1;
372 AliMpDDL* ddl = GetDDL(iDDL, false);
374 ddl = new AliMpDDL(iDDL);
375 fDDLs.AddAt(ddl, iDDL);
379 if (crateNumber.CompareTo("2-3") != 0)
380 crateId = crateNumber.Atoi();
384 // add trigger crate number for given ddl if not present
385 if ( !ddl->HasTriggerCrateId(crateId) )
386 ddl->AddTriggerCrate(crateId);
388 // if crate not existing then creating
389 if (!GetTriggerCrate(crateName, false)) {
390 crate = new AliMpTriggerCrate(crateName.Data(), iDDL);
391 fTriggerCrates.Add(crateName.Data(), crate);
394 // create list of local board in this crate
395 crate->AddLocalBoard(localNumberId);
400 if (tmp.Contains("DetElemId"))
403 AliMpDDL* ddl = GetDDL(iDDL, true);
405 // add DE for local board and DDL
406 TString detElem = &tmp[tmp.First(" ")+1];
407 AliMpHelper::DecodeName(detElem,' ',list);
409 for (Int_t i = 0; i < list.GetSize(); ++i) {
411 if (list[i]) { // skip copy card
412 AliMpDetElement* de = AliMpDEManager::GetDetElement(list[i]);
413 if (de->GetDdlId() == -1)
416 board->AddDE(list[i]);
417 if(!ddl->HasDEId(list[i]))
422 // map the different copies between cards in X and Y inputs
423 // when copying Xinput, Yinput are copied as well
424 if (tmp.Contains("X3input1"))
426 TObjArray* stringList = tmp.Tokenize(TString(" "));
428 TString copyX = ((TObjString*)stringList->At(3))->GetString();
429 TString input = ((TObjString*)stringList->At(2))->GetString();;
431 if (copyX.Contains("(1)")) {
432 inputXfromMap.Add(input, board);
433 inputYfromMap.Add(input, board);
436 if (copyX.Contains("(2)")) {
437 inputXtoMap.Add(input, board);
438 inputYtoMap.Add(input, board);
443 if (tmp.Contains("Y1input1"))
445 TObjArray* stringList = tmp.Tokenize(TString(" "));
447 TString copyY = ((TObjString*)stringList->At(3))->GetString();
448 TString input = ((TObjString*)stringList->At(2))->GetString();;
450 if (copyY.Contains("(1)"))
451 inputYfromMap.Add(input, board);
452 if (copyY.Contains("(2)"))
453 inputYtoMap.Add(input, board);
458 if (tmp.Contains("transv"))
460 // set transverse connector
461 Int_t blankPos = tmp.Last(' ');
463 TString transv(tmp(blankPos+1, tmp.Length()-blankPos));
465 if (transv.CompareTo("NONE") == 0)
469 if (tmp.Contains("Switch"))
472 in.getline(line, 255);// skip one line
474 in.getline(line, 255);
475 TString tmp(AliMpHelper::Normalize(line));
478 AliMpHelper::DecodeName(tmp,' ',list);
481 AliMpArrayI switches;
483 for (Int_t i = 0; i < list.GetSize(); ++i)
484 board->AddSwitch(list[i]);
486 // add local board into map
487 fLocalBoards.Add(board->GetId(), board);
492 // set copy card number to where the X-Y inputs are copied and
493 // from where the X-Y inputs come.
494 // deleting the first item (TString) done by AliMpStringObjMap itself
495 // keep AliMpLocalBoard object undelete
499 for (inputXfromMap.First(); !inputXfromMap.IsDone(); inputXfromMap.Next()) {
501 value = inputXfromMap.CurrentKey();
502 AliMpLocalBoard* boardFrom = (AliMpLocalBoard*)inputXfromMap.CurrentItem();
503 AliMpLocalBoard* boardTo = (AliMpLocalBoard*)inputXtoMap.Get(value);
504 boardFrom->SetInputXto(boardTo->GetId());
505 boardTo->SetInputXfrom(boardFrom->GetId());
506 AliDebug(3, Form("copy xInputs from local id %d_%s_%d to %d_%s_%d\n",
507 boardTo->GetInputXfrom(), boardFrom->GetCrate().Data(), boardFrom->GetSlot(),
508 boardFrom->GetInputXto(), boardTo->GetCrate().Data(), boardTo->GetSlot()));
511 for (inputYfromMap.First(); !inputYfromMap.IsDone(); inputYfromMap.Next()) {
513 value = inputYfromMap.CurrentKey();
514 AliMpLocalBoard* boardFrom = (AliMpLocalBoard*)inputYfromMap.CurrentItem();
515 AliMpLocalBoard* boardTo = (AliMpLocalBoard*)inputYtoMap.Get(value);
516 boardFrom->SetInputYto(boardTo->GetId());
517 boardTo->SetInputYfrom(boardFrom->GetId());
518 AliDebug(3, Form("copy yInputs from local id %d_%s_%d to %d_%s_%d\n",
519 boardTo->GetInputYfrom(), boardFrom->GetCrate().Data(), boardFrom->GetSlot(),
520 boardFrom->GetInputYto(), boardTo->GetCrate().Data(), boardTo->GetSlot()));
526 //______________________________________________________________________________
527 Bool_t AliMpDDLStore::SetManus()
529 /// Set manus for each bus patch
531 Int_t manuMask = AliMpConstants::ManuMask(AliMp::kNonBendingPlane) - 1;
534 for (Int_t iDDL = 0; iDDL < fgkNofDDLs; ++iDDL) {
536 AliDebug(3, Form("DDL # %d\n", iDDL));
538 AliMpDDL* ddl = GetDDL(iDDL);
540 // loop over DE in the given DDL
541 for (Int_t detElemIdx = 0; detElemIdx < ddl->GetNofDEs(); ++detElemIdx) {
543 Int_t detElemId = ddl->GetDEId(detElemIdx);
545 AliMpDetElement* detElement = GetDetElement(detElemId);
547 AliMp::StationType stationType = AliMpDEManager::GetStationType(detElemId);
550 // list of manu per DE on both cathode
552 for ( Int_t cath = 0; cath < 2 ; ++cath ) {
553 const AliMpVSegmentation* seg
554 = AliMpSegmentation::Instance()->GetMpSegmentation(detElemId,AliMp::GetCathodType(cath));
556 AliMp::PlaneType planeType = detElement->GetPlaneType(AliMp::GetCathodType(cath));
559 seg->GetAllElectronicCardIDs(manus);
561 // filling TList manu
562 for ( Int_t im = 0; im < manus.GetSize(); ++im ) {
564 AliMpIntPair* manu = 0x0;
565 if( stationType == AliMp::kStation345)
566 manu = new AliMpIntPair((manus[im] & manuMask), planeType, kTRUE); //remove offset for NB
568 manu = new AliMpIntPair(manus[im], planeType, kTRUE); //keep offset for NB
572 detElement->AddManu(manus[im]);
576 manuList.Sort(); // sort regardless B or NB plane
578 // filling manu to the corresponding buspatch
579 for (Int_t iEntry = 0; iEntry < manuList.GetEntries(); ++iEntry) {
581 AliMpIntPair* manuPtr = (AliMpIntPair*)manuList.At(iEntry);
583 Int_t manuId = manuPtr->GetFirst();
584 Int_t pos = GetBusPatchIndex(detElemId, manuId);
586 if (pos > detElement->GetNofBusPatches()) {
587 AliError(Form("pos greater %d than size %d manuId %d detElemId %d \n",
588 pos, detElement->GetNofBusPatches(), manuId, detElemId));
592 // get buspatch and fill manus
593 Int_t busPatchId = detElement->GetBusPatchId(pos);
594 AliMpBusPatch* busPatch = GetBusPatch(busPatchId);
596 if( stationType == AliMp::kStation345) {
598 if (manuPtr->GetSecond())
599 busPatch->AddManu(manuId+manuMask+1); // add offset again after sorted
601 busPatch->AddManu(manuId);
605 busPatch->AddManu(manuId);
612 if (AliDebugLevel() == 3) {
614 // print out for checking
615 for(Int_t pos = 0; pos < detElement->GetNofBusPatches(); ++pos) {
616 Int_t busPatchId = detElement->GetBusPatchId(pos);
617 AliMpBusPatch* busPatch = GetBusPatch(busPatchId);
618 printf("BusPatch: %d\n", busPatch->GetId());
619 for (Int_t iEntry = 0; iEntry < busPatch->GetNofManus(); ++iEntry)
620 printf("manu Id: %d\n", busPatch->GetManuId(iEntry));
624 } // detection element loop
630 //______________________________________________________________________________
631 Bool_t AliMpDDLStore::SetPatchModules()
633 /// Compute the number of manu per PCB for each buspatch
636 Bool_t result = true;
638 for ( it.First(); !it.IsDone(); it.Next() ) {
640 AliMpDetElement* detElement = it.CurrentDE();
642 for (Int_t i = 0; i < detElement->GetNofBusPatches(); ++i) {
643 AliMpBusPatch* busPatch = GetBusPatch(detElement->GetBusPatchId(i));
644 Bool_t newResult = false;
645 Int_t idDE = busPatch->GetDEId();
647 if (AliMpDEManager::GetStationType(idDE) == AliMp::kStation2 )
648 newResult = busPatch->SetNofManusPerModule(fManuBridge2[GetManuListIndex(idDE)].At(i));
650 newResult = busPatch->SetNofManusPerModule();
657 //______________________________________________________________________________
658 Bool_t AliMpDDLStore::SetBusPatchLength()
660 /// read the buspatch length file and set buspatch length
662 TString infile = AliMpFiles::BusPatchLengthFilePath();
663 ifstream in(infile, ios::in);
665 AliErrorStream() << "Data file " << infile << " not found.";
670 for (Int_t iDDL = 0; iDDL < fgkNofDDLs; ++iDDL ) {
671 AliMpDDL* ddl = GetDDL(iDDL);
673 for (Int_t iBusPatch = 0; iBusPatch < ddl->GetNofBusPatches(); ++iBusPatch) {
676 if (!in.getline(line,255)) {
677 AliWarning(Form("Wrong size in bus patch length file; index %d DDL %d",
681 } while(line[0] == '#');
683 TString tmp(AliMpHelper::Normalize(line));
685 TObjArray* stringList = tmp.Tokenize(TString(" "));
687 TString sLocalBusId = ((TObjString*)stringList->At(0))->GetString();
688 Int_t localBusId = sLocalBusId.Atoi();
690 TString sLength = ((TObjString*)stringList->At(1))->GetString();
691 Float_t length = sLength.Atof();
695 if (localBusId != iBusPatch + 1)
696 AliWarning(Form("Wrong local buspatch id %d instead of %d", iBusPatch+1, localBusId));
698 Int_t busPatchId = ddl->GetBusPatchId(iBusPatch);
699 AliMpBusPatch* busPatch = GetBusPatch(busPatchId);
700 busPatch->SetCableLength(length);
708 //________________________________________________________________
709 Int_t AliMpDDLStore::GetLocalBoardId(TString name) const
711 /// return the first board with a given side and line
713 TExMapIter i = fLocalBoards.GetIterator();
715 while ( i.Next(key, value) ) {
716 AliMpLocalBoard* local = (AliMpLocalBoard*)value;
718 TString tmp(&local->GetName()[4], 2);
719 if (name.Contains(tmp))
720 if (name[0] == local->GetName()[0])
721 return local->GetId();
733 //______________________________________________________________________________
734 AliMpDDL* AliMpDDLStore::GetDDL(Int_t ddlId, Bool_t warn) const
736 /// Return DDL for given ddlId
739 = (AliMpDDL*)fDDLs.At(ddlId);
741 if ( ! ddl && warn ) {
743 << "DDL with Id = " << ddlId << " not defined." << endl;
749 //______________________________________________________________________________
750 AliMpDetElement* AliMpDDLStore::GetDetElement(Int_t detElemId, Bool_t warn) const
752 /// Return detection element with given detElemId
754 if ( ! AliMpDEStore::Instance() ) {
755 AliFatal("DE Store has not been loaded.");
759 return AliMpDEStore::Instance()->GetDetElement(detElemId, warn);
762 //______________________________________________________________________________
763 AliMpBusPatch* AliMpDDLStore::GetBusPatch(Int_t busPatchId, Bool_t warn) const
765 /// Return bus patch with given Id
767 AliMpBusPatch* busPatch
768 = (AliMpBusPatch*) fBusPatches.GetValue(busPatchId);
770 if ( ! busPatch && warn ) {
772 << "Bus patch with Id = " << busPatchId << " not defined." << endl;
778 //______________________________________________________________________________
779 AliMpLocalBoard* AliMpDDLStore::GetLocalBoard(Int_t localBoardId, Bool_t warn) const
781 /// Return bus patch with given Id
783 AliMpLocalBoard* localBoard
784 = (AliMpLocalBoard*) fLocalBoards.GetValue(localBoardId);
786 if ( ! localBoard && warn ) {
788 << "Local board with Id = " << localBoardId << " not defined." << endl;
794 //______________________________________________________________________________
795 AliMpTriggerCrate* AliMpDDLStore::GetTriggerCrate(TString name, Bool_t warn) const
797 /// Return trigger crate with given name
799 AliMpTriggerCrate* crate
800 = (AliMpTriggerCrate*) fTriggerCrates.GetValue(name.Data());
802 if ( ! crate && warn ) {
804 << "Trigger crate with name = " << name.Data() << " not defined." << endl;
810 //______________________________________________________________________________
811 AliMpTriggerCrate* AliMpDDLStore::GetTriggerCrate(Int_t ddlId, Int_t index, Bool_t warn) const
813 /// Return trigger crate with given ddl and index crate
815 if (ddlId == 0 || ddlId == 1)
818 AliMpDDL* ddl = GetDDL(ddlId, warn);
819 if ( ! ddl ) return 0;
821 if ( index >= ddl->GetNofTriggerCrates() ) {
822 AliError(Form("crate id %d greater than array[%d]", index, ddl->GetNofTriggerCrates()));
826 Int_t crateId = ddl->GetTriggerCrateId(index);
827 TString name = AliMpTriggerCrate::GenerateName(crateId, ddlId, fgkNofDDLs);
829 return GetTriggerCrate(name, warn);
832 //______________________________________________________________________________
833 Int_t AliMpDDLStore::GetDEfromBus(Int_t busPatchId) const
835 /// Return detection element Id for given busPatchId
837 AliMpBusPatch* busPatch = GetBusPatch(busPatchId);
841 << "Bus patch with Id = " << busPatchId << " not defined." << endl;
845 return busPatch->GetDEId();
848 //______________________________________________________________________________
849 Int_t AliMpDDLStore::GetDEfromLocalBoard(Int_t localBoardId, Int_t chamberId) const
851 /// Return detElemId for local board Id and chamber id.
853 AliMpLocalBoard* localBoard = GetLocalBoard(localBoardId);
855 if ( ! localBoard ) {
857 << "Loacl board with Id = " << localBoardId << " not defined." << endl;
861 return localBoard->GetDEIdByChamber(chamberId);
864 //______________________________________________________________________________
865 Int_t AliMpDDLStore::GetDDLfromBus(Int_t busPatchId) const
867 /// Return DDL Id for given busPatchId
869 AliMpBusPatch* busPatch = GetBusPatch(busPatchId);
873 << "Bus patch with Id = " << busPatchId << " not defined." << endl;
877 return busPatch->GetDdlId();
880 //______________________________________________________________________________
881 Int_t AliMpDDLStore::GetBusPatchId(Int_t detElemId, Int_t manuId) const
883 /// Return bus patch for a given manuId
885 AliMpDetElement* detElement = GetDetElement(detElemId);
886 Int_t pos = GetBusPatchIndex(detElemId, manuId);
888 if ( pos > detElement->GetNofBusPatches() ) {
891 << " greater than the size = " << detElement->GetNofBusPatches()
892 << " for detElemId = " << detElemId
893 << " manuId = " << manuId << endl;
897 return detElement->GetBusPatchId(pos);
900 //______________________________________________________________________________
901 AliMpIntPair AliMpDDLStore::GetDetElemIdManu(Int_t manuSerial) const
903 /// Return the detElemId and manuId for given serial manu number
905 if ( ! AliMpDEStore::Instance() ) {
906 AliFatal("DE Store has not been loaded.");
907 return AliMpIntPair::Invalid();
910 return AliMpDEStore::Instance()->GetDetElemIdManu(manuSerial);
913 //______________________________________________________________________________
914 void AliMpDDLStore::PrintAllManu() const
916 /// Print all manu Ids and their serial numbers sorted by detection element
917 /// and bus patch. \n
918 /// As serial manu numbers are filled in a different way than manu Ids this
919 /// printing allows to check that both ways are consistent
923 for ( it.First(); ! it.IsDone(); it.Next() ) {
924 AliMpDetElement* de = it.CurrentDE();
925 cout << "DE: " << de->GetId() << endl;
927 // Loop over bus patches in this DE
928 for ( Int_t i=0; i< de->GetNofBusPatches(); ++i ) {
930 AliMpBusPatch* busPatch = GetBusPatch(de->GetBusPatchId(i));
931 cout << " busPatch: " << busPatch->GetId() << endl;
934 for ( Int_t j=0; j<busPatch->GetNofManus(); ++j ) {
935 cout << std::setw(6) << busPatch->GetManuId(j) << " ";
939 cout << " Manu serial: ";
940 for ( Int_t k=0; k<busPatch->GetNofManus(); ++k ) {
941 cout << std::setw(6) << de->GetManuSerialFromId(busPatch->GetManuId(k)) << " ";
948 //________________________________________________________________
949 Int_t AliMpDDLStore::GetNextDEfromLocalBoard(Int_t localBoardId, Int_t chamberId ) const
951 /// return the next detection element in line
953 AliMpLocalBoard* localBoard = GetLocalBoard(localBoardId);
955 TString name(localBoard->GetName());
957 Int_t line = localBoard->GetPosition().GetFirst();
960 name.Replace(4,1,Form("%d", line));
963 if ((nextLocalId = GetLocalBoardId(name)))
964 return GetDEfromLocalBoard(nextLocalId, chamberId);
971 //________________________________________________________________
972 Int_t AliMpDDLStore::GetPreviousDEfromLocalBoard(Int_t localBoardId, Int_t chamberId) const
974 /// return the previous detection element in line
976 AliMpLocalBoard* localBoard = GetLocalBoard(localBoardId);
978 TString name(localBoard->GetName());
980 Int_t line = localBoard->GetPosition().GetFirst();
983 name.Replace(4,1,Form("%d", line));
986 if ((prevLocalId = GetLocalBoardId(name)))
987 return GetDEfromLocalBoard(prevLocalId, chamberId);