]> git.uio.no Git - u/mrichter/AliRoot.git/blame - PHOS/AliPHOSSurvey.cxx
Additional protection when the energy loss cannot be treated using Bethe-Bloch formula
[u/mrichter/AliRoot.git] / PHOS / AliPHOSSurvey.cxx
CommitLineData
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$
21 */
22
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)
28
29#include <fstream>
30
31#include <TClonesArray.h>
32#include <TGeoManager.h>
33#include <TString.h>
34#include <TMath.h>
35
36#include "AliPHOSEMCAGeometry.h"
37#include "AliAlignObjAngles.h"
38#include "AliPHOSGeometry.h"
39#include "AliPHOSSurvey.h"
40#include "AliLog.h"
41
42ClassImp(AliPHOSSurvey)
43
44//____________________________________________________________________________
45AliPHOSSurvey::AliPHOSSurvey()
46 : fStripData()
47{
48 //Default constructor.
49}
50
51namespace {
52
53 struct Strip_t {
54 Double_t fX1;
55 Double_t fZ1;
56 Double_t fX2;
57 Double_t fZ2;
58 };
59
60}
61
62//____________________________________________________________________________
63AliPHOSSurvey::AliPHOSSurvey(const TString &txtFileName)
64 : fStripData()
65{
66 //Read survey data from txt file.
67 const AliPHOSGeometry *phosGeom = AliPHOSGeometry::GetInstance("IHEP", "IHEP");
68 if (!phosGeom) {
69 AliError("Cannot obtain AliPHOSGeometry instance.");
70 return;
71 }
72
73 std::ifstream inputFile(txtFileName.Data());
74 if (!inputFile) {
75 AliError(("Cannot open the survey file " + txtFileName).Data());
76 return;
77 }
78
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();
83
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];
92 }
93 }
94
95 Int_t dummyInt = 0;
96 Double_t dummyY = 0.;
97 std::vector<Double_t> xReal(strNum * 2), zReal(strNum * 2);
98 for (Int_t i = 0; i < strNum * 2; ++i) {
99 if (!inputFile) {
100 AliError("Error while reading input file.");
101 return;
102 }
103 inputFile>>dummyInt>>xReal[i]>>dummyY>>zReal[i];
104 xReal[i] *= 0.1;
105 zReal[i] *= 0.1;
106 }
107
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()];
116 }
117 }
118
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.;
130 }
131}
132
133//____________________________________________________________________________
134void AliPHOSSurvey::CreateAliAlignObjAngles(TClonesArray &array)
135{
136 //Create AliAlignObjAngles.
137 const AliPHOSGeometry * phosGeom = AliPHOSGeometry::GetInstance("IHEP", "IHEP");
138 if (!phosGeom) {
139 AliError("Cannot obtain AliPHOSGeometry instance.");
140 return;
141 }
142
143 if (!gGeoManager) {
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);
147 }
148
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);
153
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));
159 new(array[arrayInd])
160 AliAlignObjAngles(
161 stripName.Data(), volid,
162 t.fXShift, t.fYShift, t.fZShift,
163 -t.fPsi, -t.fTheta, -t.fPhi,
164 kFALSE
165 );
166 ++arrayInd;
167 }
168 }
169 }
170}
171
172//____________________________________________________________________________
173void AliPHOSSurvey::CreateNullObjects(TClonesArray &array, const AliPHOSGeometry *phosGeom)const
174{
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);
180
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);
186 ++arrayInd;
187 }
188}
189
190//____________________________________________________________________________
191AliPHOSSurvey::Transformation_t AliPHOSSurvey::GetStripTransformation(Int_t stripIndex, Int_t module)const
192{
193 //Strip 'stripIndex' transformation.
194 const Transformation_t t = {0., 0., 0., 0., 0., 0.};
195 if (module != 3 || !fStripData.size())
196 return t;
197 return fStripData[stripIndex];
198}