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 purpose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
17 // $MpId: AliMpMotifReader.cxx,v 1.10 2006/05/24 13:58:41 ivana Exp $
20 //-----------------------------------------------------------------------------
21 // Class AliMpMotifReader
22 // -------------------
23 // Class that takes care of reading the sector data.
24 // Included in AliRoot: 2003/05/02
25 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
26 //-----------------------------------------------------------------------------
28 #include "AliMpFiles.h"
29 #include "AliMpDataStreams.h"
30 #include "AliMpMotifReader.h"
31 #include "AliMpMotifMap.h"
32 #include "AliMpMotif.h"
33 #include "AliMpMotifSpecial.h"
34 #include "AliMpMotifType.h"
35 #include "AliMpConnection.h"
36 #include "AliMpIntPair.h"
42 #include <Riostream.h>
43 #include <Rstrstream.h>
45 #if !defined(__HP_aCC) && !defined(__alpha)
50 ClassImp(AliMpMotifReader)
53 //_____________________________________________________________________________
54 AliMpMotifReader::AliMpMotifReader(const AliMpDataStreams& dataStreams,
55 AliMp::StationType station,
56 AliMp::PlaneType plane)
58 fDataStreams(dataStreams),
59 fStationType(station),
62 /// Standard constructor
65 //_____________________________________________________________________________
66 AliMpMotifReader::~AliMpMotifReader()
75 //_____________________________________________________________________________
76 AliMpMotifType* AliMpMotifReader::BuildMotifType(const TString& motifTypeId)
78 /// Read the streams describing a motif in the "$MINSTALL/data" directory
79 /// and fill the AliMpMotifType structure with.
80 /// The streams mentioned are named padPos<maskName>.dat
81 /// and connect<maskName>.dat
87 CreateDataStream(AliMpFiles::PadPosFilePath(
88 fStationType,fPlaneType, motifTypeId));
89 istream& bergToGCStream
91 CreateDataStream(AliMpFiles::BergToGCFilePath(fStationType));
93 istream& motifTypeStream
95 CreateDataStream(AliMpFiles::MotifFilePath(
96 fStationType, fPlaneType, motifTypeId));
98 AliMpMotifType* motifType = new AliMpMotifType(motifTypeId);
100 PadMapType positions;
104 padPosStream.getline(line,255);
105 if (!padPosStream) break;
107 #if defined (__HP_aCC) || (__alpha)
111 istringstream strline(line);
116 if ((key=="#") || (key=="") ) continue;
121 positions[key].first=i;
122 positions[key].second=j;
125 positions.Add( AliMpExMap::GetIndex(key),
126 AliMpExMap::GetIndex(AliMpIntPair(i,j)) );
128 } while (!padPosStream.eof());
130 const Int_t knbergpins =
131 (fStationType == AliMp::kStation1 || fStationType == AliMp::kStation2 ) ? 80 : 100;
132 // Station1 & 2 Bergstak connectors have 80 pins, while for stations
133 // 3, 4 and 5 they have 100 pins.
134 Int_t gassiChannel[100];
138 bergToGCStream>>bergNum>>gcStr;
139 if (!bergToGCStream.good()) break;
140 if (gcStr=="GND") continue;
141 if (bergNum>knbergpins) {
142 Fatal("BuildMotifType","Berg number > 80 ...");
145 gassiChannel[bergNum-1]= atoi(gcStr);
153 Int_t ix,iy,numBerg,numKapton,padNum,gassiNum;
155 TString lineStr,token;
156 lineStr.ReadLine(motifTypeStream);
157 if (!motifTypeStream.good()) break;
158 #if defined (__HP_aCC) || (__alpha)
160 tokenList << lineStr.Data();
162 istringstream tokenList(lineStr.Data());
165 token.ReadToken(tokenList);
166 if (!tokenList.good()) continue; // column is missing...
167 if ( (token.Length()>0) && (token[0]=='#') ) continue; // this is a comment line
169 numBerg = atoi(token.Data());
171 AliWarning(Form("Berg number %s invalid",token.Data()));
175 token.ReadToken(tokenList);
176 if (!tokenList.good()) continue; // column is missing...
177 numKapton = atoi(token.Data());
178 if (numKapton==0) continue;
181 token.ReadToken(tokenList);
182 if (!tokenList.good()) continue; // column is missing...
183 if (token=="GND") continue;
184 string padName = token.Data();
185 padNum = motifType->PadNum(token);
187 token.ReadToken(tokenList);
188 if (token.IsNull() ) continue; // column is missing...
189 // if (token[0]!='E') {
190 // cerr<<"Problem : gassinumber isn't begining with E:"<<token<<endl;
193 // gassiNum = atoi(token.Data() +1 )-1;
195 if ( (numBerg<1) || (numBerg>knbergpins) ) {
196 AliWarning(Form("Berg number %d outside range (1..%d)",numBerg,knbergpins));
200 gassiNum = gassiChannel[numBerg-1];
203 PadMapTypeIterator iter = positions.find(padName);
204 if (iter==positions.end()) {
206 << "Problem: Pad number " << padNum
207 << " for motif type " << motifTypeId.Data()
208 << " found in the motifType stream, but not in the padPos stream" << endl;
212 ix= iter->second.first;
213 iy= iter->second.second;
217 Long_t value = positions.GetValue(AliMpExMap::GetIndex(padName));
220 << "Problem: Pad number " << padNum
221 << " for motif type " << motifTypeId.Data()
222 << " found in the motifType stream, but not in the padPos stream" << endl;
226 ix = AliMpExMap::GetPair(value).GetFirst();
227 iy = AliMpExMap::GetPair(value).GetSecond();
231 AliMpConnection* connection
232 = new AliMpConnection(padNum,numBerg,numKapton,gassiNum, AliMpIntPair(ix,iy));
234 motifType->AddConnection(AliMpIntPair(ix,iy),connection);
236 if (ix>=nofPadsX) nofPadsX=ix+1;
237 if (iy>=nofPadsY) nofPadsY=iy+1;
239 } while (!motifTypeStream.eof());
242 motifType->SetNofPads(nofPadsX, nofPadsY);
244 delete &padPosStream;
245 delete &bergToGCStream;
246 delete &motifTypeStream;
251 //_____________________________________________________________________________
253 AliMpMotifReader::BuildMotifSpecial(const TString& motifID,
254 AliMpMotifType* motifType,
257 /// Build a special motif by reading the file motifSpecial<motifId>.dat
258 /// in the data directory
264 CreateDataStream(AliMpFiles::MotifSpecialFilePath(
265 fStationType,fPlaneType, motifID));
267 TString id = MotifSpecialName(motifID,scale);
269 AliMpMotifSpecial* res = new AliMpMotifSpecial(id,motifType);
275 res->SetPadDimensions(AliMpIntPair(i,j),TVector2(x*scale/2.,y*scale/2.));
278 res->CalculateDimensions();
285 //_____________________________________________________________________________
287 AliMpMotifReader::MotifSpecialName(const TString& motifID, Double_t scale)
289 /// Build the name taking into the scale, if not 1.0
294 id = Form("%s-%e",motifID.Data(),scale);