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 /* History of cvs commits:
21 * Revision 1.6 2007/08/28 13:12:18 hristov
22 * AliAlignObjAngles becomes AliAlignObjParams (Raffaele)
24 * Revision 1.5 2007/07/10 12:41:38 kharlov
25 * Added a new class AliPHOSSurvet1 which read survey data from EDMS files
27 * Revision 1.4 2007/05/17 17:34:54 kharlov
28 * Merging differences if v1.2 and 1.3
30 * Revision 1.3 2007/05/17 17:13:32 kharlov
31 * Coding convensions satisfied (T.Pocheptsov)
33 * Revision 1.1 2007/04/19 15:47:20 kharlov
34 * Add misalignment of strip units with AliPHOSSurvey class
38 // Objects of this class read txt file with survey (photogrammetry) data
39 // and convert the data into AliAlignObjParams of alignable PHOS volumes.
40 // It can be used as a base class, you need to override GetStripTransformation.
41 // AliPHOSSurvey inherits TObject only to use AliLog "functions".
42 // Author: Timur Pocheptsov (JINR)
46 #include <TClonesArray.h>
47 #include <TGeoManager.h>
51 #include "AliSurveyObj.h"
53 #include "AliPHOSEMCAGeometry.h"
54 #include "AliAlignObjParams.h"
55 #include "AliPHOSGeometry.h"
56 #include "AliPHOSSurvey.h"
59 ClassImp(AliPHOSSurvey)
61 //____________________________________________________________________________
62 AliPHOSSurvey::AliPHOSSurvey()
66 //Default constructor.
71 struct AliPHOSStripCoords {
72 Double_t fX1; //x coordinate of the first strip point
73 Double_t fZ1; //z coordinate of the first strip point
74 Double_t fX2; //x coordinate of the second strip point
75 Double_t fZ2; //z coordinate of the second strip point
80 //____________________________________________________________________________
81 AliPHOSSurvey::AliPHOSSurvey(const TString &txtFileName)
85 //Read survey data from txt file.
86 const AliPHOSGeometry *phosGeom = AliPHOSGeometry::GetInstance("IHEP", "IHEP");
88 AliError("Cannot obtain AliPHOSGeometry instance.");
92 std::ifstream inputFile(txtFileName.Data());
94 AliError(("Cannot open the survey file " + txtFileName).Data());
98 AliPHOSEMCAGeometry * emcaGeom = phosGeom->GetEMCAGeometry();
99 fStrNum = emcaGeom->GetNStripX() * emcaGeom->GetNStripZ();
102 Double_t dummyY = 0.;
103 Double_t *xReal = new Double_t[fStrNum * 2];//2
104 Double_t *zReal = new Double_t[fStrNum * 2];//3
106 for (Int_t i = 0; i < fStrNum * 2; ++i) {
111 for (Int_t i = 0; i < fStrNum * 2; ++i) {
113 AliError("Error while reading input file.");
118 inputFile>>dummyInt>>xReal[i]>>dummyY>>zReal[i];
123 InitStripData(xReal, zReal);
129 //____________________________________________________________________________
130 AliPHOSSurvey::~AliPHOSSurvey()
132 delete [] fStripData;
135 //____________________________________________________________________________
136 void AliPHOSSurvey::CreateAliAlignObjParams(TClonesArray &array)
138 //Create AliAlignObjParams.
139 const AliPHOSGeometry * phosGeom = AliPHOSGeometry::GetInstance("IHEP", "IHEP");
141 AliError("Cannot obtain AliPHOSGeometry instance.");
146 AliWarning("Cannot create local transformations for strip units - gGeoManager does not exist.");
147 AliInfo("Null shifts and rotations will be created instead.");
148 return CreateNullObjects(array, phosGeom);
151 AliPHOSEMCAGeometry * emcaGeom = phosGeom->GetEMCAGeometry();
152 Int_t arrayInd = array.GetEntries(), iIndex = 0;
153 AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
154 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
156 for (Int_t module = 1; module <= phosGeom->GetNModules(); ++module) {
157 for (Int_t i = 0, stripNum = 0; i < emcaGeom->GetNStripX(); ++i) {
158 for (Int_t j = 0; j < emcaGeom->GetNStripZ(); ++j) {
159 TString stripName(TString::Format("PHOS/Module%d/Strip_%d_%d", module, i, j));
160 AliPHOSStripDelta t(GetStripTransformation(stripNum++, module));
163 stripName.Data(), volid,
164 t.fXShift, t.fYShift, t.fZShift,
165 -t.fPsi, -t.fTheta, -t.fPhi,
174 //____________________________________________________________________________
175 void AliPHOSSurvey::CreateNullObjects(TClonesArray &array, const AliPHOSGeometry *phosGeom)const
177 //Create null shifts and rotations.
178 const AliPHOSEMCAGeometry * emcaGeom = phosGeom->GetEMCAGeometry();
179 Int_t arrayInd = array.GetEntries(), iIndex = 0;
180 AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer;
181 UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex);
183 for (Int_t module = 1; module <= phosGeom->GetNModules(); ++module)
184 for (Int_t i = 0; i < emcaGeom->GetNStripX(); ++i)
185 for (Int_t j = 0; j < emcaGeom->GetNStripZ(); ++j) {
186 TString stripName(TString::Format("PHOS/Module%d/Strip_%d_%d", module, i, j));
187 new(array[arrayInd]) AliAlignObjParams(stripName.Data(), volid, 0., 0., 0., 0., 0., 0., true);
192 //____________________________________________________________________________
193 AliPHOSSurvey::AliPHOSStripDelta AliPHOSSurvey::GetStripTransformation(Int_t stripIndex, Int_t module)const
195 //Strip 'stripIndex' transformation.
196 AliPHOSStripDelta t = {0., 0., 0., 0., 0., 0.};
197 if (module != 3 || !fStripData)
199 return fStripData[stripIndex];
202 //____________________________________________________________________________
203 void AliPHOSSurvey::InitStripData(const Double_t *xReal, const Double_t *zReal)
205 const AliPHOSGeometry *phosGeom = AliPHOSGeometry::GetInstance("IHEP", "IHEP");
206 AliPHOSEMCAGeometry * emcaGeom = phosGeom->GetEMCAGeometry();
207 const Float_t *strip = emcaGeom->GetStripHalfSize();
208 const Float_t *cell = emcaGeom->GetAirCellHalfSize();
210 AliPHOSStripCoords *idealStrips = new AliPHOSStripCoords[fStrNum];//1
211 for (Int_t ix = 0, stripNumber = 0; ix < emcaGeom->GetNStripX(); ++ix) {
212 for (Int_t iz = 0; iz < emcaGeom->GetNStripZ(); ++iz) {
213 AliPHOSStripCoords &str = idealStrips[stripNumber++];
214 str.fX1 = ix * 2 * strip[0];
215 str.fX2 = str.fX1 + 14 * cell[0];
216 str.fZ1 = iz * 2 * strip[2];
217 str.fZ2 = str.fZ1 + 2 * cell[2];
221 AliPHOSStripCoords *realStrips = new AliPHOSStripCoords[fStrNum];//4
222 for (Int_t j = 0, stripNumber = 0; j < emcaGeom->GetNStripX() * 2; j += 2) {
223 for (Int_t i = 0; i < emcaGeom->GetNStripZ(); ++i) {
224 AliPHOSStripCoords &str = realStrips[stripNumber++];
225 str.fX1 = xReal[i + j * emcaGeom->GetNStripZ()];
226 str.fZ1 = zReal[i + j * emcaGeom->GetNStripZ()];
227 str.fX2 = xReal[i + (j + 1) * emcaGeom->GetNStripZ()];
228 str.fZ2 = zReal[i + (j + 1) * emcaGeom->GetNStripZ()];
232 fStripData = new AliPHOSStripDelta[fStrNum];
234 for (Int_t i = 0; i < fStrNum; ++i) {
235 const AliPHOSStripCoords &real = realStrips[i];
236 const AliPHOSStripCoords &ideal = idealStrips[i];
237 AliPHOSStripDelta &t = fStripData[i];
238 t.fTheta = TMath::ATan((real.fZ2 - real.fZ1) / (real.fX2 - real.fX1)) -
239 TMath::ATan((ideal.fZ2 - ideal.fZ1) / (ideal.fX2 - ideal.fX1));
240 t.fTheta *= TMath::RadToDeg();
241 t.fXShift = (real.fX1 + real.fX2) / 2 - (ideal.fX1 + ideal.fX2) / 2;
242 t.fZShift = (real.fZ1 + real.fZ2) / 2 - (ideal.fZ1 + ideal.fZ2) / 2;
243 t.fYShift = 0., t.fPsi = 0., t.fPhi = 0.;
246 delete [] realStrips;
247 delete [] idealStrips;