25 : m_timetype(iConfig.getParameter<std::
string>(
"timetype")), m_cacheIDs(), m_records() {
34 typedef std::vector<edm::ParameterSet>
Parameters;
36 for (Parameters::iterator
i = toCopy.begin();
i != toCopy.end(); ++
i) {
39 m_cacheIDs.insert(std::make_pair(container, 0));
40 m_records.insert(std::make_pair(container, record));
54 typedef std::map<std::string, std::string>::const_iterator recordIter;
56 container = (*i).first;
64 unsigned long nstart = 0;
71 for (
unsigned long i = nstart;
i < nrec;
i++) {
80 edm::LogInfo(
"EcalTestDevDB") <<
"Starting Transaction for run " << irun <<
"...";
82 if (container ==
"EcalPedestals") {
94 }
else if (container ==
"EcalADCToGeVConstant") {
106 }
else if (container ==
"EcalIntercalibConstants") {
117 }
else if (container ==
"EcalLinearCorrections") {
129 }
else if (container ==
"EcalGainRatios") {
141 }
else if (container ==
"EcalWeightXtalGroups") {
153 }
else if (container ==
"EcalTBWeights") {
165 }
else if (container ==
"EcalLaserAPDPNRatios") {
176 }
else if (container ==
"EcalLaserAPDPNRatiosRef") {
187 }
else if (container ==
"EcalLaserAlphas") {
199 edm::LogWarning(
"EcalTestDevDB") <<
"it does not work yet for " << container <<
"...";
209 auto peds = std::make_shared<EcalPedestals>();
215 item.mean_x1 = 200. * ((double)std::rand() / (double(RAND_MAX) + double(1)));
216 item.rms_x1 = (double)std::rand() / (double(RAND_MAX) + double(1));
217 item.mean_x6 = 1200. * ((double)std::rand() / (double(RAND_MAX) + double(1)));
218 item.rms_x6 = 6. * ((double)std::rand() / (double(RAND_MAX) + double(1)));
219 item.mean_x12 = 2400. * ((double)std::rand() / (double(RAND_MAX) + double(1)));
220 item.rms_x12 = 12. * ((double)std::rand() / (double(RAND_MAX) + double(1)));
223 peds->insert(std::make_pair(ebdetid.
rawId(),
item));
233 double r = (double)std::rand() / (double(RAND_MAX) + double(1));
234 auto agc = std::make_shared<EcalADCToGeVConstant>(36. + r * 4., 60. + r * 4);
242 auto ical = std::make_shared<EcalIntercalibConstants>();
250 double r = (double)std::rand() / (double(RAND_MAX) + double(1));
251 ical->setValue(ebid.
rawId(), 0.85 + r * 0.3);
261 auto ical = std::make_shared<EcalLinearCorrections>();
274 ical->setValue(ebid, pairAPDPN);
290 ical->setValue(eedetidpos, pairAPDPN);
294 EEDetId eedetidneg(iX, iY, -1);
301 ical->setValue(eedetidneg, pairAPDPN);
307 for (
int i = 0;
i < 92;
i++) {
312 ical->setTime(
i, TimeStamp);
323 auto gratio = std::make_shared<EcalGainRatios>();
331 double r = (double)std::rand() / (double(RAND_MAX) + double(1));
337 gratio->setValue(ebid.
rawId(), gr);
348 auto xtalGroups = std::make_shared<EcalWeightXtalGroups>();
364 auto tbwgt = std::make_shared<EcalTBWeights>();
371 for (
int itdc = 1; itdc <= nMaxTDC; ++itdc) {
373 double r = (double)std::rand() / (double(RAND_MAX) + double(1));
380 for (
size_t i = 0;
i < 3; ++
i) {
381 for (
size_t j = 0;
j < 10; ++
j) {
382 double ww = igrp * itdc * r +
i * 10. +
j;
384 mat2(
i,
j) = 100 + ww;
389 r = (double)std::rand() / (double(RAND_MAX) + double(1));
392 for (
size_t i = 0;
i < 10; ++
i) {
393 for (
size_t j = 0;
j < 10; ++
j) {
394 double ww = igrp * itdc * r +
i * 10. +
j;
395 mat3(
i,
j) = 1000 + ww;
396 mat4(
i,
j) = 1000 + 100 + ww;
401 tbwgt->setValue(std::make_pair(igrp, itdc), wgt);
411 auto laser = std::make_shared<EcalLaserAPDPNRatios>();
419 if (
m_firstRun == i_run && (i_run == 0 || i_run == 1)) {
420 APDPNpair.p1 = (double(1) + 1 / double(
log(
exp(1) +
double((i_run -
m_firstRun) * 10)))) /
double(2);
421 APDPNpair.p2 = (double(1) + 1 / double(
log(
exp(1) +
double((i_run -
m_firstRun) * 10) +
double(10)))) /
double(2);
422 APDPNpair.p3 = double(0);
423 edm::LogInfo(
"EcalTestDevDB") << i_run <<
" " <<
m_firstRun <<
" " << APDPNpair.p1 <<
" " << APDPNpair.p2;
435 if (hi < static_cast<int>(
laser->getLaserMap().size())) {
436 laser->setValue(hi, APDPNpair);
438 edm::LogError(
"EcalTestDevDB") <<
"error with laser Map (ratio)!";
456 if (hi < static_cast<int>(
laser->getLaserMap().size())) {
457 laser->setValue(hi, APDPNpair);
459 edm::LogError(
"EcalTestDevDB") <<
"error with laser Map (ratio)!";
466 EEDetId eedetidneg(iX, iY, -1);
470 if (hi < static_cast<int>(
laser->getLaserMap().size())) {
471 laser->setValue(hi, APDPNpair);
473 edm::LogError(
"EcalTestDevDB") <<
"error with laser Map (ratio)!";
479 for (
int i = 0;
i < 92;
i++) {
480 if (
i < static_cast<int>(
laser->getTimeMap().size())) {
483 laser->setTime(
i, TimeStamp);
485 edm::LogError(
"EcalTestDevDB") <<
"error with laser Map (time)!";
491 APDPNpair.p1 = (double(1) + 1 / double(
log(
exp(1) +
double((i_run -
m_firstRun) * 10)))) /
double(2);
492 APDPNpair.p2 = (double(1) + 1 / double(
log(
exp(1) +
double((i_run -
m_firstRun) * 10) +
double(10)))) /
double(2);
493 APDPNpair.p3 = double(0);
494 edm::LogInfo(
"EcalTestDevDB") << i_run <<
" " <<
m_firstRun <<
" " << APDPNpair.p1 <<
" " << APDPNpair.p2;
503 if (hi < static_cast<int>(
laser->getLaserMap().size())) {
504 laser->setValue(hi, APDPNpair);
506 edm::LogError(
"EcalTestDevDB") <<
"error with laser Map (ratio)!";
519 if (hi < static_cast<int>(
laser->getLaserMap().size())) {
520 laser->setValue(hi, APDPNpair);
522 edm::LogError(
"EcalTestDevDB") <<
"error with laser Map (ratio)!";
529 EEDetId eedetidneg(iX, iY, -1);
531 if (hi < static_cast<int>(
laser->getLaserMap().size())) {
532 laser->setValue(hi, APDPNpair);
534 edm::LogError(
"EcalTestDevDB") <<
"error with laser Map (ratio)!";
540 for (
int i = 0;
i < 92;
i++) {
541 if (
i < static_cast<int>(
laser->getTimeMap().size())) {
544 laser->setTime(
i, TimeStamp);
546 edm::LogError(
"EcalTestDevDB") <<
"error with laser Map (time)!";
559 auto laser = std::make_shared<EcalLaserAPDPNRatiosRef>();
567 APDPNref = double(1.5);
571 if (hi < static_cast<int>(
laser->getMap().size())) {
572 laser->setValue(hi, APDPNref);
574 edm::LogError(
"EcalTestDevDB") <<
"error with laser Map (ref)!";
585 APDPNref = double(1.5);
588 if (hi < static_cast<int>(
laser->getMap().size())) {
589 laser->setValue(hi, APDPNref);
591 edm::LogError(
"EcalTestDevDB") <<
"error with laser Map (ref)!";
597 EEDetId eedetidneg(iX, iY, -1);
598 APDPNref = double(1.5);
601 if (hi < static_cast<int>(
laser->getMap().size())) {
602 laser->setValue(hi, APDPNref);
604 edm::LogError(
"EcalTestDevDB") <<
"error with laser Map (ref)!";
616 auto laser = std::make_shared<EcalLaserAlphas>();
624 Alpha = double(1.55);
628 if (hi < static_cast<int>(
laser->getMap().size())) {
629 laser->setValue(hi, Alpha);
631 edm::LogError(
"EcalTestDevDB") <<
"error with laser Map (alpha)!";
642 Alpha = double(1.55);
645 if (hi < static_cast<int>(
laser->getMap().size())) {
646 laser->setValue(hi, Alpha);
648 edm::LogError(
"EcalTestDevDB") <<
"error with laser Map (alpha)!";
653 EEDetId eedetidneg(iX, iY, -1);
654 Alpha = double(1.55);
657 if (hi < static_cast<int>(
laser->getMap().size())) {
658 laser->setValue(hi, Alpha);
660 edm::LogError(
"EcalTestDevDB") <<
"error with laser Map (alpha)!";
EcalChi2WeightMatrix & getChi2WeightsBeforeGainSwitch()
std::shared_ptr< EcalLaserAPDPNRatiosRef > generateEcalLaserAPDPNRatiosRef()
int hashedIndex() const
get a compact index for arrays
static const int MIN_IPHI
static Timestamp endOfTime()
static std::vector< std::string > checklist log
std::shared_ptr< EcalLinearCorrections > generateEcalLinearCorrections()
const EventID & eventID() const
static const int MAX_HASH
static const IOVSyncValue & endOfTime()
constexpr uint32_t rawId() const
get the raw id
std::shared_ptr< EcalLaserAlphas > generateEcalLaserAlphas()
std::map< std::string, std::string > m_records
math::Matrix< 10, 10 >::type EcalChi2WeightMatrix
math::Matrix< 3, 10 >::type EcalWeightMatrix
Exp< T >::type exp(const T &t)
std::shared_ptr< EcalLaserAPDPNRatios > generateEcalLaserAPDPNRatios(uint32_t i_run)
std::shared_ptr< EcalTBWeights > generateEcalTBWeights()
Log< level::Error, false > LogError
void createOneIOV(const T &payload, cond::Time_t firstSinceTime, const std::string &recordName)
static bool validDetId(int i, int j)
check if a valid index combination
void setGain12Over6(const float &g)
void appendOneIOV(const T &payload, cond::Time_t sinceTime, const std::string &recordName)
std::shared_ptr< EcalGainRatios > generateEcalGainRatios()
EcalTestDevDB(const edm::ParameterSet &iConfig)
vector< ParameterSet > Parameters
bool isNewTagRequest(const std::string &recordName)
std::shared_ptr< EcalPedestals > generateEcalPedestals()
~EcalTestDevDB() override
cond::Time_t beginOfTime() const
EcalChi2WeightMatrix & getChi2WeightsAfterGainSwitch()
EcalWeightMatrix & getWeightsAfterGainSwitch()
std::shared_ptr< EcalIntercalibConstants > generateEcalIntercalibConstants()
void analyze(const edm::Event &evt, const edm::EventSetup &evtSetup) override
Log< level::Info, false > LogInfo
static const int MAX_IPHI
EcalWeightMatrix & getWeightsBeforeGainSwitch()
static bool validDetId(int crystal_ix, int crystal_iy, int iz)
T getParameter(std::string const &) const
static const int MAX_IETA
std::shared_ptr< EcalADCToGeVConstant > generateEcalADCToGeVConstant()
std::map< std::string, unsigned long long > m_cacheIDs
std::shared_ptr< EcalWeightXtalGroups > generateEcalWeightXtalGroups()
Log< level::Warning, false > LogWarning
void setGain6Over1(const float &g)