]>
Commit | Line | Data |
---|---|---|
3c759505 | 1 | /************************************************************************** |
2 | * Copyright(c) 1998-1999, 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 | ||
16 | /* $Id$ */ | |
17 | ||
18 | /* History of cvs commits: | |
19 | * | |
20 | * $Log$ | |
42c5218a | 21 | * Revision 1.4 2007/05/17 17:34:54 kharlov |
22 | * Merging differences if v1.2 and 1.3 | |
23 | * | |
afb6e026 | 24 | * Revision 1.3 2007/05/17 17:13:32 kharlov |
25 | * Coding convensions satisfied (T.Pocheptsov) | |
26 | * | |
ae079791 | 27 | * Revision 1.1 2007/04/19 15:47:20 kharlov |
28 | * Add misalignment of strip units with AliPHOSSurvey class | |
29 | * | |
3c759505 | 30 | */ |
31 | ||
32 | // Objects of this class read txt file with survey (photogrammetry) data | |
33 | // and convert the data into AliAlignObjAngles of alignable PHOS volumes. | |
34 | // It can be used as a base class, you need to override GetStripTransformation. | |
35 | // AliPHOSSurvey inherits TObject only to use AliLog "functions". | |
36 | // Author: Timur Pocheptsov (JINR) | |
37 | ||
38 | #include <fstream> | |
39 | ||
40 | #include <TClonesArray.h> | |
41 | #include <TGeoManager.h> | |
42 | #include <TString.h> | |
43 | #include <TMath.h> | |
44 | ||
42c5218a | 45 | #include "AliSurveyObj.h" |
46 | ||
3c759505 | 47 | #include "AliPHOSEMCAGeometry.h" |
48 | #include "AliAlignObjAngles.h" | |
49 | #include "AliPHOSGeometry.h" | |
50 | #include "AliPHOSSurvey.h" | |
51 | #include "AliLog.h" | |
52 | ||
53 | ClassImp(AliPHOSSurvey) | |
54 | ||
55 | //____________________________________________________________________________ | |
56 | AliPHOSSurvey::AliPHOSSurvey() | |
56afa9a8 | 57 | : fStrNum(0), |
58 | fStripData(0) | |
3c759505 | 59 | { |
60 | //Default constructor. | |
61 | } | |
62 | ||
63 | namespace { | |
64 | ||
56afa9a8 | 65 | struct AliPHOSStripCoords { |
66 | Double_t fX1; //x coordinate of the first strip point | |
67 | Double_t fZ1; //z coordinate of the first strip point | |
68 | Double_t fX2; //x coordinate of the second strip point | |
69 | Double_t fZ2; //z coordinate of the second strip point | |
3c759505 | 70 | }; |
71 | ||
72 | } | |
73 | ||
74 | //____________________________________________________________________________ | |
75 | AliPHOSSurvey::AliPHOSSurvey(const TString &txtFileName) | |
56afa9a8 | 76 | : fStrNum(0), |
77 | fStripData(0) | |
3c759505 | 78 | { |
79 | //Read survey data from txt file. | |
80 | const AliPHOSGeometry *phosGeom = AliPHOSGeometry::GetInstance("IHEP", "IHEP"); | |
81 | if (!phosGeom) { | |
82 | AliError("Cannot obtain AliPHOSGeometry instance."); | |
83 | return; | |
84 | } | |
85 | ||
86 | std::ifstream inputFile(txtFileName.Data()); | |
87 | if (!inputFile) { | |
88 | AliError(("Cannot open the survey file " + txtFileName).Data()); | |
89 | return; | |
90 | } | |
91 | ||
56afa9a8 | 92 | AliPHOSEMCAGeometry * emcaGeom = phosGeom->GetEMCAGeometry(); |
93 | fStrNum = emcaGeom->GetNStripX() * emcaGeom->GetNStripZ(); | |
3c759505 | 94 | |
95 | Int_t dummyInt = 0; | |
96 | Double_t dummyY = 0.; | |
56afa9a8 | 97 | Double_t *xReal = new Double_t[fStrNum * 2];//2 |
98 | Double_t *zReal = new Double_t[fStrNum * 2];//3 | |
99 | ||
100 | for (Int_t i = 0; i < fStrNum * 2; ++i) { | |
3c759505 | 101 | if (!inputFile) { |
102 | AliError("Error while reading input file."); | |
56afa9a8 | 103 | delete [] xReal; |
104 | delete [] zReal; | |
3c759505 | 105 | return; |
106 | } | |
107 | inputFile>>dummyInt>>xReal[i]>>dummyY>>zReal[i]; | |
108 | xReal[i] *= 0.1; | |
109 | zReal[i] *= 0.1; | |
110 | } | |
111 | ||
42c5218a | 112 | InitStripData(xReal, zReal); |
56afa9a8 | 113 | |
56afa9a8 | 114 | delete [] zReal; |
115 | delete [] xReal; | |
56afa9a8 | 116 | } |
117 | ||
118 | //____________________________________________________________________________ | |
119 | AliPHOSSurvey::~AliPHOSSurvey() | |
120 | { | |
121 | delete [] fStripData; | |
3c759505 | 122 | } |
123 | ||
124 | //____________________________________________________________________________ | |
125 | void AliPHOSSurvey::CreateAliAlignObjAngles(TClonesArray &array) | |
126 | { | |
127 | //Create AliAlignObjAngles. | |
128 | const AliPHOSGeometry * phosGeom = AliPHOSGeometry::GetInstance("IHEP", "IHEP"); | |
129 | if (!phosGeom) { | |
130 | AliError("Cannot obtain AliPHOSGeometry instance."); | |
131 | return; | |
132 | } | |
133 | ||
134 | if (!gGeoManager) { | |
135 | AliWarning("Cannot create local transformations for strip units - gGeoManager does not exist."); | |
136 | AliInfo("Null shifts and rotations will be created instead."); | |
137 | return CreateNullObjects(array, phosGeom); | |
138 | } | |
139 | ||
140 | AliPHOSEMCAGeometry * emcaGeom = phosGeom->GetEMCAGeometry(); | |
141 | Int_t arrayInd = array.GetEntries(), iIndex = 0; | |
afb6e026 | 142 | AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer; |
143 | UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex); | |
3c759505 | 144 | |
145 | for (Int_t module = 1; module <= phosGeom->GetNModules(); ++module) { | |
146 | for (Int_t i = 0, stripNum = 0; i < emcaGeom->GetNStripX(); ++i) { | |
147 | for (Int_t j = 0; j < emcaGeom->GetNStripZ(); ++j) { | |
148 | TString stripName(TString::Format("PHOS/Module%d/Strip_%d_%d", module, i, j)); | |
56afa9a8 | 149 | AliPHOSStripDelta t(GetStripTransformation(stripNum++, module)); |
3c759505 | 150 | new(array[arrayInd]) |
151 | AliAlignObjAngles( | |
152 | stripName.Data(), volid, | |
153 | t.fXShift, t.fYShift, t.fZShift, | |
154 | -t.fPsi, -t.fTheta, -t.fPhi, | |
56afa9a8 | 155 | false |
3c759505 | 156 | ); |
157 | ++arrayInd; | |
158 | } | |
159 | } | |
160 | } | |
161 | } | |
162 | ||
163 | //____________________________________________________________________________ | |
164 | void AliPHOSSurvey::CreateNullObjects(TClonesArray &array, const AliPHOSGeometry *phosGeom)const | |
165 | { | |
166 | //Create null shifts and rotations. | |
167 | const AliPHOSEMCAGeometry * emcaGeom = phosGeom->GetEMCAGeometry(); | |
168 | Int_t arrayInd = array.GetEntries(), iIndex = 0; | |
afb6e026 | 169 | AliGeomManager::ELayerID iLayer = AliGeomManager::kInvalidLayer; |
170 | UShort_t volid = AliGeomManager::LayerToVolUID(iLayer,iIndex); | |
3c759505 | 171 | |
172 | for (Int_t module = 1; module <= phosGeom->GetNModules(); ++module) | |
173 | for (Int_t i = 0; i < emcaGeom->GetNStripX(); ++i) | |
174 | for (Int_t j = 0; j < emcaGeom->GetNStripZ(); ++j) { | |
175 | TString stripName(TString::Format("PHOS/Module%d/Strip_%d_%d", module, i, j)); | |
56afa9a8 | 176 | new(array[arrayInd]) AliAlignObjAngles(stripName.Data(), volid, 0., 0., 0., 0., 0., 0., true); |
3c759505 | 177 | ++arrayInd; |
178 | } | |
179 | } | |
180 | ||
181 | //____________________________________________________________________________ | |
56afa9a8 | 182 | AliPHOSSurvey::AliPHOSStripDelta AliPHOSSurvey::GetStripTransformation(Int_t stripIndex, Int_t module)const |
3c759505 | 183 | { |
184 | //Strip 'stripIndex' transformation. | |
56afa9a8 | 185 | AliPHOSStripDelta t = {0., 0., 0., 0., 0., 0.}; |
186 | if (module != 3 || !fStripData) | |
3c759505 | 187 | return t; |
188 | return fStripData[stripIndex]; | |
189 | } | |
42c5218a | 190 | |
191 | //____________________________________________________________________________ | |
192 | void AliPHOSSurvey::InitStripData(const Double_t *xReal, const Double_t *zReal) | |
193 | { | |
194 | const AliPHOSGeometry *phosGeom = AliPHOSGeometry::GetInstance("IHEP", "IHEP"); | |
195 | AliPHOSEMCAGeometry * emcaGeom = phosGeom->GetEMCAGeometry(); | |
196 | const Float_t *strip = emcaGeom->GetStripHalfSize(); | |
197 | const Float_t *cell = emcaGeom->GetSteelCellHalfSize(); | |
198 | ||
199 | AliPHOSStripCoords *idealStrips = new AliPHOSStripCoords[fStrNum];//1 | |
200 | for (Int_t ix = 0, stripNumber = 0; ix < emcaGeom->GetNStripX(); ++ix) { | |
201 | for (Int_t iz = 0; iz < emcaGeom->GetNStripZ(); ++iz) { | |
202 | AliPHOSStripCoords &str = idealStrips[stripNumber++]; | |
203 | str.fX1 = ix * 2 * strip[0]; | |
204 | str.fX2 = str.fX1 + 14 * cell[0]; | |
205 | str.fZ1 = iz * 2 * strip[2]; | |
206 | str.fZ2 = str.fZ1 + 2 * cell[2]; | |
207 | } | |
208 | } | |
209 | ||
210 | AliPHOSStripCoords *realStrips = new AliPHOSStripCoords[fStrNum];//4 | |
211 | for (Int_t j = 0, stripNumber = 0; j < emcaGeom->GetNStripX() * 2; j += 2) { | |
212 | for (Int_t i = 0; i < emcaGeom->GetNStripZ(); ++i) { | |
213 | AliPHOSStripCoords &str = realStrips[stripNumber++]; | |
214 | str.fX1 = xReal[i + j * emcaGeom->GetNStripZ()]; | |
215 | str.fZ1 = zReal[i + j * emcaGeom->GetNStripZ()]; | |
216 | str.fX2 = xReal[i + (j + 1) * emcaGeom->GetNStripZ()]; | |
217 | str.fZ2 = zReal[i + (j + 1) * emcaGeom->GetNStripZ()]; | |
218 | } | |
219 | } | |
220 | ||
221 | fStripData = new AliPHOSStripDelta[fStrNum]; | |
222 | ||
223 | for (Int_t i = 0; i < fStrNum; ++i) { | |
224 | const AliPHOSStripCoords &real = realStrips[i]; | |
225 | const AliPHOSStripCoords &ideal = idealStrips[i]; | |
226 | AliPHOSStripDelta &t = fStripData[i]; | |
227 | t.fTheta = TMath::ATan((real.fZ2 - real.fZ1) / (real.fX2 - real.fX1)) - | |
228 | TMath::ATan((ideal.fZ2 - ideal.fZ1) / (ideal.fX2 - ideal.fX1)); | |
229 | t.fTheta *= TMath::RadToDeg(); | |
230 | t.fXShift = (real.fX1 + real.fX2) / 2 - (ideal.fX1 + ideal.fX2) / 2; | |
231 | t.fZShift = (real.fZ1 + real.fZ2) / 2 - (ideal.fZ1 + ideal.fZ2) / 2; | |
232 | t.fYShift = 0., t.fPsi = 0., t.fPhi = 0.; | |
233 | } | |
234 | ||
235 | delete [] realStrips; | |
236 | delete [] idealStrips; | |
237 | } |