18 std::istringstream
iss;
21 gzf = gzopen(file,
"rb");
24 edm::LogWarning(
"EcalTPG") <<
"Database file " << file <<
" not found!!!";
30 eof = (res == Z_NULL);
36 if (found != std::string::npos) {
42 explicit operator bool()
const {
return ((
eof ==
true) ?
false : !
iss.fail()); }
47 while ((
bool)gis && !(gis.
iss >> var)) {
58 : dbFilename_(iConfig.getUntrackedParameter<std::
string>(
"DatabaseFile",
"")),
59 flagPrint_(iConfig.getParameter<bool>(
"WriteInFile")) {
83 tpMode_ = std::vector<uint32_t>(18, 0);
95 auto prod = std::make_unique<EcalTPGPedestals>();
97 std::map<uint32_t, std::vector<uint32_t>>::const_iterator it;
101 item.
mean_x6 = (it->second)[3];
102 item.
mean_x1 = (it->second)[6];
103 prod->setValue(it->first, item);
110 auto prod = std::make_unique<EcalTPGLinearizationConst>();
112 std::map<uint32_t, std::vector<uint32_t>>::const_iterator it;
116 item.
mult_x6 = (it->second)[4];
117 item.
mult_x1 = (it->second)[7];
121 prod->setValue(it->first, item);
128 auto prod = std::make_unique<EcalTPGSlidingWindow>();
130 for (
int subdet = 0; subdet < 2; subdet++) {
131 std::map<uint32_t, std::vector<uint32_t>>::const_iterator it;
133 prod->setValue(it->first, (it->second)[0]);
141 auto prod = std::make_unique<EcalTPGFineGrainEBIdMap>();
144 std::map<uint32_t, std::vector<uint32_t>>::const_iterator it;
146 fg.
setValues((it->second)[0], (it->second)[1], (it->second)[2], (it->second)[3], (it->second)[4]);
147 prod->setValue(it->first, fg);
154 auto prod = std::make_unique<EcalTPGFineGrainStripEE>();
157 std::map<uint32_t, std::vector<uint32_t>>::const_iterator it;
161 item.
lut = (it->second)[4];
162 prod->setValue(it->first, item);
168 item.
lut = (it->second)[4];
169 prod->setValue(it->first, item);
176 auto prod = std::make_unique<EcalTPGFineGrainTowerEE>();
178 std::map<uint32_t, std::vector<uint32_t>>::const_iterator it;
180 prod->setValue(it->first, (it->second)[1]);
186 auto prod = std::make_unique<EcalTPGLutIdMap>();
189 std::map<uint32_t, std::vector<uint32_t>>::const_iterator it;
191 unsigned int lutArray[1024];
192 for (
int i = 0;
i < 1024;
i++)
193 lutArray[
i] = (it->second)[
i];
195 prod->setValue(it->first, lut);
201 auto prod = std::make_unique<EcalTPGWeightIdMap>();
204 std::map<uint32_t, std::vector<uint32_t>>::const_iterator it;
206 weights.
setValues((it->second)[0], (it->second)[1], (it->second)[2], (it->second)[3], (it->second)[4]);
207 prod->setValue(it->first, weights);
213 auto prod = std::make_unique<EcalTPGWeightGroup>();
215 for (
int subdet = 0; subdet < 2; subdet++) {
216 std::map<uint32_t, std::vector<uint32_t>>::const_iterator it;
218 prod->setValue(it->first, (it->second)[1]);
226 auto prod = std::make_unique<EcalTPGOddWeightIdMap>();
229 std::map<uint32_t, std::vector<uint32_t>>::const_iterator it;
231 weights.
setValues((it->second)[0], (it->second)[1], (it->second)[2], (it->second)[3], (it->second)[4]);
232 prod->setValue(it->first, weights);
239 auto prod = std::make_unique<EcalTPGOddWeightGroup>();
241 for (
int subdet = 0; subdet < 2; subdet++) {
242 std::map<uint32_t, std::vector<uint32_t>>::const_iterator it;
244 prod->setValue(it->first, (it->second)[2]);
251 auto prod = std::make_unique<EcalTPGTPMode>();
256 prod->EnableEBOddFilter =
tpMode_[0];
257 prod->EnableEEOddFilter =
tpMode_[1];
258 prod->EnableEBOddPeakFinder =
tpMode_[2];
259 prod->EnableEEOddPeakFinder =
tpMode_[3];
260 prod->DisableEBEvenPeakFinder =
tpMode_[4];
261 prod->DisableEEEvenPeakFinder =
tpMode_[5];
262 prod->FenixEBStripOutput =
tpMode_[6];
263 prod->FenixEEStripOutput =
tpMode_[7];
264 prod->FenixEBStripInfobit2 =
tpMode_[8];
265 prod->FenixEEStripInfobit2 =
tpMode_[9];
266 prod->EBFenixTcpOutput =
tpMode_[10];
267 prod->EBFenixTcpInfobit1 =
tpMode_[11];
268 prod->EEFenixTcpOutput =
tpMode_[12];
269 prod->EEFenixTcpInfobit1 =
tpMode_[13];
270 prod->FenixPar15 =
tpMode_[14];
271 prod->FenixPar16 =
tpMode_[15];
272 prod->FenixPar17 =
tpMode_[16];
273 prod->FenixPar18 =
tpMode_[17];
278 auto prod = std::make_unique<EcalTPGLutGroup>();
280 for (
int subdet = 0; subdet < 2; subdet++) {
281 std::map<uint32_t, std::vector<uint32_t>>::const_iterator it;
283 prod->setValue(it->first, (it->second)[0]);
291 auto prod = std::make_unique<EcalTPGFineGrainEBGroup>();
293 std::map<uint32_t, std::vector<uint32_t>>::const_iterator it;
295 prod->setValue(it->first, (it->second)[1]);
301 auto prod = std::make_unique<EcalTPGPhysicsConst>();
303 std::map<uint32_t, std::vector<float>>::const_iterator it;
306 item.
EtSat = (it->second)[0];
313 prod->setValue(it->first, item);
319 auto prod = std::make_unique<EcalTPGCrystalStatus>();
321 std::map<uint32_t, std::vector<uint32_t>>::const_iterator it;
325 prod->setValue(it->first, badXValue);
331 auto prod = std::make_unique<EcalTPGStripStatus>();
337 auto prod = std::make_unique<EcalTPGTowerStatus>();
339 std::map<uint32_t, std::vector<uint32_t>>::const_iterator it;
343 prod->setValue(it->first, 0);
348 prod->setValue(it->first, 0);
355 auto prod = std::make_unique<EcalTPGSpike>();
358 std::map<uint32_t, std::vector<uint32_t>>::const_iterator it;
360 prod->setValue(it->first, (it->second)[2]);
373 std::vector<unsigned int> param;
374 std::vector<float> paramF;
375 int NBstripparams[2] = {5, 5};
387 finalFileName = fileInPath.
fullPath();
390 edm::LogWarning(
"EcalTPG") <<
"Couldnt find database file via fileinpath, "
391 "trying with pathname directly!!";
397 while (gis >> dataCard) {
398 if (dataCard ==
"PHYSICS_EB" || dataCard ==
"PHYSICS_EE") {
410 for (
int i = 0;
i < 7;
i++) {
412 paramF.push_back(dataF);
418 std::ostringstream oss;
428 std::ostringstream oss;
450 if (dataCard ==
"CRYSTAL") {
460 edm::LogVerbatim(
"EcalTrigPrimESProducer") <<
"COMMENT ====== barrel crystals ====== ";
463 edm::LogVerbatim(
"EcalTrigPrimESProducer") <<
"COMMENT ====== endcap crystals ====== ";
471 for (
int i = 0;
i < 9;
i++) {
472 gis >> std::hex >>
data;
474 param.push_back(data);
478 std::ostringstream oss;
479 oss << std::hex <<
data;
487 }
else if (
i > 2 &&
i < 6) {
488 std::ostringstream oss;
489 oss << std::hex <<
data;
496 }
else if (
i > 5 &&
i < 9) {
497 std::ostringstream oss;
498 oss << std::hex <<
data;
520 if (dataCard ==
"STRIP_EB") {
529 for (
int i = 0;
i < NBstripparams[0];
i++) {
530 gis >> std::hex >>
data;
532 param.push_back(data);
537 }
else if (
i >= 1 &&
i < 3) {
540 std::ostringstream oss;
542 oss <<
"0x" << std::hex <<
data;
546 std::ostringstream oss;
547 oss <<
" 0x" << std::hex <<
data;
560 if (dataCard ==
"STRIP_EE") {
570 for (
int i = 0;
i < NBstripparams[1];
i++) {
571 gis >> std::hex >>
data;
572 param.push_back(data);
577 }
else if (
i >= 1 &&
i < 3) {
580 std::ostringstream oss;
582 oss <<
"0x" << std::hex <<
data;
586 std::ostringstream oss;
587 oss <<
" 0x" << std::hex <<
data;
601 if (dataCard ==
"TOWER_EE") {
608 for (
int i = 0;
i < 2;
i++) {
609 gis >> std::hex >>
data;
610 param.push_back(data);
625 if (dataCard ==
"TOWER_EB") {
632 for (
int i = 0;
i < 3;
i++) {
639 param.push_back(data);
646 if (dataCard ==
"WEIGHT") {
647 gis >> std::hex >>
id;
655 for (
int i = 0;
i < 5;
i++) {
656 gis >> std::hex >>
data;
657 param.push_back(data);
660 std::ostringstream oss;
661 oss << std::hex <<
data;
678 if (dataCard ==
"WEIGHT_ODD") {
679 gis >> std::hex >>
id;
687 for (
int i = 0;
i < 5;
i++) {
688 gis >> std::hex >>
data;
689 param.push_back(data);
692 std::ostringstream oss;
693 oss << std::hex <<
data;
710 if (dataCard ==
"FG") {
711 gis >> std::hex >>
id;
717 for (
int i = 0;
i < 5;
i++) {
718 gis >> std::hex >>
data;
719 param.push_back(data);
722 std::ostringstream oss;
723 oss << std::hex <<
data;
741 if (dataCard ==
"LUT") {
742 gis >> std::hex >>
id;
748 for (
int i = 0;
i < 1024;
i++) {
749 gis >> std::hex >>
data;
750 param.push_back(data);
760 if (dataCard ==
"TP_MODE") {
764 for (
int i = 0;
i < 18;
i++) {
766 param.push_back(data);
769 std::ostringstream oss;
789 int subdet,
int tccNb,
int towerNbInTcc,
int stripNbInTower,
int xtalNbInStrip) {
790 std::vector<int>
range;
805 range.push_back(109);
820 range[1] = tccNb + 1;
822 if (towerNbInTcc > 0) {
823 range[2] = towerNbInTcc;
824 range[3] = towerNbInTcc + 1;
826 if (stripNbInTower > 0) {
827 range[4] = stripNbInTower;
828 range[5] = stripNbInTower + 1;
830 if (xtalNbInStrip > 0) {
831 range[6] = xtalNbInStrip;
832 range[7] = xtalNbInStrip + 1;
Log< level::Info, true > LogVerbatim
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
std::vector< int > getRange(int subdet, int smNb, int towerNbInSm, int stripNbInTower=0, int xtalNbInStrip=0)
std::unique_ptr< EcalTPGWeightGroup > produceWeightGroup(const EcalTPGWeightGroupRcd &)
uint16_t *__restrict__ id
std::unique_ptr< EcalTPGCrystalStatus > produceBadX(const EcalTPGCrystalStatusRcd &)
void setValues(const uint32_t &ThresholdETLow, const uint32_t &ThresholdETHigh, const uint32_t &RatioLow, const uint32_t &RatioHigh, const uint32_t &LUT)
std::vector< uint32_t > tpMode_
std::map< uint32_t, std::vector< uint32_t > > mapWeight_odd_
std::unique_ptr< EcalTPGLinearizationConst > produceLinearizationConst(const EcalTPGLinearizationConstRcd &)
std::map< uint32_t, std::vector< uint32_t > > mapTower_[2]
std::unique_ptr< EcalTPGFineGrainEBIdMap > produceFineGrainEB(const EcalTPGFineGrainEBIdMapRcd &)
std::unique_ptr< EcalTPGLutIdMap > produceLUT(const EcalTPGLutIdMapRcd &)
void setLut(const unsigned int *lut)
const uint16_t range(const Frame &aFrame)
std::unique_ptr< EcalTPGTowerStatus > produceBadTT(const EcalTPGTowerStatusRcd &)
std::unique_ptr< EcalTPGPedestals > producePedestals(const EcalTPGPedestalsRcd &)
std::unique_ptr< EcalTPGPhysicsConst > producePhysicsConst(const EcalTPGPhysicsConstRcd &)
void setStatusCode(const uint16_t &val)
std::unique_ptr< EcalTPGOddWeightGroup > produceOddWeightGroup(const EcalTPGOddWeightGroupRcd &)
std::map< uint32_t, std::vector< uint32_t > > mapXtal_
list var
if using global norm cols_to_minmax = ['t_delta', 't_hmaxNearP','t_emaxNearP', 't_hAnnular', 't_eAnnular','t_pt','t_nVtx','t_ieta','t_eHcal10', 't_eHcal30','t_rhoh','t_eHcal'] df[cols_to_minmax] = df[cols_to_minmax].apply(lambda x: (x - x.min()) / (x.max() - x.min()) if (x.max() - x.min() > 0) else 1.0/200.0)
std::unique_ptr< EcalTPGTPMode > produceTPMode(const EcalTPGTPModeRcd &)
std::unique_ptr< EcalTPGFineGrainTowerEE > produceFineGrainEEtower(const EcalTPGFineGrainTowerEERcd &)
std::unique_ptr< EcalTPGSpike > produceSpike(const EcalTPGSpikeRcd &)
std::map< uint32_t, std::vector< uint32_t > > mapWeight_
std::unique_ptr< EcalTPGSlidingWindow > produceSlidingWindow(const EcalTPGSlidingWindowRcd &)
std::unique_ptr< EcalTPGOddWeightIdMap > produceOddWeight(const EcalTPGOddWeightIdMapRcd &)
~EcalTrigPrimESProducer() override
std::unique_ptr< EcalTPGFineGrainEBGroup > produceFineGrainEBGroup(const EcalTPGFineGrainEBGroupRcd &)
EcalTrigPrimESProducer(const edm::ParameterSet &)
std::unique_ptr< EcalTPGLutGroup > produceLutGroup(const EcalTPGLutGroupRcd &)
std::map< uint32_t, std::vector< uint32_t > > mapFg_
double ttf_threshold_High
std::istream & operator>>(std::istream &input, CLHEP::HepGenMatrix &matrix)
std::map< uint32_t, std::vector< float > > mapPhys_
char data[epos_bytes_allocation]
std::string fullPath() const
std::unique_ptr< EcalTPGFineGrainStripEE > produceFineGrainEEstrip(const EcalTPGFineGrainStripEERcd &)
Log< level::Warning, false > LogWarning
std::unique_ptr< EcalTPGWeightIdMap > produceWeight(const EcalTPGWeightIdMapRcd &)
std::unique_ptr< EcalTPGStripStatus > produceBadStrip(const EcalTPGStripStatusRcd &)
void setValues(const uint32_t &w0, const uint32_t &w1, const uint32_t &w2, const uint32_t &w3, const uint32_t &w4)
std::map< uint32_t, std::vector< uint32_t > > mapLut_
std::map< uint32_t, std::vector< uint32_t > > mapStrip_[2]