]> git.uio.no Git - u/mrichter/AliRoot.git/blame - MFT/MFTbase/AliMFTSegmentation.cxx
Update master to aliroot
[u/mrichter/AliRoot.git] / MFT / MFTbase / 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(),
ffc53def 48 fMFTPlanes(0x0)
820b4d9e 49{
ffc53def 50
d4643a10 51 // constructor
ffc53def 52
53 fMFTPlanes = new TClonesArray("AliMFTPlane", fNMaxPlanes);
54 fMFTPlanes -> SetOwner(kTRUE);
820b4d9e 55 Float_t zCenter, rMin, rMax, pixelSizeX, pixelSizeY, thicknessActive, thicknessSupport, thicknessReadout;
bcaf50eb 56 Float_t equivalentSilicon, equivalentSiliconBeforeFront, equivalentSiliconBeforeBack, hasPixelRectangularPatternAlongY;
820b4d9e 57
58 TFile *geomFile = new TFile(nameGeomFile);
59 TNtuple *geomNtuple = (TNtuple*) geomFile->Get("AliMFTGeometry");
60
61 geomNtuple -> SetBranchAddress("zCenter", &zCenter);
62 geomNtuple -> SetBranchAddress("rMin", &rMin);
63 geomNtuple -> SetBranchAddress("rMax", &rMax);
64 geomNtuple -> SetBranchAddress("pixelSizeX", &pixelSizeX);
65 geomNtuple -> SetBranchAddress("pixelSizeY", &pixelSizeY);
66 geomNtuple -> SetBranchAddress("thicknessActive", &thicknessActive);
67 geomNtuple -> SetBranchAddress("thicknessSupport", &thicknessSupport);
68 geomNtuple -> SetBranchAddress("thicknessReadout", &thicknessReadout);
69 geomNtuple -> SetBranchAddress("equivalentSilicon", &equivalentSilicon);
70 geomNtuple -> SetBranchAddress("equivalentSiliconBeforeFront", &equivalentSiliconBeforeFront);
71 geomNtuple -> SetBranchAddress("equivalentSiliconBeforeBack", &equivalentSiliconBeforeBack);
bcaf50eb 72 if (geomNtuple -> GetBranch("hasPixelRectangularPatternAlongY")) {
73 geomNtuple -> SetBranchAddress("hasPixelRectangularPatternAlongY", &hasPixelRectangularPatternAlongY);
74 }
75 else hasPixelRectangularPatternAlongY = 0.;
820b4d9e 76
77 Int_t nPlanes = geomNtuple->GetEntries();
78
79 for (Int_t iPlane=0; iPlane<nPlanes; iPlane++) {
80
81 // Create new plane
82
ffc53def 83 AliInfo(Form("Setting segmentation for MFT plane #%02d\n", iPlane));
820b4d9e 84
85 geomNtuple -> GetEntry(iPlane);
86 zCenter = TMath::Abs(zCenter);
87
88 AliMFTPlane *plane = new AliMFTPlane(Form("MFTPlane_%02d", iPlane), Form("MFTPlane_%02d", iPlane));
bcaf50eb 89
90 plane -> Init(iPlane,
91 zCenter,
92 rMin,
93 rMax,
94 pixelSizeX,
95 pixelSizeY,
96 thicknessActive,
97 thicknessSupport,
98 thicknessReadout,
99 (hasPixelRectangularPatternAlongY>0.5));
100
820b4d9e 101 plane -> SetEquivalentSilicon(equivalentSilicon);
102 plane -> SetEquivalentSiliconBeforeFront(equivalentSiliconBeforeFront);
103 plane -> SetEquivalentSiliconBeforeBack(equivalentSiliconBeforeBack);
104 plane -> CreateStructure();
105
106 new ((*fMFTPlanes)[fMFTPlanes->GetEntries()]) AliMFTPlane(*plane);
ffc53def 107 delete plane;
108
820b4d9e 109 }
110
111 delete geomFile;
112
ffc53def 113 AliInfo("MFT segmentation set!\n");
114
115}
116
117//====================================================================================================================================================
118
119AliMFTSegmentation::~AliMFTSegmentation() {
120
121 if (fMFTPlanes) fMFTPlanes->Delete();
122 delete fMFTPlanes;
123
124}
820b4d9e 125
ffc53def 126//====================================================================================================================================================
127
128void AliMFTSegmentation::Clear(const Option_t* /*opt*/) {
129
130 if (fMFTPlanes) fMFTPlanes->Delete();
131 delete fMFTPlanes;
132 fMFTPlanes = NULL;
133
820b4d9e 134}
135
136//====================================================================================================================================================
137
d4643a10 138THnSparseC* AliMFTSegmentation::GetDetElem(Int_t detElemID) const {
820b4d9e 139
140 // Find det elem
141
142 Int_t planeNb = detElemID/fNMaxDetElemPerPlane;
143 Int_t detElemNb = detElemID - planeNb*fNMaxDetElemPerPlane;
144
145 THnSparseC *detElem = GetPlane(planeNb)->GetActiveElement(detElemNb);
146
147 return detElem;
148
149}
150
151//====================================================================================================================================================
152
153Bool_t AliMFTSegmentation::Hit2PixelID(Double_t xHit, Double_t yHit, Int_t detElemID, Int_t &xPixel, Int_t &yPixel) {
154
bcaf50eb 155 // xPixel and yPixel start from 0
156
820b4d9e 157 THnSparseC *detElem = GetDetElem(detElemID);
158
159 if ( xHit<detElem->GetAxis(0)->GetXmin() ||
160 xHit>detElem->GetAxis(0)->GetXmax() ||
161 yHit<detElem->GetAxis(1)->GetXmin() ||
162 yHit>detElem->GetAxis(1)->GetXmax() ) return kFALSE;
163
164 xPixel = detElem->GetAxis(0)->FindBin(xHit) - 1;
165 yPixel = detElem->GetAxis(1)->FindBin(yHit) - 1;
166
167 return kTRUE;
168
169}
170
171//====================================================================================================================================================
172
bcaf50eb 173Bool_t AliMFTSegmentation::DoesPixelExist(Int_t detElemID, Int_t xPixel, Int_t yPixel) {
174
175 THnSparseC *detElem = GetDetElem(detElemID);
176
177 if (xPixel>=0 && xPixel<detElem->GetAxis(0)->GetNbins() && yPixel>=0 && yPixel<detElem->GetAxis(1)->GetNbins()) return kTRUE;
178 else return kFALSE;
179
180}
181
182//====================================================================================================================================================
183