CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_10/src/RecoTracker/ConversionSeedGenerators/src/CombinedHitQuadrupletGeneratorForPhotonConversion.cc

Go to the documentation of this file.
00001 #include "RecoTracker/ConversionSeedGenerators/interface/CombinedHitQuadrupletGeneratorForPhotonConversion.h"
00002 #include "RecoTracker/ConversionSeedGenerators/interface/HitQuadrupletGeneratorFromLayerPairForPhotonConversion.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 CombinedHitQuadrupletGeneratorForPhotonConversion::CombinedHitQuadrupletGeneratorForPhotonConversion(const edm::ParameterSet& cfg)
00015   : initialised(false), theConfig(cfg)
00016 {
00017   theMaxElement = cfg.getParameter<unsigned int>("maxElement");
00018 }
00019 
00020 void CombinedHitQuadrupletGeneratorForPhotonConversion::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 CombinedHitQuadrupletGeneratorForPhotonConversion::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 CombinedHitQuadrupletGeneratorForPhotonConversion::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 CombinedHitQuadrupletGeneratorForPhotonConversion::~CombinedHitQuadrupletGeneratorForPhotonConversion() { cleanup(); }
00053 
00054 void CombinedHitQuadrupletGeneratorForPhotonConversion::add( const SeedingLayer& inner, const SeedingLayer& outer)
00055 { 
00056   theGenerators.push_back( new HitQuadrupletGeneratorFromLayerPairForPhotonConversion( inner, outer, &theLayerCache, 0, theMaxElement));
00057 }
00058 
00059 const OrderedHitPairs & CombinedHitQuadrupletGeneratorForPhotonConversion::run(const TrackingRegion& region, const edm::Event & ev, const edm::EventSetup& es)
00060 {
00061   thePairs.clear();
00062   hitPairs(region, thePairs, ev, es);
00063   return thePairs;
00064 }
00065 
00066 
00067 void CombinedHitQuadrupletGeneratorForPhotonConversion::hitPairs(const TrackingRegion& region, OrderedHitPairs  & result,
00068                                                                  const edm::Event& ev, const edm::EventSetup& es)
00069 {
00070   if (theESWatcher.check(es) || !initialised ) {
00071     cleanup();
00072     init(theConfig,es);
00073   }
00074 
00075   size_t maxHitQuadruplets=1000000;
00076   Container::const_iterator i;
00077   for (i=theGenerators.begin(); i!=theGenerators.end() && result.size() < maxHitQuadruplets; i++) {
00078     (**i).hitPairs(region, result, ev, es); 
00079   }
00080   theLayerCache.clear();
00081 }