Go to the documentation of this file.00001 #include "RecoTracker/TkSeedingLayers/interface/SeedComparitor.h"
00002 #include "RecoTracker/TkSeedingLayers/interface/SeedComparitorFactory.h"
00003 #include "FWCore/Utilities/interface/Exception.h"
00004 #include "FWCore/ParameterSet/interface/ParameterSet.h"
00005
00006 #include <boost/ptr_container/ptr_vector.hpp>
00007
00008 class CombinedSeedComparitor : public SeedComparitor {
00009 public:
00010 CombinedSeedComparitor(const edm::ParameterSet &cfg) ;
00011 virtual ~CombinedSeedComparitor() ;
00012 virtual void init(const edm::EventSetup& es) ;
00013 virtual bool compatible(const SeedingHitSet &hits, const TrackingRegion & region) const ;
00014 virtual bool compatible(const TrajectorySeed &seed) const ;
00015 virtual bool compatible(const TrajectoryStateOnSurface &,
00016 const TransientTrackingRecHit::ConstRecHitPointer &hit) const ;
00017 virtual bool compatible(const SeedingHitSet &hits,
00018 const GlobalTrajectoryParameters &helixStateAtVertex,
00019 const FastHelix &helix,
00020 const TrackingRegion & region) const ;
00021 virtual bool compatible(const SeedingHitSet &hits,
00022 const GlobalTrajectoryParameters &straightLineStateAtVertex,
00023 const TrackingRegion & region) const ;
00024
00025 private:
00026 boost::ptr_vector<SeedComparitor> comparitors_;
00027 bool isAnd_;
00028 };
00029
00030
00031 CombinedSeedComparitor::CombinedSeedComparitor(const edm::ParameterSet &cfg)
00032 {
00033 std::string mode = cfg.getParameter<std::string>("mode");
00034 if (mode == "and") isAnd_ = true;
00035 else if (mode == "or") isAnd_ = false;
00036 else throw cms::Exception("Configuration", "Parameter 'mode' of CombinedSeedComparitor must be either 'and' or 'or'\n");
00037
00038 typedef std::vector<edm::ParameterSet> VPSet;
00039 VPSet psets = cfg.getParameter<VPSet>("comparitors");
00040 for (VPSet::const_iterator it = psets.begin(), ed = psets.end(); it != ed; ++it) {
00041 std::string name = it->getParameter<std::string>("ComponentName");
00042 comparitors_.push_back(SeedComparitorFactory::get()->create(name, *it));
00043 }
00044 }
00045
00046 CombinedSeedComparitor::~CombinedSeedComparitor()
00047 {
00048 }
00049
00050 void
00051 CombinedSeedComparitor::init(const edm::EventSetup& es) {
00052 typedef boost::ptr_vector<SeedComparitor>::iterator ITC;
00053 for (ITC it = comparitors_.begin(), ed = comparitors_.end(); it != ed; ++it) {
00054 it->init(es);
00055 }
00056 }
00057
00058 bool
00059 CombinedSeedComparitor::compatible(const SeedingHitSet &hits, const TrackingRegion & region) const
00060 {
00061 typedef boost::ptr_vector<SeedComparitor>::const_iterator ITC;
00062 for (ITC it = comparitors_.begin(), ed = comparitors_.end(); it != ed; ++it) {
00063 bool pass = it->compatible(hits, region);
00064 if (isAnd_ != pass) return pass;
00065 }
00066 return isAnd_;
00067 }
00068
00069 bool
00070 CombinedSeedComparitor::compatible(const TrajectorySeed &seed) const
00071 {
00072 typedef boost::ptr_vector<SeedComparitor>::const_iterator ITC;
00073 for (ITC it = comparitors_.begin(), ed = comparitors_.end(); it != ed; ++it) {
00074 bool pass = it->compatible(seed);
00075 if (isAnd_ != pass) return pass;
00076 }
00077 return isAnd_;
00078 }
00079
00080 bool
00081 CombinedSeedComparitor::compatible(const TrajectoryStateOnSurface &tsos,
00082 const TransientTrackingRecHit::ConstRecHitPointer &hit) const
00083 {
00084 typedef boost::ptr_vector<SeedComparitor>::const_iterator ITC;
00085 for (ITC it = comparitors_.begin(), ed = comparitors_.end(); it != ed; ++it) {
00086 bool pass = it->compatible(tsos, hit);
00087 if (isAnd_ != pass) return pass;
00088 }
00089 return isAnd_;
00090 }
00091
00092 bool
00093 CombinedSeedComparitor::compatible(const SeedingHitSet &hits,
00094 const GlobalTrajectoryParameters &helixStateAtVertex,
00095 const FastHelix &helix,
00096 const TrackingRegion & region) const
00097 {
00098 typedef boost::ptr_vector<SeedComparitor>::const_iterator ITC;
00099 for (ITC it = comparitors_.begin(), ed = comparitors_.end(); it != ed; ++it) {
00100 bool pass = it->compatible(hits, helixStateAtVertex, helix, region);
00101 if (isAnd_ != pass) return pass;
00102 }
00103 return isAnd_;
00104 }
00105
00106 bool
00107 CombinedSeedComparitor::compatible(const SeedingHitSet &hits,
00108 const GlobalTrajectoryParameters &straightLineStateAtVertex,
00109 const TrackingRegion & region) const
00110 {
00111 typedef boost::ptr_vector<SeedComparitor>::const_iterator ITC;
00112 for (ITC it = comparitors_.begin(), ed = comparitors_.end(); it != ed; ++it) {
00113 bool pass = it->compatible(hits, straightLineStateAtVertex, region);
00114 if (isAnd_ != pass) return pass;
00115 }
00116 return isAnd_;
00117 }
00118
00119
00120 DEFINE_EDM_PLUGIN(SeedComparitorFactory, CombinedSeedComparitor, "CombinedSeedComparitor");