ATLAS Offline Software
Loading...
Searching...
No Matches
LArOFCBin_PhysCaliTdiffFromStdNtuple.cxx
Go to the documentation of this file.
1/*
2 Copyright (C) 2002-2026 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
24
26{
27 return StatusCode::SUCCESS ;
28}
29
30
32{
33 ATH_MSG_INFO ( "... in stop()" );
34
35 const LArOnlineID* onlineHelper = nullptr;
36 ATH_CHECK( detStore()->retrieve(onlineHelper, "LArOnlineID") );
37
38 TChain* outfit = new TChain(m_ntuple_name.value().c_str());
39 for (const std::string& s : m_root_file_names) {
40 outfit->Add(s.c_str());
41 }
42
43
44 Int_t channelId{};
45 Int_t FT{}, slot{}, channel{};
46 Int_t bin{};
47 Double_t tdiff{};
48
49
50 Int_t gain = 0; // LARHIGHGAIN = 0, LARMEDIUMGAIN = 1, LARLOWGAIN = 2,
51 outfit->SetBranchAddress("channelId", &channelId);
52 outfit->SetBranchAddress("FT", &FT);
53 outfit->SetBranchAddress("slot", &slot);
54 outfit->SetBranchAddress("channel", &channel);
55 outfit->SetBranchAddress("gain", &gain);
56 if(m_filltdiff) {
57 outfit->SetBranchAddress("Tdiff", &tdiff);
58 }
59 if(m_fillofc) {
60 outfit->SetBranchAddress("OFCBin", &bin);
61 }
62
63 // Create new objects
64 auto larOFCParams = std::make_unique<LArOFCBinComplete>();
65 ATH_CHECK ( larOFCParams->setGroupingType(m_groupingType, msg()) );
66 ATH_CHECK ( larOFCParams->initialize() );
67 auto larTdiffParams = std::make_unique<LArPhysCaliTdiffComplete>();
68 ATH_CHECK ( larTdiffParams->setGroupingType(m_groupingType, msg()) );
69 ATH_CHECK ( larTdiffParams->initialize() );
70
71
72 unsigned int hwid{};
73 //unsigned int uflag;
74 // loop over entries in the Tuple, one entry = one channel
75 Long64_t nentries = outfit->GetEntries();
76 for ( Long64_t i = 0; i < nentries; i++ )
77 {
78 outfit->GetEvent(i);
79 ATH_MSG_INFO ( " Chan " << std::hex << channelId << std::dec );
80 ATH_MSG_INFO ( bin << " | " << tdiff );
81 hwid = channelId;
82 HWIdentifier id(hwid);
83 if(FT != onlineHelper->feedthrough(id) || slot != onlineHelper->slot(id) || channel != onlineHelper->channel(id)) {
84 ATH_MSG_ERROR ( "Inconsistency in decoding HWID !!!!" );
85 ATH_MSG_ERROR ( FT << " - " << onlineHelper->feedthrough(id) );
86 ATH_MSG_ERROR ( slot << " - " << onlineHelper->slot(id) );
87 ATH_MSG_ERROR ( channel << " - " << onlineHelper->channel(id) );
88 ATH_MSG_ERROR ( "Not creating PhysWave !!!!" );
89 continue;
90 }
91
92 // Add to objects
93 if(m_fillofc) larOFCParams->set(id,gain,bin);
94 if(m_filltdiff) larTdiffParams->set(id,gain,tdiff);
95 }
96
97
98 // store
99 if(m_fillofc) {
100 ATH_CHECK( detStore()->record(std::move(larOFCParams),m_store_key_ofcbin) );
101 }
102
103 if(m_filltdiff) {
104 ATH_CHECK( detStore()->record(larTdiffParams.get(),m_store_key_tdiff) );
105 // and symlink
106 ILArPhysCaliTdiff *ilarTdiff = nullptr;
107 ATH_CHECK( detStore()->symLink(larTdiffParams.release(),ilarTdiff) );
108 }
109
110
111 ATH_MSG_INFO ( "LArOFCBin_PhysCaliTdiffFromStdNtuple finalized!" );
112 return StatusCode::SUCCESS;
113}
#define ATH_CHECK
Evaluate an expression and check for errors.
#define ATH_MSG_ERROR(x)
#define ATH_MSG_INFO(x)
const ServiceHandle< StoreGateSvc > & detStore() const
StringProperty m_store_key_tdiff
key of the PhysCaliTdiff collection in Storegate
StringProperty m_groupingType
Grouping type. Default is Feedthrough.
StringArrayProperty m_root_file_names
list of input ntuple file names
virtual StatusCode initialize() override
implements IAlgorithm::initialize()
StringProperty m_store_key_ofcbin
key of the OFCBin collection in Storegate
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.