36 double resolEt_overEt =
37 sqrt((par[0] /
sqrt(Et)) * (par[0] /
sqrt(Et)) + (par[1] / Et) * (par[1] / Et) + par[2] * par[2]);
38 return 1. / (Et * resolEt_overEt);
186 std::ostringstream
ss;
188 ss <<
"INFO: READING timing files\n";
208 delay_eb.getline(
buf,
sizeof(
buf),
'\n');
210 std::stringstream
sin(
buf);
215 vector<int> vec_delays_eb;
216 for (
int ieb = 0; ieb < 68; ++ieb) {
219 vec_delays_eb.push_back(time_delay);
220 if (time_delay == -1)
221 edm::LogError(
"TopInfo") <<
"ERROR:Barrel timing delay -1, check file"
225 if (vec_delays_eb.size() != 68)
226 edm::LogError(
"TopInfo") <<
"ERROR:Barrel timing delay wrong, not enough towers, check file"
230 delays_EB_.insert(make_pair(tcc, vec_delays_eb));
234 for (
unsigned int ieb = 0; ieb < vec_delays_eb.size(); ++ieb)
236 ss <<
" " << vec_delays_eb[ieb];
237 delay_eb.getline(
buf,
sizeof(
buf),
'\n');
243 phase_eb.getline(
buf,
sizeof(
buf),
'\n');
245 std::stringstream
sin(
buf);
249 vector<int> vec_phases_eb;
250 for (
unsigned int ieb = 0; ieb < 68; ++ieb) {
253 vec_phases_eb.push_back(time_phase);
254 if (time_phase == -1)
255 edm::LogError(
"TopInfo") <<
"ERROR:Barrel timing phase -1, check file"
259 if (vec_phases_eb.size() != 68)
260 edm::LogError(
"TopInfo") <<
"ERROR:Barrel timing phase wrong, not enough towers, check file"
264 phases_EB_.insert(make_pair(tcc, vec_phases_eb));
268 for (
unsigned int ieb = 0; ieb < vec_phases_eb.size(); ++ieb)
270 ss <<
" " << vec_phases_eb[ieb];
271 phase_eb.getline(
buf,
sizeof(
buf),
'\n');
277 delay_ee.getline(
buf,
sizeof(
buf),
'\n');
279 std::stringstream
sin(
buf);
283 vector<int> vec_delays_ee;
284 for (
unsigned int iee = 0; iee < 48; ++iee) {
287 vec_delays_ee.push_back(time_delay);
288 if (time_delay == -1)
289 edm::LogError(
"TopInfo") <<
"ERROR:EE timing delay -1, check file"
293 if (vec_delays_ee.size() != 48)
294 edm::LogError(
"TopInfo") <<
"ERROR:EE timing delay wrong, not enough towers, check file"
298 delays_EE_.insert(make_pair(tcc, vec_delays_ee));
302 for (
unsigned int iee = 0; iee < vec_delays_ee.size(); ++iee)
304 ss <<
" " << vec_delays_ee[iee];
306 delay_ee.getline(
buf,
sizeof(
buf),
'\n');
311 phase_ee.getline(
buf,
sizeof(
buf),
'\n');
313 std::stringstream
sin(
buf);
317 vector<int> vec_phases_ee;
318 for (
unsigned int iee = 0; iee < 48; ++iee) {
321 vec_phases_ee.push_back(time_phase);
322 if (time_phase == -1)
323 edm::LogError(
"TopInfo") <<
"ERROR:EE timing phase -1, check file"
327 if (vec_phases_ee.size() != 48)
328 edm::LogError(
"TopInfo") <<
"ERROR:EE timing phase wrong, not enough towers, check file"
332 phases_EE_.insert(make_pair(tcc, vec_phases_ee));
335 for (
unsigned int iee = 0; iee < vec_phases_ee.size(); ++iee)
337 ss <<
" " << vec_phases_ee[iee];
339 phase_ee.getline(
buf,
sizeof(
buf),
'\n');
344 ss <<
"INFO: DONE reading timing files for EB and EE\n";
350 (*out_file_) <<
"EOF" << std::endl;
358 if (
item.mean_x1 < 150. ||
item.mean_x1 > 250)
360 if (
item.mean_x6 < 150. ||
item.mean_x6 > 250)
362 if (
item.mean_x12 < 150. ||
item.mean_x12 > 250)
364 if (
item.rms_x1 < 0 ||
item.rms_x1 > 2)
366 if (
item.rms_x6 < 0 ||
item.rms_x6 > 3)
368 if (
item.rms_x12 < 0 ||
item.rms_x12 > 5)
374 int etaSlice = (towerInTCC - 1) / 4 + 1;
405 std::ostringstream
ss;
406 ss <<
"EcalLaserDbAnalyzer::analyze\n";
408 ss <<
"EcalLaserDbAnalyzer::analyze-> got EcalLaserDbRecord: \n";
415 for (italpha = laserAlphaMap.
barrelItems().begin(); italpha != laserAlphaMap.
barrelItems().end(); ++italpha) {
416 if (cnt % 1000 == 0) {
418 ss <<
" Barrel ALPHA = " << (*italpha) <<
" cmsswId " << ebdetid.
rawId() <<
"\n";
422 ss <<
"Number of barrel Alpha parameters : " << cnt <<
"\n";
425 for (italpha = laserAlphaMap.
endcapItems().begin(); italpha != laserAlphaMap.
endcapItems().end(); ++italpha) {
426 if (cnt % 1000 == 0) {
428 ss <<
"EndCap ALPHA = " << (*italpha) <<
" cmsswId " << eedetid.
rawId() <<
"\n";
432 ss <<
"Number of Endcap Alpha parameters : " << cnt <<
"\n";
441 edm::LogInfo(
"TopInfo") <<
"INFO: READING transparency correction files"
443 ss <<
"INFO: READING transparency correction files\n";
450 transparency.getline(
buf,
sizeof(
buf),
'\n');
452 while (transparency) {
453 std::stringstream
sin(
buf);
458 double xtal_trans_corr;
459 sin >> xtal_trans_corr;
462 ss << raw_xtal_id <<
" " << xtal_trans_corr <<
"\n";
467 transparency.getline(
buf,
sizeof(
buf),
'\n');
469 transparency.close();
470 ss <<
"INFO: DONE transparency correction files " << xtalcounter <<
"\n";
475 edm::LogInfo(
"TopInfo") <<
"INFO: READING transparency correction tag"
483 for (
int ib = 0;
ib < 61200;
ib++) {
490 for (
int ie = 0; ie < 14648; ie++) {
496 ss <<
"INFO: DONE transparency correction tag\n";
503 TFile saving(
"EcalTPGParam.root",
"recreate");
505 TH2F* ICEB =
new TH2F(
"ICEB",
"IC: Barrel", 360, 1, 361, 172, -86, 86);
506 ICEB->GetYaxis()->SetTitle(
"eta index");
507 ICEB->GetXaxis()->SetTitle(
"phi index");
508 TH2F* tpgFactorEB =
new TH2F(
"tpgFactorEB",
"tpgFactor: Barrel", 360, 1, 361, 172, -86, 86);
509 tpgFactorEB->GetYaxis()->SetTitle(
"eta index");
510 tpgFactorEB->GetXaxis()->SetTitle(
"phi index");
512 TH2F* ICEEPlus =
new TH2F(
"ICEEPlus",
"IC: Plus Endcap", 120, -9, 111, 120, -9, 111);
513 ICEEPlus->GetYaxis()->SetTitle(
"y index");
514 ICEEPlus->GetXaxis()->SetTitle(
"x index");
515 TH2F* tpgFactorEEPlus =
new TH2F(
"tpgFactorEEPlus",
"tpgFactor: Plus Endcap", 120, -9, 111, 120, -9, 111);
516 tpgFactorEEPlus->GetYaxis()->SetTitle(
"y index");
517 tpgFactorEEPlus->GetXaxis()->SetTitle(
"x index");
518 TH2F* ICEEMinus =
new TH2F(
"ICEEMinus",
"IC: Minus Endcap", 120, -9, 111, 120, -9, 111);
519 ICEEMinus->GetYaxis()->SetTitle(
"y index");
520 ICEEMinus->GetXaxis()->SetTitle(
"x index");
521 TH2F* tpgFactorEEMinus =
new TH2F(
"tpgFactorEEMinus",
"tpgFactor: Minus Endcap", 120, -9, 111, 120, -9, 111);
522 tpgFactorEEMinus->GetYaxis()->SetTitle(
"y index");
523 tpgFactorEEMinus->GetXaxis()->SetTitle(
"x index");
525 TH2F* IC =
new TH2F(
"IC",
"IC", 720, -acos(-1.), acos(-1.), 600, -3., 3.);
526 IC->GetYaxis()->SetTitle(
"eta");
527 IC->GetXaxis()->SetTitle(
"phi");
528 TH2F* tpgFactor =
new TH2F(
"tpgFactor",
"tpgFactor", 720, -acos(-1.), acos(-1.), 600, -3., 3.);
529 tpgFactor->GetYaxis()->SetTitle(
"eta");
530 tpgFactor->GetXaxis()->SetTitle(
"phi");
532 TH1F* hshapeEB =
new TH1F(
"shapeEB",
"shapeEB", 250, 0., 10.);
533 TH1F* hshapeEE =
new TH1F(
"shapeEE",
"shapeEE", 250, 0., 10.);
535 TTree*
ntuple =
new TTree(
"tpgmap",
"TPG geometry map");
537 "fed",
"tcc",
"tower",
"stripInTower",
"xtalInStrip",
"CCU",
"VFE",
"xtalInVFE",
"xtalInCCU",
538 "ieta",
"iphi",
"ix",
"iy",
"iz",
"hashedId",
"ic",
"cmsswId",
"dbId",
539 "ietaTT",
"iphiTT",
"TCCch",
"TCCslot",
"SLBch",
"SLBslot",
"ietaGCT",
"iphiGCT"};
541 for (
int i = 0;
i < 26;
i++)
546 TNtuple* ntupleSpike =
new TNtuple(
"spikeParam",
"Spike parameters",
"gainId:theta:G:g:ped:pedLin");
551 list<uint32_t> towerListEB;
552 list<uint32_t> stripListEB;
553 list<uint32_t> towerListEE;
554 list<uint32_t> stripListEE;
555 list<uint32_t>::iterator itList;
557 map<int, uint32_t> stripMapEB;
558 map<uint32_t, uint32_t> stripMapEBsintheta;
565 ss <<
"Getting the pedestals from offline DB...\n";
573 for (pedIter = pedMapEB.begin(); pedIter != pedMapEB.end() && nPed < 10; ++pedIter, ++nPed) {
574 const auto aped = (*pedIter);
575 ss << aped.mean_x12 <<
", " << aped.mean_x6 <<
", " << aped.mean_x1 <<
"\n";
577 for (pedIter = pedMapEE.begin(); pedIter != pedMapEE.end() && nPed < 10; ++pedIter, ++nPed) {
578 const auto aped = (*pedIter);
579 ss << aped.mean_x12 <<
", " << aped.mean_x6 <<
", " << aped.mean_x1 <<
"\n";
582 ss <<
"Getting the pedestals from previous configuration\n";
588 ss <<
"trying to read previous tag if it exists tag=" <<
tag_ <<
".version" <<
version_ <<
"\n";
596 std::map<EcalLogicID, FEConfigPedDat> dataset_TpgPed;
599 typedef std::map<EcalLogicID, FEConfigPedDat>::const_iterator CIfeped;
603 for (CIfeped
p = dataset_TpgPed.begin();
p != dataset_TpgPed.end();
p++) {
610 if (ecid_name ==
"EB_crystal_number") {
611 int sm_num = ecid_xt.
getID1();
612 int xt_num = ecid_xt.
getID2();
624 ss <<
" copy the EB data "
625 <<
" ped = " <<
item.mean_x12 <<
"\n";
630 }
else if (ecid_name ==
"EE_crystal_number") {
655 for (pedIter = pedMapEB.begin(); pedIter != pedMapEB.end() && nPed < 10; ++pedIter, ++nPed) {
656 const auto aped = (*pedIter);
657 ss << aped.mean_x12 <<
", " << aped.mean_x6 <<
", " << aped.mean_x1 <<
"\n";
659 for (pedIter = pedMapEE.begin(); pedIter != pedMapEE.end() && nPed < 10; ++pedIter, ++nPed) {
660 const auto aped = (*pedIter);
661 ss << aped.mean_x12 <<
", " << aped.mean_x6 <<
", " << aped.mean_x1 <<
"\n";
665 ss <<
"Getting the pedestals from configuration number" <<
m_write_ped <<
"\n";
672 std::map<EcalLogicID, FEConfigPedDat> dataset_TpgPed;
675 typedef std::map<EcalLogicID, FEConfigPedDat>::const_iterator CIfeped;
679 for (CIfeped
p = dataset_TpgPed.begin();
p != dataset_TpgPed.end();
p++) {
686 if (ecid_name ==
"EB_crystal_number") {
689 <<
" icells = " << icells <<
"\n";
690 int sm_num = ecid_xt.
getID1();
691 int xt_num = ecid_xt.
getID2();
704 }
else if (ecid_name ==
"EE_crystal_number") {
729 for (pedIter = pedMapEB.begin(); pedIter != pedMapEB.end() && nPed < 10; ++pedIter, ++nPed) {
730 const auto aped = (*pedIter);
731 ss << aped.mean_x12 <<
", " << aped.mean_x6 <<
", " << aped.mean_x1 <<
"\n";
733 for (pedIter = pedMapEE.begin(); pedIter != pedMapEE.end() && nPed < 10; ++pedIter, ++nPed) {
734 const auto aped = (*pedIter);
735 ss << aped.mean_x12 <<
", " << aped.mean_x6 <<
", " << aped.mean_x1 <<
"\n";
743 ss <<
"Getting intercalib from offline DB...\n";
750 for (calIter = calibMapEB.begin(); calIter != calibMapEB.end() && nCal < 10; ++calIter, ++nCal) {
751 ss << (*calIter) <<
"\n";
753 for (calIter = calibMapEE.begin(); calIter != calibMapEE.end() && nCal < 10; ++calIter, ++nCal) {
754 ss << (*calIter) <<
"\n";
758 float calibvec[1700];
760 edm::LogInfo(
"TopInfo") <<
"H2: overwriting IC coef with file"
766 if (calibfile.is_open()) {
767 calibfile >> strdata >> strdata >> strdata >> strdata >> strdata;
768 while (!calibfile.eof()) {
769 calibfile >> idata >> icry >> fcali >> fdata >> fdata;
770 calibvec[icry - 1] = fcali;
771 if (calibfile.eof()) {
779 ss <<
"Getting the gain ratios from offline DB...\n";
785 for (gainIter = gainMapEB.begin(); gainIter != gainMapEB.end() && nGain < 10; ++gainIter, ++nGain) {
786 const auto aGain = (*gainIter);
787 ss << aGain.gain12Over6() <<
", " << aGain.gain6Over1() * aGain.gain12Over6() <<
"\n";
789 for (gainIter = gainMapEE.begin(); gainIter != gainMapEE.end() && nGain < 10; ++gainIter, ++nGain) {
790 const auto aGain = (*gainIter);
791 ss << aGain.gain12Over6() <<
", " << aGain.gain6Over1() * aGain.gain12Over6() <<
"\n";
797 ss <<
"Getting the ADC to GeV from offline DB...\n";
804 vector<EcalLogicID> my_EcalLogicId;
805 vector<EcalLogicID> my_TTEcalLogicId;
806 vector<EcalLogicID> my_StripEcalLogicId;
810 vector<EcalLogicID> my_TTEcalLogicId_EE;
811 vector<EcalLogicID> my_RTEcalLogicId_EE;
812 vector<EcalLogicID> my_StripEcalLogicId1_EE;
813 vector<EcalLogicID> my_StripEcalLogicId2_EE;
814 vector<EcalLogicID> my_CrystalEcalLogicId_EE;
815 vector<EcalLogicID> my_TTEcalLogicId_EB_by_TCC;
816 vector<EcalLogicID> my_StripEcalLogicId_EE_strips_by_TCC;
825 "EB_VFE", 1, 36, 1, 68, 1, 5,
"EB_VFE", 123);
826 ss <<
"got the 3 ecal barrel logic id set\n";
829 my_CrystalEcalLogicId_EE =
834 my_StripEcalLogicId1_EE =
838 my_StripEcalLogicId2_EE =
843 my_StripEcalLogicId_EE_strips_by_TCC =
865 ss <<
"Getting the latest ids for this tag (latest version) "
871 ss <<
"trying to read previous tag if it exists tag=" <<
tag_ <<
".version" <<
version_ <<
"\n";
897 map<EcalLogicID, FEConfigPedDat> pedset;
898 map<EcalLogicID, FEConfigLinDat> linset;
899 map<EcalLogicID, FEConfigLinParamDat> linparamset;
900 map<EcalLogicID, FEConfigLUTParamDat> lutparamset;
901 map<EcalLogicID, FEConfigFgrParamDat> fgrparamset;
903 map<int, linStruc> linEtaSlice;
907 int NbOfStripPerTCC[108][68];
908 for (
int i = 0;
i < 108;
i++)
909 for (
int j = 0;
j < 68;
j++)
910 NbOfStripPerTCC[
i][
j] = 0;
913 for (vector<DetId>::const_iterator it = ebCells.begin(); it != ebCells.end(); ++it) {
920 if (stripInTower > NbOfStripPerTCC[tccNb - 1][towerInTCC - 1])
921 NbOfStripPerTCC[tccNb - 1][towerInTCC - 1] = stripInTower;
923 for (vector<DetId>::const_iterator it = eeCells.begin(); it != eeCells.end(); ++it) {
930 if (stripInTower > NbOfStripPerTCC[tccNb - 1][towerInTCC - 1])
931 NbOfStripPerTCC[tccNb - 1][towerInTCC - 1] = stripInTower;
936 (*out_file_) <<
"COMMENT ====== barrel crystals ====== " << std::endl;
939 for (vector<DetId>::const_iterator it = ebCells.begin(); it != ebCells.end(); ++it) {
954 int xtalInVFE = Id.
xtalId();
955 int xtalWithinCCUid = 5 * (VFEid - 1) + xtalInVFE - 1;
957 (*geomFile_) <<
"dccNb = " << dccNb <<
" tccNb = " << tccNb <<
" towerInTCC = " << towerInTCC
958 <<
" stripInTower = " << stripInTower <<
" xtalInStrip = " << xtalInStrip <<
" CCUid = " << CCUid
959 <<
" VFEid = " << VFEid <<
" xtalInVFE = " << xtalInVFE <<
" xtalWithinCCUid = " << xtalWithinCCUid
960 <<
" ieta = " <<
id.ieta() <<
" iphi = " <<
id.iphi() <<
" xtalhashedId = " <<
id.hashedIndex()
961 <<
" xtalNb = " <<
id.ic() <<
" ietaTT = " << towid.
ieta() <<
" iphiTT = " << towid.
iphi() << endl;
963 int TCCch = towerInTCC;
964 int SLBslot =
int((towerInTCC - 1) / 8.) + 1;
965 int SLBch = (towerInTCC - 1) % 8 + 1;
966 int cmsswId =
id.rawId();
967 int ixtal = (
id.ism() - 1) * 1700 + (
id.ic() - 1);
970 int val[] = {dccNb + 600,
996 for (
int i = 0;
i < 26;
i++)
1003 if (tccNb == 37 && stripInTower == 3 && xtalInStrip == 3 && (towerInTCC - 1) % 4 == 0) {
1004 int etaSlice = towid.
ietaAbs();
1009 getCoeff(coeff, calibMap, laserAlphaMap,
id.rawId(),
str);
1011 getCoeff(coeff, gainMap,
id.rawId());
1012 getCoeff(coeff, pedMap,
id.rawId());
1014 for (
int i = 0;
i < 3;
i++) {
1018 edm::LogError(
"TopInfo") <<
"unable to compute the parameters for SM=" <<
id.ism() <<
" xt=" <<
id.ic() <<
" "
1019 <<
dec <<
id.rawId() <<
"\n";
1031 ss <<
"SM=" <<
id.ism() <<
" xt=" <<
id.ic() <<
" " <<
dec <<
id.rawId() <<
"\n";
1032 linEtaSlice[etaSlice] = lin;
1037 for (vector<DetId>::const_iterator it = ebCells.begin(); it != ebCells.end(); ++it) {
1043 towerListEB.push_back(towid.
rawId());
1045 stripListEB.push_back(elId.
rawId() & 0xfffffff8);
1054 int xtalInVFE = Id.
xtalId();
1055 int xtalWithinCCUid = 5 * (VFEid - 1) + xtalInVFE - 1;
1056 int etaSlice = towid.
ietaAbs();
1059 int hashedStripLogicID = 68 * 5 * (
id.ism() - 1) + 5 * (towerInTCC - 1) + (VFEid - 1);
1060 stripMapEB[hashedStripLogicID] = elId.
rawId() & 0xfffffff8;
1078 (*out_file_) <<
"CRYSTAL " <<
dec <<
id.rawId() << std::endl;
1085 getCoeff(coeff, calibMap, laserAlphaMap,
id.rawId(),
str);
1090 getCoeff(coeff, gainMap,
id.rawId());
1091 getCoeff(coeff, pedMap,
id.rawId());
1097 vector<int> xtalCCU;
1098 xtalCCU.push_back(dccNb + 600);
1099 xtalCCU.push_back(CCUid);
1100 xtalCCU.push_back(xtalWithinCCUid);
1101 xtalCCU.push_back(
id.rawId());
1106 map<int, linStruc>::const_iterator itLin = linEtaSlice.find(etaSlice);
1107 if (itLin != linEtaSlice.end()) {
1108 linMap[xtalCCU] = itLin->second;
1110 for (
int i = 0;
i < 3;
i++)
1111 (*
out_file_) << hex <<
" 0x" << itLin->second.pedestal_[
i] <<
" 0x" << itLin->second.mult_[
i] <<
" 0x"
1112 << itLin->second.shift_[
i] << std::endl;
1115 for (
int i = 0;
i < 3;
i++) {
1120 }
else if (
i == 1) {
1124 }
else if (
i == 2) {
1137 ss <<
"current EtaSlice = " << etaSlice <<
" not found in the EtaSlice map"
1142 int forceBase12 = 0;
1143 double invSinTheta = 1. /
sin(
theta);
1144 for (
int i = 0;
i < 3;
i++) {
1148 edm::LogError(
"TopInfo") <<
"unable to compute the parameters for SM=" <<
id.ism() <<
" xt=" <<
id.ic() <<
" "
1149 <<
dec <<
id.rawId() <<
"\n";
1161 double g =
G * invSinTheta;
1186 ss <<
"SM=" <<
id.ism() <<
" xt=" <<
id.ic() <<
" " <<
dec <<
id.rawId() <<
"\n";
1188 for (
int i = 0;
i < 3;
i++) {
1197 }
else if (
i == 1) {
1201 }
else if (
i == 2) {
1215 double g =
G * invSinTheta;
1222 ntupleSpike->Fill(
val);
1224 linMap[xtalCCU] = lin;
1228 int ixtal = (
id.ism() - 1) * 1700 + (
id.ic() - 1);
1230 pedset[logicId] = pedDB;
1231 linset[logicId] = linDB;
1239 linparamset[my_EcalLogicId_EB] = linparam;
1246 fgrparamset[my_EcalLogicId_EB] = fgrparam;
1252 lutparamset[my_EcalLogicId_EB] = lutparam;
1257 (*out_file_) <<
"COMMENT ====== endcap crystals ====== " << std::endl;
1260 for (vector<DetId>::const_iterator it = eeCells.begin(); it != eeCells.end(); ++it) {
1268 int dccNb = Id.
dccId();
1275 int xtalInVFE = Id.
xtalId();
1276 int xtalWithinCCUid = 5 * (VFEid - 1) + xtalInVFE - 1;
1278 (*geomFile_) <<
"dccNb = " << dccNb <<
" tccNb = " << tccNb <<
" towerInTCC = " << towerInTCC
1279 <<
" stripInTower = " << stripInTower <<
" xtalInStrip = " << xtalInStrip <<
" CCUid = " << CCUid
1280 <<
" VFEid = " << VFEid <<
" xtalInVFE = " << xtalInVFE <<
" xtalWithinCCUid = " << xtalWithinCCUid
1281 <<
" ix = " <<
id.ix() <<
" iy = " <<
id.iy() <<
" xtalhashedId = " <<
id.hashedIndex()
1282 <<
" xtalNb = " <<
id.isc() <<
" ietaTT = " << towid.
ieta() <<
" iphiTT = " << towid.
iphi() << endl;
1284 int TCCch = stripInTower;
1286 if (towerInTCC < 5) {
1288 SLBch = 4 + towerInTCC;
1290 SLBslot =
int((towerInTCC - 5) / 8.) + 2;
1291 SLBch = (towerInTCC - 5) % 8 + 1;
1293 for (
int j = 0;
j < towerInTCC - 1;
j++)
1294 TCCch += NbOfStripPerTCC[tccNb - 1][
j];
1296 int cmsswId =
id.rawId();
1298 int iz =
id.positiveZ();
1301 for (
int k = 0;
k < (
int)my_CrystalEcalLogicId_EE.size();
k++) {
1302 int z = my_CrystalEcalLogicId_EE[
k].getID1();
1303 int x = my_CrystalEcalLogicId_EE[
k].getID2();
1304 int y = my_CrystalEcalLogicId_EE[
k].getID3();
1305 if (
id.ix() ==
x &&
id.iy() ==
y && iz ==
z)
1306 logicId = my_CrystalEcalLogicId_EE[
k];
1310 int val[] = {dccNb + 600,
1336 for (
int i = 0;
i < 26;
i++)
1342 if ((tccNb == 76 || tccNb == 94) && stripInTower == 1 && xtalInStrip == 3 && (towerInTCC - 1) % 4 == 0) {
1343 int etaSlice = towid.
ietaAbs();
1348 getCoeff(coeff, calibMap, laserAlphaMap,
id.rawId(),
str);
1350 getCoeff(coeff, gainMap,
id.rawId());
1351 getCoeff(coeff, pedMap,
id.rawId());
1353 for (
int i = 0;
i < 3;
i++) {
1357 edm::LogError(
"TopInfo") <<
"unable to compute the parameters for Quadrant=" <<
id.iquadrant()
1358 <<
" xt=" <<
id.ic() <<
" " <<
dec <<
id.rawId() <<
"\n";
1370 ss <<
"Quadrant=" <<
id.iquadrant() <<
" xt=" <<
id.ic() <<
" " <<
dec <<
id.rawId() <<
"\n";
1372 linEtaSlice[etaSlice] = lin;
1377 for (vector<DetId>::const_iterator it = eeCells.begin(); it != eeCells.end(); ++it) {
1385 towerListEE.push_back(towid.
rawId());
1389 towerListEE.push_back(additionalTower.rawId());
1391 stripListEE.push_back(elId.
rawId() & 0xfffffff8);
1392 int dccNb = Id.
dccId();
1399 int xtalInVFE = Id.
xtalId();
1400 int xtalWithinCCUid = 5 * (VFEid - 1) + xtalInVFE - 1;
1401 int etaSlice = towid.
ietaAbs();
1407 (*out_file_) <<
"CRYSTAL " <<
dec <<
id.rawId() << std::endl;
1409 int iz =
id.positiveZ();
1412 for (
int k = 0;
k < (
int)my_CrystalEcalLogicId_EE.size();
k++) {
1413 int z = my_CrystalEcalLogicId_EE[
k].getID1();
1414 int x = my_CrystalEcalLogicId_EE[
k].getID2();
1415 int y = my_CrystalEcalLogicId_EE[
k].getID3();
1416 if (
id.ix() ==
x &&
id.iy() ==
y && iz ==
z)
1417 logicId = my_CrystalEcalLogicId_EE[
k];
1425 getCoeff(coeff, calibMap, laserAlphaMap,
id.rawId(),
str);
1427 getCoeff(coeff, gainMap,
id.rawId());
1428 getCoeff(coeff, pedMap,
id.rawId());
1430 ICEEPlus->Fill(
id.ix(),
id.iy(), coeff.
calibCoeff_);
1432 ICEEMinus->Fill(
id.ix(),
id.iy(), coeff.
calibCoeff_);
1437 vector<int> xtalCCU;
1438 xtalCCU.push_back(dccNb + 600);
1439 xtalCCU.push_back(CCUid);
1440 xtalCCU.push_back(xtalWithinCCUid);
1441 xtalCCU.push_back(
id.rawId());
1446 map<int, linStruc>::const_iterator itLin = linEtaSlice.find(etaSlice);
1447 if (itLin != linEtaSlice.end()) {
1448 linMap[xtalCCU] = itLin->second;
1450 for (
int i = 0;
i < 3;
i++)
1451 (*
out_file_) << hex <<
" 0x" << itLin->second.pedestal_[
i] <<
" 0x" << itLin->second.mult_[
i] <<
" 0x"
1452 << itLin->second.shift_[
i] << std::endl;
1455 for (
int i = 0;
i < 3;
i++) {
1460 }
else if (
i == 1) {
1464 }
else if (
i == 2) {
1473 tpgFactorEEPlus->Fill(
id.ix(),
id.iy(),
factor);
1475 tpgFactorEEMinus->Fill(
id.ix(),
id.iy(),
factor);
1480 ss <<
"current EtaSlice = " << etaSlice <<
" not found in the EtaSlice map"
1485 for (
int i = 0;
i < 3;
i++) {
1489 edm::LogError(
"TopInfo") <<
"unable to compute the parameters for " <<
dec <<
id.rawId() <<
"\n";
1501 ss <<
"Quadrant=" <<
id.iquadrant() <<
" xt=" <<
id.ic() <<
" " <<
dec <<
id.rawId() <<
"\n";
1503 for (
int i = 0;
i < 3;
i++) {
1512 }
else if (
i == 1) {
1516 }
else if (
i == 2) {
1525 tpgFactorEEPlus->Fill(
id.ix(),
id.iy(),
factor);
1527 tpgFactorEEMinus->Fill(
id.ix(),
id.iy(),
factor);
1533 linMap[xtalCCU] = lin;
1536 pedset[logicId] = pedDB;
1537 linset[logicId] = linDB;
1547 linparamset[my_EcalLogicId_EE] = linparam;
1553 lutparamset[my_EcalLogicId_EE] = lutparam;
1558 fgrparamset[my_EcalLogicId_EE] = fgrparam;
1566 ss <<
" LIN tag " << lin_tag <<
"\n";
1571 ss <<
"the ped id =" <<
ped_conf_id_ <<
" will be used for the pedestals "
1583 evgueni <<
"void getLinParamTPG_hardcoded(int fed, int ccu, int xtal," << endl;
1584 evgueni <<
" int & mult12, int & shift12, int & base12," << endl;
1585 evgueni <<
" int & mult6, int & shift6, int & base6," << endl;
1586 evgueni <<
" int & mult1, int & shift1, int & base1)" << endl;
1587 evgueni <<
"{" << endl;
1588 evgueni <<
" mult12 = 0 ; shift12 = 0 ; base12 = 0 ; mult6 = 0 ; shift6 = 0 ; base6 = 0 ; mult1 = 0 ; shift1 = 0 ; "
1591 map<vector<int>,
linStruc>::const_iterator itLinMap;
1592 for (itLinMap = linMap.begin(); itLinMap != linMap.end(); itLinMap++) {
1593 vector<int> xtalInCCU = itLinMap->first;
1594 evgueni <<
" if (fed==" << xtalInCCU[0] <<
" && ccu==" << xtalInCCU[1] <<
" && xtal==" << xtalInCCU[2] <<
") {";
1595 evgueni <<
" mult12 = " << itLinMap->second.
mult_[0] <<
" ; shift12 = " << itLinMap->second.shift_[0]
1596 <<
" ; base12 = " << itLinMap->second.pedestal_[0] <<
" ; ";
1597 evgueni <<
" mult6 = " << itLinMap->second.mult_[1] <<
" ; shift6 = " << itLinMap->second.shift_[1]
1598 <<
" ; base6 = " << itLinMap->second.pedestal_[1] <<
" ; ";
1599 evgueni <<
" mult1 = " << itLinMap->second.mult_[2] <<
" ; shift1 = " << itLinMap->second.shift_[2]
1600 <<
" ; base1 = " << itLinMap->second.pedestal_[2] <<
" ; ";
1601 evgueni <<
" return ;}" << endl;
1603 evgueni <<
"}" << endl;
1610 const int NWEIGROUPS = 2;
1611 std::vector<unsigned int>
weights[NWEIGROUPS];
1621 map<EcalLogicID, FEConfigWeightGroupDat>
dataset;
1623 for (
int igrp = 0; igrp < NWEIGROUPS; igrp++) {
1626 (*out_file_) << std::endl;
1627 (*out_file_) <<
"WEIGHT " << igrp << endl;
1630 (*out_file_) << std::endl;
1631 (*out_file_) << std::endl;
1634 ss <<
"going to write the weights for groupe:" << igrp <<
"\n";
1653 map<EcalLogicID, FEConfigWeightDat> dataset2;
1656 for (
int ich = 0; ich < (
int)my_StripEcalLogicId.size(); ich++) {
1660 dataset2[my_StripEcalLogicId[ich]] = wut;
1664 for (
int ich = 0; ich < (
int)my_StripEcalLogicId1_EE.size(); ich++) {
1669 dataset2[my_StripEcalLogicId1_EE[ich]] = wut;
1672 for (
int ich = 0; ich < (
int)my_StripEcalLogicId2_EE.size(); ich++) {
1677 dataset2[my_StripEcalLogicId2_EE[ich]] = wut;
1683 wtag <<
"Shape_NGroups_" << NWEIGROUPS;
1685 ss <<
" weight tag " << weight_tag <<
"\n";
1697 unsigned int lowRatio, highRatio, lowThreshold, highThreshold, lutFG;
1700 (*out_file_) << std::endl;
1701 (*out_file_) <<
"FG 0" << std::endl;
1702 (*out_file_) << hex <<
"0x" << lowThreshold <<
" 0x" << highThreshold <<
" 0x" << lowRatio <<
" 0x" << highRatio
1703 <<
" 0x" << lutFG << std::endl;
1708 unsigned int lut_strip;
1714 ss <<
"going to write the fgr "
1716 map<EcalLogicID, FEConfigFgrGroupDat>
dataset;
1719 for (
int ich = 0; ich < NFGRGROUPS; ich++) {
1733 map<EcalLogicID, FEConfigFgrDat> dataset2;
1735 for (
int ich = 0; ich < (
int)my_TTEcalLogicId.size(); ich++) {
1742 dataset2[my_TTEcalLogicId[ich]] = wut;
1746 for (
int ich = 0; ich < (
int)my_RTEcalLogicId_EE.size(); ich++) {
1754 dataset2[my_RTEcalLogicId_EE[ich]] = wut;
1758 map<EcalLogicID, FEConfigFgrEETowerDat> dataset3;
1759 for (
int ich = 0; ich < (
int)my_TTEcalLogicId_EE.size(); ich++) {
1762 dataset3[my_TTEcalLogicId_EE[ich]] = fgreett;
1767 map<EcalLogicID, FEConfigFgrEEStripDat> dataset4;
1768 for (
int ich = 0; ich < (
int)my_StripEcalLogicId1_EE.size(); ich++) {
1772 dataset4[my_StripEcalLogicId1_EE[ich]] = zut;
1774 for (
int ich = 0; ich < (
int)my_StripEcalLogicId2_EE.size(); ich++) {
1779 dataset4[my_StripEcalLogicId2_EE[ich]] = zut;
1781 for (
int ich = 0; ich < (
int)my_StripEcalLogicId.size(); ich++) {
1785 uint32_t elStripId = stripMapEB[ich];
1786 map<uint32_t, uint32_t>::const_iterator it = stripMapEBsintheta.find(elStripId);
1787 if (it != stripMapEBsintheta.end())
1790 edm::LogError(
"TopInfo") <<
"ERROR: strip SFGVB threshold parameter not found for that strip:"
1791 << thestrip.
getID1() <<
" " << thestrip.
getID3() <<
" " << thestrip.
getID3() <<
"\n";
1797 dataset4[thestrip] = zut;
1805 ss <<
" weight tag " << weight_tag <<
"\n";
1811 map<EcalLogicID, FEConfigSpikeDat> datasetspike;
1812 for (
int ich = 0; ich < (
int)my_TTEcalLogicId.size(); ich++) {
1815 datasetspike[my_TTEcalLogicId[ich]] = spiketh;
1823 ss <<
" spike tag " << spike_tag <<
"\n";
1829 map<EcalLogicID, FEConfigTimingDat>
1831 for (
int ich = 0; ich < (
int)my_TTEcalLogicId_EB_by_TCC.size(); ich++) {
1834 EcalLogicID logiciddelay = my_TTEcalLogicId_EB_by_TCC[ich];
1835 int id1_tcc = my_TTEcalLogicId_EB_by_TCC[ich].
getID1();
1836 int id2_tt = my_TTEcalLogicId_EB_by_TCC[ich].getID2();
1837 std::map<int, vector<int> >::const_iterator ittEB =
delays_EB_.find(id1_tcc);
1838 std::vector<int> TimingDelaysEB = ittEB->second;
1841 if (TimingDelaysEB[id2_tt - 1] == -1) {
1842 edm::LogError(
"TopInfo") <<
"ERROR: Barrel timing delay not specified, check file, putting default value 1"
1844 delay.setTimingPar1(1);
1846 delay.setTimingPar1(TimingDelaysEB[id2_tt - 1]);
1848 edm::LogError(
"TopInfo") <<
"ERROR:Barrel Could not find delay parameter for that trigger tower "
1852 delay.setTimingPar1(1);
1855 std::map<int, vector<int> >::const_iterator ittpEB =
phases_EB_.find(id1_tcc);
1856 std::vector<int> TimingPhasesEB = ittpEB->second;
1859 if (TimingPhasesEB[id2_tt - 1] == -1) {
1860 edm::LogError(
"TopInfo") <<
"ERROR: Barrel timing phase not specified, check file, putting default value 0"
1862 delay.setTimingPar2(0);
1864 delay.setTimingPar2(TimingPhasesEB[id2_tt - 1]);
1866 edm::LogError(
"TopInfo") <<
"ERROR:Barrel Could not find phase parameter for that trigger tower "
1870 delay.setTimingPar2(0);
1873 ss << ich <<
" tcc=" << id1_tcc <<
" TT=" << id2_tt <<
" logicId=" << logiciddelay.
getLogicID()
1874 <<
" delay=" << TimingDelaysEB[id2_tt - 1] <<
" phase=" << TimingPhasesEB[id2_tt - 1] <<
"\n";
1878 datasetdelay[my_TTEcalLogicId_EB_by_TCC[ich]] =
delay;
1884 for (
int ich = 0; ich < (
int)my_StripEcalLogicId_EE_strips_by_TCC.size(); ich++) {
1890 EcalLogicID logiciddelay = my_StripEcalLogicId_EE_strips_by_TCC[ich];
1891 int id1_tcc = my_StripEcalLogicId_EE_strips_by_TCC[ich].
getID1();
1892 int id2_tt = my_StripEcalLogicId_EE_strips_by_TCC[ich].getID2();
1893 int id3_st = my_StripEcalLogicId_EE_strips_by_TCC[ich].getID3();
1896 if (id1_tcc != tccin) {
1901 std::map<int, vector<int> >::const_iterator ittEE =
delays_EE_.find(id1_tcc);
1902 std::vector<int> TimingDelaysEE = ittEE->second;
1905 if (TimingDelaysEE[stripindex] == -1) {
1906 edm::LogError(
"TopInfo") <<
"ERROR: Endcap timing delay not specified, check file, putting default value 1"
1908 delay.setTimingPar1(1);
1910 delay.setTimingPar1(TimingDelaysEE[stripindex]);
1912 edm::LogError(
"TopInfo") <<
"ERROR:Endcap Could not find delay parameter for that trigger tower "
1916 delay.setTimingPar1(1);
1919 std::map<int, vector<int> >::const_iterator ittpEE =
phases_EE_.find(id1_tcc);
1920 std::vector<int> TimingPhasesEE = ittpEE->second;
1923 if (TimingPhasesEE[stripindex] == -1) {
1924 edm::LogError(
"TopInfo") <<
"ERROR: Endcap timing phase not specified, check file, putting default value 0"
1926 delay.setTimingPar2(0);
1928 delay.setTimingPar2(TimingPhasesEE[stripindex]);
1930 edm::LogError(
"TopInfo") <<
"ERROR:Endcap Could not find phase parameter for that trigger tower "
1934 delay.setTimingPar2(0);
1937 ss << ich <<
" stripindex=" << stripindex <<
" tcc=" << id1_tcc <<
" TT=" << id2_tt <<
" id3_st=" << id3_st
1938 <<
" logicId=" << logiciddelay.
getLogicID() <<
" delay=" << TimingDelaysEE[stripindex]
1939 <<
" phase=" << TimingPhasesEE[stripindex] <<
"\n";
1943 datasetdelay[my_StripEcalLogicId_EE_strips_by_TCC[ich]] =
delay;
1947 ostringstream de_tag;
1949 de_tag <<
"DelaysFromFile";
1951 ss <<
" delay tag " << delay_tag <<
"\n";
1958 ss <<
"going to write the sliding "
1960 map<EcalLogicID, FEConfigSlidingDat>
dataset;
1962 for (
int ich = 0; ich < (
int)my_StripEcalLogicId.size(); ich++) {
1968 dataset[my_StripEcalLogicId[ich]] = wut;
1972 for (
int ich = 0; ich < (
int)my_StripEcalLogicId1_EE.size(); ich++) {
1978 dataset[my_StripEcalLogicId1_EE[ich]] = wut;
1980 for (
int ich = 0; ich < (
int)my_StripEcalLogicId2_EE.size(); ich++) {
1986 dataset[my_StripEcalLogicId2_EE[ich]] = wut;
1994 ss <<
" sliding tag " << justatag <<
"\n";
2004 int lut_EB[1024], lut_EE[1024];
2009 (*out_file_) << std::endl;
2010 (*out_file_) <<
"LUT 0" << std::endl;
2011 for (
int i = 0;
i < 1024;
i++)
2012 (*
out_file_) <<
"0x" << hex << lut_EB[
i] << endl;
2013 (*out_file_) << endl;
2020 for (
int i = 0;
i < 1024;
i++)
2021 if (lut_EE[
i] != lut_EB[
i])
2024 (*out_file_) << std::endl;
2025 (*out_file_) <<
"LUT 1" << std::endl;
2026 for (
int i = 0;
i < 1024;
i++)
2027 (*
out_file_) <<
"0x" << hex << lut_EE[
i] << endl;
2028 (*out_file_) << endl;
2032 map<EcalLogicID, FEConfigLUTGroupDat>
dataset;
2038 for (
int i = 0;
i < 1024;
i++) {
2049 for (
int i = 0;
i < 1024;
i++) {
2061 map<EcalLogicID, FEConfigLUTDat> dataset2;
2063 for (
int ich = 0; ich < (
int)my_TTEcalLogicId.size(); ich++) {
2069 dataset2[my_TTEcalLogicId[ich]] = lut;
2073 for (
int ich = 0; ich < (
int)my_TTEcalLogicId_EE.size(); ich++) {
2079 dataset2[my_TTEcalLogicId_EE[ich]] = lut;
2087 ss <<
" LUT tag " << lut_tag <<
"\n";
2110 ss <<
"\n Conf ID = " << conf_id_ <<
"\n";
2119 stripListEB.unique();
2120 ss <<
"Number of EB strips=" <<
dec << stripListEB.size() <<
"\n";
2122 (*out_file_) << std::endl;
2123 for (itList = stripListEB.begin(); itList != stripListEB.end(); itList++) {
2124 (*out_file_) <<
"STRIP_EB " <<
dec << (*itList) << endl;
2125 (*out_file_) << hex <<
"0x" <<
sliding_ << std::endl;
2126 (*out_file_) <<
"0" << std::endl;
2127 (*out_file_) <<
"0x" << stripMapEBsintheta[(*itList)] <<
" 0x" <<
SFGVB_lut_ << std::endl;
2133 stripListEE.unique();
2134 ss <<
"Number of EE strips=" <<
dec << stripListEE.size() <<
"\n";
2136 (*out_file_) << std::endl;
2137 for (itList = stripListEE.begin(); itList != stripListEE.end(); itList++) {
2138 (*out_file_) <<
"STRIP_EE " <<
dec << (*itList) << endl;
2139 (*out_file_) << hex <<
"0x" <<
sliding_ << std::endl;
2141 (*out_file_) <<
" 1" << std::endl;
2142 (*out_file_) << hex <<
"0x" <<
threshold <<
" 0x" << lut_strip << std::endl;
2154 towerListEB.unique();
2155 ss <<
"Number of EB towers=" <<
dec << towerListEB.size() <<
"\n";
2157 (*out_file_) << std::endl;
2158 for (itList = towerListEB.begin(); itList != towerListEB.end(); itList++) {
2159 (*out_file_) <<
"TOWER_EB " <<
dec << (*itList) << endl;
2160 (*out_file_) <<
" 0\n 0\n";
2167 towerListEE.unique();
2168 ss <<
"Number of EE towers=" <<
dec << towerListEE.size() <<
"\n";
2170 (*out_file_) << std::endl;
2171 for (itList = towerListEE.begin(); itList != towerListEE.end(); itList++) {
2172 (*out_file_) <<
"TOWER_EE " <<
dec << (*itList) << endl;
2174 (*out_file_) <<
" 1\n";
2177 (*out_file_) << hex <<
"0x" << lut_tower << std::endl;
2187 tpgFactorEB->Write();
2189 tpgFactorEEPlus->Write();
2191 tpgFactorEEMinus->Write();
2197 ntupleSpike->Write();
2202 using namespace edm;
2203 using namespace std;
2213 (*out_file_) <<
"PHYSICS_EB " <<
dec << eb.
rawId() << std::endl;
2218 (*out_file_) << std::endl;
2220 (*out_file_) <<
"PHYSICS_EE " <<
dec << ee.
rawId() << std::endl;
2222 (*out_file_) <<
FG_Threshold_EE_ <<
" " << -1 <<
" " << -1 <<
" " << -1 << std::endl;
2223 (*out_file_) << std::endl;
2251 if (subdet ==
"EE") {
2269 edm::LogError(
"TopInfo") <<
"too bad we did not manage to calculate the factor for calib=" << calibCoeff <<
"\n";
2276 (*out_file_) <<
"COMMENT put your comments here" << std::endl;
2278 (*out_file_) <<
"COMMENT =================================" << std::endl;
2279 (*out_file_) <<
"COMMENT physics EB structure" << std::endl;
2280 (*out_file_) <<
"COMMENT" << std::endl;
2281 (*out_file_) <<
"COMMENT EtSaturation (GeV), ttf_threshold_Low (GeV), ttf_threshold_High (GeV)" << std::endl;
2282 (*out_file_) <<
"COMMENT FG_lowThreshold (GeV), FG_highThreshold (GeV), FG_lowRatio, FG_highRatio" << std::endl;
2284 (*out_file_) <<
"COMMENT =================================" << std::endl;
2285 (*out_file_) <<
"COMMENT" << std::endl;
2287 (*out_file_) <<
"COMMENT =================================" << std::endl;
2288 (*out_file_) <<
"COMMENT physics EE structure" << std::endl;
2289 (*out_file_) <<
"COMMENT" << std::endl;
2290 (*out_file_) <<
"COMMENT EtSaturation (GeV), ttf_threshold_Low (GeV), ttf_threshold_High (GeV)" << std::endl;
2291 (*out_file_) <<
"COMMENT FG_Threshold (GeV), dummy, dummy, dummy" << std::endl;
2292 (*out_file_) <<
"COMMENT =================================" << std::endl;
2293 (*out_file_) <<
"COMMENT" << std::endl;
2295 (*out_file_) <<
"COMMENT =================================" << std::endl;
2296 (*out_file_) <<
"COMMENT crystal structure (same for EB and EE)" << std::endl;
2297 (*out_file_) <<
"COMMENT" << std::endl;
2298 (*out_file_) <<
"COMMENT ped, mult, shift [gain12]" << std::endl;
2299 (*out_file_) <<
"COMMENT ped, mult, shift [gain6]" << std::endl;
2300 (*out_file_) <<
"COMMENT ped, mult, shift [gain1]" << std::endl;
2301 (*out_file_) <<
"COMMENT =================================" << std::endl;
2302 (*out_file_) <<
"COMMENT" << std::endl;
2304 (*out_file_) <<
"COMMENT =================================" << std::endl;
2305 (*out_file_) <<
"COMMENT strip EB structure" << std::endl;
2306 (*out_file_) <<
"COMMENT" << std::endl;
2307 (*out_file_) <<
"COMMENT sliding_window" << std::endl;
2308 (*out_file_) <<
"COMMENT weightGroupId" << std::endl;
2309 (*out_file_) <<
"COMMENT threshold_sfg lut_sfg" << std::endl;
2310 (*out_file_) <<
"COMMENT =================================" << std::endl;
2311 (*out_file_) <<
"COMMENT" << std::endl;
2313 (*out_file_) <<
"COMMENT =================================" << std::endl;
2314 (*out_file_) <<
"COMMENT strip EE structure" << std::endl;
2315 (*out_file_) <<
"COMMENT" << std::endl;
2316 (*out_file_) <<
"COMMENT sliding_window" << std::endl;
2317 (*out_file_) <<
"COMMENT weightGroupId" << std::endl;
2318 (*out_file_) <<
"COMMENT threshold_fg lut_fg" << std::endl;
2319 (*out_file_) <<
"COMMENT =================================" << std::endl;
2320 (*out_file_) <<
"COMMENT" << std::endl;
2322 (*out_file_) <<
"COMMENT =================================" << std::endl;
2323 (*out_file_) <<
"COMMENT tower EB structure" << std::endl;
2324 (*out_file_) <<
"COMMENT" << std::endl;
2325 (*out_file_) <<
"COMMENT LUTGroupId" << std::endl;
2326 (*out_file_) <<
"COMMENT FgGroupId" << std::endl;
2327 (*out_file_) <<
"COMMENT spike_killing_threshold" << std::endl;
2328 (*out_file_) <<
"COMMENT =================================" << std::endl;
2329 (*out_file_) <<
"COMMENT" << std::endl;
2331 (*out_file_) <<
"COMMENT =================================" << std::endl;
2332 (*out_file_) <<
"COMMENT tower EE structure" << std::endl;
2333 (*out_file_) <<
"COMMENT" << std::endl;
2334 (*out_file_) <<
"COMMENT LUTGroupId" << std::endl;
2335 (*out_file_) <<
"COMMENT tower_lut_fg" << std::endl;
2336 (*out_file_) <<
"COMMENT =================================" << std::endl;
2337 (*out_file_) <<
"COMMENT" << std::endl;
2339 (*out_file_) <<
"COMMENT =================================" << std::endl;
2340 (*out_file_) <<
"COMMENT Weight structure" << std::endl;
2341 (*out_file_) <<
"COMMENT" << std::endl;
2342 (*out_file_) <<
"COMMENT weightGroupId" << std::endl;
2343 (*out_file_) <<
"COMMENT w0, w1, w2, w3, w4" << std::endl;
2344 (*out_file_) <<
"COMMENT =================================" << std::endl;
2345 (*out_file_) <<
"COMMENT" << std::endl;
2347 (*out_file_) <<
"COMMENT =================================" << std::endl;
2348 (*out_file_) <<
"COMMENT lut structure" << std::endl;
2349 (*out_file_) <<
"COMMENT" << std::endl;
2350 (*out_file_) <<
"COMMENT LUTGroupId" << std::endl;
2351 (*out_file_) <<
"COMMENT LUT[1-1024]" << std::endl;
2352 (*out_file_) <<
"COMMENT =================================" << std::endl;
2353 (*out_file_) <<
"COMMENT" << std::endl;
2355 (*out_file_) <<
"COMMENT =================================" << std::endl;
2356 (*out_file_) <<
"COMMENT fg EB structure" << std::endl;
2357 (*out_file_) <<
"COMMENT" << std::endl;
2358 (*out_file_) <<
"COMMENT FgGroupId" << std::endl;
2359 (*out_file_) <<
"COMMENT el, eh, tl, th, lut_fg" << std::endl;
2360 (*out_file_) <<
"COMMENT =================================" << std::endl;
2361 (*out_file_) <<
"COMMENT" << std::endl;
2363 (*out_file_) << std::endl;
2368 unsigned int max = (
unsigned int)(
pow(2., complement2) - 1);
2373 iweight = iweight &
max;
2378 double weight = double(iweight) /
pow(2., 6.);
2380 if ((iweight & (1 << (complement2 - 1))) != 0)
2381 weight = (double(iweight) -
pow(2., complement2)) /
pow(2., 6.);
2386 std::ostringstream
ss;
2387 ss <<
"Computing Weights...\n";
2398 for (
int subtime = 0; subtime < 25; subtime++)
2399 histo->Fill(
float(
sample * 25. + subtime) / 25., shape(
time + subtime));
2401 double lambda = 1. / (sumf2 - sumf * sumf /
nSample_);
2417 isumw += iweight[
sample];
2419 isumw = (isumw & imax);
2432 ss <<
"Weights: sum (weight*shape) = " << ampl <<
"\n";
2437 while (isumw != 0 &&
count < 10) {
2439 unsigned int index = 0;
2442 ss <<
"Correcting for bias: adding 1\n";
2444 int new_iweight = iweight[
sample] + 1;
2454 ss <<
"Correcting for bias: subtracting 1\n";
2456 int new_iweight = iweight[
sample] - 1;
2467 isumw += iweight[
sample];
2469 isumw = (isumw & imax);
2470 ss <<
"Correcting weight number: " <<
index <<
" sum weights = " << isumw <<
"\n";
2478 isumw += iweight[
sample];
2480 isumw = (isumw & imax);
2487 ampl += new_weight * shape(
time);
2488 ss <<
"weight unbiased after integer conversion=" << new_weight <<
" shape=" << shape(
time) <<
"\n";
2492 ss <<
"Weights: sum (weight*shape) = " << ampl <<
"\n";
2495 std::vector<unsigned int> theWeights;
2497 theWeights.push_back(iweight[
sample]);
2523 for (
int i = 0;
i < 1024;
i++) {
2532 for (
int i = 0;
i < 1024;
i++) {
2534 if ((
i + 1) % 4 == 0)
2543 func->SetParameters(LUT_stochastic, LUT_noise, LUT_constant);
2544 double norm =
func->Integral(0., Et_sat);
2545 for (
int i = 0;
i < 1024;
i++) {
2546 double Et =
i * Et_sat / 1024.;
2547 lut[
i] =
int(0xff *
func->Integral(0., Et) / norm + 0.5);
2552 for (
int j = 0;
j < 1024;
j++) {
2553 double Et_GeV = Et_sat / 1024 * (
j + 0.5);
2554 if (Et_GeV <= LUT_threshold)
2557 if (Et_GeV >= TTF_highThreshold)
2559 if (Et_GeV >= TTF_lowThreshold && Et_GeV < TTF_highThreshold)
2580 double alpha_factor = 1.0;
2583 icorr = itCorr->second;
2591 st =
"Transparency correction found for xtal " +
ss.str() +
" corr=" + ss1.str() +
" intercalib=" + ss2.str() +
2594 edm::LogError(
"TopInfo") <<
"ERROR = Transparency correction not found for xtal " << rawId <<
"\n";
2597 DetId ECALdetid(rawId);
2601 st +=
"DETID=" +
ss.str() +
"\n";
2605 if (italpha != laserAlphaMap.
end())
2606 alpha_factor = (*italpha);
2608 edm::LogError(
"TopInfo") <<
"ERROR:LaserAlphe parameter note found!!"
2614 if (italpha != laserAlphaMap.
end())
2615 alpha_factor = (*italpha);
2617 edm::LogError(
"TopInfo") <<
"ERROR:LaserAlphe parameter note found!!"
2631 ss2 << alpha_factor;
2632 st +=
"rawId " +
ss.str() +
" " + ss1.str() +
" " + ss2.str() +
"\n";
2633 if (icalit != calibMap.
end())
2639 edm::LogError(
"TopInfo") <<
"getCoeff: " << rawId <<
" not found in EcalIntercalibConstantMap"
2649 if (gainIter != gainMap.
end()) {
2654 edm::LogError(
"TopInfo") <<
"getCoeff: " << rawId <<
" not found in EcalGainRatioMap"
2672 if (pedIter != pedMap.
end()) {
2678 edm::LogError(
"TopInfo") <<
"getCoeff: " << rawId <<
" not found in EcalPedestalsMap\n";
2682 const map<EcalLogicID, MonPedestalsDat>& pedMap,
2689 map<EcalLogicID, MonPedestalsDat>::const_iterator it = pedMap.find(logicId);
2690 if (it != pedMap.end()) {
2697 <<
" not found in map<EcalLogicID, MonPedestalsDat\n";
2701 unsigned int& highRatio,
2702 unsigned int& lowThreshold,
2703 unsigned int& highThreshold,
2704 unsigned int& lut) {
2706 if (lowRatio > 0x7f)
2709 if (highRatio > 0x7f)
2715 if (lowThreshold > 0xff)
2716 lowThreshold = 0xff;
2718 if (highThreshold > 0xff)
2719 highThreshold = 0xff;
2735 unsigned int& lut_strip,
2736 unsigned int& lut_tower) {
2747 for (
int i = 1;
i < 3;
i++) {
2755 for (
int i = 0;
i < 3;
i++) {
2760 <<
" ==> forcing at 0"
2771 gctphi = (ttphi + 1) / 4;
2782 gcteta = (tteta - 1) / 4 + 11;
2784 gcteta = (tteta + 1) / 4 + 10;
2789 std::stringstream sdet;
2791 if (tcc > 36 && tcc < 55)
2792 sdet <<
"EB-" << tcc - 36;
2793 else if (tcc >= 55 && tcc < 73)
2794 sdet <<
"EB+" << tcc - 54;
2800 if (tcc <= 36 || tcc >= 73) {
2803 if (tcc == 1 || tcc == 18 || tcc == 19 || tcc == 36)
2805 else if (tcc == 2 || tcc == 3 || tcc == 20 || tcc == 21)
2807 else if (tcc == 4 || tcc == 5 || tcc == 22 || tcc == 23)
2809 else if (tcc == 6 || tcc == 7 || tcc == 24 || tcc == 25)
2811 else if (tcc == 8 || tcc == 9 || tcc == 26 || tcc == 27)
2813 else if (tcc == 10 || tcc == 11 || tcc == 28 || tcc == 29)
2815 else if (tcc == 12 || tcc == 13 || tcc == 30 || tcc == 31)
2817 else if (tcc == 14 || tcc == 15 || tcc == 32 || tcc == 33)
2819 else if (tcc == 16 || tcc == 17 || tcc == 34 || tcc == 35)
2827 std::stringstream crate;
2832 if (tcc >= 40 && tcc <= 42) {
2834 slot = 5 + (tcc - 40) * 6;
2836 if (tcc >= 43 && tcc <= 45) {
2838 slot = 5 + (tcc - 43) * 6;
2840 if (tcc >= 37 && tcc <= 39) {
2842 slot = 5 + (tcc - 37) * 6;
2844 if (tcc >= 52 && tcc <= 54) {
2846 slot = 5 + (tcc - 52) * 6;
2848 if (tcc >= 46 && tcc <= 48) {
2850 slot = 5 + (tcc - 46) * 6;
2852 if (tcc >= 49 && tcc <= 51) {
2854 slot = 5 + (tcc - 49) * 6;
2856 if (tcc >= 58 && tcc <= 60) {
2858 slot = 5 + (tcc - 58) * 6;
2860 if (tcc >= 61 && tcc <= 63) {
2862 slot = 5 + (tcc - 61) * 6;
2864 if (tcc >= 55 && tcc <= 57) {
2866 slot = 5 + (tcc - 55) * 6;
2868 if (tcc >= 70 && tcc <= 72) {
2870 slot = 5 + (tcc - 70) * 6;
2872 if (tcc >= 64 && tcc <= 66) {
2874 slot = 5 + (tcc - 64) * 6;
2876 if (tcc >= 67 && tcc <= 69) {
2878 slot = 5 + (tcc - 67) * 6;
2881 if (tcc >= 76 && tcc <= 81) {
2884 slot = 2 + (tcc - 76) * 3;
2886 slot = 4 + (tcc - 77) * 3;
2888 if (tcc >= 94 && tcc <= 99) {
2891 slot = 3 + (tcc - 94) * 3;
2893 slot = 5 + (tcc - 95) * 3;
2896 if (tcc >= 22 && tcc <= 27) {
2899 slot = 2 + (tcc - 22) * 3;
2901 slot = 4 + (tcc - 23) * 3;
2903 if (tcc >= 4 && tcc <= 9) {
2906 slot = 3 + (tcc - 4) * 3;
2908 slot = 5 + (tcc - 5) * 3;
2911 if (tcc >= 82 && tcc <= 87) {
2914 slot = 2 + (tcc - 82) * 3;
2916 slot = 4 + (tcc - 83) * 3;
2918 if (tcc >= 100 && tcc <= 105) {
2921 slot = 3 + (tcc - 100) * 3;
2923 slot = 5 + (tcc - 101) * 3;
2926 if (tcc >= 28 && tcc <= 33) {
2929 slot = 2 + (tcc - 28) * 3;
2931 slot = 4 + (tcc - 29) * 3;
2933 if (tcc >= 10 && tcc <= 15) {
2936 slot = 3 + (tcc - 10) * 3;
2938 slot = 5 + (tcc - 11) * 3;
3039 return std::pair<std::string, int>(crate.str(), slot);