forked from cms-sw/cmssw
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Shervin
committed
May 2, 2015
1 parent
f699022
commit e954882
Showing
5 changed files
with
99 additions
and
116 deletions.
There are no files selected for viewing
172 changes: 74 additions & 98 deletions
172
Calibration/EcalAlCaRecoProducers/plugins/AlCaElectronTracksReducer.cc
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,98 +1,74 @@ | ||
#include "Calibration/EcalAlCaRecoProducers/plugins/AlCaElectronTracksReducer.h" | ||
#include "DataFormats/TrackReco/interface/Track.h" | ||
#include "DataFormats/TrackReco/interface/TrackFwd.h" | ||
|
||
#include "DataFormats/EgammaCandidates/interface/GsfElectron.h" | ||
#include "DataFormats/EgammaCandidates/interface/GsfElectronFwd.h" | ||
|
||
//#define ALLrecHits | ||
//#define DEBUG | ||
|
||
//#define QUICK -> if commented loop over the recHits of the SC and add them to the list of recHits to be saved | ||
// comment it if you want a faster module but be sure the window is large enough | ||
|
||
AlCaElectronTracksReducer::AlCaElectronTracksReducer(const edm::ParameterSet& iConfig) | ||
{ | ||
|
||
//gsfTracksLabel_ = iConfig.getParameter< edm::InputTag > ("gsfTracksLabel"); | ||
generalTracksLabel_ = iConfig.getParameter< edm::InputTag > ("generalTracksLabel"); | ||
generalTracksExtraLabel_ = iConfig.getParameter< edm::InputTag > ("generalTracksExtraLabel"); | ||
electronLabel_ = iConfig.getParameter< edm::InputTag > ("electronLabel"); | ||
|
||
// name of the output collection | ||
//gsfTracksCollection_ = iConfig.getParameter<std::string>("gsfTracksCollection"); | ||
alcaTrackExtraCollection_ = iConfig.getParameter<std::string>("alcaTrackExtraCollection"); | ||
|
||
//register your products | ||
produces< reco::TrackCollection > (alcaTrackCollection_) ; | ||
produces< reco::TrackExtraCollection > (alcaTrackExtraCollection_) ; | ||
|
||
} | ||
|
||
|
||
AlCaElectronTracksReducer::~AlCaElectronTracksReducer() | ||
{} | ||
|
||
|
||
// ------------ method called to produce the data ------------ | ||
void AlCaElectronTracksReducer::produce (edm::Event& iEvent, | ||
const edm::EventSetup& iSetup) | ||
{ | ||
using namespace edm; | ||
using namespace std; | ||
using namespace reco; | ||
|
||
// get the ECAL geometry: | ||
// ESHandle<CaloGeometry> geoHandle; | ||
// iSetup.get<CaloGeometryRecord>().get(geoHandle); | ||
|
||
// edm::ESHandle<CaloTopology> theCaloTopology; | ||
// iSetup.get<CaloTopologyRecord>().get(theCaloTopology); | ||
// const CaloTopology *caloTopology = theCaloTopology.product(); | ||
|
||
// Get GSFElectrons | ||
Handle<reco::GsfElectronCollection> pElectrons; | ||
iEvent.getByLabel(electronLabel_, pElectrons); | ||
// if (!pElectrons.isValid()) { | ||
// edm::LogError ("reading") << electronLabel_ << " not found" ; | ||
// return ; | ||
// } | ||
|
||
const reco::GsfElectronCollection * electronCollection = | ||
pElectrons.product(); | ||
|
||
Handle<TrackCollection> generalTracksHandle; | ||
iEvent.getByLabel(generalTracksLabel_,generalTracksHandle); | ||
|
||
Handle<TrackExtraCollection> generalTracksExtraHandle; | ||
iEvent.getByLabel(generalTracksExtraLabel_,generalTracksExtraHandle); | ||
|
||
//Create empty output collections | ||
std::auto_ptr< TrackCollection > redGeneralTracksCollection (new TrackCollection) ; | ||
std::auto_ptr< TrackExtraCollection > redGeneralTracksExtraCollection (new TrackExtraCollection) ; | ||
|
||
reco::GsfElectronCollection::const_iterator eleIt; | ||
|
||
for (eleIt=electronCollection->begin(); eleIt!=electronCollection->end(); eleIt++) { | ||
// barrel | ||
#ifndef CMSSW42X | ||
TrackRef track = (eleIt-> closestTrack() ) ; | ||
#else | ||
TrackRef track = (eleIt-> closestCtfTrackRef()); | ||
#endif | ||
if(track.isNull()){ | ||
// edm::LogError("track") << "Track Ref not found " << eleIt->energy() << "\t" << eleIt->eta(); | ||
continue; | ||
} | ||
redGeneralTracksCollection->push_back(*track); | ||
if(generalTracksExtraHandle.isValid()) redGeneralTracksExtraCollection->push_back(*(track->extra())); | ||
} | ||
|
||
//Put selected information in the event | ||
iEvent.put( redGeneralTracksCollection, alcaTrackCollection_ ); | ||
iEvent.put( redGeneralTracksExtraCollection, alcaTrackExtraCollection_ ); | ||
} | ||
|
||
|
||
DEFINE_FWK_MODULE(AlCaElectronTracksReducer); | ||
|
||
#include "Calibration/EcalAlCaRecoProducers/plugins/AlCaElectronTracksReducer.h" | ||
#include "DataFormats/TrackReco/interface/Track.h" | ||
#include "DataFormats/EgammaCandidates/interface/GsfElectron.h" | ||
|
||
AlCaElectronTracksReducer::AlCaElectronTracksReducer(const edm::ParameterSet& iConfig) | ||
{ | ||
generalTracksToken_ = consumes<reco::TrackCollection>(iConfig.getParameter< edm::InputTag > ("generalTracksLabel")); | ||
generalTracksExtraToken_ = consumes<reco::TrackExtraCollection>(iConfig.getParameter< edm::InputTag > ("generalTracksExtraLabel")); | ||
electronToken_ = consumes<reco::GsfElectronCollection>(iConfig.getParameter< edm::InputTag > ("electronLabel")); | ||
|
||
// name of the output collection | ||
alcaTrackExtraCollection_ = iConfig.getParameter<std::string>("alcaTrackExtraCollection"); | ||
|
||
//register your products | ||
produces< reco::TrackCollection > (alcaTrackCollection_) ; | ||
produces< reco::TrackExtraCollection > (alcaTrackExtraCollection_) ; | ||
|
||
} | ||
|
||
|
||
AlCaElectronTracksReducer::~AlCaElectronTracksReducer() | ||
{} | ||
|
||
|
||
// ------------ method called to produce the data ------------ | ||
void AlCaElectronTracksReducer::produce (edm::Event& iEvent, | ||
const edm::EventSetup& iSetup) | ||
{ | ||
using namespace edm; | ||
using namespace std; | ||
using namespace reco; | ||
|
||
|
||
// Get GSFElectrons | ||
Handle<reco::GsfElectronCollection> pElectrons; | ||
iEvent.getByToken(electronToken_, pElectrons); | ||
|
||
const reco::GsfElectronCollection * electronCollection = pElectrons.product(); | ||
|
||
Handle<TrackCollection> generalTracksHandle; | ||
iEvent.getByToken(generalTracksToken_,generalTracksHandle); | ||
|
||
Handle<TrackExtraCollection> generalTracksExtraHandle; | ||
iEvent.getByToken(generalTracksExtraToken_,generalTracksExtraHandle); | ||
|
||
//Create empty output collections | ||
std::auto_ptr< TrackCollection > redGeneralTracksCollection (new TrackCollection) ; | ||
std::auto_ptr< TrackExtraCollection > redGeneralTracksExtraCollection (new TrackExtraCollection) ; | ||
|
||
reco::GsfElectronCollection::const_iterator eleIt; | ||
|
||
for (eleIt=electronCollection->begin(); eleIt!=electronCollection->end(); eleIt++) { | ||
// barrel | ||
#ifndef CMSSW42X | ||
TrackRef track = (eleIt-> closestTrack() ) ; | ||
#else | ||
TrackRef track = (eleIt-> closestCtfTrackRef()); | ||
#endif | ||
if(track.isNull()){ | ||
// edm::LogError("track") << "Track Ref not found " << eleIt->energy() << "\t" << eleIt->eta(); | ||
continue; | ||
} | ||
redGeneralTracksCollection->push_back(*track); | ||
if(generalTracksExtraHandle.isValid()) redGeneralTracksExtraCollection->push_back(*(track->extra())); | ||
} | ||
|
||
//Put selected information in the event | ||
iEvent.put( redGeneralTracksCollection, alcaTrackCollection_ ); | ||
iEvent.put( redGeneralTracksExtraCollection, alcaTrackExtraCollection_ ); | ||
} | ||
|
||
|
||
DEFINE_FWK_MODULE(AlCaElectronTracksReducer); | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,7 @@ | ||
import FWCore.ParameterSet.Config as cms | ||
|
||
PUDumper = cms.EDAnalyzer('PUDumper', | ||
pileupSummary = cms.InputTag("addPileupInfo"), | ||
# vertexCollection = cms.InputTag('offlinePrimaryVertices'), | ||
# foutName = cms.string("ZShervinNtuple.root"), | ||
) |