- added the PHOS library to the autotools configuration
[u/mrichter/AliRoot.git] / EMCAL / AliEMCALGeometryOfflineTrd1.cxx
CommitLineData
1963b290 1/**************************************************************************
2 * Copyright(c) 1998-2004, 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// GeometryOfflineTrd1 class for EMCAL : singleton
14ce0a6e 16// implementation of
17// specific geometry
18// for trd 1
19//
1963b290 20//*-- Author: Aleksei Pavlinov (WSU)
21
22/* $Id$*/
23
24#include <TBrowser.h>
25#include <TMath.h>
26#include <TVector2.h>
27#include <TVector3.h>
28#include <TObjArray.h>
29
30#include "AliEMCALGeometryOfflineTrd1.h"
31#include "AliEMCALShishKebabTrd1Module.h"
32#include "AliEMCALGeometry.h"
33
91233bc7 34ClassImp(AliEMCALGeometryOfflineTrd1)
1963b290 35
36AliEMCALGeometryOfflineTrd1* AliEMCALGeometryOfflineTrd1::fgGeomOfflineTrd1=0;
37
0a4cb131 38//___________________________________________________________________________
1963b290 39AliEMCALGeometryOfflineTrd1* AliEMCALGeometryOfflineTrd1::GetInstance()
40{
14ce0a6e 41 //retrurn instance of the geometry
1963b290 42 if(fgGeomOfflineTrd1==0) {
43 fgGeomOfflineTrd1 = new AliEMCALGeometryOfflineTrd1();
44 }
45 return fgGeomOfflineTrd1;
46}
47
0a4cb131 48//___________________________________________________________________________
1963b290 49AliEMCALGeometryOfflineTrd1::AliEMCALGeometryOfflineTrd1() : TNamed("geomTRD1","")
14ce0a6e 50{
51 // this private constarctor
1963b290 52 fGeometry = AliEMCALGeometry::GetInstance("SHISH_62_TRD1");
53 Init();
54}
55
0a4cb131 56//___________________________________________________________________________
57AliEMCALGeometryOfflineTrd1::AliEMCALGeometryOfflineTrd1(const AliEMCALGeometryOfflineTrd1& geom):TNamed(geom.GetName(),geom.GetTitle())
58{
59 //copy ctor
60 fGeometry = geom.fGeometry;
61 fMaxInEta = geom.fMaxInEta;
62
63 for(Int_t mod = 0; mod < 26; mod++) fTrd1Modules[mod] = geom.fTrd1Modules[mod];
64
65 fSMMaxEta = geom.fSMMaxEta;
66 for(Int_t i = 0; i < fSMMaxEta; i++) fSMPositionEta[i] = geom.fSMPositionEta[i];
67
68 fSMPositionPhi = geom.fSMPositionPhi;
69 fShiftOnPhi = geom.fShiftOnPhi;
70 fNPhiSuperModule = geom.fNPhiSuperModule;
71 for(Int_t rot = 0; rot < 6; rot++) {
72 fSuperModuleRotationZ[rot] = geom.fSuperModuleRotationZ[rot];
73 fNameSuperModuleRotationZ[rot] = geom.fNameSuperModuleRotationZ[rot];
74 }
75 fSuperModuleRotationX = geom.fSuperModuleRotationX;
76 for(Int_t rot = 0; rot < 12; rot++) fSuperModuleRotation[rot] = geom.fSuperModuleRotation[rot];
77 fXYZofCells = geom.fXYZofCells;
78
79}
80
81//___________________________________________________________________________
1963b290 82void AliEMCALGeometryOfflineTrd1::Init()
83{
84 // Super module
85 // ETA direction
86 fMaxInEta = fGeometry->GetNZ();
87 fTrd1Modules[0] = new AliEMCALShishKebabTrd1Module();
88 fSMMaxEta = 2*fMaxInEta;
89 fSMPositionEta = new TVector2[fSMMaxEta];
e52475ed 90 fSMPositionEta[0] = fTrd1Modules[0]->GetCenterOfCellInLocalCoordinateofSM(1);
91 fSMPositionEta[1] = fTrd1Modules[0]->GetCenterOfCellInLocalCoordinateofSM(2);
1963b290 92 for(Int_t i=1; i<fMaxInEta; i++) {
93 fTrd1Modules[i] = new AliEMCALShishKebabTrd1Module(*(fTrd1Modules[i-1]));
e52475ed 94 fSMPositionEta[2*i] = fTrd1Modules[i]->GetCenterOfCellInLocalCoordinateofSM(1);
95 fSMPositionEta[2*i+1] = fTrd1Modules[i]->GetCenterOfCellInLocalCoordinateofSM(2);
1963b290 96 }
97 // PHI direction
98 fSMPositionPhi.Set(2*fGeometry->GetNPhi());
99 fShiftOnPhi = -fGeometry->GetPhiModuleSize()*fGeometry->GetNPhi()/2;
100 for(Int_t i=0; i<fGeometry->GetNPhi(); i++) {
101 fSMPositionPhi[2*i] = fGeometry->GetPhiModuleSize() * (double(i) + 0.25);
102 fSMPositionPhi[2*i+1] = fGeometry->GetPhiTileSize() + fSMPositionPhi[2*i];
103 }
104
105 // Super Module rotations
106 fNPhiSuperModule = fGeometry->GetNPhiSuperModule(); // see AliEMCALv0
107 double dphi = (fGeometry->GetArm1PhiMax() - fGeometry->GetArm1PhiMin()) / fNPhiSuperModule;
108 double phi, phiRad;
109 fSuperModuleRotationX.RotateX(TMath::Pi()); // matrix looks not so nice
110 for(Int_t i=0; i<fNPhiSuperModule; i++){
111 // rotations arround Z
112 phi = fGeometry->GetArm1PhiMin() + dphi*(2*i+1)/2.; // phi= 70, 90, 110, 130, 150, 170
113 phiRad = phi*TMath::DegToRad();
114 if(i==1) phiRad = TMath::PiOver2();
115 fSuperModuleRotationZ[i].RotateZ(phiRad);
116 TString ntmp("rotationZ_");
117 ntmp += int(phi);
118 fNameSuperModuleRotationZ[i] = ntmp;
119 // Super Module rotation
120 fSuperModuleRotation[2*i] = fSuperModuleRotationZ[i]; // Z
121 fSuperModuleRotation[2*i+1] = fSuperModuleRotationZ[i] * fSuperModuleRotationX; // Z*X
122 }
123 // Fill fXYZofCells
124 fXYZofCells = new TObjArray(fGeometry->GetNCells());
125 fXYZofCells->SetName("CellsInGC");
126 Int_t nSupMod, nTower, nIphi, nIeta, iphi, ieta;
127 for(Int_t absId=1; absId<=fGeometry->GetNCells(); absId++){
128 if(fGeometry->GetCellIndex(absId, nSupMod,nTower,nIphi,nIeta)){
d87bd045 129 fGeometry->GetCellPhiEtaIndexInSModule(nSupMod,nTower,nIphi,nIeta, iphi,ieta);
1963b290 130 TVector3 *v = new TVector3;
131 v->SetX(fSMPositionEta[ieta-1].Y());
132 v->SetZ(fSMPositionEta[ieta-1].X());
133 v->SetY(fSMPositionPhi[iphi-1] + fShiftOnPhi);
134 v->Transform(fSuperModuleRotation[nSupMod-1]);
135 fXYZofCells->AddAt(v,absId-1);
136 }
137 }
138}
139
0a4cb131 140//___________________________________________________________________________
eb0b1051 141TVector3& AliEMCALGeometryOfflineTrd1::PosInSuperModule(int nSupMod, Int_t nTower, Int_t nIphi, Int_t nIeta)
14ce0a6e 142{
143 //return location of position within supermodule
144 // 10-nov-04
1963b290 145 static Int_t iphi, ieta;
146 static TVector3 v;
d87bd045 147 fGeometry->GetCellPhiEtaIndexInSModule(nSupMod, nTower,nIphi,nIeta, iphi,ieta);
1963b290 148
149 // x-radius; y-phi; eta-z;
150 v.SetXYZ(fSMPositionEta[ieta].Y(), fSMPositionPhi[iphi], fSMPositionEta[ieta].X());
151 return v;
152}
153
0a4cb131 154//___________________________________________________________________________
eb0b1051 155void AliEMCALGeometryOfflineTrd1::PositionInSuperModule(Int_t iphi, Int_t ieta,
1963b290 156double &lphi, double &leta)
157{
14ce0a6e 158 //return location of position within supermodule
159
1963b290 160 static Int_t ie=0;
161 lphi = fSMPositionPhi[iphi-1];
162 ie = ieta - 1;
163 if(ie<0) ie = 0;
164 if(ie>fSMMaxEta-1) ie = fSMMaxEta-1;
165 leta = fSMPositionEta[ie].X();
166}
167
0a4cb131 168//___________________________________________________________________________
eb0b1051 169void AliEMCALGeometryOfflineTrd1::PositionInSuperModule(int nSupMod, Int_t nTower, Int_t nIphi, Int_t nIeta,
1963b290 170double &lphi, double &leta)
171{
14ce0a6e 172 //return location of position within supermodule
173
1963b290 174 static Int_t iphi,ieta;
d87bd045 175 fGeometry->GetCellPhiEtaIndexInSModule(nSupMod, nTower,nIphi,nIeta,iphi,ieta);
1963b290 176 PositionInSuperModule(iphi,ieta, lphi,leta);
177}
178
0a4cb131 179//___________________________________________________________________________
1963b290 180TRotation* AliEMCALGeometryOfflineTrd1::Rotation(Int_t module)
14ce0a6e 181{
182 //return rotation matrix for module
183 // module chabge from 1 to 12
1963b290 184 if(module<1) module=1;
185 if(module>12) module=12;
186 return &fSuperModuleRotation[module];
187}
188
0a4cb131 189//___________________________________________________________________________
1963b290 190TVector3* AliEMCALGeometryOfflineTrd1::CellPosition(int absId)
14ce0a6e 191{
192 //return cell position given absoluted cell id
193 // 15-nov-04
1963b290 194 if(absId<1 || absId>fXYZofCells->GetSize()) return 0;
195 return (TVector3*)fXYZofCells->At(absId-1);
196}
197
0a4cb131 198//___________________________________________________________________________
1963b290 199void AliEMCALGeometryOfflineTrd1::PrintSuperModule()
14ce0a6e 200{
201 //utility method for printing supermodule info
202 // 12-nov-04
1963b290 203 printf(" ** Super module ** fSMMaxEta %i fSMMaxPHI %i\n ETA eta(Z) (X)\n",
204 fSMMaxEta,fSMPositionPhi.GetSize());
205 for(Int_t i=0; i<fSMMaxEta; i++) {
206 printf("%3i | %8.3f %8.3f\n", i+1,fSMPositionEta[i].X(), fSMPositionEta[i].Y());
207 }
208 printf("\n PHI (Y)\n");
209 for(Int_t i=0; i<fSMPositionPhi.GetSize(); i++) {
210 printf("%3i | %8.3f\n",i+1, fSMPositionPhi[i]);
211 }
212}
213
0a4cb131 214//___________________________________________________________________________
1963b290 215void AliEMCALGeometryOfflineTrd1::PrintCell(Int_t absId)
216{
14ce0a6e 217 //utility method for printing cell info
1963b290 218 Int_t nSupMod, nTower, nIphi, nIeta, iphi, ieta;
219 if(fGeometry->GetCellIndex(absId, nSupMod,nTower,nIphi,nIeta)){
d87bd045 220 fGeometry->GetCellPhiEtaIndexInSModule(nSupMod,nTower,nIphi,nIeta, iphi,ieta);
1963b290 221 TVector3 *v = CellPosition(absId);
222 printf("(%5i) X %8.3f Y %8.3f Z %8.3f | #sup.Mod %2i #tower %3i nIphi %1i nIeta %1i | iphi %2i ieta %2i\n",
223 absId, v->X(),v->Y(),v->Z(), nSupMod,nTower,nIphi,nIeta, iphi,ieta);
224 } else {
225 Warning("PrintCell","Wrong abs id %i\n",absId);
226 }
227}
228
0a4cb131 229//___________________________________________________________________________
1963b290 230void AliEMCALGeometryOfflineTrd1::Browse(TBrowser* b)
231{
14ce0a6e 232 //Browse the geometry
1963b290 233 if(fGeometry) b->Add(fGeometry);
234
235 for(Int_t i=0; i<fMaxInEta; i++) if(fTrd1Modules[i]>0) b->Add(fTrd1Modules[i]);
236
237 for(Int_t i=0; i<fNPhiSuperModule; i++){
238 b->Add(&fSuperModuleRotationZ[i], fNameSuperModuleRotationZ[i].Data());
239 for(Int_t j=0; j<2; j++) {
240 TString name("rotationM_"); name += (2*i+j);
241 b->Add(&fSuperModuleRotation[2*i+j], name.Data());
242 }
243 }
244
245 b->Add(&fSuperModuleRotationX, "rotationX_180");
246
247 b->Add(fXYZofCells);
248}
249
0a4cb131 250//___________________________________________________________________________
1963b290 251Bool_t AliEMCALGeometryOfflineTrd1::IsFolder() const
252{
14ce0a6e 253 //folder check
1963b290 254 return kTRUE;
255}