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 // Class AliMpMotifReader
21 // -------------------
22 // Class that takes care of reading the sector data.
23 // Included in AliRoot: 2003/05/02
24 // Authors: David Guez, Ivana Hrivnacova; IPN Orsay
26 #include "AliMpFiles.h"
27 #include "AliMpMotifReader.h"
28 #include "AliMpMotifMap.h"
29 #include "AliMpMotif.h"
30 #include "AliMpMotifSpecial.h"
31 #include "AliMpMotifType.h"
32 #include "AliMpConnection.h"
33 #include "AliMpIntPair.h"
34 #include "AliMpDirection.h"
40 #include <Riostream.h>
41 #include <Rstrstream.h>
43 #if !defined(__HP_aCC) && !defined(__alpha)
48 ClassImp(AliMpMotifReader)
51 //_____________________________________________________________________________
52 AliMpMotifReader::AliMpMotifReader(AliMpStationType station,
55 fStationType(station),
58 /// Standard constructor
61 //_____________________________________________________________________________
62 AliMpMotifReader::AliMpMotifReader()
64 fStationType(kStation1),
65 fPlaneType(kBendingPlane)
67 /// Default constructor
70 //_____________________________________________________________________________
71 AliMpMotifReader::~AliMpMotifReader()
80 //_____________________________________________________________________________
81 AliMpMotifType* AliMpMotifReader::BuildMotifType(const TString& motifTypeId)
83 /// Read the files describing a motif in the "$MINSTALL/data" directory
84 /// and fill the AliMpMotifType structure with.
85 /// The files mentioned are are named padPos<maskName>.dat
86 /// and connect<maskName>.dat
88 AliMpMotifType* motifType = new AliMpMotifType(motifTypeId);
90 TString padPosFileName(AliMpFiles::PadPosFilePath(fStationType,
91 fPlaneType, motifTypeId));
92 ifstream padPos(padPosFileName);
93 AliDebugStream(2) << "Opening file " << padPosFileName << endl;
99 padPos.getline(line,255);
102 #if defined (__HP_aCC) || (__alpha)
106 istringstream strline(line);
111 if ((key=="#") || (key=="") ) continue;
116 positions[key].first=i;
117 positions[key].second=j;
120 positions.Add( AliMpExMap::GetIndex(key),
121 AliMpExMap::GetIndex(AliMpIntPair(i,j)) );
123 } while (!padPos.eof());
127 TString bergToGCFileName
128 = AliMpFiles::BergToGCFilePath(fStationType);
129 AliDebugStream(2) << "Opening file " << bergToGCFileName << endl;
131 ifstream bergToGCFile(bergToGCFileName);
132 const Int_t knbergpins =
133 (fStationType == kStation1 || fStationType == kStation2 ) ? 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 bergToGCFile>>bergNum>>gcStr;
141 if (!bergToGCFile.good()) break;
142 if (gcStr=="GND") continue;
143 if (bergNum>knbergpins) {
144 Fatal("BuildMotifType","Berg number > 80 ...");
147 gassiChannel[bergNum-1]= atoi(gcStr);
149 bergToGCFile.close();
151 TString motifTypeFileName(AliMpFiles::MotifFilePath(fStationType,
152 fPlaneType, motifTypeId));
153 ifstream motif(motifTypeFileName);
154 AliDebugStream(2) << "Opening file " << motifTypeFileName << endl;
161 Int_t ix,iy,numBerg,numKapton,padNum,gassiNum;
163 TString lineStr,token;
164 lineStr.ReadLine(motif);
165 if (!motif.good()) break;
166 #if defined (__HP_aCC) || (__alpha)
168 tokenList << lineStr.Data();
170 istringstream tokenList(lineStr.Data());
173 token.ReadToken(tokenList);
174 if (!tokenList.good()) continue; // column is missing...
175 if ( (token.Length()>0) && (token[0]=='#') ) continue; // this is a comment line
177 numBerg = atoi(token.Data());
179 AliWarning(Form("Berg number %s invalid",token.Data()));
183 token.ReadToken(tokenList);
184 if (!tokenList.good()) continue; // column is missing...
185 numKapton = atoi(token.Data());
186 if (numKapton==0) continue;
189 token.ReadToken(tokenList);
190 if (!tokenList.good()) continue; // column is missing...
191 if (token=="GND") continue;
192 string padName = token.Data();
193 padNum = motifType->PadNum(token);
195 token.ReadToken(tokenList);
196 if (token.IsNull() ) continue; // column is missing...
197 // if (token[0]!='E') {
198 // cerr<<"Problem : gassinumber isn't begining with E:"<<token<<endl;
201 // gassiNum = atoi(token.Data() +1 )-1;
203 if ( (numBerg<1) || (numBerg>knbergpins) ) {
204 AliWarning(Form("Berg number %d outside range (1..%d)",numBerg,knbergpins));
208 gassiNum = gassiChannel[numBerg-1];
211 PadMapTypeIterator iter = positions.find(padName);
212 if (iter==positions.end()) {
214 << "Problem: Pad number " << padNum
215 << " found in the file " << motifTypeFileName
216 << " but not in the file " << padPosFileName << endl;
220 ix= iter->second.first;
221 iy= iter->second.second;
225 Long_t value = positions.GetValue(AliMpExMap::GetIndex(padName));
228 << "Problem: Pad number " << padNum
229 << " found in the file " << motifTypeFileName
230 << " but not in the file " << padPosFileName << endl;
234 ix = AliMpExMap::GetPair(value).GetFirst();
235 iy = AliMpExMap::GetPair(value).GetSecond();
238 motifType->AddConnection(AliMpIntPair(ix,iy),
239 new AliMpConnection(padNum,numBerg,numKapton,gassiNum));
241 if (ix>=nofPadsX) nofPadsX=ix+1;
242 if (iy>=nofPadsY) nofPadsY=iy+1;
244 } while (!motif.eof());
247 motifType->SetNofPads(nofPadsX, nofPadsY);
255 //_____________________________________________________________________________
257 AliMpMotifReader::BuildMotifSpecial(const TString& motifID,
258 AliMpMotifType* motifType,
261 /// Build a special motif by reading the file motifSpecial<motifId>.dat
262 /// in the data directory
264 // Open the input file
265 TString motifSpecialFileName(AliMpFiles::MotifSpecialFilePath(fStationType,
266 fPlaneType, motifID));
267 ifstream in(motifSpecialFileName);
270 << "File " << motifSpecialFileName.Data() << " not found." << endl;
274 AliMpMotifSpecial* res = new AliMpMotifSpecial(motifID,motifType);
280 res->SetPadDimensions(AliMpIntPair(i,j),TVector2(x*scale/2.,y*scale/2.));
283 res->CalculateDimensions();