]>
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 | //_____________________________________________________________________________ |
ab167304 | 147 | AliMpSectorReader::AliMpSectorReader(const AliMpDataStreams& dataStreams, |
4e51cfd2 | 148 | AliMq::Station12Type station, |
cddd101e | 149 | AliMp::PlaneType plane) |
5f91c9e8 | 150 | : TObject(), |
7d5d0cc5 | 151 | fkDataStreams(dataStreams), |
4139354b | 152 | fStationType(station), |
5f91c9e8 | 153 | fPlaneType(plane), |
154 | fSector(0), | |
4e51cfd2 | 155 | fMotifReader(new AliMpMotifReader(dataStreams, AliMp::kStation12, station, plane)) |
228fd720 | 156 | |
5f91c9e8 | 157 | { |
f5671fc3 | 158 | /// Standard constructor |
5f91c9e8 | 159 | } |
160 | ||
5f91c9e8 | 161 | //_____________________________________________________________________________ |
197883c2 | 162 | AliMpSectorReader::~AliMpSectorReader() |
163 | { | |
164 | /// Destructor | |
165 | ||
166 | delete fMotifReader; | |
5f91c9e8 | 167 | } |
168 | ||
169 | // | |
170 | // private methods | |
171 | // | |
172 | ||
f79c58a5 | 173 | //_____________________________________________________________________________ |
228fd720 | 174 | void AliMpSectorReader::ReadSectorData(istream& in) |
f79c58a5 | 175 | { |
197883c2 | 176 | /// Read sector input data; |
177 | /// prepare zones and rows vectors to be filled in. | |
5f91c9e8 | 178 | |
179 | TString keyword; | |
180 | in >> keyword; | |
181 | ||
da3a1bb2 | 182 | AliDebugStream(2) << keyword << endl; |
5f91c9e8 | 183 | |
31edb2d7 | 184 | if (keyword != GetSectorKeyword()) { |
2ca8e354 | 185 | AliErrorStream() << "Wrong file format." << endl; |
5f91c9e8 | 186 | return; |
187 | } | |
188 | ||
189 | Int_t nofZones, nofRows; | |
190 | TString directionStr; | |
14b7b896 | 191 | Double_t offsetX, offsetY; |
5f91c9e8 | 192 | in >> nofZones; |
193 | in >> nofRows; | |
194 | in >> directionStr; | |
14b7b896 | 195 | in >> offsetX; |
196 | in >> offsetY; | |
5f91c9e8 | 197 | |
cddd101e | 198 | AliMp::Direction direction; |
199 | direction = (directionStr == "Y") ? AliMp::kY : AliMp::kX; | |
2c605e66 | 200 | |
da3a1bb2 | 201 | AliDebugStream(2) << nofZones << " " << nofRows << endl; |
2ca8e354 | 202 | |
ca954646 | 203 | if ( nofZones < 0 || nofZones >= std::numeric_limits<Int_t>::max() || |
204 | nofRows < 0 || nofRows >= std::numeric_limits<Int_t>::max() ) { | |
2ca8e354 | 205 | AliErrorStream() << "Wrong nofZones/nofRows value." << endl; |
206 | return; | |
207 | } | |
5f91c9e8 | 208 | |
14b7b896 | 209 | fSector = new AliMpSector("Not defined", nofZones, nofRows,direction, |
6e97fbb8 | 210 | offsetX, offsetY); |
5f91c9e8 | 211 | |
212 | TString nextKeyword; | |
213 | in >> nextKeyword; | |
214 | ||
31edb2d7 | 215 | if (nextKeyword != GetZoneKeyword()) { |
2ca8e354 | 216 | AliErrorStream() << "Wrong file format." << endl; |
5f91c9e8 | 217 | return; |
218 | } | |
219 | ||
220 | ReadZoneData(in); | |
221 | } | |
222 | ||
223 | //_____________________________________________________________________________ | |
228fd720 | 224 | void AliMpSectorReader::ReadZoneData(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 | ||
249 | ReadSubZoneData(in, zone); | |
250 | } | |
251 | ||
252 | //_____________________________________________________________________________ | |
228fd720 | 253 | void AliMpSectorReader::ReadSubZoneData(istream& in, AliMpZone* zone) |
5f91c9e8 | 254 | { |
197883c2 | 255 | /// Read subzone input data; |
256 | /// create subzone and its to the specified zone. | |
5f91c9e8 | 257 | |
31edb2d7 | 258 | AliDebugStream(2) << GetSubZoneKeyword() << endl; |
5f91c9e8 | 259 | |
260 | AliMpVMotif* motif = ReadMotifData(in, zone); | |
261 | AliMpSubZone* subZone = new AliMpSubZone(motif); | |
262 | zone->AddSubZone(subZone); | |
263 | ||
264 | TString nextKeyword; | |
265 | in >> nextKeyword; | |
266 | ||
31edb2d7 | 267 | if (nextKeyword != GetRowKeyword()) { |
2ca8e354 | 268 | AliErrorStream() << "Wrong file format." << endl; |
5f91c9e8 | 269 | return; |
270 | } | |
271 | ||
272 | ReadRowSegmentsData(in, zone, subZone); | |
273 | } | |
274 | ||
275 | //_____________________________________________________________________________ | |
228fd720 | 276 | AliMpVMotif* AliMpSectorReader::ReadMotifData(istream& in, AliMpZone* zone) |
5f91c9e8 | 277 | { |
197883c2 | 278 | /// Read the motif input data. |
5f91c9e8 | 279 | |
280 | TString motifID; | |
281 | TString motifTypeID; | |
282 | in >> motifID; | |
283 | in >> motifTypeID; | |
2c605e66 | 284 | |
da3a1bb2 | 285 | AliDebugStream(2) << motifID << " " << motifTypeID << endl; |
5f91c9e8 | 286 | |
287 | AliMpMotifMap* motifMap = fSector->GetMotifMap(); | |
288 | ||
289 | AliMpMotifType* motifType = 0; | |
290 | AliMpVMotif* motif | |
6e97fbb8 | 291 | = motifMap->FindMotif(motifID, motifTypeID, |
292 | zone->GetPadDimensionX(), zone->GetPadDimensionY()); | |
5f91c9e8 | 293 | if (!motif) { |
294 | motifType = motifMap->FindMotifType(motifTypeID); | |
295 | if (!motifType) { | |
197883c2 | 296 | motifType = fMotifReader->BuildMotifType(motifTypeID); |
5f91c9e8 | 297 | motifMap->AddMotifType(motifType); |
298 | } | |
299 | ||
6e97fbb8 | 300 | if (zone->GetPadDimensionX() != 0. && zone->GetPadDimensionY() != 0.) |
301 | motif = new AliMpMotif(motifID, motifType, | |
302 | zone->GetPadDimensionX(), zone->GetPadDimensionY()); | |
5f91c9e8 | 303 | else |
197883c2 | 304 | motif = fMotifReader->BuildMotifSpecial(motifID, motifType); |
5f91c9e8 | 305 | |
306 | if (motif) | |
307 | motifMap->AddMotif(motif); | |
308 | ||
309 | } | |
310 | ||
311 | return motif; | |
312 | } | |
313 | ||
314 | //_____________________________________________________________________________ | |
228fd720 | 315 | void AliMpSectorReader::ReadRowSegmentsData(istream& in, |
5f91c9e8 | 316 | AliMpZone* zone, AliMpSubZone* subZone) |
317 | { | |
197883c2 | 318 | /// Read row segments input data of a specified zone and subzone; |
319 | /// creates row segment and add it to the specified subzone | |
320 | /// and a corresponding row in the rows vector. | |
5f91c9e8 | 321 | |
322 | TString nextKeyword; | |
323 | do { | |
324 | // | |
325 | // Read data from file | |
326 | // | |
327 | Int_t offX, offY, inRow, nofMotifs, firstMotifPositionId, firstMotifPositionDId; | |
328 | in >> offX; | |
329 | in >> offY; | |
330 | in >> inRow; | |
331 | in >> nofMotifs; | |
332 | in >> firstMotifPositionId; | |
333 | in >> firstMotifPositionDId; | |
f0eac1a3 | 334 | |
335 | firstMotifPositionId |= AliMpConstants::ManuMask(fPlaneType); | |
336 | ||
da3a1bb2 | 337 | AliDebugStream(2) |
31edb2d7 | 338 | << GetRowKeyword() << " " |
2c605e66 | 339 | << offX << " " << offY << " " << inRow << " " << nofMotifs << " " |
340 | << firstMotifPositionId << " " << firstMotifPositionDId | |
341 | << endl; | |
5f91c9e8 | 342 | |
343 | in >> nextKeyword; | |
344 | ||
345 | // | |
346 | // Process data | |
347 | // | |
348 | AliMpRow* row = fSector->GetRow(inRow); | |
349 | AliMpVMotif* motif = subZone->GetMotif(); | |
350 | ||
351 | // Create row segment and add it to its zone, row | |
352 | AliMpVRowSegment* rowSegment | |
168e9c4d | 353 | = new AliMpRowSegment(row, motif, offX, offY, nofMotifs, |
5f91c9e8 | 354 | firstMotifPositionId, firstMotifPositionDId); |
355 | ||
356 | subZone->AddRowSegment(rowSegment); | |
357 | row->AddRowSegment(rowSegment); | |
358 | } | |
31edb2d7 | 359 | while (!in.eof() && (nextKeyword == GetRowKeyword())); |
5f91c9e8 | 360 | |
361 | if (in.eof()) return; | |
362 | ||
31edb2d7 | 363 | if (nextKeyword == GetZoneKeyword()) { |
5f91c9e8 | 364 | ReadZoneData(in); |
365 | } | |
31edb2d7 | 366 | else if (nextKeyword == GetSubZoneKeyword()) { |
5f91c9e8 | 367 | ReadSubZoneData(in, zone); |
368 | } | |
369 | else { | |
2ca8e354 | 370 | AliErrorStream() << "Wrong file format." << endl; |
5f91c9e8 | 371 | } |
372 | } | |
373 | ||
374 | //_____________________________________________________________________________ | |
228fd720 | 375 | void AliMpSectorReader::ReadSectorSpecialData(istream& in, AliMp::XDirection direction) |
5f91c9e8 | 376 | { |
197883c2 | 377 | /// Read sector input data |
378 | /// with a special (irregular) motifs. | |
5f91c9e8 | 379 | |
380 | TString keyword; | |
381 | in >> keyword; | |
2c605e66 | 382 | |
da3a1bb2 | 383 | AliDebugStream(2) << keyword << endl; |
5f91c9e8 | 384 | |
31edb2d7 | 385 | if (keyword != GetSectorSpecialKeyword()) { |
2ca8e354 | 386 | AliErrorStream() << "Wrong file format." << endl; |
5f91c9e8 | 387 | return; |
388 | } | |
389 | ||
390 | TString nextKeyword; | |
391 | in >> nextKeyword; | |
2c605e66 | 392 | |
da3a1bb2 | 393 | AliDebugStream(2) << keyword << endl; |
5f91c9e8 | 394 | |
31edb2d7 | 395 | if (nextKeyword != GetMotifKeyword()) { |
2ca8e354 | 396 | AliErrorStream() << "Wrong file format." << endl; |
5f91c9e8 | 397 | return; |
398 | } | |
399 | ||
400 | ReadMotifsSpecialData(in); | |
4139354b | 401 | ReadRowSpecialData(in, direction); |
5f91c9e8 | 402 | } |
403 | ||
404 | //_____________________________________________________________________________ | |
228fd720 | 405 | void AliMpSectorReader::ReadMotifsSpecialData(istream& in) |
5f91c9e8 | 406 | { |
197883c2 | 407 | /// Read the special (irregular) motifs input data. |
5f91c9e8 | 408 | |
31edb2d7 | 409 | AliDebugStream(2) << GetMotifKeyword() << endl; |
5f91c9e8 | 410 | |
411 | TString nextKeyword; | |
412 | do { | |
4139354b | 413 | Int_t zone; |
414 | in >> zone; | |
415 | AliMpVMotif* motif = ReadMotifData(in, fSector->GetZone(zone)); | |
5f91c9e8 | 416 | AliMpSubZone* subZone = new AliMpSubZone(motif); |
4139354b | 417 | fSector->GetZone(zone)->AddSubZone(subZone); |
5f91c9e8 | 418 | |
419 | in >> nextKeyword; | |
2c605e66 | 420 | |
da3a1bb2 | 421 | AliDebugStream(2) << nextKeyword << endl; |
5f91c9e8 | 422 | } |
31edb2d7 | 423 | while (nextKeyword == GetMotifKeyword()); |
5f91c9e8 | 424 | |
31edb2d7 | 425 | if (nextKeyword != GetRowSpecialKeyword()) { |
2ca8e354 | 426 | AliErrorStream() << "Wrong file format." << endl; |
5f91c9e8 | 427 | return; |
428 | } | |
429 | } | |
430 | ||
431 | //_____________________________________________________________________________ | |
228fd720 | 432 | void AliMpSectorReader::ReadRowSpecialData(istream& in, AliMp::XDirection direction) |
5f91c9e8 | 433 | { |
197883c2 | 434 | /// Read row input data |
435 | /// with a special (irregular) motifs. | |
5f91c9e8 | 436 | |
437 | Int_t id; | |
438 | in >> id; | |
2c605e66 | 439 | |
da3a1bb2 | 440 | AliDebugStream(2) << id << endl; |
5f91c9e8 | 441 | |
442 | // Get the row and its border | |
443 | AliMpRow* row = fSector->GetRow(id); | |
4139354b | 444 | |
445 | AliMpVRowSegmentSpecial* segment = 0; | |
cddd101e | 446 | if (direction == AliMp::kLeft) { |
4139354b | 447 | AliMpVRowSegment* firstNormalSeg = row->GetRowSegment(0); |
448 | Double_t offsetX = firstNormalSeg->LeftBorderX(); | |
5f91c9e8 | 449 | |
4139354b | 450 | // Create a special row segment |
451 | segment = new AliMpRowSegmentLSpecial(row, offsetX); | |
452 | row->AddRowSegmentInFront(segment); | |
453 | } | |
454 | else { | |
455 | AliMpVRowSegment* precedentNormalSeg | |
456 | = row->GetRowSegment(row->GetNofRowSegments()-1); | |
457 | Double_t offsetX = precedentNormalSeg->RightBorderX(); | |
5f91c9e8 | 458 | |
4139354b | 459 | // Create a special row segment |
460 | segment = new AliMpRowSegmentRSpecial(row, offsetX); | |
461 | row->AddRowSegment(segment); | |
462 | } | |
463 | ||
5f91c9e8 | 464 | TString nextKeyword; |
465 | in >> nextKeyword; | |
2c605e66 | 466 | |
da3a1bb2 | 467 | AliDebugStream(2) << nextKeyword << endl; |
5f91c9e8 | 468 | |
31edb2d7 | 469 | if (nextKeyword != GetPadRowsKeyword()) { |
2ca8e354 | 470 | AliErrorStream() << "Wrong file format." << endl; |
5f91c9e8 | 471 | return; |
472 | } | |
473 | ||
4139354b | 474 | ReadRowSegmentSpecialData(in, segment, direction); |
5f91c9e8 | 475 | |
476 | // Update row segment and set it to all subzones associated with | |
477 | // contained motifs | |
478 | ||
479 | segment->UpdateMotifVector(); | |
480 | segment->UpdatePadsOffset(); | |
481 | ||
4139354b | 482 | for (Int_t i=0; i<segment->GetNofMotifs(); i++) { |
483 | AliMpSubZone* subZone = 0; | |
484 | Int_t j = 0; | |
485 | while (!subZone && j<fSector->GetNofZones()) | |
486 | subZone = fSector->GetZone(++j)->FindSubZone(segment->GetMotif(i)); | |
487 | ||
17b4ec8d | 488 | if (subZone) subZone->AddRowSegment(segment); |
4139354b | 489 | } |
5f91c9e8 | 490 | } |
491 | ||
492 | //_____________________________________________________________________________ | |
228fd720 | 493 | void AliMpSectorReader::ReadRowSegmentSpecialData(istream& in, |
4139354b | 494 | AliMpVRowSegmentSpecial* segment, |
cddd101e | 495 | AliMp::XDirection direction) |
5f91c9e8 | 496 | { |
197883c2 | 497 | /// Read row segment input data |
498 | /// with a special (irregular) motifs. | |
5f91c9e8 | 499 | |
500 | Int_t nofPadRows; | |
501 | in >> nofPadRows; | |
2c605e66 | 502 | |
da3a1bb2 | 503 | AliDebugStream(2) << nofPadRows << endl; |
5f91c9e8 | 504 | |
d76df0d8 | 505 | if ( nofPadRows < 0 || nofPadRows >= std::numeric_limits<Int_t>::max()) { |
2ca8e354 | 506 | AliErrorStream() << "Wrong nofPadRows value." << endl; |
507 | return; | |
508 | } | |
509 | ||
5f91c9e8 | 510 | TString keyword; |
511 | in >> keyword; | |
2c605e66 | 512 | |
da3a1bb2 | 513 | AliDebugStream(2) << keyword << endl; |
5f91c9e8 | 514 | |
31edb2d7 | 515 | if (keyword != GetPadRowSegmentKeyword()) { |
2ca8e354 | 516 | AliErrorStream() << "Wrong file format." << endl; |
5f91c9e8 | 517 | return; |
518 | } | |
519 | ||
520 | // | |
521 | // Process data | |
522 | // | |
523 | ||
2294822d | 524 | TObjArray newPadRows; |
5f91c9e8 | 525 | for (Int_t i=0; i<nofPadRows; i++) { |
526 | ||
527 | // Create pad row | |
4139354b | 528 | AliMpPadRow* padRow = new AliMpPadRow(direction); |
5f91c9e8 | 529 | segment->AddPadRow(padRow); |
530 | ||
531 | // Keep the new rows in a temporary vector | |
f79c58a5 | 532 | newPadRows.Add(padRow); |
5f91c9e8 | 533 | } |
534 | ||
535 | TString nextKeyword; | |
536 | do { | |
537 | // | |
538 | // Read data from file | |
539 | // | |
540 | Int_t nofPadsInRow, motifPositionId; | |
541 | TString motifId, motifTypeId; | |
542 | in >> nofPadsInRow; | |
543 | in >> motifId; | |
544 | in >> motifPositionId; | |
545 | ||
f0eac1a3 | 546 | motifPositionId |= AliMpConstants::ManuMask(fPlaneType); |
547 | ||
da3a1bb2 | 548 | AliDebugStream(2) |
2c605e66 | 549 | << nofPadsInRow << " " << motifId << " " << motifPositionId << endl; |
5f91c9e8 | 550 | |
551 | in >> nextKeyword; | |
2c605e66 | 552 | |
da3a1bb2 | 553 | AliDebugStream(2) << nextKeyword << endl; |
5f91c9e8 | 554 | |
555 | // | |
556 | // Process data | |
557 | // | |
558 | ||
559 | for (Int_t i=0; i<nofPadRows; i++) { | |
560 | ||
561 | // Get pad row from the temporary vector | |
f79c58a5 | 562 | AliMpPadRow* padRow = (AliMpPadRow*)newPadRows[i]; |
5f91c9e8 | 563 | |
564 | // Find motif | |
565 | AliMpVMotif* motif = fSector->GetMotifMap()->FindMotif(motifId); | |
566 | ||
567 | if (!motif) { | |
2ca8e354 | 568 | AliErrorStream() << "Unknown motif" << endl; |
5f91c9e8 | 569 | return; |
570 | } | |
571 | ||
572 | // Create pad row segment | |
4139354b | 573 | padRow->AddPadRowSegment(dynamic_cast<AliMpMotif *>(motif), |
574 | motifPositionId, nofPadsInRow); | |
5f91c9e8 | 575 | } |
576 | } | |
31edb2d7 | 577 | while (!in.eof() && (nextKeyword == GetPadRowSegmentKeyword())); |
5f91c9e8 | 578 | |
579 | if (in.eof()) return; | |
580 | ||
31edb2d7 | 581 | if (nextKeyword == GetPadRowsKeyword()) { |
4139354b | 582 | ReadRowSegmentSpecialData(in, segment, direction); |
5f91c9e8 | 583 | } |
31edb2d7 | 584 | else if (nextKeyword == GetRowSpecialKeyword()) { |
4139354b | 585 | ReadRowSpecialData(in, direction); |
5f91c9e8 | 586 | } |
587 | else { | |
2ca8e354 | 588 | AliErrorStream() << "Wrong file format." << endl; |
5f91c9e8 | 589 | } |
590 | } | |
591 | ||
592 | // | |
593 | // public methods | |
594 | // | |
595 | ||
596 | //_____________________________________________________________________________ | |
197883c2 | 597 | AliMpSector* AliMpSectorReader::BuildSector() |
5f91c9e8 | 598 | { |
228fd720 | 599 | /// Read the mapping data from stream and create the basic objects: \n |
197883c2 | 600 | /// zones, subzones, rows, row segments, motifs. |
5f91c9e8 | 601 | |
228fd720 | 602 | // Open input stream |
603 | // | |
604 | istream& in | |
7d5d0cc5 | 605 | = fkDataStreams. |
ab167304 | 606 | CreateDataStream(AliMpFiles::SectorFilePath(fStationType,fPlaneType)); |
228fd720 | 607 | |
5f91c9e8 | 608 | ReadSectorData(in); |
228fd720 | 609 | delete ∈ |
610 | ||
5f91c9e8 | 611 | fSector->SetRowSegmentOffsets(); |
612 | ||
228fd720 | 613 | // Open input stream for special inner zone |
614 | ||
615 | // add is data function | |
616 | ||
5f91c9e8 | 617 | TString sectorSpecialFileName |
3d16af90 | 618 | = AliMpFiles::SectorSpecialFilePath(fStationType, fPlaneType); |
7d5d0cc5 | 619 | if ( fkDataStreams.IsDataStream(sectorSpecialFileName) ) { |
228fd720 | 620 | istream& in2 |
7d5d0cc5 | 621 | = fkDataStreams. |
ab167304 | 622 | CreateDataStream(sectorSpecialFileName); |
228fd720 | 623 | |
cddd101e | 624 | ReadSectorSpecialData(in2, AliMp::kLeft); |
228fd720 | 625 | |
626 | delete &in2; | |
627 | } | |
4139354b | 628 | |
629 | // Open input file for special outer zone | |
630 | TString sectorSpecialFileName2 | |
3d16af90 | 631 | = AliMpFiles::SectorSpecialFilePath2(fStationType, fPlaneType); |
7d5d0cc5 | 632 | if ( fkDataStreams.IsDataStream(sectorSpecialFileName2) ) { |
228fd720 | 633 | istream& in3 |
7d5d0cc5 | 634 | = fkDataStreams. |
ab167304 | 635 | CreateDataStream(sectorSpecialFileName2); |
4139354b | 636 | |
cddd101e | 637 | ReadSectorSpecialData(in3, AliMp::kRight); |
228fd720 | 638 | |
639 | delete &in3; | |
5f91c9e8 | 640 | } |
641 | ||
642 | fSector->Initialize(); | |
643 | ||
644 | return fSector; | |
645 | } | |
646 |