ATLAS Offline Software
Loading...
Searching...
No Matches
LArParamsFromStdNtuple.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= default;
25
27{
28 ATH_MSG_INFO ( "... in stop()" );
29
30 // get LArOnlineID helper
31 const LArOnlineID* onlineHelper = nullptr;
32 ATH_CHECK( detStore()->retrieve(onlineHelper, "LArOnlineID") );
33
34 TChain* outfit = new TChain(m_ntuple_name.value().c_str());
35 for (const std::string& s : m_root_file_names) {
36 outfit->Add(s.c_str());
37 }
38
39
40 Int_t channelId;
41 Int_t FT, slot, channel;
42 Double_t Tcal;
43 Double_t Fstep;
44 Double_t Offset;
45 Double_t dTimeCal;
46 Int_t nCB;
47 Double_t Omega0;
48 Double_t Taur;
49
50
51 Int_t gain = 0; // LARHIGHGAIN = 0, LARMEDIUMGAIN = 1, LARLOWGAIN = 2,
52 outfit->SetBranchAddress("channelId", &channelId);
53 outfit->SetBranchAddress("FT", &FT);
54 outfit->SetBranchAddress("slot", &slot);
55 outfit->SetBranchAddress("channel", &channel);
56 outfit->SetBranchAddress("gain", &gain);
57 outfit->SetBranchAddress("Tcal", &Tcal);
58 outfit->SetBranchAddress("Fstep", &Fstep);
59 outfit->SetBranchAddress("Offset", &Offset);
60 outfit->SetBranchAddress("dTimeCal", &dTimeCal);
61 outfit->SetBranchAddress("nCB", &nCB);
62 outfit->SetBranchAddress("Omega0", &Omega0);
63 outfit->SetBranchAddress("Taur", &Taur);
64
65 // Create new objects
66 auto larCaliPulseParams = std::make_unique<LArCaliPulseParamsComplete>();
67 ATH_CHECK ( larCaliPulseParams->setGroupingType(m_groupingType, msg()) );
68 ATH_CHECK ( larCaliPulseParams->initialize() );
69 auto larDetCellParams = std::make_unique<LArDetCellParamsComplete>();
70 ATH_CHECK ( larDetCellParams->setGroupingType(m_groupingType, msg()) );
71 ATH_CHECK ( larDetCellParams->initialize() );
72
73
74 unsigned int hwid;
75 //unsigned int uflag;
76 // loop over entries in the Tuple, one entry = one channel
77 Long64_t nentries = outfit->GetEntries();
78 for ( Long64_t i = 0; i < nentries; i++ )
79 {
80 outfit->GetEvent(i);
81 ATH_MSG_INFO ( " Chan " << std::hex << channelId << std::dec );
82 hwid = channelId;
83 HWIdentifier id(hwid);
84 if(FT != onlineHelper->feedthrough(id) || slot != onlineHelper->slot(id) || channel != onlineHelper->channel(id)) {
85 ATH_MSG_ERROR ( "Inconsistency in decoding HWID !!!!" );
86 ATH_MSG_ERROR ( FT << " - " << onlineHelper->feedthrough(id) );
87 ATH_MSG_ERROR ( slot << " - " << onlineHelper->slot(id) );
88 ATH_MSG_ERROR ( channel << " - " << onlineHelper->channel(id) );
89 ATH_MSG_ERROR ( "Not creating PhysWave !!!!" );
90 continue;
91 }
92
93 // Add to objects
94 larCaliPulseParams->set(id,gain,Tcal,Fstep,Offset,dTimeCal,nCB);
95 larDetCellParams->set(id,gain,Omega0,Taur);
96 }
97
98 ATH_CHECK( detStore()->record(std::move(larCaliPulseParams),m_store_key_cali) );
99 ATH_CHECK( detStore()->record(std::move(larDetCellParams),m_store_key_det) );
100
101 ATH_MSG_INFO ( "LArParamsFromStdNtuple stopped!" );
102 return StatusCode::SUCCESS;
103}
#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
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.
virtual StatusCode stop() override
IAlgorithm::stop() : Where the action takes place...
StringProperty m_groupingType
Grouping type. Default is Feedthrough.
StringProperty m_store_key_cali
key of the CaliPulseParams collection in Storegate
virtual ~LArParamsFromStdNtuple()
StringProperty m_store_key_det
key of the DetCellParams collection in Storegate
StringProperty m_ntuple_name
ntuple name
StringArrayProperty m_root_file_names
list of input ntuple file names