CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
SeedCombiner.cc
Go to the documentation of this file.
1 #include "SeedCombiner.h"
2 
7 
9 
13 
16 
20 
22 
24 
25 using namespace edm;
26 //using namespace reco;
27 
29  const edm::ParameterSet& cfg)
30  :
31  inputCollections_(cfg.getParameter<std::vector<edm::InputTag> >("seedCollections"))
32 {
33  produces<TrajectorySeedCollection>();
34  reKeing_=false;
35  if (cfg.exists("clusterRemovalInfos")){
36  clusterRemovalInfos_=cfg.getParameter<std::vector<edm::InputTag> >("clusterRemovalInfos");
37  if (clusterRemovalInfos_.size()!=0 && clusterRemovalInfos_.size()==inputCollections_.size()) reKeing_=true;
38  }
39 }
40 
41 
43 {
44 }
45 
46 
48 {
49 }
50 
52 {
53  // Read inputs, and count total seeds
54  size_t ninputs = inputCollections_.size();
55  size_t nseeds = 0;
56  std::vector<Handle<TrajectorySeedCollection > > seedCollections(ninputs);
57  for (size_t i = 0; i < ninputs; ++i) {
58  ev.getByLabel(inputCollections_[i], seedCollections[i]);
59  nseeds += seedCollections[i]->size();
60  }
61 
62  // Prepare output collections, with the correct capacity
63  std::auto_ptr<TrajectorySeedCollection> result(new TrajectorySeedCollection());
64  result->reserve( nseeds );
65 
66  // Write into output collection
67  unsigned int iSC=0,iSC_max=seedCollections.size();
68  for (;iSC!=iSC_max;++iSC){
69  Handle<TrajectorySeedCollection> & collection=seedCollections[iSC];
70  if (reKeing_ && !(clusterRemovalInfos_[iSC]==edm::InputTag(""))){
72 
73  for (TrajectorySeedCollection::const_iterator iS=collection->begin();
74  iS!=collection->end();++iS){
75  TrajectorySeed::recHitContainer newRecHitContainer;
76  newRecHitContainer.reserve(iS->nHits());
77  TrajectorySeed::const_iterator iH=iS->recHits().first;
78  TrajectorySeed::const_iterator iH_end=iS->recHits().second;
79  //loop seed rechits, copy over and rekey.
80  for (;iH!=iH_end;++iH){
81  newRecHitContainer.push_back(*iH);
82  refSetter.reKey(&newRecHitContainer.back());
83  }
84  result->push_back(TrajectorySeed(iS->startingState(),
85  std::move(newRecHitContainer),
86  iS->direction()));
87  }
88  }else{
89  //just insert the new seeds as they are
90  result->insert(result->end(), collection->begin(), collection->end());
91  }
92  }
93 
94  // Save result into the event
95  ev.put(result);
96 }
SeedCombiner(const edm::ParameterSet &cfg)
Definition: SeedCombiner.cc:28
T getParameter(std::string const &) const
std::vector< edm::InputTag > clusterRemovalInfos_
Definition: SeedCombiner.h:24
int i
Definition: DBlmapReader.cc:9
reference back()
Definition: OwnVector.h:320
std::vector< edm::InputTag > inputCollections_
Definition: SeedCombiner.h:22
void reKey(TrackingRecHit *hit) const
bool exists(std::string const &parameterName) const
checks if a parameter exists
virtual void beginRun(edm::Run &run, const edm::EventSetup &es)
Definition: SeedCombiner.cc:47
void push_back(D *&d)
Definition: OwnVector.h:273
std::vector< TrajectorySeed > TrajectorySeedCollection
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:85
recHitContainer::const_iterator const_iterator
tuple result
Definition: query.py:137
bool getByLabel(InputTag const &tag, Handle< PROD > &result) const
Definition: Event.h:356
virtual void produce(edm::Event &ev, const edm::EventSetup &es)
Definition: SeedCombiner.cc:51
void reserve(size_t)
Definition: OwnVector.h:267
Definition: Run.h:33