Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2022-01-02 23:15:08

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/PixelPSimHitSelector.h"
0008 
0009 void PixelPSimHitSelector::select(PSimHitCollection &selection,
0010                                   edm::Event const &event,
0011                                   edm::EventSetup const &setup) const {
0012   // Look for psimhit collection associated o the tracker
0013   PSimHitCollectionMap::const_iterator pSimHitCollections = pSimHitCollectionMap_.find("pixel");
0014 
0015   // Check that there are psimhit collections defined for the tracker
0016   if (pSimHitCollections == pSimHitCollectionMap_.end())
0017     return;
0018 
0019   // Grab all the PSimHit from the different sencitive volumes
0020   edm::Handle<CrossingFrame<PSimHit>> cfPSimHits;
0021   std::vector<const CrossingFrame<PSimHit> *> cfPSimHitProductPointers;
0022 
0023   // Collect the product pointers to the different psimhit collection
0024   for (std::size_t i = 0; i < pSimHitCollections->second.size(); ++i) {
0025     event.getByLabel("mix", pSimHitCollections->second[i], cfPSimHits);
0026     cfPSimHitProductPointers.push_back(cfPSimHits.product());
0027   }
0028 
0029   // Create a mix collection from the different psimhit collections
0030   std::unique_ptr<MixCollection<PSimHit>> pSimHits(new MixCollection<PSimHit>(cfPSimHitProductPointers));
0031 
0032   // Accessing dead pixel modules from DB:
0033   edm::ESHandle<SiPixelQuality> siPixelBadModule = setup.getHandle(badModuleToken_);
0034 
0035   // Reading the DB information
0036   std::vector<SiPixelQuality::disabledModuleType> badModules(siPixelBadModule->getBadComponentList());
0037   SiPixelQuality pixelQuality(badModules);
0038 
0039   // Select only psimhits from alive modules
0040   for (MixCollection<PSimHit>::MixItr pSimHit = pSimHits->begin(); pSimHit != pSimHits->end(); ++pSimHit) {
0041     if (!pixelQuality.IsModuleBad(pSimHit->detUnitId()))
0042       selection.push_back(*pSimHit);
0043   }
0044 }