]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MFT/AliMFTSegmentation.cxx
warning fix
[u/mrichter/AliRoot.git] / MFT / AliMFTSegmentation.cxx
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
31 ClassImp(AliMFTSegmentation)
32
33 //====================================================================================================================================================
34
35 AliMFTSegmentation::AliMFTSegmentation(): 
36   TObject(),
37   fMFTPlanes(0)
38
39
40   // TO BE CHECKED
41   
42   // default constructor
43
44   fMFTPlanes = new TClonesArray("AliMFTPlane", fNMaxPlanes);
45
46 }
47
48 //====================================================================================================================================================
49
50 AliMFTSegmentation::AliMFTSegmentation(const Char_t *nameGeomFile): 
51   TObject(),
52   fMFTPlanes(0)
53
54
55   fMFTPlanes = new TClonesArray("AliMFTPlane", fNMaxPlanes);
56
57   Float_t zCenter, rMin, rMax, pixelSizeX, pixelSizeY, thicknessActive, thicknessSupport, thicknessReadout;
58   Float_t equivalentSilicon, equivalentSiliconBeforeFront, equivalentSiliconBeforeBack;
59
60   TFile *geomFile = new TFile(nameGeomFile);
61   TNtuple *geomNtuple = (TNtuple*) geomFile->Get("AliMFTGeometry");
62
63   geomNtuple -> SetBranchAddress("zCenter", &zCenter);
64   geomNtuple -> SetBranchAddress("rMin",    &rMin);
65   geomNtuple -> SetBranchAddress("rMax",    &rMax);
66   geomNtuple -> SetBranchAddress("pixelSizeX", &pixelSizeX);
67   geomNtuple -> SetBranchAddress("pixelSizeY", &pixelSizeY);
68   geomNtuple -> SetBranchAddress("thicknessActive",  &thicknessActive);
69   geomNtuple -> SetBranchAddress("thicknessSupport", &thicknessSupport);
70   geomNtuple -> SetBranchAddress("thicknessReadout", &thicknessReadout);
71   geomNtuple -> SetBranchAddress("equivalentSilicon",            &equivalentSilicon);
72   geomNtuple -> SetBranchAddress("equivalentSiliconBeforeFront", &equivalentSiliconBeforeFront);
73   geomNtuple -> SetBranchAddress("equivalentSiliconBeforeBack",  &equivalentSiliconBeforeBack);
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));
87     plane -> Init(iPlane, zCenter, rMin, rMax, pixelSizeX, pixelSizeY, thicknessActive, thicknessSupport, thicknessReadout);
88     plane -> SetEquivalentSilicon(equivalentSilicon);
89     plane -> SetEquivalentSiliconBeforeFront(equivalentSiliconBeforeFront);
90     plane -> SetEquivalentSiliconBeforeBack(equivalentSiliconBeforeBack);
91     plane -> CreateStructure();
92     
93     new ((*fMFTPlanes)[fMFTPlanes->GetEntries()]) AliMFTPlane(*plane);
94
95   }
96   
97   delete geomFile;
98
99   printf("MFT segmentation set!\n");
100
101 }
102
103 //====================================================================================================================================================
104
105 THnSparseC* AliMFTSegmentation::GetDetElem(Int_t detElemID) {
106       
107   // Find det elem
108
109   Int_t planeNb = detElemID/fNMaxDetElemPerPlane;
110   Int_t detElemNb = detElemID - planeNb*fNMaxDetElemPerPlane;
111   
112   THnSparseC *detElem = GetPlane(planeNb)->GetActiveElement(detElemNb);
113
114   return detElem;
115
116 }
117
118 //====================================================================================================================================================
119
120 Bool_t AliMFTSegmentation::Hit2PixelID(Double_t xHit, Double_t yHit, Int_t detElemID, Int_t &xPixel, Int_t &yPixel) {
121
122   THnSparseC *detElem = GetDetElem(detElemID);
123
124   if ( xHit<detElem->GetAxis(0)->GetXmin() ||
125        xHit>detElem->GetAxis(0)->GetXmax() ||
126        yHit<detElem->GetAxis(1)->GetXmin() ||
127        yHit>detElem->GetAxis(1)->GetXmax() ) return kFALSE;
128
129   xPixel = detElem->GetAxis(0)->FindBin(xHit) - 1;
130   yPixel = detElem->GetAxis(1)->FindBin(yHit) - 1;
131
132   return kTRUE;
133
134 }
135
136 //====================================================================================================================================================
137