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) {
188 std::ostringstream
ss;
190 ss <<
"INFO: READING timing files\n";
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;
360 if (
item.mean_x1 < 150. ||
item.mean_x1 > 250)
362 if (
item.mean_x6 < 150. ||
item.mean_x6 > 250)
364 if (
item.mean_x12 < 150. ||
item.mean_x12 > 250)
366 if (
item.rms_x1 < 0 ||
item.rms_x1 > 2)
368 if (
item.rms_x6 < 0 ||
item.rms_x6 > 3)
370 if (
item.rms_x12 < 0 ||
item.rms_x12 > 5)
376 int etaSlice = (towerInTCC - 1) / 4 + 1;
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++)
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++) {
588 ss << aped.mean_x12 <<
", " << aped.mean_x6 <<
", " << aped.mean_x1 <<
"\n";
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++) {
664 ss << aped.mean_x12 <<
", " << aped.mean_x6 <<
", " << aped.mean_x1 <<
"\n";
668 ss <<
"Getting the pedestals from configuration number" <<
m_write_ped <<
"\n";
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++) {
732 ss << aped.mean_x12 <<
", " << aped.mean_x6 <<
", " << aped.mean_x1 <<
"\n";
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++) {
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";
1181 ss <<
"SM=" <<
id.ism() <<
" xt=" <<
id.ic() <<
" " <<
dec <<
id.rawId() <<
"\n";
1183 for (
int i = 0;
i < 3;
i++) {
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++) {
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";
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++) {
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"
1845 delay.setTimingPar1(1);
1847 delay.setTimingPar1(TimingDelaysEB[id2_tt - 1]);
1849 edm::LogError(
"TopInfo") <<
"ERROR:Barrel Could not find delay parameter for that trigger tower "
1853 delay.setTimingPar1(1);
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"
1863 delay.setTimingPar2(0);
1865 delay.setTimingPar2(TimingPhasesEB[id2_tt - 1]);
1867 edm::LogError(
"TopInfo") <<
"ERROR:Barrel Could not find phase parameter for that trigger tower "
1871 delay.setTimingPar2(0);
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"
1909 delay.setTimingPar1(1);
1911 delay.setTimingPar1(TimingDelaysEE[stripindex]);
1913 edm::LogError(
"TopInfo") <<
"ERROR:Endcap Could not find delay parameter for that trigger tower "
1917 delay.setTimingPar1(1);
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"
1927 delay.setTimingPar2(0);
1929 delay.setTimingPar2(TimingPhasesEE[stripindex]);
1931 edm::LogError(
"TopInfo") <<
"ERROR:Endcap Could not find phase parameter for that trigger tower "
1935 delay.setTimingPar2(0);
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++) {
2050 for (
int i = 0;
i < 1024;
i++) {
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") {
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);
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";
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_);
2418 isumw += iweight[
sample];
2420 isumw = (isumw & imax);
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";
2445 int new_iweight = iweight[
sample] + 1;
2455 ss <<
"Correcting for bias: subtracting 1\n";
2457 int new_iweight = iweight[
sample] - 1;
2468 isumw += iweight[
sample];
2470 isumw = (isumw & imax);
2471 ss <<
"Correcting weight number: " <<
index <<
" sum weights = " << isumw <<
"\n";
2479 isumw += iweight[
sample];
2481 isumw = (isumw & imax);
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;
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);