minor fix
[u/mrichter/AliRoot.git] / ITS / AliITSAlignMille2ConstrArray.cxx
CommitLineData
6526a72c 1#include "AliITSAlignMille2ConstrArray.h"
2#include "AliITSAlignMille2Module.h"
3
4//========================================================================================================
5ClassImp(AliITSAlignMille2ConstrArray)
6
7//________________________________________________________________________________________________________
8AliITSAlignMille2ConstrArray::AliITSAlignMille2ConstrArray() :
9AliITSAlignMille2Constraint(),
10fModuleIDs(0),
11fModulePatt(0),
12fCoeffs(0),
13fError(0)
14{}
15
16//________________________________________________________________________________________________________
17AliITSAlignMille2ConstrArray::AliITSAlignMille2ConstrArray(const Char_t* name,Double_t *parcf,Int_t npar,Double_t val,Double_t err) :
18 AliITSAlignMille2Constraint(name,kTypeGaussian,-100,val,0),
19 fModuleIDs(0),
20 fModulePatt(0),
21 fCoeffs(npar),
22 fError(err)
23{
b80c197e 24 // create module
6526a72c 25 for (int i=0;i<npar;i++) {fCoeffs[i] = parcf[i]; if (parcf[i]!=0) SetBit(0x1<<i);}
26}
27
28//________________________________________________________________________________________________________
29AliITSAlignMille2ConstrArray::AliITSAlignMille2ConstrArray(const AliITSAlignMille2ConstrArray& src) :
30 AliITSAlignMille2Constraint(src),
31 fModuleIDs(0),
32 fModulePatt(0),
33 fCoeffs(0),
34 fError(0)
35{/* DUMMY */}
36
37//________________________________________________________________________________________________________
ef24eb3b 38void AliITSAlignMille2ConstrArray::AddModule(AliITSAlignMille2Module* mod, Bool_t needGeom)
6526a72c 39{
b80c197e 40 // add module to constraint
6526a72c 41 int nmd = GetNModules();
42 // check if its already not there
43 for (int im=nmd;im--;) {if (mod->GetUniqueID() == (UInt_t)fModuleIDs[im]) return; }
44 fModuleIDs.Set(nmd+1);
45 fModulePatt.Set(nmd+1);
46 fModuleIDs[nmd] = mod->GetUniqueID();
ef24eb3b 47 if (needGeom) { // this is geometrical constraint
48 double jacobian[AliITSAlignMille2Module::kMaxParGeom][AliITSAlignMille2Module::kMaxParGeom];
49 if (mod->GeomParamsGlobal()) mod->CalcDerivLocGlo(&jacobian[0][0]);
50 //
51 Short_t patt = GetPattern();
52 if (mod->GeomParamsGlobal()) {
53 // the constraint is defined in the module's local frame. If the alignment of geom params is
54 // done in the global frame, we need to set the real parameter involved
e9b15b0c 55 for (int i=AliITSAlignMille2Module::kMaxParGeom;i--;) patt &= ~BIT(i); // reset the geometry parameters
ef24eb3b 56 for (int i=0;i<AliITSAlignMille2Module::kMaxParGeom;i++) {
57 if (!IncludesParam(i)) continue;
e9b15b0c 58 for (int j=0;j<AliITSAlignMille2Module::kMaxParGeom;j++) if (jacobian[i][j]!=0) patt |= BIT(j);
ef24eb3b 59 }
6526a72c 60 }
ef24eb3b 61 fModulePatt[nmd] = patt;
6526a72c 62 }
6526a72c 63}
64
65//________________________________________________________________________________________________________
66Bool_t AliITSAlignMille2ConstrArray::IncludesModule(Int_t id) const
67{
68 // is this module mentioned in the list?
69 int nmd = GetNModules();
70 for (int i=nmd;i--;) if (fModuleIDs[i]==id) return kTRUE;
71 return kFALSE;
72}
73
74//________________________________________________________________________________________________________
75Bool_t AliITSAlignMille2ConstrArray::IncludesModPar(Int_t id,Int_t par) const
76{
77 // is this module/parameter mentioned in the list?
78 int nmd = GetNModules();
79 for (int i=nmd;i--;) {
80 if (fModuleIDs[i]!=id) continue;
81 if (fModulePatt[i] & (0x1<<par)) return kTRUE;
82 }
83 return kFALSE;
84}
85
86//________________________________________________________________________________________________________
45993b23 87Bool_t AliITSAlignMille2ConstrArray::IncludesModPar(const AliITSAlignMille2Module* mod, Int_t par) const
6526a72c 88{
89 // is this module/parameter mentioned in the list?
90 return IncludesModPar(mod->GetUniqueID(), par);
91}
92
93
94//________________________________________________________________________________________________________
95void AliITSAlignMille2ConstrArray::Print(Option_t* ) const
96{
b80c197e 97 // print data
6526a72c 98 printf("#%3d Constraint %s of type %d | Value=%+e Error=%+e\n",GetConstraintID(),GetName(),GetType(),GetValue(),GetError());
99 printf("Weights on params: "); for (int i=0;i<GetNCoeffs();i++) printf("%+.3e ",GetCoeff(i));
100 printf("\nModules involved: \n");
101 int nmd = GetNModules();
102 for (int i=0;i<nmd;i++) {printf("%4d |",GetModuleID(i)); if ( ((i+1)%14)==0 ) printf("\n");}
103 if ( nmd%14 ) printf("\n");
104 //
105}
106