BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
determine_align_corrections_bmn.C
Go to the documentation of this file.
1// -----------------------------------------------------------------------------
2// This macro determins misalignment corrections to the geometry description of
3// BM@N GEM station modules, MWPC and DCH in terms of X, Y, and Z coordinates of
4// the modules in cm.
5//
6// Anatoly.Solomin@jinr.ru 2017-04-05
7//
8// Derived from original globAlignment.C macro created by Pavel.Batyk@jinr.ru 2016-11
9
10#include "../../gem/BmnGemStripConfiguration.h"
11#include "../run/bmnloadlibs.C"
12
13void determine_align_corrections_bmn(TString bmndstFileListFileName = "filelist_bmndst_it00.txt",
14 TString newAlignCorrFileName = "",
15 UInt_t nEvents = 10000)
16{
17#if ROOT_VERSION_CODE < ROOT_VERSION(5, 99, 99)
18 gROOT->LoadMacro("$VMCWORKDIR/macro/run/bmnloadlibs.C");
19#endif
20 bmnloadlibs(); // load BmnRoot libraries
21 if (!CheckFileExist(bmndstFileListFileName))
22 return;
23 if (newAlignCorrFileName == "")
24 return;
25 // ----- Timer ---------------------------------------------------------
26 TStopwatch timer;
27 timer.Start();
28 // get run period
29 // TString substr = bmndstFileListFileName(TPRegexp("bmn_run[\d]+"));
30 // substr = substr( TPRegexp( "[\d]+"));
31 // int runPeriod = substr.Atoi();
32 TString runPeriod = bmndstFileListFileName; // just to start with
33 TPRegexp("bmn_run([\\d]+)[\\w\\d\\.]+").Substitute(runPeriod, "$1");
34 int run_period = runPeriod.Atoi();
35 cout << "run_period = " << run_period << endl;
36
37 FairRunAna* fRunAna = new FairRunAna();
38 ifstream bmndstFiles(bmndstFileListFileName);
39 cout << "bmndstFileListFileName = " + bmndstFileListFileName << endl;
40 TString fname;
41 string fnamestr;
42 // to create the FairSource* fFileSource object, read here only the first file name:
43 bmndstFiles >> fnamestr;
44 // because fstream produces string, while we need TString, we reassign:
45 fname = fnamestr;
46 // at least one input bmndst file name needs to be passed to
47 // BmnGlobalAlignment to determine fRunId = evHeader->GetRunId(); from the
48 // first event in that file, and therefore we memorize name of the first
49 // file in the list to use it in construting the
50 // BmnGlobalAlignment* globAlign object:
51 TString firstBmndstFileName = fname;
52 cout << "fname = " + fname << endl;
53 FairSource* fFileSource = new BmnFileSource(fname);
54 // the rest of the files should be AddFile'ed to form a chain in the BmnFileSource object:
55 while (bmndstFiles >> fnamestr) {
56 fname = fnamestr;
57 cout << "fname = " + fname << endl;
58 fFileSource->BmnFileSource::AddFile(fname);
59 }
60 bmndstFiles.close();
61 fRunAna->SetSource(fFileSource);
62 cout << "newAlignCorrFileName = " + newAlignCorrFileName << endl;
63 fRunAna->SetOutputFile(newAlignCorrFileName);
64
65 // Define GEM config. to be used: RunWinter2016 or RunSpring2017
67 if (run_period == 6)
69 else if (run_period == 5)
71 BmnGlobalAlignment* globAlign = new BmnGlobalAlignment(gem_config, firstBmndstFileName);
72 globAlign->SetDebug(kTRUE); // Default is false
73
74 // Restrictions on track params:
75 // globAlign->SetMinHitsAccepted(5); // Default value is 3
76 // globAlign->SetChi2MaxPerNDF(2.); // Cut on chi2/ndf for found tracks, default value is not limited
77 // globAlign->SetTxMinMax(-1., 1.);
78 // globAlign->SetExclusionRangeTx(-0.02, 0.02);
79 // globAlign->SetTyMinMax(-1., 1.);
80 // globAlign->SetExclusionRangeTy(-0.02, 0.02);
81
82 // Define modules to be fixed (any character) within alignment, if necessary.
83 // st0, st1, st2, st3_modLeft(0), st3_modRight(1), st4_modLeft(0), st4_modRight(1), st5_modLeft(0), st5_modRight(1)
84 globAlign->SetGemFixedRun6("", "", "", "", "", "", "", "", "");
85 // Set of detectors in chain to be used in glob. alignment
86 // A non-empty string means that the det. subsystem is used in the procedure
87 // GEM tracker is included by default
88 // "MWPC", "DCH"
89 globAlign->SetDetectors("", "");
90
91 globAlign->SetPreSigma(0.001); // Default value is 1
92 globAlign->SetAccuracy(0.001); // Default value is 0.001
93 globAlign->SetUseRealHitErrors(kTRUE); // Default value is false
94 // globAlign->SetUseTrackWithMinChi2(kTRUE); // Default value is false
95 globAlign->SetUseRegularization(kTRUE); // Default value is false
96 // globAlign->SetHugecut(200.); // Default value is 50
97 // globAlign->SetChisqcut(5., 2.); // Default value is (0., 0.)
98 // globAlign->SetEntriesPerParam(100); // Default value is 10
99 globAlign->SetOutlierDownweighting(4); // Default value is 0
100 globAlign->SetDwfractionCut(0.5); // Default value is 0, should be less than 0.5
101
102 fRunAna->AddTask(globAlign);
103 fRunAna->Init();
104 fRunAna->Run(0, nEvents);
105 // ----- Finish --------------------------------------------------------
106 timer.Stop();
107 Double_t rtime = timer.RealTime();
108 Double_t ctime = timer.CpuTime();
109 cout << endl << endl;
110 cout << "Macro finished successfully." << endl;
111 cout << "Real time " << rtime << " s, CPU time " << ctime << " s" << endl;
112 cout << endl;
113
114 // delete fRunAna;
115 // delete fFileSource;
116 delete globAlign;
117}
unsigned int UInt_t
double Double_t
constexpr Bool_t kTRUE
#define gROOT
BmnFileSource.h.
void SetDwfractionCut(Double_t fraction)
void SetOutlierDownweighting(Int_t n)
void SetDebug(Bool_t flag)
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 SetUseRegularization(Bool_t flag)
void SetDetectors(Bool_t gem, Bool_t si)
void SetAccuracy(Double_t accuracy)
void SetUseRealHitErrors(Bool_t flag)
void SetPreSigma(Double_t presigma)
Int_t Substitute(TString &s, const TString &replace, const TString &mods="", Int_t start=0, Int_t nMatchMax=10)
Double_t RealTime()
void Start(Bool_t reset=kTRUE)
Double_t CpuTime()
void Stop()
Int_t Atoi() const
void determine_align_corrections_bmn(TString bmndstFileListFileName="filelist_bmndst_it00.txt", TString newAlignCorrFileName="", UInt_t nEvents=10000)