Go to the documentation of this file.00001 #include "CalibMuon/DTCalibration/interface/DTSegmentSelector.h"
00002
00003 #include "FWCore/Framework/interface/Event.h"
00004 #include "FWCore/Framework/interface/EventSetup.h"
00005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00006 #include "FWCore/Framework/interface/ESHandle.h"
00007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00008
00009 #include "DataFormats/DTRecHit/interface/DTRecSegment2D.h"
00010 #include "DataFormats/DTRecHit/interface/DTRecSegment4D.h"
00011 #include "DataFormats/DTRecHit/interface/DTRecSegment4DCollection.h"
00012 #include "DataFormats/DTRecHit/interface/DTRecHit1D.h"
00013 #include "CondFormats/DataRecord/interface/DTStatusFlagRcd.h"
00014 #include "CondFormats/DTObjects/interface/DTStatusFlag.h"
00015
00016 bool DTSegmentSelector::operator() (DTRecSegment4D const& segment, edm::Event const& event, edm::EventSetup const& setup){
00017
00018 bool result = true;
00019
00020
00021
00022
00023
00024
00025
00026 edm::ESHandle<DTStatusFlag> statusMap;
00027 if(checkNoisyChannels_) setup.get<DTStatusFlagRcd>().get(statusMap);
00028
00029
00030 int nPhiHits = -1;
00031 bool segmentNoisyPhi = false;
00032 if( segment.hasPhi() ){
00033 const DTChamberRecSegment2D* phiSeg = segment.phiSegment();
00034
00035
00036 std::vector<DTRecHit1D> phiRecHits = phiSeg->specificRecHits();
00037 nPhiHits = phiRecHits.size();
00038 if(checkNoisyChannels_) segmentNoisyPhi = checkNoisySegment(statusMap,phiRecHits);
00039 }
00040
00041 int nZHits = -1;
00042 bool segmentNoisyZ = false;
00043 if( segment.hasZed() ){
00044 const DTSLRecSegment2D* zSeg = segment.zSegment();
00045
00046
00047
00048 std::vector<DTRecHit1D> zRecHits = zSeg->specificRecHits();
00049 nZHits = zRecHits.size();
00050 if(checkNoisyChannels_) segmentNoisyZ = checkNoisySegment(statusMap,zRecHits);
00051 }
00052
00053
00054
00055 if(segmentNoisyPhi || segmentNoisyZ)
00056 result = false;
00057
00058
00059 if(segment.hasPhi() && nPhiHits < minHitsPhi_)
00060 result = false;
00061
00062 if(segment.hasZed() && nZHits < minHitsZ_)
00063 result = false;
00064
00065
00066 double chiSquare = segment.chi2()/segment.degreesOfFreedom();
00067 if(chiSquare > maxChi2_)
00068 result = false;
00069
00070
00071 LocalPoint segment4DLocalPos = segment.localPosition();
00072 LocalVector segment4DLocalDir = segment.localDirection();
00073 double angleZ = fabs( atan(segment4DLocalDir.y()/segment4DLocalDir.z())*180./Geom::pi() );
00074 if( angleZ > maxAngleZ_)
00075 result = false;
00076
00077 double anglePhi = fabs( atan(segment4DLocalDir.x()/segment4DLocalDir.z())*180./Geom::pi() );
00078 if( anglePhi > maxAnglePhi_)
00079 result = false;
00080
00081 return result;
00082 }
00083
00084 bool DTSegmentSelector::checkNoisySegment(edm::ESHandle<DTStatusFlag> const& statusMap, std::vector<DTRecHit1D> const& dtHits){
00085
00086 bool segmentNoisy = false;
00087
00088 std::vector<DTRecHit1D>::const_iterator dtHit = dtHits.begin();
00089 std::vector<DTRecHit1D>::const_iterator dtHits_end = dtHits.end();
00090 for(; dtHit != dtHits_end; ++dtHit){
00091
00092 DTWireId wireId = dtHit->wireId();
00093
00094 bool isNoisy = false, isFEMasked = false, isTDCMasked = false, isTrigMask = false,
00095 isDead = false, isNohv = false;
00096 statusMap->cellStatus(wireId, isNoisy, isFEMasked, isTDCMasked, isTrigMask, isDead, isNohv);
00097 if(isNoisy) {
00098 LogTrace("Calibration") << "Wire: " << wireId << " is noisy, skipping!";
00099 segmentNoisy = true; break;
00100 }
00101 }
00102 return segmentNoisy;
00103 }