83#include "Gaudi/Property.h"
84#include "GaudiKernel/IToolSvc.h"
109#include "CoralBase/Blob.h"
144 return StatusCode::SUCCESS;
149 const EventContext& ctx = Gaudi::Hive::currentContext();
157 return fix13(cabling);
159 return StatusCode::SUCCESS;
166 const EventContext& ctx = Gaudi::Hive::currentContext();
171 ATH_MSG_ERROR(
"Do not have cabling mapping from key " << m_cablingKey.key() );
172 return StatusCode::FAILURE;
178 return StatusCode::FAILURE;
183 return fix1(cabling);
185 return fix2(cabling);
187 return fix3(cabling);
189 return fix4(cabling);
191 return fix5(cabling);
193 return fix6(cabling);
195 return fix7(cabling);
197 return fix8(cabling);
199 return fix9(cabling);
201 return fix10(cabling);
203 return fix11(cabling);
205 return fix12(cabling);
207 return fix13(cabling);
209 return fix14(cabling);
215 return fix17(cabling);
217 return fix18(clCont);
219 return StatusCode::SUCCESS;
231 const LArEM_ID* em_idhelper =
nullptr;
238 SmartIF<IToolSvc> toolSvc{Gaudi::svcLocator()->service(
"ToolSvc")};
246 std::ifstream infile(
"barrel_dac2ua_oct06.txt") ;
250 return StatusCode::FAILURE;
254 int det,samp,reg,
eta;
257 while ( infile>>det>>samp>>reg>>
eta>>value )
268 if ( det==1 && samp==1 && reg==0 &&
eta==0 ){
295 return StatusCode::SUCCESS;
313 SmartIF<IToolSvc> toolSvc{Gaudi::svcLocator()->service(
"ToolSvc")};
341 for(
unsigned int gain=0;gain<3;++gain)
348 for (; it!=it_e;++it)
351 if( (*it).isEmpty() )
continue;
352 if(cabling->isOnlineConnected(hid)){
373 " Number of entries removed = " <<n );
378 hid_mod[0] = online_idhelper->
channel_Id(1,1,6,1,33);
379 hid_mod[1] = online_idhelper->
channel_Id(1,1,6,10,12);
380 hid_mod[2] = online_idhelper->
channel_Id(1,1,6,14,12);
383 std::vector<Identifier>::const_iterator it= fcal_idhelper->
fcal_begin();
384 std::vector<Identifier>::const_iterator it_e= fcal_idhelper->
fcal_end();
389 int pn = fcal_idhelper->
pos_neg(
id);
391 int phi = fcal_idhelper->
phi(
id);
394 int module = fcal_idhelper->module(
id)-1;
398 for(
unsigned int gain = 0;gain<3;++gain){
401 if (!rampP.
isEmpty()) continue ;
417 shape->
setPdata(hid,shape_std,gain);
420 noise->setPdata(hid,noise_std,gain);
425 ua2mev->
setPdata(hid,ua2mev_std,gain);
428 dac2ua->
setPdata(hid,dac2ua_std,gain);
431 fsampl->
setPdata(hid,fsampl_std,gain);
434 minbias->
setPdata(hid,minbias_std,gain);
442 return StatusCode::SUCCESS;
448 std::string filename ;
451 if(m_g4Phys==
"QGSP_EMV"){
452 filename =
"fsampl_1302_qgsp-emv.txt";
455 if( m_g4Phys==
"QGSP_BERT"){
456 filename =
"fsampl_1303_qgsp-bert.txt";
460 return StatusCode::FAILURE;
466 ATH_CHECK( updateEMfSampl(filename, cabling ) );
468 return StatusCode::SUCCESS;
474 return updateEM_DACuAMeV(
"dac2ua_ua2mev_rel13.txt", cabling );
479 float fsampl_fcal1,fsampl_fcal2,fsampl_fcal3;
480 float fsampl_hec1,fsampl_hec2;
482 if(m_g4Phys==
"QGSP_EMV"){
484 fsampl_hec2=0.021775;
488 fsampl_fcal1=0.01366;
489 fsampl_fcal2=0.00854;
490 fsampl_fcal3=0.01107;
497 if( m_g4Phys==
"QGSP_BERT"){
502 fsampl_fcal1=0.01591;
503 fsampl_fcal2=0.01144;
504 fsampl_fcal3=0.01405;
513 return StatusCode::FAILURE;
518 ATH_CHECK( detStore()->retrieve(fsampl_c) );
528 for (;
it!=it_e;++
it){
531 if( (*it).isEmpty() )
continue;
532 if(!
cabling->isOnlineConnected(hid)){
541 if(m_hec_idhelper->is_lar_hec(
id)){
543 int sam = m_hec_idhelper->sampling(
id);
546 t2.m_fSampl = fsampl_hec1;
549 t2.m_fSampl = fsampl_hec2;
557 if(m_fcal_idhelper->is_lar_fcal(
id)){
559 int sam = m_fcal_idhelper->module(
id);
562 t2.m_fSampl = fsampl_fcal1;
565 t2.m_fSampl = fsampl_fcal2;
568 t2.m_fSampl = fsampl_fcal3;
582 return StatusCode::SUCCESS;
594 ATH_CHECK( detStore()->retrieve(fsampl_c) );
600 std::ifstream infile( filename);
604 return StatusCode::FAILURE;
606 int det,samp,reg,
eta;
609 while ( infile>>det>>samp>>reg>>
eta>>value )
620 if ( det==1 && samp==1 && reg==0 &&
eta==0 ){
626 id = m_em_idhelper->channel_id(det,samp,reg,
eta,0);
630 std::string id_str = m_online_idhelper->print_to_string(hid);
643 t2.m_fSampl = value ;
650 return StatusCode::SUCCESS;
658 ATH_CHECK( detStore()->retrieve(dac2ua_c) );
662 ATH_CHECK( detStore()->retrieve(ua2mev_c) );
665 std::ifstream
infile(filename) ;
670 return StatusCode::FAILURE;
680 float dac2ua0, ua2mev0,attenuation,dac2ua,ua2mev;
681 while ( infile>>det>>samp>>reg>>
eta>>
682 dac2ua0>>ua2mev0>>attenuation>>dac2ua>>ua2mev )
694 if ( det==1 && samp==1 && reg==0 &&
eta==0 ){
700 id = m_em_idhelper->channel_id(det,samp,reg,
eta,0);
705 std::string id_str = m_online_idhelper->print_to_string(hid);
706 std::string id_str_off = m_em_idhelper->print_to_string(
id);
744 return StatusCode::SUCCESS;
754 ATH_CHECK( updateMinBias(
"mbrms_em_rel12.txt", cabling) );
755 ATH_CHECK( updateMinBias(
"mbrms_hec_rel12.txt", cabling) );
761 ATH_CHECK( detStore()->retrieve(noise_c) );
765 ATH_CHECK( detStore()->retrieve(minbias_c) );
770 for(
unsigned int gain=0;
gain<3;++
gain)
776 for (;
it!=it_e;++
it)
779 if( (*it).isEmpty() )
continue;
782 if(!m_fcal_idhelper->is_lar_fcal(
id))
continue;
784 if(
cabling->isOnlineConnected(hid)){
788 << m_online_idhelper->print_to_string(hid) );
796 " Number of connected and disconnected = " <<nconn<<
" " <<ndisc );
803 std::string
filename(
"FCal_noise_minbias.txt");
805 std::ifstream
infile(filename ) ;
810 return StatusCode::FAILURE;
817 for(
int i = 0;
i<11;++
i){
824 float vol,noise_p,noise_h, noise_m,noise_l;
826 while ( infile>>str_id >>vol>>noise_p>>noise_h>>noise_m>>noise_l )
828 const char* ch_id = str_id.c_str();
829 if(ch_id[0] !=
'A') {
835 std::sscanf(ch_id,
"A%d.%d.%d", &mod,&
phi,&
eta);
848 ATH_MSG_INFO(
" minBiasRMS, old new "<<
t2.m_MinBiasRMS<<
" " <<noise_p);
849 t2.m_MinBiasRMS = noise_p;
870 return StatusCode::SUCCESS;
875 ATH_MSG_INFO (
" in updateMinBias(), filename = "<<filename );
881 ATH_CHECK( detStore()->retrieve(minbias_c) );
887 std::ifstream
infile( filename);
891 return StatusCode::FAILURE;
899 while ( infile>>lar>>tp>>det>>samp>>reg>>
eta>>
phi>>value )
910 if ( det==1 && samp==1 && reg==0 &&
eta==0 ){
918 id = m_em_idhelper->channel_id(det,samp,reg,
eta,0);
922 id = m_hec_idhelper->channel_id(det,samp,reg,
eta,0);
933 ATH_MSG_INFO(
" online id = "<<m_online_idhelper->print_to_string(hid));
953 return StatusCode::SUCCESS;
965 ATH_CHECK( detStore()->retrieve(noise_c) );
969 ATH_CHECK( detStore()->retrieve(ramp_c) );
973 ATH_CHECK( detStore()->retrieve(ua2MeV_c) );
977 ATH_CHECK( detStore()->retrieve(dac2uA_c) );
982 for(
unsigned int gain=0;
gain<3;++
gain)
988 for (;
it!=it_e;++
it)
991 if( (*it).isEmpty() )
continue;
994 if(!m_fcal_idhelper->is_lar_fcal(
id))
continue;
996 if(
cabling->isOnlineConnected(hid)){
1002 << m_online_idhelper->print_to_string(hid) );
1010 " Number of connected and disconnected = " <<nconn<<
" " <<ndisc );
1017 std::string
filename(
"FCal_noise_minbias_adc2mev.txt");
1018 std::ifstream
infile(filename) ;
1023 return StatusCode::FAILURE;
1030 for(
int i = 0;
i<27;++
i){
1037 float vol,noise_p,noise_h, noise_m,noise_l;
1038 float ramp_val,ua2MeV_val,dac2uA_val;
1040 while ( infile>>str_id >>vol>>noise_p >> noise_h>>noise_m>>noise_l
1041 >>channel_type>> ramp_val>>ua2MeV_val>>dac2uA_val )
1043 const char* ch_id = str_id.c_str();
1045 if(str_id.substr(0,1)!=std::string(
"A")){
1051 sscanf(ch_id,
"A%d.%d.%d", &mod,&
phi,&
eta);
1092 ua2MeV0.
m_data=ua2MeV_val;
1095 dac2ua0.
m_data = dac2uA_val;
1100 return StatusCode::SUCCESS;
1110 if( m_g4Phys==
"QGSP_BERT"){
1111 filename =
"fsampl_1303_qgsp-bert.txt";
1115 return StatusCode::FAILURE;
1118 ATH_CHECK( updateEMfSampl(filename, cabling ) );
1119 return StatusCode::SUCCESS;
1130 ATH_CHECK( update_EM_HEC<LArNoiseMC>(
"noise_em.txt",
"noise_hec.txt", cabling,
true, 1 ) );
1131 ATH_CHECK( update_EM_HEC<LArAutoCorrMC>(
"",
"autocorr_hec.txt", cabling,
true, 4 ) );
1133 ATH_CHECK( update_EM_HEC<LArAutoCorrMC>(
"autocorr_em.txt",
"", cabling,
true,5) );
1134 ATH_CHECK( update_EM_HEC<LArRampMC>(
"ramp_em.txt",
"ramp_hec.txt", cabling,
true, 1 ) );
1135 ATH_CHECK( update_EM_HEC<LAruA2MeVMC>(
"ua2mev_em.txt",
"ua2mev_hec.txt", cabling,
false, 1 ) );
1136 ATH_CHECK( update_EM_HEC<LArDAC2uAMC>(
"dac2ua_em.txt",
"dac2ua_hec.txt", cabling,
false, 1 ) );
1137 ATH_CHECK( update_EM_HEC<LArShape32MC>(
"shape_em.txt",
"shape_hec.txt", cabling,
true, 64 ) );
1138 ATH_CHECK( update_EM_HEC<LArMphysOverMcalMC>(
"mphys_em.txt",
"", cabling,
true, 1 ) );
1142 return StatusCode::SUCCESS;
1148 std::ifstream infile(filename) ;
1150 if(! infile.good() )
1153 return StatusCode::FAILURE;
1163 infile.getline(s,200);
1169 while ( infile>>first )
1173 infile>>samp>>reg>>
eta;
1181 if(withGain) infile>>gain ;
1182 std::vector<float> vfl;
1185 for (
int i=0;i<nvar;++i)
1199 if ( det==1 && samp==1 && reg==0 &&
eta==0 ){
1211 if (gain >= 0 && gain < 3)
1215 return StatusCode::SUCCESS;
1220 std::ifstream infile(filename) ;
1222 if(! infile.good() )
1225 return StatusCode::FAILURE;
1235 infile.getline(s,200);
1238 int det=0,samp=0,reg=0,
eta=0;
1240 while ( infile>>first>>samp>>reg>>
eta ) {
1246 if ( det==1 && samp==1 && reg==0 &&
eta==0 ){
1253 }
else if (first == 3) {
1255 }
else if (first == 4) {
1259 if(withGain) infile>>gain ;
1260 for (
int i=0;i<nvar;++i) infile>>
x;
1263 if(withGain) infile>>gain ;
1264 std::vector<float> vfl;
1266 for (
int i=0;i<nvar;++i)
1272 <<first<<
" " <<det<<
" " <<samp<<
" " <<reg<<
" " <<
eta<<
" " );
1276 if (gain >= 0 && gain < 3)
m_cache[gain].push_back(
ROW_t(hid,vfl));
1282 return StatusCode::SUCCESS;
1298 ATH_MSG_ERROR (
"for LArNoiseMC, size of vector = "<< v.size() <<
" differs from one");
1311 msg()<<MSG::DEBUG<<
" LArAutoCorrMC" << s ;
1312 for (
unsigned int i =0 ; i<obj.m_vAutoCorr.size();++i)
1313 msg()<<
" " << obj.m_vAutoCorr[i];
1323 ATH_MSG_ERROR(
"for LArAutoCorrMC, size of vector = "<< v.size()<<
" is less then 4" );
1327 obj.m_vAutoCorr.resize(4);
1328 std::copy_n(v.begin(), 4, obj.m_vAutoCorr.begin());
1338 msg()<<MSG::DEBUG<<
" LArRampMC" << s ;
1339 for (
unsigned int i =0 ; i<obj.m_vRamp.size();++i)
1340 msg()<<
" " << obj.m_vRamp[i];
1350 ATH_MSG_ERROR (
"for LArRampMC, size of vector = "<< v.size());
1353 obj.m_vRamp.resize(3);
1355 obj.m_vRamp[1]=v[0];
1367 msg()<<MSG::DEBUG<<
" LArShape" << s ;
1368 for (
unsigned int i =0 ; i<obj.m_vShape.size();++i)
1369 msg()<<
" " << obj.m_vShape[i];
1372 msg()<<MSG::DEBUG<<
" LArShapeDer" << s ;
1373 for (
unsigned int i =0 ; i<obj.m_vShapeDer.size();++i)
1374 msg()<<
" " << obj.m_vShapeDer[i];
1383 if (v.size()!=64 && v.size()!=32 )
1385 ATH_MSG_ERROR (
"for LArShape32MC, size of vector = "<< v.size());
1389 unsigned int size = 32;
1390 obj.m_vShape.resize(
size);
1391 obj.m_vShapeDer.resize(
size);
1393 for(
unsigned int i=0;i<
size;++i){
1394 obj.m_vShape[i]=v[i];
1395 if(v.size() == 64 ) obj.m_vShapeDer[i]=v[i+
size];
else obj.m_vShapeDer[i]=0.;
1418 ATH_MSG_ERROR(
"for LArSingleFloatP, size of vector = "<< v.size() );
1435 std::unique_ptr<LArMphysOverMcalMC> mphys = std::make_unique<LArMphysOverMcalMC>();
1441 std::string filename(
"FCal_noise_minbias_adc2mev.txt");
1443 std::ifstream infile(filename ) ;
1445 if(! infile.good() )
1448 return StatusCode::FAILURE;
1455 for(
int i = 0;i<27;++i){
1456 infile.getline(s,200);
1462 float vol,noise_p,noise_h, noise_m,noise_l;
1463 float ramp_val,ua2MeV_val,dac2uA_val;
1464 std::string channel_type;
1465 while ( infile>>str_id >>vol>>noise_p >> noise_h>>noise_m>>noise_l
1466 >>channel_type>> ramp_val>>ua2MeV_val>>dac2uA_val )
1468 const char* ch_id = str_id.c_str();
1470 if(str_id.substr(0,1)!=std::string(
"A")){
1476 sscanf(ch_id,
"A%d.%d.%d", &mod,&
phi,&
eta);
1490 mphys->setPdata(hid,t,0);
1491 mphys->setPdata(hid,t,1);
1492 mphys->setPdata(hid,t,2);
1495 ATH_MSG_INFO(
" MphysOverMcal added "<<n<<
" FCAL channels");
1498 bool withGain=
false;
1500 std::string hec_filename(
"mphys_hec.txt");
1510 mphys->setPdata(hid,t,0);
1511 mphys->setPdata(hid,t,1);
1512 mphys->setPdata(hid,t,2);
1521 ATH_MSG_ERROR(
" Number of HEC channel added "<<n <<
" per gain ");
1522 return StatusCode::SUCCESS ;
1531 ATH_CHECK( detStore()->retrieve(dac2ua_c) );
1535 ATH_CHECK( detStore()->retrieve(ua2mev_c) );
1543 for(;it!=it_e;++it){
1572 for( ;
it!=it_e;++
it){
1576 if(
u.m_data> -990.)
1595 return StatusCode::SUCCESS;
1603 std::vector<float> fcal_autoCorr[3][3] ;
1604 fcal_autoCorr[0][0] = {-0.01, -0.30, -0.09, 0.08};
1605 fcal_autoCorr[0][1] = { 0.01, -0.07, -0.01, 0.03};
1606 fcal_autoCorr[0][2] = { 0.2, 0.2, 0.2, 0.2};
1607 fcal_autoCorr[1][0] = { -0.02, -0.31, -0.06, 0.06};
1608 fcal_autoCorr[1][1] = { 0.0, -0.08, -0.01, 0.02};
1609 fcal_autoCorr[1][2] = { 0.02, 0.01, 0.02, 0.02};
1610 fcal_autoCorr[2][0] = { -0.03, -0.31, -0.05, 0.07};
1611 fcal_autoCorr[2][1] = { 0.01, -0.07, -0.01, 0.02};
1612 fcal_autoCorr[2][2] = { 0.02, 0.02, 0.02, 0.02};
1618 ATH_CHECK( detStore()->retrieve(ac_c) );
1622 for(
unsigned int gain=0;
gain<3;++
gain)
1629 for (;
it!=it_e;++
it)
1633 if( (*it).isEmpty() )
continue;
1636 if(! m_fcal_idhelper->is_lar_fcal(
id)) continue ;
1637 int module = m_fcal_idhelper->module(
id) - 1;
1640 <<
u.m_vAutoCorr[0]<<
" "
1641 <<
u.m_vAutoCorr[1]<<
" "
1642 <<
u.m_vAutoCorr[2]<<
" "
1643 <<
u.m_vAutoCorr[3]<<
" " );
1658 " Number of entries modified = " <<n );
1661 return StatusCode::SUCCESS;
1671 ATH_CHECK( detStore()->retrieve(ramp_c) );
1679 for (;
it!=it_e;++
it)
1682 if( (*it).isEmpty() )
continue;
1685 if(!m_fcal_idhelper->is_lar_fcal(
id))
continue;
1687 if( !
cabling->isOnlineConnected(hid)){
1689 << m_online_idhelper->print_to_string(hid) );
1702 float ramp_high = ramp0.
m_vRamp[1];
1704 ramp1.
m_vRamp.assign ({0, ramp_high*9.96f});
1705 ramp2.
m_vRamp.assign ({0, ramp_high*9.96f*9.67f});
1716 return StatusCode::SUCCESS;
1725 ATH_CHECK( update_EM_HEC<LArRampMC>(
"",
"ramp_hec_june2008.txt", cabling,
true, 1 ) );
1726 return StatusCode::SUCCESS;
1735 ToolHandle<ICaloSuperCellIDTool> scidtool(
"CaloSuperCellIDTool");
1736 if ( scidtool.retrieve().isFailure() ) {
1740 std::set<Identifier> scidset;
1741 std::map<HWIdentifier,int> sslot_schannel_idx;
1742 std::vector<unsigned int> OrderOnlHash_OffID;
1743 std::vector<unsigned int> OrderOffHash_OnlID;
1744 OrderOnlHash_OffID.resize(40000,0);
1745 OrderOffHash_OnlID.resize(40000,0);
1747 Identifier::size_type channel_size =
m_em_idhelper->channel_hash_max();
1748 unsigned int min_onl_hash = 999999;
1749 unsigned int max_onl_hash = 0;
1750 unsigned int min_off_hash = 999999;
1751 unsigned int max_off_hash = 0;
1752 std::ofstream hashes(
"AllHashChannels_All.txt");
1753 std::ofstream of(
"AllChannels_EM.txt");
1755 for(
size_t i = 0; i < channel_size ; i++) {
1758 if ( ! isEM )
continue;
1759 Identifier SCID = scidtool->offlineToSuperCellID(chid);
1760 if ( scidset.find(SCID) == scidset.end() && (
m_scell_idhelper->calo_cell_hash( SCID ).value() < 99999) )
1761 scidset.insert(SCID);
1763 HWIdentifier hwid = cabling->createSignalChannelID(chid);
1765 of <<
"Off ID\t\tSCID\t\tOnl ID\t\tFT\tslot\tB-E pos_neg\tSamp\teta\tphi\tFEB_ID\t\tSHWID\t" << std::endl;
1786 sprintf(etaChar,
"%5.4f",
eta);
1787 sprintf(phiChar,
"%5.4f",
phi);
1788 of << std::dec <<
"\t" << feedthrough <<
"\t" << slot;
1789 of <<
"\t" << bar_ec <<
" " << pos_neg <<
"\t\t" << samp <<
"\t";
1790 of << etaChar <<
" " << phiChar <<
"\t0x";
1795 bool secondOutSlot=
false;
1797 if ( (samp==1) && (reg==5) ) secondOutSlot=
true;
1798 if ( (samp==2) && (reg==1) && (
m_em_idhelper->eta( chid )>=39 ) )
1800 if ( (samp==3) && (reg==0) && (
m_em_idhelper->eta( chid )>=18 ) )
1808 if ( secondOutSlot ) {
1811 if ( sslot_schannel_idx.find(sfeb_id) == sslot_schannel_idx.end() )
1812 sslot_schannel_idx[sfeb_id]=0;
1813 else sslot_schannel_idx[sfeb_id]++;
1816 if ( onl_hash > max_onl_hash ) max_onl_hash = onl_hash;
1817 if ( onl_hash < min_onl_hash ) min_onl_hash = onl_hash;
1819 if ( off_hash > max_off_hash ) max_off_hash = off_hash;
1820 if ( off_hash < min_off_hash ) min_off_hash = off_hash;
1826 of <<
" " << onl_hash <<
" " << off_hash;
1834 of <<
"Hash check. Onl : " << min_onl_hash <<
" " << max_onl_hash;
1835 of <<
"; Off : " << min_off_hash <<
" " << max_off_hash << std::endl;;
1839 min_onl_hash = 999999;
1841 min_off_hash = 999999;
1843 std::ofstream of1(
"AllChannels_HEC.txt");
1845 of1 <<
"Off ID\t\tSCID\t\tOnl ID\t\tFT\tslot\tB-E pos_neg\tSamp\teta\tphi\tFEB_ID\t\tSHWID\t" << std::endl;
1846 for(
size_t i = 0; i < channel_size ; i++) {
1849 Identifier SCID = scidtool->offlineToSuperCellID(chid);
1850 if ( scidset.find(SCID) == scidset.end() )
1851 scidset.insert(SCID);
1853 HWIdentifier hwid = cabling->createSignalChannelID(chid);
1872 sprintf(etaChar,
"%5.4f",
eta);
1873 sprintf(phiChar,
"%5.4f",
phi);
1874 of1 << std::dec <<
"\t" << feedthrough <<
"\t" << slot;
1875 of1 <<
"\t" << bar_ec <<
" " << pos_neg <<
"\t\t" << samp <<
"\t";
1876 of1 << etaChar <<
" " << phiChar <<
"\t0x";
1881 if ( sslot_schannel_idx.find(sfeb_id) == sslot_schannel_idx.end() )
1882 sslot_schannel_idx[sfeb_id]=0;
1883 else sslot_schannel_idx[sfeb_id]++;
1884 if ( (feedthrough==6) && (bar_ec==1) && (slot>9) ) {
1890 if ( onl_hash > max_onl_hash ) max_onl_hash = onl_hash;
1891 if ( onl_hash < min_onl_hash ) min_onl_hash = onl_hash;
1893 if ( off_hash > max_off_hash ) max_off_hash = off_hash;
1894 if ( off_hash < min_off_hash ) min_off_hash = off_hash;
1900 of1 <<
" " << onl_hash <<
" " << off_hash;
1908 min_onl_hash = 999999;
1910 min_off_hash = 999999;
1912 std::ofstream of3(
"AllChannels_FCAL.txt");
1914 of3 <<
"Off ID\t\tSCID\t\tOnl ID\t\tFT\tslot\tB-E pos_neg\tSamp\teta\tphi\tFEB_ID\t\tSHWID\t" << std::endl;
1915 for(
size_t i = 0; i < channel_size ; i++) {
1918 Identifier SCID = scidtool->offlineToSuperCellID(chid);
1919 if ( scidset.find(SCID) == scidset.end() )
1920 scidset.insert(SCID);
1922 HWIdentifier hwid = cabling->createSignalChannelID(chid);
1931 of3 << std::dec <<
"\t" << feedthrough <<
"\t" << slot;
1932 of3 <<
"\t" << bar_ec <<
" " << pos_neg <<
"\t\t" << samp <<
"\t";
1936 if ( (feedthrough==6) && (bar_ec==1) && (slot>9) ) {
1939 if ( sslot_schannel_idx.find(sfeb_id) == sslot_schannel_idx.end() )
1940 sslot_schannel_idx[sfeb_id]=0;
1941 else sslot_schannel_idx[sfeb_id]++;
1944 if ( onl_hash > max_onl_hash ) max_onl_hash = onl_hash;
1945 if ( onl_hash < min_onl_hash ) min_onl_hash = onl_hash;
1947 if ( off_hash > max_off_hash ) max_off_hash = off_hash;
1948 if ( off_hash < min_off_hash ) min_off_hash = off_hash;
1954 of3 <<
" " << onl_hash <<
" " << off_hash;
1961 of3 <<
"Hash check. Onl : " << min_onl_hash <<
" " << max_onl_hash;
1962 of3 <<
"; Off : " << min_off_hash <<
" " << max_off_hash << std::endl;;
1968 coral::AttributeListSpecification *spec_onOff =
new coral::AttributeListSpecification();
1969 spec_onOff->extend(
"OnlineHashToOfflineId",
"blob");
1970 spec_onOff->extend<
unsigned>(
"version");
1971 std::unique_ptr<AthenaAttributeList> al_onOff = std::make_unique<AthenaAttributeList>(*spec_onOff);
1972 coral::Blob& blobOnOff=(*al_onOff)[
"OnlineHashToOfflineId"].data<coral::Blob>();
1973 (*al_onOff)[
"version"].setValue(0U);
1974 blobOnOff.resize(onlHashMax*
sizeof(uint32_t));
1975 uint32_t* pBlobOnOff=
static_cast<uint32_t*
>(blobOnOff.startingAddress());
1978 const uint32_t emptyId=
Identifier().get_identifier32().get_compact();
1979 for(
size_t ii=0;ii<onlHashMax;ii++) {
1980 if (OrderOnlHash_OffID[ii] != 0) {
1981 pBlobOnOff[ii]=OrderOnlHash_OffID[ii];
1985 pBlobOnOff[ii]=emptyId;
1988 ATH_MSG_INFO (
"HashMax=" << onlHashMax <<
", connected=" << nConn );
1990 ATH_CHECK(
detStore()->record(std::move(al_onOff),
"/LAR/IdentifierOfl/OnOffIdMap_SC") );
1992 hashes <<
"idx \t Off2OnlId \t Onl2OffId" << std::endl;
1993 for(
size_t ii=0;ii<40000;ii++)
1994 if ( (OrderOffHash_OnlID[ii] != 0) || ( OrderOnlHash_OffID[ii] != 0 ) )
1995 hashes << std::dec << ii << std::hex <<
" \t " << OrderOffHash_OnlID[ii] <<
" \t\t " << OrderOnlHash_OffID[ii] << std::endl;
1998 return StatusCode::SUCCESS;
2008 std::unique_ptr<LArMinBiasMC> minbias = std::make_unique<LArMinBiasMC>();
2009 ATH_CHECK( minbias->setGroupingType(
"Single",
msg()) );
2011 std::unique_ptr<LArMinBiasAverageMC> minbias_av = std::make_unique<LArMinBiasAverageMC>();
2012 ATH_CHECK( minbias_av->setGroupingType(
"Single",
msg()) );
2015 std::unique_ptr<TFile> fin= std::make_unique<TFile>(
"ntuple_av.root");
2016 TTree *tin=
dynamic_cast<TTree*
>(fin->Get(
"m_tree"));
2019 return StatusCode::FAILURE;
2021 const int nindex=1833;
2023 std::vector<int> identifier(2862);
2024 std::vector<int> layer(2862);
2025 std::vector<int> region(2862);
2026 std::vector<int> ieta(2862);
2027 std::vector<float>
eta(2862);
2028 std::vector<double> average(2862);
2029 std::vector<double> rms(2862);
2031 TBranch *b_identifier;
2038 tin->SetMakeClass(1);
2039 tin->SetBranchAddress(
"ncell", &ncell, &b_ncell);
2040 tin->SetBranchAddress(
"identifier", identifier.data(), &b_identifier);
2041 tin->SetBranchAddress(
"layer", layer.data(), &b_layer);
2042 tin->SetBranchAddress(
"region", region.data(), &b_region);
2043 tin->SetBranchAddress(
"ieta", ieta.data(), &b_ieta);
2044 tin->SetBranchAddress(
"eta",
eta.data(), &b_eta);
2045 tin->SetBranchAddress(
"average", average.data(), &b_average);
2046 tin->SetBranchAddress(
"rms", rms.data(), &b_rms);
2049 if(ncell>nindex) ncell=nindex;
2050 for(
int icell=0; icell<ncell; ++icell) {
2056 minbias->set(hid, rms[icell]);
2057 minbias_av->set(hid, average[icell]);
2061 ATH_MSG_INFO(
" number of channels in intuple ="<<ncell);
2063 ATH_MSG_INFO (
"Stored container " << minbias->totalNumberOfConditions() <<
" conditions, key LArMinBias " );
2067 ATH_MSG_INFO (
"Stored container " << minbias_av->totalNumberOfConditions() <<
" conditions, key LArMinBiasAverage " );
2072 return StatusCode::SUCCESS;
2085 std::unique_ptr<LArMinBiasAverageMC> minbias_av = std::make_unique<LArMinBiasAverageMC>();
2086 ATH_CHECK( minbias_av->setGroupingType(
"Single",
msg()) );
2089 std::unique_ptr<TFile> fin= std::make_unique<TFile>(
m_infile.value().c_str());
2090 TTree *tin=
dynamic_cast<TTree*
>(fin->Get(
"m_tree"));
2093 return StatusCode::FAILURE;
2096 std::vector<int> identifier(2862);
2097 std::vector<int> layer(2862);
2098 std::vector<int> region(2862);
2099 std::vector<int> ieta(2862);
2100 std::vector<float>
eta(2862);
2101 std::vector<double> average(2862);
2102 std::vector<double> rms(2862);
2104 TBranch *b_identifier;
2111 tin->SetMakeClass(1);
2112 tin->SetBranchAddress(
"ncell", &ncell, &b_ncell);
2113 tin->SetBranchAddress(
"identifier", identifier.data(), &b_identifier);
2114 tin->SetBranchAddress(
"layer", layer.data(), &b_layer);
2115 tin->SetBranchAddress(
"region", region.data(), &b_region);
2116 tin->SetBranchAddress(
"ieta", ieta.data(), &b_ieta);
2117 tin->SetBranchAddress(
"eta",
eta.data(), &b_eta);
2118 tin->SetBranchAddress(
"average", average.data(), &b_average);
2119 tin->SetBranchAddress(
"rms", rms.data(), &b_rms);
2123 for(
int icell=0; icell<ncell; ++icell) {
2128 float fsampl = larfSampl->
FSAMPL(hid);
2129 minbias_av->set(hid, 6.31*average[icell]/fsampl);
2133 ATH_MSG_INFO(
" number of channels in intuple ="<<ncell);
2135 ATH_MSG_INFO (
"Stored container " << minbias_av->totalNumberOfConditions() <<
" conditions, key LArPileupAverage " );
2139 return StatusCode::SUCCESS;
2150 ATH_CHECK( detStore()->retrieve(minbias_c,
"LArPileupAverage") );
2160 for(;it!=it_e;++it){
2164 ATH_MSG_INFO(
" Old pileup = "<< u.m_MinBiasAverage<<
" " );
2172 ATH_MSG_INFO(
" New Pileup = "<< t3.m_MinBiasAverage<<
" " );
2177 return StatusCode::SUCCESS;
2184 std::string onOffIdKey=
"/LAR/Identifier/OnOffIdMap";
2186 StatusCode sc=detStore()->retrieve(attrOnOff,onOffIdKey);
2187 if (
sc.isFailure()) {
2188 ATH_MSG_ERROR(
"Failed to read AthenaAttributeList with key " << onOffIdKey);
2189 return StatusCode::FAILURE;
2191 const coral::Blob& blobOnOff=(*attrOnOff)[
"OnlineHashToOfflineId"].data<coral::Blob>();
2192 unsigned nChan=blobOnOff.size()/
sizeof(
uint32_t);
2196 if (nChan!=m_online_idhelper->channelHashMax()) {
2197 ATH_MSG_WARNING(
"Number of channels read from DB (" << nChan <<
") does not match online hash max ("
2198 <<m_online_idhelper->channelHashMax() <<
")");
2199 nChan=std::min(nChan,
static_cast<unsigned int>(m_online_idhelper->channelHashMax()));
2201 std::vector<std::pair<unsigned int, unsigned int> > swapindex(8, std::make_pair(nChan+10,nChan+10));
2203 for (
unsigned i=0;
i<nChan;++
i) {
2205 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) {
2206 if(m_online_idhelper->channel(hwid)>=96 && m_online_idhelper->channel(hwid)<=103) swapindex[m_online_idhelper->channel(hwid)-96].first=
i;
2207 if(m_online_idhelper->channel(hwid)>=112 && m_online_idhelper->channel(hwid)<=129) swapindex[m_online_idhelper->channel(hwid)-112].second=
i;
2210 for(
unsigned i=0;
i<8; ++
i) {
2213 for(
unsigned i=0;
i<8; ++
i) {
2215 if (swapindex[i].first > nChan || swapindex[i].second > nChan ) {
2216 ATH_MSG_ERROR(
"Problem in swapindex: "<< i <<
" : " << swapindex[i].first <<
" " << swapindex[i].second);
2217 return StatusCode::FAILURE;
2219 uint32_t id = pBlobOnOff[swapindex[
i].first];
2220 pBlobOnOff[swapindex[
i].first] = pBlobOnOff[swapindex[
i].second];
2221 pBlobOnOff[swapindex[
i].second] =
id;
2226 return StatusCode::SUCCESS;
2234 ATH_CHECK( update_All<LArShape32MC>(m_infile.value(), cabling,
true, 32 ) );
2236 return StatusCode::SUCCESS;
2245 coral::AttributeListSpecification* spec_calib =
new coral::AttributeListSpecification();
2246 spec_calib->extend(
"OnlineHashToCalibIds",
"blob");
2247 spec_calib->extend<
unsigned>(
"version");
2248 std::unique_ptr<AthenaAttributeList> al_calib = std::make_unique<AthenaAttributeList>(*spec_calib);
2249 coral::Blob& blobCalib=(*al_calib)[
"OnlineHashToCalibIds"].data<coral::Blob>();
2250 (*al_calib)[
"version"].setValue(0U);
2251 blobCalib.resize(onlHashMax*
sizeof(uint32_t)*4);
2253 spec_calib->release();
2255 spec_calib =
nullptr;
2257 uint32_t* pBlobCalib=
static_cast<uint32_t*
>(blobCalib.startingAddress());
2258 size_t calibIndex=0;
2262 for (
unsigned i=0;i<onlHashMax;++i) {
2265 const std::vector<HWIdentifier>& calibIDs=cabling->calibSlotLine(hwid);
2266 const size_t nCalibLines=calibIDs.size();
2269 if(nCalibLines > 1) {
2271 return StatusCode::FAILURE;
2273 if(nCalibLines==0) {
2274 pBlobCalib[calibIndex++]=0;
2281 return StatusCode::FAILURE;
2284 pBlobCalib[calibIndex++]=1;
2288 pBlobCalib[calibIndex++]=nCalibLines;
2289 for(uint32_t iCalib=0;iCalib<nCalibLines;++iCalib)
2290 pBlobCalib[calibIndex++]=calibIDs[iCalib].get_identifier32().get_compact();
2293 blobCalib.resize(calibIndex*
sizeof(uint32_t));
2297 ATH_CHECK(
detStore()->record(std::move(al_calib),
"/LAR/Identifier/CalibIdMap_EMF"));
2299 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)
virtual StatusCode execute() override
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
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()