ATLAS Offline Software
LArOFCBin_PhysCaliTdiffFromStdNtuple.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 LArOFCBin_PhysCaliTdiffFromStdNtuple::LArOFCBin_PhysCaliTdiffFromStdNtuple (const std::string& name, ISvcLocator* pSvcLocator) : AthAlgorithm(name, pSvcLocator)
24 {
25  declareProperty("FileNames", m_root_file_names);
26  declareProperty("NtupleName", m_ntuple_name="PARAMS");
27  declareProperty("Store_OFC", m_fillofc=false);
28  declareProperty("StoreKey_OFC", m_store_key_ofcbin="LArOFC");
29  declareProperty("Store_Tdiff", m_filltdiff=false);
30  declareProperty("StoreKey_Tdiff", m_store_key_tdiff="LArPhysCaliTdiff");
31  declareProperty("GroupingType", m_groupingType="FeedThrough");
32 }
33 
35 = default;
36 
38 {
39  return StatusCode::SUCCESS ;
40 }
41 
42 
44 {
45  ATH_MSG_INFO ( "... in stop()" );
46 
47  const LArOnlineID* onlineHelper = nullptr;
48  ATH_CHECK( detStore()->retrieve(onlineHelper, "LArOnlineID") );
49 
50  TChain* outfit = new TChain(m_ntuple_name.c_str());
51  for (const std::string& s : m_root_file_names) {
52  outfit->Add(s.c_str());
53  }
54 
55 
56  Int_t channelId;
57  Int_t FT, slot, channel;
58  Int_t bin;
59  Double_t tdiff;
60 
61 
62  Int_t gain = 0; // LARHIGHGAIN = 0, LARMEDIUMGAIN = 1, LARLOWGAIN = 2,
63  outfit->SetBranchAddress("channelId", &channelId);
64  outfit->SetBranchAddress("FT", &FT);
65  outfit->SetBranchAddress("slot", &slot);
66  outfit->SetBranchAddress("channel", &channel);
67  outfit->SetBranchAddress("gain", &gain);
68  if(m_filltdiff) {
69  outfit->SetBranchAddress("Tdiff", &tdiff);
70  }
71  if(m_fillofc) {
72  outfit->SetBranchAddress("OFCBin", &bin);
73  }
74 
75  // Create new objects
76  LArOFCBinComplete *larOFCParams = new LArOFCBinComplete();
77  ATH_CHECK ( larOFCParams->setGroupingType(m_groupingType, msg()) );
78  ATH_CHECK ( larOFCParams->initialize() );
79  LArPhysCaliTdiffComplete *larTdiffParams = new LArPhysCaliTdiffComplete();
80  ATH_CHECK ( larTdiffParams->setGroupingType(m_groupingType, msg()) );
81  ATH_CHECK ( larTdiffParams->initialize() );
82 
83 
84  unsigned int hwid;
85  //unsigned int uflag;
86  // loop over entries in the Tuple, one entry = one channel
87  Long64_t nentries = outfit->GetEntries();
88  for ( Long64_t i = 0; i < nentries; i++ )
89  {
90  outfit->GetEvent(i);
91  ATH_MSG_INFO ( " Chan " << std::hex << channelId << std::dec );
92  ATH_MSG_INFO ( bin << " | " << tdiff );
93  hwid = channelId;
94  HWIdentifier id(hwid);
95  if(FT != onlineHelper->feedthrough(id) || slot != onlineHelper->slot(id) || channel != onlineHelper->channel(id)) {
96  ATH_MSG_ERROR ( "Inconsistency in decoding HWID !!!!" );
97  ATH_MSG_ERROR ( FT << " - " << onlineHelper->feedthrough(id) );
98  ATH_MSG_ERROR ( slot << " - " << onlineHelper->slot(id) );
99  ATH_MSG_ERROR ( channel << " - " << onlineHelper->channel(id) );
100  ATH_MSG_ERROR ( "Not creating PhysWave !!!!" );
101  continue;
102  }
103 
104  // Add to objects
105  if(m_fillofc) larOFCParams->set(id,gain,bin);
106  if(m_filltdiff) larTdiffParams->set(id,gain,tdiff);
107  }
108 
109 
110  // store
111  if(m_fillofc) {
112  ATH_CHECK( detStore()->record(larOFCParams,m_store_key_ofcbin) );
113  }
114 
115  if(m_filltdiff) {
116  ATH_CHECK( detStore()->record(larTdiffParams,m_store_key_tdiff) );
117  }
118 
119  // and symlink
120 
121  if(m_filltdiff) {
122  ILArPhysCaliTdiff *ilarTdiff = nullptr;
123  ATH_CHECK( detStore()->symLink(larTdiffParams,ilarTdiff) );
124  }
125 
126 
127  ATH_MSG_INFO ( "LArOFCBin_PhysCaliTdiffFromStdNtuple finalized!" );
128  return StatusCode::SUCCESS;
129 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
LArOFCBin_PhysCaliTdiffFromStdNtuple::stop
StatusCode stop()
Definition: LArOFCBin_PhysCaliTdiffFromStdNtuple.cxx:43
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
LArOFCBin_PhysCaliTdiffFromStdNtuple::m_fillofc
bool m_fillofc
Definition: LArOFCBin_PhysCaliTdiffFromStdNtuple.h:39
LArOFCBin_PhysCaliTdiffFromStdNtuple::m_root_file_names
std::vector< std::string > m_root_file_names
list of input ntuple file names
Definition: LArOFCBin_PhysCaliTdiffFromStdNtuple.h:34
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:28
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
LArOFCBin_PhysCaliTdiffFromStdNtuple::LArOFCBin_PhysCaliTdiffFromStdNtuple
LArOFCBin_PhysCaliTdiffFromStdNtuple(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArOFCBin_PhysCaliTdiffFromStdNtuple.cxx:23
LArOFCBin_PhysCaliTdiffFromStdNtuple::m_store_key_tdiff
std::string m_store_key_tdiff
key of the PhysCaliTdiff collection in Storegate
Definition: LArOFCBin_PhysCaliTdiffFromStdNtuple.h:41
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
LArOFCBin_PhysCaliTdiffFromStdNtuple::m_filltdiff
bool m_filltdiff
Definition: LArOFCBin_PhysCaliTdiffFromStdNtuple.h:42
LArOnlineID_Base::slot
int slot(const HWIdentifier id) const
Return the slot number of a hardware cell identifier: slot = [1,15] Slot-ID in top part of the crat...
Definition: LArOnlineID_Base.cxx:1961
bin
Definition: BinsDiffFromStripMedian.h:43
LArOFCBin_PhysCaliTdiffFromStdNtuple::m_ntuple_name
std::string m_ntuple_name
ntuple name
Definition: LArOFCBin_PhysCaliTdiffFromStdNtuple.h:36
HWIdentifier
Definition: HWIdentifier.h:13
LArOFCBin_PhysCaliTdiffFromStdNtuple::initialize
StatusCode initialize()
implements IAlgorithm::initialize()
Definition: LArOFCBin_PhysCaliTdiffFromStdNtuple.cxx:37
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
LArOFCBin_PhysCaliTdiffFromStdNtuple::~LArOFCBin_PhysCaliTdiffFromStdNtuple
~LArOFCBin_PhysCaliTdiffFromStdNtuple()
PlotCalibFromCool.nentries
nentries
Definition: PlotCalibFromCool.py:798
LArOnlineID_Base::channel
int channel(const HWIdentifier id) const
Return the channel number of a hardware cell identifier channel = [0,127] in all FEB.
Definition: LArOnlineID_Base.cxx:1967
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
LArOFCBin_PhysCaliTdiffFromStdNtuple.h
LArOFCBinComplete.h
lumiFormat.i
int i
Definition: lumiFormat.py:92
LArPhysCaliTdiffComplete
This class implements the ILArPhysCaliTdiff interface ` *.
Definition: LArPhysCaliTdiffComplete.h:22
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
LArOFCBinComplete
Definition: LArOFCBinComplete.h:13
CaloCondBlobAlgs_fillNoiseFromASCII.channelId
channelId
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:122
AthAlgorithm
Definition: AthAlgorithm.h:47
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:194
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
plotBeamSpotVxVal.bin
int bin
Definition: plotBeamSpotVxVal.py:83
LArOFCBin_PhysCaliTdiffFromStdNtuple::m_groupingType
std::string m_groupingType
Grouping type. Default is Feedthrough.
Definition: LArOFCBin_PhysCaliTdiffFromStdNtuple.h:44
LArOnlineID
Definition: LArOnlineID.h:20
LArNewCalib_Delay_OFC_Cali.FT
FT
Definition: LArNewCalib_Delay_OFC_Cali.py:120
ILArPhysCaliTdiff
Definition: ILArPhysCaliTdiff.h:13
LArOnlineID_Base::feedthrough
int feedthrough(const HWIdentifier id) const
Return the feedthrough of a hardware cell identifier : feedthrough = [0,31] Barrel - A/C side or H/...
Definition: LArOnlineID_Base.cxx:1948
LArConditionsContainer::initialize
virtual StatusCode initialize()
Initialization done after creation or read back - derived classes may augment the functionality.
AthCommonMsg< Algorithm >::msg
MsgStream & msg() const
Definition: AthCommonMsg.h:24
LArOFCBin_PhysCaliTdiffFromStdNtuple::m_store_key_ofcbin
std::string m_store_key_ofcbin
key of the OFCBin collection in Storegate
Definition: LArOFCBin_PhysCaliTdiffFromStdNtuple.h:38
LArPhysCaliTdiffComplete.h
LArOFCBinComplete::set
void set(const HWIdentifier &chid, const int &gain, const int &bin)
Definition: LArOFCBinComplete.cxx:11
CaloGain.h
LArPhysCaliTdiffComplete::set
void set(const HWIdentifier &CellID, int gain, float tdiff)
Definition: LArPhysCaliTdiffComplete.cxx:27
LArOnlineID.h