CMS 3D CMS Logo

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

List of all members.

Public Types

typedef std::vector< PSimHitPSimHitCollection

Public Member Functions

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

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, and pSimHitCollectionMap_.

{
    // Initilize psimhit collection discriminated by sub systems
    edm::ParameterSet pSimHitCollections = config.getParameter<edm::ParameterSet>("simHitCollections");

    std::vector<std::string> subdetectors( pSimHitCollections.getParameterNames() );

    for (size_t i = 0; i < subdetectors.size(); ++i)
    {
        pSimHitCollectionMap_.insert(
            std::pair<std::string, std::vector<std::string> >(
                subdetectors[i],
                pSimHitCollections.getParameter<std::vector<std::string> >(subdetectors[i])
            )
        );
    }
}
virtual PSimHitSelector::~PSimHitSelector ( ) [inline, virtual]

Virtual destructor.

Definition at line 30 of file PSimHitSelector.h.

{}

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().

{
    // Look for all psimhit collections
    PSimHitCollectionMap::const_iterator pSimHitCollections = pSimHitCollectionMap_.begin();

    std::vector<const CrossingFrame<PSimHit> *> cfPSimHitProductPointers;

    for (; pSimHitCollections != pSimHitCollectionMap_.end(); ++pSimHitCollections)
    {
        // Grab all the PSimHit from the different sencitive volumes
        edm::Handle<CrossingFrame<PSimHit> > cfPSimHits;

        // Collect the product pointers to the different psimhit collection
        for (std::size_t i = 0; i < pSimHitCollections->second.size(); ++i)
        {
            event.getByLabel("mix", pSimHitCollections->second[i], cfPSimHits);
            cfPSimHitProductPointers.push_back(cfPSimHits.product());
        }
    }

    if (cfPSimHitProductPointers.empty()) return;

    // Create a mix collection from the different psimhit collections
    std::auto_ptr<MixCollection<PSimHit> > pSimHits(new MixCollection<PSimHit>(cfPSimHitProductPointers));

    // Select all psimhits
    for (MixCollection<PSimHit>::MixItr pSimHit = pSimHits->begin(); pSimHit != pSimHits->end(); ++pSimHit)
        selection.push_back(*pSimHit);
}

Member Data Documentation