BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
extractVertAppr.C
Go to the documentation of this file.
1
R__ADD_INCLUDE_PATH
($VMCWORKDIR)
2
#include "macro/run/bmnloadlibs.C"
3
4
#include <
TMath.h
>
5
6
using namespace
std
;
7
using namespace
TMath
;
8
9
Int_t
computeIntegral
(
TH1F
*,
Double_t
,
Double_t
);
10
11
void
extractVertAppr
(
TString
filename =
""
)
12
{
13
bmnloadlibs();
// load BmnRoot libraries
14
15
TChain
* out =
new
TChain
(
"cbmsim"
);
16
out->
Add
(filename.Data());
17
cout <<
"#recorded entries = "
<< out->
GetEntries
() <<
" in file"
<< endl;
18
19
TClonesArray
* vertex = NULL;
20
21
out->
SetBranchAddress
(
"BmnVertex"
, &vertex);
22
const
UInt_t
nEvs = out->
GetEntries
();
23
24
TH1F
* x =
new
TH1F
(
"X"
,
"X"
, 100, -10., +10.);
25
TH1F
* y =
new
TH1F
(
"Y"
,
"Y"
, 100, -10., +10.);
26
TH1F
* z =
new
TH1F
(
"Z"
,
"Z"
, 100, -10., +10.);
27
28
Double_t
roughX = 0.0;
29
Double_t
roughY = 0.0;
30
Double_t
roughZ = 0.0;
31
32
for
(
Int_t
iEv = 0; iEv < out->
GetEntries
(); iEv++) {
33
out->
GetEntry
(iEv);
34
if
(iEv % 1000 == 0)
35
cout <<
" Ev# "
<< iEv << endl;
36
37
CbmVertex
* Vp = (
CbmVertex
*)vertex->
UncheckedAt
(0);
38
x->Fill(Vp->
GetX
());
39
y->Fill(Vp->
GetY
());
40
z->Fill(Vp->
GetZ
());
41
42
if
(iEv == 0) {
43
roughX = Vp->GetRoughX();
44
roughY = Vp->GetRoughY();
45
roughZ = Vp->GetRoughZ();
46
}
47
}
48
49
Int_t
intX =
computeIntegral
(x, -1., +1.);
50
Int_t
intY =
computeIntegral
(y, -5., -3.);
51
Int_t
intZ =
computeIntegral
(z, -3., 0.);
52
53
if
(intX != 0 && intY != 0 && intZ != 0) {
54
TFitResultPtr
fitX = x->Fit(
"gaus"
,
"SQ"
,
""
, -1., +1.);
55
TFitResultPtr
fitY = y->Fit(
"gaus"
,
"SQ"
,
""
, -5., -3.);
56
TFitResultPtr
fitZ = z->Fit(
"gaus"
,
"SQ"
,
""
, -3., 0.);
57
58
if
(
Abs
(roughX - fitX->
Parameter
(1)) < 5. &&
Abs
(roughY - fitY->
Parameter
(1)) < 5.
59
&&
Abs
(roughZ - fitZ->
Parameter
(1)) < 5.)
60
{
61
FILE* f = fopen(
"fitParams.txt"
,
"w"
);
62
fprintf(f,
"%G %G %G"
, fitX->
Parameter
(1), fitY->
Parameter
(1), fitZ->
Parameter
(1));
63
fclose(f);
64
}
65
}
66
delete
out;
67
}
68
69
//------------------------------------------------------------
70
Int_t
computeIntegral
(
TH1F
* h,
Double_t
xmin,
Double_t
xmax)
71
{
72
TAxis
* axis = h->
GetXaxis
();
73
Int_t
bmin = axis->
FindBin
(xmin);
74
Int_t
bmax = axis->
FindBin
(xmax);
75
return
h->
Integral
(bmin, bmax);
76
}
Int_t
int Int_t
UInt_t
unsigned int UInt_t
Double_t
double Double_t
R__ADD_INCLUDE_PATH
#define R__ADD_INCLUDE_PATH(PATH)
TMath.h
CbmVertex
CbmVertex.h.
Definition
CbmVertex.h:21
CbmVertex::GetZ
Double_t GetZ() const
Definition
CbmVertex.h:60
CbmVertex::GetX
Double_t GetX() const
Accessors.
Definition
CbmVertex.h:58
CbmVertex::GetY
Double_t GetY() const
Definition
CbmVertex.h:59
ROOT::Fit::FitResult::Parameter
double Parameter(unsigned int i) const
TAxis
TAxis::FindBin
virtual Int_t FindBin(const char *label)
TChain
TChain::SetBranchAddress
Int_t SetBranchAddress(const char *bname, T **add, TBranch **ptr=nullptr)
TChain::Add
virtual Int_t Add(const char *name, Long64_t nentries=TTree::kMaxEntries)
TChain::GetEntries
Long64_t GetEntries() const override
TChain::GetEntry
Int_t GetEntry(Long64_t entry=0, Int_t getall=0) override
TClonesArray
TFitResultPtr
TH1F
TH1::GetXaxis
TAxis * GetXaxis()
TH1::Integral
virtual Double_t Integral(Int_t binx1, Int_t binx2, Option_t *option="") const
TObjArray::UncheckedAt
TObject * UncheckedAt(Int_t i) const
TString
extractVertAppr
void extractVertAppr(TString filename="")
Definition
extractVertAppr.C:11
computeIntegral
Int_t computeIntegral(TH1F *, Double_t, Double_t)
Definition
extractVertAppr.C:70
TMath
TMath::Abs
Double_t Abs(Double_t d)
std
Definition
json.hpp:4446
macro
alignment
instruments
extractVertAppr.C
Generated on
for BmnRoot by
1.17.0