CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/Calibration/IsolatedParticles/src/FindCaloHitCone.cc

Go to the documentation of this file.
00001 #include "Calibration/IsolatedParticles/interface/FindCaloHitCone.h"
00002 #include "DataFormats/EcalDetId/interface/EcalSubdetector.h"
00003 #include <iostream>
00004 
00005 namespace spr {
00006 
00007 
00008   //Ecal Endcap OR Barrel RecHits
00009   std::vector<EcalRecHitCollection::const_iterator> findCone(const CaloGeometry* geo, edm::Handle<EcalRecHitCollection>& hits, const GlobalPoint& hpoint1, const GlobalPoint& point1, double dR, const GlobalVector& trackMom) {
00010   
00011     std::vector<EcalRecHitCollection::const_iterator> hit;
00012   
00013     for (EcalRecHitCollection::const_iterator j=hits->begin(); 
00014          j!=hits->end(); j++) {
00015 
00016       bool keepHit = false;
00017     
00018       if (j->id().subdetId() == EcalEndcap) {
00019         EEDetId EEid = EEDetId(j->id());
00020         const GlobalPoint rechitPoint = geo->getPosition(EEid);
00021         if (getDistInPlaneTrackDir(point1, trackMom, rechitPoint)<dR) keepHit = true;
00022       } else if (j->id().subdetId() == EcalBarrel) {
00023         EBDetId EBid = EBDetId(j->id());
00024         const GlobalPoint rechitPoint = geo->getPosition(EBid);
00025         if (getDistInPlaneTrackDir(point1, trackMom, rechitPoint)<dR) keepHit = true;
00026       }
00027 
00028       if (keepHit) hit.push_back(j);
00029     }
00030     return hit;
00031   }
00032 
00033   // Ecal Endcap AND Barrel RecHits
00034   std::vector<EcalRecHitCollection::const_iterator> findCone(const CaloGeometry* geo, edm::Handle<EcalRecHitCollection>& barrelhits, edm::Handle<EcalRecHitCollection>& endcaphits, const GlobalPoint& hpoint1, const GlobalPoint& point1, double dR, const GlobalVector& trackMom) {
00035   
00036     std::vector<EcalRecHitCollection::const_iterator> hit;
00037   
00038     // Only check both barrel and endcap when track is near transition
00039     // region: 1.479-2*0.087 < trkEta < 1.479+2*0.087
00040   
00041     bool doBarrel=false, doEndcap=false;
00042     if ( std::abs(point1.eta()) < 1.653) doBarrel=true; // 1.479+2*0.087
00043     if ( std::abs(point1.eta()) > 1.305) doEndcap=true; // 1.479-2*0.087    
00044   
00045     if (doBarrel) {  
00046       for (EcalRecHitCollection::const_iterator j=barrelhits->begin(); 
00047            j!=barrelhits->end(); j++) {
00048 
00049         bool keepHit = false;
00050         if (j->id().subdetId() == EcalBarrel) {
00051           EBDetId EBid = EBDetId(j->id());
00052           const GlobalPoint rechitPoint = geo->getPosition(EBid);
00053           if (getDistInPlaneTrackDir(point1, trackMom, rechitPoint)<dR) keepHit = true;
00054         } else {
00055           std::cout << "PROBLEM : Endcap RecHits in Barrel Collection!?" 
00056                     << std::endl;
00057         }
00058         if (keepHit) hit.push_back(j);
00059       }
00060     } // doBarrel
00061   
00062     if (doEndcap) {  
00063     
00064       for (EcalRecHitCollection::const_iterator j=endcaphits->begin(); 
00065            j!=endcaphits->end(); j++) {
00066       
00067         bool keepHit = false;
00068       
00069         if (j->id().subdetId() == EcalEndcap) {
00070           EEDetId EEid = EEDetId(j->id());
00071           const GlobalPoint rechitPoint = geo->getPosition(EEid);
00072           if (getDistInPlaneTrackDir(point1, trackMom, rechitPoint)<dR) keepHit = true;
00073         } else {
00074           std::cout << "PROBLEM : Barrel RecHits in Endcap Collection!?" 
00075                     << std::endl;
00076         }
00077         if (keepHit) hit.push_back(j);
00078       }
00079     } // doEndcap
00080   
00081     return hit;
00082   }
00083 
00084 
00085   //HBHE RecHits
00086   std::vector<HBHERecHitCollection::const_iterator> findCone(const CaloGeometry* geo, edm::Handle<HBHERecHitCollection>& hits, const GlobalPoint& hpoint1, const GlobalPoint& point1, double dR, const GlobalVector& trackMom) {
00087 
00088     std::vector<HBHERecHitCollection::const_iterator> hit;
00089     // Loop over Hcal RecHits
00090     for (HBHERecHitCollection::const_iterator j=hits->begin(); 
00091          j!=hits->end(); j++) {   
00092       DetId detId(j->id());
00093       const GlobalPoint rechitPoint = geo->getPosition(detId);
00094       if (getDistInPlaneTrackDir(hpoint1, trackMom, rechitPoint)<dR) hit.push_back(j);
00095     }  
00096     return hit;
00097   }
00098 
00099   // PCalo SimHits
00100   std::vector<edm::PCaloHitContainer::const_iterator> findCone(const CaloGeometry* geo, edm::Handle<edm::PCaloHitContainer>& hits, const GlobalPoint& hpoint1, const GlobalPoint& point1, double dR, const GlobalVector& trackMom) {
00101 
00102     std::vector<edm::PCaloHitContainer::const_iterator> hit;  
00103     edm::PCaloHitContainer::const_iterator ihit;
00104     for (ihit=hits->begin(); ihit!=hits->end(); ihit++) {
00105       DetId detId(ihit->id());
00106       const GlobalPoint rechitPoint = geo->getPosition(detId);
00107       if (getDistInPlaneTrackDir(hpoint1, trackMom, rechitPoint)<dR) {
00108         hit.push_back(ihit);
00109       }
00110     }
00111     return hit;
00112   }
00113 
00114 }