1 |
#ifndef RecoAlgos_PhotonSelector_h
|
2 |
#define RecoAlgos_PhotonSelector_h
|
3 |
/** \class PhotonSelector
|
4 |
*
|
5 |
* selects a subset of an photon collection. Also clones
|
6 |
* all referenced objects
|
7 |
*
|
8 |
* \author Luca Lista, INFN
|
9 |
*
|
10 |
* \version $Revision: 1.7 $
|
11 |
*
|
12 |
* $Id: PhotonSelector.h,v 1.7 2007/09/20 18:48:28 llista Exp $
|
13 |
*
|
14 |
*/
|
15 |
|
16 |
#include "DataFormats/EgammaCandidates/interface/Photon.h"
|
17 |
#include "DataFormats/EgammaReco/interface/SuperCluster.h"
|
18 |
#include "PhysicsTools/UtilAlgos/interface/ObjectSelector.h"
|
19 |
|
20 |
namespace helper {
|
21 |
struct PhotonCollectionStoreManager {
|
22 |
typedef reco::PhotonCollection collection;
|
23 |
PhotonCollectionStoreManager(const edm::Handle<reco::PhotonCollection>&) :
|
24 |
selPhotons_( new reco::PhotonCollection ),
|
25 |
selSuperClusters_( new reco::SuperClusterCollection ) {
|
26 |
}
|
27 |
template<typename I>
|
28 |
void cloneAndStore( const I & begin, const I & end, edm::Event & evt ) {
|
29 |
using namespace reco;
|
30 |
PhotonRefProd rPhotons = evt.template getRefBeforePut<PhotonCollection>();
|
31 |
SuperClusterRefProd rSuperClusters = evt.template getRefBeforePut<SuperClusterCollection>();
|
32 |
size_t idx = 0;
|
33 |
for( I i = begin; i != end; ++ i ) {
|
34 |
const Photon & ele = * * i;
|
35 |
selPhotons_->push_back( Photon( ele ) );
|
36 |
selPhotons_->back().setSuperCluster( SuperClusterRef( rSuperClusters, idx ++ ) );
|
37 |
selSuperClusters_->push_back( SuperCluster( * ( ele.superCluster() ) ) );
|
38 |
}
|
39 |
}
|
40 |
edm::OrphanHandle<reco::PhotonCollection> put( edm::Event & evt ) {
|
41 |
edm::OrphanHandle<reco::PhotonCollection> h = evt.put( selPhotons_ );
|
42 |
evt.put( selSuperClusters_ );
|
43 |
return h;
|
44 |
}
|
45 |
size_t size() const { return selPhotons_->size(); }
|
46 |
private:
|
47 |
std::auto_ptr<reco::PhotonCollection> selPhotons_;
|
48 |
std::auto_ptr<reco::SuperClusterCollection> selSuperClusters_;
|
49 |
};
|
50 |
|
51 |
class PhotonSelectorBase : public edm::EDFilter {
|
52 |
public:
|
53 |
PhotonSelectorBase( const edm::ParameterSet & cfg ) {
|
54 |
std::string alias( cfg.getParameter<std::string>( "@module_label" ) );
|
55 |
produces<reco::PhotonCollection>().setBranchAlias( alias + "Photons" );
|
56 |
produces<reco::SuperClusterCollection>().setBranchAlias( alias + "SuperClusters" );
|
57 |
}
|
58 |
};
|
59 |
|
60 |
template<>
|
61 |
struct StoreManagerTrait<reco::PhotonCollection> {
|
62 |
typedef PhotonCollectionStoreManager type;
|
63 |
typedef PhotonSelectorBase base;
|
64 |
};
|
65 |
|
66 |
}
|
67 |
|
68 |
#endif
|