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
574 manuList.Sort(); // sort regardless B or NB plane
576 // filling manu to the corresponding buspatch
577 for (Int_t iEntry = 0; iEntry < manuList.GetEntries(); ++iEntry) {
579 AliMpIntPair* manuPtr = (AliMpIntPair*)manuList.At(iEntry);
581 Int_t manuId = manuPtr->GetFirst();
582 Int_t pos = GetBusPatchIndex(detElemId, manuId);
584 if (pos > detElement->GetNofBusPatches()) {
585 AliError(Form("pos greater %d than size %d manuId %d detElemId %d \n",
586 pos, detElement->GetNofBusPatches(), manuId, detElemId));
590 // get buspatch and fill manus
591 Int_t busPatchId = detElement->GetBusPatchId(pos);
592 AliMpBusPatch* busPatch = GetBusPatch(busPatchId);
594 if( stationType == AliMp::kStation345) {
596 if (manuPtr->GetSecond())
597 busPatch->AddManu(manuId+manuMask+1); // add offset again after sorted
599 busPatch->AddManu(manuId);
603 busPatch->AddManu(manuId);
610 if (AliDebugLevel() == 3) {
612 // print out for checking
613 for(Int_t pos = 0; pos < detElement->GetNofBusPatches(); ++pos) {
614 Int_t busPatchId = detElement->GetBusPatchId(pos);
615 AliMpBusPatch* busPatch = GetBusPatch(busPatchId);
616 printf("BusPatch: %d\n", busPatch->GetId());
617 for (Int_t iEntry = 0; iEntry < busPatch->GetNofManus(); ++iEntry)
618 printf("manu Id: %d\n", busPatch->GetManuId(iEntry));
622 } // detection element loop
628 //______________________________________________________________________________
629 Bool_t AliMpDDLStore::SetPatchModules()
631 /// Compute the number of manu per PCB for each buspatch
634 Bool_t result = true;
636 for ( it.First(); !it.IsDone(); it.Next() ) {
638 AliMpDetElement* detElement = it.CurrentDE();
640 for (Int_t i = 0; i < detElement->GetNofBusPatches(); ++i) {
641 AliMpBusPatch* busPatch = GetBusPatch(detElement->GetBusPatchId(i));
642 Bool_t newResult = false;
643 Int_t idDE = busPatch->GetDEId();
645 if (AliMpDEManager::GetStationType(idDE) == AliMp::kStation2 )
646 newResult = busPatch->SetNofManusPerModule(fManuBridge2[GetManuListIndex(idDE)].At(i));
648 newResult = busPatch->SetNofManusPerModule();
655 //______________________________________________________________________________
656 Bool_t AliMpDDLStore::SetBusPatchLength()
658 /// read the buspatch length file and set buspatch length
660 TString infile = AliMpFiles::BusPatchLengthFilePath();
661 ifstream in(infile, ios::in);
663 AliErrorStream() << "Data file " << infile << " not found.";
668 for (Int_t iDDL = 0; iDDL < fgkNofDDLs; ++iDDL ) {
669 AliMpDDL* ddl = GetDDL(iDDL);
671 for (Int_t iBusPatch = 0; iBusPatch < ddl->GetNofBusPatches(); ++iBusPatch) {
674 if (!in.getline(line,255)) {
675 AliWarning(Form("Wrong size in bus patch length file; index %d DDL %d",
679 } while(line[0] == '#');
681 TString tmp(AliMpHelper::Normalize(line));
683 TObjArray* stringList = tmp.Tokenize(TString(" "));
685 TString sLocalBusId = ((TObjString*)stringList->At(0))->GetString();
686 Int_t localBusId = sLocalBusId.Atoi();
688 TString sLength = ((TObjString*)stringList->At(1))->GetString();
689 Float_t length = sLength.Atof();
693 if (localBusId != iBusPatch + 1)
694 AliWarning(Form("Wrong local buspatch id %d instead of %d", iBusPatch+1, localBusId));
696 Int_t busPatchId = ddl->GetBusPatchId(iBusPatch);
697 AliMpBusPatch* busPatch = GetBusPatch(busPatchId);
698 busPatch->SetCableLength(length);
706 //________________________________________________________________
707 Int_t AliMpDDLStore::GetLocalBoardId(TString name) const
709 /// return the first board with a given side and line
711 TExMapIter i = fLocalBoards.GetIterator();
713 while ( i.Next(key, value) ) {
714 AliMpLocalBoard* local = (AliMpLocalBoard*)value;
716 TString tmp(&local->GetName()[4], 2);
717 if (name.Contains(tmp))
718 if (name[0] == local->GetName()[0])
719 return local->GetId();
731 //______________________________________________________________________________
732 AliMpDDL* AliMpDDLStore::GetDDL(Int_t ddlId, Bool_t warn) const
734 /// Return DDL for given ddlId
737 = (AliMpDDL*)fDDLs.At(ddlId);
739 if ( ! ddl && warn ) {
741 << "DDL with Id = " << ddlId << " not defined." << endl;
747 //______________________________________________________________________________
748 AliMpDetElement* AliMpDDLStore::GetDetElement(Int_t detElemId, Bool_t warn) const
750 /// Return detection element with given detElemId
752 if ( ! AliMpDEStore::Instance() ) {
753 AliFatal("DE Store has not been loaded.");
757 return AliMpDEStore::Instance()->GetDetElement(detElemId, warn);
760 //______________________________________________________________________________
761 AliMpBusPatch* AliMpDDLStore::GetBusPatch(Int_t busPatchId, Bool_t warn) const
763 /// Return bus patch with given Id
765 AliMpBusPatch* busPatch
766 = (AliMpBusPatch*) fBusPatches.GetValue(busPatchId);
768 if ( ! busPatch && warn ) {
770 << "Bus patch with Id = " << busPatchId << " not defined." << endl;
776 //______________________________________________________________________________
777 AliMpLocalBoard* AliMpDDLStore::GetLocalBoard(Int_t localBoardId, Bool_t warn) const
779 /// Return bus patch with given Id
781 AliMpLocalBoard* localBoard
782 = (AliMpLocalBoard*) fLocalBoards.GetValue(localBoardId);
784 if ( ! localBoard && warn ) {
786 << "Local board with Id = " << localBoardId << " not defined." << endl;
792 //______________________________________________________________________________
793 AliMpTriggerCrate* AliMpDDLStore::GetTriggerCrate(TString name, Bool_t warn) const
795 /// Return trigger crate with given name
797 AliMpTriggerCrate* crate
798 = (AliMpTriggerCrate*) fTriggerCrates.GetValue(name.Data());
800 if ( ! crate && warn ) {
802 << "Trigger crate with name = " << name.Data() << " not defined." << endl;
808 //______________________________________________________________________________
809 AliMpTriggerCrate* AliMpDDLStore::GetTriggerCrate(Int_t ddlId, Int_t index, Bool_t warn) const
811 /// Return trigger crate with given ddl and index crate
813 if (ddlId == 0 || ddlId == 1)
816 AliMpDDL* ddl = GetDDL(ddlId, warn);
817 if ( ! ddl ) return 0;
819 if ( index >= ddl->GetNofTriggerCrates() ) {
820 AliError(Form("crate id %d greater than array[%d]", index, ddl->GetNofTriggerCrates()));
824 Int_t crateId = ddl->GetTriggerCrateId(index);
825 TString name = AliMpTriggerCrate::GenerateName(crateId, ddlId, fgkNofDDLs);
827 return GetTriggerCrate(name, warn);
830 //______________________________________________________________________________
831 Int_t AliMpDDLStore::GetDEfromBus(Int_t busPatchId) const
833 /// Return detection element Id for given busPatchId
835 AliMpBusPatch* busPatch = GetBusPatch(busPatchId);
839 << "Bus patch with Id = " << busPatchId << " not defined." << endl;
843 return busPatch->GetDEId();
846 //______________________________________________________________________________
847 Int_t AliMpDDLStore::GetDEfromLocalBoard(Int_t localBoardId, Int_t chamberId) const
849 /// Return detElemId for local board Id and chamber id.
851 AliMpLocalBoard* localBoard = GetLocalBoard(localBoardId);
853 if ( ! localBoard ) {
855 << "Loacl board with Id = " << localBoardId << " not defined." << endl;
859 return localBoard->GetDEIdByChamber(chamberId);
862 //______________________________________________________________________________
863 Int_t AliMpDDLStore::GetDDLfromBus(Int_t busPatchId) const
865 /// Return DDL Id for given busPatchId
867 AliMpBusPatch* busPatch = GetBusPatch(busPatchId);
871 << "Bus patch with Id = " << busPatchId << " not defined." << endl;
875 return busPatch->GetDdlId();
878 //______________________________________________________________________________
879 Int_t AliMpDDLStore::GetBusPatchId(Int_t detElemId, Int_t manuId) const
881 /// Return bus patch for a given manuId
883 AliMpDetElement* detElement = GetDetElement(detElemId);
884 Int_t pos = GetBusPatchIndex(detElemId, manuId);
886 if ( pos > detElement->GetNofBusPatches() ) {
889 << " greater than the size = " << detElement->GetNofBusPatches()
890 << " for detElemId = " << detElemId
891 << " manuId = " << manuId << endl;
895 return detElement->GetBusPatchId(pos);
898 //______________________________________________________________________________
899 AliMpIntPair AliMpDDLStore::GetDetElemIdManu(Int_t manuSerial) const
901 /// Return the detElemId and manuId for given serial manu number
903 if ( ! AliMpDEStore::Instance() ) {
904 AliFatal("DE Store has not been loaded.");
905 return AliMpIntPair::Invalid();
908 return AliMpDEStore::Instance()->GetDetElemIdManu(manuSerial);
911 //______________________________________________________________________________
912 void AliMpDDLStore::PrintAllManu() const
914 /// Print all manu Ids and their serial numbers sorted by detection element
915 /// and bus patch. \n
916 /// As serial manu numbers are filled in a different way than manu Ids this
917 /// printing allows to check that both ways are consistent
921 for ( it.First(); ! it.IsDone(); it.Next() ) {
922 AliMpDetElement* de = it.CurrentDE();
923 cout << "DE: " << de->GetId() << endl;
925 // Loop over bus patches in this DE
926 for ( Int_t i=0; i< de->GetNofBusPatches(); ++i ) {
928 AliMpBusPatch* busPatch = GetBusPatch(de->GetBusPatchId(i));
929 cout << " busPatch: " << busPatch->GetId() << endl;
932 for ( Int_t j=0; j<busPatch->GetNofManus(); ++j ) {
933 cout << std::setw(6) << busPatch->GetManuId(j) << " ";
937 cout << " Manu serial: ";
938 for ( Int_t k=0; k<busPatch->GetNofManus(); ++k ) {
939 cout << std::setw(6) << de->GetManuSerialFromId(busPatch->GetManuId(k)) << " ";
946 //________________________________________________________________
947 Int_t AliMpDDLStore::GetNextDEfromLocalBoard(Int_t localBoardId, Int_t chamberId ) const
949 /// return the next detection element in line
951 AliMpLocalBoard* localBoard = GetLocalBoard(localBoardId);
953 TString name(localBoard->GetName());
955 Int_t line = localBoard->GetPosition().GetFirst();
958 name.Replace(4,1,Form("%d", line));
961 if ((nextLocalId = GetLocalBoardId(name)))
962 return GetDEfromLocalBoard(nextLocalId, chamberId);
969 //________________________________________________________________
970 Int_t AliMpDDLStore::GetPreviousDEfromLocalBoard(Int_t localBoardId, Int_t chamberId) const
972 /// return the previous detection element in line
974 AliMpLocalBoard* localBoard = GetLocalBoard(localBoardId);
976 TString name(localBoard->GetName());
978 Int_t line = localBoard->GetPosition().GetFirst();
981 name.Replace(4,1,Form("%d", line));
984 if ((prevLocalId = GetLocalBoardId(name)))
985 return GetDEfromLocalBoard(prevLocalId, chamberId);