]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MUON/mapping/AliMpTriggerReader.cxx
Added comments for inline functions
[u/mrichter/AliRoot.git] / MUON / mapping / AliMpTriggerReader.cxx
CommitLineData
1d9e7bed 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 purpeateose. It is *
13* provided "as is" without express or implied warranty. *
14**************************************************************************/
15
16// $Id$
63ed9c6b 17// $MpId: AliMpTriggerReader.cxx,v 1.2 2006/03/02 16:36:30 ivana Exp $
1d9e7bed 18
19#include "AliMpTriggerReader.h"
1d9e7bed 20#include "AliMpMotifReader.h"
21#include "AliMpFiles.h"
22#include "AliMpMotifType.h"
23#include "AliMpPCB.h"
24#include "AliMpSlat.h"
25#include "AliMpMotifMap.h"
26#include "AliMpMotifPosition.h"
27#include "AliMpMotif.h"
28#include "AliMpHelper.h"
29#include "AliMpSt345Reader.h"
30#include "AliMpTrigger.h"
31
63ed9c6b 32#include "AliLog.h"
1d9e7bed 33
63ed9c6b 34#include "Riostream.h"
1d9e7bed 35#include "TClass.h"
36#include "TObjString.h"
37#include "TList.h"
38#include "TString.h"
39
40#include <sstream>
63ed9c6b 41#include <cassert>
1d9e7bed 42
85fec35d 43///
44/// \class AliMpTriggerReader
45/// Read trigger slat ASCII files
46/// Basically provides 2 static methods:
47/// - AliMpTrigger* ReadSlat()
48/// - AliMpPCB* ReadPCB()
49///
50/// \author Laurent Aphecetche
51
1d9e7bed 52TMap AliMpTriggerReader::fgPCBMap;
53TMap AliMpTriggerReader::fgLocalBoardMap;
54
85fec35d 55const TString AliMpTriggerReader::fgkKeywordLayer("LAYER");
56const TString AliMpTriggerReader::fgkKeywordScale("SCALE");
57const TString AliMpTriggerReader::fgkKeywordPcb("PCB");
58const TString AliMpTriggerReader::fgkKeywordFlipX("FLIP_X");
59const TString AliMpTriggerReader::fgkKeywordFlipY("FLIP_Y");
1d9e7bed 60
63ed9c6b 61ClassImp(AliMpTriggerReader)
62
1d9e7bed 63//_____________________________________________________________________________
64AliMpTriggerReader::AliMpTriggerReader() : TObject()
65{
66 //
67 // Default ctor.
68 //
69}
70
71//_____________________________________________________________________________
72AliMpTriggerReader::~AliMpTriggerReader()
73{
74 //
75 // Dtor.
76 //
77 fgPCBMap.Delete();
78 fgLocalBoardMap.Delete();
79}
80
81//_____________________________________________________________________________
82AliMpSlat*
83AliMpTriggerReader::BuildSlat(const char* slatName,
84 AliMpPlaneType planeType,
85 const TList& lines,
86 Double_t scale)
87{
85fec35d 88 // Construct a slat from the list of lines, taking into account
89 // the scale factor
90
1d9e7bed 91 AliMpSlat* slat = new AliMpSlat(slatName, planeType);
92
93 TIter it(&lines);
94 TObjString* osline;
95 while ( ( osline = (TObjString*)it.Next() ) )
96 {
97 // note that at this stage lines should not be empty.
98 TString sline(osline->String());
99
100 TObjArray* tokens = sline.Tokenize(' ');
101
102 TString& keyword = ((TObjString*)tokens->At(0))->String();
103
85fec35d 104 if ( keyword == fgkKeywordPcb )
1d9e7bed 105 {
106 if ( tokens->GetEntriesFast() != 3 )
107 {
108 AliErrorClass(Form("Syntax error : expecting PCB type localboard-list"
109 " in following line:\n%s",sline.Data()));
110 delete slat;
111 delete tokens;
112 return 0;
113 }
114 TString pcbName = ((TObjString*)tokens->At(1))->String();
115
116 TObjArray* localBoardList = ((TObjString*)tokens->At(2))->String().Tokenize(',');
117
118 if ( scale != 1.0 )
119 {
120 std::ostringstream s;
121 s << pcbName.Data() << "x" << scale;
122 pcbName = s.str().c_str();
123 }
124
125 AliMpPCB* pcbType = PCB(pcbName.Data());
126 if (!pcbType)
127 {
128 AliErrorClass(Form("Cannot read pcbType=%s",pcbName.Data()));
129 delete slat;
130 return 0;
131 }
132
133 TArrayI allLocalBoards;
134
135 for ( Int_t ilb = 0; ilb < localBoardList->GetEntriesFast(); ++ilb)
136 {
137 TArrayI localBoardNumbers;
138 TString& localBoards = ((TObjString*)localBoardList->At(ilb))->String();
139 Ssiz_t pos = localBoards.First('-');
140 if ( pos < 0 )
141 {
142 pos = localBoards.Length();
143 }
144 AliMpHelper::DecodeName(localBoards(pos-1,localBoards.Length()-pos+1).Data(),
145 ';',localBoardNumbers);
146 for ( int i = 0; i < localBoardNumbers.GetSize(); ++i )
147 {
148 std::ostringstream name;
149 name << localBoards(0,pos-1) << localBoardNumbers[i];
150 AliDebugClass(3,name.str().c_str());
151 localBoardNumbers[i] = LocalBoardNumber(name.str().c_str());
152 AliDebugClass(3,Form("LOCALBOARDNUMBER %d\n",localBoardNumbers[i]));
153 allLocalBoards.Set(allLocalBoards.GetSize()+1);
154 allLocalBoards[allLocalBoards.GetSize()-1] = localBoardNumbers[i];
155 if (localBoardNumbers[i] < 0 )
156 {
157 AliErrorClass(Form("Got a negative local board number in %s ? Unlikely"
158 " to be correct... : %s\n",slatName,name.str().c_str()));
159 }
160 }
161 }
162 delete tokens;
163 delete localBoardList;
164 slat->Add(pcbType,allLocalBoards);
165 }
166 }
167
168 if ( slat->DX()== 0 || slat->DY() == 0 )
169 {
170 AliFatalClass(Form("Slat %s has invalid null size\n",slat->GetID()));
171 }
172 return slat;
173}
174
175//_____________________________________________________________________________
176TString
177AliMpTriggerReader::GetBoardNameFromPCBLine(const TString& s)
178{
85fec35d 179 // Decode the string to get the board name
1d9e7bed 180 TString boardName;
181
182 TObjArray* tokens = s.Tokenize(' ');
183
184 TString& keyword = ((TObjString*)tokens->At(0))->String();
185
85fec35d 186 if ( keyword == fgkKeywordPcb &&
1d9e7bed 187 tokens->GetEntriesFast() == 3 )
188 {
189 boardName = ((TObjString*)tokens->At(2))->String();
190 }
191
192 delete tokens;
193
194 return boardName;
195}
196
197//_____________________________________________________________________________
198void
199AliMpTriggerReader::FlipLines(TList& lines, Bool_t flipX, Bool_t flipY,
200 Int_t srcLine, Int_t destLine)
201{
202 //
203 // Change the local board names contained in lines,
204 // to go from right to left, and/or
205 // from top to bottom
206 //
207
85fec35d 208
1d9e7bed 209 if ( flipX )
210 {
85fec35d 211 // Simply swaps R(ight) and L(eft) in the first character of
212 // local board names
1d9e7bed 213
214 TObjString* oline;
215 TIter it(&lines);
216 while ( ( oline = (TObjString*)it.Next() ) )
217 {
218 TString& s = oline->String();
219 if ( s.Contains("RC") )
220 {
221 // Change right to left
222 s.ReplaceAll("RC","LC");
223 }
224 else if ( s.Contains("LC") )
225 {
226 // Change left to right
227 s.ReplaceAll("LC","RC");
228 }
229 }
230 }
231
1d9e7bed 232 if ( flipY )
233 {
234 // Change line number, according to parameters srcLine and destLine
235 // Note that because of road opening (for planes 3 and 4 at least),
236 // we loop for srcLine +-1
237 //
238 for ( Int_t line = -1; line <=1; ++line )
239 {
240 std::ostringstream src,dest;
241 src << "L" << srcLine+line;
242 dest << "L" << destLine-line;
243 if ( src.str() == dest.str() ) continue;
244
245 for ( Int_t i = 0; i < lines.GetSize(); ++i )
246 {
247 TObjString* oline = (TObjString*)lines.At(i);
248
249 TString& s = oline->String();
250
85fec35d 251 if ( !s.Contains(fgkKeywordPcb) )
1d9e7bed 252 {
253 // Only consider PCB lines.
254 continue;
255 }
256
257 if ( s.Contains(src.str().c_str()) )
258 {
259 AliDebugClass(4,Form("Replacing %s by %s in %s\n",
260 src.str().c_str(),dest.str().c_str(),s.Data()));
261
262 s.ReplaceAll(src.str().c_str(),dest.str().c_str());
263
264 AliDebugClass(4,s.Data());
265
266 TString boardName(GetBoardNameFromPCBLine(s));
267
268 if ( line )
269 {
270 // We must also change board numbers, with the tricky
271 // thing that up and down must be swapped...
272 // Up can only be 1 card so it must be B1
273 // Down must be the uppper card of the line before, so
274 // the biggest possible board number for this Line,Column
275
276 if (line>0)
277 {
278 // force to B1
279 AliDebugClass(4,Form("Forcing B1 in %s\n",s.Data()));
280 s.ReplaceAll(boardName(boardName.Length()-2,2),"B1");
281 AliDebugClass(4,s.Data());
282 }
283 else
284 {
285 // find the largest valid board number
286 for ( int b = 4; b>=1; --b )
287 {
288 std::ostringstream bs;
289 bs << boardName(0,boardName.Length()-1) << b;
290 if ( LocalBoardNumber(bs.str().c_str()) >= 0 )
291 {
292 AliDebugClass(4,Form("Replacing %s by %s in %s\n",
293 boardName(boardName.Length()-2,2).Data(),
294 Form("B%d",b),
295 s.Data()));
296 s.ReplaceAll(boardName(boardName.Length()-2,2),
297 Form("B%d",b));
298 AliDebugClass(4,s);
299 break;
300 }
301 }
302 }
303 // Check that the replacement we did is ok. If not,
304 // skip the line.
305 Int_t lbn = LocalBoardNumber(GetBoardNameFromPCBLine(s));
306 if ( lbn < 0 )
307 {
308 AliDebugClass(4,Form("Removing line %s\n",s.Data()));
309 lines.Remove(oline);
310 }
311
312 } // if (line)
313 }
314 }
315 }
316 }
1d9e7bed 317}
318
319//___________________________________________________________________________
320Int_t
321AliMpTriggerReader::IsLayerLine(const TString& sline)
322{
85fec35d 323 // Whether sline contains LAYER keyword
324
325 if ( sline.BeginsWith(fgkKeywordLayer) )
1d9e7bed 326 {
327 return 1;
328 }
329 else
330 {
331 return 0;
332 }
333}
334
335//___________________________________________________________________________
336Int_t
337AliMpTriggerReader::DecodeFlipLine(const TString& sline,
338 TString& slatType2,
339 Bool_t& flipX, Bool_t& flipY)
340{
85fec35d 341 // Decode a line containing FLIP_X and/or FLIP_Y keywords
342
1d9e7bed 343 Ssiz_t blankPos = sline.First(' ');
344 if ( blankPos < 0 ) return 0;
345
346 TString keyword(sline(0,blankPos));
347
85fec35d 348 if ( keyword == fgkKeywordFlipX )
1d9e7bed 349 {
350 flipX = kTRUE;
85fec35d 351 } else if ( keyword == fgkKeywordFlipY )
1d9e7bed 352 {
353 flipY = kTRUE;
354 }
355 else
356 {
357 return 0;
358 }
359
360 slatType2 = sline(blankPos+1,sline.Length()-blankPos-1);
361 return 1;
362}
363
364//___________________________________________________________________________
365Int_t
366AliMpTriggerReader::DecodeScaleLine(const TString& sline,
367 Double_t& scale, TString& slatType)
368{
85fec35d 369 // Decode sline containing SCALE keyword
370
371 if ( sline(0,fgkKeywordScale.Length()) == fgkKeywordScale )
1d9e7bed 372 {
85fec35d 373 TString tmp(sline(fgkKeywordScale.Length()+1,
374 sline.Length()-fgkKeywordScale.Length()-1));
1d9e7bed 375 Ssiz_t blankPos = tmp.First(' ');
376 if ( blankPos < 0 )
377 {
378 AliErrorClass(Form("Syntax error in slat file, should get a slatType after "
379 " SCALE keyword : %s\n",tmp.Data()));
380 return -1;
381 }
382 else
383 {
384 slatType = tmp(0,blankPos);
385 scale = TString(tmp(blankPos+1,tmp.Length()-blankPos-1)).Atof();
386 return 1;
387 }
388 }
389 scale = 1.0;
390 return 0;
391}
392
393//_____________________________________________________________________________
394Int_t
395AliMpTriggerReader::GetLine(const TString& slatType)
396{
397 //
398 // Assuming slatType is a 4 character string of the form XSLN
399 // where X=1,2,3 or 4
400 // S = R or L
401 // N is the line number
402 // returns N
403 if ( isdigit(slatType[0]) &&
404 ( slatType[1] == 'R' || slatType[1] == 'L' ) &&
405 slatType[2] == 'L' )
406 {
407 return atoi(slatType(3,1).Data());
408 }
409 return -1;
410}
411
412//_____________________________________________________________________________
413int
414AliMpTriggerReader::LocalBoardNumber(const char* localBoardName)
415{
85fec35d 416 // From local board name to local board number
417
1d9e7bed 418 if ( !fgLocalBoardMap.GetSize() )
419 {
420 ReadLocalBoardMapping();
421 }
422
423 TPair* pair = (TPair*)fgLocalBoardMap.FindObject(localBoardName);
424
425 if (pair)
426 {
427 return atoi(((TObjString*)pair->Value())->String().Data());
428 }
429 return -1;
430}
431
432//_____________________________________________________________________________
433AliMpPCB*
434AliMpTriggerReader::PCB(const char* pcbType)
435{
436 //
437 // Get access to an AliMpPCB object, given its type (e.g. N1, SB2, etc...)
438 //
439 // Note that the returned object is either a new one (read from file) or a
440 // reused one if it is already present in the internal map.
441 //
442
443 TPair* pair = (TPair*)fgPCBMap.FindObject(pcbType);
444 if ( pair )
445 {
446 AliDebugClass(1,Form("Getting pcb %s from internal map",pcbType));
447 return (AliMpPCB*)pair->Value();
448 }
449 else
450 {
451 AliDebugClass(1,Form("Reading pcb %s from file",pcbType));
452 return ReadPCB(pcbType);
453 }
454}
455
456//_____________________________________________________________________________
457void
458AliMpTriggerReader::ReadLines(const char* slatType,
459 AliMpPlaneType planeType,
460 TList& lines,
461 Double_t& scale,
462 Bool_t& flipX, Bool_t& flipY,
463 Int_t& srcLine, Int_t& destLine)
464{
85fec35d 465 //
466 // Reads in lines from file for a given slat
467 // Returns the list of lines (lines), together with some global
468 // information as the scale, whether to flip the lines, etc...
469 //
1d9e7bed 470 AliDebugClass(1,Form("SlatType %s Scale %e FlipX %d FlipY %d srcLine %d"
471 " destLine %d\n",slatType,scale,flipX,flipY,
472 srcLine,destLine));
473
474 TString filename(AliMpFiles::SlatFilePath(kStationTrigger,slatType,
475 planeType).Data());
476 std::ifstream in(filename.Data());
477 if (!in.good())
478 {
479 AliErrorClass(Form("Cannot read slat from %s",filename.Data()));
480 }
481
482 char line[80];
483
484 while ( in.getline(line,80) )
485 {
486 TString sline(AliMpHelper::Normalize(line));
487
488 if ( sline.Length() == 0 || sline[0] == '#' ) continue;
489
490 Bool_t isKeywordThere =
85fec35d 491 sline.Contains(fgkKeywordPcb) ||
492 sline.Contains(fgkKeywordLayer) ||
493 sline.Contains(fgkKeywordScale) ||
494 sline.Contains(fgkKeywordFlipX) ||
495 sline.Contains(fgkKeywordFlipY);
1d9e7bed 496
497 if ( !isKeywordThere )
498 {
499 AliErrorClass(Form("Got a line with no keyword : %s."
500 "That's not valid\n",line));
501 continue;
502 }
503
504 Double_t scale2;
505 TString slatType2;
506
507 Int_t isScaleLine = DecodeScaleLine(sline,scale2,slatType2);
508
509 scale *= scale2;
510
511 if ( isScaleLine < 0 )
512 {
85fec35d 513 AliFatalClass(Form("Syntax error near %s keyword\n",fgkKeywordScale.Data()));
1d9e7bed 514 }
515 else if ( isScaleLine > 0 && slatType2 != slatType )
516 {
517 ReadLines(slatType2.Data(),planeType,lines,scale,flipX,flipY,srcLine,destLine);
518 }
519 else
520 {
521 Bool_t fx(kFALSE);
522 Bool_t fy(kFALSE);
523 Int_t isFlipLine = DecodeFlipLine(sline,slatType2,fx,fy);
524 if ( isFlipLine )
525 {
526 if (fy)
527 {
528 srcLine = GetLine(slatType2);
529 destLine = GetLine(slatType);
530 }
531 flipX |= fx;
532 flipY |= fy;
533 ReadLines(slatType2.Data(),planeType,lines,scale,flipX,flipY,srcLine,destLine);
534 }
535 else
536 {
537 lines.Add(new TObjString(sline.Data()));
538 }
539 }
540 }
541
542 in.close();
543}
544
545//_____________________________________________________________________________
546void
547AliMpTriggerReader::ReadLocalBoardMapping()
548{
85fec35d 549 // Reads the file that contains the mapping local board name <-> number
550
1d9e7bed 551 TString filename(AliMpFiles::LocalTriggerBoardMapping());
552
553 AliDebugClass(1,Form("Reading from %s\n",filename.Data()));
554
555 fgLocalBoardMap.Delete();
556
557 ifstream in(filename.Data());
558 if (!in.good())
559 {
560 AliErrorClass(Form("Cannot read file %s\n",filename.Data()));
561 }
562 else
563 {
564 char line[80];
565
566 while ( in.getline(line,80) )
567 {
568 if ( line[0] == '#' ) continue;
569
570 TString sline(line);
9b80a514 571 if ( sline.Contains("Board") )
572 {
573 TObjArray* tokens = sline.Tokenize(' ');
574 TString& number = ((TObjString*)(tokens->At(1)))->String();
575 Int_t n = atoi(number.Data());
576 if ( n == 0 ) continue;
577 TString& name = ((TObjString*)(tokens->At(4)))->String();
578 fgLocalBoardMap.Add(new TObjString(name), new TObjString(number));
579 AliDebugClass(10,Form("Board %s has number %s\n",name.Data(),number.Data()));
580 delete tokens;
581 }
1d9e7bed 582 }
583 }
584 in.close();
585}
586
587//_____________________________________________________________________________
588AliMpPCB*
589AliMpTriggerReader::ReadPCB(const char* pcbType)
590{
591 //
592 // Create a new AliMpPCB object, by reading it from file.
593 //
594
595 AliDebugClass(1,Form("pcbType=%s\n",pcbType));
596
597 TString pcbName(pcbType);
598
599 Ssiz_t pos = pcbName.First('x');
600
601 Double_t scale = 1.0;
602
603 if ( pos > 0 )
604 {
605 scale = TString(pcbName(pos+1,pcbName.Length()-pos-1)).Atof();
606 pcbName = pcbName(0,pos);
607 }
608
609 std::ifstream in(AliMpFiles::SlatPCBFilePath(kStationTrigger,pcbName).Data());
610 if (!in.good())
611 {
612 AliErrorClass(Form("Cannot open file for PCB %s",pcbName.Data()));
613 return 0;
614 }
615
616 AliMpMotifReader reader(kStationTrigger,kNonBendingPlane);
617 // note that the nonbending
618 // parameter is of no use for trigger, as far as reading motif is
619 // concerned, as all motifs are supposed to be in the same directory
620 // (as they are shared by bending/non-bending planes).
621
622 char line[80];
623
84aac932 624 const TString kSizeKeyword("SIZES");
625 const TString kMotifKeyword("MOTIF");
626 const TString kMotifSpecialKeyword("SPECIAL_MOTIF");
1d9e7bed 627
628 AliMpPCB* pcb = 0;
629
630 while ( in.getline(line,80) )
631 {
632 if ( line[0] == '#' ) continue;
633
634 TString sline(line);
635
84aac932 636 if ( sline(0,kSizeKeyword.Length()) == kSizeKeyword )
1d9e7bed 637 {
84aac932 638 std::istringstream sin(sline(kSizeKeyword.Length(),
639 sline.Length()-kSizeKeyword.Length()-1).Data());
1d9e7bed 640 float padSizeX = 0.0;
641 float padSizeY = 0.0;
642 float pcbSizeX = 0.0;
643 float pcbSizeY = 0.0;
644 sin >> padSizeX >> padSizeY >> pcbSizeX >> pcbSizeY;
645 assert(pcb==0);
646 pcb = new AliMpPCB(pcbType,padSizeX*scale,padSizeY*scale,
647 pcbSizeX*scale,pcbSizeY*scale);
648 }
649
84aac932 650 if ( sline(0,kMotifSpecialKeyword.Length()) == kMotifSpecialKeyword )
1d9e7bed 651 {
84aac932 652 std::istringstream sin(sline(kMotifSpecialKeyword.Length(),
653 sline.Length()-kMotifSpecialKeyword.Length()).Data());
1d9e7bed 654 TString sMotifSpecial;
655 TString sMotifType;
656 sin >> sMotifSpecial >> sMotifType;
657
658 AliMpMotifType* motifType = reader.BuildMotifType(sMotifType);
659 AliMpMotifSpecial* specialMotif =
660 reader.BuildMotifSpecial(sMotifSpecial,motifType,scale);
661
662 assert(pcb==0);
663 pcb = new AliMpPCB(pcbType,specialMotif);
664 }
665
84aac932 666 if ( sline(0,kMotifKeyword.Length()) == kMotifKeyword )
1d9e7bed 667 {
84aac932 668 std::istringstream sin(sline(kMotifKeyword.Length(),
669 sline.Length()-kMotifKeyword.Length()).Data());
1d9e7bed 670 TString sMotifType;
671 int ix;
672 int iy;
673 sin >> sMotifType >> ix >> iy;
674
675 AliMpMotifType* motifType = reader.BuildMotifType(sMotifType.Data());
676
677 assert(pcb!=0);
678 pcb->Add(motifType,ix,iy);
679 }
680 }
681
682 in.close();
683
684 fgPCBMap.Add(new TObjString(pcbType),pcb);
685 return pcb;
686}
687
688//_____________________________________________________________________________
689AliMpTrigger*
690AliMpTriggerReader::ReadSlat(const char* slatType, AliMpPlaneType planeType)
691{
692 //
693 // Create a new AliMpTrigger object, by reading it from file.
694 //
695
696 Double_t scale = 1.0;
697 Bool_t flipX = kFALSE;
698 Bool_t flipY = kFALSE;
699 TList lines;
700 Int_t srcLine(-1);
701 Int_t destLine(-1);
702
703 // Read the file and its include (if any) and store the result
704 // in a TObjArray of TObjStrings.
705 ReadLines(slatType,planeType,lines,scale,flipX,flipY,srcLine,destLine);
706
707 // Here some more sanity checks could be done.
708 // For the moment we only insure that the first line contains
709 // a layer keyword.
710 TString& firstLine = ((TObjString*)lines.First())->String();
711 if ( !IsLayerLine(firstLine) )
712 {
713 std::ostringstream s;
85fec35d 714 s << fgkKeywordLayer;
1d9e7bed 715 lines.AddFirst(new TObjString(s.str().c_str()));
716 }
717
718 AliDebugClass(2,Form("Scale=%g\n",scale));
719
720 FlipLines(lines,flipX,flipY,srcLine,destLine);
721
722 // Now splits the lines in packets corresponding to different layers
723 // (if any), and create sub-slats.
724 TObjArray layers;
725 Int_t ilayer(-1);
726 TIter it(&lines);
727 TObjString* osline;
728
729 while ( ( osline = (TObjString*)it.Next() ) )
730 {
731 TString& s = osline->String();
732 if ( IsLayerLine(s) )
733 {
734 layers.Add(new TList);
735 ++ilayer;
736 }
737 else
738 {
739 ((TList*)layers.At(ilayer))->Add(new TObjString(s));
740 }
741 }
742
743 AliDebugClass(2,Form("nlayers=%d\n",layers.GetEntriesFast()));
744
745 AliMpTrigger* triggerSlat = new AliMpTrigger(slatType, planeType);
746
747 for ( Int_t ilayer = 0; ilayer < layers.GetEntriesFast(); ++ilayer )
748 {
749 TList& lines = *((TList*)layers.At(ilayer));
750 std::ostringstream slatName;
751 slatName << slatType << "-LAYER" << ilayer;
752 AliMpSlat* slat = BuildSlat(slatName.str().c_str(),planeType,lines,scale);
753 if ( slat )
754 {
755 triggerSlat->AdoptLayer(slat);
756 }
757 else
758 {
759 AliErrorClass(Form("Could not read %s\n",slatName.str().c_str()));
760 delete triggerSlat;
761 return 0;
762 }
763 }
764
765 layers.SetOwner(kTRUE);
766 layers.Delete();
767
768 return triggerSlat;
769}
770
771//_____________________________________________________________________________
772void
773AliMpTriggerReader::Reset()
774{
85fec35d 775 // Resets the PCB internal map
1d9e7bed 776 fgPCBMap.Delete();
777}