2 Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
5 //Dear emacs, this is -*-c++-*-
7 template<class CONDITIONSCONTAINER>
8 LArCalibCopyAlg<CONDITIONSCONTAINER>::LArCalibCopyAlg (const std::string& name, ISvcLocator* pSvcLocator) :
9 AthAlgorithm(name,pSvcLocator),
10 m_groupingType("ExtendedSubDetector"),
11 m_useCorrChannel(true)
13 declareProperty("GroupingType", m_groupingType);
14 declareProperty("InputKey", m_inputName);
15 declareProperty("OutputKey", m_outputName);
16 declareProperty("UseCorrChannels", m_useCorrChannel,
17 "True: Use separate correction COOL channel, False: Correction + data in the same channel");
21 template<class CONDITIONSCONTAINER>
22 LArCalibCopyAlg<CONDITIONSCONTAINER>::~LArCalibCopyAlg() {
26 template<class CONDITIONSCONTAINER>
27 StatusCode LArCalibCopyAlg<CONDITIONSCONTAINER>::initialize() {
28 //Block correction application
29 bool setFlag = LArConditionsContainerBase::applyCorrectionsAtInit(true, false);
30 ATH_MSG_INFO ( "LArConditionsContainerBase::applyCorrectionsAtInit set to " << setFlag );
32 return StatusCode::SUCCESS;
36 template<class CONDITIONSCONTAINER>
37 StatusCode LArCalibCopyAlg<CONDITIONSCONTAINER>::stop() {
38 ATH_MSG_INFO ( "Entering LArCalibCopyAlg" );
40 const CONDITIONSCONTAINER* input = nullptr;
41 ATH_CHECK( detStore()->retrieve(input,m_inputName) );
43 auto output = std::make_unique<CONDITIONSCONTAINER>();
44 ATH_CHECK( output->setGroupingType(m_groupingType,(msg())) );
45 ATH_CHECK( output->initialize() );
47 ATH_MSG_INFO ( "Loaded input container " << m_inputName
48 << ", write to new container " << m_outputName );
51 //Start copying data ...
53 unsigned nDataChans=0;
55 for (unsigned igain=CaloGain::LARHIGHGAIN;igain<CaloGain::LARNGAIN ; ++igain ) {
56 CONTIT it=input->begin(igain);
57 CONTIT it_e=input->end(igain);
58 for (;it!=it_e;it++) {
59 const HWIdentifier chid = it.channelId();
60 const LArCondObj& payload=*it;
61 output->setPdata(chid,payload,igain);
63 }//end loop over channels
65 } // end loop over gains
67 //Same with correction channels:
68 unsigned nCorrChans=0;
69 for ( unsigned igain=CaloGain::LARHIGHGAIN;igain<CaloGain::LARNGAIN ; ++igain ) {
70 CORRIT it=input->undoCorrBegin(igain);
71 CORRIT it_e=input->undoCorrEnd(igain);
72 for (;it!=it_e;it++) {
73 const HWIdentifier chid(it->first);
74 const LArCondObj& payload=it->second;
75 ATH_CHECK( output->insertCorrection(chid,payload,igain,m_useCorrChannel) );
76 } // end loop over channels
78 } //end loop over gains
81 ATH_MSG_INFO ( "Copied " << nDataChans << " data channels and " << nCorrChans << " correction channels from container '"
82 << m_inputName << "' to container '" << m_outputName << "'" );
84 ATH_CHECK( detStore()->record(std::move(output),m_outputName) );
86 return StatusCode::SUCCESS;