CMS 3D CMS Logo

EcalLaser_weekly_Linearization.cc
Go to the documentation of this file.
8 
9 #include <iostream>
10 #include <iomanip>
11 #include <sstream>
12 
14  : m_name(ps.getUntrackedParameter<std::string>("name", "EcalLaser_weekly_Handler")) {
15  std::cout << "EcalLaser Source handler constructor\n" << std::endl;
16 }
17 
19  // do nothing
20 }
21 
23  // int file[1] = {190708};
24 
25  std::cout << "------- Ecal -> getNewObjects\n";
26 
27  unsigned long long max_since = 1;
28  Ref payload = lastPayload();
29 
30  // here popcon tells us which is the last since of the last object in the offline DB
31  max_since = tagInfo().lastInterval.since;
32  Tm max_since_tm(max_since);
33 
34  // const EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap& laserRatiosMap =
35  // payload->getLaserMap();
36  // std::cout << "payload->getLaserMap(): OK " << std::endl;
37  // std::cout << "Its size is " << laserRatiosMap.size() << std::endl;
38  // const EcalLaserAPDPNRatios::EcalLaserTimeStampMap& laserTimeMap =
39  // payload->getTimeMap();
40  // std::cout << "payload->getTimeMap(): OK " << std::endl;
41  // std::cout << "Last Object in Offline DB has SINCE = " << max_since
42  // << " -> " << max_since_tm.cmsNanoSeconds()
43  // << " (" << max_since_tm << ")"
44  // << " and SIZE = " << tagInfo().size
45  // << std::endl;
46 
47  for (int week = 0; week < 1; week++) {
48  int fileIOV;
49  std::cout << " which input IOV do you want " << std::endl;
50  std::cin >> fileIOV;
51  std::ifstream fWeek;
52  std::ostringstream oss;
53  oss << fileIOV;
54  std::string fname = "/afs/cern.ch/cms/ECAL/triggerTransp/TPG_beamv6_trans_" + oss.str() + "_spikekill.txt";
55  /*
56  oss << file[week];
57  // std::string fname = "/afs/cern.ch/cms/ECAL/triggerTransp/TPG_beamv5_trans_" + oss.str() + "_";
58  std::string fname = "/afs/cern.ch/cms/ECAL/triggerTransp/TPG_beamv6_trans_" + oss.str() + "_";
59  oss.str("");
60  // if(week == 32) oss << 200000;
61  // else oss << file[week + 1] - 1;
62  oss << 200000;
63  fname += oss.str() + ".txt";
64  */
65  fWeek.open(fname.c_str());
66  if (!fWeek.is_open()) {
67  std::cout << "ERROR : can't open file '" << fname << std::endl;
68  break;
69  }
70  std::cout << " file " << fname << " opened" << std::endl;
71  // int rawId;
72  // float corrp;
74  for (int i = 0; i < 85; i++)
75  getline(fWeek, line);
76  char cryst[10];
77  uint32_t ped[kGains], mult[kGains], shift[kGains];
78  uint32_t id;
79 
81 
82  for (int iChannel = 0; iChannel < kEBChannels; iChannel++) {
83  getline(fWeek, line);
84  // std::cout << " line " << line << std::endl;
85  // fWeek >> cryst >> id;
86  sscanf(line.c_str(), "%s %u", cryst, &id);
87  // std::cout << cryst << " id " << id << std::endl;
88  // EBDetId ebId = DetId(id);
89  for (int gain = 0; gain < kGains; gain++) {
90  // fWeek >> std::hex >> ped[gain] >> mult[gain] >> shift[gain];
91  getline(fWeek, line);
92  // std::cout << " line g " << line << std::endl;
93  sscanf(line.c_str(), "%X %X %X", &ped[gain], &mult[gain], &shift[gain]);
94  // std::cout << " gain " << gain << " ped " << ped[gain] << " mult " << mult[gain] << " shift " << shift[gain]<< std::endl;
95  }
97  item.mult_x1 = mult[2];
98  item.mult_x6 = mult[1];
99  item.mult_x12 = mult[0];
100  item.shift_x1 = shift[2];
101  item.shift_x6 = shift[1];
102  item.shift_x12 = shift[0];
103 
104  linC->insert(std::make_pair(id, item));
105  // corr.p1=corr.p2=corr.p3 = corrp;
106  // corrSet->setValue((int)ebId, corr );
107  // cryst ="";
108  } // end loop over EB channels
109  getline(fWeek, line); // cmment before EE crystals
110  std::cout << " comment line " << line << std::endl;
111  for (int iChannel = 0; iChannel < kEEChannels; iChannel++) {
112  getline(fWeek, line);
113  // std::cout << " line " << line << std::endl;
114  sscanf(line.c_str(), "%s %u", cryst, &id);
115  // std::cout << cryst << " id " << id << std::endl;
116  // EEDetId eeId = DetId(id);
117  for (int gain = 0; gain < kGains; gain++) {
118  getline(fWeek, line);
119  // std::cout << " line g " << line << std::endl;
120  sscanf(line.c_str(), "%X %X %X", &ped[gain], &mult[gain], &shift[gain]);
121  // std::cout << " gain " << gain << " ped " << ped[gain] << " mult " << mult[gain] << " shift " << shift[gain]<< std::endl;
122 
123  } // corr.p1=corr.p2=corr.p3 = corrp;
124  // corrSet->setValue((int)eeId, corr );
126  item.mult_x1 = mult[2];
127  item.mult_x6 = mult[1];
128  item.mult_x12 = mult[0];
129  item.shift_x1 = shift[2];
130  item.shift_x6 = shift[1];
131  item.shift_x12 = shift[0];
132 
133  linC->insert(std::make_pair(id, item));
134  } // end loop over EE channels
135  fWeek.close();
136  // special tag for Stephanie
137  // m_to_transfer.push_back(std::make_pair((EcalTPGLinearizationConst*)linC, file[week]));
138  m_to_transfer.push_back(std::make_pair(linC, fileIOV));
139  // end special
140  } // end loop over week
141  std::cout << "Ecal -> end of getNewObjects -----------\n";
142 }
void insert(std::pair< uint32_t, Item > const &a)
string fname
main script
std::unique_ptr< EcalTPGLinearizationConst > Ref
static unsigned int const shift
Definition: Tm.h:13
EcalTPGLinearizationConstMap EcalTPGLinearizationConst
const Int_t kGains