BmnRoot 26.10.0-18-g4e3414f9
Software framework of the BM@N experiment
Loading...
Searching...
No Matches
extract_zdc_histo_from_reco.C
Go to the documentation of this file.
1/*************************************************************************************
2 * Example by: Elena Litvinenko
3 * e-mail: litvin@nf.jinr.ru
4 * Version: 29-Jan-2016
5 ************************************************************************************/
6
7void extract_zdc_histo_from_reco(const char* filename = "reco_zdc.root")
8{
9
10 Double_t x, y, ee;
11
12 TFile* f = new TFile(filename);
13
14 TH2F* hist_zdc_orig = (TH2F*)f->Get("HistZdcEn");
15
16 TChain chain("cbmsim");
17 chain.Add(filename);
18 TChain* t = &chain;
19 Int_t n_events = t->GetEntries();
20
21 TClonesArray* ELossZdcHisto_arr = 0;
22 t->SetBranchAddress("ELossZdcHisto", &ELossZdcHisto_arr);
23
24 TString main_title_zdc1 = hist_zdc_orig->GetTitle();
25
26 Int_t n_entries = t->GetEntries();
27 if (n_entries > 8)
28 n_entries = 4;
29
30 for (int i = 0; i < n_entries; i++) {
31
32 t->GetEntry(i);
33
34 TH2F* hist_zdc = hist_zdc_orig->Clone("hist_zdc");
35
36 TVectorT<float>& v1 = *((TVectorT<float>*)ELossZdcHisto_arr->At(0));
37 hist_zdc->Set(v1.GetNoElements(), v1.GetMatrixArray());
38 hist_zdc->SetEntries(v1.GetNoElements());
39 hist_zdc->SetTitle(Form("%s (event %d)", main_title_zdc1.Data(), i));
40 cout << hist_zdc->GetTitle() << " " << hist_zdc->GetSum() << endl;
41
42 if (i < 8)
43 new TCanvas();
44 hist_zdc->Draw("colz");
45 }
46}
int i
Definition P4_F32vec4.h:22
int Int_t
double Double_t
char * Form(const char *fmt,...)
Stat_t GetSum() const
void Set(Int_t n) override
Int_t SetBranchAddress(const char *bname, T **add, TBranch **ptr=nullptr)
virtual Int_t Add(const char *name, Long64_t nentries=TTree::kMaxEntries)
Long64_t GetEntries() const override
Int_t GetEntry(Long64_t entry=0, Int_t getall=0) override
void SetTitle(const char *title) override
void Draw(Option_t *option="") override
TObject * Clone(const char *newname="") const override
virtual void SetEntries(Double_t n)
const char * GetTitle() const override
TObject * At(Int_t idx) const override
const char * Data() const
Int_t GetNoElements() const
Element * GetMatrixArray()
void extract_zdc_histo_from_reco(const char *filename="reco_zdc.root")