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.1 2007/04/19 15:47:20 kharlov
22 * Add misalignment of strip units with AliPHOSSurvey class
26 // Objects of this class read txt file with survey (photogrammetry) data
27 // and convert the data into AliAlignObjAngles of alignable PHOS volumes.
28 // It can be used as a base class, you need to override GetStripTransformation.
29 // AliPHOSSurvey inherits TObject only to use AliLog "functions".
30 // Author: Timur Pocheptsov (JINR)
34 #include <TClonesArray.h>
35 #include <TGeoManager.h>
39 #include "AliPHOSEMCAGeometry.h"
40 #include "AliAlignObjAngles.h"
41 #include "AliPHOSGeometry.h"
42 #include "AliPHOSSurvey.h"
45 ClassImp(AliPHOSSurvey)
47 //____________________________________________________________________________
48 AliPHOSSurvey::AliPHOSSurvey()
52 //Default constructor.
57 struct AliPHOSStripCoords {
58 Double_t fX1; //x coordinate of the first strip point
59 Double_t fZ1; //z coordinate of the first strip point
60 Double_t fX2; //x coordinate of the second strip point
61 Double_t fZ2; //z coordinate of the second strip point
66 //____________________________________________________________________________
67 AliPHOSSurvey::AliPHOSSurvey(const TString &txtFileName)
71 //Read survey data from txt file.
72 const AliPHOSGeometry *phosGeom = AliPHOSGeometry::GetInstance("IHEP", "IHEP");
74 AliError("Cannot obtain AliPHOSGeometry instance.");
78 std::ifstream inputFile(txtFileName.Data());
80 AliError(("Cannot open the survey file " + txtFileName).Data());
84 AliPHOSEMCAGeometry * emcaGeom = phosGeom->GetEMCAGeometry();
85 fStrNum = emcaGeom->GetNStripX() * emcaGeom->GetNStripZ();
86 const Float_t *strip = emcaGeom->GetStripHalfSize();
87 const Float_t *cell = emcaGeom->GetSteelCellHalfSize();
89 AliPHOSStripCoords *idealStrips = new AliPHOSStripCoords[fStrNum];//1
90 for (Int_t ix = 0, stripNumber = 0; ix < emcaGeom->GetNStripX(); ++ix) {
91 for (Int_t iz = 0; iz < emcaGeom->GetNStripZ(); ++iz) {
92 AliPHOSStripCoords &str = idealStrips[stripNumber++];
93 str.fX1 = ix * 2 * strip[0];
94 str.fX2 = str.fX1 + 14 * cell[0];
95 str.fZ1 = iz * 2 * strip[2];
96 str.fZ2 = str.fZ1 + 2 * cell[2];
101 Double_t dummyY = 0.;
102 Double_t *xReal = new Double_t[fStrNum * 2];//2
103 Double_t *zReal = new Double_t[fStrNum * 2];//3
105 for (Int_t i = 0; i < fStrNum * 2; ++i) {
107 AliError("Error while reading input file.");
108 delete [] idealStrips;
113 inputFile>>dummyInt>>xReal[i]>>dummyY>>zReal[i];
118 AliPHOSStripCoords *realStrips = new AliPHOSStripCoords[fStrNum];//4
120 for (Int_t j = 0, stripNumber = 0; j < emcaGeom->GetNStripX() * 2; j += 2) {
121 for (Int_t i = 0; i < emcaGeom->GetNStripZ(); ++i) {
122 AliPHOSStripCoords &str = realStrips[stripNumber++];
123 str.fX1 = xReal[i + j * emcaGeom->GetNStripZ()];
124 str.fZ1 = zReal[i + j * emcaGeom->GetNStripZ()];
125 str.fX2 = xReal[i + (j + 1) * emcaGeom->GetNStripZ()];
126 str.fZ2 = zReal[i + (j + 1) * emcaGeom->GetNStripZ()];
130 fStripData = new AliPHOSStripDelta[fStrNum];
132 for (Int_t i = 0; i < fStrNum; ++i) {
133 const AliPHOSStripCoords &real = realStrips[i];
134 const AliPHOSStripCoords &ideal = idealStrips[i];
135 AliPHOSStripDelta &t = fStripData[i];
136 t.fTheta = TMath::ATan((real.fZ2 - real.fZ1) / (real.fX2 - real.fX1)) -
137 TMath::ATan((ideal.fZ2 - ideal.fZ1) / (ideal.fX2 - ideal.fX1));
138 t.fTheta *= TMath::RadToDeg();
139 t.fXShift = (real.fX1 + real.fX2) / 2 - (ideal.fX1 + ideal.fX2) / 2;
140 t.fZShift = (real.fZ1 + real.fZ2) / 2 - (ideal.fZ1 + ideal.fZ2) / 2;
141 t.fYShift = 0., t.fPsi = 0., t.fPhi = 0.;
144 delete [] realStrips;
147 delete [] idealStrips;
150 //____________________________________________________________________________
151 AliPHOSSurvey::~AliPHOSSurvey()
153 delete [] fStripData;
156 //____________________________________________________________________________
157 void AliPHOSSurvey::CreateAliAlignObjAngles(TClonesArray &array)
159 //Create AliAlignObjAngles.
160 const AliPHOSGeometry * phosGeom = AliPHOSGeometry::GetInstance("IHEP", "IHEP");
162 AliError("Cannot obtain AliPHOSGeometry instance.");
167 AliWarning("Cannot create local transformations for strip units - gGeoManager does not exist.");
168 AliInfo("Null shifts and rotations will be created instead.");
169 return CreateNullObjects(array, phosGeom);
172 AliPHOSEMCAGeometry * emcaGeom = phosGeom->GetEMCAGeometry();
173 Int_t arrayInd = array.GetEntries(), iIndex = 0;
174 AliAlignObj::ELayerID iLayer = AliAlignObj::kInvalidLayer;
175 UShort_t volid = AliAlignObj::LayerToVolUID(iLayer,iIndex);
177 for (Int_t module = 1; module <= phosGeom->GetNModules(); ++module) {
178 for (Int_t i = 0, stripNum = 0; i < emcaGeom->GetNStripX(); ++i) {
179 for (Int_t j = 0; j < emcaGeom->GetNStripZ(); ++j) {
180 TString stripName(TString::Format("PHOS/Module%d/Strip_%d_%d", module, i, j));
181 AliPHOSStripDelta t(GetStripTransformation(stripNum++, module));
184 stripName.Data(), volid,
185 t.fXShift, t.fYShift, t.fZShift,
186 -t.fPsi, -t.fTheta, -t.fPhi,
195 //____________________________________________________________________________
196 void AliPHOSSurvey::CreateNullObjects(TClonesArray &array, const AliPHOSGeometry *phosGeom)const
198 //Create null shifts and rotations.
199 const AliPHOSEMCAGeometry * emcaGeom = phosGeom->GetEMCAGeometry();
200 Int_t arrayInd = array.GetEntries(), iIndex = 0;
201 AliAlignObj::ELayerID iLayer = AliAlignObj::kInvalidLayer;
202 UShort_t volid = AliAlignObj::LayerToVolUID(iLayer,iIndex);
204 for (Int_t module = 1; module <= phosGeom->GetNModules(); ++module)
205 for (Int_t i = 0; i < emcaGeom->GetNStripX(); ++i)
206 for (Int_t j = 0; j < emcaGeom->GetNStripZ(); ++j) {
207 TString stripName(TString::Format("PHOS/Module%d/Strip_%d_%d", module, i, j));
208 new(array[arrayInd]) AliAlignObjAngles(stripName.Data(), volid, 0., 0., 0., 0., 0., 0., true);
213 //____________________________________________________________________________
214 AliPHOSSurvey::AliPHOSStripDelta AliPHOSSurvey::GetStripTransformation(Int_t stripIndex, Int_t module)const
216 //Strip 'stripIndex' transformation.
217 AliPHOSStripDelta t = {0., 0., 0., 0., 0., 0.};
218 if (module != 3 || !fStripData)
220 return fStripData[stripIndex];