Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-12-08 08:16:03

0001 // -*- C++ -*-
0002 //
0003 // Package:    OverlapProblemTSOSPositionFilter
0004 // Class:      OverlapProblemTSOSPositionFilter
0005 //
0006 /**\class OverlapProblemTSOSPositionFilter OverlapProblemTSOSPositionFilter.cc DebugTools/OverlapProblem/plugins/OverlapProblemTSOSPositionFilter.cc
0007 
0008  Description: <one line class summary>
0009 
0010  Implementation:
0011      <Notes on implementation>
0012 */
0013 //
0014 // Original Author:  Andrea Venturi
0015 //         Created:  Thu Dec 16 16:32:56 CEST 2010
0016 // $Id: OverlapProblemTSOSPositionFilter.cc,v 1.1 2012/03/12 14:46:20 venturia Exp $
0017 //
0018 //
0019 
0020 // system include files
0021 #include <memory>
0022 #include <numeric>
0023 #include <vector>
0024 
0025 // user include files
0026 #include "FWCore/Framework/interface/Frameworkfwd.h"
0027 #include "FWCore/Framework/interface/global/EDFilter.h"
0028 
0029 #include "FWCore/Framework/interface/Event.h"
0030 #include "FWCore/Framework/interface/EventSetup.h"
0031 #include "FWCore/Framework/interface/Run.h"
0032 #include "FWCore/Framework/interface/MakerMacros.h"
0033 
0034 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0035 
0036 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0037 
0038 //#include "FWCore/ServiceRegistry/interface/Service.h"
0039 //#include "CommonTools/UtilAlgos/interface/TFileService.h"
0040 
0041 #include "FWCore/Utilities/interface/InputTag.h"
0042 
0043 #include "TrackingTools/PatternTools/interface/Trajectory.h"
0044 #include "TrackingTools/PatternTools/interface/TrajTrackAssociation.h"
0045 #include "TrackingTools/PatternTools/interface/TrajectoryMeasurement.h"
0046 #include "TrackingTools/TrajectoryState/interface/TrajectoryStateOnSurface.h"
0047 #include "TrackingTools/TrackFitters/interface/TrajectoryStateCombiner.h"
0048 #include "TrackingTools/TransientTrackingRecHit/interface/TransientTrackingRecHit.h"
0049 
0050 #include "DataFormats/Common/interface/Ref.h"
0051 #include "DataFormats/TrackerCommon/interface/TrackerTopology.h"
0052 #include "DataFormats/DetId/interface/DetId.h"
0053 #include "DataFormats/TrackReco/interface/Track.h"
0054 #include "DataFormats/TrackReco/interface/TrackFwd.h"
0055 
0056 #include "Geometry/Records/interface/TrackerTopologyRcd.h"
0057 
0058 //
0059 // class decleration
0060 //
0061 
0062 class OverlapProblemTSOSPositionFilter : public edm::global::EDFilter<> {
0063 public:
0064   explicit OverlapProblemTSOSPositionFilter(const edm::ParameterSet&);
0065   ~OverlapProblemTSOSPositionFilter() override;
0066 
0067 private:
0068   bool filter(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
0069 
0070   // ----------member data ---------------------------
0071 
0072   const bool m_validOnly;
0073   edm::EDGetTokenT<TrajTrackAssociationCollection> m_ttacollToken;
0074   edm::ESGetToken<TrackerTopology, TrackerTopologyRcd> m_tTopoToken;
0075 };
0076 
0077 //
0078 // constants, enums and typedefs
0079 //
0080 
0081 //
0082 // static data member definitions
0083 //
0084 
0085 //
0086 // constructors and destructor
0087 //
0088 OverlapProblemTSOSPositionFilter::OverlapProblemTSOSPositionFilter(const edm::ParameterSet& iConfig)
0089     : m_validOnly(iConfig.getParameter<bool>("onlyValidRecHit")),
0090       m_ttacollToken(
0091           consumes<TrajTrackAssociationCollection>(iConfig.getParameter<edm::InputTag>("trajTrackAssoCollection"))),
0092       m_tTopoToken(esConsumes())
0093 
0094 {
0095   //now do what ever initialization is needed
0096 }
0097 
0098 OverlapProblemTSOSPositionFilter::~OverlapProblemTSOSPositionFilter() {
0099   // do anything here that needs to be done at desctruction time
0100   // (e.g. close files, deallocate resources etc.)
0101 }
0102 
0103 //
0104 // member functions
0105 //
0106 
0107 // ------------ method called to for each event  ------------
0108 bool OverlapProblemTSOSPositionFilter::filter(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const {
0109   using namespace edm;
0110 
0111   // loop on trajectories and plot TSOS local coordinate
0112 
0113   TrajectoryStateCombiner tsoscomb;
0114 
0115   // Trajectory Handle
0116 
0117   Handle<TrajTrackAssociationCollection> ttac;
0118   iEvent.getByToken(m_ttacollToken, ttac);
0119 
0120   const auto& tTopo = iSetup.getData(m_tTopoToken);
0121 
0122   for (TrajTrackAssociationCollection::const_iterator pair = ttac->begin(); pair != ttac->end(); ++pair) {
0123     const edm::Ref<std::vector<Trajectory> >& traj = pair->key;
0124     //    const reco::TrackRef & trk = pair->val;
0125     const std::vector<TrajectoryMeasurement>& tmcoll = traj->measurements();
0126 
0127     for (std::vector<TrajectoryMeasurement>::const_iterator meas = tmcoll.begin(); meas != tmcoll.end(); ++meas) {
0128       if (!meas->updatedState().isValid())
0129         continue;
0130 
0131       TrajectoryStateOnSurface tsos = tsoscomb(meas->forwardPredictedState(), meas->backwardPredictedState());
0132       TransientTrackingRecHit::ConstRecHitPointer hit = meas->recHit();
0133 
0134       if (!hit->isValid() && m_validOnly)
0135         continue;
0136 
0137       if (hit->geographicalId().det() != DetId::Tracker)
0138         continue;
0139 
0140       if (hit->geographicalId().subdetId() != StripSubdetector::TEC)
0141         continue;
0142 
0143       if (tTopo.tecRing(hit->geographicalId()) != 6)
0144         continue;
0145 
0146       if (tsos.localPosition().y() < 6.)
0147         continue;
0148 
0149       return true;
0150     }
0151   }
0152 
0153   return false;
0154 }
0155 
0156 //define this as a plug-in
0157 DEFINE_FWK_MODULE(OverlapProblemTSOSPositionFilter);