Modified init of AliMuonForwardTrack
[u/mrichter/AliRoot.git] / MFT / AliMFTSegmentation.cxx
CommitLineData
820b4d9e 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//====================================================================================================================================================
17//
18// Segmentation class for the planes of the ALICE Muon Forward Tracker
19//
20// Contact author: antonio.uras@cern.ch
21//
22//====================================================================================================================================================
23
24#include "TFile.h"
25#include "TNtuple.h"
26#include "TClonesArray.h"
27#include "TMath.h"
28#include "AliMFTPlane.h"
29#include "AliMFTSegmentation.h"
30
31ClassImp(AliMFTSegmentation)
32
33//====================================================================================================================================================
34
35AliMFTSegmentation::AliMFTSegmentation():
36 TObject(),
37 fMFTPlanes(0)
38{
39
820b4d9e 40 // default constructor
41
820b4d9e 42}
43
44//====================================================================================================================================================
45
46AliMFTSegmentation::AliMFTSegmentation(const Char_t *nameGeomFile):
47 TObject(),
d4643a10 48 fMFTPlanes(new TClonesArray("AliMFTPlane", fNMaxPlanes))
820b4d9e 49{
50
d4643a10 51 // constructor
820b4d9e 52
53 Float_t zCenter, rMin, rMax, pixelSizeX, pixelSizeY, thicknessActive, thicknessSupport, thicknessReadout;
bcaf50eb 54 Float_t equivalentSilicon, equivalentSiliconBeforeFront, equivalentSiliconBeforeBack, hasPixelRectangularPatternAlongY;
820b4d9e 55
56 TFile *geomFile = new TFile(nameGeomFile);
57 TNtuple *geomNtuple = (TNtuple*) geomFile->Get("AliMFTGeometry");
58
59 geomNtuple -> SetBranchAddress("zCenter", &zCenter);
60 geomNtuple -> SetBranchAddress("rMin", &rMin);
61 geomNtuple -> SetBranchAddress("rMax", &rMax);
62 geomNtuple -> SetBranchAddress("pixelSizeX", &pixelSizeX);
63 geomNtuple -> SetBranchAddress("pixelSizeY", &pixelSizeY);
64 geomNtuple -> SetBranchAddress("thicknessActive", &thicknessActive);
65 geomNtuple -> SetBranchAddress("thicknessSupport", &thicknessSupport);
66 geomNtuple -> SetBranchAddress("thicknessReadout", &thicknessReadout);
67 geomNtuple -> SetBranchAddress("equivalentSilicon", &equivalentSilicon);
68 geomNtuple -> SetBranchAddress("equivalentSiliconBeforeFront", &equivalentSiliconBeforeFront);
69 geomNtuple -> SetBranchAddress("equivalentSiliconBeforeBack", &equivalentSiliconBeforeBack);
bcaf50eb 70 if (geomNtuple -> GetBranch("hasPixelRectangularPatternAlongY")) {
71 geomNtuple -> SetBranchAddress("hasPixelRectangularPatternAlongY", &hasPixelRectangularPatternAlongY);
72 }
73 else hasPixelRectangularPatternAlongY = 0.;
820b4d9e 74
75 Int_t nPlanes = geomNtuple->GetEntries();
76
77 for (Int_t iPlane=0; iPlane<nPlanes; iPlane++) {
78
79 // Create new plane
80
81 printf("Setting segmentation for MFT plane #%02d\n", iPlane);
82
83 geomNtuple -> GetEntry(iPlane);
84 zCenter = TMath::Abs(zCenter);
85
86 AliMFTPlane *plane = new AliMFTPlane(Form("MFTPlane_%02d", iPlane), Form("MFTPlane_%02d", iPlane));
bcaf50eb 87
88 plane -> Init(iPlane,
89 zCenter,
90 rMin,
91 rMax,
92 pixelSizeX,
93 pixelSizeY,
94 thicknessActive,
95 thicknessSupport,
96 thicknessReadout,
97 (hasPixelRectangularPatternAlongY>0.5));
98
820b4d9e 99 plane -> SetEquivalentSilicon(equivalentSilicon);
100 plane -> SetEquivalentSiliconBeforeFront(equivalentSiliconBeforeFront);
101 plane -> SetEquivalentSiliconBeforeBack(equivalentSiliconBeforeBack);
102 plane -> CreateStructure();
103
104 new ((*fMFTPlanes)[fMFTPlanes->GetEntries()]) AliMFTPlane(*plane);
105
106 }
107
108 delete geomFile;
109
110 printf("MFT segmentation set!\n");
111
112}
113
114//====================================================================================================================================================
115
d4643a10 116THnSparseC* AliMFTSegmentation::GetDetElem(Int_t detElemID) const {
820b4d9e 117
118 // Find det elem
119
120 Int_t planeNb = detElemID/fNMaxDetElemPerPlane;
121 Int_t detElemNb = detElemID - planeNb*fNMaxDetElemPerPlane;
122
123 THnSparseC *detElem = GetPlane(planeNb)->GetActiveElement(detElemNb);
124
125 return detElem;
126
127}
128
129//====================================================================================================================================================
130
131Bool_t AliMFTSegmentation::Hit2PixelID(Double_t xHit, Double_t yHit, Int_t detElemID, Int_t &xPixel, Int_t &yPixel) {
132
bcaf50eb 133 // xPixel and yPixel start from 0
134
820b4d9e 135 THnSparseC *detElem = GetDetElem(detElemID);
136
137 if ( xHit<detElem->GetAxis(0)->GetXmin() ||
138 xHit>detElem->GetAxis(0)->GetXmax() ||
139 yHit<detElem->GetAxis(1)->GetXmin() ||
140 yHit>detElem->GetAxis(1)->GetXmax() ) return kFALSE;
141
142 xPixel = detElem->GetAxis(0)->FindBin(xHit) - 1;
143 yPixel = detElem->GetAxis(1)->FindBin(yHit) - 1;
144
145 return kTRUE;
146
147}
148
149//====================================================================================================================================================
150
bcaf50eb 151Bool_t AliMFTSegmentation::DoesPixelExist(Int_t detElemID, Int_t xPixel, Int_t yPixel) {
152
153 THnSparseC *detElem = GetDetElem(detElemID);
154
155 if (xPixel>=0 && xPixel<detElem->GetAxis(0)->GetNbins() && yPixel>=0 && yPixel<detElem->GetAxis(1)->GetNbins()) return kTRUE;
156 else return kFALSE;
157
158}
159
160//====================================================================================================================================================
161