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 "AliMpEncodePair.h"
42 #include <Riostream.h>
43 #include <Rstrstream.h>
45 #if !defined(__HP_aCC) && !defined(__alpha)
50 ClassImp(AliMpMotifReader)
53 //_____________________________________________________________________________
54 AliMpMotifReader::AliMpMotifReader(AliMp::StationType station,
55 AliMq::Station12Type station12,
56 AliMp::PlaneType plane)
58 fStationType(station),
59 fStation12Type(station12),
62 /// Standard constructor
65 //_____________________________________________________________________________
66 AliMpMotifReader::~AliMpMotifReader()
75 //_____________________________________________________________________________
76 AliMpMotifType* AliMpMotifReader::BuildMotifType(
77 const AliMpDataStreams& dataStreams,
78 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);
106 padPosStream.getline(line,255);
107 if (!padPosStream) break;
109 #if defined (__HP_aCC) || (__alpha)
113 istringstream strline(line);
118 if ((key=="#") || (key=="") ) continue;
122 positions.Add( AliMpExMap::GetIndex(key),
123 AliMp::Pair(i,j) + 1 );
124 // we have to add 1 to the AliMp::Pair in order to
125 // its value always != 0, as the TExMap returns 0 value
126 // if given key does not exists
127 } while (!padPosStream.eof());
129 const Int_t knbergpins =
130 (fStationType == AliMp::kStation12 ) ? 80 : 100;
131 // Station1 & 2 Bergstak connectors have 80 pins, while for stations
132 // 3, 4 and 5 they have 100 pins.
133 Int_t gassiChannel[100];
134 for (Int_t i=0; i<100; ++i) gassiChannel[i] = 0;
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 if ( bergNum <= 0 || bergNum >= 101 ) {
146 AliErrorStream() << "Wrong bergNum: " << bergNum << endl;
149 gassiChannel[bergNum-1]= atoi(gcStr);
157 Int_t ix,iy,numBerg,numKapton,padNum,gassiNum;
159 TString lineStr,token;
160 lineStr.ReadLine(motifTypeStream);
161 if (!motifTypeStream.good()) break;
162 #if defined (__HP_aCC) || (__alpha)
164 tokenList << lineStr.Data();
166 istringstream tokenList(lineStr.Data());
169 token.ReadToken(tokenList);
170 if (!tokenList.good()) continue; // column is missing...
171 if ( (token.Length()>0) && (token[0]=='#') ) continue; // this is a comment line
173 numBerg = atoi(token.Data());
175 AliWarning(Form("Berg number %s invalid",token.Data()));
179 token.ReadToken(tokenList);
180 if (!tokenList.good()) continue; // column is missing...
181 numKapton = atoi(token.Data());
182 if (numKapton==0) continue;
185 token.ReadToken(tokenList);
186 if (!tokenList.good()) continue; // column is missing...
187 if (token=="GND") continue;
188 string padName = token.Data();
189 padNum = motifType->PadNum(token);
191 token.ReadToken(tokenList);
192 if (token.IsNull() ) continue; // column is missing...
193 // if (token[0]!='E') {
194 // cerr<<"Problem : gassinumber isn't begining with E:"<<token<<endl;
197 // gassiNum = atoi(token.Data() +1 )-1;
199 if ( (numBerg<1) || (numBerg>knbergpins) ) {
200 AliWarning(Form("Berg number %d outside range (1..%d)",numBerg,knbergpins));
204 gassiNum = gassiChannel[numBerg-1];
206 Long_t value = positions.GetValue(AliMpExMap::GetIndex(padName));
209 << "Problem: Pad number " << padNum
210 << " for motif type " << motifTypeId.Data()
211 << " found in the motifType stream, but not in the padPos stream" << endl;
215 AliMpConnection* connection
216 = new AliMpConnection(padNum,numBerg,numKapton,gassiNum, --value);
218 Bool_t ok = motifType->AddConnection(connection);
222 AliFatal("Could not add connection");
225 ix = AliMp::PairFirst(value);
226 iy = AliMp::PairSecond(value);
228 if (ix>=nofPadsX) nofPadsX=ix+1;
229 if (iy>=nofPadsY) nofPadsY=iy+1;
231 } while (!motifTypeStream.eof());
234 motifType->SetNofPads(nofPadsX, nofPadsY);
236 delete &padPosStream;
237 delete &bergToGCStream;
238 delete &motifTypeStream;
243 //_____________________________________________________________________________
245 AliMpMotifReader::BuildMotifSpecial(const AliMpDataStreams& dataStreams,
246 const TString& motifID,
247 AliMpMotifType* motifType,
250 /// Build a special motif by reading the file motifSpecial<motifId>.dat
251 /// in the data directory
257 CreateDataStream(AliMpFiles::MotifSpecialFilePath(
258 fStationType, fStation12Type, fPlaneType, motifID));
260 TString id = MotifSpecialName(motifID,scale);
262 AliMpMotifSpecial* res = new AliMpMotifSpecial(id,motifType);
268 res->SetPadDimensions(i,j,x*scale/2.,y*scale/2.);
271 res->CalculateDimensions();
278 //_____________________________________________________________________________
280 AliMpMotifReader::MotifSpecialName(const TString& motifID, Double_t scale)
282 /// Build the name taking into the scale, if not 1.0
287 id = Form("%s-%e",motifID.Data(),scale);