]>
Commit | Line | Data |
---|---|---|
1 | #include "AliITSAlignMille2ConstrArray.h" | |
2 | #include "AliITSAlignMille2Module.h" | |
3 | ||
4 | //======================================================================================================== | |
5 | ClassImp(AliITSAlignMille2ConstrArray) | |
6 | ||
7 | //________________________________________________________________________________________________________ | |
8 | AliITSAlignMille2ConstrArray::AliITSAlignMille2ConstrArray() : | |
9 | AliITSAlignMille2Constraint(), | |
10 | fModuleIDs(0), | |
11 | fModulePatt(0), | |
12 | fCoeffs(0), | |
13 | fError(0) | |
14 | {} | |
15 | ||
16 | //________________________________________________________________________________________________________ | |
17 | AliITSAlignMille2ConstrArray::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 | { | |
24 | // create module | |
25 | for (int i=0;i<npar;i++) {fCoeffs[i] = parcf[i]; if (parcf[i]!=0) SetBit(0x1<<i);} | |
26 | } | |
27 | ||
28 | //________________________________________________________________________________________________________ | |
29 | AliITSAlignMille2ConstrArray::AliITSAlignMille2ConstrArray(const AliITSAlignMille2ConstrArray& src) : | |
30 | AliITSAlignMille2Constraint(src), | |
31 | fModuleIDs(0), | |
32 | fModulePatt(0), | |
33 | fCoeffs(0), | |
34 | fError(0) | |
35 | {/* DUMMY */} | |
36 | ||
37 | //________________________________________________________________________________________________________ | |
38 | void AliITSAlignMille2ConstrArray::AddModule(AliITSAlignMille2Module* mod, Bool_t needGeom) | |
39 | { | |
40 | // add module to constraint | |
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(); | |
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 | |
55 | for (int i=AliITSAlignMille2Module::kMaxParGeom;i--;) patt &= ~BIT(i); // reset the geometry parameters | |
56 | for (int i=0;i<AliITSAlignMille2Module::kMaxParGeom;i++) { | |
57 | if (!IncludesParam(i)) continue; | |
58 | for (int j=0;j<AliITSAlignMille2Module::kMaxParGeom;j++) if (jacobian[i][j]!=0) patt |= BIT(j); | |
59 | } | |
60 | } | |
61 | fModulePatt[nmd] = patt; | |
62 | } | |
63 | } | |
64 | ||
65 | //________________________________________________________________________________________________________ | |
66 | Bool_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 | //________________________________________________________________________________________________________ | |
75 | Bool_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 | //________________________________________________________________________________________________________ | |
87 | Bool_t AliITSAlignMille2ConstrArray::IncludesModPar(const AliITSAlignMille2Module* mod, Int_t par) const | |
88 | { | |
89 | // is this module/parameter mentioned in the list? | |
90 | return IncludesModPar(mod->GetUniqueID(), par); | |
91 | } | |
92 | ||
93 | ||
94 | //________________________________________________________________________________________________________ | |
95 | void AliITSAlignMille2ConstrArray::Print(Option_t* ) const | |
96 | { | |
97 | // print data | |
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 |