1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
17 // $MpId: AliMpSt345Reader.cxx,v 1.11 2006/05/24 13:58:50 ivana Exp $
19 #include "AliMpSt345Reader.h"
22 #include "AliMpSlatMotifMap.h"
23 #include "AliMpMotifReader.h"
24 #include "AliMpFiles.h"
25 #include "AliMpDataStreams.h"
26 #include "AliMpMotifType.h"
28 #include "AliMpSlat.h"
29 #include "AliMpMotifPosition.h"
30 #include "AliMpMotif.h"
31 #include "AliMpHelper.h"
32 #include "AliMpConstants.h"
34 #include "Riostream.h"
36 #include "TObjString.h"
42 //-----------------------------------------------------------------------------
43 /// \class AliMpSt345Reader
45 /// Read slat and pcb ASCII files.
47 /// Basically this class provides two methods :
48 /// - AliMpSlat* ReadSlat()
49 /// - AliMpPCB ReadPCB()
51 /// \author Laurent Aphecetche
52 //-----------------------------------------------------------------------------
55 ClassImp(AliMpSt345Reader)
58 //_____________________________________________________________________________
59 AliMpSt345Reader::AliMpSt345Reader(AliMpSlatMotifMap* motifMap)
69 //_____________________________________________________________________________
70 AliMpSt345Reader::~AliMpSt345Reader()
77 //_____________________________________________________________________________
79 AliMpSt345Reader::ReadPCB(const AliMpDataStreams& dataStreams,
83 /// Create a new AliMpPCB object, by reading it from file.
84 /// The returned object must be deleted by the client
88 CreateDataStream(AliMpFiles::SlatPCBFilePath(
89 AliMp::kStation345, pcbType));
91 AliMpMotifReader reader(AliMp::kStation345, AliMq::kNotSt12, AliMp::kNonBendingPlane);
92 // note that the nonbending
93 // parameter is of no use for station345, as far as reading motif is
94 // concerned, as all motifs are supposed to be in the same directory
95 // (as they are shared by bending/non-bending planes).
99 const TString kSizeKeyword("SIZES");
100 const TString kMotifKeyword("MOTIF");
104 while ( in.getline(line,80) )
106 if ( line[0] == '#' ) continue;
110 if ( sline(0,kSizeKeyword.Length()) == kSizeKeyword )
112 std::istringstream sin(sline(kSizeKeyword.Length(),
113 sline.Length()-kSizeKeyword.Length()).Data());
114 double padSizeX = 0.0;
115 double padSizeY = 0.0;
116 double pcbSizeX = 0.0;
117 double pcbSizeY = 0.0;
118 sin >> padSizeX >> padSizeY >> pcbSizeX >> pcbSizeY;
121 AliError("pcb not null as expected");
123 pcb = new AliMpPCB(fMotifMap,pcbType,padSizeX,padSizeY,pcbSizeX,pcbSizeY);
126 if ( sline(0,kMotifKeyword.Length()) == kMotifKeyword )
128 std::istringstream sin(sline(kMotifKeyword.Length(),
129 sline.Length()-kMotifKeyword.Length()).Data());
133 sin >> sMotifType >> ix >> iy;
135 AliMpMotifType* motifType = fMotifMap->FindMotifType(sMotifType);
138 AliDebug(1,Form("Reading motifType %s from file",sMotifType.Data()));
139 motifType = reader.BuildMotifType(dataStreams, sMotifType.Data());
140 fMotifMap->AddMotifType(motifType);
144 AliDebug(1,Form("Got motifType %s from motifMap",sMotifType.Data()));
147 if (pcb) pcb->Add(motifType,ix,iy);
156 //_____________________________________________________________________________
158 AliMpSt345Reader::ReadSlat(const AliMpDataStreams& dataStreams,
159 const char* slatType, AliMp::PlaneType planeType)
162 /// Create a new AliMpSlat object, by reading it from file.
163 /// The returned object must be deleted by the client.
167 CreateDataStream(AliMpFiles::SlatFilePath(
168 AliMp::kStation345, slatType, planeType));
172 const TString kpcbKeyword("PCB");
174 AliMpSlat* slat = new AliMpSlat(slatType, planeType);
176 while ( in.getline(line,80) )
178 if ( line[0] == '#' ) continue;
180 TString sline(AliMpHelper::Normalize(line));
182 if ( sline(0,kpcbKeyword.Length()) == kpcbKeyword )
184 TString tmp(sline(kpcbKeyword.Length()+1,sline.Length()-kpcbKeyword.Length()));
185 Ssiz_t blankPos = tmp.First(' ');
188 AliErrorClass("Syntax error in PCB file, should get a list of "
189 "manu ids after the pcbname");
194 TString pcbName(tmp(0,blankPos));
195 TString manus(tmp(blankPos+1,tmp.Length()-blankPos));
197 AliMpPCB* pcbType = ReadPCB(dataStreams,pcbName.Data());
200 AliErrorClass(Form("Cannot read pcbType=%s",pcbName.Data()));
206 AliMpHelper::DecodeName(manus,';',manuList);
207 if ( manuList.GetSize() != Int_t(pcbType->GetSize()) )
209 AliErrorClass(Form("Wrong number of manu ids for this PCB ("
210 "%s) : %d out of %d",pcbName.Data(),
211 manuList.GetSize(),pcbType->GetSize()));
217 for ( Int_t i = 0; i < manuList.GetSize(); ++i )
219 manuList[i] |= AliMpConstants::ManuMask(planeType);
221 slat->Add(*pcbType,manuList);