]>
Commit | Line | Data |
---|---|---|
cde9ca47 | 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" | |
630711ed | 27 | #include "AliMpExMapIterator.h" |
cde9ca47 | 28 | #include "AliMpTriggerCrate.h" |
29 | #include "AliMpLocalBoard.h" | |
30 | #include "AliMpConstants.h" | |
31 | #include "AliMpFiles.h" | |
228fd720 | 32 | #include "AliMpDataStreams.h" |
cde9ca47 | 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 | ||
43 | /// \cond CLASSIMP | |
44 | ClassImp(AliMpRegionalTrigger) | |
45 | /// \endcond | |
46 | ||
47 | ||
48 | //______________________________________________________________________________ | |
49 | AliMpRegionalTrigger::AliMpRegionalTrigger() | |
50 | : TObject(), | |
630711ed | 51 | fTriggerCrates(), |
52 | fLocalBoardMap(), | |
53 | fLocalBoardArray(AliMpConstants::TotalNofLocalBoards()+1) // included non-notified boards | |
cde9ca47 | 54 | { |
630711ed | 55 | /// Standard constructor |
cde9ca47 | 56 | |
57 | fTriggerCrates.SetOwner(true); | |
58 | fTriggerCrates.SetSize(AliMpConstants::LocalBoardNofChannels()); | |
cde9ca47 | 59 | } |
60 | ||
61 | //______________________________________________________________________________ | |
62 | AliMpRegionalTrigger::AliMpRegionalTrigger(const AliMpRegionalTrigger& rhs) | |
63 | : TObject(rhs), | |
64 | fTriggerCrates(rhs.fTriggerCrates), | |
630711ed | 65 | fLocalBoardMap(rhs.fLocalBoardMap), |
66 | fLocalBoardArray(rhs.fLocalBoardArray) | |
cde9ca47 | 67 | { |
68 | /// Copy constructor | |
69 | } | |
70 | ||
71 | //______________________________________________________________________________ | |
630711ed | 72 | AliMpRegionalTrigger::AliMpRegionalTrigger(TRootIOCtor* ioCtor) |
cde9ca47 | 73 | : TObject(), |
630711ed | 74 | fTriggerCrates(ioCtor), |
75 | fLocalBoardMap(ioCtor), | |
76 | fLocalBoardArray() | |
cde9ca47 | 77 | { |
78 | /// Constructor for I0 | |
79 | } | |
80 | ||
81 | //______________________________________________________________________________ | |
82 | AliMpRegionalTrigger& AliMpRegionalTrigger::operator=(const AliMpRegionalTrigger& rhs) | |
83 | { | |
84 | /// Assignment operator | |
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 | |
93 | fTriggerCrates = rhs.fTriggerCrates; | |
630711ed | 94 | fLocalBoardArray = rhs.fLocalBoardArray; |
cde9ca47 | 95 | |
96 | return *this; | |
97 | } | |
98 | ||
99 | //______________________________________________________________________________ | |
100 | AliMpRegionalTrigger::~AliMpRegionalTrigger() | |
101 | { | |
102 | /// Destructor | |
103 | } | |
104 | ||
228fd720 | 105 | |
cde9ca47 | 106 | // |
228fd720 | 107 | // private methods |
cde9ca47 | 108 | // |
109 | ||
110 | //______________________________________________________________________________ | |
228fd720 | 111 | Bool_t AliMpRegionalTrigger::ReadData(istream& in) |
cde9ca47 | 112 | { |
113 | /// Load the Regional trigger from ASCII data files | |
114 | /// and return its instance | |
115 | ||
cde9ca47 | 116 | |
117 | AliMpLocalBoard* board = 0x0; | |
118 | AliMpTriggerCrate* crate = 0x0; | |
119 | ||
120 | ||
121 | Int_t localBoardId = 0; | |
122 | TArrayI list; | |
123 | UShort_t crateId, mask; | |
cde9ca47 | 124 | |
125 | char line[80]; | |
126 | ||
127 | while (!in.eof()) | |
128 | { | |
129 | in.getline(line,80); | |
130 | if (!strlen(line)) break; | |
131 | TString crateName(AliMpHelper::Normalize(line)); | |
132 | ||
133 | in.getline(line,80); | |
134 | sscanf(line,"%hx",&crateId); | |
135 | ||
92c23b09 | 136 | // skip mode |
cde9ca47 | 137 | in.getline(line,80); |
cde9ca47 | 138 | |
92c23b09 | 139 | // skip coincidence |
cde9ca47 | 140 | in.getline(line,80); |
cde9ca47 | 141 | |
92c23b09 | 142 | // skip mask |
cde9ca47 | 143 | in.getline(line,80); |
144 | sscanf(line,"%hx",&mask); | |
145 | ||
146 | crate = (AliMpTriggerCrate*)(fTriggerCrates.GetValue(crateName.Data())); | |
147 | if (!crate) | |
148 | { | |
149 | // cout << "Creating crate: " << crateName.Data() << endl; | |
92c23b09 | 150 | crate = new AliMpTriggerCrate(crateName.Data(), crateId); |
cde9ca47 | 151 | fTriggerCrates.Add(crateName.Data(), crate); |
152 | } | |
153 | ||
154 | Char_t localBoardName[20]; | |
155 | Int_t slot; | |
156 | UInt_t switches; | |
157 | ||
158 | for ( Int_t i = 0; i < AliMpConstants::LocalBoardNofChannels(); ++i ) | |
159 | { | |
160 | if ( (mask >> i ) & 0x1 ) | |
161 | { | |
162 | in.getline(line,80); | |
163 | sscanf(line,"%02d %s %03d %03x",&slot,localBoardName,&localBoardId,&switches); | |
164 | // cout << " Creating local board: " << localBoardId << endl; | |
165 | board = new AliMpLocalBoard(localBoardId, localBoardName, slot); | |
166 | board->SetSwitch(switches); | |
167 | board->SetCrate(crateName); | |
168 | ||
169 | if (localBoardId > AliMpConstants::NofLocalBoards()) | |
170 | board->SetNotified(false); // copy cards | |
171 | ||
172 | crate->AddLocalBoard(localBoardId); | |
173 | ||
174 | // add list of DEs for local board | |
175 | list.Reset(); | |
176 | in.getline(line,80); | |
177 | TString tmp(AliMpHelper::Normalize(line)); | |
178 | AliMpHelper::DecodeName(tmp,' ',list); | |
6b6c7c4f | 179 | for (Int_t ii = 0; ii < list.GetSize(); ++ii) { |
180 | if ( list[ii] ) board->AddDE(list[ii]); | |
cde9ca47 | 181 | } |
182 | ||
183 | // set copy number and transverse connector | |
184 | in.getline(line,80); | |
185 | tmp = AliMpHelper::Normalize(line); | |
186 | AliMpHelper::DecodeName(tmp,' ',list); | |
187 | ||
188 | board->SetInputXfrom(list[0]); | |
189 | board->SetInputXto(list[1]); | |
190 | ||
191 | board->SetInputYfrom(list[2]); | |
192 | board->SetInputYto(list[3]); | |
193 | ||
194 | board->SetTC(list[4]); | |
195 | ||
630711ed | 196 | // add local board into array |
197 | fLocalBoardArray.AddAt(board,board->GetId()); | |
198 | fLocalBoardMap.Add(board->GetId(),board); | |
cde9ca47 | 199 | } |
200 | } | |
201 | } | |
228fd720 | 202 | |
cde9ca47 | 203 | return kTRUE; |
204 | } | |
205 | ||
228fd720 | 206 | // |
207 | // public methods | |
208 | // | |
209 | ||
210 | //______________________________________________________________________________ | |
211 | Bool_t AliMpRegionalTrigger::ReadData(const TString& fileName) | |
212 | { | |
213 | /// Load the Regional trigger from ASCII data files | |
214 | /// and return its instance | |
215 | ||
216 | if ( fileName != "" ) { | |
217 | AliDebugStream(2) << "Read data from file " << fileName.Data() << endl; | |
218 | ||
219 | TString inFileName(fileName); | |
220 | inFileName = gSystem->ExpandPathName(inFileName.Data()); | |
221 | ifstream inFile(inFileName.Data(), ios::in); | |
222 | if ( ! inFile.good() ) { | |
223 | AliErrorStream() | |
224 | << "Local Trigger Board Mapping File " << fileName.Data() << " not found" << endl; | |
225 | return kFALSE; | |
226 | } | |
227 | ||
228 | return ReadData(inFile); | |
229 | } | |
230 | else { | |
231 | AliDebugStream(2) << "Read data from stream " << fileName.Data() << endl; | |
232 | istream& in | |
233 | = AliMpDataStreams::Instance() | |
234 | ->CreateDataStream(AliMpFiles::LocalTriggerBoardMapping()); | |
235 | ||
236 | Bool_t result = ReadData(in); | |
237 | ||
238 | delete ∈ | |
239 | return result; | |
240 | } | |
241 | } | |
242 | ||
cde9ca47 | 243 | //______________________________________________________________________________ |
244 | AliMpLocalBoard* AliMpRegionalTrigger::FindLocalBoard(Int_t localBoardId, | |
245 | Bool_t warn) const { | |
630711ed | 246 | /// Return local board with given Id |
cde9ca47 | 247 | |
248 | AliMpLocalBoard* localBoard | |
630711ed | 249 | = static_cast<AliMpLocalBoard*>(fLocalBoardMap.GetValue(localBoardId)); |
250 | ||
cde9ca47 | 251 | if ( ! localBoard && warn ) { |
252 | AliErrorStream() | |
630711ed | 253 | << "Loacl board with localBoardId = " << localBoardId << " not found." << endl; |
254 | } | |
cde9ca47 | 255 | |
256 | return localBoard; | |
257 | } | |
258 | ||
259 | //______________________________________________________________________________ | |
260 | AliMpTriggerCrate* AliMpRegionalTrigger::FindTriggerCrate(TString name, | |
261 | Bool_t warn) const { | |
262 | /// Return trigger crate with given name | |
263 | ||
264 | AliMpTriggerCrate* crate | |
265 | = (AliMpTriggerCrate*) fTriggerCrates.GetValue(name.Data()); | |
266 | ||
267 | if ( ! crate && warn ) { | |
268 | AliErrorStream() | |
269 | << "Trigger crate with name = " << name.Data() << " not defined." << endl; | |
270 | } | |
271 | ||
272 | return crate; | |
273 | } | |
274 | ||
275 | //______________________________________________________________________________ | |
276 | Int_t AliMpRegionalTrigger::GetNofTriggerCrates() const | |
277 | { | |
278 | /// Return number of trigger crates | |
279 | ||
280 | return fTriggerCrates.GetSize(); | |
281 | } | |
282 | ||
283 | //______________________________________________________________________________ | |
630711ed | 284 | Int_t AliMpRegionalTrigger::GetNofLocalBoards() const |
cde9ca47 | 285 | { |
630711ed | 286 | /// Return number of local boards |
287 | ||
288 | return fLocalBoardArray.GetSize(); | |
cde9ca47 | 289 | } |
290 | ||
291 | //______________________________________________________________________________ | |
630711ed | 292 | TIterator* |
293 | AliMpRegionalTrigger::CreateCrateIterator() const | |
294 | { | |
295 | /// Create iterator over crates | |
cde9ca47 | 296 | |
630711ed | 297 | return fTriggerCrates.CreateIterator(); |
cde9ca47 | 298 | } |
299 | ||
300 | //______________________________________________________________________________ | |
630711ed | 301 | TIterator* |
302 | AliMpRegionalTrigger::CreateLocalBoardIterator() const | |
303 | { | |
304 | /// Create iterator over local boards | |
cde9ca47 | 305 | |
630711ed | 306 | return fLocalBoardArray.MakeIterator(); |
cde9ca47 | 307 | } |
308 | ||
309 | //______________________________________________________________________________ | |
630711ed | 310 | Int_t |
311 | AliMpRegionalTrigger::LocalBoardId(Int_t index) const | |
312 | { | |
313 | /// Return local board Id for the local boards with a given index | |
314 | ||
315 | AliMpLocalBoard* lb = static_cast<AliMpLocalBoard*>(fLocalBoardArray.At(index)); | |
316 | if (lb) | |
317 | { | |
318 | return lb->GetId(); | |
319 | } | |
320 | AliError(Form("Could not get local board at index %d",index)); | |
321 | return -1; | |
cde9ca47 | 322 | } |
323 | ||
324 |