Producer: process every event and generates trigger data.
304 LogDebug(
"DTTrigPhase2Prod") <<
"produce";
309 LogDebug(
"DTTrigPhase2Prod") <<
"\t Getting the RPC RecHits" << std::endl;
319 for (
const auto& detUnitIt : *dtdigis) {
320 const DTLayerId& layId = detUnitIt.first;
323 digiMap[chambId].put(
range, layId);
328 LogDebug(
"DTTrigPhase2Prod") <<
"produce - Getting and grouping digis per chamber using a buffer and super cells.";
330 LogDebug(
"DTTrigPhase2Prod") <<
"produce - Getting and grouping digis per chamber.";
332 std::map<int, MuonPathPtrs> muonpaths;
339 if (dmit == digiMap.end())
344 std::vector<std::pair<DTLayerId, DTDigi>> tmpvec;
347 for (
const auto& dtLayerIdIt : (*dmit).second) {
349 digiIt != (dtLayerIdIt.second).second;
351 tmpvec.emplace_back(dtLayerIdIt.first, *digiIt);
360 std::sort(tmpvec.begin(), tmpvec.end(), DigiTimeOrdering);
361 std::queue<std::pair<DTLayerId, DTDigi>> timequeue;
363 for (
const auto& elem : tmpvec)
364 timequeue.emplace(elem);
368 std::vector<DTDigiCollection*> superCells;
374 while (!superCells.empty()) {
376 superCells.pop_back();
385 for (
auto& ch_muonpaths : muonpaths) {
386 for (
unsigned int i = 0;
i < ch_muonpaths.second.size();
i++) {
388 ss <<
iEvent.id().event() <<
" mpath " <<
i <<
": ";
389 for (
int lay = 0; lay < ch_muonpaths.second.at(
i)->nprimitives(); lay++)
390 ss << ch_muonpaths.second.at(
i)->primitive(lay)->channelId() <<
" ";
391 for (
int lay = 0; lay < ch_muonpaths.second.at(
i)->nprimitives(); lay++)
392 ss << ch_muonpaths.second.at(
i)->primitive(lay)->tdcTimeStamp() <<
" ";
393 for (
int lay = 0; lay < ch_muonpaths.second.at(
i)->nprimitives(); lay++)
394 ss << ch_muonpaths.second.at(
i)->primitive(lay)->laterality() <<
" ";
400 std::map<int, std::vector<lat_vector>> lateralities;
402 for (
auto& ch_muonpaths : muonpaths) {
404 latprovider_->run(
iEvent, iEventSetup, ch_muonpaths.second, lateralities[ch_muonpaths.first]);
410 std::map<int, MuonPathPtrs> filteredmuonpaths;
411 for (
auto& ch_muonpaths : muonpaths) {
420 for (
auto& ch_filteredmuonpaths : filteredmuonpaths) {
421 for (
unsigned int i = 0;
i < ch_filteredmuonpaths.second.size();
i++) {
423 ss <<
iEvent.id().event() <<
" filt. mpath " <<
i <<
": ";
424 for (
int lay = 0; lay < ch_filteredmuonpaths.second.at(
i)->nprimitives(); lay++)
425 ss << ch_filteredmuonpaths.second.at(
i)->primitive(lay)->channelId() <<
" ";
426 for (
int lay = 0; lay < ch_filteredmuonpaths.second.at(
i)->nprimitives(); lay++)
427 ss << ch_filteredmuonpaths.second.at(
i)->primitive(lay)->tdcTimeStamp() <<
" ";
440 for (
auto& ch_muonpaths : muonpaths) {
441 LogDebug(
"DTTrigPhase2Prod") <<
"MUON PATHS found: " << ch_muonpaths.second.size() <<
" (" 442 << filteredmuonpaths[ch_muonpaths.first].size() <<
") in event " 447 LogDebug(
"DTTrigPhase2Prod") <<
"filling NmetaPrimtives" << std::endl;
448 std::map<int, std::vector<metaPrimitive>> metaPrimitives;
449 std::map<int, MuonPathPtrs> outmpaths;
452 LogDebug(
"DTTrigPhase2Prod") <<
"Fitting 1SL ";
453 for (
auto& ch_muonpaths : muonpaths) {
458 lateralities[ch_muonpaths.first],
459 metaPrimitives[ch_muonpaths.first]);
461 for (
auto& inMPath : ch_muonpaths.second) {
462 auto sl = inMPath->primitive(0)->superLayerId();
463 int selected_lay = 1;
464 if (inMPath->primitive(0)->tdcTimeStamp() != -1)
466 int dumLayId = inMPath->primitive(selected_lay)->cameraId();
468 DTSuperLayerId MuonPathSLId(dtDumlayerId.wheel(), dtDumlayerId.station(), dtDumlayerId.sector(), sl + 1);
470 metaPrimitives[ch_muonpaths.first].emplace_back(
metaPrimitive({MuonPathSLId.rawId(),
480 inMPath->primitive(0)->channelId(),
481 inMPath->primitive(0)->tdcTimeStamp(),
483 inMPath->primitive(1)->channelId(),
484 inMPath->primitive(1)->tdcTimeStamp(),
486 inMPath->primitive(2)->channelId(),
487 inMPath->primitive(2)->tdcTimeStamp(),
489 inMPath->primitive(3)->channelId(),
490 inMPath->primitive(3)->tdcTimeStamp(),
506 metaPrimitives[ch_muonpaths.first].emplace_back(
metaPrimitive({MuonPathSLId.rawId(),
528 inMPath->primitive(0)->channelId(),
529 inMPath->primitive(0)->tdcTimeStamp(),
531 inMPath->primitive(1)->channelId(),
532 inMPath->primitive(1)->tdcTimeStamp(),
534 inMPath->primitive(2)->channelId(),
535 inMPath->primitive(2)->tdcTimeStamp(),
537 inMPath->primitive(3)->channelId(),
538 inMPath->primitive(3)->tdcTimeStamp(),
544 for (
auto& inMPath : ch_muonpaths.second) {
546 auto sl = inMPath->primitive(0)->superLayerId();
547 int selected_lay = 1;
548 if (inMPath->primitive(0)->tdcTimeStamp() != -1)
550 int dumLayId = inMPath->primitive(selected_lay)->cameraId();
552 DTSuperLayerId MuonPathSLId(dtDumlayerId.wheel(), dtDumlayerId.station(), dtDumlayerId.sector(), sl + 1);
553 for (
auto&
latcomb : lateralities[ch_muonpaths.first][imp]) {
555 metaPrimitives[ch_muonpaths.first].emplace_back(
metaPrimitive({MuonPathSLId.rawId(),
565 inMPath->primitive(0)->channelId(),
566 inMPath->primitive(0)->tdcTimeStamp(),
568 inMPath->primitive(1)->channelId(),
569 inMPath->primitive(1)->tdcTimeStamp(),
571 inMPath->primitive(2)->channelId(),
572 inMPath->primitive(2)->tdcTimeStamp(),
574 inMPath->primitive(3)->channelId(),
575 inMPath->primitive(3)->tdcTimeStamp(),
591 metaPrimitives[ch_muonpaths.first].emplace_back(
metaPrimitive({MuonPathSLId.rawId(),
613 inMPath->primitive(0)->channelId(),
614 inMPath->primitive(0)->tdcTimeStamp(),
616 inMPath->primitive(1)->channelId(),
617 inMPath->primitive(1)->tdcTimeStamp(),
619 inMPath->primitive(2)->channelId(),
620 inMPath->primitive(2)->tdcTimeStamp(),
622 inMPath->primitive(3)->channelId(),
623 inMPath->primitive(3)->tdcTimeStamp(),
633 LogDebug(
"DTTrigPhase2Prod") <<
"Fitting 2SL at once ";
634 for (
auto& ch_muonpaths : muonpaths) {
642 for (
auto& ch_outmpaths : outmpaths) {
643 for (
unsigned int i = 0;
i < ch_outmpaths.second.size();
i++) {
644 LogInfo(
"DTTrigPhase2Prod") <<
iEvent.id().event() <<
" mp " <<
i <<
": " 645 << ch_outmpaths.second.at(
i)->bxTimeValue() <<
" " 646 << ch_outmpaths.second.at(
i)->horizPos() <<
" " 647 << ch_outmpaths.second.at(
i)->tanPhi() <<
" " << ch_outmpaths.second.at(
i)->phi()
648 <<
" " << ch_outmpaths.second.at(
i)->phiB() <<
" " 649 << ch_outmpaths.second.at(
i)->quality() <<
" " 650 << ch_outmpaths.second.at(
i)->chiSquare();
653 for (
auto& ch_metaPrimitives : metaPrimitives) {
654 for (
unsigned int i = 0;
i < ch_metaPrimitives.second.size();
i++) {
656 ss <<
iEvent.id().event() <<
" mp " <<
i <<
": ";
657 printmP(
ss.str(), ch_metaPrimitives.second.at(
i));
663 filteredmuonpaths.clear();
669 std::map<int, std::vector<metaPrimitive>> confirmedMetaPrimitives;
670 for (
auto& ch_metaPrimitives : metaPrimitives) {
673 iEvent, iEventSetup, ch_metaPrimitives.second, dtdigis, confirmedMetaPrimitives[ch_metaPrimitives.first]);
675 for (
auto& mp : ch_metaPrimitives.second) {
676 confirmedMetaPrimitives[ch_metaPrimitives.first].push_back(mp);
680 metaPrimitives.clear();
688 LogDebug(
"DTTrigPhase2Prod") <<
"declaring new vector for filtered" << std::endl;
690 std::map<int, std::vector<metaPrimitive>> filteredMetaPrimitives;
692 for (
auto& ch_confirmedMetaPrimitives : confirmedMetaPrimitives) {
696 ch_confirmedMetaPrimitives.second,
697 filteredMetaPrimitives[ch_confirmedMetaPrimitives.first]);
699 for (
auto& mp : ch_confirmedMetaPrimitives.second) {
700 filteredMetaPrimitives[ch_confirmedMetaPrimitives.first].push_back(mp);
704 for (
auto& ch_filteredMetaPrimitives : filteredMetaPrimitives) {
705 for (
unsigned int i = 0;
i < ch_filteredMetaPrimitives.second.size();
i++) {
707 ss <<
iEvent.id().event() <<
" filtered mp " <<
i <<
": ";
708 printmP(
ss.str(), ch_filteredMetaPrimitives.second.at(
i));
714 confirmedMetaPrimitives.clear();
717 for (
auto& ch_filteredMetaPrimitives : filteredMetaPrimitives) {
718 LogDebug(
"DTTrigPhase2Prod") <<
"DTp2 in event:" <<
iEvent.id().event() <<
" we found " 719 << ch_filteredMetaPrimitives.second.size() <<
" filteredMetaPrimitives (superlayer)" 723 LogDebug(
"DTTrigPhase2Prod") <<
"filteredMetaPrimitives: starting correlations" << std::endl;
729 std::map<int, std::vector<metaPrimitive>> correlatedMetaPrimitives;
731 for (
auto& ch_filteredMetaPrimitives : filteredMetaPrimitives) {
735 ch_filteredMetaPrimitives.second,
736 correlatedMetaPrimitives[ch_filteredMetaPrimitives.first]);
738 for (
auto& mp : ch_filteredMetaPrimitives.second) {
739 correlatedMetaPrimitives[ch_filteredMetaPrimitives.first].push_back(mp);
743 for (
auto& ch_outmpaths : outmpaths) {
744 for (
const auto& muonpath : ch_outmpaths.second) {
745 correlatedMetaPrimitives[ch_outmpaths.first].emplace_back(muonpath->rawId(),
746 (double)muonpath->bxTimeValue(),
747 muonpath->horizPos(),
751 muonpath->phi_cmssw(),
752 muonpath->phiB_cmssw(),
753 muonpath->chiSquare(),
754 (
int)muonpath->quality(),
755 muonpath->primitive(0)->channelId(),
756 muonpath->primitive(0)->tdcTimeStamp(),
757 muonpath->primitive(0)->laterality(),
758 muonpath->primitive(1)->channelId(),
759 muonpath->primitive(1)->tdcTimeStamp(),
760 muonpath->primitive(1)->laterality(),
761 muonpath->primitive(2)->channelId(),
762 muonpath->primitive(2)->tdcTimeStamp(),
763 muonpath->primitive(2)->laterality(),
764 muonpath->primitive(3)->channelId(),
765 muonpath->primitive(3)->tdcTimeStamp(),
766 muonpath->primitive(3)->laterality(),
767 muonpath->primitive(4)->channelId(),
768 muonpath->primitive(4)->tdcTimeStamp(),
769 muonpath->primitive(4)->laterality(),
770 muonpath->primitive(5)->channelId(),
771 muonpath->primitive(5)->tdcTimeStamp(),
772 muonpath->primitive(5)->laterality(),
773 muonpath->primitive(6)->channelId(),
774 muonpath->primitive(6)->tdcTimeStamp(),
775 muonpath->primitive(6)->laterality(),
776 muonpath->primitive(7)->channelId(),
777 muonpath->primitive(7)->tdcTimeStamp(),
778 muonpath->primitive(7)->laterality());
786 for (
auto& ch_correlatedMetaPrimitives : correlatedMetaPrimitives) {
787 LogDebug(
"DTTrigPhase2Prod") <<
"DTp2 in event:" <<
iEvent.id().event() <<
" we found " 788 << ch_correlatedMetaPrimitives.second.size() <<
" correlatedMetPrimitives (chamber)";
791 for (
auto& ch_correlatedMetaPrimitives : correlatedMetaPrimitives) {
792 LogDebug(
"DTTrigPhase2Prod") <<
"DTp2 in event:" <<
iEvent.id().event() <<
" we found " 793 << ch_correlatedMetaPrimitives.second.size() <<
" correlatedMetPrimitives (chamber)";
795 for (
auto& ch_correlatedMetaPrimitives : correlatedMetaPrimitives) {
796 for (
unsigned int i = 0;
i < ch_correlatedMetaPrimitives.second.size();
i++) {
798 ss <<
iEvent.id().event() <<
" correlated mp " <<
i <<
": ";
799 printmPC(
ss.str(), ch_correlatedMetaPrimitives.second.at(
i));
805 std::map<int, std::vector<metaPrimitive>> filtCorrelatedMetaPrimitives;
807 for (
auto& ch_filteredMetaPrimitives : filteredMetaPrimitives) {
811 ch_filteredMetaPrimitives.second,
812 correlatedMetaPrimitives[ch_filteredMetaPrimitives.first],
813 filtCorrelatedMetaPrimitives[ch_filteredMetaPrimitives.first]);
815 for (
auto& mp : ch_filteredMetaPrimitives.second) {
816 filtCorrelatedMetaPrimitives[ch_filteredMetaPrimitives.first].push_back(mp);
819 for (
auto& mp : correlatedMetaPrimitives[ch_filteredMetaPrimitives.first]) {
820 filtCorrelatedMetaPrimitives[ch_filteredMetaPrimitives.first].push_back(mp);
826 correlatedMetaPrimitives.clear();
827 filteredMetaPrimitives.clear();
831 std::vector<metaPrimitive> allMetaPrimitives;
832 for (
auto& ch_filtcorrelatedMetaPrimitives : filtCorrelatedMetaPrimitives) {
833 for (
const auto& metaPrimitiveIt : ch_filtcorrelatedMetaPrimitives.second) {
834 allMetaPrimitives.push_back(metaPrimitiveIt);
838 std::map<int, std::vector<metaPrimitive>> coMetaPrimitives;
840 for (
auto& ch_filtcorrelatedMetaPrimitives : filtCorrelatedMetaPrimitives) {
845 filtCorrelatedMetaPrimitives[ch_filtcorrelatedMetaPrimitives.first],
846 coMetaPrimitives[ch_filtcorrelatedMetaPrimitives.first]);
848 for (
auto& mp : ch_filtcorrelatedMetaPrimitives.second) {
849 coMetaPrimitives[ch_filtcorrelatedMetaPrimitives.first].push_back(mp);
855 allMetaPrimitives.clear();
859 double shift_back = 0;
871 for (
auto& ch_correlatedMetaPrimitives : coMetaPrimitives) {
872 rpc_integrator_->matchWithDTAndUseRPCTime(ch_correlatedMetaPrimitives.second);
880 vector<L1Phase2MuDTPhDigi> outP2Ph;
881 vector<L1Phase2MuDTExtPhDigi> outExtP2Ph;
882 vector<L1Phase2MuDTThDigi> outP2Th;
883 vector<L1Phase2MuDTExtThDigi> outExtP2Th;
887 for (
auto& ch_correlatedMetaPrimitives : coMetaPrimitives) {
891 for (
auto& ch_correlatedMetaPrimitives : coMetaPrimitives) {
892 for (
const auto& metaPrimitiveIt : ch_correlatedMetaPrimitives.second) {
896 LogDebug(
"DTTrigPhase2Prod") <<
"looping in final vector: SuperLayerId" << chId <<
" x=" << metaPrimitiveIt.x
897 <<
" quality=" << metaPrimitiveIt.quality
898 <<
" BX=" << round(metaPrimitiveIt.t0 / 25.) <<
" index=" << metaPrimitiveIt.index;
900 int sectorTP = chId.sector();
907 sectorTP = sectorTP - 1;
909 if (metaPrimitiveIt.quality <
LOWLOWQ || metaPrimitiveIt.quality ==
CHIGHQ) {
910 if (
inner(metaPrimitiveIt))
920 LogDebug(
"DTTrigPhase2Prod") <<
"pushing back phase-2 dataformat carlo-federica dataformat";
922 if (slId.superLayer() != 2) {
924 int pathWireId[8] = {metaPrimitiveIt.wi1,
931 metaPrimitiveIt.wi8};
933 int pathTDC[8] = {
max((
int)round(metaPrimitiveIt.tdc1 - shift_back *
LHC_CLK_FREQ), -1),
940 max((
int)round(metaPrimitiveIt.tdc8 - shift_back *
LHC_CLK_FREQ), -1)};
942 int pathLat[8] = {metaPrimitiveIt.lat1,
943 metaPrimitiveIt.lat2,
944 metaPrimitiveIt.lat3,
945 metaPrimitiveIt.lat4,
946 metaPrimitiveIt.lat5,
947 metaPrimitiveIt.lat6,
948 metaPrimitiveIt.lat7,
949 metaPrimitiveIt.lat8};
952 outExtP2Ph.emplace_back(
960 metaPrimitiveIt.quality,
961 metaPrimitiveIt.index,
964 (
int)round(metaPrimitiveIt.x * 1000),
965 (
int)round(metaPrimitiveIt.tanPhi * 1000),
968 metaPrimitiveIt.rpcFlag,
976 (
int)round(metaPrimitiveIt.t0 / (
float)
LHC_CLK_FREQ) - shift_back,
983 metaPrimitiveIt.quality,
984 metaPrimitiveIt.index,
987 metaPrimitiveIt.rpcFlag
992 int pathWireId[4] = {metaPrimitiveIt.wi1, metaPrimitiveIt.wi2, metaPrimitiveIt.wi3, metaPrimitiveIt.wi4};
994 int pathTDC[4] = {
max((
int)round(metaPrimitiveIt.tdc1 - shift_back *
LHC_CLK_FREQ), -1),
997 max((
int)round(metaPrimitiveIt.tdc4 - shift_back *
LHC_CLK_FREQ), -1)};
999 int pathLat[4] = {metaPrimitiveIt.lat1, metaPrimitiveIt.lat2, metaPrimitiveIt.lat3, metaPrimitiveIt.lat4};
1002 outExtP2Th.emplace_back(
1009 metaPrimitiveIt.quality,
1010 metaPrimitiveIt.index,
1013 (
int)round(metaPrimitiveIt.x * 1000),
1016 metaPrimitiveIt.rpcFlag,
1024 (
int)round(metaPrimitiveIt.t0 / (
float)
LHC_CLK_FREQ) - shift_back,
1030 metaPrimitiveIt.quality,
1031 metaPrimitiveIt.index,
1034 metaPrimitiveIt.rpcFlag
1043 for (
auto rpc_dt_digi =
rpc_integrator_->rpcRecHits_translated_.begin();
1046 outP2Ph.push_back(*rpc_dt_digi);
1053 resultExtP2Ph->setContainer(outExtP2Ph);
1058 resultP2Ph->setContainer(outP2Ph);
1062 outExtP2Ph.erase(outExtP2Ph.begin(), outExtP2Ph.end());
1064 outP2Ph.erase(outP2Ph.begin(), outP2Ph.end());
1069 resultExtP2Th->setContainer(outExtP2Th);
1074 resultP2Th->setContainer(outP2Th);
1078 outExtP2Th.erase(outExtP2Th.begin(), outExtP2Th.end());
1080 outP2Th.erase(outP2Th.begin(), outP2Th.end());
std::unique_ptr< MotherGrouping > grouping_obj_
std::map< DTChamberId, DTDigiCollection, std::less< DTChamberId > > DTDigiMap
constexpr int CHI2RES_CONV
constexpr float PHIBRES_CONV
DTChamberId id() const
Return the DTChamberId of this chamber.
std::unique_ptr< LateralityProvider > latprovider_
std::unique_ptr< MPFilter > mpathhitsfilter_
edm::EDGetTokenT< DTDigiCollection > dtDigisToken_
std::vector< DTDigiCollection * > distribDigis(std::queue< std::pair< DTLayerId, DTDigi >> &inQ)
std::unique_ptr< RPCIntegrator > rpc_integrator_
std::unique_ptr< MuonPathConfirmator > mpathconfirmator_
edm::EDGetTokenT< RPCRecHitCollection > rpcRecHitsLabel_
bool output_latpredictor_
std::vector< short > latcomb
void assignIndex(std::vector< metaPrimitive > &inMPaths)
const DTGeometry * dtGeo_
void printmPC(const std::string &ss, const metaPrimitive &mP) const
DTChamberId chamberId() const
Return the corresponding ChamberId.
bool inner(const metaPrimitive &mp) const
std::unique_ptr< MuonPathAnalyzer > mpathanalyzer_
constexpr float KRES_CONV
std::unique_ptr< MPFilter > mpathqualityenhancer_
void printmP(const std::string &ss, const metaPrimitive &mP) const
constexpr float ZRES_CONV
std::unique_ptr< MPFilter > mpathcoifilter_
std::unique_ptr< MPFilter > mpathcorfilter_
Log< level::Info, false > LogInfo
std::unique_ptr< MPFilter > mpathredundantfilter_
constexpr int TIME_TO_TDC_COUNTS
constexpr uint32_t rawId() const
get the raw id
std::pair< const_iterator, const_iterator > Range
std::unique_ptr< MuonPathAnalyzer > mpathassociator_
std::vector< DigiType >::const_iterator const_iterator
constexpr int LHC_CLK_FREQ
DTDigiMap::iterator DTDigiMap_iterator
DTSuperLayerId superlayerId() const
Return the corresponding SuperLayerId.
const std::vector< const DTChamber * > & chambers() const
Return a vector of all Chamber.
constexpr float PHIRES_CONV