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