CommonTools
UtilAlgos
interface
StoreManagerTrait.h
Go to the documentation of this file.
1
#ifndef UtilAlgos_StoreManagerTrait_h
2
#define UtilAlgos_StoreManagerTrait_h
3
/* \class helper::CollectionStoreManager
4
*
5
* \author: Luca Lista, INFN
6
*
7
*/
8
#include "
DataFormats/Common/interface/OwnVector.h
"
9
#include "
DataFormats/Common/interface/RefVector.h
"
10
#include "
DataFormats/Common/interface/RefToBase.h
"
11
#include "
DataFormats/Common/interface/RefToBaseVector.h
"
12
#include "
DataFormats/Common/interface/Ptr.h
"
13
#include "
DataFormats/Common/interface/PtrVector.h
"
14
#include "
FWCore/Framework/interface/Event.h
"
15
#include <memory>
16
#include "boost/type_traits.hpp"
17
18
namespace
helper
{
19
20
template
<
typename
Collection>
21
struct
IteratorToObjectConverter
{
22
typedef
typename
Collection::value_type
value_type
;
23
template
<
typename
I>
24
static
value_type
convert
(
const
I
&
i
) {
25
return
value_type
(**
i
);
26
}
27
};
28
29
template
<
typename
T>
30
struct
IteratorToObjectConverter
<
edm
::OwnVector<T> > {
31
typedef
std::unique_ptr<T>
value_type
;
32
template
<
typename
I>
33
static
value_type
convert
(
const
I
&
i
) {
34
return
value_type
((*i)->clone());
35
}
36
};
37
38
template
<
typename
C>
39
struct
IteratorToObjectConverter
<
edm
::
RefVector
<C> > {
40
typedef
edm::Ref<C>
value_type
;
41
template
<
typename
I>
42
static
value_type
convert
(
const
I
&
i
) {
43
return
value_type
(*
i
);
44
}
45
};
46
47
template
<
typename
T>
48
struct
IteratorToObjectConverter
<
edm
::
RefToBaseVector
<T> > {
49
typedef
edm::RefToBase<T>
value_type
;
50
template
<
typename
I>
51
static
value_type
convert
(
const
I
&
i
) {
52
return
value_type
(*
i
);
53
}
54
};
55
56
template
<
typename
T>
57
struct
IteratorToObjectConverter
<
edm
::
PtrVector
<T> > {
58
typedef
edm::Ptr<T>
value_type
;
59
template
<
typename
I>
60
static
value_type
convert
(
const
I
&
i
) {
61
return
value_type
(*
i
);
62
}
63
};
64
65
template
<
typename
OutputCollection,
typename
ClonePolicy = IteratorToObjectConverter<OutputCollection> >
66
struct
CollectionStoreManager
{
67
typedef
OutputCollection
collection
;
68
template
<
typename
C>
69
CollectionStoreManager
(
const
edm::Handle<C>
&
h
) :
selected_
(new
OutputCollection
) {}
70
template
<
typename
I>
71
void
cloneAndStore
(
const
I
&
begin
,
const
I
&
end
,
edm::Event
&) {
72
using namespace
std
;
73
for
(
I
i
=
begin
;
i
!=
end
; ++
i
) {
74
typename
ClonePolicy::value_type
v
=
ClonePolicy::convert
(
i
);
75
selected_
->push_back(
std::move
(
v
));
76
}
77
}
78
edm::OrphanHandle<collection>
put
(
edm::Event
&evt) {
return
evt.
put
(
std::move
(
selected_
)); }
79
size_t
size
()
const
{
return
selected_
->size(); }
80
81
private
:
82
std::unique_ptr<collection>
selected_
;
83
};
84
85
template
<
typename
OutputCollection,
typename
EdmFilter>
86
struct
ObjectSelectorBase
:
public
EdmFilter {
87
ObjectSelectorBase
(
const
edm::ParameterSet
&) { this->
template
produces<OutputCollection>(); }
88
};
89
90
template
<
typename
OutputCollection,
typename
EdmFilter = edm::EDFilter>
91
struct
StoreManagerTrait
{
92
using
type
=
CollectionStoreManager<OutputCollection>
;
93
using
base
=
ObjectSelectorBase<OutputCollection, EdmFilter>
;
94
};
95
96
}
// namespace helper
97
98
#endif
helper::IteratorToObjectConverter< edm::RefVector< C > >::value_type
edm::Ref< C > value_type
Definition:
StoreManagerTrait.h:40
mps_fire.i
i
Definition:
mps_fire.py:355
helper::IteratorToObjectConverter< edm::RefVector< C > >::convert
static value_type convert(const I &i)
Definition:
StoreManagerTrait.h:42
edm
HLT enums.
Definition:
AlignableModifier.h:19
helper::IteratorToObjectConverter< edm::RefToBaseVector< T > >::convert
static value_type convert(const I &i)
Definition:
StoreManagerTrait.h:51
helper::ObjectSelectorBase::ObjectSelectorBase
ObjectSelectorBase(const edm::ParameterSet &)
Definition:
StoreManagerTrait.h:87
helper::CollectionStoreManager::selected_
std::unique_ptr< collection > selected_
Definition:
StoreManagerTrait.h:82
helper::CollectionStoreManager::put
edm::OrphanHandle< collection > put(edm::Event &evt)
Definition:
StoreManagerTrait.h:78
findQualityFiles.v
v
Definition:
findQualityFiles.py:179
edm::Handle
Definition:
AssociativeIterator.h:50
helper::StoreManagerTrait
Definition:
StoreManagerTrait.h:91
helper::IteratorToObjectConverter
Definition:
StoreManagerTrait.h:21
end
#define end
Definition:
vmac.h:39
edm::Ref
Definition:
AssociativeIterator.h:58
reco::JetExtendedAssociation::RefVector
edm::RefVector< Container > RefVector
Definition:
JetExtendedAssociation.h:34
helper::CollectionStoreManager
Definition:
StoreManagerTrait.h:66
Exhume::I
const std::complex< double > I
Definition:
I.h:8
helper::CollectionStoreManager::CollectionStoreManager
CollectionStoreManager(const edm::Handle< C > &h)
Definition:
StoreManagerTrait.h:69
PtrVector.h
RefToBaseVector.h
helper::ObjectSelectorBase
Definition:
StoreManagerTrait.h:86
h
RefToBase.h
helper::CollectionStoreManager::cloneAndStore
void cloneAndStore(const I &begin, const I &end, edm::Event &)
Definition:
StoreManagerTrait.h:71
helper::IteratorToObjectConverter< edm::OwnVector< T > >::convert
static value_type convert(const I &i)
Definition:
StoreManagerTrait.h:33
fileCollector.convert
def convert(infile, ofile)
Definition:
fileCollector.py:47
helper::CollectionStoreManager::size
size_t size() const
Definition:
StoreManagerTrait.h:79
edm::ParameterSet
Definition:
ParameterSet.h:36
RefVector.h
Event.h
helper
Definition:
helper.py:1
RefToBaseVector
Ptr.h
edm::Event::put
OrphanHandle< PROD > put(std::unique_ptr< PROD > product)
Put a new product.
Definition:
Event.h:132
helper::IteratorToObjectConverter< edm::OwnVector< T > >::value_type
std::unique_ptr< T > value_type
Definition:
StoreManagerTrait.h:31
reco::JetExtendedAssociation::value_type
Container::value_type value_type
Definition:
JetExtendedAssociation.h:30
helper::IteratorToObjectConverter::value_type
Collection::value_type value_type
Definition:
StoreManagerTrait.h:22
helper::CollectionStoreManager::collection
OutputCollection collection
Definition:
StoreManagerTrait.h:67
edm::Ptr
Definition:
AssociationVector.h:31
eostools.move
def move(src, dest)
Definition:
eostools.py:511
std
Definition:
JetResolutionObject.h:76
edm::OrphanHandle
Definition:
EDProductfwd.h:39
helper::IteratorToObjectConverter< edm::RefToBaseVector< T > >::value_type
edm::RefToBase< T > value_type
Definition:
StoreManagerTrait.h:49
helper::IteratorToObjectConverter< edm::PtrVector< T > >::value_type
edm::Ptr< T > value_type
Definition:
StoreManagerTrait.h:58
edm::RefToBase
Definition:
AssociativeIterator.h:54
PtrVector
helper::IteratorToObjectConverter< edm::PtrVector< T > >::convert
static value_type convert(const I &i)
Definition:
StoreManagerTrait.h:60
OwnVector.h
edm::Event
Definition:
Event.h:73
HLTTauReferences_cfi.OutputCollection
OutputCollection
Definition:
HLTTauReferences_cfi.py:92
begin
#define begin
Definition:
vmac.h:32
helper::IteratorToObjectConverter::convert
static value_type convert(const I &i)
Definition:
StoreManagerTrait.h:24
Generated for CMSSW Reference Manual by
1.8.16