]>
Commit | Line | Data |
---|---|---|
5f91c9e8 | 1 | // $Id$ |
2 | // Category: sector | |
3 | // | |
4 | // Class AliMpReader | |
5 | // ------------------- | |
6 | // Class that takes care of reading the sector data. | |
7 | // | |
8 | // Authors: David Guez, Ivana Hrivnacova; IPN Orsay | |
9 | ||
10 | #include <string> | |
11 | #if !defined(__HP_aCC) && !defined(__alpha) | |
12 | #include <sstream> | |
13 | #endif | |
14 | ||
15 | #include <Riostream.h> | |
16 | #include <Rstrstream.h> | |
17 | #include <TSystem.h> | |
18 | #include <TError.h> | |
19 | #include <TMath.h> | |
20 | ||
21 | #include "AliMpReader.h" | |
22 | #include "AliMpSector.h" | |
23 | #include "AliMpFiles.h" | |
24 | #include "AliMpZone.h" | |
25 | #include "AliMpSubZone.h" | |
26 | #include "AliMpRow.h" | |
27 | #include "AliMpVRowSegment.h" | |
28 | #include "AliMpRowSegment.h" | |
4139354b | 29 | #include "AliMpRowSegmentLSpecial.h" |
30 | #include "AliMpRowSegmentRSpecial.h" | |
5f91c9e8 | 31 | #include "AliMpPadRow.h" |
5f91c9e8 | 32 | #include "AliMpMotifMap.h" |
33 | #include "AliMpMotif.h" | |
34 | #include "AliMpMotifSpecial.h" | |
35 | #include "AliMpMotifType.h" | |
36 | #include "AliMpConnection.h" | |
37 | #include "AliMpIntPair.h" | |
38 | #include "AliMpDirection.h" | |
39 | ||
40 | ClassImp(AliMpReader) | |
41 | ||
42 | const TString AliMpReader::fgkSectorKeyword = "SECTOR_DATA"; | |
43 | const TString AliMpReader::fgkZoneKeyword = "ZONE"; | |
44 | const TString AliMpReader::fgkSubZoneKeyword = "SUBZONE"; | |
45 | const TString AliMpReader::fgkRowKeyword = "ROW_SEGMENT"; | |
46 | const TString AliMpReader::fgkEofKeyword = "EOF"; | |
47 | const TString AliMpReader::fgkSectorSpecialKeyword = "SECTOR_SPECIAL_DATA"; | |
48 | const TString AliMpReader::fgkMotifKeyword = "MOTIF"; | |
49 | const TString AliMpReader::fgkRowSpecialKeyword = "ROW"; | |
50 | const TString AliMpReader::fgkPadRowsKeyword = "PAD_ROWS"; | |
51 | const TString AliMpReader::fgkPadRowSegmentKeyword = "PAD_ROW_SEGMENT"; | |
52 | ||
53 | //_____________________________________________________________________________ | |
4139354b | 54 | AliMpReader::AliMpReader(AliMpStationType station, AliMpPlaneType plane) |
5f91c9e8 | 55 | : TObject(), |
4139354b | 56 | fStationType(station), |
5f91c9e8 | 57 | fPlaneType(plane), |
58 | fSector(0), | |
59 | fVerboseLevel(0) | |
60 | { | |
61 | // | |
62 | } | |
63 | ||
64 | //_____________________________________________________________________________ | |
65 | AliMpReader::AliMpReader() | |
66 | : TObject(), | |
4139354b | 67 | fStationType(kStation1), |
5f91c9e8 | 68 | fPlaneType(kBendingPlane), |
69 | fSector(0), | |
70 | fVerboseLevel(0) | |
71 | { | |
72 | // | |
73 | } | |
74 | ||
75 | //_____________________________________________________________________________ | |
76 | AliMpReader::~AliMpReader() { | |
77 | // | |
78 | } | |
79 | ||
80 | // | |
81 | // private methods | |
82 | // | |
83 | ||
84 | //_____________________________________________________________________________ | |
85 | void AliMpReader::ReadSectorData(ifstream& in) | |
86 | { | |
87 | // Reads sector input data; | |
88 | // prepares zones and rows vectors to be filled in. | |
89 | // --- | |
90 | ||
91 | TString keyword; | |
92 | in >> keyword; | |
93 | ||
94 | if (fVerboseLevel>0) | |
95 | cout << keyword << endl; | |
96 | ||
97 | if (keyword != fgkSectorKeyword) { | |
98 | Fatal("ReadSectorData", "Wrong file format."); | |
99 | return; | |
100 | } | |
101 | ||
102 | Int_t nofZones, nofRows; | |
103 | TString directionStr; | |
104 | in >> nofZones; | |
105 | in >> nofRows; | |
106 | in >> directionStr; | |
107 | ||
108 | AliMpDirection direction; | |
109 | direction = (directionStr == "Y") ? kY : kX; | |
110 | if (fVerboseLevel>0) | |
111 | cout << nofZones << " " << nofRows << endl; | |
112 | ||
113 | fSector = new AliMpSector("Not defined", nofZones, nofRows,direction); | |
114 | ||
115 | TString nextKeyword; | |
116 | in >> nextKeyword; | |
117 | ||
118 | if (nextKeyword != fgkZoneKeyword) { | |
119 | Fatal("ReadSectorData", "Wrong file format."); | |
120 | return; | |
121 | } | |
122 | ||
123 | ReadZoneData(in); | |
124 | } | |
125 | ||
126 | //_____________________________________________________________________________ | |
127 | void AliMpReader::ReadZoneData(ifstream& in) | |
128 | { | |
129 | // Reads zone input data; | |
130 | // creates zone and adds it to zones vector. | |
131 | // --- | |
132 | ||
133 | Int_t zoneID; | |
134 | Double_t sizex, sizey; | |
135 | in >> zoneID; | |
136 | in >> sizex; | |
137 | in >> sizey; | |
138 | if (fVerboseLevel>0) | |
139 | cout << fgkZoneKeyword << " " << zoneID << " " | |
140 | << sizex << " " << sizey << endl; | |
141 | ||
142 | AliMpZone* zone = fSector->GetZone(zoneID); | |
143 | zone->SetPadDimensions(TVector2(sizex/2.,sizey/2.)); | |
144 | ||
145 | TString nextKeyword; | |
146 | in >> nextKeyword; | |
147 | ||
148 | if (nextKeyword != fgkSubZoneKeyword) { | |
149 | Fatal("ReadZoneData", "Wrong file format."); | |
150 | return; | |
151 | } | |
152 | ||
153 | ReadSubZoneData(in, zone); | |
154 | } | |
155 | ||
156 | //_____________________________________________________________________________ | |
157 | void AliMpReader::ReadSubZoneData(ifstream& in, AliMpZone* zone) | |
158 | { | |
159 | // Reads subzone input data; | |
160 | // creates subzone and its to the specified zone. | |
161 | // --- | |
162 | ||
163 | if (fVerboseLevel>0) | |
164 | cout << fgkSubZoneKeyword << " "; | |
165 | ||
166 | AliMpVMotif* motif = ReadMotifData(in, zone); | |
167 | AliMpSubZone* subZone = new AliMpSubZone(motif); | |
168 | zone->AddSubZone(subZone); | |
169 | ||
170 | TString nextKeyword; | |
171 | in >> nextKeyword; | |
172 | ||
173 | if (nextKeyword != fgkRowKeyword) { | |
174 | Fatal("ReadSubZoneData", "Wrong file format."); | |
175 | return; | |
176 | } | |
177 | ||
178 | ReadRowSegmentsData(in, zone, subZone); | |
179 | } | |
180 | ||
181 | //_____________________________________________________________________________ | |
182 | AliMpVMotif* AliMpReader::ReadMotifData(ifstream& in, AliMpZone* zone) | |
183 | { | |
184 | // Reads the motif input data. | |
185 | // --- | |
186 | ||
187 | TString motifID; | |
188 | TString motifTypeID; | |
189 | in >> motifID; | |
190 | in >> motifTypeID; | |
191 | if (fVerboseLevel>0) { | |
192 | cout << motifID << " " | |
193 | << motifTypeID << endl; | |
194 | } | |
195 | ||
196 | AliMpMotifMap* motifMap = fSector->GetMotifMap(); | |
197 | ||
198 | AliMpMotifType* motifType = 0; | |
199 | AliMpVMotif* motif | |
200 | = motifMap->FindMotif(motifID, motifTypeID, zone->GetPadDimensions()); | |
201 | if (!motif) { | |
202 | motifType = motifMap->FindMotifType(motifTypeID); | |
203 | if (!motifType) { | |
204 | motifType = BuildMotifType(motifTypeID); | |
205 | motifMap->AddMotifType(motifType); | |
206 | } | |
207 | ||
208 | if (zone->GetPadDimensions().X() != 0. && zone->GetPadDimensions().Y() != 0.) | |
209 | motif = new AliMpMotif(motifID, motifType, zone->GetPadDimensions()); | |
210 | else | |
211 | motif = BuildMotifSpecial(motifID, motifType); | |
212 | ||
213 | if (motif) | |
214 | motifMap->AddMotif(motif); | |
215 | ||
216 | } | |
217 | ||
218 | return motif; | |
219 | } | |
220 | ||
221 | //_____________________________________________________________________________ | |
222 | void AliMpReader::ReadRowSegmentsData(ifstream& in, | |
223 | AliMpZone* zone, AliMpSubZone* subZone) | |
224 | { | |
225 | // Reads row segments input data of a specified zone and subzone; | |
226 | // creates row segment and adds it to the specified subzone | |
227 | // and a corresponding row in the rows vector. | |
228 | // --- | |
229 | ||
230 | TString nextKeyword; | |
231 | do { | |
232 | // | |
233 | // Read data from file | |
234 | // | |
235 | Int_t offX, offY, inRow, nofMotifs, firstMotifPositionId, firstMotifPositionDId; | |
236 | in >> offX; | |
237 | in >> offY; | |
238 | in >> inRow; | |
239 | in >> nofMotifs; | |
240 | in >> firstMotifPositionId; | |
241 | in >> firstMotifPositionDId; | |
242 | if (fVerboseLevel>0) | |
243 | cout << fgkRowKeyword << " " | |
244 | << offX << " " << offY << " " << inRow << " " << nofMotifs << " " | |
245 | << firstMotifPositionId << " " << firstMotifPositionDId | |
246 | << endl; | |
247 | ||
248 | in >> nextKeyword; | |
249 | ||
250 | // | |
251 | // Process data | |
252 | // | |
253 | AliMpRow* row = fSector->GetRow(inRow); | |
254 | AliMpVMotif* motif = subZone->GetMotif(); | |
255 | ||
256 | // Create row segment and add it to its zone, row | |
257 | AliMpVRowSegment* rowSegment | |
258 | = new AliMpRowSegment(row, motif, AliMpIntPair(offX, offY), nofMotifs, | |
259 | firstMotifPositionId, firstMotifPositionDId); | |
260 | ||
261 | subZone->AddRowSegment(rowSegment); | |
262 | row->AddRowSegment(rowSegment); | |
263 | } | |
264 | while (!in.eof() && (nextKeyword == fgkRowKeyword)); | |
265 | ||
266 | if (in.eof()) return; | |
267 | ||
268 | if (nextKeyword == fgkZoneKeyword) { | |
269 | ReadZoneData(in); | |
270 | } | |
271 | else if (nextKeyword == fgkSubZoneKeyword) { | |
272 | ReadSubZoneData(in, zone); | |
273 | } | |
274 | else { | |
275 | Fatal("ReadRowSegmentsData", "Wrong file format."); | |
276 | } | |
277 | } | |
278 | ||
279 | //_____________________________________________________________________________ | |
4139354b | 280 | void AliMpReader::ReadSectorSpecialData(ifstream& in, AliMpXDirection direction) |
5f91c9e8 | 281 | { |
282 | // Reads sector input data | |
283 | // with a special (irregular) motifs. | |
284 | // --- | |
285 | ||
286 | TString keyword; | |
287 | in >> keyword; | |
288 | if (fVerboseLevel>0) | |
289 | cout << keyword << endl; | |
290 | ||
291 | if (keyword != fgkSectorSpecialKeyword) { | |
292 | Fatal("ReadSectorSpecialData", "Wrong file format."); | |
293 | return; | |
294 | } | |
295 | ||
296 | TString nextKeyword; | |
297 | in >> nextKeyword; | |
298 | if (fVerboseLevel>0) | |
299 | cout << keyword << endl; | |
300 | ||
301 | if (nextKeyword != fgkMotifKeyword) { | |
302 | Fatal("ReadSectorSpecialData", "Wrong file format."); | |
303 | return; | |
304 | } | |
305 | ||
306 | ReadMotifsSpecialData(in); | |
4139354b | 307 | ReadRowSpecialData(in, direction); |
5f91c9e8 | 308 | } |
309 | ||
310 | //_____________________________________________________________________________ | |
311 | void AliMpReader::ReadMotifsSpecialData(ifstream& in) | |
312 | { | |
313 | // Reads the special (irregular) motifs input data. | |
314 | // --- | |
315 | ||
316 | if (fVerboseLevel>0) | |
317 | cout << fgkMotifKeyword << " "; | |
318 | ||
319 | TString nextKeyword; | |
320 | do { | |
4139354b | 321 | Int_t zone; |
322 | in >> zone; | |
323 | AliMpVMotif* motif = ReadMotifData(in, fSector->GetZone(zone)); | |
5f91c9e8 | 324 | AliMpSubZone* subZone = new AliMpSubZone(motif); |
4139354b | 325 | fSector->GetZone(zone)->AddSubZone(subZone); |
5f91c9e8 | 326 | |
327 | in >> nextKeyword; | |
328 | if (fVerboseLevel>0) | |
329 | cout << nextKeyword << " "; | |
330 | } | |
331 | while (nextKeyword == fgkMotifKeyword); | |
332 | ||
333 | if (nextKeyword != fgkRowSpecialKeyword) { | |
334 | Fatal("ReadMotifSpecialData", "Wrong file format."); | |
335 | return; | |
336 | } | |
337 | } | |
338 | ||
339 | //_____________________________________________________________________________ | |
4139354b | 340 | void AliMpReader::ReadRowSpecialData(ifstream& in, AliMpXDirection direction) |
5f91c9e8 | 341 | { |
342 | // Reads row input data | |
343 | // with a special (irregular) motifs. | |
344 | // --- | |
345 | ||
346 | Int_t id; | |
347 | in >> id; | |
348 | if (fVerboseLevel>0) | |
349 | cout << id << endl; | |
350 | ||
351 | // Get the row and its border | |
352 | AliMpRow* row = fSector->GetRow(id); | |
4139354b | 353 | |
354 | AliMpVRowSegmentSpecial* segment = 0; | |
355 | if (direction == kLeft) { | |
356 | AliMpVRowSegment* firstNormalSeg = row->GetRowSegment(0); | |
357 | Double_t offsetX = firstNormalSeg->LeftBorderX(); | |
5f91c9e8 | 358 | |
4139354b | 359 | // Create a special row segment |
360 | segment = new AliMpRowSegmentLSpecial(row, offsetX); | |
361 | row->AddRowSegmentInFront(segment); | |
362 | } | |
363 | else { | |
364 | AliMpVRowSegment* precedentNormalSeg | |
365 | = row->GetRowSegment(row->GetNofRowSegments()-1); | |
366 | Double_t offsetX = precedentNormalSeg->RightBorderX(); | |
5f91c9e8 | 367 | |
4139354b | 368 | // Create a special row segment |
369 | segment = new AliMpRowSegmentRSpecial(row, offsetX); | |
370 | row->AddRowSegment(segment); | |
371 | } | |
372 | ||
5f91c9e8 | 373 | TString nextKeyword; |
374 | in >> nextKeyword; | |
375 | if (fVerboseLevel>0) | |
376 | cout << nextKeyword << " "; | |
377 | ||
378 | if (nextKeyword != fgkPadRowsKeyword) { | |
379 | Fatal("ReadRowSpecialData", "Wrong file format."); | |
380 | return; | |
381 | } | |
382 | ||
4139354b | 383 | ReadRowSegmentSpecialData(in, segment, direction); |
5f91c9e8 | 384 | |
385 | // Update row segment and set it to all subzones associated with | |
386 | // contained motifs | |
387 | ||
388 | segment->UpdateMotifVector(); | |
389 | segment->UpdatePadsOffset(); | |
390 | ||
4139354b | 391 | for (Int_t i=0; i<segment->GetNofMotifs(); i++) { |
392 | AliMpSubZone* subZone = 0; | |
393 | Int_t j = 0; | |
394 | while (!subZone && j<fSector->GetNofZones()) | |
395 | subZone = fSector->GetZone(++j)->FindSubZone(segment->GetMotif(i)); | |
396 | ||
397 | subZone->AddRowSegment(segment); | |
398 | } | |
5f91c9e8 | 399 | } |
400 | ||
401 | //_____________________________________________________________________________ | |
402 | void AliMpReader::ReadRowSegmentSpecialData(ifstream& in, | |
4139354b | 403 | AliMpVRowSegmentSpecial* segment, |
404 | AliMpXDirection direction) | |
5f91c9e8 | 405 | { |
406 | // Reads row segment input data | |
407 | // with a special (irregular) motifs. | |
408 | // --- | |
409 | ||
410 | Int_t nofPadRows; | |
411 | in >> nofPadRows; | |
412 | if (fVerboseLevel>0) | |
413 | cout << nofPadRows << endl; | |
414 | ||
415 | TString keyword; | |
416 | in >> keyword; | |
417 | if (fVerboseLevel>0) | |
418 | cout << keyword << " "; | |
419 | ||
420 | if (keyword != fgkPadRowSegmentKeyword) { | |
421 | Fatal("ReadRowSegmentSpecialData", "Wrong file format."); | |
422 | return; | |
423 | } | |
424 | ||
425 | // | |
426 | // Process data | |
427 | // | |
428 | ||
429 | PadRowVector newPadRows; | |
430 | for (Int_t i=0; i<nofPadRows; i++) { | |
431 | ||
432 | // Create pad row | |
4139354b | 433 | AliMpPadRow* padRow = new AliMpPadRow(direction); |
5f91c9e8 | 434 | segment->AddPadRow(padRow); |
435 | ||
436 | // Keep the new rows in a temporary vector | |
437 | newPadRows.push_back(padRow); | |
438 | } | |
439 | ||
440 | TString nextKeyword; | |
441 | do { | |
442 | // | |
443 | // Read data from file | |
444 | // | |
445 | Int_t nofPadsInRow, motifPositionId; | |
446 | TString motifId, motifTypeId; | |
447 | in >> nofPadsInRow; | |
448 | in >> motifId; | |
449 | in >> motifPositionId; | |
450 | ||
451 | if (fVerboseLevel>0) | |
452 | cout << nofPadsInRow << " " << motifId << " " << motifPositionId << endl; | |
453 | ||
454 | in >> nextKeyword; | |
455 | if (fVerboseLevel>0) | |
456 | cout << nextKeyword << " "; | |
457 | ||
458 | // | |
459 | // Process data | |
460 | // | |
461 | ||
462 | for (Int_t i=0; i<nofPadRows; i++) { | |
463 | ||
464 | // Get pad row from the temporary vector | |
465 | AliMpPadRow* padRow = newPadRows[i]; | |
466 | ||
467 | // Find motif | |
468 | AliMpVMotif* motif = fSector->GetMotifMap()->FindMotif(motifId); | |
469 | ||
470 | if (!motif) { | |
471 | Fatal("ReadRowSegmentSpecialData", "Unknown motif."); | |
472 | return; | |
473 | } | |
474 | ||
475 | // Create pad row segment | |
4139354b | 476 | padRow->AddPadRowSegment(dynamic_cast<AliMpMotif *>(motif), |
477 | motifPositionId, nofPadsInRow); | |
5f91c9e8 | 478 | } |
479 | } | |
480 | while (!in.eof() && (nextKeyword == fgkPadRowSegmentKeyword)); | |
481 | ||
482 | if (in.eof()) return; | |
483 | ||
484 | if (nextKeyword == fgkPadRowsKeyword) { | |
4139354b | 485 | ReadRowSegmentSpecialData(in, segment, direction); |
5f91c9e8 | 486 | } |
487 | else if (nextKeyword == fgkRowSpecialKeyword) { | |
4139354b | 488 | ReadRowSpecialData(in, direction); |
5f91c9e8 | 489 | } |
490 | else { | |
491 | Fatal("ReadRowSegmentSpecialData", "Wrong file format."); | |
492 | } | |
493 | } | |
494 | ||
495 | // | |
496 | // public methods | |
497 | // | |
498 | ||
499 | //_____________________________________________________________________________ | |
500 | AliMpSector* AliMpReader::BuildSector() | |
501 | { | |
502 | // Reads the mapping data from ascii file | |
503 | // $MINSTALL/data/fileName and creates the basic objects: | |
504 | // zones, subzones, rows, row segments, motifs. | |
505 | // --- | |
506 | ||
507 | // Open input file | |
4139354b | 508 | ifstream in(AliMpFiles::Instance() |
509 | ->SectorFilePath(fStationType, fPlaneType).Data(), ios::in); | |
510 | if (!in) { | |
511 | cerr << AliMpFiles::Instance() | |
512 | ->SectorFilePath(fStationType, fPlaneType) << endl; | |
513 | Error("BuildSector", "File not found."); | |
5f91c9e8 | 514 | return 0; |
515 | } | |
516 | ||
517 | ReadSectorData(in); | |
518 | fSector->SetRowSegmentOffsets(); | |
519 | ||
4139354b | 520 | // Open input file for special inner zone |
5f91c9e8 | 521 | TString sectorSpecialFileName |
4139354b | 522 | = AliMpFiles::Instance()->SectorSpecialFilePath(fStationType, fPlaneType); |
5f91c9e8 | 523 | if (!gSystem->AccessPathName(sectorSpecialFileName.Data())) { |
524 | ifstream in2(sectorSpecialFileName.Data(), ios::in); | |
525 | if (!in2) { | |
4139354b | 526 | cerr << AliMpFiles::Instance() |
527 | ->SectorSpecialFilePath(fStationType, fPlaneType) << endl; | |
528 | Error("BuildSector", "File not found."); | |
5f91c9e8 | 529 | return 0; |
530 | } | |
531 | ||
4139354b | 532 | ReadSectorSpecialData(in2, kLeft); |
533 | } | |
534 | ||
535 | // Open input file for special outer zone | |
536 | TString sectorSpecialFileName2 | |
537 | = AliMpFiles::Instance()->SectorSpecialFilePath2(fStationType, fPlaneType); | |
538 | if (!gSystem->AccessPathName(sectorSpecialFileName2.Data())) { | |
539 | ifstream in3(sectorSpecialFileName2.Data(), ios::in); | |
540 | if (!in3) { | |
541 | cerr << AliMpFiles::Instance() | |
542 | ->SectorSpecialFilePath2(fStationType, fPlaneType) << endl; | |
543 | Error("Build", "File not found."); | |
544 | return 0; | |
545 | } | |
546 | ||
547 | ReadSectorSpecialData(in3, kRight); | |
5f91c9e8 | 548 | } |
549 | ||
550 | fSector->Initialize(); | |
551 | ||
552 | return fSector; | |
553 | } | |
554 | ||
555 | //_____________________________________________________________________________ | |
4139354b | 556 | AliMpMotifType* AliMpReader::BuildMotifType(const TString& motifTypeId) |
5f91c9e8 | 557 | { |
558 | ||
559 | // Read the files describing a motif in the "$MINSTALL/data" directory | |
560 | // and fill the AliMpMotifType structure with. | |
561 | // The files mentioned are are named padPos<maskName>.dat | |
562 | // and connect<maskName>.dat | |
563 | ||
564 | AliMpMotifType* motifType = new AliMpMotifType(motifTypeId); | |
565 | ||
566 | TString strPadPos | |
4139354b | 567 | = AliMpFiles::Instance() |
568 | ->PadPosFilePath(fStationType, fPlaneType, motifTypeId); | |
5f91c9e8 | 569 | ifstream padPos(strPadPos.Data()); |
570 | if (fVerboseLevel>0) cout<<"Opening file "<<strPadPos<<endl; | |
571 | ||
572 | PadMapType positions; | |
573 | ||
574 | char line[256]; | |
575 | do { | |
576 | padPos.getline(line,255); | |
577 | if (!padPos) break; | |
578 | ||
579 | #if defined (__HP_aCC) || (__alpha) | |
580 | strstream strline; | |
581 | strline << line; | |
582 | #else | |
583 | istringstream strline(line); | |
584 | #endif | |
585 | string key; | |
586 | ||
587 | strline>>key; | |
588 | if ((key=="#") || (key=="") ) continue; | |
589 | ||
590 | int i,j; | |
591 | strline>>i>>j; | |
592 | positions[key].first=i; | |
593 | positions[key].second=j; | |
594 | } while (!padPos.eof()); | |
595 | ||
596 | padPos.close(); | |
597 | ||
4139354b | 598 | if (fVerboseLevel>0) |
599 | cout << "Opening file " | |
600 | << AliMpFiles::Instance()->BergToGCFilePath(fStationType) | |
601 | << endl; | |
5f91c9e8 | 602 | |
4139354b | 603 | ifstream bergToGCFile(AliMpFiles::Instance()->BergToGCFilePath(fStationType)); |
604 | Int_t gassiChannel[80]; | |
5f91c9e8 | 605 | while(1) { |
606 | Int_t bergNum; | |
4139354b | 607 | TString gcStr; |
608 | bergToGCFile>>bergNum>>gcStr; | |
5f91c9e8 | 609 | if (!bergToGCFile.good()) break; |
4139354b | 610 | if (gcStr=="GND") continue; |
5f91c9e8 | 611 | if (bergNum>80) { |
612 | Fatal("BuildMotifType","Berg number > 80 ..."); | |
613 | continue; | |
614 | } | |
4139354b | 615 | gassiChannel[bergNum-1]= atoi(gcStr); |
5f91c9e8 | 616 | } |
617 | bergToGCFile.close(); | |
618 | ||
619 | TString strMotif | |
4139354b | 620 | = AliMpFiles::Instance() |
621 | ->MotifFilePath(fStationType, fPlaneType, motifTypeId); | |
5f91c9e8 | 622 | ifstream motif(strMotif); |
623 | if (fVerboseLevel>0) cout<<"Opening file "<<strMotif<<endl; | |
624 | ||
625 | ||
626 | Int_t nofPadsX=0; | |
627 | Int_t nofPadsY=0; | |
628 | ||
629 | do { | |
630 | ||
631 | Int_t ix,iy,numBerg,numKapton,padNum,gassiNum; | |
632 | ||
633 | TString lineStr,token; | |
634 | lineStr.ReadLine(motif); | |
635 | if (!motif.good()) break; | |
636 | #if defined (__HP_aCC) || (__alpha) | |
637 | strstream tokenList; | |
638 | tokenList << lineStr.Data(); | |
639 | #else | |
640 | istringstream tokenList(lineStr.Data()); | |
641 | #endif | |
642 | ||
643 | token.ReadToken(tokenList); | |
644 | if (!tokenList.good()) continue; // column is missing... | |
645 | if ( (token.Length()>0) && (token[0]=='#') ) continue; // this is a comment line | |
646 | ||
647 | numBerg = atoi(token.Data()); | |
648 | if (numBerg==0) { | |
649 | Warning("BuildMotifType","Berg number invalid"); | |
650 | continue; | |
651 | } | |
652 | ||
653 | token.ReadToken(tokenList); | |
654 | if (!tokenList.good()) continue; // column is missing... | |
655 | numKapton = atoi(token.Data()); | |
656 | if (numKapton==0) continue; | |
657 | ||
658 | ||
659 | token.ReadToken(tokenList); | |
660 | if (!tokenList.good()) continue; // column is missing... | |
661 | if (token=="GND") continue; | |
662 | string padName = token.Data(); | |
663 | padNum = motifType->PadNum(token); | |
664 | ||
665 | token.ReadToken(tokenList); | |
666 | if (token.IsNull() ) continue; // column is missing... | |
667 | // if (token[0]!='E') { | |
668 | // cerr<<"Problem : gassinumber isn't begining with E:"<<token<<endl; | |
669 | // continue; | |
670 | // } else { | |
671 | // gassiNum = atoi(token.Data() +1 )-1; | |
672 | // } | |
673 | if ( (numBerg<1) || (numBerg>80) ) { | |
674 | Warning("BuildMotifType","Berg number outside range"); | |
675 | continue; | |
676 | } | |
677 | ||
4139354b | 678 | gassiNum = gassiChannel[numBerg-1]; |
5f91c9e8 | 679 | |
680 | PadMapTypeIterator iter = positions.find(padName); | |
681 | if (iter==positions.end()) { | |
682 | cerr<<"Problem: Pad number "<<padNum<<" found in the file "<<strMotif | |
683 | <<" but not in the file"<<strPadPos<<endl; | |
684 | continue; | |
685 | } | |
686 | ||
687 | ix= iter->second.first; | |
688 | iy= iter->second.second; | |
689 | ||
690 | motifType->AddConnection(AliMpIntPair(ix,iy), | |
691 | new AliMpConnection(padNum,numBerg,numKapton,gassiNum)); | |
692 | ||
693 | if (ix>=nofPadsX) nofPadsX=ix+1; | |
694 | if (iy>=nofPadsY) nofPadsY=iy+1; | |
695 | ||
696 | } while (!motif.eof()); | |
697 | ||
698 | ||
699 | motifType->SetNofPads(nofPadsX, nofPadsY); | |
700 | ||
701 | motif.close(); | |
702 | ||
703 | return motifType; | |
704 | } | |
705 | ||
706 | ||
707 | //_____________________________________________________________________________ | |
708 | AliMpMotifSpecial* | |
4139354b | 709 | AliMpReader::BuildMotifSpecial(const TString& motifID, |
710 | AliMpMotifType* motifType) | |
5f91c9e8 | 711 | { |
712 | // Build a special motif by reading the file motifSpecial<motifId>.dat | |
713 | // in the data directory | |
714 | // --- | |
715 | ||
716 | // Open the input file | |
717 | ifstream in(AliMpFiles::Instance() | |
4139354b | 718 | ->MotifSpecialFilePath(fStationType, fPlaneType, motifID).Data(), |
719 | ios::in); | |
5f91c9e8 | 720 | if (!in) { |
721 | Error("BuildMotifSpecial", "File not found."); | |
722 | return 0; | |
723 | } | |
724 | ||
725 | AliMpMotifSpecial* res = new AliMpMotifSpecial(motifID,motifType); | |
726 | Int_t i,j; | |
727 | Double_t x,y; | |
728 | in >> i; | |
729 | while (!in.eof()){ | |
730 | in >>j >>x >> y; | |
731 | res->SetPadDimensions(AliMpIntPair(i,j),TVector2(x/2.,y/2.)); | |
732 | in >> i; | |
733 | } | |
734 | ||
735 | in.close(); | |
736 | return res; | |
737 | } | |
738 | ||
739 | ||
740 | //_____________________________________________________________________________ | |
741 | void AliMpReader::SetVerboseLevel(Int_t verboseLevel) | |
742 | { | |
743 | // Sets verbose level. | |
744 | // --- | |
745 | ||
746 | fVerboseLevel = verboseLevel; | |
747 | } | |
748 |