AliRoot Core  d69033e (d69033e)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMUONTriggerCrateStore.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 
19 #include "AliMpExMapIterator.h"
20 #include "AliMUONTriggerCrate.h"
26 #include "AliMUONCalibrationData.h"
27 #include "AliMUONTriggerLut.h"
28 
29 #include "AliMpTriggerCrate.h"
30 #include "AliMpLocalBoard.h"
31 #include "AliMpDDLStore.h"
32 #include "AliMpExMap.h"
33 #include "AliLog.h"
34 
35 #include <TString.h>
36 #include <TSystem.h>
37 #include <Riostream.h>
38 
39 #include <cstdio>
40 
41 //-----------------------------------------------------------------------------
48 //-----------------------------------------------------------------------------
49 
53 
54 //_____________________________________________________________________________
56 : TObject(),
57 fCrates(0x0),
58 fLocalBoards(0x0)
59 {
61 }
62 
63 //_____________________________________________________________________________
65 {
67  delete fCrates;
68  delete fLocalBoards;
69 }
70 
71 //_____________________________________________________________________________
72 void
74 {
76  if (!fCrates)
77  {
78  AliError("Object not properly initialized");
79  return;
80  }
81 
82  AliDebug(1,Form("Adding crate %s",name));
83  TObject* there = fCrates->GetValue(name);
84  if (there)
85  {
86  AliError(Form("Cannot add crate %s because it's already there !",name));
87  }
88  else
89  {
90  fCrates->Add(name,new AliMUONTriggerCrate(name,17));
91  }
92 }
93 
94 //_____________________________________________________________________________
96 AliMUONTriggerCrateStore::LocalBoard(Int_t boardNumber) const
97 {
99 
100  if ( !fLocalBoards )
101  {
102  AliError("Object not properly initialized");
103  return 0x0;
104  }
105 
106  return static_cast<AliMUONLocalTriggerBoard*>(fLocalBoards->GetValue(boardNumber));
107 }
108 
109 //_____________________________________________________________________________
110 TIterator*
112 {
114 
115  return fCrates ? fCrates->CreateIterator() : 0x0;
116 }
117 
118 //_____________________________________________________________________________
119 TIterator*
121 {
123 
124  return fLocalBoards ? fLocalBoards->CreateIterator() : 0x0;
125 }
126 
127 //_____________________________________________________________________________
129 AliMUONTriggerCrateStore::Crate(const char *name) const
130 {
132  if ( !fCrates )
133  {
134  AliError("Object not properly initialized");
135  return 0x0;
136  }
137  return static_cast<AliMUONTriggerCrate*>(fCrates->GetValue(name));
138 }
139 
140 // to be removed once AliMUONDigitMaker is linked with new mapping
141 //_____________________________________________________________________________
143 AliMUONTriggerCrateStore::Crate(Int_t ddl, Int_t reg) const
144 {
146  if ( !fCrates )
147  {
148  AliError("Object not properly initialized");
149  return 0x0;
150  }
151  TString name = GetCrateName(ddl, reg);
152  return static_cast<AliMUONTriggerCrate*>(fCrates->GetValue(name.Data()));
153 }
154 //____________________________________________________________________
155 TString AliMUONTriggerCrateStore::GetCrateName(Int_t ddl, Int_t reg) const
156 {
158 
159  Char_t name[10];
160  switch(reg) {
161  case 0:
162  case 1:
163  snprintf(name,10,"%d", reg+1);
164  break;
165  case 2:
166  strcpy(name, "2-3");
167  break;
168  case 3:
169  case 4:
170  case 5:
171  case 6:
172  case 7:
173  snprintf(name,10,"%d", reg);
174  break;
175  }
176 
177  // crate Right for first DDL
178  if (ddl == 0)
179  strncat(name, "R", 1);
180  else
181  strncat(name, "L", 1);
182 
183  return TString(name);
184 }
185 //_____________________________________________________________________________
186 Int_t
188 {
190  if ( fCrates ) return fCrates->GetSize();
191  return 0;
192 }
193 
194 //_____________________________________________________________________________
195 Int_t
197 {
199  if ( fLocalBoards ) return fLocalBoards->GetSize();
200  return 0;
201 }
202 
203 //_____________________________________________________________________________
204 void
206 {
208  fCrates = new AliMpExMap;
209  fCrates->SetOwner(kTRUE);
210  fLocalBoards = new AliMpExMap;
211  fLocalBoards->SetOwner(kFALSE);
212 
213 
214  AliMUONTriggerLut* lut = calibData->TriggerLut();
215 
216  if (!lut)
217  AliWarning("No valid trigger LUT in CDB");
218 
220  if (!regionalConfig) {
221  AliError("No valid regional trigger configuration in CDB");
222  return;
223  }
224 
225  TIter next(AliMpDDLStore::Instance()->GetRegionalTrigger()->CreateCrateIterator());
226  AliMpTriggerCrate* crateMapping;
227 
228  while ( ( crateMapping = static_cast<AliMpTriggerCrate*>(next()) ) )
229  {
230 
231  TString crateName = crateMapping->GetName();
232  AliMUONTriggerCrate *crate = Crate(crateName.Data());
233 
234  AliMUONTriggerCrateConfig* crateConfig = regionalConfig->FindTriggerCrate(crateName);
235 
236  if (!crate)
237  {
238  AddCrate(crateName.Data());
239  crate = Crate(crateName.Data());
240  AliDebug(3, Form("crate name %s\n", crateName.Data()));
242  crate->AddBoard(rboard, 0);
243  }
244 
245  for(Int_t iLocal = 0; iLocal < crateMapping->GetNofLocalBoards(); ++iLocal) {
246 
247  Int_t localBoardId = crateMapping->GetLocalBoardId(iLocal);
248  if (!localBoardId) continue; //empty slot, should not happen
249 
250  AliMpLocalBoard* localBoardMapping = AliMpDDLStore::Instance()->GetLocalBoard(localBoardId);
251  AliDebug(3, Form("local name %s id %d\n", localBoardMapping->GetName(), localBoardId));
252 
253  Int_t slot = localBoardMapping->GetSlot();
254  AliMUONLocalTriggerBoard *board = new AliMUONLocalTriggerBoard(localBoardMapping);
255  board->SetCoinc44(crateConfig->GetCoinc());
256  board->SetLUT(lut);
257 
258 
259  fLocalBoards->Add(localBoardId, board);
260 
261  crate->AddBoard(board, slot);
262 
263  } // iLocal
264  } // while
265 }
266 
void ReadFromFile(AliMUONCalibrationData *calibData)
The class defines the configuration of trigger crate.
AliMUONRegionalTriggerConfig * RegionalTriggerConfig() const
Get the config for regional trigger.
void SetCoinc44(Int_t coinc44=0)
Set Coinc 44 (0/1 = coinc34/coinc44)
AliMpLocalBoard * GetLocalBoard(Int_t localBoardId, Bool_t warn=true) const
The class defines the properties of trigger crate.
Int_t GetLocalBoardId(Int_t index) const
AliMUONTriggerCrateStore * fCrates
Class that manages the properties of the local board.
AliMUONLocalTriggerBoard * LocalBoard(Int_t boardNumber) const
Regional trigger - real HW algorithm is implemented.
TString GetCrateName(Int_t ddl, Int_t reg) const
TIterator * CreateCrateIterator() const
A container for AliMUONTriggerCrate objects.
AliMUONTriggerLut * TriggerLut() const
Get the trigger Look Up Table.
virtual void AddBoard(AliMUONTriggerBoard *board, Int_t i)
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
Int_t GetSize() const
Definition: AliMpExMap.cxx:340
Int_t GetNofLocalBoards() const
static AliMpDDLStore * Instance(Bool_t warn=true)
AliMpExMap * fCrates
list of crates
Implementation of local trigger board objects.
AliMUONTriggerCrateConfig * FindTriggerCrate(TString crateName, Bool_t warn=true) const
AliMpExMap * fLocalBoards
local boards (indexed by their number)
Int_t GetSlot() const
Return the slot Identifier in the given crate.
TObject * GetValue(Int_t keyFirst, Int_t keySecond) const
Definition: AliMpExMap.cxx:365
AliMUONRegionalTriggerConfig * regionalConfig
void Add(Int_t keyFirst, Int_t keySecond, TObject *object)
Definition: AliMpExMap.cxx:292
void AddCrate(const char *crateName)
AliMUONCalibrationData * calibData
void SetOwner(Bool_t owner)
Definition: AliMpExMap.cxx:332
Single entry point to access MUON calibration data.
TIterator * CreateLocalBoardIterator() const
AliMUONTriggerCrate * Crate(const char *crateName) const
MUON trigger look up table class.
The class defines the properties of regional trigger crate.
Helper class making Root persistent TExMap.
Definition: AliMpExMap.h:28
AliMpExMapIterator * CreateIterator() const
Definition: AliMpExMap.cxx:357
void SetLUT(AliMUONTriggerLut *lut)
Set LUT.