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
|
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include "TFile.h"
#include "TH1D.h"
#include "TCanvas.h"
#define NOISEPREFIX "Profile_NoiseFromCondDB__det__"
#define PEDESTALPREFIX "Profile_PedestalFromCondDB__det__"
void printPlot(TH1D* hist, char* prefix, char* postfix);
int main(int argc, char* argv[]) {
char* rootfilename;
char* modulelistname;
int pnbits;
char* prefix;
char* postfix;
if (argc == 6) {
rootfilename = argv[1];
modulelistname = argv[2];
pnbits = atoi(argv[3]);
prefix = argv[4];
postfix = argv[5];
} else {
std::cout << "Wrong number of parameters " << argc << std::endl;
return 1;
}
std::cout << "ready to go " << rootfilename << ' ' << modulelistname << std::endl;
TFile* rootfile = new TFile(rootfilename, "READ");
if (!rootfile) {
std::cout << "Problems with input root file" << std::endl;
return 2;
}
int detid;
std::ifstream modulelist(modulelistname);
while (modulelist >> detid) {
std::cout << " ready to go with detid " << detid << " " << pnbits << std::endl;
// bit 0: noise
if (pnbits & 1) {
std::stringstream histoname;
histoname << NOISEPREFIX << detid;
std::cout << " ready to go with histogram " << histoname.str() << std::endl;
TH1D* hist = (TH1D*)rootfile->FindObjectAny(histoname.str().c_str());
if (hist) {
std::cout << histoname.str() << " found!" << std::endl;
printPlot(hist, prefix, postfix);
} else {
std::cout << histoname.str() << " NOT found..." << std::endl;
}
}
// bit 1: pedestal
if (pnbits & 2) {
std::stringstream histoname;
histoname << PEDESTALPREFIX << detid;
std::cout << " ready to go with histogram " << histoname.str() << std::endl;
TH1D* hist = (TH1D*)rootfile->FindObjectAny(histoname.str().c_str());
if (hist) {
std::cout << histoname.str() << " found!" << std::endl;
printPlot(hist, prefix, postfix);
} else {
std::cout << histoname.str() << " NOT found..." << std::endl;
}
}
}
return 0;
}
void printPlot(TH1D* hist, char* prefix, char* postfix) {
TCanvas* cc = new TCanvas;
hist->Draw("hist");
std::stringstream filename;
filename << prefix << hist->GetName() << postfix << ".png";
cc->Print(filename.str().c_str());
delete cc;
}
|