52 double resolEt_overEt =
53 sqrt((par[0] /
sqrt(Et)) * (par[0] /
sqrt(Et)) + (par[1] / Et) * (par[1] / Et) + par[2] * par[2]);
54 return 1. / (Et * resolEt_overEt);
58 : xtal_LSB_EB_(0), xtal_LSB_EE_(0), nSample_(5), complement2_(7), useDBShape_(
true) {
111 if (m_write_ped != 0 && m_write_ped != 1)
115 edm::LogInfo(
"TopInfo") <<
"data will be saved with tag and version=" << tag_ <<
".version" << version_ <<
"\n";
169 useTransparencyCorr_ = pSet.
getParameter<
bool>(
"useTransparencyCorr");
175 if (SFGVB_SpikeKillingThreshold_ == -1 || (SFGVB_SpikeKillingThreshold_ > Et_sat_EB_))
176 SFGVB_SpikeKillingThreshold_ = 1023;
178 SFGVB_SpikeKillingThreshold_ =
int(SFGVB_SpikeKillingThreshold_ * 1024 / Et_sat_EB_);
179 edm::LogInfo(
"TopInfo") <<
"INFO:SPIKE KILLING THRESHOLD (ADC)=" << SFGVB_SpikeKillingThreshold_ <<
"\n";
188 std::ostringstream
ss;
190 ss <<
"INFO: READING timing files\n";
195 std::ifstream delay_ee(TimingDelays_EE_.c_str());
197 edm::LogError(
"TopInfo") <<
"ERROR: File " << TimingDelays_EE_.c_str() <<
" could not be opened" 199 std::ifstream phase_eb(TimingPhases_EB_.c_str());
201 edm::LogError(
"TopInfo") <<
"ERROR: File " << TimingPhases_EB_.c_str() <<
" could not be opened" 203 std::ifstream phase_ee(TimingPhases_EE_.c_str());
205 edm::LogError(
"TopInfo") <<
"ERROR: File " << TimingPhases_EE_.c_str() <<
" could not be opened" 210 delay_eb.getline(buf,
sizeof(buf),
'\n');
212 std::stringstream
sin(buf);
217 vector<int> vec_delays_eb;
218 for (
int ieb = 0; ieb < 68; ++ieb) {
221 vec_delays_eb.push_back(time_delay);
222 if (time_delay == -1)
223 edm::LogError(
"TopInfo") <<
"ERROR:Barrel timing delay -1, check file" 227 if (vec_delays_eb.size() != 68)
228 edm::LogError(
"TopInfo") <<
"ERROR:Barrel timing delay wrong, not enough towers, check file" 232 delays_EB_.insert(make_pair(tcc, vec_delays_eb));
236 for (
unsigned int ieb = 0; ieb < vec_delays_eb.size(); ++ieb)
238 ss <<
" " << vec_delays_eb[ieb];
239 delay_eb.getline(buf,
sizeof(buf),
'\n');
245 phase_eb.getline(buf,
sizeof(buf),
'\n');
247 std::stringstream
sin(buf);
251 vector<int> vec_phases_eb;
252 for (
unsigned int ieb = 0; ieb < 68; ++ieb) {
255 vec_phases_eb.push_back(time_phase);
256 if (time_phase == -1)
257 edm::LogError(
"TopInfo") <<
"ERROR:Barrel timing phase -1, check file" 261 if (vec_phases_eb.size() != 68)
262 edm::LogError(
"TopInfo") <<
"ERROR:Barrel timing phase wrong, not enough towers, check file" 266 phases_EB_.insert(make_pair(tcc, vec_phases_eb));
270 for (
unsigned int ieb = 0; ieb < vec_phases_eb.size(); ++ieb)
272 ss <<
" " << vec_phases_eb[ieb];
273 phase_eb.getline(buf,
sizeof(buf),
'\n');
279 delay_ee.getline(buf,
sizeof(buf),
'\n');
281 std::stringstream
sin(buf);
285 vector<int> vec_delays_ee;
286 for (
unsigned int iee = 0; iee < 48; ++iee) {
289 vec_delays_ee.push_back(time_delay);
290 if (time_delay == -1)
291 edm::LogError(
"TopInfo") <<
"ERROR:EE timing delay -1, check file" 295 if (vec_delays_ee.size() != 48)
296 edm::LogError(
"TopInfo") <<
"ERROR:EE timing delay wrong, not enough towers, check file" 300 delays_EE_.insert(make_pair(tcc, vec_delays_ee));
304 for (
unsigned int iee = 0; iee < vec_delays_ee.size(); ++iee)
306 ss <<
" " << vec_delays_ee[iee];
308 delay_ee.getline(buf,
sizeof(buf),
'\n');
313 phase_ee.getline(buf,
sizeof(buf),
'\n');
315 std::stringstream
sin(buf);
319 vector<int> vec_phases_ee;
320 for (
unsigned int iee = 0; iee < 48; ++iee) {
323 vec_phases_ee.push_back(time_phase);
324 if (time_phase == -1)
325 edm::LogError(
"TopInfo") <<
"ERROR:EE timing phase -1, check file" 329 if (vec_phases_ee.size() != 48)
330 edm::LogError(
"TopInfo") <<
"ERROR:EE timing phase wrong, not enough towers, check file" 334 phases_EE_.insert(make_pair(tcc, vec_phases_ee));
337 for (
unsigned int iee = 0; iee < vec_phases_ee.size(); ++iee)
339 ss <<
" " << vec_phases_ee[iee];
341 phase_ee.getline(buf,
sizeof(buf),
'\n');
346 ss <<
"INFO: DONE reading timing files for EB and EE\n";
352 (*out_file_) <<
"EOF" << std::endl;
376 int etaSlice = (towerInTCC - 1) / 4 + 1;
378 if (tccId > 36 || tccId < 73)
382 if (tccId >= 1 && tccId <= 18)
384 if (tccId >= 19 && tccId <= 36)
386 if (tccId >= 91 && tccId <= 108)
388 if (tccId >= 73 && tccId <= 90)
414 std::ostringstream
ss;
415 ss <<
"EcalLaserDbAnalyzer::analyze\n";
418 ss <<
"EcalLaserDbAnalyzer::analyze-> got EcalLaserDbRecord: \n";
426 for (italpha = laserAlphaMap.
barrelItems().begin(); italpha != laserAlphaMap.
barrelItems().end(); ++italpha) {
427 if (cnt % 1000 == 0) {
429 ss <<
" Barrel ALPHA = " << (*italpha) <<
" cmsswId " << ebdetid.
rawId() <<
"\n";
433 ss <<
"Number of barrel Alpha parameters : " << cnt <<
"\n";
436 for (italpha = laserAlphaMap.
endcapItems().begin(); italpha != laserAlphaMap.
endcapItems().end(); ++italpha) {
437 if (cnt % 1000 == 0) {
439 ss <<
"EndCap ALPHA = " << (*italpha) <<
" cmsswId " << eedetid.
rawId() <<
"\n";
443 ss <<
"Number of Endcap Alpha parameters : " << cnt <<
"\n";
452 edm::LogInfo(
"TopInfo") <<
"INFO: READING transparency correction files" 454 ss <<
"INFO: READING transparency correction files\n";
461 transparency.getline(buf,
sizeof(buf),
'\n');
463 while (transparency) {
464 std::stringstream
sin(buf);
469 double xtal_trans_corr;
470 sin >> xtal_trans_corr;
473 ss << raw_xtal_id <<
" " << xtal_trans_corr <<
"\n";
478 transparency.getline(buf,
sizeof(buf),
'\n');
480 transparency.close();
481 ss <<
"INFO: DONE transparency correction files " << xtalcounter <<
"\n";
486 edm::LogInfo(
"TopInfo") <<
"INFO: READING transparency correction tag" 496 for (
int ib = 0;
ib < 61200;
ib++) {
503 for (
int ie = 0; ie < 14648; ie++) {
509 ss <<
"INFO: DONE transparency correction tag\n";
516 TFile saving(
"EcalTPGParam.root",
"recreate");
518 TH2F* ICEB =
new TH2F(
"ICEB",
"IC: Barrel", 360, 1, 361, 172, -86, 86);
519 ICEB->GetYaxis()->SetTitle(
"eta index");
520 ICEB->GetXaxis()->SetTitle(
"phi index");
521 TH2F* tpgFactorEB =
new TH2F(
"tpgFactorEB",
"tpgFactor: Barrel", 360, 1, 361, 172, -86, 86);
522 tpgFactorEB->GetYaxis()->SetTitle(
"eta index");
523 tpgFactorEB->GetXaxis()->SetTitle(
"phi index");
525 TH2F* ICEEPlus =
new TH2F(
"ICEEPlus",
"IC: Plus Endcap", 120, -9, 111, 120, -9, 111);
526 ICEEPlus->GetYaxis()->SetTitle(
"y index");
527 ICEEPlus->GetXaxis()->SetTitle(
"x index");
528 TH2F* tpgFactorEEPlus =
new TH2F(
"tpgFactorEEPlus",
"tpgFactor: Plus Endcap", 120, -9, 111, 120, -9, 111);
529 tpgFactorEEPlus->GetYaxis()->SetTitle(
"y index");
530 tpgFactorEEPlus->GetXaxis()->SetTitle(
"x index");
531 TH2F* ICEEMinus =
new TH2F(
"ICEEMinus",
"IC: Minus Endcap", 120, -9, 111, 120, -9, 111);
532 ICEEMinus->GetYaxis()->SetTitle(
"y index");
533 ICEEMinus->GetXaxis()->SetTitle(
"x index");
534 TH2F* tpgFactorEEMinus =
new TH2F(
"tpgFactorEEMinus",
"tpgFactor: Minus Endcap", 120, -9, 111, 120, -9, 111);
535 tpgFactorEEMinus->GetYaxis()->SetTitle(
"y index");
536 tpgFactorEEMinus->GetXaxis()->SetTitle(
"x index");
538 TH2F* IC =
new TH2F(
"IC",
"IC", 720, -acos(-1.), acos(-1.), 600, -3., 3.);
539 IC->GetYaxis()->SetTitle(
"eta");
540 IC->GetXaxis()->SetTitle(
"phi");
541 TH2F* tpgFactor =
new TH2F(
"tpgFactor",
"tpgFactor", 720, -acos(-1.), acos(-1.), 600, -3., 3.);
542 tpgFactor->GetYaxis()->SetTitle(
"eta");
543 tpgFactor->GetXaxis()->SetTitle(
"phi");
545 TH1F* hshapeEB =
new TH1F(
"shapeEB",
"shapeEB", 250, 0., 10.);
546 TH1F* hshapeEE =
new TH1F(
"shapeEE",
"shapeEE", 250, 0., 10.);
548 TTree*
ntuple =
new TTree(
"tpgmap",
"TPG geometry map");
550 "fed",
"tcc",
"tower",
"stripInTower",
"xtalInStrip",
"CCU",
"VFE",
"xtalInVFE",
"xtalInCCU",
551 "ieta",
"iphi",
"ix",
"iy",
"iz",
"hashedId",
"ic",
"cmsswId",
"dbId",
552 "ietaTT",
"iphiTT",
"TCCch",
"TCCslot",
"SLBch",
"SLBslot",
"ietaGCT",
"iphiGCT"};
554 for (
int i = 0;
i < 26;
i++)
555 ntuple->Branch(branchFloat[
i].c_str(), &
ntupleInts_[
i], (branchFloat[
i] +
string(
"/I")).c_str());
559 TNtuple* ntupleSpike =
new TNtuple(
"spikeParam",
"Spike parameters",
"gainId:theta:G:g:ped:pedLin");
564 list<uint32_t> towerListEB;
565 list<uint32_t> stripListEB;
566 list<uint32_t> towerListEE;
567 list<uint32_t> stripListEE;
568 list<uint32_t>::iterator itList;
570 map<int, uint32_t> stripMapEB;
571 map<uint32_t, uint32_t> stripMapEBsintheta;
578 ss <<
"Getting the pedestals from offline DB...\n";
586 for (pedIter = pedMap.
begin(); pedIter != pedMap.
end() && nPed < 10; ++pedIter, nPed++) {
591 ss <<
"Getting the pedestals from previous configuration\n";
597 ss <<
"trying to read previous tag if it exists tag=" <<
tag_ <<
".version" <<
version_ <<
"\n";
605 std::map<EcalLogicID, FEConfigPedDat> dataset_TpgPed;
608 typedef std::map<EcalLogicID, FEConfigPedDat>::const_iterator CIfeped;
612 for (CIfeped
p = dataset_TpgPed.begin();
p != dataset_TpgPed.end();
p++) {
619 if (ecid_name ==
"EB_crystal_number") {
620 int sm_num = ecid_xt.
getID1();
621 int xt_num = ecid_xt.
getID2();
633 ss <<
" copy the EB data " 634 <<
" ped = " << item.
mean_x12 <<
"\n";
639 }
else if (ecid_name ==
"EE_crystal_number") {
662 for (pedIter = pedMap.
begin(); pedIter != pedMap.
end() && nPed < 10; ++pedIter, nPed++) {
668 ss <<
"Getting the pedestals from configuration number" <<
m_write_ped <<
"\n";
673 fe_ped_info.
setId(m_write_ped);
675 std::map<EcalLogicID, FEConfigPedDat> dataset_TpgPed;
678 typedef std::map<EcalLogicID, FEConfigPedDat>::const_iterator CIfeped;
682 for (CIfeped
p = dataset_TpgPed.begin();
p != dataset_TpgPed.end();
p++) {
689 if (ecid_name ==
"EB_crystal_number") {
692 <<
" icells = " << icells <<
"\n";
693 int sm_num = ecid_xt.
getID1();
694 int xt_num = ecid_xt.
getID2();
707 }
else if (ecid_name ==
"EE_crystal_number") {
730 for (pedIter = pedMap.
begin(); pedIter != pedMap.
end() && nPed < 10; ++pedIter, nPed++) {
740 ss <<
"Getting intercalib from offline DB...\n";
747 for (calIter = calibMap.
begin(); calIter != calibMap.
end() && nCal < 10; ++calIter, nCal++) {
748 ss << (*calIter) <<
"\n";
752 float calibvec[1700];
754 edm::LogInfo(
"TopInfo") <<
"H2: overwriting IC coef with file" 760 if (calibfile.is_open()) {
761 calibfile >> strdata >> strdata >> strdata >> strdata >> strdata;
762 while (!calibfile.eof()) {
763 calibfile >> idata >> icry >> fcali >> fdata >> fdata;
764 calibvec[icry - 1] = fcali;
765 if (calibfile.eof()) {
773 ss <<
"Getting the gain ratios from offline DB...\n";
779 for (gainIter = gainMap.
begin(); gainIter != gainMap.
end() && nGain < 10; ++gainIter, nGain++) {
787 ss <<
"Getting the ADC to GeV from offline DB...\n";
796 vector<EcalLogicID> my_EcalLogicId;
797 vector<EcalLogicID> my_TTEcalLogicId;
798 vector<EcalLogicID> my_StripEcalLogicId;
802 vector<EcalLogicID> my_TTEcalLogicId_EE;
803 vector<EcalLogicID> my_RTEcalLogicId_EE;
804 vector<EcalLogicID> my_StripEcalLogicId1_EE;
805 vector<EcalLogicID> my_StripEcalLogicId2_EE;
806 vector<EcalLogicID> my_CrystalEcalLogicId_EE;
807 vector<EcalLogicID> my_TTEcalLogicId_EB_by_TCC;
808 vector<EcalLogicID> my_StripEcalLogicId_EE_strips_by_TCC;
817 "EB_VFE", 1, 36, 1, 68, 1, 5,
"EB_VFE", 123);
818 ss <<
"got the 3 ecal barrel logic id set\n";
821 my_CrystalEcalLogicId_EE =
826 my_StripEcalLogicId1_EE =
830 my_StripEcalLogicId2_EE =
835 my_StripEcalLogicId_EE_strips_by_TCC =
857 ss <<
"Getting the latest ids for this tag (latest version) " 863 ss <<
"trying to read previous tag if it exists tag=" <<
tag_ <<
".version" <<
version_ <<
"\n";
889 map<EcalLogicID, FEConfigPedDat> pedset;
890 map<EcalLogicID, FEConfigLinDat> linset;
891 map<EcalLogicID, FEConfigLinParamDat> linparamset;
892 map<EcalLogicID, FEConfigLUTParamDat> lutparamset;
893 map<EcalLogicID, FEConfigFgrParamDat> fgrparamset;
895 map<int, linStruc> linEtaSlice;
899 int NbOfStripPerTCC[108][68];
900 for (
int i = 0;
i < 108;
i++)
901 for (
int j = 0;
j < 68;
j++)
902 NbOfStripPerTCC[
i][
j] = 0;
905 for (vector<DetId>::const_iterator it = ebCells.begin(); it != ebCells.end(); ++it) {
912 if (stripInTower > NbOfStripPerTCC[tccNb - 1][towerInTCC - 1])
913 NbOfStripPerTCC[tccNb - 1][towerInTCC - 1] = stripInTower;
915 for (vector<DetId>::const_iterator it = eeCells.begin(); it != eeCells.end(); ++it) {
922 if (stripInTower > NbOfStripPerTCC[tccNb - 1][towerInTCC - 1])
923 NbOfStripPerTCC[tccNb - 1][towerInTCC - 1] = stripInTower;
928 (*out_file_) <<
"COMMENT ====== barrel crystals ====== " << std::endl;
931 for (vector<DetId>::const_iterator it = ebCells.begin(); it != ebCells.end(); ++it) {
946 int xtalInVFE = Id.
xtalId();
947 int xtalWithinCCUid = 5 * (VFEid - 1) + xtalInVFE - 1;
949 (*geomFile_) <<
"dccNb = " << dccNb <<
" tccNb = " << tccNb <<
" towerInTCC = " << towerInTCC
950 <<
" stripInTower = " << stripInTower <<
" xtalInStrip = " << xtalInStrip <<
" CCUid = " << CCUid
951 <<
" VFEid = " << VFEid <<
" xtalInVFE = " << xtalInVFE <<
" xtalWithinCCUid = " << xtalWithinCCUid
952 <<
" ieta = " <<
id.ieta() <<
" iphi = " <<
id.iphi() <<
" xtalhashedId = " <<
id.hashedIndex()
953 <<
" xtalNb = " <<
id.ic() <<
" ietaTT = " << towid.
ieta() <<
" iphiTT = " << towid.
iphi() << endl;
955 int TCCch = towerInTCC;
956 int SLBslot =
int((towerInTCC - 1) / 8.) + 1;
957 int SLBch = (towerInTCC - 1) % 8 + 1;
958 int cmsswId =
id.rawId();
959 int ixtal = (
id.ism() - 1) * 1700 + (
id.ic() - 1);
962 int val[] = {dccNb + 600,
988 for (
int i = 0;
i < 26;
i++)
995 if (tccNb == 37 && stripInTower == 3 && xtalInStrip == 3 && (towerInTCC - 1) % 4 == 0) {
996 int etaSlice = towid.
ietaAbs();
1001 getCoeff(coeff, calibMap, laserAlphaMap,
id.rawId(), str);
1003 getCoeff(coeff, gainMap,
id.rawId());
1004 getCoeff(coeff, pedMap,
id.rawId());
1006 for (
int i = 0;
i < 3;
i++) {
1010 edm::LogError(
"TopInfo") <<
"unable to compute the parameters for SM=" <<
id.ism() <<
" xt=" <<
id.ic() <<
" " 1011 <<
dec <<
id.rawId() <<
"\n";
1023 ss <<
"SM=" <<
id.ism() <<
" xt=" <<
id.ic() <<
" " <<
dec <<
id.rawId() <<
"\n";
1024 linEtaSlice[etaSlice] = lin;
1029 for (vector<DetId>::const_iterator it = ebCells.begin(); it != ebCells.end(); ++it) {
1035 towerListEB.push_back(towid.
rawId());
1037 stripListEB.push_back(elId.
rawId() & 0xfffffff8);
1046 int xtalInVFE = Id.
xtalId();
1047 int xtalWithinCCUid = 5 * (VFEid - 1) + xtalInVFE - 1;
1048 int etaSlice = towid.
ietaAbs();
1051 int hashedStripLogicID = 68 * 5 * (
id.ism() - 1) + 5 * (towerInTCC - 1) + (VFEid - 1);
1052 stripMapEB[hashedStripLogicID] = elId.
rawId() & 0xfffffff8;
1070 (*out_file_) <<
"CRYSTAL " <<
dec <<
id.rawId() << std::endl;
1077 getCoeff(coeff, calibMap, laserAlphaMap,
id.rawId(), str);
1082 getCoeff(coeff, gainMap,
id.rawId());
1083 getCoeff(coeff, pedMap,
id.rawId());
1089 vector<int> xtalCCU;
1090 xtalCCU.push_back(dccNb + 600);
1091 xtalCCU.push_back(CCUid);
1092 xtalCCU.push_back(xtalWithinCCUid);
1093 xtalCCU.push_back(
id.rawId());
1098 map<int, linStruc>::const_iterator itLin = linEtaSlice.find(etaSlice);
1099 if (itLin != linEtaSlice.end()) {
1100 linMap[xtalCCU] = itLin->second;
1102 for (
int i = 0;
i < 3;
i++)
1103 (*
out_file_) << hex <<
" 0x" << itLin->second.pedestal_[
i] <<
" 0x" << itLin->second.mult_[
i] <<
" 0x" 1104 << itLin->second.shift_[
i] << std::endl;
1107 for (
int i = 0;
i < 3;
i++) {
1126 tpgFactorEB->Fill(
id.
iphi(),
id.
ieta(), factor);
1131 ss <<
"current EtaSlice = " << etaSlice <<
" not found in the EtaSlice map" 1136 int forceBase12 = 0;
1137 for (
int i = 0;
i < 3;
i++) {
1141 edm::LogError(
"TopInfo") <<
"unable to compute the parameters for SM=" <<
id.ism() <<
" xt=" <<
id.ic() <<
" " 1142 <<
dec <<
id.rawId() <<
"\n";
1154 double G = mult *
pow(2.0, -(shift + 2));
1155 double g = G /
sin(theta);
1157 base = double(coeff.
pedestals_[
i]) - pedestal_offset_ /
g;
1160 forceBase12 =
int(base);
1181 ss <<
"SM=" <<
id.ism() <<
" xt=" <<
id.ic() <<
" " <<
dec <<
id.rawId() <<
"\n";
1183 for (
int i = 0;
i < 3;
i++) {
1206 tpgFactorEB->Fill(
id.
iphi(),
id.
ieta(), factor);
1212 double g = G /
sin(theta);
1219 ntupleSpike->Fill(val);
1221 linMap[xtalCCU] = lin;
1225 int ixtal = (
id.ism() - 1) * 1700 + (
id.ic() - 1);
1227 pedset[logicId] = pedDB;
1228 linset[logicId] = linDB;
1236 linparamset[my_EcalLogicId_EB] = linparam;
1243 fgrparamset[my_EcalLogicId_EB] = fgrparam;
1249 lutparamset[my_EcalLogicId_EB] = lutparam;
1254 (*out_file_) <<
"COMMENT ====== endcap crystals ====== " << std::endl;
1257 for (vector<DetId>::const_iterator it = eeCells.begin(); it != eeCells.end(); ++it) {
1265 int dccNb = Id.
dccId();
1272 int xtalInVFE = Id.
xtalId();
1273 int xtalWithinCCUid = 5 * (VFEid - 1) + xtalInVFE - 1;
1275 (*geomFile_) <<
"dccNb = " << dccNb <<
" tccNb = " << tccNb <<
" towerInTCC = " << towerInTCC
1276 <<
" stripInTower = " << stripInTower <<
" xtalInStrip = " << xtalInStrip <<
" CCUid = " << CCUid
1277 <<
" VFEid = " << VFEid <<
" xtalInVFE = " << xtalInVFE <<
" xtalWithinCCUid = " << xtalWithinCCUid
1278 <<
" ix = " <<
id.ix() <<
" iy = " <<
id.iy() <<
" xtalhashedId = " <<
id.hashedIndex()
1279 <<
" xtalNb = " <<
id.isc() <<
" ietaTT = " << towid.
ieta() <<
" iphiTT = " << towid.
iphi() << endl;
1281 int TCCch = stripInTower;
1283 if (towerInTCC < 5) {
1285 SLBch = 4 + towerInTCC;
1287 SLBslot =
int((towerInTCC - 5) / 8.) + 2;
1288 SLBch = (towerInTCC - 5) % 8 + 1;
1290 for (
int j = 0;
j < towerInTCC - 1;
j++)
1291 TCCch += NbOfStripPerTCC[tccNb - 1][
j];
1293 int cmsswId =
id.rawId();
1295 int iz =
id.positiveZ();
1298 for (
int k = 0;
k < (
int)my_CrystalEcalLogicId_EE.size();
k++) {
1299 int z = my_CrystalEcalLogicId_EE[
k].getID1();
1300 int x = my_CrystalEcalLogicId_EE[
k].getID2();
1301 int y = my_CrystalEcalLogicId_EE[
k].getID3();
1302 if (
id.ix() == x &&
id.iy() == y && iz == z)
1303 logicId = my_CrystalEcalLogicId_EE[
k];
1307 int val[] = {dccNb + 600,
1333 for (
int i = 0;
i < 26;
i++)
1339 if ((tccNb == 76 || tccNb == 94) && stripInTower == 1 && xtalInStrip == 3 && (towerInTCC - 1) % 4 == 0) {
1340 int etaSlice = towid.
ietaAbs();
1345 getCoeff(coeff, calibMap, laserAlphaMap,
id.rawId(), str);
1347 getCoeff(coeff, gainMap,
id.rawId());
1348 getCoeff(coeff, pedMap,
id.rawId());
1350 for (
int i = 0;
i < 3;
i++) {
1354 edm::LogError(
"TopInfo") <<
"unable to compute the parameters for Quadrant=" <<
id.iquadrant()
1355 <<
" xt=" <<
id.ic() <<
" " <<
dec <<
id.rawId() <<
"\n";
1367 ss <<
"Quadrant=" <<
id.iquadrant() <<
" xt=" <<
id.ic() <<
" " <<
dec <<
id.rawId() <<
"\n";
1369 linEtaSlice[etaSlice] = lin;
1374 for (vector<DetId>::const_iterator it = eeCells.begin(); it != eeCells.end(); ++it) {
1382 towerListEE.push_back(towid.
rawId());
1386 towerListEE.push_back(additionalTower.rawId());
1388 stripListEE.push_back(elId.
rawId() & 0xfffffff8);
1389 int dccNb = Id.
dccId();
1396 int xtalInVFE = Id.
xtalId();
1397 int xtalWithinCCUid = 5 * (VFEid - 1) + xtalInVFE - 1;
1398 int etaSlice = towid.
ietaAbs();
1404 (*out_file_) <<
"CRYSTAL " <<
dec <<
id.rawId() << std::endl;
1406 int iz =
id.positiveZ();
1409 for (
int k = 0;
k < (
int)my_CrystalEcalLogicId_EE.size();
k++) {
1410 int z = my_CrystalEcalLogicId_EE[
k].getID1();
1411 int x = my_CrystalEcalLogicId_EE[
k].getID2();
1412 int y = my_CrystalEcalLogicId_EE[
k].getID3();
1413 if (
id.ix() == x &&
id.iy() == y && iz == z)
1414 logicId = my_CrystalEcalLogicId_EE[
k];
1422 getCoeff(coeff, calibMap, laserAlphaMap,
id.rawId(), str);
1424 getCoeff(coeff, gainMap,
id.rawId());
1425 getCoeff(coeff, pedMap,
id.rawId());
1427 ICEEPlus->Fill(
id.ix(),
id.iy(), coeff.
calibCoeff_);
1429 ICEEMinus->Fill(
id.ix(),
id.iy(), coeff.
calibCoeff_);
1434 vector<int> xtalCCU;
1435 xtalCCU.push_back(dccNb + 600);
1436 xtalCCU.push_back(CCUid);
1437 xtalCCU.push_back(xtalWithinCCUid);
1438 xtalCCU.push_back(
id.rawId());
1443 map<int, linStruc>::const_iterator itLin = linEtaSlice.find(etaSlice);
1444 if (itLin != linEtaSlice.end()) {
1445 linMap[xtalCCU] = itLin->second;
1447 for (
int i = 0;
i < 3;
i++)
1448 (*
out_file_) << hex <<
" 0x" << itLin->second.pedestal_[
i] <<
" 0x" << itLin->second.mult_[
i] <<
" 0x" 1449 << itLin->second.shift_[
i] << std::endl;
1452 for (
int i = 0;
i < 3;
i++) {
1472 tpgFactorEEPlus->Fill(
id.ix(),
id.iy(), factor);
1474 tpgFactorEEMinus->Fill(
id.ix(),
id.iy(), factor);
1479 ss <<
"current EtaSlice = " << etaSlice <<
" not found in the EtaSlice map" 1484 for (
int i = 0;
i < 3;
i++) {
1488 edm::LogError(
"TopInfo") <<
"unable to compute the parameters for " <<
dec <<
id.rawId() <<
"\n";
1500 ss <<
"Quadrant=" <<
id.iquadrant() <<
" xt=" <<
id.ic() <<
" " <<
dec <<
id.rawId() <<
"\n";
1502 for (
int i = 0;
i < 3;
i++) {
1526 tpgFactorEEPlus->Fill(
id.ix(),
id.iy(), factor);
1528 tpgFactorEEMinus->Fill(
id.ix(),
id.iy(), factor);
1534 linMap[xtalCCU] = lin;
1537 pedset[logicId] = pedDB;
1538 linset[logicId] = linDB;
1548 linparamset[my_EcalLogicId_EE] = linparam;
1554 lutparamset[my_EcalLogicId_EE] = lutparam;
1559 fgrparamset[my_EcalLogicId_EE] = fgrparam;
1567 ss <<
" LIN tag " << lin_tag <<
"\n";
1572 ss <<
"the ped id =" <<
ped_conf_id_ <<
" will be used for the pedestals " 1584 evgueni <<
"void getLinParamTPG_hardcoded(int fed, int ccu, int xtal," << endl;
1585 evgueni <<
" int & mult12, int & shift12, int & base12," << endl;
1586 evgueni <<
" int & mult6, int & shift6, int & base6," << endl;
1587 evgueni <<
" int & mult1, int & shift1, int & base1)" << endl;
1588 evgueni <<
"{" << endl;
1589 evgueni <<
" mult12 = 0 ; shift12 = 0 ; base12 = 0 ; mult6 = 0 ; shift6 = 0 ; base6 = 0 ; mult1 = 0 ; shift1 = 0 ; " 1592 map<vector<int>,
linStruc>::const_iterator itLinMap;
1593 for (itLinMap = linMap.begin(); itLinMap != linMap.end(); itLinMap++) {
1594 vector<int> xtalInCCU = itLinMap->first;
1595 evgueni <<
" if (fed==" << xtalInCCU[0] <<
" && ccu==" << xtalInCCU[1] <<
" && xtal==" << xtalInCCU[2] <<
") {";
1596 evgueni <<
" mult12 = " << itLinMap->second.
mult_[0] <<
" ; shift12 = " << itLinMap->second.shift_[0]
1597 <<
" ; base12 = " << itLinMap->second.pedestal_[0] <<
" ; ";
1598 evgueni <<
" mult6 = " << itLinMap->second.mult_[1] <<
" ; shift6 = " << itLinMap->second.shift_[1]
1599 <<
" ; base6 = " << itLinMap->second.pedestal_[1] <<
" ; ";
1600 evgueni <<
" mult1 = " << itLinMap->second.mult_[2] <<
" ; shift1 = " << itLinMap->second.shift_[2]
1601 <<
" ; base1 = " << itLinMap->second.pedestal_[2] <<
" ; ";
1602 evgueni <<
" return ;}" << endl;
1604 evgueni <<
"}" << endl;
1611 const int NWEIGROUPS = 2;
1612 std::vector<unsigned int>
weights[NWEIGROUPS];
1622 map<EcalLogicID, FEConfigWeightGroupDat>
dataset;
1624 for (
int igrp = 0; igrp < NWEIGROUPS; igrp++) {
1625 if (weights[igrp].
size() == 5) {
1627 (*out_file_) << std::endl;
1628 (*out_file_) <<
"WEIGHT " << igrp << endl;
1631 (*out_file_) << std::endl;
1632 (*out_file_) << std::endl;
1635 ss <<
"going to write the weights for groupe:" << igrp <<
"\n";
1647 dataset[ecid] = gut;
1654 map<EcalLogicID, FEConfigWeightDat> dataset2;
1657 for (
int ich = 0; ich < (
int)my_StripEcalLogicId.size(); ich++) {
1661 dataset2[my_StripEcalLogicId[ich]] = wut;
1665 for (
int ich = 0; ich < (
int)my_StripEcalLogicId1_EE.size(); ich++) {
1670 dataset2[my_StripEcalLogicId1_EE[ich]] = wut;
1673 for (
int ich = 0; ich < (
int)my_StripEcalLogicId2_EE.size(); ich++) {
1678 dataset2[my_StripEcalLogicId2_EE[ich]] = wut;
1684 wtag <<
"Shape_NGroups_" << NWEIGROUPS;
1686 ss <<
" weight tag " << weight_tag <<
"\n";
1698 unsigned int lowRatio, highRatio, lowThreshold, highThreshold, lutFG;
1701 (*out_file_) << std::endl;
1702 (*out_file_) <<
"FG 0" << std::endl;
1703 (*out_file_) << hex <<
"0x" << lowThreshold <<
" 0x" << highThreshold <<
" 0x" << lowRatio <<
" 0x" << highRatio
1704 <<
" 0x" << lutFG << std::endl;
1709 unsigned int lut_strip;
1715 ss <<
"going to write the fgr " 1717 map<EcalLogicID, FEConfigFgrGroupDat>
dataset;
1720 for (
int ich = 0; ich < NFGRGROUPS; ich++) {
1730 dataset[ecid] = gut;
1734 map<EcalLogicID, FEConfigFgrDat> dataset2;
1736 for (
int ich = 0; ich < (
int)my_TTEcalLogicId.size(); ich++) {
1743 dataset2[my_TTEcalLogicId[ich]] = wut;
1747 for (
int ich = 0; ich < (
int)my_RTEcalLogicId_EE.size(); ich++) {
1755 dataset2[my_RTEcalLogicId_EE[ich]] = wut;
1759 map<EcalLogicID, FEConfigFgrEETowerDat> dataset3;
1760 for (
int ich = 0; ich < (
int)my_TTEcalLogicId_EE.size(); ich++) {
1763 dataset3[my_TTEcalLogicId_EE[ich]] = fgreett;
1768 map<EcalLogicID, FEConfigFgrEEStripDat> dataset4;
1769 for (
int ich = 0; ich < (
int)my_StripEcalLogicId1_EE.size(); ich++) {
1773 dataset4[my_StripEcalLogicId1_EE[ich]] = zut;
1775 for (
int ich = 0; ich < (
int)my_StripEcalLogicId2_EE.size(); ich++) {
1780 dataset4[my_StripEcalLogicId2_EE[ich]] = zut;
1782 for (
int ich = 0; ich < (
int)my_StripEcalLogicId.size(); ich++) {
1786 uint32_t elStripId = stripMapEB[ich];
1787 map<uint32_t, uint32_t>::const_iterator it = stripMapEBsintheta.find(elStripId);
1788 if (it != stripMapEBsintheta.end())
1791 edm::LogError(
"TopInfo") <<
"ERROR: strip SFGVB threshold parameter not found for that strip:" 1792 << thestrip.
getID1() <<
" " << thestrip.
getID3() <<
" " << thestrip.
getID3() <<
"\n";
1798 dataset4[thestrip] = zut;
1806 ss <<
" weight tag " << weight_tag <<
"\n";
1812 map<EcalLogicID, FEConfigSpikeDat> datasetspike;
1813 for (
int ich = 0; ich < (
int)my_TTEcalLogicId.size(); ich++) {
1816 datasetspike[my_TTEcalLogicId[ich]] = spiketh;
1824 ss <<
" spike tag " << spike_tag <<
"\n";
1830 map<EcalLogicID, FEConfigTimingDat>
1832 for (
int ich = 0; ich < (
int)my_TTEcalLogicId_EB_by_TCC.size(); ich++) {
1835 EcalLogicID logiciddelay = my_TTEcalLogicId_EB_by_TCC[ich];
1836 int id1_tcc = my_TTEcalLogicId_EB_by_TCC[ich].
getID1();
1837 int id2_tt = my_TTEcalLogicId_EB_by_TCC[ich].getID2();
1838 std::map<int, vector<int> >::const_iterator ittEB =
delays_EB_.find(id1_tcc);
1839 std::vector<int> TimingDelaysEB = ittEB->second;
1842 if (TimingDelaysEB[id2_tt - 1] == -1) {
1843 edm::LogError(
"TopInfo") <<
"ERROR: Barrel timing delay not specified, check file, putting default value 1" 1849 edm::LogError(
"TopInfo") <<
"ERROR:Barrel Could not find delay parameter for that trigger tower " 1856 std::map<int, vector<int> >::const_iterator ittpEB =
phases_EB_.find(id1_tcc);
1857 std::vector<int> TimingPhasesEB = ittpEB->second;
1860 if (TimingPhasesEB[id2_tt - 1] == -1) {
1861 edm::LogError(
"TopInfo") <<
"ERROR: Barrel timing phase not specified, check file, putting default value 0" 1867 edm::LogError(
"TopInfo") <<
"ERROR:Barrel Could not find phase parameter for that trigger tower " 1874 ss << ich <<
" tcc=" << id1_tcc <<
" TT=" << id2_tt <<
" logicId=" << logiciddelay.
getLogicID()
1875 <<
" delay=" << TimingDelaysEB[id2_tt - 1] <<
" phase=" << TimingPhasesEB[id2_tt - 1] <<
"\n";
1879 datasetdelay[my_TTEcalLogicId_EB_by_TCC[ich]] = delay;
1885 for (
int ich = 0; ich < (
int)my_StripEcalLogicId_EE_strips_by_TCC.size(); ich++) {
1891 EcalLogicID logiciddelay = my_StripEcalLogicId_EE_strips_by_TCC[ich];
1892 int id1_tcc = my_StripEcalLogicId_EE_strips_by_TCC[ich].
getID1();
1893 int id2_tt = my_StripEcalLogicId_EE_strips_by_TCC[ich].getID2();
1894 int id3_st = my_StripEcalLogicId_EE_strips_by_TCC[ich].getID3();
1897 if (id1_tcc != tccin) {
1902 std::map<int, vector<int> >::const_iterator ittEE =
delays_EE_.find(id1_tcc);
1903 std::vector<int> TimingDelaysEE = ittEE->second;
1906 if (TimingDelaysEE[stripindex] == -1) {
1907 edm::LogError(
"TopInfo") <<
"ERROR: Endcap timing delay not specified, check file, putting default value 1" 1913 edm::LogError(
"TopInfo") <<
"ERROR:Endcap Could not find delay parameter for that trigger tower " 1920 std::map<int, vector<int> >::const_iterator ittpEE =
phases_EE_.find(id1_tcc);
1921 std::vector<int> TimingPhasesEE = ittpEE->second;
1924 if (TimingPhasesEE[stripindex] == -1) {
1925 edm::LogError(
"TopInfo") <<
"ERROR: Endcap timing phase not specified, check file, putting default value 0" 1931 edm::LogError(
"TopInfo") <<
"ERROR:Endcap Could not find phase parameter for that trigger tower " 1938 ss << ich <<
" stripindex=" << stripindex <<
" tcc=" << id1_tcc <<
" TT=" << id2_tt <<
" id3_st=" << id3_st
1939 <<
" logicId=" << logiciddelay.
getLogicID() <<
" delay=" << TimingDelaysEE[stripindex]
1940 <<
" phase=" << TimingPhasesEE[stripindex] <<
"\n";
1944 datasetdelay[my_StripEcalLogicId_EE_strips_by_TCC[ich]] = delay;
1948 ostringstream de_tag;
1950 de_tag <<
"DelaysFromFile";
1952 ss <<
" delay tag " << delay_tag <<
"\n";
1959 ss <<
"going to write the sliding " 1961 map<EcalLogicID, FEConfigSlidingDat>
dataset;
1963 for (
int ich = 0; ich < (
int)my_StripEcalLogicId.size(); ich++) {
1969 dataset[my_StripEcalLogicId[ich]] = wut;
1973 for (
int ich = 0; ich < (
int)my_StripEcalLogicId1_EE.size(); ich++) {
1979 dataset[my_StripEcalLogicId1_EE[ich]] = wut;
1981 for (
int ich = 0; ich < (
int)my_StripEcalLogicId2_EE.size(); ich++) {
1987 dataset[my_StripEcalLogicId2_EE[ich]] = wut;
1995 ss <<
" sliding tag " << justatag <<
"\n";
2005 int lut_EB[1024], lut_EE[1024];
2010 (*out_file_) << std::endl;
2011 (*out_file_) <<
"LUT 0" << std::endl;
2012 for (
int i = 0;
i < 1024;
i++)
2013 (*
out_file_) <<
"0x" << hex << lut_EB[
i] << endl;
2014 (*out_file_) << endl;
2021 for (
int i = 0;
i < 1024;
i++)
2022 if (lut_EE[
i] != lut_EB[
i])
2025 (*out_file_) << std::endl;
2026 (*out_file_) <<
"LUT 1" << std::endl;
2027 for (
int i = 0; i < 1024; i++)
2028 (*
out_file_) <<
"0x" << hex << lut_EE[
i] << endl;
2029 (*out_file_) << endl;
2033 map<EcalLogicID, FEConfigLUTGroupDat>
dataset;
2039 for (
int i = 0; i < 1024; i++) {
2044 dataset[ecid] = lut;
2050 for (
int i = 0; i < 1024; i++) {
2055 dataset[ecide] = lute;
2062 map<EcalLogicID, FEConfigLUTDat> dataset2;
2064 for (
int ich = 0; ich < (
int)my_TTEcalLogicId.size(); ich++) {
2070 dataset2[my_TTEcalLogicId[ich]] = lut;
2074 for (
int ich = 0; ich < (
int)my_TTEcalLogicId_EE.size(); ich++) {
2080 dataset2[my_TTEcalLogicId_EE[ich]] = lut;
2088 ss <<
" LUT tag " << lut_tag <<
"\n";
2111 ss <<
"\n Conf ID = " << conf_id_ <<
"\n";
2120 stripListEB.unique();
2121 ss <<
"Number of EB strips=" <<
dec << stripListEB.size() <<
"\n";
2123 (*out_file_) << std::endl;
2124 for (itList = stripListEB.begin(); itList != stripListEB.end(); itList++) {
2125 (*out_file_) <<
"STRIP_EB " <<
dec << (*itList) << endl;
2126 (*out_file_) << hex <<
"0x" <<
sliding_ << std::endl;
2127 (*out_file_) <<
"0" << std::endl;
2128 (*out_file_) <<
"0x" << stripMapEBsintheta[(*itList)] <<
" 0x" <<
SFGVB_lut_ << std::endl;
2134 stripListEE.unique();
2135 ss <<
"Number of EE strips=" <<
dec << stripListEE.size() <<
"\n";
2137 (*out_file_) << std::endl;
2138 for (itList = stripListEE.begin(); itList != stripListEE.end(); itList++) {
2139 (*out_file_) <<
"STRIP_EE " <<
dec << (*itList) << endl;
2140 (*out_file_) << hex <<
"0x" <<
sliding_ << std::endl;
2142 (*out_file_) <<
" 1" << std::endl;
2143 (*out_file_) << hex <<
"0x" << threshold <<
" 0x" << lut_strip << std::endl;
2155 towerListEB.unique();
2156 ss <<
"Number of EB towers=" <<
dec << towerListEB.size() <<
"\n";
2158 (*out_file_) << std::endl;
2159 for (itList = towerListEB.begin(); itList != towerListEB.end(); itList++) {
2160 (*out_file_) <<
"TOWER_EB " <<
dec << (*itList) << endl;
2161 (*out_file_) <<
" 0\n 0\n";
2168 towerListEE.unique();
2169 ss <<
"Number of EE towers=" <<
dec << towerListEE.size() <<
"\n";
2171 (*out_file_) << std::endl;
2172 for (itList = towerListEE.begin(); itList != towerListEE.end(); itList++) {
2173 (*out_file_) <<
"TOWER_EE " <<
dec << (*itList) << endl;
2175 (*out_file_) <<
" 1\n";
2178 (*out_file_) << hex <<
"0x" << lut_tower << std::endl;
2188 tpgFactorEB->Write();
2190 tpgFactorEEPlus->Write();
2192 tpgFactorEEMinus->Write();
2198 ntupleSpike->Write();
2203 using namespace edm;
2204 using namespace std;
2214 (*out_file_) <<
"PHYSICS_EB " <<
dec << eb.
rawId() << std::endl;
2219 (*out_file_) << std::endl;
2221 (*out_file_) <<
"PHYSICS_EE " <<
dec << ee.
rawId() << std::endl;
2223 (*out_file_) <<
FG_Threshold_EE_ <<
" " << -1 <<
" " << -1 <<
" " << -1 << std::endl;
2224 (*out_file_) << std::endl;
2252 if (subdet ==
"EE") {
2261 double factor = 1024 * ratio * gainRatio * calibCoeff *
sin(theta) * (1 << (
sliding_ + shiftDet + 2));
2263 mult = (
int)(factor + 0.5);
2264 for (shift = 0; shift < 15; shift++) {
2265 if (mult >= 128 && mult < 256)
2268 mult = (
int)(factor + 0.5);
2270 edm::LogError(
"TopInfo") <<
"too bad we did not manage to calculate the factor for calib=" << calibCoeff <<
"\n";
2277 (*out_file_) <<
"COMMENT put your comments here" << std::endl;
2279 (*out_file_) <<
"COMMENT =================================" << std::endl;
2280 (*out_file_) <<
"COMMENT physics EB structure" << std::endl;
2281 (*out_file_) <<
"COMMENT" << std::endl;
2282 (*out_file_) <<
"COMMENT EtSaturation (GeV), ttf_threshold_Low (GeV), ttf_threshold_High (GeV)" << std::endl;
2283 (*out_file_) <<
"COMMENT FG_lowThreshold (GeV), FG_highThreshold (GeV), FG_lowRatio, FG_highRatio" << std::endl;
2285 (*out_file_) <<
"COMMENT =================================" << std::endl;
2286 (*out_file_) <<
"COMMENT" << std::endl;
2288 (*out_file_) <<
"COMMENT =================================" << std::endl;
2289 (*out_file_) <<
"COMMENT physics EE structure" << std::endl;
2290 (*out_file_) <<
"COMMENT" << std::endl;
2291 (*out_file_) <<
"COMMENT EtSaturation (GeV), ttf_threshold_Low (GeV), ttf_threshold_High (GeV)" << std::endl;
2292 (*out_file_) <<
"COMMENT FG_Threshold (GeV), dummy, dummy, dummy" << std::endl;
2293 (*out_file_) <<
"COMMENT =================================" << std::endl;
2294 (*out_file_) <<
"COMMENT" << std::endl;
2296 (*out_file_) <<
"COMMENT =================================" << std::endl;
2297 (*out_file_) <<
"COMMENT crystal structure (same for EB and EE)" << std::endl;
2298 (*out_file_) <<
"COMMENT" << std::endl;
2299 (*out_file_) <<
"COMMENT ped, mult, shift [gain12]" << std::endl;
2300 (*out_file_) <<
"COMMENT ped, mult, shift [gain6]" << std::endl;
2301 (*out_file_) <<
"COMMENT ped, mult, shift [gain1]" << std::endl;
2302 (*out_file_) <<
"COMMENT =================================" << std::endl;
2303 (*out_file_) <<
"COMMENT" << std::endl;
2305 (*out_file_) <<
"COMMENT =================================" << std::endl;
2306 (*out_file_) <<
"COMMENT strip EB structure" << std::endl;
2307 (*out_file_) <<
"COMMENT" << std::endl;
2308 (*out_file_) <<
"COMMENT sliding_window" << std::endl;
2309 (*out_file_) <<
"COMMENT weightGroupId" << std::endl;
2310 (*out_file_) <<
"COMMENT threshold_sfg lut_sfg" << std::endl;
2311 (*out_file_) <<
"COMMENT =================================" << std::endl;
2312 (*out_file_) <<
"COMMENT" << std::endl;
2314 (*out_file_) <<
"COMMENT =================================" << std::endl;
2315 (*out_file_) <<
"COMMENT strip EE structure" << std::endl;
2316 (*out_file_) <<
"COMMENT" << std::endl;
2317 (*out_file_) <<
"COMMENT sliding_window" << std::endl;
2318 (*out_file_) <<
"COMMENT weightGroupId" << std::endl;
2319 (*out_file_) <<
"COMMENT threshold_fg lut_fg" << std::endl;
2320 (*out_file_) <<
"COMMENT =================================" << std::endl;
2321 (*out_file_) <<
"COMMENT" << std::endl;
2323 (*out_file_) <<
"COMMENT =================================" << std::endl;
2324 (*out_file_) <<
"COMMENT tower EB structure" << std::endl;
2325 (*out_file_) <<
"COMMENT" << std::endl;
2326 (*out_file_) <<
"COMMENT LUTGroupId" << std::endl;
2327 (*out_file_) <<
"COMMENT FgGroupId" << std::endl;
2328 (*out_file_) <<
"COMMENT spike_killing_threshold" << std::endl;
2329 (*out_file_) <<
"COMMENT =================================" << std::endl;
2330 (*out_file_) <<
"COMMENT" << std::endl;
2332 (*out_file_) <<
"COMMENT =================================" << std::endl;
2333 (*out_file_) <<
"COMMENT tower EE structure" << std::endl;
2334 (*out_file_) <<
"COMMENT" << std::endl;
2335 (*out_file_) <<
"COMMENT LUTGroupId" << std::endl;
2336 (*out_file_) <<
"COMMENT tower_lut_fg" << std::endl;
2337 (*out_file_) <<
"COMMENT =================================" << std::endl;
2338 (*out_file_) <<
"COMMENT" << std::endl;
2340 (*out_file_) <<
"COMMENT =================================" << std::endl;
2341 (*out_file_) <<
"COMMENT Weight structure" << std::endl;
2342 (*out_file_) <<
"COMMENT" << std::endl;
2343 (*out_file_) <<
"COMMENT weightGroupId" << std::endl;
2344 (*out_file_) <<
"COMMENT w0, w1, w2, w3, w4" << std::endl;
2345 (*out_file_) <<
"COMMENT =================================" << std::endl;
2346 (*out_file_) <<
"COMMENT" << std::endl;
2348 (*out_file_) <<
"COMMENT =================================" << std::endl;
2349 (*out_file_) <<
"COMMENT lut structure" << std::endl;
2350 (*out_file_) <<
"COMMENT" << std::endl;
2351 (*out_file_) <<
"COMMENT LUTGroupId" << std::endl;
2352 (*out_file_) <<
"COMMENT LUT[1-1024]" << std::endl;
2353 (*out_file_) <<
"COMMENT =================================" << std::endl;
2354 (*out_file_) <<
"COMMENT" << std::endl;
2356 (*out_file_) <<
"COMMENT =================================" << std::endl;
2357 (*out_file_) <<
"COMMENT fg EB structure" << std::endl;
2358 (*out_file_) <<
"COMMENT" << std::endl;
2359 (*out_file_) <<
"COMMENT FgGroupId" << std::endl;
2360 (*out_file_) <<
"COMMENT el, eh, tl, th, lut_fg" << std::endl;
2361 (*out_file_) <<
"COMMENT =================================" << std::endl;
2362 (*out_file_) <<
"COMMENT" << std::endl;
2364 (*out_file_) << std::endl;
2369 unsigned int max = (
unsigned int)(
pow(2., complement2) - 1);
2371 iweight =
int((1 << 6) * weight + 0.5);
2373 iweight = max -
int(-weight * (1 << 6) + 0.5) + 1;
2374 iweight = iweight &
max;
2379 double weight = double(iweight) /
pow(2., 6.);
2381 if ((iweight & (1 << (complement2 - 1))) != 0)
2382 weight = (double(iweight) -
pow(2., complement2)) /
pow(2., 6.);
2387 std::ostringstream
ss;
2388 ss <<
"Computing Weights...\n";
2390 double max = shape(timeMax);
2397 sumf += shape(time) /
max;
2398 sumf2 += shape(time) / max * shape(time) /
max;
2399 for (
int subtime = 0; subtime < 25; subtime++)
2400 histo->Fill(
float(
sample * 25. + subtime) / 25., shape(time + subtime));
2402 double lambda = 1. / (sumf2 - sumf * sumf /
nSample_);
2408 weight[
sample] = lambda * shape(time) / max +
gamma;
2417 for (
unsigned int sample = 0; sample <
nSample_; sample++)
2418 isumw += iweight[sample];
2420 isumw = (isumw & imax);
2424 for (
unsigned int sample = 0; sample <
nSample_; sample++) {
2427 ampl += weight[
sample] * shape(time);
2429 ss <<
"weight=" << weight[
sample] <<
" shape=" << shape(time) <<
"\n";
2433 ss <<
"Weights: sum (weight*shape) = " << ampl <<
"\n";
2438 while (isumw != 0 && count < 10) {
2440 unsigned int index = 0;
2443 ss <<
"Correcting for bias: adding 1\n";
2444 for (
unsigned int sample = 0; sample <
nSample_; sample++) {
2445 int new_iweight = iweight[
sample] + 1;
2447 if (fabs(new_weight - weight[sample]) < min) {
2448 min = fabs(new_weight - weight[sample]);
2455 ss <<
"Correcting for bias: subtracting 1\n";
2456 for (
unsigned int sample = 0; sample <
nSample_; sample++) {
2457 int new_iweight = iweight[
sample] - 1;
2459 if (fabs(new_weight - weight[sample]) < min) {
2460 min = fabs(new_weight - weight[sample]);
2467 for (
unsigned int sample = 0; sample <
nSample_; sample++)
2468 isumw += iweight[sample];
2470 isumw = (isumw & imax);
2471 ss <<
"Correcting weight number: " << index <<
" sum weights = " << isumw <<
"\n";
2478 for (
unsigned int sample = 0; sample <
nSample_; sample++)
2479 isumw += iweight[sample];
2481 isumw = (isumw & imax);
2483 for (
unsigned int sample = 0; sample <
nSample_; sample++) {
2488 ampl += new_weight * shape(time);
2489 ss <<
"weight unbiased after integer conversion=" << new_weight <<
" shape=" << shape(time) <<
"\n";
2493 ss <<
"Weights: sum (weight*shape) = " << ampl <<
"\n";
2496 std::vector<unsigned int> theWeights;
2497 for (
unsigned int sample = 0; sample <
nSample_; sample++)
2498 theWeights.push_back(iweight[sample]);
2524 for (
int i = 0;
i < 1024;
i++) {
2533 for (
int i = 0;
i < 1024;
i++) {
2535 if ((
i + 1) % 4 == 0)
2544 func->SetParameters(LUT_stochastic, LUT_noise, LUT_constant);
2545 double norm = func->Integral(0., Et_sat);
2546 for (
int i = 0;
i < 1024;
i++) {
2547 double Et =
i * Et_sat / 1024.;
2548 lut[
i] =
int(0xff * func->Integral(0., Et) / norm + 0.5);
2553 for (
int j = 0;
j < 1024;
j++) {
2554 double Et_GeV = Et_sat / 1024 * (
j + 0.5);
2555 if (Et_GeV <= LUT_threshold)
2558 if (Et_GeV >= TTF_highThreshold)
2560 if (Et_GeV >= TTF_lowThreshold && Et_GeV < TTF_highThreshold)
2581 double alpha_factor = 1.0;
2584 icorr = itCorr->second;
2592 st =
"Transparency correction found for xtal " + ss.str() +
" corr=" + ss1.str() +
" intercalib=" + ss2.str() +
2595 edm::LogError(
"TopInfo") <<
"ERROR = Transparency correction not found for xtal " << rawId <<
"\n";
2598 DetId ECALdetid(rawId);
2602 st +=
"DETID=" + ss.str() +
"\n";
2606 if (italpha != laserAlphaMap.
end())
2607 alpha_factor = (*italpha);
2609 edm::LogError(
"TopInfo") <<
"ERROR:LaserAlphe parameter note found!!" 2615 if (italpha != laserAlphaMap.
end())
2616 alpha_factor = (*italpha);
2618 edm::LogError(
"TopInfo") <<
"ERROR:LaserAlphe parameter note found!!" 2632 ss2 << alpha_factor;
2633 st +=
"rawId " + ss.str() +
" " + ss1.str() +
" " + ss2.str() +
"\n";
2634 if (icalit != calibMap.
end())
2640 edm::LogError(
"TopInfo") <<
"getCoeff: " << rawId <<
" not found in EcalIntercalibConstantMap" 2650 if (gainIter != gainMap.
end()) {
2655 edm::LogError(
"TopInfo") <<
"getCoeff: " << rawId <<
" not found in EcalGainRatioMap" 2673 if (pedIter != pedMap.
end()) {
2679 edm::LogError(
"TopInfo") <<
"getCoeff: " << rawId <<
" not found in EcalPedestalsMap\n";
2683 const map<EcalLogicID, MonPedestalsDat>& pedMap,
2690 map<EcalLogicID, MonPedestalsDat>::const_iterator it = pedMap.find(logicId);
2691 if (it != pedMap.end()) {
2698 <<
" not found in map<EcalLogicID, MonPedestalsDat\n";
2702 unsigned int& highRatio,
2703 unsigned int& lowThreshold,
2704 unsigned int& highThreshold,
2705 unsigned int& lut) {
2707 if (lowRatio > 0x7f)
2710 if (highRatio > 0x7f)
2716 if (lowThreshold > 0xff)
2717 lowThreshold = 0xff;
2719 if (highThreshold > 0xff)
2720 highThreshold = 0xff;
2736 unsigned int& lut_strip,
2737 unsigned int& lut_tower) {
2748 for (
int i = 1;
i < 3;
i++) {
2756 for (
int i = 0;
i < 3;
i++) {
2761 <<
" ==> forcing at 0" 2772 gctphi = (ttphi + 1) / 4;
2783 gcteta = (tteta - 1) / 4 + 11;
2785 gcteta = (tteta + 1) / 4 + 10;
2790 std::stringstream sdet;
2792 if (tcc > 36 && tcc < 55)
2793 sdet <<
"EB-" << tcc - 36;
2794 else if (tcc >= 55 && tcc < 73)
2795 sdet <<
"EB+" << tcc - 54;
2801 if (tcc <= 36 || tcc >= 73) {
2804 if (tcc == 1 || tcc == 18 || tcc == 19 || tcc == 36)
2806 else if (tcc == 2 || tcc == 3 || tcc == 20 || tcc == 21)
2808 else if (tcc == 4 || tcc == 5 || tcc == 22 || tcc == 23)
2810 else if (tcc == 6 || tcc == 7 || tcc == 24 || tcc == 25)
2812 else if (tcc == 8 || tcc == 9 || tcc == 26 || tcc == 27)
2814 else if (tcc == 10 || tcc == 11 || tcc == 28 || tcc == 29)
2816 else if (tcc == 12 || tcc == 13 || tcc == 30 || tcc == 31)
2818 else if (tcc == 14 || tcc == 15 || tcc == 32 || tcc == 33)
2820 else if (tcc == 16 || tcc == 17 || tcc == 34 || tcc == 35)
2828 std::stringstream crate;
2833 if (tcc >= 40 && tcc <= 42) {
2835 slot = 5 + (tcc - 40) * 6;
2837 if (tcc >= 43 && tcc <= 45) {
2839 slot = 5 + (tcc - 43) * 6;
2841 if (tcc >= 37 && tcc <= 39) {
2843 slot = 5 + (tcc - 37) * 6;
2845 if (tcc >= 52 && tcc <= 54) {
2847 slot = 5 + (tcc - 52) * 6;
2849 if (tcc >= 46 && tcc <= 48) {
2851 slot = 5 + (tcc - 46) * 6;
2853 if (tcc >= 49 && tcc <= 51) {
2855 slot = 5 + (tcc - 49) * 6;
2857 if (tcc >= 58 && tcc <= 60) {
2859 slot = 5 + (tcc - 58) * 6;
2861 if (tcc >= 61 && tcc <= 63) {
2863 slot = 5 + (tcc - 61) * 6;
2865 if (tcc >= 55 && tcc <= 57) {
2867 slot = 5 + (tcc - 55) * 6;
2869 if (tcc >= 70 && tcc <= 72) {
2871 slot = 5 + (tcc - 70) * 6;
2873 if (tcc >= 64 && tcc <= 66) {
2875 slot = 5 + (tcc - 64) * 6;
2877 if (tcc >= 67 && tcc <= 69) {
2879 slot = 5 + (tcc - 67) * 6;
2882 if (tcc >= 76 && tcc <= 81) {
2885 slot = 2 + (tcc - 76) * 3;
2887 slot = 4 + (tcc - 77) * 3;
2889 if (tcc >= 94 && tcc <= 99) {
2892 slot = 3 + (tcc - 94) * 3;
2894 slot = 5 + (tcc - 95) * 3;
2897 if (tcc >= 22 && tcc <= 27) {
2900 slot = 2 + (tcc - 22) * 3;
2902 slot = 4 + (tcc - 23) * 3;
2904 if (tcc >= 4 && tcc <= 9) {
2907 slot = 3 + (tcc - 4) * 3;
2909 slot = 5 + (tcc - 5) * 3;
2912 if (tcc >= 82 && tcc <= 87) {
2915 slot = 2 + (tcc - 82) * 3;
2917 slot = 4 + (tcc - 83) * 3;
2919 if (tcc >= 100 && tcc <= 105) {
2922 slot = 3 + (tcc - 100) * 3;
2924 slot = 5 + (tcc - 101) * 3;
2927 if (tcc >= 28 && tcc <= 33) {
2930 slot = 2 + (tcc - 28) * 3;
2932 slot = 4 + (tcc - 29) * 3;
2934 if (tcc >= 10 && tcc <= 15) {
2937 slot = 3 + (tcc - 10) * 3;
2939 slot = 5 + (tcc - 11) * 3;
3040 return std::pair<std::string, int>(crate.str(), slot);
int writeToConfDB_TPGLinearCoef(const std::map< EcalLogicID, FEConfigLinDat > &linset, const std::map< EcalLogicID, FEConfigLinParamDat > &linparamset, int iovId, std::string tag)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::map< int, std::vector< int > > phases_EB_
bool useTransparencyCorr_
void setThreshLow(float x)
edm::ESHandle< EcalTrigTowerConstituentsMap > eTTmap_
int xtalId() const
get the channel id
void setLUTGroupId(int x)
int stripId() const
get the tower id
void setFGhighratio(float x)
const self & getMap() const
EcalLogicID getEcalLogicID(std::string name, int id1=EcalLogicID::NULLID, int id2=EcalLogicID::NULLID, int id3=EcalLogicID::NULLID, std::string mapsTo="") noexcept(false)
float getPedMeanG1() const
Ecal readout channel identification [32:20] Unused (so far) [19:13] DCC id [12:6] tower [5:3] strip [...
double TTF_highThreshold_EB_
void setTimingPar2(int x)
unsigned int SFGVB_Threshold_
std::pair< std::string, int > getCrate(int tcc)
const Items & barrelItems() const
int getGCTRegionPhi(int ttphi)
Sin< T >::type sin(const T &t)
constexpr uint32_t rawId() const
get the raw id
std::string TimingPhases_EE_
std::string getDet(int tcc)
double oneOverEtResolEt(double *x, double *par)
Geom::Theta< T > theta() const
unsigned tccId(DetId const &)
std::string Transparency_Corr_
bool weight_unbias_recovery_
void setFGlowthresh(float x)
int towerId() const
get the tower id
void setRatioHigh(float x)
int iTT(const EcalTrigTowerDetId &id) const
returns the index of a Trigger Tower within its TCC.
int writeToConfDB_TPGSliding(const std::map< EcalLogicID, FEConfigSlidingDat > &sliset, int iovId, std::string tag)
void fetchConfigSet(ICONF *iconf) noexcept(false)
unsigned int FG_lut_tower_EE_
static EEDetId unhashIndex(int hi)
std::string TimingDelays_EE_
int writeToConfDB_Delay(const std::map< EcalLogicID, FEConfigTimingDat > &delaygroupset, std::string tag)
const CaloSubdetectorGeometry * theEndcapGeometry_
double FG_lowThreshold_EB_
int writeToConfDB_TPGMain(int ped, int lin, int lut, int fgr, int sli, int wei, int spi, int tim, int bxt, int btt, int bst, std::string tag, int ver)
std::ofstream * out_file_
void fetchDataSet(std::map< EcalLogicID, DATT > *fillMap, IOVT *iov) noexcept(false)
std::map< int, std::vector< int > > delays_EB_
The Signals That Services Can Subscribe To This is based on ActivityRegistry and is current per Services can connect to the signals distributed by the ActivityRegistry in order to monitor the activity of the application Each possible callback has some defined which we here list in angle e g
int channelId() const
get the channel id
int ieta() const
get the tower ieta
void setPedMeanG6(float mean)
int zside() const
get the z-side of the tower (1/-1)
virtual const std::vector< DetId > & getValidDetIds(DetId::Detector det=DetId::Detector(0), int subdet=0) const
Get a list of valid detector ids (for the given subdetector)
int TCCid(const EBDetId &id) const
returns the TCCid of an EBDetId
int SFGVB_SpikeKillingThreshold_
std::vector< unsigned int > computeWeights(EcalShapeBase &shape, TH1F *histo)
int hashedIndex(int ieta, int iphi)
EcalElectronicsId getElectronicsId(const DetId &id) const
Get the electronics id for this det id.
double TTF_lowThreshold_EE_
std::string getName() const
const EcalLaserAPDPNRatiosMap & getLaserMap() const
void setThreshold(unsigned int mean)
void setPedMeanG1(float mean)
void setThreshHigh(float x)
float getPedMeanG12() const
~EcalTPGParamBuilder() override
std::map< int, std::vector< int > > delays_EE_
std::string TimingDelays_EB_
EcalPedestalsMap::const_iterator EcalPedestalsMapIterator
void setLutFgr(unsigned int mean)
int ietaAbs() const
get the absolute value of the tower ieta
const EcalElectronicsMapping * theMapping_
std::vector< EcalLogicID > getEcalLogicIDSetOrdered(std::string name, int fromId1, int toId1, int fromId2=EcalLogicID::NULLID, int toId2=EcalLogicID::NULLID, int fromId3=EcalLogicID::NULLID, int toId3=EcalLogicID::NULLID, std::string mapsTo="", int orderedBy=EcalLogicID::NULLID) noexcept(false)
void computeLUT(int *lut, std::string det="EB")
bool useTransverseEnergy_
EcalTPGParamBuilder(edm::ParameterSet const &pSet)
void analyze(const edm::Event &evt, const edm::EventSetup &evtSetup) override
void setLUTValue(int i, int x)
constexpr int subdetId() const
get the contents of the subdetector field (not cast into any detector's numbering enum) ...
Abs< T >::type abs(const T &t)
EcalTriggerElectronicsId getTriggerElectronicsId(const DetId &id) const
Get the trigger electronics id for this det id.
double LUT_stochastic_EE_
std::ofstream * geomFile_
void setLUTGroupId(int x)
void setFgrGroupId(int x)
int pseudoStripId() const
get the tower id
int dccId() const
get the DCC (Ecal Local DCC value not global one) id
void setSpikeThreshold(int x)
float getPedMeanG12() const
void setTimingPar1(int x)
const_iterator begin() const
void insert(std::pair< uint32_t, Item > const &a)
void setRatioLow(float x)
void setFgrGroupId(int x)
int writeToConfDB_Spike(const std::map< EcalLogicID, FEConfigSpikeDat > &spikegroupset, std::string tag)
void computeFineGrainEEParameters(uint &threshold, uint &lut_strip, uint &lut_tower)
bool realignBaseline(linStruc &lin, float forceBase12)
bool computeLinearizerParam(double theta, double gainRatio, double calibCoeff, std::string subdet, int &mult, int &shift)
unsigned int pedestal_offset_
int iphi() const
get the tower iphi
const CaloSubdetectorGeometry * theBarrelGeometry_
bool useInterCalibration_
int writeToConfDB_TPGPedestals(const std::map< EcalLogicID, FEConfigPedDat > &pedset, int iovId, std::string tag)
void setPedMeanG12(float mean)
virtual std::shared_ptr< const CaloCellGeometry > getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
std::vector< Item >::const_iterator const_iterator
int DCCid(const EBDetId &id) const
returns the DCC of an EBDetId
float gain12Over6() const
float getPedMeanG1() const
float getPedMeanG6() const
static EBDetId unhashIndex(int hi)
get a DetId from a compact index for arrays
EcalSubdetector subDet() const
get the subDetector associated to the Trigger Tower
void setConfigTag(std::string x)
void setFGlowratio(float x)
double TTF_highThreshold_EE_
void setSliding(float mean)
std::string TimingPhases_EB_
double LUT_stochastic_EB_
void setTTThreshhigh(float x)
int writeToConfDB_TPGLUT(const std::map< EcalLogicID, FEConfigLUTGroupDat > &lutgroup, const std::map< EcalLogicID, FEConfigLUTDat > &lutdat, const std::map< EcalLogicID, FEConfigLUTParamDat > &lutparamset, int iovId, std::string tag)
void setEventSetup(const edm::EventSetup &evtSetup)
float getPedMeanG6() const
const_iterator find(uint32_t rawId) const
static unsigned int const shift
void setWeightGroupId(int x)
int writeToConfDB_TPGFgr(const std::map< EcalLogicID, FEConfigFgrGroupDat > &lutgroup, const std::map< EcalLogicID, FEConfigFgrDat > &lutdat, const std::map< EcalLogicID, FEConfigFgrParamDat > &fgrparamset, const std::map< EcalLogicID, FEConfigFgrEETowerDat > &dataset3, const std::map< EcalLogicID, FEConfigFgrEEStripDat > &dataset4, int iovId, std::string tag)
unsigned int complement2_
const_iterator end() const
int writeToConfDB_TPGWeight(const std::map< EcalLogicID, FEConfigWeightGroupDat > &lutgroup, const std::map< EcalLogicID, FEConfigWeightDat > &lutdat, int iovId, std::string tag)
int getGCTRegionEta(int tteta)
std::map< int, double > Transparency_Correction_
void setTTThreshlow(float x)
const Items & endcapItems() const
static const int SMCRYSTALMODE
void setWeightGroupId(int x)
unsigned int FG_lut_strip_EE_
int getEtaSlice(int tccId, int towerInTCC)
double FG_highThreshold_EB_
T const * product() const
void setLutValue(int mean)
Ecal trigger electronics identification [32:20] Unused (so far) [19:13] TCC id [12:6] TT id [5:3] pse...
void setFGhighthresh(float x)
Power< A, B >::type pow(const A &a, const B &b)
std::map< int, std::vector< int > > phases_EE_
double TTF_lowThreshold_EB_
bool checkIfOK(EcalPedestals::Item item)
void computeFineGrainEBParameters(uint &lowRatio, uint &highRatio, uint &lowThreshold, uint &highThreshold, uint &lut)
void getCoeff(coeffStruc &coeff, const EcalGainRatioMap &gainMap, uint rawId)
int uncodeWeight(double weight, int complement2=7)