BPHDecayToFlyingCascadeBuilder

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120
#ifndef HeavyFlavorAnalysis_SpecificDecay_BPHDecayToFlyingCascadeBuilder_h
#define HeavyFlavorAnalysis_SpecificDecay_BPHDecayToFlyingCascadeBuilder_h
/** \class BPHDecayToFlyingCascadeBuilder
 *
 *  Description: 
 *     Class to build a particle having a flying particle in the
 *     final state, for generic particle types
 *
 *  \author Paolo Ronchese INFN Padova
 *
 */

//----------------------
// Base Class Headers --
//----------------------
#include "HeavyFlavorAnalysis/SpecificDecay/interface/BPHDecayToFlyingCascadeBuilderBase.h"
#include "HeavyFlavorAnalysis/SpecificDecay/interface/BPHDecayGenericBuilder.h"

//------------------------------------
// Collaborating Class Declarations --
//------------------------------------
#include "HeavyFlavorAnalysis/SpecificDecay/interface/BPHKinFitChi2Select.h"

#include "HeavyFlavorAnalysis/RecoDecay/interface/BPHRecoBuilder.h"

#include "FWCore/Framework/interface/EventSetup.h"

class BPHEventSetupWrapper;

//---------------
// C++ Headers --
//---------------
#include <string>
#include <vector>
#include <iostream>
//              ---------------------
//              -- Class Interface --
//              ---------------------

template <class ProdType, class FlyingType>
class BPHDecayToFlyingCascadeBuilder : public virtual BPHDecayToFlyingCascadeBuilderBase,
                                       public virtual BPHDecayGenericBuilder<ProdType> {
public:
  using typename BPHDecayGenericBuilder<ProdType>::prod_ptr;
  typedef typename FlyingType::const_pointer flying_ptr;

  /** Constructor
   */
  BPHDecayToFlyingCascadeBuilder(const BPHEventSetupWrapper& es,
                                 const std::string& flyName,
                                 double flyMass,
                                 double flyMSigma,
                                 const std::vector<flying_ptr>& flyCollection)
      : BPHDecayGenericBuilderBase(es, nullptr),
        BPHDecayToFlyingCascadeBuilderBase(flyName, flyMass, flyMSigma),
        fCollection(&flyCollection) {}

  // deleted copy constructor and assignment operator
  BPHDecayToFlyingCascadeBuilder(const BPHDecayToFlyingCascadeBuilder& x) = delete;
  BPHDecayToFlyingCascadeBuilder& operator=(const BPHDecayToFlyingCascadeBuilder& x) = delete;

  /** Destructor
   */
  ~BPHDecayToFlyingCascadeBuilder() override = default;

protected:
  BPHDecayToFlyingCascadeBuilder(const std::vector<flying_ptr>& flyCollection) : fCollection(&flyCollection) {}

  const std::vector<flying_ptr>* fCollection;

  void addFlyCollection(BPHRecoBuilder& brb) override {
    const std::vector<flying_ptr>& fc = *this->fCollection;
    if (flySel->getMassMax() > 0.0) {
      fCollectSel.clear();
      fCollectSel.reserve(fc.size());
      for (const flying_ptr& f : fc) {
        if (flySel->accept(*f))
          fCollectSel.push_back(f);
      }
      brb.add(fName, fCollectSel);
    } else
      brb.add(fName, *this->fCollection);
  }

  /// fit and select candidates
  void fitAndFilter(std::vector<prod_ptr>& prodList) {
    std::vector<prod_ptr> tempList;
    int iRec;
    int nRec = prodList.size();
    tempList.reserve(nRec);
    for (iRec = 0; iRec < nRec; ++iRec) {
      prod_ptr& ctmp = prodList[iRec];
      ProdType* cptr = ctmp->clone();
      prod_ptr cand(cptr);
      // fit for flying reconstruction
      // indipendent from other particles
      cptr->setIndependentFit(fName, true, fMass, fMSigma);
      cptr->resetKinematicFit();
      if ((mFitSel->getMassMax() >= 0) && (!mFitSel->accept(*cptr)))
        continue;
      const RefCountedKinematicVertex tdv = cptr->topDecayVertex();
      if ((kfChi2Sel->getProbMin() >= 0) && !kfChi2Sel->accept(*cptr))
        continue;
      const std::vector<std::string>& cList = ctmp->compNames();
      int iComp;
      int nComp = cList.size();
      for (iComp = 0; iComp < nComp; ++iComp) {
        const std::string& cName = cList[iComp];
        dMap[cand->getComp(cName).get()] = ctmp->getComp(cName).get();
      }
      tempList.push_back(cand);
    }
    prodList = tempList;
  }

private:
  std::vector<flying_ptr> fCollectSel;
};

#endif