]>
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" |
228fd720 | 29 | #include "AliMpDataStreams.h" |
197883c2 | 30 | #include "AliMpMotifReader.h" |
31 | #include "AliMpMotifMap.h" | |
32 | #include "AliMpMotif.h" | |
33 | #include "AliMpMotifSpecial.h" | |
34 | #include "AliMpMotifType.h" | |
35 | #include "AliMpConnection.h" | |
36 | #include "AliMpIntPair.h" | |
197883c2 | 37 | |
2c605e66 | 38 | #include "AliLog.h" |
39 | ||
40 | #include <TSystem.h> | |
41 | #include <TMath.h> | |
42 | #include <Riostream.h> | |
43 | #include <Rstrstream.h> | |
44 | ||
45 | #if !defined(__HP_aCC) && !defined(__alpha) | |
46 | #include <sstream> | |
47 | #endif | |
48 | ||
13985652 | 49 | /// \cond CLASSIMP |
197883c2 | 50 | ClassImp(AliMpMotifReader) |
13985652 | 51 | /// \endcond |
197883c2 | 52 | |
197883c2 | 53 | //_____________________________________________________________________________ |
ab167304 | 54 | AliMpMotifReader::AliMpMotifReader(const AliMpDataStreams& dataStreams, |
55 | AliMp::StationType station, | |
cddd101e | 56 | AliMp::PlaneType plane) |
197883c2 | 57 | : TObject(), |
ab167304 | 58 | fDataStreams(dataStreams), |
197883c2 | 59 | fStationType(station), |
2c605e66 | 60 | fPlaneType(plane) |
197883c2 | 61 | { |
62 | /// Standard constructor | |
63 | } | |
64 | ||
197883c2 | 65 | //_____________________________________________________________________________ |
66 | AliMpMotifReader::~AliMpMotifReader() | |
67 | { | |
68 | /// Destructor | |
69 | } | |
70 | ||
197883c2 | 71 | // |
72 | // public methods | |
73 | // | |
74 | ||
75 | //_____________________________________________________________________________ | |
76 | AliMpMotifType* AliMpMotifReader::BuildMotifType(const TString& motifTypeId) | |
77 | { | |
228fd720 | 78 | /// Read the streams describing a motif in the "$MINSTALL/data" directory |
197883c2 | 79 | /// and fill the AliMpMotifType structure with. |
228fd720 | 80 | /// The streams mentioned are named padPos<maskName>.dat |
197883c2 | 81 | /// and connect<maskName>.dat |
82 | ||
228fd720 | 83 | // Open streams |
84 | // | |
85 | istream& padPosStream | |
ab167304 | 86 | = fDataStreams. |
87 | CreateDataStream(AliMpFiles::PadPosFilePath( | |
228fd720 | 88 | fStationType,fPlaneType, motifTypeId)); |
89 | istream& bergToGCStream | |
ab167304 | 90 | = fDataStreams. |
91 | CreateDataStream(AliMpFiles::BergToGCFilePath(fStationType)); | |
228fd720 | 92 | |
93 | istream& motifTypeStream | |
ab167304 | 94 | = fDataStreams. |
95 | CreateDataStream(AliMpFiles::MotifFilePath( | |
228fd720 | 96 | fStationType, fPlaneType, motifTypeId)); |
197883c2 | 97 | |
228fd720 | 98 | AliMpMotifType* motifType = new AliMpMotifType(motifTypeId); |
197883c2 | 99 | |
100 | PadMapType positions; | |
101 | ||
102 | char line[256]; | |
103 | do { | |
228fd720 | 104 | padPosStream.getline(line,255); |
105 | if (!padPosStream) break; | |
197883c2 | 106 | |
107 | #if defined (__HP_aCC) || (__alpha) | |
108 | strstream strline; | |
109 | strline << line; | |
110 | #else | |
111 | istringstream strline(line); | |
112 | #endif | |
113 | string key; | |
114 | ||
115 | strline>>key; | |
116 | if ((key=="#") || (key=="") ) continue; | |
117 | ||
118 | int i,j; | |
119 | strline>>i>>j; | |
120 | #ifdef WITH_STL | |
121 | positions[key].first=i; | |
122 | positions[key].second=j; | |
123 | #endif | |
124 | #ifdef WITH_ROOT | |
5006ec94 | 125 | positions.Add( AliMpExMap::GetIndex(key), |
126 | AliMpExMap::GetIndex(AliMpIntPair(i,j)) ); | |
197883c2 | 127 | #endif |
228fd720 | 128 | } while (!padPosStream.eof()); |
197883c2 | 129 | |
f29ba3e1 | 130 | const Int_t knbergpins = |
cddd101e | 131 | (fStationType == AliMp::kStation1 || fStationType == AliMp::kStation2 ) ? 80 : 100; |
197883c2 | 132 | // Station1 & 2 Bergstak connectors have 80 pins, while for stations |
133 | // 3, 4 and 5 they have 100 pins. | |
134 | Int_t gassiChannel[100]; | |
135 | while(1) { | |
136 | Int_t bergNum; | |
137 | TString gcStr; | |
228fd720 | 138 | bergToGCStream>>bergNum>>gcStr; |
139 | if (!bergToGCStream.good()) break; | |
197883c2 | 140 | if (gcStr=="GND") continue; |
f29ba3e1 | 141 | if (bergNum>knbergpins) { |
197883c2 | 142 | Fatal("BuildMotifType","Berg number > 80 ..."); |
143 | continue; | |
144 | } | |
145 | gassiChannel[bergNum-1]= atoi(gcStr); | |
146 | } | |
197883c2 | 147 | |
197883c2 | 148 | Int_t nofPadsX=0; |
149 | Int_t nofPadsY=0; | |
150 | ||
151 | do { | |
152 | ||
153 | Int_t ix,iy,numBerg,numKapton,padNum,gassiNum; | |
154 | ||
155 | TString lineStr,token; | |
228fd720 | 156 | lineStr.ReadLine(motifTypeStream); |
157 | if (!motifTypeStream.good()) break; | |
197883c2 | 158 | #if defined (__HP_aCC) || (__alpha) |
159 | strstream tokenList; | |
160 | tokenList << lineStr.Data(); | |
161 | #else | |
162 | istringstream tokenList(lineStr.Data()); | |
163 | #endif | |
164 | ||
165 | token.ReadToken(tokenList); | |
166 | if (!tokenList.good()) continue; // column is missing... | |
167 | if ( (token.Length()>0) && (token[0]=='#') ) continue; // this is a comment line | |
168 | ||
169 | numBerg = atoi(token.Data()); | |
170 | if (numBerg==0) { | |
171 | AliWarning(Form("Berg number %s invalid",token.Data())); | |
172 | continue; | |
173 | } | |
174 | ||
175 | token.ReadToken(tokenList); | |
176 | if (!tokenList.good()) continue; // column is missing... | |
177 | numKapton = atoi(token.Data()); | |
178 | if (numKapton==0) continue; | |
179 | ||
180 | ||
181 | token.ReadToken(tokenList); | |
182 | if (!tokenList.good()) continue; // column is missing... | |
183 | if (token=="GND") continue; | |
184 | string padName = token.Data(); | |
185 | padNum = motifType->PadNum(token); | |
186 | ||
187 | token.ReadToken(tokenList); | |
188 | if (token.IsNull() ) continue; // column is missing... | |
189 | // if (token[0]!='E') { | |
190 | // cerr<<"Problem : gassinumber isn't begining with E:"<<token<<endl; | |
191 | // continue; | |
192 | // } else { | |
193 | // gassiNum = atoi(token.Data() +1 )-1; | |
194 | // } | |
f29ba3e1 | 195 | if ( (numBerg<1) || (numBerg>knbergpins) ) { |
196 | AliWarning(Form("Berg number %d outside range (1..%d)",numBerg,knbergpins)); | |
197883c2 | 197 | continue; |
198 | } | |
199 | ||
200 | gassiNum = gassiChannel[numBerg-1]; | |
201 | ||
202 | #ifdef WITH_STL | |
203 | PadMapTypeIterator iter = positions.find(padName); | |
204 | if (iter==positions.end()) { | |
2c605e66 | 205 | AliWarningStream() |
206 | << "Problem: Pad number " << padNum | |
228fd720 | 207 | << " for motif type " << motifTypeId.Data() |
208 | << " found in the motifType stream, but not in the padPos stream" << endl; | |
197883c2 | 209 | continue; |
210 | } | |
211 | ||
212 | ix= iter->second.first; | |
213 | iy= iter->second.second; | |
214 | #endif | |
215 | ||
216 | #ifdef WITH_ROOT | |
5006ec94 | 217 | Long_t value = positions.GetValue(AliMpExMap::GetIndex(padName)); |
197883c2 | 218 | if (!value) { |
2c605e66 | 219 | AliWarningStream() |
220 | << "Problem: Pad number " << padNum | |
228fd720 | 221 | << " for motif type " << motifTypeId.Data() |
222 | << " found in the motifType stream, but not in the padPos stream" << endl; | |
197883c2 | 223 | continue; |
224 | } | |
225 | ||
5006ec94 | 226 | ix = AliMpExMap::GetPair(value).GetFirst(); |
227 | iy = AliMpExMap::GetPair(value).GetSecond(); | |
630711ed | 228 | |
197883c2 | 229 | #endif |
230 | ||
630711ed | 231 | AliMpConnection* connection |
232 | = new AliMpConnection(padNum,numBerg,numKapton,gassiNum, AliMpIntPair(ix,iy)); | |
233 | ||
234 | motifType->AddConnection(AliMpIntPair(ix,iy),connection); | |
235 | ||
197883c2 | 236 | if (ix>=nofPadsX) nofPadsX=ix+1; |
237 | if (iy>=nofPadsY) nofPadsY=iy+1; | |
238 | ||
228fd720 | 239 | } while (!motifTypeStream.eof()); |
197883c2 | 240 | |
241 | ||
242 | motifType->SetNofPads(nofPadsX, nofPadsY); | |
228fd720 | 243 | |
244 | delete &padPosStream; | |
245 | delete &bergToGCStream; | |
246 | delete &motifTypeStream; | |
197883c2 | 247 | |
248 | return motifType; | |
249 | } | |
250 | ||
197883c2 | 251 | //_____________________________________________________________________________ |
252 | AliMpMotifSpecial* | |
253 | AliMpMotifReader::BuildMotifSpecial(const TString& motifID, | |
d1c53ece | 254 | AliMpMotifType* motifType, |
255 | Double_t scale) | |
197883c2 | 256 | { |
257 | /// Build a special motif by reading the file motifSpecial<motifId>.dat | |
258 | /// in the data directory | |
259 | ||
228fd720 | 260 | // Open streams |
261 | // | |
262 | istream& in | |
ab167304 | 263 | = fDataStreams. |
264 | CreateDataStream(AliMpFiles::MotifSpecialFilePath( | |
228fd720 | 265 | fStationType,fPlaneType, motifID)); |
197883c2 | 266 | |
0e8df63e | 267 | TString id = MotifSpecialName(motifID,scale); |
268 | ||
269 | AliMpMotifSpecial* res = new AliMpMotifSpecial(id,motifType); | |
197883c2 | 270 | Int_t i,j; |
271 | Double_t x,y; | |
272 | in >> i; | |
273 | while (!in.eof()){ | |
274 | in >>j >>x >> y; | |
d1c53ece | 275 | res->SetPadDimensions(AliMpIntPair(i,j),TVector2(x*scale/2.,y*scale/2.)); |
197883c2 | 276 | in >> i; |
277 | } | |
d7885370 | 278 | res->CalculateDimensions(); |
197883c2 | 279 | |
228fd720 | 280 | delete ∈ |
281 | ||
197883c2 | 282 | return res; |
283 | } | |
284 | ||
228fd720 | 285 | //_____________________________________________________________________________ |
286 | TString | |
287 | AliMpMotifReader::MotifSpecialName(const TString& motifID, Double_t scale) | |
288 | { | |
289 | /// Build the name taking into the scale, if not 1.0 | |
290 | TString id; | |
291 | ||
292 | if ( scale != 1.0 ) | |
293 | { | |
294 | id = Form("%s-%e",motifID.Data(),scale); | |
295 | } | |
296 | else | |
297 | { | |
298 | id = motifID; | |
299 | } | |
300 | return id; | |
301 | } | |
302 |