]> git.uio.no Git - u/mrichter/AliRoot.git/blob - MUON/AliMUONAlignment.h
unlock TGeoManager before deleting it
[u/mrichter/AliRoot.git] / MUON / AliMUONAlignment.h
1 #ifndef ALIMUONALIGNMENT_H
2 #define ALIMUONALIGNMENT_H
3 /* Copyright(c) 1998-1999, ALICE Experiment at CERN, All rights reserved. *
4 * See cxx source for full Copyright notice                               */
5
6 /* $Id: AliMUONAlignment.h 50858 2011-07-29 10:58:20Z ivana $ */
7
8 /// \ingroup rec
9 /// \class AliMUONAlignment
10 /// \brief Class for alignment of muon spectrometer
11 //
12 // Authors: Bruce Becker, Javier Castillo, Hugo Pereira Da Costa
13
14 #include "AliMillePedeRecord.h"
15
16 #include <TObject.h>
17 #include <TString.h>
18 #include <TGeoMatrix.h>
19
20 class TClonesArray;
21 class AliMillePede2;
22 class AliMUONGeometryTransformer;
23 class AliMUONTrack;
24 class AliMUONTrackParam;
25 class AliMUONVCluster;
26
27 class AliMUONAlignment:public TObject
28 {
29
30   public:
31
32   AliMUONAlignment();
33
34   virtual ~AliMUONAlignment();
35
36   void Init( void );
37
38   // array dimendions
39   enum
40   {
41     /// Number tracking stations
42     fgNSt = 5,
43
44     /// Number tracking chambers
45     fgNCh = 10,
46
47     /// Number of tracking modules (4 ch + 6*2 half-ch)
48     fgNTrkMod = 16,
49
50     /// Total number of detection elements
51     /// (4*2 + 4*2 + 18*2 + 26*2 + 26*2)
52     fgNDetElem = 156,
53
54     /// Number of local parameters
55     fNLocal = 4,
56
57     /// Number of degrees of freedom per chamber
58     fgNParCh = 4,
59
60     /// Number of global parameters
61     fNGlobal = fgNParCh*fgNDetElem
62   };
63
64   /// Number of detection elements per chamber
65   static const Int_t fgNDetElemCh[fgNCh];
66
67   /// Sum of detection elements up to this chamber
68   static const Int_t fgSNDetElemCh[fgNCh+1];
69
70   /// global parameter bit set, used for masks
71   enum ParameterMask
72   {
73     ParX = 1<<0,
74     ParY = 1<<1,
75     ParZ = 1<<2,
76     ParTZ = 1<<3,
77
78     ParAllTranslations = ParX|ParY|ParZ,
79     ParAllRotations = ParTZ,
80     ParAll = ParAllTranslations|ParAllRotations
81
82   };
83
84   /// detector sides bit set, used for selecting sides in constrains
85   enum SidesMask
86   {
87     SideTop = 1<<0,
88     SideLeft = 1<<1,
89     SideBottom = 1<<2,
90     SideRight = 1<<3,
91     SideTopLeft = SideTop|SideLeft,
92     SideTopRight = SideTop|SideRight,
93     SideBottomLeft = SideBottom|SideLeft,
94     SideBottomRight = SideBottom|SideRight,
95     AllSides = SideTop|SideBottom|SideLeft|SideRight
96   };
97
98   AliMillePedeRecord* ProcessTrack( AliMUONTrack* track, Bool_t doAlignment, Double_t weight = 1 );
99
100   void ProcessTrack( AliMillePedeRecord* );
101
102   //@name modifiers
103   //@{
104
105   /// run number
106   void SetRunNumber( Int_t id )
107   {fRunNumber = id;}
108
109   /// Set flag for Magnetic field On/Off
110   void SetBFieldOn( Bool_t value )
111   { fBFieldOn = value; }
112
113   void SetAllowedVariation( Int_t iPar, Double_t value );
114
115   void SetSigmaXY(Double_t sigmaX, Double_t sigmaY);
116
117   /// Set geometry transformer
118   void SetGeometryTransformer( AliMUONGeometryTransformer * transformer )
119   { fTransform = transformer; }
120
121   //@}
122
123   //@name fixing detectors
124   //@{
125
126   void FixAll( UInt_t parameterMask = ParAll );
127
128   void FixChamber( Int_t iCh, UInt_t parameterMask = ParAll );
129
130   void FixDetElem( Int_t iDetElemId, UInt_t parameterMask = ParAll );
131
132   void FixHalfSpectrometer( const Bool_t* bChOnOff, UInt_t sidesMask = AllSides, UInt_t parameterMask = ParAll );
133
134   void FixParameter( Int_t iPar );
135
136   void FixParameter( Int_t iDetElem, Int_t iPar )
137   { FixParameter( iDetElem*fgNParCh + iPar ); }
138
139   //@}
140
141   //@name releasing detectors
142   //@{
143
144   void ReleaseChamber( Int_t iCh, UInt_t parameterMask = ParAll );
145
146   void ReleaseDetElem( Int_t iDetElemId, UInt_t parameterMask = ParAll );
147
148   void ReleaseParameter( Int_t iPar );
149
150   void ReleaseParameter( Int_t iDetElem, Int_t iPar )
151   { ReleaseParameter( iDetElem*fgNParCh + iPar ); }
152
153   //@}
154
155   //@name grouping detectors
156   //@{
157
158   void GroupChamber( Int_t iCh, UInt_t parameterMask = ParAll );
159
160   void GroupDetElems( Int_t detElemMin, Int_t detElemMax, UInt_t parameterMask = ParAll );
161
162   void GroupDetElems( Int_t *detElemList, Int_t nDetElem, UInt_t parameterMask = ParAll );
163
164   //@}
165
166   //@name define non linearity
167   //@{
168
169   void SetChamberNonLinear( Int_t iCh, UInt_t parameterMask);
170
171   void SetDetElemNonLinear( Int_t iSt, UInt_t parameterMask);
172
173   void SetParameterNonLinear( Int_t iPar );
174
175   void SetParameterNonLinear( Int_t iDetElem, Int_t iPar )
176   { SetParameterNonLinear( iDetElem*fgNParCh + iPar ); }
177
178   //@}
179
180   //@name constraints
181   //@{
182
183   void AddConstraints( const Bool_t *bChOnOff, UInt_t parameterMask );
184
185   void AddConstraints( const Bool_t *bChOnOff, const Bool_t *lVarXYT, UInt_t sidesMask = AllSides );
186
187   //@}
188
189   /// initialize global parameters to a give set of values
190   void InitGlobalParameters( Double_t *par );
191
192   /// perform global fit
193   void GlobalFit( Double_t *parameters,Double_t *errors,Double_t *pulls );
194
195   /// print global parameters
196   void PrintGlobalParameters( void ) const;
197
198   /// get error on a given parameter
199   Double_t GetParError( Int_t iPar ) const;
200
201   AliMUONGeometryTransformer* ReAlign( const AliMUONGeometryTransformer * transformer, const double *misAlignments, Bool_t verbose );
202
203   void SetAlignmentResolution( const TClonesArray* misAlignArray, Int_t chId, Double_t chResX, Double_t chResY, Double_t deResX, Double_t deResY );
204
205   private:
206
207   /// Not implemented
208   AliMUONAlignment(const AliMUONAlignment& right);
209
210   /// Not implemented
211   AliMUONAlignment&  operator = (const AliMUONAlignment& right);
212
213   /// Set array of local derivatives
214   void SetLocalDerivative(Int_t index, Double_t value)
215   { fLocalDerivatives[index] = value; }
216
217   /// Set array of global derivatives
218   void SetGlobalDerivative(Int_t index, Double_t value)
219   { fGlobalDerivatives[index] = value; }
220
221   void FillDetElemData( AliMUONVCluster* );
222
223   void FillRecPointData( AliMUONVCluster* );
224
225   void FillTrackParamData( AliMUONTrackParam* );
226
227   void LocalEquationX( void );
228
229   void LocalEquationY( void );
230
231   TGeoCombiTrans DeltaTransform(const double *detElemMisAlignment) const;
232
233   ///@name utilities
234   //@{
235
236   void AddConstraint(Double_t* parameters, Double_t value );
237
238   Int_t GetChamberId( Int_t iDetElemNumber ) const;
239
240   Bool_t DetElemIsValid( Int_t iDetElemId ) const;
241
242   Int_t GetDetElemNumber( Int_t iDetElemId ) const;
243
244   TString GetParameterMaskString( UInt_t parameterMask ) const;
245
246   TString GetSidesMaskString( UInt_t sidesMask ) const;
247
248   //@}
249
250   /// true when initialized
251   Bool_t fInitialized;
252
253   /// current run id
254   Int_t fRunNumber;
255
256   /// Flag for Magnetic filed On/Off
257   Bool_t fBFieldOn;
258
259   /// "Encouraged" variation for degrees of freedom
260   Double_t fAllowVar[fgNParCh];
261
262   /// Initial value for chi2 cut
263   /** if > 1 Iterations in AliMillepede are turned on */
264   Double_t fStartFac;
265
266   /// Cut on residual for first iteration
267   Double_t fResCutInitial;
268
269   /// Cut on residual for other iterations
270   Double_t fResCut;
271
272   /// Detector independent alignment class
273   AliMillePede2* fMillepede;
274
275   /// running AliMUONVCluster
276   AliMUONVCluster* fCluster;
277
278   /// Number of standard deviations for chi2 cut
279   Int_t fNStdDev;
280
281   /// Cluster (global) position
282   Double_t fClustPos[3];
283
284   /// Track slope at reference point
285   Double_t fTrackSlope0[2];
286
287   /// Track slope at current point
288   Double_t fTrackSlope[2];
289
290   /// Track intersection at reference point
291   Double_t fTrackPos0[3];
292
293   /// Track intersection at current point
294   Double_t fTrackPos[3];
295
296   /// Current measurement (depend on B field On/Off)
297   Double_t fMeas[2];
298
299   /// Estimated resolution on measurement
300   Double_t fSigma[2];
301
302   /// degrees of freedom
303   enum
304   {
305     kFixedParId = -1,
306     kFreeParId = kFixedParId-1,
307     kGroupBaseId = -10
308   };
309
310   /// Array of effective degrees of freedom
311   /// it is used to fix detectors, parameters, etc.
312   Int_t fGlobalParameterStatus[fNGlobal];
313
314   /// Array of global derivatives
315   Double_t fGlobalDerivatives[fNGlobal];
316
317   /// Array of local derivatives
318   Double_t fLocalDerivatives[fNLocal];
319
320   /// current detection element number
321   Int_t fDetElemNumber;
322
323   /// running Track record
324   AliMillePedeRecord fTrackRecord;
325
326   /// Geometry transformation
327   AliMUONGeometryTransformer *fTransform;
328   TGeoCombiTrans fGeoCombiTransInverse;
329
330   ClassDef(AliMUONAlignment, 2)
331
332 };
333
334 #endif