CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_5/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::produce(edm::Event& ev, const edm::EventSetup& es)
00048 {
00049     // Read inputs, and count total seeds
00050     size_t ninputs = inputCollections_.size();
00051     size_t nseeds = 0;
00052     std::vector<Handle<TrajectorySeedCollection > > seedCollections(ninputs);
00053     for (size_t i = 0; i < ninputs; ++i) {
00054         ev.getByLabel(inputCollections_[i], seedCollections[i]);
00055         nseeds += seedCollections[i]->size();
00056     }
00057 
00058     // Prepare output collections, with the correct capacity
00059     std::auto_ptr<TrajectorySeedCollection> result(new TrajectorySeedCollection());
00060     result->reserve( nseeds );
00061 
00062     // Write into output collection
00063     unsigned int iSC=0,iSC_max=seedCollections.size();
00064     for (;iSC!=iSC_max;++iSC){
00065       Handle<TrajectorySeedCollection> & collection=seedCollections[iSC];
00066       if (reKeing_ && !(clusterRemovalInfos_[iSC]==edm::InputTag(""))){
00067         ClusterRemovalRefSetter refSetter(ev, clusterRemovalInfos_[iSC]);
00068         
00069         for (TrajectorySeedCollection::const_iterator iS=collection->begin();
00070              iS!=collection->end();++iS){
00071           TrajectorySeed::recHitContainer  newRecHitContainer;
00072           newRecHitContainer.reserve(iS->nHits());
00073           TrajectorySeed::const_iterator iH=iS->recHits().first;
00074           TrajectorySeed::const_iterator iH_end=iS->recHits().second;
00075           //loop seed rechits, copy over and rekey.
00076           for (;iH!=iH_end;++iH){
00077             newRecHitContainer.push_back(*iH);
00078             refSetter.reKey(&newRecHitContainer.back());
00079           }
00080           result->push_back(TrajectorySeed(iS->startingState(),
00081                                            std::move(newRecHitContainer),
00082                                            iS->direction()));
00083         }
00084       }else{
00085         //just insert the new seeds as they are
00086         result->insert(result->end(), collection->begin(), collection->end());
00087       }
00088     }
00089 
00090     // Save result into the event
00091     ev.put(result);
00092 }