CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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 
36  unsigned long long max_since= 1;
37  Ref payload= lastPayload();
38 
39  // here popcon tells us which is the last since of the last object in the
40  // offline DB
41  max_since=tagInfo().lastInterval.first;
42  // Tm max_since_tm((max_since >> 32)*1000000);
43  Tm max_since_tm(max_since);
44  // get the last object in the orcoff
45  edm::Timestamp t_min= edm::Timestamp(18446744073709551615ULL);
46 
47  const EcalLaserAPDPNRatios::EcalLaserAPDPNRatiosMap& laserRatiosMap =
48  payload->getLaserMap();
49  std::cout << "payload->getLaserMap(): OK " << std::endl;
50  std::cout << "Its size is " << laserRatiosMap.size() << std::endl;
51  const EcalLaserAPDPNRatios::EcalLaserTimeStampMap& laserTimeMap =
52  payload->getTimeMap();
53  std::cout << "payload->getTimeMap(): OK " << std::endl;
54  std::cout << "Last Object in Offline DB has SINCE = " << max_since
55  << " -> " << max_since_tm.cmsNanoSeconds()
56  << " (" << max_since_tm << ")"
57  << " and SIZE = " << tagInfo().size
58  << std::endl;
59  // loop through light modules and determine the minimum date among the
60  // available channels
61  for (int i=0; i<92; i++) {
63  if( t_min > timestamp.t1) {
64  t_min=timestamp.t1;
65  }
66  }
67 
68  std::cout <<"WOW: we just retrieved the last valid record from DB "
69  << std::endl;
70  //std::cout <<"Its tmin is "<< Tm((t_min.value() >> 32)*1000000)
71  std::cout <<"Its tmin is "<< Tm(t_min.value()) << std::endl;
72 
73  // for(int week = 0; week < 1; week++) {
75 
77  int fileIOV;
78  std::cout << " which input IOV do you want " << std::endl;
79  std::cin >> fileIOV;
80  std::ifstream fWeek;
81  std::ostringstream oss;
82  oss << fileIOV;
83  std::string fname = "../../../Tools/DBDump/bin/weekly_" + oss.str();
84  fWeek.open(fname.c_str());
85  if(!fWeek.is_open()) {
86  std::cout << "ERROR : can't open file 'weekly_" << oss.str() << std::endl;
87  exit(-1);
88  }
89  std::cout << " file weekly_" << oss.str() << " opened" << std::endl;
90 
91  // find the timestamp for this run
92  std::ifstream fRunStartTime;
93  fRunStartTime.open("RunStartTime");
94  if(!fRunStartTime.is_open()) {
95  std::cout << "ERROR : cannot open file RunStartTime" << std::endl;
96  exit (1);
97  }
98  uint64_t iov = 0;
99  while(!fRunStartTime.eof()) {
100  int run;
101  uint64_t start;
102  fRunStartTime >> run >> start;
103  if(run == fileIOV) {
104  iov = start;
105  std::cout << "run " << run << " timestamp " << start << "\n";
106  break;
107  }
108  else if (run == fileIOV) {
109  std::cout << " run " << fileIOV << " not found in RunStartTime. Let us give up" << std::endl;
110  exit(-1);
111  }
112  }
113  fRunStartTime.close();
115 
116  t1 = iov;
117  // t3 = t1 + 2597596220620800; // 1 week << 32
118  t3 = t1 + 7792788661862400; // 3 weeks << 32
119  t2 = t1 + (t3 - t1)/2;
120  // iovStart = t1;
121  for(size_t i = 0; i < nLmes; ++i){
122  t.t1 = edm::Timestamp(t1);
123  t.t2 = edm::Timestamp(t2);
124  t.t3 = edm::Timestamp(t3);
125  corrSet->setTime(i, t);
126  }
127 
128  int rawId;
129  float corrp;
130  for (int iChannel = 0; iChannel < kEBChannels; iChannel++) {
131  EBDetId ebId = EBDetId::unhashIndex(iChannel);
132  fWeek >> rawId >> corrp;
133  corr.p1=corr.p2=corr.p3 = corrp;
134  corrSet->setValue((int)ebId, corr );
135  }
136  for (int iChannel = 0; iChannel < kEEChannels; iChannel++) {
137  EEDetId eeId = EEDetId::unhashIndex(iChannel);
138  fWeek >> rawId >> corrp;
139  corr.p1=corr.p2=corr.p3 = corrp;
140  corrSet->setValue((int)eeId, corr );
141  }
142  fWeek.close();
143 
144  std::cout << "Write IOV " << iIov << " starting from " << fileIOV << "... "<< std::endl;
145  // db_->writeOne(corrSet, iovStart, "EcalLaserAPDPNRatiosRcd");
146  m_to_transfer.push_back(std::make_pair(corrSet, fileIOV));
147  iIov++;
148  // } // end loop over week
149  std::cout << "Ecal -> end of getNewObjects -----------\n";
150 }
int i
Definition: DBlmapReader.cc:9
tuple start
Check for commandline option errors.
Definition: dqm_diff.py:58
EcalLaser_weekly_Handler(edm::ParameterSet const &)
static EEDetId unhashIndex(int hi)
Definition: EEDetId.cc:99
tuple iov
Definition: o2o.py:307
auto const T2 &decltype(t1.eta()) t2
Definition: deltaR.h:16
uint64_t cmsNanoSeconds() const
Definition: Tm.cc:116
JetCorrectorParameters corr
Definition: classes.h:5
unsigned long long uint64_t
Definition: Time.h:15
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:114
tuple cout
Definition: gather_cfg.py:145
Definition: Tm.h:13
TimeValue_t value() const
Definition: Timestamp.h:56