#include "TClonesArray.h"
#include "TMap.h"
+#include "TMath.h"
#include "AliMUONSegmentationDetectionElement.h"
#include "AliMUONSegmentManuIndex.h"
AliMUONSegmentationDetectionElement::AliMUONSegmentationDetectionElement() : TObject()
{
//Default constructor
+ fWireD = 0.25; // wire pitch in cm
+ fWireX0 = 0.; // X0 position of the 1st wire
fMapManuIndexIndex= 0x0;
fMapIndexManuIndex= 0x0;
fMapIndexPosition= 0x0;
fMapPositionIndex->Clear();
}
+//__________________________________________________
+AliMUONSegmentIndex * AliMUONSegmentationDetectionElement::FindIndexFromPosition(Float_t x, Float_t y, Int_t cathode)
+{
+ // Finding x_wire corresponding to x
+ Float_t x_wire = GetAnod(x);
+
+ //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
+ //
+ Int_t ix_max = (cathode==0) ? TMath::Nint(5./AliMUONSegmentPosition::GetUnit()) : TMath::Nint(1.5/AliMUONSegmentPosition::GetUnit());
+ Int_t iy_max = (cathode==0) ? TMath::Nint(1.5/AliMUONSegmentPosition::GetUnit()) : TMath::Nint(5./AliMUONSegmentPosition::GetUnit());
+
+ AliMUONSegmentIndex * segmentindex =0x0;
+ AliMUONSegmentIndex * foundsegmentindex =0x0;
+ AliMUONSegmentPosition * segmentposition=0x0;
+ Int_t ix, iy;
+ Float_t xt,yt;
+ Float_t distance = 99999999.;
+ //printf("%d %d \n",ix_max, iy_max);
+
+ for(ix=-ix_max; ix<ix_max; ix++) {
+ xt = x_wire + ((Float_t)ix)*AliMUONSegmentPosition::GetUnit();
+ for(iy=-iy_max; iy<iy_max; iy++) {
+ yt = y + ((Float_t)iy)*AliMUONSegmentPosition::GetUnit();
+ segmentindex = GetIndexFromPosition( xt, yt, cathode);
+ if ( segmentindex ) {
+ // segmentindex->Print();
+ segmentposition = GetPosition(segmentindex->GetName());
+ if ( segmentposition->Distance(x_wire, y) < distance ) {
+ //printf("adfafa xt %f yt %f distance %f \n", xt, yt, segmentposition->Distance(xt,yt) );
+ distance = segmentposition->Distance(x_wire,y);
+ foundsegmentindex = segmentindex;
+ }
+ }
+ }
+ }
+ if (!foundsegmentindex) {
+ Warning("FindIndexFromPosition","Not found Index for position x=%5.2f y=%5.2f \n",x,y);
+ }
+ return foundsegmentindex;
+}
+
+//____________________________________________________-
+Float_t AliMUONSegmentationDetectionElement::GetAnod(Float_t xhit) const
+{
+ // Returns for a hit position xhit the position of the nearest anode wire
+ Float_t wire= ( (xhit- fWireX0)>0 ) ?
+ Int_t( (xhit- fWireX0)/fWireD )+0.5 :
+ Int_t( (xhit- fWireX0)/fWireD )-0.5;
+ return fWireD*wire+fWireX0;
+}
//_________________________________________________
AliMUONSegmentIndex * AliMUONSegmentationDetectionElement::GetIndex(Int_t manu, Int_t channel) const
{
return 0x0;
}
}
+//__________________________________________________
+void AliMUONSegmentationDetectionElement::GetPadC(Int_t ix, Int_t iy, Int_t cathode, Float_t &x, Float_t &y )
+{
+ x = GetPosition(ix,iy,cathode)->GetXlocal();
+ y = GetPosition(ix,iy,cathode)->GetYlocal();
+}
+//__________________________________________________
+void AliMUONSegmentationDetectionElement::GetPadI(Float_t x, Float_t y, Int_t cathode, Int_t &padx, Int_t &pady)
+{
+
+ AliMUONSegmentIndex * segmentindex = FindIndexFromPosition(x,y,cathode);
+
+ if (segmentindex) {
+ padx = segmentindex->GetPadX();
+ pady = segmentindex->GetPadX();
+ }
+ else {
+ Warning("GetPadI","Not found Index for position x=%5.2f y=%5.2f \n",x,y);
+ }
+}
//_________________________________________________
AliMUONSegmentPosition * AliMUONSegmentationDetectionElement::GetPosition(Int_t padx, Int_t pady, Int_t cathode ) const
{
AliMUONSegmentIndex * AliMUONSegmentationDetectionElement::GetIndexFromPosition(Float_t x, Float_t y, Int_t cathode) const
{
// Getting Index from position if position is a center pad position
- return GetIndexFromPosition( AliMUONSegmentPosition::Name(x,y, cathode).Data() );
+ return GetIndexFromPosition( AliMUONSegmentPosition::Name(x, y, cathode).Data() );
}
//_________________________________________________
AliMUONSegmentIndex * AliMUONSegmentationDetectionElement::GetIndexFromPosition( const char * PositionName) const
}
}
//_________________________________________________
-AliMUONSegmentIndex * AliMUONSegmentationDetectionElement::FindIndexFromPosition(Float_t /*x*/, Float_t /*y*/, Int_t /*cathode*/ ) const
-{
-
- // char * name = AliMUONSegmentPosition::Name(x,y);
-
-// if (GetIndexFromPosition( AliMUONSegmentPosition::Name(x,y)) )
-// return GetIndexFromPosition( AliMUONSegmentPosition::Name(x,y) );
-
-// Float_t xl= ((Int_t) x*10 )/10.;
-// Float_t yl= ((Int_t) y*10 )/10.;
-// Int_t ix,iy, ixp;
-
-// for(ix=1; ix<4; ix++) {
-// xl = ((Int_t) 0.5+10.*(x + ((Float_t) ix )*0.1))/10.;
-// for(iy=-ix; iy<ix+1; iy++) {
-// printf("A %d and %d and %f and %f \n",ix,iy,xl,yl);
-// yl = ((Int_t) 10.*(y + ((Float_t) iy )*0.1))/10. ;
-// sprintf(name,"%5.1f-%5.1f",xl, yl);
-// if (GetIndexFromPosition(name)) break;
-// }
-// if (GetIndexFromPosition(name)) break;
-
-
-// for(ixp=ix-1; ixp>-ix-1; ixp--) {
-// xl = ((Int_t) 0.5+10.*(x + ((Float_t) ixp )*0.1))/10. ;
-// printf("B %d and %d and %f and %f \n",ixp,ix, xl, yl);
-// sprintf(name,"%5.1f-%5.1f",xl, yl);
-// if (GetIndexFromPosition(name)) break;
-// }
-// if (GetIndexFromPosition(name)) break;
-
-// for(iy=ix-1; iy>-ix-1; iy--) {
-// yl = ((Int_t) 0.5+10.*(y + ((Float_t) iy )*0.1))/10. ;
-// printf("C %d and %d and %f and %f \n",-ix,iy,xl,yl);
-// sprintf(name,"%5.1f-%5.1f",xl, yl);
-// if (GetIndexFromPosition(name)) break;
-// }
-// if (GetIndexFromPosition(name)) break;
-
-// for(ixp=-ix+1; ixp<ix+1; ixp++) {
-// xl = ((Int_t) 0.5+10.*(x + ((Float_t) ixp )*0.1))/10. ;
-// printf("D %d and %d and %f and %f \n",ixp,-ix,xl,yl);
-// sprintf(name,"%5.1f-%5.1f",xl, yl);
-// if (GetIndexFromPosition(name)) break;
-// }
-// if (GetIndexFromPosition(name)) break;
-// }
-// return GetIndexFromPosition(name);
- return 0x0;
-}
-//_________________________________________________
void AliMUONSegmentationDetectionElement::Init(const char * DetectionElementType)
{
TString elementType(DetectionElementType);
fSegmentationMappingFileBending = fgkDefaultTop+fgkStationDir+"345"
+fgkBendingDir+"/"+elementType+fgkBendingExt+fgkFileExt;
- printf("file is %s\n", fSegmentationMappingFileBending.Data());
fSegmentationMappingFileNonBending = fgkDefaultTop+fgkStationDir+"345"
+fgkNonBendingDir+"/"+elementType+fgkNonBendingExt+fgkFileExt;
Int_t icathode;
//Bendingplane
icathode=0;
+ Info("ReadingSegmentationMappingFile","%s", fSegmentationMappingFileBending.Data());
ReadingSegmentationMappingFile(fSegmentationMappingFileBending ,icathode);
//NonBendingplane
icathode=1;
+ Info("Init","Reading mapping file is %s\n", fSegmentationMappingFileNonBending.Data());
ReadingSegmentationMappingFile(fSegmentationMappingFileNonBending,icathode);
}
{
ifstream in( infile, ios::in);
if (!in) {
- // Error("ReadingSegmentationMappingFile", "File not found.");
+ Error("ReadingSegmentationMappingFile", "File not found.");
}
else {
Int_t id, ix, iy, idmanu, idchannel;
Float_t x, y;
- while ( !in.eof()) {
+ do {
in >> id >> ix >> iy >> x >> y >> idmanu >> idchannel;
- printf("id=%d ix=%d iy=%d x=%f y=%f idmanu=%d and idchannel=%d\n",id, ix, iy, x, y,idmanu, idchannel);
+ // printf("id=%d ix=%d iy=%d x=%f y=%f idmanu=%d and idchannel=%d\n",id, ix, iy, x, y,idmanu, idchannel);
fListOfIndexes->AddAt( new AliMUONSegmentIndex(id,ix,iy,cathode), id);
fListOfManuIndexes->AddAt( new AliMUONSegmentManuIndex(id,idmanu,0,idchannel), id);;
fListOfPositions->AddAt( new AliMUONSegmentPosition(id, x, y,cathode), id);;
- ( (AliMUONSegmentIndex* )fListOfIndexes->At(id))->Print();
- ( (AliMUONSegmentManuIndex*)fListOfManuIndexes->At(id))->Print();
- ( (AliMUONSegmentPosition*)fListOfPositions->At(id))->Print();
+ //( (AliMUONSegmentIndex* )fListOfIndexes->At(id))->Print();
+ //( (AliMUONSegmentManuIndex*)fListOfManuIndexes->At(id))->Print();
+ //( (AliMUONSegmentPosition*)fListOfPositions->At(id))->Print();
fMapManuIndexIndex->Add( fListOfManuIndexes->At(id), fListOfIndexes->At(id));
fMapIndexManuIndex->Add( fListOfIndexes->At(id), fListOfManuIndexes->At(id));
fMapIndexPosition->Add( fListOfIndexes->At(id), fListOfPositions->At(id));
- fMapPositionIndex->Add( fListOfPositions->At(id), fListOfIndexes->At(id) );
- }
+ fMapPositionIndex->Add( fListOfPositions->At(id), fListOfIndexes->At(id) );
+ }
+ while ( !in.eof());
}
in.close();
}
//===========================================================
#include <Riostream.h>
-
-#include <TObject.h>
#include <TString.h>
-#include <TArrayF.h>
+
+#include "AliSegmentation.h"
class TClonesArray;
class TMap;
//AliMUONSegmentationDetectionElement(const char* ElementType="");
virtual ~AliMUONSegmentationDetectionElement();
- // User functions
+ // User common functions
+
+ AliMUONSegmentIndex * FindIndexFromPosition(Float_t x, Float_t y, Int_t cathode);
AliMUONSegmentIndex * GetIndex(Int_t manu, Int_t channel) const;
- AliMUONSegmentIndex * GetIndexFromPosition(Float_t x, Float_t y, Int_t icathode) const;
+ AliMUONSegmentIndex * GetIndexFromPosition(Float_t x, Float_t y, Int_t cathode) const;
AliMUONSegmentManuIndex * GetManuIndex( Int_t padx, Int_t pady, Int_t cathode) const ;
AliMUONSegmentPosition * GetPosition(Int_t padx, Int_t pady, Int_t cathode) const ;
-
+ TObjArray * ListOfIndexes() {return fListOfIndexes;}
+ TObjArray * ListOfManuIndexes() {return fListOfManuIndexes;}
+ TObjArray * ListOfPositions() {return fListOfPositions;}
+ void Init(const char * DetectionElementType="slat220000N");
+ void ReadingSegmentationMappingFile(TString infile, Int_t cathode);
+
+ // virtual functions from AliSegmentation. In future this class should derive from AliSegmentation
+ Float_t GetAnod(Float_t xhit) const; // Anod wire coordinate closest to xhit
+ void SetDAnod(Float_t D) {fWireD = D;}; // Wire Pitch
+ void GetPadI(Float_t x, Float_t y , Int_t cathode, Int_t &padx, Int_t &pady); // Transform from Position to closest Index
+ void GetPadC(Int_t ix, Int_t iy, Int_t cathode, Float_t &x, Float_t &y ); // Transform from Index to Position
+/* void FirstPad(Float_t xhit, Float_t yhit, Float_t dx, Float_t dy);// Initialiser */
+/* void NextPad(); // Stepper */
+/* Int_t MorePads(); // Condition */
+/* void Neighbours(Int_t iX, Int_t iY, Int_t* Nlist, Int_t Xlist[10], Int_t Ylist[10]); // Get next neighbours */
+
+ protected:
AliMUONSegmentIndex * GetIndex( const char * SegmentManuIndexName)const;
AliMUONSegmentIndex * GetIndexFromPosition( const char * PositionName)const;
AliMUONSegmentManuIndex * GetManuIndex( const char * SegmentIndexName) const;
AliMUONSegmentPosition * GetPosition( const char * SegmentIndexName) const;
- TObjArray * ListOfIndexes() {return fListOfIndexes;}
- TObjArray * ListOfManuIndexes() {return fListOfIndexes;}
- TObjArray * ListOfPositions() {return fListOfIndexes;}
-
AliMUONSegmentManuIndex * FindManuIndex(const char* ManuIndexName="") const;
- AliMUONSegmentIndex * FindIndex(const char* IndexName="") const;
+ AliMUONSegmentIndex * FindIndex(const char* IndexName="") const;
- AliMUONSegmentIndex * FindIndexFromPosition(Float_t x, Float_t y, Int_t cathode) const;
-
- void Init(const char * DetectionElementType="slat220000N");
-
- void ReadingSegmentationMappingFile(TString infile, Int_t cathode);
-
- protected:
AliMUONSegmentationDetectionElement(const AliMUONSegmentationDetectionElement& rhs);
private:
static const TString fgkNonBendingExt; // bending file extention
// data members
- TString fDetectionElementType; // Type of detection element St1Sector, slat220000N, etc ....
- TString fSegmentationMappingFileBending; // Segmentation & mapping file for bending plane
- TString fSegmentationMappingFileNonBending; // Segmentation & mapping file for non bending plane
+ Float_t fWireD; // Wire pitch in cm
+ Float_t fWireX0; // Initial X0 position in local coordinates of the first wire
+ Int_t fCurrentSegment;// Index of the current segment
+ TString fDetectionElementType; // Type of detection element St1Sector, slat220000N, etc ....
+ TString fSegmentationMappingFileBending; // Segmentation & mapping file for bending plane
+ TString fSegmentationMappingFileNonBending; // Segmentation & mapping file for non bending plane
TObjArray * fListOfIndexes; // TObject Array fo AliMUONSegmentIndex
TObjArray * fListOfManuIndexes; // TObject Array fo AliMUONSegmentManuIndex
TObjArray * fListOfPositions; // TObject Array fo AliMUONSegmentPositions
- TMap * fMapManuIndexIndex; // Map with key ManuIndex and value = Index
- TMap * fMapIndexManuIndex;// Map with key ManuIndexIndex and value = ManuIndex
- TMap * fMapIndexPosition;// Map with key Index and value = Position
- TMap * fMapPositionIndex;// Map with key Index and value = Position
-
+ TMap * fMapManuIndexIndex; // Map with key ManuIndex and value = Index
+ TMap * fMapIndexManuIndex;// Map with key ManuIndexIndex and value = ManuIndex
+ TMap * fMapIndexPosition;// Map with key Index and value = Position
+ TMap * fMapPositionIndex;// Map with key Index and value = Position
ClassDef(AliMUONSegmentationDetectionElement,1) // Segmentation for MUON detection elements