64 using namespace cmsdt;
67 typedef std::map<DTChamberId, DTDigiCollection, std::less<DTChamberId>>
DTDigiMap;
93 bool hasPosRF(
int wh,
int sec)
const;
99 void setChiSquareThreshold(
float ch2Thr);
140 std::vector<DTDigiCollection*> distribDigis(
std::queue<std::pair<DTLayerId, DTDigi>>& inQ);
141 void processDigi(
std::queue<std::pair<DTLayerId, DTDigi>>& inQ,
148 void assignIndex(std::vector<metaPrimitive>& inMPaths);
149 void assignIndexPerBX(std::vector<metaPrimitive>& inMPaths);
152 const std::unordered_map<int, int>
qmap_;
157 bool operator()(std::pair<DTLayerId, DTDigi>
a, std::pair<DTLayerId, DTDigi>
b)
const {
158 return (
a.second.time() <
b.second.time());
160 }
const DigiTimeOrdering;
164 : qmap_({{9, 9}, {8, 8}, {7, 6}, {6, 7}, {5, 3}, {4, 5}, {3, 4}, {2, 2}, {1, 1}}) {
165 produces<L1Phase2MuDTPhContainer>();
166 produces<L1Phase2MuDTThContainer>();
168 debug_ =
pset.getUntrackedParameter<
bool>(
"debug");
169 dump_ =
pset.getUntrackedParameter<
bool>(
"dump");
171 do_correlation_ =
pset.getParameter<
bool>(
"do_correlation");
172 scenario_ =
pset.getParameter<
int>(
"scenario");
174 dtDigisToken_ = consumes<DTDigiCollection>(
pset.getParameter<
edm::InputTag>(
"digiTag"));
176 rpcRecHitsLabel_ = consumes<RPCRecHitCollection>(
pset.getParameter<
edm::InputTag>(
"rpcRecHits"));
177 useRPC_ =
pset.getParameter<
bool>(
"useRPC");
180 algo_ =
pset.getParameter<
int>(
"algo");
183 cmssw_for_global_ =
pset.getUntrackedParameter<
bool>(
"cmssw_for_global",
true);
184 geometry_tag_ =
pset.getUntrackedParameter<
std::string>(
"geometry_tag",
"");
187 globalcoordsobtainer_ = std::make_shared<GlobalCoordsObtainer>(
pset);
188 if (!cmssw_for_global_)
189 globalcoordsobtainer_->generate_luts();
193 std::make_unique<PseudoBayesGrouping>(
pset.getParameter<
edm::ParameterSet>(
"PseudoBayesPattern"), consumesColl);
196 std::make_unique<HoughGrouping>(
pset.getParameter<
edm::ParameterSet>(
"HoughGrouping"), consumesColl);
198 grouping_obj_ = std::make_unique<InitialGrouping>(
pset, consumesColl);
203 LogDebug(
"DTTrigPhase2Prod") <<
"DTp2:constructor: JM analyzer";
204 mpathanalyzer_ = std::make_unique<MuonPathAnalyticAnalyzer>(
pset, consumesColl, globalcoordsobtainer_);
207 LogDebug(
"DTTrigPhase2Prod") <<
"DTp2:constructor: Full chamber analyzer";
208 mpathanalyzer_ = std::make_unique<MuonPathAnalyzerInChamber>(
pset, consumesColl);
212 activateBuffer_ =
pset.getParameter<
bool>(
"activateBuffer");
213 superCellhalfspacewidth_ =
pset.getParameter<
int>(
"superCellspacewidth") / 2;
214 superCelltimewidth_ =
pset.getParameter<
double>(
"superCelltimewidth");
216 mpathqualityenhancer_ = std::make_unique<MPQualityEnhancerFilter>(
pset);
217 mpathredundantfilter_ = std::make_unique<MPRedundantFilter>(
pset);
218 mpathassociator_ = std::make_unique<MuonPathAssociator>(
pset, consumesColl, globalcoordsobtainer_);
219 rpc_integrator_ = std::make_unique<RPCIntegrator>(
pset, consumesColl);
221 dtGeomH = esConsumes<DTGeometry, MuonGeometryRecord, edm::Transition::BeginRun>();
226 LogDebug(
"DTTrigPhase2Prod") <<
"DTp2: calling destructor" << std::endl;
231 LogDebug(
"DTTrigPhase2Prod") <<
"beginRun " << iRun.
id().
run();
233 LogDebug(
"DTTrigPhase2Prod") <<
"beginRun: getting DT geometry";
248 LogDebug(
"DTTrigPhase2Prod") <<
"produce";
253 LogDebug(
"DTTrigPhase2Prod") <<
"\t Getting the RPC RecHits" << std::endl;
262 for (
const auto& detUnitIt : *dtdigis) {
263 const DTLayerId& layId = detUnitIt.first;
266 digiMap[chambId].put(
range, layId);
271 LogDebug(
"DTTrigPhase2Prod") <<
"produce - Getting and grouping digis per chamber using a buffer and super cells.";
273 LogDebug(
"DTTrigPhase2Prod") <<
"produce - Getting and grouping digis per chamber.";
282 if (dmit == digiMap.end())
287 std::vector<std::pair<DTLayerId, DTDigi>> tmpvec;
290 for (
const auto& dtLayerIdIt : (*dmit).second) {
292 digiIt != (dtLayerIdIt.second).second;
294 tmpvec.emplace_back(dtLayerIdIt.first, *digiIt);
303 std::sort(tmpvec.begin(), tmpvec.end(), DigiTimeOrdering);
304 std::queue<std::pair<DTLayerId, DTDigi>> timequeue;
306 for (
const auto& elem : tmpvec)
307 timequeue.emplace(elem);
311 std::vector<DTDigiCollection*> superCells;
316 while (!superCells.empty()) {
318 superCells.pop_back();
327 for (
unsigned int i = 0;
i < muonpaths.size();
i++) {
329 ss <<
iEvent.id().event() <<
" mpath " <<
i <<
": ";
330 for (
int lay = 0; lay < muonpaths.at(
i)->nprimitives(); lay++)
331 ss << muonpaths.at(
i)->primitive(lay)->channelId() <<
" ";
332 for (
int lay = 0; lay < muonpaths.at(
i)->nprimitives(); lay++)
333 ss << muonpaths.at(
i)->primitive(lay)->tdcTimeStamp() <<
" ";
334 for (
int lay = 0; lay < muonpaths.at(
i)->nprimitives(); lay++)
335 ss << muonpaths.at(
i)->primitive(lay)->laterality() <<
" ";
347 for (
unsigned int i = 0;
i < filteredmuonpaths.size();
i++) {
349 ss <<
iEvent.id().event() <<
" filt. mpath " <<
i <<
": ";
350 for (
int lay = 0; lay < filteredmuonpaths.at(
i)->nprimitives(); lay++)
351 ss << filteredmuonpaths.at(
i)->primitive(lay)->channelId() <<
" ";
352 for (
int lay = 0; lay < filteredmuonpaths.at(
i)->nprimitives(); lay++)
353 ss << filteredmuonpaths.at(
i)->primitive(lay)->tdcTimeStamp() <<
" ";
362 LogDebug(
"DTTrigPhase2Prod") <<
"MUON PATHS found: " << muonpaths.size() <<
" (" << filteredmuonpaths.size()
363 <<
") in event " <<
iEvent.id().event();
365 LogDebug(
"DTTrigPhase2Prod") <<
"filling NmetaPrimtives" << std::endl;
366 std::vector<metaPrimitive> metaPrimitives;
370 LogDebug(
"DTTrigPhase2Prod") <<
"Fitting 1SL ";
375 LogDebug(
"DTTrigPhase2Prod") <<
"Fitting 2SL at once ";
380 for (
unsigned int i = 0;
i < outmpaths.size();
i++) {
381 LogInfo(
"DTTrigPhase2Prod") <<
iEvent.id().event() <<
" mp " <<
i <<
": " << outmpaths.at(
i)->bxTimeValue() <<
" "
382 << outmpaths.at(
i)->horizPos() <<
" " << outmpaths.at(
i)->tanPhi() <<
" "
383 << outmpaths.at(
i)->phi() <<
" " << outmpaths.at(
i)->phiB() <<
" "
384 << outmpaths.at(
i)->quality() <<
" " << outmpaths.at(
i)->chiSquare();
386 for (
unsigned int i = 0;
i < metaPrimitives.size();
i++) {
388 ss <<
iEvent.id().event() <<
" mp " <<
i <<
": ";
394 filteredmuonpaths.clear();
400 LogDebug(
"DTTrigPhase2Prod") <<
"declaring new vector for filtered" << std::endl;
402 std::vector<metaPrimitive> filteredMetaPrimitives;
407 for (
unsigned int i = 0;
i < filteredMetaPrimitives.size();
i++) {
409 ss <<
iEvent.id().event() <<
" filtered mp " <<
i <<
": ";
410 printmP(
ss.str(), filteredMetaPrimitives.at(
i));
414 metaPrimitives.clear();
415 metaPrimitives.erase(metaPrimitives.begin(), metaPrimitives.end());
418 LogDebug(
"DTTrigPhase2Prod") <<
"DTp2 in event:" <<
iEvent.id().event() <<
" we found "
419 << filteredMetaPrimitives.size() <<
" filteredMetaPrimitives (superlayer)"
422 LogDebug(
"DTTrigPhase2Prod") <<
"filteredMetaPrimitives: starting correlations" << std::endl;
427 std::vector<metaPrimitive> correlatedMetaPrimitives;
431 for (
const auto& muonpath : outmpaths) {
432 correlatedMetaPrimitives.emplace_back(muonpath->rawId(),
433 (double)muonpath->bxTimeValue(),
434 muonpath->horizPos(),
438 muonpath->chiSquare(),
439 (
int)muonpath->quality(),
440 muonpath->primitive(0)->channelId(),
441 muonpath->primitive(0)->tdcTimeStamp(),
442 muonpath->primitive(0)->laterality(),
443 muonpath->primitive(1)->channelId(),
444 muonpath->primitive(1)->tdcTimeStamp(),
445 muonpath->primitive(1)->laterality(),
446 muonpath->primitive(2)->channelId(),
447 muonpath->primitive(2)->tdcTimeStamp(),
448 muonpath->primitive(2)->laterality(),
449 muonpath->primitive(3)->channelId(),
450 muonpath->primitive(3)->tdcTimeStamp(),
451 muonpath->primitive(3)->laterality(),
452 muonpath->primitive(4)->channelId(),
453 muonpath->primitive(4)->tdcTimeStamp(),
454 muonpath->primitive(4)->laterality(),
455 muonpath->primitive(5)->channelId(),
456 muonpath->primitive(5)->tdcTimeStamp(),
457 muonpath->primitive(5)->laterality(),
458 muonpath->primitive(6)->channelId(),
459 muonpath->primitive(6)->tdcTimeStamp(),
460 muonpath->primitive(6)->laterality(),
461 muonpath->primitive(7)->channelId(),
462 muonpath->primitive(7)->tdcTimeStamp(),
463 muonpath->primitive(7)->laterality());
466 filteredMetaPrimitives.clear();
469 LogDebug(
"DTTrigPhase2Prod") <<
"DTp2 in event:" <<
iEvent.id().event() <<
" we found "
470 << correlatedMetaPrimitives.size() <<
" correlatedMetPrimitives (chamber)";
473 LogInfo(
"DTTrigPhase2Prod") <<
"DTp2 in event:" <<
iEvent.id().event() <<
" we found "
474 << correlatedMetaPrimitives.size() <<
" correlatedMetPrimitives (chamber)";
476 for (
unsigned int i = 0;
i < correlatedMetaPrimitives.size();
i++) {
478 ss <<
iEvent.id().event() <<
" correlated mp " <<
i <<
": ";
479 printmPC(
ss.str(), correlatedMetaPrimitives.at(
i));
483 double shift_back = 0;
502 vector<L1Phase2MuDTPhDigi> outP2Ph;
503 vector<L1Phase2MuDTThDigi> outP2Th;
507 for (
const auto& metaPrimitiveIt : correlatedMetaPrimitives) {
511 LogDebug(
"DTTrigPhase2Prod") <<
"looping in final vector: SuperLayerId" << chId <<
" x=" << metaPrimitiveIt.x
512 <<
" quality=" << metaPrimitiveIt.quality
513 <<
" BX=" << round(metaPrimitiveIt.t0 / 25.) <<
" index=" << metaPrimitiveIt.index;
515 int sectorTP = chId.
sector();
522 sectorTP = sectorTP - 1;
524 if (metaPrimitiveIt.quality <
LOWLOWQ || metaPrimitiveIt.quality ==
CHIGHQ) {
525 if (
inner(metaPrimitiveIt))
532 LogDebug(
"DTTrigPhase2Prod") <<
"pushing back phase-2 dataformat carlo-federica dataformat";
537 (
int)round(metaPrimitiveIt.t0 / (
float)
LHC_CLK_FREQ) - shift_back,
544 metaPrimitiveIt.quality,
545 metaPrimitiveIt.index,
548 metaPrimitiveIt.rpcFlag
553 (
int)round(metaPrimitiveIt.t0 / (
float)
LHC_CLK_FREQ) - shift_back,
559 metaPrimitiveIt.quality,
560 metaPrimitiveIt.index,
563 metaPrimitiveIt.rpcFlag
570 for (
auto rpc_dt_digi =
rpc_integrator_->rpcRecHits_translated_.begin();
573 outP2Ph.push_back(*rpc_dt_digi);
577 auto resultP2Ph = std::make_unique<L1Phase2MuDTPhContainer>();
578 resultP2Ph->setContainer(outP2Ph);
581 outP2Ph.erase(outP2Ph.begin(), outP2Ph.end());
584 resultP2Th->setContainer(outP2Th);
587 outP2Th.erase(outP2Th.begin(), outP2Th.end());
613 LogInfo(
"DTTrigPhase2Prod") <<
ss << (
int)slId <<
"\t " << setw(2) << left << mP.
wi1 <<
" " << setw(2) << left
614 << mP.
wi2 <<
" " << setw(2) << left << mP.
wi3 <<
" " << setw(2) << left << mP.
wi4 <<
" "
615 << setw(5) << left << mP.
tdc1 <<
" " << setw(5) << left << mP.
tdc2 <<
" " << setw(5)
616 << left << mP.
tdc3 <<
" " << setw(5) << left << mP.
tdc4 <<
" " << setw(10) << right
617 << mP.
x <<
" " << setw(9) << left << mP.
tanPhi <<
" " << setw(5) << left << mP.
t0 <<
" "
618 << setw(13) << left << mP.
chi2 <<
" r:" <<
rango(mP);
623 LogInfo(
"DTTrigPhase2Prod") <<
ss << (
int)
ChId <<
"\t " << setw(2) << left << mP.
wi1 <<
" " << setw(2) << left
624 << mP.
wi2 <<
" " << setw(2) << left << mP.
wi3 <<
" " << setw(2) << left << mP.
wi4 <<
" "
625 << setw(2) << left << mP.
wi5 <<
" " << setw(2) << left << mP.
wi6 <<
" " << setw(2) << left
626 << mP.
wi7 <<
" " << setw(2) << left << mP.
wi8 <<
" " << setw(5) << left << mP.
tdc1 <<
" "
627 << setw(5) << left << mP.
tdc2 <<
" " << setw(5) << left << mP.
tdc3 <<
" " << setw(5)
628 << left << mP.
tdc4 <<
" " << setw(5) << left << mP.
tdc5 <<
" " << setw(5) << left
629 << mP.
tdc6 <<
" " << setw(5) << left << mP.
tdc7 <<
" " << setw(5) << left << mP.
tdc8
630 <<
" " << setw(2) << left << mP.
lat1 <<
" " << setw(2) << left << mP.
lat2 <<
" "
631 << setw(2) << left << mP.
lat3 <<
" " << setw(2) << left << mP.
lat4 <<
" " << setw(2)
632 << left << mP.
lat5 <<
" " << setw(2) << left << mP.
lat6 <<
" " << setw(2) << left
633 << mP.
lat7 <<
" " << setw(2) << left << mP.
lat8 <<
" " << setw(10) << right << mP.
x <<
" "
634 << setw(9) << left << mP.
tanPhi <<
" " << setw(5) << left << mP.
t0 <<
" " << setw(13)
635 << left << mP.
chi2 <<
" r:" <<
rango(mP);
647 std::map<int, std::vector<metaPrimitive>> primsPerBX;
653 for (
auto& prims : primsPerBX) {
655 for (
const auto&
primitive : prims.second)
664 for (
auto& metaPrimitiveIt : inMPaths) {
666 rawId = metaPrimitiveIt.rawId;
670 for (
auto& metaPrimitiveItN : inMPaths) {
673 if (rawId != metaPrimitiveItN.rawId)
676 metaPrimitiveIt.index =
inf;
678 }
else if (iOrder < nOrder) {
680 }
else if (iOrder > nOrder) {
681 metaPrimitiveItN.index++;
682 }
else if (iOrder == nOrder) {
685 }
else if (
std::abs(metaPrimitiveIt.phiB) <
std::abs(metaPrimitiveItN.phiB)) {
686 metaPrimitiveItN.index++;
701 std::vector<std::queue<std::pair<DTLayerId, DTDigi>>*> tmpVector;
703 std::vector<DTDigiCollection*> collVector;
705 while (!inQ.empty()) {
708 for (
auto& sQ : tmpVector) {
710 while (!sQ->empty()) {
711 tmpColl.insertDigi((sQ->front().first), (sQ->front().second));
714 collVector.push_back(&tmpColl);
721 bool classified =
false;
723 for (
auto& sC : vec) {
739 std::queue<std::pair<DTLayerId, DTDigi>> newQueue;
741 std::pair<DTLayerId, DTDigi> tmpPair;
743 newQueue.push(tmpPair);
746 vec.push_back(&newQueue);