Go to the documentation of this file.00001 #include "HLTrigger/special/interface/HLTCSCRing2or3Filter.h"
00002
00003 #include "DataFormats/Common/interface/Handle.h"
00004 #include "FWCore/Framework/interface/ESHandle.h"
00005 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00006
00007 #include "DataFormats/CSCRecHit/interface/CSCRecHit2DCollection.h"
00008 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
00009 #include "Geometry/CSCGeometry/interface/CSCGeometry.h"
00010 #include "Geometry/Records/interface/MuonGeometryRecord.h"
00011 #include "FWCore/ServiceRegistry/interface/Service.h"
00012 #include "CommonTools/UtilAlgos/interface/TFileService.h"
00013
00014 HLTCSCRing2or3Filter::HLTCSCRing2or3Filter(const edm::ParameterSet& iConfig)
00015 : m_input(iConfig.getParameter<edm::InputTag>("input"))
00016 , m_minHits(iConfig.getParameter<unsigned int>("minHits"))
00017 , m_xWindow(iConfig.getParameter<double>("xWindow"))
00018 , m_yWindow(iConfig.getParameter<double>("yWindow"))
00019 {}
00020
00021 HLTCSCRing2or3Filter::~HLTCSCRing2or3Filter() { }
00022
00023 bool HLTCSCRing2or3Filter::filter(edm::Event& iEvent, const edm::EventSetup& iSetup) {
00024 edm::Handle<CSCRecHit2DCollection> hits;
00025 iEvent.getByLabel(m_input, hits);
00026
00027 edm::ESHandle<CSCGeometry> cscGeometry;
00028 bool got_cscGeometry = false;
00029
00030 std::map<int, std::vector<const CSCRecHit2D*> > chamber_tohit;
00031
00032 for (CSCRecHit2DCollection::const_iterator hit = hits->begin(); hit != hits->end(); ++hit) {
00033 CSCDetId id(hit->geographicalId());
00034 int chamber_id = CSCDetId(id.endcap(), id.station(), id.ring(), id.chamber(), 0).rawId();
00035
00036 if (id.ring() == 2 || id.ring() == 3) {
00037 std::map<int, std::vector<const CSCRecHit2D*> >::const_iterator chamber_iter = chamber_tohit.find(chamber_id);
00038 if (chamber_iter == chamber_tohit.end()) {
00039 std::vector<const CSCRecHit2D*> newlist;
00040 newlist.push_back(&(*hit));
00041 }
00042 chamber_tohit[chamber_id].push_back(&(*hit));
00043 }
00044 }
00045
00046 unsigned int minHitsAlmostSquared = (m_minHits-1) * (m_minHits-2);
00047 for (std::map<int, std::vector<const CSCRecHit2D*> >::const_iterator chamber_iter = chamber_tohit.begin();
00048 chamber_iter != chamber_tohit.end();
00049 ++chamber_iter) {
00050
00051 if (chamber_iter->second.size() >= m_minHits) {
00052 if (!got_cscGeometry) {
00053 iSetup.get<MuonGeometryRecord>().get(cscGeometry);
00054 got_cscGeometry = true;
00055 }
00056
00057 unsigned int pairs_in_window = 0;
00058 for (std::vector<const CSCRecHit2D*>::const_iterator hit1 = chamber_iter->second.begin(); hit1 != chamber_iter->second.end(); ++hit1) {
00059 for (std::vector<const CSCRecHit2D*>::const_iterator hit2 = chamber_iter->second.begin(); hit2 != hit1; ++hit2) {
00060 GlobalPoint pos1 = cscGeometry->idToDet((*hit1)->geographicalId())->surface().toGlobal((*hit1)->localPosition());
00061 GlobalPoint pos2 = cscGeometry->idToDet((*hit2)->geographicalId())->surface().toGlobal((*hit2)->localPosition());
00062
00063 if (fabs(pos1.x() - pos2.x()) < m_xWindow && fabs(pos1.y() - pos2.y()) < m_yWindow) pairs_in_window++;
00064
00065 if (pairs_in_window >= minHitsAlmostSquared) return true;
00066 }
00067 }
00068
00069 }
00070 }
00071
00072 return false;
00073 }