37 #include "Riostream.h"
40 #include "TObjString.h"
68 static const TString kKeywordLayer(
"LAYER");
76 static const TString kKeywordScale(
"SCALE");
84 static const TString kKeywordPcb(
"PCB");
92 static const TString kKeywordFlipX(
"FLIP_X");
100 static const TString kKeywordFlipY(
"FLIP_Y");
101 return kKeywordFlipY;
132 const char* slatName,
140 AliDebug(1,Form(
"slat %s %s scale %e",
151 while ( ( osline = (TObjString*)it.Next() ) )
154 TString sline(osline->String());
158 TString& keyword = ((TObjString*)tokens->At(0))->String();
162 if ( tokens->GetEntriesFast() != 3 )
164 AliErrorClass(Form(
"Syntax error : expecting PCB type localboard-list"
165 " in following line:\n%s",sline.Data()));
170 TString pcbName = ((TObjString*)tokens->At(1))->String();
172 TObjArray* localBoardList = ((TObjString*)tokens->At(2))->String().Tokenize(
',');
176 std::ostringstream s;
177 s << pcbName.Data() <<
"x" <<
scale;
178 pcbName = s.str().c_str();
184 AliErrorClass(Form(
"Cannot read pcbType=%s",pcbName.Data()));
190 TArrayI allLocalBoards;
192 for ( Int_t ilb = 0; ilb < localBoardList->GetEntriesFast(); ++ilb)
194 TArrayI localBoardNumbers;
195 TString& localBoards = ((TObjString*)localBoardList->At(ilb))->String();
196 Ssiz_t pos = localBoards.First(
'-');
199 pos = localBoards.Length();
202 ';',localBoardNumbers);
203 for (
int i = 0; i < localBoardNumbers.GetSize(); ++i )
205 std::ostringstream name;
206 name << localBoards(0,pos-1) << localBoardNumbers[i];
207 AliDebugClass(3,name.str().c_str());
209 AliDebugClass(3,Form(
"LOCALBOARDNUMBER %d\n",localBoardNumbers[i]));
210 allLocalBoards.Set(allLocalBoards.GetSize()+1);
211 allLocalBoards[allLocalBoards.GetSize()-1] = localBoardNumbers[i];
212 if (localBoardNumbers[i] < 0 )
214 AliErrorClass(Form(
"Got a negative local board number in %s ? Unlikely"
215 " to be correct... : %s\n",slatName,name.str().c_str()));
219 AliDebug(3,
"Deleting tokens");
221 AliDebug(3,
"Deleting localBoardList");
222 delete localBoardList;
223 AliDebug(3,
"Adding pcb to slat");
224 slat->
Add(*pcbType,allLocalBoards);
225 AliDebug(3,Form(
"Deleting pcbType=%p %s",pcbType,pcbName.Data()));
230 if ( slat->
DX()== 0 || slat->
DY() == 0 )
232 AliFatalClass(Form(
"Slat %s has invalid null size\n",slat->
GetID()));
246 TString& keyword = ((TObjString*)tokens->At(0))->String();
249 tokens->GetEntriesFast() == 3 )
251 boardName = ((TObjString*)tokens->At(2))->String();
262 TList& lines, Bool_t flipX, Bool_t flipY,
263 Int_t srcLine, Int_t destLine)
279 while ( ( oline = (TObjString*)it.Next() ) )
281 TString& s = oline->String();
282 if ( s.Contains(
"RC") )
285 s.ReplaceAll(
"RC",
"LC");
287 else if ( s.Contains(
"LC") )
290 s.ReplaceAll(
"LC",
"RC");
301 for ( Int_t line = -1; line <=1; ++line )
303 std::ostringstream src,dest;
304 src <<
"L" << srcLine+line;
305 dest <<
"L" << destLine-line;
306 if ( src.str() == dest.str() )
continue;
308 for ( Int_t i = 0; i < lines.GetSize(); ++i )
310 TObjString* oline = (TObjString*)lines.At(i);
312 TString& s = oline->String();
320 if ( s.Contains(src.str().c_str()) )
322 AliDebugClass(4,Form(
"Replacing %s by %s in %s\n",
323 src.str().c_str(),dest.str().c_str(),s.Data()));
325 s.ReplaceAll(src.str().c_str(),dest.str().c_str());
327 AliDebugClass(4,s.Data());
342 AliDebugClass(4,Form(
"Forcing B1 in %s\n",s.Data()));
343 s.ReplaceAll(boardName(boardName.Length()-2,2),
"B1");
344 AliDebugClass(4,s.Data());
349 for (
int b = 4; b>=1; --b )
351 std::ostringstream bs;
352 bs << boardName(0,boardName.Length()-1) << b;
355 AliDebugClass(4,Form(
"Replacing %s by %s in %s\n",
356 boardName(boardName.Length()-2,2).Data(),
359 s.ReplaceAll(boardName(boardName.Length()-2,2),
371 AliDebugClass(4,Form(
"Removing line %s\n",s.Data()));
402 Bool_t& flipX, Bool_t& flipY)
406 Ssiz_t blankPos = sline.First(
' ');
407 if ( blankPos < 0 )
return 0;
409 TString keyword(sline(0,blankPos));
423 slatType2 = sline(blankPos+1,sline.Length()-blankPos-1);
430 Double_t&
scale, TString& slatType)
438 Ssiz_t blankPos = tmp.First(
' ');
441 AliErrorClass(Form(
"Syntax error in slat file, should get a slatType after "
442 " SCALE keyword : %s\n",tmp.Data()));
447 slatType = tmp(0,blankPos);
448 scale = TString(tmp(blankPos+1,tmp.Length()-blankPos-1)).Atof();
467 if ( isdigit(slatType[0]) &&
468 ( slatType[1] ==
'R' || slatType[1] ==
'L' ) &&
471 return atoi(slatType(3,1).Data());
479 const char* localBoardName)
492 return atoi(((TObjString*)pair->Value())->String().Data());
500 const char* slatType,
504 Bool_t& flipX, Bool_t& flipY,
505 Int_t& srcLine, Int_t& destLine)
512 AliDebugClass(2,Form(
"SlatType %s Scale %e FlipX %d FlipY %d srcLine %d"
513 " destLine %d\n",slatType,scale,flipX,flipY,
523 while ( in.getline(line,80) )
527 if ( sline.Length() == 0 || sline[0] ==
'#' )
continue;
529 Bool_t isKeywordThere =
536 if ( !isKeywordThere )
538 AliErrorClass(Form(
"Got a line with no keyword : %s."
539 "That's not valid\n",line));
550 if ( isScaleLine < 0 )
552 AliFatalClass(Form(
"Syntax error near %s keyword\n",
GetKeywordScale().Data()));
554 else if ( isScaleLine > 0 && slatType2 != slatType )
557 slatType2.Data(),planeType,lines,
scale,flipX,flipY,srcLine,destLine);
574 slatType2.Data(),planeType,lines,
scale,flipX,flipY,srcLine,destLine);
578 lines.Add(
new TObjString(sline.Data()));
601 Char_t localBoardName[20];
602 Int_t j,localBoardId;
608 for (Int_t i = 0; i < 4; ++i)
609 if (!in.getline(line,80))
continue;
612 if (!in.getline(line,80))
break;
613 sscanf(line,
"%hx",&mask);
616 if (!in.getline(line,80))
break;
617 sscanf(line,
"%d",&nofBoards);
619 for ( Int_t i = 0; i < nofBoards; ++i )
622 if (!in.getline(line,80))
break;
623 sscanf(line,
"%02d %19s %03d %03x", &j, localBoardName, &localBoardId, &switches);
626 fLocalBoardMap.Add(
new TObjString(localBoardName),
new TObjString(Form(
"%d",localBoardId)));
627 AliDebugClass(10,Form(
"Board %s has number %d\n", localBoardName, localBoardId));
630 if (!in.getline(line,80))
break;
631 if (!in.getline(line,80))
break;
648 AliDebugClass(2,Form(
"pcbType=%s\n",pcbType));
650 TString pcbName(pcbType);
652 Ssiz_t pos = pcbName.First(
'x');
654 Double_t
scale = 1.0;
658 scale = TString(pcbName(pos+1,pcbName.Length()-pos-1)).Atof();
659 pcbName = pcbName(0,pos);
675 const TString kSizeKeyword(
"SIZES");
676 const TString kMotifKeyword(
"MOTIF");
677 const TString kMotifSpecialKeyword(
"SPECIAL_MOTIF");
681 while ( in.getline(line,80) )
683 if ( line[0] ==
'#' )
continue;
687 if ( sline(0,kSizeKeyword.Length()) == kSizeKeyword )
689 std::istringstream sin(sline(kSizeKeyword.Length(),
690 sline.Length()-kSizeKeyword.Length()-1).Data());
691 float padSizeX = 0.0;
692 float padSizeY = 0.0;
693 float pcbSizeX = 0.0;
694 float pcbSizeY = 0.0;
695 sin >> padSizeX >> padSizeY >> pcbSizeX >> pcbSizeY;
698 AliError(
"pcb not null as expected");
701 pcbSizeX*scale,pcbSizeY*scale);
704 if ( sline(0,kMotifSpecialKeyword.Length()) == kMotifSpecialKeyword )
706 std::istringstream sin(sline(kMotifSpecialKeyword.Length(),
707 sline.Length()-kMotifSpecialKeyword.Length()).Data());
708 TString sMotifSpecial;
710 sin >> sMotifSpecial >> sMotifType;
718 AliDebug(1,Form(
"Reading motifSpecial %s (%s) from file",
719 sMotifSpecial.Data(),
id.Data()));
723 AliDebug(1,Form(
"Reading motifType %s (%s) from file",
724 sMotifType.Data(),
id.Data()));
730 AliDebug(1,Form(
"Got motifType %s (%s) from motifMap",
731 sMotifType.Data(),
id.Data()));
733 specialMotif = reader.
BuildMotifSpecial(dataStreams,sMotifSpecial,motifType,scale);
738 AliDebug(1,Form(
"Got motifSpecial %s from motifMap",sMotifSpecial.Data()));
742 AliError(
"pcb not null as expected");
744 pcb =
new AliMpPCB(pcbType,specialMotif);
747 if ( sline(0,kMotifKeyword.Length()) == kMotifKeyword )
749 std::istringstream sin(sline(kMotifKeyword.Length(),
750 sline.Length()-kMotifKeyword.Length()).Data());
754 sin >> sMotifType >> ix >> iy;
759 AliDebug(1,Form(
"Reading motifType %s from file",sMotifType.Data()));
765 AliDebug(1,Form(
"Got motifType %s from motifMap",sMotifType.Data()));
770 AliError(
"pcb null");
773 pcb->
Add(motifType,ix,iy);
791 Double_t
scale = 1.0;
792 Bool_t flipX = kFALSE;
793 Bool_t flipY = kFALSE;
795 lines.SetOwner(kTRUE);
802 slatType,planeType,lines,scale,flipX,flipY,srcLine,destLine);
807 TString& firstLine = ((TObjString*)lines.First())->String();
810 std::ostringstream s;
812 lines.AddFirst(
new TObjString(s.str().c_str()));
815 AliDebugClass(2,Form(
"Scale=%g\n",scale));
817 FlipLines(dataStreams,lines,flipX,flipY,srcLine,destLine);
822 layers.SetOwner(kTRUE);
827 while ( ( osline = (TObjString*)it.Next() ) )
829 TString& s = osline->String();
832 TList* list =
new TList;
833 list->SetOwner(kTRUE);
839 ((TList*)layers.At(ilayer))->
Add(
new TObjString(s));
843 AliDebugClass(2,Form(
"nlayers=%d\n",layers.GetEntriesFast()));
847 for ( ilayer = 0; ilayer < layers.GetEntriesFast(); ++ilayer )
849 TList& lines1 = *((TList*)layers.At(ilayer));
850 std::ostringstream slatName;
851 slatName << slatType <<
"-LAYER" << ilayer;
853 slatName.str().c_str(),planeType,lines1,
scale);
859 StdoutToAliError(cout <<
"could not add slat=" << endl;
861 cout <<
"to the triggerSlat=" << endl;
862 triggerSlat->
Print();
864 AliError(
"Slat is=");
865 for ( Int_t i = 0; i < slat->
GetSize(); ++i )
868 AliError(Form(
"ERR pcb %d size %e,%e (unscaled is %e,%e)",
869 i,pcb->
DX()*2,pcb->
DY()*2,
872 AliError(
"TriggerSlat is=");
873 for ( Int_t j = 0; j < triggerSlat->
GetSize(); ++j )
876 AliError(Form(
"Layer %d",j));
877 for ( Int_t i = 0; i < slat1->
GetSize(); ++i )
880 AliError(Form(
"ERR pcb %d size %e,%e (unscaled is %e,%e)",
881 i,pcb->
DX()*2,pcb->
DY()*2,
890 AliErrorClass(Form(
"Could not read %s\n",slatName.str().c_str()));
AliMpPCB * ReadPCB(const AliMpDataStreams &dataStreams, const char *pcbType)
Bool_t AddMotifType(AliMpMotifType *motifType, Bool_t warn=kTRUE)
Read trigger slat ASCII files.
static const TString & GetKeywordFlipX()
A special motif with varying pad dimensions.
static TString Normalize(const char *line)
AliMpMotifSpecial * BuildMotifSpecial(const AliMpDataStreams &dataStreams, const TString &motifID, AliMpMotifType *motifType, Double_t scale=1.0)
void Add(AliMUONVStore &destStore, const AliMUONVStore &srcStore)
void Print(Option_t *option="") const
AliMpTriggerReader(AliMpSlatMotifMap *motifMap)
TString MotifSpecialName(const TString &motifID, Double_t scale)
A PCB for station 3,4 or 5.
void Add(const AliMpPCB &pcbType, const TArrayI &manuList)
AliMpSlat * GetLayer(int layer) const
AliMpSlatMotifMap * fMotifMap
! storage for motifTypes and motifs...
AliMpMotifType * BuildMotifType(const AliMpDataStreams &dataStreams, const TString &motifTypeId)
AliMpSlat * BuildSlat(const AliMpDataStreams &dataStreams, const char *slatName, AliMp::PlaneType planeType, const TList &descriptionLines, Double_t scale=1.0)
A slat (building block of stations 3, 4 and 5)
static const TString & GetKeywordFlipY()
static Int_t NofLocalBoards()
Return number of trigger local boards.
static const TString & GetKeywordScale()
Int_t DecodeFlipLine(const TString &sline, TString &slatType2, Bool_t &flipX, Bool_t &flipY)
A container to keep track of allocated motifs and motifTypes for slats (both St345 and trigger ones)...
void ReadLocalBoardMapping(const AliMpDataStreams &dataStreams)
static TString LocalTriggerBoardMapping()
static TString SlatPCBFilePath(AliMp::StationType stationType, const char *pcbType)
static const TString & GetKeywordLayer()
Bool_t AdoptLayer(AliMpSlat *slat)
void Print(Option_t *option="") const
Int_t DecodeScaleLine(const TString &sline, Double_t &scale, TString &slatType)
void Add(AliMpMotifType *motifType, Int_t ix, Int_t iy)
Int_t GetSize() const
Returns the number of layers.
AliMpPCB * GetPCB(Int_t i) const
Returns the i-th PCB of this slat.
void FlipLines(const AliMpDataStreams &dataStreams, TList &lines, Bool_t flipX, Bool_t flipY, Int_t srcLine, Int_t destLine)
TString PlaneTypeName(AliMp::PlaneType planeType)
Return name for given planeType.
TMap fLocalBoardMap
! map of TObjString to TObjString
const char * GetID() const
virtual ~AliMpTriggerReader()
void Print(Option_t *opt="") const
AliMpVMotif * FindMotif(const TString &id) const
value for all non sector stations
Int_t IsLayerLine(const TString &sline) const
void ReadLines(const AliMpDataStreams &dataStreams, const char *slatType, AliMp::PlaneType planeType, TList &lines, Double_t &scale, Bool_t &flipX, Bool_t &flipY, Int_t &srcLine, Int_t &destLine)
Class that takes care of reading the motifs data.
TString GetBoardNameFromPCBLine(const TString &sline)
AliMpTrigger * ReadSlat(const AliMpDataStreams &dataStreams, const char *slatType, AliMp::PlaneType planeType)
AliMpMotifType * FindMotifType(const TString &id) const
Bool_t AddMotif(AliMpVMotif *motif, Bool_t warn=kTRUE)
static const TString & GetKeywordPcb()
static TString SlatFilePath(AliMp::StationType stationType, const char *slatType, AliMp::PlaneType plane)
int LocalBoardNumber(const AliMpDataStreams &dataStreams, const char *localBoardName)
Int_t GetSize() const
Returns the number of PCBs of this slat.
Class that defines the motif properties.
Int_t GetLine(const TString &slatType)
Mapping data streams provider.
static void DecodeName(const char *manus, char sep, TArrayI &theList)