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 "AliMpMotifReader.h"
30 #include "AliMpMotifMap.h"
31 #include "AliMpMotif.h"
32 #include "AliMpMotifSpecial.h"
33 #include "AliMpMotifType.h"
34 #include "AliMpConnection.h"
35 #include "AliMpIntPair.h"
41 #include <Riostream.h>
42 #include <Rstrstream.h>
44 #if !defined(__HP_aCC) && !defined(__alpha)
49 ClassImp(AliMpMotifReader)
52 //_____________________________________________________________________________
53 AliMpMotifReader::AliMpMotifReader(AliMp::StationType station,
54 AliMp::PlaneType plane)
56 fStationType(station),
59 /// Standard constructor
62 //_____________________________________________________________________________
63 AliMpMotifReader::AliMpMotifReader()
65 fStationType(AliMp::kStation1),
66 fPlaneType(AliMp::kBendingPlane)
68 /// Default constructor
71 //_____________________________________________________________________________
72 AliMpMotifReader::~AliMpMotifReader()
81 //_____________________________________________________________________________
82 AliMpMotifType* AliMpMotifReader::BuildMotifType(const TString& motifTypeId)
84 /// Read the files describing a motif in the "$MINSTALL/data" directory
85 /// and fill the AliMpMotifType structure with.
86 /// The files mentioned are are named padPos<maskName>.dat
87 /// and connect<maskName>.dat
89 AliMpMotifType* motifType = new AliMpMotifType(motifTypeId);
91 TString padPosFileName(AliMpFiles::PadPosFilePath(fStationType,
92 fPlaneType, motifTypeId));
93 ifstream padPos(padPosFileName);
94 AliDebugStream(2) << "Opening file " << padPosFileName << endl;
100 padPos.getline(line,255);
103 #if defined (__HP_aCC) || (__alpha)
107 istringstream strline(line);
112 if ((key=="#") || (key=="") ) continue;
117 positions[key].first=i;
118 positions[key].second=j;
121 positions.Add( AliMpExMap::GetIndex(key),
122 AliMpExMap::GetIndex(AliMpIntPair(i,j)) );
124 } while (!padPos.eof());
128 TString bergToGCFileName
129 = AliMpFiles::BergToGCFilePath(fStationType);
130 AliDebugStream(2) << "Opening file " << bergToGCFileName << endl;
132 ifstream bergToGCFile(bergToGCFileName);
133 const Int_t knbergpins =
134 (fStationType == AliMp::kStation1 || fStationType == AliMp::kStation2 ) ? 80 : 100;
135 // Station1 & 2 Bergstak connectors have 80 pins, while for stations
136 // 3, 4 and 5 they have 100 pins.
137 Int_t gassiChannel[100];
141 bergToGCFile>>bergNum>>gcStr;
142 if (!bergToGCFile.good()) break;
143 if (gcStr=="GND") continue;
144 if (bergNum>knbergpins) {
145 Fatal("BuildMotifType","Berg number > 80 ...");
148 gassiChannel[bergNum-1]= atoi(gcStr);
150 bergToGCFile.close();
152 TString motifTypeFileName(AliMpFiles::MotifFilePath(fStationType,
153 fPlaneType, motifTypeId));
154 ifstream motif(motifTypeFileName);
155 AliDebugStream(2) << "Opening file " << motifTypeFileName << endl;
162 Int_t ix,iy,numBerg,numKapton,padNum,gassiNum;
164 TString lineStr,token;
165 lineStr.ReadLine(motif);
166 if (!motif.good()) break;
167 #if defined (__HP_aCC) || (__alpha)
169 tokenList << lineStr.Data();
171 istringstream tokenList(lineStr.Data());
174 token.ReadToken(tokenList);
175 if (!tokenList.good()) continue; // column is missing...
176 if ( (token.Length()>0) && (token[0]=='#') ) continue; // this is a comment line
178 numBerg = atoi(token.Data());
180 AliWarning(Form("Berg number %s invalid",token.Data()));
184 token.ReadToken(tokenList);
185 if (!tokenList.good()) continue; // column is missing...
186 numKapton = atoi(token.Data());
187 if (numKapton==0) continue;
190 token.ReadToken(tokenList);
191 if (!tokenList.good()) continue; // column is missing...
192 if (token=="GND") continue;
193 string padName = token.Data();
194 padNum = motifType->PadNum(token);
196 token.ReadToken(tokenList);
197 if (token.IsNull() ) continue; // column is missing...
198 // if (token[0]!='E') {
199 // cerr<<"Problem : gassinumber isn't begining with E:"<<token<<endl;
202 // gassiNum = atoi(token.Data() +1 )-1;
204 if ( (numBerg<1) || (numBerg>knbergpins) ) {
205 AliWarning(Form("Berg number %d outside range (1..%d)",numBerg,knbergpins));
209 gassiNum = gassiChannel[numBerg-1];
212 PadMapTypeIterator iter = positions.find(padName);
213 if (iter==positions.end()) {
215 << "Problem: Pad number " << padNum
216 << " found in the file " << motifTypeFileName
217 << " but not in the file " << padPosFileName << endl;
221 ix= iter->second.first;
222 iy= iter->second.second;
226 Long_t value = positions.GetValue(AliMpExMap::GetIndex(padName));
229 << "Problem: Pad number " << padNum
230 << " found in the file " << motifTypeFileName
231 << " but not in the file " << padPosFileName << endl;
235 ix = AliMpExMap::GetPair(value).GetFirst();
236 iy = AliMpExMap::GetPair(value).GetSecond();
239 motifType->AddConnection(AliMpIntPair(ix,iy),
240 new AliMpConnection(padNum,numBerg,numKapton,gassiNum));
242 if (ix>=nofPadsX) nofPadsX=ix+1;
243 if (iy>=nofPadsY) nofPadsY=iy+1;
245 } while (!motif.eof());
248 motifType->SetNofPads(nofPadsX, nofPadsY);
255 //_____________________________________________________________________________
257 AliMpMotifReader::MotifSpecialName(const TString& motifID, Double_t scale)
259 /// Build the name taking into the scale, if not 1.0
264 id = Form("%s-%e",motifID.Data(),scale);
273 //_____________________________________________________________________________
275 AliMpMotifReader::BuildMotifSpecial(const TString& motifID,
276 AliMpMotifType* motifType,
279 /// Build a special motif by reading the file motifSpecial<motifId>.dat
280 /// in the data directory
282 // Open the input file
283 TString motifSpecialFileName(AliMpFiles::MotifSpecialFilePath(fStationType,
284 fPlaneType, motifID));
285 ifstream in(motifSpecialFileName);
288 << "File " << motifSpecialFileName.Data() << " not found." << endl;
292 TString id = MotifSpecialName(motifID,scale);
294 AliMpMotifSpecial* res = new AliMpMotifSpecial(id,motifType);
300 res->SetPadDimensions(AliMpIntPair(i,j),TVector2(x*scale/2.,y*scale/2.));
303 res->CalculateDimensions();