-
Notifications
You must be signed in to change notification settings - Fork 494
Expand file tree
/
Copy pathreadEMCHits.C
More file actions
50 lines (44 loc) · 1.36 KB
/
readEMCHits.C
File metadata and controls
50 lines (44 loc) · 1.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
#if !defined(__CLING__) || defined(__ROOTCLING__)
#include <TFile.h>
#include <TTree.h>
#include <TH1F.h>
#include <TStopwatch.h>
#include <TVector3.h>
#include <TVector2.h>
#include <TH2F.h>
#include <memory>
#include <iostream>
#include <fairlogger/Logger.h>
#include "SimulationDataFormat/MCTruthContainer.h"
#include "SimulationDataFormat/MCCompLabel.h"
#include "EMCALBase/Hit.h"
#endif
/// read and draw the hits for EMC obtained from simulation
void readEMCHits(std::string path = "./",
std::string mcfileName = "o2sim_EMChits.root")
{
if (path.back() != '/') {
path += '/';
}
TH2* ep = new TH2F("etaph", "hist", 100, -0.7, 0.7, 100, 0., 7.);
std::unique_ptr<TFile> mcfile(TFile::Open((path + mcfileName).c_str()));
if (!mcfile || mcfile->IsZombie()) {
std::cout << "Failed to open input hit file " << (path + mcfileName) << std::endl;
return;
}
TTree* hitTree = (TTree*)mcfile->Get("o2sim");
if (!hitTree) {
std::cout << "Failed to get hit tree" << std::endl;
return;
}
std::vector<o2::emcal::Hit>* dv = nullptr;
hitTree->SetBranchAddress("EMCHit", &dv);
for (int iev = 0; iev < hitTree->GetEntries(); iev++) {
hitTree->GetEntry(iev);
for (const auto& h : *dv) {
TVector3 posvec(h.GetX(), h.GetY(), h.GetZ());
ep->Fill(posvec.Eta(), TVector2::Phi_0_2pi(posvec.Phi()));
}
}
ep->Draw("colz");
}