Go to the documentation of this file.00001 #include "RecoTracker/NuclearSeedGenerator/interface/NuclearSeedsEDProducer.h"
00002 #include "RecoTracker/NuclearSeedGenerator/interface/NuclearInteractionFinder.h"
00003
00004 #include "FWCore/Utilities/interface/InputTag.h"
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006
00007 #include "DataFormats/TrackReco/interface/Track.h"
00008 #include "DataFormats/TrackReco/interface/TrackBase.h"
00009
00010 using namespace edm;
00011 using namespace std;
00012 using namespace reco;
00013
00014
00015
00016
00017
00018 NuclearSeedsEDProducer::NuclearSeedsEDProducer(const edm::ParameterSet& iConfig) : conf_(iConfig),
00019 improveSeeds(iConfig.getParameter<bool>("improveSeeds")),
00020 producer_(iConfig.getParameter<std::string>("producer"))
00021 {
00022 produces<TrajectorySeedCollection>();
00023 produces<TrajectoryToSeedsMap>();
00024
00025
00026 }
00027
00028
00029 NuclearSeedsEDProducer::~NuclearSeedsEDProducer()
00030 {
00031 }
00032
00033
00034
00035
00036
00037
00038
00039 void
00040 NuclearSeedsEDProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00041 {
00042 typedef TrajectoryMeasurement TM;
00043
00044 edm::Handle< TrajectoryCollection > m_TrajectoryCollection;
00045 iEvent.getByLabel( producer_, m_TrajectoryCollection );
00046
00047 LogDebug("NuclearSeedGenerator") << "Number of trajectory in event :" << m_TrajectoryCollection->size() << "\n";
00048
00049 std::auto_ptr<TrajectorySeedCollection> output(new TrajectorySeedCollection);
00050 std::auto_ptr<TrajectoryToSeedsMap> outAssoc(new TrajectoryToSeedsMap);
00051
00052
00053 theNuclearInteractionFinder->setEvent(iEvent);
00054 NavigationSetter setter( *(theNuclearInteractionFinder->nav()) );
00055
00056 std::vector<std::pair<int, int> > assocPair;
00057 int i=0;
00058
00059 for(std::vector<Trajectory>::const_iterator iTraj = m_TrajectoryCollection->begin(); iTraj != m_TrajectoryCollection->end(); iTraj++,i++) {
00060
00061
00062 theNuclearInteractionFinder->run( *iTraj );
00063
00064
00065 if( improveSeeds == true ) theNuclearInteractionFinder->improveSeeds();
00066
00067
00068 std::auto_ptr<TrajectorySeedCollection> newSeeds(theNuclearInteractionFinder->getPersistentSeeds());
00069 output->insert(output->end(), newSeeds->begin(), newSeeds->end());
00070
00071
00072 for(unsigned int j=0; j<newSeeds->size(); j++) {
00073 assocPair.push_back( std::make_pair( i, output->size()-newSeeds->size()+j ) );
00074 }
00075
00076 }
00077
00078 const edm::OrphanHandle<TrajectorySeedCollection> refprodTrajSeedColl = iEvent.put(output);
00079
00080 for(std::vector<std::pair<int, int> >::const_iterator iVecP = assocPair.begin(); iVecP != assocPair.end(); iVecP++) {
00081 outAssoc->insert(edm::Ref<TrajectoryCollection>(m_TrajectoryCollection,iVecP->first), edm::Ref<TrajectorySeedCollection>(refprodTrajSeedColl, iVecP->second));
00082 }
00083 iEvent.put(outAssoc);
00084
00085 }
00086
00087
00088 void
00089 NuclearSeedsEDProducer::beginRun(edm::Run & run, const edm::EventSetup& es)
00090 {
00091 theNuclearInteractionFinder = std::auto_ptr<NuclearInteractionFinder>(new NuclearInteractionFinder(es, conf_));
00092
00093 }
00094
00095 void NuclearSeedsEDProducer::endJob() {}
00096
00097