383 TFile saving (
"EcalTPGParam.root",
"recreate") ;
385 TH2F * ICEB =
new TH2F(
"ICEB",
"IC: Barrel", 360, 1, 361, 172, -86, 86) ;
386 ICEB->GetYaxis()->SetTitle(
"eta index") ;
387 ICEB->GetXaxis()->SetTitle(
"phi index") ;
388 TH2F * tpgFactorEB =
new TH2F(
"tpgFactorEB",
"tpgFactor: Barrel", 360, 1, 361, 172, -86, 86) ;
389 tpgFactorEB->GetYaxis()->SetTitle(
"eta index") ;
390 tpgFactorEB->GetXaxis()->SetTitle(
"phi index") ;
392 TH2F * ICEEPlus =
new TH2F(
"ICEEPlus",
"IC: Plus Endcap", 120, -9, 111, 120, -9, 111) ;
393 ICEEPlus->GetYaxis()->SetTitle(
"y index") ;
394 ICEEPlus->GetXaxis()->SetTitle(
"x index") ;
395 TH2F * tpgFactorEEPlus =
new TH2F(
"tpgFactorEEPlus",
"tpgFactor: Plus Endcap", 120, -9, 111, 120, -9, 111) ;
396 tpgFactorEEPlus->GetYaxis()->SetTitle(
"y index") ;
397 tpgFactorEEPlus->GetXaxis()->SetTitle(
"x index") ;
398 TH2F * ICEEMinus =
new TH2F(
"ICEEMinus",
"IC: Minus Endcap", 120, -9, 111, 120, -9, 111) ;
399 ICEEMinus->GetYaxis()->SetTitle(
"y index") ;
400 ICEEMinus->GetXaxis()->SetTitle(
"x index") ;
401 TH2F * tpgFactorEEMinus =
new TH2F(
"tpgFactorEEMinus",
"tpgFactor: Minus Endcap", 120, -9, 111, 120, -9, 111) ;
402 tpgFactorEEMinus->GetYaxis()->SetTitle(
"y index") ;
403 tpgFactorEEMinus->GetXaxis()->SetTitle(
"x index") ;
405 TH2F * IC =
new TH2F(
"IC",
"IC", 720, -acos(-1.), acos(-1.), 600, -3., 3.) ;
406 IC->GetYaxis()->SetTitle(
"eta") ;
407 IC->GetXaxis()->SetTitle(
"phi") ;
408 TH2F * tpgFactor =
new TH2F(
"tpgFactor",
"tpgFactor", 720, -acos(-1.), acos(-1.), 600, -3., 3.) ;
409 tpgFactor->GetYaxis()->SetTitle(
"eta") ;
410 tpgFactor->GetXaxis()->SetTitle(
"phi") ;
412 TH1F * hshapeEB =
new TH1F(
"shapeEB",
"shapeEB", 250, 0., 10.) ;
413 TH1F * hshapeEE =
new TH1F(
"shapeEE",
"shapeEE", 250, 0., 10.) ;
415 TTree * ntuple =
new TTree(
"tpgmap",
"TPG geometry map") ;
416 const std::string branchFloat[26] = {
"fed",
"tcc",
"tower",
"stripInTower",
"xtalInStrip",
417 "CCU",
"VFE",
"xtalInVFE",
"xtalInCCU",
"ieta",
"iphi",
418 "ix",
"iy",
"iz",
"hashedId",
"ic",
"cmsswId",
"dbId",
"ietaTT",
"iphiTT",
419 "TCCch",
"TCCslot",
"SLBch",
"SLBslot",
"ietaGCT",
"iphiGCT"} ;
421 for (
int i=0 ;
i<26 ;
i++) ntuple->Branch(branchFloat[
i].c_str(),&
ntupleInts_[
i],(branchFloat[
i]+string(
"/I")).c_str()) ;
426 TNtuple *ntupleSpike =
new TNtuple(
"spikeParam",
"Spike parameters",
"gainId:theta:G:g:ped:pedLin") ;
434 list<uint32_t> towerListEB ;
435 list<uint32_t> stripListEB ;
436 list<uint32_t> towerListEE ;
437 list<uint32_t> stripListEE ;
438 list<uint32_t>::iterator itList ;
440 map<int, uint32_t> stripMapEB ;
441 map<uint32_t, uint32_t> stripMapEBsintheta ;
449 std::cout <<
"Getting the pedestals from offline DB..."<<endl;
453 pedMap = pedHandle.
product()->getMap() ;
458 for (pedIter = pedMap.begin() ; pedIter != pedMap.end() && nPed<10 ; ++pedIter, nPed++) {
460 std::cout<<aped.mean_x12<<
", "<<aped.mean_x6<<
", "<<aped.mean_x1<<std::endl ;
463 std::cout <<
"Getting the pedestals from previous configuration"<<std::endl;
471 db_-> fetchConfigSet(&fe_main_info);
476 db_-> fetchConfigSet(&fe_ped_info);
477 std::map<EcalLogicID, FEConfigPedDat> dataset_TpgPed;
480 typedef std::map<EcalLogicID, FEConfigPedDat>::const_iterator CIfeped;
484 for (CIfeped
p = dataset_TpgPed.begin();
p != dataset_TpgPed.end();
p++)
489 std::string ecid_name=ecid_xt.
getName();
492 if (ecid_name==
"EB_crystal_number") {
495 int sm_num=ecid_xt.
getID1();
496 int xt_num=ecid_xt.
getID2();
507 if(icells<10)
std::cout <<
" copy the EB data " <<
" ped = " << item.mean_x12<< std::endl;
509 peds.
insert(std::make_pair(ebdetid.rawId(),item));
512 }
else if (ecid_name==
"EE_crystal_number"){
527 peds.
insert(std::make_pair(eedetid.rawId(),item));
536 for (pedIter = pedMap.begin() ; pedIter != pedMap.end() && nPed<10 ; ++pedIter, nPed++) {
538 std::cout<<aped.mean_x12<<
", "<<aped.mean_x6<<
", "<<aped.mean_x1<<std::endl ;
543 cout <<
" error reading previous pedestals " << endl;
545 cout <<
"Unknown error reading previous pedestals " << endl;
562 db_-> fetchConfigSet(&fe_ped_info);
563 std::map<EcalLogicID, FEConfigPedDat> dataset_TpgPed;
566 typedef std::map<EcalLogicID, FEConfigPedDat>::const_iterator CIfeped;
570 for (CIfeped
p = dataset_TpgPed.begin();
p != dataset_TpgPed.end();
p++)
575 std::string ecid_name=ecid_xt.
getName();
578 if (ecid_name==
"EB_crystal_number") {
579 if(icells<10)
std::cout <<
" copy the EB data " <<
" icells = " << icells << std::endl;
580 int sm_num=ecid_xt.
getID1();
581 int xt_num=ecid_xt.
getID2();
592 peds.
insert(std::make_pair(ebdetid.rawId(),item));
594 }
else if (ecid_name==
"EE_crystal_number"){
609 peds.
insert(std::make_pair(eedetid.rawId(),item));
618 for (pedIter = pedMap.begin() ; pedIter != pedMap.end() && nPed<10 ; ++pedIter, nPed++) {
620 std::cout<<aped.mean_x12<<
", "<<aped.mean_x6<<
", "<<aped.mean_x1<<std::endl ;
625 cout <<
" error reading previous pedestals " << endl;
627 cout <<
"Unknown error reading previous pedestals " << endl;
639 std::cout <<
"Getting intercalib from offline DB..."<<endl;
646 for (calIter = calibMap.begin() ; calIter != calibMap.end() && nCal<10 ; ++calIter, nCal++) {
650 float calibvec[1700] ;
652 std::cout<<
"H2: overwriting IC coef with file"<<std::endl ;
656 std::string strdata ;
657 if (calibfile.is_open()) {
658 calibfile >> strdata >> strdata >> strdata >> strdata >> strdata ;
659 while(!calibfile.eof()) {
660 calibfile >> idata >> icry >> fcali >> fdata >> fdata ;
661 calibvec[icry-1] = fcali ;
670 std::cout <<
"Getting the gain ratios from offline DB..."<<endl;
676 for (gainIter = gainMap.begin() ; gainIter != gainMap.end() && nGain<10 ; ++gainIter, nGain++) {
684 std::cout <<
"Getting the ADC to GEV from offline DB..."<<endl;
695 vector<EcalLogicID> my_EcalLogicId;
696 vector<EcalLogicID> my_TTEcalLogicId;
697 vector<EcalLogicID> my_StripEcalLogicId;
701 vector<EcalLogicID> my_TTEcalLogicId_EE;
702 vector<EcalLogicID> my_RTEcalLogicId_EE;
703 vector<EcalLogicID> my_StripEcalLogicId1_EE;
704 vector<EcalLogicID> my_StripEcalLogicId2_EE;
705 vector<EcalLogicID> my_CrystalEcalLogicId_EE;
706 vector<EcalLogicID> my_TTEcalLogicId_EB_by_TCC;
707 vector<EcalLogicID> my_StripEcalLogicId_EE_strips_by_TCC;
710 std::cout<<
"going to get the ecal logic id set"<< endl;
717 "EB_crystal_number",12 );
722 "EB_trigger_tower",12 );
724 std::cout<<
"got the 3 ecal barrel logic id set"<< endl;
731 "EE_crystal_number",123 );
739 "ECAL_readout_strip",123 );
746 "ECAL_readout_strip",123 );
754 "EE_trigger_strip",123 );
764 "ECAL_trigger_tower",12 );
772 "EE_trigger_tower",12 );
780 "EE_readout_tower",12 );
782 std::cout<<
"got the end cap logic id set"<< endl;
785 std::cout<<
"Getting the latest ids for this tag (latest version) "<< endl;
792 db_-> fetchConfigSet(&fe_main_info);
810 cout <<
" tag did not exist a new tag will be created " << endl;
812 cout <<
"Unknown error caught" << endl;
821 map<EcalLogicID, FEConfigPedDat> pedset ;
822 map<EcalLogicID, FEConfigLinDat> linset ;
823 map<EcalLogicID, FEConfigLinParamDat> linparamset ;
824 map<EcalLogicID, FEConfigLUTParamDat> lutparamset ;
825 map<EcalLogicID, FEConfigFgrParamDat> fgrparamset ;
827 map<int, linStruc> linEtaSlice ;
828 map< vector<int>,
linStruc > linMap ;
831 int NbOfStripPerTCC[108][68] ;
832 for (
int i=0 ;
i<108 ;
i++)
833 for (
int j=0 ;
j<68 ;
j++)
834 NbOfStripPerTCC[
i][
j] = 0 ;
837 for (vector<DetId>::const_iterator it = ebCells.begin(); it != ebCells.end(); ++it) {
844 if (stripInTower>NbOfStripPerTCC[tccNb-1][towerInTCC-1]) NbOfStripPerTCC[tccNb-1][towerInTCC-1] = stripInTower ;
846 for (vector<DetId>::const_iterator it = eeCells.begin(); it != eeCells.end(); ++it) {
853 if (stripInTower>NbOfStripPerTCC[tccNb-1][towerInTCC-1]) NbOfStripPerTCC[tccNb-1][towerInTCC-1] = stripInTower ;
859 if (
writeToFiles_) (*out_file_)<<
"COMMENT ====== barrel crystals ====== "<<std::endl ;
862 for (vector<DetId>::const_iterator it = ebCells.begin(); it != ebCells.end(); ++it) {
876 int xtalInVFE = Id.
xtalId() ;
877 int xtalWithinCCUid = 5*(VFEid-1) + xtalInVFE -1 ;
879 (*geomFile_)<<
"dccNb = "<<dccNb<<
" tccNb = "<<tccNb<<
" towerInTCC = "<<towerInTCC
880 <<
" stripInTower = "<<stripInTower<<
" xtalInStrip = "<<xtalInStrip
881 <<
" CCUid = "<<CCUid<<
" VFEid = "<<VFEid<<
" xtalInVFE = "<<xtalInVFE
882 <<
" xtalWithinCCUid = "<<xtalWithinCCUid<<
" ieta = "<<
id.ieta()<<
" iphi = "<<
id.iphi()
883 <<
" xtalhashedId = "<<
id.hashedIndex()<<
" xtalNb = "<<
id.ic()
884 <<
" ietaTT = "<<towid.
ieta()<<
" iphiTT = "<<towid.
iphi()<<endl ;
886 int TCCch = towerInTCC ;
887 int SLBslot = int((towerInTCC-1)/8.) + 1 ;
888 int SLBch = (towerInTCC-1)%8 + 1 ;
889 int cmsswId =
id.rawId() ;
890 int ixtal=(
id.ism()-1)*1700+(
id.ic()-1);
893 int val[] = {dccNb+600,tccNb,towerInTCC,stripInTower,
894 xtalInStrip,CCUid,VFEid,xtalInVFE,xtalWithinCCUid,
id.ieta(),
id.iphi(),
896 id.ic(), cmsswId, dbId,
906 if (tccNb == 37 && stripInTower == 3 && xtalInStrip == 3 && (towerInTCC-1)%4==0) {
907 int etaSlice = towid.
ietaAbs() ;
909 getCoeff(coeff, calibMap,
id.rawId()) ;
910 getCoeff(coeff, gainMap,
id.rawId()) ;
911 getCoeff(coeff, pedMap,
id.rawId()) ;
913 for (
int i=0 ;
i<3 ;
i++) {
916 if (!ok)
std::cout <<
"unable to compute the parameters for SM="<<
id.ism()<<
" xt="<<
id.ic()<<
" " <<dec<<
id.rawId()<<std::endl ;
926 if (!ok)
std::cout<<
"SM="<<
id.ism()<<
" xt="<<
id.ic()<<
" " <<dec<<
id.rawId()<<std::endl ;
927 linEtaSlice[etaSlice] = lin ;
932 for (vector<DetId>::const_iterator it = ebCells.begin(); it != ebCells.end(); ++it) {
937 towerListEB.push_back(towid.
rawId()) ;
939 stripListEB.push_back(elId.
rawId() & 0xfffffff8) ;
948 int xtalInVFE = Id.
xtalId() ;
949 int xtalWithinCCUid = 5*(VFEid-1) + xtalInVFE -1 ;
950 int etaSlice = towid.
ietaAbs() ;
953 int hashedStripLogicID = 68*5*(
id.ism()-1) + 5*(towerInTCC-1) + (VFEid-1) ;
954 stripMapEB[hashedStripLogicID] = elId.
rawId() & 0xfffffff8 ;
971 if (
writeToFiles_) (*out_file_)<<
"CRYSTAL "<<dec<<
id.rawId()<<std::endl ;
975 getCoeff(coeff, calibMap,
id.rawId()) ;
977 getCoeff(coeff, gainMap,
id.rawId()) ;
978 getCoeff(coeff, pedMap,
id.rawId()) ;
979 ICEB->Fill(
id.iphi(),
id.ieta(), coeff.
calibCoeff_) ;
982 vector<int> xtalCCU ;
983 xtalCCU.push_back(dccNb+600) ;
984 xtalCCU.push_back(CCUid) ;
985 xtalCCU.push_back(xtalWithinCCUid) ;
986 xtalCCU.push_back(
id.rawId()) ;
991 map<int, linStruc>::const_iterator itLin = linEtaSlice.find(etaSlice);
992 if (itLin != linEtaSlice.end()) {
993 linMap[xtalCCU] = itLin->second ;
995 for (
int i=0 ;
i<3 ;
i++)
996 (*
out_file_) << hex <<
" 0x"<<itLin->second.pedestal_[
i]<<
" 0x"<<itLin->second.mult_[
i]<<
" 0x"<<itLin->second.shift_[
i]<<std::endl;
999 for (
int i=0 ;
i<3 ;
i++) {
1005 float factor = float(itLin->second.mult_[0])*
pow(2.,-itLin->second.shift_[0])/
xtal_LSB_EB_ ;
1006 tpgFactorEB->Fill(
id.iphi(),
id.ieta(), factor) ;
1010 else std::cout<<
"current EtaSlice = "<<etaSlice<<
" not found in the EtaSlice map"<<std::endl ;
1015 int forceBase12 = 0 ;
1016 for (
int i=0 ;
i<3 ;
i++) {
1019 if (!ok)
std::cout <<
"unable to compute the parameters for SM="<<
id.ism()<<
" xt="<<
id.ic()<<
" " <<dec<<
id.rawId()<<std::endl ;
1031 double G = mult*
pow(2.0,-(shift+2)) ;
1032 double g = G/
sin(theta) ;
1035 if (base<0.) base = 0 ;
1036 forceBase12 = int(base) ;
1055 if (!ok)
std::cout<<
"SM="<<
id.ism()<<
" xt="<<
id.ic()<<
" " <<dec<<
id.rawId()<<std::endl ;
1057 for (
int i=0 ;
i<3 ;
i++) {
1066 tpgFactorEB->Fill(
id.iphi(),
id.ieta(), factor) ;
1071 double g = G/
sin(theta) ;
1072 float val[] = { float(
i),
1078 ntupleSpike->Fill(val) ;
1080 linMap[xtalCCU] = lin ;
1084 int ixtal=(
id.ism()-1)*1700+(
id.ic()-1);
1086 pedset[logicId] = pedDB ;
1087 linset[logicId] = linDB ;
1095 linparamset[my_EcalLogicId_EB] = linparam ;
1102 fgrparamset[my_EcalLogicId_EB] = fgrparam ;
1109 lutparamset[my_EcalLogicId_EB] = lutparam ;
1115 if (
writeToFiles_) (*out_file_)<<
"COMMENT ====== endcap crystals ====== "<<std::endl ;
1118 for (vector<DetId>::const_iterator it = eeCells.begin(); it != eeCells.end(); ++it) {
1125 int dccNb = Id.
dccId() ;
1132 int xtalInVFE = Id.
xtalId() ;
1133 int xtalWithinCCUid = 5*(VFEid-1) + xtalInVFE -1 ;
1135 (*geomFile_)<<
"dccNb = "<<dccNb<<
" tccNb = "<<tccNb<<
" towerInTCC = "<<towerInTCC
1136 <<
" stripInTower = "<<stripInTower<<
" xtalInStrip = "<<xtalInStrip
1137 <<
" CCUid = "<<CCUid<<
" VFEid = "<<VFEid<<
" xtalInVFE = "<<xtalInVFE
1138 <<
" xtalWithinCCUid = "<<xtalWithinCCUid<<
" ix = "<<
id.ix()<<
" iy = "<<
id.iy()
1139 <<
" xtalhashedId = "<<
id.hashedIndex()<<
" xtalNb = "<<
id.isc()
1140 <<
" ietaTT = "<<towid.
ieta()<<
" iphiTT = "<<towid.
iphi()<<endl ;
1142 int TCCch = stripInTower ;
1143 int SLBslot, SLBch ;
1146 SLBch = 4 + towerInTCC ;
1149 SLBslot = int((towerInTCC-5)/8.) + 2 ;
1150 SLBch = (towerInTCC-5)%8 + 1 ;
1152 for (
int j=0 ;
j<towerInTCC-1 ;
j++) TCCch += NbOfStripPerTCC[tccNb-1][
j] ;
1154 int cmsswId =
id.rawId() ;
1156 int iz =
id.positiveZ() ;
1157 if (iz ==0) iz = -1 ;
1158 for (
int k=0;
k<(int)my_CrystalEcalLogicId_EE.size();
k++) {
1159 int z= my_CrystalEcalLogicId_EE[
k].
getID1() ;
1160 int x= my_CrystalEcalLogicId_EE[
k].getID2() ;
1161 int y= my_CrystalEcalLogicId_EE[
k].getID3() ;
1162 if (
id.ix()==x &&
id.iy()==y && iz==z) logicId=my_CrystalEcalLogicId_EE[
k];
1166 int val[] = {dccNb+600,tccNb,towerInTCC,stripInTower,
1167 xtalInStrip,CCUid,VFEid,xtalInVFE,xtalWithinCCUid,-999,-999,
1169 id.ic(),cmsswId, dbId,
1177 if ((tccNb == 76 || tccNb == 94) && stripInTower == 1 && xtalInStrip == 3 && (towerInTCC-1)%4==0) {
1178 int etaSlice = towid.
ietaAbs() ;
1180 getCoeff(coeff, calibMap,
id.rawId()) ;
1181 getCoeff(coeff, gainMap,
id.rawId()) ;
1182 getCoeff(coeff, pedMap,
id.rawId()) ;
1184 for (
int i=0 ;
i<3 ;
i++) {
1187 if (!ok)
std::cout <<
"unable to compute the parameters for Quadrant="<<
id.iquadrant()<<
" xt="<<
id.ic()<<
" " <<dec<<
id.rawId()<<std::endl ;
1197 if (!ok)
std::cout<<
"Quadrant="<<
id.iquadrant()<<
" xt="<<
id.ic()<<
" " <<dec<<
id.rawId()<<std::endl ;
1199 linEtaSlice[etaSlice] = lin ;
1204 for (vector<DetId>::const_iterator it = eeCells.begin(); it != eeCells.end(); ++it) {
1211 towerListEE.push_back(towid.
rawId()) ;
1215 towerListEE.push_back(additionalTower.rawId()) ;
1217 stripListEE.push_back(elId.
rawId() & 0xfffffff8) ;
1218 int dccNb = Id.
dccId() ;
1225 int xtalInVFE = Id.
xtalId() ;
1226 int xtalWithinCCUid = 5*(VFEid-1) + xtalInVFE -1 ;
1227 int etaSlice = towid.
ietaAbs() ;
1232 if (
writeToFiles_) (*out_file_)<<
"CRYSTAL "<<dec<<
id.rawId()<<std::endl ;
1234 int iz =
id.positiveZ() ;
1235 if (iz ==0) iz = -1 ;
1236 for (
int k=0;
k<(int)my_CrystalEcalLogicId_EE.size();
k++) {
1237 int z= my_CrystalEcalLogicId_EE[
k].getID1() ;
1238 int x= my_CrystalEcalLogicId_EE[
k].getID2() ;
1239 int y= my_CrystalEcalLogicId_EE[
k].getID3() ;
1240 if (
id.ix()==x &&
id.iy()==y && iz==z) logicId=my_CrystalEcalLogicId_EE[
k];
1245 getCoeff(coeff, calibMap,
id.rawId()) ;
1246 getCoeff(coeff, gainMap,
id.rawId()) ;
1247 getCoeff(coeff, pedMap,
id.rawId()) ;
1248 if (
id.zside()>0) ICEEPlus->Fill(
id.ix(),
id.iy(), coeff.
calibCoeff_) ;
1249 else ICEEMinus->Fill(
id.ix(),
id.iy(), coeff.
calibCoeff_) ;
1252 vector<int> xtalCCU ;
1253 xtalCCU.push_back(dccNb+600) ;
1254 xtalCCU.push_back(CCUid) ;
1255 xtalCCU.push_back(xtalWithinCCUid) ;
1256 xtalCCU.push_back(
id.rawId()) ;
1261 map<int, linStruc>::const_iterator itLin = linEtaSlice.find(etaSlice);
1262 if (itLin != linEtaSlice.end()) {
1263 linMap[xtalCCU] = itLin->second ;
1265 for (
int i=0 ;
i<3 ;
i++)
1266 (*
out_file_) << hex <<
" 0x"<<itLin->second.pedestal_[
i]<<
" 0x"<<itLin->second.mult_[
i]<<
" 0x"<<itLin->second.shift_[
i]<<std::endl;
1269 for (
int i=0 ;
i<3 ;
i++) {
1275 float factor = float(itLin->second.mult_[0])*
pow(2.,-itLin->second.shift_[0])/
xtal_LSB_EE_ ;
1276 if (
id.zside()>0) tpgFactorEEPlus->Fill(
id.ix(),
id.iy(), factor) ;
1277 else tpgFactorEEMinus->Fill(
id.ix(),
id.iy(), factor) ;
1281 else std::cout<<
"current EtaSlice = "<<etaSlice<<
" not found in the EtaSlice map"<<std::endl ;
1286 for (
int i=0 ;
i<3 ;
i++) {
1289 if (!ok)
std::cout <<
"unable to compute the parameters for "<<dec<<
id.rawId()<<std::endl ;
1299 if (!ok)
std::cout<<
"Quadrant="<<
id.iquadrant()<<
" xt="<<
id.ic()<<
" " <<dec<<
id.rawId()<<std::endl ;
1301 for (
int i=0 ;
i<3 ;
i++) {
1310 if (
id.zside()>0) tpgFactorEEPlus->Fill(
id.ix(),
id.iy(), factor) ;
1311 else tpgFactorEEMinus->Fill(
id.ix(),
id.iy(), factor) ;
1316 linMap[xtalCCU] = lin ;
1319 pedset[logicId] = pedDB ;
1320 linset[logicId] = linDB ;
1328 linparamset[my_EcalLogicId_EE] = linparam ;
1334 lutparamset[my_EcalLogicId_EE] = lutparam ;
1340 fgrparamset[my_EcalLogicId_EE] = fgrparam ;
1348 std::string lin_tag=ltag.str();
1364 evgueni<<
"void getLinParamTPG_hardcoded(int fed, int ccu, int xtal,"<<endl ;
1365 evgueni<<
" int & mult12, int & shift12, int & base12,"<<endl ;
1366 evgueni<<
" int & mult6, int & shift6, int & base6,"<<endl ;
1367 evgueni<<
" int & mult1, int & shift1, int & base1)"<<endl ;
1369 evgueni<<
" mult12 = 0 ; shift12 = 0 ; base12 = 0 ; mult6 = 0 ; shift6 = 0 ; base6 = 0 ; mult1 = 0 ; shift1 = 0 ; base1 = 0 ;"<<endl ;
1370 map< vector<int>,
linStruc>::const_iterator itLinMap ;
1371 for (itLinMap = linMap.begin() ; itLinMap != linMap.end() ; itLinMap++) {
1372 vector<int> xtalInCCU = itLinMap->first ;
1373 evgueni<<
" if (fed=="<<xtalInCCU[0]<<
" && ccu=="<<xtalInCCU[1]<<
" && xtal=="<<xtalInCCU[2]<<
") {" ;
1374 evgueni<<
" mult12 = "<<itLinMap->second.
mult_[0]<<
" ; shift12 = "<<itLinMap->second.shift_[0]<<
" ; base12 = "<<itLinMap->second.pedestal_[0]<<
" ; " ;
1375 evgueni<<
" mult6 = "<<itLinMap->second.mult_[1]<<
" ; shift6 = "<<itLinMap->second.shift_[1]<<
" ; base6 = "<<itLinMap->second.pedestal_[1]<<
" ; " ;
1376 evgueni<<
" mult1 = "<<itLinMap->second.mult_[2]<<
" ; shift1 = "<<itLinMap->second.shift_[2]<<
" ; base1 = "<<itLinMap->second.pedestal_[2]<<
" ; " ;
1377 evgueni<<
" return ;}" <<endl ;
1379 evgueni<<
"}" <<endl ;
1388 const int NWEIGROUPS = 2 ;
1389 std::vector<unsigned int>
weights[NWEIGROUPS] ;
1391 #if (CMSSW_VERSION>=340)
1403 weights[1] = weights[0] ;
1406 map<EcalLogicID, FEConfigWeightGroupDat>
dataset;
1408 for (
int igrp=0 ; igrp<NWEIGROUPS ; igrp++) {
1410 if (weights[igrp].
size() == 5) {
1413 (*out_file_) <<std::endl ;
1414 (*out_file_) <<
"WEIGHT "<<igrp<<endl ;
1416 (*out_file_)<<std::endl ;
1417 (*out_file_) <<std::endl ;
1420 std::cout<<
"going to write the weights for groupe:"<<igrp<<endl;
1431 dataset[ecid] = gut;
1439 map<EcalLogicID, FEConfigWeightDat> dataset2;
1442 for (
int ich=0; ich<(int)my_StripEcalLogicId.size() ; ich++){
1446 dataset2[my_StripEcalLogicId[ich]] = wut;
1450 for (
int ich=0; ich<(int)my_StripEcalLogicId1_EE.size() ; ich++){
1455 dataset2[my_StripEcalLogicId1_EE[ich]] = wut;
1458 for (
int ich=0; ich<(int)my_StripEcalLogicId2_EE.size() ; ich++){
1463 dataset2[my_StripEcalLogicId2_EE[ich]] = wut;
1468 wtag.str(
""); wtag<<
"Shape_NGroups_"<<NWEIGROUPS;
1469 std::string weight_tag=wtag.str();
1470 std::cout<<
" weight tag "<<weight_tag<<endl;
1480 unsigned int lowRatio, highRatio, lowThreshold, highThreshold, lutFG ;
1483 (*out_file_) <<std::endl ;
1484 (*out_file_) <<
"FG 0"<<std::endl ;
1485 (*out_file_)<<hex<<
"0x"<<lowThreshold<<
" 0x"<<highThreshold
1486 <<
" 0x"<<lowRatio<<
" 0x"<<highRatio<<
" 0x"<<lutFG
1492 unsigned int lut_strip;
1499 std::cout<<
"going to write the fgr "<< endl;
1500 map<EcalLogicID, FEConfigFgrGroupDat>
dataset;
1503 for (
int ich=0; ich<NFGRGROUPS; ich++){
1513 dataset[ecid] = gut;
1517 map<EcalLogicID, FEConfigFgrDat> dataset2;
1519 for (
int ich=0; ich<(int)my_TTEcalLogicId.size() ; ich++){
1526 dataset2[my_TTEcalLogicId[ich]] = wut;
1530 for (
int ich=0; ich<(int)my_RTEcalLogicId_EE.size() ; ich++){
1538 dataset2[my_RTEcalLogicId_EE[ich]] = wut;
1542 map<EcalLogicID, FEConfigFgrEETowerDat> dataset3;
1543 for (
int ich=0; ich<(int)my_TTEcalLogicId_EE.size() ; ich++){
1546 dataset3[my_TTEcalLogicId_EE[ich]]=fgreett;
1551 map<EcalLogicID, FEConfigFgrEEStripDat> dataset4;
1552 for (
int ich=0; ich<(int)my_StripEcalLogicId1_EE.size() ; ich++){
1556 dataset4[my_StripEcalLogicId1_EE[ich]] = zut;
1558 for (
int ich=0; ich<(int)my_StripEcalLogicId2_EE.size() ; ich++){
1563 dataset4[my_StripEcalLogicId2_EE[ich]] = zut;
1565 for (
int ich=0; ich<(int)my_StripEcalLogicId.size() ; ich++){
1569 uint32_t elStripId = stripMapEB[ich] ;
1570 map<uint32_t, uint32_t>::const_iterator it = stripMapEBsintheta.find(elStripId) ;
1571 if (it != stripMapEBsintheta.end()) zut.
setThreshold(it->second);
1573 cout<<
"ERROR: strip SFGVB threshold parameter not found for that strip:"<<thestrip.
getID1()<<
" "<<thestrip.
getID3()<<
" "<<thestrip.
getID3()<<endl ;
1579 dataset4[thestrip] = zut;
1585 std::string weight_tag=wtag.str();
1586 std::cout<<
" weight tag "<<weight_tag<<endl;
1590 map<EcalLogicID, FEConfigSpikeDat> datasetspike;
1591 for (
int ich=0; ich<(int)my_TTEcalLogicId.size() ; ich++){
1594 datasetspike[my_TTEcalLogicId[ich]] = spiketh;
1600 std::string spike_tag=stag.str();
1601 std::cout<<
" spike tag "<<spike_tag<<endl;
1606 map<EcalLogicID, FEConfigTimingDat> datasetdelay;
1607 for (
int ich=0; ich<(int)my_TTEcalLogicId_EB_by_TCC.size() ; ich++){
1610 EcalLogicID logiciddelay = my_TTEcalLogicId_EB_by_TCC[ich] ;
1611 int id1_tcc=my_TTEcalLogicId_EB_by_TCC[ich].
getID1();
1612 int id2_tt =my_TTEcalLogicId_EB_by_TCC[ich].getID2();
1613 std::map<int, vector<int> >::const_iterator ittEB =
delays_EB_.find(id1_tcc);
1614 std::vector<int> TimingDelaysEB = ittEB->second;
1617 if(TimingDelaysEB[id2_tt-1] == -1){
1618 std::cout <<
"ERROR: Barrel timing delay not specified, check file, putting default value 1" << std::endl;
1623 std::cout <<
"ERROR:Barrel Could not find delay parameter for that trigger tower " << std::endl;
1624 std::cout <<
"Using default value = 1" << std::endl;
1628 std::map<int, vector<int> >::const_iterator ittpEB =
phases_EB_.find(id1_tcc);
1629 std::vector<int> TimingPhasesEB = ittpEB->second;
1632 if(TimingPhasesEB[id2_tt-1] == -1){
1633 std::cout <<
"ERROR: Barrel timing phase not specified, check file, putting default value 0" << std::endl;
1638 std::cout <<
"ERROR:Barrel Could not find phase parameter for that trigger tower " << std::endl;
1639 std::cout <<
"Using default value = 0" << std::endl;
1643 std::cout << ich <<
" tcc=" << id1_tcc <<
" TT=" << id2_tt <<
" logicId=" << logiciddelay.
getLogicID()
1644 <<
" delay=" << TimingDelaysEB[id2_tt-1] <<
" phase=" << TimingPhasesEB[id2_tt-1] << std::endl;
1648 datasetdelay[my_TTEcalLogicId_EB_by_TCC[ich]] = delay;
1654 for (
int ich=0; ich<(int)my_StripEcalLogicId_EE_strips_by_TCC.size() ; ich++){
1660 EcalLogicID logiciddelay = my_StripEcalLogicId_EE_strips_by_TCC[ich] ;
1661 int id1_tcc=my_StripEcalLogicId_EE_strips_by_TCC[ich].
getID1();
1662 int id2_tt =my_StripEcalLogicId_EE_strips_by_TCC[ich].getID2();
1663 int id3_st =my_StripEcalLogicId_EE_strips_by_TCC[ich].getID3();
1666 if(id1_tcc != tccin) {tccin = id1_tcc; stripindex=0;}
1668 std::map<int, vector<int> >::const_iterator ittEE =
delays_EE_.find(id1_tcc);
1669 std::vector<int> TimingDelaysEE = ittEE->second;
1672 if(TimingDelaysEE[stripindex] == -1){
1673 std::cout <<
"ERROR: Endcap timing delay not specified, check file, putting default value 1" << std::endl;
1678 std::cout <<
"ERROR:Endcap Could not find delay parameter for that trigger tower " << std::endl;
1679 std::cout <<
"Using default value = 1" << std::endl;
1683 std::map<int, vector<int> >::const_iterator ittpEE =
phases_EE_.find(id1_tcc);
1684 std::vector<int> TimingPhasesEE = ittpEE->second;
1687 if(TimingPhasesEE[stripindex] == -1){
1688 std::cout <<
"ERROR: Endcap timing phase not specified, check file, putting default value 0" << std::endl;
1693 std::cout <<
"ERROR:Endcap Could not find phase parameter for that trigger tower " << std::endl;
1694 std::cout <<
"Using default value = 0" << std::endl;
1698 std::cout << ich <<
" stripindex=" << stripindex <<
" tcc=" << id1_tcc <<
" TT=" << id2_tt <<
" id3_st=" << id3_st
1700 <<
" delay=" << TimingDelaysEE[stripindex] <<
" phase=" << TimingPhasesEE[stripindex] << std::endl;
1705 datasetdelay[my_StripEcalLogicId_EE_strips_by_TCC[ich]] = delay;
1709 ostringstream de_tag;
1710 de_tag.str(
""); de_tag<<
"DelaysFromFile";
1711 std::string delay_tag=de_tag.str();
1712 std::cout<<
" delay tag "<<delay_tag<<endl;
1719 std::cout<<
"going to write the sliding "<< endl;
1720 map<EcalLogicID, FEConfigSlidingDat>
dataset;
1722 for (
int ich=0; ich<(int)my_StripEcalLogicId.size() ; ich++){
1728 dataset[my_StripEcalLogicId[ich]] = wut;
1732 for (
int ich=0; ich<(int)my_StripEcalLogicId1_EE.size() ; ich++){
1738 dataset[my_StripEcalLogicId1_EE[ich]] = wut;
1740 for (
int ich=0; ich<(int)my_StripEcalLogicId2_EE.size() ; ich++){
1746 dataset[my_StripEcalLogicId2_EE[ich]] = wut;
1752 wtag.str(
""); wtag<<
"Sliding_"<<
sliding_;
1753 std::string justatag=wtag.str();
1754 std::cout<<
" sliding tag "<<justatag<<endl;
1767 int lut_EB[1024], lut_EE[1024] ;
1772 (*out_file_) <<std::endl ;
1773 (*out_file_) <<
"LUT 0"<<std::endl ;
1774 for (
int i=0 ;
i<1024 ;
i++) (*
out_file_)<<
"0x"<<hex<<lut_EB[
i]<<endl ;
1775 (*out_file_)<<endl ;
1781 bool newLUT(
false) ;
1782 for (
int i=0 ;
i<1024 ;
i++)
if (lut_EE[
i] != lut_EB[
i]) newLUT =
true ;
1784 (*out_file_) <<std::endl ;
1785 (*out_file_) <<
"LUT 1"<<std::endl ;
1786 for (
int i=0 ; i<1024 ; i++) (*
out_file_)<<
"0x"<<hex<<lut_EE[
i]<<endl ;
1787 (*out_file_)<<endl ;
1796 map<EcalLogicID, FEConfigLUTGroupDat>
dataset;
1802 for (
int i=0; i<1024; i++){
1807 dataset[ecid] =
lut;
1813 for (
int i=0; i<1024; i++){
1818 dataset[ecide] =
lute;
1825 map<EcalLogicID, FEConfigLUTDat> dataset2;
1827 for (
int ich=0; ich<(int)my_TTEcalLogicId.size() ; ich++){
1833 dataset2[my_TTEcalLogicId[ich]] =
lut;
1837 for (
int ich=0; ich<(int)my_TTEcalLogicId_EE.size() ; ich++){
1843 dataset2[my_TTEcalLogicId_EE[ich]] =
lut;
1848 ltag.str(
""); ltag<<
LUT_option_<<
"_NGroups_"<<NLUTGROUPS;
1849 std::string lut_tag=ltag.str();
1863 std::cout <<
"\n Conf ID = " << conf_id_ << std::endl;
1873 stripListEB.sort() ;
1874 stripListEB.unique() ;
1875 cout<<
"Number of EB strips="<<dec<<stripListEB.size()<<endl ;
1877 (*out_file_) <<std::endl ;
1878 for (itList = stripListEB.begin(); itList != stripListEB.end(); itList++ ) {
1879 (*out_file_) <<
"STRIP_EB "<<dec<<(*itList)<<endl ;
1880 (*out_file_) << hex <<
"0x" <<sliding_<<std::endl ;
1881 (*out_file_) <<
"0" <<std::endl ;
1882 (*out_file_) <<
"0x"<<stripMapEBsintheta[(*itList)] <<
" 0x" <<
SFGVB_lut_ <<std::endl ;
1887 stripListEE.sort() ;
1888 stripListEE.unique() ;
1889 cout<<
"Number of EE strips="<<dec<<stripListEE.size()<<endl ;
1891 (*out_file_) <<std::endl ;
1892 for (itList = stripListEE.begin(); itList != stripListEE.end(); itList++ ) {
1893 (*out_file_) <<
"STRIP_EE "<<dec<<(*itList)<<endl ;
1894 (*out_file_) << hex <<
"0x" <<sliding_<<std::endl ;
1895 (*out_file_) <<
" 0" << std::endl ;
1896 (*out_file_)<<hex<<
"0x"<<threshold<<
" 0x"<<lut_strip<<std::endl ;
1906 towerListEB.sort() ;
1907 towerListEB.unique() ;
1908 cout<<
"Number of EB towers="<<dec<<towerListEB.size()<<endl ;
1910 (*out_file_) <<std::endl ;
1911 for (itList = towerListEB.begin(); itList != towerListEB.end(); itList++ ) {
1912 (*out_file_) <<
"TOWER_EB "<<dec<<(*itList)<<endl ;
1913 (*out_file_) <<
" 0\n 0\n" ;
1914 (*out_file_) <<
" " << SFGVB_SpikeKillingThreshold_ << std::endl;
1919 towerListEE.sort() ;
1920 towerListEE.unique() ;
1921 cout<<
"Number of EE towers="<<dec<<towerListEE.size()<<endl ;
1923 (*out_file_) <<std::endl ;
1924 for (itList = towerListEE.begin(); itList != towerListEE.end(); itList++ ) {
1925 (*out_file_) <<
"TOWER_EE "<<dec<<(*itList)<<endl ;
1926 if (newLUT) (*out_file_) <<
" 1\n" ;
1928 (*out_file_)<<hex<<
"0x"<<lut_tower<<std::endl ;
1939 tpgFactorEB->Write() ;
1941 tpgFactorEEPlus->Write() ;
1942 ICEEMinus->Write() ;
1943 tpgFactorEEMinus->Write() ;
1945 tpgFactor->Write() ;
1949 ntupleSpike->Write() ;
int writeToConfDB_TPGLinearCoef(const std::map< EcalLogicID, FEConfigLinDat > &linset, const std::map< EcalLogicID, FEConfigLinParamDat > &linparamset, int iovId, std::string tag)
std::map< int, std::vector< int > > phases_EB_
void setThreshLow(float x)
edm::ESHandle< EcalTrigTowerConstituentsMap > eTTmap_
int xtalId() const
get the channel id
virtual const CaloSimParameters & simParameters(const DetId &id) const
return the sim parameters relative to the right subdet
void setLUTGroupId(int x)
int stripId() const
get the tower id
void setFGhighratio(float x)
const self & getMap() const
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)
int getGCTRegionPhi(int ttphi)
Sin< T >::type sin(const T &t)
Geom::Phi< T > phi() const
std::string getDet(int tcc)
Geom::Theta< T > theta() const
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)
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
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_
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)
void getCoeff(coeffStruc &coeff, const EcalIntercalibConstantMap &calibMap, uint rawId)
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)
virtual const CaloCellGeometry * getGeometry(const DetId &id) const
Get the cell geometry of a given detector id. Should return false if not found.
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)
Geom::Theta< T > theta() const
uint32_t rawId() const
get the raw id
double timePhase() const
the adjustment you need to apply to get the signal where you want it
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
void setThreshold(unsigned int mean)
void setPedMeanG1(float mean)
void setThreshHigh(float x)
std::map< int, std::vector< int > > delays_EE_
EcalPedestalsMap::const_iterator EcalPedestalsMapIterator
void setLutFgr(unsigned int mean)
int ietaAbs() const
get the absolute value of the tower ieta
const EcalElectronicsMapping * theMapping_
void computeLUT(int *lut, std::string det="EB")
bool useTransverseEnergy_
void fetchDataSet(std::map< EcalLogicID, DATT > *fillMap, IOVT *iov)
void setLUTValue(int i, int x)
EcalLogicID getEcalLogicID(std::string name, int id1=EcalLogicID::NULLID, int id2=EcalLogicID::NULLID, int id3=EcalLogicID::NULLID, std::string mapsTo="")
EcalTriggerElectronicsId getTriggerElectronicsId(const DetId &id) const
Get the trigger electronics id for this det id.
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)
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_
int writeToConfDB_TPGPedestals(const std::map< EcalLogicID, FEConfigPedDat > &pedset, int iovId, std::string tag)
void setPedMeanG12(float mean)
std::vector< Item >::const_iterator const_iterator
T const * product() const
int DCCid(const EBDetId &id) const
returns the DCC of an EBDetId
float gain12Over6() const
float getPedMeanG6() const
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)
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)
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)
int writeToConfDB_TPGWeight(const std::map< EcalLogicID, FEConfigWeightGroupDat > &lutgroup, const std::map< EcalLogicID, FEConfigWeightDat > &lutdat, int iovId, std::string tag)
int getGCTRegionEta(int tteta)
void setTTThreshlow(float x)
static const int SMCRYSTALMODE
void setWeightGroupId(int x)
double FG_highThreshold_EB_
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)
tuple size
Write out results.
Power< A, B >::type pow(const A &a, const B &b)
std::map< int, std::vector< int > > phases_EE_
double TTF_lowThreshold_EB_
void computeFineGrainEBParameters(uint &lowRatio, uint &highRatio, uint &lowThreshold, uint &highThreshold, uint &lut)