CMS 3D CMS Logo

EcalLaser_weekly_Handler.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  // wrongBy = ps.getUntrackedParameter<double>("WrongBy",1.0);
16  std::cout << "EcalLaser Source handler constructor\n" << std::endl;
17 }
18 
20  // do nothing
21 }
22 
24  // uint64_t iov[1] = {5726925116361670656};
25  // int file[1] = {190111};
26  // int file[1] = {190708};
27  const size_t nLmes = 92;
28  // cond::Time_t iovStart = 0;
29  uint64_t t1, t2, t3;
30 
31  int iIov = 0;
32 
33  std::cout << "------- Ecal -> getNewObjects\n";
34 
35  unsigned long long max_since = 1;
36  Ref payload = lastPayload();
37 
38  // here popcon tells us which is the last since of the last object in the
39  // offline DB
40  max_since = tagInfo().lastInterval.since;
41  // Tm max_since_tm((max_since >> 32)*1000000);
42  Tm max_since_tm(max_since);
43  // get the last object in the orcoff
44  edm::Timestamp t_min = edm::Timestamp(18446744073709551615ULL);
45 
46  const EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap& laserRatiosMap = payload->getLaserMap();
47  std::cout << "payload->getLaserMap(): OK " << std::endl;
48  std::cout << "Its size is " << laserRatiosMap.size() << std::endl;
49  const EcalLaserAPDPNRatios::EcalLaserTimeStampMap& laserTimeMap = payload->getTimeMap();
50  std::cout << "payload->getTimeMap(): OK " << std::endl;
51  std::cout << "Last Object in Offline DB has SINCE = " << max_since << " -> " << max_since_tm.cmsNanoSeconds() << " ("
52  << max_since_tm << ")"
53  << " and SIZE = " << tagInfo().size << std::endl;
54  // loop through light modules and determine the minimum date among the
55  // available channels
56  for (int i = 0; i < 92; i++) {
58  if (t_min > timestamp.t1) {
59  t_min = timestamp.t1;
60  }
61  }
62 
63  std::cout << "WOW: we just retrieved the last valid record from DB " << std::endl;
64  //std::cout <<"Its tmin is "<< Tm((t_min.value() >> 32)*1000000)
65  std::cout << "Its tmin is " << Tm(t_min.value()) << std::endl;
66 
67  // for(int week = 0; week < 1; week++) {
69 
71  int fileIOV;
72  std::cout << " which input IOV do you want " << std::endl;
73  std::cin >> fileIOV;
74  std::ifstream fWeek;
75  std::ostringstream oss;
76  oss << fileIOV;
77  std::string fname = "../../../Tools/DBDump/bin/weekly_" + oss.str();
78  fWeek.open(fname.c_str());
79  if (!fWeek.is_open()) {
80  std::cout << "ERROR : can't open file 'weekly_" << oss.str() << std::endl;
81  exit(-1);
82  }
83  std::cout << " file weekly_" << oss.str() << " opened" << std::endl;
84 
85  // find the timestamp for this run
86  std::ifstream fRunStartTime;
87  fRunStartTime.open("RunStartTime");
88  if (!fRunStartTime.is_open()) {
89  std::cout << "ERROR : cannot open file RunStartTime" << std::endl;
90  exit(1);
91  }
92  uint64_t iov = 0;
93  while (!fRunStartTime.eof()) {
94  int run;
96  fRunStartTime >> run >> start;
97  if (run == fileIOV) {
98  iov = start;
99  std::cout << "run " << run << " timestamp " << start << "\n";
100  break;
101  } else if (run == fileIOV) {
102  std::cout << " run " << fileIOV << " not found in RunStartTime. Let us give up" << std::endl;
103  exit(-1);
104  }
105  }
106  fRunStartTime.close();
108 
109  t1 = iov;
110  // t3 = t1 + 2597596220620800; // 1 week << 32
111  t3 = t1 + 7792788661862400; // 3 weeks << 32
112  t2 = t1 + (t3 - t1) / 2;
113  // iovStart = t1;
114  for (size_t i = 0; i < nLmes; ++i) {
115  t.t1 = edm::Timestamp(t1);
116  t.t2 = edm::Timestamp(t2);
117  t.t3 = edm::Timestamp(t3);
118  corrSet->setTime(i, t);
119  }
120 
121  int rawId;
122  float corrp;
123  for (int iChannel = 0; iChannel < kEBChannels; iChannel++) {
124  EBDetId ebId = EBDetId::unhashIndex(iChannel);
125  fWeek >> rawId >> corrp;
126  corr.p1 = corr.p2 = corr.p3 = corrp;
127  corrSet->setValue((int)ebId, corr);
128  }
129  for (int iChannel = 0; iChannel < kEEChannels; iChannel++) {
130  EEDetId eeId = EEDetId::unhashIndex(iChannel);
131  fWeek >> rawId >> corrp;
132  corr.p1 = corr.p2 = corr.p3 = corrp;
133  corrSet->setValue((int)eeId, corr);
134  }
135  fWeek.close();
136 
137  std::cout << "Write IOV " << iIov << " starting from " << fileIOV << "... " << std::endl;
138  // db_->writeOne(corrSet, iovStart, "EcalLaserAPDPNRatiosRcd");
139  m_to_transfer.push_back(std::make_pair(corrSet, fileIOV));
140  iIov++;
141  // } // end loop over week
142  std::cout << "Ecal -> end of getNewObjects -----------\n";
143 }
uint64_t cmsNanoSeconds() const
Definition: Tm.cc:92
Definition: start.py:1
EcalLaser_weekly_Handler(edm::ParameterSet const &)
static EEDetId unhashIndex(int hi)
Definition: EEDetId.cc:65
dictionary corr
unsigned long long uint64_t
Definition: Time.h:13
TimeValue_t value() const
Definition: Timestamp.h:38
std::vector< EcalLaserTimeStamp > EcalLaserTimeStampMap
string fname
main script
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
Definition: EBDetId.h:110
std::unique_ptr< EcalLaserAPDPNRatios > Ref
Definition: Tm.h:13
def exit(msg="")