Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:29:15

0001 #ifndef usercode_PrimaryVertexAnalyzer_VertexTimeAlgorithmBase_h
0002 #define usercode_PrimaryVertexAnalyzer_VertexTimeAlgorithmBase_h
0003 #include "RecoVertex/VertexPrimitives/interface/TransientVertex.h"
0004 
0005 namespace edm {
0006   class Event;
0007   class EventSetup;
0008   class ParameterSet;
0009   class ParameterSetDescription;
0010   class ConsumesCollector;
0011 }  // namespace edm
0012 
0013 class VertexTimeAlgorithmBase {
0014 public:
0015   VertexTimeAlgorithmBase(const edm::ParameterSet& conf, edm::ConsumesCollector& iC) {}
0016   virtual ~VertexTimeAlgorithmBase() = default;
0017   VertexTimeAlgorithmBase(const VertexTimeAlgorithmBase&) = delete;
0018   VertexTimeAlgorithmBase& operator=(const VertexTimeAlgorithmBase&) = delete;
0019 
0020   static void fillPSetDescription(edm::ParameterSetDescription& iDesc) {}
0021 
0022   virtual void setEvent(edm::Event& iEvent, edm::EventSetup const& iSetup) = 0;
0023 
0024   /**
0025    * estimate the vertex time and time uncertainty for transient vertex
0026    * 
0027    * returns true when a valid time has been determined, otherwise return false
0028    */
0029   virtual bool vertexTime(float& vtxTime, float& vtxTimeError, TransientVertex const& vtx) const = 0;
0030 
0031   /**
0032    * replace the vertices in the input vector by new vertices with time coordinates
0033    * determined by the vertexTime method
0034    * this implementation does not alter the weights from the previous fit
0035    * must be overridden to change weights, coordinates, tracklists or to add or remove vertices
0036    */
0037   virtual void fill_vertex_times(std::vector<TransientVertex>& pvs) {
0038     for (unsigned int i = 0; i < pvs.size(); i++) {
0039       auto vtx = pvs[i];
0040       if (vtx.isValid()) {
0041         auto vtxTime(0.f), vtxTimeError(-1.f);
0042         if (vertexTime(vtxTime, vtxTimeError, vtx)) {
0043           auto err = vtx.positionError().matrix4D();
0044           err(3, 3) = vtxTimeError * vtxTimeError;
0045           auto trkWeightMap3d = vtx.weightMap();
0046           auto vtx_with_time = TransientVertex(
0047               vtx.position(), vtxTime, err, vtx.originalTracks(), vtx.totalChiSquared(), vtx.degreesOfFreedom());
0048           vtx_with_time.weightMap(trkWeightMap3d);
0049           pvs[i] = vtx_with_time;
0050         }
0051       }
0052     }
0053   }
0054 };
0055 
0056 #endif