Go to the documentation of this file.00001
00002 #include "CondFormats/CSCObjects/interface/CSCBadChambers.h"
00003 #include "CondFormats/DataRecord/interface/CSCBadChambersRcd.h"
00004
00005 #include "FWCore/Framework/interface/ESHandle.h"
00006
00007 #include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h"
00008 #include "SimDataFormats/CrossingFrame/interface/MixCollection.h"
00009
00010 #include "SimGeneral/TrackingAnalysis/interface/MuonPSimHitSelector.h"
00011
00012
00013
00014
00015 void MuonPSimHitSelector::select(PSimHitCollection & selection, edm::Event const & event, edm::EventSetup const & setup) const
00016 {
00017
00018 PSimHitCollectionMap::const_iterator pSimHitCollections = pSimHitCollectionMap_.find("muon");
00019
00020
00021 if (pSimHitCollections == pSimHitCollectionMap_.end()) return;
00022
00023
00024 edm::Handle<CrossingFrame<PSimHit> > cfPSimHits;
00025 std::vector<const CrossingFrame<PSimHit> *> cfPSimHitProductPointers;
00026
00027
00028 for (std::size_t i = 0; i < pSimHitCollections->second.size(); ++i)
00029 {
00030 event.getByLabel("mix", pSimHitCollections->second[i], cfPSimHits);
00031 cfPSimHitProductPointers.push_back(cfPSimHits.product());
00032 }
00033
00034
00035 std::auto_ptr<MixCollection<PSimHit> > pSimHits(new MixCollection<PSimHit>(cfPSimHitProductPointers));
00036
00037
00038 edm::ESHandle<CSCBadChambers> cscBadChambers;
00039 setup.get<CSCBadChambersRcd>().get(cscBadChambers);
00040
00041
00042 for (MixCollection<PSimHit>::MixItr pSimHit = pSimHits->begin(); pSimHit != pSimHits->end(); ++pSimHit)
00043 {
00044 DetId dId = DetId( pSimHit->detUnitId() );
00045
00046 if (dId.det() == DetId::Muon && dId.subdetId() == MuonSubdetId::CSC)
00047 {
00048 if ( !cscBadChambers->isInBadChamber(CSCDetId(dId)) )
00049 selection.push_back(*pSimHit);
00050 }
00051 else
00052 selection.push_back(*pSimHit);
00053 }
00054 }