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(AliMp::StationType station,
55 AliMp::PlaneType plane)
57 fStationType(station),
60 /// Standard constructor
63 //_____________________________________________________________________________
64 AliMpMotifReader::AliMpMotifReader()
66 fStationType(AliMp::kStation1),
67 fPlaneType(AliMp::kBendingPlane)
69 /// Default constructor
72 //_____________________________________________________________________________
73 AliMpMotifReader::~AliMpMotifReader()
82 //_____________________________________________________________________________
83 AliMpMotifType* AliMpMotifReader::BuildMotifType(const TString& motifTypeId)
85 /// Read the streams describing a motif in the "$MINSTALL/data" directory
86 /// and fill the AliMpMotifType structure with.
87 /// The streams mentioned are named padPos<maskName>.dat
88 /// and connect<maskName>.dat
93 = AliMpDataStreams::Instance()
94 ->CreateDataStream(AliMpFiles::PadPosFilePath(
95 fStationType,fPlaneType, motifTypeId));
96 istream& bergToGCStream
97 = AliMpDataStreams::Instance()
98 ->CreateDataStream(AliMpFiles::BergToGCFilePath(fStationType));
100 istream& motifTypeStream
101 = AliMpDataStreams::Instance()
102 ->CreateDataStream(AliMpFiles::MotifFilePath(
103 fStationType, fPlaneType, motifTypeId));
105 AliMpMotifType* motifType = new AliMpMotifType(motifTypeId);
107 PadMapType positions;
111 padPosStream.getline(line,255);
112 if (!padPosStream) break;
114 #if defined (__HP_aCC) || (__alpha)
118 istringstream strline(line);
123 if ((key=="#") || (key=="") ) continue;
128 positions[key].first=i;
129 positions[key].second=j;
132 positions.Add( AliMpExMap::GetIndex(key),
133 AliMpExMap::GetIndex(AliMpIntPair(i,j)) );
135 } while (!padPosStream.eof());
137 const Int_t knbergpins =
138 (fStationType == AliMp::kStation1 || fStationType == AliMp::kStation2 ) ? 80 : 100;
139 // Station1 & 2 Bergstak connectors have 80 pins, while for stations
140 // 3, 4 and 5 they have 100 pins.
141 Int_t gassiChannel[100];
145 bergToGCStream>>bergNum>>gcStr;
146 if (!bergToGCStream.good()) break;
147 if (gcStr=="GND") continue;
148 if (bergNum>knbergpins) {
149 Fatal("BuildMotifType","Berg number > 80 ...");
152 gassiChannel[bergNum-1]= atoi(gcStr);
160 Int_t ix,iy,numBerg,numKapton,padNum,gassiNum;
162 TString lineStr,token;
163 lineStr.ReadLine(motifTypeStream);
164 if (!motifTypeStream.good()) break;
165 #if defined (__HP_aCC) || (__alpha)
167 tokenList << lineStr.Data();
169 istringstream tokenList(lineStr.Data());
172 token.ReadToken(tokenList);
173 if (!tokenList.good()) continue; // column is missing...
174 if ( (token.Length()>0) && (token[0]=='#') ) continue; // this is a comment line
176 numBerg = atoi(token.Data());
178 AliWarning(Form("Berg number %s invalid",token.Data()));
182 token.ReadToken(tokenList);
183 if (!tokenList.good()) continue; // column is missing...
184 numKapton = atoi(token.Data());
185 if (numKapton==0) continue;
188 token.ReadToken(tokenList);
189 if (!tokenList.good()) continue; // column is missing...
190 if (token=="GND") continue;
191 string padName = token.Data();
192 padNum = motifType->PadNum(token);
194 token.ReadToken(tokenList);
195 if (token.IsNull() ) continue; // column is missing...
196 // if (token[0]!='E') {
197 // cerr<<"Problem : gassinumber isn't begining with E:"<<token<<endl;
200 // gassiNum = atoi(token.Data() +1 )-1;
202 if ( (numBerg<1) || (numBerg>knbergpins) ) {
203 AliWarning(Form("Berg number %d outside range (1..%d)",numBerg,knbergpins));
207 gassiNum = gassiChannel[numBerg-1];
210 PadMapTypeIterator iter = positions.find(padName);
211 if (iter==positions.end()) {
213 << "Problem: Pad number " << padNum
214 << " for motif type " << motifTypeId.Data()
215 << " found in the motifType stream, but not in the padPos stream" << endl;
219 ix= iter->second.first;
220 iy= iter->second.second;
224 Long_t value = positions.GetValue(AliMpExMap::GetIndex(padName));
227 << "Problem: Pad number " << padNum
228 << " for motif type " << motifTypeId.Data()
229 << " found in the motifType stream, but not in the padPos stream" << endl;
233 ix = AliMpExMap::GetPair(value).GetFirst();
234 iy = AliMpExMap::GetPair(value).GetSecond();
238 AliMpConnection* connection
239 = new AliMpConnection(padNum,numBerg,numKapton,gassiNum, AliMpIntPair(ix,iy));
241 motifType->AddConnection(AliMpIntPair(ix,iy),connection);
243 if (ix>=nofPadsX) nofPadsX=ix+1;
244 if (iy>=nofPadsY) nofPadsY=iy+1;
246 } while (!motifTypeStream.eof());
249 motifType->SetNofPads(nofPadsX, nofPadsY);
251 delete &padPosStream;
252 delete &bergToGCStream;
253 delete &motifTypeStream;
258 //_____________________________________________________________________________
260 AliMpMotifReader::BuildMotifSpecial(const TString& motifID,
261 AliMpMotifType* motifType,
264 /// Build a special motif by reading the file motifSpecial<motifId>.dat
265 /// in the data directory
270 = AliMpDataStreams::Instance()
271 ->CreateDataStream(AliMpFiles::MotifSpecialFilePath(
272 fStationType,fPlaneType, motifID));
274 TString id = MotifSpecialName(motifID,scale);
276 AliMpMotifSpecial* res = new AliMpMotifSpecial(id,motifType);
282 res->SetPadDimensions(AliMpIntPair(i,j),TVector2(x*scale/2.,y*scale/2.));
285 res->CalculateDimensions();
292 //_____________________________________________________________________________
294 AliMpMotifReader::MotifSpecialName(const TString& motifID, Double_t scale)
296 /// Build the name taking into the scale, if not 1.0
301 id = Form("%s-%e",motifID.Data(),scale);