Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Low pT electrons (up to GsfTracks) for 10_5_X #25679

Merged
merged 22 commits into from
Jan 22, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
22 commits
Select commit Hold shift + click to select a range
ab2a292
GsfTracks using LowPtGsfElectronSeedProducer
bainbrid Dec 7, 2018
5d6eb57
updated model filenames
bainbrid Dec 10, 2018
86ff5eb
only consume PF or KF tracks depending on UsePfTracks configurable
bainbrid Dec 10, 2018
f0f4658
fillDescriptions
bainbrid Dec 10, 2018
0782b0e
consume collections only when necessary
bainbrid Dec 11, 2018
61e635f
removed commented line
bainbrid Dec 13, 2018
c5c761d
comments from perotta
bainbrid Dec 13, 2018
1b3dd57
fixing low pt eles for fastsim
Sam-Harper Dec 19, 2018
aa2ffc9
fixing low pt ele for phaseII
Sam-Harper Dec 19, 2018
d1a7fc5
explicitly specify low pT GsfTracks
bainbrid Dec 19, 2018
82d13fb
const args, comment from mauro
bainbrid Dec 19, 2018
5409453
dPhi(traj,clu) * charge
bainbrid Dec 19, 2018
1503e52
modifiers for BParking + triv tidy up
bainbrid Dec 19, 2018
7a3eedf
fix white space, tidy up
bainbrid Dec 20, 2018
8c156c8
move dphi,deta inside if clause; protect against chi2==0.
bainbrid Dec 20, 2018
7f6c948
rename to bParking (lower case)
bainbrid Jan 9, 2019
4a196ae
moved unncessary casts, changed others to c++ casts
bainbrid Jan 9, 2019
b912e0e
moved track fitter and cloner and builder into loop() method
bainbrid Jan 9, 2019
82d3b67
standard pT>1.0, bParking pT>0.5
bainbrid Jan 11, 2019
2a1ad40
use full ECAL RecHit collection
bainbrid Jan 21, 2019
8bc32f8
move lowPtGsfElectronSequence from highlevelreco to egammaHighLevelRe…
bainbrid Jan 21, 2019
f6a640b
move lowPtGsfElectronSequence from highlevelreco to egammaHighLevelRe…
bainbrid Jan 21, 2019
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Configuration/Eras/python/Modifier_bParking_cff.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
import FWCore.ParameterSet.Config as cms

bParking = cms.Modifier()
3 changes: 2 additions & 1 deletion Configuration/StandardSequences/python/Eras.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,8 @@ def __init__(self):
'tracker_apv_vfp30_2016', 'pf_badHcalMitigation', 'run2_miniAOD_80XLegacy','run2_miniAOD_94XFall17', 'run2_nanoAOD_92X',
'run2_nanoAOD_94XMiniAODv1', 'run2_nanoAOD_94XMiniAODv2', 'run2_nanoAOD_94X2016',
'run2_miniAOD_devel', 'run2_nanoAOD_102Xv1',
'hcalHardcodeConditions', 'hcalSkipPacker']
'hcalHardcodeConditions', 'hcalSkipPacker',
'bParking']
internalUseModChains = ['run2_2017_noTrackingModifier']


Expand Down
180 changes: 83 additions & 97 deletions FastSimulation/Tracking/plugins/ElectronSeedTrackRefFix.cc
Original file line number Diff line number Diff line change
@@ -1,126 +1,112 @@
#include "DataFormats/Common/interface/ValueMap.h"
#include "DataFormats/EgammaReco/interface/ElectronSeed.h"
#include "DataFormats/ParticleFlowReco/interface/PreId.h"
#include "DataFormats/TrackReco/interface/Track.h"
#include "FastSimulation/Tracking/plugins/ElectronSeedTrackRefFix.h"

#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "DataFormats/ParticleFlowReco/interface/PreId.h"
#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/EgammaReco/interface/ElectronSeed.h"
#include "DataFormats/Common/interface/ValueMap.h"
//
// class declaration
//



namespace {

template<typename VMType,typename HandleType>
const edm::OrphanHandle<edm::ValueMap<VMType> > addVMToEvent(edm::Event& event,const edm::Handle<HandleType>& handle,
std::vector<VMType> values,const std::string& label)
{
auto vMap = std::make_unique<edm::ValueMap<VMType> >();
typename edm::ValueMap<VMType>::Filler mapFiller(*vMap);
mapFiller.insert(handle,values.begin(),values.end());
mapFiller.fill();
return event.put(std::move(vMap),label);
}

template<typename T> edm::Handle<T> getHandle(const edm::Event& event,
const edm::EDGetTokenT<T>& token)
{
edm::Handle<T> handle;
event.getByToken(token,handle);
return handle;
}

//
// constructors and destructor
//

using namespace std;
using namespace reco;
using namespace edm;
}

ElectronSeedTrackRefFix::ElectronSeedTrackRefFix(const edm::ParameterSet& iConfig)
{

// read parameters
preidgsfLabel = iConfig.getParameter<string>("PreGsfLabel");
preidLabel= iConfig.getParameter<string>("PreIdLabel");
oldTracksTag = iConfig.getParameter<InputTag>("oldTrackCollection");
newTracksTag = iConfig.getParameter<InputTag>("newTrackCollection");
seedsTag = iConfig.getParameter<InputTag>("seedCollection");
idsTag = iConfig.getParameter<InputTag>("idCollection");
preidgsfLabel_ = iConfig.getParameter<std::string>("PreGsfLabel");
preidLabel_ = iConfig.getParameter<std::vector<std::string> >("PreIdLabel");
oldTracksTag_ = iConfig.getParameter<edm::InputTag>("oldTrackCollection");
newTracksTag_ = iConfig.getParameter<edm::InputTag>("newTrackCollection");
seedsTag_ = iConfig.getParameter<edm::InputTag>("seedCollection");
idsTag_ = iConfig.getParameter<std::vector<edm::InputTag>>("idCollection");

//register your products
produces<reco::ElectronSeedCollection>(preidgsfLabel);
produces<reco::PreIdCollection>(preidLabel);
produces<ValueMap<reco::PreIdRef> >(preidLabel);
produces<reco::ElectronSeedCollection>(preidgsfLabel_);
for(const auto& idLabel : preidLabel_){
produces<reco::PreIdCollection>(idLabel);
produces<edm::ValueMap<reco::PreIdRef> >(idLabel);
}

//create tokens
oldTracksToken = consumes<reco::TrackCollection>(oldTracksTag);
newTracksToken = consumes<reco::TrackCollection>(newTracksTag);
seedsToken = consumes<reco::ElectronSeedCollection>(seedsTag);
idsToken = consumes<reco::PreIdCollection >(idsTag);
idMapToken = consumes<ValueMap<reco::PreIdRef> >(idsTag) ;
}
oldTracksToken_ = consumes<reco::TrackCollection>(oldTracksTag_);
newTracksToken_ = consumes<reco::TrackCollection>(newTracksTag_);
seedsToken_ = consumes<reco::ElectronSeedCollection>(seedsTag_);
for(const auto& idTag: idsTag_){
idsToken_.emplace_back(consumes<reco::PreIdCollection >(idTag));
idMapToken_.emplace_back(consumes<edm::ValueMap<reco::PreIdRef> >(idTag));
}

}

ElectronSeedTrackRefFix::~ElectronSeedTrackRefFix()
{

// do anything here that needs to be done at desctruction time
// (e.g. close files, deallocate resources etc.)

// do anything here that needs to be done at desctruction time
// (e.g. close files, deallocate resources etc.)
}


//
// member functions
//

// ------------ method called to produce the data ------------
void
ElectronSeedTrackRefFix::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
void ElectronSeedTrackRefFix::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
{
using namespace edm;

Handle<TrackCollection> oldTracks;
iEvent.getByToken(oldTracksToken,oldTracks);

Handle<TrackCollection> newTracks;
iEvent.getByToken(newTracksToken,newTracks);

Handle<ElectronSeedCollection> iSeeds;
iEvent.getByToken(seedsToken,iSeeds);

Handle<PreIdCollection > iIds;
iEvent.getByToken(idsToken,iIds);

Handle<ValueMap<PreIdRef> > iIdMap;
iEvent.getByToken(idMapToken,iIdMap);

unique_ptr<ElectronSeedCollection> oSeeds(new ElectronSeedCollection);
unique_ptr<PreIdCollection> oIds(new PreIdCollection);
unique_ptr<ValueMap<PreIdRef> > oIdMap(new ValueMap<PreIdRef>);

ValueMap<PreIdRef>::Filler mapFiller(*oIdMap);

for(unsigned int s = 0;s<iSeeds->size();++s){
oSeeds->push_back(iSeeds->at(s));
TrackRef newTrackRef(newTracks,oSeeds->back().ctfTrack().index());
oSeeds->back().setCtfTrack(newTrackRef);
}

for(unsigned int i = 0;i<iIds->size();++i){
oIds->push_back(iIds->at(i));
TrackRef newTrackRef(newTracks,oIds->back().trackRef().index());
oIds->back().setTrack(newTrackRef);
}

iEvent.put(std::move(oSeeds),preidgsfLabel);
const edm::OrphanHandle<reco::PreIdCollection> preIdProd = iEvent.put(std::move(oIds),preidLabel);

vector<PreIdRef> values;
for(unsigned int t = 0;t<newTracks->size();++t){
if(t < oldTracks->size()){
TrackRef oldTrackRef(oldTracks,t);
values.push_back(PreIdRef(preIdProd,(*(iIdMap.product()))[oldTrackRef].index()));
}
else{
values.push_back(PreIdRef());
}
}
mapFiller.insert(newTracks,values.begin(),values.end());
mapFiller.fill();

auto oldTracks = getHandle(iEvent,oldTracksToken_);
auto newTracks = getHandle(iEvent,newTracksToken_);
auto iSeeds = getHandle(iEvent,seedsToken_);

auto oSeeds = std::make_unique<reco::ElectronSeedCollection>();
for(unsigned int s = 0;s<iSeeds->size();++s){
oSeeds->push_back(iSeeds->at(s));
reco::TrackRef newTrackRef(newTracks,oSeeds->back().ctfTrack().index());
oSeeds->back().setCtfTrack(newTrackRef);
}
iEvent.put(std::move(oSeeds),preidgsfLabel_);

for(size_t idNr = 0; idNr < idsTag_.size(); idNr++){
auto iIds = getHandle(iEvent,idsToken_[idNr]);
auto oIds = std::make_unique<reco::PreIdCollection>();
for(unsigned int i = 0;i<iIds->size();++i){
oIds->push_back(iIds->at(i));
reco::TrackRef newTrackRef(newTracks,oIds->back().trackRef().index());
oIds->back().setTrack(newTrackRef);
}
const edm::OrphanHandle<reco::PreIdCollection> preIdProd = iEvent.put(std::move(oIds),preidLabel_[idNr]);

auto iIdMap = getHandle(iEvent,idMapToken_[idNr]);
std::vector<reco::PreIdRef> values;
for(size_t trkNr = 0;trkNr<newTracks->size();++trkNr){
//low pt electron seeds do not make the idMaps so this is now optional to fill in a useful way
if(trkNr < oldTracks->size() && iIdMap.isValid()){
reco::TrackRef oldTrackRef(oldTracks,trkNr);
values.push_back(reco::PreIdRef(preIdProd,(*(iIdMap.product()))[oldTrackRef].index()));
}else values.push_back(reco::PreIdRef());
}
addVMToEvent(iEvent,newTracks,std::move(values),preidLabel_[idNr]);
}//end loop over ids

iEvent.put(std::move(oIdMap),preidLabel);
}

// ------------ method fills 'descriptions' with the allowed parameters for the module ------------
void
ElectronSeedTrackRefFix::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
void ElectronSeedTrackRefFix::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
//The following says we do not know what parameters are allowed so do no validation
// Please change this to state exactly what you do use, even if it is no parameters
edm::ParameterSetDescription desc;
Expand Down
51 changes: 24 additions & 27 deletions FastSimulation/Tracking/plugins/ElectronSeedTrackRefFix.h
Original file line number Diff line number Diff line change
@@ -1,44 +1,41 @@
// system include files
#ifndef FastSimulation_Tracking_ElectronSeedTrackRefFix_h
#define FastSimulation_Tracking_ElectronSeedTrackRefFix_h


#include <memory>

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "DataFormats/Common/interface/ValueMap.h"
#include "DataFormats/EgammaReco/interface/ElectronSeedFwd.h"
#include "DataFormats/ParticleFlowReco/interface/PreIdFwd.h"
#include "DataFormats/TrackReco/interface/TrackFwd.h"
#include "DataFormats/EgammaReco/interface/ElectronSeedFwd.h"

#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/stream/EDProducer.h"
#include "DataFormats/Common/interface/ValueMap.h"

#include <memory>

class ElectronSeedTrackRefFix : public edm::stream::EDProducer<> {
public:

public:

explicit ElectronSeedTrackRefFix(const edm::ParameterSet&);
~ElectronSeedTrackRefFix() override;

static void fillDescriptions(edm::ConfigurationDescriptions& descriptions);

private:
private:

void produce(edm::Event&, const edm::EventSetup&) override;

// ----------member data ---------------------------
edm::EDGetTokenT<reco::TrackCollection > newTracksToken;
edm::EDGetTokenT<reco::TrackCollection > oldTracksToken;
edm::EDGetTokenT<reco::ElectronSeedCollection > seedsToken;
edm::EDGetTokenT<reco::PreIdCollection > idsToken;
edm::EDGetTokenT<edm::ValueMap<reco::PreIdRef> > idMapToken;

std::string preidgsfLabel;
std::string preidLabel;
edm::InputTag oldTracksTag;
edm::InputTag newTracksTag;
edm::InputTag seedsTag;
edm::InputTag idsTag;
// member data

edm::EDGetTokenT<reco::TrackCollection > newTracksToken_;
edm::EDGetTokenT<reco::TrackCollection > oldTracksToken_;
edm::EDGetTokenT<reco::ElectronSeedCollection > seedsToken_;
std::vector<edm::EDGetTokenT<reco::PreIdCollection > > idsToken_;
std::vector<edm::EDGetTokenT<edm::ValueMap<reco::PreIdRef> > > idMapToken_;
std::string preidgsfLabel_;
std::vector<std::string> preidLabel_;
edm::InputTag oldTracksTag_;
edm::InputTag newTracksTag_;
edm::InputTag seedsTag_;
std::vector<edm::InputTag> idsTag_;

};

#endif
#endif // FastSimulation_Tracking_ElectronSeedTrackRefFix_h
4 changes: 2 additions & 2 deletions FastSimulation/Tracking/python/ElectronSeedTrackRefFix_cfi.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,9 @@
fixedTrackerDrivenElectronSeeds = cms.EDProducer(
"ElectronSeedTrackRefFix",
PreGsfLabel = cms.string("SeedsForGsf"),
PreIdLabel = cms.string("preid"),
PreIdLabel = cms.vstring("preid",),
oldTrackCollection = cms.InputTag("generalTracksBeforeMixing"),
newTrackCollection = cms.InputTag("generalTracks"),
seedCollection = cms.InputTag("trackerDrivenElectronSeeds","SeedsForGsf"),
idCollection = cms.InputTag("trackerDrivenElectronSeeds","preid")
idCollection = cms.VInputTag("trackerDrivenElectronSeeds:preid",)
)
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,8 @@
'keep *_hfRecoEcalCandidate_*_*',
'keep *_hfEMClusters_*_*',
'keep *_gedGsfElectronCores_*_*',
'keep *_gedGsfElectrons_*_*'
'keep *_gedGsfElectrons_*_*',
'keep recoGsfTracks_lowPtGsfEleGsfTracks_*_*'
)
)

Expand Down Expand Up @@ -96,7 +97,8 @@
'keep recoRecoEcalCandidates_hfRecoEcalCandidate_*_*',
'keep *_hfEMClusters_*_*',
'keep *_gedGsfElectronCores_*_*',
'keep *_gedGsfElectrons_*_*'
'keep *_gedGsfElectrons_*_*',
'keep recoGsfTracks_lowPtGsfEleGsfTracks_*_*'
)
)

Expand Down Expand Up @@ -141,7 +143,8 @@
'keep recoRecoEcalCandidates_hfRecoEcalCandidate_*_*',
'keep *_hfEMClusters_*_*',
'keep *_gedGsfElectronCores_*_*',
'keep *_gedGsfElectrons_*_*'
'keep *_gedGsfElectrons_*_*',
'keep recoGsfTracks_lowPtGsfEleGsfTracks_*_*'
)
)

Expand Down
3 changes: 2 additions & 1 deletion RecoEgamma/Configuration/python/RecoEgamma_cff.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import FWCore.ParameterSet.Config as cms

from RecoEgamma.EgammaElectronProducers.electronSequence_cff import *
from RecoEgamma.EgammaElectronProducers.lowPtGsfElectronSequence_cff import *
from RecoEgamma.EgammaElectronProducers.uncleanedOnlyElectronSequence_cff import *
from RecoEgamma.EgammaPhotonProducers.photonSequence_cff import *
from RecoEgamma.EgammaPhotonProducers.conversionSequence_cff import *
Expand Down Expand Up @@ -28,7 +29,7 @@
fastSim.toReplaceWith(egammaGlobalReco, _fastSim_egammaGlobalReco)

egammareco = cms.Sequence(electronSequence*conversionSequence*photonSequence)
egammaHighLevelRecoPrePF = cms.Sequence(gsfEcalDrivenElectronSequence*uncleanedOnlyElectronSequence*conversionSequence*photonSequence)
egammaHighLevelRecoPrePF = cms.Sequence(gsfEcalDrivenElectronSequence*uncleanedOnlyElectronSequence*conversionSequence*photonSequence*lowPtGsfElectronSequence)
# not commisoned and not relevant in FastSim (?):
fastSim.toReplaceWith(egammareco, egammareco.copyAndExclude([conversionSequence]))
fastSim.toReplaceWith(egammaHighLevelRecoPrePF,egammaHighLevelRecoPrePF.copyAndExclude([uncleanedOnlyElectronSequence,conversionSequence]))
Expand Down
10 changes: 10 additions & 0 deletions RecoEgamma/EgammaElectronProducers/BuildFile.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
<use name="CommonTools/MVAUtils"/>
<use name="CondFormats/EgammaObjects"/>
<use name="DataFormats/BeamSpot"/>
<use name="DataFormats/ParticleFlowReco"/>
<use name="DataFormats/TrackReco"/>
<use name="FWCore/ParameterSet"/>
<use name="RecoEcal/EgammaCoreTools"/>
<export>
<lib name="RecoEgammaEgammaElectronProducers"/>
</export>
Loading