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