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 //===========================================================
18 // Segmentation classes for MUON Detection Elements
19 // Gines MARTINEZ, SUBATECH July 04
20 // This class interfaces with the mapping and segmentation
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 //===========================================================
32 #include <Riostream.h>
34 #include "TClonesArray.h"
37 #include "AliMUONSegmentationDetectionElement.h"
38 #include "AliMUONSegmentManuIndex.h"
39 #include "AliMUONSegmentPosition.h"
40 #include "AliMUONSegmentIndex.h"
42 //___________________________________________
43 ClassImp(AliMUONSegmentationDetectionElement)
46 const TString AliMUONSegmentationDetectionElement::fgkDefaultTop =getenv("ALICE_ROOT") ;
47 const TString AliMUONSegmentationDetectionElement::fgkStationDir = "/MUON/mapping/data/station";
48 const TString AliMUONSegmentationDetectionElement::fgkBendingDir= "/bending_plane";
49 const TString AliMUONSegmentationDetectionElement::fgkNonBendingDir= "/non-bending_plane";
50 const TString AliMUONSegmentationDetectionElement::fgkFileExt = ".map";
51 const TString AliMUONSegmentationDetectionElement::fgkBendingExt = ".Bending";
52 const TString AliMUONSegmentationDetectionElement::fgkNonBendingExt = ".NonBending";
54 //___________________________________________
56 AliMUONSegmentationDetectionElement::AliMUONSegmentationDetectionElement() : TObject()
59 fMapManuIndexIndex= 0x0;
60 fMapIndexManuIndex= 0x0;
61 fMapIndexPosition= 0x0;
62 fMapPositionIndex=0X0;
66 // AliMUONSegmentationDetectionElement::AliMUONSegmentationDetectionElement(const char* ElementType)
69 // fMapManuIndexIndex= 0x0;
70 // fMapIndexManuIndex= 0x0;
71 // fMapIndexPosition= 0x0;
74 //________________________________________________
75 AliMUONSegmentationDetectionElement::AliMUONSegmentationDetectionElement(const AliMUONSegmentationDetectionElement& rhs): TObject(rhs)
77 // Protected copy constructor
79 Fatal("AliMUONSegmentationDetectionElementModule", "Not implemented.");
81 //_________________________________________________
82 AliMUONSegmentationDetectionElement::~AliMUONSegmentationDetectionElement(){
84 fListOfIndexes->Delete();
85 fListOfManuIndexes->Delete();
86 fListOfPositions->Delete();
87 fMapManuIndexIndex->Clear();
88 fMapIndexManuIndex->Clear();
89 fMapIndexPosition->Clear();
90 fMapPositionIndex->Clear();
93 //_________________________________________________
94 AliMUONSegmentIndex * AliMUONSegmentationDetectionElement::GetIndex(Int_t manu, Int_t channel) const
96 // Getting AliMUONSegmentIndex from ManuIndex
97 return GetIndex( AliMUONSegmentManuIndex::Name(manu, channel).Data() ) ;
99 //_________________________________________________
100 AliMUONSegmentIndex * AliMUONSegmentationDetectionElement::GetIndex( const char * SegmentManuIndexName) const
102 // Getting AliMUONSegmentIndex from name of AliMUONSegmentManuIndex
103 if (fMapManuIndexIndex) return (AliMUONSegmentIndex*) fMapManuIndexIndex->GetValue(SegmentManuIndexName);
105 Warning("GetIndex","SegmentManuIndex %s out of DetectionElement Mapping %s",
106 SegmentManuIndexName,fDetectionElementType.Data());
110 //_________________________________________________
111 AliMUONSegmentManuIndex * AliMUONSegmentationDetectionElement::GetManuIndex(Int_t padx, Int_t pady, Int_t cathode ) const
113 // Getting ManuIndex from Index
114 return GetManuIndex( AliMUONSegmentIndex::Name(padx, pady, cathode).Data() );
116 //_________________________________________________
117 AliMUONSegmentManuIndex * AliMUONSegmentationDetectionElement::GetManuIndex( const char * SegmentIndexName) const
119 // Getting ManuIndex from manuname
120 if (fMapIndexManuIndex) return (AliMUONSegmentManuIndex*) fMapIndexManuIndex->GetValue(SegmentIndexName);
122 Warning("GetManuIndex","SegmentIndex %s out of Detection Element mapping %s",
123 SegmentIndexName,fDetectionElementType.Data());
127 //_________________________________________________
128 AliMUONSegmentPosition * AliMUONSegmentationDetectionElement::GetPosition(Int_t padx, Int_t pady, Int_t cathode ) const
130 //Getting position from index
131 return GetPosition( AliMUONSegmentIndex::Name(padx, pady, cathode).Data() );
133 //_________________________________________________
134 AliMUONSegmentPosition * AliMUONSegmentationDetectionElement::GetPosition( const char * SegmentIndexName) const
136 // Getting position from indexname
137 if (fMapIndexPosition) return (AliMUONSegmentPosition*) fMapIndexPosition->GetValue(SegmentIndexName);
139 Warning("GetPosition","SegmentIndex %s out of DetectionElement mapping %s",
140 SegmentIndexName, fDetectionElementType.Data());
144 //_________________________________________________
145 AliMUONSegmentIndex * AliMUONSegmentationDetectionElement::GetIndexFromPosition(Float_t x, Float_t y, Int_t cathode) const
147 // Getting Index from position if position is a center pad position
148 return GetIndexFromPosition( AliMUONSegmentPosition::Name(x,y, cathode).Data() );
150 //_________________________________________________
151 AliMUONSegmentIndex * AliMUONSegmentationDetectionElement::GetIndexFromPosition( const char * PositionName) const
153 // Getting index form positionname
154 if (fMapPositionIndex) return (AliMUONSegmentIndex*) fMapPositionIndex->GetValue(PositionName);
156 Warning("GetIndexFromPosition","SegmentPosition %s out of DetectionElement Mapping %s",
157 PositionName,fDetectionElementType.Data());
162 //_________________________________________________
163 AliMUONSegmentManuIndex * AliMUONSegmentationDetectionElement::FindManuIndex( const char* ManuIndexName)const
165 // Getting AliMUONSegmentManuIndex objecto from manu index
166 if (fMapManuIndexIndex) return (AliMUONSegmentManuIndex*) fMapManuIndexIndex->FindObject(ManuIndexName);
168 Warning("FindManuIndex","SegmentManuIndex %s out of DetectionElement mapping %s",
169 ManuIndexName,fDetectionElementType.Data());
174 //_________________________________________________
175 AliMUONSegmentIndex * AliMUONSegmentationDetectionElement::FindIndex(const char* IndexName) const
178 if (fMapIndexPosition) return (AliMUONSegmentIndex *) fMapIndexPosition->FindObject(IndexName);
180 Warning("FindIndex","SegmentIndex %s out of DetectionElement mapping %s",
181 IndexName,fDetectionElementType.Data());
185 //_________________________________________________
186 AliMUONSegmentIndex * AliMUONSegmentationDetectionElement::FindIndexFromPosition(Float_t /*x*/, Float_t /*y*/, Int_t /*cathode*/ ) const
189 // char * name = AliMUONSegmentPosition::Name(x,y);
191 // if (GetIndexFromPosition( AliMUONSegmentPosition::Name(x,y)) )
192 // return GetIndexFromPosition( AliMUONSegmentPosition::Name(x,y) );
194 // Float_t xl= ((Int_t) x*10 )/10.;
195 // Float_t yl= ((Int_t) y*10 )/10.;
198 // for(ix=1; ix<4; ix++) {
199 // xl = ((Int_t) 0.5+10.*(x + ((Float_t) ix )*0.1))/10.;
200 // for(iy=-ix; iy<ix+1; iy++) {
201 // printf("A %d and %d and %f and %f \n",ix,iy,xl,yl);
202 // yl = ((Int_t) 10.*(y + ((Float_t) iy )*0.1))/10. ;
203 // sprintf(name,"%5.1f-%5.1f",xl, yl);
204 // if (GetIndexFromPosition(name)) break;
206 // if (GetIndexFromPosition(name)) break;
209 // for(ixp=ix-1; ixp>-ix-1; ixp--) {
210 // xl = ((Int_t) 0.5+10.*(x + ((Float_t) ixp )*0.1))/10. ;
211 // printf("B %d and %d and %f and %f \n",ixp,ix, xl, yl);
212 // sprintf(name,"%5.1f-%5.1f",xl, yl);
213 // if (GetIndexFromPosition(name)) break;
215 // if (GetIndexFromPosition(name)) break;
217 // for(iy=ix-1; iy>-ix-1; iy--) {
218 // yl = ((Int_t) 0.5+10.*(y + ((Float_t) iy )*0.1))/10. ;
219 // printf("C %d and %d and %f and %f \n",-ix,iy,xl,yl);
220 // sprintf(name,"%5.1f-%5.1f",xl, yl);
221 // if (GetIndexFromPosition(name)) break;
223 // if (GetIndexFromPosition(name)) break;
225 // for(ixp=-ix+1; ixp<ix+1; ixp++) {
226 // xl = ((Int_t) 0.5+10.*(x + ((Float_t) ixp )*0.1))/10. ;
227 // printf("D %d and %d and %f and %f \n",ixp,-ix,xl,yl);
228 // sprintf(name,"%5.1f-%5.1f",xl, yl);
229 // if (GetIndexFromPosition(name)) break;
231 // if (GetIndexFromPosition(name)) break;
233 // return GetIndexFromPosition(name);
236 //_________________________________________________
237 void AliMUONSegmentationDetectionElement::Init(const char * DetectionElementType)
239 TString elementType(DetectionElementType);
240 fSegmentationMappingFileBending = fgkDefaultTop+fgkStationDir+"345"
241 +fgkBendingDir+"/"+elementType+fgkBendingExt+fgkFileExt;
242 printf("file is %s\n", fSegmentationMappingFileBending.Data());
243 fSegmentationMappingFileNonBending = fgkDefaultTop+fgkStationDir+"345"
244 +fgkNonBendingDir+"/"+elementType+fgkNonBendingExt+fgkFileExt;
246 if (fMapManuIndexIndex==0x0) {
247 fListOfIndexes = new TObjArray(15000);
248 fListOfManuIndexes =new TObjArray(15000);
249 fListOfPositions =new TObjArray(15000);
250 fMapManuIndexIndex= new TMap();
251 fMapIndexManuIndex = new TMap();
252 fMapIndexPosition = new TMap();
253 fMapPositionIndex = new TMap();
256 fListOfIndexes->Delete();
257 fListOfManuIndexes->Delete();
258 fListOfPositions->Delete();
259 fMapManuIndexIndex->Clear();
260 fMapIndexManuIndex->Clear();
261 fMapIndexPosition->Clear();
262 fMapPositionIndex->Clear();
267 ReadingSegmentationMappingFile(fSegmentationMappingFileBending ,icathode);
270 ReadingSegmentationMappingFile(fSegmentationMappingFileNonBending,icathode);
273 //_______________________________________________________________
274 void AliMUONSegmentationDetectionElement::ReadingSegmentationMappingFile(TString infile, Int_t cathode)
276 ifstream in( infile, ios::in);
278 // Error("ReadingSegmentationMappingFile", "File not found.");
281 Int_t id, ix, iy, idmanu, idchannel;
284 in >> id >> ix >> iy >> x >> y >> idmanu >> idchannel;
285 printf("id=%d ix=%d iy=%d x=%f y=%f idmanu=%d and idchannel=%d\n",id, ix, iy, x, y,idmanu, idchannel);
287 fListOfIndexes->AddAt( new AliMUONSegmentIndex(id,ix,iy,cathode), id);
288 fListOfManuIndexes->AddAt( new AliMUONSegmentManuIndex(id,idmanu,0,idchannel), id);;
289 fListOfPositions->AddAt( new AliMUONSegmentPosition(id, x, y,cathode), id);;
291 ( (AliMUONSegmentIndex* )fListOfIndexes->At(id))->Print();
292 ( (AliMUONSegmentManuIndex*)fListOfManuIndexes->At(id))->Print();
293 ( (AliMUONSegmentPosition*)fListOfPositions->At(id))->Print();
295 fMapManuIndexIndex->Add( fListOfManuIndexes->At(id), fListOfIndexes->At(id));
296 fMapIndexManuIndex->Add( fListOfIndexes->At(id), fListOfManuIndexes->At(id));
297 fMapIndexPosition->Add( fListOfIndexes->At(id), fListOfPositions->At(id));
298 fMapPositionIndex->Add( fListOfPositions->At(id), fListOfIndexes->At(id) );