00001 #ifndef MUONBUILDER_H_ 00002 #define MUONBUILDER_H_ 00003 00004 #include <memory> 00005 #include <optional> 00006 #include <vector> 00007 00008 #include <TTreeReaderArray.h> 00009 00010 #include <CollectionBuilder.h> 00011 #include <Dataset.h> 00012 #include <Options.h> 00013 #include <PhysicsObjects.h> 00014 #include <RoccoR.h> 00015 #include <TabulatedRandomGenerator.h> 00016 00017 00028 class MuonBuilder : public CollectionBuilder<Muon> { 00029 public: 00037 MuonBuilder(Dataset &dataset, Options const &options, 00038 TabulatedRngEngine &rngEngine); 00039 00041 std::vector<Muon> const &Get() const override; 00042 00044 std::vector<Muon> const &GetLoose() const; 00045 00047 std::vector<Muon> const &GetTight() const; 00048 00049 private: 00061 void ApplyRochesterCorrection(int index, Muon *muon, int trackerLayers) const; 00062 00064 void Build() const override; 00065 00075 std::optional<GenParticle> FindGenMatch(Muon const &muon, double maxDR) const; 00076 00078 double minPtLoose_; 00079 00081 double minPtTight_; 00082 00084 double maxRelIsoLoose_; 00085 00087 double maxRelIsoTight_; 00088 00090 mutable std::vector<Muon> looseMuons_; 00091 00093 mutable std::vector<Muon> tightMuons_; 00094 00096 bool isSim_; 00097 00099 std::unique_ptr<RoccoR> rochesterCorrection_; 00100 00102 TabulatedRandomGenerator tabulatedRng_; 00103 00104 mutable TTreeReaderArray<float> srcPt_, srcEta_, srcPhi_, srcMass_; 00105 mutable TTreeReaderArray<int> srcCharge_; 00106 mutable TTreeReaderArray<float> srcIsolation_; 00107 mutable TTreeReaderArray<bool> srcIsPfMuon_, srcIsGlobalMuon_; 00108 mutable TTreeReaderArray<bool> srcIsTrackerMuon_, srcId_; 00109 mutable TTreeReaderArray<int> srcTrackerLayers_; 00110 mutable std::unique_ptr<TTreeReaderArray<int>> genPartId_; 00111 mutable std::unique_ptr<TTreeReaderArray<float>> genPartPt_, genPartEta_; 00112 mutable std::unique_ptr<TTreeReaderArray<float>> genPartPhi_; 00113 }; 00114 00115 00116 inline std::vector<Muon> const &MuonBuilder::Get() const { 00117 return GetTight(); 00118 } 00119 00120 #endif // MUONBUILDER_H_ 00121