-
Notifications
You must be signed in to change notification settings - Fork 499
Expand file tree
/
Copy pathplot_hit_cpv.C
More file actions
94 lines (84 loc) · 2.66 KB
/
plot_hit_cpv.C
File metadata and controls
94 lines (84 loc) · 2.66 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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
#if !defined(__CLING__) || defined(__ROOTCLING__)
#include <sstream>
#include "TROOT.h"
#include <TStopwatch.h>
#include "TCanvas.h"
#include "TH2.h"
//#include "DataFormatsParameters/GRPObject.h"
#include "FairFileSource.h"
#include <fairlogger/Logger.h>
#include "FairRunAna.h"
#include "FairParRootFileIo.h"
#include "FairSystemInfo.h"
#include "SimulationDataFormat/MCCompLabel.h"
#include "CPVBase/Geometry.h"
#include "DataFormatsCPV/Hit.h"
#include "DetectorsCommonDataFormats/DetectorNameConf.h"
#include "DetectorsCommonDataFormats/DetID.h"
#endif
using namespace o2::detectors;
void plot_hit_cpv(int ievent = 0, std::string inputprefix = "o2sim")
{
// macros to plot CPV hits
// Hits
std::string inputfile(o2::base::DetectorNameConf::getHitsFileName(DetID::CPV, inputprefix));
TFile* file0 = TFile::Open(inputfile.c_str());
std::cout << " Open hits file " << inputfile << std::endl;
TTree* hitTree = (TTree*)gFile->Get("o2sim");
std::vector<o2::cpv::Hit>* mHitsArray = nullptr;
hitTree->SetBranchAddress("CPVHit", &mHitsArray);
if (!mHitsArray) {
std::cout << "CPV hits not registered in the FairRootManager. Exiting ..." << std::endl;
return;
}
hitTree->GetEvent(ievent);
TH2D* vMod[5][100] = {0};
int primLabels[5][100];
for (int mod = 1; mod < 5; mod++)
for (int j = 0; j < 100; j++)
primLabels[mod][j] = -1;
std::vector<o2::cpv::Hit>::iterator it;
short relId[3];
// for(it=mHitsArray->begin(); it!=mHitsArray->end(); it++){
for (auto& it : *mHitsArray) {
short absId = it.GetDetectorID();
float en = it.GetEnergyLoss();
int lab = it.GetTrackID();
o2::cpv::Geometry::absToRelNumbering(absId, relId);
printf("reldId=(%d,%d,%d) \n", relId[0], relId[1], relId[2]);
// check, if this label already exist
int j = 0;
bool found = false;
while (primLabels[relId[0]][j] >= 0) {
if (primLabels[relId[0]][j] == lab) {
found = true;
break;
} else {
j++;
}
}
if (!found) {
primLabels[relId[0]][j] = lab;
}
if (!vMod[relId[0]][j]) {
gROOT->cd();
vMod[relId[0]][j] =
new TH2D(Form("hMod%d_prim%d", relId[0], j), Form("hMod%d_prim%d", relId[0], j), 128, 0., 128., 60, 0., 60.);
}
vMod[relId[0]][j]->Fill(relId[1] - 0.5, relId[2] - 0.5, en);
}
TCanvas* c[5];
for (int mod = 1; mod < 5; mod++) {
c[mod] =
new TCanvas(Form("HitInMod%d", mod), Form("CPV hits in module %d", mod), 10 * mod, 0, 600 + 10 * mod, 400);
int j = 0;
while (vMod[mod][j]) {
vMod[mod][j]->SetLineColor(j + 1);
if (j == 0)
vMod[mod][j]->Draw("box");
else
vMod[mod][j]->Draw("boxsame");
j++;
}
}
}