BmnRoot
26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Toggle main menu visibility
Loading...
Searching...
No Matches
Tof400Identification.c
Go to the documentation of this file.
1
/*
2
* To change this license header, choose License Headers in Project Properties.
3
* To change this template file, choose Tools | Templates
4
* and open the template in the editor.
5
*/
6
7
#include "
TCanvas.h
"
8
#include "
TChain.h
"
9
#include "
TClonesArray.h
"
10
#include "
TDirectory.h
"
11
#include "
TF1.h
"
12
#include "
TFile.h
"
13
#include "
TH1.h
"
14
#include "
TH2.h
"
15
#include "
TList.h
"
16
#include "
TPad.h
"
17
#include "
TVector3.h
"
18
19
#include <
TMath.h
>
20
#include <ctime>
21
#include <fstream>
22
#include <iostream>
23
#include <istream>
24
#include <stdio.h>
25
#include <vector>
26
27
void
Tof400Identification
(
TString
NameFileIn =
"bmndst.root"
,
Int_t
nEvForRead = 0)
28
{
29
30
TStopwatch
timer;
31
timer.
Start
();
32
Int_t
nBytes = 0;
33
34
gROOT
->LoadMacro(
"$VMCWORKDIR/macro/run/bmnloadlibs.C"
);
35
bmnloadlibs();
// load BmnRoot libraries
36
// gStyle->SetOptStat(kFALSE);
37
38
TH1I
* hBetta =
new
TH1I
(
"hBetta"
,
"hBetta"
, 400, -2., 2.);
39
hBetta->
GetXaxis
()->
SetTitle
(
"beta "
);
40
hBetta->
SetMarkerStyle
(8);
41
hBetta->
SetMarkerColor
(2);
42
43
TH2I
* hMomentumBetta =
new
TH2I
(
"hMomentumBeta"
,
"hMomentumBeta"
, 1000, -10., 10., 400, -2., 2.);
44
hMomentumBetta->
GetXaxis
()->
SetTitle
(
"momentum, GeV/c "
);
45
hMomentumBetta->
GetYaxis
()->
SetTitle
(
"beta "
);
46
47
//--------Data Analysis-----------------------------------------------------------------
48
49
TChain
* eveTree =
new
TChain
(
"cbmsim"
);
50
TString
inName =
Form
(
"$VMCWORKDIR/macro/run/%s"
, NameFileIn.Data());
51
// inName = file;
52
cout <<
"Open file "
<< inName << endl << endl;
53
eveTree->
Add
(inName);
54
55
TClonesArray
* Tof400Hits;
56
eveTree->
SetBranchAddress
(
"BmnTof400Hit"
, &Tof400Hits);
57
58
TClonesArray
* BmnGlobTr;
59
eveTree->
SetBranchAddress
(
"BmnGlobalTrack"
, &BmnGlobTr);
60
61
Long64_t
nEvents = eveTree->
GetEntries
();
62
if
(nEvForRead == 0 || nEvForRead > nEvents)
63
nEvForRead = nEvents;
64
cout <<
"Will be read "
<< nEvForRead <<
" events from "
<< nEvents << endl;
65
66
for
(
Int_t
iEv = 0; iEv < nEvForRead; iEv++) {
67
68
if
(iEv % 50000 == 0)
69
cout <<
"EVENT: "
<< iEv << endl;
70
nBytes = eveTree->
GetEntry
(iEv);
71
72
for
(
Int_t
iGlobTrack = 0; iGlobTrack < BmnGlobTr->
GetEntriesFast
(); iGlobTrack++) {
73
BmnGlobalTrack
* Track = (
BmnGlobalTrack
*)BmnGlobTr->
At
(iGlobTrack);
74
FairTrackParam parLast(*(Track->
GetParamLast
()));
75
FairTrackParam parFirst(*(Track->
GetParamFirst
()));
76
Int_t
IndexTof1Hit = Track->
GetTof1HitIndex
();
77
if
(IndexTof1Hit == -1)
78
continue
;
79
// cout << "Event#" << iEv << endl;
80
BmnTofHit
* hitTof400 = (
BmnTofHit
*)Tof400Hits->
At
(IndexTof1Hit);
81
Double_t
Velocity = hitTof400->
GetLength
() / hitTof400->GetTimeStamp() / 10.;
// * 10^8 m/s
82
Double_t
Betta = Velocity / 2.99792458;
//
83
hBetta->
Fill
(Betta);
84
Double_t
Momentum = 1. / Track->
GetParamLast
()->GetQp();
85
hMomentumBetta->
Fill
(Momentum, Betta);
86
87
}
// end for (Int_t iGlobTrack = 0; iGlobTrack < BmnGlobalTrack->GetEntriesFast(); iGlobTrack++)
88
}
// end for (Int_t iEv = 0; iEv < nEvForRead; iEv++)
89
90
timer.
Stop
();
91
cout <<
"Readed "
<< nEvForRead <<
" events"
<< endl;
92
cout <<
"Time = "
<< timer.
RealTime
() <<
" s"
<< endl;
93
cout <<
"Time/Event = "
<< timer.
RealTime
() / (
Double_t
)nEvForRead * 1000. <<
" ms/Event"
<< endl;
94
cout <<
"TimeCPU = "
<< timer.
CpuTime
() <<
" s"
<< endl;
95
cout <<
"TimeCPU/Event = "
<< timer.
CpuTime
() / (
Double_t
)nEvForRead * 1000. <<
" ms/Event"
<< endl;
96
97
timer.
Reset
();
98
timer.
Start
();
99
TString
outName = NameFileIn;
100
Int_t
Point = outName.
First
(
'.'
);
101
outName.
Replace
(Point, 15,
"_Identification.root"
);
102
outName =
Form
(
"/home/storage/analysis/%s"
, outName.
Data
());
103
cout <<
"Save data to "
<< outName.
Data
() << endl;
104
TFile
* fileout =
new
TFile
(outName.
Data
(),
"RECREATE"
);
105
106
hBetta->
Write
();
107
hMomentumBetta->
Write
();
108
109
fileout->
Close
();
110
111
timer.
Stop
();
112
113
cout <<
"Time for write root = "
<< timer.
RealTime
() <<
" s"
<< endl;
114
}
Int_t
int Int_t
Double_t
double Double_t
Long64_t
long long Long64_t
TCanvas.h
TChain.h
TClonesArray.h
TDirectory.h
TF1.h
TFile.h
TH1.h
TH2.h
TList.h
TMath.h
TPad.h
gROOT
#define gROOT
Form
char * Form(const char *fmt,...)
TVector3.h
BmnGlobalTrack
BmnGlobalTrack.h.
Definition
BmnGlobalTrack.h:14
BmnGlobalTrack::GetTof1HitIndex
Int_t GetTof1HitIndex() const
Definition
BmnGlobalTrack.h:36
BmnHit::GetLength
Double_t GetLength()
Definition
BmnHit.h:33
BmnTofHit
Definition
BmnTofHit.h:22
BmnTrack::GetParamFirst
FairTrackParam * GetParamFirst()
Definition
BmnTrack.h:63
BmnTrack::GetParamLast
FairTrackParam * GetParamLast()
Definition
BmnTrack.h:65
TAttMarker::SetMarkerColor
virtual void SetMarkerColor(Color_t mcolor=1)
TAttMarker::SetMarkerStyle
virtual void SetMarkerStyle(Style_t mstyle=1)
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
TFile
TFile::Close
void Close(Option_t *option="") override
TH1I
TH1::GetXaxis
TAxis * GetXaxis()
TH1::GetYaxis
TAxis * GetYaxis()
TH1::Fill
virtual Int_t Fill(const char *name, Double_t w)
TH2I
TH2::Fill
virtual Int_t Fill(const char *namex, const char *namey, Double_t w)
TNamed::SetTitle
virtual void SetTitle(const char *title="")
TObjArray::GetEntriesFast
Int_t GetEntriesFast() const
TObjArray::At
TObject * At(Int_t idx) const override
TObject::Write
virtual Int_t Write(const char *name=nullptr, Int_t option=0, Int_t bufsize=0)
TStopwatch
TStopwatch::RealTime
Double_t RealTime()
TStopwatch::Start
void Start(Bool_t reset=kTRUE)
TStopwatch::CpuTime
Double_t CpuTime()
TStopwatch::Stop
void Stop()
TStopwatch::Reset
void Reset()
TString
TString::Replace
TString & Replace(Ssiz_t pos, Ssiz_t n, const char *s)
TString::First
Ssiz_t First(char c) const
TString::Data
const char * Data() const
Tof400Identification
void Tof400Identification(TString NameFileIn="bmndst.root", Int_t nEvForRead=0)
Definition
Tof400Identification.c:27
install
macro
detectors
tof_400
Tof400Identification.c
Generated on
for BmnRoot by
1.17.0