CMS 3D CMS Logo

/afs/cern.ch/work/a/aaltunda/public/www/CMSSW_6_2_7/src/Alignment/CommonAlignmentProducer/src/AlignmentCSCBeamHaloSelector.cc

Go to the documentation of this file.
00001 #include "Alignment/CommonAlignmentProducer/interface/AlignmentCSCBeamHaloSelector.h"
00002 
00003 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00005 
00006 #include "DataFormats/DetId/interface/DetId.h"
00007 #include "DataFormats/MuonDetId/interface/MuonSubdetId.h"
00008 #include "DataFormats/MuonDetId/interface/CSCDetId.h"
00009 #include "DataFormats/TrackingRecHit/interface/TrackingRecHit.h"
00010 #include "DataFormats/TrackingRecHit/interface/TrackingRecHitFwd.h"
00011 
00012 // constructor ----------------------------------------------------------------
00013 
00014 AlignmentCSCBeamHaloSelector::AlignmentCSCBeamHaloSelector(const edm::ParameterSet &iConfig)
00015    : m_minStations(iConfig.getParameter<unsigned int>("minStations"))
00016    , m_minHitsPerStation(iConfig.getParameter<unsigned int>("minHitsPerStation"))
00017 {
00018    edm::LogInfo("AlignmentCSCBeamHaloSelector") 
00019       << "Acceptable tracks must have at least " << m_minHitsPerStation << " hits in " << m_minStations << " different CSC stations." << std::endl;
00020 }
00021 
00022 // destructor -----------------------------------------------------------------
00023 
00024 AlignmentCSCBeamHaloSelector::~AlignmentCSCBeamHaloSelector() {}
00025 
00026 // do selection ---------------------------------------------------------------
00027 
00028 AlignmentCSCBeamHaloSelector::Tracks 
00029 AlignmentCSCBeamHaloSelector::select(const Tracks &tracks, const edm::Event &iEvent) const {
00030    Tracks result;
00031 
00032    for (Tracks::const_iterator track = tracks.begin();  track != tracks.end();  ++track) {
00033       std::map<int, unsigned int> station_map;
00034 
00035       for (trackingRecHit_iterator hit = (*track)->recHitsBegin();  hit != (*track)->recHitsEnd();  ++hit) {
00036          DetId id = (*hit)->geographicalId();
00037          if (id.det() == DetId::Muon  &&  id.subdetId() == MuonSubdetId::CSC) {
00038             CSCDetId cscid(id.rawId());
00039             int station = (cscid.endcap() == 1 ? 1 : -1) * cscid.station();
00040 
00041             std::map<int, unsigned int>::const_iterator station_iter = station_map.find(station);
00042             if (station_iter == station_map.end()) {
00043                station_map[station] = 0;
00044             }
00045             station_map[station]++;
00046          } // end if it's a CSC hit
00047       } // end loop over hits
00048 
00049       unsigned int stations = 0;
00050       for (std::map<int, unsigned int>::const_iterator station_iter = station_map.begin();  station_iter != station_map.end();  ++station_iter) {
00051          if (station_iter->second > m_minHitsPerStation) stations++;
00052       }
00053       if (stations >= m_minStations) {
00054          result.push_back(*track);
00055       }
00056    } // end loop over tracks
00057   
00058    return result;
00059 }