CMS 3D CMS Logo

PSimHitSelector.cc
Go to the documentation of this file.
1 
4 
6 
8  // Initilize psimhit collection discriminated by sub systems
9  edm::ParameterSet pSimHitCollections = config.getParameter<edm::ParameterSet>("simHitCollections");
10 
11  std::vector<std::string> subdetectors(pSimHitCollections.getParameterNames());
12 
13  mixLabel_ = config.getParameter<std::string>("mixLabel");
14 
15  for (size_t i = 0; i < subdetectors.size(); ++i) {
16  pSimHitCollectionMap_.insert(std::pair<std::string, std::vector<std::string>>(
17  subdetectors[i], pSimHitCollections.getParameter<std::vector<std::string>>(subdetectors[i])));
18  }
19 }
20 
22  edm::Event const &event,
23  edm::EventSetup const &setup) const {
24  // Look for all psimhit collections
25  PSimHitCollectionMap::const_iterator pSimHitCollections = pSimHitCollectionMap_.begin();
26 
27  std::vector<const CrossingFrame<PSimHit> *> cfPSimHitProductPointers;
28 
29  for (; pSimHitCollections != pSimHitCollectionMap_.end(); ++pSimHitCollections) {
30  // Grab all the PSimHit from the different sencitive volumes
32 
33  // Collect the product pointers to the different psimhit collection
34  for (std::size_t i = 0; i < pSimHitCollections->second.size(); ++i) {
35  event.getByLabel(mixLabel_, pSimHitCollections->second[i], cfPSimHits);
36  cfPSimHitProductPointers.push_back(cfPSimHits.product());
37  }
38  }
39 
40  if (cfPSimHitProductPointers.empty())
41  return;
42 
43  // Create a mix collection from the different psimhit collections
44  std::unique_ptr<MixCollection<PSimHit>> pSimHits(new MixCollection<PSimHit>(cfPSimHitProductPointers));
45 
46  // Select all psimhits
47  for (MixCollection<PSimHit>::MixItr pSimHit = pSimHits->begin(); pSimHit != pSimHits->end(); ++pSimHit)
48  selection.push_back(*pSimHit);
49 }
T getParameter(std::string const &) const
Definition: ParameterSet.h:303
T const * product() const
Definition: Handle.h:70
selection
main part
Definition: corrVsCorr.py:100
std::string mixLabel_
Definition: config.py:1
PSimHitSelector(edm::ParameterSet const &, edm::ConsumesCollector &)
Constructor by pset.
std::vector< PSimHit > PSimHitCollection
PSimHitCollectionMap pSimHitCollectionMap_
virtual void select(PSimHitCollection &, edm::Event const &, edm::EventSetup const &) const
Select the psimhit add them to a PSimHitCollection.
std::vector< std::string > getParameterNames() const
Definition: event.py:1