CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
print_TrackerMap.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <string>
3 
6 
7 void printTrackerMap(const std::string filename, const std::string title, const std::string outfile, const int size, const std::string logscale, std::string withpixel, const float min, const float max);
8 
9 int main(int argc, char *argv[]) {
10 
11  if(argc>=4) {
12 
13  int size=4500;
14  float min = 10.;
15  float max = -1.;
16  std::string logscale = "False";
17  std::string withpixel = "False";
18 
19  char* filename =argv[1];
20  char* title = argv[2];
21  char* outfile = argv[3];
22  std::cout << "ready to use file " << filename << " to create the map " << title << " and save it in " <<outfile << std::endl;
23 
24  if(argc>=5) {
25  size = atoi(argv[4]);
26  }
27  if(argc>=6) {
28  logscale = argv[5];
29  withpixel = argv[6];
30  }
31  if(argc>=9) {
32  min = atof(argv[7]);
33  max = atof(argv[8]);
34  }
35 
36  printTrackerMap(filename,title,outfile,size,logscale,withpixel,min,max);
37 
38  }
39  else { std::cout << "Wrong number of arguments: " << argc << std::endl; return -1; }
40 
41  return 0;
42 }
43 
45  const int size, const std::string logscale, std::string withpixel, const float min, const float max) {
46 
47 
48  edm::ParameterSet pset;
49 
50  if(logscale=="True") pset.addUntrackedParameter<bool>("logScale",true);
51  if(logscale=="False") pset.addUntrackedParameter<bool>("logScale",false);
52 
53  TrackerMap themap(pset);
54  themap.setTitle(title); // title as input parameter
55  double ratio=2400./4500.;
56  if(withpixel=="True") {themap.addPixel(true); themap.onlyPixel(false); ratio=8./19.;}
57  if(withpixel=="Only") {themap.addPixel(false); themap.onlyPixel(true); ratio=16./9.;}
58  if(withpixel=="False") {themap.addPixel(false); themap.onlyPixel(false); ratio=8./15.;}
59 
60  std::ifstream input(filename);
61 
62  unsigned int detid;
63  float val;
64 
65  while( input >> detid >> val) {
66  themap.fill_current_val(detid,val);
67  }
68 
69  std::cout << "preparing a map with size " << size << "x" << int(size*ratio) << std::endl;
70 
71  themap.save(true,min,max,outfile,size,int(size*ratio)); // name and size as input parameters
72 
73 
74 
75 }
static std::string const input
Definition: EdmProvDump.cc:43
int main(int argc, char **argv)
T min(T a, T b)
Definition: MathUtil.h:58
void addUntrackedParameter(std::string const &name, T const &value)
Definition: ParameterSet.h:207
tuple argc
Definition: dir2webdir.py:38
tuple filename
Definition: lut2db_cfg.py:20
tuple cout
Definition: gather_cfg.py:121
tuple size
Write out results.