Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:30:41

0001 
0002 #include "FWCore/Framework/interface/ESHandle.h"
0003 
0004 #include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h"
0005 #include "SimDataFormats/CrossingFrame/interface/MixCollection.h"
0006 
0007 #include "SimGeneral/TrackingAnalysis/interface/MuonPSimHitSelector.h"
0008 
0009 // #include "SimTracker/Common/interface/SimHitSelectorFromDB.h"
0010 
0011 void MuonPSimHitSelector::select(PSimHitCollection &selection,
0012                                  edm::Event const &event,
0013                                  edm::EventSetup const &setup) const {
0014   // Look for psimhit collection associated to the muon system
0015   PSimHitCollectionMap::const_iterator pSimHitCollections = pSimHitCollectionMap_.find("muon");
0016 
0017   // Check that there are psimhit collections defined for the tracker
0018   if (pSimHitCollections == pSimHitCollectionMap_.end())
0019     return;
0020 
0021   // Grab all the PSimHit from the different sencitive volumes
0022   edm::Handle<CrossingFrame<PSimHit>> cfPSimHits;
0023   std::vector<const CrossingFrame<PSimHit> *> cfPSimHitProductPointers;
0024 
0025   // Collect the product pointers to the different psimhit collection
0026   for (std::size_t i = 0; i < pSimHitCollections->second.size(); ++i) {
0027     event.getByLabel("mix", pSimHitCollections->second[i], cfPSimHits);
0028     cfPSimHitProductPointers.push_back(cfPSimHits.product());
0029   }
0030 
0031   // Create a mix collection from the different psimhit collections
0032   std::unique_ptr<MixCollection<PSimHit>> pSimHits(new MixCollection<PSimHit>(cfPSimHitProductPointers));
0033 
0034   // Get CSC Bad Chambers (ME4/2)
0035   edm::ESHandle<CSCBadChambers> cscBadChambers = setup.getHandle(cscBadToken_);
0036 
0037   // Select only psimhits from alive modules
0038   for (MixCollection<PSimHit>::MixItr pSimHit = pSimHits->begin(); pSimHit != pSimHits->end(); ++pSimHit) {
0039     DetId dId = DetId(pSimHit->detUnitId());
0040 
0041     if (dId.det() == DetId::Muon && dId.subdetId() == MuonSubdetId::CSC) {
0042       if (!cscBadChambers->isInBadChamber(CSCDetId(dId)))
0043         selection.push_back(*pSimHit);
0044     } else
0045       selection.push_back(*pSimHit);
0046   }
0047 }