83#include "Gaudi/Property.h"
84#include "GaudiKernel/IToolSvc.h"
109#include "CoralBase/Blob.h"
144 return StatusCode::SUCCESS;
155 return fix13(cabling);
157 return StatusCode::SUCCESS;
164 const EventContext& ctx = Gaudi::Hive::currentContext();
169 ATH_MSG_ERROR(
"Do not have cabling mapping from key " << m_cablingKey.key() );
170 return StatusCode::FAILURE;
176 return StatusCode::FAILURE;
181 return fix1(cabling);
183 return fix2(cabling);
185 return fix3(cabling);
187 return fix4(cabling);
189 return fix5(cabling);
191 return fix6(cabling);
193 return fix7(cabling);
195 return fix8(cabling);
197 return fix9(cabling);
199 return fix10(cabling);
201 return fix11(cabling);
203 return fix12(cabling);
205 return fix13(cabling);
207 return fix14(cabling);
213 return fix17(cabling);
215 return fix18(clCont);
217 return StatusCode::SUCCESS;
229 const LArEM_ID* em_idhelper =
nullptr;
236 SmartIF<IToolSvc> toolSvc{Gaudi::svcLocator()->service(
"ToolSvc")};
244 std::ifstream infile(
"barrel_dac2ua_oct06.txt") ;
248 return StatusCode::FAILURE;
252 int det,samp,reg,
eta;
255 while ( infile>>det>>samp>>reg>>
eta>>value )
266 if ( det==1 && samp==1 && reg==0 &&
eta==0 ){
293 return StatusCode::SUCCESS;
311 SmartIF<IToolSvc> toolSvc{Gaudi::svcLocator()->service(
"ToolSvc")};
339 for(
unsigned int gain=0;gain<3;++gain)
346 for (; it!=it_e;++it)
349 if( (*it).isEmpty() )
continue;
350 if(cabling->isOnlineConnected(hid)){
371 " Number of entries removed = " <<n );
376 hid_mod[0] = online_idhelper->
channel_Id(1,1,6,1,33);
377 hid_mod[1] = online_idhelper->
channel_Id(1,1,6,10,12);
378 hid_mod[2] = online_idhelper->
channel_Id(1,1,6,14,12);
381 std::vector<Identifier>::const_iterator it= fcal_idhelper->
fcal_begin();
382 std::vector<Identifier>::const_iterator it_e= fcal_idhelper->
fcal_end();
387 int pn = fcal_idhelper->
pos_neg(
id);
389 int phi = fcal_idhelper->
phi(
id);
392 int module = fcal_idhelper->module(
id)-1;
396 for(
unsigned int gain = 0;gain<3;++gain){
399 if (!rampP.
isEmpty()) continue ;
415 shape->
setPdata(hid,shape_std,gain);
418 noise->setPdata(hid,noise_std,gain);
423 ua2mev->
setPdata(hid,ua2mev_std,gain);
426 dac2ua->
setPdata(hid,dac2ua_std,gain);
429 fsampl->
setPdata(hid,fsampl_std,gain);
432 minbias->
setPdata(hid,minbias_std,gain);
440 return StatusCode::SUCCESS;
446 std::string filename ;
449 if(m_g4Phys==
"QGSP_EMV"){
450 filename =
"fsampl_1302_qgsp-emv.txt";
453 if( m_g4Phys==
"QGSP_BERT"){
454 filename =
"fsampl_1303_qgsp-bert.txt";
458 return StatusCode::FAILURE;
464 ATH_CHECK( updateEMfSampl(filename, cabling ) );
466 return StatusCode::SUCCESS;
472 return updateEM_DACuAMeV(
"dac2ua_ua2mev_rel13.txt", cabling );
477 float fsampl_fcal1,fsampl_fcal2,fsampl_fcal3;
478 float fsampl_hec1,fsampl_hec2;
480 if(m_g4Phys==
"QGSP_EMV"){
482 fsampl_hec2=0.021775;
486 fsampl_fcal1=0.01366;
487 fsampl_fcal2=0.00854;
488 fsampl_fcal3=0.01107;
495 if( m_g4Phys==
"QGSP_BERT"){
500 fsampl_fcal1=0.01591;
501 fsampl_fcal2=0.01144;
502 fsampl_fcal3=0.01405;
511 return StatusCode::FAILURE;
516 ATH_CHECK( detStore()->retrieve(fsampl_c) );
526 for (;
it!=it_e;++
it){
529 if( (*it).isEmpty() )
continue;
530 if(!
cabling->isOnlineConnected(hid)){
539 if(m_hec_idhelper->is_lar_hec(
id)){
541 int sam = m_hec_idhelper->sampling(
id);
544 t2.m_fSampl = fsampl_hec1;
547 t2.m_fSampl = fsampl_hec2;
555 if(m_fcal_idhelper->is_lar_fcal(
id)){
557 int sam = m_fcal_idhelper->module(
id);
560 t2.m_fSampl = fsampl_fcal1;
563 t2.m_fSampl = fsampl_fcal2;
566 t2.m_fSampl = fsampl_fcal3;
580 return StatusCode::SUCCESS;
592 ATH_CHECK( detStore()->retrieve(fsampl_c) );
598 std::ifstream infile( filename);
602 return StatusCode::FAILURE;
604 int det,samp,reg,
eta;
607 while ( infile>>det>>samp>>reg>>
eta>>value )
618 if ( det==1 && samp==1 && reg==0 &&
eta==0 ){
624 id = m_em_idhelper->channel_id(det,samp,reg,
eta,0);
628 std::string id_str = m_online_idhelper->print_to_string(hid);
641 t2.m_fSampl = value ;
648 return StatusCode::SUCCESS;
656 ATH_CHECK( detStore()->retrieve(dac2ua_c) );
660 ATH_CHECK( detStore()->retrieve(ua2mev_c) );
663 std::ifstream
infile(filename) ;
668 return StatusCode::FAILURE;
678 float dac2ua0, ua2mev0,attenuation,dac2ua,ua2mev;
679 while ( infile>>det>>samp>>reg>>
eta>>
680 dac2ua0>>ua2mev0>>attenuation>>dac2ua>>ua2mev )
692 if ( det==1 && samp==1 && reg==0 &&
eta==0 ){
698 id = m_em_idhelper->channel_id(det,samp,reg,
eta,0);
703 std::string id_str = m_online_idhelper->print_to_string(hid);
704 std::string id_str_off = m_em_idhelper->print_to_string(
id);
742 return StatusCode::SUCCESS;
752 ATH_CHECK( updateMinBias(
"mbrms_em_rel12.txt", cabling) );
753 ATH_CHECK( updateMinBias(
"mbrms_hec_rel12.txt", cabling) );
759 ATH_CHECK( detStore()->retrieve(noise_c) );
763 ATH_CHECK( detStore()->retrieve(minbias_c) );
768 for(
unsigned int gain=0;
gain<3;++
gain)
774 for (;
it!=it_e;++
it)
777 if( (*it).isEmpty() )
continue;
780 if(!m_fcal_idhelper->is_lar_fcal(
id))
continue;
782 if(
cabling->isOnlineConnected(hid)){
786 << m_online_idhelper->print_to_string(hid) );
794 " Number of connected and disconnected = " <<nconn<<
" " <<ndisc );
801 std::string
filename(
"FCal_noise_minbias.txt");
803 std::ifstream
infile(filename ) ;
808 return StatusCode::FAILURE;
815 for(
int i = 0;
i<11;++
i){
822 float vol,noise_p,noise_h, noise_m,noise_l;
824 while ( infile>>str_id >>vol>>noise_p>>noise_h>>noise_m>>noise_l )
826 const char* ch_id = str_id.c_str();
827 if(ch_id[0] !=
'A') {
833 std::sscanf(ch_id,
"A%d.%d.%d", &mod,&
phi,&
eta);
846 ATH_MSG_INFO(
" minBiasRMS, old new "<<
t2.m_MinBiasRMS<<
" " <<noise_p);
847 t2.m_MinBiasRMS = noise_p;
868 return StatusCode::SUCCESS;
873 ATH_MSG_INFO (
" in updateMinBias(), filename = "<<filename );
879 ATH_CHECK( detStore()->retrieve(minbias_c) );
885 std::ifstream
infile( filename);
889 return StatusCode::FAILURE;
897 while ( infile>>lar>>tp>>det>>samp>>reg>>
eta>>
phi>>value )
908 if ( det==1 && samp==1 && reg==0 &&
eta==0 ){
916 id = m_em_idhelper->channel_id(det,samp,reg,
eta,0);
920 id = m_hec_idhelper->channel_id(det,samp,reg,
eta,0);
931 ATH_MSG_INFO(
" online id = "<<m_online_idhelper->print_to_string(hid));
951 return StatusCode::SUCCESS;
963 ATH_CHECK( detStore()->retrieve(noise_c) );
967 ATH_CHECK( detStore()->retrieve(ramp_c) );
971 ATH_CHECK( detStore()->retrieve(ua2MeV_c) );
975 ATH_CHECK( detStore()->retrieve(dac2uA_c) );
980 for(
unsigned int gain=0;
gain<3;++
gain)
986 for (;
it!=it_e;++
it)
989 if( (*it).isEmpty() )
continue;
992 if(!m_fcal_idhelper->is_lar_fcal(
id))
continue;
994 if(
cabling->isOnlineConnected(hid)){
1000 << m_online_idhelper->print_to_string(hid) );
1008 " Number of connected and disconnected = " <<nconn<<
" " <<ndisc );
1015 std::string
filename(
"FCal_noise_minbias_adc2mev.txt");
1016 std::ifstream
infile(filename) ;
1021 return StatusCode::FAILURE;
1028 for(
int i = 0;
i<27;++
i){
1035 float vol,noise_p,noise_h, noise_m,noise_l;
1036 float ramp_val,ua2MeV_val,dac2uA_val;
1038 while ( infile>>str_id >>vol>>noise_p >> noise_h>>noise_m>>noise_l
1039 >>channel_type>> ramp_val>>ua2MeV_val>>dac2uA_val )
1041 const char* ch_id = str_id.c_str();
1043 if(str_id.substr(0,1)!=std::string(
"A")){
1049 sscanf(ch_id,
"A%d.%d.%d", &mod,&
phi,&
eta);
1090 ua2MeV0.
m_data=ua2MeV_val;
1093 dac2ua0.
m_data = dac2uA_val;
1098 return StatusCode::SUCCESS;
1108 if( m_g4Phys==
"QGSP_BERT"){
1109 filename =
"fsampl_1303_qgsp-bert.txt";
1113 return StatusCode::FAILURE;
1116 ATH_CHECK( updateEMfSampl(filename, cabling ) );
1117 return StatusCode::SUCCESS;
1128 ATH_CHECK( update_EM_HEC<LArNoiseMC>(
"noise_em.txt",
"noise_hec.txt", cabling,
true, 1 ) );
1129 ATH_CHECK( update_EM_HEC<LArAutoCorrMC>(
"",
"autocorr_hec.txt", cabling,
true, 4 ) );
1131 ATH_CHECK( update_EM_HEC<LArAutoCorrMC>(
"autocorr_em.txt",
"", cabling,
true,5) );
1132 ATH_CHECK( update_EM_HEC<LArRampMC>(
"ramp_em.txt",
"ramp_hec.txt", cabling,
true, 1 ) );
1133 ATH_CHECK( update_EM_HEC<LAruA2MeVMC>(
"ua2mev_em.txt",
"ua2mev_hec.txt", cabling,
false, 1 ) );
1134 ATH_CHECK( update_EM_HEC<LArDAC2uAMC>(
"dac2ua_em.txt",
"dac2ua_hec.txt", cabling,
false, 1 ) );
1135 ATH_CHECK( update_EM_HEC<LArShape32MC>(
"shape_em.txt",
"shape_hec.txt", cabling,
true, 64 ) );
1136 ATH_CHECK( update_EM_HEC<LArMphysOverMcalMC>(
"mphys_em.txt",
"", cabling,
true, 1 ) );
1140 return StatusCode::SUCCESS;
1146 std::ifstream infile(filename) ;
1148 if(! infile.good() )
1151 return StatusCode::FAILURE;
1161 infile.getline(s,200);
1167 while ( infile>>first )
1171 infile>>samp>>reg>>
eta;
1179 if(withGain) infile>>gain ;
1180 std::vector<float> vfl;
1183 for (
int i=0;i<nvar;++i)
1197 if ( det==1 && samp==1 && reg==0 &&
eta==0 ){
1209 if (gain >= 0 && gain < 3)
1213 return StatusCode::SUCCESS;
1218 std::ifstream infile(filename) ;
1220 if(! infile.good() )
1223 return StatusCode::FAILURE;
1233 infile.getline(s,200);
1236 int det=0,samp=0,reg=0,
eta=0;
1238 while ( infile>>first>>samp>>reg>>
eta ) {
1244 if ( det==1 && samp==1 && reg==0 &&
eta==0 ){
1251 }
else if (first == 3) {
1253 }
else if (first == 4) {
1257 if(withGain) infile>>gain ;
1258 for (
int i=0;i<nvar;++i) infile>>
x;
1261 if(withGain) infile>>gain ;
1262 std::vector<float> vfl;
1264 for (
int i=0;i<nvar;++i)
1270 <<first<<
" " <<det<<
" " <<samp<<
" " <<reg<<
" " <<
eta<<
" " );
1274 if (gain >= 0 && gain < 3)
m_cache[gain].push_back(
ROW_t(hid,vfl));
1280 return StatusCode::SUCCESS;
1296 ATH_MSG_ERROR (
"for LArNoiseMC, size of vector = "<< v.size() <<
" differs from one");
1309 msg()<<MSG::DEBUG<<
" LArAutoCorrMC" << s ;
1310 for (
unsigned int i =0 ; i<obj.m_vAutoCorr.size();++i)
1311 msg()<<
" " << obj.m_vAutoCorr[i];
1321 ATH_MSG_ERROR(
"for LArAutoCorrMC, size of vector = "<< v.size()<<
" is less then 4" );
1325 obj.m_vAutoCorr.resize(4);
1326 std::copy_n(v.begin(), 4, obj.m_vAutoCorr.begin());
1336 msg()<<MSG::DEBUG<<
" LArRampMC" << s ;
1337 for (
unsigned int i =0 ; i<obj.m_vRamp.size();++i)
1338 msg()<<
" " << obj.m_vRamp[i];
1348 ATH_MSG_ERROR (
"for LArRampMC, size of vector = "<< v.size());
1351 obj.m_vRamp.resize(3);
1353 obj.m_vRamp[1]=v[0];
1365 msg()<<MSG::DEBUG<<
" LArShape" << s ;
1366 for (
unsigned int i =0 ; i<obj.m_vShape.size();++i)
1367 msg()<<
" " << obj.m_vShape[i];
1370 msg()<<MSG::DEBUG<<
" LArShapeDer" << s ;
1371 for (
unsigned int i =0 ; i<obj.m_vShapeDer.size();++i)
1372 msg()<<
" " << obj.m_vShapeDer[i];
1381 if (v.size()!=64 && v.size()!=32 )
1383 ATH_MSG_ERROR (
"for LArShape32MC, size of vector = "<< v.size());
1387 unsigned int size = 32;
1388 obj.m_vShape.resize(
size);
1389 obj.m_vShapeDer.resize(
size);
1391 for(
unsigned int i=0;i<
size;++i){
1392 obj.m_vShape[i]=v[i];
1393 if(v.size() == 64 ) obj.m_vShapeDer[i]=v[i+
size];
else obj.m_vShapeDer[i]=0.;
1416 ATH_MSG_ERROR(
"for LArSingleFloatP, size of vector = "<< v.size() );
1433 std::unique_ptr<LArMphysOverMcalMC> mphys = std::make_unique<LArMphysOverMcalMC>();
1439 std::string filename(
"FCal_noise_minbias_adc2mev.txt");
1441 std::ifstream infile(filename ) ;
1443 if(! infile.good() )
1446 return StatusCode::FAILURE;
1453 for(
int i = 0;i<27;++i){
1454 infile.getline(s,200);
1460 float vol,noise_p,noise_h, noise_m,noise_l;
1461 float ramp_val,ua2MeV_val,dac2uA_val;
1462 std::string channel_type;
1463 while ( infile>>str_id >>vol>>noise_p >> noise_h>>noise_m>>noise_l
1464 >>channel_type>> ramp_val>>ua2MeV_val>>dac2uA_val )
1466 const char* ch_id = str_id.c_str();
1468 if(str_id.substr(0,1)!=std::string(
"A")){
1474 sscanf(ch_id,
"A%d.%d.%d", &mod,&
phi,&
eta);
1488 mphys->setPdata(hid,t,0);
1489 mphys->setPdata(hid,t,1);
1490 mphys->setPdata(hid,t,2);
1493 ATH_MSG_INFO(
" MphysOverMcal added "<<n<<
" FCAL channels");
1496 bool withGain=
false;
1498 std::string hec_filename(
"mphys_hec.txt");
1508 mphys->setPdata(hid,t,0);
1509 mphys->setPdata(hid,t,1);
1510 mphys->setPdata(hid,t,2);
1517 ATH_MSG_ERROR(
" Number of HEC channel added "<<n <<
" per gain ");
1518 return StatusCode::SUCCESS ;
1527 ATH_CHECK( detStore()->retrieve(dac2ua_c) );
1531 ATH_CHECK( detStore()->retrieve(ua2mev_c) );
1539 for(;it!=it_e;++it){
1568 for( ;
it!=it_e;++
it){
1572 if(
u.m_data> -990.)
1591 return StatusCode::SUCCESS;
1599 std::vector<float> fcal_autoCorr[3][3] ;
1600 fcal_autoCorr[0][0] = {-0.01, -0.30, -0.09, 0.08};
1601 fcal_autoCorr[0][1] = { 0.01, -0.07, -0.01, 0.03};
1602 fcal_autoCorr[0][2] = { 0.2, 0.2, 0.2, 0.2};
1603 fcal_autoCorr[1][0] = { -0.02, -0.31, -0.06, 0.06};
1604 fcal_autoCorr[1][1] = { 0.0, -0.08, -0.01, 0.02};
1605 fcal_autoCorr[1][2] = { 0.02, 0.01, 0.02, 0.02};
1606 fcal_autoCorr[2][0] = { -0.03, -0.31, -0.05, 0.07};
1607 fcal_autoCorr[2][1] = { 0.01, -0.07, -0.01, 0.02};
1608 fcal_autoCorr[2][2] = { 0.02, 0.02, 0.02, 0.02};
1614 ATH_CHECK( detStore()->retrieve(ac_c) );
1618 for(
unsigned int gain=0;
gain<3;++
gain)
1625 for (;
it!=it_e;++
it)
1629 if( (*it).isEmpty() )
continue;
1632 if(! m_fcal_idhelper->is_lar_fcal(
id)) continue ;
1633 int module = m_fcal_idhelper->module(
id) - 1;
1636 <<
u.m_vAutoCorr[0]<<
" "
1637 <<
u.m_vAutoCorr[1]<<
" "
1638 <<
u.m_vAutoCorr[2]<<
" "
1639 <<
u.m_vAutoCorr[3]<<
" " );
1654 " Number of entries modified = " <<n );
1657 return StatusCode::SUCCESS;
1667 ATH_CHECK( detStore()->retrieve(ramp_c) );
1675 for (;
it!=it_e;++
it)
1678 if( (*it).isEmpty() )
continue;
1681 if(!m_fcal_idhelper->is_lar_fcal(
id))
continue;
1683 if( !
cabling->isOnlineConnected(hid)){
1685 << m_online_idhelper->print_to_string(hid) );
1698 float ramp_high = ramp0.
m_vRamp[1];
1700 ramp1.
m_vRamp.assign ({0, ramp_high*9.96f});
1701 ramp2.
m_vRamp.assign ({0, ramp_high*9.96f*9.67f});
1712 return StatusCode::SUCCESS;
1721 ATH_CHECK( update_EM_HEC<LArRampMC>(
"",
"ramp_hec_june2008.txt", cabling,
true, 1 ) );
1722 return StatusCode::SUCCESS;
1731 ToolHandle<ICaloSuperCellIDTool> scidtool(
"CaloSuperCellIDTool");
1732 if ( scidtool.retrieve().isFailure() ) {
1736 std::set<Identifier> scidset;
1737 std::map<HWIdentifier,int> sslot_schannel_idx;
1738 std::vector<unsigned int> OrderOnlHash_OffID;
1739 std::vector<unsigned int> OrderOffHash_OnlID;
1740 OrderOnlHash_OffID.resize(40000,0);
1741 OrderOffHash_OnlID.resize(40000,0);
1743 Identifier::size_type channel_size =
m_em_idhelper->channel_hash_max();
1744 unsigned int min_onl_hash = 999999;
1745 unsigned int max_onl_hash = 0;
1746 unsigned int min_off_hash = 999999;
1747 unsigned int max_off_hash = 0;
1748 std::ofstream hashes(
"AllHashChannels_All.txt");
1749 std::ofstream of(
"AllChannels_EM.txt");
1751 for(
size_t i = 0; i < channel_size ; i++) {
1754 if ( ! isEM )
continue;
1755 Identifier SCID = scidtool->offlineToSuperCellID(chid);
1756 if ( scidset.find(SCID) == scidset.end() && (
m_scell_idhelper->calo_cell_hash( SCID ).value() < 99999) )
1757 scidset.insert(SCID);
1759 HWIdentifier hwid = cabling->createSignalChannelID(chid);
1761 of <<
"Off ID\t\tSCID\t\tOnl ID\t\tFT\tslot\tB-E pos_neg\tSamp\teta\tphi\tFEB_ID\t\tSHWID\t" <<
'\n';
1782 sprintf(etaChar,
"%5.4f",
eta);
1783 sprintf(phiChar,
"%5.4f",
phi);
1784 of << std::dec <<
"\t" << feedthrough <<
"\t" << slot;
1785 of <<
"\t" << bar_ec <<
" " << pos_neg <<
"\t\t" << samp <<
"\t";
1786 of << etaChar <<
" " << phiChar <<
"\t0x";
1791 bool secondOutSlot=
false;
1793 if ( (samp==1) && (reg==5) ) secondOutSlot=
true;
1794 if ( (samp==2) && (reg==1) && (
m_em_idhelper->eta( chid )>=39 ) )
1796 if ( (samp==3) && (reg==0) && (
m_em_idhelper->eta( chid )>=18 ) )
1804 if ( secondOutSlot ) {
1807 if ( sslot_schannel_idx.find(sfeb_id) == sslot_schannel_idx.end() )
1808 sslot_schannel_idx[sfeb_id]=0;
1809 else sslot_schannel_idx[sfeb_id]++;
1812 if ( onl_hash > max_onl_hash ) max_onl_hash = onl_hash;
1813 if ( onl_hash < min_onl_hash ) min_onl_hash = onl_hash;
1815 if ( off_hash > max_off_hash ) max_off_hash = off_hash;
1816 if ( off_hash < min_off_hash ) min_off_hash = off_hash;
1822 of <<
" " << onl_hash <<
" " << off_hash;
1830 of <<
"Hash check. Onl : " << min_onl_hash <<
" " << max_onl_hash;
1831 of <<
"; Off : " << min_off_hash <<
" " << max_off_hash <<
'\n';;
1835 min_onl_hash = 999999;
1837 min_off_hash = 999999;
1839 std::ofstream of1(
"AllChannels_HEC.txt");
1841 of1 <<
"Off ID\t\tSCID\t\tOnl ID\t\tFT\tslot\tB-E pos_neg\tSamp\teta\tphi\tFEB_ID\t\tSHWID\t" <<
'\n';
1842 for(
size_t i = 0; i < channel_size ; i++) {
1845 Identifier SCID = scidtool->offlineToSuperCellID(chid);
1846 if ( scidset.find(SCID) == scidset.end() )
1847 scidset.insert(SCID);
1849 HWIdentifier hwid = cabling->createSignalChannelID(chid);
1868 sprintf(etaChar,
"%5.4f",
eta);
1869 sprintf(phiChar,
"%5.4f",
phi);
1870 of1 << std::dec <<
"\t" << feedthrough <<
"\t" << slot;
1871 of1 <<
"\t" << bar_ec <<
" " << pos_neg <<
"\t\t" << samp <<
"\t";
1872 of1 << etaChar <<
" " << phiChar <<
"\t0x";
1877 if ( sslot_schannel_idx.find(sfeb_id) == sslot_schannel_idx.end() )
1878 sslot_schannel_idx[sfeb_id]=0;
1879 else sslot_schannel_idx[sfeb_id]++;
1880 if ( (feedthrough==6) && (bar_ec==1) && (slot>9) ) {
1886 if ( onl_hash > max_onl_hash ) max_onl_hash = onl_hash;
1887 if ( onl_hash < min_onl_hash ) min_onl_hash = onl_hash;
1889 if ( off_hash > max_off_hash ) max_off_hash = off_hash;
1890 if ( off_hash < min_off_hash ) min_off_hash = off_hash;
1896 of1 <<
" " << onl_hash <<
" " << off_hash;
1904 min_onl_hash = 999999;
1906 min_off_hash = 999999;
1908 std::ofstream of3(
"AllChannels_FCAL.txt");
1910 of3 <<
"Off ID\t\tSCID\t\tOnl ID\t\tFT\tslot\tB-E pos_neg\tSamp\teta\tphi\tFEB_ID\t\tSHWID\t" <<
'\n';
1911 for(
size_t i = 0; i < channel_size ; i++) {
1914 Identifier SCID = scidtool->offlineToSuperCellID(chid);
1915 if ( scidset.find(SCID) == scidset.end() )
1916 scidset.insert(SCID);
1918 HWIdentifier hwid = cabling->createSignalChannelID(chid);
1927 of3 << std::dec <<
"\t" << feedthrough <<
"\t" << slot;
1928 of3 <<
"\t" << bar_ec <<
" " << pos_neg <<
"\t\t" << samp <<
"\t";
1932 if ( (feedthrough==6) && (bar_ec==1) && (slot>9) ) {
1935 if ( sslot_schannel_idx.find(sfeb_id) == sslot_schannel_idx.end() )
1936 sslot_schannel_idx[sfeb_id]=0;
1937 else sslot_schannel_idx[sfeb_id]++;
1940 if ( onl_hash > max_onl_hash ) max_onl_hash = onl_hash;
1941 if ( onl_hash < min_onl_hash ) min_onl_hash = onl_hash;
1943 if ( off_hash > max_off_hash ) max_off_hash = off_hash;
1944 if ( off_hash < min_off_hash ) min_off_hash = off_hash;
1950 of3 <<
" " << onl_hash <<
" " << off_hash;
1957 of3 <<
"Hash check. Onl : " << min_onl_hash <<
" " << max_onl_hash;
1958 of3 <<
"; Off : " << min_off_hash <<
" " << max_off_hash <<
'\n';;
1964 coral::AttributeListSpecification *spec_onOff =
new coral::AttributeListSpecification();
1965 spec_onOff->extend(
"OnlineHashToOfflineId",
"blob");
1966 spec_onOff->extend<
unsigned>(
"version");
1967 std::unique_ptr<AthenaAttributeList> al_onOff = std::make_unique<AthenaAttributeList>(*spec_onOff);
1968 coral::Blob& blobOnOff=(*al_onOff)[
"OnlineHashToOfflineId"].data<coral::Blob>();
1969 (*al_onOff)[
"version"].setValue(0U);
1970 blobOnOff.resize(onlHashMax*
sizeof(uint32_t));
1971 uint32_t* pBlobOnOff=
static_cast<uint32_t*
>(blobOnOff.startingAddress());
1974 const uint32_t emptyId=
Identifier().get_identifier32().get_compact();
1975 for(
size_t ii=0;ii<onlHashMax;ii++) {
1976 if (OrderOnlHash_OffID[ii] != 0) {
1977 pBlobOnOff[ii]=OrderOnlHash_OffID[ii];
1981 pBlobOnOff[ii]=emptyId;
1984 ATH_MSG_INFO (
"HashMax=" << onlHashMax <<
", connected=" << nConn );
1986 ATH_CHECK(
detStore()->record(std::move(al_onOff),
"/LAR/IdentifierOfl/OnOffIdMap_SC") );
1988 hashes <<
"idx \t Off2OnlId \t Onl2OffId" <<
'\n';
1989 for(
size_t ii=0;ii<40000;ii++)
1990 if ( (OrderOffHash_OnlID[ii] != 0) || ( OrderOnlHash_OffID[ii] != 0 ) )
1991 hashes << std::dec << ii << std::hex <<
" \t " << OrderOffHash_OnlID[ii] <<
" \t\t " << OrderOnlHash_OffID[ii] <<
'\n';
1994 return StatusCode::SUCCESS;
2004 std::unique_ptr<LArMinBiasMC> minbias = std::make_unique<LArMinBiasMC>();
2005 ATH_CHECK( minbias->setGroupingType(
"Single",
msg()) );
2007 std::unique_ptr<LArMinBiasAverageMC> minbias_av = std::make_unique<LArMinBiasAverageMC>();
2008 ATH_CHECK( minbias_av->setGroupingType(
"Single",
msg()) );
2011 std::unique_ptr<TFile> fin= std::make_unique<TFile>(
"ntuple_av.root");
2012 TTree *tin=
dynamic_cast<TTree*
>(fin->Get(
"m_tree"));
2015 return StatusCode::FAILURE;
2017 const int nindex=1833;
2019 std::vector<int> identifier(2862);
2020 std::vector<int> layer(2862);
2021 std::vector<int> region(2862);
2022 std::vector<int> ieta(2862);
2023 std::vector<float>
eta(2862);
2024 std::vector<double> average(2862);
2025 std::vector<double> rms(2862);
2027 TBranch *b_identifier;
2034 tin->SetMakeClass(1);
2035 tin->SetBranchAddress(
"ncell", &ncell, &b_ncell);
2036 tin->SetBranchAddress(
"identifier", identifier.data(), &b_identifier);
2037 tin->SetBranchAddress(
"layer", layer.data(), &b_layer);
2038 tin->SetBranchAddress(
"region", region.data(), &b_region);
2039 tin->SetBranchAddress(
"ieta", ieta.data(), &b_ieta);
2040 tin->SetBranchAddress(
"eta",
eta.data(), &b_eta);
2041 tin->SetBranchAddress(
"average", average.data(), &b_average);
2042 tin->SetBranchAddress(
"rms", rms.data(), &b_rms);
2045 if(ncell>nindex) ncell=nindex;
2046 for(
int icell=0; icell<ncell; ++icell) {
2052 minbias->set(hid, rms[icell]);
2053 minbias_av->set(hid, average[icell]);
2057 ATH_MSG_INFO(
" number of channels in intuple ="<<ncell);
2059 ATH_MSG_INFO (
"Stored container " << minbias->totalNumberOfConditions() <<
" conditions, key LArMinBias " );
2061 ATH_MSG_INFO (
"Stored container " << minbias_av->totalNumberOfConditions() <<
" conditions, key LArMinBiasAverage " );
2064 return StatusCode::SUCCESS;
2077 std::unique_ptr<LArMinBiasAverageMC> minbias_av = std::make_unique<LArMinBiasAverageMC>();
2078 ATH_CHECK( minbias_av->setGroupingType(
"Single",
msg()) );
2081 std::unique_ptr<TFile> fin= std::make_unique<TFile>(
m_infile.value().c_str());
2082 TTree *tin=
dynamic_cast<TTree*
>(fin->Get(
"m_tree"));
2085 return StatusCode::FAILURE;
2088 std::vector<int> identifier(2862);
2089 std::vector<int> layer(2862);
2090 std::vector<int> region(2862);
2091 std::vector<int> ieta(2862);
2092 std::vector<float>
eta(2862);
2093 std::vector<double> average(2862);
2094 std::vector<double> rms(2862);
2096 TBranch *b_identifier;
2103 tin->SetMakeClass(1);
2104 tin->SetBranchAddress(
"ncell", &ncell, &b_ncell);
2105 tin->SetBranchAddress(
"identifier", identifier.data(), &b_identifier);
2106 tin->SetBranchAddress(
"layer", layer.data(), &b_layer);
2107 tin->SetBranchAddress(
"region", region.data(), &b_region);
2108 tin->SetBranchAddress(
"ieta", ieta.data(), &b_ieta);
2109 tin->SetBranchAddress(
"eta",
eta.data(), &b_eta);
2110 tin->SetBranchAddress(
"average", average.data(), &b_average);
2111 tin->SetBranchAddress(
"rms", rms.data(), &b_rms);
2115 for(
int icell=0; icell<ncell; ++icell) {
2120 float fsampl = larfSampl->
FSAMPL(hid);
2121 minbias_av->set(hid, 6.31*average[icell]/fsampl);
2125 ATH_MSG_INFO(
" number of channels in intuple ="<<ncell);
2127 ATH_MSG_INFO (
"Stored container " << minbias_av->totalNumberOfConditions() <<
" conditions, key LArPileupAverage " );
2130 return StatusCode::SUCCESS;
2141 ATH_CHECK( detStore()->retrieve(minbias_c,
"LArPileupAverage") );
2151 for(;it!=it_e;++it){
2155 ATH_MSG_INFO(
" Old pileup = "<< u.m_MinBiasAverage<<
" " );
2163 ATH_MSG_INFO(
" New Pileup = "<< t3.m_MinBiasAverage<<
" " );
2168 return StatusCode::SUCCESS;
2175 std::string onOffIdKey=
"/LAR/Identifier/OnOffIdMap";
2177 StatusCode sc=detStore()->retrieve(attrOnOff,onOffIdKey);
2178 if (
sc.isFailure()) {
2179 ATH_MSG_ERROR(
"Failed to read AthenaAttributeList with key " << onOffIdKey);
2180 return StatusCode::FAILURE;
2182 const coral::Blob& blobOnOff=(*attrOnOff)[
"OnlineHashToOfflineId"].data<coral::Blob>();
2183 unsigned nChan=blobOnOff.size()/
sizeof(
uint32_t);
2187 if (nChan!=m_online_idhelper->channelHashMax()) {
2188 ATH_MSG_WARNING(
"Number of channels read from DB (" << nChan <<
") does not match online hash max ("
2189 <<m_online_idhelper->channelHashMax() <<
")");
2190 nChan=std::min(nChan,
static_cast<unsigned int>(m_online_idhelper->channelHashMax()));
2192 std::vector<std::pair<unsigned int, unsigned int> > swapindex(8, std::make_pair(nChan+10,nChan+10));
2194 for (
unsigned i=0;
i<nChan;++
i) {
2196 if(m_online_idhelper->isEMECchannel(hwid) && m_online_idhelper->pos_neg(hwid) == 1 && m_online_idhelper->feedthrough(hwid) == 7 && m_online_idhelper->slot(hwid) == 11) {
2197 if(m_online_idhelper->channel(hwid)>=96 && m_online_idhelper->channel(hwid)<=103) swapindex[m_online_idhelper->channel(hwid)-96].first=
i;
2198 if(m_online_idhelper->channel(hwid)>=112 && m_online_idhelper->channel(hwid)<=129) swapindex[m_online_idhelper->channel(hwid)-112].second=
i;
2201 for(
unsigned i=0;
i<8; ++
i) {
2204 for(
unsigned i=0;
i<8; ++
i) {
2206 if (swapindex[i].first > nChan || swapindex[i].second > nChan ) {
2207 ATH_MSG_ERROR(
"Problem in swapindex: "<< i <<
" : " << swapindex[i].first <<
" " << swapindex[i].second);
2208 return StatusCode::FAILURE;
2210 uint32_t id = pBlobOnOff[swapindex[
i].first];
2211 pBlobOnOff[swapindex[
i].first] = pBlobOnOff[swapindex[
i].second];
2212 pBlobOnOff[swapindex[
i].second] =
id;
2217 return StatusCode::SUCCESS;
2225 ATH_CHECK( update_All<LArShape32MC>(m_infile.value(), cabling,
true, 32 ) );
2227 return StatusCode::SUCCESS;
2236 coral::AttributeListSpecification* spec_calib =
new coral::AttributeListSpecification();
2237 spec_calib->extend(
"OnlineHashToCalibIds",
"blob");
2238 spec_calib->extend<
unsigned>(
"version");
2239 std::unique_ptr<AthenaAttributeList> al_calib = std::make_unique<AthenaAttributeList>(*spec_calib);
2240 coral::Blob& blobCalib=(*al_calib)[
"OnlineHashToCalibIds"].data<coral::Blob>();
2241 (*al_calib)[
"version"].setValue(0U);
2242 blobCalib.resize(onlHashMax*
sizeof(uint32_t)*4);
2244 spec_calib->release();
2246 spec_calib =
nullptr;
2248 uint32_t* pBlobCalib=
static_cast<uint32_t*
>(blobCalib.startingAddress());
2249 size_t calibIndex=0;
2253 for (
unsigned i=0;i<onlHashMax;++i) {
2256 const std::vector<HWIdentifier>& calibIDs=cabling->calibSlotLine(hwid);
2257 const size_t nCalibLines=calibIDs.size();
2260 if(nCalibLines > 1) {
2262 return StatusCode::FAILURE;
2264 if(nCalibLines==0) {
2265 pBlobCalib[calibIndex++]=0;
2272 return StatusCode::FAILURE;
2275 pBlobCalib[calibIndex++]=1;
2279 pBlobCalib[calibIndex++]=nCalibLines;
2280 for(uint32_t iCalib=0;iCalib<nCalibLines;++iCalib)
2281 pBlobCalib[calibIndex++]=calibIDs[iCalib].get_identifier32().get_compact();
2284 blobCalib.resize(calibIndex*
sizeof(uint32_t));
2288 ATH_CHECK(
detStore()->record(std::move(al_calib),
"/LAR/Identifier/CalibIdMap_EMF"));
2290 return StatusCode::SUCCESS;
Scalar eta() const
pseudorapidity method
Scalar phi() const
phi method
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_DEBUG(x,...)
#define ATH_MSG_ERROR(x,...)
#define ATH_MSG_WARNING(x,...)
#define ATH_MSG_INFO(x,...)
Helper class for offline supercell identifiers.
StatusCode FixLArElecCalib::stop ATLAS_NOT_THREAD_SAFE()
Install fatal handler with default options.
size_t size() const
Number of registered mappings.
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor.
const ServiceHandle< StoreGateSvc > & detStore() const
An AttributeList represents a logical row of attributes in a metadata table.
std::string print_to_string(Identifier id, const IdContext *context=0) const
or provide the printout in string form
StatusCode fix13(const LArOnOffIdMapping *cabling)
SG::ReadCondHandleKey< LArOnOffIdMapping > m_cablingKey
StatusCode fix12(const LArOnOffIdMapping *cabling)
void set_object(LArNoiseMC::LArCondObj &obj, const std::vector< float > &v)
StatusCode ReadFile(const std::string &filename, const LArOnOffIdMapping *cabling, bool EM, bool withGain, int nvar)
const LArOnline_SuperCellID * m_sonline_idhelper
virtual StatusCode initialize() override
StatusCode fix2(const LArOnOffIdMapping *cabling)
const LArEM_SuperCell_ID * m_sem_idhelper
StatusCode fix1(const LArOnOffIdMapping *cabling)
StatusCode fix18(const LArCalibLineMapping *clmap)
SG::ReadCondHandleKey< LArCalibLineMapping > m_CLKey
const LArHEC_ID * m_hec_idhelper
IntegerProperty m_fixFlag
const LArOnlineID * m_online_idhelper
void print_object(std::string_view msg, const LArNoiseMC::LArCondObj &obj)
const LArFCAL_ID * m_fcal_idhelper
const CaloCell_SuperCell_ID * m_scell_idhelper
const LArEM_ID * m_em_idhelper
std::pair< HWIdentifier, std::vector< float > > ROW_t
virtual StatusCode execute(const EventContext &ctx) override
Execute method.
StatusCode fix14(const LArOnOffIdMapping *cabling)
StatusCode addMphysOverMcal(const LArOnOffIdMapping *cabling)
const LArHEC_SuperCell_ID * m_shec_idhelper
StatusCode ReadFileAll(const std::string &filename, const LArOnOffIdMapping *cabling, bool withGain, int nvar)
FixLArElecCalib(const std::string &name, ISvcLocator *pSvcLocator)
virtual const float & FSAMPL(const HWIdentifier &id) const =0
value_type get_compact() const
Get the compact id.
This is a "hash" representation of an Identifier.
Identifier32 get_identifier32() const
Get the 32-bit version Identifier, will be invalid if >32 bits needed.
Implementation of the interface ILArAutoCorr for MC Derives from LArAutoCorrComplete,...
std::vector< float > m_vAutoCorr
void setPdata(const HWIdentifier id, const T &payload, unsigned int gain=0)
put payload in persistent data
ConstReference get(const HWIdentifier id, unsigned int gain=0) const
get data with online identifier
ConstConditionsMapIterator begin(unsigned int gain) const
get iterator for all channels for a gain
ConstConditionsMapIterator end(unsigned int gain) const
end of all channels for this gain
LArSingleFloatP LArCondObj
ConditionsMap::iterator ConditionsMapIterator
Implementation of the interface ILArDAC2uA for MC Derives from LArDAC2uAComplete, and implements the ...
Identifier channel_id(const ExpandedIdentifier &exp_id) const
Build a cell identifier from an expanded identifier.
Helper class for LArEM offline identifiers.
id_iterator fcal_end() const
end iterator over full set of Fcal Identifiers for channels
id_iterator fcal_begin() const
begin iterator over full set of Fcal Identifiers for channels
int phi(const Identifier id) const
phi [0,15]
int pos_neg(const Identifier id) const
pos_neg : +/- 2 (A/C side)
Helper class for LArFCAL offline identifiers.
Implementation of the interface ILArMinBiasAverage for MC Derives from LArMinBiasAverageComplete,...
Implementation of the interface ILArMinBias for MC Derives from LArMinBiasComplete,...
Implementation of the interface ILArNoise for MC Derives from LArNoiseComplete, and implements the ph...
HWIdentifier channel_Id(int barrel_ec, int pos_neg, int feedthrough, int slot, int channel) const
create channel identifier from fields
Implementation of the interface ILArRamp for MC Derives from LArRampComplete, and implements the phi-...
std::vector< float > m_vRamp
This class implements the ILArShape interface.
Implementation of the interface ILArfSampl for MC Derives from LArfSamplComplete, and implements the ...
Implementation of the interface ILAruA2MeV for MC Derives from LAruA2MeVComplete, and implements the ...
std::vector< ALFA_RawDataContainer_p1 > t2
std::vector< ALFA_RawDataCollection_p1 > t1
::StatusCode StatusCode
StatusCode definition for legacy code.
std::vector< LUCID_RawData_p1 > t3
@ u
Enums for curvilinear frames.