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