CMS 3D CMS Logo

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