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) {
165 int numberForFactorial = numberObjects - nObjInCond;
169 for(
int i=numberForFactorial;
i>0;
i-- ) myfactorial *=
i;
172 int jump = myfactorial;
180 bool condResult =
false;
185 objectsInComb.reserve(nObjInCond);
188 (combinationsInCond()).
clear();
199 objectsInComb.clear();
201 bool tmpResult =
true;
203 bool passCondition =
false;
205 for (
int i = 0;
i < nObjInCond;
i++) {
207 passCondition = checkObjectParameter(
i, *(candVec->
at(useBx,index[
i]) ));
208 tmpResult &= passCondition;
210 LogDebug(
"l1t|Global") <<
"===> MuCondition::evaluateCondition, CONGRATS!! This muon passed the condition." << std::endl;
212 LogDebug(
"l1t|Global") <<
"===> MuCondition::evaluateCondition, FAIL!! This muon failed the condition." << std::endl;
213 objectsInComb.push_back(index[i]);
227 *(m_gtMuonTemplate->correlationParameter());
233 if ((chargeCorr & 1) == 0) {
235 for (
int i = 0;
i < nObjInCond;
i++) {
237 int chargeValid = (candVec->
at(useBx,index[
i]))->hwChargeValid();
238 tmpResult &= chargeValid;
240 if ( chargeValid==0) {
249 if (nObjInCond == 1) {
252 if ( ! ( ( (chargeCorr & 4) != 0 && (candVec->
at(useBx,index[0]))->charge()> 0 )
253 || ( (chargeCorr & 2) != 0 && (candVec->
at(useBx,index[0]))->charge() < 0 ) )) {
262 bool equalSigns =
true;
263 for (
int i = 0;
i < nObjInCond-1;
i++) {
264 if ((candVec->
at(useBx,index[
i]))->charge() != (candVec->
at(useBx,index[i+1]))->charge()) {
271 if (nObjInCond == 2 || nObjInCond == 3) {
273 if ( ! ( ( (chargeCorr & 4) != 0 && equalSigns ) || ( (chargeCorr & 2) != 0
274 && !equalSigns ) )) {
281 if (nObjInCond == 4) {
283 unsigned int posCount = 0;
285 for (
int i = 0;
i < nObjInCond;
i++) {
286 if ((candVec->
at(useBx,index[
i]))->charge()> 0) {
292 if ( ! ( ( (chargeCorr & 4) != 0 && equalSigns ) || ( (chargeCorr & 2) != 0
293 && posCount == 2 ) )) {
302 if (m_gtMuonTemplate->wsc()) {
307 const int ObjInWscComb = 2;
308 if (nObjInCond != ObjInWscComb) {
311 <<
"number of particles in condition with spatial correlation = " << nObjInCond
312 <<
"\n it must be = " << ObjInWscComb << std::endl;
318 unsigned int candDeltaEta;
319 unsigned int candDeltaPhi;
325 int signedEta[ObjInWscComb];
326 int signBit[ObjInWscComb] = { 0, 0 };
328 int scaleEta = 1 << (m_ifMuEtaNumberBits - 1);
330 for (
int i = 0;
i < ObjInWscComb; ++
i) {
331 signBit[
i] = ((candVec->
at(useBx,index[
i]))->hwEta() & scaleEta)>>(m_ifMuEtaNumberBits - 1);
332 signedEta[
i] = ((candVec->
at(useBx,index[i]))->hwEta() )%scaleEta;
334 if (signBit[i] == 1) {
335 signedEta[
i] = (-1)*signedEta[i];
341 candDeltaEta =
static_cast<int> (
std::abs(signedEta[1] - signedEta[0]))
342 + static_cast<int> (signBit[1]^signBit[0]);
351 if ((candVec->
at(useBx,index[0]))->hwPhi()> (candVec->
at(useBx,index[1]))->hwPhi()) {
352 candDeltaPhi = (candVec->
at(useBx,index[0]))->hwPhi() - (candVec->
at(useBx,index[1]))->hwPhi();
355 candDeltaPhi = (candVec->
at(useBx,index[1]))->hwPhi() - (candVec->
at(useBx,index[0]))->hwPhi();
365 while (candDeltaPhi >= m_corrParDeltaPhiNrBins) {
367 unsigned int candDeltaPhiInitial = candDeltaPhi;
370 candDeltaPhi = (m_corrParDeltaPhiNrBins - 1) * 2 - candDeltaPhi;
373 <<
" Initial candDeltaPhi = "
374 << candDeltaPhiInitial
375 <<
" > m_corrParDeltaPhiNrBins = "
376 << m_corrParDeltaPhiNrBins
377 <<
" ==> candDeltaPhi rescaled to: "
378 << candDeltaPhi <<
" [ loop index " << iLoop
379 <<
"; breaks after " << nMaxLoop <<
" loops ]\n"
384 if (iLoop > nMaxLoop) {
390 if (candDeltaPhi < 64) {
408 (combinationsInCond()).push_back(objectsInComb);
410 }
while (std::next_permutation(index.begin(), index.end()) );
424 return (m_gtGTL->getCandL1Mu())->
at(bx,indexCand);
439 int nObjInCond = m_gtMuonTemplate->nrObjects();
441 if (iCondition >= nObjInCond || iCondition < 0) {
451 ( *(m_gtMuonTemplate->objectParameter()) )[iCondition];
479 <<
"\n MuonTemplate::ObjectParameter : "
483 <<
"\n\t enableIso = " << objPar.
enableIso
484 <<
"\n\t etaRange = " << objPar.
etaRange
485 <<
"\n\t phiLow = " << objPar.
phiLow
486 <<
"\n\t phiHigh = " << objPar.
phiHigh
488 <<
"\n\t enableMip = " << objPar.
enableMip
493 <<
"\n\t hwPt = " << cand.
hwPt()
494 <<
"\n\t hwEta = " << cand.
hwEta()
495 <<
"\n\t hwPhi = " << cand.
hwPhi()
496 <<
"\n\t hwQual = " << cand.
hwQual()
497 <<
"\n\t hwIso = " << cand.
hwIso()
498 <<
"\n\t hwMip = " << cand.
hwMip()
504 if ( !checkThreshold(objPar.
ptLowThreshold, cand.
hwPt(), m_gtMuonTemplate->condGEq()) ) {
505 LogDebug(
"l1t|Global") <<
"\t\t Muon Failed checkThreshold " << std::endl;
510 if ( !cand.
hwIso() ) {
512 LogDebug(
"l1t|Global") <<
"\t\t Muon Failed hwIso " << std::endl;
520 if ( !cand.
hwIso() ) {
522 LogDebug(
"l1t|Global") <<
"\t\t Muon Failed hwIso " << std::endl;
568 LogDebug(
"l1t|Global") <<
"\t\t Muon Failed hwQual() == 0" << std::endl;
573 LogDebug(
"l1t|Global") <<
"\t\t Muon Failed qualityRange == 0" << std::endl;
578 LogDebug(
"l1t|Global") <<
"\t\t Muon Failed checkBit(qualityRange) " << std::endl;
586 LogDebug(
"l1t|Global") <<
"\t\t Muon Failed enableMip" << std::endl;
600 m_gtMuonTemplate->print(myCout);
602 myCout <<
" Number of bits for eta of muon objects = "
603 << m_ifMuEtaNumberBits << std::endl;
604 myCout <<
" Maximum number of bins for the delta phi scales = "
605 << 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 m_condMaxNumberObjects
const l1t::Muon * getCandidate(const int bx, const int indexCand) const
load muon candidates
unsigned int chargeCorrelation
MuCondition & operator=(const MuCondition &)
const GtBoard * gtGTL() const
get / set the pointer to GTL
const T & at(int bx, unsigned i) const