CMS 3D CMS Logo

Public Member Functions | Private Member Functions | Private Attributes

EgammaHLTIslandClusterProducer Class Reference

#include <EgammaHLTIslandClusterProducer.h>

Inheritance diagram for EgammaHLTIslandClusterProducer:
edm::EDProducer edm::ProducerBase edm::ProductRegistryHelper

List of all members.

Public Member Functions

 EgammaHLTIslandClusterProducer (const edm::ParameterSet &ps)
virtual void produce (edm::Event &, const edm::EventSetup &)
 ~EgammaHLTIslandClusterProducer ()

Private Member Functions

void clusterizeECALPart (edm::Event &evt, const edm::EventSetup &es, const std::string &hitProducer, const std::string &hitCollection, const std::string &clusterCollection, const std::vector< EcalEtaPhiRegion > &regions, const IslandClusterAlgo::EcalPart &ecalPart)
bool counterExceeded () const
const EcalRecHitCollectiongetCollection (edm::Event &evt, const std::string &hitProducer_, const std::string &hitCollection_)

Private Attributes

std::string barrelClusterCollection_
std::string barrelHitCollection_
edm::InputTag barrelHitProducer_
bool doBarrel_
bool doEndcaps_
bool doIsolated_
std::string endcapClusterCollection_
std::string endcapHitCollection_
edm::InputTag endcapHitProducer_
IslandClusterAlgoisland_p
double l1LowerThr_
double l1LowerThrIgnoreIsolation_
edm::InputTag l1TagIsolated_
edm::InputTag l1TagNonIsolated_
double l1UpperThr_
int nEvt_
int nMaxPrintout_
PositionCalc posCalculator_
double regionEtaMargin_
double regionPhiMargin_
IslandClusterAlgo::VerbosityLevel verbosity

Detailed Description

Definition at line 24 of file EgammaHLTIslandClusterProducer.h.


Constructor & Destructor Documentation

EgammaHLTIslandClusterProducer::EgammaHLTIslandClusterProducer ( const edm::ParameterSet ps)

Definition at line 42 of file EgammaHLTIslandClusterProducer.cc.

References barrelClusterCollection_, barrelHitCollection_, barrelHitProducer_, doBarrel_, doEndcaps_, doIsolated_, endcapClusterCollection_, endcapHitCollection_, endcapHitProducer_, edm::ParameterSet::getParameter(), island_p, l1LowerThr_, l1LowerThrIgnoreIsolation_, l1TagIsolated_, l1TagNonIsolated_, l1UpperThr_, nEvt_, IslandClusterAlgo::pDEBUG, IslandClusterAlgo::pERROR, IslandClusterAlgo::pINFO, posCalculator_, IslandClusterAlgo::pWARNING, regionEtaMargin_, regionPhiMargin_, and verbosity.

{
  // The verbosity level
  std::string verbosityString = ps.getParameter<std::string>("VerbosityLevel");
  if      (verbosityString == "DEBUG")   verbosity = IslandClusterAlgo::pDEBUG;
  else if (verbosityString == "WARNING") verbosity = IslandClusterAlgo::pWARNING;
  else if (verbosityString == "INFO")    verbosity = IslandClusterAlgo::pINFO;
  else                                   verbosity = IslandClusterAlgo::pERROR;

  doBarrel_   = ps.getParameter<bool>("doBarrel");
  doEndcaps_   = ps.getParameter<bool>("doEndcaps");
  doIsolated_   = ps.getParameter<bool>("doIsolated");

  // Parameters to identify the hit collections
  barrelHitProducer_   = ps.getParameter<edm::InputTag>("barrelHitProducer");
  endcapHitProducer_   = ps.getParameter<edm::InputTag>("endcapHitProducer");
  barrelHitCollection_ = ps.getParameter<std::string>("barrelHitCollection");
  endcapHitCollection_ = ps.getParameter<std::string>("endcapHitCollection");

  // The names of the produced cluster collections
  barrelClusterCollection_  = ps.getParameter<std::string>("barrelClusterCollection");
  endcapClusterCollection_  = ps.getParameter<std::string>("endcapClusterCollection");

  // Island algorithm parameters
  double barrelSeedThreshold = ps.getParameter<double>("IslandBarrelSeedThr");
  double endcapSeedThreshold = ps.getParameter<double>("IslandEndcapSeedThr");

  // L1 matching parameters
  l1TagIsolated_ = ps.getParameter< edm::InputTag > ("l1TagIsolated");
  l1TagNonIsolated_ = ps.getParameter< edm::InputTag > ("l1TagNonIsolated");
  l1LowerThr_ = ps.getParameter<double> ("l1LowerThr");
  l1UpperThr_ = ps.getParameter<double> ("l1UpperThr");
  l1LowerThrIgnoreIsolation_ = ps.getParameter<double> ("l1LowerThrIgnoreIsolation");

  regionEtaMargin_   = ps.getParameter<double>("regionEtaMargin");
  regionPhiMargin_   = ps.getParameter<double>("regionPhiMargin");

   // Parameters for the position calculation:
  posCalculator_ = PositionCalc( ps.getParameter<edm::ParameterSet>("posCalcParameters") );

  // Produces a collection of barrel and a collection of endcap clusters

  produces< reco::BasicClusterCollection >(endcapClusterCollection_);
  produces< reco::BasicClusterCollection >(barrelClusterCollection_);

  island_p = new IslandClusterAlgo(barrelSeedThreshold, endcapSeedThreshold, posCalculator_,verbosity);

  nEvt_ = 0;
}
EgammaHLTIslandClusterProducer::~EgammaHLTIslandClusterProducer ( )

Definition at line 93 of file EgammaHLTIslandClusterProducer.cc.

References island_p.

{
  delete island_p;
}

Member Function Documentation

void EgammaHLTIslandClusterProducer::clusterizeECALPart ( edm::Event evt,
const edm::EventSetup es,
const std::string &  hitProducer,
const std::string &  hitCollection,
const std::string &  clusterCollection,
const std::vector< EcalEtaPhiRegion > &  regions,
const IslandClusterAlgo::EcalPart ecalPart 
) [private]

Definition at line 247 of file EgammaHLTIslandClusterProducer.cc.

References IslandClusterAlgo::barrel, barrelClusterCollection_, DetId::Ecal, EcalBarrel, EcalEndcap, EcalPreshower, endcapClusterCollection_, edm::EventSetup::get(), getCollection(), island_p, IslandClusterAlgo::makeClusters(), and edm::Event::put().

Referenced by produce().

{
  // get the hit collection from the event:
  const EcalRecHitCollection *hitCollection_p = getCollection(evt, hitProducer, hitCollection);

  // get the geometry and topology from the event setup:
  edm::ESHandle<CaloGeometry> geoHandle;
  es.get<CaloGeometryRecord>().get(geoHandle);

  const CaloSubdetectorGeometry *geometry_p;
  CaloSubdetectorTopology *topology_p;

  if (ecalPart == IslandClusterAlgo::barrel) 
    {
      geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalBarrel);
      topology_p = new EcalBarrelTopology(geoHandle);
    }
  else
    {
      geometry_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalEndcap);
      topology_p = new EcalEndcapTopology(geoHandle); 
   }

  const CaloSubdetectorGeometry *geometryES_p;
  geometryES_p = geoHandle->getSubdetectorGeometry(DetId::Ecal, EcalPreshower);

  // Run the clusterization algorithm:
  reco::BasicClusterCollection clusters;
  clusters = island_p->makeClusters(hitCollection_p, geometry_p, topology_p, geometryES_p, ecalPart, true, regions);

  // create an auto_ptr to a BasicClusterCollection, copy the barrel clusters into it and put in the Event:
  std::auto_ptr< reco::BasicClusterCollection > clusters_p(new reco::BasicClusterCollection);
  clusters_p->assign(clusters.begin(), clusters.end());
  edm::OrphanHandle<reco::BasicClusterCollection> bccHandle;
  if (ecalPart == IslandClusterAlgo::barrel) 
    bccHandle = evt.put(clusters_p, barrelClusterCollection_);
  else
    bccHandle = evt.put(clusters_p, endcapClusterCollection_);

  delete topology_p;
}
bool EgammaHLTIslandClusterProducer::counterExceeded ( ) const [inline, private]

Definition at line 65 of file EgammaHLTIslandClusterProducer.h.

References nEvt_, and nMaxPrintout_.

{ return ((nEvt_ > nMaxPrintout_) || (nMaxPrintout_ < 0)); }
const EcalRecHitCollection * EgammaHLTIslandClusterProducer::getCollection ( edm::Event evt,
const std::string &  hitProducer_,
const std::string &  hitCollection_ 
) [private]

Definition at line 230 of file EgammaHLTIslandClusterProducer.cc.

References gather_cfg::cout, edm::Event::getByLabel(), edm::HandleBase::isValid(), and edm::Handle< T >::product().

Referenced by clusterizeECALPart().

{
  edm::Handle<EcalRecHitCollection> rhcHandle;

  evt.getByLabel(hitProducer_, hitCollection_, rhcHandle);
  if (!(rhcHandle.isValid())) 
    {
      std::cout << "could not get a handle on the EcalRecHitCollection!" << std::endl;
      edm::LogError("EgammaHLTIslandClusterProducerError") << "Error! can't get the product " << hitCollection_.c_str() ;
      return 0;
    } 
  return rhcHandle.product();
}
void EgammaHLTIslandClusterProducer::produce ( edm::Event evt,
const edm::EventSetup es 
) [virtual]

Implements edm::EDProducer.

Definition at line 99 of file EgammaHLTIslandClusterProducer.cc.

References Reference_intrackfit_cff::barrel, barrelClusterCollection_, barrelHitCollection_, barrelHitProducer_, clusterizeECALPart(), doBarrel_, doEndcaps_, doIsolated_, Reference_intrackfit_cff::endcap, endcapClusterCollection_, endcapHitCollection_, endcapHitProducer_, edm::EventSetup::get(), edm::Event::getByLabel(), l1LowerThr_, l1LowerThrIgnoreIsolation_, l1TagIsolated_, l1TagNonIsolated_, l1UpperThr_, edm::InputTag::label(), nEvt_, regionEtaMargin_, and regionPhiMargin_.

{
  //Get the L1 EM Particle Collection
  edm::Handle< l1extra::L1EmParticleCollection > emIsolColl ;
  if(doIsolated_)
    evt.getByLabel(l1TagIsolated_, emIsolColl);
  //Get the L1 EM Particle Collection
  edm::Handle< l1extra::L1EmParticleCollection > emNonIsolColl ;
  evt.getByLabel(l1TagNonIsolated_, emNonIsolColl);
  // Get the CaloGeometry
  edm::ESHandle<L1CaloGeometry> l1CaloGeom ;
  es.get<L1CaloGeometryRecord>().get(l1CaloGeom) ;

  std::vector<EcalEtaPhiRegion> barrelRegions;
  std::vector<EcalEtaPhiRegion> endcapRegions;

  if(doIsolated_) {
    for( l1extra::L1EmParticleCollection::const_iterator emItr = emIsolColl->begin(); emItr != emIsolColl->end() ;++emItr ){

      if (emItr->et() > l1LowerThr_ && emItr->et() < l1UpperThr_) {
        
        // Access the GCT hardware object corresponding to the L1Extra EM object.
        int etaIndex = emItr->gctEmCand()->etaIndex() ;
        
        
        int phiIndex = emItr->gctEmCand()->phiIndex() ;
        // Use the L1CaloGeometry to find the eta, phi bin boundaries.
        double etaLow  = l1CaloGeom->etaBinLowEdge( etaIndex ) ;
        double etaHigh = l1CaloGeom->etaBinHighEdge( etaIndex ) ;
        double phiLow  = l1CaloGeom->emJetPhiBinLowEdge( phiIndex ) ;
        double phiHigh = l1CaloGeom->emJetPhiBinHighEdge( phiIndex ) ;

        //Attention isForward does not work
        int isforw=0;
        int isbarl=0;
        if((float)(etaHigh)>1.479 || (float)(etaLow)<-1.479) isforw=1;
        if(((float)(etaLow)>-1.479 && (float)(etaLow)<1.479) || 
           ((float)(etaHigh)>-1.479 && (float)(etaHigh)<1.479)) isbarl=1;

        //std::cout<<"Island etaindex "<<etaIndex<<" low hig : "<<etaLow<<" "<<etaHigh<<" phi low hig" <<phiLow<<" " << phiHigh<<" isforw "<<emItr->gctEmCand()->regionId().isForward()<<" isforwnew" <<isforw<< std::endl;
        
        etaLow -= regionEtaMargin_;
        etaHigh += regionEtaMargin_;
        phiLow -= regionPhiMargin_;
        phiHigh += regionPhiMargin_;

        //if (emItr->gctEmCand()->regionId().isForward()) {
        if (isforw) {
          if (etaHigh>-1.479 && etaHigh<1.479) etaHigh=-1.479;
          if ( etaLow>-1.479 &&  etaLow<1.479) etaLow=1.479;
          EcalEtaPhiRegion region(etaLow,etaHigh,phiLow,phiHigh);
          endcapRegions.push_back(region);
        }
        if (isbarl) {
          if (etaHigh>1.479) etaHigh=1.479;
          if (etaLow<-1.479) etaLow=-1.479;
          EcalEtaPhiRegion region(etaLow,etaHigh,phiLow,phiHigh);
          barrelRegions.push_back(region);
        }
        EcalEtaPhiRegion region(etaLow,etaHigh,phiLow,phiHigh);
        
      }
    }
  }


  if(!doIsolated_||l1LowerThrIgnoreIsolation_<64) {
    for( l1extra::L1EmParticleCollection::const_iterator emItr = emNonIsolColl->begin(); emItr != emNonIsolColl->end() ;++emItr ){

      if(doIsolated_&&emItr->et()<l1LowerThrIgnoreIsolation_) continue;

      if (emItr->et() > l1LowerThr_ && emItr->et() < l1UpperThr_) {
        
        // Access the GCT hardware object corresponding to the L1Extra EM object.
        int etaIndex = emItr->gctEmCand()->etaIndex() ;
        
        
        int phiIndex = emItr->gctEmCand()->phiIndex() ;
        // Use the L1CaloGeometry to find the eta, phi bin boundaries.
        double etaLow  = l1CaloGeom->etaBinLowEdge( etaIndex ) ;
        double etaHigh = l1CaloGeom->etaBinHighEdge( etaIndex ) ;
        double phiLow  = l1CaloGeom->emJetPhiBinLowEdge( phiIndex ) ;
        double phiHigh = l1CaloGeom->emJetPhiBinHighEdge( phiIndex ) ;


        int isforw=0;
        int isbarl=0;
        if((float)(etaHigh)>1.479 || (float)(etaLow)<-1.479) isforw=1;
        if(((float)(etaLow)>-1.479 && (float)(etaLow)<1.479) || 
           ((float)(etaHigh)>-1.479 && (float)(etaHigh)<1.479)) isbarl=1;

        //std::cout<<"Island etaindex "<<etaIndex<<" low hig : "<<etaLow<<" "<<etaHigh<<" phi low hig" <<phiLow<<" " << phiHigh<<" isforw "<<emItr->gctEmCand()->regionId().isForward()<<" isforwnew" <<isforw<< std::endl;
        
        etaLow -= regionEtaMargin_;
        etaHigh += regionEtaMargin_;
        phiLow -= regionPhiMargin_;
        phiHigh += regionPhiMargin_;

        //if (emItr->gctEmCand()->regionId().isForward()) {
        if (isforw) {
          if (etaHigh>-1.479 && etaHigh<1.479) etaHigh=-1.479;
          if ( etaLow>-1.479 &&  etaLow<1.479) etaLow=1.479;
          EcalEtaPhiRegion region(etaLow,etaHigh,phiLow,phiHigh);
          endcapRegions.push_back(region);
        }
        if (isbarl) {
          if (etaHigh>1.479) etaHigh=1.479;
          if (etaLow<-1.479) etaLow=-1.479;
          EcalEtaPhiRegion region(etaLow,etaHigh,phiLow,phiHigh);
          barrelRegions.push_back(region);
        }
        
      }
    }
  }

  if (doEndcaps_ 
      //&&endcapRegions.size()!=0
      ) {

    clusterizeECALPart(evt, es, endcapHitProducer_.label(), endcapHitCollection_, endcapClusterCollection_, endcapRegions, IslandClusterAlgo::endcap);
  }
  if (doBarrel_ 
      //&& barrelRegions.size()!=0
      ) {
    clusterizeECALPart(evt, es, barrelHitProducer_.label(), barrelHitCollection_, barrelClusterCollection_, barrelRegions, IslandClusterAlgo::barrel);
  }
  nEvt_++;
}

Member Data Documentation

Definition at line 47 of file EgammaHLTIslandClusterProducer.h.

Referenced by EgammaHLTIslandClusterProducer(), and produce().

Definition at line 45 of file EgammaHLTIslandClusterProducer.h.

Referenced by EgammaHLTIslandClusterProducer(), and produce().

Definition at line 41 of file EgammaHLTIslandClusterProducer.h.

Referenced by EgammaHLTIslandClusterProducer(), and produce().

Definition at line 42 of file EgammaHLTIslandClusterProducer.h.

Referenced by EgammaHLTIslandClusterProducer(), and produce().

Definition at line 43 of file EgammaHLTIslandClusterProducer.h.

Referenced by EgammaHLTIslandClusterProducer(), and produce().

Definition at line 48 of file EgammaHLTIslandClusterProducer.h.

Referenced by EgammaHLTIslandClusterProducer(), and produce().

Definition at line 46 of file EgammaHLTIslandClusterProducer.h.

Referenced by EgammaHLTIslandClusterProducer(), and produce().

Definition at line 55 of file EgammaHLTIslandClusterProducer.h.

Referenced by EgammaHLTIslandClusterProducer(), and produce().

Definition at line 57 of file EgammaHLTIslandClusterProducer.h.

Referenced by EgammaHLTIslandClusterProducer(), and produce().

Definition at line 53 of file EgammaHLTIslandClusterProducer.h.

Referenced by EgammaHLTIslandClusterProducer(), and produce().

Definition at line 54 of file EgammaHLTIslandClusterProducer.h.

Referenced by EgammaHLTIslandClusterProducer(), and produce().

Definition at line 56 of file EgammaHLTIslandClusterProducer.h.

Referenced by EgammaHLTIslandClusterProducer(), and produce().

Definition at line 36 of file EgammaHLTIslandClusterProducer.h.

Referenced by counterExceeded().

Definition at line 62 of file EgammaHLTIslandClusterProducer.h.

Referenced by EgammaHLTIslandClusterProducer().

Definition at line 59 of file EgammaHLTIslandClusterProducer.h.

Referenced by EgammaHLTIslandClusterProducer(), and produce().

Definition at line 60 of file EgammaHLTIslandClusterProducer.h.

Referenced by EgammaHLTIslandClusterProducer(), and produce().

Definition at line 39 of file EgammaHLTIslandClusterProducer.h.

Referenced by EgammaHLTIslandClusterProducer().