ATLAS Offline Software
LArAutoCorrAlgToDB.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 /********************************************************************
6 
7  NAME: LArAutoCorrAlgToDB.cxx
8  PACKAGE: LArCalorimeter/LArCalibUtils
9 
10  AUTHORS: P. Strizenec, based on Tool by G. Unal
11 
12  PURPOSE: write LArAutoCorr in Database from LArAutoCorrTotal conditions object
13 
14 ********************************************************************/
15 
16 // Include files
20 
21 
22 LArAutoCorrAlgToDB::LArAutoCorrAlgToDB(const std::string& name, ISvcLocator* pSvcLocator)
23  : AthAlgorithm(name, pSvcLocator),
24  m_onlineHelper(nullptr)
25 {
26  declareProperty("GroupingType", m_groupingType="ExtendedFeedThrough");
27  declareProperty("OutAutoCorrKey", m_acContName="LArPhysAutoCorr");
28  declareProperty("isSC",m_isSC=false);
29  declareProperty("NMinbias", m_nMinbias);
30 }
31 
32 
34 = default;
35 
36 //----------------------------------------------------------------------------
38 {
39  StatusCode sc;
40  if ( m_isSC ) {
42  sc = detStore()->retrieve(ll, "LArOnline_SuperCellID");
43  if (sc.isFailure()) {
44  ATH_MSG_ERROR( "Could not get LArOnlineID helper !" );
45  return StatusCode::FAILURE;
46  }
47  else {
49  ATH_MSG_DEBUG("Found the LArOnlineID helper");
50  }
51  m_nGains=1;
52  } else { // m_isSC
53  const LArOnlineID* ll;
54  sc = detStore()->retrieve(ll, "LArOnlineID");
55  if (sc.isFailure()) {
56  ATH_MSG_ERROR( "Could not get LArOnlineID helper !" );
57  return StatusCode::FAILURE;
58  }
59  else {
61  ATH_MSG_DEBUG(" Found the LArOnlineID helper. ");
62  }
64  }
65 
67  return StatusCode::SUCCESS;
68 }
69 
70 //---------------------------------------------------------------------------
72 
73  ATH_MSG_INFO ( ">>> stop()" );
74 
75  // ReadHandle setup
77  const LArAutoCorrTotal *acTotal = *acHdl;
78  if(!acTotal) {
79  ATH_MSG_ERROR("Could not read LArAutoCorrTotal with key " <<m_autocorrKey.key()<<" from ConditionsStore");
80  return StatusCode::FAILURE;
81  }
82 
83  auto larAutoCorrComplete = std::make_unique<LArAutoCorrComplete>();
84  // Initialize LArAutoCorrComplete
85  ATH_CHECK( larAutoCorrComplete->setGroupingType(m_groupingType,msg()) );
86  ATH_CHECK( larAutoCorrComplete->initialize() );
87 
88  //Loop over gains
89  for (unsigned igain=0;igain<m_nGains;igain++) {
91  //Loop over cells
92  std::vector<HWIdentifier>::const_iterator it =m_onlineHelper->channel_begin();
93  std::vector<HWIdentifier>::const_iterator it_e =m_onlineHelper->channel_end();
94  unsigned nSkipped=0;
95  unsigned nDone=0;
96  for(;it!=it_e;++it) {
97 
98  HWIdentifier chid = (*it);
99 
100  const std::vector<double> AutoCorr = acTotal->autoCorrTotal(chid,igain,m_nMinbias);
101  // Not to process channels not existing in input elec. autocorr. DB
102  if(AutoCorr.size() < 2 || (AutoCorr[0]==0. && AutoCorr[1]==0.)) {
103  ++nSkipped;
104  continue;
105  }
106  const std::vector<double> rmsSampl = acTotal->samplRMS(chid,igain,m_nMinbias);
107  unsigned int nsamples_AC = (1+((int)(sqrt(1+8*AutoCorr.size()))))/2;
108 
109  std::vector<float> cov;
110  unsigned int ntot = nsamples_AC*(nsamples_AC+1) / 2;
111  cov.resize(ntot,0.);
112 
113  unsigned int k=0;
114  for (unsigned i=0;i<nsamples_AC;i++) {
115  for (unsigned j=i;j<nsamples_AC;j++,k++) {
116  double AC;
117  if (i==j) {
118  AC=1.;
119  }
120  else {
121  int i1=std::min(i,j);
122  int i2=std::max(i,j);
123  int index = i1*nsamples_AC - i1*(i1+1)/2 -(i1+1) + i2;
124  AC=AutoCorr[index];
125  }
126  AC = AC*rmsSampl[i]*rmsSampl[j];
127  cov[k] = AC;
128  }
129  }
130 
131  larAutoCorrComplete->set(chid,gain,cov);
132  ++nDone;
133  }//end loop over all cells
134  ATH_MSG_INFO ( "Gain " << gain << ": " << nDone << " channels done, " << nSkipped << " channels skipped (no Elec Noise AC in input)" );
135  }//end loop over gains
136 
137  // Record LArAutoCorrComplete
138  ATH_CHECK( detStore()->record(std::move(larAutoCorrComplete),m_acContName) );
139  ATH_MSG_INFO ( "Recorded LArAutCorrComplete object with key " << m_acContName );
141  ATH_MSG_INFO(detStore()->dump());
142 
143  return StatusCode::SUCCESS;
144 }
145 
146 
147 
148 
149 
150 
151 
152 
LArAutoCorrAlgToDB.h
max
#define max(a, b)
Definition: cfImp.cxx:41
LArAutoCorrAlgToDB::stop
StatusCode stop()
Definition: LArAutoCorrAlgToDB.cxx:71
SG::ReadCondHandle
Definition: ReadCondHandle.h:44
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
LArAutoCorrAlgToDB::initialize
StatusCode initialize()
Definition: LArAutoCorrAlgToDB.cxx:37
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
LArAutoCorrAlgToDB::LArAutoCorrAlgToDB
LArAutoCorrAlgToDB(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArAutoCorrAlgToDB.cxx:22
index
Definition: index.py:1
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
skel.it
it
Definition: skel.GENtoEVGEN.py:423
plotBeamSpotVxVal.cov
cov
Definition: plotBeamSpotVxVal.py:201
TRT_PAI_gasdata::AC
const float AC
Definition: TRT_PAI_gasdata.h:27
SG::VarHandleKey::key
const std::string & key() const
Return the StoreGate ID for the referenced object.
Definition: AthToolSupport/AsgDataHandles/Root/VarHandleKey.cxx:141
LArAutoCorrTotal
Definition: LArAutoCorrTotal.h:19
HWIdentifier
Definition: HWIdentifier.h:13
CaloGain::LARNGAIN
@ LARNGAIN
Definition: CaloGain.h:19
LArOnlineID_Base::channel_end
id_iterator channel_end() const
Definition: LArOnlineID_Base.cxx:1931
LArAutoCorrTotal::autoCorrTotal
const std::vector< double > autoCorrTotal(const IdentifierHash &hid, int gain, float Nminbias) const
Definition: LArAutoCorrTotal.cxx:58
xAOD::unsigned
unsigned
Definition: RingSetConf_v1.cxx:662
AthenaPoolTestRead.sc
sc
Definition: AthenaPoolTestRead.py:27
AthCommonDataStore< AthCommonMsg< Algorithm > >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
The standard StoreGateSvc/DetectorStore Returns (kind of) a pointer to the StoreGateSvc.
Definition: AthCommonDataStore.h:95
MonDataType::AutoCorr
@ AutoCorr
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:92
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_MSG_DEBUG
#define ATH_MSG_DEBUG(x)
Definition: AthMsgStreamMacros.h:29
ClassID_traits
Default, invalid implementation of ClassID_traits.
Definition: Control/AthenaKernel/AthenaKernel/ClassID_traits.h:40
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
WriteCellNoiseToCool.igain
igain
Definition: WriteCellNoiseToCool.py:338
LArAutoCorrTotal::samplRMS
const std::vector< double > samplRMS(const IdentifierHash &hid, int gain, float Nminbias) const
Definition: LArAutoCorrTotal.cxx:90
LArAutoCorrComplete.h
AthAlgorithm
Definition: AthAlgorithm.h:47
LArAutoCorrAlgToDB::m_nGains
unsigned int m_nGains
Definition: LArAutoCorrAlgToDB.h:60
LArAutoCorrAlgToDB::~LArAutoCorrAlgToDB
~LArAutoCorrAlgToDB()
min
#define min(a, b)
Definition: cfImp.cxx:40
LArOnlineID_Base
Helper for the Liquid Argon Calorimeter cell identifiers.
Definition: LArOnlineID_Base.h:105
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
SG::CondHandleKey::initialize
StatusCode initialize(bool used=true)
LArOnlineID
Definition: LArOnlineID.h:20
LArAutoCorrAlgToDB::m_onlineHelper
const LArOnlineID_Base * m_onlineHelper
Definition: LArAutoCorrAlgToDB.h:47
LArOnline_SuperCellID
Definition: LArOnline_SuperCellID.h:20
LArAutoCorrAlgToDB::m_autocorrKey
SG::ReadCondHandleKey< LArAutoCorrTotal > m_autocorrKey
Definition: LArAutoCorrAlgToDB.h:51
CaloGain::CaloGain
CaloGain
Definition: CaloGain.h:11
DeMoScan.index
string index
Definition: DeMoScan.py:362
LArAutoCorrAlgToDB::m_nMinbias
float m_nMinbias
Definition: LArAutoCorrAlgToDB.h:62
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
LArAutoCorrAlgToDB::m_isSC
bool m_isSC
Definition: LArAutoCorrAlgToDB.h:49
CaloGain.h
FourMomUtils::dump
std::ostream & dump(std::ostream &out, const I4MomIter iBeg, const I4MomIter iEnd)
Helper to stream out a range of I4Momentum objects.
Definition: P4Dumper.h:24
LArAutoCorrAlgToDB::m_groupingType
std::string m_groupingType
Definition: LArAutoCorrAlgToDB.h:54
LArOnlineID_Base::channel_begin
id_iterator channel_begin() const
Returns an iterator pointing to a channel identifier collection.
Definition: LArOnlineID_Base.cxx:1926
fitman.k
k
Definition: fitman.py:528
LArAutoCorrAlgToDB::m_acContName
std::string m_acContName
Definition: LArAutoCorrAlgToDB.h:57
DiTauMassTools::TauTypes::ll
@ ll
Definition: PhysicsAnalysis/TauID/DiTauMassTools/DiTauMassTools/HelperFunctions.h:49