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