61 using namespace cmsdt;
64 typedef std::map<DTChamberId, DTDigiCollection, std::less<DTChamberId>>
DTDigiMap;
90 bool hasPosRF(
int wh,
int sec)
const;
96 void setChiSquareThreshold(
float ch2Thr);
138 std::vector<DTDigiCollection*> distribDigis(
std::queue<std::pair<DTLayerId, DTDigi>>& inQ);
139 void processDigi(
std::queue<std::pair<DTLayerId, DTDigi>>& inQ,
146 void assignIndex(std::vector<metaPrimitive>& inMPaths);
147 void assignIndexPerBX(std::vector<metaPrimitive>& inMPaths);
150 const std::unordered_map<int, int>
qmap_;
155 bool operator()(std::pair<DTLayerId, DTDigi>
a, std::pair<DTLayerId, DTDigi>
b)
const {
156 return (
a.second.time() <
b.second.time());
162 : qmap_({{9, 9}, {8, 8}, {7, 6}, {6, 7}, {5, 3}, {4, 5}, {3, 4}, {2, 2}, {1, 1}}) {
163 produces<L1Phase2MuDTPhContainer>();
165 debug_ =
pset.getUntrackedParameter<
bool>(
"debug");
166 dump_ =
pset.getUntrackedParameter<
bool>(
"dump");
168 do_correlation_ =
pset.getParameter<
bool>(
"do_correlation");
169 scenario_ =
pset.getParameter<
int>(
"scenario");
171 dtDigisToken_ = consumes<DTDigiCollection>(
pset.getParameter<
edm::InputTag>(
"digiTag"));
173 rpcRecHitsLabel_ = consumes<RPCRecHitCollection>(
pset.getParameter<
edm::InputTag>(
"rpcRecHits"));
174 useRPC_ =
pset.getParameter<
bool>(
"useRPC");
177 algo_ =
pset.getParameter<
int>(
"algo");
183 std::make_unique<PseudoBayesGrouping>(
pset.getParameter<
edm::ParameterSet>(
"PseudoBayesPattern"), consumesColl);
186 std::make_unique<HoughGrouping>(
pset.getParameter<
edm::ParameterSet>(
"HoughGrouping"), consumesColl);
188 grouping_obj_ = std::make_unique<InitialGrouping>(
pset, consumesColl);
193 LogDebug(
"DTTrigPhase2Prod") <<
"DTp2:constructor: JM analyzer";
194 mpathanalyzer_ = std::make_unique<MuonPathAnalyzerPerSL>(
pset, consumesColl);
197 LogDebug(
"DTTrigPhase2Prod") <<
"DTp2:constructor: Full chamber analyzer";
198 mpathanalyzer_ = std::make_unique<MuonPathAnalyzerInChamber>(
pset, consumesColl);
202 activateBuffer_ =
pset.getParameter<
bool>(
"activateBuffer");
203 superCellhalfspacewidth_ =
pset.getParameter<
int>(
"superCellspacewidth") / 2;
204 superCelltimewidth_ =
pset.getParameter<
double>(
"superCelltimewidth");
206 mpathqualityenhancer_ = std::make_unique<MPQualityEnhancerFilter>(
pset);
207 mpathredundantfilter_ = std::make_unique<MPRedundantFilter>(
pset);
208 mpathassociator_ = std::make_unique<MuonPathAssociator>(
pset, consumesColl);
209 rpc_integrator_ = std::make_unique<RPCIntegrator>(
pset, consumesColl);
211 dtGeomH = esConsumes<DTGeometry, MuonGeometryRecord, edm::Transition::BeginRun>();
216 LogDebug(
"DTTrigPhase2Prod") <<
"DTp2: calling destructor" << std::endl;
221 LogDebug(
"DTTrigPhase2Prod") <<
"beginRun " << iRun.
id().
run();
223 LogDebug(
"DTTrigPhase2Prod") <<
"beginRun: getting DT geometry";
237 LogDebug(
"DTTrigPhase2Prod") <<
"produce";
242 LogDebug(
"DTTrigPhase2Prod") <<
"\t Getting the RPC RecHits" << std::endl;
251 for (
const auto& detUnitIt : *dtdigis) {
252 const DTLayerId& layId = detUnitIt.first;
255 digiMap[chambId].put(
range, layId);
260 LogDebug(
"DTTrigPhase2Prod") <<
"produce - Getting and grouping digis per chamber using a buffer and super cells.";
262 LogDebug(
"DTTrigPhase2Prod") <<
"produce - Getting and grouping digis per chamber.";
271 if (dmit == digiMap.end())
276 std::vector<std::pair<DTLayerId, DTDigi>> tmpvec;
279 for (
const auto& dtLayerIdIt : (*dmit).second) {
281 digiIt != (dtLayerIdIt.second).second;
283 tmpvec.emplace_back(dtLayerIdIt.first, *digiIt);
292 std::sort(tmpvec.begin(), tmpvec.end(), DigiTimeOrdering);
293 std::queue<std::pair<DTLayerId, DTDigi>> timequeue;
295 for (
const auto& elem : tmpvec)
296 timequeue.emplace(elem);
300 std::vector<DTDigiCollection*> superCells;
305 while (!superCells.empty()) {
307 superCells.pop_back();
316 for (
unsigned int i = 0;
i < muonpaths.size();
i++) {
318 ss <<
iEvent.id().event() <<
" mpath " <<
i <<
": ";
319 for (
int lay = 0; lay < muonpaths.at(
i)->nprimitives(); lay++)
320 ss << muonpaths.at(
i)->primitive(lay)->channelId() <<
" ";
321 for (
int lay = 0; lay < muonpaths.at(
i)->nprimitives(); lay++)
322 ss << muonpaths.at(
i)->primitive(lay)->tdcTimeStamp() <<
" ";
323 for (
int lay = 0; lay < muonpaths.at(
i)->nprimitives(); lay++)
324 ss << muonpaths.at(
i)->primitive(lay)->laterality() <<
" ";
336 for (
unsigned int i = 0;
i < filteredmuonpaths.size();
i++) {
338 ss <<
iEvent.id().event() <<
" filt. mpath " <<
i <<
": ";
339 for (
int lay = 0; lay < filteredmuonpaths.at(
i)->nprimitives(); lay++)
340 ss << filteredmuonpaths.at(
i)->primitive(lay)->channelId() <<
" ";
341 for (
int lay = 0; lay < filteredmuonpaths.at(
i)->nprimitives(); lay++)
342 ss << filteredmuonpaths.at(
i)->primitive(lay)->tdcTimeStamp() <<
" ";
351 LogDebug(
"DTTrigPhase2Prod") <<
"MUON PATHS found: " << muonpaths.size() <<
" (" << filteredmuonpaths.size()
352 <<
") in event " <<
iEvent.id().event();
354 LogDebug(
"DTTrigPhase2Prod") <<
"filling NmetaPrimtives" << std::endl;
355 std::vector<metaPrimitive> metaPrimitives;
359 LogDebug(
"DTTrigPhase2Prod") <<
"Fitting 1SL ";
364 LogDebug(
"DTTrigPhase2Prod") <<
"Fitting 2SL at once ";
369 for (
unsigned int i = 0;
i < outmpaths.size();
i++) {
370 LogInfo(
"DTTrigPhase2Prod") <<
iEvent.id().event() <<
" mp " <<
i <<
": " << outmpaths.at(
i)->bxTimeValue() <<
" "
371 << outmpaths.at(
i)->horizPos() <<
" " << outmpaths.at(
i)->tanPhi() <<
" "
372 << outmpaths.at(
i)->phi() <<
" " << outmpaths.at(
i)->phiB() <<
" "
373 << outmpaths.at(
i)->quality() <<
" " << outmpaths.at(
i)->chiSquare();
375 for (
unsigned int i = 0;
i < metaPrimitives.size();
i++) {
377 ss <<
iEvent.id().event() <<
" mp " <<
i <<
": ";
383 filteredmuonpaths.clear();
389 LogDebug(
"DTTrigPhase2Prod") <<
"declaring new vector for filtered" << std::endl;
391 std::vector<metaPrimitive> filteredMetaPrimitives;
396 for (
unsigned int i = 0;
i < filteredMetaPrimitives.size();
i++) {
398 ss <<
iEvent.id().event() <<
" filtered mp " <<
i <<
": ";
399 printmP(
ss.str(), filteredMetaPrimitives.at(
i));
403 metaPrimitives.clear();
404 metaPrimitives.erase(metaPrimitives.begin(), metaPrimitives.end());
407 LogDebug(
"DTTrigPhase2Prod") <<
"DTp2 in event:" <<
iEvent.id().event() <<
" we found "
408 << filteredMetaPrimitives.size() <<
" filteredMetaPrimitives (superlayer)"
411 LogDebug(
"DTTrigPhase2Prod") <<
"filteredMetaPrimitives: starting correlations" << std::endl;
416 std::vector<metaPrimitive> correlatedMetaPrimitives;
420 for (
const auto& muonpath : outmpaths) {
421 correlatedMetaPrimitives.emplace_back(muonpath->rawId(),
422 (double)muonpath->bxTimeValue(),
423 muonpath->horizPos(),
427 muonpath->chiSquare(),
428 (
int)muonpath->quality(),
429 muonpath->primitive(0)->channelId(),
430 muonpath->primitive(0)->tdcTimeStamp(),
431 muonpath->primitive(0)->laterality(),
432 muonpath->primitive(1)->channelId(),
433 muonpath->primitive(1)->tdcTimeStamp(),
434 muonpath->primitive(1)->laterality(),
435 muonpath->primitive(2)->channelId(),
436 muonpath->primitive(2)->tdcTimeStamp(),
437 muonpath->primitive(2)->laterality(),
438 muonpath->primitive(3)->channelId(),
439 muonpath->primitive(3)->tdcTimeStamp(),
440 muonpath->primitive(3)->laterality(),
441 muonpath->primitive(4)->channelId(),
442 muonpath->primitive(4)->tdcTimeStamp(),
443 muonpath->primitive(4)->laterality(),
444 muonpath->primitive(5)->channelId(),
445 muonpath->primitive(5)->tdcTimeStamp(),
446 muonpath->primitive(5)->laterality(),
447 muonpath->primitive(6)->channelId(),
448 muonpath->primitive(6)->tdcTimeStamp(),
449 muonpath->primitive(6)->laterality(),
450 muonpath->primitive(7)->channelId(),
451 muonpath->primitive(7)->tdcTimeStamp(),
452 muonpath->primitive(7)->laterality());
455 filteredMetaPrimitives.clear();
458 LogDebug(
"DTTrigPhase2Prod") <<
"DTp2 in event:" <<
iEvent.id().event() <<
" we found "
459 << correlatedMetaPrimitives.size() <<
" correlatedMetPrimitives (chamber)";
462 LogInfo(
"DTTrigPhase2Prod") <<
"DTp2 in event:" <<
iEvent.id().event() <<
" we found "
463 << correlatedMetaPrimitives.size() <<
" correlatedMetPrimitives (chamber)";
465 for (
unsigned int i = 0;
i < correlatedMetaPrimitives.size();
i++) {
467 ss <<
iEvent.id().event() <<
" correlated mp " <<
i <<
": ";
468 printmPC(
ss.str(), correlatedMetaPrimitives.at(
i));
472 double shift_back = 0;
491 vector<L1Phase2MuDTPhDigi> outP2Ph;
495 for (
const auto& metaPrimitiveIt : correlatedMetaPrimitives) {
498 LogDebug(
"DTTrigPhase2Prod") <<
"looping in final vector: SuperLayerId" << chId <<
" x=" << metaPrimitiveIt.x
499 <<
" quality=" << metaPrimitiveIt.quality
500 <<
" BX=" << round(metaPrimitiveIt.t0 / 25.) <<
" index=" << metaPrimitiveIt.index;
502 int sectorTP = chId.
sector();
509 sectorTP = sectorTP - 1;
511 if (metaPrimitiveIt.quality <
LOWLOWQ || metaPrimitiveIt.quality ==
CHIGHQ) {
512 if (
inner(metaPrimitiveIt))
519 LogDebug(
"DTTrigPhase2Prod") <<
"pushing back phase-2 dataformat carlo-federica dataformat";
521 (
int)round(metaPrimitiveIt.t0 / (
float)
LHC_CLK_FREQ) - shift_back,
528 metaPrimitiveIt.quality,
529 metaPrimitiveIt.index,
532 metaPrimitiveIt.rpcFlag
538 for (
auto rpc_dt_digi =
rpc_integrator_->rpcRecHits_translated_.begin();
541 outP2Ph.push_back(*rpc_dt_digi);
545 auto resultP2Ph = std::make_unique<L1Phase2MuDTPhContainer>();
546 resultP2Ph->setContainer(outP2Ph);
549 outP2Ph.erase(outP2Ph.begin(), outP2Ph.end());
575 LogInfo(
"DTTrigPhase2Prod") <<
ss << (
int)slId <<
"\t " << setw(2) << left << mP.
wi1 <<
" " << setw(2) << left
576 << mP.
wi2 <<
" " << setw(2) << left << mP.
wi3 <<
" " << setw(2) << left << mP.
wi4 <<
" "
577 << setw(5) << left << mP.
tdc1 <<
" " << setw(5) << left << mP.
tdc2 <<
" " << setw(5)
578 << left << mP.
tdc3 <<
" " << setw(5) << left << mP.
tdc4 <<
" " << setw(10) << right
579 << mP.
x <<
" " << setw(9) << left << mP.
tanPhi <<
" " << setw(5) << left << mP.
t0 <<
" "
580 << setw(13) << left << mP.
chi2 <<
" r:" <<
rango(mP);
585 LogInfo(
"DTTrigPhase2Prod") <<
ss << (
int)
ChId <<
"\t " << setw(2) << left << mP.
wi1 <<
" " << setw(2) << left
586 << mP.
wi2 <<
" " << setw(2) << left << mP.
wi3 <<
" " << setw(2) << left << mP.
wi4 <<
" "
587 << setw(2) << left << mP.
wi5 <<
" " << setw(2) << left << mP.
wi6 <<
" " << setw(2) << left
588 << mP.
wi7 <<
" " << setw(2) << left << mP.
wi8 <<
" " << setw(5) << left << mP.
tdc1 <<
" "
589 << setw(5) << left << mP.
tdc2 <<
" " << setw(5) << left << mP.
tdc3 <<
" " << setw(5)
590 << left << mP.
tdc4 <<
" " << setw(5) << left << mP.
tdc5 <<
" " << setw(5) << left
591 << mP.
tdc6 <<
" " << setw(5) << left << mP.
tdc7 <<
" " << setw(5) << left << mP.
tdc8
592 <<
" " << setw(2) << left << mP.
lat1 <<
" " << setw(2) << left << mP.
lat2 <<
" "
593 << setw(2) << left << mP.
lat3 <<
" " << setw(2) << left << mP.
lat4 <<
" " << setw(2)
594 << left << mP.
lat5 <<
" " << setw(2) << left << mP.
lat6 <<
" " << setw(2) << left
595 << mP.
lat7 <<
" " << setw(2) << left << mP.
lat8 <<
" " << setw(10) << right << mP.
x <<
" "
596 << setw(9) << left << mP.
tanPhi <<
" " << setw(5) << left << mP.
t0 <<
" " << setw(13)
597 << left << mP.
chi2 <<
" r:" <<
rango(mP);
609 std::map<int, std::vector<metaPrimitive>> primsPerBX;
615 for (
auto& prims : primsPerBX) {
617 for (
const auto&
primitive : prims.second)
626 for (
auto& metaPrimitiveIt : inMPaths) {
628 rawId = metaPrimitiveIt.rawId;
632 for (
auto& metaPrimitiveItN : inMPaths) {
635 if (rawId != metaPrimitiveItN.rawId)
638 metaPrimitiveIt.index =
inf;
640 }
else if (iOrder < nOrder) {
642 }
else if (iOrder > nOrder) {
643 metaPrimitiveItN.index++;
644 }
else if (iOrder == nOrder) {
647 }
else if (
std::abs(metaPrimitiveIt.phiB) <
std::abs(metaPrimitiveItN.phiB)) {
648 metaPrimitiveItN.index++;
663 std::vector<std::queue<std::pair<DTLayerId, DTDigi>>*> tmpVector;
665 std::vector<DTDigiCollection*> collVector;
667 while (!inQ.empty()) {
670 for (
auto& sQ : tmpVector) {
672 while (!sQ->empty()) {
673 tmpColl.insertDigi((sQ->front().first), (sQ->front().second));
676 collVector.push_back(&tmpColl);
683 bool classified =
false;
685 for (
auto& sC : vec) {
701 std::queue<std::pair<DTLayerId, DTDigi>> newQueue;
703 std::pair<DTLayerId, DTDigi> tmpPair;
705 newQueue.push(tmpPair);
708 vec.push_back(&newQueue);