]>
Commit | Line | Data |
---|---|---|
30dd09e2 | 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 | ||
18 | #include "AliMUONTriggerCrateStore.h" | |
19 | ||
20 | #include "AliMUONTriggerCrate.h" | |
21 | #include "AliMUONLocalTriggerBoard.h" | |
22 | #include "AliMUONRegionalTriggerBoard.h" | |
92c23b09 | 23 | #include "AliMUONRegionalTriggerConfig.h" |
24 | #include "AliMUONGlobalCrateConfig.h" | |
25 | #include "AliMUONTriggerCrateConfig.h" | |
26 | #include "AliMUONCalibrationData.h" | |
27 | #include "AliMUONTriggerLut.h" | |
ac809573 | 28 | |
29 | #include "AliMpTriggerCrate.h" | |
30 | #include "AliMpLocalBoard.h" | |
31 | #include "AliMpDDLStore.h" | |
30dd09e2 | 32 | #include "AliMpExMap.h" |
30dd09e2 | 33 | #include "AliLog.h" |
ac809573 | 34 | |
35 | #include <TString.h> | |
36 | #include <TSystem.h> | |
37 | #include <Riostream.h> | |
30dd09e2 | 38 | |
3d1463c8 | 39 | |
40 | //----------------------------------------------------------------------------- | |
30dd09e2 | 41 | /// \class AliMUONTriggerCrateStore |
42 | /// | |
43 | /// A container of trigger crate objects that offers iteration | |
44 | /// over both the crates themselves and the local boards they contain | |
45 | /// | |
46 | /// \author Laurent Aphecetche | |
3d1463c8 | 47 | //----------------------------------------------------------------------------- |
30dd09e2 | 48 | |
5398f946 | 49 | /// \cond CLASSIMP |
30dd09e2 | 50 | ClassImp(AliMUONTriggerCrateStore) |
5398f946 | 51 | /// \endcond |
30dd09e2 | 52 | |
53 | //_____________________________________________________________________________ | |
54 | AliMUONTriggerCrateStore::AliMUONTriggerCrateStore() | |
55 | : TObject(), | |
56 | fCrates(0x0), | |
57 | fLocalBoards(0x0), | |
58 | fCrateIterator(0x0), | |
59 | fLBIterator(0x0), | |
60 | fCurrentCrate(0x0), | |
61 | fCurrentLocalBoard(-1) | |
62 | { | |
5398f946 | 63 | /// Default constructor |
30dd09e2 | 64 | } |
65 | ||
66 | //_____________________________________________________________________________ | |
67 | AliMUONTriggerCrateStore::~AliMUONTriggerCrateStore() | |
68 | { | |
5398f946 | 69 | /// Destructor |
30dd09e2 | 70 | delete fCrateIterator; |
71 | delete fLBIterator; | |
72 | delete fCrates; | |
73 | delete fLocalBoards; | |
74 | } | |
75 | ||
76 | //_____________________________________________________________________________ | |
77 | void | |
78 | AliMUONTriggerCrateStore::AddCrate(const char *name) | |
79 | { | |
80 | /// create and add a crate to our map | |
81 | if (!fCrates) | |
82 | { | |
83 | AliError("Object not properly initialized"); | |
84 | return; | |
85 | } | |
86 | ||
87 | AliDebug(1,Form("Adding crate %s",name)); | |
88 | TObject* there = fCrates->GetValue(name); | |
89 | if (there) | |
90 | { | |
91 | AliError(Form("Cannot add crate %s because it's already there !",name)); | |
92 | } | |
93 | else | |
94 | { | |
95 | fCrates->Add(name,new AliMUONTriggerCrate(name,17)); | |
96 | } | |
97 | } | |
98 | ||
99 | //_____________________________________________________________________________ | |
100 | AliMUONLocalTriggerBoard* | |
101 | AliMUONTriggerCrateStore::LocalBoard(Int_t boardNumber) const | |
102 | { | |
103 | /// return a board by number | |
104 | ||
105 | if ( !fLocalBoards ) | |
106 | { | |
107 | AliError("Object not properly initialized"); | |
108 | return 0x0; | |
109 | } | |
110 | ||
111 | return static_cast<AliMUONLocalTriggerBoard*>(fLocalBoards->GetValue(boardNumber)); | |
112 | } | |
113 | ||
114 | //_____________________________________________________________________________ | |
115 | AliMUONTriggerCrate* | |
116 | AliMUONTriggerCrateStore::Crate(const char *name) const | |
117 | { | |
118 | /// return a crate by name | |
119 | if ( !fCrates ) | |
120 | { | |
121 | AliError("Object not properly initialized"); | |
122 | return 0x0; | |
123 | } | |
124 | return static_cast<AliMUONTriggerCrate*>(fCrates->GetValue(name)); | |
125 | } | |
126 | ||
ac809573 | 127 | // to be removed once AliMUONDigitMaker is linked with new mapping |
aa6ecf89 | 128 | //_____________________________________________________________________________ |
129 | AliMUONTriggerCrate* | |
130 | AliMUONTriggerCrateStore::Crate(Int_t ddl, Int_t reg) const | |
131 | { | |
132 | /// return a crate by name | |
133 | if ( !fCrates ) | |
134 | { | |
135 | AliError("Object not properly initialized"); | |
136 | return 0x0; | |
137 | } | |
138 | TString name = GetCrateName(ddl, reg); | |
139 | return static_cast<AliMUONTriggerCrate*>(fCrates->GetValue(name.Data())); | |
140 | } | |
ac809573 | 141 | //____________________________________________________________________ |
aa6ecf89 | 142 | TString AliMUONTriggerCrateStore::GetCrateName(Int_t ddl, Int_t reg) const |
143 | { | |
71a2d3aa | 144 | /// set crate name from DDL & reg number |
aa6ecf89 | 145 | |
146 | Char_t name[10]; | |
147 | switch(reg) { | |
148 | case 0: | |
149 | case 1: | |
150 | sprintf(name,"%d", reg+1); | |
151 | break; | |
152 | case 2: | |
153 | strcpy(name, "2-3"); | |
154 | break; | |
155 | case 3: | |
156 | case 4: | |
157 | case 5: | |
158 | case 6: | |
159 | case 7: | |
160 | sprintf(name,"%d", reg); | |
161 | break; | |
162 | } | |
163 | ||
164 | // crate Right for first DDL | |
165 | if (ddl == 0) | |
166 | strcat(name, "R"); | |
167 | else | |
168 | strcat(name, "L"); | |
169 | ||
170 | return TString(name); | |
171 | } | |
30dd09e2 | 172 | //_____________________________________________________________________________ |
173 | void | |
174 | AliMUONTriggerCrateStore::FirstCrate() | |
175 | { | |
176 | /// initialize iteration | |
177 | if ( !fCrates ) | |
178 | { | |
179 | AliError("Object not properly initialized"); | |
180 | return; | |
181 | } | |
182 | if (!fCrateIterator) | |
183 | { | |
184 | fCrateIterator = new TExMapIter(fCrates->GetIterator()); | |
185 | } | |
186 | fCrateIterator->Reset(); | |
187 | } | |
188 | ||
189 | //_____________________________________________________________________________ | |
190 | void | |
191 | AliMUONTriggerCrateStore::FirstLocalBoard() | |
192 | { | |
193 | /// Initialize iterator on local boards. | |
194 | /// Please note that we're not using directly the FirstCrate() and | |
195 | /// NextCrate() methods here to avoid mix and match between crate iterator | |
196 | /// and local board iterator | |
197 | fCurrentCrate = 0x0; | |
198 | fCurrentLocalBoard = 0; | |
199 | ||
200 | if ( !fLBIterator ) | |
201 | { | |
202 | fLBIterator = new TExMapIter(fCrates->GetIterator()); | |
203 | } | |
204 | fLBIterator->Reset(); | |
205 | Long_t key, value; | |
206 | Bool_t ok = fLBIterator->Next(key,value); | |
207 | if ( ok ) | |
208 | { | |
209 | fCurrentCrate = reinterpret_cast<AliMUONTriggerCrate*>(value); | |
210 | fCurrentLocalBoard = 1; | |
211 | } | |
212 | } | |
213 | ||
214 | //_____________________________________________________________________________ | |
215 | AliMUONTriggerCrate* | |
216 | AliMUONTriggerCrateStore::NextCrate() | |
217 | { | |
218 | /// Return the next crate in iteration, or 0 if iteration is ended. | |
219 | if (!fCrateIterator) return 0x0; | |
220 | ||
221 | Long_t key, value; | |
222 | Bool_t ok = fCrateIterator->Next(key,value); | |
223 | if (ok) | |
224 | { | |
225 | return reinterpret_cast<AliMUONTriggerCrate*>(value); | |
226 | } | |
227 | else | |
228 | { | |
229 | return 0x0; | |
230 | } | |
231 | } | |
232 | ||
233 | //_____________________________________________________________________________ | |
234 | AliMUONLocalTriggerBoard* | |
235 | AliMUONTriggerCrateStore::NextLocalBoard() | |
236 | { | |
237 | /// Return the next local board in iteration, or 0 if iteration is ended. | |
238 | if ( !fLBIterator ) return 0x0; | |
239 | ||
240 | if ( fCurrentLocalBoard >= fCurrentCrate->Boards()->GetLast() +1) | |
241 | // if ( fCurrentLocalBoard >= fCurrentCrate->Boards()->GetLast() ) | |
242 | { | |
243 | // try to go to next crate, if some are left | |
244 | Long_t key, value; | |
245 | Bool_t ok = fLBIterator->Next(key,value); | |
246 | if ( ok ) | |
247 | { | |
248 | fCurrentCrate = reinterpret_cast<AliMUONTriggerCrate*>(value); | |
249 | fCurrentLocalBoard = 1; | |
250 | } | |
251 | else | |
252 | { | |
253 | fCurrentLocalBoard = 0; | |
254 | return 0x0; | |
255 | } | |
256 | } | |
257 | ||
258 | AliMUONLocalTriggerBoard* lb = static_cast<AliMUONLocalTriggerBoard*> | |
259 | (fCurrentCrate->Boards()->At(fCurrentLocalBoard)); | |
260 | ||
261 | ++fCurrentLocalBoard; | |
262 | ||
263 | return lb; | |
264 | } | |
265 | ||
266 | //_____________________________________________________________________________ | |
267 | Int_t | |
268 | AliMUONTriggerCrateStore::NumberOfCrates() const | |
269 | { | |
270 | /// Number of crates we're holding | |
271 | if ( fCrates ) return fCrates->GetSize(); | |
272 | return 0; | |
273 | } | |
274 | ||
275 | //_____________________________________________________________________________ | |
276 | Int_t | |
277 | AliMUONTriggerCrateStore::NumberOfLocalBoards() const | |
278 | { | |
279 | /// Number of local boards we're holding | |
280 | if ( fLocalBoards ) return fLocalBoards->GetSize(); | |
281 | return 0; | |
282 | } | |
283 | ||
284 | //_____________________________________________________________________________ | |
285 | void | |
92c23b09 | 286 | AliMUONTriggerCrateStore::ReadFromFile(AliMUONCalibrationData* calibData) |
30dd09e2 | 287 | { |
92c23b09 | 288 | /// create crate and local board objects from mapping & calib (Ch.F) |
5a92f8e6 | 289 | fCrates = new AliMpExMap(kTRUE); |
6e241007 | 290 | fCrates->SetOwner(kTRUE); |
291 | fLocalBoards = new AliMpExMap(kTRUE); | |
292 | fLocalBoards->SetOwner(kFALSE); | |
30dd09e2 | 293 | |
92c23b09 | 294 | |
295 | AliMUONTriggerLut* lut = calibData->TriggerLut(); | |
ac809573 | 296 | |
92c23b09 | 297 | if (!lut) |
298 | AliWarning("No valid trigger LUT in CDB"); | |
299 | ||
300 | AliMUONRegionalTriggerConfig* regionalConfig = calibData->RegionalTriggerConfig(); | |
301 | if (!regionalConfig) | |
302 | AliWarning("No valid regional trigger configuration in CDB"); | |
303 | ||
304 | TExMapIter itr = AliMpDDLStore::Instance()->GetTriggerCrateItr(); | |
305 | ||
ac809573 | 306 | Long_t key, value; |
92c23b09 | 307 | |
ac809573 | 308 | while(itr.Next(key, value)) |
5a92f8e6 | 309 | { |
ac809573 | 310 | AliMpTriggerCrate* crateMapping = reinterpret_cast<AliMpTriggerCrate*>(value); |
92c23b09 | 311 | |
ac809573 | 312 | TString crateName = crateMapping->GetName(); |
313 | AliMUONTriggerCrate *crate = Crate(crateName.Data()); | |
92c23b09 | 314 | |
315 | AliMUONTriggerCrateConfig* crateConfig = regionalConfig->FindTriggerCrate(crateName); | |
ac809573 | 316 | |
317 | if (!crate) | |
30dd09e2 | 318 | { |
ac809573 | 319 | AddCrate(crateName.Data()); |
320 | crate = Crate(crateName.Data()); | |
321 | AliDebug(3, Form("crate name %s\n", crateName.Data())); | |
322 | AliMUONRegionalTriggerBoard *rboard = new AliMUONRegionalTriggerBoard(); | |
323 | crate->AddBoard(rboard, 0); | |
324 | } | |
325 | ||
326 | for(Int_t iLocal = 0; iLocal < crateMapping->GetNofLocalBoards(); ++iLocal) { | |
92c23b09 | 327 | |
ac809573 | 328 | Int_t localBoardId = crateMapping->GetLocalBoardId(iLocal); |
329 | if (!localBoardId) continue; //empty slot, should not happen | |
330 | ||
331 | AliMpLocalBoard* localBoardMapping = AliMpDDLStore::Instance()->GetLocalBoard(localBoardId); | |
332 | AliDebug(3, Form("local name %s id %d\n", localBoardMapping->GetName(), localBoardId)); | |
92c23b09 | 333 | |
ac809573 | 334 | Int_t slot = localBoardMapping->GetSlot(); |
92c23b09 | 335 | AliMUONLocalTriggerBoard *board = new AliMUONLocalTriggerBoard(localBoardMapping); |
336 | board->SetCoinc44(crateConfig->GetCoinc()); | |
337 | board->SetLUT(lut); | |
ac809573 | 338 | |
92c23b09 | 339 | |
ac809573 | 340 | if (localBoardMapping->IsNotified()) { |
341 | fLocalBoards->Add(localBoardId, board); | |
5a92f8e6 | 342 | } |
92c23b09 | 343 | |
ac809573 | 344 | crate->AddBoard(board, slot); |
92c23b09 | 345 | |
ac809573 | 346 | } // iLocal |
347 | } // while | |
30dd09e2 | 348 | } |
92c23b09 | 349 |