1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * Author: The ALICE Off-line Project. *
5 * Contributors are mentioned in the code where appropriate. *
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 **************************************************************************/
18 // Objects of this class read txt file with survey data
19 // and convert the data into AliAlignObjParams of alignable EMCAL volumes.
20 // AliEMCALSurvey inherits TObject only to use AliLog "functions".
22 // This whole thing is just a dummy class with dummy variables until
23 // the actual survey points are determined. For now I assumed that
24 // the x,y center and starting z value of each supermodule is the only
27 // J.L. Klay - Cal Poly
33 #include <TClonesArray.h>
34 #include <TGeoManager.h>
38 #include "AliSurveyObj.h"
40 #include "AliAlignObjParams.h"
41 #include "AliEMCALGeometry.h"
42 #include "AliEMCALSurvey.h"
45 ClassImp(AliEMCALSurvey)
47 //____________________________________________________________________________
48 AliEMCALSurvey::AliEMCALSurvey()
52 //Default constructor.
57 //for now, measurements assumed to be taken at x,y center and
58 //nominal starting z value of each supermodule
60 struct AliEMCALSuperModuleCoords {
61 Double_t fX1; //x coordinate of the first supermodule point
62 Double_t fY1; //y coordinate of the first supermodule point
63 Double_t fZ1; //z coordinate of the first supermodule point
68 //____________________________________________________________________________
69 AliEMCALSurvey::AliEMCALSurvey(const TString &txtFileName)
73 //Read survey data from txt file.
74 const AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance();
76 AliError("Cannot obtain AliEMCALGeometry instance.");
80 std::ifstream inputFile(txtFileName.Data());
82 AliError(("Cannot open the survey file " + txtFileName).Data());
86 fNSuperModule = geom->GetNumberOfSuperModules();
89 Double_t *xReal = new Double_t[fNSuperModule];
90 Double_t *yReal = new Double_t[fNSuperModule];
91 Double_t *zReal = new Double_t[fNSuperModule];
93 for (Int_t i = 0; i < fNSuperModule; ++i) {
95 AliError("Error while reading input file.");
101 inputFile>>dummyInt>>xReal[i]>>yReal[i]>>zReal[i];
104 InitSuperModuleData(xReal, yReal, zReal);
111 //____________________________________________________________________________
112 AliEMCALSurvey::~AliEMCALSurvey()
114 delete [] fSuperModuleData;
117 //____________________________________________________________________________
118 void AliEMCALSurvey::CreateAliAlignObjParams(TClonesArray &array)
120 //Create AliAlignObjParams.
121 const AliEMCALGeometry * geom = AliEMCALGeometry::GetInstance();
123 AliError("Cannot obtain AliEMCALGeometry instance.");
128 AliWarning("Cannot create local transformations for supermodules - gGeoManager does not exist.");
129 AliInfo("Null shifts and rotations will be created instead.");
130 return CreateNullObjects(array, geom);
133 Int_t arrayInd = array.GetEntries(), iIndex = 0;
134 AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
135 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
137 for (Int_t smodnum = 0; smodnum < geom->GetNumberOfSuperModules(); ++smodnum) {
138 TString smodName(TString::Format("EMCAL/FullSupermodule%d", smodnum+1));
139 if(geom->GetKey110DEG() && smodnum >= 10) {
140 smodName = "EMCAL/HalfSupermodule";
141 smodName += (smodnum-10+1);
143 AliEMCALSuperModuleDelta t(GetSuperModuleTransformation(smodnum));
146 smodName.Data(), volid,
147 t.fXShift, t.fYShift, t.fZShift,
148 -t.fPsi, -t.fTheta, -t.fPhi,
156 //____________________________________________________________________________
157 void AliEMCALSurvey::CreateNullObjects(TClonesArray &array, const AliEMCALGeometry *geom)const
159 //Create null shifts and rotations.
160 Int_t arrayInd = array.GetEntries(), iIndex = 0;
161 AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
162 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
164 for (Int_t smodnum = 0; smodnum < geom->GetNumberOfSuperModules(); ++smodnum) {
165 TString smodName(TString::Format("EMCAL/FullSupermodule%d", smodnum+1));
166 if(geom->GetKey110DEG() && smodnum >= 10) {
167 smodName = "EMCAL/HalfSupermodule";
168 smodName += (smodnum-10+1);
170 new(array[arrayInd]) AliAlignObjParams(smodName.Data(), volid, 0., 0., 0., 0., 0., 0., true);
175 //____________________________________________________________________________
176 AliEMCALSurvey::AliEMCALSuperModuleDelta AliEMCALSurvey::GetSuperModuleTransformation(Int_t supModIndex)const
178 //Supermodule transformation.
179 AliEMCALSuperModuleDelta t = {0., 0., 0., 0., 0., 0.};
180 if (!fSuperModuleData)
183 return fSuperModuleData[supModIndex];
186 //____________________________________________________________________________
187 void AliEMCALSurvey::InitSuperModuleData(const Double_t *xReal, const Double_t *yReal, const Double_t *zReal)
190 AliEMCALGeometry *geom = AliEMCALGeometry::GetInstance();
191 //Center of supermodules
192 Float_t *pars = geom->GetSuperModulesPars();
193 Double_t rpos = (geom->GetEnvelop(0) + geom->GetEnvelop(1))/2.;
194 Double_t phi, phiRad, xpos, ypos, zpos;
196 AliEMCALSuperModuleCoords *idealSM = new AliEMCALSuperModuleCoords[fNSuperModule];
197 for (Int_t smodnum = 0; smodnum < geom->GetNumberOfSuperModules(); ++smodnum) {
198 AliEMCALSuperModuleCoords &smc = idealSM[smodnum];
199 phiRad = geom->GetPhiCenterOfSM(smodnum); //comes in radians
200 phi = phiRad*180./TMath::Pi(); //need degrees for AliAlignObjParams
201 xpos = rpos * TMath::Cos(phiRad);
202 ypos = rpos * TMath::Sin(phiRad);
204 if(geom->GetKey110DEG() && smodnum >= 10) {
205 xpos += (pars[1]/2. * TMath::Sin(phiRad));
206 ypos -= (pars[1]/2. * TMath::Cos(phiRad));
218 AliEMCALSuperModuleCoords *realSM = new AliEMCALSuperModuleCoords[fNSuperModule];
219 for (Int_t smodnum = 0; smodnum < geom->GetNumberOfSuperModules(); ++smodnum) {
220 AliEMCALSuperModuleCoords &smc = realSM[smodnum];
222 smc.fX1 = xReal[smodnum]; //x and y match
223 smc.fY1 = yReal[smodnum]; //x and y match
225 smc.fZ1 = zReal[smodnum]-zpos; //z measured is along end,
226 } else { //convert to middle of SM
227 smc.fZ1 = zReal[smodnum]+zpos;
231 fSuperModuleData = new AliEMCALSuperModuleDelta[fNSuperModule];
233 for (Int_t i = 0; i < fNSuperModule; ++i) {
234 const AliEMCALSuperModuleCoords &real = realSM[i];
235 const AliEMCALSuperModuleCoords &ideal = idealSM[i];
236 AliEMCALSuperModuleDelta &t = fSuperModuleData[i];
237 t.fTheta = TMath::ATan(real.fZ1 / real.fX1) -
238 TMath::ATan(ideal.fZ1 / ideal.fX1);
239 t.fTheta *= TMath::RadToDeg();
241 t.fPhi = TMath::ATan(real.fY1 / real.fX1) - TMath::ATan(ideal.fY1 / ideal.fX1);
242 t.fPhi *= TMath::RadToDeg();
243 t.fXShift = real.fX1 - ideal.fX1;
244 t.fYShift = real.fY1 - ideal.fY1;
245 t.fZShift = real.fZ1 - ideal.fZ1;