BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
BmnGlobalAlignment.h
Go to the documentation of this file.
1// @(#)bmnroot/alignment:$Id$
2// Author: Pavel Batyuk <pavel.batyuk@jinr.ru> 2017-03-31
3
4////////////////////////////////////////////////////////////////////////////////
5// //
6// BmnGlobalAlignment //
7// //
8// Alignment of tracking detectors. //
9// //
10// Uses Volker Blobel and Claus Kleinwort Millepede II //
11// //
12////////////////////////////////////////////////////////////////////////////////
13#ifndef BMNGLOBALALIGNMENT_H
14#define BMNGLOBALALIGNMENT_H 1
15
17#include "BmnGemStripHit.h"
18#include "BmnMille.h"
19#include "BmnMilleContainer.h"
21#include "BmnSiliconHit.h"
22#include "FairEventHeader.h"
23#include "FairRootManager.h"
24#include "FairTask.h"
25
26#include <BmnFieldMap.h>
27#include <BmnGemStripStationSet.h>
28#include <BmnGlobalTrack.h>
29#include <BmnNewFieldMap.h>
30#include <BmnSiliconStationSet.h>
31#include <FairField.h>
32#include <TClonesArray.h>
33#include <TFitResult.h>
34#include <TFitResultPtr.h>
35#include <TGeoManager.h>
36#include <TMath.h>
37#include <TNamed.h>
38#include <TString.h>
39#include <TSystem.h>
40#include <UniDetectorParameter.h>
41#include <UniRun.h>
42#include <fstream>
43#include <sstream>
44#include <vector>
45
46using namespace std;
47using namespace TMath;
48
50{
51 public:
54 TString,
55 Int_t,
56 Int_t,
57 TString misAlignFile = "misAlignment.root",
58 Bool_t doTest = kFALSE);
59 virtual ~BmnGlobalAlignment();
60
61 virtual InitStatus Init();
62
63 virtual void Exec(Option_t* opt);
64
65 virtual void Finish();
66
67 void SetDoTest(Bool_t flag) { fIsDoTest = flag; }
68
70 {
71 fDetectorSet[0] = gem;
72 fDetectorSet[1] = si;
73 }
74
76
77 void SetPreSigma(Double_t presigma) { fPreSigma = presigma; }
78
79 void SetAccuracy(Double_t accuracy) { fAccuracy = accuracy; }
80
82
84
85 void SetDwfractionCut(Double_t fraction) { fDwfractioncut = fraction; }
86
88
90
92 {
93 fTxMin = min;
94 fTxMax = max;
95 }
96
98 {
99 fTyMin = min;
100 fTyMax = max;
101 }
102
103 void SetDebug(Bool_t flag) { fDebug = flag; }
104
105 void SetHugecut(Double_t val) { fHugecut = val; }
106
108 {
109 fChisqcut[0] = val1;
110 fChisqcut[1] = val2;
111 }
112
113 void SetEntriesPerParam(Int_t entries) { fEntries = entries; }
114
116 Bool_t st1_0,
117 Bool_t st2_0,
118 Bool_t st3_0,
119 Bool_t st3_1,
120 Bool_t st4_0,
121 Bool_t st4_1,
122 Bool_t st5_0,
123 Bool_t st5_1)
124 {
125
126 cout << "GEM" << endl;
127 const Int_t nModulMax = 2; // To be fixed
128 Bool_t** gems = new Bool_t*[fDetectorGEM->GetNStations()];
129 for (Int_t iStat = 0; iStat < fDetectorGEM->GetNStations(); iStat++)
130 gems[iStat] = new Bool_t[nModulMax];
131 gems[0][0] = st0_0;
132 gems[1][0] = st1_0;
133 gems[2][0] = st2_0;
134 gems[3][0] = st3_0;
135 gems[3][1] = st3_1;
136 gems[4][0] = st4_0;
137 gems[4][1] = st4_1;
138 gems[5][0] = st5_0;
139 gems[5][1] = st5_1;
140
141 for (Int_t iStat = 0; iStat < fDetectorGEM->GetNStations(); iStat++)
142 for (Int_t iMod = 0; iMod < fDetectorGEM->GetGemStation(iStat)->GetNModules(); iMod++)
143 if (gems[iStat][iMod])
144 fixedGemElements[iStat][iMod] = kTRUE;
145
146 if (fDebug)
147 for (Int_t iStat = 0; iStat < fDetectorGEM->GetNStations(); iStat++)
148 for (Int_t iMod = 0; iMod < fDetectorGEM->GetGemStation(iStat)->GetNModules(); iMod++)
149 cout << "Stat = " << iStat << " Mod = " << iMod << " isFixed (true / false) "
150 << fixedGemElements[iStat][iMod] << endl;
151 }
152
154 Bool_t st0_1,
155 Bool_t st0_2,
156 Bool_t st0_3,
157 Bool_t st0_4,
158 Bool_t st0_5,
159 Bool_t st0_6,
160 Bool_t st0_7)
161 {
162 cout << "SI" << endl;
163 const Int_t nModulMax = 8; // FIXME
164 Bool_t** si = new Bool_t*[fDetectorSI->GetNStations()];
165 for (Int_t iStat = 0; iStat < fDetectorSI->GetNStations(); iStat++)
166 si[iStat] = new Bool_t[nModulMax];
167 si[0][0] = st0_0;
168 si[0][1] = st0_1;
169 si[0][2] = st0_2;
170 si[0][3] = st0_3;
171 si[0][4] = st0_4;
172 si[0][5] = st0_5;
173 si[0][6] = st0_6;
174 si[0][7] = st0_7;
175
176 for (Int_t iStat = 0; iStat < fDetectorSI->GetNStations(); iStat++)
177 for (Int_t iMod = 0; iMod < fDetectorSI->GetSiliconStation(iStat)->GetNModules(); iMod++)
178 if (si[iStat][iMod])
179 fixedSiElements[iStat][iMod] = kTRUE;
180
181 if (fDebug)
182 for (Int_t iStat = 0; iStat < fDetectorSI->GetNStations(); iStat++)
183 for (Int_t iMod = 0; iMod < fDetectorSI->GetSiliconStation(iStat)->GetNModules(); iMod++)
184 cout << "Stat = " << iStat << " Mod = " << iMod << " isFixed (true / false) "
185 << fixedSiElements[iStat][iMod] << endl;
186 }
187
189 Bool_t st0_1,
190 Bool_t st0_2,
191 Bool_t st0_3,
192 Bool_t st1_0,
193 Bool_t st1_1,
194 Bool_t st2_0,
195 Bool_t st2_1,
196 Bool_t st2_2,
197 Bool_t st2_3,
198 Bool_t st2_4,
199 Bool_t st2_5,
200 Bool_t st2_6,
201 Bool_t st2_7)
202 {
203 cout << "SI" << endl;
204 const Int_t nModulMax = 8; // FIXME
205 Bool_t** si = new Bool_t*[fDetectorSI->GetNStations()];
206 for (Int_t iStat = 0; iStat < fDetectorSI->GetNStations(); iStat++)
207 si[iStat] = new Bool_t[nModulMax];
208
209 // Stat #0
210 si[0][0] = st0_0;
211 si[0][1] = st0_1;
212 si[0][2] = st0_2;
213 si[0][3] = st0_3;
214
215 // Stat #1
216 si[1][0] = st1_0;
217 si[1][1] = st1_1;
218
219 // Stat #2
220 si[2][0] = st2_0;
221 si[2][1] = st2_1;
222 si[2][2] = st2_2;
223 si[2][3] = st2_3;
224 si[2][4] = st2_4;
225 si[2][5] = st2_5;
226 si[2][6] = st2_6;
227 si[2][7] = st2_7;
228
229 for (Int_t iStat = 0; iStat < fDetectorSI->GetNStations(); iStat++)
230 for (Int_t iMod = 0; iMod < fDetectorSI->GetSiliconStation(iStat)->GetNModules(); iMod++)
231 if (si[iStat][iMod])
232 fixedSiElements[iStat][iMod] = kTRUE;
233 }
234
236 Bool_t st0_1,
237 Bool_t st0_2,
238 Bool_t st0_3,
239 Bool_t st1_0,
240 Bool_t st1_1,
241 Bool_t st2_0,
242 Bool_t st2_1,
243 Bool_t st2_2,
244 Bool_t st2_3,
245 Bool_t st2_4,
246 Bool_t st2_5,
247 Bool_t st2_6,
248 Bool_t st2_7)
249 {
250 SetSiFixedRun7(st0_0, st0_1, st0_2, st0_3, st1_0, st1_1, st2_0, st2_1, st2_2, st2_3, st2_4, st2_5, st2_6,
251 st2_7);
252 }
253
255 Bool_t st1_0,
256 Bool_t st2_0,
257 Bool_t st3_0,
258 Bool_t st4_0,
259 Bool_t st4_1,
260 Bool_t st5_0,
261 Bool_t st5_1,
262 Bool_t st6_0,
263 Bool_t st6_1,
264 Bool_t st7_0,
265 Bool_t st7_1,
266 Bool_t st8_0,
267 Bool_t st8_1,
268 Bool_t st9_0,
269 Bool_t st9_1)
270 {
271
272 cout << "GEM" << endl;
273 const Int_t nModulMax = 2; // FIXME
274 Bool_t** gem = new Bool_t*[fDetectorGEM->GetNStations()];
275 for (Int_t iStat = 0; iStat < fDetectorGEM->GetNStations(); iStat++)
276 gem[iStat] = new Bool_t[nModulMax];
277
278 // Stat #0
279 gem[0][0] = st0_0;
280
281 // Stat #1
282 gem[1][0] = st1_0;
283
284 // Stat #2
285 gem[2][0] = st2_0;
286
287 // Stat #3
288 gem[3][0] = st3_0;
289
290 // Stat #4
291 gem[4][0] = st4_0;
292 gem[4][1] = st4_1;
293
294 // Stat #5
295 gem[5][0] = st5_0;
296 gem[5][1] = st5_1;
297
298 // Stat #6
299 gem[6][0] = st6_0;
300 gem[6][1] = st6_1;
301
302 // Stat #7
303 gem[7][0] = st7_0;
304 gem[7][1] = st7_1;
305
306 // Stat #8
307 gem[8][0] = st8_0;
308 gem[8][1] = st8_1;
309
310 // Stat #9
311 gem[9][0] = st9_0;
312 gem[9][1] = st9_1;
313
314 for (Int_t iStat = 0; iStat < fDetectorGEM->GetNStations(); iStat++)
315 for (Int_t iMod = 0; iMod < fDetectorGEM->GetGemStation(iStat)->GetNModules(); iMod++)
316 if (gem[iStat][iMod])
317 fixedGemElements[iStat][iMod] = kTRUE;
318 }
319
326
333
335
336 private:
338 const Int_t MakeBinFile();
339 void MakeSteerFile();
340 void MilleNoFieldRuns(BmnGlobalTrack*, Int_t, Int_t, vector<BmnMilleContainer*>&, vector<BmnMilleContainer*>&);
341 void Pede();
342 void ReadPedeOutput(ifstream&);
343 void ExtractCorrValues(ifstream&, Double_t*);
345
347 {
348 // return 3 * (2 * st + mod + 1); // FIXME!!!
349 return gemStatModLabel.find(pair<Int_t, Int_t>(st, mod))->second;
350 }
351
353 {
354 // Int_t coeff[3] = {0, 6, 3}; FIXME!!
355 // return GemStatModLabel(st, mod) + coeff[st] * st;
356 return silStatModLabel.find(pair<Int_t, Int_t>(st, mod))->second;
357 }
358
359 inline vector<Int_t> GetSiliconStatMod(Int_t label)
360 {
361 while (label % 3 != 0)
362 label++;
363
364 vector<Int_t> out;
365 for (auto it : silStatModLabel) {
366 if (it.second != label)
367 continue;
368 out.push_back(it.first.first);
369 out.push_back(it.first.second);
370 break;
371 }
372 return out;
373 }
374
375 inline vector<Int_t> GetGemStatMod(Int_t label)
376 {
377 while (label % 3 != 0)
378 label++;
379
380 vector<Int_t> out;
381 for (auto it : gemStatModLabel) {
382 if (it.second != label)
383 continue;
384 out.push_back(it.first.first);
385 out.push_back(it.first.second);
386 break;
387 }
388 return out;
389 }
390
391 void FillMaps()
392 {
393 // Choose appropriate configuration (BM@N or SRC)
394 Bool_t isSRC = (fRunId < 3589) ? kTRUE : kFALSE;
395
396 Int_t srcGEM[10][2] = {{3, -1}, {6, -1}, {9, -1}, {12, -1}, {15, 18},
397 {21, 24}, {27, 30}, {33, 36}, {39, 42}, {45, 48}};
398
399 Int_t bmnGEM[6][2] = {{3, 6}, {9, 12}, {15, 18}, {21, 24}, {27, 30}, {33, 36}};
400
401 const Int_t nGemStats = isSRC ? 10 : 6;
402 const Int_t nGemMods = 2;
403
404 Int_t** gem = new Int_t*[nGemStats];
405 for (Int_t iStat = 0; iStat < nGemStats; iStat++) {
406 gem[iStat] = new Int_t[nGemMods];
407 for (Int_t iMod = 0; iMod < nGemMods; iMod++)
408 gem[iStat][iMod] = isSRC ? srcGEM[iStat][iMod] : bmnGEM[iStat][iMod];
409 }
410
411 for (Int_t iStat = 0; iStat < fDetectorGEM->GetNStations(); iStat++)
412 for (Int_t iMod = 0; iMod < fDetectorGEM->GetGemStation(iStat)->GetNModules(); iMod++)
413 gemStatModLabel[pair<Int_t, Int_t>(iStat, iMod)] = gem[iStat][iMod];
414
415 const Int_t nSilStats = 3; // FIXME!!
416 const Int_t nSilMods = 8;
417
418 Int_t bmnSIL[nSilStats][nSilMods] = {
419 {39, 42, 45, 48, -1, -1, -1, -1}, {51, 54, -1, -1, -1, -1, -1, -1}, {57, 60, 63, 66, 69, 72, 75, 78}};
420
421 Int_t srcSIL[nSilStats][nSilMods] = {
422 {51, 54, 57, 60, -1, -1, -1, -1}, {63, 66, -1, -1, -1, -1, -1, -1}, {69, 72, 75, 78, 81, 84, 87, 90}};
423
424 Int_t** sil = new Int_t*[nSilStats];
425 for (Int_t iStat = 0; iStat < nSilStats; iStat++) {
426 sil[iStat] = new Int_t[nSilMods];
427 for (Int_t iMod = 0; iMod < nSilMods; iMod++)
428 sil[iStat][iMod] = isSRC ? srcSIL[iStat][iMod] : bmnSIL[iStat][iMod];
429 }
430
431 for (Int_t iStat = 0; iStat < fDetectorSI->GetNStations(); iStat++)
432 for (Int_t iMod = 0; iMod < fDetectorSI->GetSiliconStation(iStat)->GetNModules(); iMod++)
433 silStatModLabel[pair<Int_t, Int_t>(iStat, iMod)] = sil[iStat][iMod];
434
435 // if (!fDebug)
436 // return;
437
438 cout << "GEM" << endl;
439 cout << gemStatModLabel.size() << endl;
440 for (auto it : gemStatModLabel)
441 cout << it.first.first << ", " << it.first.second << " --> " << it.second << endl;
442
443 cout << "SILICON" << endl;
444 for (auto it : silStatModLabel)
445 cout << it.first.first << ", " << it.first.second << " --> " << it.second << endl;
446 }
447
449
453 map<Int_t, pair<vector<BmnMilleContainer*>, vector<BmnMilleContainer*>>> fCONTAINER;
454 map<Int_t, pair<vector<BmnMilleContainer*>, vector<BmnMilleContainer*>>>::iterator fITERATOR;
455 map<pair<Int_t, Int_t>, Int_t> gemStatModLabel;
456 map<pair<Int_t, Int_t>, Int_t> silStatModLabel;
460
463
466
469
471
474
477
481
484
488
491
493
494 Bool_t fUseRealHitErrors; // errors are taken from hit finder algorithm
495
496 // Restrictions on track params
503 // Range to be exluded in case of "beam-target" alignment...
504 Bool_t fIsExcludedTx; // do exclusion (true) or not, manipulated by SetExclusionRangeTx
505 Bool_t fIsExcludedTy; // do exclusion (true) or not, manipulated by SetExclusionRangeTy
510
511 // Int_t nSelectedTracks;
512
516
517 // Millepede params
518 Bool_t fUseRegularization; // use regularization or not
519 Double_t fHugecut; // cut factor in iteration 0
520 Double_t fChisqcut[2]; // cut factor in iterations 1 and 2
521 Int_t fEntries; // lower limit on number of entries/parameter
522 Int_t fOutlierdownweighting; // number of internal iterations (> 1)
523 Double_t fDwfractioncut; // reject all cases with a down-weight fraction >= val
524
528
529 vector<Int_t> fFixedStats;
532
534 Int_t* Labels; // array containing a fixed param. number for each detector.
535
536 // Use constraints or not
538
542
544};
545
546#endif
friend F32vec4 min(const F32vec4 &a, const F32vec4 &b)
Definition P4_F32vec4.h:30
friend F32vec4 max(const F32vec4 &a, const F32vec4 &b)
Definition P4_F32vec4.h:31
bool Bool_t
int Int_t
constexpr Bool_t kFALSE
double Double_t
constexpr Bool_t kTRUE
const char Option_t
#define ClassDef(name, id)
void SetDwfractionCut(Double_t fraction)
void SetUseConstraints(Bool_t flag)
void ExtractCorrValues(ifstream &, Double_t *)
void SetExclusionRangeTy(Double_t min, Double_t max)
virtual InitStatus Init()
TClonesArray * fSiAlignCorr
TClonesArray * fGemAlignCorr
void SetOutlierDownweighting(Int_t n)
void SetGemConfigSRC(Bool_t st0_0, Bool_t st1_0, Bool_t st2_0, Bool_t st3_0, Bool_t st4_0, Bool_t st4_1, Bool_t st5_0, Bool_t st5_1, Bool_t st6_0, Bool_t st6_1, Bool_t st7_0, Bool_t st7_1, Bool_t st8_0, Bool_t st8_1, Bool_t st9_0, Bool_t st9_1)
TClonesArray * fGemTracks
void SetDebug(Bool_t flag)
vector< Int_t > fFixedStats
void SetChi2MaxPerNDF(Double_t val)
void SetSiFixedRun7(Bool_t st0_0, Bool_t st0_1, Bool_t st0_2, Bool_t st0_3, Bool_t st1_0, Bool_t st1_1, Bool_t st2_0, Bool_t st2_1, Bool_t st2_2, Bool_t st2_3, Bool_t st2_4, Bool_t st2_5, Bool_t st2_6, Bool_t st2_7)
Int_t SiliconStatModLabel(Int_t st, Int_t mod)
void MilleNoFieldRuns(BmnGlobalTrack *, Int_t, Int_t, vector< BmnMilleContainer * > &, vector< BmnMilleContainer * > &)
virtual void Exec(Option_t *opt)
map< pair< Int_t, Int_t >, Int_t > gemStatModLabel
TClonesArray * fGlobalTracks
map< Int_t, pair< vector< BmnMilleContainer * >, vector< BmnMilleContainer * > > >::iterator fITERATOR
void SetGemFixedRun6(Bool_t st0_0, Bool_t st1_0, Bool_t st2_0, Bool_t st3_0, Bool_t st3_1, Bool_t st4_0, Bool_t st4_1, Bool_t st5_0, Bool_t st5_1)
void SetSiConfigSRC(Bool_t st0_0, Bool_t st0_1, Bool_t st0_2, Bool_t st0_3, Bool_t st1_0, Bool_t st1_1, Bool_t st2_0, Bool_t st2_1, Bool_t st2_2, Bool_t st2_3, Bool_t st2_4, Bool_t st2_5, Bool_t st2_6, Bool_t st2_7)
void SetExclusionRangeTx(Double_t min, Double_t max)
vector< Int_t > GetSiliconStatMod(Int_t label)
void SetEntriesPerParam(Int_t entries)
BmnSiliconStationSet * fDetectorSI
void _Mille(Double_t *, Double_t *, BmnMille *, Int_t)
BmnGemStripStationSet * fDetectorGEM
void SetUseRegularization(Bool_t flag)
void SetTxMinMax(Double_t min, Double_t max)
map< Int_t, pair< vector< BmnMilleContainer * >, vector< BmnMilleContainer * > > > fCONTAINER
void SetTyMinMax(Double_t min, Double_t max)
void SetDoTest(Bool_t flag)
void SetChisqcut(Double_t val1, Double_t val2)
void ReadPedeOutput(ifstream &)
FairEventHeader * fFairEventHeader
TClonesArray * fSilTracks
void SetDetectors(Bool_t gem, Bool_t si)
void SetSiFixedRun6(Bool_t st0_0, Bool_t st0_1, Bool_t st0_2, Bool_t st0_3, Bool_t st0_4, Bool_t st0_5, Bool_t st0_6, Bool_t st0_7)
void SetAccuracy(Double_t accuracy)
map< pair< Int_t, Int_t >, Int_t > silStatModLabel
void SetUseRealHitErrors(Bool_t flag)
BmnMilleContainer * FillMilleContainer(BmnGlobalTrack *, BmnHit *)
TClonesArray * fBmnGemMisalign
Int_t GemStatModLabel(Int_t st, Int_t mod)
void SetPreSigma(Double_t presigma)
void SetHugecut(Double_t val)
void SetMinHitsAccepted(Int_t val)
vector< Int_t > GetGemStatMod(Int_t label)
BmnGlobalTrack.h.
*brief user defined string literal for JSON values *sa std::size_t n
Definition json.hpp:20362
Definition json.hpp:4446