ATLAS Offline Software
LArParamsFromStdNtuple.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 LArParamsFromStdNtuple::LArParamsFromStdNtuple (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("StoreKey_Cali", m_store_key_cali="FromStdNtuple");
28  declareProperty("StoreKey_Det", m_store_key_det="FromStdNtuple");
29  declareProperty("GroupingType", m_groupingType="FeedThrough");
30 }
31 
33 = default;
34 
36 {
37  return StatusCode::SUCCESS ;
38 }
39 
40 
42 {
43  ATH_MSG_INFO ( "... in stop()" );
44 
45  // get LArOnlineID helper
46  const LArOnlineID* onlineHelper = nullptr;
47  ATH_CHECK( detStore()->retrieve(onlineHelper, "LArOnlineID") );
48 
49  TChain* outfit = new TChain(m_ntuple_name.c_str());
50  for (const std::string& s : m_root_file_names) {
51  outfit->Add(s.c_str());
52  }
53 
54 
55  Int_t channelId;
56  Int_t FT, slot, channel;
57  Double_t Tcal;
58  Double_t Fstep;
59  Double_t Offset;
60  Double_t dTimeCal;
61  Int_t nCB;
62  Double_t Omega0;
63  Double_t Taur;
64 
65 
66  Int_t gain = 0; // LARHIGHGAIN = 0, LARMEDIUMGAIN = 1, LARLOWGAIN = 2,
67  outfit->SetBranchAddress("channelId", &channelId);
68  outfit->SetBranchAddress("FT", &FT);
69  outfit->SetBranchAddress("slot", &slot);
70  outfit->SetBranchAddress("channel", &channel);
71  outfit->SetBranchAddress("gain", &gain);
72  outfit->SetBranchAddress("Tcal", &Tcal);
73  outfit->SetBranchAddress("Fstep", &Fstep);
74  outfit->SetBranchAddress("Offset", &Offset);
75  outfit->SetBranchAddress("dTimeCal", &dTimeCal);
76  outfit->SetBranchAddress("nCB", &nCB);
77  outfit->SetBranchAddress("Omega0", &Omega0);
78  outfit->SetBranchAddress("Taur", &Taur);
79 
80  // Create new objects
81  LArCaliPulseParamsComplete *larCaliPulseParams = new LArCaliPulseParamsComplete();
82  ATH_CHECK ( larCaliPulseParams->setGroupingType(m_groupingType, msg()) );
83  ATH_CHECK ( larCaliPulseParams->initialize() );
84  LArDetCellParamsComplete *larDetCellParams = new LArDetCellParamsComplete();
85  ATH_CHECK ( larDetCellParams->setGroupingType(m_groupingType, msg()) );
86  ATH_CHECK ( larDetCellParams->initialize() );
87 
88 
89  unsigned int hwid;
90  //unsigned int uflag;
91  // loop over entries in the Tuple, one entry = one channel
92  Long64_t nentries = outfit->GetEntries();
93  for ( Long64_t i = 0; i < nentries; i++ )
94  {
95  outfit->GetEvent(i);
96  ATH_MSG_INFO ( " Chan " << std::hex << channelId << std::dec );
97  hwid = channelId;
98  HWIdentifier id(hwid);
99  if(FT != onlineHelper->feedthrough(id) || slot != onlineHelper->slot(id) || channel != onlineHelper->channel(id)) {
100  ATH_MSG_ERROR ( "Inconsistency in decoding HWID !!!!" );
101  ATH_MSG_ERROR ( FT << " - " << onlineHelper->feedthrough(id) );
102  ATH_MSG_ERROR ( slot << " - " << onlineHelper->slot(id) );
103  ATH_MSG_ERROR ( channel << " - " << onlineHelper->channel(id) );
104  ATH_MSG_ERROR ( "Not creating PhysWave !!!!" );
105  continue;
106  }
107 
108  // Add to objects
109  larCaliPulseParams->set(id,gain,Tcal,Fstep,Offset,dTimeCal,nCB);
110  larDetCellParams->set(id,gain,Omega0,Taur);
111  }
112 
113  ATH_CHECK( detStore()->record(larCaliPulseParams,m_store_key_cali) );
114  ATH_CHECK( detStore()->record(larDetCellParams,m_store_key_det) );
115 
116  // and symlink
117  ILArCaliPulseParams *ilarCaliPulse = nullptr;
118  ATH_CHECK( detStore()->symLink(larCaliPulseParams,ilarCaliPulse) );
119 
120  ILArDetCellParams *ilarDetCell = nullptr;
121  ATH_CHECK( detStore()->symLink(larDetCellParams,ilarDetCell) );
122 
123  ATH_MSG_INFO ( "LArParamsFromStdNtuple finalized!" );
124  return StatusCode::SUCCESS;
125 }
python.PyKernel.retrieve
def retrieve(aClass, aKey=None)
Definition: PyKernel.py:110
LArDetCellParamsComplete.h
LArParamsFromStdNtuple::LArParamsFromStdNtuple
LArParamsFromStdNtuple(const std::string &name, ISvcLocator *pSvcLocator)
Definition: LArParamsFromStdNtuple.cxx:23
python.SystemOfUnits.s
int s
Definition: SystemOfUnits.py:131
plotting.yearwise_efficiency.channel
channel
Definition: yearwise_efficiency.py:24
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition: AthMsgStreamMacros.h:31
LArDetCellParamsComplete::set
void set(const HWIdentifier &CellID, int gain, float omega0, float taur)
Definition: LArDetCellParamsComplete.cxx:12
LArParamsFromStdNtuple::~LArParamsFromStdNtuple
~LArParamsFromStdNtuple()
AthCommonDataStore< AthCommonMsg< Algorithm > >::declareProperty
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T > &t)
Definition: AthCommonDataStore.h:145
ILArDetCellParams
Definition: ILArDetCellParams.h:13
CaloCondBlobAlgs_fillNoiseFromASCII.gain
gain
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:110
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:1957
LArParamsFromStdNtuple::initialize
StatusCode initialize()
implements IAlgorithm::initialize()
Definition: LArParamsFromStdNtuple.cxx:35
HWIdentifier
Definition: HWIdentifier.h:13
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
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:1963
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition: AthMsgStreamMacros.h:33
lumiFormat.i
int i
Definition: lumiFormat.py:85
EL::StatusCode
::StatusCode StatusCode
StatusCode definition for legacy code.
Definition: PhysicsAnalysis/D3PDTools/EventLoop/EventLoop/StatusCode.h:22
LArCaliPulseParamsComplete.h
ATH_CHECK
#define ATH_CHECK
Definition: AthCheckMacros.h:40
LArParamsFromStdNtuple.h
CaloCondBlobAlgs_fillNoiseFromASCII.channelId
channelId
Definition: CaloCondBlobAlgs_fillNoiseFromASCII.py:122
LArCaliPulseParamsComplete
This class implements the ILArCaliPulseParams interface.
Definition: LArCaliPulseParamsComplete.h:27
AthAlgorithm
Definition: AthAlgorithm.h:47
id
SG::auxid_t id
Definition: Control/AthContainers/Root/debug.cxx:220
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:221
LArParamsFromStdNtuple::m_store_key_cali
std::string m_store_key_cali
key of the CaliPulseParams collection in Storegate
Definition: LArParamsFromStdNtuple.h:45
LArOnlineID
Definition: LArOnlineID.h:20
LArCaliPulseParamsComplete::set
void set(const HWIdentifier &CellID, int gain, float tcal, float fstep)
Definition: LArCaliPulseParamsComplete.cxx:14
LArNewCalib_Delay_OFC_Cali.FT
FT
Definition: LArNewCalib_Delay_OFC_Cali.py:123
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:1944
LArParamsFromStdNtuple::stop
StatusCode stop()
Definition: LArParamsFromStdNtuple.cxx:41
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
LArParamsFromStdNtuple::m_ntuple_name
std::string m_ntuple_name
ntuple name
Definition: LArParamsFromStdNtuple.h:43
LArParamsFromStdNtuple::m_store_key_det
std::string m_store_key_det
key of the DetCellParams collection in Storegate
Definition: LArParamsFromStdNtuple.h:47
LArParamsFromStdNtuple::m_root_file_names
std::vector< std::string > m_root_file_names
list of input ntuple file names
Definition: LArParamsFromStdNtuple.h:41
CaloGain.h
LArParamsFromStdNtuple::m_groupingType
std::string m_groupingType
Grouping type. Default is Feedthrough.
Definition: LArParamsFromStdNtuple.h:49
ILArCaliPulseParams
Definition: ILArCaliPulseParams.h:14
LArOnlineID.h
LArDetCellParamsComplete
This class implements the ILArDetCellParams interface.
Definition: LArDetCellParamsComplete.h:24