ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
LArCalorimeter
LArSamplesMon
src
D3PDConverter.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 "
LArSamplesMon/D3PDConverter.h
"
6
7
#include "
LArCafJobs/DataStore.h
"
8
#include "
LArCafJobs/RunData.h
"
9
#include "
LArCafJobs/EventData.h
"
10
#include "
LArCafJobs/DataContainer.h
"
11
#include "
LArCafJobs/HistoryContainer.h
"
12
#include "
LArCafJobs/CellInfo.h
"
13
#include "
LArSamplesMon/Interface.h
"
14
#include "
LArSamplesMon/LArIdTranslatorHelper.h
"
15
16
#include "
Identifier/IdentifierHash.h
"
17
18
#include <iostream>
19
using
std::cout;
20
using
std::endl;
21
22
using namespace
LArSamples
;
23
24
D3PDConverter::D3PDConverter
(TTree&
tree
,
const
TString& templateFile,
const
TString& translatorFile)
25
:
CaloD3PDClass
(&
tree
)
26
{
27
initMapping
(templateFile, translatorFile);
28
}
29
30
D3PDConverter::~D3PDConverter
() =
default
;
31
32
bool
D3PDConverter::makeSamplesTuple
(
const
TString&
outputFileName
)
33
{
34
DataStore
* samples =
new
DataStore
();
35
RunData
* runData =
nullptr
;
36
37
cout <<
"Processing "
<<
fChain
->GetEntries() <<
" entries"
<< endl;
38
for
(
long
long
i = 0; i <
fChain
->GetEntries(); i++) {
39
if
(i % 500 == 0) cout <<
"Processing Entry "
<< i << endl;
40
fChain
->GetEntry(i);
41
if
(!runData || runData->
run
() != (
int
)
RunNumber
) {
42
// new run
43
runData =
new
RunData
(
RunNumber
);
44
samples->
addRun
(runData);
45
}
46
47
EventData
* eventData =
new
EventData
(
EventNumber
, 0,
lbn
,
bcid
);
48
eventData->
setRunData
(runData);
49
unsigned
int
eventIndex = samples->
addEvent
(eventData);
50
51
52
for
(
int
j = 0; j <
cc_sel_n
; j++) {
53
// skip Tile cells
54
if
((*
cc_sel_DetCells
)[j] & 8)
continue
;
55
unsigned
int
hash =
m_id2hash
[(*cc_sel_IdCells)[j]];
56
if
(hash == 0) {
57
cout <<
"ERROR: skipping cell with offline ID = "
<< (*cc_sel_IdCells)[j] << endl;
58
continue
;
59
}
60
61
// find digit
62
int
digitIndex = -1;
63
for
(
int
k = 0; k <
lardigit_n
; k++) {
64
if
((*
lardigit_offlineId
)[k] == (*
cc_sel_IdCells
)[j]) {
65
digitIndex = k;
66
break
;
67
}
68
}
69
//if (digitIndex >= 0) cout << "digitIndex = " << digitIndex << endl;
70
hash -= 1;
71
HistoryContainer
* histCont = samples->
hist_cont
(hash);
72
CellInfo
* info =
nullptr
;
73
if
(!histCont) {
74
std::unique_ptr<const CellInfo> templateInfo =
m_template
->cellInfo(hash);
75
info =
new
CellInfo
(templateInfo->calo(), templateInfo->layer(),
76
templateInfo->iEta(), templateInfo->iPhi(),
77
templateInfo->feedThrough(), templateInfo->slot(), templateInfo->channel(),
78
nullptr
,
nullptr
,
nullptr
, templateInfo->position(), templateInfo->onlid());
79
histCont = samples->
makeNewHistory
(
IdentifierHash
(hash), info);
80
}
81
else
82
info = histCont->
cell_info
();
83
84
CaloGain::CaloGain
gain =
CaloGain::UNKNOWNGAIN
;
85
std::vector<short> samples;
86
if
(digitIndex >= 0) {
87
gain = (
CaloGain::CaloGain
)(*
lardigit_gain
)[digitIndex];
88
std::vector<int> intSamples = (*lardigit_Samples)[digitIndex];
89
for
(
int
s : intSamples) {
90
samples.push_back((
short
)s);
91
}
92
}
93
DataContainer
* data =
94
new
DataContainer
(gain, samples, (*
cc_sel_E
)[j], (*
cc_sel_TimeCells
)[j],
95
(*
cc_sel_QCells
)[j], eventIndex,
96
std::vector<float>(), (*
cc_sel_Sigma
)[j],
97
-1, -1, (*
cc_sel_BadCells
)[j]);
98
histCont->
add
(data);
99
}
100
}
101
samples->
writeTrees
(
outputFileName
);
102
delete
samples;
103
return
true
;
104
}
105
106
107
bool
D3PDConverter::initMapping
(
const
TString& templateFile,
const
TString& translatorFile)
108
{
109
LArIdTranslatorHelper
translator(translatorFile);
110
m_template
=
Interface::open
(templateFile);
111
112
cout <<
"Making online->hash map"
<< endl;
113
std::map<unsigned long long, unsigned int> on2hash;
114
for
(
unsigned
int
i = 0; i <
m_template
->nChannels(); i++) {
115
std::unique_ptr<const CellInfo> info =
m_template
->cellInfo(i);
116
if
(!info)
continue
;
117
on2hash[info->onlid()] = i;
118
}
119
120
cout <<
"Making offlineID->hash map"
<< endl;
121
for
(
unsigned
int
i = 0; i < translator.
Tree
()->
GetEntries
(); i++) {
122
translator.
Tree
()->GetEntry(i);
123
m_id2hash
[translator.
offlid
] = on2hash[translator.
onlid
] + 1;
124
}
125
return
true
;
126
}
127
128
129
CellInfo.h
D3PDConverter.h
DataContainer.h
EventData.h
HistoryContainer.h
ClusterComm::EventData
@ EventData
Definition
IMPIClusterSvc.h:18
IdentifierHash.h
Interface.h
DataStore.h
LArIdTranslatorHelper.h
outputFileName
static const std::string outputFileName
Definition
ProduceDummyStripCabling.cxx:17
RunData.h
GetEntries
TGraphErrors * GetEntries(TH2F *histo)
Definition
TRTCalib_makeplots.cxx:4025
CaloD3PDClass::lardigit_offlineId
vector< unsigned int > * lardigit_offlineId
Definition
CaloD3PDClass.h:220
CaloD3PDClass::fChain
TTree * fChain
Definition
CaloD3PDClass.h:30
CaloD3PDClass::cc_sel_TimeCells
vector< float > * cc_sel_TimeCells
Definition
CaloD3PDClass.h:74
CaloD3PDClass::cc_sel_BadCells
vector< int > * cc_sel_BadCells
Definition
CaloD3PDClass.h:78
CaloD3PDClass::EventNumber
UInt_t EventNumber
Definition
CaloD3PDClass.h:35
CaloD3PDClass::lardigit_n
Int_t lardigit_n
Definition
CaloD3PDClass.h:208
CaloD3PDClass::cc_sel_IdCells
vector< unsigned int > * cc_sel_IdCells
Definition
CaloD3PDClass.h:79
CaloD3PDClass::bcid
UInt_t bcid
Definition
CaloD3PDClass.h:39
CaloD3PDClass::RunNumber
UInt_t RunNumber
current Tree number in a TChain
Definition
CaloD3PDClass.h:34
CaloD3PDClass::cc_sel_DetCells
vector< int > * cc_sel_DetCells
Definition
CaloD3PDClass.h:73
CaloD3PDClass::lbn
UInt_t lbn
Definition
CaloD3PDClass.h:38
CaloD3PDClass::CaloD3PDClass
CaloD3PDClass(TTree *tree=0)
CaloD3PDClass::cc_sel_QCells
vector< int > * cc_sel_QCells
Definition
CaloD3PDClass.h:71
CaloD3PDClass::cc_sel_E
vector< float > * cc_sel_E
Definition
CaloD3PDClass.h:67
CaloD3PDClass::cc_sel_Sigma
vector< float > * cc_sel_Sigma
Definition
CaloD3PDClass.h:80
CaloD3PDClass::lardigit_gain
vector< int > * lardigit_gain
Definition
CaloD3PDClass.h:218
CaloD3PDClass::cc_sel_n
Int_t cc_sel_n
Definition
CaloD3PDClass.h:66
IdentifierHash
This is a "hash" representation of an Identifier.
Definition
IdentifierHash.h:25
LArIdTranslatorHelper
Definition
LArIdTranslatorHelper.h:30
LArIdTranslatorHelper::offlid
ULong64_t offlid
Definition
LArIdTranslatorHelper.h:41
LArIdTranslatorHelper::Tree
TTree * Tree()
Definition
LArIdTranslatorHelper.h:60
LArIdTranslatorHelper::onlid
ULong64_t onlid
Definition
LArIdTranslatorHelper.h:41
LArSamples::CellInfo
Definition
CellInfo.h:31
LArSamples::D3PDConverter::initMapping
bool initMapping(const TString &templateFile, const TString &translatorFile)
Definition
D3PDConverter.cxx:107
LArSamples::D3PDConverter::~D3PDConverter
virtual ~D3PDConverter()
LArSamples::D3PDConverter::m_template
std::unique_ptr< Interface > m_template
Definition
D3PDConverter.h:40
LArSamples::D3PDConverter::makeSamplesTuple
bool makeSamplesTuple(const TString &outputFileName)
Definition
D3PDConverter.cxx:32
LArSamples::D3PDConverter::D3PDConverter
D3PDConverter(TTree &tree, const TString &templateFile, const TString &translatorFile)
Constructor.
Definition
D3PDConverter.cxx:24
LArSamples::D3PDConverter::m_id2hash
std::map< unsigned int, unsigned int > m_id2hash
Definition
D3PDConverter.h:39
LArSamples::DataContainer
Definition
DataContainer.h:25
LArSamples::DataStore
storage of the time histories of all the cells
Definition
LArCalorimeter/LArCafJobs/LArCafJobs/DataStore.h:32
LArSamples::DataStore::makeNewHistory
HistoryContainer * makeNewHistory(const IdentifierHash &hash, CellInfo *info)
append data (takes ownership of everything)
Definition
LArCalorimeter/LArCafJobs/src/DataStore.cxx:40
LArSamples::DataStore::addEvent
unsigned int addEvent(EventData *eventData)
Definition
LArCalorimeter/LArCafJobs/src/DataStore.cxx:72
LArSamples::DataStore::hist_cont
HistoryContainer *& hist_cont(unsigned int i)
Definition
LArCalorimeter/LArCafJobs/LArCafJobs/DataStore.h:72
LArSamples::DataStore::addRun
unsigned int addRun(RunData *eventData)
Definition
LArCalorimeter/LArCafJobs/src/DataStore.cxx:79
LArSamples::DataStore::writeTrees
bool writeTrees(const char *fileName)
Definition
LArCalorimeter/LArCafJobs/src/DataStore.cxx:152
LArSamples::EventData
Definition
EventData.h:29
LArSamples::EventData::setRunData
void setRunData(const RunData *runData)
Definition
EventData.h:75
LArSamples::HistoryContainer
Definition
HistoryContainer.h:29
LArSamples::HistoryContainer::add
void add(const DataContainer *data)
append data (takes ownership)
Definition
HistoryContainer.h:46
LArSamples::HistoryContainer::cell_info
CellInfo * cell_info() const
Definition
HistoryContainer.h:57
LArSamples::Interface::open
static std::unique_ptr< Interface > open(const TString &fileName)
Definition
Interface.cxx:35
LArSamples::RunData
Definition
RunData.h:21
LArSamples::RunData::run
int run() const
Definition
RunData.h:36
CaloGain::CaloGain
CaloGain
Definition
CaloGain.h:11
CaloGain::UNKNOWNGAIN
@ UNKNOWNGAIN
Definition
CaloGain.h:21
LArSamples
Definition
AbsShape.h:24
tree
TChain * tree
Definition
tile_monitor.h:30
Generated on
for ATLAS Offline Software by
1.17.0