CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_6_1_1/src/SimGeneral/TrackingAnalysis/src/MuonPSimHitSelector.cc

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 // #include "SimTracker/Common/interface/SimHitSelectorFromDB.h"
00013 
00014 
00015 void MuonPSimHitSelector::select(PSimHitCollection & selection, edm::Event const & event, edm::EventSetup const & setup) const
00016 {
00017     // Look for psimhit collection associated to the muon system
00018     PSimHitCollectionMap::const_iterator pSimHitCollections = pSimHitCollectionMap_.find("muon");
00019 
00020     // Check that there are psimhit collections defined for the tracker
00021     if (pSimHitCollections == pSimHitCollectionMap_.end()) return;
00022 
00023     // Grab all the PSimHit from the different sencitive volumes
00024     edm::Handle<CrossingFrame<PSimHit> > cfPSimHits;
00025     std::vector<const CrossingFrame<PSimHit> *> cfPSimHitProductPointers;
00026 
00027     // Collect the product pointers to the different psimhit collection
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     // Create a mix collection from the different psimhit collections
00035     std::auto_ptr<MixCollection<PSimHit> > pSimHits(new MixCollection<PSimHit>(cfPSimHitProductPointers));
00036 
00037     // Get CSC Bad Chambers (ME4/2)
00038     edm::ESHandle<CSCBadChambers> cscBadChambers;
00039     setup.get<CSCBadChambersRcd>().get(cscBadChambers);
00040 
00041     // Select only psimhits from alive modules
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 }