CMS 3D CMS Logo

Macros | Functions
moduleOccupancyPlots.cc File Reference
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include "TFile.h"
#include "TH1D.h"
#include "TDirectoryFile.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 getChannelNumber (int ival)
 
int main (int argc, char *argv[])
 
void printPlot (TH1D *hist, char *prefix, char *postfix)
 

Macro Definition Documentation

◆ NOISEPREFIX

#define NOISEPREFIX   "Profile_NoiseFromCondDB__det__"

Definition at line 11 of file moduleOccupancyPlots.cc.

◆ OCCUPANCYPREFIX

#define OCCUPANCYPREFIX   "ClusterDigiPosition__det__"

Definition at line 13 of file moduleOccupancyPlots.cc.

◆ PEDESTALPREFIX

#define PEDESTALPREFIX   "Profile_PedestalFromCondDB__det__"

Definition at line 12 of file moduleOccupancyPlots.cc.

Function Documentation

◆ getChannelNumber()

int getChannelNumber ( int  ival)

Definition at line 176 of file moduleOccupancyPlots.cc.

176  {
177 
178  int chan=int(32*fmod(int(fmod(ival,256.)/2.),4.) +
179  8*int(int(fmod(ival,256.)/2.)/4.) -
180  31*int(int(fmod(ival,256.)/2.)/16.) +
181  fmod(fmod(ival,256.),2.)*128 +
182  int(ival/256)*256);
183  return chan;
184 }

References officialStyle::chan, and createfilelist::int.

Referenced by main().

◆ main()

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

===============================================================================================================================================================================================


variant2: for each run define phi-averaged A for normalization channel (Dref,16) and then, divide Rijk on it, i.e. get RRijk

eta=27

eta=25

eta=23

eta=22

eta=21

eta=26

eta=24

eta=19

eta=17

eta=25

eta=23

eta=22

eta=21

eta=26

eta=24

eta=20

eta=19

eta=18

eta=27 L1=1

eta=25 L1=1

eta=23 L1=1

eta=22 L1=1

eta=21 L1=1

eta=29 L1=1

eta=26 L1=1

eta=24 L1=1

eta=20 L1=1

eta=19 L1=1

eta=18 L1=1

eta=17 L1=1

eta=28 L7=1

eta=27 L7=1

eta=25 L7=1

eta=23 L7=1

eta=22 L7=1

eta=21 L7=1

eta=26 L7=1

eta=24 L7=1

eta=20 L7=1

eta=19 L7=1

eta=18 L7=1

eta=17 L7=1

eta=27

eta=25

eta=23

eta=22

eta=21

eta=26

eta=24

eta=19

eta=17

eta=25

eta=23

eta=22

eta=21

eta=26

eta=24

eta=20

eta=19

eta=18

eta=27 L1=1

eta=25 L1=1

eta=23 L1=1

eta=22 L1=1

eta=21 L1=1

eta=26 L1=1

eta=24 L1=1

eta=20 L1=1

eta=19 L1=1

eta=18 L1=1

eta=17 L1=1

eta=28 L7=1

eta=27 L7=1

eta=25 L7=1

eta=23 L7=1

eta=22 L7=1

eta=21 L7=1

eta=26 L7=1

eta=24 L7=1

eta=20 L7=1

eta=19 L7=1

eta=18 L7=1

eta=17 L7=1

eta=27

eta=28

errA with average Amplitudes

errA with average Amplitudes

errA with average Amplitudes

errA with average Amplitudes

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

RBX:

errA with average Amplitudes

errA with average Amplitudes

errA with average Amplitudes

errA with average Amplitudes

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

RBX:

errA with average Amplitudes

errA with average Amplitudes

errA with average Amplitudes

errA with average Amplitudes

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

Summed Amplitude Plots:

RBX:

Prepare maps of good/bad channels:

Prepare maps of good/bad channels:

Definition at line 18 of file moduleOccupancyPlots.cc.

18  {
19 
20  char* rootfilename;
21  char* modulelistname;
22  int pnbits;
23  char* prefix;
24  char* postfix;
25 
26  bool debugPrint = false;
27  bool imagePrint = false;
28 
29  if(argc==6) {
30  rootfilename = argv[1];
31  modulelistname = argv[2];
32  pnbits = atoi(argv[3]);
33  prefix = argv[4];
34  postfix = argv[5];
35  }
36  else {
37  std::cout << "Wrong number of parameters " << argc << std::endl;
38  return 1;
39  }
40 
41  if (debugPrint) std::cout << "ready to go " << rootfilename << ' ' << modulelistname << std::endl;
42 
43  TFile* rootfile = TFile::Open(rootfilename,"READ");
44  if(!rootfile) {
45  std::cout << "Problems with input root file" << std::endl;
46  return 2;
47  }
48  int detid;
49  std::ifstream modulelist(modulelistname);
50 
51  std::stringstream outrootfilename;
52  outrootfilename << prefix << "SummaryFile" << postfix << ".root";
53  TFile* outrootfile = TFile::Open(outrootfilename.str().c_str(),"RECREATE");
54 
55  TH1D* th_summary = nullptr;
56  Double_t TotalEvents = 0.0;
57  Double_t TotalDigis = 0.0;
58 
59  TH1D* TotEvents= new TH1D("TotEvents","TotEvents",1,0,1);
60 
61  if(pnbits & 4) {
62  TDirectoryFile* tdir = (TDirectoryFile*) rootfile->FindObjectAny("AlCaReco");
63  TH1D* hist = (TH1D*)tdir->FindObjectAny("TotalNumberOfCluster__TIB");
64  if (hist) {
65  TotalEvents = hist->GetEntries();
66  TotEvents->SetBinContent(1,TotalEvents);
67  TotEvents->Write();
68  }
69  }
70  while (modulelist >> detid) {
71  if (debugPrint) std::cout << " ready to go with detid " << detid << " " << pnbits << std::endl;
72  // bit 0: noise
73  if(pnbits & 1) {
74  std::stringstream histoname;
75  histoname << NOISEPREFIX << detid;
76  if (debugPrint) std::cout << " ready to go with histogram " << histoname.str() << std::endl;
77  TH1D* hist = (TH1D*)rootfile->FindObjectAny(histoname.str().c_str());
78  if(hist) {
79  if (debugPrint) std::cout << histoname.str() << " found!" << std::endl;
80  if (imagePrint) printPlot(hist,prefix,postfix);
81  hist->Write();
82  } else {
83  std::cout << histoname.str() << " NOT found..." << std::endl;
84  }
85  }
86  // bit 1: pedestal
87  if(pnbits & 2) {
88  std::stringstream histoname;
89  histoname << PEDESTALPREFIX << detid;
90  if (debugPrint) std::cout << " ready to go with histogram " << histoname.str() << std::endl;
91  TH1D* hist = (TH1D*)rootfile->FindObjectAny(histoname.str().c_str());
92  if(hist) {
93  if (debugPrint) std::cout << histoname.str() << " found!" << std::endl;
94  if (imagePrint) printPlot(hist,prefix,postfix);
95  hist->Write();
96  } else {
97  std::cout << histoname.str() << " NOT found..." << std::endl;
98  }
99  }
100  // bit 2: Occupancy
101  if(pnbits & 4) {
102  std::stringstream histoname;
103  histoname << OCCUPANCYPREFIX << detid;
104  std::string SummaryName= "ClusterDigiPosition__det__Summary";
105 
106  if (debugPrint) std::cout << " ready to go with histogram " << histoname.str() << std::endl;
107  if (th_summary == nullptr) th_summary = new TH1D(SummaryName.c_str(), SummaryName.c_str(), 768, 0.5, 768.5);
108  TH1D* hist = (TH1D*)rootfile->FindObjectAny(histoname.str().c_str());
109  if(hist) {
110  if (debugPrint) std::cout << histoname.str() << " found!" << hist->GetEntries() << std::endl;
111  for (int i = 1; i < hist->GetNbinsX()+1; i++) {
112  th_summary->AddBinContent(i, hist->GetBinContent(i));
113  TotalDigis += hist->GetBinContent(i);
114  }
115  hist->SetLineColor(2);
116  if (imagePrint) printPlot(hist,prefix,postfix);
117  hist->Write();
118  } else {
119  std::cout << histoname.str() << " NOT found..." << std::endl;
120  }
121  }
122  // bit 3 : reorder
123  if(pnbits & 8) {
124  std::stringstream histoname;
125  histoname << OCCUPANCYPREFIX << detid;
126  if (debugPrint) std::cout << " ready to go with histogram " << histoname.str() << std::endl;
127  TH1D* hist = (TH1D*)rootfile->FindObjectAny(histoname.str().c_str());
128  if(hist) {
129  if (debugPrint) std::cout << histoname.str() << " found!" << std::endl;
130  std::stringstream histoname_reorder;
131  histoname_reorder << OCCUPANCYPREFIX <<"_reorder_"<< detid;
132  TH1D* hist_reorder = new TH1D(histoname_reorder.str().c_str(), histoname_reorder.str().c_str(),
133  hist->GetXaxis()->GetNbins(), hist->GetXaxis()->GetXmin(), hist->GetXaxis()->GetXmax());
134  for (int i = 0; i < hist_reorder->GetNbinsX(); i++) {
135  int chan = getChannelNumber(i);
136  hist_reorder->SetBinContent(i+1,hist->GetBinContent(chan));
137  }
138  hist->Write();
139  hist_reorder->Write();
140  } else {
141  std::cout << histoname.str() << " NOT found..." << std::endl;
142  }
143  }
144 
145  }
146  if (th_summary) {
147  std::string fname = rootfilename;
148  std::string run = fname.substr(fname.find("R000")+4,6);
149  if (TotalEvents) {
150  Double_t fac = 1.0/TotalEvents;
151  th_summary->Scale(fac);
152  std::cout << " Run Number " << run << " Events " << TotalEvents << " Total # of Digis " << TotalDigis << " Av. Digis " << TotalDigis*fac << std::endl;
153  th_summary->SetEntries(TotalDigis*fac);
154 
155  }
156  th_summary->Write();
157  printPlot(th_summary,prefix,postfix);
158  }
159 
160  outrootfile->Close();
161 
162  return 0;
163 
164 }

References dir2webdir::argc, cmsBatch::argv, officialStyle::chan, gather_cfg::cout, alignmentValidation::fname, getChannelNumber(), compare::hist, mps_fire::i, NOISEPREFIX, OCCUPANCYPREFIX, PEDESTALPREFIX, ZMuMuAnalysisNtupler_cff::prefix, printPlot(), doHarvest::rootfile, writedatasetfile::run, and AlCaHLTBitMon_QueryRunRegistry::string.

◆ printPlot()

void printPlot ( TH1D *  hist,
char *  prefix,
char *  postfix 
)

Definition at line 166 of file moduleOccupancyPlots.cc.

166  {
167 
168  TCanvas* cc= new TCanvas;
169  hist->Draw();
170  std::stringstream filename;
171  filename << prefix << hist->GetName() << postfix << ".png";
172  cc->Print(filename.str().c_str());
173  delete cc;
174 
175 }

References corrVsCorr::filename, compare::hist, and ZMuMuAnalysisNtupler_cff::prefix.

Referenced by main().

cmsBatch.argv
argv
Definition: cmsBatch.py:279
mps_fire.i
i
Definition: mps_fire.py:428
OCCUPANCYPREFIX
#define OCCUPANCYPREFIX
Definition: moduleOccupancyPlots.cc:13
dir2webdir.argc
argc
Definition: dir2webdir.py:39
gather_cfg.cout
cout
Definition: gather_cfg.py:144
getChannelNumber
int getChannelNumber(int ival)
Definition: moduleOccupancyPlots.cc:176
compare.hist
hist
Definition: compare.py:376
corrVsCorr.filename
filename
Definition: corrVsCorr.py:123
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
printPlot
void printPlot(TH1D *hist, char *prefix, char *postfix)
Definition: moduleOccupancyPlots.cc:166
createfilelist.int
int
Definition: createfilelist.py:10
cc
alignmentValidation.fname
string fname
main script
Definition: alignmentValidation.py:959
writedatasetfile.run
run
Definition: writedatasetfile.py:27
officialStyle.chan
chan
lumi = TPaveText(lowX+0.38, lowY+0.061, lowX+0.45, lowY+0.161, "NDC") lumi.SetBorderSize( 0 ) lumi....
Definition: officialStyle.py:106
doHarvest.rootfile
rootfile
Definition: doHarvest.py:122
NOISEPREFIX
#define NOISEPREFIX
Definition: moduleOccupancyPlots.cc:11
ZMuMuAnalysisNtupler_cff.prefix
prefix
Definition: ZMuMuAnalysisNtupler_cff.py:14
PEDESTALPREFIX
#define PEDESTALPREFIX
Definition: moduleOccupancyPlots.cc:12