AliRoot Core  a565103 (a565103)
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Groups Pages
AliMpRegionalTrigger.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: AliMpTrigger.cxx,v 1.4 2006/05/24 13:58:52 ivana Exp $
18 
19 //-----------------------------------------------------------------------------
20 // Class AliMpRegionalTrigger
21 // --------------------
22 // The class defines the properties of regional trigger crate
23 // Author: Ch. Finck, Subatech Nantes
24 //-----------------------------------------------------------------------------
25 
26 #include "AliMpRegionalTrigger.h"
27 #include "AliMpExMapIterator.h"
28 #include "AliMpTriggerCrate.h"
29 #include "AliMpLocalBoard.h"
30 #include "AliMpConstants.h"
31 #include "AliMpFiles.h"
32 #include "AliMpDataStreams.h"
33 #include "AliMpHelper.h"
34 
35 #include "AliLog.h"
36 
37 #include <TArrayI.h>
38 #include <Riostream.h>
39 #include <TClass.h>
40 #include <TSystem.h>
41 
42 
46 
47 
48 //______________________________________________________________________________
50  : TObject(),
51  fTriggerCrates(),
52  fLocalBoardMap(),
53  fLocalBoardArray(AliMpConstants::TotalNofLocalBoards()+1) // included non-notified boards
54 {
56 
57  fTriggerCrates.SetOwner(true);
58  fTriggerCrates.SetSize(AliMpConstants::LocalBoardNofChannels());
59 }
60 
61 //______________________________________________________________________________
63  : TObject(rhs),
64  fTriggerCrates(rhs.fTriggerCrates),
65  fLocalBoardMap(rhs.fLocalBoardMap),
66  fLocalBoardArray(rhs.fLocalBoardArray)
67 {
69 }
70 
71 //______________________________________________________________________________
73  : TObject(),
74  fTriggerCrates(ioCtor),
75  fLocalBoardMap(ioCtor),
76  fLocalBoardArray()
77 {
79 }
80 
81 //______________________________________________________________________________
83 {
85 
86  // check assignment to self
87  if (this == &rhs) return *this;
88 
89  // base class assignment
90  TObject::operator=(rhs);
91 
92  // assignment operator
95 
96  return *this;
97 }
98 
99 //______________________________________________________________________________
101 {
103 }
104 
105 
106 //
107 // private methods
108 //
109 
110 //______________________________________________________________________________
112 {
115 
116  if ( !in.good() ) return kFALSE;
117 
118  Int_t localBoardId = 0;
119  TArrayI listInt;
120  UShort_t crateId;
121  Int_t nofBoards;
122  Int_t localBoardIndex(0);
123  char line[80];
124 
125  // decode file and store in objects
126  while (!in.eof())
127  {
128  in.getline(line,80);
129  if (!strlen(line)) break;
130  TString crateName(AliMpHelper::Normalize(line));
131 
132  in.getline(line,80);
133  sscanf(line,"%hx",&crateId);
134 
135  // skip data which are not stored in mapping object
136  // (mode, coincidence, mask)
137  in.getline(line,80);
138  in.getline(line,80);
139  in.getline(line,80);
140 
141  // read # local board
142  in.getline(line,80);
143  sscanf(line,"%d",&nofBoards);
144 
145  AliMpTriggerCrate* crate
146  = (AliMpTriggerCrate*)(fTriggerCrates.GetValue(crateName.Data()));
147  if (!crate) {
148  crate = new AliMpTriggerCrate(crateName.Data(), crateId);
149  fTriggerCrates.Add(crateName.Data(), crate);
150  }
151 
152  Char_t localBoardName[20];
153  Int_t slot;
154  UInt_t switches;
155 
156  for ( Int_t i = 0; i < nofBoards; ++i )
157  {
158  in.getline(line,80);
159  sscanf(line,"%02d %19s %03d %03x",&slot,localBoardName,&localBoardId,&switches);
160  AliMpLocalBoard* board = new AliMpLocalBoard(localBoardId, localBoardName, slot);
161  board->SetSwitch(switches);
162  board->SetCrate(crateName);
163 
164  if (localBoardId > AliMpConstants::NofLocalBoards())
165  board->SetNotified(false); // copy cards
166 
167  crate->AddLocalBoard(localBoardId);
168 
169  // add list of DEs for local board
170  listInt.Reset();
171  in.getline(line,80);
172  TString tmp(AliMpHelper::Normalize(line));
173  AliMpHelper::DecodeName(tmp,' ',listInt);
174  for (Int_t ii = 0; ii < listInt.GetSize(); ++ii) {
175  if ( listInt[ii] ) board->AddDE(listInt[ii]);
176  }
177 
178  // set copy number and transverse connector
179  in.getline(line,80);
180  TString tmp1 = AliMpHelper::Normalize(line);
181  AliMpHelper::DecodeName(tmp1,' ',listInt);
182 
183  board->SetInputXfrom(listInt[0]);
184  board->SetInputXto(listInt[1]);
185 
186  board->SetInputYfrom(listInt[2]);
187  board->SetInputYto(listInt[3]);
188 
189  board->SetTC(listInt[4]);
190 
191  // add local board into array
192  fLocalBoardArray.AddAt(board,localBoardIndex);
193  fLocalBoardMap.Add(board->GetId(),board);
194 
195  ++localBoardIndex;
196  }
197  }
198 
199  AliDebug(1,Form("%d trigger crate created",fTriggerCrates.GetSize()));
200  AliDebug(1,Form("%d local board added to the map",fLocalBoardMap.GetSize()));
201  AliDebug(1,Form("%d local board referenced from the array",fLocalBoardArray.GetLast()+1));
202 
203  return kTRUE;
204 }
205 
206 //
207 // public methods
208 //
209 
210 //______________________________________________________________________________
211 Bool_t AliMpRegionalTrigger::ReadData(const TString& fileName)
212 {
215 
216  AliDebugStream(2) << "Read data from file " << fileName.Data() << endl;
217 
218  TString inFileName(gSystem->ExpandPathName(fileName.Data()));
219  ifstream inFile(inFileName.Data(), ios::in);
220  if ( ! inFile.good() ) {
221  AliErrorStream()
222  << "Local Trigger Board Mapping File " << inFileName.Data() << " not found bordel de merde" << endl;
223  return kFALSE;
224  }
225 
226  return ReadData(inFile);
227 }
228 
229 //______________________________________________________________________________
231 {
234 
235  AliDebugStream(2) << "Read data from stream " << endl;
236  istream& in
237  = dataStreams.
238  CreateDataStream(AliMpFiles::LocalTriggerBoardMapping());
239 
240  Bool_t result = ReadData(in);
241 
242  delete &in;
243  return result;
244 }
245 
246 //______________________________________________________________________________
248  Bool_t warn) const {
250 
251  AliMpLocalBoard* localBoard
252  = static_cast<AliMpLocalBoard*>(fLocalBoardMap.GetValue(localBoardId));
253 
254  if ( ! localBoard && warn ) {
255  AliErrorStream()
256  << "Loacl board with localBoardId = " << localBoardId << " not found." << endl;
257  }
258 
259  return localBoard;
260 }
261 
262 //______________________________________________________________________________
264  Bool_t warn) const {
266 
267  AliMpTriggerCrate* crate
268  = (AliMpTriggerCrate*) fTriggerCrates.GetValue(name.Data());
269 
270  if ( ! crate && warn ) {
271  AliErrorStream()
272  << "Trigger crate with name = " << name.Data() << " not defined." << endl;
273  }
274 
275  return crate;
276 }
277 
278 //______________________________________________________________________________
280 {
282 
283  return fTriggerCrates.GetSize();
284 }
285 
286 //______________________________________________________________________________
288 {
290 
291  return fLocalBoardArray.GetLast()+1;
292 }
293 
294 //______________________________________________________________________________
295 TIterator*
297 {
299 
301 }
302 
303 //______________________________________________________________________________
304 TIterator*
306 {
308 
309  return fLocalBoardArray.MakeIterator();
310 }
311 
312 //______________________________________________________________________________
313 Int_t
315 {
317 
318  AliMpLocalBoard* lb = static_cast<AliMpLocalBoard*>(fLocalBoardArray.At(index));
319  if (lb)
320  {
321  return lb->GetId();
322  }
323  AliError(Form("Could not get local board at index %d",index));
324  return -1;
325 }
326 
327 //______________________________________________________________________________
329 {
331 
332  fTriggerCrates.SetOwner(owner);
333 }
void SetInputYto(Int_t id)
Set Id to where the Y input are copied.
Bool_t AddDE(Int_t detElemId)
AliMpLocalBoard * FindLocalBoard(Int_t localBoardId, Bool_t warn=true) const
Bool_t ReadData(const TString &fileName)
Int_t GetNofTriggerCrates() const
Int_t GetId() const
Return the identifier (unique)
The class defines the properties of trigger crate.
AliMpRegionalTrigger & operator=(const AliMpRegionalTrigger &rhs)
static TString Normalize(const char *line)
AliMpExMap fLocalBoardMap
map of local boards (owner of boards)
void SetInputXto(Int_t id)
Set Id to where the X input are copied.
void SetTC(Bool_t connect)
Set transverse connector.
Class that manages the properties of the local board.
static Int_t NofLocalBoards()
Return number of trigger local boards.
Bool_t AddLocalBoard(Int_t localBoardId)
TIterator * CreateLocalBoardIterator() const
static TString LocalTriggerBoardMapping()
Definition: AliMpFiles.cxx:337
ClassImp(TPCGenInfo)
Definition: AliTPCCmpNG.C:254
Int_t GetSize() const
Definition: AliMpExMap.cxx:340
void SetNotified(Bool_t notify)
Set notified flag (not copy card)
TObjArray fLocalBoardArray
array of local boards (not owner of boards, the map is the owner)
void SetInputXfrom(Int_t id)
Set Id from where the X input are copied.
void SetCrate(TString name)
Set crate name.
void SetTriggerCratesOwner(Bool_t owner)
AliMpTriggerCrate * FindTriggerCrate(TString crateName, Bool_t warn=true) const
void SetSwitch(UInt_t swit)
Set switch in a compact way.
TObject * GetValue(Int_t keyFirst, Int_t keySecond) const
Definition: AliMpExMap.cxx:365
void SetInputYfrom(Int_t id)
Set Id from where the Y input are copied.
The class defines the properties of regional trigger crate.
static Int_t LocalBoardNofChannels()
Max number of channels per local board.
void Add(Int_t keyFirst, Int_t keySecond, TObject *object)
Definition: AliMpExMap.cxx:292
void SetOwner(Bool_t owner)
Definition: AliMpExMap.cxx:332
AliMpExMap fTriggerCrates
map for trigger crates
Globally used constants definition.
Int_t LocalBoardId(Int_t index) const
TIterator * CreateCrateIterator() const
AliMpExMapIterator * CreateIterator() const
Definition: AliMpExMap.cxx:357
Mapping data streams provider.
static void DecodeName(const char *manus, char sep, TArrayI &theList)