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
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
00073 m_condMaxNumberObjects = cp.condMaxNumberObjects();
00074 m_condLastResult = cp.condLastResult();
00075 m_combinationsInCond = cp.getCombinationsInCond();
00076
00077 m_verbosity = cp.m_verbosity;
00078
00079 }
00080
00081 L1GtMuonCondition::L1GtMuonCondition(const L1GtMuonCondition& cp) :
00082 L1GtConditionEvaluation() {
00083 copy(cp);
00084 }
00085
00086
00087 L1GtMuonCondition::~L1GtMuonCondition() {
00088
00089
00090
00091 }
00092
00093
00094 L1GtMuonCondition& L1GtMuonCondition::operator= (const L1GtMuonCondition& cp)
00095 {
00096 copy(cp);
00097 return *this;
00098 }
00099
00100
00101 void L1GtMuonCondition::setGtMuonTemplate(const L1GtMuonTemplate* muonTempl) {
00102
00103 m_gtMuonTemplate = muonTempl;
00104
00105 }
00106
00107
00108 void L1GtMuonCondition::setGtIfMuEtaNumberBits(const int& ifMuEtaNumberBitsValue) {
00109
00110 m_ifMuEtaNumberBits = ifMuEtaNumberBitsValue;
00111
00112 }
00113
00115 void L1GtMuonCondition::setGtGTL(const L1GlobalTriggerGTL* ptrGTL) {
00116
00117 m_gtGTL = ptrGTL;
00118
00119 }
00120
00121
00122 const bool L1GtMuonCondition::evaluateCondition() const {
00123
00124
00125 int nObjInCond = m_gtMuonTemplate->nrObjects();
00126
00127
00128 const std::vector<const L1MuGMTCand*>* candVec = m_gtGTL->getCandL1Mu();
00129
00130 int numberObjects = candVec->size();
00131
00132
00133 if (numberObjects < nObjInCond) {
00134 return false;
00135 }
00136
00137 std::vector<int> index(numberObjects);
00138
00139 for (int i = 0; i < numberObjects; ++i) {
00140 index[i] = i;
00141 }
00142
00143 int jumpIndex = 1;
00144 int jump = factorial(numberObjects - nObjInCond);
00145
00146 int totalLoops = 0;
00147 int passLoops = 0;
00148
00149
00150
00151
00152 bool condResult = false;
00153
00154
00155
00156 SingleCombInCond objectsInComb;
00157 objectsInComb.reserve(nObjInCond);
00158
00159
00160 (*m_combinationsInCond).clear();
00161
00162 do {
00163
00164 if (--jumpIndex)
00165 continue;
00166
00167 jumpIndex = jump;
00168 totalLoops++;
00169
00170
00171 objectsInComb.clear();
00172
00173 bool tmpResult = true;
00174
00175
00176 for (int i = 0; i < nObjInCond; i++) {
00177
00178 tmpResult &= checkObjectParameter(i, *(*candVec)[index[i]]);
00179 objectsInComb.push_back(index[i]);
00180
00181 }
00182
00183
00184
00185 if ( !tmpResult) {
00186
00187 continue;
00188
00189 }
00190
00191
00192 L1GtMuonTemplate::CorrelationParameter corrPar =
00193 *(m_gtMuonTemplate->correlationParameter());
00194
00195
00196 unsigned int chargeCorr = corrPar.chargeCorrelation;
00197
00198
00199 if ((chargeCorr & 1) == 0) {
00200
00201 for (int i = 0; i < nObjInCond; i++) {
00202
00203 bool chargeValid = (*candVec)[index[i]]->charge_valid();
00204 tmpResult &= chargeValid;
00205
00206 if ( !chargeValid) {
00207 continue;
00208 }
00209 }
00210
00211 if ( !tmpResult) {
00212 continue;
00213 }
00214
00215 if (nObjInCond == 1) {
00216
00217
00218 if ( ! ( ( (chargeCorr & 4) != 0 && (*candVec)[index[0]]->charge()> 0 )
00219 || ( (chargeCorr & 2) != 0 && (*candVec)[index[0]]->charge() < 0 ) )) {
00220
00221 continue;
00222 }
00223
00224 }
00225 else {
00226
00227
00228 bool equalSigns = true;
00229 for (int i = 0; i < nObjInCond-1; i++) {
00230 if ((*candVec)[index[i]]->charge() != (*candVec)[index[i+1]]->charge()) {
00231 equalSigns = false;
00232 break;
00233 }
00234 }
00235
00236
00237 if (nObjInCond == 2 || nObjInCond == 3) {
00238
00239 if ( ! ( ( (chargeCorr & 4) != 0 && equalSigns ) || ( (chargeCorr & 2) != 0
00240 && !equalSigns ) )) {
00241
00242 continue;
00243 }
00244 }
00245
00246
00247 if (nObjInCond == 4) {
00248
00249 unsigned int posCount = 0;
00250
00251 for (int i = 0; i < nObjInCond; i++) {
00252 if ((*candVec)[index[i]]->charge()> 0) {
00253 posCount++;
00254 }
00255 }
00256
00257
00258 if ( ! ( ( (chargeCorr & 4) != 0 && equalSigns ) || ( (chargeCorr & 2) != 0
00259 && posCount == 2 ) )) {
00260
00261 continue;
00262 }
00263 }
00264 }
00265 }
00266
00267
00268 if (m_gtMuonTemplate->wsc()) {
00269
00270
00271
00272
00273 const int ObjInWscComb = 2;
00274 if (nObjInCond != ObjInWscComb) {
00275
00276 edm::LogError("L1GtMuonCondition") << "\n Error: "
00277 << "number of particles in condition with spatial correlation = " << nObjInCond
00278 << "\n it must be = " << ObjInWscComb << std::endl;
00279
00280
00281 continue;
00282 }
00283
00284 unsigned int candDeltaEta;
00285 unsigned int candDeltaPhi;
00286
00287
00288
00289
00290
00291 int signedEta[ObjInWscComb];
00292 int signBit[ObjInWscComb] = { 0, 0 };
00293
00294 int scaleEta = 1 << (m_ifMuEtaNumberBits - 1);
00295
00296 for (int i = 0; i < ObjInWscComb; ++i) {
00297 signBit[i] = ((*candVec)[index[i]]->etaIndex() & scaleEta)>>(m_ifMuEtaNumberBits - 1);
00298 signedEta[i] = ((*candVec)[index[i]]->etaIndex() )%scaleEta;
00299
00300 if (signBit[i] == 1) {
00301 signedEta[i] = (-1)*signedEta[i];
00302 }
00303
00304 }
00305
00306
00307 candDeltaEta = static_cast<int> (std::abs(signedEta[1] - signedEta[0]))
00308 + static_cast<int> (signBit[1]^signBit[0]);
00309
00310 if ( !checkBit(corrPar.deltaEtaRange, candDeltaEta) ) {
00311 continue;
00312 }
00313
00314
00315
00316
00317 if ((*candVec)[index[0]]->phiIndex()> (*candVec)[index[1]]->phiIndex()) {
00318 candDeltaPhi = (*candVec)[index[0]]->phiIndex() - (*candVec)[index[1]]->phiIndex();
00319 }
00320 else {
00321 candDeltaPhi = (*candVec)[index[1]]->phiIndex() - (*candVec)[index[0]]->phiIndex();
00322 }
00323
00324
00325
00326 while (candDeltaPhi> corrPar.deltaPhiMaxbits) {
00327
00328
00329 candDeltaPhi = (corrPar.deltaPhiMaxbits - 1)*2 - candDeltaPhi;
00330 LogTrace("L1GtMuonCondition") << " candDeltaPhi rescaled to: " << candDeltaPhi
00331 << std::endl;
00332 }
00333
00334
00335 if (candDeltaPhi < 64) {
00336 if (!checkBit(corrPar.deltaPhiRange0Word, candDeltaPhi) ) {
00337 continue;
00338 }
00339 }
00340 else {
00341 if (!checkBit(corrPar.deltaPhiRange1Word, (candDeltaPhi - 64))) {
00342 continue;
00343 }
00344 }
00345
00346 }
00347
00348
00349
00350
00351 condResult = true;
00352 passLoops++;
00353 (*m_combinationsInCond).push_back(objectsInComb);
00354
00355 } while (std::next_permutation(index.begin(), index.end()) );
00356
00357
00358
00359
00360
00361
00362 return condResult;
00363
00364 }
00365
00366
00367 const L1MuGMTCand* L1GtMuonCondition::getCandidate(const int indexCand) const {
00368
00369 return (*(m_gtGTL->getCandL1Mu()))[indexCand];
00370 }
00371
00381 const bool L1GtMuonCondition::checkObjectParameter(const int iCondition, const L1MuGMTCand& cand) const {
00382
00383
00384 int nObjInCond = m_gtMuonTemplate->nrObjects();
00385
00386 if (iCondition >= nObjInCond || iCondition < 0) {
00387 return false;
00388 }
00389
00390
00391 if (cand.empty()) {
00392 return false;
00393 }
00394
00395 const L1GtMuonTemplate::ObjectParameter objPar =
00396 ( *(m_gtMuonTemplate->objectParameter()) )[iCondition];
00397
00398
00399
00400
00401
00402
00403
00404
00405
00406
00407
00408
00409
00410
00411
00412
00413
00414
00415
00416
00417
00418
00419
00420
00421
00422
00423
00424 if ( !checkThreshold(objPar.ptHighThreshold, cand.ptIndex(), m_gtMuonTemplate->condGEq()) ) {
00425
00426 if ( !checkThreshold(objPar.ptLowThreshold, cand.ptIndex(), m_gtMuonTemplate->condGEq()) ) {
00427
00428 return false;
00429 }
00430 else {
00431
00432
00433 if ( !cand.isol() ) {
00434 if (objPar.requestIso || objPar.enableIso) {
00435
00436 return false;
00437 }
00438 }
00439
00440 }
00441
00442 }
00443 else {
00444
00445 if ( !cand.isol() ) {
00446 if (objPar.requestIso) {
00447
00448 return false;
00449 }
00450 }
00451
00452 }
00453
00454
00455
00456 if (!checkBit(objPar.etaRange, cand.etaIndex())) {
00457 return false;
00458 }
00459
00460
00461
00462
00463
00464 if (objPar.phiHigh >= objPar.phiLow) {
00465
00466 if (! ( (objPar.phiLow <= cand.phiIndex()) && (cand.phiIndex() <= objPar.phiHigh ) )) {
00467
00468 return false;
00469 }
00470
00471 }
00472 else {
00473 if (! ( (objPar.phiLow <= cand.phiIndex()) || (cand.phiIndex() <= objPar.phiHigh ) )) {
00474
00475 return false;
00476 }
00477 }
00478
00479
00480
00481
00482
00483
00484
00485 if (cand.quality() == 0) {
00486 return false;
00487 }
00488
00489 if (objPar.qualityRange == 0) {
00490 return false;
00491 }
00492 else {
00493 if (!checkBit(objPar.qualityRange, cand.quality())) {
00494 return false;
00495 }
00496 }
00497
00498
00499 if (objPar.enableMip) {
00500 if (!cand.mip()) {
00501
00502 return false;
00503 }
00504 }
00505
00506
00507
00508
00509
00510 return true;
00511 }
00512
00513 void L1GtMuonCondition::print(std::ostream& myCout) const {
00514
00515 m_gtMuonTemplate->print(myCout);
00516 L1GtConditionEvaluation::print(myCout);
00517
00518 }
00519