]>
Commit | Line | Data |
---|---|---|
74f8c8e3 | 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$ */ | |
17 | //=========================================================== | |
18 | // Segmentation classes for MUON Detection Elements | |
19 | // Gines MARTINEZ, SUBATECH July 04 | |
20 | // This class interfaces with the mapping and segmentation | |
21 | // files MUON. | |
22 | // This files are placed by default in | |
23 | // $ALICE_ROOT/MUON/mapping/data/Stationxxx/yyy_plane/ | |
24 | // There are in tracking 23 types of detection elements | |
25 | // 8 SectorSt1, 8 SectorSt2, 2 122000SR1, 2 122000NR1, 4 112200SR2, 4 112200NR2 | |
26 | // 4 122200S, 4 122200N, 8 222000N,8 220000N, 8 330000N, 4 122300N, 8 112230NR3 | |
27 | // 8 112230N, 8 222330N, 8 223300N, 16 333000N, 4 122330N, 8 112233NR3, 8 112233N | |
28 | // 8 222333N, 8 223330N, 8 333300N | |
29 | // Detailed information in Alice Technical Note xxxxxxxx (2004) | |
30 | //=========================================================== | |
31 | ||
32 | #include <Riostream.h> | |
9d936539 | 33 | #include <stdlib.h> |
74f8c8e3 | 34 | |
35 | #include "TClonesArray.h" | |
36 | #include "TMap.h" | |
6b74910d | 37 | #include "TMath.h" |
74f8c8e3 | 38 | |
39 | #include "AliMUONSegmentationDetectionElement.h" | |
40 | #include "AliMUONSegmentManuIndex.h" | |
41 | #include "AliMUONSegmentPosition.h" | |
42 | #include "AliMUONSegmentIndex.h" | |
43 | ||
74f8c8e3 | 44 | //___________________________________________ |
45 | ClassImp(AliMUONSegmentationDetectionElement) | |
46 | ||
47 | //static data member | |
48 | const TString AliMUONSegmentationDetectionElement::fgkDefaultTop =getenv("ALICE_ROOT") ; | |
49 | const TString AliMUONSegmentationDetectionElement::fgkStationDir = "/MUON/mapping/data/station"; | |
50 | const TString AliMUONSegmentationDetectionElement::fgkBendingDir= "/bending_plane"; | |
51 | const TString AliMUONSegmentationDetectionElement::fgkNonBendingDir= "/non-bending_plane"; | |
52 | const TString AliMUONSegmentationDetectionElement::fgkFileExt = ".map"; | |
53 | const TString AliMUONSegmentationDetectionElement::fgkBendingExt = ".Bending"; | |
54 | const TString AliMUONSegmentationDetectionElement::fgkNonBendingExt = ".NonBending"; | |
55 | ||
56 | //___________________________________________ | |
57 | ||
58 | AliMUONSegmentationDetectionElement::AliMUONSegmentationDetectionElement() : TObject() | |
59 | { | |
212bb69d | 60 | //Default constructor |
6b74910d | 61 | fWireD = 0.25; // wire pitch in cm |
62 | fWireX0 = 0.; // X0 position of the 1st wire | |
74f8c8e3 | 63 | fMapManuIndexIndex= 0x0; |
64 | fMapIndexManuIndex= 0x0; | |
65 | fMapIndexPosition= 0x0; | |
212bb69d | 66 | fMapPositionIndex=0X0; |
74f8c8e3 | 67 | } |
68 | ||
69 | ||
70 | // AliMUONSegmentationDetectionElement::AliMUONSegmentationDetectionElement(const char* ElementType) | |
71 | // { | |
72 | ||
73 | // fMapManuIndexIndex= 0x0; | |
74 | // fMapIndexManuIndex= 0x0; | |
75 | // fMapIndexPosition= 0x0; | |
74f8c8e3 | 76 | // } |
77 | ||
78 | //________________________________________________ | |
79 | AliMUONSegmentationDetectionElement::AliMUONSegmentationDetectionElement(const AliMUONSegmentationDetectionElement& rhs): TObject(rhs) | |
80 | { | |
81 | // Protected copy constructor | |
82 | ||
83 | Fatal("AliMUONSegmentationDetectionElementModule", "Not implemented."); | |
84 | } | |
85 | //_________________________________________________ | |
86 | AliMUONSegmentationDetectionElement::~AliMUONSegmentationDetectionElement(){ | |
212bb69d | 87 | //Class destructor |
74f8c8e3 | 88 | fListOfIndexes->Delete(); |
89 | fListOfManuIndexes->Delete(); | |
90 | fListOfPositions->Delete(); | |
91 | fMapManuIndexIndex->Clear(); | |
92 | fMapIndexManuIndex->Clear(); | |
93 | fMapIndexPosition->Clear(); | |
212bb69d | 94 | fMapPositionIndex->Clear(); |
95 | } | |
96 | ||
6b74910d | 97 | //__________________________________________________ |
98 | AliMUONSegmentIndex * AliMUONSegmentationDetectionElement::FindIndexFromPosition(Float_t x, Float_t y, Int_t cathode) | |
99 | { | |
100 | // Finding x_wire corresponding to x | |
101 | Float_t x_wire = GetAnod(x); | |
102 | ||
103 | //Finding pad corresponding to the position (x_wire, y) in a zone of size 3cm x 10cm or 10cm x 3cm depending on cathode plane | |
104 | // | |
105 | Int_t ix_max = (cathode==0) ? TMath::Nint(5./AliMUONSegmentPosition::GetUnit()) : TMath::Nint(1.5/AliMUONSegmentPosition::GetUnit()); | |
106 | Int_t iy_max = (cathode==0) ? TMath::Nint(1.5/AliMUONSegmentPosition::GetUnit()) : TMath::Nint(5./AliMUONSegmentPosition::GetUnit()); | |
107 | ||
108 | AliMUONSegmentIndex * segmentindex =0x0; | |
109 | AliMUONSegmentIndex * foundsegmentindex =0x0; | |
110 | AliMUONSegmentPosition * segmentposition=0x0; | |
111 | Int_t ix, iy; | |
112 | Float_t xt,yt; | |
113 | Float_t distance = 99999999.; | |
114 | //printf("%d %d \n",ix_max, iy_max); | |
115 | ||
116 | for(ix=-ix_max; ix<ix_max; ix++) { | |
117 | xt = x_wire + ((Float_t)ix)*AliMUONSegmentPosition::GetUnit(); | |
118 | for(iy=-iy_max; iy<iy_max; iy++) { | |
119 | yt = y + ((Float_t)iy)*AliMUONSegmentPosition::GetUnit(); | |
120 | segmentindex = GetIndexFromPosition( xt, yt, cathode); | |
121 | if ( segmentindex ) { | |
122 | // segmentindex->Print(); | |
123 | segmentposition = GetPosition(segmentindex->GetName()); | |
124 | if ( segmentposition->Distance(x_wire, y) < distance ) { | |
125 | //printf("adfafa xt %f yt %f distance %f \n", xt, yt, segmentposition->Distance(xt,yt) ); | |
126 | distance = segmentposition->Distance(x_wire,y); | |
127 | foundsegmentindex = segmentindex; | |
128 | } | |
129 | } | |
130 | } | |
131 | } | |
132 | if (!foundsegmentindex) { | |
133 | Warning("FindIndexFromPosition","Not found Index for position x=%5.2f y=%5.2f \n",x,y); | |
134 | } | |
135 | return foundsegmentindex; | |
136 | } | |
137 | ||
138 | //____________________________________________________- | |
139 | Float_t AliMUONSegmentationDetectionElement::GetAnod(Float_t xhit) const | |
140 | { | |
141 | // Returns for a hit position xhit the position of the nearest anode wire | |
142 | Float_t wire= ( (xhit- fWireX0)>0 ) ? | |
143 | Int_t( (xhit- fWireX0)/fWireD )+0.5 : | |
144 | Int_t( (xhit- fWireX0)/fWireD )-0.5; | |
145 | return fWireD*wire+fWireX0; | |
146 | } | |
212bb69d | 147 | //_________________________________________________ |
148 | AliMUONSegmentIndex * AliMUONSegmentationDetectionElement::GetIndex(Int_t manu, Int_t channel) const | |
149 | { | |
150 | // Getting AliMUONSegmentIndex from ManuIndex | |
151 | return GetIndex( AliMUONSegmentManuIndex::Name(manu, channel).Data() ) ; | |
74f8c8e3 | 152 | } |
153 | //_________________________________________________ | |
212bb69d | 154 | AliMUONSegmentIndex * AliMUONSegmentationDetectionElement::GetIndex( const char * SegmentManuIndexName) const |
74f8c8e3 | 155 | { |
212bb69d | 156 | // Getting AliMUONSegmentIndex from name of AliMUONSegmentManuIndex |
74f8c8e3 | 157 | if (fMapManuIndexIndex) return (AliMUONSegmentIndex*) fMapManuIndexIndex->GetValue(SegmentManuIndexName); |
158 | else { | |
159 | Warning("GetIndex","SegmentManuIndex %s out of DetectionElement Mapping %s", | |
160 | SegmentManuIndexName,fDetectionElementType.Data()); | |
161 | return 0x0; | |
162 | } | |
163 | } | |
74f8c8e3 | 164 | //_________________________________________________ |
212bb69d | 165 | AliMUONSegmentManuIndex * AliMUONSegmentationDetectionElement::GetManuIndex(Int_t padx, Int_t pady, Int_t cathode ) const |
166 | { | |
167 | // Getting ManuIndex from Index | |
168 | return GetManuIndex( AliMUONSegmentIndex::Name(padx, pady, cathode).Data() ); | |
169 | } | |
170 | //_________________________________________________ | |
171 | AliMUONSegmentManuIndex * AliMUONSegmentationDetectionElement::GetManuIndex( const char * SegmentIndexName) const | |
74f8c8e3 | 172 | { |
212bb69d | 173 | // Getting ManuIndex from manuname |
74f8c8e3 | 174 | if (fMapIndexManuIndex) return (AliMUONSegmentManuIndex*) fMapIndexManuIndex->GetValue(SegmentIndexName); |
175 | else { | |
176 | Warning("GetManuIndex","SegmentIndex %s out of Detection Element mapping %s", | |
177 | SegmentIndexName,fDetectionElementType.Data()); | |
178 | return 0x0; | |
179 | } | |
180 | } | |
6b74910d | 181 | //__________________________________________________ |
182 | void AliMUONSegmentationDetectionElement::GetPadC(Int_t ix, Int_t iy, Int_t cathode, Float_t &x, Float_t &y ) | |
183 | { | |
184 | x = GetPosition(ix,iy,cathode)->GetXlocal(); | |
185 | y = GetPosition(ix,iy,cathode)->GetYlocal(); | |
186 | } | |
187 | //__________________________________________________ | |
188 | void AliMUONSegmentationDetectionElement::GetPadI(Float_t x, Float_t y, Int_t cathode, Int_t &padx, Int_t &pady) | |
189 | { | |
190 | ||
191 | AliMUONSegmentIndex * segmentindex = FindIndexFromPosition(x,y,cathode); | |
192 | ||
193 | if (segmentindex) { | |
194 | padx = segmentindex->GetPadX(); | |
195 | pady = segmentindex->GetPadX(); | |
196 | } | |
197 | else { | |
198 | Warning("GetPadI","Not found Index for position x=%5.2f y=%5.2f \n",x,y); | |
199 | } | |
200 | } | |
74f8c8e3 | 201 | //_________________________________________________ |
212bb69d | 202 | AliMUONSegmentPosition * AliMUONSegmentationDetectionElement::GetPosition(Int_t padx, Int_t pady, Int_t cathode ) const |
203 | { | |
204 | //Getting position from index | |
205 | return GetPosition( AliMUONSegmentIndex::Name(padx, pady, cathode).Data() ); | |
206 | } | |
207 | //_________________________________________________ | |
208 | AliMUONSegmentPosition * AliMUONSegmentationDetectionElement::GetPosition( const char * SegmentIndexName) const | |
74f8c8e3 | 209 | { |
212bb69d | 210 | // Getting position from indexname |
74f8c8e3 | 211 | if (fMapIndexPosition) return (AliMUONSegmentPosition*) fMapIndexPosition->GetValue(SegmentIndexName); |
212 | else { | |
213 | Warning("GetPosition","SegmentIndex %s out of DetectionElement mapping %s", | |
214 | SegmentIndexName, fDetectionElementType.Data()); | |
215 | return 0x0; | |
216 | } | |
217 | } | |
212bb69d | 218 | //_________________________________________________ |
219 | AliMUONSegmentIndex * AliMUONSegmentationDetectionElement::GetIndexFromPosition(Float_t x, Float_t y, Int_t cathode) const | |
220 | { | |
221 | // Getting Index from position if position is a center pad position | |
6b74910d | 222 | return GetIndexFromPosition( AliMUONSegmentPosition::Name(x, y, cathode).Data() ); |
212bb69d | 223 | } |
224 | //_________________________________________________ | |
225 | AliMUONSegmentIndex * AliMUONSegmentationDetectionElement::GetIndexFromPosition( const char * PositionName) const | |
226 | { | |
227 | // Getting index form positionname | |
228 | if (fMapPositionIndex) return (AliMUONSegmentIndex*) fMapPositionIndex->GetValue(PositionName); | |
229 | else { | |
230 | Warning("GetIndexFromPosition","SegmentPosition %s out of DetectionElement Mapping %s", | |
231 | PositionName,fDetectionElementType.Data()); | |
232 | return 0x0; | |
233 | } | |
234 | } | |
74f8c8e3 | 235 | |
236 | //_________________________________________________ | |
212bb69d | 237 | AliMUONSegmentManuIndex * AliMUONSegmentationDetectionElement::FindManuIndex( const char* ManuIndexName)const |
74f8c8e3 | 238 | { |
212bb69d | 239 | // Getting AliMUONSegmentManuIndex objecto from manu index |
74f8c8e3 | 240 | if (fMapManuIndexIndex) return (AliMUONSegmentManuIndex*) fMapManuIndexIndex->FindObject(ManuIndexName); |
241 | else { | |
242 | Warning("FindManuIndex","SegmentManuIndex %s out of DetectionElement mapping %s", | |
243 | ManuIndexName,fDetectionElementType.Data()); | |
244 | return 0x0; | |
245 | } | |
246 | } | |
247 | ||
248 | //_________________________________________________ | |
212bb69d | 249 | AliMUONSegmentIndex * AliMUONSegmentationDetectionElement::FindIndex(const char* IndexName) const |
74f8c8e3 | 250 | { |
212bb69d | 251 | // Getting |
252 | if (fMapIndexPosition) return (AliMUONSegmentIndex *) fMapIndexPosition->FindObject(IndexName); | |
74f8c8e3 | 253 | else { |
254 | Warning("FindIndex","SegmentIndex %s out of DetectionElement mapping %s", | |
255 | IndexName,fDetectionElementType.Data()); | |
256 | return 0x0; | |
257 | } | |
258 | } | |
212bb69d | 259 | //_________________________________________________ |
74f8c8e3 | 260 | void AliMUONSegmentationDetectionElement::Init(const char * DetectionElementType) |
261 | { | |
212bb69d | 262 | TString elementType(DetectionElementType); |
263 | fSegmentationMappingFileBending = fgkDefaultTop+fgkStationDir+"345" | |
264 | +fgkBendingDir+"/"+elementType+fgkBendingExt+fgkFileExt; | |
212bb69d | 265 | fSegmentationMappingFileNonBending = fgkDefaultTop+fgkStationDir+"345" |
266 | +fgkNonBendingDir+"/"+elementType+fgkNonBendingExt+fgkFileExt; | |
74f8c8e3 | 267 | |
268 | if (fMapManuIndexIndex==0x0) { | |
212bb69d | 269 | fListOfIndexes = new TObjArray(15000); |
270 | fListOfManuIndexes =new TObjArray(15000); | |
271 | fListOfPositions =new TObjArray(15000); | |
74f8c8e3 | 272 | fMapManuIndexIndex= new TMap(); |
273 | fMapIndexManuIndex = new TMap(); | |
274 | fMapIndexPosition = new TMap(); | |
212bb69d | 275 | fMapPositionIndex = new TMap(); |
74f8c8e3 | 276 | } |
277 | else { | |
278 | fListOfIndexes->Delete(); | |
279 | fListOfManuIndexes->Delete(); | |
280 | fListOfPositions->Delete(); | |
281 | fMapManuIndexIndex->Clear(); | |
282 | fMapIndexManuIndex->Clear(); | |
283 | fMapIndexPosition->Clear(); | |
212bb69d | 284 | fMapPositionIndex->Clear(); |
74f8c8e3 | 285 | } |
74f8c8e3 | 286 | Int_t icathode; |
287 | //Bendingplane | |
288 | icathode=0; | |
6b74910d | 289 | Info("ReadingSegmentationMappingFile","%s", fSegmentationMappingFileBending.Data()); |
212bb69d | 290 | ReadingSegmentationMappingFile(fSegmentationMappingFileBending ,icathode); |
74f8c8e3 | 291 | //NonBendingplane |
292 | icathode=1; | |
6b74910d | 293 | Info("Init","Reading mapping file is %s\n", fSegmentationMappingFileNonBending.Data()); |
212bb69d | 294 | ReadingSegmentationMappingFile(fSegmentationMappingFileNonBending,icathode); |
74f8c8e3 | 295 | |
296 | } | |
297 | //_______________________________________________________________ | |
298 | void AliMUONSegmentationDetectionElement::ReadingSegmentationMappingFile(TString infile, Int_t cathode) | |
299 | { | |
300 | ifstream in( infile, ios::in); | |
301 | if (!in) { | |
6b74910d | 302 | Error("ReadingSegmentationMappingFile", "File not found."); |
74f8c8e3 | 303 | } |
304 | else { | |
305 | Int_t id, ix, iy, idmanu, idchannel; | |
306 | Float_t x, y; | |
6b74910d | 307 | do { |
74f8c8e3 | 308 | in >> id >> ix >> iy >> x >> y >> idmanu >> idchannel; |
6b74910d | 309 | // printf("id=%d ix=%d iy=%d x=%f y=%f idmanu=%d and idchannel=%d\n",id, ix, iy, x, y,idmanu, idchannel); |
74f8c8e3 | 310 | |
311 | fListOfIndexes->AddAt( new AliMUONSegmentIndex(id,ix,iy,cathode), id); | |
312 | fListOfManuIndexes->AddAt( new AliMUONSegmentManuIndex(id,idmanu,0,idchannel), id);; | |
313 | fListOfPositions->AddAt( new AliMUONSegmentPosition(id, x, y,cathode), id);; | |
314 | ||
6b74910d | 315 | //( (AliMUONSegmentIndex* )fListOfIndexes->At(id))->Print(); |
316 | //( (AliMUONSegmentManuIndex*)fListOfManuIndexes->At(id))->Print(); | |
317 | //( (AliMUONSegmentPosition*)fListOfPositions->At(id))->Print(); | |
74f8c8e3 | 318 | |
319 | fMapManuIndexIndex->Add( fListOfManuIndexes->At(id), fListOfIndexes->At(id)); | |
320 | fMapIndexManuIndex->Add( fListOfIndexes->At(id), fListOfManuIndexes->At(id)); | |
321 | fMapIndexPosition->Add( fListOfIndexes->At(id), fListOfPositions->At(id)); | |
6b74910d | 322 | fMapPositionIndex->Add( fListOfPositions->At(id), fListOfIndexes->At(id) ); |
323 | } | |
324 | while ( !in.eof()); | |
74f8c8e3 | 325 | } |
326 | in.close(); | |
327 | } |