|
|
Go to the documentation of this file.
27 eventListFileName_(ps.getParameter<
string>(
"eventListFile")),
28 verb_(ps.getParameter<
int>(
"verbosity")),
29 mode_(ps.getParameter<
string>(
"mode")),
30 fnames_(ps.getParameter<
vector<
string> >(
"laserCorrectionAsciiFiles")),
31 skipIov_(ps.getParameter<
int>(
"skipIov")),
32 nIovs_(ps.getParameter<
int>(
"nIovs")),
33 fromTime_(ps.getParameter<
int>(
"fromTime")),
34 toTime_(ps.getParameter<
int>(
"toTime")),
35 minP_(ps.getParameter<double>(
"transparencyMin")),
36 maxP_(ps.getParameter<double>(
"transparencyMax")) {
37 ferr_ = fopen(
"corr_errors.txt",
"w");
38 fprintf(
ferr_,
"#t1\tdetid\tp1\tp2\tp3");
55 static bool done =
false;
57 if (
mode_ ==
"ascii_file_to_db") {
61 cout <<
"ascii_file_to_db mode" << endl;
63 throw cms::Exception(
"CondDBAccess") <<
"Failed to connect to PoolDBOutputService\n";
68 }
else if (
mode_ ==
"db_to_ascii_file") {
71 cms::Exception(
"InvalidParam") <<
"Value of parameter mode is not valid. Expecting ascii_file_to_db or read";
77 int processedIovs = 0;
79 cout <<
"Starting filling DB...\n";
93 while (fscanf(
eventList_,
" %1[#]%*[^\n]\n", &
c) == 1)
96 int n = fscanf(
eventList_,
"%*d %*d %*d %d%*[^\n]\n", &
t);
106 <<
" are not ordered in increased time as required! See line " <<
iline <<
"\n";
108 throw cms::Exception(
"User") <<
"Found an unexpected t = 0 time value "
109 "in the event list file"
112 bool iovFound =
true;
115 cout <<
"Event in same IOV than previous one.\n";
119 while ((iovFound =
r.readTime(
t1,
t2,
t3)) &&
t3 <
t)
123 if (
t1 < prevT1 &&
t3 < prevT3)
125 <<
"IOVs in the correction ascii file are not ordered in increased time as required!\n";
126 else if (
t1 < prevT1 ||
t3 < prevT3)
127 throw cms::Exception(
"User") <<
"Found interleaved IOVs in the correction ascii file!\n";
135 while (
r.readTime(
t1,
t2,
t3)) {
138 std::cout <<
"Skipping IOV " << iIov <<
"\n";
140 }
else if (processedIovs >=
nIovs_) {
141 std::cout <<
"Requested number of IOVs, " <<
nIovs_ <<
", processed.\n";
169 std::cout <<
"Skipping IOV " << iIov <<
", "
194 constexpr
int ncrystals = 75848;
195 std::set<int> detidList;
196 for (
int i = 0;
i < ncrystals; ++
i) {
201 cout <<
"Reading " <<
toNth(
i + 1) <<
" crystal\n";
202 if (!
r.readPs(detid,
corr)) {
203 throw cms::Exception(
"LasCor") <<
"Failed to read " <<
toNth(
i + 1) <<
" crystal correction.\n";
206 pair<std::set<int>::iterator,
bool>
res = detidList.insert(
int(detid));
209 std::cout <<
"Duplicate det id, for IOV " << iIov <<
" t1 = " <<
t1 <<
" detid = " <<
int(detid) << endl;
227 <<
"p1 = " <<
corr.p1 <<
"\t"
228 <<
"p2 = " <<
corr.p2 <<
"\t"
229 <<
"p3 = " <<
corr.p3 <<
"\n";
239 cout <<
"First IOV, extending starting time." << endl;
243 gettimeofday(&
t,
nullptr);
246 <<
"Write IOV " << iIov <<
" starting from " <<
timeToString(iovStart >> 32) <<
"... ";
247 db_->
writeOne(corrSet, iovStart,
"EcalLaserAPDPNRatiosRcd");
249 std::cout <<
"Failed.\nException cathed while writting to cond DB" <<
e.what() <<
"\n";
259 cout <<
"No more correction files.\n";
276 if ((f_ ==
nullptr || feof(f_)) && !nextFile()) {
278 cout <<
"No more record\n";
284 while ((
i = fgetc(f_)) !=
'T' &&
i !=
'L' &&
i >= 0)
285 getline(&
buf, &
s, f_);
300 cout <<
"No more record or bad line type/marker (getc returned " <<
i <<
")\n";
305 int n = fscanf(f_,
"%d %d", &
t1, &
t3);
307 int nn = fscanf(f_,
"%d", &
t2[
i]);
313 int nnn = fscanf(f_,
" ");
317 <<
": syntax error. Expecting 'T' marker followed by 94 values: "
326 cout <<
"Requested to read p1..p3 parameter line while no file is closed.\n";
335 cout <<
"File " <<
fnames_[ifile_] <<
" line " << iline_ <<
": unexpected line type, '" << (char)
i
336 <<
"' while expecting 'P'\n";
338 cout <<
"Failed to read p1..p3 parameter line\n";
343 int n = fscanf(f_,
"%d %f %f %f\n", &rawdetid, &
corr.p1, &
corr.p2, &
corr.p3);
349 throw cms::Exception(
"I/O") <<
"Syntax error at line " << iline_ <<
"of file " <<
fnames_[ifile_] <<
" read " <<
n
351 <<
" raw id" << rawdetid <<
": " <<
corr.p1 <<
", " <<
corr.p2;
354 constexpr
int ECALID = 3;
355 if (detid.
det() != ECALID)
357 <<
" contains an invalid det ID (detector code is not ECAL!)\n";
362 <<
" contains an invalid det ID (detector code is not ECAL!)\n";
368 <<
" contains an invalid det ID (detector code is not ECAL!)\n";
377 bool skipLine =
false;
379 while ((
c = fgetc(f_)) >= 0 && (
c ==
' ' ||
c ==
'\t' ||
c ==
'\n' ||
c ==
'#' || skipLine)) {
393 if (
n % 100 < 10 ||
n % 100 > 20) {
416 localtime_r(&
t, <);
417 strftime(
buf,
sizeof(
buf),
"%F %R:%S", <);
432 throw cms::Exception(
"LasCor") <<
"Unexpected number time parameter triplets\n";
434 if (
fout_ ==
nullptr) {
435 fout_ = fopen(
"corr_dump.txt",
"w");
436 if (
fout_ ==
nullptr)
437 throw cms::Exception(
"LasCor") <<
"Failed to create file corr_dump.txt\n";
440 unsigned t1 =
t[0].t1.unixTime();
441 unsigned t3 =
t[0].t3.unixTime();
447 for (
unsigned i = 0;
i <
t.size(); ++
i) {
448 if (
t[
i].
t1.unixTime() !=
t1 ||
t[
i].t3.unixTime() !=
t3) {
450 <<
"t1(lme 1) =" <<
t1 <<
", t1(lme " << (
i + 1) <<
") = " <<
t[
i].
t1.unixTime()
451 <<
", t3(lme 1) =" <<
t3 <<
", t3(lme " << (
i + 1) <<
") = " <<
t[
i].
t3.unixTime()
454 fprintf(
fout_,
"\t%d",
t[
i].
t2.unixTime());
471 for (
int iZ = 1; iZ >= -1; --iZ) {
int hashedIndex() const
get a compact index for arrays
T const * product() const
cond::Time_t beginOfTime() const
constexpr Detector det() const
get the detector field from this detid
static const int MAX_IPHI
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum)
unsigned long long Time_t
void setValue(uint32_t rawId, const EcalLaserAPDPNpair &value)
std::vector< EcalLaserTimeStamp > EcalLaserTimeStampMap
static bool validDetId(int i, int j)
check if a valid index combination
Hash writeOne(const T *payload, Time_t time, const std::string &recordName)
int ietaAbs() const
get the absolute value of the crystal ieta
bool isNewTagRequest(const std::string &recordName)
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
unsigned long long uint64_t
int iphi() const
get the crystal iphi
void setTime(int hashedIndex, const EcalLaserTimeStamp &value)
static void trim(std::string &s)
static const int MAX_IETA
static const int MIN_IPHI