ATLAS Offline Software
LArCalibCopyAlg.icc
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2017 CERN for the benefit of the ATLAS collaboration
3 */
4 
5 //Dear emacs, this is -*-c++-*-
6 
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)
12  {
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");
18 
19 }
20 
21 template<class CONDITIONSCONTAINER>
22 LArCalibCopyAlg<CONDITIONSCONTAINER>::~LArCalibCopyAlg() {
23 }
24 
25 
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 );
31 
32  return StatusCode::SUCCESS;
33 }
34 
35 
36 template<class CONDITIONSCONTAINER>
37 StatusCode LArCalibCopyAlg<CONDITIONSCONTAINER>::stop() {
38  ATH_MSG_INFO ( "Entering LArCalibCopyAlg" );
39 
40  const CONDITIONSCONTAINER* input = nullptr;
41  ATH_CHECK( detStore()->retrieve(input,m_inputName) );
42 
43  auto output = std::make_unique<CONDITIONSCONTAINER>();
44  ATH_CHECK( output->setGroupingType(m_groupingType,(msg())) );
45  ATH_CHECK( output->initialize() );
46 
47  ATH_MSG_INFO ( "Loaded input container " << m_inputName
48  << ", write to new container " << m_outputName );
49 
50 
51  //Start copying data ...
52 
53  unsigned nDataChans=0;
54 
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);
62  ++nDataChans;
63  }//end loop over channels
64 
65  } // end loop over gains
66 
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
77  ++nCorrChans;
78  } //end loop over gains
79 
80 
81  ATH_MSG_INFO ( "Copied " << nDataChans << " data channels and " << nCorrChans << " correction channels from container '"
82  << m_inputName << "' to container '" << m_outputName << "'" );
83 
84  ATH_CHECK( detStore()->record(std::move(output),m_outputName) );
85 
86  return StatusCode::SUCCESS;
87 }
88 
89