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);
1519 ATH_MSG_ERROR(
" Number of HEC channel added "<<n <<
" per gain ");
1520 return StatusCode::SUCCESS ;
1529 ATH_CHECK( detStore()->retrieve(dac2ua_c) );
1533 ATH_CHECK( detStore()->retrieve(ua2mev_c) );
1541 for(;it!=it_e;++it){
1570 for( ;
it!=it_e;++
it){
1574 if(
u.m_data> -990.)
1593 return StatusCode::SUCCESS;
1601 std::vector<float> fcal_autoCorr[3][3] ;
1602 fcal_autoCorr[0][0] = {-0.01, -0.30, -0.09, 0.08};
1603 fcal_autoCorr[0][1] = { 0.01, -0.07, -0.01, 0.03};
1604 fcal_autoCorr[0][2] = { 0.2, 0.2, 0.2, 0.2};
1605 fcal_autoCorr[1][0] = { -0.02, -0.31, -0.06, 0.06};
1606 fcal_autoCorr[1][1] = { 0.0, -0.08, -0.01, 0.02};
1607 fcal_autoCorr[1][2] = { 0.02, 0.01, 0.02, 0.02};
1608 fcal_autoCorr[2][0] = { -0.03, -0.31, -0.05, 0.07};
1609 fcal_autoCorr[2][1] = { 0.01, -0.07, -0.01, 0.02};
1610 fcal_autoCorr[2][2] = { 0.02, 0.02, 0.02, 0.02};
1616 ATH_CHECK( detStore()->retrieve(ac_c) );
1620 for(
unsigned int gain=0;
gain<3;++
gain)
1627 for (;
it!=it_e;++
it)
1631 if( (*it).isEmpty() )
continue;
1634 if(! m_fcal_idhelper->is_lar_fcal(
id)) continue ;
1635 int module = m_fcal_idhelper->module(
id) - 1;
1638 <<
u.m_vAutoCorr[0]<<
" "
1639 <<
u.m_vAutoCorr[1]<<
" "
1640 <<
u.m_vAutoCorr[2]<<
" "
1641 <<
u.m_vAutoCorr[3]<<
" " );
1656 " Number of entries modified = " <<n );
1659 return StatusCode::SUCCESS;
1669 ATH_CHECK( detStore()->retrieve(ramp_c) );
1677 for (;
it!=it_e;++
it)
1680 if( (*it).isEmpty() )
continue;
1683 if(!m_fcal_idhelper->is_lar_fcal(
id))
continue;
1685 if( !
cabling->isOnlineConnected(hid)){
1687 << m_online_idhelper->print_to_string(hid) );
1700 float ramp_high = ramp0.
m_vRamp[1];
1702 ramp1.
m_vRamp.assign ({0, ramp_high*9.96f});
1703 ramp2.
m_vRamp.assign ({0, ramp_high*9.96f*9.67f});
1714 return StatusCode::SUCCESS;
1723 ATH_CHECK( update_EM_HEC<LArRampMC>(
"",
"ramp_hec_june2008.txt", cabling,
true, 1 ) );
1724 return StatusCode::SUCCESS;
1733 ToolHandle<ICaloSuperCellIDTool> scidtool(
"CaloSuperCellIDTool");
1734 if ( scidtool.retrieve().isFailure() ) {
1738 std::set<Identifier> scidset;
1739 std::map<HWIdentifier,int> sslot_schannel_idx;
1740 std::vector<unsigned int> OrderOnlHash_OffID;
1741 std::vector<unsigned int> OrderOffHash_OnlID;
1742 OrderOnlHash_OffID.resize(40000,0);
1743 OrderOffHash_OnlID.resize(40000,0);
1745 Identifier::size_type channel_size =
m_em_idhelper->channel_hash_max();
1746 unsigned int min_onl_hash = 999999;
1747 unsigned int max_onl_hash = 0;
1748 unsigned int min_off_hash = 999999;
1749 unsigned int max_off_hash = 0;
1750 std::ofstream hashes(
"AllHashChannels_All.txt");
1751 std::ofstream of(
"AllChannels_EM.txt");
1753 for(
size_t i = 0; i < channel_size ; i++) {
1756 if ( ! isEM )
continue;
1757 Identifier SCID = scidtool->offlineToSuperCellID(chid);
1758 if ( scidset.find(SCID) == scidset.end() && (
m_scell_idhelper->calo_cell_hash( SCID ).value() < 99999) )
1759 scidset.insert(SCID);
1761 HWIdentifier hwid = cabling->createSignalChannelID(chid);
1763 of <<
"Off ID\t\tSCID\t\tOnl ID\t\tFT\tslot\tB-E pos_neg\tSamp\teta\tphi\tFEB_ID\t\tSHWID\t" <<
'\n';
1784 sprintf(etaChar,
"%5.4f",
eta);
1785 sprintf(phiChar,
"%5.4f",
phi);
1786 of << std::dec <<
"\t" << feedthrough <<
"\t" << slot;
1787 of <<
"\t" << bar_ec <<
" " << pos_neg <<
"\t\t" << samp <<
"\t";
1788 of << etaChar <<
" " << phiChar <<
"\t0x";
1793 bool secondOutSlot=
false;
1795 if ( (samp==1) && (reg==5) ) secondOutSlot=
true;
1796 if ( (samp==2) && (reg==1) && (
m_em_idhelper->eta( chid )>=39 ) )
1798 if ( (samp==3) && (reg==0) && (
m_em_idhelper->eta( chid )>=18 ) )
1806 if ( secondOutSlot ) {
1809 if ( sslot_schannel_idx.find(sfeb_id) == sslot_schannel_idx.end() )
1810 sslot_schannel_idx[sfeb_id]=0;
1811 else sslot_schannel_idx[sfeb_id]++;
1814 if ( onl_hash > max_onl_hash ) max_onl_hash = onl_hash;
1815 if ( onl_hash < min_onl_hash ) min_onl_hash = onl_hash;
1817 if ( off_hash > max_off_hash ) max_off_hash = off_hash;
1818 if ( off_hash < min_off_hash ) min_off_hash = off_hash;
1824 of <<
" " << onl_hash <<
" " << off_hash;
1832 of <<
"Hash check. Onl : " << min_onl_hash <<
" " << max_onl_hash;
1833 of <<
"; Off : " << min_off_hash <<
" " << max_off_hash <<
'\n';;
1837 min_onl_hash = 999999;
1839 min_off_hash = 999999;
1841 std::ofstream of1(
"AllChannels_HEC.txt");
1843 of1 <<
"Off ID\t\tSCID\t\tOnl ID\t\tFT\tslot\tB-E pos_neg\tSamp\teta\tphi\tFEB_ID\t\tSHWID\t" <<
'\n';
1844 for(
size_t i = 0; i < channel_size ; i++) {
1847 Identifier SCID = scidtool->offlineToSuperCellID(chid);
1848 if ( scidset.find(SCID) == scidset.end() )
1849 scidset.insert(SCID);
1851 HWIdentifier hwid = cabling->createSignalChannelID(chid);
1870 sprintf(etaChar,
"%5.4f",
eta);
1871 sprintf(phiChar,
"%5.4f",
phi);
1872 of1 << std::dec <<
"\t" << feedthrough <<
"\t" << slot;
1873 of1 <<
"\t" << bar_ec <<
" " << pos_neg <<
"\t\t" << samp <<
"\t";
1874 of1 << etaChar <<
" " << phiChar <<
"\t0x";
1879 if ( sslot_schannel_idx.find(sfeb_id) == sslot_schannel_idx.end() )
1880 sslot_schannel_idx[sfeb_id]=0;
1881 else sslot_schannel_idx[sfeb_id]++;
1882 if ( (feedthrough==6) && (bar_ec==1) && (slot>9) ) {
1888 if ( onl_hash > max_onl_hash ) max_onl_hash = onl_hash;
1889 if ( onl_hash < min_onl_hash ) min_onl_hash = onl_hash;
1891 if ( off_hash > max_off_hash ) max_off_hash = off_hash;
1892 if ( off_hash < min_off_hash ) min_off_hash = off_hash;
1898 of1 <<
" " << onl_hash <<
" " << off_hash;
1906 min_onl_hash = 999999;
1908 min_off_hash = 999999;
1910 std::ofstream of3(
"AllChannels_FCAL.txt");
1912 of3 <<
"Off ID\t\tSCID\t\tOnl ID\t\tFT\tslot\tB-E pos_neg\tSamp\teta\tphi\tFEB_ID\t\tSHWID\t" <<
'\n';
1913 for(
size_t i = 0; i < channel_size ; i++) {
1916 Identifier SCID = scidtool->offlineToSuperCellID(chid);
1917 if ( scidset.find(SCID) == scidset.end() )
1918 scidset.insert(SCID);
1920 HWIdentifier hwid = cabling->createSignalChannelID(chid);
1929 of3 << std::dec <<
"\t" << feedthrough <<
"\t" << slot;
1930 of3 <<
"\t" << bar_ec <<
" " << pos_neg <<
"\t\t" << samp <<
"\t";
1934 if ( (feedthrough==6) && (bar_ec==1) && (slot>9) ) {
1937 if ( sslot_schannel_idx.find(sfeb_id) == sslot_schannel_idx.end() )
1938 sslot_schannel_idx[sfeb_id]=0;
1939 else sslot_schannel_idx[sfeb_id]++;
1942 if ( onl_hash > max_onl_hash ) max_onl_hash = onl_hash;
1943 if ( onl_hash < min_onl_hash ) min_onl_hash = onl_hash;
1945 if ( off_hash > max_off_hash ) max_off_hash = off_hash;
1946 if ( off_hash < min_off_hash ) min_off_hash = off_hash;
1952 of3 <<
" " << onl_hash <<
" " << off_hash;
1959 of3 <<
"Hash check. Onl : " << min_onl_hash <<
" " << max_onl_hash;
1960 of3 <<
"; Off : " << min_off_hash <<
" " << max_off_hash <<
'\n';;
1966 coral::AttributeListSpecification *spec_onOff =
new coral::AttributeListSpecification();
1967 spec_onOff->extend(
"OnlineHashToOfflineId",
"blob");
1968 spec_onOff->extend<
unsigned>(
"version");
1969 std::unique_ptr<AthenaAttributeList> al_onOff = std::make_unique<AthenaAttributeList>(*spec_onOff);
1970 coral::Blob& blobOnOff=(*al_onOff)[
"OnlineHashToOfflineId"].data<coral::Blob>();
1971 (*al_onOff)[
"version"].setValue(0U);
1972 blobOnOff.resize(onlHashMax*
sizeof(uint32_t));
1973 uint32_t* pBlobOnOff=
static_cast<uint32_t*
>(blobOnOff.startingAddress());
1976 const uint32_t emptyId=
Identifier().get_identifier32().get_compact();
1977 for(
size_t ii=0;ii<onlHashMax;ii++) {
1978 if (OrderOnlHash_OffID[ii] != 0) {
1979 pBlobOnOff[ii]=OrderOnlHash_OffID[ii];
1983 pBlobOnOff[ii]=emptyId;
1986 ATH_MSG_INFO (
"HashMax=" << onlHashMax <<
", connected=" << nConn );
1988 ATH_CHECK(
detStore()->record(std::move(al_onOff),
"/LAR/IdentifierOfl/OnOffIdMap_SC") );
1990 hashes <<
"idx \t Off2OnlId \t Onl2OffId" <<
'\n';
1991 for(
size_t ii=0;ii<40000;ii++)
1992 if ( (OrderOffHash_OnlID[ii] != 0) || ( OrderOnlHash_OffID[ii] != 0 ) )
1993 hashes << std::dec << ii << std::hex <<
" \t " << OrderOffHash_OnlID[ii] <<
" \t\t " << OrderOnlHash_OffID[ii] <<
'\n';
1996 return StatusCode::SUCCESS;
2006 std::unique_ptr<LArMinBiasMC> minbias = std::make_unique<LArMinBiasMC>();
2007 ATH_CHECK( minbias->setGroupingType(
"Single",
msg()) );
2009 std::unique_ptr<LArMinBiasAverageMC> minbias_av = std::make_unique<LArMinBiasAverageMC>();
2010 ATH_CHECK( minbias_av->setGroupingType(
"Single",
msg()) );
2013 std::unique_ptr<TFile> fin= std::make_unique<TFile>(
"ntuple_av.root");
2014 TTree *tin=
dynamic_cast<TTree*
>(fin->Get(
"m_tree"));
2017 return StatusCode::FAILURE;
2019 const int nindex=1833;
2021 std::vector<int> identifier(2862);
2022 std::vector<int> layer(2862);
2023 std::vector<int> region(2862);
2024 std::vector<int> ieta(2862);
2025 std::vector<float>
eta(2862);
2026 std::vector<double> average(2862);
2027 std::vector<double> rms(2862);
2029 TBranch *b_identifier;
2036 tin->SetMakeClass(1);
2037 tin->SetBranchAddress(
"ncell", &ncell, &b_ncell);
2038 tin->SetBranchAddress(
"identifier", identifier.data(), &b_identifier);
2039 tin->SetBranchAddress(
"layer", layer.data(), &b_layer);
2040 tin->SetBranchAddress(
"region", region.data(), &b_region);
2041 tin->SetBranchAddress(
"ieta", ieta.data(), &b_ieta);
2042 tin->SetBranchAddress(
"eta",
eta.data(), &b_eta);
2043 tin->SetBranchAddress(
"average", average.data(), &b_average);
2044 tin->SetBranchAddress(
"rms", rms.data(), &b_rms);
2047 if(ncell>nindex) ncell=nindex;
2048 for(
int icell=0; icell<ncell; ++icell) {
2054 minbias->set(hid, rms[icell]);
2055 minbias_av->set(hid, average[icell]);
2059 ATH_MSG_INFO(
" number of channels in intuple ="<<ncell);
2061 ATH_MSG_INFO (
"Stored container " << minbias->totalNumberOfConditions() <<
" conditions, key LArMinBias " );
2065 ATH_MSG_INFO (
"Stored container " << minbias_av->totalNumberOfConditions() <<
" conditions, key LArMinBiasAverage " );
2070 return StatusCode::SUCCESS;
2083 std::unique_ptr<LArMinBiasAverageMC> minbias_av = std::make_unique<LArMinBiasAverageMC>();
2084 ATH_CHECK( minbias_av->setGroupingType(
"Single",
msg()) );
2087 std::unique_ptr<TFile> fin= std::make_unique<TFile>(
m_infile.value().c_str());
2088 TTree *tin=
dynamic_cast<TTree*
>(fin->Get(
"m_tree"));
2091 return StatusCode::FAILURE;
2094 std::vector<int> identifier(2862);
2095 std::vector<int> layer(2862);
2096 std::vector<int> region(2862);
2097 std::vector<int> ieta(2862);
2098 std::vector<float>
eta(2862);
2099 std::vector<double> average(2862);
2100 std::vector<double> rms(2862);
2102 TBranch *b_identifier;
2109 tin->SetMakeClass(1);
2110 tin->SetBranchAddress(
"ncell", &ncell, &b_ncell);
2111 tin->SetBranchAddress(
"identifier", identifier.data(), &b_identifier);
2112 tin->SetBranchAddress(
"layer", layer.data(), &b_layer);
2113 tin->SetBranchAddress(
"region", region.data(), &b_region);
2114 tin->SetBranchAddress(
"ieta", ieta.data(), &b_ieta);
2115 tin->SetBranchAddress(
"eta",
eta.data(), &b_eta);
2116 tin->SetBranchAddress(
"average", average.data(), &b_average);
2117 tin->SetBranchAddress(
"rms", rms.data(), &b_rms);
2121 for(
int icell=0; icell<ncell; ++icell) {
2126 float fsampl = larfSampl->
FSAMPL(hid);
2127 minbias_av->set(hid, 6.31*average[icell]/fsampl);
2131 ATH_MSG_INFO(
" number of channels in intuple ="<<ncell);
2133 ATH_MSG_INFO (
"Stored container " << minbias_av->totalNumberOfConditions() <<
" conditions, key LArPileupAverage " );
2137 return StatusCode::SUCCESS;
2148 ATH_CHECK( detStore()->retrieve(minbias_c,
"LArPileupAverage") );
2158 for(;it!=it_e;++it){
2162 ATH_MSG_INFO(
" Old pileup = "<< u.m_MinBiasAverage<<
" " );
2170 ATH_MSG_INFO(
" New Pileup = "<< t3.m_MinBiasAverage<<
" " );
2175 return StatusCode::SUCCESS;
2182 std::string onOffIdKey=
"/LAR/Identifier/OnOffIdMap";
2184 StatusCode sc=detStore()->retrieve(attrOnOff,onOffIdKey);
2185 if (
sc.isFailure()) {
2186 ATH_MSG_ERROR(
"Failed to read AthenaAttributeList with key " << onOffIdKey);
2187 return StatusCode::FAILURE;
2189 const coral::Blob& blobOnOff=(*attrOnOff)[
"OnlineHashToOfflineId"].data<coral::Blob>();
2190 unsigned nChan=blobOnOff.size()/
sizeof(
uint32_t);
2194 if (nChan!=m_online_idhelper->channelHashMax()) {
2195 ATH_MSG_WARNING(
"Number of channels read from DB (" << nChan <<
") does not match online hash max ("
2196 <<m_online_idhelper->channelHashMax() <<
")");
2197 nChan=std::min(nChan,
static_cast<unsigned int>(m_online_idhelper->channelHashMax()));
2199 std::vector<std::pair<unsigned int, unsigned int> > swapindex(8, std::make_pair(nChan+10,nChan+10));
2201 for (
unsigned i=0;
i<nChan;++
i) {
2203 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) {
2204 if(m_online_idhelper->channel(hwid)>=96 && m_online_idhelper->channel(hwid)<=103) swapindex[m_online_idhelper->channel(hwid)-96].first=
i;
2205 if(m_online_idhelper->channel(hwid)>=112 && m_online_idhelper->channel(hwid)<=129) swapindex[m_online_idhelper->channel(hwid)-112].second=
i;
2208 for(
unsigned i=0;
i<8; ++
i) {
2211 for(
unsigned i=0;
i<8; ++
i) {
2213 if (swapindex[i].first > nChan || swapindex[i].second > nChan ) {
2214 ATH_MSG_ERROR(
"Problem in swapindex: "<< i <<
" : " << swapindex[i].first <<
" " << swapindex[i].second);
2215 return StatusCode::FAILURE;
2217 uint32_t id = pBlobOnOff[swapindex[
i].first];
2218 pBlobOnOff[swapindex[
i].first] = pBlobOnOff[swapindex[
i].second];
2219 pBlobOnOff[swapindex[
i].second] =
id;
2224 return StatusCode::SUCCESS;
2232 ATH_CHECK( update_All<LArShape32MC>(m_infile.value(), cabling,
true, 32 ) );
2234 return StatusCode::SUCCESS;
2243 coral::AttributeListSpecification* spec_calib =
new coral::AttributeListSpecification();
2244 spec_calib->extend(
"OnlineHashToCalibIds",
"blob");
2245 spec_calib->extend<
unsigned>(
"version");
2246 std::unique_ptr<AthenaAttributeList> al_calib = std::make_unique<AthenaAttributeList>(*spec_calib);
2247 coral::Blob& blobCalib=(*al_calib)[
"OnlineHashToCalibIds"].data<coral::Blob>();
2248 (*al_calib)[
"version"].setValue(0U);
2249 blobCalib.resize(onlHashMax*
sizeof(uint32_t)*4);
2251 spec_calib->release();
2253 spec_calib =
nullptr;
2255 uint32_t* pBlobCalib=
static_cast<uint32_t*
>(blobCalib.startingAddress());
2256 size_t calibIndex=0;
2260 for (
unsigned i=0;i<onlHashMax;++i) {
2263 const std::vector<HWIdentifier>& calibIDs=cabling->calibSlotLine(hwid);
2264 const size_t nCalibLines=calibIDs.size();
2267 if(nCalibLines > 1) {
2269 return StatusCode::FAILURE;
2271 if(nCalibLines==0) {
2272 pBlobCalib[calibIndex++]=0;
2279 return StatusCode::FAILURE;
2282 pBlobCalib[calibIndex++]=1;
2286 pBlobCalib[calibIndex++]=nCalibLines;
2287 for(uint32_t iCalib=0;iCalib<nCalibLines;++iCalib)
2288 pBlobCalib[calibIndex++]=calibIDs[iCalib].get_identifier32().get_compact();
2291 blobCalib.resize(calibIndex*
sizeof(uint32_t));
2295 ATH_CHECK(
detStore()->record(std::move(al_calib),
"/LAR/Identifier/CalibIdMap_EMF"));
2297 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_WARNING(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 with parameters:
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.
static constexpr CLID ID()