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 AliMq::Station12Type station12,
57 AliMp::PlaneType plane)
59 fDataStreams(dataStreams),
60 fStationType(station),
61 fStation12Type(station12),
64 /// Standard constructor
67 //_____________________________________________________________________________
68 AliMpMotifReader::~AliMpMotifReader()
77 //_____________________________________________________________________________
78 AliMpMotifType* AliMpMotifReader::BuildMotifType(const TString& motifTypeId)
80 /// Read the streams describing a motif in the "$MINSTALL/data" directory
81 /// and fill the AliMpMotifType structure with.
82 /// The streams mentioned are named padPos<maskName>.dat
83 /// and connect<maskName>.dat
89 CreateDataStream(AliMpFiles::PadPosFilePath(
90 fStationType, fStation12Type, fPlaneType, motifTypeId));
91 istream& bergToGCStream
93 CreateDataStream(AliMpFiles::BergToGCFilePath(fStationType, fStation12Type));
95 istream& motifTypeStream
97 CreateDataStream(AliMpFiles::MotifFilePath(
98 fStationType, fStation12Type, fPlaneType, motifTypeId));
100 AliMpMotifType* motifType = new AliMpMotifType(motifTypeId);
102 PadMapType positions;
106 padPosStream.getline(line,255);
107 if (!padPosStream) break;
109 #if defined (__HP_aCC) || (__alpha)
113 istringstream strline(line);
118 if ((key=="#") || (key=="") ) continue;
123 positions[key].first=i;
124 positions[key].second=j;
127 positions.Add( AliMpExMap::GetIndex(key),
128 AliMpExMap::GetIndex(AliMpIntPair(i,j)) );
130 } while (!padPosStream.eof());
132 const Int_t knbergpins =
133 (fStationType == AliMp::kStation12 ) ? 80 : 100;
134 // Station1 & 2 Bergstak connectors have 80 pins, while for stations
135 // 3, 4 and 5 they have 100 pins.
136 Int_t gassiChannel[100];
140 bergToGCStream>>bergNum>>gcStr;
141 if (!bergToGCStream.good()) break;
142 if (gcStr=="GND") continue;
143 if (bergNum>knbergpins) {
144 Fatal("BuildMotifType","Berg number > 80 ...");
147 gassiChannel[bergNum-1]= atoi(gcStr);
155 Int_t ix,iy,numBerg,numKapton,padNum,gassiNum;
157 TString lineStr,token;
158 lineStr.ReadLine(motifTypeStream);
159 if (!motifTypeStream.good()) break;
160 #if defined (__HP_aCC) || (__alpha)
162 tokenList << lineStr.Data();
164 istringstream tokenList(lineStr.Data());
167 token.ReadToken(tokenList);
168 if (!tokenList.good()) continue; // column is missing...
169 if ( (token.Length()>0) && (token[0]=='#') ) continue; // this is a comment line
171 numBerg = atoi(token.Data());
173 AliWarning(Form("Berg number %s invalid",token.Data()));
177 token.ReadToken(tokenList);
178 if (!tokenList.good()) continue; // column is missing...
179 numKapton = atoi(token.Data());
180 if (numKapton==0) continue;
183 token.ReadToken(tokenList);
184 if (!tokenList.good()) continue; // column is missing...
185 if (token=="GND") continue;
186 string padName = token.Data();
187 padNum = motifType->PadNum(token);
189 token.ReadToken(tokenList);
190 if (token.IsNull() ) continue; // column is missing...
191 // if (token[0]!='E') {
192 // cerr<<"Problem : gassinumber isn't begining with E:"<<token<<endl;
195 // gassiNum = atoi(token.Data() +1 )-1;
197 if ( (numBerg<1) || (numBerg>knbergpins) ) {
198 AliWarning(Form("Berg number %d outside range (1..%d)",numBerg,knbergpins));
202 gassiNum = gassiChannel[numBerg-1];
205 PadMapTypeIterator iter = positions.find(padName);
206 if (iter==positions.end()) {
208 << "Problem: Pad number " << padNum
209 << " for motif type " << motifTypeId.Data()
210 << " found in the motifType stream, but not in the padPos stream" << endl;
214 ix= iter->second.first;
215 iy= iter->second.second;
219 Long_t value = positions.GetValue(AliMpExMap::GetIndex(padName));
222 << "Problem: Pad number " << padNum
223 << " for motif type " << motifTypeId.Data()
224 << " found in the motifType stream, but not in the padPos stream" << endl;
228 ix = AliMpExMap::GetPair(value).GetFirst();
229 iy = AliMpExMap::GetPair(value).GetSecond();
233 AliMpConnection* connection
234 = new AliMpConnection(padNum,numBerg,numKapton,gassiNum, AliMpIntPair(ix,iy));
236 motifType->AddConnection(AliMpIntPair(ix,iy),connection);
238 if (ix>=nofPadsX) nofPadsX=ix+1;
239 if (iy>=nofPadsY) nofPadsY=iy+1;
241 } while (!motifTypeStream.eof());
244 motifType->SetNofPads(nofPadsX, nofPadsY);
246 delete &padPosStream;
247 delete &bergToGCStream;
248 delete &motifTypeStream;
253 //_____________________________________________________________________________
255 AliMpMotifReader::BuildMotifSpecial(const TString& motifID,
256 AliMpMotifType* motifType,
259 /// Build a special motif by reading the file motifSpecial<motifId>.dat
260 /// in the data directory
266 CreateDataStream(AliMpFiles::MotifSpecialFilePath(
267 fStationType, fStation12Type, fPlaneType, motifID));
269 TString id = MotifSpecialName(motifID,scale);
271 AliMpMotifSpecial* res = new AliMpMotifSpecial(id,motifType);
277 res->SetPadDimensions(AliMpIntPair(i,j),TVector2(x*scale/2.,y*scale/2.));
280 res->CalculateDimensions();
287 //_____________________________________________________________________________
289 AliMpMotifReader::MotifSpecialName(const TString& motifID, Double_t scale)
291 /// Build the name taking into the scale, if not 1.0
296 id = Form("%s-%e",motifID.Data(),scale);