ATLAS Offline Software
Loading...
Searching...
No Matches
LArOFCBin_PhysCaliTdiffFromStdNtuple.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2024 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
23LArOFCBin_PhysCaliTdiffFromStdNtuple::LArOFCBin_PhysCaliTdiffFromStdNtuple (const std::string& name, ISvcLocator* pSvcLocator) : AthAlgorithm(name, pSvcLocator)
24{
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 auto larOFCParams = std::make_unique<LArOFCBinComplete>();
77 ATH_CHECK ( larOFCParams->setGroupingType(m_groupingType, msg()) );
78 ATH_CHECK ( larOFCParams->initialize() );
79 auto larTdiffParams = std::make_unique<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(std::move(larOFCParams),m_store_key_ofcbin) );
113 }
114
115 if(m_filltdiff) {
116 ATH_CHECK( detStore()->record(larTdiffParams.get(),m_store_key_tdiff) );
117 // and symlink
118 ILArPhysCaliTdiff *ilarTdiff = nullptr;
119 ATH_CHECK( detStore()->symLink(larTdiffParams.release(),ilarTdiff) );
120 }
121
122
123 ATH_MSG_INFO ( "LArOFCBin_PhysCaliTdiffFromStdNtuple finalized!" );
124 return StatusCode::SUCCESS;
125}
#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
std::string m_groupingType
Grouping type. Default is Feedthrough.
std::string m_store_key_tdiff
key of the PhysCaliTdiff collection in Storegate
std::string m_store_key_ofcbin
key of the OFCBin collection in Storegate
StatusCode initialize()
implements IAlgorithm::initialize()
LArOFCBin_PhysCaliTdiffFromStdNtuple(const std::string &name, ISvcLocator *pSvcLocator)
std::vector< std::string > m_root_file_names
list of input ntuple file names
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.