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 AliMpRegionalTrigger
21 // --------------------
22 // The class defines the properties of regional trigger crate
23 // Author: Ch. Finck, Subatech Nantes
24 //-----------------------------------------------------------------------------
26 #include "AliMpRegionalTrigger.h"
27 #include "AliMpTriggerCrate.h"
28 #include "AliMpLocalBoard.h"
29 #include "AliMpConstants.h"
30 #include "AliMpFiles.h"
31 #include "AliMpHelper.h"
36 #include <Riostream.h>
42 ClassImp(AliMpRegionalTrigger)
46 //______________________________________________________________________________
47 AliMpRegionalTrigger::AliMpRegionalTrigger()
52 /// Standard constructor
54 fTriggerCrates.SetOwner(true);
55 fTriggerCrates.SetSize(AliMpConstants::LocalBoardNofChannels());
57 fLocalBoards.SetOwner(true);
58 fLocalBoards.SetSize(AliMpConstants::TotalNofLocalBoards()); // included non-notified boards
61 //______________________________________________________________________________
62 AliMpRegionalTrigger::AliMpRegionalTrigger(const AliMpRegionalTrigger& rhs)
64 fTriggerCrates(rhs.fTriggerCrates),
65 fLocalBoards(rhs.fLocalBoards)
70 //______________________________________________________________________________
71 AliMpRegionalTrigger::AliMpRegionalTrigger(TRootIOCtor* /*ioCtor*/)
76 /// Constructor for I0
79 //______________________________________________________________________________
80 AliMpRegionalTrigger& AliMpRegionalTrigger::operator=(const AliMpRegionalTrigger& rhs)
82 /// Assignment operator
84 // check assignment to self
85 if (this == &rhs) return *this;
87 // base class assignment
88 TObject::operator=(rhs);
90 // assignment operator
91 fTriggerCrates = rhs.fTriggerCrates;
92 fLocalBoards = rhs.fLocalBoards;
97 //______________________________________________________________________________
98 AliMpRegionalTrigger::~AliMpRegionalTrigger()
107 //______________________________________________________________________________
108 Bool_t AliMpRegionalTrigger::ReadData(const TString& fileName)
110 /// Load the Regional trigger from ASCII data files
111 /// and return its instance
113 TString inFileName(fileName);
114 if ( inFileName == "" )
115 inFileName = AliMpFiles::LocalTriggerBoardMapping();
117 inFileName = gSystem->ExpandPathName(inFileName.Data());
119 ifstream in(inFileName.Data(), ios::in);
123 << "Local Trigger Board Mapping File " << fileName.Data() << " not found" << endl;
127 AliMpLocalBoard* board = 0x0;
128 AliMpTriggerCrate* crate = 0x0;
131 Int_t localBoardId = 0;
133 UShort_t crateId, mask;
140 if (!strlen(line)) break;
141 TString crateName(AliMpHelper::Normalize(line));
144 sscanf(line,"%hx",&crateId);
154 sscanf(line,"%hx",&mask);
156 crate = (AliMpTriggerCrate*)(fTriggerCrates.GetValue(crateName.Data()));
159 // cout << "Creating crate: " << crateName.Data() << endl;
160 crate = new AliMpTriggerCrate(crateName.Data(), crateId);
161 fTriggerCrates.Add(crateName.Data(), crate);
164 Char_t localBoardName[20];
168 for ( Int_t i = 0; i < AliMpConstants::LocalBoardNofChannels(); ++i )
170 if ( (mask >> i ) & 0x1 )
173 sscanf(line,"%02d %s %03d %03x",&slot,localBoardName,&localBoardId,&switches);
174 // cout << " Creating local board: " << localBoardId << endl;
175 board = new AliMpLocalBoard(localBoardId, localBoardName, slot);
176 board->SetSwitch(switches);
177 board->SetCrate(crateName);
179 if (localBoardId > AliMpConstants::NofLocalBoards())
180 board->SetNotified(false); // copy cards
182 crate->AddLocalBoard(localBoardId);
184 // add list of DEs for local board
187 TString tmp(AliMpHelper::Normalize(line));
188 AliMpHelper::DecodeName(tmp,' ',list);
189 for (Int_t i = 0; i < list.GetSize(); ++i) {
190 if ( list[i] ) board->AddDE(list[i]);
193 // set copy number and transverse connector
195 tmp = AliMpHelper::Normalize(line);
196 AliMpHelper::DecodeName(tmp,' ',list);
198 board->SetInputXfrom(list[0]);
199 board->SetInputXto(list[1]);
201 board->SetInputYfrom(list[2]);
202 board->SetInputYto(list[3]);
204 board->SetTC(list[4]);
206 // add local board into map
207 fLocalBoards.Add(board->GetId(), board);
214 //______________________________________________________________________________
215 AliMpLocalBoard* AliMpRegionalTrigger::FindLocalBoard(Int_t localBoardId,
217 /// Return bus patch with given Id
219 AliMpLocalBoard* localBoard
220 = (AliMpLocalBoard*) fLocalBoards.GetValue(localBoardId);
222 if ( ! localBoard && warn ) {
224 << "Local board with Id = " << localBoardId << " not defined." << endl;
230 //______________________________________________________________________________
231 AliMpTriggerCrate* AliMpRegionalTrigger::FindTriggerCrate(TString name,
233 /// Return trigger crate with given name
235 AliMpTriggerCrate* crate
236 = (AliMpTriggerCrate*) fTriggerCrates.GetValue(name.Data());
238 if ( ! crate && warn ) {
240 << "Trigger crate with name = " << name.Data() << " not defined." << endl;
246 //______________________________________________________________________________
247 Int_t AliMpRegionalTrigger::GetNofTriggerCrates() const
249 /// Return number of trigger crates
251 return fTriggerCrates.GetSize();
254 //______________________________________________________________________________
255 AliMpTriggerCrate* AliMpRegionalTrigger::GetTriggerCrate(Int_t index) const
257 /// Return the trigger crates with given index;
259 return static_cast<AliMpTriggerCrate*>(fTriggerCrates.GetObject(index));
262 //______________________________________________________________________________
263 AliMpTriggerCrate* AliMpRegionalTrigger::GetTriggerCrateFast(Int_t index) const
265 /// Return the trigger crates with given index;
266 /// the index is not checked as we use the fast method in AliMpExMap.
268 return static_cast<AliMpTriggerCrate*>(fTriggerCrates.GetObjectFast(index));
271 //______________________________________________________________________________
272 Int_t AliMpRegionalTrigger::GetNofLocalBoards() const
274 /// Return number of local boards
276 return fLocalBoards.GetSize();
279 //______________________________________________________________________________
280 AliMpLocalBoard* AliMpRegionalTrigger::GetLocalBoard(Int_t index) const
282 /// Return local board with given index;
284 return static_cast<AliMpLocalBoard*>(fLocalBoards.GetObject(index));
287 //______________________________________________________________________________
288 AliMpLocalBoard* AliMpRegionalTrigger::GetLocalBoardFast(Int_t index) const
290 /// Return local board with given index;
291 /// the index is not checked as we use the fast method in AliMpExMap.
293 return static_cast<AliMpLocalBoard*>(fLocalBoards.GetObjectFast(index));