ATLAS Offline Software
Loading...
Searching...
No Matches
LArParamsFromStdNtuple.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2025 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
23LArParamsFromStdNtuple::LArParamsFromStdNtuple (const std::string& name, ISvcLocator* pSvcLocator) : AthAlgorithm(name, pSvcLocator)
24{
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 auto larCaliPulseParams = std::make_unique<LArCaliPulseParamsComplete>();
82 ATH_CHECK ( larCaliPulseParams->setGroupingType(m_groupingType, msg()) );
83 ATH_CHECK ( larCaliPulseParams->initialize() );
84 auto larDetCellParams = std::make_unique<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(std::move(larCaliPulseParams),m_store_key_cali) );
114 ATH_CHECK( detStore()->record(std::move(larDetCellParams),m_store_key_det) );
115
116 ATH_MSG_INFO ( "LArParamsFromStdNtuple finalized!" );
117 return StatusCode::SUCCESS;
118}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
AthAlgorithm(const std::string &name, ISvcLocator *pSvcLocator)
Constructor with parameters:
Gaudi::Details::PropertyBase & declareProperty(Gaudi::Property< T, V, H > &t)
const ServiceHandle< StoreGateSvc > & detStore() const
MsgStream & msg() const
int feedthrough(const HWIdentifier id) const
Return the feedthrough of a hardware cell identifier : feedthrough = [0,31] Barrel - A/C side or H/...
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...
int channel(const HWIdentifier id) const
Return the channel number of a hardware cell identifier channel = [0,127] in all FEB.
std::string m_store_key_det
key of the DetCellParams collection in Storegate
std::string m_store_key_cali
key of the CaliPulseParams collection in Storegate
std::vector< std::string > m_root_file_names
list of input ntuple file names
StatusCode initialize()
implements IAlgorithm::initialize()
std::string m_ntuple_name
ntuple name
LArParamsFromStdNtuple(const std::string &name, ISvcLocator *pSvcLocator)
std::string m_groupingType
Grouping type. Default is Feedthrough.