CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
Macros | Functions
moduleOccupancyPlots.cc File Reference
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include "TFile.h"
#include "TH1D.h"
#include "TCanvas.h"

Go to the source code of this file.

Macros

#define NOISEPREFIX   "Profile_NoiseFromCondDB__det__"
 
#define OCCUPANCYPREFIX   "ClusterDigiPosition__det__"
 
#define PEDESTALPREFIX   "Profile_PedestalFromCondDB__det__"
 

Functions

int main (int argc, char *argv[])
 
void printPlot (TH1D *hist, char *prefix, char *postfix)
 

Macro Definition Documentation

#define NOISEPREFIX   "Profile_NoiseFromCondDB__det__"

Definition at line 10 of file moduleOccupancyPlots.cc.

Referenced by main().

#define OCCUPANCYPREFIX   "ClusterDigiPosition__det__"

Definition at line 12 of file moduleOccupancyPlots.cc.

Referenced by main().

#define PEDESTALPREFIX   "Profile_PedestalFromCondDB__det__"

Definition at line 11 of file moduleOccupancyPlots.cc.

Referenced by main().

Function Documentation

int main ( int  argc,
char *  argv[] 
)

Definition at line 16 of file moduleOccupancyPlots.cc.

References gather_cfg::cout, cond::rpcobgas::detid, estimatePileup::hist, NOISEPREFIX, OCCUPANCYPREFIX, PEDESTALPREFIX, prof2calltree::prefix, printPlot(), and reco_application_2006_simpleTBanalysis_cfg::rootfile.

16  {
17 
18  char* rootfilename;
19  char* modulelistname;
20  int pnbits;
21  char* prefix;
22  char* postfix;
23 
24  if(argc==6) {
25  rootfilename = argv[1];
26  modulelistname = argv[2];
27  pnbits = atoi(argv[3]);
28  prefix = argv[4];
29  postfix = argv[5];
30  }
31  else {
32  std::cout << "Wrong number of parameters " << argc << std::endl;
33  return 1;
34  }
35 
36  std::cout << "ready to go " << rootfilename << ' ' << modulelistname << std::endl;
37 
38  TFile* rootfile = new TFile(rootfilename,"READ");
39  if(!rootfile) {
40  std::cout << "Problems with input root file" << std::endl;
41  return 2;
42  }
43  int detid;
44  std::ifstream modulelist(modulelistname);
45 
46  std::stringstream outrootfilename;
47  outrootfilename << prefix << "SummaryFile" << postfix << ".root";
48  TFile* outrootfile = new TFile(outrootfilename.str().c_str(),"CREATE");
49 
50  while (modulelist >> detid) {
51  std::cout << " ready to go with detid " << detid << " " << pnbits << std::endl;
52  // bit 0: noise
53  if(pnbits & 1) {
54  std::stringstream histoname;
55  histoname << NOISEPREFIX << detid;
56  std::cout << " ready to go with histogram " << histoname.str() << std::endl;
57  TH1D* hist = (TH1D*)rootfile->FindObjectAny(histoname.str().c_str());
58  if(hist) {
59  std:: cout << histoname.str() << " found!" << std::endl;
60  printPlot(hist,prefix,postfix);
61  hist->Write();
62  } else {
63  std:: cout << histoname.str() << " NOT found..." << std::endl;
64  }
65  }
66  // bit 1: pedestal
67  if(pnbits & 2) {
68  std::stringstream histoname;
69  histoname << PEDESTALPREFIX << detid;
70  std::cout << " ready to go with histogram " << histoname.str() << std::endl;
71  TH1D* hist = (TH1D*)rootfile->FindObjectAny(histoname.str().c_str());
72  if(hist) {
73  std:: cout << histoname.str() << " found!" << std::endl;
74  printPlot(hist,prefix,postfix);
75  hist->Write();
76  } else {
77  std:: cout << histoname.str() << " NOT found..." << std::endl;
78  }
79  }
80  // bit 2: pedestal
81  if(pnbits & 4) {
82  std::stringstream histoname;
83  histoname << OCCUPANCYPREFIX << detid;
84  std::cout << " ready to go with histogram " << histoname.str() << std::endl;
85  TH1D* hist = (TH1D*)rootfile->FindObjectAny(histoname.str().c_str());
86  if(hist) {
87  std:: cout << histoname.str() << " found!" << std::endl;
88  printPlot(hist,prefix,postfix);
89  hist->Write();
90  } else {
91  std:: cout << histoname.str() << " NOT found..." << std::endl;
92  }
93  }
94  }
95 
96  outrootfile->Close();
97 
98  return 0;
99 
100 }
void printPlot(TH1D *hist, char *prefix, char *postfix)
#define NOISEPREFIX
#define OCCUPANCYPREFIX
tuple argc
Definition: dir2webdir.py:38
#define PEDESTALPREFIX
tuple cout
Definition: gather_cfg.py:121
void printPlot ( TH1D *  hist,
char *  prefix,
char *  postfix 
)

Definition at line 102 of file moduleOccupancyPlots.cc.

References lut2db_cfg::filename.

Referenced by main().

102  {
103 
104  TCanvas* cc= new TCanvas;
105  hist->Draw();
106  std::stringstream filename;
107  filename << prefix << hist->GetName() << postfix << ".png";
108  cc->Print(filename.str().c_str());
109  delete cc;
110 
111 }
tuple filename
Definition: lut2db_cfg.py:20