CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_4_1_8_patch13/src/RecoTracker/TkSeedGenerator/plugins/SeedCombiner.cc

Go to the documentation of this file.
00001 #include "SeedCombiner.h"
00002 
00003 #include "FWCore/Framework/interface/Event.h"
00004 #include "FWCore/Framework/interface/EventSetup.h"
00005 #include "DataFormats/Common/interface/Handle.h"
00006 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00007 
00008 #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"
00009 
00010 #include "RecoTracker/TkTrackingRegions/interface/TrackingRegionProducerFactory.h"
00011 #include "RecoTracker/TkTrackingRegions/interface/TrackingRegionProducer.h"
00012 #include "RecoTracker/TkTrackingRegions/interface/TrackingRegion.h"
00013 
00014 #include "RecoTracker/TkTrackingRegions/interface/OrderedHitsGeneratorFactory.h"
00015 #include "RecoTracker/TkTrackingRegions/interface/OrderedHitsGenerator.h"
00016 
00017 #include "RecoTracker/TkSeedingLayers/interface/SeedComparitorFactory.h"
00018 #include "RecoTracker/TkSeedingLayers/interface/SeedComparitor.h"
00019 #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"
00020 
00021 #include "RecoTracker/TkSeedGenerator/interface/SeedGeneratorFromRegionHits.h"
00022 
00023 #include "RecoTracker/TrackProducer/interface/ClusterRemovalRefSetter.h"
00024 
00025 using namespace edm;
00026 //using namespace reco;
00027 
00028 SeedCombiner::SeedCombiner(
00029     const edm::ParameterSet& cfg) 
00030   : 
00031     inputCollections_(cfg.getParameter<std::vector<edm::InputTag> >("seedCollections"))
00032 {
00033     produces<TrajectorySeedCollection>();
00034     reKeing_=false;
00035     if (cfg.exists("clusterRemovalInfos")){
00036       clusterRemovalInfos_=cfg.getParameter<std::vector<edm::InputTag> >("clusterRemovalInfos");
00037       if (clusterRemovalInfos_.size()!=0 && clusterRemovalInfos_.size()==inputCollections_.size()) reKeing_=true;
00038     }
00039 }
00040 
00041 
00042 SeedCombiner::~SeedCombiner()
00043 {
00044 }
00045 
00046 
00047 void SeedCombiner::beginRun(edm::Run & run, const edm::EventSetup& es)
00048 {
00049 }
00050 
00051 void SeedCombiner::produce(edm::Event& ev, const edm::EventSetup& es)
00052 {
00053     // Read inputs, and count total seeds
00054     size_t ninputs = inputCollections_.size();
00055     size_t nseeds = 0;
00056     std::vector<Handle<TrajectorySeedCollection > > seedCollections(ninputs);
00057     for (size_t i = 0; i < ninputs; ++i) {
00058         ev.getByLabel(inputCollections_[i], seedCollections[i]);
00059         nseeds += seedCollections[i]->size();
00060     }
00061 
00062     // Prepare output collections, with the correct capacity
00063     std::auto_ptr<TrajectorySeedCollection> result(new TrajectorySeedCollection());
00064     result->reserve( nseeds );
00065 
00066     // Write into output collection
00067     unsigned int iSC=0,iSC_max=seedCollections.size();
00068     for (;iSC!=iSC_max;++iSC){
00069       Handle<TrajectorySeedCollection> & collection=seedCollections[iSC];
00070       if (reKeing_ && !(clusterRemovalInfos_[iSC]==edm::InputTag(""))){
00071         ClusterRemovalRefSetter refSetter(ev, clusterRemovalInfos_[iSC]);
00072         
00073         for (TrajectorySeedCollection::const_iterator iS=collection->begin();
00074              iS!=collection->end();++iS){
00075           TrajectorySeed::recHitContainer  newRecHitContainer;
00076           newRecHitContainer.reserve(iS->nHits());
00077           TrajectorySeed::const_iterator iH=iS->recHits().first;
00078           TrajectorySeed::const_iterator iH_end=iS->recHits().second;
00079           //loop seed rechits, copy over and rekey.
00080           for (;iH!=iH_end;++iH){
00081             newRecHitContainer.push_back(*iH);
00082             refSetter.reKey(&newRecHitContainer.back());
00083           }
00084           result->push_back(TrajectorySeed(iS->startingState(),
00085                                            newRecHitContainer,
00086                                            iS->direction()));
00087         }
00088       }else{
00089         //just insert the new seeds as they are
00090         result->insert(result->end(), collection->begin(), collection->end());
00091       }
00092     }
00093 
00094     // Save result into the event
00095     ev.put(result);
00096 }