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 }
mps_fire.i
i
Definition: mps_fire.py:355
PSimHitSelector::PSimHitCollection
std::vector< PSimHit > PSimHitCollection
Definition: PSimHitSelector.h:17
edm::Handle::product
T const * product() const
Definition: Handle.h:70
CrossingFrame.h
edm::Handle
Definition: AssociativeIterator.h:50
MixCollection::MixItr
Definition: MixCollection.h:62
singleTopDQM_cfi.setup
setup
Definition: singleTopDQM_cfi.py:37
PSimHitSelector::pSimHitCollectionMap_
PSimHitCollectionMap pSimHitCollectionMap_
Definition: PSimHitSelector.h:36
TrackingMonitor_cfi.subdetectors
subdetectors
Definition: TrackingMonitor_cfi.py:181
config
Definition: config.py:1
MixCollection.h
PSimHitSelector::select
virtual void select(PSimHitCollection &, edm::Event const &, edm::EventSetup const &) const
Select the psimhit add them to a PSimHitCollection.
Definition: PSimHitSelector.cc:21
MixCollection
Definition: MixCollection.h:11
corrVsCorr.selection
selection
main part
Definition: corrVsCorr.py:100
AlCaHLTBitMon_QueryRunRegistry.string
string
Definition: AlCaHLTBitMon_QueryRunRegistry.py:256
PSimHitSelector.h
edm::ParameterSet
Definition: ParameterSet.h:36
edm::ParameterSet::getParameterNames
std::vector< std::string > getParameterNames() const
Definition: ParameterSet.cc:656
edm::EventSetup
Definition: EventSetup.h:57
PSimHitSelector::mixLabel_
std::string mixLabel_
Definition: PSimHitSelector.h:25
edm::ParameterSet::getParameter
T getParameter(std::string const &) const
event
Definition: event.py:1
edm::Event
Definition: Event.h:73
PSimHitSelector::PSimHitSelector
PSimHitSelector(edm::ParameterSet const &)
Constructor by pset.
Definition: PSimHitSelector.cc:7