Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-09-28 23:48:44

0001 /**
0002  * \class L1GtTriggerMaskAlgoTrigConfigOnlineProd
0003  *
0004  *
0005  * Description: online producer for L1GtTriggerMaskAlgoTrigRcd.
0006  *
0007  * Implementation:
0008  *    <TODO: enter implementation details>
0009  *
0010  * \author: Vasile Mihai Ghete - HEPHY Vienna
0011  *
0012  *
0013  */
0014 
0015 // this class header
0016 #include "L1TriggerConfig/L1GtConfigProducers/interface/L1GtTriggerMaskAlgoTrigConfigOnlineProd.h"
0017 
0018 // system include files
0019 #include <vector>
0020 
0021 // user include files
0022 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0023 
0024 // constructor
0025 L1GtTriggerMaskAlgoTrigConfigOnlineProd::L1GtTriggerMaskAlgoTrigConfigOnlineProd(const edm::ParameterSet& parSet)
0026     : L1ConfigOnlineProdBase<L1GtTriggerMaskAlgoTrigRcd, L1GtTriggerMask>(parSet),
0027       m_partitionNumber(parSet.getParameter<int>("PartitionNumber")) {
0028   // empty
0029 }
0030 
0031 // destructor
0032 L1GtTriggerMaskAlgoTrigConfigOnlineProd::~L1GtTriggerMaskAlgoTrigConfigOnlineProd() {
0033   // empty
0034 }
0035 
0036 // public methods
0037 
0038 std::unique_ptr<L1GtTriggerMask> L1GtTriggerMaskAlgoTrigConfigOnlineProd::newObject(const std::string& objectKey) {
0039   auto pL1GtTriggerMask = std::make_unique<L1GtTriggerMask>();
0040 
0041   // l1GtTriggerMaskAlgoTrig: FINOR_ALGO_FK key in GT_PARTITION_FINOR_ALGO
0042 
0043   const std::string gtSchema = "CMS_GT";
0044 
0045   // SQL query:
0046   // select * from CMS_GT.GT_PARTITION_FINOR_ALGO WHERE GT_PARTITION_FINOR_ALGO.ID = objectKey
0047 
0048   const std::vector<std::string>& columns = m_omdsReader.columnNames(gtSchema, "GT_PARTITION_FINOR_ALGO");
0049 
0050   if (edm::isDebugEnabled()) {
0051     for (std::vector<std::string>::const_iterator iter = columns.begin(); iter != columns.end(); iter++) {
0052       LogTrace("L1GtTriggerMaskAlgoTrigConfigOnlineProd") << (*iter) << std::endl;
0053     }
0054   }
0055 
0056   l1t::OMDSReader::QueryResults results = m_omdsReader.basicQuery(columns,
0057                                                                   gtSchema,
0058                                                                   "GT_PARTITION_FINOR_ALGO",
0059                                                                   "GT_PARTITION_FINOR_ALGO.ID",
0060                                                                   m_omdsReader.singleAttribute(objectKey));
0061 
0062   // check if query was successful
0063   if (results.queryFailed()) {
0064     edm::LogError("L1-O2O") << "Problem with L1GtTriggerMaskAlgoTrigRcd key:" << objectKey;
0065     return pL1GtTriggerMask;
0066   }
0067 
0068   // mask for other partitions than m_partitionNumber set to 1 (algorithm masked)
0069   int maskSize = columns.size() - 1;  // table ID is also in columns
0070   std::vector<bool> trigMaskBool(maskSize, false);
0071   std::vector<unsigned int> trigMask(maskSize, 0);
0072 
0073   for (int i = 0; i < maskSize; i++) {
0074     bool tMask = trigMaskBool[i];
0075     results.fillVariable(columns[i + 1], tMask);
0076     trigMask[i] = 0xFF & (~(static_cast<unsigned int>(tMask) << m_partitionNumber));
0077   }
0078 
0079   // fill the record
0080   pL1GtTriggerMask->setGtTriggerMask(trigMask);
0081 
0082   if (edm::isDebugEnabled()) {
0083     std::ostringstream myCoutStream;
0084     pL1GtTriggerMask->print(myCoutStream);
0085     LogTrace("L1GtTriggerMaskAlgoTrigConfigOnlineProd")
0086         << "\nThe following L1GtTriggerMaskAlgoTrigRcd record was read from OMDS: \n"
0087         << myCoutStream.str() << "\n"
0088         << std::endl;
0089   }
0090 
0091   return pL1GtTriggerMask;
0092 }
0093 
0094 DEFINE_FWK_EVENTSETUP_MODULE(L1GtTriggerMaskAlgoTrigConfigOnlineProd);