CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/RecoEgamma/EgammaHLTProducers/src/EgammaHLTRegionalPixelSeedGeneratorProducers.cc

Go to the documentation of this file.
00001 //
00002 // Package:         RecoEgamma/EgammaHLTProducers
00003 // Class:           EgammaHLTRegionalPixelSeedGeneratorProducers
00004 //  Modified from TkSeedGeneratorFromTrk by Jeremy Werner, Princeton University, USA
00005 // $Id: EgammaHLTRegionalPixelSeedGeneratorProducers.cc,v 1.10 2010/04/13 16:44:20 covarell Exp $
00006 //
00007 
00008 #include <iostream>
00009 #include <memory>
00010 #include <string>
00011 
00012 #include "RecoEgamma/EgammaHLTProducers/interface/EgammaHLTRegionalPixelSeedGeneratorProducers.h"
00013 #include "DataFormats/TrackerRecHit2D/interface/SiPixelRecHitCollection.h"
00014 #include "DataFormats/TrajectorySeed/interface/TrajectorySeedCollection.h"
00015 #include "DataFormats/Common/interface/Handle.h"
00016 #include "FWCore/Framework/interface/ESHandle.h"
00017 #include "FWCore/Framework/interface/EventSetup.h"
00018 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00019 #include "Geometry/Records/interface/TrackerDigiGeometryRecord.h"
00020 #include "Geometry/TrackerGeometryBuilder/interface/TrackerGeometry.h"
00021 #include "RecoTracker/TkTrackingRegions/interface/RectangularEtaPhiTrackingRegion.h"
00022 #include "DataFormats/TrackReco/interface/Track.h"
00023 #include "DataFormats/Math/interface/Vector3D.h"
00024 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidate.h"
00025 #include "DataFormats/RecoCandidate/interface/RecoEcalCandidateFwd.h"
00026 #include "DataFormats/EgammaCandidates/interface/Electron.h"
00027 #include "DataFormats/EgammaCandidates/interface/ElectronFwd.h"
00028 #include "DataFormats/EgammaReco/interface/SuperCluster.h"
00029 
00030 #include "RecoTracker/TkTrackingRegions/interface/OrderedHitsGeneratorFactory.h"
00031 #include "RecoTracker/TkTrackingRegions/interface/OrderedHitsGenerator.h"
00032 #include "RecoTracker/TkSeedGenerator/interface/SeedGeneratorFromRegionHits.h"
00033 
00034 #include "CondFormats/DataRecord/interface/BeamSpotObjectsRcd.h"//needed?
00035 #include "CondFormats/BeamSpotObjects/interface/BeamSpotObjects.h"//needed?
00036 
00037 #include "DataFormats/BeamSpot/interface/BeamSpot.h"
00038 #include "DataFormats/Math/interface/Point3D.h"
00039 // Math
00040 #include "Math/GenVector/VectorUtil.h"
00041 #include "Math/GenVector/PxPyPzE4D.h"
00042 
00043 using namespace std;
00044 using namespace reco;
00045 
00046 EgammaHLTRegionalPixelSeedGeneratorProducers::EgammaHLTRegionalPixelSeedGeneratorProducers(edm::ParameterSet const& conf) :   conf_(conf),combinatorialSeedGenerator(0)
00047 {
00048 
00049   produces<TrajectorySeedCollection>();
00050 
00051   ptmin_       = conf_.getParameter<double>("ptMin");
00052   vertexz_     = conf_.getParameter<double>("vertexZ");
00053   originradius_= conf_.getParameter<double>("originRadius");
00054   halflength_  = conf_.getParameter<double>("originHalfLength");
00055   deltaEta_    = conf_.getParameter<double>("deltaEtaRegion");
00056   deltaPhi_    = conf_.getParameter<double>("deltaPhiRegion");
00057   candTag_     = conf_.getParameter< edm::InputTag > ("candTag");
00058   candTagEle_  = conf_.getParameter< edm::InputTag > ("candTagEle");
00059   useZvertex_  = conf_.getParameter<bool>("UseZInVertex");
00060   BSProducer_ = conf.getParameter<edm::InputTag>("BSProducer");
00061   // setup orderedhits setup (in order to tell seed generator to use pairs/triplets, which layers)
00062 }
00063 
00064 // Virtual destructor needed.
00065 EgammaHLTRegionalPixelSeedGeneratorProducers::~EgammaHLTRegionalPixelSeedGeneratorProducers() { 
00066 }  
00067 
00068 void EgammaHLTRegionalPixelSeedGeneratorProducers::endRun(edm::Run &run, const edm::EventSetup& es)
00069 {
00070   delete combinatorialSeedGenerator;
00071   combinatorialSeedGenerator=0;
00072 }
00073 
00074 
00075 void EgammaHLTRegionalPixelSeedGeneratorProducers::beginRun(edm::Run &run, const edm::EventSetup& es)
00076 {
00077   edm::ParameterSet hitsfactoryPSet =
00078       conf_.getParameter<edm::ParameterSet>("OrderedHitsFactoryPSet");
00079   std::string hitsfactoryName = hitsfactoryPSet.getParameter<std::string>("ComponentName");
00080 
00081   // get orderd hits generator from factory
00082   OrderedHitsGenerator*  hitsGenerator =
00083         OrderedHitsGeneratorFactory::get()->create( hitsfactoryName, hitsfactoryPSet);
00084 
00085   // start seed generator
00086   combinatorialSeedGenerator = new SeedGeneratorFromRegionHits( hitsGenerator, conf_);
00087 }
00088 
00089 // Functions that gets called by framework every event
00090 void EgammaHLTRegionalPixelSeedGeneratorProducers::produce(edm::Event& iEvent, const edm::EventSetup& iSetup)
00091 {
00092 
00093   // resulting collection
00094   std::auto_ptr<TrajectorySeedCollection> output(new TrajectorySeedCollection());    
00095 
00096   // Get the recoEcalCandidates
00097   edm::Handle<reco::RecoEcalCandidateCollection> recoecalcands;
00098   iEvent.getByLabel(candTag_,recoecalcands);
00099 
00100   //Get the Beam Spot position
00101   edm::Handle<reco::BeamSpot> recoBeamSpotHandle;
00102   // iEvent.getByType(recoBeamSpotHandle);
00103   iEvent.getByLabel(BSProducer_,recoBeamSpotHandle);
00104   // gets its position
00105   const BeamSpot::Point& BSPosition = recoBeamSpotHandle->position(); 
00106 
00107   //Get the HLT electrons collection if needed
00108   edm::Handle<reco::ElectronCollection> electronHandle;
00109   if(useZvertex_){iEvent.getByLabel(candTagEle_,electronHandle);}
00110 
00111   reco::SuperClusterRef scRef;
00112   for (reco::RecoEcalCandidateCollection::const_iterator recoecalcand= recoecalcands->begin(); recoecalcand!=recoecalcands->end(); recoecalcand++) {
00113     scRef = recoecalcand->superCluster();
00114     float zvertex = 0;
00115     if( useZvertex_ ){
00116       reco::SuperClusterRef scRefEle;
00117       for(reco::ElectronCollection::const_iterator iElectron = electronHandle->begin(); iElectron != electronHandle->end(); iElectron++){
00118         //Compare electron SC with EcalCandidate SC
00119         scRefEle = iElectron->superCluster();
00120         if(&(*scRef) == &(*scRefEle)){
00121           zvertex = iElectron->track()->vz();     
00122           break;
00123         }
00124       }
00125 
00126     }
00127     GlobalVector dirVector((recoecalcand)->px(),(recoecalcand)->py(),(recoecalcand)->pz());
00128     RectangularEtaPhiTrackingRegion etaphiRegion( dirVector,
00129                                                                                            GlobalPoint( BSPosition.x(), BSPosition.y(), zvertex ), 
00130                                                                                            ptmin_,
00131                                                                                            originradius_,
00132                                                                                            halflength_,
00133                                                                                            deltaEta_,
00134                                                                                            deltaPhi_);
00135 
00136     // fill Trajectory seed collection
00137     combinatorialSeedGenerator->run(*output, etaphiRegion, iEvent, iSetup);
00138     
00139   }
00140 
00141     iEvent.put(output);
00142 }