CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/RecoTracker/TkHitPairs/src/CombinedHitPairGenerator.cc

Go to the documentation of this file.
00001 #include "RecoTracker/TkHitPairs/interface/CombinedHitPairGenerator.h"
00002 #include "RecoTracker/TkHitPairs/interface/HitPairGeneratorFromLayerPair.h"
00003 #include "RecoTracker/TkSeedingLayers/interface/SeedingLayerSets.h"
00004 #include "RecoTracker/TkSeedingLayers/interface/SeedingLayerSetsBuilder.h"
00005 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00006 #include "FWCore/Framework/interface/ESHandle.h"
00007 #include "FWCore/Framework/interface/ESWatcher.h"
00008 #include "FWCore/Framework/interface/EventSetup.h"
00009 
00010 
00011 using namespace std;
00012 using namespace ctfseeding;
00013 
00014 CombinedHitPairGenerator::CombinedHitPairGenerator(const edm::ParameterSet& cfg)
00015   : initialised(false), theConfig(cfg)
00016 {
00017   theMaxElement = cfg.getParameter<unsigned int>("maxElement");
00018 }
00019 
00020 void CombinedHitPairGenerator::init(const edm::ParameterSet & cfg, const edm::EventSetup& es)
00021 {
00022   theMaxElement = cfg.getParameter<unsigned int>("maxElement");
00023 
00024   std::string layerBuilderName = cfg.getParameter<std::string>("SeedingLayers");
00025   edm::ESHandle<SeedingLayerSetsBuilder> layerBuilder;
00026   es.get<TrackerDigiGeometryRecord>().get(layerBuilderName, layerBuilder);
00027 
00028   SeedingLayerSets layerSets  =  layerBuilder->layers(es); 
00029   init(layerSets);
00030 }
00031 
00032 void CombinedHitPairGenerator::init(const SeedingLayerSets & layerSets)
00033 {
00034   initialised = true;
00035   typedef SeedingLayerSets::const_iterator IL;
00036   for (IL il=layerSets.begin(), ilEnd=layerSets.end(); il != ilEnd; ++il) {
00037     const SeedingLayers & set = *il;
00038     if (set.size() != 2) continue;
00039     add( set[0], set[1] );
00040   }
00041 }
00042 
00043 void CombinedHitPairGenerator::cleanup()
00044 {
00045   Container::const_iterator it;
00046   for (it = theGenerators.begin(); it!= theGenerators.end(); it++) {
00047     delete (*it);
00048   }
00049   theGenerators.clear();
00050 }
00051 
00052 CombinedHitPairGenerator::~CombinedHitPairGenerator() { cleanup(); }
00053 
00054 void CombinedHitPairGenerator::add( const SeedingLayer& inner, const SeedingLayer& outer)
00055 { 
00056   theGenerators.push_back( new HitPairGeneratorFromLayerPair( inner, outer, &theLayerCache, 0, theMaxElement));
00057 }
00058 
00059 void CombinedHitPairGenerator::hitPairs(
00060    const TrackingRegion& region, OrderedHitPairs  & result,
00061    const edm::Event& ev, const edm::EventSetup& es)
00062 {
00063   if (theESWatcher.check(es) || !initialised ) {
00064     cleanup();
00065     init(theConfig,es);
00066   }
00067 
00068   Container::const_iterator i;
00069   for (i=theGenerators.begin(); i!=theGenerators.end(); i++) {
00070     (**i).hitPairs( region, result, ev, es); 
00071   }
00072   theLayerCache.clear();
00073 
00074   LogDebug("CombinedHitPairGenerator")<<" total number of pairs provided back CHPG : "<<result.size();
00075 
00076 }