Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 12:53:51

0001 
0002 #include "DataFormats/L1GlobalTrigger/interface/L1GlobalTriggerObjectMaps.h"
0003 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0004 #include "DataFormats/Provenance/interface/ParameterSetID.h"
0005 
0006 #include <vector>
0007 #include <iostream>
0008 #include <cassert>
0009 
0010 int main() {
0011   L1GlobalTriggerObjectMaps objMaps1;
0012   L1GlobalTriggerObjectMaps objMaps2;
0013 
0014   objMaps1.pushBackAlgorithm(0, 1, true);
0015 
0016   objMaps1.pushBackAlgorithm(0, 2, false);
0017   objMaps1.pushBackCondition(0, 3, true);
0018   objMaps1.pushBackObjectIndex(2);
0019   objMaps1.pushBackObjectIndex(0);
0020   objMaps1.pushBackObjectIndex(1);
0021   objMaps1.pushBackObjectIndex(21);
0022   objMaps1.pushBackObjectIndex(11);
0023   objMaps1.pushBackObjectIndex(31);
0024   objMaps1.pushBackCondition(6, 0, false);
0025 
0026   objMaps1.pushBackAlgorithm(2, 3, true);
0027   objMaps1.pushBackCondition(6, 1, true);
0028   objMaps1.pushBackObjectIndex(11);
0029 
0030   objMaps1.pushBackAlgorithm(3, 5, true);
0031 
0032   objMaps1.consistencyCheck();
0033 
0034   edm::ParameterSet pset;
0035   pset.addParameter<int>("blah", 1);
0036   pset.registerIt();
0037   edm::ParameterSetID psetID = pset.id();
0038   objMaps1.setNamesParameterSetID(psetID);
0039 
0040   swap(objMaps1, objMaps2);
0041 
0042   assert(psetID == objMaps2.namesParameterSetID());
0043 
0044   std::vector<int> algoBitNumbers;
0045   algoBitNumbers.push_back(11);  // should get erased
0046   objMaps1.getAlgorithmBitNumbers(algoBitNumbers);
0047   std::vector<int> expected;  // empty at this point
0048   assert(expected == algoBitNumbers);
0049 
0050   objMaps2.getAlgorithmBitNumbers(algoBitNumbers);
0051   expected.push_back(1);
0052   expected.push_back(2);
0053   expected.push_back(3);
0054   expected.push_back(5);
0055   assert(expected == algoBitNumbers);
0056 
0057   assert(objMaps2.algorithmResult(1) == true);
0058   assert(objMaps2.algorithmResult(2) == false);
0059   assert(objMaps2.algorithmResult(3) == true);
0060 
0061   L1GlobalTriggerObjectMaps::AlgorithmResult ar1;
0062   assert(ar1.startIndexOfConditions() == 0);
0063   assert(ar1.algorithmBitNumber() == 0);
0064   assert(ar1.algorithmResult() == false);
0065 
0066   L1GlobalTriggerObjectMaps::AlgorithmResult ar2(5, 1, true);
0067   assert(ar2.startIndexOfConditions() == 5);
0068   assert(ar2.algorithmBitNumber() == 1);
0069   assert(ar2.algorithmResult() == true);
0070   L1GlobalTriggerObjectMaps::AlgorithmResult ar3(6, 1, true);
0071   assert(ar1 < ar2);
0072   assert(!(ar2 < ar3));
0073 
0074   L1GlobalTriggerObjectMaps::ConditionResult cr1;
0075   assert(cr1.startIndexOfCombinations() == 0);
0076   assert(cr1.nObjectsPerCombination() == 0);
0077   assert(cr1.conditionResult() == false);
0078 
0079   L1GlobalTriggerObjectMaps::ConditionResult cr2(10, 11, true);
0080   assert(cr2.startIndexOfCombinations() == 10);
0081   assert(cr2.nObjectsPerCombination() == 11);
0082   assert(cr2.conditionResult() == true);
0083 
0084   assert(objMaps2.getNumberOfConditions(1) == 0);
0085   assert(objMaps2.getNumberOfConditions(2) == 2);
0086   assert(objMaps2.getNumberOfConditions(3) == 1);
0087   assert(objMaps2.getNumberOfConditions(5) == 0);
0088 
0089   std::vector<L1GtLogicParser::OperandToken> operandTokenVector;
0090   objMaps2.updateOperandTokenVector(1, operandTokenVector);
0091 
0092   L1GtLogicParser::OperandToken token0;
0093   token0.tokenName = "car";
0094   token0.tokenNumber = 5;
0095   token0.tokenResult = false;
0096   operandTokenVector.push_back(token0);
0097 
0098   L1GtLogicParser::OperandToken token1;
0099   token1.tokenName = "car";
0100   token1.tokenNumber = 5;
0101   token1.tokenResult = true;
0102   operandTokenVector.push_back(token1);
0103 
0104   objMaps2.updateOperandTokenVector(2, operandTokenVector);
0105 
0106   assert(operandTokenVector.at(0).tokenResult == true);
0107   assert(operandTokenVector.at(1).tokenResult == false);
0108 
0109   L1GlobalTriggerObjectMaps::ConditionsInAlgorithm conditions = objMaps2.getConditionsInAlgorithm(2);
0110 
0111   assert(conditions.nConditions() == 2);
0112   assert(conditions.getConditionResult(0) == true);
0113   assert(conditions.getConditionResult(1) == false);
0114 
0115   L1GlobalTriggerObjectMaps::CombinationsInCondition combinations = objMaps2.getCombinationsInCondition(2, 0);
0116 
0117   assert(combinations.nCombinations() == 2);
0118   assert(combinations.nObjectsPerCombination() == 3);
0119   assert(combinations.getObjectIndex(0, 0) == 2);
0120   assert(combinations.getObjectIndex(0, 1) == 0);
0121   assert(combinations.getObjectIndex(0, 2) == 1);
0122   assert(combinations.getObjectIndex(1, 0) == 21);
0123   assert(combinations.getObjectIndex(1, 1) == 11);
0124   assert(combinations.getObjectIndex(1, 2) == 31);
0125 
0126   L1GlobalTriggerObjectMaps::CombinationsInCondition combinations1 = objMaps2.getCombinationsInCondition(3, 0);
0127 
0128   assert(combinations1.nCombinations() == 1);
0129   assert(combinations1.nObjectsPerCombination() == 1);
0130   assert(combinations1.getObjectIndex(0, 0) == 11);
0131 
0132   L1GlobalTriggerObjectMaps::CombinationsInCondition combinations2 = objMaps2.getCombinationsInCondition(2, 1);
0133 
0134   assert(combinations2.nCombinations() == 0);
0135   assert(combinations2.nObjectsPerCombination() == 0);
0136 
0137   return 0;
0138 }