24
24
using namespace std ;
25
25
using namespace reco ;
26
26
class ElectronIdMVAProducer : public edm ::EDFilter {
27
- public:
28
- explicit ElectronIdMVAProducer (const edm::ParameterSet&);
29
- ~ElectronIdMVAProducer ();
30
-
31
- private:
32
- virtual bool filter (edm::Event&, const edm::EventSetup&);
33
-
34
- // ----------member data ---------------------------
35
- bool verbose_;
36
- edm::EDGetTokenT<reco::VertexCollection> vertexToken_;
37
- edm::EDGetTokenT<reco::GsfElectronCollection> electronToken_;
38
- edm::EDGetTokenT<double > eventrhoToken_;
39
- edm::InputTag reducedEBRecHitCollection_;
40
- edm::InputTag reducedEERecHitCollection_;
41
-
42
- double _Rho;
43
- string method_;
44
- vector<string> mvaWeightFiles_;
45
- bool Trig_;
46
- bool NoIP_;
47
-
48
- EGammaMvaEleEstimator* mvaID_;
49
-
27
+ public:
28
+ explicit ElectronIdMVAProducer (const edm::ParameterSet&);
29
+ ~ElectronIdMVAProducer ();
30
+
31
+ private:
32
+ virtual bool filter (edm::Event&, const edm::EventSetup&);
33
+
34
+ // ----------member data ---------------------------
35
+ bool verbose_;
36
+ edm::EDGetTokenT<reco::VertexCollection> vertexToken_;
37
+ edm::EDGetTokenT<reco::GsfElectronCollection> electronToken_;
38
+ edm::EDGetTokenT<double > eventrhoToken_;
39
+ edm::EDGetTokenT<EcalRecHitCollection> reducedEBRecHitCollectionToken_;
40
+ edm::EDGetTokenT<EcalRecHitCollection> reducedEERecHitCollectionToken_;
41
+
42
+ double _Rho;
43
+ string method_;
44
+ vector<string> mvaWeightFiles_;
45
+ bool Trig_;
46
+ bool NoIP_;
47
+
48
+ EGammaMvaEleEstimator* mvaID_;
50
49
};
51
50
52
51
//
@@ -61,47 +60,47 @@ class ElectronIdMVAProducer : public edm::EDFilter {
61
60
// constructors and destructor
62
61
//
63
62
ElectronIdMVAProducer::ElectronIdMVAProducer (const edm::ParameterSet& iConfig) {
64
- verbose_ = iConfig.getUntrackedParameter <bool >(" verbose" , false );
65
- vertexToken_ = consumes<reco::VertexCollection>(iConfig.getParameter <edm::InputTag>(" vertexTag" ));
66
- electronToken_ = consumes<reco::GsfElectronCollection>(iConfig.getParameter <edm::InputTag>(" electronTag" ));
67
- eventrhoToken_ = consumes<double >(edm::InputTag (" kt6PFJets" , " rho" ));
68
- reducedEBRecHitCollection_ = iConfig.getParameter <edm::InputTag>(" reducedEBRecHitCollection" );
69
- reducedEERecHitCollection_ = iConfig.getParameter <edm::InputTag>(" reducedEERecHitCollection" );
70
- method_ = iConfig.getParameter <string>(" method" );
71
- std::vector<string> fpMvaWeightFiles = iConfig.getParameter <std::vector<std::string> >(" mvaWeightFile" );
72
- Trig_ = iConfig.getParameter <bool >(" Trig" );
73
- NoIP_ = iConfig.getParameter <bool >(" NoIP" );
74
-
75
- produces<edm::ValueMap<float > >(" " );
76
-
77
- mvaID_ = new EGammaMvaEleEstimator ();
78
-
79
- EGammaMvaEleEstimator::MVAType type_;
80
- if (Trig_ && !NoIP_){type_ = EGammaMvaEleEstimator::kTrig ;}
81
-
82
- if (Trig_ && NoIP_){type_ = EGammaMvaEleEstimator::kTrigNoIP ;}
83
-
84
- if (!Trig_){type_ = EGammaMvaEleEstimator::kNonTrig ;}
85
-
86
- bool manualCat_ = true ;
87
-
88
- string path_mvaWeightFileEleID;
89
- for (unsigned ifile=0 ; ifile < fpMvaWeightFiles.size () ; ++ifile) {
90
- path_mvaWeightFileEleID = edm::FileInPath ( fpMvaWeightFiles[ifile].c_str () ).fullPath ();
91
- mvaWeightFiles_.push_back (path_mvaWeightFileEleID);
92
- }
93
-
94
- mvaID_->initialize (method_, type_, manualCat_, mvaWeightFiles_);
95
-
63
+ verbose_ = iConfig.getUntrackedParameter <bool >(" verbose" , false );
64
+ vertexToken_ = consumes<reco::VertexCollection>(iConfig.getParameter <edm::InputTag>(" vertexTag" ));
65
+ electronToken_ = consumes<reco::GsfElectronCollection>(iConfig.getParameter <edm::InputTag>(" electronTag" ));
66
+ eventrhoToken_ = consumes<double >(edm::InputTag (" kt6PFJets" , " rho" ));
67
+ reducedEBRecHitCollectionToken_ = consumes<EcalRecHitCollection>( iConfig.getParameter <edm::InputTag>(" reducedEBRecHitCollection" ) );
68
+ reducedEERecHitCollectionToken_ = consumes<EcalRecHitCollection>( iConfig.getParameter <edm::InputTag>(" reducedEERecHitCollection" ) );
69
+ method_ = iConfig.getParameter <string>(" method" );
70
+ std::vector<string> fpMvaWeightFiles = iConfig.getParameter <std::vector<std::string> >(" mvaWeightFile" );
71
+ Trig_ = iConfig.getParameter <bool >(" Trig" );
72
+ NoIP_ = iConfig.getParameter <bool >(" NoIP" );
73
+
74
+ produces<edm::ValueMap<float > >(" " );
75
+
76
+ mvaID_ = new EGammaMvaEleEstimator ();
77
+
78
+ EGammaMvaEleEstimator::MVAType type_;
79
+ if (Trig_ && !NoIP_){type_ = EGammaMvaEleEstimator::kTrig ;}
80
+
81
+ if (Trig_ && NoIP_){type_ = EGammaMvaEleEstimator::kTrigNoIP ;}
82
+
83
+ if (!Trig_){type_ = EGammaMvaEleEstimator::kNonTrig ;}
84
+
85
+ bool manualCat_ = true ;
86
+
87
+ string path_mvaWeightFileEleID;
88
+ for (unsigned ifile=0 ; ifile < fpMvaWeightFiles.size () ; ++ifile) {
89
+ path_mvaWeightFileEleID = edm::FileInPath ( fpMvaWeightFiles[ifile].c_str () ).fullPath ();
90
+ mvaWeightFiles_.push_back (path_mvaWeightFileEleID);
91
+ }
92
+
93
+ mvaID_->initialize (method_, type_, manualCat_, mvaWeightFiles_);
94
+
96
95
}
97
96
98
97
99
98
ElectronIdMVAProducer::~ElectronIdMVAProducer ()
100
99
{
101
-
102
- // do anything here that needs to be done at desctruction time
103
- // (e.g. close files, deallocate resources etc.)
104
-
100
+
101
+ // do anything here that needs to be done at desctruction time
102
+ // (e.g. close files, deallocate resources etc.)
103
+
105
104
}
106
105
107
106
@@ -111,64 +110,64 @@ ElectronIdMVAProducer::~ElectronIdMVAProducer()
111
110
112
111
// ------------ method called on each new Event ------------
113
112
bool ElectronIdMVAProducer::filter (edm::Event& iEvent, const edm::EventSetup& iSetup) {
114
- using namespace edm ;
115
-
116
- std::auto_ptr<edm::ValueMap<float > > out (new edm::ValueMap<float >() );
117
-
118
- Handle <reco::VertexCollection> vertexCollection;
119
- iEvent.getByToken (vertexToken_, vertexCollection);
120
-
121
- Vertex dummy;
122
- const Vertex *pv = &dummy;
123
- if ( vertexCollection->size () != 0 ) {
124
- pv = &*vertexCollection->begin ();
125
- } else { // create a dummy PV
126
- Vertex::Error e;
127
- e (0 , 0 ) = 0.0015 * 0.0015 ;
128
- e (1 , 1 ) = 0.0015 * 0.0015 ;
129
- e (2 , 2 ) = 15 . * 15 .;
130
- Vertex::Point p (0 , 0 , 0 );
131
- dummy = Vertex (p, e, 0 , 0 , 0 );
132
- }
133
-
134
- EcalClusterLazyTools lazyTools (iEvent, iSetup, reducedEBRecHitCollection_, reducedEERecHitCollection_ );
135
-
136
- edm::ESHandle<TransientTrackBuilder> builder;
137
- iSetup.get <TransientTrackRecord>().get (" TransientTrackBuilder" , builder);
138
- TransientTrackBuilder thebuilder = *(builder.product ());
139
-
140
- Handle <reco::GsfElectronCollection> egCollection;
141
- iEvent.getByToken (electronToken_,egCollection);
142
- const reco::GsfElectronCollection egCandidates = (*egCollection.product ());
143
-
144
- _Rho=0 ;
145
- edm::Handle <double > rhoPtr;
146
- iEvent.getByToken (eventrhoToken_,rhoPtr);
147
- _Rho=*rhoPtr;
148
-
149
- std::vector<float > values;
150
- values.reserve (egCollection->size ());
151
-
152
- for ( reco::GsfElectronCollection::const_iterator egIter = egCandidates.begin (); egIter != egCandidates.end (); ++egIter) {
153
-
154
- double mvaVal = -999999 ;
155
- if (!NoIP_){
156
- mvaVal = mvaID_->mvaValue ( *egIter, *pv,thebuilder,lazyTools, verbose_);
157
- }
158
- if (NoIP_){
159
- mvaVal = mvaID_->mvaValue ( *egIter, *pv, _Rho,/* thebuilder,*/ lazyTools, verbose_);
160
- }
161
-
162
- values.push_back ( mvaVal );
163
- }
164
-
165
- edm::ValueMap<float >::Filler filler (*out);
166
- filler.insert (egCollection, values.begin (), values.end () );
167
- filler.fill ();
168
-
169
- iEvent.put (out);
170
-
171
- return true ;
113
+ using namespace edm ;
114
+
115
+ std::auto_ptr<edm::ValueMap<float > > out (new edm::ValueMap<float >() );
116
+
117
+ Handle <reco::VertexCollection> vertexCollection;
118
+ iEvent.getByToken (vertexToken_, vertexCollection);
119
+
120
+ Vertex dummy;
121
+ const Vertex *pv = &dummy;
122
+ if ( vertexCollection->size () != 0 ) {
123
+ pv = &*vertexCollection->begin ();
124
+ } else { // create a dummy PV
125
+ Vertex::Error e;
126
+ e (0 , 0 ) = 0.0015 * 0.0015 ;
127
+ e (1 , 1 ) = 0.0015 * 0.0015 ;
128
+ e (2 , 2 ) = 15 . * 15 .;
129
+ Vertex::Point p (0 , 0 , 0 );
130
+ dummy = Vertex (p, e, 0 , 0 , 0 );
131
+ }
132
+
133
+ EcalClusterLazyTools lazyTools (iEvent, iSetup, reducedEBRecHitCollectionToken_, reducedEERecHitCollectionToken_ );
134
+
135
+ edm::ESHandle<TransientTrackBuilder> builder;
136
+ iSetup.get <TransientTrackRecord>().get (" TransientTrackBuilder" , builder);
137
+ TransientTrackBuilder thebuilder = *(builder.product ());
138
+
139
+ Handle <reco::GsfElectronCollection> egCollection;
140
+ iEvent.getByToken (electronToken_,egCollection);
141
+ const reco::GsfElectronCollection egCandidates = (*egCollection.product ());
142
+
143
+ _Rho=0 ;
144
+ edm::Handle <double > rhoPtr;
145
+ iEvent.getByToken (eventrhoToken_,rhoPtr);
146
+ _Rho=*rhoPtr;
147
+
148
+ std::vector<float > values;
149
+ values.reserve (egCollection->size ());
150
+
151
+ for ( reco::GsfElectronCollection::const_iterator egIter = egCandidates.begin (); egIter != egCandidates.end (); ++egIter) {
152
+
153
+ double mvaVal = -999999 ;
154
+ if (!NoIP_){
155
+ mvaVal = mvaID_->mvaValue ( *egIter, *pv,thebuilder,lazyTools, verbose_);
156
+ }
157
+ if (NoIP_){
158
+ mvaVal = mvaID_->mvaValue ( *egIter, *pv, _Rho,/* thebuilder,*/ lazyTools, verbose_);
159
+ }
160
+
161
+ values.push_back ( mvaVal );
162
+ }
163
+
164
+ edm::ValueMap<float >::Filler filler (*out);
165
+ filler.insert (egCollection, values.begin (), values.end () );
166
+ filler.fill ();
167
+
168
+ iEvent.put (out);
169
+
170
+ return true ;
172
171
}
173
172
174
173
// define this as a plug-in
0 commit comments