SimGeneral
HepPDTESSource
src
HepPDTESSource.cc
Go to the documentation of this file.
1
#include "HepPDT/HeavyIonUnknownID.hh"
2
#include "
SimGeneral/HepPDTESSource/interface/HepPDTESSource.h
"
3
#include "tbb/concurrent_vector.h"
4
5
namespace
{
6
7
class
CachingHeavyIonUnknownID :
public
HepPDT::ProcessUnknownID {
8
HepPDT::ParticleData
*processUnknownID(
HepPDT::ParticleID
id
,
const
HepPDT::ParticleDataTable
&
table
)
final
{
9
// HeavyIonUnknownID constructs a new particle but does not delete it
10
// we need to do that ourselves
11
std::unique_ptr<HepPDT::ParticleData>
p
{wrapped_.processUnknownID(
id
,
table
)};
12
auto
*pPtr =
p
.get();
13
if
(
p
) {
14
particles_.emplace_back(
std::move
(
p
));
15
}
16
return
pPtr;
17
}
18
19
HepPDT::HeavyIonUnknownID wrapped_;
20
tbb::concurrent_vector<std::unique_ptr<HepPDT::ParticleData>> particles_;
21
};
22
23
}
// namespace
24
25
HepPDTESSource::HepPDTESSource
(
const
edm::ParameterSet
&
cfg
)
26
:
pdtFileName
(
cfg
.getParameter<
edm
::FileInPath>(
"pdtFileName"
)) {
27
setWhatProduced
(
this
);
28
findingRecord<PDTRecord>();
29
}
30
31
HepPDTESSource::~HepPDTESSource
() {}
32
33
HepPDTESSource::ReturnType
HepPDTESSource::produce
(
const
PDTRecord
&iRecord) {
34
using namespace
edm::es
;
35
auto
pdt = std::make_unique<PDT>(
"PDG table"
,
new
CachingHeavyIonUnknownID);
36
std::ifstream pdtFile(
pdtFileName
.
fullPath
().c_str());
37
if
(!pdtFile)
38
throw
cms::Exception
(
"FileNotFound"
,
"can't open pdt file"
) <<
"cannot open "
<<
pdtFileName
.
fullPath
();
39
{
// notice: the builder has to be destroyed
40
// in order to fill the table!
41
HepPDT::TableBuilder builder(*pdt);
42
if
(!addParticleTable(pdtFile, builder)) {
43
throw
cms::Exception
(
"ConfigError"
,
"can't read pdt file"
) <<
"wrong format of "
<<
pdtFileName
.
fullPath
();
44
}
45
}
46
return
pdt;
47
}
48
49
void
HepPDTESSource::setIntervalFor
(
const
edm::eventsetup::EventSetupRecordKey
&,
50
const
edm::IOVSyncValue
&,
51
edm::ValidityInterval
&oInterval) {
52
// the same PDT is valid for any time
53
oInterval =
edm::ValidityInterval
(
edm::IOVSyncValue::beginOfTime
(),
edm::IOVSyncValue::endOfTime
());
54
}
55
56
// define this as a plug-in
57
// DEFINE_FWK_EVENTSETUP_SOURCE( HepPDTESSource );
HepPDTESSource::pdtFileName
edm::FileInPath pdtFileName
Definition:
HepPDTESSource.h:49
edm
HLT enums.
Definition:
AlignableModifier.h:19
AlCaHLTBitMon_ParallelJobs.p
p
Definition:
AlCaHLTBitMon_ParallelJobs.py:153
edm::ESProducer::setWhatProduced
auto setWhatProduced(T *iThis, const es::Label &iLabel={})
Definition:
ESProducer.h:138
edm::ValidityInterval
Definition:
ValidityInterval.h:28
HepPDTESSource::~HepPDTESSource
~HepPDTESSource() override
destructor
Definition:
HepPDTESSource.cc:31
HepPDTESSource::ReturnType
std::unique_ptr< PDT > ReturnType
define the return type
Definition:
HepPDTESSource.h:40
edm::eventsetup::EventSetupRecordKey
Definition:
EventSetupRecordKey.h:30
ParticleData
HepPDT::ParticleData ParticleData
Definition:
ParticleDataTable.h:9
HepPDTESSource.h
HepPDTESSource::setIntervalFor
void setIntervalFor(const edm::eventsetup::EventSetupRecordKey &, const edm::IOVSyncValue &, edm::ValidityInterval &) override
set validity interval
Definition:
HepPDTESSource.cc:49
HepPDTESSource::produce
ReturnType produce(const PDTRecord &)
return the particle table
Definition:
HepPDTESSource.cc:33
edm::IOVSyncValue
Definition:
IOVSyncValue.h:31
edm::ParameterSet
Definition:
ParameterSet.h:36
edm::IOVSyncValue::endOfTime
static const IOVSyncValue & endOfTime()
Definition:
IOVSyncValue.cc:82
HepPDTESSource::HepPDTESSource
HepPDTESSource(const edm::ParameterSet &)
constructor from parameter set
Definition:
HepPDTESSource.cc:25
looper.cfg
cfg
Definition:
looper.py:297
cond::ValidityInterval
std::pair< Time_t, Time_t > ValidityInterval
Definition:
Time.h:17
eostools.move
def move(src, dest)
Definition:
eostools.py:511
Exception
Definition:
hltDiff.cc:246
edm::es
Definition:
es_Label.h:33
edm::IOVSyncValue::beginOfTime
static const IOVSyncValue & beginOfTime()
Definition:
IOVSyncValue.cc:88
TableParser.table
table
Definition:
TableParser.py:111
LHEGenericFilter_cfi.ParticleID
ParticleID
Definition:
LHEGenericFilter_cfi.py:6
PDTRecord
Definition:
PDTRecord.h:14
ParticleDataTable
HepPDT::ParticleDataTable ParticleDataTable
Definition:
ParticleDataTable.h:8
pythiapdt_cfi.pdtFileName
pdtFileName
Definition:
pythiapdt_cfi.py:4
edm::FileInPath::fullPath
std::string fullPath() const
Definition:
FileInPath.cc:163
Generated for CMSSW Reference Manual by
1.8.16