AliRoot Core  3abf5b4 (3abf5b4)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMpDDLStore.cxx
Go to the documentation of this file.
1 /**************************************************************************
2  * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3  * *
4  * Author: The ALICE Off-line Project. *
5  * Contributors are mentioned in the code where appropriate. *
6  * *
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  **************************************************************************/
15 
16 // $Id$
17 // $MpId: AliMpDDLStore.cxx,v 1.4 2006/05/24 13:58:34 ivana Exp $
18 // Category: management
19 
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 //-----------------------------------------------------------------------------
29 
30 #include <cstdlib>
31 #include "AliMpDDLStore.h"
32 #include "AliMpExMapIterator.h"
33 #include "AliMpConstants.h"
34 #include "AliMpDEStore.h"
36 #include "AliMpDDL.h"
37 #include "AliMpFiles.h"
38 #include "AliMpDataStreams.h"
39 #include "AliMpHelper.h"
40 #include "AliMpDEManager.h"
41 #include "AliMpManuStore.h"
42 #include "AliMpDetElement.h"
43 #include "AliMpBusPatch.h"
44 #include "AliMpTriggerCrate.h"
45 #include "AliMpLocalBoard.h"
46 #include "AliMpSegmentation.h"
47 #include "AliMpVSegmentation.h"
48 #include "AliMpStringObjMap.h"
49 #include "AliMpEncodePair.h"
50 #include "AliMpIntPair.h"
51 
52 #include "AliLog.h"
53 
54 #include <Riostream.h>
55 #include <TList.h>
56 #include <TObjArray.h>
57 #include <TString.h>
58 #include <TObjString.h>
59 #include <TClass.h>
60 
64 
65 AliMpDDLStore* AliMpDDLStore::fgInstance = 0;
66 const Int_t AliMpDDLStore::fgkNofDDLs = 20;
67 const Int_t AliMpDDLStore::fgkNofTriggerDDLs = 2;
68 
69 //
70 // static methods
71 //
72 
73 //______________________________________________________________________________
74 const TString& AliMpDDLStore::GetRevertKeyword()
75 {
77  static const TString kRevertKeyword = "REVERT";
78  return kRevertKeyword;
79 }
80 
81 //______________________________________________________________________________
83 {
85  static const TString kExplicitKeyword = "EXPLICIT";
86  return kExplicitKeyword;
87 }
88 
89 //______________________________________________________________________________
91 {
94 
95  if ( ! fgInstance && warn ) {
96  AliWarningClass("DDL Store has not been loaded");
97  }
98 
99  return fgInstance;
100 }
101 
102 //______________________________________________________________________________
104  Bool_t warn)
105 {
108 
109  if ( fgInstance ) {
110  if ( warn )
111  AliWarningClass("DDL Store has been already loaded");
112  return fgInstance;
113  }
114 
115  if ( dataStreams.GetReadFromFiles() )
116  AliInfoClass("Reading DDL Store from ASCII files.");
117 
118  fgInstance = new AliMpDDLStore(dataStreams);
119  return fgInstance;
120 }
121 
122 //
123 // ctors, dtor
124 //
125 
126 //______________________________________________________________________________
128  : TObject(),
129  fDDLs(fgkNofDDLs+fgkNofTriggerDDLs), // FIXEME
130  fBusPatches(),
131  fManuList12(),
132  fManuBridge2(),
133  fRegionalTrigger()
134 {
136 
137  AliDebug(1,"");
138  fDDLs.SetOwner(true);
139  fBusPatches.SetOwner(true);
140  fBusPatches.SetSize(900);
141 
142  // Load segmentation & DE store data
143  if ( ! AliMpSegmentation::Instance(false) )
144  AliMpSegmentation::ReadData(dataStreams, true);
145 
146  // Create all detection elements
147  ReadDDLs(dataStreams);
148  ReadTrigger(dataStreams);
149  SetTriggerDDLs();
150  SetManus();
151  ReadBusPatchSpecial(dataStreams);
152  SetPatchModules();
153  ReadBusPatchInfo(dataStreams);
154 }
155 
156 //______________________________________________________________________________
157 AliMpDDLStore::AliMpDDLStore(TRootIOCtor* ioCtor)
158  : TObject(),
159  fDDLs(),
160  fBusPatches(ioCtor),
161  fRegionalTrigger(ioCtor)
162 {
164 
165  AliDebug(1,"");
166 
167  fgInstance = this;
168 }
169 
170 
171 //______________________________________________________________________________
173 {
175 
176  AliDebug(1,"");
177 
178  // DDL objects are deleted with fDDLs
179  // Bus patches objects are deleted with fBusPatches
180 
181  fgInstance = 0;
182 }
183 
184 //
185 // private methods
186 //
187 
188 //______________________________________________________________________________
189 Int_t AliMpDDLStore::GetManuListIndex(Int_t detElemId) const
190 {
192 
193  return AliMpDEManager::GetChamberId(detElemId)*4 + (detElemId % 100);
194 }
195 
196 
197 //______________________________________________________________________________
198 Int_t AliMpDDLStore::GetBusPatchIndex(Int_t detElemId, Int_t manuId) const
199 {
201 
202  Int_t pos = 0;
203  AliMp::StationType stationType = AliMpDEManager::GetStationType(detElemId);
204  static Int_t manuMask = AliMpConstants::ManuMask(AliMp::kNonBendingPlane) - 1;
205 
206  if( stationType == AliMp::kStation345) {
207  pos = (manuId & manuMask)/100;
208  } else {
209  Int_t idx = GetManuListIndex(detElemId);
210 
211  // using array defined from DetElemIdToBusPatch.dat file
212  for (pos = fManuList12[idx].GetSize()-1; pos >= 0; --pos)
213  if ( manuId >= fManuList12[idx].At(pos))
214  break;
215  }
216 
217  return pos;
218 }
219 
220 //______________________________________________________________________________
221 Bool_t AliMpDDLStore::ReadDDLs(const AliMpDataStreams& dataStreams)
222 {
224 
225  istream& in
226  = dataStreams.
227  CreateDataStream(AliMpFiles::BusPatchFilePath());
228 
229  char line[255];
230 
231  while ( in.getline(line,255) ) {
232 
233  if ( line[0] == '#' )
234  continue;
235 
236  TString tmp(AliMpHelper::Normalize(line));
237 
238  TObjArray* stringList = tmp.Tokenize(TString(" "));
239 
240  TString sDE = ((TObjString*)stringList->At(0))->GetString();
241  Int_t idDE = atoi(sDE.Data());
242 
243  if ( ! AliMpDEManager::IsValidDetElemId(idDE, false) ) {
244  AliErrorStream() << "DetElemId "<< idDE << " not valid." << endl;
245  delete stringList;
246  return false;
247  }
248 
249  TString busPatch = ((TObjString*)stringList->At(1))->GetString();
250 
251 
252  TString sDDL = ((TObjString*)stringList->At(2))->GetString();
253  Int_t iDDL = atoi(sDDL.Data());
254 
255  if ( iDDL < 0 || iDDL >= fgkNofDDLs ) {
256  AliErrorStream() << "DDL id "<< iDDL << " outside limits." << endl;
257  delete stringList;
258  return false;
259  }
260 
261  AliDebugStream(3)
262  << "idDE " << idDE << " buspatch " << busPatch.Data() << " iDDL " << iDDL
263  << endl;
264 
265  // reading 1st manu Id for each bus patch (station 1 & 2)
267 
268  TString sManu = ((TObjString*)stringList->At(3))->GetString();
270 
272  TString sManuBridge = ((TObjString*)stringList->At(4))->GetString();
273  AliMpHelper::DecodeName(sManuBridge,',',fManuBridge2[GetManuListIndex(idDE)]);
274  }
275 
276  }
277 
278  delete stringList;
279 
280  AliMpDDL* ddl = GetDDL(iDDL, false);
281  if ( !ddl) {
282  ddl = new AliMpDDL(iDDL);
283  fDDLs.AddAt(ddl, iDDL);
284  }
285  ddl->AddDE(idDE);
286 
287  TArrayI busPatchList;
288  // decoding range of buspatch
289  AliMpHelper::DecodeName(busPatch,';',busPatchList);
290 
291  // Update DE
293  de->SetDdlId(iDDL);
294  // filling buspatch -> idDE
295  for (Int_t i = 0; i < busPatchList.GetSize(); i++) {
296  fBusPatches.Add(busPatchList[i],
297  new AliMpBusPatch(busPatchList[i], idDE, iDDL));
298  de->AddBusPatch(busPatchList[i]);
299  }
300  }
301 
302  // Fill bus patch Ids array in DDLs now
303  for ( Int_t i=0; i<fDDLs.GetEntriesFast(); i++ ) {
304  AliMpDDL* ddl = (AliMpDDL*) fDDLs.At(i);
305  ddl->FillBusPatchIds();
306  }
307 
308  delete &in;
309  return true;
310 }
311 
312 //______________________________________________________________________________
314 {
316 
317  if ( ! fRegionalTrigger.ReadData(dataStreams) ) return false;
318 
319  return true;
320 }
321 
322 //______________________________________________________________________________
323 Bool_t
325 {
327 
328  Int_t iDDL = -1;
330  AliMpTriggerCrate* crate;
331 
332  while ( ( crate = static_cast<AliMpTriggerCrate*>(next()) ) )
333  {
334  TString crateName = crate->GetName();
335 
336  // determine ddl number vs crate side
337  if (crateName.Contains("R"))
338  iDDL = fgkNofDDLs; // starts where tracker ends
339  else
340  iDDL = fgkNofDDLs + 1;
341 
342  // Create DDL if it does not yet exist and set it to the crate
343  AliMpDDL* ddl = (AliMpDDL*)fDDLs.At(iDDL);
344  if ( !ddl) {
345  ddl = new AliMpDDL(iDDL);
346  fDDLs.AddAt(ddl, iDDL);
347  }
348  crate->SetDdlId(iDDL);
349 
350 
351  // Add trigger crate number for given ddl if not present
352  if ( !ddl->HasTriggerCrateId(crate->GetId()) )
353  ddl->AddTriggerCrate(crate->GetId());
354 
355 
356  // Loop over local boards in this crate
357 
358  for ( Int_t j=0; j<crate->GetNofLocalBoards(); ++j )
359  {
360  Int_t localBoardId = crate->GetLocalBoardId(j);
361  AliMpLocalBoard* localBoard
362  = fRegionalTrigger.FindLocalBoard(localBoardId);
363  if (!localBoard ) {
364  AliFatalClass("Cannot find local board.");
365  return kFALSE;
366  }
367 
368  // Loop over DEs in this localBoard
369 
370  for ( Int_t k=0; k<localBoard->GetNofDEs(); ++k )
371  {
372 
373  Int_t deId = localBoard->GetDEId(k);
375 
376  if ( de->GetDdlId() == -1 ) de->SetDdlId(iDDL);
377 
378  if ( ! ddl->HasDEId(deId) ) ddl->AddDE(deId);
379  }
380  }
381  }
382  return kTRUE;
383 }
384 
385 //______________________________________________________________________________
387 {
389 
391 
392  // loop over DDL
393  for (Int_t iDDL = 0; iDDL < fgkNofDDLs; ++iDDL) {
394 
395  AliDebug(3, Form("DDL # %d\n", iDDL));
396 
397  AliMpDDL* ddl = GetDDL(iDDL);
398 
399  // loop over DE in the given DDL
400  for (Int_t detElemIdx = 0; detElemIdx < ddl->GetNofDEs(); ++detElemIdx) {
401 
402  Int_t detElemId = ddl->GetDEId(detElemIdx);
403 
404  AliMpDetElement* detElement = GetDetElement(detElemId);
405 
406  AliMp::StationType stationType = AliMpDEManager::GetStationType(detElemId);
407 
408 
409  // list of manu per DE on both cathode
410  TList manuList;
411  for ( Int_t cath = 0; cath < 2 ; ++cath ) {
412  const AliMpVSegmentation* seg
414 
415  AliMp::PlaneType planeType = detElement->GetPlaneType(AliMp::GetCathodType(cath));
416 
417  TArrayI manus;
418  seg->GetAllElectronicCardIDs(manus);
419 
420  // filling TList manu
421  for ( Int_t im = 0; im < manus.GetSize(); ++im ) {
422 
423  AliMpIntPair* manu = 0x0;
424  if( stationType == AliMp::kStation345)
425  manu = new AliMpIntPair((manus[im] & manuMask), planeType, kTRUE); //remove offset for NB
426  else
427  manu = new AliMpIntPair(manus[im], planeType, kTRUE); //keep offset for NB
428 
429  manuList.Add(manu);
430 
431  detElement->AddManu(manus[im]);
432  }
433  }// cathode
434 
435  manuList.Sort(); // sort regardless B or NB plane
436 
437  // filling manu to the corresponding buspatch
438  for (Int_t iEntry = 0; iEntry < manuList.GetEntries(); ++iEntry) {
439 
440  AliMpIntPair* manuPtr = (AliMpIntPair*)manuList.At(iEntry);
441 
442  Int_t manuId = manuPtr->GetFirst();
443  Int_t pos = GetBusPatchIndex(detElemId, manuId);
444 
445  if (pos > detElement->GetNofBusPatches()) {
446  AliError(Form("pos greater %d than size %d manuId %d detElemId %d \n",
447  pos, detElement->GetNofBusPatches(), manuId, detElemId));
448  return false;
449  }
450 
451  // get buspatch and fill manus
452  Int_t busPatchId = detElement->GetBusPatchId(pos);
453  AliMpBusPatch* busPatch = GetBusPatch(busPatchId);
454 
455  if( stationType == AliMp::kStation345) {
456 
457  if (manuPtr->GetSecond())
458  busPatch->AddManu(manuId+manuMask+1); // add offset again after sorted
459  else
460  busPatch->AddManu(manuId);
461 
462  } else {
463 
464  busPatch->AddManu(manuId);
465 
466  }
467  }
468 
469  manuList.Delete();
470 
471  if (AliDebugLevel() == 3) {
472 
473  // print out for checking
474  for(Int_t pos = 0; pos < detElement->GetNofBusPatches(); ++pos) {
475  Int_t busPatchId = detElement->GetBusPatchId(pos);
476  AliMpBusPatch* busPatch = GetBusPatch(busPatchId);
477  printf("BusPatch: %d\n", busPatch->GetId());
478  for (Int_t iEntry = 0; iEntry < busPatch->GetNofManus(); ++iEntry)
479  printf("manu Id: %d\n", busPatch->GetManuId(iEntry));
480  }
481  }
482 
483  } // detection element loop
484  }// DDL loop
485 
486  return true;
487 }
488 
489 //______________________________________________________________________________
491 {
494 
495  istream& in
496  = dataStreams.
497  CreateDataStream(AliMpFiles::BusPatchSpecialFilePath());
498 
499  char line[255];
500 
501  while ( in.getline(line,255) ) {
502 
503  if ( line[0] == '#' ) continue;
504 
505  TString tmp(AliMpHelper::Normalize(line));
506  TObjArray* stringList = tmp.Tokenize(TString(" "));
507 
508  TString sKey = ((TObjString*)stringList->At(0))->GetString();
509 
510  TString sDDL = ((TObjString*)stringList->At(1))->GetString();
511  TArrayI ddlList;
512  AliMpHelper::DecodeName(sDDL,';',ddlList);
513 
514  TString sBusPatch = ((TObjString*)stringList->At(2))->GetString();
515  TArrayI busPatchList;
516  AliMpHelper::DecodeName(sBusPatch,',',busPatchList);
517 
518  // Loop over DDL and Bus Patch
519  for (Int_t iDDL = 0; iDDL < ddlList.GetSize(); ++iDDL ) {
520  for (Int_t iBusPatch = 0; iBusPatch < busPatchList.GetSize(); ++iBusPatch) {
521  // Global bus patch ID
522  Int_t busPatchID
524  busPatchList.At(iBusPatch), ddlList.At(iDDL));
525 
526  // Get this bus patch
527  AliMpBusPatch* busPatch = GetBusPatch(busPatchID);
528  if ( ! busPatch ) {
529  AliErrorStream() << "Bus patch " << busPatchID << " does not exist." << endl;
530  delete stringList;
531  return kFALSE;
532  }
533 
534  if ( sKey == GetRevertKeyword() ) {
535  AliDebugStream(3)
536  << "Reverting readout of bus patch " << busPatchID << endl;
537 
538  // Now revert the manus in this bus patch
539  busPatch->RevertReadout();
540  }
541  else if ( sKey == GetExplicitKeyword() ) {
542 
543  busPatch->ResetReadout();
544 
545  TString sManus = ((TObjString*)stringList->At(3))->GetString();
546  TArrayI manuList;
547  AliMpHelper::DecodeName(sManus,',',manuList);
548 
549  AliDebugStream(3)
550  << "Reseting readout of bus patch " << busPatchID
551  << " manus: " << sManus.Data() << endl;
552 
553  for (Int_t i = 0; i < manuList.GetSize(); i++) {
554  busPatch->AddManu(manuList.At(i));
555  }
556  }
557  else {
558  AliErrorStream() << "Unrecognized key." << endl;
559  delete stringList;
560  return kFALSE;
561  }
562  }
563  }
564  delete stringList;
565  }
566 
567  delete &in;
568 
569  return kTRUE;
570 }
571 
572 
573 //______________________________________________________________________________
575 {
577 
578  AliMpDEIterator it;
579  Bool_t result = true;
580 
581  for ( it.First(); !it.IsDone(); it.Next() ) {
582 
583  AliMpDetElement* detElement = it.CurrentDE();
584 
585  for (Int_t i = 0; i < detElement->GetNofBusPatches(); ++i) {
586  AliMpBusPatch* busPatch = GetBusPatch(detElement->GetBusPatchId(i));
587  Bool_t newResult = false;
588  Int_t idDE = busPatch->GetDEId();
589 
591  newResult = busPatch->SetNofManusPerModule(fManuBridge2[GetManuListIndex(idDE)].At(i));
592  else
593  newResult = busPatch->SetNofManusPerModule();
594  result = result && newResult;
595  }
596  }
597 
598  return result;
599 }
600 
601 //______________________________________________________________________________
603 {
605 
606  istream& in
607  = dataStreams.
608  CreateDataStream(AliMpFiles::BusPatchInfoFilePath());
609 
610  char line[255];
611 
612  for (Int_t iDDL = 0; iDDL < fgkNofDDLs; ++iDDL ) {
613  AliMpDDL* ddl = GetDDL(iDDL);
614 
615  for (Int_t iBusPatch = 0; iBusPatch < ddl->GetNofBusPatches(); ++iBusPatch) {
616 
617  do {
618  if (!in.getline(line,255)) {
619  AliWarning(Form("Wrong size in bus patch length file; index %d DDL %d",
620  iBusPatch, iDDL));
621  return false;
622  }
623  } while(line[0] == '#');
624 
625  TString tmp(AliMpHelper::Normalize(line));
626 
627  TObjArray* stringList = tmp.Tokenize(TString(" "));
628 
629  // Crocus label
630  TString crLabel = ((TObjString*)stringList->At(0))->GetString();
631  Int_t pos = crLabel.First('-');
632  tmp = crLabel(pos-2, crLabel.Length()-pos+2);
633  TArrayI list;
634  AliMpHelper::DecodeName(tmp.Data(), '-', list);
635 
636  Int_t localDDLId = list[0];
637  Int_t frtId = list[1] - 1; // begin at zero !
638  Int_t localBusId = list[2];
639 
640  // Add FRT number for given ddl if not present
641  if ( !ddl->HasFrtId(frtId) )
642  ddl->AddFrt(frtId);
643 
644  // BP & translator label
645  TString label = ((TObjString*)stringList->At(1))->GetString();
646  TString transLabel = ((TObjString*)stringList->At(2))->GetString();
647 
648  // BP length
649  TString sLength = ((TObjString*)stringList->At(3))->GetString();
650  Float_t length = sLength.Atof();
651 
652  delete stringList;
653 
654  if (localBusId != iBusPatch + 1)
655  AliWarning(Form("Wrong local buspatch id %d instead of %d", iBusPatch+1, localBusId));
656 
657  if(localDDLId != ddl->GetId()+1)
658  AliWarning(Form("Wrong local DDL id %d instead of %d", ddl->GetId()+1, localDDLId));
659 
660  Int_t busPatchId = ddl->GetBusPatchId(iBusPatch);
661  AliMpBusPatch* busPatch = GetBusPatch(busPatchId);
662  busPatch->SetCableLength(length);
663  busPatch->SetCableLabel(label);
664  busPatch->SetTranslatorLabel(transLabel);
665  busPatch->SetFrtId(frtId);
666 
667  }
668  }
669 
670  delete &in;
671 
672  return true;
673 }
674 
675 
676 //________________________________________________________________
677 Int_t AliMpDDLStore::GetLocalBoardId(TString name) const {
679 
681  AliMpLocalBoard* local;
682 
683  while ( ( local = static_cast<AliMpLocalBoard*>(next()) ) )
684  {
685  TString tmp(&local->GetName()[4], 2);
686  if (name.Contains(tmp))
687  if (name[0] == local->GetName()[0])
688  return local->GetId();
689  }
690 
691  return 0;
692 }
693 
694 //
695 // public methods
696 //
697 
698 
699 //______________________________________________________________________________
700 AliMpDDL* AliMpDDLStore::GetDDL(Int_t ddlId, Bool_t warn) const {
702 
703  AliMpDDL* ddl
704  = (AliMpDDL*)fDDLs.At(ddlId);
705 
706  if ( ! ddl && warn ) {
707  AliErrorStream()
708  << "DDL with Id = " << ddlId << " not defined." << endl;
709  }
710 
711  return ddl;
712 }
713 
714 //______________________________________________________________________________
715 AliMpDetElement* AliMpDDLStore::GetDetElement(Int_t detElemId, Bool_t warn) const {
717 
718  if ( ! AliMpDEStore::Instance() ) {
719  AliFatal("DE Store has not been loaded.");
720  return 0;
721  }
722 
723  return AliMpDEStore::Instance()->GetDetElement(detElemId, warn);
724 }
725 
726 //______________________________________________________________________________
727 AliMpBusPatch* AliMpDDLStore::GetBusPatch(Int_t busPatchId, Bool_t warn) const {
729 
730  AliMpBusPatch* busPatch
731  = (AliMpBusPatch*) fBusPatches.GetValue(busPatchId);
732 
733  if ( ! busPatch && warn ) {
734  AliErrorStream()
735  << "Bus patch with Id = " << busPatchId << " not defined." << endl;
736  }
737 
738  return busPatch;
739 }
740 
741 
742 //______________________________________________________________________________
743 AliMpLocalBoard* AliMpDDLStore::GetLocalBoard(Int_t localBoardId, Bool_t warn) const {
745 
746  return fRegionalTrigger.FindLocalBoard(localBoardId, warn);
747 }
748 
749 //______________________________________________________________________________
750 AliMpTriggerCrate* AliMpDDLStore::GetTriggerCrate(TString name, Bool_t warn) const {
752 
753  return fRegionalTrigger.FindTriggerCrate(name, warn);
754 }
755 
756 //______________________________________________________________________________
757 AliMpTriggerCrate* AliMpDDLStore::GetTriggerCrate(Int_t ddlId, Int_t index, Bool_t warn) const {
759 
760  if (ddlId == 0 || ddlId == 1)
761  ddlId += fgkNofDDLs;
762 
763  AliMpDDL* ddl = GetDDL(ddlId, warn);
764  if ( ! ddl )
765  return 0;
766 
767  if ( index >= ddl->GetNofTriggerCrates() ) {
768  AliError(Form("crate id %d greater than array[%d]", index, ddl->GetNofTriggerCrates()));
769  return 0;
770  }
771 
772  TString name = AliMpTriggerCrate::GenerateName(index, ddlId, fgkNofDDLs);
773 
774  return GetTriggerCrate(name, warn);
775 }
776 
777 //______________________________________________________________________________
778 Int_t AliMpDDLStore::GetDEfromBus(Int_t busPatchId) const {
780 
781  AliMpBusPatch* busPatch = GetBusPatch(busPatchId);
782 
783  if ( ! busPatch ) {
784  AliErrorStream()
785  << "Bus patch with Id = " << busPatchId << " not defined." << endl;
786  return 0;
787  }
788 
789  return busPatch->GetDEId();
790 }
791 
792 //______________________________________________________________________________
793 Int_t AliMpDDLStore::GetDEfromLocalBoard(Int_t localBoardId, Int_t chamberId) const {
795 
796  AliMpLocalBoard* localBoard = GetLocalBoard(localBoardId);
797 
798  if ( ! localBoard ) {
799  AliErrorStream()
800  << "Loacl board with Id = " << localBoardId << " not defined." << endl;
801  return 0;
802  }
803 
804  return localBoard->GetDEIdByChamber(chamberId);
805 }
806 
807 //______________________________________________________________________________
808 Int_t AliMpDDLStore::GetDDLfromBus(Int_t busPatchId) const {
810 
811  AliMpBusPatch* busPatch = GetBusPatch(busPatchId);
812 
813  if ( ! busPatch ) {
814  AliErrorStream()
815  << "Bus patch with Id = " << busPatchId << " not defined." << endl;
816  return 0;
817  }
818 
819  return busPatch->GetDdlId();
820 }
821 
822 //______________________________________________________________________________
823 Int_t AliMpDDLStore::GetBusPatchId(Int_t detElemId, Int_t manuId) const {
825 
826  AliMpDetElement* detElement = GetDetElement(detElemId);
827  Int_t pos = GetBusPatchIndex(detElemId, manuId);
828 
829  if ( pos >= detElement->GetNofBusPatches() )
830  {
831  AliErrorStream()
832  << "Pos = " << pos
833  << " greater than the size = " << detElement->GetNofBusPatches()
834  << " for detElemId = " << detElemId
835  << " manuId = " << manuId << endl;
836  return -1;
837  }
838 
839  return detElement->GetBusPatchId(pos);
840 }
841 
842 
843 //______________________________________________________________________________
844 Long_t AliMpDDLStore::GetLinkPortId(Int_t busPatchId) const {
845 
849 
850  AliMpBusPatch* busPatch = GetBusPatch(busPatchId);
851  Int_t ddlId = busPatch->GetDdlId();
852 
853  Int_t localBusPatchId = AliMpBusPatch::GetLocalBusID(busPatchId, ddlId) - 1; // begin at zero
854 
855  Int_t pos = (localBusPatchId % AliMpFrtCrocusConstants::GetNofBusPatches());
856 
858 
859 }
860 
861 //______________________________________________________________________________
867 
868  // Loop over DE
869  AliMpDEIterator it;
870  for ( it.First(); ! it.IsDone(); it.Next() ) {
871  AliMpDetElement* de = it.CurrentDE();
872  cout << "DE: " << de->GetId() << endl;
873 
874  // Loop over bus patches in this DE
875  for ( Int_t i=0; i< de->GetNofBusPatches(); ++i ) {
876 
877  AliMpBusPatch* busPatch = GetBusPatch(de->GetBusPatchId(i));
878  cout << " busPatch: " << busPatch->GetId() << endl;
879 
880  cout << " Manu : ";
881  for ( Int_t j=0; j<busPatch->GetNofManus(); ++j ) {
882  cout << std::setw(6) << busPatch->GetManuId(j) << " ";
883  }
884  cout << endl;
885 
886  if ( AliMpManuStore::Instance(kFALSE) ) {
887  cout << " Manu serial: ";
888  for ( Int_t k=0; k<busPatch->GetNofManus(); ++k ) {
889  cout << std::setw(6)
891  ->GetManuSerial(de->GetId(), busPatch->GetManuId(k)) << " ";
892  }
893  cout << endl;
894  }
895  }
896  }
897 }
898 
899 //______________________________________________________________________________
900 Int_t AliMpDDLStore::GetNextDEfromLocalBoard(Int_t localBoardId, Int_t chamberId ) const {
902 
903  AliMpLocalBoard* localBoard = GetLocalBoard(localBoardId);
904 
905  TString name(localBoard->GetName());
906 
907  Int_t line = AliMp::PairFirst(localBoard->GetPosition());
908  ++line;
909 
910  name.Replace(4,1,Form("%d", line));
911 
912  Int_t nextLocalId;
913  if ((nextLocalId = GetLocalBoardId(name)))
914  return GetDEfromLocalBoard(nextLocalId, chamberId);
915  else
916  return 0;
917 
918  return 0;
919 }
920 
921 //______________________________________________________________________________
922 Int_t AliMpDDLStore::GetPreviousDEfromLocalBoard(Int_t localBoardId, Int_t chamberId) const {
924 
925  AliMpLocalBoard* localBoard = GetLocalBoard(localBoardId);
926 
927  TString name(localBoard->GetName());
928 
929  Int_t line = AliMp::PairFirst(localBoard->GetPosition());
930  --line;
931 
932  name.Replace(4,1,Form("%d", line));
933 
934  Int_t prevLocalId;
935  if ((prevLocalId = GetLocalBoardId(name)))
936  return GetDEfromLocalBoard(prevLocalId, chamberId);
937  else
938  return 0;
939 
940 }
941 
942 //______________________________________________________________________________
944 {
946 
947  fRegionalTrigger = regionalTrigger;
948 
949  // Remove the existing trigger DDLsf
950  fDDLs.RemoveAt(fgkNofDDLs+1);
951  fDDLs.RemoveAt(fgkNofDDLs);
952 
953  // Set new trigger DDLs from new regional trigger
954  SetTriggerDDLs();
955 }
956 
957 
958 //______________________________________________________________________________
959 TIterator*
961 {
963 
964  return fBusPatches.CreateIterator();
965 }
Int_t GetNofManus() const
void SetTranslatorLabel(TString label)
Set label of translator.
Bool_t HasTriggerCrateId(Int_t crateId) const
Definition: AliMpDDL.cxx:243
static AliMq::Station12Type GetStation12Type(Int_t detElemId)
Long_t GetLinkPortId(Int_t busPatchId) const
Bool_t ReadTrigger(const AliMpDataStreams &dataStreams)
printf("Chi2/npoints = %f\n", TMath::Sqrt(chi2/npoints))
Int_t GetFirst() const
Return first value.
Definition: AliMpIntPair.h:50
The iterator over detection elements.
const AliMpVSegmentation * GetMpSegmentation(Int_t detElemId, AliMp::CathodType cath, Bool_t warn=true) const
AliMpLocalBoard * FindLocalBoard(Int_t localBoardId, Bool_t warn=true) const
TArrayI fManuBridge2[16]
Arrays of manu number before the bridge in buspatch.
void SetRegionalTrigger(const AliMpRegionalTrigger &regionalTrigger)
Bool_t ReadData(const TString &fileName)
AliMpLocalBoard * GetLocalBoard(Int_t localBoardId, Bool_t warn=true) const
static MpPair_t GetLinkPortId(Int_t index)
static AliMpDEStore * Instance(Bool_t warn=true)
Bool_t SetPatchModules()
#define AliDebugLevel()
Int_t GetDEfromLocalBoard(Int_t localBoardId, Int_t chamberId) const
Int_t GetId() const
Return the identifier (unique)
The class defines the properties of trigger crate.
static AliMpSegmentation * Instance(Bool_t warn=true)
#define TObjArray
static TString Normalize(const char *line)
void SetCableLabel(TString label)
Set label of buspatch.
The top container class for DDLs, det elements and bus patched.
Definition: AliMpDDLStore.h:35
TObjArray fDDLs
Array of DDL objects.
static const Int_t fgkNofDDLs
Total number of DDLs.
Bool_t ReadDDLs(const AliMpDataStreams &dataStreams)
Bool_t IsDone() const
station 3,4,5 (slats)
Bool_t AddTriggerCrate(Int_t crateId)
Definition: AliMpDDL.cxx:117
void SetSize(Int_t size)
Definition: AliMpExMap.cxx:322
static AliMpSegmentation * ReadData(const AliMpDataStreams &dataStreams, Bool_t warn=true)
Int_t GetDEfromBus(Int_t busPatchId) const
TIterator * CreateBusPatchIterator() const
Int_t GetPreviousDEfromLocalBoard(Int_t localBoardId, Int_t chamberId) const
Int_t GetDEId() const
Return the Detection element Id.
Definition: AliMpBusPatch.h:93
AliMpDetElement * GetDetElement(Int_t detElemId, Bool_t warn=true) const
AliMpDDLStore()
Not implemented.
AliMpDetElement * CurrentDE() const
Int_t GetNofDEs() const
AliMpDetElement * GetDetElement(Int_t detElemId, Bool_t warn=true) const
Int_t GetManuId(Int_t index) const
static AliMpManuStore * Instance(Bool_t warn=true)
Class that manages the properties of the local board.
Bool_t HasFrtId(Int_t frtId) const
Definition: AliMpDDL.cxx:194
The class defines the electronics properties of detection element.
AliMpRegionalTrigger fRegionalTrigger
Regional trigger.
static TString BusPatchSpecialFilePath()
Definition: AliMpFiles.cxx:310
Int_t GetDEId(Int_t index) const
Bool_t ReadBusPatchSpecial(const AliMpDataStreams &dataStreams)
The class defined electronics properties of DDL.
Definition: AliMpDDL.h:20
TIterator * CreateLocalBoardIterator() const
Bool_t AddFrt(Int_t frtId)
Definition: AliMpDDL.cxx:135
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
Bool_t AddBusPatch(Int_t busPatchId)
static AliMpDDLStore * Instance(Bool_t warn=true)
void SetDdlId(Int_t ddlId)
Set DDL Id.
static Int_t GetChamberId(Int_t detElemId, Bool_t warn=true)
AliMpExMap fBusPatches
The map of bus patches per their IDs.
Int_t GetNofBusPatches() const
Definition: AliMpDDL.cxx:203
static Int_t GetGlobalBusID(Int_t localID, Int_t ddlID)
Int_t GetBusPatchId(Int_t detElemId, Int_t manuId) const
Int_t GetManuSerial(Int_t detElemId, Int_t manuId) const
Int_t GetBusPatchIndex(Int_t detElemId, Int_t manuId) const
static TString GenerateName(Int_t crateId, Int_t ddlId, Int_t nodDdls)
void FillBusPatchIds()
Definition: AliMpDDL.cxx:78
AliMpDDL * GetDDL(Int_t ddlId, Bool_t warn=true) const
Int_t GetId() const
Return the unique Id.
Definition: AliMpDDL.h:83
Bool_t SetNofManusPerModule(Int_t manuNumber=0)
Int_t GetDEId(Int_t index) const
Definition: AliMpDDL.cxx:162
static AliMpDDLStore * fgInstance
Singleton instance.
Int_t GetNextDEfromLocalBoard(Int_t localBoardId, Int_t chamberId) const
MpPair_t GetPosition() const
given position (line, col)
non-bending plane
void SetCableLength(Float_t length)
Set length of buspatch.
static const TString & GetExplicitKeyword()
static AliMp::StationType GetStationType(Int_t detElemId)
AliMp::PlaneType GetPlaneType(AliMp::CathodType cath) const
Int_t GetDEIdByChamber(Int_t chamberId) const
AliMpBusPatch * GetBusPatch(Int_t busPatchId, Bool_t warn=true) const
AliMpTriggerCrate * FindTriggerCrate(TString crateName, Bool_t warn=true) const
TObject * GetValue(Int_t keyFirst, Int_t keySecond) const
Definition: AliMpExMap.cxx:365
Int_t GetDdlId() const
Return the Ddl Id.
Definition: AliMpBusPatch.h:97
Int_t GetId() const
Return the unique Id.
Definition: AliMpBusPatch.h:89
static AliMpDDLStore * ReadData(const AliMpDataStreams &dataStreams, Bool_t warn=true)
static TString BusPatchInfoFilePath()
Definition: AliMpFiles.cxx:302
AliMp::CathodType GetCathodType(Int_t cathodNumber)
Convert integer number in enum;.
The class defines the properties of regional trigger crate.
Bool_t HasDEId(Int_t detElemId) const
Definition: AliMpDDL.cxx:170
void Add(Int_t keyFirst, Int_t keySecond, TObject *object)
Definition: AliMpExMap.cxx:292
static const TString & GetRevertKeyword()
Int_t GetDdlId() const
Return DDL Id.
void SetOwner(Bool_t owner)
Definition: AliMpExMap.cxx:332
static Int_t GetLocalBusID(Int_t globalID, Int_t ddlID)
Int_t GetNofBusPatches() const
The class defines the properties of BusPatch.
Definition: AliMpBusPatch.h:21
TArrayI fManuList12[16]
Arrays of 1st manu in bus.
AliMpTriggerCrate * GetTriggerCrate(TString crateName, Bool_t warn=true) const
The abstract base class for the segmentation.
Bool_t AddDE(Int_t detElemId)
Definition: AliMpDDL.cxx:96
Int_t GetBusPatchId(Int_t index) const
Int_t PairFirst(MpPair_t pair)
Decode the first integer from encoded pair.
void SetFrtId(Int_t id)
Set FRT id for buspatch.
Int_t GetManuListIndex(Int_t detElemId) const
Bool_t SetTriggerDDLs()
void PrintAllManu() const
Print info of all manus.
static AliMpDetElement * GetDetElement(Int_t detElemId, Bool_t warn=true)
A pair of integers.
Definition: AliMpIntPair.h:23
Int_t GetBusPatchId(Int_t index) const
Definition: AliMpDDL.cxx:211
Bool_t ReadBusPatchInfo(const AliMpDataStreams &dataStreams)
Int_t GetSecond() const
Return second value.
Definition: AliMpIntPair.h:52
Int_t GetLocalBoardId(TString name) const
Bool_t AddManu(Int_t manuId)
void AddManu(Int_t manuId)
virtual ~AliMpDDLStore()
TIterator * CreateCrateIterator() const
Int_t GetId() const
Return Id.
static Bool_t IsValidDetElemId(Int_t detElemId, Bool_t warn=false)
Int_t GetDDLfromBus(Int_t busPatchId) const
Bool_t GetReadFromFiles() const
Int_t GetNofDEs() const
Definition: AliMpDDL.cxx:154
static Int_t ManuMask(AliMp::PlaneType planeType)
AliMpExMapIterator * CreateIterator() const
Definition: AliMpExMap.cxx:357
Mapping data streams provider.
static void DecodeName(const char *manus, char sep, TArrayI &theList)
virtual void GetAllElectronicCardIDs(TArrayI &ecn) const =0
Fill the given array with the electronic card IDs.
Int_t GetNofTriggerCrates() const
Definition: AliMpDDL.cxx:227
static TString BusPatchFilePath()
Definition: AliMpFiles.cxx:294