-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathPlotRawDec.C
More file actions
110 lines (97 loc) · 3 KB
/
PlotRawDec.C
File metadata and controls
110 lines (97 loc) · 3 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
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
#include <stdio.h>
#include <math.h>
#include "TROOT.h"
#include "TFile.h"
#include "TTree.h"
#include "TBrowser.h"
#include "TMath.h"
#include "TRandom.h"
#include "TCanvas.h"
#include "TGraph.h"
#include <sstream>
#include <vector>
#include <fstream>
#include <string>
using namespace o2::base;
using namespace o2::detectors;
using o2::itsmft::Digit;
vector <int> getChipDec()
{
fstream inputDec; //read chip_ID.txt in order to have the number of chip in raw data file
inputDec.open("/home/alice/alice/output/Chip_ID.txt", ios_base::in);
vector <int> vecChipDec;
int ChipDecod;
int sizeVecDec=vecChipDec.size();
while(inputDec >> ChipDecod)vecChipDec.push_back(ChipDecod);
inputDec.close();
return vecChipDec;
}
vector <string> getHistoName()
{
fstream inputHistoName; //read file with namehisto
inputHistoName.open("/home/alice/alice/output/histoname.txt",ios_base::in);
vector <string> vecHistoName;
string word2;
while(inputHistoName >> word2) vecHistoName.push_back(word2);
inputHistoName.close();
return vecHistoName;
}
void PlotRawDec(const Char_t *inFile="/home/alice/alice/output/data-d4-f1-2020_09_03__14_10_16__.raw_200904_183137.root",const char *dataraw=" ",const char *datatime=" "){
TFile *inputFile =new TFile(inFile);
vector<int> vecChipDec=getChipDec();
int sizeVecDec=vecChipDec.size();
std::cout<<"How many chips? "<<sizeVecDec<<std::endl;
vector<string> vecHistoName=getHistoName();
gStyle->SetPalette(55); // Rainbow
TCanvas *c1[sizeVecDec];
TH2F *hplot[sizeVecDec];
char *histoname = new char[sizeVecDec];
for(int i=0;i<sizeVecDec;i++){
hplot[i] = new TH2F(histoname,histoname,1024,0,1024,512,0,512);
TString os1=vecHistoName[i]+";Cols;Rows";
TString os2=vecHistoName[i];
hplot[i]->SetName(os2);
hplot[i]->SetTitle(os1);
hplot[i]->GetName();
hplot[i]->GetTitle();
}
TTree *tree=(TTree*)inputFile->Get("o2sim");
auto nentries=tree->GetEntries();
std::vector<o2::itsmft::Digit>* digArr = nullptr;
tree->SetBranchAddress("MFTDigit", &digArr);
for(int i=0;i<nentries;i++){
tree->GetEvent(i);
Int_t nd = digArr->size();
cout<<"Events? "<<nd<<endl;
while (nd--) {
Int_t binx,biny, bin, binmax;
const Digit* d = &(*digArr)[nd];
Int_t chipID = d->getChipIndex();
for(int j=0;j<sizeVecDec;j++){
if (chipID==vecChipDec[j]){
hplot[j]->Fill(d->getColumn(), d->getRow());
}
}
}
}
for(int k=0;k<sizeVecDec;k++){ //to have the plot
TString os2=vecHistoName[k];
c1[k]= new TCanvas();
c1[k]->SetName(os2);
c1[k]->SetTitle(os2);
c1[k]->GetName();
c1[k]->GetTitle();
c1[k]->cd(k);
gStyle->SetOptStat(0);
hplot[k]->Draw("colz PMC");
std::string histnamesave = "Plots/hist_";
histnamesave +=os2;
histnamesave += "_raw_";
histnamesave += dataraw;
histnamesave += "_created_";
histnamesave += datatime;
histnamesave += ".pdf";
const char *finalname = histnamesave.c_str();
c1[k]->SaveAs(finalname);
}
}