CMS 3D CMS Logo

Public Member Functions

MuonPSimHitSelector Class Reference

MuonPSimHitSelector class. More...

#include <MuonPSimHitSelector.h>

Inheritance diagram for MuonPSimHitSelector:
PSimHitSelector

List of all members.

Public Member Functions

 MuonPSimHitSelector (edm::ParameterSet const &config)
 Constructor by pset.
virtual void select (PSimHitCollection &, edm::Event const &, edm::EventSetup const &) const
 Pre-process event information.

Detailed Description

MuonPSimHitSelector class.

Definition at line 7 of file MuonPSimHitSelector.h.


Constructor & Destructor Documentation

MuonPSimHitSelector::MuonPSimHitSelector ( edm::ParameterSet const &  config) [inline]

Constructor by pset.

Definition at line 17 of file MuonPSimHitSelector.h.


Member Function Documentation

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

Pre-process event information.

Reimplemented from PSimHitSelector.

Definition at line 15 of file MuonPSimHitSelector.cc.

References MixCollection< T >::begin(), CSC(), CSC_BadChambers_cfi::cscBadChambers, DetId::det(), edm::EventSetup::get(), i, DetId::Muon, edm::Handle< T >::product(), PSimHitSelector::pSimHitCollectionMap_, and DetId::subdetId().

Referenced by TrackingTruthProducer::produce().

{
    // Look for psimhit collection associated to the muon system
    PSimHitCollectionMap::const_iterator pSimHitCollections = pSimHitCollectionMap_.find("muon");

    // Check that there are psimhit collections defined for the tracker
    if (pSimHitCollections == pSimHitCollectionMap_.end()) return;

    // Grab all the PSimHit from the different sencitive volumes
    edm::Handle<CrossingFrame<PSimHit> > cfPSimHits;
    std::vector<const CrossingFrame<PSimHit> *> cfPSimHitProductPointers;

    // 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());
    }

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

    // Get CSC Bad Chambers (ME4/2)
    edm::ESHandle<CSCBadChambers> cscBadChambers;
    setup.get<CSCBadChambersRcd>().get(cscBadChambers);

    // Select only psimhits from alive modules
    for (MixCollection<PSimHit>::MixItr pSimHit = pSimHits->begin(); pSimHit != pSimHits->end(); ++pSimHit)
    {
        DetId dId = DetId( pSimHit->detUnitId() );

        if (dId.det() == DetId::Muon && dId.subdetId() == MuonSubdetId::CSC)
        {
            if ( !cscBadChambers->isInBadChamber(CSCDetId(dId)) )
                selection.push_back(*pSimHit);
        }
        else
            selection.push_back(*pSimHit);
    }
}