Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2023-10-25 10:04:47

0001 #include "FWCore/Framework/interface/ESHandle.h"
0002 
0003 #include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h"
0004 #include "SimDataFormats/CrossingFrame/interface/MixCollection.h"
0005 
0006 #include "SimGeneral/TrackingAnalysis/interface/TrackerPSimHitSelector.h"
0007 
0008 #include "SimTracker/Common/interface/SimHitSelectorFromDB.h"
0009 
0010 void TrackerPSimHitSelector::select(PSimHitCollection &selection,
0011                                     edm::Event const &event,
0012                                     edm::EventSetup const &setup) const {
0013   // Look for psimhit collection associated o the tracker
0014   PSimHitCollectionMap::const_iterator pSimHitCollections = pSimHitCollectionMap_.find("tracker");
0015 
0016   // Check that there are psimhit collections defined for the tracker
0017   if (pSimHitCollections == pSimHitCollectionMap_.end())
0018     return;
0019 
0020   // Grab all the PSimHit from the different sencitive volumes
0021   edm::Handle<CrossingFrame<PSimHit>> cfPSimHits;
0022   std::vector<const CrossingFrame<PSimHit> *> cfPSimHitProductPointers;
0023 
0024   // Collect the product pointers to the different psimhit collection
0025   for (std::size_t i = 0; i < pSimHitCollections->second.size(); ++i) {
0026     event.getByLabel(mixLabel_, pSimHitCollections->second[i], cfPSimHits);
0027     cfPSimHitProductPointers.push_back(cfPSimHits.product());
0028   }
0029 
0030   // Create a mix collection from the different psimhit collections
0031   std::unique_ptr<MixCollection<PSimHit>> pSimHits(new MixCollection<PSimHit>(cfPSimHitProductPointers));
0032 
0033   // Setup the cabling mapping
0034   std::map<uint32_t, std::vector<int>> theDetIdList;
0035   edm::ESHandle<SiStripDetCabling> detCabling = setup.getHandle(cableToken_);
0036   detCabling->addConnected(theDetIdList);
0037 
0038   // Select only psimhits from alive modules
0039   std::vector<std::pair<const PSimHit *, int>> psimhits(SimHitSelectorFromDB().getSimHit(pSimHits, theDetIdList));
0040 
0041   // Add the selected psimhit to the main list
0042   for (std::size_t i = 0; i < psimhits.size(); ++i)
0043     selection.push_back(*(const_cast<PSimHit *>(psimhits[i].first)));
0044 }