CMS 3D CMS Logo

makeModulePlots.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <fstream>
3 #include <sstream>
4 #include <string>
5 
6 #include "TFile.h"
7 #include "TH1D.h"
8 #include "TCanvas.h"
9 
10 #define NOISEPREFIX "Profile_NoiseFromCondDB__det__"
11 #define PEDESTALPREFIX "Profile_PedestalFromCondDB__det__"
12 
13 void printPlot(TH1D* hist, char* prefix, char* postfix);
14 
15 int main(int argc, char *argv[]) {
16 
17  char* rootfilename;
18  char* modulelistname;
19  int pnbits;
20  char* prefix;
21  char* postfix;
22 
23  if(argc==6) {
24  rootfilename = argv[1];
25  modulelistname = argv[2];
26  pnbits = atoi(argv[3]);
27  prefix = argv[4];
28  postfix = argv[5];
29  }
30  else {
31  std::cout << "Wrong number of parameters " << argc << std::endl;
32  return 1;
33  }
34 
35  std::cout << "ready to go " << rootfilename << ' ' << modulelistname << std::endl;
36 
37  TFile* rootfile = new TFile(rootfilename,"READ");
38  if(!rootfile) {
39  std::cout << "Problems with input root file" << std::endl;
40  return 2;
41  }
42  int detid;
43  std::ifstream modulelist(modulelistname);
44 
45 
46 
47  while (modulelist >> detid) {
48  std::cout << " ready to go with detid " << detid << " " << pnbits << std::endl;
49  // bit 0: noise
50  if(pnbits & 1) {
51  std::stringstream histoname;
52  histoname << NOISEPREFIX << detid;
53  std::cout << " ready to go with histogram " << histoname.str() << std::endl;
54  TH1D* hist = (TH1D*)rootfile->FindObjectAny(histoname.str().c_str());
55  if(hist) {
56  std:: cout << histoname.str() << " found!" << std::endl;
58  } else {
59  std:: cout << histoname.str() << " NOT found..." << std::endl;
60  }
61  }
62  // bit 1: pedestal
63  if(pnbits & 2) {
64  std::stringstream histoname;
65  histoname << PEDESTALPREFIX << detid;
66  std::cout << " ready to go with histogram " << histoname.str() << std::endl;
67  TH1D* hist = (TH1D*)rootfile->FindObjectAny(histoname.str().c_str());
68  if(hist) {
69  std:: cout << histoname.str() << " found!" << std::endl;
71  } else {
72  std:: cout << histoname.str() << " NOT found..." << std::endl;
73  }
74  }
75  }
76 
77  return 0;
78 
79 }
80 
81 void printPlot(TH1D* hist, char* prefix, char* postfix) {
82 
83  TCanvas* cc= new TCanvas;
84  hist->Draw("hist");
85  std::stringstream filename;
86  filename << prefix << hist->GetName() << postfix << ".png";
87  cc->Print(filename.str().c_str());
88  delete cc;
89 
90 }
uint32_t cc[maxCellsPerHit]
Definition: gpuFishbone.h:49
#define PEDESTALPREFIX
int main(int argc, char *argv[])
void printPlot(TH1D *hist, char *prefix, char *postfix)
#define NOISEPREFIX