CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_2_9/src/RecoTracker/ConversionSeedGenerators/src/CombinedHitPairGeneratorForPhotonConversion.cc

Go to the documentation of this file.
00001 #include "RecoTracker/ConversionSeedGenerators/interface/CombinedHitPairGeneratorForPhotonConversion.h"
00002 #include "RecoTracker/ConversionSeedGenerators/interface/HitPairGeneratorFromLayerPairForPhotonConversion.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 CombinedHitPairGeneratorForPhotonConversion::CombinedHitPairGeneratorForPhotonConversion(const edm::ParameterSet& cfg)
00015   : initialised(false), theConfig(cfg)
00016 {
00017   theMaxElement = cfg.getParameter<unsigned int>("maxElement");
00018   maxHitPairsPerTrackAndGenerator = cfg.getParameter<unsigned int>("maxHitPairsPerTrackAndGenerator");
00019 
00020 }
00021 
00022 void CombinedHitPairGeneratorForPhotonConversion::init(const edm::ParameterSet & cfg, const edm::EventSetup& es)
00023 {
00024   theMaxElement = cfg.getParameter<unsigned int>("maxElement");
00025   maxHitPairsPerTrackAndGenerator = cfg.getParameter<unsigned int>("maxHitPairsPerTrackAndGenerator");
00026 
00027   std::string layerBuilderName = cfg.getParameter<std::string>("SeedingLayers");
00028   edm::ESHandle<SeedingLayerSetsBuilder> layerBuilder;
00029   es.get<TrackerDigiGeometryRecord>().get(layerBuilderName, layerBuilder);
00030 
00031   SeedingLayerSets layerSets  =  layerBuilder->layers(es); 
00032   init(layerSets);
00033 }
00034 
00035 void CombinedHitPairGeneratorForPhotonConversion::init(const SeedingLayerSets & layerSets)
00036 {
00037   initialised = true;
00038   typedef SeedingLayerSets::const_iterator IL;
00039   for (IL il=layerSets.begin(), ilEnd=layerSets.end(); il != ilEnd; ++il) {
00040     const SeedingLayers & set = *il;
00041     if (set.size() != 2) continue;
00042     add( set[0], set[1] );
00043   }
00044 }
00045 
00046 void CombinedHitPairGeneratorForPhotonConversion::cleanup()
00047 {
00048   Container::const_iterator it;
00049   for (it = theGenerators.begin(); it!= theGenerators.end(); it++) {
00050     delete (*it);
00051   }
00052   theGenerators.clear();
00053 }
00054 
00055 CombinedHitPairGeneratorForPhotonConversion::~CombinedHitPairGeneratorForPhotonConversion() { cleanup(); }
00056 
00057 void CombinedHitPairGeneratorForPhotonConversion::add( const SeedingLayer& inner, const SeedingLayer& outer)
00058 { 
00059   theGenerators.push_back( new HitPairGeneratorFromLayerPairForPhotonConversion( inner, outer, &theLayerCache, 0, maxHitPairsPerTrackAndGenerator));
00060 }
00061 
00062 const OrderedHitPairs & CombinedHitPairGeneratorForPhotonConversion::run(
00063                                                                          const ConversionRegion& convRegion,
00064                                                                          const TrackingRegion& region, const edm::Event & ev, const edm::EventSetup& es)
00065 {
00066   thePairs.clear();
00067   hitPairs(convRegion, region, thePairs, ev, es);
00068   return thePairs;
00069 }
00070 
00071 
00072 void CombinedHitPairGeneratorForPhotonConversion::hitPairs(
00073                                                            const ConversionRegion& convRegion,
00074                                                            const TrackingRegion& region, OrderedHitPairs  & result,
00075                                                            const edm::Event& ev, const edm::EventSetup& es)
00076 {
00077   if (theESWatcher.check(es) || !initialised ) {
00078     cleanup();
00079     init(theConfig,es);
00080   }
00081 
00082   Container::const_iterator i;
00083   OrderedHitPairs  resultTmp;
00084   resultTmp.reserve(maxHitPairsPerTrackAndGenerator);
00085 
00086   for (i=theGenerators.begin(); i!=theGenerators.end() && result.size() < theMaxElement; i++) {
00087     resultTmp.clear();
00088     (**i).hitPairs(convRegion, region, resultTmp, ev, es); 
00089     result.insert(result.end(),resultTmp.begin(),resultTmp.end());
00090   }
00091   //theLayerCache.clear(); //Don't want to clear now, because have to loop on all the tracks. will be cleared later, calling a specific method
00092 }