CMS 3D CMS Logo

/data/doxygen/doxygen-1.7.3/gen/CMSSW_4_2_8/src/SimTracker/TrackHistory/interface/VertexClassifierByProxy.h

Go to the documentation of this file.
00001 
00002 #ifndef VertexClassifierByProxy_h
00003 #define VertexClassifierByProxy_h
00004 
00005 #include "DataFormats/Common/interface/AssociationMap.h"
00006 
00007 #include "SimTracker/TrackHistory/interface/VertexClassifier.h"
00008 
00010 template <typename Collection>
00011 class VertexClassifierByProxy : public VertexClassifier
00012 {
00013 
00014 public:
00015 
00017     typedef edm::AssociationMap<edm::OneToMany<Collection, reco::VertexCollection> > Association;
00018 
00020     VertexClassifierByProxy(edm::ParameterSet const & config) : VertexClassifier(config),
00021             proxy_( config.getUntrackedParameter<edm::InputTag>("vertexProducer") ) {}
00022 
00024     virtual void newEvent(edm::Event const & event, edm::EventSetup const & config)
00025     {
00026         // Get the association part of the proxy to the collection
00027         event.getByLabel(proxy_, proxyHandler_);
00028         // Call the previous new event
00029         VertexClassifier::newEvent(event, config);
00030     }
00031 
00033     VertexClassifierByProxy<Collection> const & evaluate (TrackingVertexRef const & vertex)
00034     {
00035         VertexClassifier::evaluate(vertex);
00036         return *this;
00037     }
00038 
00040     VertexClassifierByProxy<Collection> const & evaluate (edm::Ref<Collection> const & vertex, std::size_t index)
00041     {
00042         const reco::VertexRefVector * vertexes = 0;
00043 
00044         try
00045         {
00046             // Get a reference to the vector of associated vertexes
00047             vertexes = &(proxyHandler_->find(vertex)->val);
00048         }
00049         catch (edm::Exception& e)
00050         {
00051             // If association fails define the vertex as unknown
00052             reset();
00053             unknownVertex();
00054             return *this;
00055         }
00056 
00057         // Evaluate the history for a given index
00058         VertexClassifier::evaluate( vertexes->at(index) );
00059 
00060         return *this;
00061     }
00062 
00064     VertexClassifierByProxy<Collection> const & evaluate (edm::Ref<Collection> const & vertex)
00065     {
00066         const reco::VertexRefVector * vertexes = 0;
00067 
00068         try
00069         {
00070             // Get a reference to the vector of associated vertexes
00071             vertexes = &(proxyHandler_->find(vertex)->val);
00072         }
00073         catch (edm::Exception& e)
00074         {
00075             // If association fails define the vertex as unknown
00076             reset();
00077             unknownVertex();
00078             return *this;
00079         }
00080 
00081         // Loop over all the associated vertexes
00082         for (std::size_t index = 0; index < vertexes->size(); ++index)
00083         {
00084             // Copy the last status for all the flags
00085             Flags flags(flags_);
00086 
00087             // Evaluate the history for a given index
00088             VertexClassifier::evaluate( vertexes->at(index) );
00089 
00090             // Combine OR the flag information
00091             for (std::size_t i = 0; i < flags_.size(); ++i)
00092                 flags_[i] = flags_[i] | flags[i];
00093         }
00094 
00095         return *this;
00096     }
00097 
00098 private:
00099 
00100     const edm::InputTag proxy_;
00101 
00102     edm::Handle<Association> proxyHandler_;
00103 
00104 };
00105 
00106 #endif