FWCore
Framework
src
PrincipalCache.cc
Go to the documentation of this file.
1
#include "
FWCore/Framework/src/PrincipalCache.h
"
2
3
#include "
FWCore/Framework/interface/EventPrincipal.h
"
4
#include "
FWCore/Framework/interface/LuminosityBlockPrincipal.h
"
5
#include "
FWCore/Framework/interface/ProcessBlockPrincipal.h
"
6
#include "
FWCore/Framework/interface/RunPrincipal.h
"
7
#include "
FWCore/Framework/src/PreallocationConfiguration.h
"
8
#include "
FWCore/Utilities/interface/EDMException.h
"
9
#include "
DataFormats/Provenance/interface/ProcessHistoryRegistry.h
"
10
11
namespace
edm
{
12
13
PrincipalCache::PrincipalCache
() : run_(0
U
), lumi_(0
U
) {}
14
15
PrincipalCache::~PrincipalCache
() {}
16
17
void
PrincipalCache::setNumberOfConcurrentPrincipals
(
PreallocationConfiguration
const
& iConfig) {
18
eventPrincipals_
.resize(iConfig.
numberOfStreams
());
19
}
20
21
RunPrincipal
&
PrincipalCache::runPrincipal
(
ProcessHistoryID
const
& phid,
RunNumber_t
run
)
const
{
22
if
(phid !=
reducedInputProcessHistoryID_
||
run
!=
run_
||
runPrincipal_
.get() ==
nullptr
) {
23
throwRunMissing
();
24
}
25
return
*
runPrincipal_
.get();
26
}
27
28
std::shared_ptr<RunPrincipal>
const
&
PrincipalCache::runPrincipalPtr
(
ProcessHistoryID
const
& phid,
29
RunNumber_t
run
)
const
{
30
if
(phid !=
reducedInputProcessHistoryID_
||
run
!=
run_
||
runPrincipal_
.get() ==
nullptr
) {
31
throwRunMissing
();
32
}
33
return
runPrincipal_
;
34
}
35
36
RunPrincipal
&
PrincipalCache::runPrincipal
()
const
{
37
if
(
runPrincipal_
.get() ==
nullptr
) {
38
throwRunMissing
();
39
}
40
return
*
runPrincipal_
.get();
41
}
42
43
std::shared_ptr<RunPrincipal>
const
&
PrincipalCache::runPrincipalPtr
()
const
{
44
if
(
runPrincipal_
.get() ==
nullptr
) {
45
throwRunMissing
();
46
}
47
return
runPrincipal_
;
48
}
49
50
std::shared_ptr<LuminosityBlockPrincipal>
PrincipalCache::getAvailableLumiPrincipalPtr
() {
51
return
lumiHolder_
.tryToGet();
52
}
53
54
void
PrincipalCache::merge
(std::shared_ptr<RunAuxiliary>
aux
, std::shared_ptr<ProductRegistry const> reg) {
55
if
(
runPrincipal_
.get() ==
nullptr
) {
56
throw
edm::Exception
(
edm::errors::LogicError
) <<
"PrincipalCache::merge\n"
57
<<
"Illegal attempt to merge run into cache\n"
58
<<
"There is no run in cache to merge with\n"
59
<<
"Contact a Framework Developer\n"
;
60
}
61
if
(
inputProcessHistoryID_
!=
aux
->processHistoryID()) {
62
if
(
reducedInputProcessHistoryID_
!=
processHistoryRegistry_
->
reducedProcessHistoryID
(
aux
->processHistoryID())) {
63
throw
edm::Exception
(
edm::errors::LogicError
)
64
<<
"PrincipalCache::merge\n"
65
<<
"Illegal attempt to merge run into cache\n"
66
<<
"Reduced ProcessHistoryID inconsistent with the one already in cache\n"
67
<<
"Contact a Framework Developer\n"
;
68
}
69
inputProcessHistoryID_
=
aux
->processHistoryID();
70
}
71
if
(
aux
->run() !=
run_
) {
72
throw
edm::Exception
(
edm::errors::LogicError
) <<
"PrincipalCache::merge\n"
73
<<
"Illegal attempt to merge run into cache\n"
74
<<
"Run number inconsistent with run number already in cache\n"
75
<<
"Contact a Framework Developer\n"
;
76
}
77
bool
runOK =
runPrincipal_
->adjustToNewProductRegistry(*reg);
78
assert
(runOK);
79
runPrincipal_
->mergeAuxiliary(*
aux
);
80
}
81
82
void
PrincipalCache::insert
(std::shared_ptr<RunPrincipal> rp) {
83
if
(
runPrincipal_
.get() !=
nullptr
) {
84
throw
edm::Exception
(
edm::errors::LogicError
) <<
"PrincipalCache::insert\n"
85
<<
"Illegal attempt to insert run into cache\n"
86
<<
"Contact a Framework Developer\n"
;
87
}
88
if
(
inputProcessHistoryID_
!= rp->aux().processHistoryID()) {
89
reducedInputProcessHistoryID_
=
processHistoryRegistry_
->
reducedProcessHistoryID
(rp->aux().processHistoryID());
90
inputProcessHistoryID_
= rp->aux().processHistoryID();
91
}
92
run_
= rp->run();
93
runPrincipal_
= rp;
94
}
95
96
void
PrincipalCache::insert
(std::unique_ptr<ProcessBlockPrincipal> pb) {
processBlockPrincipal_
=
std::move
(pb); }
97
98
void
PrincipalCache::insertForInput
(std::unique_ptr<ProcessBlockPrincipal> pb) {
99
inputProcessBlockPrincipal_
=
std::move
(pb);
100
}
101
102
void
PrincipalCache::insert
(std::unique_ptr<LuminosityBlockPrincipal> lbp) {
lumiHolder_
.add(
std::move
(lbp)); }
103
104
void
PrincipalCache::insert
(std::shared_ptr<EventPrincipal>
ep
) {
105
unsigned
int
iStreamIndex =
ep
->streamID().value();
106
assert
(iStreamIndex <
eventPrincipals_
.size());
107
eventPrincipals_
[iStreamIndex] =
ep
;
108
}
109
110
void
PrincipalCache::deleteRun
(
ProcessHistoryID
const
& phid,
RunNumber_t
run
) {
111
if
(
runPrincipal_
.get() ==
nullptr
) {
112
throw
edm::Exception
(
edm::errors::LogicError
) <<
"PrincipalCache::deleteRun\n"
113
<<
"Illegal attempt to delete run from cache\n"
114
<<
"There is no run in cache to delete\n"
115
<<
"Contact a Framework Developer\n"
;
116
}
117
if
(
reducedInputProcessHistoryID_
!= phid ||
run
!=
run_
) {
118
throw
edm::Exception
(
edm::errors::LogicError
)
119
<<
"PrincipalCache::deleteRun\n"
120
<<
"Illegal attempt to delete run from cache\n"
121
<<
"Run number or reduced ProcessHistoryID inconsistent with those in cache\n"
122
<<
"Contact a Framework Developer\n"
;
123
}
124
runPrincipal_
.reset();
125
}
126
127
void
PrincipalCache::adjustEventsToNewProductRegistry
(std::shared_ptr<ProductRegistry const> reg) {
128
for
(
auto
&
eventPrincipal
:
eventPrincipals_
) {
129
if
(
eventPrincipal
) {
130
eventPrincipal
->
adjustIndexesAfterProductRegistryAddition
();
131
bool
eventOK =
eventPrincipal
->
adjustToNewProductRegistry
(*reg);
132
assert
(eventOK);
133
}
134
}
135
}
136
137
void
PrincipalCache::adjustIndexesAfterProductRegistryAddition
() {
138
if
(
runPrincipal_
) {
139
runPrincipal_
->adjustIndexesAfterProductRegistryAddition();
140
}
141
//Need to temporarily hold all the lumis to clear out the lumiHolder_
142
std::vector<std::shared_ptr<LuminosityBlockPrincipal>>
temp
;
143
while
(
auto
p
=
lumiHolder_
.tryToGet()) {
144
p
->adjustIndexesAfterProductRegistryAddition();
145
temp
.emplace_back(
std::move
(
p
));
146
}
147
}
148
149
void
PrincipalCache::preReadFile
() {
150
if
(
runPrincipal_
) {
151
runPrincipal_
->preReadFile();
152
}
153
}
154
155
void
PrincipalCache::throwRunMissing
()
const
{
156
throw
edm::Exception
(
edm::errors::LogicError
) <<
"PrincipalCache::runPrincipal\n"
157
<<
"Requested a run that is not in the cache (should never happen)\n"
158
<<
"Contact a Framework Developer\n"
;
159
}
160
161
void
PrincipalCache::throwLumiMissing
()
const
{
162
throw
edm::Exception
(
edm::errors::LogicError
)
163
<<
"PrincipalCache::lumiPrincipal or PrincipalCache::lumiPrincipalPtr\n"
164
<<
"Requested a luminosity block that is not in the cache (should never happen)\n"
165
<<
"Contact a Framework Developer\n"
;
166
}
167
}
// namespace edm
edm::RunNumber_t
unsigned int RunNumber_t
Definition:
RunLumiEventNumber.h:14
edm::PrincipalCache::processBlockPrincipal_
std::unique_ptr< ProcessBlockPrincipal > processBlockPrincipal_
Definition:
PrincipalCache.h:97
edm::errors::LogicError
Definition:
EDMException.h:37
edm
HLT enums.
Definition:
AlignableModifier.h:19
edm::Principal::adjustToNewProductRegistry
bool adjustToNewProductRegistry(ProductRegistry const ®)
Definition:
Principal.cc:315
cms::cuda::assert
assert(be >=bs)
ProcessBlockPrincipal.h
ProcessHistoryRegistry.h
PreallocationConfiguration.h
edm::PrincipalCache::~PrincipalCache
~PrincipalCache()
Definition:
PrincipalCache.cc:15
groupFilesInBlocks.temp
list temp
Definition:
groupFilesInBlocks.py:142
edm::PrincipalCache::runPrincipalPtr
std::shared_ptr< RunPrincipal > const & runPrincipalPtr() const
Definition:
PrincipalCache.cc:43
edm::Principal::adjustIndexesAfterProductRegistryAddition
void adjustIndexesAfterProductRegistryAddition()
Definition:
Principal.cc:939
edm::PrincipalCache::throwLumiMissing
void throwLumiMissing() const
Definition:
PrincipalCache.cc:161
EDMException.h
edm::PrincipalCache::eventPrincipals_
std::vector< std::shared_ptr< EventPrincipal > > eventPrincipals_
Definition:
PrincipalCache.h:101
edm::PrincipalCache::merge
void merge(std::shared_ptr< RunAuxiliary > aux, std::shared_ptr< ProductRegistry const > reg)
Definition:
PrincipalCache.cc:54
EventPrincipal.h
edm::PrincipalCache::runPrincipal_
std::shared_ptr< RunPrincipal > runPrincipal_
Definition:
PrincipalCache.h:99
edm::Hash< ProcessHistoryType >
edm::PrincipalCache::PrincipalCache
PrincipalCache()
Definition:
PrincipalCache.cc:13
mitigatedMETSequence_cff.U
U
Definition:
mitigatedMETSequence_cff.py:36
edm::PrincipalCache::preReadFile
void preReadFile()
Definition:
PrincipalCache.cc:149
AlCaHLTBitMon_ParallelJobs.p
def p
Definition:
AlCaHLTBitMon_ParallelJobs.py:153
PrincipalCache.h
RunPrincipal.h
edm::PrincipalCache::deleteRun
void deleteRun(ProcessHistoryID const &phid, RunNumber_t run)
Definition:
PrincipalCache.cc:110
edm::PrincipalCache::processHistoryRegistry_
ProcessHistoryRegistry const * processHistoryRegistry_
Definition:
PrincipalCache.h:104
printConversionInfo.aux
aux
Definition:
printConversionInfo.py:19
edm::PrincipalCache::throwRunMissing
void throwRunMissing() const
Definition:
PrincipalCache.cc:155
edm::PrincipalCache::reducedInputProcessHistoryID_
ProcessHistoryID reducedInputProcessHistoryID_
Definition:
PrincipalCache.h:114
edm::PrincipalCache::runPrincipal
RunPrincipal & runPrincipal() const
Definition:
PrincipalCache.cc:36
edm::PrincipalCache::inputProcessBlockPrincipal_
std::unique_ptr< ProcessBlockPrincipal > inputProcessBlockPrincipal_
Definition:
PrincipalCache.h:98
edm::PrincipalCache::insertForInput
void insertForInput(std::unique_ptr< ProcessBlockPrincipal >)
Definition:
PrincipalCache.cc:98
edm::PrincipalCache::adjustEventsToNewProductRegistry
void adjustEventsToNewProductRegistry(std::shared_ptr< ProductRegistry const > reg)
Definition:
PrincipalCache.cc:127
edm::PrincipalCache::inputProcessHistoryID_
ProcessHistoryID inputProcessHistoryID_
Definition:
PrincipalCache.h:113
edm::ProcessHistoryRegistry::reducedProcessHistoryID
ProcessHistoryID const & reducedProcessHistoryID(ProcessHistoryID const &fullID) const
Definition:
ProcessHistoryRegistry.cc:23
LuminosityBlockPrincipal.h
edm::PreallocationConfiguration
Definition:
PreallocationConfiguration.h:27
eostools.move
def move(src, dest)
Definition:
eostools.py:511
writedatasetfile.run
run
Definition:
writedatasetfile.py:27
edm::PrincipalCache::getAvailableLumiPrincipalPtr
std::shared_ptr< LuminosityBlockPrincipal > getAvailableLumiPrincipalPtr()
Definition:
PrincipalCache.cc:50
Exception
Definition:
hltDiff.cc:245
edm::PreallocationConfiguration::numberOfStreams
unsigned int numberOfStreams() const
Definition:
PreallocationConfiguration.h:35
edm::RunPrincipal
Definition:
RunPrincipal.h:34
edm::PrincipalCache::eventPrincipal
EventPrincipal & eventPrincipal(unsigned int iStreamIndex) const
Definition:
PrincipalCache.h:70
edm::PrincipalCache::insert
void insert(std::unique_ptr< ProcessBlockPrincipal >)
Definition:
PrincipalCache.cc:96
edm::PrincipalCache::lumiHolder_
edm::ReusableObjectHolder< LuminosityBlockPrincipal > lumiHolder_
Definition:
PrincipalCache.h:100
edm::PrincipalCache::run_
RunNumber_t run_
Definition:
PrincipalCache.h:115
SiStripBadComponentsDQMServiceTemplate_cfg.ep
ep
Definition:
SiStripBadComponentsDQMServiceTemplate_cfg.py:86
edm::PrincipalCache::adjustIndexesAfterProductRegistryAddition
void adjustIndexesAfterProductRegistryAddition()
Definition:
PrincipalCache.cc:137
edm::PrincipalCache::setNumberOfConcurrentPrincipals
void setNumberOfConcurrentPrincipals(PreallocationConfiguration const &)
Definition:
PrincipalCache.cc:17
Generated for CMSSW Reference Manual by
1.8.16