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:
23 // Objects of this class read txt file with survey (photogrammetry) data
24 // and convert the data into AliAlignObjAngles of alignable PHOS volumes.
25 // It can be used as a base class, you need to override GetStripTransformation.
26 // AliPHOSSurvey inherits TObject only to use AliLog "functions".
27 // Author: Timur Pocheptsov (JINR)
31 #include <TClonesArray.h>
32 #include <TGeoManager.h>
36 #include "AliPHOSEMCAGeometry.h"
37 #include "AliAlignObjAngles.h"
38 #include "AliPHOSGeometry.h"
39 #include "AliPHOSSurvey.h"
42 ClassImp(AliPHOSSurvey)
44 //____________________________________________________________________________
45 AliPHOSSurvey::AliPHOSSurvey()
48 //Default constructor.
62 //____________________________________________________________________________
63 AliPHOSSurvey::AliPHOSSurvey(const TString &txtFileName)
66 //Read survey data from txt file.
67 const AliPHOSGeometry *phosGeom = AliPHOSGeometry::GetInstance("IHEP", "IHEP");
69 AliError("Cannot obtain AliPHOSGeometry instance.");
73 std::ifstream inputFile(txtFileName.Data());
75 AliError(("Cannot open the survey file " + txtFileName).Data());
79 AliPHOSEMCAGeometry * emcaGeom = phosGeom->GetEMCAGeometry();
80 const Int_t strNum = emcaGeom->GetNStripX() * emcaGeom->GetNStripZ();
81 const Float_t *strip = emcaGeom->GetStripHalfSize();
82 const Float_t *cell = emcaGeom->GetSteelCellHalfSize();
84 std::vector<Strip_t> idealStrips(strNum);
85 for (Int_t ix = 0, stripNumber = 0; ix < emcaGeom->GetNStripX(); ++ix) {
86 for (Int_t iz = 0; iz < emcaGeom->GetNStripZ(); ++iz) {
87 Strip_t &str = idealStrips[stripNumber++];
88 str.fX1 = ix * 2 * strip[0];
89 str.fX2 = str.fX1 + 14 * cell[0];
90 str.fZ1 = iz * 2 * strip[2];
91 str.fZ2 = str.fZ1 + 2 * cell[2];
97 std::vector<Double_t> xReal(strNum * 2), zReal(strNum * 2);
98 for (Int_t i = 0; i < strNum * 2; ++i) {
100 AliError("Error while reading input file.");
103 inputFile>>dummyInt>>xReal[i]>>dummyY>>zReal[i];
108 std::vector<Strip_t> realStrips(strNum);
109 for (Int_t j = 0, stripNumber = 0; j < emcaGeom->GetNStripX() * 2; j += 2) {
110 for (Int_t i = 0; i < emcaGeom->GetNStripZ(); ++i) {
111 Strip_t &str = realStrips[stripNumber++];
112 str.fX1 = xReal[i + j * emcaGeom->GetNStripZ()];
113 str.fZ1 = zReal[i + j * emcaGeom->GetNStripZ()];
114 str.fX2 = xReal[i + (j + 1) * emcaGeom->GetNStripZ()];
115 str.fZ2 = zReal[i + (j + 1) * emcaGeom->GetNStripZ()];
119 fStripData.resize(strNum);
120 for (Int_t i = 0; i < strNum; ++i) {
121 const Strip_t &real = realStrips[i];
122 const Strip_t &ideal = idealStrips[i];
123 Transformation_t &t = fStripData[i];
124 t.fTheta = TMath::ATan((real.fZ2 - real.fZ1) / (real.fX2 - real.fX1)) -
125 TMath::ATan((ideal.fZ2 - ideal.fZ1) / (ideal.fX2 - ideal.fX1));
126 t.fTheta *= TMath::RadToDeg();
127 t.fXShift = (real.fX1 + real.fX2) / 2 - (ideal.fX1 + ideal.fX2) / 2;
128 t.fZShift = (real.fZ1 + real.fZ2) / 2 - (ideal.fZ1 + ideal.fZ2) / 2;
129 t.fYShift = 0., t.fPsi = 0., t.fPhi = 0.;
133 //____________________________________________________________________________
134 void AliPHOSSurvey::CreateAliAlignObjAngles(TClonesArray &array)
136 //Create AliAlignObjAngles.
137 const AliPHOSGeometry * phosGeom = AliPHOSGeometry::GetInstance("IHEP", "IHEP");
139 AliError("Cannot obtain AliPHOSGeometry instance.");
144 AliWarning("Cannot create local transformations for strip units - gGeoManager does not exist.");
145 AliInfo("Null shifts and rotations will be created instead.");
146 return CreateNullObjects(array, phosGeom);
149 AliPHOSEMCAGeometry * emcaGeom = phosGeom->GetEMCAGeometry();
150 Int_t arrayInd = array.GetEntries(), iIndex = 0;
151 AliAlignObj::ELayerID iLayer = AliAlignObj::kInvalidLayer;
152 UShort_t volid = AliAlignObj::LayerToVolUID(iLayer,iIndex);
154 for (Int_t module = 1; module <= phosGeom->GetNModules(); ++module) {
155 for (Int_t i = 0, stripNum = 0; i < emcaGeom->GetNStripX(); ++i) {
156 for (Int_t j = 0; j < emcaGeom->GetNStripZ(); ++j) {
157 TString stripName(TString::Format("PHOS/Module%d/Strip_%d_%d", module, i, j));
158 Transformation_t t(GetStripTransformation(stripNum++, module));
161 stripName.Data(), volid,
162 t.fXShift, t.fYShift, t.fZShift,
163 -t.fPsi, -t.fTheta, -t.fPhi,
172 //____________________________________________________________________________
173 void AliPHOSSurvey::CreateNullObjects(TClonesArray &array, const AliPHOSGeometry *phosGeom)const
175 //Create null shifts and rotations.
176 const AliPHOSEMCAGeometry * emcaGeom = phosGeom->GetEMCAGeometry();
177 Int_t arrayInd = array.GetEntries(), iIndex = 0;
178 AliAlignObj::ELayerID iLayer = AliAlignObj::kInvalidLayer;
179 UShort_t volid = AliAlignObj::LayerToVolUID(iLayer,iIndex);
181 for (Int_t module = 1; module <= phosGeom->GetNModules(); ++module)
182 for (Int_t i = 0; i < emcaGeom->GetNStripX(); ++i)
183 for (Int_t j = 0; j < emcaGeom->GetNStripZ(); ++j) {
184 TString stripName(TString::Format("PHOS/Module%d/Strip_%d_%d", module, i, j));
185 new(array[arrayInd]) AliAlignObjAngles(stripName.Data(), volid, 0., 0., 0., 0., 0., 0., kTRUE);
190 //____________________________________________________________________________
191 AliPHOSSurvey::Transformation_t AliPHOSSurvey::GetStripTransformation(Int_t stripIndex, Int_t module)const
193 //Strip 'stripIndex' transformation.
194 const Transformation_t t = {0., 0., 0., 0., 0., 0.};
195 if (module != 3 || !fStripData.size())
197 return fStripData[stripIndex];