CMS 3D CMS Logo

Enumerations | Functions
printPixelROCsMap.cc File Reference
#include "DQM/TrackerRemapper/interface/Phase1PixelROCMaps.h"
#include <bitset>
#include <cstdint>
#include <cstdlib>
#include <fstream>
#include <iostream>
#include <numeric>
#include <sstream>
#include <string>
#include <vector>
#include "TCanvas.h"
#include "TStyle.h"

Go to the source code of this file.

Enumerations

enum  Region { Region::Barrel = 0, Region::Forward = 1, Region::Full = 2 }
 

Functions

int main (int argc, char *argv[])
 
Region parseRegion (const std::string &regionStr)
 
std::string regionToString (Region region)
 
void showHelp (const std::string &scriptName)
 

Enumeration Type Documentation

◆ Region

enum Region
strong
Enumerator
Barrel 
Forward 
Full 

Definition at line 16 of file printPixelROCsMap.cc.

16  {
17  Barrel = 0, // Assume 0 for barrel
18  Forward = 1, // 1 for forward
19  Full = 2 // 2 for full
20 };

Function Documentation

◆ 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:

Sticking ADC counts in neughbouring TS for HB:

Sticking ADC counts in neughbouring TS for HE:

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:

Prepare maps of good/bad channels:

Prepare maps of good/bad channels:

Definition at line 58 of file printPixelROCsMap.cc.

References dir2webdir::argc, GCPpyPlots::argv, Barrel, svgfig::canvas(), DMR_cfg::cerr, ALPAKA_ACCELERATOR_NAMESPACE::brokenline::constexpr(), gather_cfg::cout, ALCARECOPPSCalTrackBasedSel_cff::detid, Phase1PixelROCMaps::drawBarrelMaps(), Phase1PixelROCMaps::drawForwardMaps(), Phase1PixelROCMaps::drawMaps(), geometryDiff::file, MillePedeFileConverter_cfg::fileName, Phase1PixelROCMaps::fillSelectedRocs(), Phase1PixelROCMaps::fillWholeModule(), Forward, Full, mps_fire::i, makeListRunsInFiles::inputFile, mps_splice::line, parseRegion(), nano_mu_digi_cff::region, regionToString(), PixelMapPlotter::rocs, showHelp(), AlCaHLTBitMon_QueryRunRegistry::string, and runGCPTkAlMap::title.

58  {
59  static constexpr std::array<int, 3> k_height = {{1200, 600, 1600}};
60 
62  std::string inputROCsFile;
63  Region region = Region::Full; // Default value: Full region
64  std::vector<std::pair<uint32_t, float>> detidValues;
65  std::vector<std::pair<uint32_t, std::bitset<16>>> detidRocs;
66 
67  // If no arguments are passed or --h/--help is passed, show the help message
68  if (argc == 1) {
69  showHelp(argv[0]);
70  return 0;
71  }
72 
73  // Parse command line arguments
74  for (int i = 1; i < argc; ++i) {
75  std::string arg = argv[i];
76 
77  if (arg == "--h" || arg == "--help") {
78  showHelp(argv[0]);
79  return 0; // Exit after displaying help
80  } else if (arg == "--input-file" && i + 1 < argc) {
81  inputFile = argv[++i];
82  } else if (arg == "--input-ROCs" && i + 1 < argc) {
83  inputROCsFile = argv[++i];
84  } else if (arg == "--region" && i + 1 < argc) {
85  std::string regionArg = argv[++i];
86  try {
87  region = parseRegion(regionArg); // Parse region from string
88  } catch (const std::invalid_argument&) {
89  std::cerr << "Invalid value for --region: " << regionArg << "\n";
90  showHelp(argv[0]);
91  return 1;
92  }
93  } else {
94  // Assume it's a DetId, convert to uint32_t
95  try {
96  uint32_t detid = std::stoul(arg);
97  detidValues.emplace_back(detid, 1.0); // Default value is 1.0
98  } catch (const std::invalid_argument&) {
99  std::cerr << "Invalid argument: " << arg << "\n";
100  showHelp(argv[0]);
101  return 1;
102  }
103  }
104  }
105 
106  // If --input-file is provided, read from file
107  if (!inputFile.empty()) {
108  std::ifstream file(inputFile);
109  if (!file) {
110  std::cerr << "Error: Unable to open input file " << inputFile << std::endl;
111  return 1;
112  }
113 
115  while (std::getline(file, line)) {
116  std::istringstream iss(line);
117  uint32_t detid;
118  float value = 1.0; // Default value
119 
120  iss >> detid;
121  if (iss >> value) { // If a second column exists, read it as value
122  detidValues.emplace_back(detid, value);
123  } else {
124  detidValues.emplace_back(detid, 1.0);
125  }
126  }
127  }
128 
129  // If --input-ROCs is provided, read from file
130  if (!inputROCsFile.empty()) {
131  std::ifstream file(inputROCsFile);
132  if (!file) {
133  std::cerr << "Error: Unable to open input ROCs file " << inputROCsFile << std::endl;
134  return 1;
135  }
136 
138  while (std::getline(file, line)) {
139  std::istringstream iss(line);
140  uint32_t detid;
141  std::string rocBits;
142  iss >> detid >> rocBits;
143 
144  if (rocBits.length() == 16) {
145  std::bitset<16> rocs(rocBits);
146  detidRocs.emplace_back(detid, rocs);
147  } else {
148  std::cerr << "Error: Invalid ROC bits string for detid " << detid << std::endl;
149  return 1;
150  }
151  }
152  }
153 
154  // Create the map and fill it
155  Phase1PixelROCMaps theMap("");
156 
157  // Fill with detidValues if --input-file or command line DetIds are used
158  for (const auto& [detid, value] : detidValues) {
159  theMap.fillWholeModule(detid, value);
160  }
161 
162  // Fill with detidRocs if --input-ROCs is used
163  for (const auto& [detid, rocs] : detidRocs) {
164  theMap.fillSelectedRocs(detid, rocs, 1.0); // Default value 1.0
165  }
166 
167  // Construct the full label string
168  std::string title = "Marked Pixel ROCs - " + regionToString(region);
169 
170  // Draw and save the map
171  TCanvas canvas("Summary", "Summary", 1200, k_height[static_cast<int>(region)]);
172  if (region == Region::Full) {
173  theMap.drawMaps(canvas, title.c_str());
174  } else if (region == Region::Barrel) {
175  theMap.drawBarrelMaps(canvas, title.c_str());
176  } else if (region == Region::Forward) {
177  theMap.drawForwardMaps(canvas, title.c_str());
178  }
179 
180  // Construct the filename string based on the region
181  std::string fileName = "Phase1PixelROCMap_" + regionToString(region) + ".png";
182  // Save the canvas with the constructed filename
183  canvas.SaveAs(fileName.c_str());
184 
185  std::cout << "Filled Phase1 Pixel ROC map with " << detidValues.size() + detidRocs.size() << " detids." << std::endl;
186 
187  return 0;
188 }
void showHelp(const std::string &scriptName)
Region parseRegion(const std::string &regionStr)
A arg
Definition: Factorize.h:31
std::string regionToString(Region region)
Definition: value.py:1
def canvas(sub, attr)
Definition: svgfig.py:482

◆ parseRegion()

Region parseRegion ( const std::string &  regionStr)

Definition at line 46 of file printPixelROCsMap.cc.

References Barrel, Forward, and Full.

Referenced by main().

46  {
47  if (regionStr == "barrel") {
48  return Region::Barrel;
49  } else if (regionStr == "forward") {
50  return Region::Forward;
51  } else if (regionStr == "full") {
52  return Region::Full;
53  } else {
54  throw std::invalid_argument("Invalid region value");
55  }
56 }

◆ regionToString()

std::string regionToString ( Region  region)

Definition at line 32 of file printPixelROCsMap.cc.

References Barrel, Forward, Full, and nano_mu_digi_cff::region.

Referenced by main().

32  {
33  switch (region) {
34  case Region::Barrel:
35  return "barrel";
36  case Region::Forward:
37  return "forward";
38  case Region::Full:
39  return "full";
40  default:
41  return "unknown";
42  }
43 }

◆ showHelp()

void showHelp ( const std::string &  scriptName)

Definition at line 22 of file printPixelROCsMap.cc.

References gather_cfg::cout, and Herwig7_Dummy_ReadLHE_GEN_SIM::scriptName.

Referenced by main().

22  {
23  std::cout << "Usage: " << scriptName << " [options] <detid>\n"
24  << " --input-file <filename> Specify the input file\n"
25  << " --input-ROCs <filename> Specify the input ROCs file\n"
26  << " --region <barrel|forward|full> Specify the region (default: full)\n"
27  << " --h or --help Show this help message\n"
28  << " <detid> Provide DetId (list of DetIds)\n";
29 }