CMS 3D CMS Logo

EcalTPGFineGrainTowerfromFile.cc
Go to the documentation of this file.
2 
4 
6 
9 
10 #include<iostream>
11 #include<fstream>
12 #include <sstream>
13 
15  : m_name(ps.getUntrackedParameter<std::string>("name","EcalTPGFineGrainTowerfromFile")) {
16  fname = ps.getParameter<std::string>("FileName");
17 
18  std::cout << "EcalTPGFineGrainTowerfromFile constructor\n" << std::endl;
19 }
20 
22 
24  std::cout << "------- Ecal -> getNewObjects\n";
25  edm::LogInfo("EcalTPGFineGrainTowerfromFile") << "Started GetNewObjects!!!";
26 
28  int fileIOV;
29  std::cout << "LinPed which input IOV do you want " << std::endl;
30  std::cin >> fileIOV;
31  std::ifstream fLin;
32  std::ostringstream oss;
33  oss << fileIOV;
34  // std::string fname = "/afs/cern.ch/cms/ECAL/triggerTransp/TPG_beamv6_trans_" + oss.str() + "_spikekill.txt";
35  fLin.open(fname.c_str());
36  if(!fLin.is_open()) {
37  std::cout << "ERROR : can't open file '" << fname << std::endl;
38  return;
39  }
40  std::cout << " file " << fname << " opened" << std::endl;
41  /* structure of the file:
42 TOWER_EB 365224/375015 : 9792 lines 2448 towers 3 lines : 0, 0, 96 (LUTGroupId, FgGroupId, spike_killing_threshold)
43 empty line 375016
44 TOWER_EE 375017/379768 : 4752 lines 1584 towers 2 lines : 0, 0x0 (LUTGroupId, tower_lut_fg)
45  */
47  for(int i = 0; i < 375016; i++) getline (fLin, line);
48  char tower[8];
49  unsigned int towerId, LUTFg;
50  for (int itower = 0; itower < 1584; itower++) {
51  getline (fLin, line);
52  sscanf(line.c_str(), "%s %u", tower, &towerId);
53  if(itower < 10 || (itower > 1574 && itower < 1584)) std::cout << " string " << tower << " Id " << towerId;
54  getline (fLin, line); // LUTGroupId
55  getline (fLin, line); // tower_lut_fg
56  if(itower < 10 || (itower > 1574 && itower < 1584)) std::cout << " line " << line << std::endl;
57  sscanf(line.c_str(), "%x", &LUTFg);
58  // EcalTPGFineGrainTowerEE::Item item;
59  // item.lut = LUTFg;
60  // fgrMap->setValue(towerId, item);
61 
62  fgrMap->setValue(towerId, LUTFg);
63  } // end loop over EE towers
64  fLin.close();
65 
66  m_to_transfer.push_back(std::make_pair((EcalTPGFineGrainTowerEE*)fgrMap, fileIOV));
67 
68  std::cout << "Ecal -> end of getNewObjects -----------\n";
69 }
T getParameter(std::string const &) const
void setValue(const uint32_t &id, const uint32_t &lut)
unsigned towerId(DetId const &)