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"
39 #include <Riostream.h>
40 #include <Rstrstream.h>
42 #if !defined(__HP_aCC) && !defined(__alpha)
47 ClassImp(AliMpMotifReader)
50 //_____________________________________________________________________________
51 AliMpMotifReader::AliMpMotifReader(AliMp::StationType station,
52 AliMp::PlaneType plane)
54 fStationType(station),
57 /// Standard constructor
60 //_____________________________________________________________________________
61 AliMpMotifReader::AliMpMotifReader()
63 fStationType(AliMp::kStation1),
64 fPlaneType(AliMp::kBendingPlane)
66 /// Default constructor
69 //_____________________________________________________________________________
70 AliMpMotifReader::~AliMpMotifReader()
79 //_____________________________________________________________________________
80 AliMpMotifType* AliMpMotifReader::BuildMotifType(const TString& motifTypeId)
82 /// Read the files describing a motif in the "$MINSTALL/data" directory
83 /// and fill the AliMpMotifType structure with.
84 /// The files mentioned are are named padPos<maskName>.dat
85 /// and connect<maskName>.dat
87 AliMpMotifType* motifType = new AliMpMotifType(motifTypeId);
89 TString padPosFileName(AliMpFiles::PadPosFilePath(fStationType,
90 fPlaneType, motifTypeId));
91 ifstream padPos(padPosFileName);
92 AliDebugStream(2) << "Opening file " << padPosFileName << endl;
98 padPos.getline(line,255);
101 #if defined (__HP_aCC) || (__alpha)
105 istringstream strline(line);
110 if ((key=="#") || (key=="") ) continue;
115 positions[key].first=i;
116 positions[key].second=j;
119 positions.Add( AliMpExMap::GetIndex(key),
120 AliMpExMap::GetIndex(AliMpIntPair(i,j)) );
122 } while (!padPos.eof());
126 TString bergToGCFileName
127 = AliMpFiles::BergToGCFilePath(fStationType);
128 AliDebugStream(2) << "Opening file " << bergToGCFileName << endl;
130 ifstream bergToGCFile(bergToGCFileName);
131 const Int_t knbergpins =
132 (fStationType == AliMp::kStation1 || fStationType == AliMp::kStation2 ) ? 80 : 100;
133 // Station1 & 2 Bergstak connectors have 80 pins, while for stations
134 // 3, 4 and 5 they have 100 pins.
135 Int_t gassiChannel[100];
139 bergToGCFile>>bergNum>>gcStr;
140 if (!bergToGCFile.good()) break;
141 if (gcStr=="GND") continue;
142 if (bergNum>knbergpins) {
143 Fatal("BuildMotifType","Berg number > 80 ...");
146 gassiChannel[bergNum-1]= atoi(gcStr);
148 bergToGCFile.close();
150 TString motifTypeFileName(AliMpFiles::MotifFilePath(fStationType,
151 fPlaneType, motifTypeId));
152 ifstream motif(motifTypeFileName);
153 AliDebugStream(2) << "Opening file " << motifTypeFileName << endl;
160 Int_t ix,iy,numBerg,numKapton,padNum,gassiNum;
162 TString lineStr,token;
163 lineStr.ReadLine(motif);
164 if (!motif.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 << " found in the file " << motifTypeFileName
215 << " but not in the file " << padPosFileName << 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 << " found in the file " << motifTypeFileName
229 << " but not in the file " << padPosFileName << endl;
233 ix = AliMpExMap::GetPair(value).GetFirst();
234 iy = AliMpExMap::GetPair(value).GetSecond();
237 motifType->AddConnection(AliMpIntPair(ix,iy),
238 new AliMpConnection(padNum,numBerg,numKapton,gassiNum));
240 if (ix>=nofPadsX) nofPadsX=ix+1;
241 if (iy>=nofPadsY) nofPadsY=iy+1;
243 } while (!motif.eof());
246 motifType->SetNofPads(nofPadsX, nofPadsY);
253 //_____________________________________________________________________________
255 AliMpMotifReader::MotifSpecialName(const TString& motifID, Double_t scale)
257 /// Build the name taking into the scale, if not 1.0
262 id = Form("%s-%e",motifID.Data(),scale);
271 //_____________________________________________________________________________
273 AliMpMotifReader::BuildMotifSpecial(const TString& motifID,
274 AliMpMotifType* motifType,
277 /// Build a special motif by reading the file motifSpecial<motifId>.dat
278 /// in the data directory
280 // Open the input file
281 TString motifSpecialFileName(AliMpFiles::MotifSpecialFilePath(fStationType,
282 fPlaneType, motifID));
283 ifstream in(motifSpecialFileName);
286 << "File " << motifSpecialFileName.Data() << " not found." << endl;
290 TString id = MotifSpecialName(motifID,scale);
292 AliMpMotifSpecial* res = new AliMpMotifSpecial(id,motifType);
298 res->SetPadDimensions(AliMpIntPair(i,j),TVector2(x*scale/2.,y*scale/2.));
301 res->CalculateDimensions();