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

Consumes famosproducer #3245

Merged
merged 5 commits into from Apr 8, 2014
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 19 additions & 3 deletions FastSimulation/EventProducer/interface/FamosProducer.h
Expand Up @@ -3,6 +3,11 @@

#include "FWCore/Framework/interface/EDProducer.h"

#include "DataFormats/HepMCCandidate/interface/GenParticle.h"
#include "DataFormats/BeamSpot/interface/BeamSpot.h"
#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h" // future obsolete
#include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h" // obsolete

class FamosManager;
class ParameterSet;
class Event;
Expand All @@ -28,10 +33,21 @@ class FamosProducer : public edm::EDProducer
FamosManager * famosManager_;
HepMC::GenEvent * evt_;
bool simulateMuons;
edm::InputTag theSourceLabel;
edm::InputTag theGenParticleLabel;
edm::InputTag theBeamSpotLabel;

// labels
edm::InputTag sourceLabel; // FUTURE OBSOLETE
edm::InputTag genParticleLabel;
edm::InputTag beamSpotLabel;

// tokens
edm::EDGetTokenT<reco::BeamSpot> beamSpotToken;
edm::EDGetTokenT<reco::GenParticleCollection> genParticleToken;
// FUTURE OBSOLETE CODE
edm::EDGetTokenT<edm::HepMCProduct> sourceToken;
edm::EDGetTokenT<edm::HepMCProduct> puToken;
// OBSOLETE CODE
edm::EDGetTokenT<CrossingFrame<edm::HepMCProduct> > mixSourceToken;
edm::EDGetTokenT<reco::GenParticleCollection> mixGenParticleToken;
};

#endif
61 changes: 39 additions & 22 deletions FastSimulation/EventProducer/src/FamosProducer.cc
Expand Up @@ -3,7 +3,6 @@
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"

#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"
#include "SimDataFormats/CaloHit/interface/PCaloHitContainer.h"
#include "SimDataFormats/TrackingHit/interface/PSimHitContainer.h"

Expand All @@ -22,12 +21,10 @@
#include "FastSimulation/Calorimetry/interface/CalorimetryManager.h"
#include "FastSimulation/TrajectoryManager/interface/TrajectoryManager.h"
#include "FastSimulation/Utilities/interface/RandomEngineAndDistribution.h"
#include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h"
#include "DataFormats/HepMCCandidate/interface/GenParticle.h"
#include "Geometry/Records/interface/IdealGeometryRecord.h"

#include "HepMC/GenEvent.h"
#include "HepMC/GenVertex.h"
#include "HepMC/GenEvent.h"

#include <iostream>
#include <memory>
Expand All @@ -49,12 +46,25 @@ FamosProducer::FamosProducer(edm::ParameterSet const & p)
if ( simulateMuons ) produces<edm::SimTrackContainer>("MuonSimTracks");

// The generator input label
theSourceLabel = p.getParameter<edm::InputTag>("SourceLabel");
theGenParticleLabel = p.getParameter<edm::InputTag>("GenParticleLabel");
theBeamSpotLabel = p.getParameter<edm::InputTag>("BeamSpotLabel");

sourceLabel = p.getParameter<edm::InputTag>("SourceLabel");
genParticleLabel = p.getParameter<edm::InputTag>("GenParticleLabel");
beamSpotLabel = p.getParameter<edm::InputTag>("BeamSpotLabel");

// consume declarations
beamSpotToken = consumes<reco::BeamSpot>(beamSpotLabel);
genParticleToken = consumes<reco::GenParticleCollection>(genParticleLabel);
// FUTURE OBSOLETE CODE
sourceToken = consumes<edm::HepMCProduct>(sourceLabel);
edm::InputTag _label = edm::InputTag("famosPileUp","PileUpEvents");
puToken = consumes<edm::HepMCProduct>(_label);
// OBSOLETE CODE
_label = edm::InputTag("mixGenPU","generator");
mixSourceToken = consumes<CrossingFrame<edm::HepMCProduct> >(_label);
_label = edm::InputTag("genParticlesFromMixingModule");
mixGenParticleToken = consumes<reco::GenParticleCollection>(_label);

// famos manager
famosManager_ = new FamosManager(p);

}

FamosProducer::~FamosProducer()
Expand All @@ -77,7 +87,7 @@ void FamosProducer::produce(edm::Event & iEvent, const edm::EventSetup & es)

// // The beam spot position
edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
iEvent.getByLabel(theBeamSpotLabel,recoBeamSpotHandle);
iEvent.getByToken(beamSpotToken,recoBeamSpotHandle);
math::XYZPoint BSPosition_ = recoBeamSpotHandle->position();

//Retrieve tracker topology from geometry
Expand All @@ -101,21 +111,23 @@ void FamosProducer::produce(edm::Event & iEvent, const edm::EventSetup & es)
PrimaryVertexGenerator* theVertexGenerator = fevt->thePrimaryVertexGenerator();


const reco::GenParticleCollection* myGenParticlesXF = 0;
const reco::GenParticleCollection* myGenParticlesXF = 0; //OBSOLETE
const reco::GenParticleCollection* myGenParticles = 0;
const HepMC::GenEvent* thePUEvents = 0;

// BEGIN OBSOLETE CODE
Handle<CrossingFrame<HepMCProduct> > theHepMCProductCrossingFrame;
bool isPileUpXF = iEvent.getByLabel("mixGenPU","generator",theHepMCProductCrossingFrame);

bool isPileUpXF = iEvent.getByToken(mixSourceToken,theHepMCProductCrossingFrame);
if (isPileUpXF){// take the GenParticle from crossingframe event collection, if it exists
Handle<reco::GenParticleCollection> genEvtXF;
bool genPartXF = iEvent.getByLabel("genParticlesFromMixingModule",genEvtXF);
bool genPartXF = iEvent.getByToken(mixGenParticleToken,genEvtXF);
if(genPartXF) myGenParticlesXF = &(*genEvtXF);
}
else{// otherwise, use the old famos PU
// END OBSOLETE CODE
// Get the generated signal event
bool source = iEvent.getByLabel(theSourceLabel,theHepMCProduct);
// BEGIN FUTURE OBSOLETE CODE
bool source = iEvent.getByToken(sourceToken,theHepMCProduct);
if ( source ) {
myGenEvent = theHepMCProduct->GetEvent();
// First rotate in case of beam crossing angle (except if done already)
Expand All @@ -127,13 +139,14 @@ void FamosProducer::produce(edm::Event & iEvent, const edm::EventSetup & es)
}

fevt->setBeamSpot(BSPosition_);
// GEN LEVEL INFO NOT IN HEPMC FORMAT
// In case there is no HepMCProduct, seek a genParticle Candidate Collection
bool genPart = false;
if ( !myGenEvent ) {
//END FUTURE OBSOLETE CODE
// Look for the particle CandidateCollection
Handle<reco::GenParticleCollection> genEvt;
genPart = iEvent.getByLabel(theGenParticleLabel,genEvt);
genPart = iEvent.getByToken(genParticleToken,genEvt);
if ( genPart ) myGenParticles = &(*genEvt);
}

Expand All @@ -142,21 +155,24 @@ void FamosProducer::produce(edm::Event & iEvent, const edm::EventSetup & es)
<< "any form (HepMCProduct, genParticles)" << std::endl
<< "Please check SourceLabel or GenParticleLabel" << std::endl;

// BEGIN FUTURE OBSOLETE CODE
// Get the pile-up events from the pile-up producer
// There might be no pile-up events, by the way, in that case, just continue
Handle<HepMCProduct> thePileUpEvents;
bool isPileUp = iEvent.getByLabel("famosPileUp","PileUpEvents",thePileUpEvents);
bool isPileUp = iEvent.getByToken(puToken,thePileUpEvents);
thePUEvents = isPileUp ? thePileUpEvents->GetEvent() : 0;
// END FUTURE OBSOLETE CODE
}//end else


// pass the event to the Famos Manager for propagation and simulation
if (myGenParticlesXF) {
if (myGenParticlesXF) {// OBSOLETE OPTION
famosManager_->reconstruct(myGenParticlesXF,tTopo, &random);
} else {
famosManager_->reconstruct(myGenEvent,myGenParticles,thePUEvents,tTopo, &random);
famosManager_->reconstruct(myGenEvent,myGenParticles,thePUEvents,tTopo, &random); // FUTURE OBSOLETE ARGUMENTS: myGenEvents, thePUEvents
}

// BEGIN FUTURE OBSOLETE CODE
// Set the vertex back to the HepMCProduct (except if it was smeared already)
if ( myGenEvent ) {
if ( theVertexGenerator ) {
Expand All @@ -168,7 +184,8 @@ void FamosProducer::produce(edm::Event & iEvent, const edm::EventSetup & es)
if ( fabs(theVertexGenerator->Z()) > 1E-10 ) theHepMCProduct->applyVtxGen( &theVertex );
}
}

// END FUTURE OBSOLETE CODE

CalorimetryManager * calo = famosManager_->calorimetryManager();
TrajectoryManager * tracker = famosManager_->trackerManager();

Expand Down
16 changes: 13 additions & 3 deletions FastSimulation/MuonSimHitProducer/interface/MuonSimHitProducer.h
Expand Up @@ -37,7 +37,8 @@ class MaterialEffects;
class TrajectoryStateOnSurface;
class Propagator;
class RandomEngineAndDistribution;

class SimTrack;
class SimVertex;
/*
namespace reco {
class Muon;
Expand Down Expand Up @@ -93,10 +94,19 @@ class MuonSimHitProducer : public edm::EDProducer {
RandomEngineAndDistribution const*);


// ----------- parameters ----------------------------
// ----------- parameters ----------------------------
bool fullPattern_;
bool doL1_ , doL3_ , doGL_;
std::string theSimModuleLabel_ , theSimModuleProcess_, theTrkModuleLabel_ ;

// tags
edm::InputTag simMuonLabel;
edm::InputTag simVertexLabel;

// tokens
edm::EDGetTokenT<std::vector<SimTrack> > simMuonToken;
edm::EDGetTokenT<std::vector<SimVertex> > simVertexToken;


};

#endif
17 changes: 12 additions & 5 deletions FastSimulation/MuonSimHitProducer/src/MuonSimHitProducer.cc
Expand Up @@ -95,6 +95,11 @@ MuonSimHitProducer::MuonSimHitProducer(const edm::ParameterSet& iConfig):
edm::ParameterSet serviceParameters =
iConfig.getParameter<edm::ParameterSet>("ServiceParameters");
theService = new MuonServiceProxy(serviceParameters);

// consumes
simMuonToken = consumes<std::vector<SimTrack> >(simMuonLabel);
simVertexToken = consumes<std::vector<SimVertex> >(simVertexLabel);

}

// ---- method called once each job just before starting event loop ----
Expand Down Expand Up @@ -160,8 +165,8 @@ MuonSimHitProducer::produce(edm::Event& iEvent,const edm::EventSetup& iSetup) {
std::vector<PSimHit> theRPCHits;

DirectMuonNavigation navigation(theService->detLayerGeometry());
iEvent.getByLabel(theSimModuleLabel_,theSimModuleProcess_,simMuons);
iEvent.getByLabel(theSimModuleLabel_,simVertices);
iEvent.getByToken(simMuonToken,simMuons);
iEvent.getByToken(simVertexToken,simVertices);

for ( unsigned int itrk=0; itrk<simMuons->size(); itrk++ ) {
const SimTrack &mySimTrack = (*simMuons)[itrk];
Expand Down Expand Up @@ -526,9 +531,11 @@ MuonSimHitProducer::readParameters(const edm::ParameterSet& fastMuons,
const edm::ParameterSet& fastTracks,
const edm::ParameterSet& matEff) {
// Muons
theSimModuleLabel_ = fastMuons.getParameter<std::string>("simModuleLabel");
theSimModuleProcess_ = fastMuons.getParameter<std::string>("simModuleProcess");
theTrkModuleLabel_ = fastMuons.getParameter<std::string>("trackModuleLabel");
std::string _simModuleLabel = fastMuons.getParameter<std::string>("simModuleLabel");
std::string _simModuleProcess = fastMuons.getParameter<std::string>("simModuleProcess");
simMuonLabel = edm::InputTag(_simModuleLabel,_simModuleProcess);
simVertexLabel = edm::InputTag(_simModuleLabel);

std::vector<double> simHitIneffDT = fastMuons.getParameter<std::vector<double> >("simHitDTIneffParameters");
std::vector<double> simHitIneffCSC = fastMuons.getParameter<std::vector<double> >("simHitCSCIneffParameters");
kDT = simHitIneffDT[0];
Expand Down
7 changes: 4 additions & 3 deletions FastSimulation/ParticleFlow/plugins/FSPFProducer.cc
Expand Up @@ -3,7 +3,6 @@
#include "FWCore/Utilities/interface/Exception.h"

#include "DataFormats/ParticleFlowCandidate/interface/PFCandidateFwd.h"
#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"
#include "DataFormats/Math/interface/LorentzVector.h"

using namespace std;
Expand All @@ -25,7 +24,9 @@ FSPFProducer::FSPFProducer(const edm::ParameterSet& iConfig) {
middle_th = iConfig.getParameter<double>("middle_th");
// register products
produces<reco::PFCandidateCollection>();


// consumes
pfCandidateToken = consumes<reco::PFCandidateCollection>(labelPFCandidateCollection_);
}

FSPFProducer::~FSPFProducer() {}
Expand All @@ -35,7 +36,7 @@ FSPFProducer::produce(Event& iEvent,
const EventSetup& iSetup) {

Handle < reco::PFCandidateCollection > pfCandidates;
iEvent.getByLabel (labelPFCandidateCollection_, pfCandidates);
iEvent.getByToken (pfCandidateToken, pfCandidates);

auto_ptr< reco::PFCandidateCollection > pOutputCandidateCollection(new PFCandidateCollection);

Expand Down
5 changes: 4 additions & 1 deletion FastSimulation/ParticleFlow/plugins/FSPFProducer.h
Expand Up @@ -12,6 +12,8 @@
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"

#include "DataFormats/ParticleFlowCandidate/interface/PFCandidate.h"

class PFCandidate;

class FSPFProducer : public edm::EDProducer {
Expand All @@ -33,7 +35,8 @@ class FSPFProducer : public edm::EDProducer {
std::vector<double> EM_HF_ScaleFactor;

double energy_threshold(double eta);


edm::EDGetTokenT<reco::PFCandidateCollection> pfCandidateToken;
};

#endif
21 changes: 14 additions & 7 deletions FastSimulation/Tracking/plugins/FastTrackMerger.cc
Expand Up @@ -10,12 +10,9 @@
#include "DataFormats/TrackerRecHit2D/interface/SiTrackerGSRecHit2DCollection.h"
#include "DataFormats/TrackerRecHit2D/interface/SiTrackerGSMatchedRecHit2DCollection.h"
#include "DataFormats/TrackReco/interface/TrackFwd.h"
#include "DataFormats/TrackReco/interface/Track.h"
#include "DataFormats/TrackReco/interface/TrackExtra.h"
#include "DataFormats/TrackReco/interface/TrackExtraFwd.h"

#include "TrackingTools/PatternTools/interface/Trajectory.h"
#include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h"

#include "FastSimulation/Tracking/plugins/FastTrackMerger.h"

Expand Down Expand Up @@ -82,6 +79,16 @@ FastTrackMerger::FastTrackMerger(const edm::ParameterSet& conf)
produces<reco::TrackExtraCollection>();
produces<TrackingRecHitCollection>();
}

// consumes
for ( unsigned aProducer=0; aProducer<removeTrackProducers.size(); ++aProducer ) {
removeTrackTokens.push_back(consumes<reco::TrackCollection>(removeTrackProducers[aProducer]));
}
for ( unsigned aProducer=0; aProducer<trackProducers.size(); ++aProducer ) {
trackTokens.push_back(consumes<reco::TrackCollection>(trackProducers[aProducer]));
trajectoryTokens.push_back(consumes<std::vector<Trajectory> >(trackProducers[aProducer]));
assoMapTokens.push_back(consumes<TrajTrackAssociationCollection>(trackProducers[aProducer]));
}
}


Expand Down Expand Up @@ -147,7 +154,7 @@ FastTrackMerger::produce(edm::Event& e, const edm::EventSetup& es) {
// First, the tracks to be removed
std::set<unsigned> removeTracks;
for ( unsigned aProducer=0; aProducer<removeTrackProducers.size(); ++aProducer ) {
bool isTrackCollection = e.getByLabel(removeTrackProducers[aProducer],theTrackCollection);
bool isTrackCollection = e.getByToken(removeTrackTokens[aProducer],theTrackCollection);
if (!isTrackCollection) continue;
reco::TrackCollection::const_iterator aTrack = theTrackCollection->begin();
reco::TrackCollection::const_iterator lastTrack = theTrackCollection->end();
Expand All @@ -167,7 +174,7 @@ FastTrackMerger::produce(edm::Event& e, const edm::EventSetup& es) {
// Loop on the track producers to be merged
for ( unsigned aProducer=0; aProducer<trackProducers.size(); ++aProducer ) {

bool isTrackCollection = e.getByLabel(trackProducers[aProducer],theTrackCollection);
bool isTrackCollection = e.getByToken(trackTokens[aProducer],theTrackCollection);
if ( ! isTrackCollection ) {
#ifdef FAMOS_DEBUG
std::cout << "***FastTrackMerger*** Warning! The track collection "
Expand Down Expand Up @@ -272,8 +279,8 @@ FastTrackMerger::produce(edm::Event& e, const edm::EventSetup& es) {
for ( ; aTrack!=lastTrack; ++aTrack ) nRecoHits+= aTrack->recHitsSize();
recoHits->reserve(nRecoHits); // This is to save some time at push_back.

e.getByLabel(trackProducers[aProducer],theTrajectoryCollection);
e.getByLabel(trackProducers[aProducer],theAssoMap);
e.getByToken(trajectoryTokens[aProducer],theTrajectoryCollection);
e.getByToken(assoMapTokens[aProducer],theAssoMap);

// The track collection iterators.
TrajTrackAssociationCollection::const_iterator anAssociation;
Expand Down
17 changes: 14 additions & 3 deletions FastSimulation/Tracking/plugins/FastTrackMerger.h
Expand Up @@ -4,6 +4,10 @@
#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Utilities/interface/InputTag.h"

#include "DataFormats/TrackReco/interface/Track.h"
#include "TrackingTools/PatternTools/interface/Trajectory.h"
#include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h"

#include <vector>
#include <string>

Expand All @@ -13,9 +17,10 @@ namespace edm {
class EventSetup;
}

namespace reco {
class Track;
}
//namespace reco {
// class Track;
//}


class FastTrackMerger : public edm::EDProducer
{
Expand Down Expand Up @@ -45,6 +50,12 @@ class FastTrackMerger : public edm::EDProducer
unsigned theMaxLostHits;
unsigned theMaxConsecutiveLostHits;

// consumes
std::vector<edm::EDGetTokenT<reco::TrackCollection> > removeTrackTokens;
std::vector<edm::EDGetTokenT<reco::TrackCollection> > trackTokens;
std::vector<edm::EDGetTokenT<std::vector<Trajectory> > > trajectoryTokens;
std::vector<edm::EDGetTokenT<TrajTrackAssociationCollection> > assoMapTokens;

};

#endif