102 theTrackerGeometry = tGeometryHandle.
product();
105 std::vector<float> TTStubs_x;
106 std::vector<float> TTStubs_y;
107 std::vector<float> TTStubs_z;
108 std::vector<float> TTStubs_r;
109 std::vector<float> TTStubs_eta;
110 std::vector<float> TTStubs_phi;
111 std::vector<int> TTStubs_tpId;
117 std::vector<float> v_tp_pt;
118 std::vector<float> v_tp_eta;
119 std::vector<float> v_tp_phi;
120 std::vector<float> v_tp_nLayers;
127 for (inputIter = TTStubHandle->begin(); inputIter != TTStubHandle->end(); ++inputIter) {
128 for (contentIter = inputIter->
begin(); contentIter != inputIter->
end(); ++contentIter) {
132 DetId detIdStub = theTrackerGeometry->
idToDet((tempStubRef->getClusterRef(0))->getDetId())->geographicalId();
133 const MeasurementPoint &mp = (tempStubRef->getClusterRef(0))->findAverageLocalCoordinates();
134 const GeomDet *theGeomDet = theTrackerGeometry->
idToDet(detIdStub);
140 float stubs_x = posStub.
x();
141 float stubs_y = posStub.
y();
142 float stubs_z = posStub.
z();
143 float stubs_r = posStub.
perp();
144 float stubs_eta = posStub.
eta();
145 float stubs_phi = posStub.
phi();
146 TTStubs_x.push_back(stubs_x);
147 TTStubs_y.push_back(stubs_y);
148 TTStubs_z.push_back(stubs_z);
149 TTStubs_r.push_back(stubs_r);
150 TTStubs_eta.push_back(stubs_eta);
151 TTStubs_phi.push_back(stubs_phi);
154 TTStubs_tpId.push_back(-1);
157 bool genuineStub =
false;
158 if (MCTruthTTStubHandle.
isValid()) {
159 genuineStub = MCTruthTTStubHandle->isGenuine(tempStubPtr);
167 float px = tpPtr->
p4().px();
168 float py = tpPtr->
p4().py();
169 float pz = tpPtr->
p4().pz();
173 for (
auto it : *trackingParticleHandle) {
175 float allowedRes = 0.001;
176 if (std::fabs(it.vx() -
x) > allowedRes)
178 if (std::fabs(it.vy() -
y) > allowedRes)
180 if (std::fabs(it.vz() -
z) > allowedRes)
182 if (std::fabs(it.px() - px) > allowedRes)
184 if (std::fabs(it.py() - py) > allowedRes)
186 if (std::fabs(it.pz() - pz) > allowedRes)
191 TTStubs_tpId.back() =
idx;
201 std::vector<TpStruct> TPStructs;
202 for (
unsigned j = 0; j < TTStubs_tpId.size(); j++) {
203 const int ID = TTStubs_tpId[j];
208 for (
auto thisStruct : TPStructs) {
210 if (ID == thisStruct.TpId) {
220 int totalLayers = 11;
221 std::vector<bool> layerElement(totalLayers,
false);
222 thisTPStruct.
layer = layerElement;
223 TPStructs.push_back(thisTPStruct);
224 pos = TPStructs.size() - 1;
226 int l =
Layer(TTStubs_r[j],
230 TPStructs[pos].layer[
l] =
true;
235 for (
auto iterTP1 : *trackingParticleHandle) {
236 v_tp_pt.push_back(iterTP1.pt());
237 v_tp_eta.push_back(iterTP1.eta());
238 v_tp_phi.push_back(iterTP1.phi());
239 v_tp_nLayers.push_back(-1);
245 for (
auto thisStruct : TPStructs) {
246 int id = thisStruct.TpId;
247 v_tp_nLayers.at(
id - 1) = thisStruct.Nlayers();
251 for (
unsigned j = 0; j < v_tp_eta.size(); j++) {
252 double trkParts_eta = v_tp_eta[j];
253 double trkParts_pt = v_tp_pt[j];
254 double trkParts_phi = v_tp_phi[j];
255 double trkParts_nLayers = v_tp_nLayers[j];
259 if (std::fabs(trkParts_eta) < 2.4 && trkParts_pt > 2 && trkParts_nLayers >= 4) {
268 std::vector<float> trkParts_eta;
269 std::vector<float> trkParts_phi;
270 std::vector<float> trkParts_pt;
271 std::vector<float> trkParts_VtxZ;
272 std::vector<float> trkParts_d0;
273 std::vector<float> trkParts_VtxR;
274 std::vector<int> trkParts_pdgId;
275 std::vector<int> trkParts_nMatch;
276 std::vector<int> trkParts_nStub;
277 std::vector<int> trkParts_eventId;
278 std::vector<float> matchTrk_pt;
279 std::vector<float> matchTrk_eta;
280 std::vector<float> matchTrk_phi;
281 std::vector<float> matchTrk_VtxZ;
282 std::vector<float> matchTrk_d0;
283 std::vector<float> matchTrk_chi2;
284 std::vector<int> matchTrk_nStub;
293 for (
auto iterTP : *trackingParticleHandle) {
297 int tmp_eventid = iterTP.eventId().event();
298 float tmp_tp_pt = iterTP.pt();
299 float tmp_tp_phi = iterTP.phi();
300 float tmp_tp_eta = iterTP.eta();
301 float tmp_tp_vz = iterTP.vz();
302 float tmp_tp_vx = iterTP.vx();
303 float tmp_tp_vy = iterTP.vy();
304 float tmp_tp_charge = tp_ptr->
charge();
305 int tmp_tp_pdgid = iterTP.pdgId();
310 float tmp_tp_t =
tan(2.0 * atan(1.0) - 2.0 * atan(
exp(-tmp_tp_eta)));
311 float delx = -tmp_tp_vx;
312 float dely = -tmp_tp_vy;
313 float K = 0.01 * 0.5696 / tmp_tp_pt * tmp_tp_charge;
314 float A = 1. / (2. * K);
315 float tmp_tp_x0p = delx - A *
sin(tmp_tp_phi);
316 float tmp_tp_y0p = dely + A *
cos(tmp_tp_phi);
317 float tmp_tp_rp =
sqrt(tmp_tp_x0p * tmp_tp_x0p + tmp_tp_y0p * tmp_tp_y0p);
318 static double pi = 4.0 * atan(1.0);
319 float delphi = tmp_tp_phi - atan2(-K * tmp_tp_x0p, K * tmp_tp_y0p);
325 float tmp_tp_VtxZ = tmp_tp_vz + tmp_tp_t * delphi / (2.0 * K);
326 float VtxR =
sqrt(tmp_tp_vx * tmp_tp_vx + tmp_tp_vy * tmp_tp_vy);
327 float tmp_tp_VtxR = VtxR;
328 float tmp_tp_d0 = tmp_tp_charge * tmp_tp_rp - (1. / (2. * K));
332 float other_d0 = -tmp_tp_vx *
sin(tmp_tp_phi) + tmp_tp_vy *
cos(tmp_tp_phi);
333 tmp_tp_d0 = tmp_tp_d0 * (-1);
335 tmp_tp_d0 = other_d0;
336 tmp_tp_VtxZ = tmp_tp_vz;
339 if (MCTruthTTStubHandle.
isValid()) {
341 theStubRefs = MCTruthTTStubHandle->findTTStubRefs(tp_ptr);
342 nStubTP = (
int)theStubRefs.size();
357 if (MCTruthTTClusterHandle.
isValid()) {
358 if (MCTruthTTClusterHandle->findTTClusterRefs(tp_ptr).empty())
365 if (tmp_tp_pt > 0 && tmp_tp_pt <= 10)
379 if (!MCTruthTTTrackHandle.
isValid())
381 std::vector<edm::Ptr<TTTrack<Ref_Phase2TrackerDigi_>>> matchedTracks =
382 MCTruthTTTrackHandle->findTTTrackPtrs(tp_ptr);
386 float i_chi2dof = 99999;
394 for (
auto thisTrack : matchedTracks) {
395 bool tmp_trk_genuine =
false;
396 if (MCTruthTTTrackHandle->isGenuine(thisTrack))
397 tmp_trk_genuine =
true;
398 if (!tmp_trk_genuine)
404 int tmp_trk_nstub = thisTrack->getStubRefs().size();
407 float dmatch_pt = 999;
408 float dmatch_eta = 999;
409 float dmatch_phi = 999;
413 dmatch_pt = std::fabs(my_tp->
p4().pt() - tmp_tp_pt);
414 dmatch_eta = std::fabs(my_tp->
p4().eta() - tmp_tp_eta);
415 dmatch_phi = std::fabs(my_tp->
p4().phi() - tmp_tp_phi);
416 match_id = my_tp->
pdgId();
417 float tmp_trk_chi2dof = (thisTrack->getChi2(
L1Tk_nPar)) / (2 * tmp_trk_nstub -
L1Tk_nPar);
420 if (dmatch_pt < 0.1 && dmatch_eta < 0.1 && dmatch_phi < 0.1 && tmp_tp_pdgid == match_id) {
422 if (i_track < 0 || tmp_trk_chi2dof < i_chi2dof) {
423 i_track = trkCounter;
424 i_chi2dof = tmp_trk_chi2dof;
432 float tmp_matchtrk_pt = -999;
433 float tmp_matchtrk_eta = -999;
434 float tmp_matchtrk_phi = -999;
435 float tmp_matchtrk_VtxZ = -999;
436 float tmp_matchtrk_chi2 = -999;
437 float tmp_matchtrk_chi2R = -999;
438 int tmp_matchTrk_nStub = -999;
439 float tmp_matchtrk_d0 = -999;
442 tmp_matchtrk_pt = matchedTracks[i_track]->getMomentum(
L1Tk_nPar).perp();
443 tmp_matchtrk_eta = matchedTracks[i_track]->getMomentum(
L1Tk_nPar).eta();
444 tmp_matchtrk_phi = matchedTracks[i_track]->getMomentum(
L1Tk_nPar).phi();
445 tmp_matchtrk_VtxZ = matchedTracks[i_track]->getPOCA(
L1Tk_nPar).z();
446 tmp_matchtrk_chi2 = matchedTracks[i_track]->getChi2(
L1Tk_nPar);
447 tmp_matchtrk_chi2R = matchedTracks[i_track]->getChi2Red(
L1Tk_nPar);
448 tmp_matchTrk_nStub = (
int)matchedTracks[i_track]->getStubRefs().size();
454 float tmp_matchtrk_x0 = matchedTracks[i_track]->getPOCA(
L1Tk_nPar).x();
455 float tmp_matchtrk_y0 = matchedTracks[i_track]->getPOCA(
L1Tk_nPar).y();
456 tmp_matchtrk_d0 = -tmp_matchtrk_x0 *
sin(tmp_matchtrk_phi) + tmp_matchtrk_y0 *
cos(tmp_matchtrk_phi);
459 trkParts_pt.push_back(tmp_tp_pt);
460 trkParts_eta.push_back(tmp_tp_eta);
461 trkParts_phi.push_back(tmp_tp_phi);
462 trkParts_d0.push_back(tmp_tp_d0);
463 trkParts_VtxZ.push_back(tmp_tp_VtxZ);
465 trkParts_pdgId.push_back(tmp_tp_pdgid);
466 trkParts_VtxR.push_back(tmp_tp_VtxR);
467 trkParts_nMatch.push_back(nMatch);
468 trkParts_nStub.push_back(nStubTP);
469 trkParts_eventId.push_back(tmp_eventid);
471 matchTrk_pt.push_back(tmp_matchtrk_pt);
472 matchTrk_eta.push_back(tmp_matchtrk_eta);
473 matchTrk_phi.push_back(tmp_matchtrk_phi);
474 matchTrk_VtxZ.push_back(tmp_matchtrk_VtxZ);
475 matchTrk_d0.push_back(tmp_matchtrk_d0);
477 matchTrk_chi2.push_back(tmp_matchtrk_chi2);
478 matchTrk_nStub.push_back(tmp_matchTrk_nStub);
481 for (
unsigned j = 0; j < trkParts_eta.size(); j++) {
482 float eta = trkParts_eta[j];
483 float pt = trkParts_pt[j];
484 float VtxR = trkParts_VtxR[j];
485 float d0 = trkParts_d0[j];
486 float VtxZ = trkParts_VtxZ[j];
487 float eventId = trkParts_eventId[j];
501 if (trkParts_nMatch[j] < 1)
507 float chi2 = matchTrk_chi2[j];
508 int ndof = 2 * matchTrk_nStub[j] - 4;
509 float chi2dof = (
float)chi2 / ndof;
518 if (pt > 0 && pt <= 10)
528 res_pt->
Fill(matchTrk_pt[j] - trkParts_pt[j]);
529 res_ptRel->
Fill((matchTrk_pt[j] - trkParts_pt[j]) / trkParts_pt[j]);
533 float pt_res = (matchTrk_pt[j] - trkParts_pt[j]) / trkParts_pt[j];
534 float eta_res = matchTrk_eta[j] - trkParts_eta[j];
535 float phi_res = matchTrk_phi[j] - trkParts_phi[j];
536 float VtxZ_res = matchTrk_VtxZ[j] - trkParts_VtxZ[j];
537 float d0_res = matchTrk_d0[j] - trkParts_d0[j];
539 float tP_eta = trkParts_eta[j];
540 float tP_pt = trkParts_pt[j];
544 if (std::fabs(tP_eta) >= 0 && std::fabs(tP_eta) < 0.7) {
549 if (tP_pt >= 2 && tP_pt < 3)
551 else if (tP_pt >= 3 && tP_pt < 8)
555 }
else if (std::fabs(tP_eta) >= 0.7 && std::fabs(tP_eta) < 1.0) {
560 if (tP_pt >= 2 && tP_pt < 3)
562 else if (tP_pt >= 3 && tP_pt < 8)
566 }
else if (std::fabs(tP_eta) >= 1.0 && std::fabs(tP_eta) < 1.2) {
571 if (tP_pt >= 2 && tP_pt < 3)
573 else if (tP_pt >= 3 && tP_pt < 8)
577 }
else if (std::fabs(tP_eta) >= 1.2 && std::fabs(tP_eta) < 1.6) {
582 if (tP_pt >= 2 && tP_pt < 3)
584 else if (tP_pt >= 3 && tP_pt < 8)
588 }
else if (std::fabs(tP_eta) >= 1.6 && std::fabs(tP_eta) < 2.0) {
593 if (tP_pt >= 2 && tP_pt < 3)
595 else if (tP_pt >= 3 && tP_pt < 8)
599 }
else if (std::fabs(tP_eta) >= 2.0 && std::fabs(tP_eta) <= 2.4) {
604 if (tP_pt >= 2 && tP_pt < 3)
606 else if (tP_pt >= 3 && tP_pt < 8)
620 TTStubs_tpId.clear();
624 v_tp_nLayers.clear();
626 trkParts_eta.clear();
627 trkParts_phi.clear();
629 trkParts_VtxZ.clear();
630 trkParts_VtxR.clear();
631 trkParts_pdgId.clear();
632 trkParts_nMatch.clear();
633 trkParts_nStub.clear();
634 trkParts_eventId.clear();
636 matchTrk_eta.clear();
637 matchTrk_phi.clear();
639 matchTrk_VtxZ.clear();
640 matchTrk_chi2.clear();
641 matchTrk_nStub.clear();
655 HistoName =
"trackParts_Pt";
666 HistoName =
"trackParts_Eta";
677 HistoName =
"trackParts_Phi";
690 HistoName =
"Track_MatchedChi2";
701 HistoName =
"Track_MatchedChi2Red";
724 HistoName =
"match_tp_pt";
735 HistoName =
"tp_pt_zoom";
745 HistoName =
"match_tp_pt_zoom";
756 HistoName =
"tp_eta";
766 HistoName =
"match_tp_eta";
787 HistoName =
"match_tp_d0";
798 HistoName =
"tp_VtxR";
808 HistoName =
"match_tp_VtxR";
819 HistoName =
"tp_VtxZ";
829 HistoName =
"match_tp_VtxZ";
842 HistoName =
"res_pt";
853 HistoName =
"res_eta";
864 HistoName =
"res_ptRel";
875 HistoName =
"reseta_eta0to0p7";
885 HistoName =
"reseta_eta0p7to1";
895 HistoName =
"reseta_eta1to1p2";
905 HistoName =
"reseta_eta1p2to1p6";
915 HistoName =
"reseta_eta1p6to2";
925 HistoName =
"reseta_eta2to2p4";
937 HistoName =
"respt_eta0to0p7_pt2to3";
947 HistoName =
"respt_eta0p7to1_pt2to3";
957 HistoName =
"respt_eta1to1p2_pt2to3";
967 HistoName =
"respt_eta1p2to1p6_pt2to3";
977 HistoName =
"respt_eta1p6to2_pt2to3";
987 HistoName =
"respt_eta2to2p4_pt2to3";
998 HistoName =
"respt_eta0to0p7_pt3to8";
1008 HistoName =
"respt_eta0p7to1_pt3to8";
1018 HistoName =
"respt_eta1to1p2_pt3to8";
1028 HistoName =
"respt_eta1p2to1p6_pt3to8";
1038 HistoName =
"respt_eta1p6to2_pt3to8";
1048 HistoName =
"respt_eta2to2p4_pt3to8";
1059 HistoName =
"respt_eta0to0p7_pt8toInf";
1069 HistoName =
"respt_eta0p7to1_pt8toInf";
1079 HistoName =
"respt_eta1to1p2_pt8toInf";
1089 HistoName =
"respt_eta1p2to1p6_pt8toInf";
1099 HistoName =
"respt_eta1p6to2_pt8toInf";
1109 HistoName =
"respt_eta2to2p4_pt8toInf";
1121 HistoName =
"resphi_eta0to0p7";
1131 HistoName =
"resphi_eta0p7to1";
1141 HistoName =
"resphi_eta1to1p2";
1151 HistoName =
"resphi_eta1p2to1p6";
1161 HistoName =
"resphi_eta1p6to2";
1171 HistoName =
"resphi_eta2to2p4";
1183 HistoName =
"resVtxZ_eta0to0p7";
1193 HistoName =
"resVtxZ_eta0p7to1";
1203 HistoName =
"resVtxZ_eta1to1p2";
1213 HistoName =
"resVtxZ_eta1p2to1p6";
1223 HistoName =
"resVtxZ_eta1p6to2";
1233 HistoName =
"resVtxZ_eta2to2p4";
1245 HistoName =
"resd0_eta0to0p7";
1255 HistoName =
"resd0_eta0p7to1";
1265 HistoName =
"resd0_eta1to1p2";
1275 HistoName =
"resd0_eta1p2to1p6";
1285 HistoName =
"resd0_eta1p6to2";
1295 HistoName =
"resd0_eta2to2p4";
1308 const int sectionNum = 6;
1309 const float Rmin[sectionNum] = {20., 33., 48., 65., 82., 105.};
1310 const float Rmax[sectionNum] = {30., 40., 58., 75., 91., 120.};
1311 const float zMin[sectionNum] = {0., 125., 145., 165., 200., 240.};
1313 for (
int i = 5;
i >= 0; --
i) {
1314 if (std::fabs(Z_) >= zMin[
i]) {
1320 for (
unsigned i = 0;
i < unsigned(sectionNum); ++
i) {
1321 if (R_ > Rmin[
i] && R_ < Rmax[
i]) {
const LorentzVector & p4() const
Four-momentum Lorentz vector. Note this is taken from the first SimTrack only.
MonitorElement * resd0_eta1to1p2
MonitorElement * match_tp_d0
GlobalPoint toGlobal(const Point2DBase< Scalar, LocalTag > lp) const
T getParameter(std::string const &) const
edm::Ref< typename HandleT::element_type, typename HandleT::element_type::value_type::value_type > makeRefTo(const HandleT &iHandle, typename HandleT::element_type::value_type::const_iterator itIter)
MonitorElement * match_tp_VtxR
MonitorElement * respt_eta2to2p4_pt8toInf
const_iterator end(bool update=false) const
MonitorElement * Track_MatchedChi2
MonitorElement * resVtxZ_eta1to1p2
void bookHistograms(DQMStore::IBooker &, edm::Run const &, edm::EventSetup const &) override
MonitorElement * resVtxZ_eta1p6to2
std::vector< TrackingParticle > TrackingParticleCollection
MonitorElement * trackParts_Phi
bool getByToken(EDGetToken token, Handle< PROD > &result) const
MonitorElement * match_tp_pt
virtual const Topology & topology() const
MonitorElement * trackParts_Pt
std::vector< bool > layer
int pdgId() const
PDG ID.
Sin< T >::type sin(const T &t)
MonitorElement * respt_eta1p6to2_pt3to8
Geom::Phi< T > phi() const
MonitorElement * match_tp_eta
MonitorElement * reseta_eta1p6to2
~OuterTrackerMonitorTrackingParticles() override
MonitorElement * resd0_eta1p6to2
int Layer(const float R_, const float Z_) const
edm::EDGetTokenT< std::vector< TTTrack< Ref_Phase2TrackerDigi_ > > > ttTrackToken_
const Plane & surface() const
The nominal surface of the GeomDet.
MonitorElement * reseta_eta1to1p2
edm::EDGetTokenT< std::vector< TrackingParticle > > trackingParticleToken_
MonitorElement * match_tp_VtxZ
MonitorElement * tp_pt_zoom
MonitorElement * respt_eta0to0p7_pt3to8
float charge() const
Electric charge. Note this is taken from the first SimTrack only.
#define DEFINE_FWK_MODULE(type)
MonitorElement * resphi_eta0to0p7
void setCurrentFolder(std::string const &fullpath)
MonitorElement * reseta_eta2to2p4
edm::EDGetTokenT< TTTrackAssociationMap< Ref_Phase2TrackerDigi_ > > ttTrackMCTruthToken_
MonitorElement * respt_eta1to1p2_pt3to8
MonitorElement * respt_eta1to1p2_pt8toInf
Cos< T >::type cos(const T &t)
MonitorElement * resd0_eta1p2to1p6
MonitorElement * book1D(Args &&...args)
Tan< T >::type tan(const T &t)
MonitorElement * respt_eta1p2to1p6_pt2to3
edm::EDGetTokenT< TTClusterAssociationMap< Ref_Phase2TrackerDigi_ > > ttClusterMCTruthToken_
MonitorElement * reseta_eta1p2to1p6
MonitorElement * resphi_eta0p7to1
MonitorElement * respt_eta0p7to1_pt8toInf
MonitorElement * resd0_eta2to2p4
MonitorElement * resVtxZ_eta0p7to1
MonitorElement * resphi_eta2to2p4
Class to store the L1 Track Trigger stubs.
MonitorElement * match_tp_pt_zoom
MonitorElement * resVtxZ_eta2to2p4
MonitorElement * respt_eta0p7to1_pt3to8
MonitorElement * respt_eta2to2p4_pt2to3
MonitorElement * resVtxZ_eta0to0p7
edm::EDGetTokenT< TTStubAssociationMap< Ref_Phase2TrackerDigi_ > > ttStubMCTruthToken_
bool isNonnull() const
Checks for non-null.
MonitorElement * respt_eta1p2to1p6_pt8toInf
MonitorElement * respt_eta1p6to2_pt2to3
MonitorElement * resphi_eta1p2to1p6
MonitorElement * reseta_eta0to0p7
MonitorElement * respt_eta0p7to1_pt2to3
MonitorElement * reseta_eta0p7to1
MonitorElement * resVtxZ_eta1p2to1p6
virtual LocalPoint localPosition(const MeasurementPoint &) const =0
std::string topFolderName_
MonitorElement * Track_MatchedChi2Red
void analyze(const edm::Event &, const edm::EventSetup &) override
Point vertex() const
Parent vertex position.
edm::EDGetTokenT< edmNew::DetSetVector< TTStub< Ref_Phase2TrackerDigi_ > > > ttStubToken_
static std::atomic< unsigned int > counter
const TrackerGeomDet * idToDet(DetId) const override
MonitorElement * respt_eta0to0p7_pt2to3
MonitorElement * respt_eta1p6to2_pt8toInf
MonitorElement * respt_eta2to2p4_pt3to8
const double Rmax[kNumberCalorimeter]
MonitorElement * resd0_eta0p7to1
MonitorElement * respt_eta1to1p2_pt2to3
OuterTrackerMonitorTrackingParticles(const edm::ParameterSet &)
MonitorElement * resphi_eta1to1p2
void setAxisTitle(const std::string &title, int axis=1)
set x-, y- or z-axis title (axis=1, 2, 3 respectively)
T const * product() const
const double Rmin[kNumberCalorimeter]
const_iterator begin(bool update=false) const
MonitorElement * respt_eta1p2to1p6_pt3to8
MonitorElement * resphi_eta1p6to2
MonitorElement * respt_eta0to0p7_pt8toInf
MonitorElement * res_ptRel
MonitorElement * trackParts_Eta
MonitorElement * resd0_eta0to0p7