00001 00002 #include "SimDataFormats/CrossingFrame/interface/CrossingFrame.h" 00003 #include "SimDataFormats/CrossingFrame/interface/MixCollection.h" 00004 00005 #include "SimGeneral/TrackingAnalysis/interface/PSimHitSelector.h" 00006 00007 PSimHitSelector::PSimHitSelector(edm::ParameterSet const & config) 00008 { 00009 // Initilize psimhit collection discriminated by sub systems 00010 edm::ParameterSet pSimHitCollections = config.getParameter<edm::ParameterSet>("simHitCollections"); 00011 00012 std::vector<std::string> subdetectors( pSimHitCollections.getParameterNames() ); 00013 00014 for (size_t i = 0; i < subdetectors.size(); ++i) 00015 { 00016 pSimHitCollectionMap_.insert( 00017 std::pair<std::string, std::vector<std::string> >( 00018 subdetectors[i], 00019 pSimHitCollections.getParameter<std::vector<std::string> >(subdetectors[i]) 00020 ) 00021 ); 00022 } 00023 } 00024 00025 00026 void PSimHitSelector::select(PSimHitCollection & selection, edm::Event const & event, edm::EventSetup const & setup) const 00027 { 00028 // Look for all psimhit collections 00029 PSimHitCollectionMap::const_iterator pSimHitCollections = pSimHitCollectionMap_.begin(); 00030 00031 std::vector<const CrossingFrame<PSimHit> *> cfPSimHitProductPointers; 00032 00033 for (; pSimHitCollections != pSimHitCollectionMap_.end(); ++pSimHitCollections) 00034 { 00035 // Grab all the PSimHit from the different sencitive volumes 00036 edm::Handle<CrossingFrame<PSimHit> > cfPSimHits; 00037 00038 // Collect the product pointers to the different psimhit collection 00039 for (std::size_t i = 0; i < pSimHitCollections->second.size(); ++i) 00040 { 00041 event.getByLabel("mix", pSimHitCollections->second[i], cfPSimHits); 00042 cfPSimHitProductPointers.push_back(cfPSimHits.product()); 00043 } 00044 } 00045 00046 if (cfPSimHitProductPointers.empty()) return; 00047 00048 // Create a mix collection from the different psimhit collections 00049 std::auto_ptr<MixCollection<PSimHit> > pSimHits(new MixCollection<PSimHit>(cfPSimHitProductPointers)); 00050 00051 // Select all psimhits 00052 for (MixCollection<PSimHit>::MixItr pSimHit = pSimHits->begin(); pSimHit != pSimHits->end(); ++pSimHit) 00053 selection.push_back(*pSimHit); 00054 }