CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Protected Types | Protected Attributes
PSimHitSelector Class Reference

PSimHitSelector class. More...

#include <PSimHitSelector.h>

Inheritance diagram for PSimHitSelector:
MuonPSimHitSelector PixelPSimHitSelector TrackerPSimHitSelector

Public Types

typedef std::vector< PSimHitPSimHitCollection
 

Public Member Functions

 PSimHitSelector (edm::ParameterSet const &)
 Constructor by pset. More...
 
virtual void select (PSimHitCollection &, edm::Event const &, edm::EventSetup const &) const
 Select the psimhit add them to a PSimHitCollection. More...
 
virtual ~PSimHitSelector ()
 Virtual destructor. More...
 

Protected Types

typedef std::map< std::string,
std::vector< std::string > > 
PSimHitCollectionMap
 

Protected Attributes

PSimHitCollectionMap pSimHitCollectionMap_
 

Detailed Description

PSimHitSelector class.

Definition at line 15 of file PSimHitSelector.h.

Member Typedef Documentation

Definition at line 20 of file PSimHitSelector.h.

typedef std::map<std::string, std::vector<std::string> > PSimHitSelector::PSimHitCollectionMap
protected

Definition at line 37 of file PSimHitSelector.h.

Constructor & Destructor Documentation

PSimHitSelector::PSimHitSelector ( edm::ParameterSet const &  config)

Constructor by pset.

Definition at line 7 of file PSimHitSelector.cc.

References edm::ParameterSet::getParameter(), edm::ParameterSet::getParameterNames(), i, pSimHitCollectionMap_, and produceOfflineValidationTex::subdetectors.

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  for (size_t i = 0; i < subdetectors.size(); ++i)
15  {
16  pSimHitCollectionMap_.insert(
17  std::pair<std::string, std::vector<std::string> >(
18  subdetectors[i],
19  pSimHitCollections.getParameter<std::vector<std::string> >(subdetectors[i])
20  )
21  );
22  }
23 }
T getParameter(std::string const &) const
int i
Definition: DBlmapReader.cc:9
std::vector< std::string > getParameterNames() const
PSimHitCollectionMap pSimHitCollectionMap_
virtual PSimHitSelector::~PSimHitSelector ( )
inlinevirtual

Virtual destructor.

Definition at line 30 of file PSimHitSelector.h.

30 {}

Member Function Documentation

void PSimHitSelector::select ( PSimHitCollection selection,
edm::Event const &  event,
edm::EventSetup const &  setup 
) const
virtual

Select the psimhit add them to a PSimHitCollection.

Reimplemented in MuonPSimHitSelector, PixelPSimHitSelector, and TrackerPSimHitSelector.

Definition at line 26 of file PSimHitSelector.cc.

References MixCollection< T >::begin(), i, edm::Handle< T >::product(), and pSimHitCollectionMap_.

Referenced by TrackingTruthProducer::produce().

27 {
28  // Look for all psimhit collections
29  PSimHitCollectionMap::const_iterator pSimHitCollections = pSimHitCollectionMap_.begin();
30 
31  std::vector<const CrossingFrame<PSimHit> *> cfPSimHitProductPointers;
32 
33  for (; pSimHitCollections != pSimHitCollectionMap_.end(); ++pSimHitCollections)
34  {
35  // Grab all the PSimHit from the different sencitive volumes
37 
38  // Collect the product pointers to the different psimhit collection
39  for (std::size_t i = 0; i < pSimHitCollections->second.size(); ++i)
40  {
41  event.getByLabel("mix", pSimHitCollections->second[i], cfPSimHits);
42  cfPSimHitProductPointers.push_back(cfPSimHits.product());
43  }
44  }
45 
46  if (cfPSimHitProductPointers.empty()) return;
47 
48  // Create a mix collection from the different psimhit collections
49  std::auto_ptr<MixCollection<PSimHit> > pSimHits(new MixCollection<PSimHit>(cfPSimHitProductPointers));
50 
51  // Select all psimhits
52  for (MixCollection<PSimHit>::MixItr pSimHit = pSimHits->begin(); pSimHit != pSimHits->end(); ++pSimHit)
53  selection.push_back(*pSimHit);
54 }
int i
Definition: DBlmapReader.cc:9
selection
main part
Definition: corrVsCorr.py:98
iterator begin()
T const * product() const
Definition: Handle.h:74
PSimHitCollectionMap pSimHitCollectionMap_

Member Data Documentation

PSimHitCollectionMap PSimHitSelector::pSimHitCollectionMap_
protected