ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArCalibTools
src
LArPhysWaveFromTuple.cxx
Go to the documentation of this file.
1
/*
2
Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
*/
4
5
#include "
LArCalibTools/LArPhysWaveFromTuple.h
"
6
7
#include "
LArIdentifier/LArOnlineID.h
"
8
#include "
LArRawConditions/LArPhysWave.h
"
9
#include "
LArRawConditions/LArPhysWaveContainer.h
"
10
#include "
CaloIdentifier/CaloGain.h
"
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
LArPhysWaveFromTuple::~LArPhysWaveFromTuple
()
24
=
default
;
25
26
StatusCode
LArPhysWaveFromTuple::initialize
()
27
{
28
return
StatusCode::SUCCESS ;
29
}
30
31
32
StatusCode
LArPhysWaveFromTuple::stop
()
33
{
34
ATH_MSG_INFO
(
"... in stop()"
);
35
36
// get LArOnlineID helper
37
const
LArOnlineID
* onlineHelper =
nullptr
;
38
ATH_CHECK
(
detStore
()->retrieve(onlineHelper,
"LArOnlineID"
) );
39
40
TChain* outfit =
new
TChain(
m_ntuple_name
.value().c_str());
41
outfit->Add(
m_root_file_name
.value().c_str());
42
43
// This algorithm assumes the input NTuple in contains less than 2000
44
// points. If the NTuple contains less than 2000 points, the
45
// remaining points are automatically initialized to 0.
46
// Catch potential array index out of range error.
47
if
(
m_NPoints
> 2000 ) {
48
ATH_MSG_WARNING
(
" Too many points specified vs the expected content of the ntuple ! "
);
49
ATH_MSG_WARNING
(
" Only 2000 will be used !"
);
50
m_NPoints
= 2000;
51
}
52
53
// variable names as in the Ntuple
54
Int_t channelId;
55
UInt_t tIndex;
56
std::vector<Double_t> Amplitude(2000);
57
std::vector<Double_t> Time(2000);
58
outfit->SetBranchAddress(
"channelId"
, &channelId);
59
outfit->SetBranchAddress(
"timeIndex"
, &tIndex);
60
outfit->SetBranchAddress(
"Amplitude"
, Amplitude.data());
61
outfit->SetBranchAddress(
"Time"
, Time.data());
62
63
// Create new LArPhysWaveContainer
64
auto
larPhysWaveContainerNew = std::make_unique<LArPhysWaveContainer>();
65
ATH_CHECK
( larPhysWaveContainerNew->setGroupingType(
m_groupingType
,
msg
()) );
66
ATH_CHECK
( larPhysWaveContainerNew->initialize() );
67
68
// loop over entries in the Tuple, one entry = one channel
69
Long64_t nentries = outfit->GetEntries();
70
std::vector<double> wave(
m_NPoints
);
71
for
( Long64_t i = 0; i < nentries; i++ )
72
{
73
outfit->GetEvent(i);
74
HWIdentifier
id(channelId);
75
ATH_MSG_INFO
( std::hex <<
id
<< std::dec );
76
77
for
(
unsigned
int
i = 0; i <
m_NPoints
; i++ ) wave[i]=0.;
78
unsigned
int
skipped = 0;
79
unsigned
int
limit = tIndex<
m_NPoints
.value() ? tIndex :
m_NPoints
.value();
80
if
(
m_skipPoints
<
m_prefixPoints
) limit =
m_NPoints
.value() +
m_skipPoints
.value() -
m_prefixPoints
.value();
81
double
dt=Time[1]-Time[0];
82
for
(
unsigned
int
i = 0; i < limit; i++ )
83
{
84
if
(i>1 && Time[i] - Time[i-1] != dt) {
85
ATH_MSG_ERROR
(
"No equidistant time, could not process...."
);
86
return
StatusCode::FAILURE;
87
}
88
if
( skipped >=
m_skipPoints
)
89
{
90
wave[i-
m_skipPoints
+
m_prefixPoints
]=Amplitude[i];
91
}
92
else
skipped++;
93
}
94
95
LArPhysWave
newLArPhysWave(wave, dt,
m_flag
);
96
97
// Add physics wave to container
98
larPhysWaveContainerNew->setPdata(
id
, newLArPhysWave, (
CaloGain::CaloGain
)
m_gain
.value());
99
}
100
101
ATH_CHECK
(
detStore
()->record(std::move(larPhysWaveContainerNew),
m_store_key
) );
102
ATH_MSG_INFO
(
"LArPhysWaveFromTuple finalized!"
);
103
return
StatusCode::SUCCESS;
104
}
ATH_CHECK
#define ATH_CHECK
Evaluate an expression and check for errors.
Definition
AthCheckMacros.h:40
ATH_MSG_ERROR
#define ATH_MSG_ERROR(x)
Definition
AthMsgStreamMacros.h:33
ATH_MSG_INFO
#define ATH_MSG_INFO(x)
Definition
AthMsgStreamMacros.h:31
ATH_MSG_WARNING
#define ATH_MSG_WARNING(x)
Definition
AthMsgStreamMacros.h:32
CaloGain.h
LArOnlineID.h
LArPhysWaveContainer.h
LArPhysWaveFromTuple.h
LArPhysWave.h
AthCommonAlgorithm< Gaudi::Algorithm >::detStore
const ServiceHandle< StoreGateSvc > & detStore() const
Definition
AthCommonDataStore.h:95
AthCommonAlgorithm< Gaudi::Algorithm >::msg
MsgStream & msg() const
Definition
AthCommonMsg.h:24
HWIdentifier
Definition
HWIdentifier.h:13
LArOnlineID
Definition
LArOnlineID.h:21
LArPhysWaveFromTuple::m_root_file_name
Gaudi::Property< std::string > m_root_file_name
input file name
Definition
LArPhysWaveFromTuple.h:48
LArPhysWaveFromTuple::m_flag
Gaudi::Property< unsigned int > m_flag
flag for the PhysWave container
Definition
LArPhysWaveFromTuple.h:46
LArPhysWaveFromTuple::m_NPoints
Gaudi::Property< unsigned int > m_NPoints
max number of points of the waveform in the ntuple
Definition
LArPhysWaveFromTuple.h:40
LArPhysWaveFromTuple::~LArPhysWaveFromTuple
virtual ~LArPhysWaveFromTuple()
LArPhysWaveFromTuple::initialize
virtual StatusCode initialize() override
Definition
LArPhysWaveFromTuple.cxx:26
LArPhysWaveFromTuple::m_store_key
Gaudi::Property< std::string > m_store_key
key of the PhysWave collection in Storegate
Definition
LArPhysWaveFromTuple.h:52
LArPhysWaveFromTuple::m_ntuple_name
Gaudi::Property< std::string > m_ntuple_name
ntuple name
Definition
LArPhysWaveFromTuple.h:50
LArPhysWaveFromTuple::m_groupingType
Gaudi::Property< std::string > m_groupingType
Grouping type. Default is Feedthrough.
Definition
LArPhysWaveFromTuple.h:54
LArPhysWaveFromTuple::m_gain
Gaudi::Property< int > m_gain
Definition
LArPhysWaveFromTuple.h:56
LArPhysWaveFromTuple::stop
virtual StatusCode stop() override
Definition
LArPhysWaveFromTuple.cxx:32
LArPhysWaveFromTuple::m_skipPoints
Gaudi::Property< unsigned int > m_skipPoints
the first m_skipPoints points of the waveform in the ntuple are skipped
Definition
LArPhysWaveFromTuple.h:42
LArPhysWaveFromTuple::m_prefixPoints
Gaudi::Property< unsigned int > m_prefixPoints
make a PhysWave with the first m_prefixPoints as zeros
Definition
LArPhysWaveFromTuple.h:44
LArPhysWave
Definition
LArPhysWave.h:14
CaloGain::CaloGain
CaloGain
Definition
CaloGain.h:11
Generated on
for ATLAS Offline Software by
1.17.0