ATLAS Offline Software
LArMphysOverMcalFromTuple.cxx
Go to the documentation of this file.
1 /*
2  Copyright (C) 2002-2021 CERN for the benefit of the ATLAS collaboration
3 */
4 
6 
11 
12 #include "TFile.h"
13 #include "TBranch.h"
14 #include "TTree.h"
15 #include "TChain.h"
16 
17 #include <vector>
18 #include <iostream>
19 #include <fstream>
20 #include <string>
21 
22 
23 LArMphysOverMcalFromTuple::LArMphysOverMcalFromTuple (const std::string& name, ISvcLocator* pSvcLocator) : AthAlgorithm(name, pSvcLocator)
24 {
25  declareProperty("FileNames", m_root_file_names);
26  declareProperty("StoreKey", m_store_key="FROMTUPLE");
27 }
28 
30 = default;
31 
33 {
34  return StatusCode::SUCCESS ;
35 }
36 
37 
39 {
40  ATH_MSG_INFO ( "... in finalize()" );
41 
42  // get LArOnlineID helper
43  const LArOnlineID* onlineHelper = nullptr;
44  ATH_CHECK( detStore()->retrieve(onlineHelper, "LArOnlineID") );
45 
46  TChain* outfit = new TChain("outfit");
47  for (const std::string& s : m_root_file_names) {
48  outfit->Add(s.c_str());
49  }
50 
51  // variable names as in the Ntuple
52  Int_t BarAC; // 0 = barrel C 1 = barrel A
53  Int_t FT; // feedthrough 0 - 31
54  Int_t Channel; // 0 - 14
55  Int_t Slot; // 1 -14
56  Double_t PhysOCal; // Mphys/Mcal
57  int gain = 0; // LARHIGHGAIN = 0, LARMEDIUMGAIN = 1, LARLOWGAIN = 2,
58 
59  outfit->SetBranchAddress("Channel", &Channel);
60  outfit->SetBranchAddress("Slot", &Slot);
61  outfit->SetBranchAddress("FT", &FT);
62  outfit->SetBranchAddress("BarAC", &BarAC);
63  outfit->SetBranchAddress("PhysOCal", &PhysOCal);
64 
65 
66  // Create new LArMphysOverMcalComplete
68 // container->setGroupingType(LArConditionsContainerBase::FeedThroughGrouping);
69  container->setGroupingType(LArConditionsContainerBase::ExtendedFTGrouping);
70  ATH_CHECK( container->initialize() );
71 
72 
73 
74 
75  // loop over entries in the Tuple, one entry = one channel
76  Long64_t nentries = outfit->GetEntries();
77  for ( Int_t i = 0; i < nentries; i++ )
78  {
79  outfit->GetEntry(i);
80  HWIdentifier id = onlineHelper->channel_Id(0, BarAC, FT, Slot, Channel);
81  container->set(id,gain,PhysOCal);
82  }
83 
84 
85  // store
86  ATH_CHECK( detStore()->record(container,m_store_key) );
87  // Symlink LArMphysOverMcalComplete to ILArMphysOverMcal for further use
88  ILArMphysOverMcal *larMphysOverMcal = nullptr;
89  ATH_CHECK( detStore()->symLink(container,larMphysOverMcal) );
90 
91  ATH_MSG_INFO ( "LArMphysOverMcalyFromTuple finalized!" );
92 
93  return StatusCode::SUCCESS;
94 }
LArMphysOverMcalComplete::set
void set(const HWIdentifier &CellID, int gain, float vMphysOverMcal)
Definition: LArMphysOverMcalComplete.cxx:14
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
LArBadChanBlobUtils::Channel
Identifier32::value_type Channel
Definition: LArBadChanBlobUtils.h:24
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
LArMphysOverMcalFromTuple::m_store_key
std::string m_store_key
key of the PhysWave collection in StoreGate
Definition: LArMphysOverMcalFromTuple.h:52
HWIdentifier
Definition: HWIdentifier.h:13
ILArMphysOverMcal.h
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
LArMphysOverMcalFromTuple::stop
StatusCode stop()
Definition: LArMphysOverMcalFromTuple.cxx:38
PlotCalibFromCool.nentries
nentries
Definition: PlotCalibFromCool.py:798
LArMphysOverMcalComplete
This class implements the ILArMphysOverMcal interface.
Definition: LArMphysOverMcalComplete.h:29
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
LArMphysOverMcalFromTuple::m_root_file_names
std::vector< std::string > m_root_file_names
list of input ntuple file names
Definition: LArMphysOverMcalFromTuple.h:49
LArOnlineID_Base::channel_Id
HWIdentifier channel_Id(int barrel_ec, int pos_neg, int feedthrough, int slot, int channel) const
create channel identifier from fields
Definition: LArOnlineID_Base.cxx:1569
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
AthAlgorithm
Definition: AthAlgorithm.h:47
ILArMphysOverMcal
Definition: ILArMphysOverMcal.h:13
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
LArMphysOverMcalFromTuple::initialize
StatusCode initialize()
implements IAlgorithm::initialize()
Definition: LArMphysOverMcalFromTuple.cxx:32
LArOnlineID
Definition: LArOnlineID.h:20
LArConditionsContainerBase::ExtendedFTGrouping
@ ExtendedFTGrouping
Definition: LArConditionsContainerBase.h:49
LArMphysOverMcalFromTuple::~LArMphysOverMcalFromTuple
~LArMphysOverMcalFromTuple()
LArNewCalib_Delay_OFC_Cali.FT
FT
Definition: LArNewCalib_Delay_OFC_Cali.py:120
LArConditionsContainer::initialize
virtual StatusCode initialize()
Initialization done after creation or read back - derived classes may augment the functionality.
LArMphysOverMcalFromTuple.h
LArMphysOverMcalComplete.h
CaloGain.h
LArMphysOverMcalFromTuple::LArMphysOverMcalFromTuple
LArMphysOverMcalFromTuple(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArMphysOverMcalFromTuple.cxx:23
LArOnlineID.h