]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/MUONCheckMisAligner.C
Updated list of MUON libraries
[u/mrichter/AliRoot.git] / MUON / MUONCheckMisAligner.C
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 /*
19   MUONCheckMisAligner: 
20   
21   This macro performs the misalignment on an existing muon arm geometry
22   based on the standard definition of the detector elements in 
23   $ALICE_ROOT/MUON/data
24
25   It uses AliMUONGeometryAligner : 
26   --> creates a new AliMUONGeometryTransformer and AliMUONGeometryAligner
27   --> reads the transformations in from the transform.dat file (make sure that
28   this file is the _standard_ one by comparing it to the one in CVS)
29   --> creates a second AliMUONGeometryTransformer by misaligning the existing 
30   one using AliMUONAligner::MisAlign
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   --> User can also set misalignment ranges by hand using the methods : 
35   SetMaxCartMisAlig, SetMaxAngMisAlig, SetXYAngMisAligFactor
36   (last method takes account of the fact that the misalingment is greatest in 
37   the XY plane, since the detection elements are fixed to a support structure
38   in this plane. Misalignments in the XZ and YZ plane will be very small 
39   compared to those in the XY plane, which are small already - of the order 
40   of microns)
41   --> Default behavior generates a "residual" misalignment using gaussian
42   distributions. Uniform distributions can still be used, see 
43   AliMUONGeometryAligner.
44   --> User can also generate module misalignments using SetModuleCartMisAlig
45   and SetModuleAngMisAlig
46   Note : If the detection elements are allowed to be misaligned in all
47   directions, this has consequences for the alignment algorithm, which 
48   needs to know the number of free parameters. Eric only allowed 3 : 
49   x,y,theta_xy, but in principle z and the other two angles are alignable
50   as well.  
51
52 // Author:Bruce Becker
53
54 */
55
56 #if !defined(__CINT__) || defined(__MAKECINT__)
57
58 #include "AliMUONGeometryTransformer.h"
59 #include "AliMUONGeometryMisAligner.h"
60
61 #include "AliSimulation.h"
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
71 void MUONCheckMisAligner(Double_t xcartmisaligm = 0.0, Double_t xcartmisaligw = 0.004, 
72                          Double_t ycartmisaligm = 0.0, Double_t ycartmisaligw = 0.003, 
73                          Double_t angmisaligm = 0.0, Double_t angmisaligw = 0.0023,
74                          TString nameCDB = "ResMisAlignCDB", 
75                          const TString& geomFileName = "geometry.root")
76 {
77   
78   // Load geometry from file 
79   TGeoManager::Import(geomFileName.Data());
80   if ( ! gGeoManager ) return;
81
82   AliMUONGeometryTransformer *transform = new AliMUONGeometryTransformer(true);
83   transform->ReadGeometryData("volpath.dat", geomFileName.Data());
84   AliMUONGeometryMisAligner misAligner(xcartmisaligm,xcartmisaligw,
85                                        ycartmisaligm,ycartmisaligw,
86                                        angmisaligm,angmisaligw);
87
88   // Generate mis alignment data
89   // Uncomment lines below if you would like to generate module misalignments
90 //  misAligner.SetModuleCartMisAlig(0.0,0.1,0.0,0.1,0.0,0.1); // Full
91 //   misAligner.SetModuleAngMisAlig(0.0,0.02,0.0,0.04,0.0,0.02); // Full
92 //   misAligner.SetModuleCartMisAlig(0.0,0.003,0.0,0.003,0.0,0.003); // Res
93 //   misAligner.SetModuleAngMisAlig(0.0,0.0006,0.0,0.001,0.0,0.0005); // Res
94   AliMUONGeometryTransformer *newTransform = misAligner.MisAlign(transform,true); 
95   newTransform->WriteTransformations("transform2.dat");
96   newTransform->WriteMisAlignmentData("misalign.root");
97
98   // Apply misAlignment via AliRoot framework
99   AliSimulation sim;
100   sim.ApplyAlignObjsToGeom(
101      const_cast<TClonesArray*>(newTransform->GetMisAlignmentData()));
102   // Save new geometry file
103   gGeoManager->Export("geometry2.root");
104   
105   // Extract new transformations
106   AliMUONGeometryTransformer* transform3 = new AliMUONGeometryTransformer(true);
107   transform3->ReadGeometryData("volpath.dat", "geometry2.root");
108   transform3->WriteTransformations("transform3.dat");
109                // Check that transform3.dat is equal to transform2.dat
110
111   // Generate misaligned data in local cdb
112   const TClonesArray* array = newTransform->GetMisAlignmentData();
113    
114   TString sLocCDB("local://");
115   sLocCDB += nameCDB;
116   // CDB manager
117   AliCDBManager* cdbManager = AliCDBManager::Instance();
118   cdbManager->SetDefaultStorage(sLocCDB.Data());
119   
120   AliCDBMetaData* cdbData = new AliCDBMetaData();
121   cdbData->SetResponsible("Dimuon Offline project");
122   cdbData->SetComment("MUON alignment objects with residual misalignment");
123   AliCDBId id("MUON/Align/Data", 0, 0); 
124   cdbManager->Put(const_cast<TClonesArray*>(array), id, cdbData);
125
126   // To run simulation with misaligned geometry, you have to set
127   // the Align option in Config.C:
128   // MUON->SetAlign("transform2.dat");
129 }
130
131
132
133