123 return (
b.x() >
a.x());
126 return (
b.y() >
a.y());
128 return (
a.z() >
b.z());
204 readMoreMcTruth_(iConfig.getParameter<
bool>(
"readMoreMcTruth")),
221 produces<std::vector<TTTrack<Ref_Phase2TrackerDigi_>>>(
"Level1TTTracks").setBranchAlias(
"Level1TTTracks");
239 esGetToken_ = esConsumes<trackerDTC::Setup, trackerDTC::SetupRcd, edm::Transition::BeginRun>();
323 auto L1TkTracksForOutput = std::make_unique<std::vector<TTTrack<Ref_Phase2TrackerDigi_>>>();
336 ev.setIP(bsPosition.x(), bsPosition.y());
353 map<edm::Ptr<TrackingParticle>,
int> translateTP;
366 for (
const auto& iterTP : *TrackingParticleHandle) {
371 if (MCTruthTTClusterHandle->findTTClusterRefs(tp_ptr).empty())
374 if (iterTP.g4Tracks().empty()) {
378 int sim_eventid = iterTP.g4Tracks().at(0).eventId().event();
379 int sim_type = iterTP.pdgId();
380 float sim_pt = iterTP.pt();
381 float sim_eta = iterTP.eta();
382 float sim_phi = iterTP.phi();
384 float vx = iterTP.vertex().x();
385 float vy = iterTP.vertex().y();
386 float vz = iterTP.vertex().z();
388 if (sim_pt < 1.0 ||
std::abs(vz) > 100.0 || hypot(vx, vy) > 50.0)
391 ev.addL1SimTrack(sim_eventid, ntps, sim_type, sim_pt, sim_eta, sim_phi, vx, vy, vz);
393 translateTP[tp_ptr] = ntps;
406 for (
const int& channel : handleDTC->
tfpChannels()) {
409 static string dtcbasenames[12] = {
410 "PS10G_1",
"PS10G_2",
"PS10G_3",
"PS10G_4",
"PS_1",
"PS_2",
"2S_1",
"2S_2",
"2S_3",
"2S_4",
"2S_5",
"2S_6"};
412 string dtcname = dtcbasenames[channel % 12];
414 if (channel % 24 >= 12)
415 dtcname =
"neg" + dtcname;
417 dtcname += (channel < 24) ?
"_A" :
"_B";
423 for (
size_t stubIndex = 0; stubIndex < streamFromDTC.size(); ++stubIndex) {
426 if (stub.first.isNull()) {
433 string layerword = stub.second.to_string().substr(61, 2);
434 unsigned int layercode = 2 * (layerword[0] -
'0') + layerword[1] -
'0';
439 static int layerdisktab[12][4] = {{0, 6, 8, 10},
452 int layerdisk = layerdisktab[channel % 12][layercode];
456 constexpr
int DTCLinkWordSize = 64;
457 constexpr
int StubWordSize = 36;
458 constexpr
int LayerandStatusCodeSize = 3;
460 stub.second.to_string().substr(DTCLinkWordSize - StubWordSize - LayerandStatusCodeSize, StubWordSize);
461 string stubwordhex =
"";
464 for (
unsigned int i = 0;
i < 9;
i++) {
465 bitset<4> bits(stubword.substr(
i * 4, 4));
466 ulong
val = bits.to_ulong();
467 stubwordhex += ((
val < 10) ? (
'0' +
val) : (
'A' +
val - 10));
472 innerCluster = stub.first->clusterRef(0);
474 outerCluster = stub.first->clusterRef(1);
480 const DetId innerDetId = innerCluster->getDetId();
482 const auto* theGeomDet_inner = dynamic_cast<const PixelGeomDetUnit*>(det_inner);
483 const PixelTopology* topol_inner = dynamic_cast<const PixelTopology*>(&(theGeomDet_inner->specificTopology()));
485 MeasurementPoint coords_inner = innerCluster->findAverageLocalCoordinatesCentered();
487 GlobalPoint posStub_inner = theGeomDet_inner->surface().toGlobal(clustlp_inner);
489 const DetId outerDetId = outerCluster->getDetId();
491 const auto* theGeomDet_outer = dynamic_cast<const PixelGeomDetUnit*>(det_outer);
492 const PixelTopology* topol_outer = dynamic_cast<const PixelTopology*>(&(theGeomDet_outer->specificTopology()));
494 MeasurementPoint coords_outer = outerCluster->findAverageLocalCoordinatesCentered();
496 GlobalPoint posStub_outer = theGeomDet_outer->surface().toGlobal(clustlp_outer);
498 bool isFlipped = (posStub_outer.
mag() < posStub_inner.
mag());
500 vector<int> assocTPs;
502 for (
unsigned int iClus = 0; iClus <= 1; iClus++) {
504 const TTClusterRef& ttClusterRef = stub.first->clusterRef(iClus);
507 vector<edm::Ptr<TrackingParticle>> vecTpPtr = MCTruthTTClusterHandle->findTrackingParticlePtrs(ttClusterRef);
510 if (translateTP.find(tpPtr) != translateTP.end()) {
512 assocTPs.push_back(translateTP.at(tpPtr));
514 assocTPs.push_back(-translateTP.at(tpPtr));
518 assocTPs.push_back(0);
523 double stubbend = stub.first->bendFE();
524 if (ttPos.
z() < -120) {
525 stubbend = -stubbend;
538 stub.first->innerClusterPosition(),
542 stubMap[lastStub] = stub.first;
562 if (
track.duplicate())
573 double tmp_chi2rphi =
track.chisqrphi();
574 double tmp_chi2rz =
track.chisqrz();
575 unsigned int tmp_hit =
track.hitpattern();
591 unsigned int trksector =
track.sector();
592 unsigned int trkseed = (
unsigned int)
abs(
track.seed());
594 aTrack.setPhiSector(trksector);
595 aTrack.setTrackSeedType(trkseed);
597 const vector<trklet::L1TStub>& stubptrs =
track.stubs();
598 vector<trklet::L1TStub> stubs;
600 stubs.reserve(stubptrs.size());
601 for (
const auto& stubptr : stubptrs) {
602 stubs.push_back(stubptr);
605 stubMapType::const_iterator it;
606 for (
const auto& itstubs : stubs) {
607 it = stubMap.find(itstubs);
608 if (it != stubMap.end()) {
609 aTrack.addStubRef(it->second);
616 aTrack.setStubPtConsistency(
620 aTrack.setTrackWordBits();
629 L1TkTracksForOutput->push_back(aTrack);