CMS 3D CMS Logo

ElectronPixelSeedProducer.cc

Go to the documentation of this file.
00001 // -*- C++ -*-
00002 //
00003 // Package:    ElectronProducers
00004 // Class:      ElectronPixelSeedProducer
00005 // 
00013 //
00014 // Original Author:  Ursula Berthon, Claude Charlot
00015 //         Created:  Mon Mar 27 13:22:06 CEST 2006
00016 // $Id: ElectronPixelSeedProducer.cc,v 1.25 2008/08/27 14:36:43 charlot Exp $
00017 //
00018 //
00019 
00020 // user include files
00021 #include "FWCore/Framework/interface/Frameworkfwd.h"
00022 #include "FWCore/Framework/interface/EDProducer.h"
00023 #include "FWCore/Framework/interface/Event.h"
00024 #include "FWCore/Framework/interface/MakerMacros.h"
00025 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00026 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00027 
00028 #include "Geometry/Records/interface/CaloGeometryRecord.h"
00029 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
00030 
00031 #include "RecoEgamma/EgammaElectronAlgos/interface/ElectronPixelSeedGenerator.h"
00032 #include "RecoEgamma/EgammaElectronAlgos/interface/SeedFilter.h"
00033 
00034 #include "DataFormats/EgammaReco/interface/ElectronPixelSeed.h"
00035 #include "DataFormats/EgammaReco/interface/ElectronPixelSeedFwd.h"
00036 
00037 #include "ElectronPixelSeedProducer.h"
00038 
00039 #include <string>
00040 
00041 using namespace reco;
00042  
00043 ElectronPixelSeedProducer::ElectronPixelSeedProducer(const edm::ParameterSet& iConfig) :conf_(iConfig),seedFilter_(0),cacheID_(0)
00044 {
00045   edm::ParameterSet pset = iConfig.getParameter<edm::ParameterSet>("SeedConfiguration");
00046   initialSeeds_=pset.getParameter<edm::InputTag>("initialSeeds");
00047   SCEtCut_=pset.getParameter<double>("SCEtCut");
00048   maxHOverE_=pset.getParameter<double>("maxHOverE");
00049   fromTrackerSeeds_=pset.getParameter<bool>("fromTrackerSeeds");
00050   prefilteredSeeds_=pset.getParameter<bool>("preFilteredSeeds");
00051 
00052   matcher_ = new ElectronPixelSeedGenerator(pset);
00053  
00054   if (prefilteredSeeds_) seedFilter_ = new SeedFilter(pset);
00055 
00056   //  get collections from config'
00057   superClusters_[0]=iConfig.getParameter<edm::InputTag>("barrelSuperClusters");
00058   superClusters_[1]=iConfig.getParameter<edm::InputTag>("endcapSuperClusters");
00059   hcalRecHits_ = pset.getParameter<edm::InputTag>("hcalRecHits");
00060 
00061   //register your products
00062   produces<ElectronPixelSeedCollection>();
00063 }
00064 
00065 
00066 ElectronPixelSeedProducer::~ElectronPixelSeedProducer()
00067 {
00068    // do anything here that needs to be done at desctruction time
00069    // (e.g. close files, deallocate resources etc.)
00070       delete matcher_;
00071       delete seedFilter_;
00072 }
00073 
00074 void ElectronPixelSeedProducer::beginJob(edm::EventSetup const&iSetup) 
00075 {
00076 }
00077 
00078 void ElectronPixelSeedProducer::produce(edm::Event& e, const edm::EventSetup& iSetup) 
00079 {
00080   LogDebug("ElectronPixelSeedProducer");
00081   LogDebug("ElectronPixelSeedProducer")  <<"[ElectronPixelSeedProducer::produce] entering " ;
00082   // get calo geometry 
00083   if (cacheID_!=iSetup.get<CaloGeometryRecord>().cacheIdentifier()) {
00084               iSetup.get<CaloGeometryRecord>().get(theCaloGeom);
00085               cacheID_=iSetup.get<CaloGeometryRecord>().cacheIdentifier();
00086   }
00087 
00088   matcher_->setupES(iSetup);  
00089 
00090   // get Hcal Rechit collection
00091   edm::Handle<HBHERecHitCollection> hbhe;
00092   HBHERecHitMetaCollection *mhbhe=0;
00093   bool got =    e.getByLabel(hcalRecHits_,hbhe);  
00094   if (got) mhbhe=  new HBHERecHitMetaCollection(*hbhe);
00095 
00096   // get initial TrajectorySeeds if necessary
00097   if (fromTrackerSeeds_) {
00098     if (!prefilteredSeeds_) {
00099       edm::Handle<TrajectorySeedCollection> hSeeds;
00100       e.getByLabel(initialSeeds_, hSeeds);
00101       theInitialSeedColl = const_cast<TrajectorySeedCollection *> (hSeeds.product());
00102     }
00103     else theInitialSeedColl =new TrajectorySeedCollection;
00104   }else
00105     theInitialSeedColl=0;// not needed in this case
00106  
00107 
00108 
00109   ElectronPixelSeedCollection *seeds= new ElectronPixelSeedCollection;
00110 std::auto_ptr<ElectronPixelSeedCollection> pSeeds;
00111 
00112   // loop over barrel + endcap
00113   calc_=HoECalculator(theCaloGeom);
00114   for (unsigned int i=0; i<2; i++) {  
00115    // invoke algorithm
00116     edm::Handle<SuperClusterCollection> clusters;
00117     if (e.getByLabel(superClusters_[i],clusters))   {
00118         SuperClusterRefVector clusterRefs;
00119         filterClusters(clusters,mhbhe,clusterRefs);
00120         if ((fromTrackerSeeds_) && (prefilteredSeeds_)) filterSeeds(e,iSetup,clusterRefs);
00121         matcher_->run(e,iSetup,clusterRefs,theInitialSeedColl,*seeds);
00122 
00123     }
00124   }
00125 
00126   // store the accumulated result
00127   pSeeds=  std::auto_ptr<ElectronPixelSeedCollection>(seeds);
00128   for (ElectronPixelSeedCollection::iterator is=pSeeds->begin(); is!=pSeeds->end();is++) {
00129     LogDebug("ElectronPixelSeedProducer")  << "new seed with " << (*is).nHits() << " hits, charge " << (*is).getCharge() <<
00130         " and cluster energy " << (*is).superCluster()->energy() << " PID "<<(*is).superCluster().id();
00131   }
00132   e.put(pSeeds);
00133   delete mhbhe;
00134   if (fromTrackerSeeds_ && prefilteredSeeds_) delete theInitialSeedColl;
00135  }
00136 
00137 void ElectronPixelSeedProducer::filterClusters(const edm::Handle<reco::SuperClusterCollection> &superClusters,HBHERecHitMetaCollection*mhbhe, SuperClusterRefVector &sclRefs) {
00138 
00139   // filter the superclusters
00140   // - with EtCut
00141   // - with HoE
00142   for (unsigned int i=0;i<superClusters->size();++i) {
00143     const SuperCluster &scl=(*superClusters)[i];
00144 
00145     if (scl.energy()/cosh(scl.eta())>SCEtCut_) {
00146 
00147       double HoE=calc_(&scl,mhbhe);
00148       if (HoE <= maxHOverE_) {
00149         sclRefs.push_back(edm::Ref<reco::SuperClusterCollection> (superClusters,i));
00150       }
00151     }
00152   }
00153   LogDebug("ElectronPixelSeedProducer")  <<"Filtered out "<<sclRefs.size() <<" superclusters from "<<superClusters->size() ;
00154 }
00155 
00156 void ElectronPixelSeedProducer::filterSeeds(edm::Event& e, const edm::EventSetup& setup, reco::SuperClusterRefVector &sclRefs)
00157 {
00158 
00159   for  (unsigned int i=0;i<sclRefs.size();++i) {
00160     seedFilter_->seeds(e, setup, sclRefs[i], theInitialSeedColl);
00161 
00162     LogDebug("ElectronPixelSeedProducer")<< "Number fo Seeds: " << theInitialSeedColl->size() ;
00163   }
00164  
00165 
00166 }

Generated on Tue Jun 9 17:43:21 2009 for CMSSW by  doxygen 1.5.4