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: AliMpTrigger.cxx,v 1.4 2006/05/24 13:58:52 ivana Exp $
19 //-----------------------------------------------------------------------------
20 // Class AliMUONGlobalCrateConfig
21 // --------------------
22 // The class defines the configuration of trigger crate
23 // Author: Ch. Finck, Subatech Nantes
24 //-----------------------------------------------------------------------------
26 #include "AliMUONGlobalCrateConfig.h"
27 #include "AliMpConstants.h"
28 #include "AliMpFiles.h"
29 #include "AliMpHelper.h"
34 #include <Riostream.h>
38 ClassImp(AliMUONGlobalCrateConfig)
41 const Char_t* AliMUONGlobalCrateConfig::fgkJtagName = "JtagBoard";
42 const Char_t* AliMUONGlobalCrateConfig::fgkFirstDarcName = "LeftDarcBoard";
43 const Char_t* AliMUONGlobalCrateConfig::fgkSecondDarcName = "RightDarcBoard";
44 const Char_t* AliMUONGlobalCrateConfig::fgkGlobalName = "GlobalBoard";
45 const Char_t* AliMUONGlobalCrateConfig::fgkFetName = "FetBoard";
47 const Int_t AliMUONGlobalCrateConfig::fgkGlobalNofRegisters = 13;
48 const Int_t AliMUONGlobalCrateConfig::fgkFetNofRegisters = 7;
49 const Int_t AliMUONGlobalCrateConfig::fgkJtagNofLines = 4;
50 //______________________________________________________________________________
51 AliMUONGlobalCrateConfig::AliMUONGlobalCrateConfig()
52 : TNamed("GlobalCrate", "mapping trigger global crate"),
53 fGlobalCrateEnable(0x0),
60 fFirstDarcVmeAddr(0x0),
64 fFirstDarcL1TimeOut(0),
65 fFirstDarcGlobalL0(0),
67 fSecondDarcVmeAddr(0x0),
69 fSecondDarcDisable(0),
70 fSecondDarcL0Delay(0),
71 fSecondDarcL1TimeOut(0),
72 fSecondDarcGlobalL0(0),
77 /// Standard constructor
79 for (Int_t i = 0; i < fgkGlobalNofRegisters; ++i)
80 fGlobalRegisters[i] = 0;
82 for (Int_t j = 0; j < fgkFetNofRegisters; ++j)
86 //______________________________________________________________________________
87 AliMUONGlobalCrateConfig::~AliMUONGlobalCrateConfig()
92 //______________________________________________________________________________
93 Int_t AliMUONGlobalCrateConfig::ReadData(const TString& fileName)
95 /// Fill trigger global crate object from ascii file
96 /// put the method static to be used by other class w/o initializing object
98 TString inFileName(fileName);
99 if ( inFileName == "" )
100 inFileName = AliMpFiles::GlobalTriggerBoardMapping();
102 inFileName = gSystem->ExpandPathName(inFileName.Data());
104 ifstream in(inFileName.Data(), ios::in);
108 << "Global Trigger Board Mapping File " << fileName.Data() << " not found" << endl;
115 in.getline(line, 255);
116 TString tmp(AliMpHelper::Normalize(line));
118 if (!tmp.Contains(GetName()))
119 AliWarning("Wrong Global Crate File");
122 in.getline(line, 255);
123 tmp = AliMpHelper::Normalize(line);
125 sscanf(tmp.Data(), "%x", &en);
126 SetGlobalCrateEnable(en);
128 in.getline(line, 255);
129 tmp = AliMpHelper::Normalize(line);
131 if (tmp.Contains(GetJtagName())) {
133 in.getline(line, 255);
134 tmp = AliMpHelper::Normalize(line);
136 sscanf(tmp.Data(), "%lx", &addr);
137 SetJtagVmeAddr(addr);
138 AliDebug(1, Form("Jtag Vme Address: 0x%lx", addr));
140 // clk div, rx phase, read delay
141 in.getline(line, 255);
142 tmp = AliMpHelper::Normalize(line);
144 AliMpHelper::DecodeName(line, ' ', list);
145 SetJtagClockDiv(list[0]);
146 SetJtagRxPhase(list[1]);
147 SetJtagRdDelay(list[2]);
148 AliDebug(1, Form("Jtag Clock Div: %d, Rx Phase: %d, Read Delay %d", list[0], list[1], list[2]));
151 in.getline(line, 255);
152 tmp = AliMpHelper::Normalize(line);
153 AliMpHelper::DecodeName(line, ' ', list);
155 for (Int_t i = 0; i < GetJtagNofLines(); ++i)
156 enable |= (list[i] << i);
157 SetEnableJtag(enable);
158 AliDebug(1, Form("Jtag Enable: 0x%x", enable));
160 for (Int_t i = 0; i < GetJtagNofLines(); ++i) {
161 in.getline(line, 255);
162 for (Int_t j = 0; j < GetJtagNofLines(); ++j) {
163 in.getline(line, 255);
164 tmp = AliMpHelper::Normalize(line);
165 SetJtagCrateName(i*GetJtagNofLines() + j, tmp);
166 //AliDebug(1, Form("Jtag Crate Name: %s", tmp.Data()));
171 in.getline(line, 255);
172 tmp = AliMpHelper::Normalize(line);
173 if (tmp.Contains(GetFirstDarcName())) {
175 in.getline(line, 255);
176 tmp = AliMpHelper::Normalize(line);
178 sscanf(tmp.Data(), "%lx", &addr);
180 SetFirstDarcVmeAddr(addr);
181 AliDebug(1, Form("First Darc Vme Address: 0x%lx", addr));
184 in.getline(line, 255);
185 tmp = AliMpHelper::Normalize(line);
186 SetFirstDarcType(tmp.Atoi());
187 AliDebug(1, Form("First Darc Type: %d", tmp.Atoi()));
190 in.getline(line, 255);
192 tmp = AliMpHelper::Normalize(line);
193 sscanf(tmp.Data(), "%x", &item);
194 SetFirstDarcDisable(item);
195 AliDebug(1, Form("First Darc Disable: 0x%x", item));
198 in.getline(line, 255);
199 tmp = AliMpHelper::Normalize(line);
200 sscanf(tmp.Data(), "%x", &item);
201 SetFirstDarcL0Delay(item);
202 AliDebug(1, Form("First Darc L0 Delay: 0x%x", item));
205 in.getline(line, 255);
206 tmp = AliMpHelper::Normalize(line);
207 sscanf(tmp.Data(), "%x", &item);
208 SetFirstDarcL1TimeOut(item);
209 AliDebug(1, Form("First Darc L1 Time Out: 0x%x", item));
212 in.getline(line, 255);
213 tmp = AliMpHelper::Normalize(line);
214 sscanf(tmp.Data(), "%x", &item);
215 SetFirstDarcGlobalL0(item);
216 AliDebug(1, Form("First Darc Global L0 delay: 0x%x", item));
218 // Trigger configuration
219 in.getline(line, 255);
220 tmp = AliMpHelper::Normalize(line);
221 sscanf(tmp.Data(), "%x", &item);
222 SetFirstDarcConfig(item);
223 AliDebug(1, Form("First Darc Config: 0x%x", item));
227 in.getline(line, 255);
228 tmp = AliMpHelper::Normalize(line);
229 if (tmp.Contains(GetSecondDarcName())) {
231 in.getline(line, 255);
232 tmp = AliMpHelper::Normalize(line);
234 sscanf(tmp.Data(), "%lx", &addr);
236 SetSecondDarcVmeAddr(addr);
237 AliDebug(1, Form("Second Darc Vme Address: 0x%lx", addr));
240 in.getline(line, 255);
241 tmp = AliMpHelper::Normalize(line);
242 SetSecondDarcType(tmp.Atoi());
243 AliDebug(1, Form("Second Darc Type: %d", tmp.Atoi()));
246 in.getline(line, 255);
248 tmp = AliMpHelper::Normalize(line);
249 sscanf(tmp.Data(), "%x", &item);
250 SetSecondDarcDisable(item);
251 AliDebug(1, Form("Second Darc Disable: 0x%x", item));
254 in.getline(line, 255);
255 tmp = AliMpHelper::Normalize(line);
256 sscanf(tmp.Data(), "%x", &item);
257 SetSecondDarcL0Delay(item);
258 AliDebug(1, Form("Second Darc L0 Delay: 0x%x", item));
261 in.getline(line, 255);
262 tmp = AliMpHelper::Normalize(line);
263 sscanf(tmp.Data(), "%x", &item);
264 SetSecondDarcL1TimeOut(item);
265 AliDebug(1, Form("Second Darc L1 Time Out: 0x%x", item));
268 in.getline(line, 255);
269 tmp = AliMpHelper::Normalize(line);
270 sscanf(tmp.Data(), "%x", &item);
271 SetSecondDarcGlobalL0(item);
272 AliDebug(1, Form("Second Darc Global L0 delay: 0x%x", item));
274 // Trigger configuration
275 in.getline(line, 255);
276 tmp = AliMpHelper::Normalize(line);
277 sscanf(tmp.Data(), "%x", &item);
278 SetSecondDarcConfig(item);
279 AliDebug(1, Form("Second Darc Config: 0x%x", item));
282 in.getline(line, 255);
283 tmp = AliMpHelper::Normalize(line);
284 if (tmp.Contains(GetGlobalName())) {
285 in.getline(line, 255);
286 tmp = AliMpHelper::Normalize(line);
288 sscanf(tmp.Data(), "%lx", &addr);
289 SetGlobalVmeAddr(addr);
290 AliDebug(1, Form("Global Vme Address: 0x%lx", addr));
292 for (Int_t i = 0; i < GetGlobalNofRegisters(); ++i) {
293 in.getline(line, 255);
294 tmp = AliMpHelper::Normalize(line);
296 sscanf(tmp.Data(), "%x", ®);
297 SetGlobalRegister(i, reg);
298 AliDebug(1, Form("Global Register %d: 0x%x", i, reg));
302 in.getline(line, 255);
303 tmp = AliMpHelper::Normalize(line);
304 if (tmp.Contains(GetFetName())) {
305 in.getline(line, 255);
306 tmp = AliMpHelper::Normalize(line);
308 sscanf(tmp.Data(), "%lx", &addr);
310 AliDebug(1, Form("Fet Vme Address: 0x%lx", addr));
312 for (Int_t i = 0; i < GetFetNofRegisters(); ++i) {
313 in.getline(line, 255);
314 tmp = AliMpHelper::Normalize(line);
316 sscanf(tmp.Data(), "%x", ®);
317 SetFetRegister(i, reg);
318 AliDebug(1, Form("Fet Register %d: 0x%x", i, reg));
325 //______________________________________________________________________________
326 Bool_t AliMUONGlobalCrateConfig::GetEnableJtag(Int_t index) const
328 /// returns enable mask for a given Jtag line
330 if (index > fgkJtagNofLines) {
331 AliWarning("Index size too big for Jtag line");
334 return ((fEnableJtag >> index) & 0x1);
338 //______________________________________________________________________________
339 void AliMUONGlobalCrateConfig::SetJtagCrateName(Int_t index, TString name)
341 /// Get Jtag crate name for a given index
342 if (index > AliMpConstants::LocalBoardNofChannels()) {
343 AliWarning("Index size too big for Jtag line");
346 fJtagCrateName[index] = name;
349 //______________________________________________________________________________
350 TString AliMUONGlobalCrateConfig::GetJtagCrateName(Int_t jtagLine, Int_t index) const
352 /// Get the crate name for a given line and a given index
353 if (jtagLine > AliMpConstants::LocalBoardNofChannels() || index > AliMpConstants::LocalBoardNofChannels())
356 return fJtagCrateName[jtagLine*fgkJtagNofLines + index];
359 //______________________________________________________________________________
360 UInt_t AliMUONGlobalCrateConfig::GetGlobalRegister(Int_t index) const
362 /// return global register for a given index
363 if (index >= fgkGlobalNofRegisters) {
364 AliWarning("Index size too big for Global Register");
367 return fGlobalRegisters[index];
370 //______________________________________________________________________________
371 void AliMUONGlobalCrateConfig::SetGlobalRegister(Int_t index, UInt_t reg)
373 /// set Global register for a given index
374 if (index >= fgkGlobalNofRegisters) {
375 AliWarning("Index size too big for Global Register");
378 fGlobalRegisters[index] = reg;
381 //______________________________________________________________________________
382 void AliMUONGlobalCrateConfig::SetGlobalMask(Int_t index, UInt_t mask)
384 /// set one word of the global mask
386 if (index >= 0 && index < 4) {
387 SetGlobalRegister(index,mask);
389 AliWarning(Form("Check register number of the mask (%d) \n",index));
394 //______________________________________________________________________________
395 UInt_t AliMUONGlobalCrateConfig::GetGlobalMask(Int_t index) const
397 /// return one word of the global mask
398 if (index >= 0 && index < 4) {
399 return fGlobalRegisters[index];
401 AliWarning(Form("Check register number of the mask (%d) \n",index));
406 //______________________________________________________________________________
407 Bool_t AliMUONGlobalCrateConfig::GetMasksOn() const
409 /// indicates if global masks are active on global inputs
412 if (fGlobalRegisters[4] & 0x40) return kTRUE;
418 //______________________________________________________________________________
419 UInt_t AliMUONGlobalCrateConfig::GetFetRegister(Int_t index) const
421 /// return global register for a given index
422 if (index >= fgkFetNofRegisters) {
423 AliWarning("Index size too big for Fet Register");
426 return fFetRegisters[index];
429 //______________________________________________________________________________
430 void AliMUONGlobalCrateConfig::SetFetRegister(Int_t index, UInt_t reg)
432 /// set Global register for a given index
433 if (index >= fgkFetNofRegisters) {
434 AliWarning("Index size too big for Global Register");
437 fFetRegisters[index] = reg;