CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_1/src/SimGeneral/TrackingAnalysis/src/TrackerPSimHitSelector.cc

Go to the documentation of this file.
00001 
00002 
00003 #include "CalibFormats/SiStripObjects/interface/SiStripDetCabling.h"
00004 #include "CalibTracker/Records/interface/SiStripDetCablingRcd.h"
00005 
00006 #include "FWCore/Framework/interface/ESHandle.h"
00007 
00008 #include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h"
00009 #include "SimDataFormats/CrossingFrame/interface/MixCollection.h"
00010 
00011 #include "SimGeneral/TrackingAnalysis/interface/TrackerPSimHitSelector.h"
00012 
00013 #include "SimTracker/Common/interface/SimHitSelectorFromDB.h"
00014 
00015 
00016 void TrackerPSimHitSelector::select(PSimHitCollection & selection, edm::Event const & event, edm::EventSetup const & setup) const
00017 {
00018     // Look for psimhit collection associated o the tracker
00019     PSimHitCollectionMap::const_iterator pSimHitCollections = pSimHitCollectionMap_.find("tracker");
00020 
00021     // Check that there are psimhit collections defined for the tracker
00022     if (pSimHitCollections == pSimHitCollectionMap_.end()) return;
00023 
00024     // Grab all the PSimHit from the different sencitive volumes
00025     edm::Handle<CrossingFrame<PSimHit> > cfPSimHits;
00026     std::vector<const CrossingFrame<PSimHit> *> cfPSimHitProductPointers;
00027 
00028     // Collect the product pointers to the different psimhit collection
00029     for (std::size_t i = 0; i < pSimHitCollections->second.size(); ++i)
00030     {
00031         event.getByLabel("mix", pSimHitCollections->second[i], cfPSimHits);
00032         cfPSimHitProductPointers.push_back(cfPSimHits.product());
00033     }
00034 
00035     // Create a mix collection from the different psimhit collections
00036     std::auto_ptr<MixCollection<PSimHit> > pSimHits(new MixCollection<PSimHit>(cfPSimHitProductPointers));
00037 
00038     // Setup the cabling mapping
00039     std::map<uint32_t, std::vector<int> > theDetIdList;
00040     edm::ESHandle<SiStripDetCabling> detCabling;
00041     setup.get<SiStripDetCablingRcd>().get( detCabling );
00042     detCabling->addConnected(theDetIdList);
00043 
00044     // Select only psimhits from alive modules
00045     std::vector<std::pair<const PSimHit*,int> > psimhits(SimHitSelectorFromDB().getSimHit(pSimHits, theDetIdList));
00046 
00047     // Add the selected psimhit to the main list
00048     for (std::size_t i = 0; i < psimhits.size(); ++i)
00049         selection.push_back( *(const_cast<PSimHit*>(psimhits[i].first)) );
00050 }