47 if (Et<1
e-6)
return 1./par[1] ;
48 double resolEt_overEt =
sqrt( (par[0]/
sqrt(Et))*(par[0]/
sqrt(Et)) + (par[1]/Et)*(par[1]/Et) + par[2]*par[2] ) ;
49 return 1./(Et*resolEt_overEt) ;
53 : xtal_LSB_EB_(0), xtal_LSB_EE_(0), nSample_(5), complement2_(7)
110 if (
writeToDB_)
std::cout <<
"data will be saved with tag and version="<< tag_<<
".version"<<version_<< endl;
113 cout <<
"ERROR: " << e.what() << endl;
115 cout <<
"Unknown error caught" << endl;
172 if(SFGVB_SpikeKillingThreshold_ == -1 || (SFGVB_SpikeKillingThreshold_ > Et_sat_EB_))
173 SFGVB_SpikeKillingThreshold_ = 1023;
175 SFGVB_SpikeKillingThreshold_ = int(SFGVB_SpikeKillingThreshold_ * 1024/Et_sat_EB_);
176 std::cout <<
"INFO:SPIKE KILLING THRESHOLD (ADC)=" << SFGVB_SpikeKillingThreshold_ << std::endl;
185 std::cout <<
"INFO: READING timing files" << std::endl;
188 std::ifstream delay_ee(TimingDelays_EE_.c_str());
189 if(!delay_ee)
std::cout <<
"ERROR: File " << TimingDelays_EE_.c_str() <<
" could not be opened" << std::endl;
190 std::ifstream phase_eb(TimingPhases_EB_.c_str());
191 if(!phase_eb)
std::cout <<
"ERROR: File " << TimingPhases_EB_.c_str() <<
" could not be opened" << std::endl;
192 std::ifstream phase_ee(TimingPhases_EE_.c_str());
193 if(!phase_ee)
std::cout <<
"ERROR: File " << TimingPhases_EE_.c_str() <<
" could not be opened" << std::endl;
197 delay_eb.getline(buf,
sizeof(buf),
'\n');
199 std::stringstream
sin(buf);
204 vector<int> vec_delays_eb;
205 for(
int ieb=0; ieb<68; ++ieb){
208 vec_delays_eb.push_back(time_delay);
209 if(time_delay==-1)
std::cout <<
"ERROR:Barrel timing delay -1, check file" << std::endl;
212 if(vec_delays_eb.size()!=68)
213 std::cout <<
"ERROR:Barrel timing delay wrong, not enough towers, check file" << std::endl;
216 delays_EB_.insert(make_pair(tcc,vec_delays_eb));
219 for(
unsigned int ieb=0; ieb<vec_delays_eb.size(); ++ieb)
220 cout << vec_delays_eb[ieb] <<
" ";
223 delay_eb.getline(buf,
sizeof(buf),
'\n');
228 phase_eb.getline(buf,
sizeof(buf),
'\n');
230 std::stringstream
sin(buf);
234 vector<int> vec_phases_eb;
235 for(
unsigned int ieb=0; ieb<68; ++ieb){
238 vec_phases_eb.push_back(time_phase);
239 if(time_phase==-1)
std::cout <<
"ERROR:Barrel timing phase -1, check file" << std::endl;
242 if(vec_phases_eb.size()!=68)
243 std::cout <<
"ERROR:Barrel timing phase wrong, not enough towers, check file" << std::endl;
246 phases_EB_.insert(make_pair(tcc,vec_phases_eb));
249 for(
unsigned int ieb=0; ieb<vec_phases_eb.size(); ++ieb)
250 cout << vec_phases_eb[ieb] <<
" ";
253 phase_eb.getline(buf,
sizeof(buf),
'\n');
258 delay_ee.getline(buf,
sizeof(buf),
'\n');
260 std::stringstream
sin(buf);
264 vector<int> vec_delays_ee;
265 for(
unsigned int iee=0; iee<48; ++iee){
268 vec_delays_ee.push_back(time_delay);
269 if(time_delay==-1)
std::cout <<
"ERROR:EE timing delay -1, check file" << std::endl;
272 if(vec_delays_ee.size()!=48)
273 std::cout <<
"ERROR:EE timing delay wrong, not enough towers, check file" << std::endl;
276 delays_EE_.insert(make_pair(tcc,vec_delays_ee));
279 for(
unsigned int iee=0; iee<vec_delays_ee.size(); ++iee)
280 cout << vec_delays_ee[iee] <<
" ";
283 delay_ee.getline(buf,
sizeof(buf),
'\n');
289 phase_ee.getline(buf,
sizeof(buf),
'\n');
291 std::stringstream
sin(buf);
295 vector<int> vec_phases_ee;
296 for(
unsigned int iee=0; iee<48; ++iee){
299 vec_phases_ee.push_back(time_phase);
300 if(time_phase==-1)
std::cout <<
"ERROR:EE timing phase -1, check file" << std::endl;
303 if(vec_phases_ee.size()!=48)
304 std::cout <<
"ERROR:EE timing phase wrong, not enough towers, check file" << std::endl;
307 phases_EE_.insert(make_pair(tcc,vec_phases_ee));
310 for(
unsigned int iee=0; iee<vec_phases_ee.size(); ++iee)
311 cout << vec_phases_ee[iee] <<
" ";
314 phase_ee.getline(buf,
sizeof(buf),
'\n');
318 std::cout <<
"INFO: DONE reading timing files for EB and EE" << std::endl;
325 (*out_file_ )<<
"EOF"<<std::endl ;
346 int etaSlice = (towerInTCC-1)/4+1 ;
348 if (tccId>36 || tccId<73)
return etaSlice ;
351 if (tccId >=1 && tccId <= 18) etaSlice += 21 ;
352 if (tccId >=19 && tccId <= 36) etaSlice += 17 ;
353 if (tccId >=91 && tccId <= 108) etaSlice += 21 ;
354 if (tccId >=73 && tccId <= 90) etaSlice += 17 ;
381 TFile saving (
"EcalTPGParam.root",
"recreate") ;
383 TH2F * ICEB =
new TH2F(
"ICEB",
"IC: Barrel", 360, 1, 361, 172, -86, 86) ;
384 ICEB->GetYaxis()->SetTitle(
"eta index") ;
385 ICEB->GetXaxis()->SetTitle(
"phi index") ;
386 TH2F * tpgFactorEB =
new TH2F(
"tpgFactorEB",
"tpgFactor: Barrel", 360, 1, 361, 172, -86, 86) ;
387 tpgFactorEB->GetYaxis()->SetTitle(
"eta index") ;
388 tpgFactorEB->GetXaxis()->SetTitle(
"phi index") ;
390 TH2F * ICEEPlus =
new TH2F(
"ICEEPlus",
"IC: Plus Endcap", 120, -9, 111, 120, -9, 111) ;
391 ICEEPlus->GetYaxis()->SetTitle(
"y index") ;
392 ICEEPlus->GetXaxis()->SetTitle(
"x index") ;
393 TH2F * tpgFactorEEPlus =
new TH2F(
"tpgFactorEEPlus",
"tpgFactor: Plus Endcap", 120, -9, 111, 120, -9, 111) ;
394 tpgFactorEEPlus->GetYaxis()->SetTitle(
"y index") ;
395 tpgFactorEEPlus->GetXaxis()->SetTitle(
"x index") ;
396 TH2F * ICEEMinus =
new TH2F(
"ICEEMinus",
"IC: Minus Endcap", 120, -9, 111, 120, -9, 111) ;
397 ICEEMinus->GetYaxis()->SetTitle(
"y index") ;
398 ICEEMinus->GetXaxis()->SetTitle(
"x index") ;
399 TH2F * tpgFactorEEMinus =
new TH2F(
"tpgFactorEEMinus",
"tpgFactor: Minus Endcap", 120, -9, 111, 120, -9, 111) ;
400 tpgFactorEEMinus->GetYaxis()->SetTitle(
"y index") ;
401 tpgFactorEEMinus->GetXaxis()->SetTitle(
"x index") ;
403 TH2F * IC =
new TH2F(
"IC",
"IC", 720, -acos(-1.), acos(-1.), 600, -3., 3.) ;
404 IC->GetYaxis()->SetTitle(
"eta") ;
405 IC->GetXaxis()->SetTitle(
"phi") ;
406 TH2F * tpgFactor =
new TH2F(
"tpgFactor",
"tpgFactor", 720, -acos(-1.), acos(-1.), 600, -3., 3.) ;
407 tpgFactor->GetYaxis()->SetTitle(
"eta") ;
408 tpgFactor->GetXaxis()->SetTitle(
"phi") ;
410 TH1F * hshapeEB =
new TH1F(
"shapeEB",
"shapeEB", 250, 0., 10.) ;
411 TH1F * hshapeEE =
new TH1F(
"shapeEE",
"shapeEE", 250, 0., 10.) ;
413 TTree * ntuple =
new TTree(
"tpgmap",
"TPG geometry map") ;
414 const std::string branchFloat[26] = {
"fed",
"tcc",
"tower",
"stripInTower",
"xtalInStrip",
415 "CCU",
"VFE",
"xtalInVFE",
"xtalInCCU",
"ieta",
"iphi",
416 "ix",
"iy",
"iz",
"hashedId",
"ic",
"cmsswId",
"dbId",
"ietaTT",
"iphiTT",
417 "TCCch",
"TCCslot",
"SLBch",
"SLBslot",
"ietaGCT",
"iphiGCT"} ;
419 for (
int i=0 ;
i<26 ;
i++) ntuple->Branch(branchFloat[
i].c_str(),&
ntupleInts_[
i],(branchFloat[
i]+
string(
"/I")).c_str()) ;
424 TNtuple *ntupleSpike =
new TNtuple(
"spikeParam",
"Spike parameters",
"gainId:theta:G:g:ped:pedLin") ;
432 list<uint32_t> towerListEB ;
433 list<uint32_t> stripListEB ;
434 list<uint32_t> towerListEE ;
435 list<uint32_t> stripListEE ;
436 list<uint32_t>::iterator itList ;
438 map<int, uint32_t> stripMapEB ;
439 map<uint32_t, uint32_t> stripMapEBsintheta ;
447 std::cout <<
"Getting the pedestals from offline DB..."<<endl;
451 pedMap = pedHandle.
product()->getMap() ;
456 for (pedIter = pedMap.begin() ; pedIter != pedMap.end() && nPed<10 ; ++pedIter, nPed++) {
461 std::cout <<
"Getting the pedestals from previous configuration"<<std::endl;
469 db_-> fetchConfigSet(&fe_main_info);
474 db_-> fetchConfigSet(&fe_ped_info);
475 std::map<EcalLogicID, FEConfigPedDat> dataset_TpgPed;
478 typedef std::map<EcalLogicID, FEConfigPedDat>::const_iterator CIfeped;
482 for (CIfeped
p = dataset_TpgPed.begin();
p != dataset_TpgPed.end();
p++)
490 if (ecid_name==
"EB_crystal_number") {
493 int sm_num=ecid_xt.
getID1();
494 int xt_num=ecid_xt.
getID2();
505 if(icells<10)
std::cout <<
" copy the EB data " <<
" ped = " << item.
mean_x12<< std::endl;
510 }
else if (ecid_name==
"EE_crystal_number"){
534 for (pedIter = pedMap.begin() ; pedIter != pedMap.end() && nPed<10 ; ++pedIter, nPed++) {
541 cout <<
" error reading previous pedestals " << endl;
543 cout <<
"Unknown error reading previous pedestals " << endl;
560 db_-> fetchConfigSet(&fe_ped_info);
561 std::map<EcalLogicID, FEConfigPedDat> dataset_TpgPed;
564 typedef std::map<EcalLogicID, FEConfigPedDat>::const_iterator CIfeped;
568 for (CIfeped
p = dataset_TpgPed.begin();
p != dataset_TpgPed.end();
p++)
576 if (ecid_name==
"EB_crystal_number") {
577 if(icells<10)
std::cout <<
" copy the EB data " <<
" icells = " << icells << std::endl;
578 int sm_num=ecid_xt.
getID1();
579 int xt_num=ecid_xt.
getID2();
592 }
else if (ecid_name==
"EE_crystal_number"){
616 for (pedIter = pedMap.begin() ; pedIter != pedMap.end() && nPed<10 ; ++pedIter, nPed++) {
623 cout <<
" error reading previous pedestals " << endl;
625 cout <<
"Unknown error reading previous pedestals " << endl;
637 std::cout <<
"Getting intercalib from offline DB..."<<endl;
644 for (calIter = calibMap.begin() ; calIter != calibMap.end() && nCal<10 ; ++calIter, nCal++) {
648 float calibvec[1700] ;
650 std::cout<<
"H2: overwriting IC coef with file"<<std::endl ;
655 if (calibfile.is_open()) {
656 calibfile >> strdata >> strdata >> strdata >> strdata >> strdata ;
657 while(!calibfile.eof()) {
658 calibfile >> idata >> icry >> fcali >> fdata >> fdata ;
659 calibvec[icry-1] = fcali ;
668 std::cout <<
"Getting the gain ratios from offline DB..."<<endl;
674 for (gainIter = gainMap.begin() ; gainIter != gainMap.end() && nGain<10 ; ++gainIter, nGain++) {
682 std::cout <<
"Getting the ADC to GEV from offline DB..."<<endl;
693 vector<EcalLogicID> my_EcalLogicId;
694 vector<EcalLogicID> my_TTEcalLogicId;
695 vector<EcalLogicID> my_StripEcalLogicId;
699 vector<EcalLogicID> my_TTEcalLogicId_EE;
700 vector<EcalLogicID> my_RTEcalLogicId_EE;
701 vector<EcalLogicID> my_StripEcalLogicId1_EE;
702 vector<EcalLogicID> my_StripEcalLogicId2_EE;
703 vector<EcalLogicID> my_CrystalEcalLogicId_EE;
704 vector<EcalLogicID> my_TTEcalLogicId_EB_by_TCC;
705 vector<EcalLogicID> my_StripEcalLogicId_EE_strips_by_TCC;
708 std::cout<<
"going to get the ecal logic id set"<< endl;
715 "EB_crystal_number",12 );
720 "EB_trigger_tower",12 );
722 std::cout<<
"got the 3 ecal barrel logic id set"<< endl;
729 "EE_crystal_number",123 );
737 "ECAL_readout_strip",123 );
744 "ECAL_readout_strip",123 );
752 "EE_trigger_strip",123 );
762 "ECAL_trigger_tower",12 );
770 "EE_trigger_tower",12 );
778 "EE_readout_tower",12 );
780 std::cout<<
"got the end cap logic id set"<< endl;
783 std::cout<<
"Getting the latest ids for this tag (latest version) "<< endl;
790 db_-> fetchConfigSet(&fe_main_info);
808 cout <<
" tag did not exist a new tag will be created " << endl;
810 cout <<
"Unknown error caught" << endl;
819 map<EcalLogicID, FEConfigPedDat> pedset ;
820 map<EcalLogicID, FEConfigLinDat> linset ;
821 map<EcalLogicID, FEConfigLinParamDat> linparamset ;
822 map<EcalLogicID, FEConfigLUTParamDat> lutparamset ;
823 map<EcalLogicID, FEConfigFgrParamDat> fgrparamset ;
825 map<int, linStruc> linEtaSlice ;
826 map< vector<int>,
linStruc > linMap ;
829 int NbOfStripPerTCC[108][68] ;
830 for (
int i=0 ;
i<108 ;
i++)
831 for (
int j=0 ;
j<68 ;
j++)
832 NbOfStripPerTCC[
i][
j] = 0 ;
835 for (vector<DetId>::const_iterator it = ebCells.begin(); it != ebCells.end(); ++it) {
842 if (stripInTower>NbOfStripPerTCC[tccNb-1][towerInTCC-1]) NbOfStripPerTCC[tccNb-1][towerInTCC-1] = stripInTower ;
844 for (vector<DetId>::const_iterator it = eeCells.begin(); it != eeCells.end(); ++it) {
851 if (stripInTower>NbOfStripPerTCC[tccNb-1][towerInTCC-1]) NbOfStripPerTCC[tccNb-1][towerInTCC-1] = stripInTower ;
857 if (
writeToFiles_) (*out_file_)<<
"COMMENT ====== barrel crystals ====== "<<std::endl ;
860 for (vector<DetId>::const_iterator it = ebCells.begin(); it != ebCells.end(); ++it) {
874 int xtalInVFE = Id.
xtalId() ;
875 int xtalWithinCCUid = 5*(VFEid-1) + xtalInVFE -1 ;
877 (*geomFile_)<<
"dccNb = "<<dccNb<<
" tccNb = "<<tccNb<<
" towerInTCC = "<<towerInTCC
878 <<
" stripInTower = "<<stripInTower<<
" xtalInStrip = "<<xtalInStrip
879 <<
" CCUid = "<<CCUid<<
" VFEid = "<<VFEid<<
" xtalInVFE = "<<xtalInVFE
880 <<
" xtalWithinCCUid = "<<xtalWithinCCUid<<
" ieta = "<<
id.ieta()<<
" iphi = "<<
id.iphi()
881 <<
" xtalhashedId = "<<
id.hashedIndex()<<
" xtalNb = "<<
id.ic()
882 <<
" ietaTT = "<<towid.
ieta()<<
" iphiTT = "<<towid.
iphi()<<endl ;
884 int TCCch = towerInTCC ;
885 int SLBslot = int((towerInTCC-1)/8.) + 1 ;
886 int SLBch = (towerInTCC-1)%8 + 1 ;
887 int cmsswId =
id.rawId() ;
888 int ixtal=(
id.ism()-1)*1700+(
id.ic()-1);
891 int val[] = {dccNb+600,tccNb,towerInTCC,stripInTower,
892 xtalInStrip,CCUid,VFEid,xtalInVFE,xtalWithinCCUid,
id.ieta(),
id.iphi(),
894 id.ic(), cmsswId, dbId,
904 if (tccNb == 37 && stripInTower == 3 && xtalInStrip == 3 && (towerInTCC-1)%4==0) {
905 int etaSlice = towid.
ietaAbs() ;
907 getCoeff(coeff, calibMap,
id.rawId()) ;
908 getCoeff(coeff, gainMap,
id.rawId()) ;
909 getCoeff(coeff, pedMap,
id.rawId()) ;
911 for (
int i=0 ;
i<3 ;
i++) {
914 if (!ok)
std::cout <<
"unable to compute the parameters for SM="<<
id.ism()<<
" xt="<<
id.ic()<<
" " <<dec<<
id.rawId()<<std::endl ;
924 if (!ok)
std::cout<<
"SM="<<
id.ism()<<
" xt="<<
id.ic()<<
" " <<dec<<
id.rawId()<<std::endl ;
925 linEtaSlice[etaSlice] = lin ;
930 for (vector<DetId>::const_iterator it = ebCells.begin(); it != ebCells.end(); ++it) {
935 towerListEB.push_back(towid.
rawId()) ;
937 stripListEB.push_back(elId.
rawId() & 0xfffffff8) ;
946 int xtalInVFE = Id.
xtalId() ;
947 int xtalWithinCCUid = 5*(VFEid-1) + xtalInVFE -1 ;
948 int etaSlice = towid.
ietaAbs() ;
951 int hashedStripLogicID = 68*5*(
id.ism()-1) + 5*(towerInTCC-1) + (VFEid-1) ;
952 stripMapEB[hashedStripLogicID] = elId.
rawId() & 0xfffffff8 ;
969 if (
writeToFiles_) (*out_file_)<<
"CRYSTAL "<<dec<<
id.rawId()<<std::endl ;
973 getCoeff(coeff, calibMap,
id.rawId()) ;
975 getCoeff(coeff, gainMap,
id.rawId()) ;
976 getCoeff(coeff, pedMap,
id.rawId()) ;
977 ICEB->Fill(
id.iphi(),
id.ieta(), coeff.
calibCoeff_) ;
980 vector<int> xtalCCU ;
981 xtalCCU.push_back(dccNb+600) ;
982 xtalCCU.push_back(CCUid) ;
983 xtalCCU.push_back(xtalWithinCCUid) ;
984 xtalCCU.push_back(
id.rawId()) ;
989 map<int, linStruc>::const_iterator itLin = linEtaSlice.find(etaSlice);
990 if (itLin != linEtaSlice.end()) {
991 linMap[xtalCCU] = itLin->second ;
993 for (
int i=0 ;
i<3 ;
i++)
994 (*
out_file_) << hex <<
" 0x"<<itLin->second.pedestal_[
i]<<
" 0x"<<itLin->second.mult_[
i]<<
" 0x"<<itLin->second.shift_[
i]<<std::endl;
997 for (
int i=0 ;
i<3 ;
i++) {
1003 float factor = float(itLin->second.mult_[0])*
pow(2.,-itLin->second.shift_[0])/
xtal_LSB_EB_ ;
1004 tpgFactorEB->Fill(
id.iphi(),
id.ieta(), factor) ;
1008 else std::cout<<
"current EtaSlice = "<<etaSlice<<
" not found in the EtaSlice map"<<std::endl ;
1013 int forceBase12 = 0 ;
1014 for (
int i=0 ;
i<3 ;
i++) {
1017 if (!ok)
std::cout <<
"unable to compute the parameters for SM="<<
id.ism()<<
" xt="<<
id.ic()<<
" " <<dec<<
id.rawId()<<std::endl ;
1029 double G = mult*
pow(2.0,-(shift+2)) ;
1030 double g = G/
sin(theta) ;
1032 base = double(coeff.
pedestals_[
i]) - pedestal_offset_/
g ;
1033 if (base<0.) base = 0 ;
1034 forceBase12 = int(base) ;
1053 if (!ok)
std::cout<<
"SM="<<
id.ism()<<
" xt="<<
id.ic()<<
" " <<dec<<
id.rawId()<<std::endl ;
1055 for (
int i=0 ;
i<3 ;
i++) {
1064 tpgFactorEB->Fill(
id.iphi(),
id.ieta(), factor) ;
1069 double g = G/
sin(theta) ;
1070 float val[] = { float(
i),
1076 ntupleSpike->Fill(val) ;
1078 linMap[xtalCCU] = lin ;
1082 int ixtal=(
id.ism()-1)*1700+(
id.ic()-1);
1084 pedset[logicId] = pedDB ;
1085 linset[logicId] = linDB ;
1093 linparamset[my_EcalLogicId_EB] = linparam ;
1100 fgrparamset[my_EcalLogicId_EB] = fgrparam ;
1107 lutparamset[my_EcalLogicId_EB] = lutparam ;
1113 if (
writeToFiles_) (*out_file_)<<
"COMMENT ====== endcap crystals ====== "<<std::endl ;
1116 for (vector<DetId>::const_iterator it = eeCells.begin(); it != eeCells.end(); ++it) {
1123 int dccNb = Id.
dccId() ;
1130 int xtalInVFE = Id.
xtalId() ;
1131 int xtalWithinCCUid = 5*(VFEid-1) + xtalInVFE -1 ;
1133 (*geomFile_)<<
"dccNb = "<<dccNb<<
" tccNb = "<<tccNb<<
" towerInTCC = "<<towerInTCC
1134 <<
" stripInTower = "<<stripInTower<<
" xtalInStrip = "<<xtalInStrip
1135 <<
" CCUid = "<<CCUid<<
" VFEid = "<<VFEid<<
" xtalInVFE = "<<xtalInVFE
1136 <<
" xtalWithinCCUid = "<<xtalWithinCCUid<<
" ix = "<<
id.ix()<<
" iy = "<<
id.iy()
1137 <<
" xtalhashedId = "<<
id.hashedIndex()<<
" xtalNb = "<<
id.isc()
1138 <<
" ietaTT = "<<towid.
ieta()<<
" iphiTT = "<<towid.
iphi()<<endl ;
1140 int TCCch = stripInTower ;
1141 int SLBslot, SLBch ;
1144 SLBch = 4 + towerInTCC ;
1147 SLBslot = int((towerInTCC-5)/8.) + 2 ;
1148 SLBch = (towerInTCC-5)%8 + 1 ;
1150 for (
int j=0 ;
j<towerInTCC-1 ;
j++) TCCch += NbOfStripPerTCC[tccNb-1][
j] ;
1152 int cmsswId =
id.rawId() ;
1154 int iz =
id.positiveZ() ;
1155 if (iz ==0) iz = -1 ;
1156 for (
int k=0;
k<(int)my_CrystalEcalLogicId_EE.size();
k++) {
1157 int z= my_CrystalEcalLogicId_EE[
k].getID1() ;
1158 int x= my_CrystalEcalLogicId_EE[
k].getID2() ;
1159 int y= my_CrystalEcalLogicId_EE[
k].getID3() ;
1160 if (
id.ix()==x &&
id.iy()==y && iz==z) logicId=my_CrystalEcalLogicId_EE[
k];
1164 int val[] = {dccNb+600,tccNb,towerInTCC,stripInTower,
1165 xtalInStrip,CCUid,VFEid,xtalInVFE,xtalWithinCCUid,-999,-999,
1167 id.ic(),cmsswId, dbId,
1175 if ((tccNb == 76 || tccNb == 94) && stripInTower == 1 && xtalInStrip == 3 && (towerInTCC-1)%4==0) {
1176 int etaSlice = towid.
ietaAbs() ;
1178 getCoeff(coeff, calibMap,
id.rawId()) ;
1179 getCoeff(coeff, gainMap,
id.rawId()) ;
1180 getCoeff(coeff, pedMap,
id.rawId()) ;
1182 for (
int i=0 ;
i<3 ;
i++) {
1185 if (!ok)
std::cout <<
"unable to compute the parameters for Quadrant="<<
id.iquadrant()<<
" xt="<<
id.ic()<<
" " <<dec<<
id.rawId()<<std::endl ;
1195 if (!ok)
std::cout<<
"Quadrant="<<
id.iquadrant()<<
" xt="<<
id.ic()<<
" " <<dec<<
id.rawId()<<std::endl ;
1197 linEtaSlice[etaSlice] = lin ;
1202 for (vector<DetId>::const_iterator it = eeCells.begin(); it != eeCells.end(); ++it) {
1209 towerListEE.push_back(towid.
rawId()) ;
1213 towerListEE.push_back(additionalTower.rawId()) ;
1215 stripListEE.push_back(elId.
rawId() & 0xfffffff8) ;
1216 int dccNb = Id.
dccId() ;
1223 int xtalInVFE = Id.
xtalId() ;
1224 int xtalWithinCCUid = 5*(VFEid-1) + xtalInVFE -1 ;
1225 int etaSlice = towid.
ietaAbs() ;
1230 if (
writeToFiles_) (*out_file_)<<
"CRYSTAL "<<dec<<
id.rawId()<<std::endl ;
1232 int iz =
id.positiveZ() ;
1233 if (iz ==0) iz = -1 ;
1234 for (
int k=0;
k<(int)my_CrystalEcalLogicId_EE.size();
k++) {
1235 int z= my_CrystalEcalLogicId_EE[
k].getID1() ;
1236 int x= my_CrystalEcalLogicId_EE[
k].getID2() ;
1237 int y= my_CrystalEcalLogicId_EE[
k].getID3() ;
1238 if (
id.ix()==x &&
id.iy()==y && iz==z) logicId=my_CrystalEcalLogicId_EE[
k];
1243 getCoeff(coeff, calibMap,
id.rawId()) ;
1244 getCoeff(coeff, gainMap,
id.rawId()) ;
1245 getCoeff(coeff, pedMap,
id.rawId()) ;
1247 else ICEEMinus->Fill(
id.ix(),
id.iy(), coeff.
calibCoeff_) ;
1250 vector<int> xtalCCU ;
1251 xtalCCU.push_back(dccNb+600) ;
1252 xtalCCU.push_back(CCUid) ;
1253 xtalCCU.push_back(xtalWithinCCUid) ;
1254 xtalCCU.push_back(
id.rawId()) ;
1259 map<int, linStruc>::const_iterator itLin = linEtaSlice.find(etaSlice);
1260 if (itLin != linEtaSlice.end()) {
1261 linMap[xtalCCU] = itLin->second ;
1263 for (
int i=0 ;
i<3 ;
i++)
1264 (*
out_file_) << hex <<
" 0x"<<itLin->second.pedestal_[
i]<<
" 0x"<<itLin->second.mult_[
i]<<
" 0x"<<itLin->second.shift_[
i]<<std::endl;
1267 for (
int i=0 ;
i<3 ;
i++) {
1273 float factor = float(itLin->second.mult_[0])*
pow(2.,-itLin->second.shift_[0])/
xtal_LSB_EE_ ;
1274 if (
id.
zside()>0) tpgFactorEEPlus->Fill(
id.ix(),
id.iy(), factor) ;
1275 else tpgFactorEEMinus->Fill(
id.ix(),
id.iy(), factor) ;
1279 else std::cout<<
"current EtaSlice = "<<etaSlice<<
" not found in the EtaSlice map"<<std::endl ;
1284 for (
int i=0 ;
i<3 ;
i++) {
1287 if (!ok)
std::cout <<
"unable to compute the parameters for "<<dec<<
id.rawId()<<std::endl ;
1297 if (!ok)
std::cout<<
"Quadrant="<<
id.iquadrant()<<
" xt="<<
id.ic()<<
" " <<dec<<
id.rawId()<<std::endl ;
1299 for (
int i=0 ;
i<3 ;
i++) {
1308 if (
id.
zside()>0) tpgFactorEEPlus->Fill(
id.ix(),
id.iy(), factor) ;
1309 else tpgFactorEEMinus->Fill(
id.ix(),
id.iy(), factor) ;
1314 linMap[xtalCCU] = lin ;
1317 pedset[logicId] = pedDB ;
1318 linset[logicId] = linDB ;
1326 linparamset[my_EcalLogicId_EE] = linparam ;
1332 lutparamset[my_EcalLogicId_EE] = lutparam ;
1338 fgrparamset[my_EcalLogicId_EE] = fgrparam ;
1362 evgueni<<
"void getLinParamTPG_hardcoded(int fed, int ccu, int xtal,"<<endl ;
1363 evgueni<<
" int & mult12, int & shift12, int & base12,"<<endl ;
1364 evgueni<<
" int & mult6, int & shift6, int & base6,"<<endl ;
1365 evgueni<<
" int & mult1, int & shift1, int & base1)"<<endl ;
1367 evgueni<<
" mult12 = 0 ; shift12 = 0 ; base12 = 0 ; mult6 = 0 ; shift6 = 0 ; base6 = 0 ; mult1 = 0 ; shift1 = 0 ; base1 = 0 ;"<<endl ;
1368 map< vector<int>,
linStruc>::const_iterator itLinMap ;
1369 for (itLinMap = linMap.begin() ; itLinMap != linMap.end() ; itLinMap++) {
1370 vector<int> xtalInCCU = itLinMap->first ;
1371 evgueni<<
" if (fed=="<<xtalInCCU[0]<<
" && ccu=="<<xtalInCCU[1]<<
" && xtal=="<<xtalInCCU[2]<<
") {" ;
1372 evgueni<<
" mult12 = "<<itLinMap->second.
mult_[0]<<
" ; shift12 = "<<itLinMap->second.shift_[0]<<
" ; base12 = "<<itLinMap->second.pedestal_[0]<<
" ; " ;
1373 evgueni<<
" mult6 = "<<itLinMap->second.mult_[1]<<
" ; shift6 = "<<itLinMap->second.shift_[1]<<
" ; base6 = "<<itLinMap->second.pedestal_[1]<<
" ; " ;
1374 evgueni<<
" mult1 = "<<itLinMap->second.mult_[2]<<
" ; shift1 = "<<itLinMap->second.shift_[2]<<
" ; base1 = "<<itLinMap->second.pedestal_[2]<<
" ; " ;
1375 evgueni<<
" return ;}" <<endl ;
1377 evgueni<<
"}" <<endl ;
1386 const int NWEIGROUPS = 2 ;
1387 std::vector<unsigned int>
weights[NWEIGROUPS] ;
1394 map<EcalLogicID, FEConfigWeightGroupDat>
dataset;
1396 for (
int igrp=0 ; igrp<NWEIGROUPS ; igrp++) {
1398 if (weights[igrp].
size() == 5) {
1401 (*out_file_) <<std::endl ;
1402 (*out_file_) <<
"WEIGHT "<<igrp<<endl ;
1404 (*out_file_)<<std::endl ;
1405 (*out_file_) <<std::endl ;
1408 std::cout<<
"going to write the weights for groupe:"<<igrp<<endl;
1419 dataset[ecid] = gut;
1427 map<EcalLogicID, FEConfigWeightDat> dataset2;
1430 for (
int ich=0; ich<(int)my_StripEcalLogicId.size() ; ich++){
1434 dataset2[my_StripEcalLogicId[ich]] = wut;
1438 for (
int ich=0; ich<(int)my_StripEcalLogicId1_EE.size() ; ich++){
1443 dataset2[my_StripEcalLogicId1_EE[ich]] = wut;
1446 for (
int ich=0; ich<(int)my_StripEcalLogicId2_EE.size() ; ich++){
1451 dataset2[my_StripEcalLogicId2_EE[ich]] = wut;
1456 wtag.str(
""); wtag<<
"Shape_NGroups_"<<NWEIGROUPS;
1458 std::cout<<
" weight tag "<<weight_tag<<endl;
1468 unsigned int lowRatio, highRatio, lowThreshold, highThreshold, lutFG ;
1471 (*out_file_) <<std::endl ;
1472 (*out_file_) <<
"FG 0"<<std::endl ;
1473 (*out_file_)<<hex<<
"0x"<<lowThreshold<<
" 0x"<<highThreshold
1474 <<
" 0x"<<lowRatio<<
" 0x"<<highRatio<<
" 0x"<<lutFG
1480 unsigned int lut_strip;
1487 std::cout<<
"going to write the fgr "<< endl;
1488 map<EcalLogicID, FEConfigFgrGroupDat>
dataset;
1491 for (
int ich=0; ich<NFGRGROUPS; ich++){
1501 dataset[ecid] = gut;
1505 map<EcalLogicID, FEConfigFgrDat> dataset2;
1507 for (
int ich=0; ich<(int)my_TTEcalLogicId.size() ; ich++){
1514 dataset2[my_TTEcalLogicId[ich]] = wut;
1518 for (
int ich=0; ich<(int)my_RTEcalLogicId_EE.size() ; ich++){
1526 dataset2[my_RTEcalLogicId_EE[ich]] = wut;
1530 map<EcalLogicID, FEConfigFgrEETowerDat> dataset3;
1531 for (
int ich=0; ich<(int)my_TTEcalLogicId_EE.size() ; ich++){
1534 dataset3[my_TTEcalLogicId_EE[ich]]=fgreett;
1539 map<EcalLogicID, FEConfigFgrEEStripDat> dataset4;
1540 for (
int ich=0; ich<(int)my_StripEcalLogicId1_EE.size() ; ich++){
1544 dataset4[my_StripEcalLogicId1_EE[ich]] = zut;
1546 for (
int ich=0; ich<(int)my_StripEcalLogicId2_EE.size() ; ich++){
1551 dataset4[my_StripEcalLogicId2_EE[ich]] = zut;
1553 for (
int ich=0; ich<(int)my_StripEcalLogicId.size() ; ich++){
1557 uint32_t elStripId = stripMapEB[ich] ;
1558 map<uint32_t, uint32_t>::const_iterator it = stripMapEBsintheta.find(elStripId) ;
1559 if (it != stripMapEBsintheta.end()) zut.
setThreshold(it->second);
1561 cout<<
"ERROR: strip SFGVB threshold parameter not found for that strip:"<<thestrip.
getID1()<<
" "<<thestrip.
getID3()<<
" "<<thestrip.
getID3()<<endl ;
1567 dataset4[thestrip] = zut;
1574 std::cout<<
" weight tag "<<weight_tag<<endl;
1578 map<EcalLogicID, FEConfigSpikeDat> datasetspike;
1579 for (
int ich=0; ich<(int)my_TTEcalLogicId.size() ; ich++){
1582 datasetspike[my_TTEcalLogicId[ich]] = spiketh;
1589 std::cout<<
" spike tag "<<spike_tag<<endl;
1594 map<EcalLogicID, FEConfigTimingDat> datasetdelay;
1595 for (
int ich=0; ich<(int)my_TTEcalLogicId_EB_by_TCC.size() ; ich++){
1598 EcalLogicID logiciddelay = my_TTEcalLogicId_EB_by_TCC[ich] ;
1599 int id1_tcc=my_TTEcalLogicId_EB_by_TCC[ich].
getID1();
1600 int id2_tt =my_TTEcalLogicId_EB_by_TCC[ich].getID2();
1601 std::map<int, vector<int> >::const_iterator ittEB =
delays_EB_.find(id1_tcc);
1602 std::vector<int> TimingDelaysEB = ittEB->second;
1605 if(TimingDelaysEB[id2_tt-1] == -1){
1606 std::cout <<
"ERROR: Barrel timing delay not specified, check file, putting default value 1" << std::endl;
1611 std::cout <<
"ERROR:Barrel Could not find delay parameter for that trigger tower " << std::endl;
1612 std::cout <<
"Using default value = 1" << std::endl;
1616 std::map<int, vector<int> >::const_iterator ittpEB =
phases_EB_.find(id1_tcc);
1617 std::vector<int> TimingPhasesEB = ittpEB->second;
1620 if(TimingPhasesEB[id2_tt-1] == -1){
1621 std::cout <<
"ERROR: Barrel timing phase not specified, check file, putting default value 0" << std::endl;
1626 std::cout <<
"ERROR:Barrel Could not find phase parameter for that trigger tower " << std::endl;
1627 std::cout <<
"Using default value = 0" << std::endl;
1631 std::cout << ich <<
" tcc=" << id1_tcc <<
" TT=" << id2_tt <<
" logicId=" << logiciddelay.
getLogicID()
1632 <<
" delay=" << TimingDelaysEB[id2_tt-1] <<
" phase=" << TimingPhasesEB[id2_tt-1] << std::endl;
1636 datasetdelay[my_TTEcalLogicId_EB_by_TCC[ich]] = delay;
1642 for (
int ich=0; ich<(int)my_StripEcalLogicId_EE_strips_by_TCC.size() ; ich++){
1648 EcalLogicID logiciddelay = my_StripEcalLogicId_EE_strips_by_TCC[ich] ;
1649 int id1_tcc=my_StripEcalLogicId_EE_strips_by_TCC[ich].
getID1();
1650 int id2_tt =my_StripEcalLogicId_EE_strips_by_TCC[ich].getID2();
1651 int id3_st =my_StripEcalLogicId_EE_strips_by_TCC[ich].getID3();
1654 if(id1_tcc != tccin) {tccin = id1_tcc; stripindex=0;}
1656 std::map<int, vector<int> >::const_iterator ittEE =
delays_EE_.find(id1_tcc);
1657 std::vector<int> TimingDelaysEE = ittEE->second;
1660 if(TimingDelaysEE[stripindex] == -1){
1661 std::cout <<
"ERROR: Endcap timing delay not specified, check file, putting default value 1" << std::endl;
1666 std::cout <<
"ERROR:Endcap Could not find delay parameter for that trigger tower " << std::endl;
1667 std::cout <<
"Using default value = 1" << std::endl;
1671 std::map<int, vector<int> >::const_iterator ittpEE =
phases_EE_.find(id1_tcc);
1672 std::vector<int> TimingPhasesEE = ittpEE->second;
1675 if(TimingPhasesEE[stripindex] == -1){
1676 std::cout <<
"ERROR: Endcap timing phase not specified, check file, putting default value 0" << std::endl;
1681 std::cout <<
"ERROR:Endcap Could not find phase parameter for that trigger tower " << std::endl;
1682 std::cout <<
"Using default value = 0" << std::endl;
1686 std::cout << ich <<
" stripindex=" << stripindex <<
" tcc=" << id1_tcc <<
" TT=" << id2_tt <<
" id3_st=" << id3_st
1688 <<
" delay=" << TimingDelaysEE[stripindex] <<
" phase=" << TimingPhasesEE[stripindex] << std::endl;
1693 datasetdelay[my_StripEcalLogicId_EE_strips_by_TCC[ich]] = delay;
1697 ostringstream de_tag;
1698 de_tag.str(
""); de_tag<<
"DelaysFromFile";
1700 std::cout<<
" delay tag "<<delay_tag<<endl;
1707 std::cout<<
"going to write the sliding "<< endl;
1708 map<EcalLogicID, FEConfigSlidingDat>
dataset;
1710 for (
int ich=0; ich<(int)my_StripEcalLogicId.size() ; ich++){
1716 dataset[my_StripEcalLogicId[ich]] = wut;
1720 for (
int ich=0; ich<(int)my_StripEcalLogicId1_EE.size() ; ich++){
1726 dataset[my_StripEcalLogicId1_EE[ich]] = wut;
1728 for (
int ich=0; ich<(int)my_StripEcalLogicId2_EE.size() ; ich++){
1734 dataset[my_StripEcalLogicId2_EE[ich]] = wut;
1740 wtag.str(
""); wtag<<
"Sliding_"<<
sliding_;
1742 std::cout<<
" sliding tag "<<justatag<<endl;
1755 int lut_EB[1024], lut_EE[1024] ;
1760 (*out_file_) <<std::endl ;
1761 (*out_file_) <<
"LUT 0"<<std::endl ;
1762 for (
int i=0 ;
i<1024 ;
i++) (*
out_file_)<<
"0x"<<hex<<lut_EB[
i]<<endl ;
1763 (*out_file_)<<endl ;
1769 bool newLUT(
false) ;
1770 for (
int i=0 ;
i<1024 ;
i++)
if (lut_EE[
i] != lut_EB[
i]) newLUT =
true ;
1772 (*out_file_) <<std::endl ;
1773 (*out_file_) <<
"LUT 1"<<std::endl ;
1774 for (
int i=0 ; i<1024 ; i++) (*
out_file_)<<
"0x"<<hex<<lut_EE[
i]<<endl ;
1775 (*out_file_)<<endl ;
1784 map<EcalLogicID, FEConfigLUTGroupDat>
dataset;
1790 for (
int i=0; i<1024; i++){
1795 dataset[ecid] =
lut;
1801 for (
int i=0; i<1024; i++){
1806 dataset[ecide] =
lute;
1813 map<EcalLogicID, FEConfigLUTDat> dataset2;
1815 for (
int ich=0; ich<(int)my_TTEcalLogicId.size() ; ich++){
1821 dataset2[my_TTEcalLogicId[ich]] =
lut;
1825 for (
int ich=0; ich<(int)my_TTEcalLogicId_EE.size() ; ich++){
1831 dataset2[my_TTEcalLogicId_EE[ich]] =
lut;
1836 ltag.str(
""); ltag<<
LUT_option_<<
"_NGroups_"<<NLUTGROUPS;
1851 std::cout <<
"\n Conf ID = " << conf_id_ << std::endl;
1861 stripListEB.sort() ;
1862 stripListEB.unique() ;
1863 cout<<
"Number of EB strips="<<dec<<stripListEB.size()<<endl ;
1865 (*out_file_) <<std::endl ;
1866 for (itList = stripListEB.begin(); itList != stripListEB.end(); itList++ ) {
1867 (*out_file_) <<
"STRIP_EB "<<dec<<(*itList)<<endl ;
1868 (*out_file_) << hex <<
"0x" <<
sliding_<<std::endl ;
1869 (*out_file_) <<
"0" <<std::endl ;
1870 (*out_file_) <<
"0x"<<stripMapEBsintheta[(*itList)] <<
" 0x" <<
SFGVB_lut_ <<std::endl ;
1875 stripListEE.sort() ;
1876 stripListEE.unique() ;
1877 cout<<
"Number of EE strips="<<dec<<stripListEE.size()<<endl ;
1879 (*out_file_) <<std::endl ;
1880 for (itList = stripListEE.begin(); itList != stripListEE.end(); itList++ ) {
1881 (*out_file_) <<
"STRIP_EE "<<dec<<(*itList)<<endl ;
1882 (*out_file_) << hex <<
"0x" <<
sliding_<<std::endl ;
1883 (*out_file_) <<
" 0" << std::endl ;
1884 (*out_file_)<<hex<<
"0x"<<threshold<<
" 0x"<<lut_strip<<std::endl ;
1894 towerListEB.sort() ;
1895 towerListEB.unique() ;
1896 cout<<
"Number of EB towers="<<dec<<towerListEB.size()<<endl ;
1898 (*out_file_) <<std::endl ;
1899 for (itList = towerListEB.begin(); itList != towerListEB.end(); itList++ ) {
1900 (*out_file_) <<
"TOWER_EB "<<dec<<(*itList)<<endl ;
1901 (*out_file_) <<
" 0\n 0\n" ;
1907 towerListEE.sort() ;
1908 towerListEE.unique() ;
1909 cout<<
"Number of EE towers="<<dec<<towerListEE.size()<<endl ;
1911 (*out_file_) <<std::endl ;
1912 for (itList = towerListEE.begin(); itList != towerListEE.end(); itList++ ) {
1913 (*out_file_) <<
"TOWER_EE "<<dec<<(*itList)<<endl ;
1914 if (newLUT) (*out_file_) <<
" 1\n" ;
1916 (*out_file_)<<hex<<
"0x"<<lut_tower<<std::endl ;
1927 tpgFactorEB->Write() ;
1929 tpgFactorEEPlus->Write() ;
1930 ICEEMinus->Write() ;
1931 tpgFactorEEMinus->Write() ;
1933 tpgFactor->Write() ;
1937 ntupleSpike->Write() ;
1943 using namespace edm;
1944 using namespace std;
1954 (*out_file_)<<
"PHYSICS_EB "<<dec<<eb.
rawId()<<std::endl ;
1959 (*out_file_) <<std::endl ;
1961 (*out_file_)<<
"PHYSICS_EE "<<dec<<ee.
rawId()<<std::endl ;
1964 <<-1<<
" "<<-1<<std::endl ;
1965 (*out_file_) <<std::endl ;
2004 double factor = 1024 * ratio * gainRatio * calibCoeff *
sin(theta) * (1 << (
sliding_ + shiftDet + 2)) ;
2006 mult = (int)(factor+0.5) ;
2007 for (shift = 0 ; shift<15 ; shift++) {
2008 if (mult>=128 && mult<256)
return true ;
2010 mult = (int)(factor+0.5) ;
2012 std::cout <<
"too bad we did not manage to calculate the factor for calib="<<calibCoeff<<endl;
2019 (*out_file_) <<
"COMMENT put your comments here"<<std::endl ;
2021 (*out_file_) <<
"COMMENT ================================="<<std::endl ;
2022 (*out_file_) <<
"COMMENT physics EB structure"<<std::endl ;
2023 (*out_file_) <<
"COMMENT"<<std::endl ;
2024 (*out_file_) <<
"COMMENT EtSaturation (GeV), ttf_threshold_Low (GeV), ttf_threshold_High (GeV)"<<std::endl ;
2025 (*out_file_) <<
"COMMENT FG_lowThreshold (GeV), FG_highThreshold (GeV), FG_lowRatio, FG_highRatio"<<std::endl ;
2027 (*out_file_) <<
"COMMENT ================================="<<std::endl ;
2028 (*out_file_) <<
"COMMENT"<<std::endl ;
2030 (*out_file_) <<
"COMMENT ================================="<<std::endl ;
2031 (*out_file_) <<
"COMMENT physics EE structure"<<std::endl ;
2032 (*out_file_) <<
"COMMENT"<<std::endl ;
2033 (*out_file_) <<
"COMMENT EtSaturation (GeV), ttf_threshold_Low (GeV), ttf_threshold_High (GeV)"<<std::endl ;
2034 (*out_file_) <<
"COMMENT FG_Threshold (GeV), dummy, dummy, dummy"<<std::endl ;
2035 (*out_file_) <<
"COMMENT ================================="<<std::endl ;
2036 (*out_file_) <<
"COMMENT"<<std::endl ;
2038 (*out_file_) <<
"COMMENT ================================="<<std::endl ;
2039 (*out_file_) <<
"COMMENT crystal structure (same for EB and EE)"<<std::endl ;
2040 (*out_file_) <<
"COMMENT"<<std::endl ;
2041 (*out_file_) <<
"COMMENT ped, mult, shift [gain12]"<<std::endl ;
2042 (*out_file_) <<
"COMMENT ped, mult, shift [gain6]"<<std::endl ;
2043 (*out_file_) <<
"COMMENT ped, mult, shift [gain1]"<<std::endl ;
2044 (*out_file_) <<
"COMMENT ================================="<<std::endl ;
2045 (*out_file_) <<
"COMMENT"<<std::endl ;
2047 (*out_file_) <<
"COMMENT ================================="<<std::endl ;
2048 (*out_file_) <<
"COMMENT strip EB structure"<<std::endl ;
2049 (*out_file_) <<
"COMMENT"<<std::endl ;
2050 (*out_file_) <<
"COMMENT sliding_window"<<std::endl ;
2051 (*out_file_) <<
"COMMENT weightGroupId"<<std::endl ;
2052 (*out_file_) <<
"COMMENT threshold_sfg lut_sfg"<<std::endl ;
2053 (*out_file_) <<
"COMMENT ================================="<<std::endl ;
2054 (*out_file_) <<
"COMMENT"<<std::endl ;
2056 (*out_file_) <<
"COMMENT ================================="<<std::endl ;
2057 (*out_file_) <<
"COMMENT strip EE structure"<<std::endl ;
2058 (*out_file_) <<
"COMMENT"<<std::endl ;
2059 (*out_file_) <<
"COMMENT sliding_window"<<std::endl ;
2060 (*out_file_) <<
"COMMENT weightGroupId"<<std::endl ;
2061 (*out_file_) <<
"COMMENT threshold_fg lut_fg"<<std::endl ;
2062 (*out_file_) <<
"COMMENT ================================="<<std::endl ;
2063 (*out_file_) <<
"COMMENT"<<std::endl ;
2065 (*out_file_) <<
"COMMENT ================================="<<std::endl ;
2066 (*out_file_) <<
"COMMENT tower EB structure"<<std::endl ;
2067 (*out_file_) <<
"COMMENT"<<std::endl ;
2068 (*out_file_) <<
"COMMENT LUTGroupId"<<std::endl ;
2069 (*out_file_) <<
"COMMENT FgGroupId"<<std::endl ;
2070 (*out_file_) <<
"COMMENT spike_killing_threshold"<<std::endl ;
2071 (*out_file_) <<
"COMMENT ================================="<<std::endl ;
2072 (*out_file_) <<
"COMMENT"<<std::endl ;
2074 (*out_file_) <<
"COMMENT ================================="<<std::endl ;
2075 (*out_file_) <<
"COMMENT tower EE structure"<<std::endl ;
2076 (*out_file_) <<
"COMMENT"<<std::endl ;
2077 (*out_file_) <<
"COMMENT LUTGroupId"<<std::endl ;
2078 (*out_file_) <<
"COMMENT tower_lut_fg"<<std::endl ;
2079 (*out_file_) <<
"COMMENT ================================="<<std::endl ;
2080 (*out_file_) <<
"COMMENT"<<std::endl ;
2082 (*out_file_) <<
"COMMENT ================================="<<std::endl ;
2083 (*out_file_) <<
"COMMENT Weight structure"<<std::endl ;
2084 (*out_file_) <<
"COMMENT"<<std::endl ;
2085 (*out_file_) <<
"COMMENT weightGroupId"<<std::endl ;
2086 (*out_file_) <<
"COMMENT w0, w1, w2, w3, w4"<<std::endl ;
2087 (*out_file_) <<
"COMMENT ================================="<<std::endl ;
2088 (*out_file_) <<
"COMMENT"<<std::endl ;
2090 (*out_file_) <<
"COMMENT ================================="<<std::endl ;
2091 (*out_file_) <<
"COMMENT lut structure"<<std::endl ;
2092 (*out_file_) <<
"COMMENT"<<std::endl ;
2093 (*out_file_) <<
"COMMENT LUTGroupId"<<std::endl ;
2094 (*out_file_) <<
"COMMENT LUT[1-1024]"<<std::endl ;
2095 (*out_file_) <<
"COMMENT ================================="<<std::endl ;
2096 (*out_file_) <<
"COMMENT"<<std::endl ;
2098 (*out_file_) <<
"COMMENT ================================="<<std::endl ;
2099 (*out_file_) <<
"COMMENT fg EB structure"<<std::endl ;
2100 (*out_file_) <<
"COMMENT"<<std::endl ;
2101 (*out_file_) <<
"COMMENT FgGroupId"<<std::endl ;
2102 (*out_file_) <<
"COMMENT el, eh, tl, th, lut_fg"<<std::endl ;
2103 (*out_file_) <<
"COMMENT ================================="<<std::endl ;
2104 (*out_file_) <<
"COMMENT"<<std::endl ;
2106 (*out_file_) <<std::endl ;
2113 unsigned int max = (
unsigned int)(
pow(2.,complement2)-1) ;
2114 if (weight>0) iweight=int((1<<6)*weight+0.5) ;
2115 else iweight= max - int(-weight*(1<<6)+0.5) +1 ;
2116 iweight = iweight &
max ;
2122 double weight = double(iweight)/
pow(2., 6.) ;
2124 if ( (iweight & (1<<(complement2-1))) != 0) weight = (double(iweight)-
pow(2., complement2))/
pow(2., 6.) ;
2130 std::cout<<
"Computing Weights..."<<std::endl ;
2132 double max = shape(timeMax) ;
2139 sumf += shape(time)/
max ;
2140 sumf2 += shape(time)/max * shape(time)/
max ;
2141 for (
int subtime = 0 ; subtime<25 ; subtime++) histo->Fill(
float(
sample*25. + subtime)/25., shape(time+subtime)) ;
2143 double lambda = 1./(sumf2-sumf*sumf/
nSample_) ;
2144 double gamma = -lambda*sumf/
nSample_ ;
2149 weight[
sample] = lambda*shape(time)/max + gamma ;
2153 int * iweight =
new int[
nSample_] ;
2158 for (
unsigned int sample = 0 ; sample<
nSample_ ; sample++) isumw += iweight[sample] ;
2160 isumw = (isumw & imax ) ;
2164 for (
unsigned int sample = 0 ; sample<
nSample_ ; sample++) {
2167 ampl += weight[
sample]*shape(time) ;
2169 std::cout<<
"weight="<<weight[
sample]<<
" shape="<<shape(time)<<std::endl ;
2172 std::cout<<
"Weights: sum (weight*shape) = "<<ampl<<std::endl ;
2179 while (isumw != 0 && count<10) {
2181 unsigned int index = 0 ;
2184 std::cout<<
"Correcting for bias: adding 1"<<std::endl ;
2185 for (
unsigned int sample = 0 ; sample<
nSample_ ; sample++) {
2186 int new_iweight = iweight[
sample]+1 ;
2188 if (fabs(new_weight-weight[sample])<min) {
2189 min = fabs(new_weight-weight[sample]) ;
2196 std::cout<<
"Correcting for bias: subtracting 1"<<std::endl ;
2197 for (
unsigned int sample = 0 ; sample<
nSample_ ; sample++) {
2198 int new_iweight = iweight[
sample]-1 ;
2200 if (fabs(new_weight-weight[sample])<min) {
2201 min = fabs(new_weight-weight[sample]) ;
2208 for (
unsigned int sample = 0 ; sample<
nSample_ ; sample++) isumw += iweight[sample] ;
2210 isumw = (isumw & imax ) ;
2211 std::cout<<
"Correcting weight number: "<<index<<
" sum weights = "<<isumw<<std::endl ;
2218 for (
unsigned int sample = 0 ; sample<
nSample_ ; sample++) isumw += iweight[sample] ;
2220 isumw = (isumw & imax ) ;
2222 for (
unsigned int sample = 0 ; sample<
nSample_ ; sample++) {
2227 ampl += new_weight*shape(time) ;
2228 std::cout<<
"weight unbiased after integer conversion="<<new_weight<<
" shape="<<shape(time)<<std::endl ;
2231 std::cout<<
"Weights: sum (weight*shape) = "<<ampl<<std::endl ;
2235 std::vector<unsigned int> theWeights ;
2236 for (
unsigned int sample = 0 ; sample<
nSample_ ; sample++) theWeights.push_back(iweight[sample]) ;
2264 for (
int i=0 ;
i<1024 ;
i++) {
2266 if (lut[
i]>0xff) lut[
i] = 0xff ;
2272 for (
int i=0 ;
i<1024 ;
i++) {
2274 if ((
i+1)%4 == 0 ) mylut++ ;
2282 func->SetParameters(LUT_stochastic, LUT_noise, LUT_constant) ;
2283 double norm = func->Integral(0., Et_sat) ;
2284 for (
int i=0 ;
i<1024 ;
i++) {
2285 double Et =
i*Et_sat/1024. ;
2286 lut[
i] = int(0xff*func->Integral(0., Et)/norm + 0.5) ;
2291 for (
int j=0 ;
j<1024 ;
j++) {
2292 double Et_GeV = Et_sat/1024*(
j+0.5) ;
2293 if (Et_GeV <= LUT_threshold) lut[
j] = 0 ;
2295 if (Et_GeV >= TTF_highThreshold) ttf = 3 ;
2296 if (Et_GeV >= TTF_lowThreshold && Et_GeV < TTF_highThreshold) ttf = 1 ;
2310 else std::cout<<
"getCoeff: "<<rawId<<
" not found in EcalIntercalibConstantMap"<<std::endl ;
2320 if (gainIter != gainMap.
end()) {
2325 else std::cout<<
"getCoeff: "<<rawId<<
" not found in EcalGainRatioMap"<<std::endl ;
2343 if (pedIter != pedMap.
end()) {
2349 else std::cout<<
"getCoeff: "<<rawId<<
" not found in EcalPedestalsMap"<<std::endl ;
2359 map<EcalLogicID, MonPedestalsDat>::const_iterator it = pedMap.find(logicId);
2360 if (it != pedMap.end()) {
2367 <<
" not found in map<EcalLogicID, MonPedestalsDat>"<<std::endl ;
2371 unsigned int & lowThreshold,
unsigned int & highThreshold,
unsigned int &
lut)
2374 if (lowRatio>0x7f) lowRatio = 0x7f ;
2376 if (highRatio>0x7f) highRatio = 0x7f ;
2381 if (lowThreshold>0xff) lowThreshold = 0xff ;
2383 if (highThreshold>0xff) highThreshold = 0xff ;
2409 for (
int i=1 ;
i<3 ;
i++) {
2413 }
else base[
i] = 0 ;
2416 for (
int i=0 ;
i<3 ;
i++) {
2420 cout<<
"WARNING: base= "<<base[
i]<<
", "<<lin.
pedestal_[
i]<<
" for gainId[0-2]="<<
i<<
" ==> forcing at 0"<<endl ;
2431 gctphi = (ttphi+1)/4;
2432 if(ttphi<=2) gctphi=0;
2433 if(ttphi>=71) gctphi=0;
2439 if(tteta>0) gcteta = (tteta-1)/4 + 11;
2440 else if(tteta<0) gcteta = (tteta+1)/4 + 10;
2445 std::stringstream sdet ;
2447 if (tcc>36 && tcc<55) sdet<<
"EB-"<<tcc-36 ;
2448 else if (tcc>=55 && tcc<73) sdet<<
"EB+"<<tcc-54 ;
2449 else if (tcc<=36) sdet<<
"EE-" ;
2452 if (tcc<=36 || tcc>=73) {
2453 if (tcc>=73) tcc-=72 ;
2454 if (tcc==1 || tcc==18 || tcc==19 || tcc==36) sdet<<7 ;
2455 else if (tcc==2 || tcc==3 || tcc==20 || tcc==21) sdet<<8 ;
2456 else if (tcc==4 || tcc==5 || tcc==22 || tcc==23) sdet<<9 ;
2457 else if (tcc==6 || tcc==7 || tcc==24 || tcc==25) sdet<<1 ;
2458 else if (tcc==8 || tcc==9 || tcc==26 || tcc==27) sdet<<2 ;
2459 else if (tcc==10 || tcc==11 || tcc==28 || tcc==29) sdet<<3 ;
2460 else if (tcc==12 || tcc==13 || tcc==30 || tcc==31) sdet<<4 ;
2461 else if (tcc==14 || tcc==15 || tcc==32 || tcc==33) sdet<<5 ;
2462 else if (tcc==16 || tcc==17 || tcc==34 || tcc==35) sdet<<6 ;
2469 std::stringstream crate ;
2474 if (tcc>=40 && tcc<=42) {crate<<
"02d" ; slot = 5 + (tcc-40)*6 ;}
2475 if (tcc>=43 && tcc<=45) {crate<<
"03d" ; slot = 5 + (tcc-43)*6 ;}
2476 if (tcc>=37 && tcc<=39) {crate<<
"04d" ; slot = 5 + (tcc-37)*6 ;}
2477 if (tcc>=52 && tcc<=54) {crate<<
"06d" ; slot = 5 + (tcc-52)*6 ;}
2478 if (tcc>=46 && tcc<=48) {crate<<
"07d" ; slot = 5 + (tcc-46)*6 ;}
2479 if (tcc>=49 && tcc<=51) {crate<<
"08d" ; slot = 5 + (tcc-49)*6 ;}
2480 if (tcc>=58 && tcc<=60) {crate<<
"02h" ; slot = 5 + (tcc-58)*6 ;}
2481 if (tcc>=61 && tcc<=63) {crate<<
"03h" ; slot = 5 + (tcc-61)*6 ;}
2482 if (tcc>=55 && tcc<=57) {crate<<
"04h" ; slot = 5 + (tcc-55)*6 ;}
2483 if (tcc>=70 && tcc<=72) {crate<<
"06h" ; slot = 5 + (tcc-70)*6 ;}
2484 if (tcc>=64 && tcc<=66) {crate<<
"07h" ; slot = 5 + (tcc-64)*6 ;}
2485 if (tcc>=67 && tcc<=69) {crate<<
"08h" ; slot = 5 + (tcc-67)*6 ;}
2487 if (tcc>=76 && tcc<=81) {
2489 if (tcc%2==0) slot = 2 + (tcc-76)*3 ;
2490 else slot = 4 + (tcc-77)*3 ;
2492 if (tcc>=94 && tcc<=99) {
2494 if (tcc%2==0) slot = 3 + (tcc-94)*3 ;
2495 else slot = 5 + (tcc-95)*3 ;
2498 if (tcc>=22 && tcc<=27) {
2500 if (tcc%2==0) slot = 2 + (tcc-22)*3 ;
2501 else slot = 4 + (tcc-23)*3 ;
2503 if (tcc>=4 && tcc<=9) {
2505 if (tcc%2==0) slot = 3 + (tcc-4)*3 ;
2506 else slot = 5 + (tcc-5)*3 ;
2509 if (tcc>=82 && tcc<=87) {
2511 if (tcc%2==0) slot = 2 + (tcc-82)*3 ;
2512 else slot = 4 + (tcc-83)*3 ;
2514 if (tcc>=100 && tcc<=105) {
2516 if (tcc%2==0) slot = 3 + (tcc-100)*3 ;
2517 else slot = 5 + (tcc-101)*3 ;
2520 if (tcc>=28 && tcc<=33) {
2522 if (tcc%2==0) slot = 2 + (tcc-28)*3 ;
2523 else slot = 4 + (tcc-29)*3 ;
2525 if (tcc>=10 && tcc<=15) {
2527 if (tcc%2==0) slot = 3 + (tcc-10)*3 ;
2528 else slot = 5 + (tcc-11)*3 ;
2531 if (tcc==34) {crate<<
"04l" ; slot = 2 ;}
2532 if (tcc==16) {crate<<
"04l" ; slot = 3 ;}
2533 if (tcc==35) {crate<<
"04l" ; slot = 4 ;}
2534 if (tcc==17) {crate<<
"04l" ; slot = 5 ;}
2535 if (tcc==36) {crate<<
"04l" ; slot = 8 ;}
2536 if (tcc==18) {crate<<
"04l" ; slot = 9 ;}
2537 if (tcc==19) {crate<<
"04l" ; slot = 10 ;}
2538 if (tcc==1) {crate<<
"04l" ; slot = 11 ;}
2539 if (tcc==20) {crate<<
"04l" ; slot = 14 ;}
2540 if (tcc==2) {crate<<
"04l" ; slot = 15 ;}
2541 if (tcc==21) {crate<<
"04l" ; slot = 16 ;}
2542 if (tcc==3) {crate<<
"04l" ; slot = 17 ;}
2544 if (tcc==88) {crate<<
"06l" ; slot = 2 ;}
2545 if (tcc==106) {crate<<
"06l" ; slot = 3 ;}
2546 if (tcc==89) {crate<<
"06l" ; slot = 4 ;}
2547 if (tcc==107) {crate<<
"06l" ; slot = 5 ;}
2548 if (tcc==90) {crate<<
"06l" ; slot = 8 ;}
2549 if (tcc==108) {crate<<
"06l" ; slot = 9 ;}
2550 if (tcc==73) {crate<<
"06l" ; slot = 10 ;}
2551 if (tcc==91) {crate<<
"06l" ; slot = 11 ;}
2552 if (tcc==74) {crate<<
"06l" ; slot = 14 ;}
2553 if (tcc==92) {crate<<
"06l" ; slot = 15 ;}
2554 if (tcc==75) {crate<<
"06l" ; slot = 16 ;}
2555 if (tcc==93) {crate<<
"06l" ; slot = 17 ;}
2557 return std::pair< std::string, int > (crate.str(),slot) ;
int writeToConfDB_TPGLinearCoef(const std::map< EcalLogicID, FEConfigLinDat > &linset, const std::map< EcalLogicID, FEConfigLinParamDat > &linparamset, int iovId, std::string tag)
T getParameter(std::string const &) const
T getUntrackedParameter(std::string const &, T const &) const
std::map< int, std::vector< int > > phases_EB_
bool checkIfOK(const EcalPedestals::Item &item)
void setThreshLow(float x)
edm::ESHandle< EcalTrigTowerConstituentsMap > eTTmap_
int xtalId() const
get the channel id
void setLUTGroupId(int x)
int stripId() const
get the tower id
void setFGhighratio(float x)
const self & getMap() const
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 TimingPhases_EE_
std::string getDet(int tcc)
double oneOverEtResolEt(double *x, double *par)
Geom::Theta< T > theta() const
unsigned tccId(DetId const &)
bool weight_unbias_recovery_
void setFGlowthresh(float x)
int towerId() const
get the tower id
void setRatioHigh(float x)
int iTT(const EcalTrigTowerDetId &id) const
returns the index of a Trigger Tower within its TCC.
int writeToConfDB_TPGSliding(const std::map< EcalLogicID, FEConfigSlidingDat > &sliset, int iovId, std::string tag)
unsigned int FG_lut_tower_EE_
std::string TimingDelays_EE_
int writeToConfDB_Delay(const std::map< EcalLogicID, FEConfigTimingDat > &delaygroupset, std::string tag)
const CaloSubdetectorGeometry * theEndcapGeometry_
double FG_lowThreshold_EB_
int writeToConfDB_TPGMain(int ped, int lin, int lut, int fgr, int sli, int wei, int spi, int tim, int bxt, int btt, int bst, std::string tag, int ver)
std::ofstream * out_file_
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
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)
float getPedMeanG12() const
std::map< int, std::vector< int > > delays_EE_
std::string TimingDelays_EB_
const T & max(const T &a, const T &b)
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_
EcalTPGParamBuilder(edm::ParameterSet const &pSet)
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="")
virtual void analyze(const edm::Event &evt, const edm::EventSetup &evtSetup)
Abs< T >::type abs(const T &t)
EcalTriggerElectronicsId getTriggerElectronicsId(const DetId &id) const
Get the trigger electronics id for this det id.
double LUT_stochastic_EE_
std::ofstream * geomFile_
void setLUTGroupId(int x)
void setFgrGroupId(int x)
int pseudoStripId() const
get the tower id
int dccId() const
get the DCC (Ecal Local DCC value not global one) id
void setSpikeThreshold(int x)
float getPedMeanG12() const
void setTimingPar1(int x)
void insert(std::pair< uint32_t, Item > const &a)
void setRatioLow(float x)
void setFgrGroupId(int x)
int writeToConfDB_Spike(const std::map< EcalLogicID, FEConfigSpikeDat > &spikegroupset, std::string tag)
void computeFineGrainEEParameters(uint &threshold, uint &lut_strip, uint &lut_tower)
bool realignBaseline(linStruc &lin, float forceBase12)
bool computeLinearizerParam(double theta, double gainRatio, double calibCoeff, std::string subdet, int &mult, int &shift)
unsigned int pedestal_offset_
int iphi() const
get the tower iphi
const CaloSubdetectorGeometry * theBarrelGeometry_
bool useInterCalibration_
int writeToConfDB_TPGPedestals(const std::map< EcalLogicID, FEConfigPedDat > &pedset, int iovId, std::string tag)
void setPedMeanG12(float mean)
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 getPedMeanG1() const
float getPedMeanG6() const
return(e1-e2)*(e1-e2)+dp *dp
EcalSubdetector subDet() const
get the subDetector associated to the Trigger Tower
void setConfigTag(std::string x)
void setFGlowratio(float x)
double TTF_highThreshold_EE_
void setSliding(float mean)
std::string TimingPhases_EB_
double LUT_stochastic_EB_
void setTTThreshhigh(float x)
int writeToConfDB_TPGLUT(const std::map< EcalLogicID, FEConfigLUTGroupDat > &lutgroup, const std::map< EcalLogicID, FEConfigLUTDat > &lutdat, const std::map< EcalLogicID, FEConfigLUTParamDat > &lutparamset, int iovId, std::string tag)
float getPedMeanG6() const
const_iterator find(uint32_t rawId) const
static unsigned int const shift
void setWeightGroupId(int x)
int writeToConfDB_TPGFgr(const std::map< EcalLogicID, FEConfigFgrGroupDat > &lutgroup, const std::map< EcalLogicID, FEConfigFgrDat > &lutdat, const std::map< EcalLogicID, FEConfigFgrParamDat > &fgrparamset, const std::map< EcalLogicID, FEConfigFgrEETowerDat > &dataset3, const std::map< EcalLogicID, FEConfigFgrEEStripDat > &dataset4, int iovId, std::string tag)
unsigned int complement2_
const_iterator end() const
int writeToConfDB_TPGWeight(const std::map< EcalLogicID, FEConfigWeightGroupDat > &lutgroup, const std::map< EcalLogicID, FEConfigWeightDat > &lutdat, int iovId, std::string tag)
int getGCTRegionEta(int tteta)
volatile std::atomic< bool > shutdown_flag false
void setTTThreshlow(float x)
static const int SMCRYSTALMODE
void setWeightGroupId(int x)
unsigned int FG_lut_strip_EE_
const GlobalPoint & getPosition() const
Returns the position of reference for this cell.
int getEtaSlice(int tccId, int towerInTCC)
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)
int uncodeWeight(double weight, int complement2=7)