Go to the documentation of this file.00001
00017
00018 #include "L1Trigger/GlobalTrigger/interface/L1GtMuonCondition.h"
00019
00020
00021 #include <iostream>
00022 #include <iomanip>
00023
00024 #include <string>
00025 #include <vector>
00026 #include <algorithm>
00027
00028
00029
00030 #include "CondFormats/L1TObjects/interface/L1GtMuonTemplate.h"
00031 #include "L1Trigger/GlobalTrigger/interface/L1GtConditionEvaluation.h"
00032
00033 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerReadoutSetupFwd.h"
00034
00035 #include "DataFormats/L1GlobalMuonTrigger/interface/L1MuGMTCand.h"
00036
00037 #include "L1Trigger/GlobalTrigger/interface/L1GlobalTriggerFunctions.h"
00038 #include "L1Trigger/GlobalTrigger/interface/L1GlobalTriggerGTL.h"
00039
00040 #include "FWCore/MessageLogger/interface/MessageLogger.h"
00041 #include "FWCore/MessageLogger/interface/MessageDrop.h"
00042
00043
00044
00045 L1GtMuonCondition::L1GtMuonCondition() :
00046 L1GtConditionEvaluation() {
00047
00048
00049
00050 }
00051
00052
00053 L1GtMuonCondition::L1GtMuonCondition(const L1GtCondition* muonTemplate,
00054 const L1GlobalTriggerGTL* ptrGTL, const int nrL1Mu,
00055 const int ifMuEtaNumberBits) :
00056 L1GtConditionEvaluation(),
00057 m_gtMuonTemplate(static_cast<const L1GtMuonTemplate*>(muonTemplate)),
00058 m_gtGTL(ptrGTL),
00059 m_ifMuEtaNumberBits(ifMuEtaNumberBits)
00060 {
00061 m_corrParDeltaPhiNrBins = 0;
00062 m_condMaxNumberObjects = nrL1Mu;
00063 }
00064
00065
00066 void L1GtMuonCondition::copy(const L1GtMuonCondition &cp) {
00067
00068 m_gtMuonTemplate = cp.gtMuonTemplate();
00069 m_gtGTL = cp.gtGTL();
00070
00071 m_ifMuEtaNumberBits = cp.gtIfMuEtaNumberBits();
00072 m_corrParDeltaPhiNrBins = cp.m_corrParDeltaPhiNrBins;
00073
00074 m_condMaxNumberObjects = cp.condMaxNumberObjects();
00075 m_condLastResult = cp.condLastResult();
00076 m_combinationsInCond = cp.getCombinationsInCond();
00077
00078 m_verbosity = cp.m_verbosity;
00079
00080 }
00081
00082 L1GtMuonCondition::L1GtMuonCondition(const L1GtMuonCondition& cp) :
00083 L1GtConditionEvaluation() {
00084 copy(cp);
00085 }
00086
00087
00088 L1GtMuonCondition::~L1GtMuonCondition() {
00089
00090
00091
00092 }
00093
00094
00095 L1GtMuonCondition& L1GtMuonCondition::operator= (const L1GtMuonCondition& cp)
00096 {
00097 copy(cp);
00098 return *this;
00099 }
00100
00101
00102 void L1GtMuonCondition::setGtMuonTemplate(const L1GtMuonTemplate* muonTempl) {
00103
00104 m_gtMuonTemplate = muonTempl;
00105
00106 }
00107
00109 void L1GtMuonCondition::setGtGTL(const L1GlobalTriggerGTL* ptrGTL) {
00110
00111 m_gtGTL = ptrGTL;
00112
00113 }
00114
00115
00116
00117 void L1GtMuonCondition::setGtIfMuEtaNumberBits(
00118 const int& ifMuEtaNumberBitsValue) {
00119
00120 m_ifMuEtaNumberBits = ifMuEtaNumberBitsValue;
00121
00122 }
00123
00124
00125 void L1GtMuonCondition::setGtCorrParDeltaPhiNrBins(
00126 const int& corrParDeltaPhiNrBins) {
00127
00128 m_corrParDeltaPhiNrBins = corrParDeltaPhiNrBins;
00129
00130 }
00131
00132
00133
00134 const bool L1GtMuonCondition::evaluateCondition() const {
00135
00136
00137 int nObjInCond = m_gtMuonTemplate->nrObjects();
00138
00139
00140 const std::vector<const L1MuGMTCand*>* candVec = m_gtGTL->getCandL1Mu();
00141
00142 int numberObjects = candVec->size();
00143
00144
00145 if (numberObjects < nObjInCond) {
00146 return false;
00147 }
00148
00149 std::vector<int> index(numberObjects);
00150
00151 for (int i = 0; i < numberObjects; ++i) {
00152 index[i] = i;
00153 }
00154
00155 int jumpIndex = 1;
00156 int jump = factorial(numberObjects - nObjInCond);
00157
00158 int totalLoops = 0;
00159 int passLoops = 0;
00160
00161
00162
00163
00164 bool condResult = false;
00165
00166
00167
00168 SingleCombInCond objectsInComb;
00169 objectsInComb.reserve(nObjInCond);
00170
00171
00172 (combinationsInCond()).clear();
00173
00174 do {
00175
00176 if (--jumpIndex)
00177 continue;
00178
00179 jumpIndex = jump;
00180 totalLoops++;
00181
00182
00183 objectsInComb.clear();
00184
00185 bool tmpResult = true;
00186
00187
00188 for (int i = 0; i < nObjInCond; i++) {
00189
00190 tmpResult &= checkObjectParameter(i, *(*candVec)[index[i]]);
00191 objectsInComb.push_back(index[i]);
00192
00193 }
00194
00195
00196
00197 if ( !tmpResult) {
00198
00199 continue;
00200
00201 }
00202
00203
00204 L1GtMuonTemplate::CorrelationParameter corrPar =
00205 *(m_gtMuonTemplate->correlationParameter());
00206
00207
00208 unsigned int chargeCorr = corrPar.chargeCorrelation;
00209
00210
00211 if ((chargeCorr & 1) == 0) {
00212
00213 for (int i = 0; i < nObjInCond; i++) {
00214
00215 bool chargeValid = (*candVec)[index[i]]->charge_valid();
00216 tmpResult &= chargeValid;
00217
00218 if ( !chargeValid) {
00219 continue;
00220 }
00221 }
00222
00223 if ( !tmpResult) {
00224 continue;
00225 }
00226
00227 if (nObjInCond == 1) {
00228
00229
00230 if ( ! ( ( (chargeCorr & 4) != 0 && (*candVec)[index[0]]->charge()> 0 )
00231 || ( (chargeCorr & 2) != 0 && (*candVec)[index[0]]->charge() < 0 ) )) {
00232
00233 continue;
00234 }
00235
00236 }
00237 else {
00238
00239
00240 bool equalSigns = true;
00241 for (int i = 0; i < nObjInCond-1; i++) {
00242 if ((*candVec)[index[i]]->charge() != (*candVec)[index[i+1]]->charge()) {
00243 equalSigns = false;
00244 break;
00245 }
00246 }
00247
00248
00249 if (nObjInCond == 2 || nObjInCond == 3) {
00250
00251 if ( ! ( ( (chargeCorr & 4) != 0 && equalSigns ) || ( (chargeCorr & 2) != 0
00252 && !equalSigns ) )) {
00253
00254 continue;
00255 }
00256 }
00257
00258
00259 if (nObjInCond == 4) {
00260
00261 unsigned int posCount = 0;
00262
00263 for (int i = 0; i < nObjInCond; i++) {
00264 if ((*candVec)[index[i]]->charge()> 0) {
00265 posCount++;
00266 }
00267 }
00268
00269
00270 if ( ! ( ( (chargeCorr & 4) != 0 && equalSigns ) || ( (chargeCorr & 2) != 0
00271 && posCount == 2 ) )) {
00272
00273 continue;
00274 }
00275 }
00276 }
00277 }
00278
00279
00280 if (m_gtMuonTemplate->wsc()) {
00281
00282
00283
00284
00285 const int ObjInWscComb = 2;
00286 if (nObjInCond != ObjInWscComb) {
00287
00288 edm::LogError("L1GlobalTrigger") << "\n Error: "
00289 << "number of particles in condition with spatial correlation = " << nObjInCond
00290 << "\n it must be = " << ObjInWscComb << std::endl;
00291
00292
00293 continue;
00294 }
00295
00296 unsigned int candDeltaEta;
00297 unsigned int candDeltaPhi;
00298
00299
00300
00301
00302
00303 int signedEta[ObjInWscComb];
00304 int signBit[ObjInWscComb] = { 0, 0 };
00305
00306 int scaleEta = 1 << (m_ifMuEtaNumberBits - 1);
00307
00308 for (int i = 0; i < ObjInWscComb; ++i) {
00309 signBit[i] = ((*candVec)[index[i]]->etaIndex() & scaleEta)>>(m_ifMuEtaNumberBits - 1);
00310 signedEta[i] = ((*candVec)[index[i]]->etaIndex() )%scaleEta;
00311
00312 if (signBit[i] == 1) {
00313 signedEta[i] = (-1)*signedEta[i];
00314 }
00315
00316 }
00317
00318
00319 candDeltaEta = static_cast<int> (std::abs(signedEta[1] - signedEta[0]))
00320 + static_cast<int> (signBit[1]^signBit[0]);
00321
00322 if ( !checkBit(corrPar.deltaEtaRange, candDeltaEta) ) {
00323 continue;
00324 }
00325
00326
00327
00328
00329 if ((*candVec)[index[0]]->phiIndex()> (*candVec)[index[1]]->phiIndex()) {
00330 candDeltaPhi = (*candVec)[index[0]]->phiIndex() - (*candVec)[index[1]]->phiIndex();
00331 }
00332 else {
00333 candDeltaPhi = (*candVec)[index[1]]->phiIndex() - (*candVec)[index[0]]->phiIndex();
00334 }
00335
00336
00337
00338
00339
00340 int nMaxLoop = 10;
00341 int iLoop = 0;
00342
00343 while (candDeltaPhi >= m_corrParDeltaPhiNrBins) {
00344
00345 unsigned int candDeltaPhiInitial = candDeltaPhi;
00346
00347
00348 candDeltaPhi = (m_corrParDeltaPhiNrBins - 1) * 2 - candDeltaPhi;
00349 if (m_verbosity) {
00350 LogTrace("L1GlobalTrigger")
00351 << " Initial candDeltaPhi = "
00352 << candDeltaPhiInitial
00353 << " > m_corrParDeltaPhiNrBins = "
00354 << m_corrParDeltaPhiNrBins
00355 << " ==> candDeltaPhi rescaled to: "
00356 << candDeltaPhi << " [ loop index " << iLoop
00357 << "; breaks after " << nMaxLoop << " loops ]\n"
00358 << std::endl;
00359 }
00360
00361 iLoop++;
00362 if (iLoop > nMaxLoop) {
00363 return false;
00364 }
00365 }
00366
00367
00368 if (candDeltaPhi < 64) {
00369 if (!checkBit(corrPar.deltaPhiRange0Word, candDeltaPhi) ) {
00370 continue;
00371 }
00372 }
00373 else {
00374 if (!checkBit(corrPar.deltaPhiRange1Word, (candDeltaPhi - 64))) {
00375 continue;
00376 }
00377 }
00378
00379 }
00380
00381
00382
00383
00384 condResult = true;
00385 passLoops++;
00386 (combinationsInCond()).push_back(objectsInComb);
00387
00388 } while (std::next_permutation(index.begin(), index.end()) );
00389
00390
00391
00392
00393
00394
00395 return condResult;
00396
00397 }
00398
00399
00400 const L1MuGMTCand* L1GtMuonCondition::getCandidate(const int indexCand) const {
00401
00402 return (*(m_gtGTL->getCandL1Mu()))[indexCand];
00403 }
00404
00414 const bool L1GtMuonCondition::checkObjectParameter(const int iCondition, const L1MuGMTCand& cand) const {
00415
00416
00417 int nObjInCond = m_gtMuonTemplate->nrObjects();
00418
00419 if (iCondition >= nObjInCond || iCondition < 0) {
00420 return false;
00421 }
00422
00423
00424 if (cand.empty()) {
00425 return false;
00426 }
00427
00428 const L1GtMuonTemplate::ObjectParameter objPar =
00429 ( *(m_gtMuonTemplate->objectParameter()) )[iCondition];
00430
00431
00432
00433
00434
00435
00436
00437
00438
00439
00440
00441
00442
00443
00444
00445
00446
00447
00448
00449
00450
00451
00452
00453
00454
00455
00456
00457 if ( !checkThreshold(objPar.ptHighThreshold, cand.ptIndex(), m_gtMuonTemplate->condGEq()) ) {
00458
00459 if ( !checkThreshold(objPar.ptLowThreshold, cand.ptIndex(), m_gtMuonTemplate->condGEq()) ) {
00460
00461 return false;
00462 }
00463 else {
00464
00465
00466 if ( !cand.isol() ) {
00467 if (objPar.requestIso || objPar.enableIso) {
00468
00469 return false;
00470 }
00471 }
00472
00473 }
00474
00475 }
00476 else {
00477
00478 if ( !cand.isol() ) {
00479 if (objPar.requestIso) {
00480
00481 return false;
00482 }
00483 }
00484
00485 }
00486
00487
00488
00489 if (!checkBit(objPar.etaRange, cand.etaIndex())) {
00490 return false;
00491 }
00492
00493
00494
00495
00496
00497 if (objPar.phiHigh >= objPar.phiLow) {
00498
00499 if (! ( (objPar.phiLow <= cand.phiIndex()) && (cand.phiIndex() <= objPar.phiHigh ) )) {
00500
00501 return false;
00502 }
00503
00504 }
00505 else {
00506 if (! ( (objPar.phiLow <= cand.phiIndex()) || (cand.phiIndex() <= objPar.phiHigh ) )) {
00507
00508 return false;
00509 }
00510 }
00511
00512
00513
00514
00515
00516
00517
00518 if (cand.quality() == 0) {
00519 return false;
00520 }
00521
00522 if (objPar.qualityRange == 0) {
00523 return false;
00524 }
00525 else {
00526 if (!checkBit(objPar.qualityRange, cand.quality())) {
00527 return false;
00528 }
00529 }
00530
00531
00532 if (objPar.enableMip) {
00533 if (!cand.mip()) {
00534
00535 return false;
00536 }
00537 }
00538
00539
00540
00541
00542
00543 return true;
00544 }
00545
00546 void L1GtMuonCondition::print(std::ostream& myCout) const {
00547
00548 m_gtMuonTemplate->print(myCout);
00549
00550 myCout << " Number of bits for eta of muon objects = "
00551 << m_ifMuEtaNumberBits << std::endl;
00552 myCout << " Maximum number of bins for the delta phi scales = "
00553 << m_corrParDeltaPhiNrBins << "\n " << std::endl;
00554
00555 L1GtConditionEvaluation::print(myCout);
00556
00557 }
00558