File indexing completed on 2021-02-14 13:12:01
0001 #include <iostream>
0002 #include <fstream>
0003 #include <sstream>
0004 #include <string>
0005
0006 #include "TFile.h"
0007 #include "TH1D.h"
0008 #include "TCanvas.h"
0009
0010 #define NOISEPREFIX "Profile_NoiseFromCondDB__det__"
0011 #define PEDESTALPREFIX "Profile_PedestalFromCondDB__det__"
0012
0013 void printPlot(TH1D* hist, char* prefix, char* postfix);
0014
0015 int main(int argc, char *argv[]) {
0016
0017 char* rootfilename;
0018 char* modulelistname;
0019 int pnbits;
0020 char* prefix;
0021 char* postfix;
0022
0023 if(argc==6) {
0024 rootfilename = argv[1];
0025 modulelistname = argv[2];
0026 pnbits = atoi(argv[3]);
0027 prefix = argv[4];
0028 postfix = argv[5];
0029 }
0030 else {
0031 std::cout << "Wrong number of parameters " << argc << std::endl;
0032 return 1;
0033 }
0034
0035 std::cout << "ready to go " << rootfilename << ' ' << modulelistname << std::endl;
0036
0037 TFile* rootfile = new TFile(rootfilename,"READ");
0038 if(!rootfile) {
0039 std::cout << "Problems with input root file" << std::endl;
0040 return 2;
0041 }
0042 int detid;
0043 std::ifstream modulelist(modulelistname);
0044
0045
0046
0047 while (modulelist >> detid) {
0048 std::cout << " ready to go with detid " << detid << " " << pnbits << std::endl;
0049
0050 if(pnbits & 1) {
0051 std::stringstream histoname;
0052 histoname << NOISEPREFIX << detid;
0053 std::cout << " ready to go with histogram " << histoname.str() << std::endl;
0054 TH1D* hist = (TH1D*)rootfile->FindObjectAny(histoname.str().c_str());
0055 if(hist) {
0056 std:: cout << histoname.str() << " found!" << std::endl;
0057 printPlot(hist,prefix,postfix);
0058 } else {
0059 std:: cout << histoname.str() << " NOT found..." << std::endl;
0060 }
0061 }
0062
0063 if(pnbits & 2) {
0064 std::stringstream histoname;
0065 histoname << PEDESTALPREFIX << detid;
0066 std::cout << " ready to go with histogram " << histoname.str() << std::endl;
0067 TH1D* hist = (TH1D*)rootfile->FindObjectAny(histoname.str().c_str());
0068 if(hist) {
0069 std:: cout << histoname.str() << " found!" << std::endl;
0070 printPlot(hist,prefix,postfix);
0071 } else {
0072 std:: cout << histoname.str() << " NOT found..." << std::endl;
0073 }
0074 }
0075 }
0076
0077 return 0;
0078
0079 }
0080
0081 void printPlot(TH1D* hist, char* prefix, char* postfix) {
0082
0083 TCanvas* cc= new TCanvas;
0084 hist->Draw("hist");
0085 std::stringstream filename;
0086 filename << prefix << hist->GetName() << postfix << ".png";
0087 cc->Print(filename.str().c_str());
0088 delete cc;
0089
0090 }