CMS 3D CMS Logo

EcalTPGPedfromFile.cc
Go to the documentation of this file.
9 
10 #include<iostream>
11 #include<iomanip>
12 #include <sstream>
13 
15  : m_name(ps.getUntrackedParameter<std::string>("name","EcalTPGPedfromFileHandler")) {
16  std::cout << "EcalTPGPedfromFile constructor\n" << std::endl;
17 }
18 
20  // do nothing
21 }
22 
24  std::cout << "------- Ecal -> getNewObjects\n";
25 
26  unsigned long long max_since = 1;
28 
29  // here popcon tells us which is the last since of the last object in the offline DB
30  max_since=tagInfo().lastInterval.first;
31  Tm max_since_tm(max_since);
32 
35  int fileIOV;
36  std::cout << "PedfromFile which input IOV do you want " << std::endl;
37  std::cin >> fileIOV;
38  std::ifstream fLin;
39  std::ostringstream oss;
40  oss << fileIOV;
41  std::string fname = "/afs/cern.ch/cms/ECAL/triggerTransp/TPG_beamv6_trans_" + oss.str() + "_spikekill.txt";
42  fLin.open(fname.c_str());
43  if(!fLin.is_open()) {
44  std::cout << "ERROR : can't open file '" << fname << std::endl;
45  return;
46  }
47  std::cout << " file " << fname << " opened" << std::endl;
49  for(int i = 0; i < 85; i++) getline (fLin, line);
50  char cryst[10];
51  uint32_t ped[kGains], mult[kGains], shift[kGains];
52  uint32_t id;
53  for (int iChannel = 0; iChannel < kEBChannels; iChannel++) {
54  getline (fLin, line);
55  sscanf(line.c_str(), "%s %u", cryst, &id);
56  for (int gain = 0; gain < kGains; gain++) {
57  getline (fLin, line);
58  sscanf(line.c_str(), "%X %X %X", &ped[gain], &mult[gain], &shift[gain]);
59  }
61  item.mult_x1 = mult[2];
62  item.mult_x6 = mult[1];
63  item.mult_x12 = mult[0];
64  item.shift_x1 = shift[2];
65  item.shift_x6 = shift[1];
66  item.shift_x12 = shift[0];
67 
68  EcalTPGPedestals::Item itemPed;
69  itemPed.mean_x1 = ped[2];
70  itemPed.mean_x6 = ped[1];
71  itemPed.mean_x12 = ped[0];
72 
73  linC->insert(std::make_pair(id, item));
74  peds->insert(std::make_pair(id, itemPed));
75  } // end loop over EB channels
76  getline (fLin, line); // comment before EE crystals
77  std::cout << " comment line " << line << std::endl;
78  for (int iChannel = 0; iChannel < kEEChannels; iChannel++) {
79  getline (fLin, line);
80  // std::cout << " line " << line << std::endl;
81  sscanf(line.c_str(), "%s %u", cryst, &id);
82  // std::cout << cryst << " id " << id << std::endl;
83  for (int gain =0; gain < kGains; gain++) {
84  getline (fLin, line);
85  // std::cout << " line g " << line << std::endl;
86  sscanf(line.c_str(), "%X %X %X", &ped[gain], &mult[gain], &shift[gain]);
87  // std::cout << " gain " << gain << " ped " << ped[gain] << " mult " << mult[gain] << " shift " << shift[gain]<< std::endl;
88 
89  }
91  item.mult_x1 = mult[2];
92  item.mult_x6 = mult[1];
93  item.mult_x12 = mult[0];
94  item.shift_x1 = shift[2];
95  item.shift_x6 = shift[1];
96  item.shift_x12 = shift[0];
97 
98  EcalTPGPedestals::Item itemPed;
99  itemPed.mean_x1 = ped[2];
100  itemPed.mean_x6 = ped[1];
101  itemPed.mean_x12 = ped[0];
102 
103  linC->insert(std::make_pair(id, item));
104  peds->insert(std::make_pair(id, itemPed));
105  } // end loop over EE channels
106  fLin.close();
107  // for the time beeing just transfer pedestal
108  // m_to_transfer.push_back(std::make_pair((EcalTPGLinearizationConst*)linC, fileIOV));
109  m_to_transfer.push_back(std::make_pair((EcalTPGPedestals*)peds, fileIOV));
110 
111  std::cout << "Ecal -> end of getNewObjects -----------\n";
112 }
std::string id() const override
EcalTPGPedfromFile(edm::ParameterSet const &)
cond::ValidityInterval lastInterval
Definition: Types.h:75
void insert(std::pair< uint32_t, Item > const &a)
string fname
main script
static unsigned int const shift
EcalTPGPedestalsMap EcalTPGPedestals
Definition: Tm.h:13
EcalTPGLinearizationConstMap EcalTPGLinearizationConst