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.6 2005/09/26 16:11:20 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 #if !defined(__HP_aCC) && !defined(__alpha)
30 #include <Riostream.h>
31 #include <Rstrstream.h>
37 #include "AliMpFiles.h"
38 #include "AliMpMotifReader.h"
39 #include "AliMpMotifMap.h"
40 #include "AliMpMotif.h"
41 #include "AliMpMotifSpecial.h"
42 #include "AliMpMotifType.h"
43 #include "AliMpConnection.h"
44 #include "AliMpIntPair.h"
45 #include "AliMpDirection.h"
47 ClassImp(AliMpMotifReader)
49 //_____________________________________________________________________________
50 AliMpMotifReader::AliMpMotifReader(AliMpStationType station,
53 fStationType(station),
57 /// Standard constructor
60 //_____________________________________________________________________________
61 AliMpMotifReader::AliMpMotifReader()
63 fStationType(kStation1),
64 fPlaneType(kBendingPlane),
67 /// Default constructor
70 //_____________________________________________________________________________
71 AliMpMotifReader::AliMpMotifReader(const AliMpMotifReader& right)
74 /// Protected copy constructor (not provided)
76 Fatal("AliMpMotifReader", "Copy constructor not provided.");
79 //_____________________________________________________________________________
80 AliMpMotifReader::~AliMpMotifReader()
89 //_____________________________________________________________________________
90 AliMpMotifReader& AliMpMotifReader::operator=(const AliMpMotifReader& right)
92 /// Protected assignment operator (not provided)
94 // check assignment to self
95 if (this == &right) return *this;
97 Fatal("operator =", "Assignment operator not provided.");
111 //_____________________________________________________________________________
112 AliMpMotifType* AliMpMotifReader::BuildMotifType(const TString& motifTypeId)
114 /// Read the files describing a motif in the "$MINSTALL/data" directory
115 /// and fill the AliMpMotifType structure with.
116 /// The files mentioned are are named padPos<maskName>.dat
117 /// and connect<maskName>.dat
119 AliMpMotifType* motifType = new AliMpMotifType(motifTypeId);
121 TString padPosFileName(AliMpFiles::PadPosFilePath(fStationType,
122 fPlaneType, motifTypeId));
123 ifstream padPos(padPosFileName);
124 if (fVerboseLevel>0) cout<<"Opening file "<<padPosFileName<<endl;
126 PadMapType positions;
130 padPos.getline(line,255);
133 #if defined (__HP_aCC) || (__alpha)
137 istringstream strline(line);
142 if ((key=="#") || (key=="") ) continue;
147 positions[key].first=i;
148 positions[key].second=j;
151 positions.Add( AliMpExMap::GetIndex(key),
152 AliMpExMap::GetIndex(AliMpIntPair(i,j)) );
154 } while (!padPos.eof());
158 TString bergToGCFileName
159 = AliMpFiles::BergToGCFilePath(fStationType);
161 cout << "Opening file " << bergToGCFileName << endl;
163 ifstream bergToGCFile(bergToGCFileName);
164 const Int_t knbergpins =
165 (fStationType == kStation1 || fStationType == kStation2 ) ? 80 : 100;
166 // Station1 & 2 Bergstak connectors have 80 pins, while for stations
167 // 3, 4 and 5 they have 100 pins.
168 Int_t gassiChannel[100];
172 bergToGCFile>>bergNum>>gcStr;
173 if (!bergToGCFile.good()) break;
174 if (gcStr=="GND") continue;
175 if (bergNum>knbergpins) {
176 Fatal("BuildMotifType","Berg number > 80 ...");
179 gassiChannel[bergNum-1]= atoi(gcStr);
181 bergToGCFile.close();
183 TString motifTypeFileName(AliMpFiles::MotifFilePath(fStationType,
184 fPlaneType, motifTypeId));
185 ifstream motif(motifTypeFileName);
186 if (fVerboseLevel>0) cout<<"Opening file "<<motifTypeFileName<<endl;
193 Int_t ix,iy,numBerg,numKapton,padNum,gassiNum;
195 TString lineStr,token;
196 lineStr.ReadLine(motif);
197 if (!motif.good()) break;
198 #if defined (__HP_aCC) || (__alpha)
200 tokenList << lineStr.Data();
202 istringstream tokenList(lineStr.Data());
205 token.ReadToken(tokenList);
206 if (!tokenList.good()) continue; // column is missing...
207 if ( (token.Length()>0) && (token[0]=='#') ) continue; // this is a comment line
209 numBerg = atoi(token.Data());
211 AliWarning(Form("Berg number %s invalid",token.Data()));
215 token.ReadToken(tokenList);
216 if (!tokenList.good()) continue; // column is missing...
217 numKapton = atoi(token.Data());
218 if (numKapton==0) continue;
221 token.ReadToken(tokenList);
222 if (!tokenList.good()) continue; // column is missing...
223 if (token=="GND") continue;
224 string padName = token.Data();
225 padNum = motifType->PadNum(token);
227 token.ReadToken(tokenList);
228 if (token.IsNull() ) continue; // column is missing...
229 // if (token[0]!='E') {
230 // cerr<<"Problem : gassinumber isn't begining with E:"<<token<<endl;
233 // gassiNum = atoi(token.Data() +1 )-1;
235 if ( (numBerg<1) || (numBerg>knbergpins) ) {
236 AliWarning(Form("Berg number %d outside range (1..%d)",numBerg,knbergpins));
240 gassiNum = gassiChannel[numBerg-1];
243 PadMapTypeIterator iter = positions.find(padName);
244 if (iter==positions.end()) {
245 cerr<<"Problem: Pad number "<<padNum<<" found in the file "<<motifTypeFileName
246 <<" but not in the file"<<padPosFileName<<endl;
250 ix= iter->second.first;
251 iy= iter->second.second;
255 Long_t value = positions.GetValue(AliMpExMap::GetIndex(padName));
257 cerr<<"Problem: Pad number "<<padNum<<" found in the file "<<motifTypeFileName
258 <<" but not in the file"<<padPosFileName<<endl;
262 ix = AliMpExMap::GetPair(value).GetFirst();
263 iy = AliMpExMap::GetPair(value).GetSecond();
266 motifType->AddConnection(AliMpIntPair(ix,iy),
267 new AliMpConnection(padNum,numBerg,numKapton,gassiNum));
269 if (ix>=nofPadsX) nofPadsX=ix+1;
270 if (iy>=nofPadsY) nofPadsY=iy+1;
272 } while (!motif.eof());
275 motifType->SetNofPads(nofPadsX, nofPadsY);
283 //_____________________________________________________________________________
285 AliMpMotifReader::BuildMotifSpecial(const TString& motifID,
286 AliMpMotifType* motifType,
289 /// Build a special motif by reading the file motifSpecial<motifId>.dat
290 /// in the data directory
292 // Open the input file
293 TString motifSpecialFileName(AliMpFiles::MotifSpecialFilePath(fStationType,
294 fPlaneType, motifID));
295 ifstream in(motifSpecialFileName);
297 AliError(Form("File %s not found.\n",motifSpecialFileName.Data()));
301 AliMpMotifSpecial* res = new AliMpMotifSpecial(motifID,motifType);
307 res->SetPadDimensions(AliMpIntPair(i,j),TVector2(x*scale/2.,y*scale/2.));
316 //_____________________________________________________________________________
317 void AliMpMotifReader::SetVerboseLevel(Int_t verboseLevel)
319 // Sets verbose level.
322 fVerboseLevel = verboseLevel;