]>
Commit | Line | Data |
---|---|---|
197883c2 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. * | |
3 | * * | |
4 | * Author: The ALICE Off-line Project. * | |
5 | * Contributors are mentioned in the code where appropriate. * | |
6 | * * | |
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 | **************************************************************************/ | |
15 | ||
16 | // $Id$ | |
13985652 | 17 | // $MpId: AliMpMotifReader.cxx,v 1.10 2006/05/24 13:58:41 ivana Exp $ |
197883c2 | 18 | // Category: sector |
3d1463c8 | 19 | |
20 | //----------------------------------------------------------------------------- | |
197883c2 | 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 | |
3d1463c8 | 26 | //----------------------------------------------------------------------------- |
197883c2 | 27 | |
197883c2 | 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" | |
197883c2 | 36 | |
2c605e66 | 37 | #include "AliLog.h" |
38 | ||
39 | #include <TSystem.h> | |
40 | #include <TMath.h> | |
41 | #include <Riostream.h> | |
42 | #include <Rstrstream.h> | |
43 | ||
44 | #if !defined(__HP_aCC) && !defined(__alpha) | |
45 | #include <sstream> | |
46 | #endif | |
47 | ||
13985652 | 48 | /// \cond CLASSIMP |
197883c2 | 49 | ClassImp(AliMpMotifReader) |
13985652 | 50 | /// \endcond |
197883c2 | 51 | |
197883c2 | 52 | //_____________________________________________________________________________ |
cddd101e | 53 | AliMpMotifReader::AliMpMotifReader(AliMp::StationType station, |
54 | AliMp::PlaneType plane) | |
197883c2 | 55 | : TObject(), |
56 | fStationType(station), | |
2c605e66 | 57 | fPlaneType(plane) |
197883c2 | 58 | { |
59 | /// Standard constructor | |
60 | } | |
61 | ||
62 | //_____________________________________________________________________________ | |
63 | AliMpMotifReader::AliMpMotifReader() | |
64 | : TObject(), | |
cddd101e | 65 | fStationType(AliMp::kStation1), |
66 | fPlaneType(AliMp::kBendingPlane) | |
197883c2 | 67 | { |
68 | /// Default constructor | |
69 | } | |
70 | ||
197883c2 | 71 | //_____________________________________________________________________________ |
72 | AliMpMotifReader::~AliMpMotifReader() | |
73 | { | |
74 | /// Destructor | |
75 | } | |
76 | ||
197883c2 | 77 | // |
78 | // public methods | |
79 | // | |
80 | ||
81 | //_____________________________________________________________________________ | |
82 | AliMpMotifType* AliMpMotifReader::BuildMotifType(const TString& motifTypeId) | |
83 | { | |
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 | |
88 | ||
89 | AliMpMotifType* motifType = new AliMpMotifType(motifTypeId); | |
90 | ||
d1c53ece | 91 | TString padPosFileName(AliMpFiles::PadPosFilePath(fStationType, |
92 | fPlaneType, motifTypeId)); | |
197883c2 | 93 | ifstream padPos(padPosFileName); |
da3a1bb2 | 94 | AliDebugStream(2) << "Opening file " << padPosFileName << endl; |
197883c2 | 95 | |
96 | PadMapType positions; | |
97 | ||
98 | char line[256]; | |
99 | do { | |
100 | padPos.getline(line,255); | |
101 | if (!padPos) break; | |
102 | ||
103 | #if defined (__HP_aCC) || (__alpha) | |
104 | strstream strline; | |
105 | strline << line; | |
106 | #else | |
107 | istringstream strline(line); | |
108 | #endif | |
109 | string key; | |
110 | ||
111 | strline>>key; | |
112 | if ((key=="#") || (key=="") ) continue; | |
113 | ||
114 | int i,j; | |
115 | strline>>i>>j; | |
116 | #ifdef WITH_STL | |
117 | positions[key].first=i; | |
118 | positions[key].second=j; | |
119 | #endif | |
120 | #ifdef WITH_ROOT | |
5006ec94 | 121 | positions.Add( AliMpExMap::GetIndex(key), |
122 | AliMpExMap::GetIndex(AliMpIntPair(i,j)) ); | |
197883c2 | 123 | #endif |
124 | } while (!padPos.eof()); | |
125 | ||
126 | padPos.close(); | |
127 | ||
128 | TString bergToGCFileName | |
d1c53ece | 129 | = AliMpFiles::BergToGCFilePath(fStationType); |
da3a1bb2 | 130 | AliDebugStream(2) << "Opening file " << bergToGCFileName << endl; |
197883c2 | 131 | |
132 | ifstream bergToGCFile(bergToGCFileName); | |
f29ba3e1 | 133 | const Int_t knbergpins = |
cddd101e | 134 | (fStationType == AliMp::kStation1 || fStationType == AliMp::kStation2 ) ? 80 : 100; |
197883c2 | 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]; | |
138 | while(1) { | |
139 | Int_t bergNum; | |
140 | TString gcStr; | |
141 | bergToGCFile>>bergNum>>gcStr; | |
142 | if (!bergToGCFile.good()) break; | |
143 | if (gcStr=="GND") continue; | |
f29ba3e1 | 144 | if (bergNum>knbergpins) { |
197883c2 | 145 | Fatal("BuildMotifType","Berg number > 80 ..."); |
146 | continue; | |
147 | } | |
148 | gassiChannel[bergNum-1]= atoi(gcStr); | |
149 | } | |
150 | bergToGCFile.close(); | |
151 | ||
d1c53ece | 152 | TString motifTypeFileName(AliMpFiles::MotifFilePath(fStationType, |
153 | fPlaneType, motifTypeId)); | |
197883c2 | 154 | ifstream motif(motifTypeFileName); |
da3a1bb2 | 155 | AliDebugStream(2) << "Opening file " << motifTypeFileName << endl; |
197883c2 | 156 | |
157 | Int_t nofPadsX=0; | |
158 | Int_t nofPadsY=0; | |
159 | ||
160 | do { | |
161 | ||
162 | Int_t ix,iy,numBerg,numKapton,padNum,gassiNum; | |
163 | ||
164 | TString lineStr,token; | |
165 | lineStr.ReadLine(motif); | |
166 | if (!motif.good()) break; | |
167 | #if defined (__HP_aCC) || (__alpha) | |
168 | strstream tokenList; | |
169 | tokenList << lineStr.Data(); | |
170 | #else | |
171 | istringstream tokenList(lineStr.Data()); | |
172 | #endif | |
173 | ||
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 | |
177 | ||
178 | numBerg = atoi(token.Data()); | |
179 | if (numBerg==0) { | |
180 | AliWarning(Form("Berg number %s invalid",token.Data())); | |
181 | continue; | |
182 | } | |
183 | ||
184 | token.ReadToken(tokenList); | |
185 | if (!tokenList.good()) continue; // column is missing... | |
186 | numKapton = atoi(token.Data()); | |
187 | if (numKapton==0) continue; | |
188 | ||
189 | ||
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); | |
195 | ||
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; | |
200 | // continue; | |
201 | // } else { | |
202 | // gassiNum = atoi(token.Data() +1 )-1; | |
203 | // } | |
f29ba3e1 | 204 | if ( (numBerg<1) || (numBerg>knbergpins) ) { |
205 | AliWarning(Form("Berg number %d outside range (1..%d)",numBerg,knbergpins)); | |
197883c2 | 206 | continue; |
207 | } | |
208 | ||
209 | gassiNum = gassiChannel[numBerg-1]; | |
210 | ||
211 | #ifdef WITH_STL | |
212 | PadMapTypeIterator iter = positions.find(padName); | |
213 | if (iter==positions.end()) { | |
2c605e66 | 214 | AliWarningStream() |
215 | << "Problem: Pad number " << padNum | |
216 | << " found in the file " << motifTypeFileName | |
217 | << " but not in the file " << padPosFileName << endl; | |
197883c2 | 218 | continue; |
219 | } | |
220 | ||
221 | ix= iter->second.first; | |
222 | iy= iter->second.second; | |
223 | #endif | |
224 | ||
225 | #ifdef WITH_ROOT | |
5006ec94 | 226 | Long_t value = positions.GetValue(AliMpExMap::GetIndex(padName)); |
197883c2 | 227 | if (!value) { |
2c605e66 | 228 | AliWarningStream() |
229 | << "Problem: Pad number " << padNum | |
230 | << " found in the file " << motifTypeFileName | |
231 | << " but not in the file " << padPosFileName << endl; | |
197883c2 | 232 | continue; |
233 | } | |
234 | ||
5006ec94 | 235 | ix = AliMpExMap::GetPair(value).GetFirst(); |
236 | iy = AliMpExMap::GetPair(value).GetSecond(); | |
197883c2 | 237 | #endif |
238 | ||
239 | motifType->AddConnection(AliMpIntPair(ix,iy), | |
240 | new AliMpConnection(padNum,numBerg,numKapton,gassiNum)); | |
241 | ||
242 | if (ix>=nofPadsX) nofPadsX=ix+1; | |
243 | if (iy>=nofPadsY) nofPadsY=iy+1; | |
244 | ||
245 | } while (!motif.eof()); | |
246 | ||
247 | ||
248 | motifType->SetNofPads(nofPadsX, nofPadsY); | |
249 | ||
250 | motif.close(); | |
251 | ||
252 | return motifType; | |
253 | } | |
254 | ||
0e8df63e | 255 | //_____________________________________________________________________________ |
256 | TString | |
257 | AliMpMotifReader::MotifSpecialName(const TString& motifID, Double_t scale) | |
258 | { | |
259 | /// Build the name taking into the scale, if not 1.0 | |
260 | TString id; | |
261 | ||
262 | if ( scale != 1.0 ) | |
263 | { | |
264 | id = Form("%s-%e",motifID.Data(),scale); | |
265 | } | |
266 | else | |
267 | { | |
268 | id = motifID; | |
269 | } | |
270 | return id; | |
271 | } | |
197883c2 | 272 | |
273 | //_____________________________________________________________________________ | |
274 | AliMpMotifSpecial* | |
275 | AliMpMotifReader::BuildMotifSpecial(const TString& motifID, | |
d1c53ece | 276 | AliMpMotifType* motifType, |
277 | Double_t scale) | |
197883c2 | 278 | { |
279 | /// Build a special motif by reading the file motifSpecial<motifId>.dat | |
280 | /// in the data directory | |
281 | ||
282 | // Open the input file | |
d1c53ece | 283 | TString motifSpecialFileName(AliMpFiles::MotifSpecialFilePath(fStationType, |
284 | fPlaneType, motifID)); | |
197883c2 | 285 | ifstream in(motifSpecialFileName); |
286 | if (!in) { | |
2c605e66 | 287 | AliErrorStream() |
288 | << "File " << motifSpecialFileName.Data() << " not found." << endl; | |
197883c2 | 289 | return 0; |
290 | } | |
291 | ||
0e8df63e | 292 | TString id = MotifSpecialName(motifID,scale); |
293 | ||
294 | AliMpMotifSpecial* res = new AliMpMotifSpecial(id,motifType); | |
197883c2 | 295 | Int_t i,j; |
296 | Double_t x,y; | |
297 | in >> i; | |
298 | while (!in.eof()){ | |
299 | in >>j >>x >> y; | |
d1c53ece | 300 | res->SetPadDimensions(AliMpIntPair(i,j),TVector2(x*scale/2.,y*scale/2.)); |
197883c2 | 301 | in >> i; |
302 | } | |
d7885370 | 303 | res->CalculateDimensions(); |
197883c2 | 304 | |
305 | in.close(); | |
306 | return res; | |
307 | } | |
308 |