diff --git a/DataFormats/L1Trigger/interface/DisplacedVertex.h b/DataFormats/L1Trigger/interface/DisplacedVertex.h new file mode 100644 index 0000000000000..4853dddcb0957 --- /dev/null +++ b/DataFormats/L1Trigger/interface/DisplacedVertex.h @@ -0,0 +1,115 @@ +#ifndef DataFormats_L1TVertex_DisplacedVertex_h +#define DataFormats_L1TVertex_DisplacedVertex_h +#include +#include "DataFormats/Common/interface/Ptr.h" +#include "DataFormats/L1TrackTrigger/interface/TTTrack.h" +#include "DataFormats/L1TrackTrigger/interface/TTTypes.h" + +namespace l1t { + + class DisplacedTrueVertex { + public: + DisplacedTrueVertex(float d_T, float R_T, float cos_T, float x, float y, float z, float openingAngle, float parentPt) + : d_T_(d_T), R_T_(R_T), cos_T_(cos_T), x_(x), y_(y), z_(z), openingAngle_(openingAngle), parentPt_(parentPt) {} + DisplacedTrueVertex() {} + ~DisplacedTrueVertex() {} + float d_T() const { return d_T_; } + float R_T() const { return R_T_; } + float cos_T() const { return cos_T_; } + float x() const { return x_; } + float y() const { return y_; } + float z() const { return z_; } + float openingAngle() const { return openingAngle_; } + float parentPt() const { return parentPt_; } + + private: + float d_T_; + float R_T_; + float cos_T_; + float x_; + float y_; + float z_; + float openingAngle_; + float parentPt_; + }; + typedef std::vector DisplacedTrueVertexCollection; + + class DisplacedTrackVertex { + public: + DisplacedTrackVertex(int firstIndexTrk, + int secondIndexTrk, + int firstIndexPt, + int secondIndexPt, + int inTraj, + float d_T, + float R_T, + float cos_T, + float del_Z, + float x, + float y, + float z, + float openingAngle, + float parentPt, + int delIndexPt, + bool isReal) + : firstIndexTrk_(firstIndexTrk), + secondIndexTrk_(secondIndexTrk), + firstIndexPt_(firstIndexPt), + secondIndexPt_(secondIndexPt), + inTraj_(inTraj), + d_T_(d_T), + R_T_(R_T), + cos_T_(cos_T), + del_Z_(del_Z), + x_(x), + y_(y), + z_(z), + openingAngle_(openingAngle), + parentPt_(parentPt), + delIndexPt_(delIndexPt), + isReal_(isReal) {} + DisplacedTrackVertex() {} + ~DisplacedTrackVertex() {} + void setScore(float score) { score_ = score; } + float d_T() const { return d_T_; } + float R_T() const { return R_T_; } + float cos_T() const { return cos_T_; } + float x() const { return x_; } + float y() const { return y_; } + float z() const { return z_; } + float openingAngle() const { return openingAngle_; } + float parentPt() const { return parentPt_; } + int firstIndexTrk() const { return firstIndexTrk_; } + int secondIndexTrk() const { return secondIndexTrk_; } + int firstIndexPt() const { return firstIndexPt_; } + int secondIndexPt() const { return secondIndexPt_; } + int inTraj() const { return inTraj_; } + float del_Z() const { return del_Z_; } + int delIndexPt() const { return delIndexPt_; } + bool isReal() const { return isReal_; } + float score() const { return score_; } + + private: + int firstIndexTrk_; + int secondIndexTrk_; + int firstIndexPt_; + int secondIndexPt_; + int inTraj_; + float d_T_; + float R_T_; + float cos_T_; + float del_Z_; + float x_; + float y_; + float z_; + float openingAngle_; + float parentPt_; + int delIndexPt_; + bool isReal_; + float score_; + }; + + typedef std::vector DisplacedTrackVertexCollection; +} // namespace l1t + +#endif diff --git a/DataFormats/L1Trigger/src/classes.h b/DataFormats/L1Trigger/src/classes.h index 6589b8b674620..69f1a3e1df14a 100644 --- a/DataFormats/L1Trigger/src/classes.h +++ b/DataFormats/L1Trigger/src/classes.h @@ -39,3 +39,4 @@ #include "DataFormats/Common/interface/RefToBase.h" #include "DataFormats/L1Trigger/interface/P2GTCandidate.h" #include "DataFormats/L1Trigger/interface/P2GTAlgoBlock.h" +#include "DataFormats/L1Trigger/interface/DisplacedVertex.h" diff --git a/DataFormats/L1Trigger/src/classes_def.xml b/DataFormats/L1Trigger/src/classes_def.xml index 3b76a6164b287..b98d290325dae 100644 --- a/DataFormats/L1Trigger/src/classes_def.xml +++ b/DataFormats/L1Trigger/src/classes_def.xml @@ -335,6 +335,11 @@ + + + + + diff --git a/L1Trigger/L1TTrackMatch/BuildFile.xml b/L1Trigger/L1TTrackMatch/BuildFile.xml index 2caaa0df5472c..7447a06895574 100644 --- a/L1Trigger/L1TTrackMatch/BuildFile.xml +++ b/L1Trigger/L1TTrackMatch/BuildFile.xml @@ -4,6 +4,8 @@ + + diff --git a/L1Trigger/L1TTrackMatch/interface/DisplacedVertexProducer.h b/L1Trigger/L1TTrackMatch/interface/DisplacedVertexProducer.h new file mode 100644 index 0000000000000..6aeb20ca0eb62 --- /dev/null +++ b/L1Trigger/L1TTrackMatch/interface/DisplacedVertexProducer.h @@ -0,0 +1,224 @@ +#ifndef __L1Trigger_L1TTrackMatch_DisplacedVertexProducer_h__ +#define __L1Trigger_L1TTrackMatch_DisplacedVertexProducer_h__ + +#include "DataFormats/L1Trigger/interface/DisplacedVertex.h" +#include "FWCore/Framework/interface/global/EDProducer.h" +#include "DataFormats/L1TrackTrigger/interface/TTTypes.h" +#include "FWCore/Framework/interface/Event.h" +#include "FWCore/Framework/interface/EventSetup.h" +#include "FWCore/Framework/interface/MakerMacros.h" +#include "FWCore/MessageLogger/interface/MessageLogger.h" +#include "FWCore/ParameterSet/interface/ParameterSet.h" +#include "PhysicsTools/ONNXRuntime/interface/ONNXRuntime.h" +#include "SimTracker/TrackTriggerAssociation/interface/TTTrackAssociationMap.h" +#include "TMath.h" +#include +#include +#include +#include +#include +#include + +using namespace std; + +class Track_Parameters { +public: + float pt; + float d0; + float dxy = -99999; + float z0; + float eta; + float phi; + float charge; + float rho; + int index; + int pdgid = -99999; + float vx; + float vy; + float vz; + Track_Parameters* tp; + float x0; + float y0; + int nstubs; + float chi2rphi; + float chi2rz; + float bendchi2; + float MVA1; + float MVA2; + + float z(float x, float y) { + float t = std::sinh(eta); + float r = TMath::Sqrt(pow(x, 2) + pow(y, 2)); + return (z0 + + (t * r * + (1 + (pow(d0, 2) / pow(r, 2)) + + (1.0 / 6.0) * pow(r / (2 * rho), 2)))); // can do higher order terms if necessary from displaced math + } + Track_Parameters(float pt_in, + float d0_in, + float z0_in, + float eta_in, + float phi_in, + int pdgid_in, + float vx_in, + float vy_in, + float vz_in, + float charge_in = 0, + int index_in = -1, + Track_Parameters* tp_in = nullptr, + int nstubs_in = 0, + float chi2rphi_in = 0, + float chi2rz_in = 0, + float bendchi2_in = 0, + float MVA1_in = 0, + float MVA2_in = 0) { + pt = pt_in; + d0 = d0_in; + z0 = z0_in; + eta = eta_in; + phi = phi_in; + if (charge_in > 0) { + charge = 1; + } else if (charge_in < 0) { + charge = -1; + } else { + charge = 0; + } + index = index_in; + pdgid = pdgid_in; + vx = vx_in; + vy = vy_in; + vz = vz_in; + tp = tp_in; + rho = fabs(1 / charge_in); + x0 = (rho + charge * d0) * TMath::Cos(phi - (charge * TMath::Pi() / 2)); + y0 = (rho + charge * d0) * TMath::Sin(phi - (charge * TMath::Pi() / 2)); + nstubs = nstubs_in; + chi2rphi = chi2rphi_in; + chi2rz = chi2rz_in; + bendchi2 = bendchi2_in; + MVA1 = MVA1_in; + MVA2 = MVA2_in; + } + Track_Parameters(){}; + ~Track_Parameters(){}; +}; + +inline std::valarray calcPVec(Track_Parameters a, double_t v_x, double_t v_y) { + std::valarray r_vec = {float(v_x) - a.x0, float(v_y) - a.y0}; + std::valarray p_vec = {-r_vec[1], r_vec[0]}; + if (a.charge > 0) { + p_vec *= -1; + } + if ((p_vec[0] != 0.0) || (p_vec[1] != 0.0)) { + p_vec /= TMath::Sqrt(pow(p_vec[0], 2) + pow(p_vec[1], 2)); + } + p_vec *= a.pt; + return p_vec; +} + +class Vertex_Parameters { +public: + Double_t x_dv; + Double_t y_dv; + Double_t z_dv; + float score; + Track_Parameters a; + Track_Parameters b; + int inTraj; + bool matched = false; + std::vector tracks = {}; + float p_mag; + float p2_mag; + float openingAngle = -999.0; + float R_T; + float cos_T = -999.0; + float alpha_T = -999.0; + float d_T; + float chi2rphidofSum; + float chi2rzdofSum; + float bendchi2Sum; + float MVA1Sum; + float MVA2Sum; + int numStubsSum; + float delta_z; + float delta_eta; + float phi; + Vertex_Parameters(Double_t x_dv_in, + Double_t y_dv_in, + Double_t z_dv_in, + Track_Parameters a_in, + Track_Parameters b_in, + float score_in = -1, + int inTraj_in = 4) + : a(a_in), b(b_in) { + x_dv = x_dv_in; + y_dv = y_dv_in; + z_dv = z_dv_in; + score = score_in; + tracks.push_back(a_in); + tracks.push_back(b_in); + inTraj = inTraj_in; + std::valarray p_trk_1 = calcPVec(a_in, x_dv_in, y_dv_in); + std::valarray p_trk_2 = calcPVec(b_in, x_dv_in, y_dv_in); + std::valarray p_tot = p_trk_1 + p_trk_2; + p_mag = TMath::Sqrt(pow(p_tot[0], 2) + pow(p_tot[1], 2)); + if (((p_trk_1[0] != 0.0) || (p_trk_2[1] != 0.0)) && ((p_trk_2[0] != 0.0) || (p_trk_2[1] != 0.0))) { + openingAngle = + (p_trk_1[0] * p_trk_2[0] + p_trk_1[1] * p_trk_2[1]) / + (TMath::Sqrt(pow(p_trk_1[0], 2) + pow(p_trk_1[1], 2)) * TMath::Sqrt(pow(p_trk_2[0], 2) + pow(p_trk_2[1], 2))); + } + R_T = TMath::Sqrt(pow(x_dv_in, 2) + pow(y_dv_in, 2)); + if ((R_T != 0.0) && ((p_tot[0] != 0.0) || (p_tot[1] != 0.0))) { + cos_T = (p_tot[0] * x_dv_in + p_tot[1] * y_dv_in) / (R_T * TMath::Sqrt(pow(p_tot[0], 2) + pow(p_tot[1], 2))); + alpha_T = acos(cos_T); + } + phi = atan2(p_tot[1], p_tot[0]); + d_T = fabs(cos(phi) * y_dv_in - sin(phi) * x_dv_in); + int ndof_1 = 2 * a_in.nstubs - 5; + float chi2rphidof_1 = a_in.chi2rphi / ndof_1; + float chi2rzdof_1 = a_in.chi2rz / ndof_1; + float bendchi2_1 = a_in.bendchi2; + int ndof_2 = 2 * b_in.nstubs - 5; + float chi2rphidof_2 = b_in.chi2rphi / ndof_2; + float chi2rzdof_2 = b_in.chi2rz / ndof_2; + float bendchi2_2 = b_in.bendchi2; + chi2rphidofSum = chi2rphidof_1 + chi2rphidof_2; + chi2rzdofSum = chi2rzdof_1 + chi2rzdof_2; + bendchi2Sum = bendchi2_1 + bendchi2_2; + MVA1Sum = a_in.MVA1 + b_in.MVA1; + MVA2Sum = a_in.MVA2 + b_in.MVA2; + numStubsSum = a_in.nstubs + b_in.nstubs; + p2_mag = pow(a_in.pt, 2) + pow(b_in.pt, 2); + delta_z = fabs(a_in.z(x_dv_in, y_dv_in) - b_in.z(x_dv_in, y_dv_in)); + delta_eta = fabs(a_in.eta - b_in.eta); + } + + Vertex_Parameters(){}; + ~Vertex_Parameters(){}; +}; + +class DisplacedVertexProducer : public edm::global::EDProducer<> { +public: + explicit DisplacedVertexProducer(const edm::ParameterSet&); + ~DisplacedVertexProducer() override = default; + +private: + void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override; + +private: + const edm::EDGetTokenT> ttTrackMCTruthToken_; + const edm::EDGetTokenT>> trackToken_; + const std::string outputTrackCollectionName_; + const std::string qualityAlgorithm_; + const edm::FileInPath ONNXmodel_; + const std::string ONNXInputName_; + const edm::ParameterSet cutSet_; + const double chi2rzMax_, dispMVAMin_, promptMVAMin_, ptMin_, etaMax_, dispD0Min_, promptMVADispTrackMin_, + overlapEtaMin_, overlapEtaMax_; + const int overlapNStubsMin_; + const double diskEtaMin_, diskD0Min_, barrelD0Min_; + std::unique_ptr runTime_; +}; + +#endif diff --git a/L1Trigger/L1TTrackMatch/plugins/DisplacedVertexProducer.cc b/L1Trigger/L1TTrackMatch/plugins/DisplacedVertexProducer.cc new file mode 100644 index 0000000000000..49136505fdb06 --- /dev/null +++ b/L1Trigger/L1TTrackMatch/plugins/DisplacedVertexProducer.cc @@ -0,0 +1,295 @@ +#include "L1Trigger/L1TTrackMatch/interface/DisplacedVertexProducer.h" + +bool ComparePtTrack(std::pair> a, + std::pair> b) { + return a.first.pt > b.first.pt; +} + +Double_t dist(Double_t x1, Double_t y1, Double_t x2 = 0, Double_t y2 = 0) { // Distance between 2 points + return (TMath::Sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2))); +} + +Double_t dist_TPs(Track_Parameters a, Track_Parameters b) { + float x1 = a.x0; // Centers of the circles + float y1 = a.y0; // + float x2 = b.x0; // + float y2 = b.y0; // + float R1 = a.rho; // Radii of the circles + float R2 = b.rho; + float R = dist(x1, y1, x2, y2); // Distance between centers + if ((R >= fabs(R1 - R2)) && (R <= (R1 + R2))) { + return (0); + } else if (R == 0) { + return (-99999.0); + } else { + return (R - R1 - R2); + } +} + +Int_t calcVertex(Track_Parameters a, Track_Parameters b, Double_t& x_vtx, Double_t& y_vtx, Double_t& z_vtx) { + float x1 = a.x0; // Centers of the circles + float y1 = a.y0; // + float x2 = b.x0; // + float y2 = b.y0; // + float R1 = a.rho; // Radii of the circles + float R2 = b.rho; + float R = dist(x1, y1, x2, y2); // Distance between centers + if (R == 0) + return -1; + float co1 = (pow(R1, 2) - pow(R2, 2)) / (2 * pow(R, 2)); + float radicand = (2 / pow(R, 2)) * (pow(R1, 2) + pow(R2, 2)) - (pow(pow(R1, 2) - pow(R2, 2), 2) / pow(R, 4)) - 1; + float co2 = 0; + if (radicand > 0) + co2 = 0.5 * TMath::Sqrt(radicand); + float ix1_x = 0.5 * (x1 + x2) + co1 * (x2 - x1) + co2 * (y2 - y1); + float ix2_x = 0.5 * (x1 + x2) + co1 * (x2 - x1) - co2 * (y2 - y1); + float ix1_y = 0.5 * (y1 + y2) + co1 * (y2 - y1) + co2 * (x1 - x2); + float ix2_y = 0.5 * (y1 + y2) + co1 * (y2 - y1) - co2 * (x1 - x2); + float ix1_z1 = a.z(ix1_x, ix1_y); + float ix1_z2 = b.z(ix1_x, ix1_y); + float ix1_delz = fabs(ix1_z1 - ix1_z2); + float ix2_z1 = a.z(ix2_x, ix2_y); + float ix2_z2 = b.z(ix2_x, ix2_y); + float ix2_delz = fabs(ix2_z1 - ix2_z2); + float trk1_POCA[2] = {a.d0 * sin(a.phi), -1 * a.d0 * cos(a.phi)}; + float trk2_POCA[2] = {b.d0 * sin(b.phi), -1 * b.d0 * cos(b.phi)}; + float trk1_ix1_delxy[2] = {ix1_x - trk1_POCA[0], ix1_y - trk1_POCA[1]}; + float trk1_ix2_delxy[2] = {ix2_x - trk1_POCA[0], ix2_y - trk1_POCA[1]}; + float trk2_ix1_delxy[2] = {ix1_x - trk2_POCA[0], ix1_y - trk2_POCA[1]}; + float trk2_ix2_delxy[2] = {ix2_x - trk2_POCA[0], ix2_y - trk2_POCA[1]}; + float trk1_traj[2] = {cos(a.phi), sin(a.phi)}; + float trk2_traj[2] = {cos(b.phi), sin(b.phi)}; + bool trk1_ix1_inTraj = ((trk1_ix1_delxy[0] * trk1_traj[0] + trk1_ix1_delxy[1] * trk1_traj[1]) > 0) ? true : false; + bool trk1_ix2_inTraj = ((trk1_ix2_delxy[0] * trk1_traj[0] + trk1_ix2_delxy[1] * trk1_traj[1]) > 0) ? true : false; + bool trk2_ix1_inTraj = ((trk2_ix1_delxy[0] * trk2_traj[0] + trk2_ix1_delxy[1] * trk2_traj[1]) > 0) ? true : false; + bool trk2_ix2_inTraj = ((trk2_ix2_delxy[0] * trk2_traj[0] + trk2_ix2_delxy[1] * trk2_traj[1]) > 0) ? true : false; + if (trk1_ix1_inTraj && trk2_ix1_inTraj && trk1_ix2_inTraj && trk2_ix2_inTraj) { + if (ix1_delz < ix2_delz) { + x_vtx = ix1_x; + y_vtx = ix1_y; + z_vtx = (ix1_z1 + ix1_z2) / 2; + return 0; + } else { + x_vtx = ix2_x; + y_vtx = ix2_y; + z_vtx = (ix2_z1 + ix2_z2) / 2; + return 0; + } + } + if (trk1_ix1_inTraj && trk2_ix1_inTraj) { + x_vtx = ix1_x; + y_vtx = ix1_y; + z_vtx = (ix1_z1 + ix1_z2) / 2; + return 1; + } + if (trk1_ix2_inTraj && trk2_ix2_inTraj) { + x_vtx = ix2_x; + y_vtx = ix2_y; + z_vtx = (ix2_z1 + ix2_z2) / 2; + return 2; + } else { + if (ix1_delz < ix2_delz) { + x_vtx = ix1_x; + y_vtx = ix1_y; + z_vtx = (ix1_z1 + ix1_z2) / 2; + return 3; + } else { + x_vtx = ix2_x; + y_vtx = ix2_y; + z_vtx = (ix2_z1 + ix2_z2) / 2; + return 3; + } + } + return 4; +} + +DisplacedVertexProducer::DisplacedVertexProducer(const edm::ParameterSet& iConfig) + : ttTrackMCTruthToken_(consumes>( + iConfig.getParameter("mcTruthTrackInputTag"))), + trackToken_(consumes>>( + iConfig.getParameter("l1TracksInputTag"))), + outputTrackCollectionName_(iConfig.getParameter("l1TrackVertexCollectionName")), + ONNXmodel_(iConfig.getParameter("ONNXmodel")), + ONNXInputName_(iConfig.getParameter("ONNXInputName")), + cutSet_(iConfig.getParameter("cutSet")), + chi2rzMax_(cutSet_.getParameter("chi2rzMax")), + dispMVAMin_(cutSet_.getParameter("dispMVAMin")), + promptMVAMin_(cutSet_.getParameter("promptMVAMin")), + ptMin_(cutSet_.getParameter("ptMin")), + etaMax_(cutSet_.getParameter("etaMax")), + dispD0Min_(cutSet_.getParameter("dispD0Min")), + promptMVADispTrackMin_(cutSet_.getParameter("promptMVADispTrackMin")), + overlapEtaMin_(cutSet_.getParameter("overlapEtaMin")), + overlapEtaMax_(cutSet_.getParameter("overlapEtaMax")), + overlapNStubsMin_(cutSet_.getParameter("overlapNStubsMin")), + diskEtaMin_(cutSet_.getParameter("diskEtaMin")), + diskD0Min_(cutSet_.getParameter("diskD0Min")), + barrelD0Min_(cutSet_.getParameter("barrelD0Min")) { + //--- Define EDM output to be written to file (if required) + produces(outputTrackCollectionName_); + runTime_ = std::make_unique(this->ONNXmodel_.fullPath()); +} + +void DisplacedVertexProducer::produce(edm::StreamID, edm::Event& iEvent, const edm::EventSetup& iSetup) const { + edm::Handle> MCTruthTTTrackHandle; + iEvent.getByToken(ttTrackMCTruthToken_, MCTruthTTTrackHandle); + edm::Handle>> TTTrackHandle; + iEvent.getByToken(trackToken_, TTTrackHandle); + std::vector>::const_iterator iterL1Track; + int this_l1track = 0; + std::vector>> selectedTracksWithTruth; + + for (iterL1Track = TTTrackHandle->begin(); iterL1Track != TTTrackHandle->end(); iterL1Track++) { + edm::Ptr> l1track_ptr(TTTrackHandle, this_l1track); + this_l1track++; + + float pt = l1track_ptr->momentum().perp(); + float eta = l1track_ptr->momentum().eta(); + float phi = l1track_ptr->momentum().phi(); + float z0 = l1track_ptr->z0(); //cm + float x0 = l1track_ptr->POCA().x(); + float y0 = l1track_ptr->POCA().y(); + float d0 = -x0 * sin(phi) + y0 * cos(phi); + float rinv = l1track_ptr->rInv(); + float chi2 = l1track_ptr->chi2Red(); + float chi2rphi = l1track_ptr->chi2XYRed(); + float chi2rz = l1track_ptr->chi2ZRed(); + float bendchi2 = l1track_ptr->stubPtConsistency(); + float MVA1 = l1track_ptr->trkMVA1(); + float MVA2 = l1track_ptr->trkMVA2(); + std::vector>, TTStub>> + stubRefs = l1track_ptr->getStubRefs(); + int nstub = (int)stubRefs.size(); + if (chi2rz < chi2rzMax_ && MVA2 > dispMVAMin_ && MVA1 > promptMVAMin_ && pt > ptMin_ && fabs(eta) < etaMax_) { + if (fabs(d0) > dispD0Min_) { + if (MVA1 <= promptMVADispTrackMin_) + continue; + } + if (fabs(eta) > overlapEtaMin_ && fabs(eta) < overlapEtaMax_) { + if (nstub <= overlapNStubsMin_) + continue; + } + if (fabs(eta) > diskEtaMin_) { + if (fabs(d0) <= diskD0Min_) + continue; + } + if (fabs(eta) <= diskEtaMin_) { + if (fabs(d0) <= barrelD0Min_) + continue; + } + + Track_Parameters track = Track_Parameters(pt, + -d0, + z0, + eta, + phi, + -99999, + -999, + -999, + -999, + rinv, + (this_l1track - 1), + nullptr, + nstub, + chi2rphi, + chi2rz, + bendchi2, + MVA1, + MVA2); + + edm::Ptr my_tp = MCTruthTTTrackHandle->findTrackingParticlePtr(l1track_ptr); + selectedTracksWithTruth.push_back(std::make_pair(track, my_tp)); + } + } + + sort(selectedTracksWithTruth.begin(), selectedTracksWithTruth.end(), ComparePtTrack); + std::unique_ptr product(new std::vector()); + for (int i = 0; i < int(selectedTracksWithTruth.size() - 1); i++) { + for (int j = i + 1; j < int(selectedTracksWithTruth.size()); j++) { + if (dist_TPs(selectedTracksWithTruth[i].first, selectedTracksWithTruth[j].first) != 0) + continue; + Double_t x_dv_trk = -9999.0; + Double_t y_dv_trk = -9999.0; + Double_t z_dv_trk = -9999.0; + edm::Ptr tp_i = selectedTracksWithTruth[i].second; + edm::Ptr tp_j = selectedTracksWithTruth[j].second; + bool isReal = false; + if (!tp_i.isNull() && !tp_j.isNull()) { + bool isHard_i = false; + bool isHard_j = false; + if (!tp_i->genParticles().empty() && !tp_j->genParticles().empty()) { + isHard_i = tp_i->genParticles()[0]->isHardProcess() || tp_i->genParticles()[0]->fromHardProcessFinalState(); + isHard_j = tp_j->genParticles()[0]->isHardProcess() || tp_j->genParticles()[0]->fromHardProcessFinalState(); + } + + if (tp_i->eventId().event() == 0 && tp_j->eventId().event() == 0 && fabs(tp_i->vx() - tp_j->vx()) < 0.0001 && + fabs(tp_i->vy() - tp_j->vy()) < 0.0001 && fabs(tp_i->vz() - tp_j->vz()) < 0.0001 && isHard_i && isHard_j && + ((tp_i->charge() + tp_j->charge()) == 0)) { + isReal = true; + } + } + + int inTraj = + calcVertex(selectedTracksWithTruth[i].first, selectedTracksWithTruth[j].first, x_dv_trk, y_dv_trk, z_dv_trk); + Vertex_Parameters vertex = Vertex_Parameters( + x_dv_trk, y_dv_trk, z_dv_trk, selectedTracksWithTruth[i].first, selectedTracksWithTruth[j].first); + l1t::DisplacedTrackVertex outputVertex = l1t::DisplacedTrackVertex(selectedTracksWithTruth[i].first.index, + selectedTracksWithTruth[j].first.index, + i, + j, + inTraj, + vertex.d_T, + vertex.R_T, + vertex.cos_T, + vertex.delta_z, + vertex.x_dv, + vertex.y_dv, + vertex.z_dv, + vertex.openingAngle, + vertex.p_mag, + fabs(i - j), + isReal); + std::vector ortinput_names; + std::vector ortoutput_names; + cms::Ort::FloatArrays ortinput; + cms::Ort::FloatArrays ortoutputs; + float minD0 = vertex.a.d0; + if (fabs(vertex.b.d0) < fabs(minD0)) + minD0 = vertex.b.d0; + std::vector Transformed_features = {selectedTracksWithTruth[i].first.pt, + selectedTracksWithTruth[j].first.pt, + selectedTracksWithTruth[i].first.eta, + selectedTracksWithTruth[j].first.eta, + selectedTracksWithTruth[i].first.phi, + selectedTracksWithTruth[j].first.phi, + selectedTracksWithTruth[i].first.d0, + selectedTracksWithTruth[j].first.d0, + selectedTracksWithTruth[i].first.z0, + selectedTracksWithTruth[j].first.z0, + selectedTracksWithTruth[i].first.chi2rz, + selectedTracksWithTruth[j].first.chi2rz, + selectedTracksWithTruth[i].first.bendchi2, + selectedTracksWithTruth[j].first.bendchi2, + selectedTracksWithTruth[i].first.MVA1, + selectedTracksWithTruth[j].first.MVA1, + selectedTracksWithTruth[i].first.MVA2, + selectedTracksWithTruth[j].first.MVA2, + vertex.d_T, + vertex.R_T, + vertex.cos_T, + vertex.delta_z}; + ortinput_names.push_back(this->ONNXInputName_); + ortoutput_names = runTime_->getOutputNames(); + ortinput.push_back(Transformed_features); + int batch_size = 1; + ortoutputs = runTime_->run(ortinput_names, ortinput, {}, ortoutput_names, batch_size); + outputVertex.setScore(ortoutputs[1][1]); + product->emplace_back(outputVertex); + } + } + // //=== Store output + + iEvent.put(std::move(product), outputTrackCollectionName_); +} + +DEFINE_FWK_MODULE(DisplacedVertexProducer); diff --git a/L1Trigger/L1TTrackMatch/plugins/L1TrackSelectionProducer.cc b/L1Trigger/L1TTrackMatch/plugins/L1TrackSelectionProducer.cc index 3c71f53073875..1bf15bde7cc6e 100644 --- a/L1Trigger/L1TTrackMatch/plugins/L1TrackSelectionProducer.cc +++ b/L1Trigger/L1TTrackMatch/plugins/L1TrackSelectionProducer.cc @@ -180,6 +180,39 @@ class L1TrackSelectionProducer : public edm::global::EDProducer<> { private: double nStubsMin_; }; + struct TTTrackNStubsMinEtaOverlapSelector { + TTTrackNStubsMinEtaOverlapSelector(double nStubsMinEtaOverlap) : nStubsMinEtaOverlap_(nStubsMinEtaOverlap) {} + TTTrackNStubsMinEtaOverlapSelector(const edm::ParameterSet& cfg) + : nStubsMinEtaOverlap_(cfg.template getParameter("nStubsMinEtaOverlap")) {} + bool operator()(const L1Track& t) const { + if ((std::abs(t.momentum().eta()) < 1.7) && (std::abs(t.momentum().eta()) > 1.1)) { + return (t.getStubRefs().size() >= nStubsMinEtaOverlap_); + } else { + return true; + } + } + + private: + double nStubsMinEtaOverlap_; + }; + struct TTTrackWordNStubsMinEtaOverlapSelector { + TTTrackWordNStubsMinEtaOverlapSelector(double nStubsMinEtaOverlap) : nStubsMinEtaOverlap_(nStubsMinEtaOverlap) {} + TTTrackWordNStubsMinEtaOverlapSelector(const edm::ParameterSet& cfg) + : nStubsMinEtaOverlap_(cfg.template getParameter("nStubsMinEtaOverlap")) {} + bool operator()(const L1Track& t) const { + TTTrack_TrackWord::tanl_t etaEmulationBits = t.getTanlWord(); + ap_fixed etaEmulation; + etaEmulation.V = etaEmulationBits.range(); + if ((std::abs(etaEmulation.to_double()) < 1.7) && (std::abs(etaEmulation.to_double()) > 1.1)) { + return (t.getNStubs() >= nStubsMinEtaOverlap_); + } else { + return true; + } + } + + private: + double nStubsMinEtaOverlap_; + }; struct TTTrackNPSStubsMinSelector { TTTrackNPSStubsMinSelector(double nStubsMin, const TrackerTopology& tTopo) : nPSStubsMin_(nStubsMin), tTopo_(tTopo) {} @@ -222,6 +255,58 @@ class L1TrackSelectionProducer : public edm::global::EDProducer<> { private: double promptMVAMin_; }; + struct TTTrackPromptMVAMinD0Min1Selector { + TTTrackPromptMVAMinD0Min1Selector(double promptMVAMinD0Min1) : promptMVAMinD0Min1_(promptMVAMinD0Min1) {} + TTTrackPromptMVAMinD0Min1Selector(const edm::ParameterSet& cfg) + : promptMVAMinD0Min1_(cfg.template getParameter("promptMVAMinD0Min1")) {} + bool operator()(const L1Track& t) const { + if (std::abs(t.d0()) > 1.0) { + return (t.trkMVA1() > promptMVAMinD0Min1_); + } else { + return true; + } + } + + private: + double promptMVAMinD0Min1_; + }; + struct TTTrackWordPromptMVAMinD0Min1Selector { + TTTrackWordPromptMVAMinD0Min1Selector(double promptMVAMinD0Min1) : promptMVAMinD0Min1_(promptMVAMinD0Min1) {} + TTTrackWordPromptMVAMinD0Min1Selector(const edm::ParameterSet& cfg) + : promptMVAMinD0Min1_(cfg.template getParameter("promptMVAMinD0Min1")) {} + bool operator()(const L1Track& t) const { + double floatD0 = t.undigitizeSignedValue( + t.getD0Bits(), TTTrack_TrackWord::TrackBitWidths::kD0Size, TTTrack_TrackWord::stepD0, 0.0); + if (std::abs(floatD0) > 1.0) { + return t.trkMVA1() >= promptMVAMinD0Min1_; + } else { + return true; + } + } //change when mva bins in word are set + + private: + double promptMVAMinD0Min1_; + }; + struct TTTrackDisplacedMVAMinSelector { + TTTrackDisplacedMVAMinSelector(double displacedMVAMin) : displacedMVAMin_(displacedMVAMin) {} + TTTrackDisplacedMVAMinSelector(const edm::ParameterSet& cfg) + : displacedMVAMin_(cfg.template getParameter("displacedMVAMin")) {} + bool operator()(const L1Track& t) const { return t.trkMVA2() >= displacedMVAMin_; } + + private: + double displacedMVAMin_; + }; + struct TTTrackWordDisplacedMVAMinSelector { + TTTrackWordDisplacedMVAMinSelector(double displacedMVAMin) : displacedMVAMin_(displacedMVAMin) {} + TTTrackWordDisplacedMVAMinSelector(const edm::ParameterSet& cfg) + : displacedMVAMin_(cfg.template getParameter("displacedMVAMin")) {} + bool operator()(const L1Track& t) const { + return t.trkMVA2() >= displacedMVAMin_; + } //change when mva bins in word are set + + private: + double displacedMVAMin_; + }; struct TTTrackBendChi2MaxSelector { TTTrackBendChi2MaxSelector(double bendChi2Max) : bendChi2Max_(bendChi2Max) {} TTTrackBendChi2MaxSelector(const edm::ParameterSet& cfg) @@ -367,12 +452,53 @@ class L1TrackSelectionProducer : public edm::global::EDProducer<> { double reducedBendChi2MaxNstub5_; }; - typedef AndSelector + struct TTTrackAbsD0MinEtaSelector { + TTTrackAbsD0MinEtaSelector(double absD0MinEtaMin0p95, double absD0MinEtaMax0p95) + : absD0MinEtaMin0p95_(absD0MinEtaMin0p95), absD0MinEtaMax0p95_(absD0MinEtaMax0p95) {} + TTTrackAbsD0MinEtaSelector(const edm::ParameterSet& cfg) + : absD0MinEtaMin0p95_(cfg.template getParameter("absD0MinEtaMin0p95")), + absD0MinEtaMax0p95_(cfg.template getParameter("absD0MinEtaMax0p95")) {} + bool operator()(const L1Track& t) const { + return (((std::abs(t.d0()) > absD0MinEtaMin0p95_) && (std::abs(t.momentum().eta()) > 0.95)) || + ((std::abs(t.d0()) > absD0MinEtaMax0p95_) && (std::abs(t.momentum().eta()) <= 0.95))); + } + + private: + double absD0MinEtaMin0p95_; + double absD0MinEtaMax0p95_; + }; + struct TTTrackWordAbsD0MinEtaSelector { + TTTrackWordAbsD0MinEtaSelector(double absD0MinEtaMin0p95, double absD0MinEtaMax0p95) + : absD0MinEtaMin0p95_(absD0MinEtaMin0p95), absD0MinEtaMax0p95_(absD0MinEtaMax0p95) {} + TTTrackWordAbsD0MinEtaSelector(const edm::ParameterSet& cfg) + : absD0MinEtaMin0p95_(cfg.template getParameter("absD0MinEtaMin0p95")), + absD0MinEtaMax0p95_(cfg.template getParameter("absD0MinEtaMax0p95")) {} + bool operator()(const L1Track& t) const { + double floatD0 = t.undigitizeSignedValue( + t.getD0Bits(), TTTrack_TrackWord::TrackBitWidths::kD0Size, TTTrack_TrackWord::stepD0, 0.0); + TTTrack_TrackWord::tanl_t etaEmulationBits = t.getTanlWord(); + ap_fixed etaEmulation; + etaEmulation.V = etaEmulationBits.range(); + return (((std::abs(floatD0) > absD0MinEtaMin0p95_) && (std::abs(etaEmulation.to_double()) > 0.95)) || + ((std::abs(floatD0) > absD0MinEtaMax0p95_) && (std::abs(etaEmulation.to_double()) <= 0.95))); + } + + private: + double absD0MinEtaMin0p95_; + double absD0MinEtaMax0p95_; + }; + + typedef AndSelector TTTrackPtMinEtaMaxZ0MaxNStubsMinSelector; typedef AndSelector + TTTrackWordNStubsMinSelector, + TTTrackWordNStubsMinEtaOverlapSelector> TTTrackWordPtMinEtaMaxZ0MaxNStubsMinSelector; typedef AndSelector TTTrackBendChi2Chi2RZChi2RPhiMaxSelector; @@ -384,16 +510,23 @@ class L1TrackSelectionProducer : public edm::global::EDProducer<> { TTTrackWordChi2RPhiMaxNstubSelector, TTTrackWordBendChi2MaxNstubSelector> TTTrackWordChi2MaxNstubSelector; + typedef AndSelector + TTTrackMVAMinSelector; + typedef AndSelector + TTTrackWordMVAMinSelector; // ----------member data --------------------------- const edm::EDGetTokenT l1TracksToken_; edm::ESGetToken tTopoToken_; const std::string outputCollectionName_; const edm::ParameterSet cutSet_; - const double ptMin_, absEtaMax_, absZ0Max_, promptMVAMin_, bendChi2Max_, reducedChi2RZMax_, reducedChi2RPhiMax_; + const double ptMin_, absEtaMax_, absZ0Max_, promptMVAMin_, promptMVAMinD0Min1_, displacedMVAMin_, bendChi2Max_, + reducedChi2RZMax_, reducedChi2RPhiMax_; const double reducedChi2RZMaxNstub4_, reducedChi2RZMaxNstub5_, reducedChi2RPhiMaxNstub4_, reducedChi2RPhiMaxNstub5_, - reducedBendChi2MaxNstub4_, reducedBendChi2MaxNstub5_; - const int nStubsMin_, nPSStubsMin_; + reducedBendChi2MaxNstub4_, reducedBendChi2MaxNstub5_, absD0MinEtaMin0p95_, absD0MinEtaMax0p95_; + const int nStubsMin_, nStubsMinEtaOverlap_, nPSStubsMin_; bool processSimulatedTracks_, processEmulatedTracks_; int debug_; }; @@ -411,6 +544,8 @@ L1TrackSelectionProducer::L1TrackSelectionProducer(const edm::ParameterSet& iCon absEtaMax_(cutSet_.getParameter("absEtaMax")), absZ0Max_(cutSet_.getParameter("absZ0Max")), promptMVAMin_(cutSet_.getParameter("promptMVAMin")), + promptMVAMinD0Min1_(cutSet_.getParameter("promptMVAMinD0Min1")), + displacedMVAMin_(cutSet_.getParameter("displacedMVAMin")), bendChi2Max_(cutSet_.getParameter("reducedBendChi2Max")), reducedChi2RZMax_(cutSet_.getParameter("reducedChi2RZMax")), reducedChi2RPhiMax_(cutSet_.getParameter("reducedChi2RPhiMax")), @@ -420,7 +555,10 @@ L1TrackSelectionProducer::L1TrackSelectionProducer(const edm::ParameterSet& iCon reducedChi2RPhiMaxNstub5_(cutSet_.getParameter("reducedChi2RPhiMaxNstub5")), reducedBendChi2MaxNstub4_(cutSet_.getParameter("reducedBendChi2MaxNstub4")), reducedBendChi2MaxNstub5_(cutSet_.getParameter("reducedBendChi2MaxNstub5")), + absD0MinEtaMin0p95_(cutSet_.getParameter("absD0MinEtaMin0p95")), + absD0MinEtaMax0p95_(cutSet_.getParameter("absD0MinEtaMax0p95")), nStubsMin_(cutSet_.getParameter("nStubsMin")), + nStubsMinEtaOverlap_(cutSet_.getParameter("nStubsMinEtaOverlap")), nPSStubsMin_(cutSet_.getParameter("nPSStubsMin")), processSimulatedTracks_(iConfig.getParameter("processSimulatedTracks")), processEmulatedTracks_(iConfig.getParameter("processEmulatedTracks")), @@ -538,31 +676,35 @@ void L1TrackSelectionProducer::produce(edm::StreamID, edm::Event& iEvent, const vTTTrackEmulationOutput->reserve(nOutputApproximate); } - TTTrackPtMinEtaMaxZ0MaxNStubsMinSelector kinSel(ptMin_, absEtaMax_, absZ0Max_, nStubsMin_); - TTTrackWordPtMinEtaMaxZ0MaxNStubsMinSelector kinSelEmu(ptMin_, absEtaMax_, absZ0Max_, nStubsMin_); + TTTrackPtMinEtaMaxZ0MaxNStubsMinSelector kinSel(ptMin_, absEtaMax_, absZ0Max_, nStubsMin_, nStubsMinEtaOverlap_); + TTTrackWordPtMinEtaMaxZ0MaxNStubsMinSelector kinSelEmu( + ptMin_, absEtaMax_, absZ0Max_, nStubsMin_, nStubsMinEtaOverlap_); TTTrackBendChi2Chi2RZChi2RPhiMaxSelector chi2Sel(bendChi2Max_, reducedChi2RZMax_, reducedChi2RPhiMax_); TTTrackWordBendChi2Chi2RZChi2RPhiMaxSelector chi2SelEmu(bendChi2Max_, reducedChi2RZMax_, reducedChi2RPhiMax_); TTTrackNPSStubsMinSelector nPSStubsSel(nPSStubsMin_, tTopo); - TTTrackPromptMVAMinSelector mvaSel(promptMVAMin_); - TTTrackWordPromptMVAMinSelector mvaSelEmu(promptMVAMin_); + TTTrackMVAMinSelector mvaSel(promptMVAMin_, promptMVAMinD0Min1_, displacedMVAMin_); + TTTrackWordMVAMinSelector mvaSelEmu(promptMVAMin_, promptMVAMinD0Min1_, displacedMVAMin_); TTTrackChi2MaxNstubSelector chi2NstubSel({reducedChi2RZMaxNstub4_, reducedChi2RZMaxNstub5_}, {reducedChi2RPhiMaxNstub4_, reducedChi2RPhiMaxNstub5_}, {reducedBendChi2MaxNstub4_, reducedBendChi2MaxNstub5_}); TTTrackWordChi2MaxNstubSelector chi2NstubSelEmu({reducedChi2RZMaxNstub4_, reducedChi2RZMaxNstub5_}, {reducedChi2RPhiMaxNstub4_, reducedChi2RPhiMaxNstub5_}, {reducedBendChi2MaxNstub4_, reducedBendChi2MaxNstub5_}); + TTTrackAbsD0MinEtaSelector d0Sel(absD0MinEtaMin0p95_, absD0MinEtaMax0p95_); + TTTrackWordAbsD0MinEtaSelector d0SelEmu(absD0MinEtaMin0p95_, absD0MinEtaMax0p95_); for (size_t i = 0; i < nOutputApproximate; i++) { const auto& track = l1TracksHandle->at(i); // Select tracks based on the floating point TTTrack if (processSimulatedTracks_ && kinSel(track) && nPSStubsSel(track) && chi2Sel(track) && mvaSel(track) && - chi2NstubSel(track)) { + d0Sel(track) && chi2NstubSel(track)) { vTTTrackOutput->push_back(TTTrackRef(l1TracksHandle, i)); } // Select tracks based on the bitwise accurate TTTrack_TrackWord - if (processEmulatedTracks_ && kinSelEmu(track) && chi2SelEmu(track) && mvaSelEmu(track) && chi2NstubSelEmu(track)) { + if (processEmulatedTracks_ && kinSelEmu(track) && chi2SelEmu(track) && mvaSelEmu(track) && d0SelEmu(track) && + chi2NstubSelEmu(track)) { vTTTrackEmulationOutput->push_back(TTTrackRef(l1TracksHandle, i)); } } @@ -592,10 +734,15 @@ void L1TrackSelectionProducer::fillDescriptions(edm::ConfigurationDescriptions& descCutSet.add("absEtaMax", 2.4)->setComment("absolute value of eta must be less than this value"); descCutSet.add("absZ0Max", 15.0)->setComment("z0 must be less than this value, [cm]"); descCutSet.add("nStubsMin", 4)->setComment("number of stubs must be greater than or equal to this value"); + descCutSet.add("nStubsMinEtaOverlap", 4) + ->setComment("number of stubs must be greater than or equal to this value for tracks with 1.1<|eta|<1.7"); descCutSet.add("nPSStubsMin", 0) ->setComment("number of stubs in the PS Modules must be greater than or equal to this value"); descCutSet.add("promptMVAMin", -1.0)->setComment("MVA must be greater than this value"); + descCutSet.add("promptMVAMinD0Min1", -1.0) + ->setComment("MVA for tracks with |d0|>1cm must be greater than this value"); + descCutSet.add("displacedMVAMin", -1.0)->setComment("Displaced MVA must be greater than this value"); descCutSet.add("reducedBendChi2Max", 2.25)->setComment("bend chi2 must be less than this value"); descCutSet.add("reducedChi2RZMax", 5.0)->setComment("chi2rz/dof must be less than this value"); descCutSet.add("reducedChi2RPhiMax", 20.0)->setComment("chi2rphi/dof must be less than this value"); @@ -611,6 +758,10 @@ void L1TrackSelectionProducer::fillDescriptions(edm::ConfigurationDescriptions& ->setComment("bend chi2 must be less than this value in nstub==4"); descCutSet.add("reducedBendChi2MaxNstub5", 999.9) ->setComment("bend chi2 must be less than this value in nstub>4"); + descCutSet.add("absD0MinEtaMin0p95", -1.0) + ->setComment("absolute value of d0 must be greater than this value for tracks with |eta|>0.95"); + descCutSet.add("absD0MinEtaMax0p95", -1.0) + ->setComment("absolute value of d0 must be greater than this value for tracks with |eta|<=0.95"); desc.add("cutSet", descCutSet); } diff --git a/L1Trigger/L1TTrackMatch/python/DisplacedVertexProducer_cfi.py b/L1Trigger/L1TTrackMatch/python/DisplacedVertexProducer_cfi.py new file mode 100644 index 0000000000000..6022a2a16c9fb --- /dev/null +++ b/L1Trigger/L1TTrackMatch/python/DisplacedVertexProducer_cfi.py @@ -0,0 +1,32 @@ +import FWCore.ParameterSet.Config as cms + +DisplacedVertexProducer = cms.EDProducer('DisplacedVertexProducer', + l1TracksInputTag = cms.InputTag("l1tTTTracksFromExtendedTrackletEmulation", "Level1TTTracks"), + l1TrackVertexCollectionName = cms.string("dispVertices"), + mcTruthTrackInputTag = cms.InputTag("TTTrackAssociatorFromPixelDigisExtended", "Level1TTTracks"), + # The ONNX model should be found at this path, if you want a local version of the model: # git clone https://github.com/cms-data/L1Trigger-L1TTrackMatch.git L1Trigger/L1TTrackMatch/data + ONNXmodel = cms.FileInPath("L1Trigger/L1TTrackMatch/data/DisplacedVertexingModel.onnx"), + ONNXInputName = cms.string("feature_input"), + cutSet = cms.PSet( + chi2rzMax = cms.double(3.0), # chi2rz value for all tracks must be less than this + dispMVAMin = cms.double(0.2), # displaced track quality MVA score for all tracks must be greater than this + promptMVAMin = cms.double(0.2), # prompt track quality MVA score for all tracks must be greater than this + ptMin = cms.double(3.0), # pt value for all tracks must be greater than this [GeV] + etaMax = cms.double(2.4), # eta value for all tracks must be less than this + dispD0Min = cms.double(1.0), # d0 value for tracks to be considered for displaced track cuts must be greater than this [cm] + promptMVADispTrackMin = cms.double(0.5), # prompt track quality MVA score for tracks with |d0|>dispD0Min must be greater than this + overlapEtaMin = cms.double(1.1), # eta value for tracks to be considered for overlap track cuts must be greater than this + overlapEtaMax = cms.double(1.7), # eta value for tracks to be considered for overlap track cuts must be less than this + overlapNStubsMin = cms.int32(4), # number of stubs for tracks with overlapEtaMin<|eta|diskEtaMin must be greater than this [cm] + barrelD0Min = cms.double(0.06) # abs d0 value for tracks with |eta|<=diskEtaMin must be greater than this [cm] + + ) +) + +''' +Features for displaced vertex BDT: ['trkExt_pt_firstTrk', 'trkExt_pt', 'trkExt_eta_firstTrk', 'trkExt_eta', 'trkExt_phi_firstTrk', 'trkExt_phi', 'trkExt_d0_firstTrk', 'trkExt_d0', 'trkExt_z0_firstTrk', 'trkExt_z0', 'trkExt_chi2rz_firstTrk', 'trkExt_chi2rz', 'trkExt_bendchi2_firstTrk', 'trkExt_bendchi2', 'trkExt_MVA_firstTrk', 'trkExt_MVA', 'trkExt_MVA2_firstTrk', 'trkExt_MVA2', 'dv_d_T', 'dv_R_T', 'dv_cos_T', 'dv_del_Z']) + +dv inputs are vertex quantities and trkExt is a displaced track property. The firstTrk suffix means the track quantity comes from the higher pt track associated to a vertex. If there's no firstTrk suffix, then the track property is from the lower pt track associated to a vertex. +''' diff --git a/L1Trigger/L1TTrackMatch/python/L1TkObjectProducers_cff.py b/L1Trigger/L1TTrackMatch/python/L1TkObjectProducers_cff.py index 6b642ed5781a2..79bcb2d8903ac 100644 --- a/L1Trigger/L1TTrackMatch/python/L1TkObjectProducers_cff.py +++ b/L1Trigger/L1TTrackMatch/python/L1TkObjectProducers_cff.py @@ -41,6 +41,9 @@ #Other tk Objects +from L1Trigger.L1TTrackMatch.DisplacedVertexProducer_cfi.py import DisplacedVertexProducer +pDisplacedVertexProducer = cms.Path( DisplacedVertexProducer) + # from L1Trigger.L1TTrackMatch.L1TrackerJetProducer_cfi import L1TrackerJets # pL1TrackerJets = cms.Path( L1TrackerJets) diff --git a/L1Trigger/L1TTrackMatch/python/l1tTrackSelectionProducer_cfi.py b/L1Trigger/L1TTrackMatch/python/l1tTrackSelectionProducer_cfi.py index d78ab75961480..3f3bc4417567c 100644 --- a/L1Trigger/L1TTrackMatch/python/l1tTrackSelectionProducer_cfi.py +++ b/L1Trigger/L1TTrackMatch/python/l1tTrackSelectionProducer_cfi.py @@ -8,9 +8,12 @@ absEtaMax = cms.double(2.4), # absolute value of eta must be less than this value absZ0Max = cms.double(15.0), # z0 must be less than this value, [cm] nStubsMin = cms.int32(4), # number of stubs must be greater than or equal to this value + nStubsMinEtaOverlap = cms.int32(4), # number of stubs must be greater than or equal to this value for tracks with 1.1<|eta|<1.7 nPSStubsMin = cms.int32(0), # the number of stubs in the PS Modules must be greater than or equal to this value promptMVAMin = cms.double(-1.0), # MVA must be greater than this value + promptMVAMinD0Min1 = cms.double(-1.0), # MVA for tracks with |d0|>1cm must be greater than this value + displacedMVAMin = cms.double(-1.0), # Displaced MVA must be greater than this value reducedBendChi2Max = cms.double(2.25), # bend chi2 must be less than this value reducedChi2RZMax = cms.double(5.0), # chi2rz/dof must be less than this value reducedChi2RPhiMax = cms.double(20.0), # chi2rphi/dof must be less than this value @@ -20,6 +23,8 @@ reducedChi2RPhiMaxNstub5 = cms.double(999.9), # chi2rphi/dof with nstub>4 must be less than this value reducedBendChi2MaxNstub4 = cms.double(999.9), # bend chi2 with nstub==4 must be less than this value reducedBendChi2MaxNstub5 = cms.double(999.9), # bend chi2 with nstub>4 must be less than this value + absD0MinEtaMin0p95 = cms.double(-1.0), #absolute value of d0 must be greater than this value for tracks with |eta|>0.95 + absD0MinEtaMax0p95 = cms.double(-1.0), #absolute value of d0 must be greater than this value for tracks with |eta|<=0.95 ), processSimulatedTracks = cms.bool(True), # return selected tracks after cutting on the floating point values processEmulatedTracks = cms.bool(True), # return selected tracks after cutting on the bitwise emulated values @@ -34,9 +39,12 @@ absEtaMax = 2.4, # absolute value of eta must be less than this value absZ0Max = 15.0, # z0 must be less than this value, [cm] nStubsMin = 4, # number of stubs must be greater than or equal to this value + nStubsMinEtaOverlap = 4, # number of stubs must be greater than or equal to this value for tracks with 1.1<|eta|<1.7 nPSStubsMin = 0, # the number of stubs in the PS Modules must be greater than or equal to this value - promptMVAMin = -1.0, # MVA must be greater than this value + promptMVAMin = -1.0, # MVA must be greater than this value + promptMVAMinD0Min1 = -1.0, # MVA for tracks with |d0|>1cm must be greater than this value + displacedMVAMin = -1.0, # Displaced MVA must be greater than this value reducedBendChi2Max = 2.4, # bend chi2 must be less than this value reducedChi2RZMax = 10.0, # chi2rz/dof must be less than this value reducedChi2RPhiMax = 40.0, # chi2rphi/dof must be less than this value @@ -45,7 +53,9 @@ reducedChi2RPhiMaxNstub4 = cms.double(999.9), # chi2rphi/dof with nstub==4 must be less than this value reducedChi2RPhiMaxNstub5 = cms.double(999.9), # chi2rphi/dof with nstub>4 must be less than this value reducedBendChi2MaxNstub4 = 999.9, # bend chi2 with nstub==4 must be less than this value - reducedBendChi2MaxNstub5 = 999.9, # bend chi2 with nstub>4 must be less than this value + reducedBendChi2MaxNstub5 = 999.9, # bend chi2 with nstub>4 must be less than this value + absD0MinEtaMin0p95 = -1.0, #absolute value of d0 must be greater than this value for tracks with |eta|>0.95 + absD0MinEtaMax0p95 = -1.0, #absolute value of d0 must be greater than this value for tracks with |eta|<=0.95 ), processSimulatedTracks = cms.bool(True), # return selected tracks after cutting on the floating point values processEmulatedTracks = cms.bool(True), # return selected tracks after cutting on the bitwise emulated values @@ -97,4 +107,31 @@ l1tTrackSelectionProducerExtendedForEtMiss = l1tTrackSelectionProducerExtended.clone() - +l1tTrackSelectionProducerExtendedForDispVert = l1tTrackSelectionProducerExtended.clone( + l1TracksInputTag = ("l1tTTTracksFromExtendedTrackletEmulation", "Level1TTTracks"), + outputCollectionName = "Level1TTTracksSelected", + cutSet = dict( + ptMin = 3.0, # pt must be greater than this value, [GeV] + absEtaMax = 2.4, # absolute value of eta must be less than this value + absZ0Max = 999.9, # z0 must be less than this value, [cm] + nStubsMin = 0, # number of stubs must be greater than or equal to this value + nStubsMinEtaOverlap = 5, # number of stubs must be greater than or equal to this value for tracks with 1.1<|eta|<1.7 + nPSStubsMin = 0, # the number of stubs in the PS Modules must be greater than or equal to this value + promptMVAMin = 0.2, # MVA must be greater than this value + promptMVAMinD0Min1 = 0.5, # MVA for tracks with |d0|>1cm must be greater than this value + displacedMVAMin = 0.2, # Displaced MVA must be greater than this value + reducedBendChi2Max = 999.9, # bend chi2 must be less than this value + reducedChi2RZMax = 3.0, # chi2rz/dof must be less than this value + reducedChi2RPhiMax = 999.9, # chi2rphi/dof must be less than this value + reducedChi2RZMaxNstub4 = cms.double(999.9), # chi2rz/dof with nstub==4 must be less than this value + reducedChi2RZMaxNstub5 = cms.double(999.9), # chi2rz/dof with nstub>4 must be less than this value + reducedChi2RPhiMaxNstub4 = cms.double(999.9), # chi2rphi/dof with nstub==4 must be less than this value + reducedChi2RPhiMaxNstub5 = cms.double(999.9), # chi2rphi/dof with nstub>4 must be less than this value + reducedBendChi2MaxNstub4 = 999.9, # bend chi2 with nstub==4 must be less than this value + reducedBendChi2MaxNstub5 = 999.9, # bend chi2 with nstub>4 must be less than this value + absD0MinEtaMin0p95 = 0.08, #absolute value of d0 must be greater than this value for tracks with |eta|>0.95 + absD0MinEtaMax0p95 = 0.06, #absolute value of d0 must be greater than this value for tracks with |eta|<=0.95 + ), + processSimulatedTracks = cms.bool(True), # return selected tracks after cutting on the floating point values + processEmulatedTracks = cms.bool(False), # return selected tracks after cutting on the bitwise emulated values + ) diff --git a/L1Trigger/L1TTrackMatch/test/L1TrackObjectNtupleMaker.cc b/L1Trigger/L1TTrackMatch/test/L1TrackObjectNtupleMaker.cc index 0266e8463f5f8..e5799df3dab5a 100644 --- a/L1Trigger/L1TTrackMatch/test/L1TrackObjectNtupleMaker.cc +++ b/L1Trigger/L1TTrackMatch/test/L1TrackObjectNtupleMaker.cc @@ -72,6 +72,7 @@ #include "DataFormats/L1Trigger/interface/EtSum.h" #include "L1Trigger/L1TTrackMatch/interface/L1TkEtMissEmuAlgo.h" #include "L1Trigger/L1TTrackMatch/interface/L1TkHTMissEmulatorProducer.h" +#include "DataFormats/L1Trigger/interface/DisplacedVertex.h" /////////////// // ROOT HEADERS @@ -143,6 +144,7 @@ class L1TrackObjectNtupleMaker : public edm::one::EDAnalyzer= minNStub (this is mostly for tracklet purposes) bool SaveTrackJets; bool SaveTrackSums; + bool runDispVert; edm::InputTag L1TrackInputTag; // L1 track collection edm::InputTag MCTruthTrackInputTag; // MC truth collection @@ -184,6 +186,7 @@ class L1TrackObjectNtupleMaker : public edm::one::EDAnalyzer> GenJetToken_; edm::EDGetTokenT> GenParticleToken_; edm::EDGetTokenT> SimVertexToken_; + edm::EDGetTokenT> DispVertToken_; edm::EDGetTokenT L1VertexToken_; edm::EDGetTokenT L1VertexEmuToken_; @@ -286,12 +290,32 @@ class L1TrackObjectNtupleMaker : public edm::one::EDAnalyzer* m_gen_z0; std::vector* m_gen_mother_pdgid; + //displaced vertices + std::vector* m_dv_d_T; + std::vector* m_dv_R_T; + std::vector* m_dv_cos_T; + std::vector* m_dv_x; + std::vector* m_dv_y; + std::vector* m_dv_z; + std::vector* m_dv_openingAngle; + std::vector* m_dv_parentPt; + std::vector* m_dv_firstIndexTrk; + std::vector* m_dv_secondIndexTrk; + std::vector* m_dv_firstIndexPt; + std::vector* m_dv_secondIndexPt; + std::vector* m_dv_inTraj; + std::vector* m_dv_del_Z; + std::vector* m_dv_delIndexPt; + std::vector* m_dv_isReal; + std::vector* m_dv_score; + // all L1 tracks (prompt) std::vector* m_trk_pt; std::vector* m_trk_eta; std::vector* m_trk_phi; std::vector* m_trk_phi_local; std::vector* m_trk_d0; // (filled if nFitPar==5, else 999) + std::vector* m_trk_rinv; std::vector* m_trk_z0; std::vector* m_trk_chi2; std::vector* m_trk_chi2dof; @@ -299,6 +323,7 @@ class L1TrackObjectNtupleMaker : public edm::one::EDAnalyzer* m_trk_chi2rz; std::vector* m_trk_bendchi2; std::vector* m_trk_MVA1; + std::vector* m_trk_MVA2; std::vector* m_trk_nstub; std::vector* m_trk_lhits; std::vector* m_trk_dhits; @@ -340,6 +365,7 @@ class L1TrackObjectNtupleMaker : public edm::one::EDAnalyzer* m_trkExt_phi; std::vector* m_trkExt_phi_local; std::vector* m_trkExt_d0; // (filled if nFitPar==5, else 999) + std::vector* m_trkExt_rinv; std::vector* m_trkExt_z0; std::vector* m_trkExt_chi2; std::vector* m_trkExt_chi2dof; @@ -347,6 +373,7 @@ class L1TrackObjectNtupleMaker : public edm::one::EDAnalyzer* m_trkExt_chi2rz; std::vector* m_trkExt_bendchi2; std::vector* m_trkExt_MVA; + std::vector* m_trkExt_MVA2; std::vector* m_trkExt_nstub; std::vector* m_trkExt_lhits; std::vector* m_trkExt_dhits; @@ -364,6 +391,10 @@ class L1TrackObjectNtupleMaker : public edm::one::EDAnalyzer* m_trkExt_matchtp_phi; std::vector* m_trkExt_matchtp_z0; std::vector* m_trkExt_matchtp_dxy; + std::vector* m_trkExt_matchtp_d0; + std::vector* m_trkExt_matchtp_x; + std::vector* m_trkExt_matchtp_y; + std::vector* m_trkExt_matchtp_z; std::vector* m_trkExt_gtt_pt; std::vector* m_trkExt_gtt_eta; std::vector* m_trkExt_gtt_phi; @@ -387,6 +418,9 @@ class L1TrackObjectNtupleMaker : public edm::one::EDAnalyzer* m_tp_dxy; std::vector* m_tp_d0; std::vector* m_tp_z0; + std::vector* m_tp_x; + std::vector* m_tp_y; + std::vector* m_tp_z; std::vector* m_tp_d0_prod; std::vector* m_tp_z0_prod; std::vector* m_tp_pdgid; @@ -400,6 +434,7 @@ class L1TrackObjectNtupleMaker : public edm::one::EDAnalyzer* m_matchtrk_eta; std::vector* m_matchtrk_phi; std::vector* m_matchtrk_d0; //this variable is only filled if nFitPar==5 + std::vector* m_matchtrk_rinv; std::vector* m_matchtrk_z0; std::vector* m_matchtrk_chi2; std::vector* m_matchtrk_chi2dof; @@ -407,6 +442,7 @@ class L1TrackObjectNtupleMaker : public edm::one::EDAnalyzer* m_matchtrk_chi2rz; std::vector* m_matchtrk_bendchi2; std::vector* m_matchtrk_MVA1; + std::vector* m_matchtrk_MVA2; std::vector* m_matchtrk_nstub; std::vector* m_matchtrk_lhits; std::vector* m_matchtrk_dhits; @@ -418,6 +454,7 @@ class L1TrackObjectNtupleMaker : public edm::one::EDAnalyzer* m_matchtrkExt_eta; std::vector* m_matchtrkExt_phi; std::vector* m_matchtrkExt_d0; //this variable is only filled if nFitPar==5 + std::vector* m_matchtrkExt_rinv; std::vector* m_matchtrkExt_z0; std::vector* m_matchtrkExt_chi2; std::vector* m_matchtrkExt_chi2dof; @@ -425,6 +462,7 @@ class L1TrackObjectNtupleMaker : public edm::one::EDAnalyzer* m_matchtrkExt_chi2rz; std::vector* m_matchtrkExt_bendchi2; std::vector* m_matchtrkExt_MVA; + std::vector* m_matchtrkExt_MVA2; std::vector* m_matchtrkExt_nstub; std::vector* m_matchtrkExt_lhits; std::vector* m_matchtrkExt_dhits; @@ -584,6 +622,7 @@ L1TrackObjectNtupleMaker::L1TrackObjectNtupleMaker(edm::ParameterSet const& iCon SaveTrackJets = iConfig.getParameter("SaveTrackJets"); SaveTrackSums = iConfig.getParameter("SaveTrackSums"); + runDispVert = iConfig.getParameter("runDispVert"); L1StubInputTag = iConfig.getParameter("L1StubInputTag"); MCTruthClusterInputTag = iConfig.getParameter("MCTruthClusterInputTag"); @@ -595,6 +634,7 @@ L1TrackObjectNtupleMaker::L1TrackObjectNtupleMaker(edm::ParameterSet const& iCon RecoVertexEmuInputTag = iConfig.getParameter("RecoVertexEmuInputTag"); GenParticleInputTag = iConfig.getParameter("GenParticleInputTag"); SimVertexInputTag = iConfig.getParameter("SimVertexInputTag"); + DisplacedVertexInputTag = iConfig.getParameter("DisplacedVertexInputTag"); if (Displaced == "Prompt" || Displaced == "Both") { L1TrackInputTag = iConfig.getParameter("L1TrackInputTag"); @@ -732,6 +772,8 @@ L1TrackObjectNtupleMaker::L1TrackObjectNtupleMaker(edm::ParameterSet const& iCon GenJetToken_ = consumes>(GenJetInputTag); GenParticleToken_ = consumes>(GenParticleInputTag); SimVertexToken_ = consumes>(SimVertexInputTag); + if (runDispVert) + DispVertToken_ = consumes>(DisplacedVertexInputTag); L1VertexToken_ = consumes(RecoVertexInputTag); L1VertexEmuToken_ = consumes(RecoVertexEmuInputTag); tTopoToken_ = esConsumes(edm::ESInputTag("", "")); @@ -756,12 +798,14 @@ void L1TrackObjectNtupleMaker::endJob() { delete m_trk_phi_local; delete m_trk_z0; delete m_trk_d0; + delete m_trk_rinv; delete m_trk_chi2; delete m_trk_chi2dof; delete m_trk_chi2rphi; delete m_trk_chi2rz; delete m_trk_bendchi2; delete m_trk_MVA1; + delete m_trk_MVA2; delete m_trk_nstub; delete m_trk_lhits; delete m_trk_dhits; @@ -803,12 +847,14 @@ void L1TrackObjectNtupleMaker::endJob() { delete m_trkExt_phi_local; delete m_trkExt_z0; delete m_trkExt_d0; + delete m_trkExt_rinv; delete m_trkExt_chi2; delete m_trkExt_chi2dof; delete m_trkExt_chi2rphi; delete m_trkExt_chi2rz; delete m_trkExt_bendchi2; delete m_trkExt_MVA; + delete m_trkExt_MVA2; delete m_trkExt_nstub; delete m_trkExt_lhits; delete m_trkExt_dhits; @@ -826,6 +872,10 @@ void L1TrackObjectNtupleMaker::endJob() { delete m_trkExt_matchtp_phi; delete m_trkExt_matchtp_z0; delete m_trkExt_matchtp_dxy; + delete m_trkExt_matchtp_d0; + delete m_trkExt_matchtp_x; + delete m_trkExt_matchtp_y; + delete m_trkExt_matchtp_z; delete m_trkExt_gtt_pt; delete m_trkExt_gtt_eta; delete m_trkExt_gtt_phi; @@ -848,6 +898,9 @@ void L1TrackObjectNtupleMaker::endJob() { delete m_tp_dxy; delete m_tp_d0; delete m_tp_z0; + delete m_tp_x; + delete m_tp_y; + delete m_tp_z; delete m_tp_d0_prod; delete m_tp_z0_prod; delete m_tp_pdgid; @@ -863,17 +916,37 @@ void L1TrackObjectNtupleMaker::endJob() { delete m_gen_z0; + delete m_dv_d_T; + delete m_dv_R_T; + delete m_dv_cos_T; + delete m_dv_x; + delete m_dv_y; + delete m_dv_z; + delete m_dv_openingAngle; + delete m_dv_parentPt; + delete m_dv_firstIndexTrk; + delete m_dv_secondIndexTrk; + delete m_dv_firstIndexPt; + delete m_dv_secondIndexPt; + delete m_dv_inTraj; + delete m_dv_del_Z; + delete m_dv_delIndexPt; + delete m_dv_isReal; + delete m_dv_score; + delete m_matchtrk_pt; delete m_matchtrk_eta; delete m_matchtrk_phi; delete m_matchtrk_z0; delete m_matchtrk_d0; + delete m_matchtrk_rinv; delete m_matchtrk_chi2; delete m_matchtrk_chi2dof; delete m_matchtrk_chi2rphi; delete m_matchtrk_chi2rz; delete m_matchtrk_bendchi2; delete m_matchtrk_MVA1; + delete m_matchtrk_MVA2; delete m_matchtrk_nstub; delete m_matchtrk_dhits; delete m_matchtrk_lhits; @@ -885,12 +958,14 @@ void L1TrackObjectNtupleMaker::endJob() { delete m_matchtrkExt_phi; delete m_matchtrkExt_z0; delete m_matchtrkExt_d0; + delete m_matchtrkExt_rinv; delete m_matchtrkExt_chi2; delete m_matchtrkExt_chi2dof; delete m_matchtrkExt_chi2rphi; delete m_matchtrkExt_chi2rz; delete m_matchtrkExt_bendchi2; delete m_matchtrkExt_MVA; + delete m_matchtrkExt_MVA2; delete m_matchtrkExt_nstub; delete m_matchtrkExt_dhits; delete m_matchtrkExt_lhits; @@ -1023,12 +1098,14 @@ void L1TrackObjectNtupleMaker::beginJob() { m_trk_phi_local = new std::vector; m_trk_z0 = new std::vector; m_trk_d0 = new std::vector; + m_trk_rinv = new std::vector; m_trk_chi2 = new std::vector; m_trk_chi2dof = new std::vector; m_trk_chi2rphi = new std::vector; m_trk_chi2rz = new std::vector; m_trk_bendchi2 = new std::vector; m_trk_MVA1 = new std::vector; + m_trk_MVA2 = new std::vector; m_trk_nstub = new std::vector; m_trk_lhits = new std::vector; m_trk_dhits = new std::vector; @@ -1070,12 +1147,14 @@ void L1TrackObjectNtupleMaker::beginJob() { m_trkExt_phi_local = new std::vector; m_trkExt_z0 = new std::vector; m_trkExt_d0 = new std::vector; + m_trkExt_rinv = new std::vector; m_trkExt_chi2 = new std::vector; m_trkExt_chi2dof = new std::vector; m_trkExt_chi2rphi = new std::vector; m_trkExt_chi2rz = new std::vector; m_trkExt_bendchi2 = new std::vector; m_trkExt_MVA = new std::vector; + m_trkExt_MVA2 = new std::vector; m_trkExt_nstub = new std::vector; m_trkExt_lhits = new std::vector; m_trkExt_dhits = new std::vector; @@ -1093,6 +1172,10 @@ void L1TrackObjectNtupleMaker::beginJob() { m_trkExt_matchtp_phi = new std::vector; m_trkExt_matchtp_z0 = new std::vector; m_trkExt_matchtp_dxy = new std::vector; + m_trkExt_matchtp_d0 = new std::vector; + m_trkExt_matchtp_x = new std::vector; + m_trkExt_matchtp_y = new std::vector; + m_trkExt_matchtp_z = new std::vector; m_trkExt_gtt_pt = new std::vector; m_trkExt_gtt_eta = new std::vector; m_trkExt_gtt_phi = new std::vector; @@ -1115,6 +1198,9 @@ void L1TrackObjectNtupleMaker::beginJob() { m_tp_dxy = new std::vector; m_tp_d0 = new std::vector; m_tp_z0 = new std::vector; + m_tp_x = new std::vector; + m_tp_y = new std::vector; + m_tp_z = new std::vector; m_tp_d0_prod = new std::vector; m_tp_z0_prod = new std::vector; m_tp_pdgid = new std::vector; @@ -1130,17 +1216,37 @@ void L1TrackObjectNtupleMaker::beginJob() { m_gen_z0 = new std::vector; + m_dv_d_T = new std::vector; + m_dv_R_T = new std::vector; + m_dv_cos_T = new std::vector; + m_dv_x = new std::vector; + m_dv_y = new std::vector; + m_dv_z = new std::vector; + m_dv_openingAngle = new std::vector; + m_dv_parentPt = new std::vector; + m_dv_firstIndexTrk = new std::vector; + m_dv_secondIndexTrk = new std::vector; + m_dv_firstIndexPt = new std::vector; + m_dv_secondIndexPt = new std::vector; + m_dv_inTraj = new std::vector; + m_dv_del_Z = new std::vector; + m_dv_delIndexPt = new std::vector; + m_dv_isReal = new std::vector; + m_dv_score = new std::vector; + m_matchtrk_pt = new std::vector; m_matchtrk_eta = new std::vector; m_matchtrk_phi = new std::vector; m_matchtrk_z0 = new std::vector; m_matchtrk_d0 = new std::vector; + m_matchtrk_rinv = new std::vector; m_matchtrk_chi2 = new std::vector; m_matchtrk_chi2dof = new std::vector; m_matchtrk_chi2rphi = new std::vector; m_matchtrk_chi2rz = new std::vector; m_matchtrk_bendchi2 = new std::vector; m_matchtrk_MVA1 = new std::vector; + m_matchtrk_MVA2 = new std::vector; m_matchtrk_nstub = new std::vector; m_matchtrk_dhits = new std::vector; m_matchtrk_lhits = new std::vector; @@ -1152,12 +1258,14 @@ void L1TrackObjectNtupleMaker::beginJob() { m_matchtrkExt_phi = new std::vector; m_matchtrkExt_z0 = new std::vector; m_matchtrkExt_d0 = new std::vector; + m_matchtrkExt_rinv = new std::vector; m_matchtrkExt_chi2 = new std::vector; m_matchtrkExt_chi2dof = new std::vector; m_matchtrkExt_chi2rphi = new std::vector; m_matchtrkExt_chi2rz = new std::vector; m_matchtrkExt_bendchi2 = new std::vector; m_matchtrkExt_MVA = new std::vector; + m_matchtrkExt_MVA2 = new std::vector; m_matchtrkExt_nstub = new std::vector; m_matchtrkExt_dhits = new std::vector; m_matchtrkExt_lhits = new std::vector; @@ -1282,6 +1390,7 @@ void L1TrackObjectNtupleMaker::beginJob() { eventTree->Branch("trk_phi", &m_trk_phi); eventTree->Branch("trk_phi_local", &m_trk_phi_local); eventTree->Branch("trk_d0", &m_trk_d0); + eventTree->Branch("trk_rinv", &m_trk_rinv); eventTree->Branch("trk_z0", &m_trk_z0); eventTree->Branch("trk_chi2", &m_trk_chi2); eventTree->Branch("trk_chi2dof", &m_trk_chi2dof); @@ -1289,6 +1398,7 @@ void L1TrackObjectNtupleMaker::beginJob() { eventTree->Branch("trk_chi2rz", &m_trk_chi2rz); eventTree->Branch("trk_bendchi2", &m_trk_bendchi2); eventTree->Branch("trk_MVA1", &m_trk_MVA1); + eventTree->Branch("trk_MVA2", &m_trk_MVA2); eventTree->Branch("trk_nstub", &m_trk_nstub); eventTree->Branch("trk_lhits", &m_trk_lhits); eventTree->Branch("trk_dhits", &m_trk_dhits); @@ -1333,6 +1443,7 @@ void L1TrackObjectNtupleMaker::beginJob() { eventTree->Branch("trkExt_phi", &m_trkExt_phi); eventTree->Branch("trkExt_phi_local", &m_trkExt_phi_local); eventTree->Branch("trkExt_d0", &m_trkExt_d0); + eventTree->Branch("trkExt_rinv", &m_trkExt_rinv); eventTree->Branch("trkExt_z0", &m_trkExt_z0); eventTree->Branch("trkExt_chi2", &m_trkExt_chi2); eventTree->Branch("trkExt_chi2dof", &m_trkExt_chi2dof); @@ -1340,6 +1451,7 @@ void L1TrackObjectNtupleMaker::beginJob() { eventTree->Branch("trkExt_chi2rz", &m_trkExt_chi2rz); eventTree->Branch("trkExt_bendchi2", &m_trkExt_bendchi2); eventTree->Branch("trkExt_MVA", &m_trkExt_MVA); + eventTree->Branch("trkExt_MVA2", &m_trkExt_MVA2); eventTree->Branch("trkExt_nstub", &m_trkExt_nstub); eventTree->Branch("trkExt_lhits", &m_trkExt_lhits); eventTree->Branch("trkExt_dhits", &m_trkExt_dhits); @@ -1357,6 +1469,10 @@ void L1TrackObjectNtupleMaker::beginJob() { eventTree->Branch("trkExt_matchtp_phi", &m_trkExt_matchtp_phi); eventTree->Branch("trkExt_matchtp_z0", &m_trkExt_matchtp_z0); eventTree->Branch("trkExt_matchtp_dxy", &m_trkExt_matchtp_dxy); + eventTree->Branch("trkExt_matchtp_d0", &m_trkExt_matchtp_d0); + eventTree->Branch("trkExt_matchtp_x", &m_trkExt_matchtp_x); + eventTree->Branch("trkExt_matchtp_y", &m_trkExt_matchtp_y); + eventTree->Branch("trkExt_matchtp_z", &m_trkExt_matchtp_z); eventTree->Branch("trkExt_gtt_pt", &m_trkExt_gtt_pt); eventTree->Branch("trkExt_gtt_eta", &m_trkExt_gtt_eta); eventTree->Branch("trkExt_gtt_phi", &m_trkExt_gtt_phi); @@ -1381,6 +1497,9 @@ void L1TrackObjectNtupleMaker::beginJob() { eventTree->Branch("tp_dxy", &m_tp_dxy); eventTree->Branch("tp_d0", &m_tp_d0); eventTree->Branch("tp_z0", &m_tp_z0); + eventTree->Branch("tp_x", &m_tp_x); + eventTree->Branch("tp_y", &m_tp_y); + eventTree->Branch("tp_z", &m_tp_z); eventTree->Branch("tp_d0_prod", &m_tp_d0_prod); eventTree->Branch("tp_z0_prod", &m_tp_z0_prod); eventTree->Branch("tp_pdgid", &m_tp_pdgid); @@ -1395,12 +1514,14 @@ void L1TrackObjectNtupleMaker::beginJob() { eventTree->Branch("matchtrk_phi", &m_matchtrk_phi); eventTree->Branch("matchtrk_z0", &m_matchtrk_z0); eventTree->Branch("matchtrk_d0", &m_matchtrk_d0); + eventTree->Branch("matchtrk_rinv", &m_matchtrk_rinv); eventTree->Branch("matchtrk_chi2", &m_matchtrk_chi2); eventTree->Branch("matchtrk_chi2dof", &m_matchtrk_chi2dof); eventTree->Branch("matchtrk_chi2rphi", &m_matchtrk_chi2rphi); eventTree->Branch("matchtrk_chi2rz", &m_matchtrk_chi2rz); eventTree->Branch("matchtrk_bendchi2", &m_matchtrk_bendchi2); eventTree->Branch("matchtrk_MVA1", &m_matchtrk_MVA1); + eventTree->Branch("matchtrk_MVA2", &m_matchtrk_MVA2); eventTree->Branch("matchtrk_nstub", &m_matchtrk_nstub); eventTree->Branch("matchtrk_lhits", &m_matchtrk_lhits); eventTree->Branch("matchtrk_dhits", &m_matchtrk_dhits); @@ -1414,12 +1535,14 @@ void L1TrackObjectNtupleMaker::beginJob() { eventTree->Branch("matchtrkExt_phi", &m_matchtrkExt_phi); eventTree->Branch("matchtrkExt_z0", &m_matchtrkExt_z0); eventTree->Branch("matchtrkExt_d0", &m_matchtrkExt_d0); + eventTree->Branch("matchtrkExt_rinv", &m_matchtrkExt_rinv); eventTree->Branch("matchtrkExt_chi2", &m_matchtrkExt_chi2); eventTree->Branch("matchtrkExt_chi2dof", &m_matchtrkExt_chi2dof); eventTree->Branch("matchtrkExt_chi2rphi", &m_matchtrkExt_chi2rphi); eventTree->Branch("matchtrkExt_chi2rz", &m_matchtrkExt_chi2rz); eventTree->Branch("matchtrkExt_bendchi2", &m_matchtrkExt_bendchi2); eventTree->Branch("matchtrkExt_MVA", &m_matchtrkExt_MVA); + eventTree->Branch("matchtrkExt_MVA2", &m_matchtrkExt_MVA2); eventTree->Branch("matchtrkExt_nstub", &m_matchtrkExt_nstub); eventTree->Branch("matchtrkExt_lhits", &m_matchtrkExt_lhits); eventTree->Branch("matchtrkExt_dhits", &m_matchtrkExt_dhits); @@ -1457,7 +1580,25 @@ void L1TrackObjectNtupleMaker::beginJob() { eventTree->Branch("gen_mother_pdgid", &m_gen_mother_pdgid); eventTree->Branch("gen_z0", &m_gen_z0); - + if (runDispVert) { + eventTree->Branch("dv_d_T", &m_dv_d_T); + eventTree->Branch("dv_R_T", &m_dv_R_T); + eventTree->Branch("dv_cos_T", &m_dv_cos_T); + eventTree->Branch("dv_x", &m_dv_x); + eventTree->Branch("dv_y", &m_dv_y); + eventTree->Branch("dv_z", &m_dv_z); + eventTree->Branch("dv_openingAngle", &m_dv_openingAngle); + eventTree->Branch("dv_parentPt", &m_dv_parentPt); + eventTree->Branch("dv_firstIndexTrk", &m_dv_firstIndexTrk); + eventTree->Branch("dv_secondIndexTrk", &m_dv_secondIndexTrk); + eventTree->Branch("dv_firstIndexPt", &m_dv_firstIndexPt); + eventTree->Branch("dv_secondIndexPt", &m_dv_secondIndexPt); + eventTree->Branch("dv_inTraj", &m_dv_inTraj); + eventTree->Branch("dv_del_Z", &m_dv_del_Z); + eventTree->Branch("dv_delIndexPt", &m_dv_delIndexPt); + eventTree->Branch("dv_isReal", &m_dv_isReal); + eventTree->Branch("dv_score", &m_dv_score); + } if (SaveTrackJets) { eventTree->Branch("genjet_eta", &m_genjet_eta); eventTree->Branch("genjet_p", &m_genjet_p); @@ -1591,6 +1732,7 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even m_trk_phi->clear(); m_trk_phi_local->clear(); m_trk_d0->clear(); + m_trk_rinv->clear(); m_trk_z0->clear(); m_trk_chi2->clear(); m_trk_chi2dof->clear(); @@ -1598,6 +1740,7 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even m_trk_chi2rz->clear(); m_trk_bendchi2->clear(); m_trk_MVA1->clear(); + m_trk_MVA2->clear(); m_trk_nstub->clear(); m_trk_lhits->clear(); m_trk_dhits->clear(); @@ -1639,6 +1782,7 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even m_trkExt_phi->clear(); m_trkExt_phi_local->clear(); m_trkExt_d0->clear(); + m_trkExt_rinv->clear(); m_trkExt_z0->clear(); m_trkExt_chi2->clear(); m_trkExt_chi2dof->clear(); @@ -1646,6 +1790,7 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even m_trkExt_chi2rz->clear(); m_trkExt_bendchi2->clear(); m_trkExt_MVA->clear(); + m_trkExt_MVA2->clear(); m_trkExt_nstub->clear(); m_trkExt_lhits->clear(); m_trkExt_dhits->clear(); @@ -1663,6 +1808,10 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even m_trkExt_matchtp_phi->clear(); m_trkExt_matchtp_z0->clear(); m_trkExt_matchtp_dxy->clear(); + m_trkExt_matchtp_d0->clear(); + m_trkExt_matchtp_x->clear(); + m_trkExt_matchtp_y->clear(); + m_trkExt_matchtp_z->clear(); m_trkExt_gtt_pt->clear(); m_trkExt_gtt_eta->clear(); m_trkExt_gtt_phi->clear(); @@ -1685,6 +1834,9 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even m_tp_dxy->clear(); m_tp_d0->clear(); m_tp_z0->clear(); + m_tp_x->clear(); + m_tp_y->clear(); + m_tp_z->clear(); m_tp_d0_prod->clear(); m_tp_z0_prod->clear(); m_tp_pdgid->clear(); @@ -1699,19 +1851,39 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even m_gen_mother_pdgid->clear(); m_gen_z0->clear(); - + if (runDispVert) { + m_dv_d_T->clear(); + m_dv_R_T->clear(); + m_dv_cos_T->clear(); + m_dv_x->clear(); + m_dv_y->clear(); + m_dv_z->clear(); + m_dv_openingAngle->clear(); + m_dv_parentPt->clear(); + m_dv_firstIndexTrk->clear(); + m_dv_secondIndexTrk->clear(); + m_dv_firstIndexPt->clear(); + m_dv_secondIndexPt->clear(); + m_dv_inTraj->clear(); + m_dv_del_Z->clear(); + m_dv_delIndexPt->clear(); + m_dv_isReal->clear(); + m_dv_score->clear(); + } if (Displaced == "Prompt" || Displaced == "Both") { m_matchtrk_pt->clear(); m_matchtrk_eta->clear(); m_matchtrk_phi->clear(); m_matchtrk_z0->clear(); m_matchtrk_d0->clear(); + m_matchtrk_rinv->clear(); m_matchtrk_chi2->clear(); m_matchtrk_chi2dof->clear(); m_matchtrk_chi2rphi->clear(); m_matchtrk_chi2rz->clear(); m_matchtrk_bendchi2->clear(); m_matchtrk_MVA1->clear(); + m_matchtrk_MVA2->clear(); m_matchtrk_nstub->clear(); m_matchtrk_lhits->clear(); m_matchtrk_dhits->clear(); @@ -1725,12 +1897,14 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even m_matchtrkExt_phi->clear(); m_matchtrkExt_z0->clear(); m_matchtrkExt_d0->clear(); + m_matchtrkExt_rinv->clear(); m_matchtrkExt_chi2->clear(); m_matchtrkExt_chi2dof->clear(); m_matchtrkExt_chi2rphi->clear(); m_matchtrkExt_chi2rz->clear(); m_matchtrkExt_bendchi2->clear(); m_matchtrkExt_MVA->clear(); + m_matchtrkExt_MVA2->clear(); m_matchtrkExt_nstub->clear(); m_matchtrkExt_lhits->clear(); m_matchtrkExt_dhits->clear(); @@ -1884,6 +2058,11 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even edm::Handle> GenJetHandle; iEvent.getByToken(GenJetToken_, GenJetHandle); + //Displaced vertices + edm::Handle> DispVertHandle; + if (runDispVert) + iEvent.getByToken(DispVertToken_, DispVertHandle); + //Vertex edm::Handle L1PrimaryVertexHandle; iEvent.getByToken(L1VertexToken_, L1PrimaryVertexHandle); @@ -2040,6 +2219,30 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even edm::LogWarning("DataNotFound") << "\nWarning: GenParticleHandle not found in the event" << std::endl; } + // loop over displaced vertices + if (DispVertHandle.isValid()) { + vector::const_iterator dispVertIter; + for (dispVertIter = DispVertHandle->begin(); dispVertIter != DispVertHandle->end(); ++dispVertIter) { + m_dv_d_T->push_back(dispVertIter->d_T()); + m_dv_R_T->push_back(dispVertIter->R_T()); + m_dv_cos_T->push_back(dispVertIter->cos_T()); + m_dv_x->push_back(dispVertIter->x()); + m_dv_y->push_back(dispVertIter->y()); + m_dv_z->push_back(dispVertIter->z()); + m_dv_openingAngle->push_back(dispVertIter->openingAngle()); + m_dv_parentPt->push_back(dispVertIter->parentPt()); + m_dv_firstIndexTrk->push_back(dispVertIter->firstIndexTrk()); + m_dv_secondIndexTrk->push_back(dispVertIter->secondIndexTrk()); + m_dv_firstIndexPt->push_back(dispVertIter->firstIndexPt()); + m_dv_secondIndexPt->push_back(dispVertIter->secondIndexPt()); + m_dv_inTraj->push_back(dispVertIter->inTraj()); + m_dv_del_Z->push_back(dispVertIter->del_Z()); + m_dv_delIndexPt->push_back(dispVertIter->delIndexPt()); + m_dv_isReal->push_back(dispVertIter->isReal()); + m_dv_score->push_back(dispVertIter->score()); + } + } + if (SimVertexHandle.isValid()) { const SimVertex simPVh = *(SimVertexHandle->begin()); m_pv_MC->push_back(simPVh.position().z()); @@ -2166,6 +2369,7 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even int tmp_trk_nFitPars = iterL1Track->nFitPars(); //4 or 5 float tmp_trk_d0 = -999; + float tmp_trk_rinv = iterL1Track->rInv(); if (tmp_trk_nFitPars == 5) { float tmp_trk_x0 = iterL1Track->POCA().x(); float tmp_trk_y0 = iterL1Track->POCA().y(); @@ -2179,6 +2383,7 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even float tmp_trk_chi2rz = iterL1Track->chi2ZRed(); float tmp_trk_bendchi2 = iterL1Track->stubPtConsistency(); float tmp_trk_MVA1 = iterL1Track->trkMVA1(); + float tmp_trk_MVA2 = iterL1Track->trkMVA2(); std::vector>, TTStub>> stubRefs = iterL1Track->getStubRefs(); @@ -2260,12 +2465,14 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even m_trk_d0->push_back(tmp_trk_d0); else m_trk_d0->push_back(999.); + m_trk_rinv->push_back(tmp_trk_rinv); m_trk_chi2->push_back(tmp_trk_chi2); m_trk_chi2dof->push_back(tmp_trk_chi2dof); m_trk_chi2rphi->push_back(tmp_trk_chi2rphi); m_trk_chi2rz->push_back(tmp_trk_chi2rz); m_trk_bendchi2->push_back(tmp_trk_bendchi2); m_trk_MVA1->push_back(tmp_trk_MVA1); + m_trk_MVA2->push_back(tmp_trk_MVA2); m_trk_nstub->push_back(tmp_trk_nstub); m_trk_dhits->push_back(tmp_trk_dhits); m_trk_lhits->push_back(tmp_trk_lhits); @@ -2389,6 +2596,7 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even int tmp_trk_nFitPars = iterL1Track->nFitPars(); //4 or 5 float tmp_trk_d0 = -999; + float tmp_trk_rinv = iterL1Track->rInv(); if (tmp_trk_nFitPars == 5) { float tmp_trk_x0 = iterL1Track->POCA().x(); float tmp_trk_y0 = iterL1Track->POCA().y(); @@ -2402,6 +2610,7 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even float tmp_trk_chi2rz = iterL1Track->chi2ZRed(); float tmp_trk_bendchi2 = iterL1Track->stubPtConsistency(); float tmp_trk_MVA1 = iterL1Track->trkMVA1(); + float tmp_trk_MVA2 = iterL1Track->trkMVA2(); std::vector>, TTStub>> stubRefs = iterL1Track->getStubRefs(); @@ -2483,12 +2692,14 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even m_trkExt_d0->push_back(tmp_trk_d0); else m_trkExt_d0->push_back(999.); + m_trkExt_rinv->push_back(tmp_trk_rinv); m_trkExt_chi2->push_back(tmp_trk_chi2); m_trkExt_chi2dof->push_back(tmp_trk_chi2dof); m_trkExt_chi2rphi->push_back(tmp_trk_chi2rphi); m_trkExt_chi2rz->push_back(tmp_trk_chi2rz); m_trkExt_bendchi2->push_back(tmp_trk_bendchi2); m_trkExt_MVA->push_back(tmp_trk_MVA1); + m_trkExt_MVA2->push_back(tmp_trk_MVA2); m_trkExt_nstub->push_back(tmp_trk_nstub); m_trkExt_dhits->push_back(tmp_trk_dhits); m_trkExt_lhits->push_back(tmp_trk_lhits); @@ -2511,7 +2722,11 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even float myTP_eta = -999; float myTP_phi = -999; float myTP_z0 = -999; + float myTP_z = -999; float myTP_dxy = -999; + float myTP_d0 = -999; + float myTP_x0 = -999; + float myTP_y0 = -999; if (my_tp.isNull()) myFake = 0; @@ -2526,12 +2741,35 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even myTP_pt = my_tp->p4().pt(); myTP_eta = my_tp->p4().eta(); myTP_phi = my_tp->p4().phi(); - myTP_z0 = my_tp->vertex().z(); + myTP_z = my_tp->vertex().z(); + + myTP_x0 = my_tp->vertex().x(); + myTP_y0 = my_tp->vertex().y(); - float myTP_x0 = my_tp->vertex().x(); - float myTP_y0 = my_tp->vertex().y(); myTP_dxy = sqrt(myTP_x0 * myTP_x0 + myTP_y0 * myTP_y0); + // get d0/z0 propagated back to the IP + float tmp_tp_t = tan(2.0 * atan(1.0) - 2.0 * atan(exp(-myTP_eta))); + float delx = -myTP_x0; + float dely = -myTP_y0; + float A = 0.01 * 0.5696; + float Kmagnitude = A / myTP_pt; + float tmp_tp_charge = my_tp->charge(); + float K = Kmagnitude * tmp_tp_charge; + float d = 0; + float tmp_tp_x0p = delx - (d + 1. / (2. * K) * sin(myTP_phi)); + float tmp_tp_y0p = dely + (d + 1. / (2. * K) * cos(myTP_phi)); + float tmp_tp_rp = sqrt(tmp_tp_x0p * tmp_tp_x0p + tmp_tp_y0p * tmp_tp_y0p); + float tmp_tp_d0 = tmp_tp_charge * tmp_tp_rp - (1. / (2. * K)); + myTP_d0 = tmp_tp_d0 * (-1); //fix d0 sign + const double pi = 4.0 * atan(1.0); + float delphi = myTP_phi - atan2(-K * tmp_tp_x0p, K * tmp_tp_y0p); + if (delphi < -pi) + delphi += 2.0 * pi; + if (delphi > pi) + delphi -= 2.0 * pi; + + myTP_z0 = myTP_z + tmp_tp_t * delphi / (2.0 * K); if (DebugMode) { edm::LogVerbatim("Tracklet") << "TP matched to track has pt = " << my_tp->p4().pt() << " eta = " << my_tp->momentum().eta() << " phi = " << my_tp->momentum().phi() @@ -2547,6 +2785,10 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even m_trkExt_matchtp_phi->push_back(myTP_phi); m_trkExt_matchtp_z0->push_back(myTP_z0); m_trkExt_matchtp_dxy->push_back(myTP_dxy); + m_trkExt_matchtp_d0->push_back(myTP_d0); + m_trkExt_matchtp_x->push_back(myTP_x0); + m_trkExt_matchtp_y->push_back(myTP_y0); + m_trkExt_matchtp_z->push_back(myTP_z); // ---------------------------------------------------------------------------------------------- // store the index to the selected track or -1 if not selected @@ -2741,6 +2983,9 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even m_tp_dxy->push_back(tmp_tp_dxy); m_tp_z0->push_back(tmp_tp_z0); m_tp_d0->push_back(tmp_tp_d0); + m_tp_x->push_back(tmp_tp_vx); + m_tp_y->push_back(tmp_tp_vy); + m_tp_z->push_back(tmp_tp_vz); m_tp_z0_prod->push_back(tmp_tp_z0_prod); m_tp_d0_prod->push_back(tmp_tp_d0_prod); m_tp_pdgid->push_back(tmp_tp_pdgid); @@ -2837,12 +3082,14 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even float tmp_matchtrk_phi = -999; float tmp_matchtrk_z0 = -999; float tmp_matchtrk_d0 = -999; + float tmp_matchtrk_rinv = -999; float tmp_matchtrk_chi2 = -999; float tmp_matchtrk_chi2dof = -999; float tmp_matchtrk_chi2rphi = -999; float tmp_matchtrk_chi2rz = -999; float tmp_matchtrk_bendchi2 = -999; float tmp_matchtrk_MVA1 = -999; + float tmp_matchtrk_MVA2 = -999; int tmp_matchtrk_nstub = -999; int tmp_matchtrk_dhits = -999; int tmp_matchtrk_lhits = -999; @@ -2866,13 +3113,14 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even tmp_matchtrk_d0 = -tmp_matchtrk_x0 * sin(tmp_matchtrk_phi) + tmp_matchtrk_y0 * cos(tmp_matchtrk_phi); // tmp_matchtrk_d0 = matchedTracks.at(i_track)->d0(); } - + tmp_matchtrk_rinv = matchedTracks.at(i_track)->rInv(); tmp_matchtrk_chi2 = matchedTracks.at(i_track)->chi2(); tmp_matchtrk_chi2dof = matchedTracks.at(i_track)->chi2Red(); tmp_matchtrk_chi2rphi = matchedTracks.at(i_track)->chi2XYRed(); tmp_matchtrk_chi2rz = matchedTracks.at(i_track)->chi2ZRed(); tmp_matchtrk_bendchi2 = matchedTracks.at(i_track)->stubPtConsistency(); tmp_matchtrk_MVA1 = matchedTracks.at(i_track)->trkMVA1(); + tmp_matchtrk_MVA2 = matchedTracks.at(i_track)->trkMVA2(); tmp_matchtrk_nstub = (int)matchedTracks.at(i_track)->getStubRefs().size(); tmp_matchtrk_seed = (int)matchedTracks.at(i_track)->trackSeedType(); tmp_matchtrk_hitpattern = (int)matchedTracks.at(i_track)->hitPattern(); @@ -2905,12 +3153,14 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even m_matchtrk_phi->push_back(tmp_matchtrk_phi); m_matchtrk_z0->push_back(tmp_matchtrk_z0); m_matchtrk_d0->push_back(tmp_matchtrk_d0); + m_matchtrk_rinv->push_back(tmp_matchtrk_rinv); m_matchtrk_chi2->push_back(tmp_matchtrk_chi2); m_matchtrk_chi2dof->push_back(tmp_matchtrk_chi2dof); m_matchtrk_chi2rphi->push_back(tmp_matchtrk_chi2rphi); m_matchtrk_chi2rz->push_back(tmp_matchtrk_chi2rz); m_matchtrk_bendchi2->push_back(tmp_matchtrk_bendchi2); m_matchtrk_MVA1->push_back(tmp_matchtrk_MVA1); + m_matchtrk_MVA2->push_back(tmp_matchtrk_MVA2); m_matchtrk_nstub->push_back(tmp_matchtrk_nstub); m_matchtrk_dhits->push_back(tmp_matchtrk_dhits); m_matchtrk_lhits->push_back(tmp_matchtrk_lhits); @@ -3008,12 +3258,14 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even float tmp_matchtrkExt_phi = -999; float tmp_matchtrkExt_z0 = -999; float tmp_matchtrkExt_d0 = -999; + float tmp_matchtrkExt_rinv = -999; float tmp_matchtrkExt_chi2 = -999; float tmp_matchtrkExt_chi2dof = -999; float tmp_matchtrkExt_chi2rphi = -999; float tmp_matchtrkExt_chi2rz = -999; float tmp_matchtrkExt_bendchi2 = -999; float tmp_matchtrkExt_MVA = -999; + float tmp_matchtrkExt_MVA2 = -999; int tmp_matchtrkExt_nstub = -999; int tmp_matchtrkExt_dhits = -999; int tmp_matchtrkExt_lhits = -999; @@ -3039,12 +3291,14 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even // tmp_matchtrkExt_d0 = matchedTracks.at(i_track)->d0(); } + tmp_matchtrkExt_rinv = matchedTracks.at(i_track)->rInv(); tmp_matchtrkExt_chi2 = matchedTracks.at(i_track)->chi2(); tmp_matchtrkExt_chi2dof = matchedTracks.at(i_track)->chi2Red(); tmp_matchtrkExt_chi2rphi = matchedTracks.at(i_track)->chi2XYRed(); tmp_matchtrkExt_chi2rz = matchedTracks.at(i_track)->chi2ZRed(); tmp_matchtrkExt_bendchi2 = matchedTracks.at(i_track)->stubPtConsistency(); tmp_matchtrkExt_MVA = matchedTracks.at(i_track)->trkMVA1(); + tmp_matchtrkExt_MVA2 = matchedTracks.at(i_track)->trkMVA2(); tmp_matchtrkExt_nstub = (int)matchedTracks.at(i_track)->getStubRefs().size(); tmp_matchtrkExt_seed = (int)matchedTracks.at(i_track)->trackSeedType(); tmp_matchtrkExt_hitpattern = (int)matchedTracks.at(i_track)->hitPattern(); @@ -3076,12 +3330,14 @@ void L1TrackObjectNtupleMaker::analyze(const edm::Event& iEvent, const edm::Even m_matchtrkExt_phi->push_back(tmp_matchtrkExt_phi); m_matchtrkExt_z0->push_back(tmp_matchtrkExt_z0); m_matchtrkExt_d0->push_back(tmp_matchtrkExt_d0); + m_matchtrkExt_rinv->push_back(tmp_matchtrkExt_rinv); m_matchtrkExt_chi2->push_back(tmp_matchtrkExt_chi2); m_matchtrkExt_chi2dof->push_back(tmp_matchtrkExt_chi2dof); m_matchtrkExt_chi2rphi->push_back(tmp_matchtrkExt_chi2rphi); m_matchtrkExt_chi2rz->push_back(tmp_matchtrkExt_chi2rz); m_matchtrkExt_bendchi2->push_back(tmp_matchtrkExt_bendchi2); m_matchtrkExt_MVA->push_back(tmp_matchtrkExt_MVA); + m_matchtrkExt_MVA2->push_back(tmp_matchtrkExt_MVA2); m_matchtrkExt_nstub->push_back(tmp_matchtrkExt_nstub); m_matchtrkExt_dhits->push_back(tmp_matchtrkExt_dhits); m_matchtrkExt_lhits->push_back(tmp_matchtrkExt_lhits); diff --git a/L1Trigger/L1TTrackMatch/test/L1TrackObjectNtupleMaker_cfg.py b/L1Trigger/L1TTrackMatch/test/L1TrackObjectNtupleMaker_cfg.py index dc8ec551fd186..49fd4bd966339 100644 --- a/L1Trigger/L1TTrackMatch/test/L1TrackObjectNtupleMaker_cfg.py +++ b/L1Trigger/L1TTrackMatch/test/L1TrackObjectNtupleMaker_cfg.py @@ -20,6 +20,7 @@ runVtxNN = True +runDispVert = False ############################################################ # import standard configurations ############################################################ @@ -96,8 +97,7 @@ process.load("L1Trigger.L1TTrackMatch.l1tTrackerEmuHTMiss_cfi") process.load("L1Trigger.L1TTrackMatch.l1tTrackTripletEmulation_cfi") process.load('L1Trigger.VertexFinder.l1tVertexProducer_cfi') - - +process.load('L1Trigger.L1TTrackMatch.DisplacedVertexProducer_cfi') ############################################################ # Primary vertex @@ -156,10 +156,17 @@ elif (L1TRKALGO == 'HYBRID_DISPLACED'): process.TTTracksEmu = cms.Path(process.L1TExtendedHybridTracks) process.TTTracksEmuWithTruth = cms.Path(process.L1TExtendedHybridTracksWithAssociators) - process.pL1TrackSelection = cms.Path(process.l1tTrackSelectionProducer * - process.l1tTrackSelectionProducerExtended * - process.l1tTrackSelectionProducerExtendedForJets * - process.l1tTrackSelectionProducerExtendedForEtMiss) + if(runDispVert): + process.pL1TrackSelection = cms.Path(process.l1tTrackSelectionProducer * + process.l1tTrackSelectionProducerExtended * + process.l1tTrackSelectionProducerExtendedForJets * + process.l1tTrackSelectionProducerExtendedForEtMiss * + process.l1tTrackSelectionProducerExtendedForDispVert) + else: + process.pL1TrackSelection = cms.Path(process.l1tTrackSelectionProducer * + process.l1tTrackSelectionProducerExtended * + process.l1tTrackSelectionProducerExtendedForJets * + process.l1tTrackSelectionProducerExtendedForEtMiss) process.pL1TrackVertexAssociation = cms.Path(process.l1tTrackVertexAssociationProducerExtended * process.l1tTrackVertexAssociationProducerExtendedForJets * process.l1tTrackVertexAssociationProducerExtendedForEtMiss) @@ -170,15 +177,23 @@ process.pTkMET = cms.Path(process.l1tTrackerEtMissExtended) process.pTkMHT = cms.Path(process.l1tTrackerHTMissExtended) process.pTkMHTEmulator = cms.Path(process.l1tTrackerEmuHTMissExtended) + if(runDispVert): + process.DispVert = cms.Path(process.DisplacedVertexProducer) DISPLACED = 'Displaced'# # HYBRID: extended tracking elif (L1TRKALGO == 'HYBRID_PROMPTANDDISP'): process.TTTracksEmu = cms.Path(process.L1TPromptExtendedHybridTracks) process.TTTracksEmuWithTruth = cms.Path(process.L1TPromptExtendedHybridTracksWithAssociators) - process.pL1TrackSelection = cms.Path(process.l1tTrackSelectionProducer * process.l1tTrackSelectionProducerExtended * - process.l1tTrackSelectionProducerForJets * process.l1tTrackSelectionProducerExtendedForJets * - process.l1tTrackSelectionProducerForEtMiss * process.l1tTrackSelectionProducerExtendedForEtMiss) + if(runDispVert): + process.pL1TrackSelection = cms.Path(process.l1tTrackSelectionProducer * process.l1tTrackSelectionProducerExtended * + process.l1tTrackSelectionProducerForJets * process.l1tTrackSelectionProducerExtendedForJets * + process.l1tTrackSelectionProducerForEtMiss * process.l1tTrackSelectionProducerExtendedForEtMiss * + process.l1tTrackSelectionProducerExtendedForDispVert) + else: + process.pL1TrackSelection = cms.Path(process.l1tTrackSelectionProducer * process.l1tTrackSelectionProducerExtended * + process.l1tTrackSelectionProducerForJets * process.l1tTrackSelectionProducerExtendedForJets * + process.l1tTrackSelectionProducerForEtMiss * process.l1tTrackSelectionProducerExtendedForEtMiss) process.pL1TrackVertexAssociation = cms.Path(VertexAssociator * process.l1tTrackVertexAssociationProducerExtended * process.l1tTrackVertexAssociationProducerForJets * process.l1tTrackVertexAssociationProducerExtendedForJets * process.l1tTrackVertexAssociationProducerForEtMiss * process.l1tTrackVertexAssociationProducerExtendedForEtMiss) @@ -191,6 +206,8 @@ process.pTkMHT = cms.Path(process.l1tTrackerHTMiss*process.l1tTrackerHTMissExtended) process.pTkMHTEmulator = cms.Path(process.l1tTrackerEmuHTMiss*process.l1tTrackerEmuHTMissExtended) process.pL1TrackTripletEmulator = cms.Path(process.l1tTrackTripletEmulation) + if(runDispVert): + process.DispVert = cms.Path(process.DisplacedVertexProducer) DISPLACED = 'Both' @@ -281,6 +298,8 @@ GenParticleInputTag = cms.InputTag("genParticles",""), RecoVertexInputTag=cms.InputTag("l1tVertexFinder", "L1Vertices"), RecoVertexEmuInputTag=cms.InputTag("l1tVertexFinderEmulator", "L1VerticesEmulation"), + DisplacedVertexInputTag = cms.InputTag("DisplacedVertexProducer","dispVertices"), + runDispVert = cms.bool(runDispVert) ) process.ntuple = cms.Path(process.L1TrackNtuple) @@ -301,4 +320,7 @@ # use this if cluster/stub associators not available # process.schedule = cms.Schedule(process.TTClusterStubTruth,process.TTTracksEmuWithTruth,process.ntuple) -process.schedule = cms.Schedule(process.TTClusterStub, process.TTClusterStubTruth, process.dtc, process.TTTracksEmuWithTruth, process.pL1GTTInput, process.pL1TrackSelection, process.pPV, process.pPVemu,process.pL1TrackVertexAssociation, process.pL1TrackJets, process.pL1TrackJetsEmu,process.pL1TrackFastJets, process.pTkMET, process.pTkMETEmu, process.pTkMHT, process.pTkMHTEmulator,process.pL1TrackTripletEmulator, process.ntuple) +if(runDispVert): + process.schedule = cms.Schedule(process.TTClusterStub, process.TTClusterStubTruth, process.dtc, process.TTTracksEmuWithTruth, process.pL1GTTInput, process.pL1TrackSelection, process.pPV, process.pPVemu,process.pL1TrackVertexAssociation, process.pL1TrackJets, process.pL1TrackJetsEmu,process.pL1TrackFastJets, process.pTkMET, process.pTkMETEmu, process.pTkMHT, process.pTkMHTEmulator,process.pL1TrackTripletEmulator, process.DispVert, process.ntuple) +else: + process.schedule = cms.Schedule(process.TTClusterStub, process.TTClusterStubTruth, process.dtc, process.TTTracksEmuWithTruth, process.pL1GTTInput, process.pL1TrackSelection, process.pPV, process.pPVemu,process.pL1TrackVertexAssociation, process.pL1TrackJets, process.pL1TrackJetsEmu,process.pL1TrackFastJets, process.pTkMET, process.pTkMETEmu, process.pTkMHT, process.pTkMHTEmulator,process.pL1TrackTripletEmulator,process.ntuple) diff --git a/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc b/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc index 7a4bbe1d3b9d2..016988f7acb50 100644 --- a/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc +++ b/L1Trigger/TrackFindingTracklet/plugins/L1FPGATrackProducer.cc @@ -180,6 +180,7 @@ class L1FPGATrackProducer : public edm::one::EDProducer { bool trackQuality_; std::unique_ptr trackQualityModel_; + std::unique_ptr trackQualityDispModel_; std::map> dtclayerdisk; @@ -321,6 +322,8 @@ L1FPGATrackProducer::L1FPGATrackProducer(edm::ParameterSet const& iConfig) trackQuality_ = iConfig.getParameter("TrackQuality"); if (trackQuality_) { trackQualityModel_ = std::make_unique(iConfig.getParameter("TrackQualityPSet")); + trackQualityDispModel_ = + std::make_unique(iConfig.getParameter("TrackQualityDispPSet")); } if (settings_.storeTrackBuilderOutput() && (settings_.doMultipleMatches() || !settings_.removalType().empty())) { cms::Exception exception("ConfigurationNotSupported."); @@ -742,9 +745,10 @@ void L1FPGATrackProducer::produce(edm::Event& iEvent, const edm::EventSetup& iSe aTrack.setTrackWordBits(); if (trackQuality_) { - trackQualityModel_->setL1TrackQuality(aTrack); + aTrack.settrkMVA1(trackQualityModel_->getL1TrackQuality(aTrack)); + if (extended_) + aTrack.settrkMVA2(trackQualityDispModel_->getL1TrackQuality(aTrack)); } - // hph::HitPatternHelper hph(setupHPH_, tmp_hit, tmp_tanL, tmp_z0); // if (trackQuality_) { // trackQualityModel_->setBonusFeatures(hph.bonusFeatures()); diff --git a/L1Trigger/TrackFindingTracklet/python/Producer_cfi.py b/L1Trigger/TrackFindingTracklet/python/Producer_cfi.py index 5e2128b2ac70a..71c14c20eb954 100644 --- a/L1Trigger/TrackFindingTracklet/python/Producer_cfi.py +++ b/L1Trigger/TrackFindingTracklet/python/Producer_cfi.py @@ -22,6 +22,6 @@ PrintKFDebug = cms.bool ( False ), # print end job internal unused MSB UseTTStubResiduals = cms.bool ( False ), # stub residuals are recalculated from seed parameter and TTStub position TrackQualityPSet = cms.PSet ( TrackQualityParams ), - + TrackQualityDispPSet = cms.PSet ( TrackQualityDispParams ), ) diff --git a/L1Trigger/TrackFindingTracklet/python/l1tTTTracksFromTrackletEmulation_cfi.py b/L1Trigger/TrackFindingTracklet/python/l1tTTTracksFromTrackletEmulation_cfi.py index b870494441670..256f41c2be853 100644 --- a/L1Trigger/TrackFindingTracklet/python/l1tTTTracksFromTrackletEmulation_cfi.py +++ b/L1Trigger/TrackFindingTracklet/python/l1tTTTracksFromTrackletEmulation_cfi.py @@ -23,6 +23,7 @@ # Quality Flag and Quality params TrackQuality = cms.bool(True), TrackQualityPSet = cms.PSet(TrackQualityParams), + TrackQualityDispPSet = cms.PSet(TrackQualityDispParams), Fakefit = cms.bool(False), # True causes Tracklet reco to output TTTracks before DR & KF StoreTrackBuilderOutput = cms.bool(False), # if True EDProducts for TrackBuilder tracks and stubs will be filled RemovalType = cms.string("merge"), # Duplicate track removal @@ -37,6 +38,7 @@ tableTEDFile = cms.FileInPath('L1Trigger/TrackFindingTracklet/data/table_TED/table_TED_D1PHIA1_D2PHIA1.txt'), tableTREFile = cms.FileInPath('L1Trigger/TrackFindingTracklet/data/table_TRE/table_TRE_D1AD2A_1.txt'), # Quality Flag and Quality params - TrackQuality = cms.bool(False), - TrackQualityPSet = cms.PSet(TrackQualityParams) + TrackQuality = cms.bool(True), + TrackQualityPSet = cms.PSet(TrackQualityParams), + TrackQualityDispPSet = cms.PSet(TrackQualityDispParams) ) diff --git a/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker.cc b/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker.cc index 9225b3015a3e9..b2614917d6173 100644 --- a/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker.cc +++ b/L1Trigger/TrackFindingTracklet/test/L1TrackNtupleMaker.cc @@ -186,6 +186,7 @@ class L1TrackNtupleMaker : public one::EDAnalyzer* m_trk_combinatoric; std::vector* m_trk_fake; //0 fake, 1 track from primary interaction, 2 secondary track std::vector* m_trk_MVA1; + std::vector* m_trk_MVA2; std::vector* m_trk_matchtp_pdgid; std::vector* m_trk_matchtp_pt; std::vector* m_trk_matchtp_eta; @@ -229,6 +230,7 @@ class L1TrackNtupleMaker : public one::EDAnalyzer* m_matchtrk_chi2rz_dof; std::vector* m_matchtrk_bendchi2; std::vector* m_matchtrk_MVA1; + std::vector* m_matchtrk_MVA2; std::vector* m_matchtrk_nstub; std::vector* m_matchtrk_lhits; std::vector* m_matchtrk_dhits; @@ -484,6 +486,7 @@ void L1TrackNtupleMaker::beginJob() { m_trk_combinatoric = new std::vector; m_trk_fake = new std::vector; m_trk_MVA1 = new std::vector; + m_trk_MVA2 = new std::vector; m_trk_matchtp_pdgid = new std::vector; m_trk_matchtp_pt = new std::vector; m_trk_matchtp_eta = new std::vector; @@ -525,6 +528,7 @@ void L1TrackNtupleMaker::beginJob() { m_matchtrk_chi2rz_dof = new std::vector; m_matchtrk_bendchi2 = new std::vector; m_matchtrk_MVA1 = new std::vector; + m_matchtrk_MVA2 = new std::vector; m_matchtrk_nstub = new std::vector; m_matchtrk_dhits = new std::vector; m_matchtrk_lhits = new std::vector; @@ -598,6 +602,7 @@ void L1TrackNtupleMaker::beginJob() { eventTree->Branch("trk_combinatoric", &m_trk_combinatoric); eventTree->Branch("trk_fake", &m_trk_fake); eventTree->Branch("trk_MVA1", &m_trk_MVA1); + eventTree->Branch("trk_MVA2", &m_trk_MVA2); eventTree->Branch("trk_matchtp_pdgid", &m_trk_matchtp_pdgid); eventTree->Branch("trk_matchtp_pt", &m_trk_matchtp_pt); eventTree->Branch("trk_matchtp_eta", &m_trk_matchtp_eta); @@ -644,6 +649,7 @@ void L1TrackNtupleMaker::beginJob() { eventTree->Branch("matchtrk_chi2rz_dof", &m_matchtrk_chi2rz_dof); eventTree->Branch("matchtrk_bendchi2", &m_matchtrk_bendchi2); eventTree->Branch("matchtrk_MVA1", &m_matchtrk_MVA1); + eventTree->Branch("matchtrk_MVA2", &m_matchtrk_MVA2); eventTree->Branch("matchtrk_nstub", &m_matchtrk_nstub); eventTree->Branch("matchtrk_lhits", &m_matchtrk_lhits); eventTree->Branch("matchtrk_dhits", &m_matchtrk_dhits); @@ -741,6 +747,7 @@ void L1TrackNtupleMaker::analyze(const edm::Event& iEvent, const edm::EventSetup m_trk_combinatoric->clear(); m_trk_fake->clear(); m_trk_MVA1->clear(); + m_trk_MVA2->clear(); m_trk_matchtp_pdgid->clear(); m_trk_matchtp_pt->clear(); m_trk_matchtp_eta->clear(); @@ -783,6 +790,7 @@ void L1TrackNtupleMaker::analyze(const edm::Event& iEvent, const edm::EventSetup m_matchtrk_chi2rz_dof->clear(); m_matchtrk_bendchi2->clear(); m_matchtrk_MVA1->clear(); + m_matchtrk_MVA2->clear(); m_matchtrk_nstub->clear(); m_matchtrk_lhits->clear(); m_matchtrk_dhits->clear(); @@ -1094,6 +1102,7 @@ void L1TrackNtupleMaker::analyze(const edm::Event& iEvent, const edm::EventSetup float tmp_trk_chi2rz = iterL1Track->chi2Z(); float tmp_trk_bendchi2 = iterL1Track->stubPtConsistency(); float tmp_trk_MVA1 = iterL1Track->trkMVA1(); + float tmp_trk_MVA2 = iterL1Track->trkMVA2(); std::vector >, TTStub > > stubRefs = iterL1Track->getStubRefs(); @@ -1194,6 +1203,7 @@ void L1TrackNtupleMaker::analyze(const edm::Event& iEvent, const edm::EventSetup m_trk_chi2rz_dof->push_back(tmp_trk_chi2rz_dof); m_trk_bendchi2->push_back(tmp_trk_bendchi2); m_trk_MVA1->push_back(tmp_trk_MVA1); + m_trk_MVA2->push_back(tmp_trk_MVA2); m_trk_nstub->push_back(tmp_trk_nstub); m_trk_dhits->push_back(tmp_trk_dhits); m_trk_lhits->push_back(tmp_trk_lhits); @@ -1602,6 +1612,7 @@ void L1TrackNtupleMaker::analyze(const edm::Event& iEvent, const edm::EventSetup float tmp_matchtrk_chi2rz_dof = -999; float tmp_matchtrk_bendchi2 = -999; float tmp_matchtrk_MVA1 = -999; + float tmp_matchtrk_MVA2 = -999; int tmp_matchtrk_nstub = -999; int tmp_matchtrk_dhits = -999; int tmp_matchtrk_lhits = -999; @@ -1628,6 +1639,7 @@ void L1TrackNtupleMaker::analyze(const edm::Event& iEvent, const edm::EventSetup tmp_matchtrk_chi2rz = matchedTracks.at(i_track)->chi2Z(); tmp_matchtrk_bendchi2 = matchedTracks.at(i_track)->stubPtConsistency(); tmp_matchtrk_MVA1 = matchedTracks.at(i_track)->trkMVA1(); + tmp_matchtrk_MVA2 = matchedTracks.at(i_track)->trkMVA2(); tmp_matchtrk_nstub = (int)matchedTracks.at(i_track)->getStubRefs().size(); tmp_matchtrk_seed = (int)matchedTracks.at(i_track)->trackSeedType(); tmp_matchtrk_hitpattern = (int)matchedTracks.at(i_track)->hitPattern(); @@ -1695,6 +1707,7 @@ void L1TrackNtupleMaker::analyze(const edm::Event& iEvent, const edm::EventSetup m_matchtrk_chi2rz->push_back(tmp_matchtrk_chi2rz); m_matchtrk_bendchi2->push_back(tmp_matchtrk_bendchi2); m_matchtrk_MVA1->push_back(tmp_matchtrk_MVA1); + m_matchtrk_MVA2->push_back(tmp_matchtrk_MVA2); m_matchtrk_nstub->push_back(tmp_matchtrk_nstub); m_matchtrk_dhits->push_back(tmp_matchtrk_dhits); m_matchtrk_lhits->push_back(tmp_matchtrk_lhits); diff --git a/L1Trigger/TrackTrigger/interface/L1TrackQuality.h b/L1Trigger/TrackTrigger/interface/L1TrackQuality.h index 1107ed3e74fbb..963c19e8d0785 100644 --- a/L1Trigger/TrackTrigger/interface/L1TrackQuality.h +++ b/L1Trigger/TrackTrigger/interface/L1TrackQuality.h @@ -20,6 +20,7 @@ C.Brown 28/07/20 #include "DataFormats/L1TrackTrigger/interface/TTTrack.h" #include "DataFormats/L1TrackTrigger/interface/TTTrack_TrackWord.h" #include "DataFormats/L1TrackTrigger/interface/TTTypes.h" +#include "PhysicsTools/ONNXRuntime/interface/ONNXRuntime.h" #include #include "conifer.h" @@ -40,13 +41,15 @@ class L1TrackQuality { std::vector const& featureNames); // Passed by reference a track without MVA filled, method fills the track's MVA field - void setL1TrackQuality(TTTrack& aTrack); + double getL1TrackQuality(TTTrack& aTrack); // Function to run the BDT in isolation allowing a feature vector in the ap_fixed datatype to be passed // and a single output to be returned which is then used to fill the bits in the Track Word for situations // where a TTTrack datatype is unavailable to be passed to the track quality float runEmulatedTQ(std::vector> inputFeatures); - void setModel(edm::FileInPath const& model, std::vector const& featureNames); + void setModel(edm::FileInPath const& model, + std::vector const& featureNames, + std::string const& inputName = ""); void setBonusFeatures(std::vector bonusFeatures); @@ -69,5 +72,7 @@ class L1TrackQuality { std::vector featureNames_; bool useHPH_; std::vector bonusFeatures_; + std::string inputName_; + std::unique_ptr runTime_; }; #endif diff --git a/L1Trigger/TrackTrigger/python/TrackQualityParams_cfi.py b/L1Trigger/TrackTrigger/python/TrackQualityParams_cfi.py index e1e8f6cdb5ec2..b15ff405014e2 100644 --- a/L1Trigger/TrackTrigger/python/TrackQualityParams_cfi.py +++ b/L1Trigger/TrackTrigger/python/TrackQualityParams_cfi.py @@ -9,3 +9,16 @@ tqemu_TanlScale = cms.double( 128.0), tqemu_Z0Scale = cms.double( 64.0 ), ) + +TrackQualityDispParams = cms.PSet( + model = cms.FileInPath("L1Trigger/TrackTrigger/data/clf_GBDT_newbin_disp_xgb.onnx"), + ONNXInputName = cms.string("feature_input"), + # The ONNX model should be found at this path, if you want a local version of the model: + # git clone https://github.com/cms-data/L1Trigger-TrackTrigger.git L1Trigger/TrackTrigger/data + #Vector of strings of training features, in the order that the model was trained with + featureNames = cms.vstring(["phi", "eta", "z0", "bendchi2_bin", "nstub", + "nlaymiss_interior", "chi2rphi_bin", "chi2rz_bin", + "d0" ]), + tqemu_TanlScale = cms.double( 128.0), + tqemu_Z0Scale = cms.double( 64.0 ), + ) diff --git a/L1Trigger/TrackTrigger/src/L1TrackQuality.cc b/L1Trigger/TrackTrigger/src/L1TrackQuality.cc index 7296cb385e665..b443050cac965 100644 --- a/L1Trigger/TrackTrigger/src/L1TrackQuality.cc +++ b/L1Trigger/TrackTrigger/src/L1TrackQuality.cc @@ -10,9 +10,19 @@ C.Brown & C.Savard 07/2020 L1TrackQuality::L1TrackQuality() {} L1TrackQuality::L1TrackQuality(const edm::ParameterSet& qualityParams) : useHPH_(false), bonusFeatures_() { - // Unpacks EDM parameter set itself to save unecessary processing within TrackProducers - setModel(qualityParams.getParameter("model"), - qualityParams.getParameter>("featureNames")); + edm::FileInPath modelPath = qualityParams.getParameter("model"); + std::string fullPath = modelPath.fullPath(); + + if (fullPath.substr(fullPath.length() - 4) == "onnx") { + setModel(qualityParams.getParameter("model"), + qualityParams.getParameter>("featureNames"), + qualityParams.getParameter("ONNXInputName")); + runTime_ = std::make_unique(this->model_.fullPath()); + } else { + // Unpacks EDM parameter set itself to save unecessary processing within TrackProducers + setModel(qualityParams.getParameter("model"), + qualityParams.getParameter>("featureNames")); + } } std::vector L1TrackQuality::featureTransform(TTTrack& aTrack, @@ -61,6 +71,7 @@ std::vector L1TrackQuality::featureTransform(TTTrack L1TrackQuality::featureTransform(TTTrack L1TrackQuality::featureTransform(TTTrack& aTrack) { +double L1TrackQuality::getL1TrackQuality(TTTrack& aTrack) { + std::string fullPath = this->model_.fullPath(); + if (fullPath.substr(fullPath.length() - 4) == "onnx") { + // Setup ONNX input and output names and arrays + std::vector ortinput_names; + std::vector ortoutput_names; + + cms::Ort::FloatArrays ortinput; + cms::Ort::FloatArrays ortoutputs; + + std::vector Transformed_features = featureTransform(aTrack, this->featureNames_); + + ortinput_names.push_back(this->inputName_); + ortoutput_names = runTime_->getOutputNames(); + + //ONNX runtime recieves a vector of vectors of floats so push back the input + // vector of float to create a 1,1,21 ortinput + ortinput.push_back(Transformed_features); + + // batch_size 1 as only one set of transformed features is being processed + int batch_size = 1; + // Run classification + ortoutputs = runTime_->run(ortinput_names, ortinput, {}, ortoutput_names, batch_size); + return ortoutputs[1][1]; + } + // load in bdt conifer::BDT bdt(this->model_.fullPath()); // collect features and classify using bdt std::vector inputs = featureTransform(aTrack, this->featureNames_); std::vector output = bdt.decision_function(inputs); - aTrack.settrkMVA1(1. / (1. + exp(-output.at(0)))); + return (1. / (1. + exp(-output.at(0)))); } float L1TrackQuality::runEmulatedTQ(std::vector> inputFeatures) { @@ -103,10 +140,13 @@ float L1TrackQuality::runEmulatedTQ(std::vector> inputFeatures) return output.at(0).to_float(); // need logistic sigmoid fcn applied to xgb output } -void L1TrackQuality::setModel(edm::FileInPath const& model, std::vector const& featureNames) { +void L1TrackQuality::setModel(edm::FileInPath const& model, + std::vector const& featureNames, + std::string const& inputName) { //Convert algorithm string to Enum class for track by track comparison model_ = model; featureNames_ = featureNames; + inputName_ = inputName; } void L1TrackQuality::setBonusFeatures(std::vector bonusFeatures) {