CMS 3D CMS Logo

/data/refman/pasoursint/CMSSW_5_3_9_patch3/src/RecoCaloTools/Selectors/src/CaloConeSelector.cc

Go to the documentation of this file.
00001 #include "RecoCaloTools/Selectors/interface/CaloConeSelector.h"
00002 #include "RecoCaloTools/MetaCollections/interface/CaloRecHitMetaCollectionFast.h" 
00003 #include "Geometry/CaloGeometry/interface/CaloSubdetectorGeometry.h"
00004 
00005 CaloConeSelector::CaloConeSelector(double dR, const CaloGeometry* geom) :
00006   geom_(geom),deltaR_(dR),detector_(DetId::Detector(0)),subdet_(0) {
00007 }
00008 
00009 CaloConeSelector::CaloConeSelector(double dR, const CaloGeometry* geom, DetId::Detector detector, int subdet) : 
00010   geom_(geom),deltaR_(dR),detector_(detector),subdet_(subdet) {
00011 }
00012 
00013 std::auto_ptr<CaloRecHitMetaCollectionV> CaloConeSelector::select(double eta, double phi, const CaloRecHitMetaCollectionV& inputCollection) {
00014   GlobalPoint p(GlobalPoint::Cylindrical(1,phi,tanh(eta)));
00015   return select(p,inputCollection);
00016 }
00017 
00018 std::auto_ptr<CaloRecHitMetaCollectionV> CaloConeSelector::select(const GlobalPoint& p, const CaloRecHitMetaCollectionV& inputCollection) {
00019   CaloRecHitMetaCollectionFast* c=new CaloRecHitMetaCollectionFast();
00020 
00021   // TODO: handle default setting of detector_ (loops over subdet)
00022   // TODO: heuristics of when it is better to loop over inputCollection instead (small # hits)
00023   for (int subdet=subdet_; subdet<=7 && (subdet_==0 || subdet_==subdet); subdet++) {
00024     const CaloSubdetectorGeometry* sdg=geom_->getSubdetectorGeometry(detector_,subdet);
00025     if (sdg!=0) {
00026       // get the list of detids within range (from geometry)
00027       CaloSubdetectorGeometry::DetIdSet dis=sdg->getCells(p,deltaR_);
00028       // loop over detids...
00029       CaloRecHitMetaCollectionV::const_iterator j,je=inputCollection.end();      
00030 
00031       for (CaloSubdetectorGeometry::DetIdSet::iterator i=dis.begin(); i!=dis.end(); i++) {
00032         if (i->subdetId()!=subdet) continue; // possible for HCAL where the same geometry object handles all the detectors
00033         j=inputCollection.find(*i);
00034         if (j!=je) c->add(&(*j));
00035       }
00036     }    
00037   }
00038 
00039   return std::auto_ptr<CaloRecHitMetaCollectionV>(c);
00040 }