1 /**************************************************************************
2 * Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
3 * SigmaEffect_thetadegrees *
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 purpeateose. It is *
13 * provided "as is" without express or implied warranty. *
14 **************************************************************************/
18 // Class AliMUONGeometryMisAligner
19 // ----------------------------
20 // Class for misalignment of geometry transformations
22 // Author:Bruce Becker
24 //__________________________________________________________________
26 /////////////////////////////////////////////////////////////////////
27 //This performs the misalignment on an existing muon arm geometry
28 // based on the standard definition of the detector elements in
29 // $ALICE_ROOT/MUON/data
31 // --> User has to specify the magnitude of the alignments, in the Cartesian
32 // co-ordiantes (which are used to apply translation misalignments) and in the
33 // spherical co-ordinates (which are used to apply angular displacements)
34 // --> If the constructor is used with no arguments, user has to set
35 // misalignment ranges by hand using the methods :
36 // SetApplyMisAlig, SetMaxCartMisAlig, SetMaxAngMisAlig, SetXYAngMisAligFactor
37 // (last method takes account of the fact that the misalingment is greatest in
38 // the XY plane, since the detection elements are fixed to a support structure
39 // in this plane. Misalignments in the XZ and YZ plane will be very small
40 // compared to those in the XY plane, which are small already - of the order
43 // Note : If the detection elements are allowed to be misaligned in all
44 // directions, this has consequences for the alignment algorithm
45 // (AliMUONAlignment), which needs to know the number of free parameters.
46 // Eric only allowed 3 : x,y,theta_xy, but in principle z and the other
47 // two angles are alignable as well.
51 #include "AliMUONGeometryMisAligner.h"
52 #include "AliMUONGeometryTransformer.h"
53 #include "AliMUONGeometryModuleTransformer.h"
54 #include "AliMUONGeometryDetElement.h"
55 #include "AliMUONGeometryStore.h"
56 #include "AliMUONGeometryBuilder.h"
57 #include <TGeoManager.h>
58 #include <Riostream.h>
59 #include <TObjArray.h>
68 ClassImp(AliMUONGeometryMisAligner)
69 //______________________________________________________________________________
70 AliMUONGeometryMisAligner::AliMUONGeometryMisAligner(Double_t cartMisAlig, Double_t angMisAlig)
71 :TObject(), fDisplacementGenerator(0)
73 /// Standard constructor
74 fMaxCartMisAlig = cartMisAlig; // 0.5 mm. Perhaps this should go into AliMUONConstants.h ?
75 fMaxAngMisAlig = angMisAlig;
76 fXYAngMisAligFactor = 1.0;
77 fDisplacementGenerator = new TRandom(0);
80 //_____________________________________________________________________________
81 AliMUONGeometryMisAligner::AliMUONGeometryMisAligner()
82 :TObject(), fDisplacementGenerator(0)
84 /// Default constructor
87 //______________________________________________________________________________
88 AliMUONGeometryMisAligner::
89 AliMUONGeometryMisAligner(const AliMUONGeometryMisAligner & right):
92 /// Copy constructor (not implemented)
94 AliFatal("Copy constructor not provided.");
97 //______________________________________________________________________________
98 AliMUONGeometryMisAligner::~AliMUONGeometryMisAligner()
102 delete fDisplacementGenerator;
105 //______________________________________________________________________________
106 AliMUONGeometryMisAligner & AliMUONGeometryMisAligner::
107 operator=(const AliMUONGeometryMisAligner & right)
109 /// Assignement operator (not implemented)
111 // check assignement to self
115 AliFatal("Assignement operator not provided.");
121 AliMUONGeometryMisAligner::SetXYAngMisAligFactor(Double_t factor)
123 if (TMath::Abs(factor) > 1.0 && factor > 0.)
124 fXYAngMisAligFactor = factor;
126 AliError(Form("Invalid factor, %d", factor));
129 //_________________________________________________________________________
130 TGeoCombiTrans AliMUONGeometryMisAligner::MisAlign(const TGeoCombiTrans & transform) const
132 /// Misalign given transformation and return the misaligned transformation
134 Double_t cartMisAlig[3] = {0,0,0};
135 Double_t angMisAlig[3] = {0,0,0};
136 const Double_t *trans = transform.GetTranslation();
138 // check if the rotation we obtain is not NULL
139 if (transform.GetRotation())
141 rot = transform.GetRotation();
145 rot = new TGeoRotation("rot");
146 } // default constructor.
148 cartMisAlig[0] = fDisplacementGenerator->Uniform(-1. * fMaxCartMisAlig, fMaxCartMisAlig);
149 cartMisAlig[1] = fDisplacementGenerator->Uniform(-1. * fMaxCartMisAlig, fMaxCartMisAlig);
150 cartMisAlig[2] = fDisplacementGenerator->Uniform(-1. * fMaxCartMisAlig, fMaxCartMisAlig);
152 TGeoTranslation newTrans(cartMisAlig[0] + trans[0], cartMisAlig[1] + trans[1], cartMisAlig[2] + trans[2]);
155 misalign the centre of the local transformation
157 fAngMisAlig[1,2,3] = [x,y,z]
158 Assume that misalignment about the x and y axes (misalignment of z plane)
159 is much smaller, since the entire detection plane has to be moved (the
160 detection elements are on a support structure), while rotation of the x-y
164 angMisAlig[0] = fDisplacementGenerator->Uniform(fXYAngMisAligFactor * fMaxAngMisAlig, 1.0 * fMaxAngMisAlig);
165 angMisAlig[1] = fDisplacementGenerator->Uniform(fXYAngMisAligFactor * fMaxAngMisAlig, 1.0 * fMaxAngMisAlig);
166 angMisAlig[2] = fDisplacementGenerator->Uniform(-1. * fMaxAngMisAlig, fMaxAngMisAlig); // degrees
167 AliInfo(Form("Rotated by %f about Z axis.", angMisAlig[2]));
168 rot->RotateX(angMisAlig[0]);
169 rot->RotateY(angMisAlig[1]);
170 rot->RotateZ(angMisAlig[2]);
172 return TGeoCombiTrans(newTrans, *rot);
176 //______________________________________________________________________
177 AliMUONGeometryTransformer *
178 AliMUONGeometryMisAligner::MisAlign(const AliMUONGeometryTransformer *
179 transformer, Bool_t verbose)
181 /////////////////////////////////////////////////////////////////////
182 // Takes the internal geometry module transformers, copies them
183 // and gets the Detection Elements from them.
184 // Calculates misalignment parameters and applies these
185 // to the local transform of the Detection Element
186 // Obtains the global transform by multiplying the module transformer
187 // transformation with the local transformation
188 // Applies the global transform to a new detection element
189 // Adds the new detection element to a new module transformer
190 // Adds the new module transformer to a new geometry transformer
191 // Returns the new geometry transformer
194 AliMUONGeometryTransformer *newGeometryTransformer =
195 new AliMUONGeometryTransformer(kTRUE);
196 for (Int_t iMt = 0; iMt < transformer->GetNofModuleTransformers(); iMt++)
197 { // module transformers
199 const AliMUONGeometryModuleTransformer *kModuleTransformer =
200 transformer->GetModuleTransformer(iMt, true);
202 AliMUONGeometryModuleTransformer *newModuleTransformer =
203 new AliMUONGeometryModuleTransformer(iMt);
204 newGeometryTransformer->AddModuleTransformer(newModuleTransformer);
206 const TGeoCombiTrans *kModuleTransform =
207 kModuleTransformer->GetTransformation();
208 TGeoCombiTrans *newModuleTransform = new TGeoCombiTrans(*kModuleTransform); // same module transform as the previous one
209 newModuleTransformer->SetTransformation(*kModuleTransform);
211 AliMUONGeometryStore *detElements =
212 kModuleTransformer->GetDetElementStore();
216 ("%i DEs in old GeometryStore %i",
217 detElements->GetNofEntries(), iMt));
219 for (Int_t iDe = 0; iDe < detElements->GetNofEntries(); iDe++)
220 { // detection elements.
221 AliMUONGeometryDetElement *detElement =
222 (AliMUONGeometryDetElement *) detElements->GetEntry(iDe);
224 AliFatal("Detection element not found.");
226 // local transformation of this detection element.
227 const TGeoCombiTrans *kLocalTransform =
228 detElement->GetLocalTransformation();
229 TGeoCombiTrans newLocalTransform = MisAlign(*kLocalTransform);
231 /// make a new detection element with this local transform
232 AliMUONGeometryDetElement *newDetElement =
233 new AliMUONGeometryDetElement(detElement->GetId(),
234 detElement->GetAlignedVolume(),
237 TGeoHMatrix newGlobalTransform =
238 AliMUONGeometryBuilder::Multiply(newLocalTransform,
239 *newModuleTransform);
241 newDetElement->SetGlobalTransformation(newGlobalTransform);
243 AliInfo("GlobalTransforms:");
244 newModuleTransformer->GetDetElementStore()->Add(
245 newDetElement->GetId(),
249 AliInfo(Form("Added module transformer %i to the transformer", iMt));
250 newGeometryTransformer->AddModuleTransformer(newModuleTransformer);
252 return newGeometryTransformer;