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>
41 ClassImp(AliMUONGlobalCrateConfig)
44 const Char_t* AliMUONGlobalCrateConfig::fgkJtagName = "JtagBoard";
45 const Char_t* AliMUONGlobalCrateConfig::fgkFirstDarcName = "LeftDarcBoard";
46 const Char_t* AliMUONGlobalCrateConfig::fgkSecondDarcName = "RightDarcBoard";
47 const Char_t* AliMUONGlobalCrateConfig::fgkGlobalName = "GlobalBoard";
48 const Char_t* AliMUONGlobalCrateConfig::fgkFetName = "FetBoard";
50 const Int_t AliMUONGlobalCrateConfig::fgkGlobalNofRegisters = 13;
51 const Int_t AliMUONGlobalCrateConfig::fgkFetNofRegisters = 7;
52 const Int_t AliMUONGlobalCrateConfig::fgkJtagNofLines = 4;
53 //______________________________________________________________________________
54 AliMUONGlobalCrateConfig::AliMUONGlobalCrateConfig()
55 : TNamed("GlobalCrate", "mapping trigger global crate"),
56 fGlobalCrateEnable(0x0),
63 fFirstDarcVmeAddr(0x0),
67 fFirstDarcL1TimeOut(0),
68 fFirstDarcGlobalL0(0),
70 fSecondDarcVmeAddr(0x0),
72 fSecondDarcDisable(0),
73 fSecondDarcL0Delay(0),
74 fSecondDarcL1TimeOut(0),
75 fSecondDarcGlobalL0(0),
80 /// Standard constructor
82 for (Int_t i = 0; i < fgkGlobalNofRegisters; ++i)
83 fGlobalRegisters[i] = 0;
85 for (Int_t j = 0; j < fgkFetNofRegisters; ++j)
89 //______________________________________________________________________________
90 AliMUONGlobalCrateConfig::~AliMUONGlobalCrateConfig()
95 //______________________________________________________________________________
96 Int_t AliMUONGlobalCrateConfig::ReadData(const TString& fileName)
98 /// Fill trigger global crate object from ascii file
99 /// put the method static to be used by other class w/o initializing object
101 TString inFileName(fileName);
102 if ( inFileName == "" )
103 inFileName = AliMpFiles::GlobalTriggerBoardMapping();
105 inFileName = gSystem->ExpandPathName(inFileName.Data());
107 ifstream in(inFileName.Data(), ios::in);
111 << "Global Trigger Board Mapping File " << fileName.Data() << " not found" << endl;
118 in.getline(line, 255);
119 TString tmp(AliMpHelper::Normalize(line));
121 if (!tmp.Contains(GetName()))
122 AliWarning("Wrong Global Crate File");
125 in.getline(line, 255);
126 tmp = AliMpHelper::Normalize(line);
128 sscanf(tmp.Data(), "%x", &en);
129 SetGlobalCrateEnable(en);
131 in.getline(line, 255);
132 tmp = AliMpHelper::Normalize(line);
134 if (tmp.Contains(GetJtagName())) {
136 in.getline(line, 255);
137 tmp = AliMpHelper::Normalize(line);
139 sscanf(tmp.Data(), "%lx", &addr);
140 SetJtagVmeAddr(addr);
141 AliDebug(1, Form("Jtag Vme Address: 0x%lx", addr));
143 // clk div, rx phase, read delay
144 in.getline(line, 255);
145 tmp = AliMpHelper::Normalize(line);
147 AliMpHelper::DecodeName(line, ' ', list);
148 SetJtagClockDiv(list[0]);
149 SetJtagRxPhase(list[1]);
150 SetJtagRdDelay(list[2]);
151 AliDebug(1, Form("Jtag Clock Div: %d, Rx Phase: %d, Read Delay %d", list[0], list[1], list[2]));
154 in.getline(line, 255);
155 tmp = AliMpHelper::Normalize(line);
156 AliMpHelper::DecodeName(line, ' ', list);
158 for (Int_t i = 0; i < GetJtagNofLines(); ++i)
159 enable |= (list[i] << i);
160 SetEnableJtag(enable);
161 AliDebug(1, Form("Jtag Enable: 0x%x", enable));
163 for (Int_t i = 0; i < GetJtagNofLines(); ++i) {
164 in.getline(line, 255);
165 for (Int_t j = 0; j < GetJtagNofLines(); ++j) {
166 in.getline(line, 255);
167 tmp = AliMpHelper::Normalize(line);
168 SetJtagCrateName(i*GetJtagNofLines() + j, tmp);
169 //AliDebug(1, Form("Jtag Crate Name: %s", tmp.Data()));
174 in.getline(line, 255);
175 tmp = AliMpHelper::Normalize(line);
176 if (tmp.Contains(GetFirstDarcName())) {
178 in.getline(line, 255);
179 tmp = AliMpHelper::Normalize(line);
181 sscanf(tmp.Data(), "%lx", &addr);
183 SetFirstDarcVmeAddr(addr);
184 AliDebug(1, Form("First Darc Vme Address: 0x%lx", addr));
187 in.getline(line, 255);
188 tmp = AliMpHelper::Normalize(line);
189 SetFirstDarcType(tmp.Atoi());
190 AliDebug(1, Form("First Darc Type: %d", tmp.Atoi()));
193 in.getline(line, 255);
195 tmp = AliMpHelper::Normalize(line);
196 sscanf(tmp.Data(), "%x", &item);
197 SetFirstDarcDisable(item);
198 AliDebug(1, Form("First Darc Disable: 0x%x", item));
201 in.getline(line, 255);
202 tmp = AliMpHelper::Normalize(line);
203 sscanf(tmp.Data(), "%x", &item);
204 SetFirstDarcL0Delay(item);
205 AliDebug(1, Form("First Darc L0 Delay: 0x%x", item));
208 in.getline(line, 255);
209 tmp = AliMpHelper::Normalize(line);
210 sscanf(tmp.Data(), "%x", &item);
211 SetFirstDarcL1TimeOut(item);
212 AliDebug(1, Form("First Darc L1 Time Out: 0x%x", item));
215 in.getline(line, 255);
216 tmp = AliMpHelper::Normalize(line);
217 sscanf(tmp.Data(), "%x", &item);
218 SetFirstDarcGlobalL0(item);
219 AliDebug(1, Form("First Darc Global L0 delay: 0x%x", item));
221 // Trigger configuration
222 in.getline(line, 255);
223 tmp = AliMpHelper::Normalize(line);
224 sscanf(tmp.Data(), "%x", &item);
225 SetFirstDarcConfig(item);
226 AliDebug(1, Form("First Darc Config: 0x%x", item));
230 in.getline(line, 255);
231 tmp = AliMpHelper::Normalize(line);
232 if (tmp.Contains(GetSecondDarcName())) {
234 in.getline(line, 255);
235 tmp = AliMpHelper::Normalize(line);
237 sscanf(tmp.Data(), "%lx", &addr);
239 SetSecondDarcVmeAddr(addr);
240 AliDebug(1, Form("Second Darc Vme Address: 0x%lx", addr));
243 in.getline(line, 255);
244 tmp = AliMpHelper::Normalize(line);
245 SetSecondDarcType(tmp.Atoi());
246 AliDebug(1, Form("Second Darc Type: %d", tmp.Atoi()));
249 in.getline(line, 255);
251 tmp = AliMpHelper::Normalize(line);
252 sscanf(tmp.Data(), "%x", &item);
253 SetSecondDarcDisable(item);
254 AliDebug(1, Form("Second Darc Disable: 0x%x", item));
257 in.getline(line, 255);
258 tmp = AliMpHelper::Normalize(line);
259 sscanf(tmp.Data(), "%x", &item);
260 SetSecondDarcL0Delay(item);
261 AliDebug(1, Form("Second Darc L0 Delay: 0x%x", item));
264 in.getline(line, 255);
265 tmp = AliMpHelper::Normalize(line);
266 sscanf(tmp.Data(), "%x", &item);
267 SetSecondDarcL1TimeOut(item);
268 AliDebug(1, Form("Second Darc L1 Time Out: 0x%x", item));
271 in.getline(line, 255);
272 tmp = AliMpHelper::Normalize(line);
273 sscanf(tmp.Data(), "%x", &item);
274 SetSecondDarcGlobalL0(item);
275 AliDebug(1, Form("Second Darc Global L0 delay: 0x%x", item));
277 // Trigger configuration
278 in.getline(line, 255);
279 tmp = AliMpHelper::Normalize(line);
280 sscanf(tmp.Data(), "%x", &item);
281 SetSecondDarcConfig(item);
282 AliDebug(1, Form("Second Darc Config: 0x%x", item));
285 in.getline(line, 255);
286 tmp = AliMpHelper::Normalize(line);
287 if (tmp.Contains(GetGlobalName())) {
288 in.getline(line, 255);
289 tmp = AliMpHelper::Normalize(line);
291 sscanf(tmp.Data(), "%lx", &addr);
292 SetGlobalVmeAddr(addr);
293 AliDebug(1, Form("Global Vme Address: 0x%lx", addr));
295 for (Int_t i = 0; i < GetGlobalNofRegisters(); ++i) {
296 in.getline(line, 255);
297 tmp = AliMpHelper::Normalize(line);
299 sscanf(tmp.Data(), "%x", ®);
300 SetGlobalRegister(i, reg);
301 AliDebug(1, Form("Global Register %d: 0x%x", i, reg));
305 in.getline(line, 255);
306 tmp = AliMpHelper::Normalize(line);
307 if (tmp.Contains(GetFetName())) {
308 in.getline(line, 255);
309 tmp = AliMpHelper::Normalize(line);
311 sscanf(tmp.Data(), "%lx", &addr);
313 AliDebug(1, Form("Fet Vme Address: 0x%lx", addr));
315 for (Int_t i = 0; i < GetFetNofRegisters(); ++i) {
316 in.getline(line, 255);
317 tmp = AliMpHelper::Normalize(line);
319 sscanf(tmp.Data(), "%x", ®);
320 SetFetRegister(i, reg);
321 AliDebug(1, Form("Fet Register %d: 0x%x", i, reg));
328 //______________________________________________________________________________
329 Bool_t AliMUONGlobalCrateConfig::GetEnableJtag(Int_t index) const
331 /// returns enable mask for a given Jtag line
333 if (index > fgkJtagNofLines) {
334 AliWarning("Index size too big for Jtag line");
337 return ((fEnableJtag >> index) & 0x1);
341 //______________________________________________________________________________
342 void AliMUONGlobalCrateConfig::SetJtagCrateName(Int_t index, TString name)
344 /// Get Jtag crate name for a given index
345 if (index > AliMpConstants::LocalBoardNofChannels()) {
346 AliWarning("Index size too big for Jtag line");
349 fJtagCrateName[index] = name;
352 //______________________________________________________________________________
353 TString AliMUONGlobalCrateConfig::GetJtagCrateName(Int_t jtagLine, Int_t index) const
355 /// Get the crate name for a given line and a given index
356 if (jtagLine > AliMpConstants::LocalBoardNofChannels() || index > AliMpConstants::LocalBoardNofChannels())
359 return fJtagCrateName[jtagLine*fgkJtagNofLines + index];
362 //______________________________________________________________________________
363 UInt_t AliMUONGlobalCrateConfig::GetGlobalRegister(Int_t index) const
365 /// return global register for a given index
366 if (index >= fgkGlobalNofRegisters) {
367 AliWarning("Index size too big for Global Register");
370 return fGlobalRegisters[index];
373 //______________________________________________________________________________
374 void AliMUONGlobalCrateConfig::SetGlobalRegister(Int_t index, UInt_t reg)
376 /// set Global register for a given index
377 if (index >= fgkGlobalNofRegisters) {
378 AliWarning("Index size too big for Global Register");
381 fGlobalRegisters[index] = reg;
384 //______________________________________________________________________________
385 void AliMUONGlobalCrateConfig::SetGlobalMask(Int_t index, UInt_t mask)
387 /// set one word of the global mask
389 if (index >= 0 && index < 4) {
390 SetGlobalRegister(index,mask);
392 AliWarning(Form("Check register number of the mask (%d) \n",index));
397 //______________________________________________________________________________
398 UInt_t AliMUONGlobalCrateConfig::GetGlobalMask(Int_t index) const
400 /// return one word of the global mask
401 if (index >= 0 && index < 4) {
402 return fGlobalRegisters[index];
404 AliWarning(Form("Check register number of the mask (%d) \n",index));
409 //______________________________________________________________________________
410 Bool_t AliMUONGlobalCrateConfig::GetMasksOn() const
412 /// indicates if global masks are active on global inputs
415 if (fGlobalRegisters[4] & 0x40) return kTRUE;
421 //______________________________________________________________________________
422 UInt_t AliMUONGlobalCrateConfig::GetFetRegister(Int_t index) const
424 /// return global register for a given index
425 if (index >= fgkFetNofRegisters) {
426 AliWarning("Index size too big for Fet Register");
429 return fFetRegisters[index];
432 //______________________________________________________________________________
433 void AliMUONGlobalCrateConfig::SetFetRegister(Int_t index, UInt_t reg)
435 /// set Global register for a given index
436 if (index >= fgkFetNofRegisters) {
437 AliWarning("Index size too big for Global Register");
440 fFetRegisters[index] = reg;