Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:01:12

0001 #include <iostream>
0002 #include <string>
0003 
0004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0005 #include "CommonTools/TrackerMap/interface/TrackerMap.h"
0006 
0007 void printTrackerMap(const std::string filename,
0008                      const std::string title,
0009                      const std::string outfile,
0010                      const int size,
0011                      const std::string logscale,
0012                      std::string withpixel,
0013                      const float min,
0014                      const float max);
0015 
0016 int main(int argc, char* argv[]) {
0017   if (argc >= 4) {
0018     int size = 4500;
0019     float min = 10.;
0020     float max = -1.;
0021     std::string logscale = "False";
0022     std::string withpixel = "False";
0023 
0024     char* filename = argv[1];
0025     char* title = argv[2];
0026     char* outfile = argv[3];
0027     std::cout << "ready to use file " << filename << " to create the map " << title << " and save it in " << outfile
0028               << std::endl;
0029 
0030     if (argc >= 5) {
0031       size = atoi(argv[4]);
0032     }
0033     if (argc >= 6) {
0034       logscale = argv[5];
0035       withpixel = argv[6];
0036     }
0037     if (argc >= 9) {
0038       min = atof(argv[7]);
0039       max = atof(argv[8]);
0040     }
0041 
0042     printTrackerMap(filename, title, outfile, size, logscale, withpixel, min, max);
0043 
0044   } else {
0045     std::cout << "Wrong number of arguments: " << argc << std::endl;
0046     return -1;
0047   }
0048 
0049   return 0;
0050 }
0051 
0052 void printTrackerMap(const std::string filename,
0053                      const std::string title,
0054                      const std::string outfile,
0055                      const int size,
0056                      const std::string logscale,
0057                      std::string withpixel,
0058                      const float min,
0059                      const float max) {
0060   edm::ParameterSet pset;
0061 
0062   if (logscale == "True")
0063     pset.addUntrackedParameter<bool>("logScale", true);
0064   if (logscale == "False")
0065     pset.addUntrackedParameter<bool>("logScale", false);
0066 
0067   TrackerMap themap(pset);
0068   themap.setTitle(title);  // title as input parameter
0069   double ratio = 2400. / 4500.;
0070   if (withpixel == "True") {
0071     themap.addPixel(true);
0072     themap.onlyPixel(false);
0073     ratio = 8. / 19.;
0074   }
0075   if (withpixel == "Only") {
0076     themap.addPixel(false);
0077     themap.onlyPixel(true);
0078     ratio = 16. / 9.;
0079   }
0080   if (withpixel == "False") {
0081     themap.addPixel(false);
0082     themap.onlyPixel(false);
0083     ratio = 8. / 15.;
0084   }
0085 
0086   std::ifstream input(filename);
0087 
0088   unsigned int detid;
0089   float val;
0090 
0091   while (input >> detid >> val) {
0092     themap.fill_current_val(detid, val);
0093   }
0094 
0095   std::cout << "preparing a map with size " << size << "x" << int(size * ratio) << std::endl;
0096 
0097   themap.save(true, min, max, outfile, size, int(size * ratio));  // name and size as input parameters
0098 }