52 const GtBoard* ptrGTL,
const int nrL1Mu,
53 const int ifMuEtaNumberBits) :
57 m_ifMuEtaNumberBits(ifMuEtaNumberBits)
102 m_gtMuonTemplate = muonTempl;
116 const int& ifMuEtaNumberBitsValue) {
118 m_ifMuEtaNumberBits = ifMuEtaNumberBitsValue;
124 const int& corrParDeltaPhiNrBins) {
126 m_corrParDeltaPhiNrBins = corrParDeltaPhiNrBins;
138 int nObjInCond = m_gtMuonTemplate->nrObjects();
144 int useBx = bxEval + m_gtMuonTemplate->condRelativeBx();
147 if( ( useBx < candVec->getFirstBX() ) ||
152 int numberObjects = candVec->
size(useBx);
155 if (numberObjects < nObjInCond) {
159 std::vector<int>
index(numberObjects);
161 for (
int i = 0;
i < numberObjects; ++
i) {
166 int jump =
factorial(numberObjects - nObjInCond);
174 bool condResult =
false;
179 objectsInComb.reserve(nObjInCond);
182 (combinationsInCond()).
clear();
193 objectsInComb.clear();
195 bool tmpResult =
true;
197 bool passCondition =
false;
199 for (
int i = 0;
i < nObjInCond;
i++) {
201 passCondition = checkObjectParameter(
i, *(candVec->
at(useBx,index[
i]) ));
202 tmpResult &= passCondition;
204 LogDebug(
"l1t|Global") <<
"===> MuCondition::evaluateCondition, CONGRATS!! This muon passed the condition." << std::endl;
206 LogDebug(
"l1t|Global") <<
"===> MuCondition::evaluateCondition, FAIL!! This muon failed the condition." << std::endl;
207 objectsInComb.push_back(index[i]);
221 *(m_gtMuonTemplate->correlationParameter());
227 if ((chargeCorr & 1) == 0) {
229 for (
int i = 0;
i < nObjInCond;
i++) {
231 int chargeValid = (candVec->
at(useBx,index[
i]))->hwChargeValid();
232 tmpResult &= chargeValid;
234 if ( chargeValid==0) {
243 if (nObjInCond == 1) {
246 if ( ! ( ( (chargeCorr & 4) != 0 && (candVec->
at(useBx,index[0]))->
charge()> 0 )
247 || ( (chargeCorr & 2) != 0 && (candVec->
at(useBx,index[0]))->
charge() < 0 ) )) {
256 bool equalSigns =
true;
257 for (
int i = 0;
i < nObjInCond-1;
i++) {
258 if ((candVec->
at(useBx,index[
i]))->
charge() != (candVec->
at(useBx,index[i+1]))->
charge()) {
265 if (nObjInCond == 2 || nObjInCond == 3) {
267 if ( ! ( ( (chargeCorr & 4) != 0 && equalSigns ) || ( (chargeCorr & 2) != 0
268 && !equalSigns ) )) {
275 if (nObjInCond == 4) {
277 unsigned int posCount = 0;
279 for (
int i = 0;
i < nObjInCond;
i++) {
280 if ((candVec->
at(useBx,index[
i]))->
charge()> 0) {
286 if ( ! ( ( (chargeCorr & 4) != 0 && equalSigns ) || ( (chargeCorr & 2) != 0
287 && posCount == 2 ) )) {
296 if (m_gtMuonTemplate->wsc()) {
301 const int ObjInWscComb = 2;
302 if (nObjInCond != ObjInWscComb) {
305 <<
"number of particles in condition with spatial correlation = " << nObjInCond
306 <<
"\n it must be = " << ObjInWscComb << std::endl;
312 unsigned int candDeltaEta;
313 unsigned int candDeltaPhi;
319 int signedEta[ObjInWscComb];
320 int signBit[ObjInWscComb] = { 0, 0 };
322 int scaleEta = 1 << (m_ifMuEtaNumberBits - 1);
324 for (
int i = 0;
i < ObjInWscComb; ++
i) {
325 signBit[
i] = ((candVec->
at(useBx,index[
i]))->hwEta() & scaleEta)>>(m_ifMuEtaNumberBits - 1);
326 signedEta[
i] = ((candVec->
at(useBx,index[i]))->hwEta() )%scaleEta;
328 if (signBit[i] == 1) {
329 signedEta[
i] = (-1)*signedEta[i];
335 candDeltaEta =
static_cast<int> (
std::abs(signedEta[1] - signedEta[0]))
336 + static_cast<int> (signBit[1]^signBit[0]);
345 if ((candVec->
at(useBx,index[0]))->hwPhi()> (candVec->
at(useBx,index[1]))->hwPhi()) {
346 candDeltaPhi = (candVec->
at(useBx,index[0]))->hwPhi() - (candVec->
at(useBx,index[1]))->hwPhi();
349 candDeltaPhi = (candVec->
at(useBx,index[1]))->hwPhi() - (candVec->
at(useBx,index[0]))->hwPhi();
359 while (candDeltaPhi >= m_corrParDeltaPhiNrBins) {
361 unsigned int candDeltaPhiInitial = candDeltaPhi;
364 candDeltaPhi = (m_corrParDeltaPhiNrBins - 1) * 2 - candDeltaPhi;
367 <<
" Initial candDeltaPhi = "
368 << candDeltaPhiInitial
369 <<
" > m_corrParDeltaPhiNrBins = "
370 << m_corrParDeltaPhiNrBins
371 <<
" ==> candDeltaPhi rescaled to: "
372 << candDeltaPhi <<
" [ loop index " << iLoop
373 <<
"; breaks after " << nMaxLoop <<
" loops ]\n"
378 if (iLoop > nMaxLoop) {
384 if (candDeltaPhi < 64) {
402 (combinationsInCond()).push_back(objectsInComb);
404 }
while (std::next_permutation(index.begin(), index.end()) );
418 return (m_gtGTL->getCandL1Mu())->
at(bx,indexCand);
433 int nObjInCond = m_gtMuonTemplate->nrObjects();
435 if (iCondition >= nObjInCond || iCondition < 0) {
445 ( *(m_gtMuonTemplate->objectParameter()) )[iCondition];
473 <<
"\n MuonTemplate::ObjectParameter : "
477 <<
"\n\t enableIso = " << objPar.
enableIso
478 <<
"\n\t etaRange = " << objPar.
etaRange
479 <<
"\n\t phiLow = " << objPar.
phiLow
480 <<
"\n\t phiHigh = " << objPar.
phiHigh
482 <<
"\n\t enableMip = " << objPar.
enableMip
487 <<
"\n\t hwPt = " << cand.
hwPt()
488 <<
"\n\t hwEta = " << cand.
hwEta()
489 <<
"\n\t hwPhi = " << cand.
hwPhi()
490 <<
"\n\t hwQual = " << cand.
hwQual()
491 <<
"\n\t hwIso = " << cand.
hwIso()
492 <<
"\n\t hwMip = " << cand.
hwMip()
498 if ( !checkThreshold(objPar.
ptLowThreshold, cand.
hwPt(), m_gtMuonTemplate->condGEq()) ) {
499 LogDebug(
"l1t|Global") <<
"\t\t Muon Failed checkThreshold " << std::endl;
504 if ( !cand.
hwIso() ) {
506 LogDebug(
"l1t|Global") <<
"\t\t Muon Failed hwIso " << std::endl;
514 if ( !cand.
hwIso() ) {
516 LogDebug(
"l1t|Global") <<
"\t\t Muon Failed hwIso " << std::endl;
562 LogDebug(
"l1t|Global") <<
"\t\t Muon Failed hwQual() == 0" << std::endl;
567 LogDebug(
"l1t|Global") <<
"\t\t Muon Failed qualityRange == 0" << std::endl;
572 LogDebug(
"l1t|Global") <<
"\t\t Muon Failed checkBit(qualityRange) " << std::endl;
580 LogDebug(
"l1t|Global") <<
"\t\t Muon Failed enableMip" << std::endl;
594 m_gtMuonTemplate->print(myCout);
596 myCout <<
" Number of bits for eta of muon objects = "
597 << m_ifMuEtaNumberBits << std::endl;
598 myCout <<
" Maximum number of bins for the delta phi scales = "
599 << m_corrParDeltaPhiNrBins <<
"\n " << std::endl;
unsigned size(int bx) const
CombinationsInCond const & getCombinationsInCond() const
get all the object combinations evaluated to true in the condition
unsigned int qualityRange
const MuonTemplate * gtMuonTemplate() const
get / set the pointer to a Condition
unsigned int ptHighThreshold
void print(std::ostream &myCout) const
print condition
const bool checkObjectParameter(const int iCondition, const l1t::Muon &cand) const
function to check a single object if it matches a condition
virtual void print(std::ostream &myCout) const
print condition
std::vector< int > SingleCombInCond
typedefs
const bool evaluateCondition(const int bxEval) const
the core function to check if the condition matches
unsigned int ptLowThreshold
bool condLastResult() const
get the latest result for the condition
const int gtIfMuEtaNumberBits() const
get / set the number of bits for eta of muon objects
unsigned long long etaRange
void clear(CLHEP::HepGenMatrix &m)
Helper function: Reset all elements of a matrix to 0.
unsigned int m_corrParDeltaPhiNrBins
Abs< T >::type abs(const T &t)
void setGtIfMuEtaNumberBits(const int &)
unsigned long long deltaPhiRange0Word
void setGtGTL(const GtBoard *)
set the pointer to GTL
int m_verbosity
verbosity level
void setGtCorrParDeltaPhiNrBins(const int &)
int condMaxNumberObjects() const
void copy(const MuCondition &cp)
copy function for copy constructor and operator=
void setGtMuonTemplate(const MuonTemplate *)
unsigned long long deltaPhiRange1Word
unsigned long long deltaEtaRange
int factorial(int n)
factorial function
int m_condMaxNumberObjects
const l1t::Muon * getCandidate(const int bx, const int indexCand) const
load muon candidates
const T & at(int bx, int i) const
unsigned int chargeCorrelation
MuCondition & operator=(const MuCondition &)
const GtBoard * gtGTL() const
get / set the pointer to GTL