]>
Commit | Line | Data |
---|---|---|
197883c2 | 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 | ||
5f91c9e8 | 16 | // $Id$ |
13985652 | 17 | // $MpId: AliMpSectorReader.cxx,v 1.9 2006/05/24 13:58:46 ivana Exp $ |
5f91c9e8 | 18 | // Category: sector |
3d1463c8 | 19 | |
20 | //----------------------------------------------------------------------------- | |
197883c2 | 21 | // Class AliMpSectorReader |
22 | // ----------------------- | |
5f91c9e8 | 23 | // Class that takes care of reading the sector data. |
dbe945cc | 24 | // Included in AliRoot: 2003/05/02 |
5f91c9e8 | 25 | // Authors: David Guez, Ivana Hrivnacova; IPN Orsay |
3d1463c8 | 26 | //----------------------------------------------------------------------------- |
5f91c9e8 | 27 | |
197883c2 | 28 | #include "AliMpSectorReader.h" |
5f91c9e8 | 29 | #include "AliMpSector.h" |
30 | #include "AliMpFiles.h" | |
228fd720 | 31 | #include "AliMpDataStreams.h" |
5f91c9e8 | 32 | #include "AliMpZone.h" |
33 | #include "AliMpSubZone.h" | |
34 | #include "AliMpRow.h" | |
35 | #include "AliMpVRowSegment.h" | |
36 | #include "AliMpRowSegment.h" | |
4139354b | 37 | #include "AliMpRowSegmentLSpecial.h" |
38 | #include "AliMpRowSegmentRSpecial.h" | |
5f91c9e8 | 39 | #include "AliMpPadRow.h" |
197883c2 | 40 | #include "AliMpMotifReader.h" |
5f91c9e8 | 41 | #include "AliMpMotifMap.h" |
42 | #include "AliMpMotif.h" | |
43 | #include "AliMpMotifSpecial.h" | |
44 | #include "AliMpMotifType.h" | |
45 | #include "AliMpConnection.h" | |
5f91c9e8 | 46 | #include "AliMpDirection.h" |
f0eac1a3 | 47 | #include "AliMpConstants.h" |
5f91c9e8 | 48 | |
2c605e66 | 49 | #include "AliLog.h" |
50 | ||
f0eac1a3 | 51 | #include <Riostream.h> |
52 | #include <Rstrstream.h> | |
53 | #include <TSystem.h> | |
f0eac1a3 | 54 | #include <TMath.h> |
55 | ||
ca954646 | 56 | #include <limits> |
57 | ||
f0eac1a3 | 58 | #if !defined(__HP_aCC) && !defined(__alpha) |
59 | #include <sstream> | |
60 | #endif | |
f79c58a5 | 61 | |
13985652 | 62 | /// \cond CLASSIMP |
63 | ClassImp(AliMpSectorReader) | |
64 | /// \endcond | |
65 | ||
31edb2d7 | 66 | // |
67 | // static private methods | |
68 | // | |
69 | ||
70 | //_____________________________________________________________________________ | |
71 | const TString& AliMpSectorReader::GetSectorKeyword() | |
72 | { | |
73 | /// sector keyword | |
74 | static const TString kSectorKeyword = "SECTOR_DATA"; | |
75 | return kSectorKeyword; | |
76 | } | |
5f91c9e8 | 77 | |
31edb2d7 | 78 | //_____________________________________________________________________________ |
79 | const TString& AliMpSectorReader::GetZoneKeyword() | |
80 | { | |
81 | /// zone keyword | |
82 | static const TString kZoneKeyword = "ZONE"; | |
83 | return kZoneKeyword; | |
84 | } | |
85 | ||
86 | //_____________________________________________________________________________ | |
87 | const TString& AliMpSectorReader::GetSubZoneKeyword() | |
88 | { | |
89 | /// subzone keyword | |
90 | static const TString kSubZoneKeyword = "SUBZONE"; | |
91 | return kSubZoneKeyword; | |
92 | } | |
93 | ||
94 | //_____________________________________________________________________________ | |
95 | const TString& AliMpSectorReader::GetRowKeyword() | |
96 | { | |
97 | /// row keyword | |
98 | static const TString kRowKeyword = "ROW_SEGMENT"; | |
99 | return kRowKeyword; | |
100 | } | |
101 | ||
102 | //_____________________________________________________________________________ | |
103 | const TString& AliMpSectorReader::GetSectorSpecialKeyword() | |
104 | { | |
105 | /// sector special keyword | |
106 | static const TString kSectorSpecialKeyword = "SECTOR_SPECIAL_DATA"; | |
107 | return kSectorSpecialKeyword; | |
108 | } | |
109 | ||
110 | //_____________________________________________________________________________ | |
111 | const TString& AliMpSectorReader::GetMotifKeyword() | |
112 | { | |
113 | /// motif keyword | |
114 | static const TString kMotifKeyword = "MOTIF"; | |
115 | return kMotifKeyword; | |
116 | } | |
117 | ||
118 | //_____________________________________________________________________________ | |
119 | const TString& AliMpSectorReader::GetRowSpecialKeyword() | |
120 | { | |
121 | /// row special keyword | |
122 | static const TString kRowSpecialKeyword = "ROW"; | |
123 | return kRowSpecialKeyword; | |
124 | } | |
125 | ||
126 | //_____________________________________________________________________________ | |
127 | const TString& AliMpSectorReader::GetPadRowsKeyword() | |
128 | { | |
129 | /// pad rows keyword | |
130 | static const TString kPadRowsKeyword = "PAD_ROWS"; | |
131 | return kPadRowsKeyword; | |
132 | } | |
133 | ||
134 | //_____________________________________________________________________________ | |
135 | const TString& AliMpSectorReader::GetPadRowSegmentKeyword() | |
136 | { | |
137 | /// pad row segment keyword | |
138 | static const TString kPadRowSegmentKeyword = "PAD_ROW_SEGMENT"; | |
139 | return kPadRowSegmentKeyword; | |
140 | } | |
141 | ||
142 | // | |
143 | // ctors, dtor | |
144 | // | |
145 | ||
5f91c9e8 | 146 | //_____________________________________________________________________________ |
21027e5a | 147 | AliMpSectorReader::AliMpSectorReader(AliMq::Station12Type station, |
cddd101e | 148 | AliMp::PlaneType plane) |
5f91c9e8 | 149 | : TObject(), |
4139354b | 150 | fStationType(station), |
5f91c9e8 | 151 | fPlaneType(plane), |
152 | fSector(0), | |
21027e5a | 153 | fMotifReader(new AliMpMotifReader(AliMp::kStation12, station, plane)) |
228fd720 | 154 | |
5f91c9e8 | 155 | { |
f5671fc3 | 156 | /// Standard constructor |
5f91c9e8 | 157 | } |
158 | ||
5f91c9e8 | 159 | //_____________________________________________________________________________ |
197883c2 | 160 | AliMpSectorReader::~AliMpSectorReader() |
161 | { | |
162 | /// Destructor | |
163 | ||
164 | delete fMotifReader; | |
5f91c9e8 | 165 | } |
166 | ||
167 | // | |
168 | // private methods | |
169 | // | |
170 | ||
f79c58a5 | 171 | //_____________________________________________________________________________ |
21027e5a | 172 | void AliMpSectorReader::ReadSectorData(const AliMpDataStreams& dataStreams, |
173 | istream& in) | |
f79c58a5 | 174 | { |
197883c2 | 175 | /// Read sector input data; |
176 | /// prepare zones and rows vectors to be filled in. | |
5f91c9e8 | 177 | |
178 | TString keyword; | |
179 | in >> keyword; | |
180 | ||
da3a1bb2 | 181 | AliDebugStream(2) << keyword << endl; |
5f91c9e8 | 182 | |
31edb2d7 | 183 | if (keyword != GetSectorKeyword()) { |
2ca8e354 | 184 | AliErrorStream() << "Wrong file format." << endl; |
5f91c9e8 | 185 | return; |
186 | } | |
187 | ||
188 | Int_t nofZones, nofRows; | |
189 | TString directionStr; | |
14b7b896 | 190 | Double_t offsetX, offsetY; |
5f91c9e8 | 191 | in >> nofZones; |
192 | in >> nofRows; | |
193 | in >> directionStr; | |
14b7b896 | 194 | in >> offsetX; |
195 | in >> offsetY; | |
5f91c9e8 | 196 | |
cddd101e | 197 | AliMp::Direction direction; |
198 | direction = (directionStr == "Y") ? AliMp::kY : AliMp::kX; | |
2c605e66 | 199 | |
da3a1bb2 | 200 | AliDebugStream(2) << nofZones << " " << nofRows << endl; |
2ca8e354 | 201 | |
ca954646 | 202 | if ( nofZones < 0 || nofZones >= std::numeric_limits<Int_t>::max() || |
203 | nofRows < 0 || nofRows >= std::numeric_limits<Int_t>::max() ) { | |
2ca8e354 | 204 | AliErrorStream() << "Wrong nofZones/nofRows value." << endl; |
205 | return; | |
206 | } | |
5f91c9e8 | 207 | |
14b7b896 | 208 | fSector = new AliMpSector("Not defined", nofZones, nofRows,direction, |
6e97fbb8 | 209 | offsetX, offsetY); |
5f91c9e8 | 210 | |
211 | TString nextKeyword; | |
212 | in >> nextKeyword; | |
213 | ||
31edb2d7 | 214 | if (nextKeyword != GetZoneKeyword()) { |
2ca8e354 | 215 | AliErrorStream() << "Wrong file format." << endl; |
5f91c9e8 | 216 | return; |
217 | } | |
218 | ||
21027e5a | 219 | ReadZoneData(dataStreams, in); |
5f91c9e8 | 220 | } |
221 | ||
222 | //_____________________________________________________________________________ | |
21027e5a | 223 | void AliMpSectorReader::ReadZoneData(const AliMpDataStreams& dataStreams, |
224 | istream& in) | |
5f91c9e8 | 225 | { |
197883c2 | 226 | /// Read zone input data; |
227 | /// create zone and adds it to zones vector. | |
5f91c9e8 | 228 | |
229 | Int_t zoneID; | |
230 | Double_t sizex, sizey; | |
231 | in >> zoneID; | |
232 | in >> sizex; | |
233 | in >> sizey; | |
da3a1bb2 | 234 | AliDebugStream(2) |
31edb2d7 | 235 | << GetZoneKeyword() << " " << zoneID << " " |
2c605e66 | 236 | << sizex << " " << sizey << endl; |
5f91c9e8 | 237 | |
238 | AliMpZone* zone = fSector->GetZone(zoneID); | |
6e97fbb8 | 239 | zone->SetPadDimensions(sizex/2.,sizey/2.); |
5f91c9e8 | 240 | |
241 | TString nextKeyword; | |
242 | in >> nextKeyword; | |
243 | ||
31edb2d7 | 244 | if (nextKeyword != GetSubZoneKeyword()) { |
2ca8e354 | 245 | AliErrorStream() << "Wrong file format." << endl; |
5f91c9e8 | 246 | return; |
247 | } | |
248 | ||
21027e5a | 249 | ReadSubZoneData(dataStreams, in, zone); |
5f91c9e8 | 250 | } |
251 | ||
252 | //_____________________________________________________________________________ | |
21027e5a | 253 | void AliMpSectorReader::ReadSubZoneData(const AliMpDataStreams& dataStreams, |
254 | istream& in, AliMpZone* zone) | |
5f91c9e8 | 255 | { |
197883c2 | 256 | /// Read subzone input data; |
257 | /// create subzone and its to the specified zone. | |
5f91c9e8 | 258 | |
31edb2d7 | 259 | AliDebugStream(2) << GetSubZoneKeyword() << endl; |
5f91c9e8 | 260 | |
21027e5a | 261 | AliMpVMotif* motif = ReadMotifData(dataStreams, in, zone); |
5f91c9e8 | 262 | AliMpSubZone* subZone = new AliMpSubZone(motif); |
263 | zone->AddSubZone(subZone); | |
264 | ||
265 | TString nextKeyword; | |
266 | in >> nextKeyword; | |
267 | ||
31edb2d7 | 268 | if (nextKeyword != GetRowKeyword()) { |
2ca8e354 | 269 | AliErrorStream() << "Wrong file format." << endl; |
5f91c9e8 | 270 | return; |
271 | } | |
272 | ||
21027e5a | 273 | ReadRowSegmentsData(dataStreams, in, zone, subZone); |
5f91c9e8 | 274 | } |
275 | ||
276 | //_____________________________________________________________________________ | |
21027e5a | 277 | AliMpVMotif* AliMpSectorReader::ReadMotifData( |
278 | const AliMpDataStreams& dataStreams, | |
279 | istream& in, AliMpZone* zone) | |
5f91c9e8 | 280 | { |
197883c2 | 281 | /// Read the motif input data. |
5f91c9e8 | 282 | |
283 | TString motifID; | |
284 | TString motifTypeID; | |
285 | in >> motifID; | |
286 | in >> motifTypeID; | |
2c605e66 | 287 | |
da3a1bb2 | 288 | AliDebugStream(2) << motifID << " " << motifTypeID << endl; |
5f91c9e8 | 289 | |
290 | AliMpMotifMap* motifMap = fSector->GetMotifMap(); | |
291 | ||
292 | AliMpMotifType* motifType = 0; | |
293 | AliMpVMotif* motif | |
6e97fbb8 | 294 | = motifMap->FindMotif(motifID, motifTypeID, |
295 | zone->GetPadDimensionX(), zone->GetPadDimensionY()); | |
5f91c9e8 | 296 | if (!motif) { |
297 | motifType = motifMap->FindMotifType(motifTypeID); | |
298 | if (!motifType) { | |
21027e5a | 299 | motifType = fMotifReader->BuildMotifType(dataStreams, motifTypeID); |
5f91c9e8 | 300 | motifMap->AddMotifType(motifType); |
301 | } | |
302 | ||
6e97fbb8 | 303 | if (zone->GetPadDimensionX() != 0. && zone->GetPadDimensionY() != 0.) |
304 | motif = new AliMpMotif(motifID, motifType, | |
305 | zone->GetPadDimensionX(), zone->GetPadDimensionY()); | |
5f91c9e8 | 306 | else |
21027e5a | 307 | motif = fMotifReader->BuildMotifSpecial(dataStreams, motifID, motifType); |
5f91c9e8 | 308 | |
309 | if (motif) | |
310 | motifMap->AddMotif(motif); | |
311 | ||
312 | } | |
313 | ||
314 | return motif; | |
315 | } | |
316 | ||
317 | //_____________________________________________________________________________ | |
21027e5a | 318 | void AliMpSectorReader::ReadRowSegmentsData(const AliMpDataStreams& dataStreams, |
319 | istream& in, | |
5f91c9e8 | 320 | AliMpZone* zone, AliMpSubZone* subZone) |
321 | { | |
197883c2 | 322 | /// Read row segments input data of a specified zone and subzone; |
323 | /// creates row segment and add it to the specified subzone | |
324 | /// and a corresponding row in the rows vector. | |
5f91c9e8 | 325 | |
326 | TString nextKeyword; | |
327 | do { | |
328 | // | |
329 | // Read data from file | |
330 | // | |
331 | Int_t offX, offY, inRow, nofMotifs, firstMotifPositionId, firstMotifPositionDId; | |
332 | in >> offX; | |
333 | in >> offY; | |
334 | in >> inRow; | |
335 | in >> nofMotifs; | |
336 | in >> firstMotifPositionId; | |
337 | in >> firstMotifPositionDId; | |
f0eac1a3 | 338 | |
339 | firstMotifPositionId |= AliMpConstants::ManuMask(fPlaneType); | |
340 | ||
da3a1bb2 | 341 | AliDebugStream(2) |
31edb2d7 | 342 | << GetRowKeyword() << " " |
2c605e66 | 343 | << offX << " " << offY << " " << inRow << " " << nofMotifs << " " |
344 | << firstMotifPositionId << " " << firstMotifPositionDId | |
345 | << endl; | |
5f91c9e8 | 346 | |
347 | in >> nextKeyword; | |
348 | ||
349 | // | |
350 | // Process data | |
351 | // | |
352 | AliMpRow* row = fSector->GetRow(inRow); | |
353 | AliMpVMotif* motif = subZone->GetMotif(); | |
354 | ||
355 | // Create row segment and add it to its zone, row | |
356 | AliMpVRowSegment* rowSegment | |
168e9c4d | 357 | = new AliMpRowSegment(row, motif, offX, offY, nofMotifs, |
5f91c9e8 | 358 | firstMotifPositionId, firstMotifPositionDId); |
359 | ||
360 | subZone->AddRowSegment(rowSegment); | |
361 | row->AddRowSegment(rowSegment); | |
362 | } | |
31edb2d7 | 363 | while (!in.eof() && (nextKeyword == GetRowKeyword())); |
5f91c9e8 | 364 | |
365 | if (in.eof()) return; | |
366 | ||
31edb2d7 | 367 | if (nextKeyword == GetZoneKeyword()) { |
21027e5a | 368 | ReadZoneData(dataStreams, in); |
5f91c9e8 | 369 | } |
31edb2d7 | 370 | else if (nextKeyword == GetSubZoneKeyword()) { |
21027e5a | 371 | ReadSubZoneData(dataStreams, in, zone); |
5f91c9e8 | 372 | } |
373 | else { | |
2ca8e354 | 374 | AliErrorStream() << "Wrong file format." << endl; |
5f91c9e8 | 375 | } |
376 | } | |
377 | ||
378 | //_____________________________________________________________________________ | |
21027e5a | 379 | void AliMpSectorReader::ReadSectorSpecialData( |
380 | const AliMpDataStreams& dataStreams, | |
381 | istream& in, AliMp::XDirection direction) | |
5f91c9e8 | 382 | { |
197883c2 | 383 | /// Read sector input data |
384 | /// with a special (irregular) motifs. | |
5f91c9e8 | 385 | |
386 | TString keyword; | |
387 | in >> keyword; | |
2c605e66 | 388 | |
da3a1bb2 | 389 | AliDebugStream(2) << keyword << endl; |
5f91c9e8 | 390 | |
31edb2d7 | 391 | if (keyword != GetSectorSpecialKeyword()) { |
2ca8e354 | 392 | AliErrorStream() << "Wrong file format." << endl; |
5f91c9e8 | 393 | return; |
394 | } | |
395 | ||
396 | TString nextKeyword; | |
397 | in >> nextKeyword; | |
2c605e66 | 398 | |
da3a1bb2 | 399 | AliDebugStream(2) << keyword << endl; |
5f91c9e8 | 400 | |
31edb2d7 | 401 | if (nextKeyword != GetMotifKeyword()) { |
2ca8e354 | 402 | AliErrorStream() << "Wrong file format." << endl; |
5f91c9e8 | 403 | return; |
404 | } | |
405 | ||
21027e5a | 406 | ReadMotifsSpecialData(dataStreams, in); |
407 | ReadRowSpecialData(dataStreams, in, direction); | |
5f91c9e8 | 408 | } |
409 | ||
410 | //_____________________________________________________________________________ | |
21027e5a | 411 | void AliMpSectorReader::ReadMotifsSpecialData( |
412 | const AliMpDataStreams& dataStreams, | |
413 | istream& in) | |
5f91c9e8 | 414 | { |
197883c2 | 415 | /// Read the special (irregular) motifs input data. |
5f91c9e8 | 416 | |
31edb2d7 | 417 | AliDebugStream(2) << GetMotifKeyword() << endl; |
5f91c9e8 | 418 | |
419 | TString nextKeyword; | |
420 | do { | |
4139354b | 421 | Int_t zone; |
422 | in >> zone; | |
21027e5a | 423 | AliMpVMotif* motif = ReadMotifData(dataStreams, in, fSector->GetZone(zone)); |
5f91c9e8 | 424 | AliMpSubZone* subZone = new AliMpSubZone(motif); |
4139354b | 425 | fSector->GetZone(zone)->AddSubZone(subZone); |
5f91c9e8 | 426 | |
427 | in >> nextKeyword; | |
2c605e66 | 428 | |
da3a1bb2 | 429 | AliDebugStream(2) << nextKeyword << endl; |
5f91c9e8 | 430 | } |
31edb2d7 | 431 | while (nextKeyword == GetMotifKeyword()); |
5f91c9e8 | 432 | |
31edb2d7 | 433 | if (nextKeyword != GetRowSpecialKeyword()) { |
2ca8e354 | 434 | AliErrorStream() << "Wrong file format." << endl; |
5f91c9e8 | 435 | return; |
436 | } | |
437 | } | |
438 | ||
439 | //_____________________________________________________________________________ | |
21027e5a | 440 | void AliMpSectorReader::ReadRowSpecialData( |
441 | const AliMpDataStreams& dataStreams, | |
442 | istream& in, AliMp::XDirection direction) | |
5f91c9e8 | 443 | { |
197883c2 | 444 | /// Read row input data |
445 | /// with a special (irregular) motifs. | |
5f91c9e8 | 446 | |
447 | Int_t id; | |
448 | in >> id; | |
2c605e66 | 449 | |
da3a1bb2 | 450 | AliDebugStream(2) << id << endl; |
5f91c9e8 | 451 | |
452 | // Get the row and its border | |
453 | AliMpRow* row = fSector->GetRow(id); | |
4139354b | 454 | |
455 | AliMpVRowSegmentSpecial* segment = 0; | |
cddd101e | 456 | if (direction == AliMp::kLeft) { |
4139354b | 457 | AliMpVRowSegment* firstNormalSeg = row->GetRowSegment(0); |
458 | Double_t offsetX = firstNormalSeg->LeftBorderX(); | |
5f91c9e8 | 459 | |
4139354b | 460 | // Create a special row segment |
461 | segment = new AliMpRowSegmentLSpecial(row, offsetX); | |
462 | row->AddRowSegmentInFront(segment); | |
463 | } | |
464 | else { | |
465 | AliMpVRowSegment* precedentNormalSeg | |
466 | = row->GetRowSegment(row->GetNofRowSegments()-1); | |
467 | Double_t offsetX = precedentNormalSeg->RightBorderX(); | |
5f91c9e8 | 468 | |
4139354b | 469 | // Create a special row segment |
470 | segment = new AliMpRowSegmentRSpecial(row, offsetX); | |
471 | row->AddRowSegment(segment); | |
472 | } | |
473 | ||
5f91c9e8 | 474 | TString nextKeyword; |
475 | in >> nextKeyword; | |
2c605e66 | 476 | |
da3a1bb2 | 477 | AliDebugStream(2) << nextKeyword << endl; |
5f91c9e8 | 478 | |
31edb2d7 | 479 | if (nextKeyword != GetPadRowsKeyword()) { |
2ca8e354 | 480 | AliErrorStream() << "Wrong file format." << endl; |
5f91c9e8 | 481 | return; |
482 | } | |
483 | ||
21027e5a | 484 | ReadRowSegmentSpecialData(dataStreams, in, segment, direction); |
5f91c9e8 | 485 | |
486 | // Update row segment and set it to all subzones associated with | |
487 | // contained motifs | |
488 | ||
489 | segment->UpdateMotifVector(); | |
490 | segment->UpdatePadsOffset(); | |
491 | ||
4139354b | 492 | for (Int_t i=0; i<segment->GetNofMotifs(); i++) { |
493 | AliMpSubZone* subZone = 0; | |
494 | Int_t j = 0; | |
495 | while (!subZone && j<fSector->GetNofZones()) | |
496 | subZone = fSector->GetZone(++j)->FindSubZone(segment->GetMotif(i)); | |
497 | ||
17b4ec8d | 498 | if (subZone) subZone->AddRowSegment(segment); |
4139354b | 499 | } |
5f91c9e8 | 500 | } |
501 | ||
502 | //_____________________________________________________________________________ | |
21027e5a | 503 | void AliMpSectorReader::ReadRowSegmentSpecialData( |
504 | const AliMpDataStreams& dataStreams, | |
505 | istream& in, | |
506 | AliMpVRowSegmentSpecial* segment, | |
507 | AliMp::XDirection direction) | |
5f91c9e8 | 508 | { |
197883c2 | 509 | /// Read row segment input data |
510 | /// with a special (irregular) motifs. | |
5f91c9e8 | 511 | |
512 | Int_t nofPadRows; | |
513 | in >> nofPadRows; | |
2c605e66 | 514 | |
da3a1bb2 | 515 | AliDebugStream(2) << nofPadRows << endl; |
5f91c9e8 | 516 | |
d76df0d8 | 517 | if ( nofPadRows < 0 || nofPadRows >= std::numeric_limits<Int_t>::max()) { |
2ca8e354 | 518 | AliErrorStream() << "Wrong nofPadRows value." << endl; |
519 | return; | |
520 | } | |
521 | ||
5f91c9e8 | 522 | TString keyword; |
523 | in >> keyword; | |
2c605e66 | 524 | |
da3a1bb2 | 525 | AliDebugStream(2) << keyword << endl; |
5f91c9e8 | 526 | |
31edb2d7 | 527 | if (keyword != GetPadRowSegmentKeyword()) { |
2ca8e354 | 528 | AliErrorStream() << "Wrong file format." << endl; |
5f91c9e8 | 529 | return; |
530 | } | |
531 | ||
532 | // | |
533 | // Process data | |
534 | // | |
535 | ||
2294822d | 536 | TObjArray newPadRows; |
5f91c9e8 | 537 | for (Int_t i=0; i<nofPadRows; i++) { |
538 | ||
539 | // Create pad row | |
4139354b | 540 | AliMpPadRow* padRow = new AliMpPadRow(direction); |
5f91c9e8 | 541 | segment->AddPadRow(padRow); |
542 | ||
543 | // Keep the new rows in a temporary vector | |
f79c58a5 | 544 | newPadRows.Add(padRow); |
5f91c9e8 | 545 | } |
546 | ||
547 | TString nextKeyword; | |
548 | do { | |
549 | // | |
550 | // Read data from file | |
551 | // | |
552 | Int_t nofPadsInRow, motifPositionId; | |
553 | TString motifId, motifTypeId; | |
554 | in >> nofPadsInRow; | |
555 | in >> motifId; | |
556 | in >> motifPositionId; | |
557 | ||
f0eac1a3 | 558 | motifPositionId |= AliMpConstants::ManuMask(fPlaneType); |
559 | ||
da3a1bb2 | 560 | AliDebugStream(2) |
2c605e66 | 561 | << nofPadsInRow << " " << motifId << " " << motifPositionId << endl; |
5f91c9e8 | 562 | |
563 | in >> nextKeyword; | |
2c605e66 | 564 | |
da3a1bb2 | 565 | AliDebugStream(2) << nextKeyword << endl; |
5f91c9e8 | 566 | |
567 | // | |
568 | // Process data | |
569 | // | |
570 | ||
571 | for (Int_t i=0; i<nofPadRows; i++) { | |
572 | ||
573 | // Get pad row from the temporary vector | |
f79c58a5 | 574 | AliMpPadRow* padRow = (AliMpPadRow*)newPadRows[i]; |
5f91c9e8 | 575 | |
576 | // Find motif | |
577 | AliMpVMotif* motif = fSector->GetMotifMap()->FindMotif(motifId); | |
578 | ||
579 | if (!motif) { | |
2ca8e354 | 580 | AliErrorStream() << "Unknown motif" << endl; |
5f91c9e8 | 581 | return; |
582 | } | |
583 | ||
584 | // Create pad row segment | |
4139354b | 585 | padRow->AddPadRowSegment(dynamic_cast<AliMpMotif *>(motif), |
586 | motifPositionId, nofPadsInRow); | |
5f91c9e8 | 587 | } |
588 | } | |
31edb2d7 | 589 | while (!in.eof() && (nextKeyword == GetPadRowSegmentKeyword())); |
5f91c9e8 | 590 | |
591 | if (in.eof()) return; | |
592 | ||
31edb2d7 | 593 | if (nextKeyword == GetPadRowsKeyword()) { |
21027e5a | 594 | ReadRowSegmentSpecialData(dataStreams, in, segment, direction); |
5f91c9e8 | 595 | } |
31edb2d7 | 596 | else if (nextKeyword == GetRowSpecialKeyword()) { |
21027e5a | 597 | ReadRowSpecialData(dataStreams, in, direction); |
5f91c9e8 | 598 | } |
599 | else { | |
2ca8e354 | 600 | AliErrorStream() << "Wrong file format." << endl; |
5f91c9e8 | 601 | } |
602 | } | |
603 | ||
604 | // | |
605 | // public methods | |
606 | // | |
607 | ||
608 | //_____________________________________________________________________________ | |
21027e5a | 609 | AliMpSector* AliMpSectorReader::BuildSector(const AliMpDataStreams& dataStreams) |
5f91c9e8 | 610 | { |
228fd720 | 611 | /// Read the mapping data from stream and create the basic objects: \n |
197883c2 | 612 | /// zones, subzones, rows, row segments, motifs. |
5f91c9e8 | 613 | |
228fd720 | 614 | // Open input stream |
615 | // | |
616 | istream& in | |
21027e5a | 617 | = dataStreams. |
ab167304 | 618 | CreateDataStream(AliMpFiles::SectorFilePath(fStationType,fPlaneType)); |
228fd720 | 619 | |
21027e5a | 620 | ReadSectorData(dataStreams, in); |
228fd720 | 621 | delete ∈ |
622 | ||
5f91c9e8 | 623 | fSector->SetRowSegmentOffsets(); |
624 | ||
228fd720 | 625 | // Open input stream for special inner zone |
626 | ||
627 | // add is data function | |
628 | ||
5f91c9e8 | 629 | TString sectorSpecialFileName |
3d16af90 | 630 | = AliMpFiles::SectorSpecialFilePath(fStationType, fPlaneType); |
21027e5a | 631 | if ( dataStreams.IsDataStream(sectorSpecialFileName) ) { |
228fd720 | 632 | istream& in2 |
21027e5a | 633 | = dataStreams. |
ab167304 | 634 | CreateDataStream(sectorSpecialFileName); |
228fd720 | 635 | |
21027e5a | 636 | ReadSectorSpecialData(dataStreams, in2, AliMp::kLeft); |
228fd720 | 637 | |
638 | delete &in2; | |
639 | } | |
4139354b | 640 | |
641 | // Open input file for special outer zone | |
642 | TString sectorSpecialFileName2 | |
3d16af90 | 643 | = AliMpFiles::SectorSpecialFilePath2(fStationType, fPlaneType); |
21027e5a | 644 | if ( dataStreams.IsDataStream(sectorSpecialFileName2) ) { |
228fd720 | 645 | istream& in3 |
21027e5a | 646 | = dataStreams. |
ab167304 | 647 | CreateDataStream(sectorSpecialFileName2); |
4139354b | 648 | |
21027e5a | 649 | ReadSectorSpecialData(dataStreams, in3, AliMp::kRight); |
228fd720 | 650 | |
651 | delete &in3; | |
5f91c9e8 | 652 | } |
653 | ||
654 | fSector->Initialize(); | |
655 | ||
656 | return fSector; | |
657 | } | |
658 |