preprocessor stored DCS points in RefCDB
[u/mrichter/AliRoot.git] / MUON / MUONCheckMisAligner.C
CommitLineData
57e827c3 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
e54bf126 18/// \ingroup macros
19/// \file MUONCheckMisAligner.C
20/// \brief This macro performs the misalignment on an existing muon arm geometry
21///
22/// This macro performs the misalignment on an existing muon arm geometry
23/// based on the standard definition of the detector elements in
24/// the AliMUONGeometryTransformer class.
25///
26/// It uses AliMUONGeometryMisAligner :
27/// - Creates a new AliMUONGeometryTransformer and AliMUONGeometryMisAligner
28/// - Reads the transformations in from the transform.dat file (make sure that
29/// this file is the _standard_ one by comparing it to the one in CVS)
30/// - Creates a second AliMUONGeometryTransformer by misaligning the existing
31/// one using AliMUONGeometryMisAligner::MisAlign
32/// - User has to specify the magnitude of the alignments, in the Cartesian
33/// co-ordiantes (which are used to apply translation misalignments) and in the
34/// spherical co-ordinates (which are used to apply angular displacements)
35/// - User can also set misalignment ranges by hand using the methods :
36/// 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
41/// of microns)
42/// - Default behavior generates a "residual" misalignment using gaussian
43/// distributions. Uniform distributions can still be used, see
44/// AliMUONGeometryMisAligner.
45/// - User can also generate module misalignments using SetModuleCartMisAlig
46/// and SetModuleAngMisAlig
47///
48/// Note: If the detection elements are allowed to be misaligned in all
49/// directions, this has consequences for the alignment algorithm, which
50/// needs to know the number of free parameters. Eric only allowed 3 :
51/// x,y,theta_xy, but in principle z and the other two angles are alignable
52/// as well.
53///
54/// \author:Bruce Becker
57e827c3 55
edd305e8 56#if !defined(__CINT__) || defined(__MAKECINT__)
57
58#include "AliMUONGeometryTransformer.h"
59#include "AliMUONGeometryMisAligner.h"
60
ef4cb4f1 61#include "AliGeomManager.h"
edd305e8 62#include "AliCDBManager.h"
63#include "AliCDBMetaData.h"
64#include "AliCDBId.h"
65
66#include <TGeoManager.h>
67#include <TClonesArray.h>
68
69#endif
70
2cbab029 71void MUONCheckMisAligner(Double_t xcartmisaligm = 0.0, Double_t xcartmisaligw = 0.004,
72 Double_t ycartmisaligm = 0.0, Double_t ycartmisaligw = 0.003,
b9bff1ec 73 Double_t angmisaligm = 0.0, Double_t angmisaligw = 0.0023,
edd305e8 74 TString nameCDB = "ResMisAlignCDB",
75 const TString& geomFileName = "geometry.root")
57e827c3 76{
77
ef4cb4f1 78 AliMUONGeometryTransformer *transform = new AliMUONGeometryTransformer();
79 transform->LoadGeometryData(geomFileName.Data());
edd305e8 80
2cbab029 81 AliMUONGeometryMisAligner misAligner(xcartmisaligm,xcartmisaligw,
82 ycartmisaligm,ycartmisaligw,
83 angmisaligm,angmisaligw);
57e827c3 84
f1d59163 85 // Generate mis alignment data
ef4cb4f1 86
4600314b 87 // Uncomment lines below if you would like to generate module misalignments
ef4cb4f1 88 // misAligner.SetModuleCartMisAlig(0.0,0.1,0.0,0.1,0.0,0.1); // Full
89 // misAligner.SetModuleAngMisAlig(0.0,0.02,0.0,0.04,0.0,0.02); // Full
90 // misAligner.SetModuleCartMisAlig(0.0,0.003,0.0,0.003,0.0,0.003); // Res
91 // misAligner.SetModuleAngMisAlig(0.0,0.0006,0.0,0.001,0.0,0.0005); // Res
92
57e827c3 93 AliMUONGeometryTransformer *newTransform = misAligner.MisAlign(transform,true);
94 newTransform->WriteTransformations("transform2.dat");
f1d59163 95 newTransform->WriteMisAlignmentData("misalign.root");
96
97 // Apply misAlignment via AliRoot framework
ef4cb4f1 98 AliGeomManager::ApplyAlignObjsToGeom(
99 *const_cast<TClonesArray*>(newTransform->GetMisAlignmentData()));
f1d59163 100 // Save new geometry file
101 gGeoManager->Export("geometry2.root");
102
103 // Extract new transformations
ef4cb4f1 104 AliMUONGeometryTransformer* transform3 = new AliMUONGeometryTransformer();
105 transform3->LoadGeometryData("geometry2.root");
f1d59163 106 transform3->WriteTransformations("transform3.dat");
107 // Check that transform3.dat is equal to transform2.dat
57e827c3 108
2cbab029 109 // Generate misaligned data in local cdb
edd305e8 110 const TClonesArray* array = newTransform->GetMisAlignmentData();
2cbab029 111
b9bff1ec 112 TString sLocCDB("local://");
113 sLocCDB += nameCDB;
2cbab029 114 // CDB manager
115 AliCDBManager* cdbManager = AliCDBManager::Instance();
b9bff1ec 116 cdbManager->SetDefaultStorage(sLocCDB.Data());
2cbab029 117
118 AliCDBMetaData* cdbData = new AliCDBMetaData();
119 cdbData->SetResponsible("Dimuon Offline project");
120 cdbData->SetComment("MUON alignment objects with residual misalignment");
121 AliCDBId id("MUON/Align/Data", 0, 0);
edd305e8 122 cdbManager->Put(const_cast<TClonesArray*>(array), id, cdbData);
2cbab029 123
57e827c3 124 // To run simulation with misaligned geometry, you have to set
125 // the Align option in Config.C:
126 // MUON->SetAlign("transform2.dat");
127}
128
129
130
131