Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /**
0002  * \class L1GtTriggerMaskTechTrigConfigOnlineProd
0003  *
0004  *
0005  * Description: online producer for L1GtTriggerMaskTechTrigRcd.
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/L1GtTriggerMaskTechTrigConfigOnlineProd.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 L1GtTriggerMaskTechTrigConfigOnlineProd::L1GtTriggerMaskTechTrigConfigOnlineProd(const edm::ParameterSet& parSet)
0026     : L1ConfigOnlineProdBase<L1GtTriggerMaskTechTrigRcd, L1GtTriggerMask>(parSet),
0027       m_partitionNumber(parSet.getParameter<int>("PartitionNumber")) {
0028   // empty
0029 }
0030 
0031 // destructor
0032 L1GtTriggerMaskTechTrigConfigOnlineProd::~L1GtTriggerMaskTechTrigConfigOnlineProd() {
0033   // empty
0034 }
0035 
0036 // public methods
0037 
0038 std::unique_ptr<L1GtTriggerMask> L1GtTriggerMaskTechTrigConfigOnlineProd::newObject(const std::string& objectKey) {
0039   auto pL1GtTriggerMask = std::make_unique<L1GtTriggerMask>();
0040 
0041   // l1GtTriggerMaskTechTrig: FINOR_TT_FK key in GT_PARTITION_FINOR_TT
0042 
0043   const std::string gtSchema = "CMS_GT";
0044 
0045   // SQL query:
0046   //
0047   // select * from CMS_GT.GT_PARTITION_FINOR_TT WHERE GT_PARTITION_FINOR_TT.ID = objectKey
0048 
0049   const std::vector<std::string>& columns = m_omdsReader.columnNames(gtSchema, "GT_PARTITION_FINOR_TT");
0050 
0051   if (edm::isDebugEnabled()) {
0052     for (std::vector<std::string>::const_iterator iter = columns.begin(); iter != columns.end(); iter++) {
0053       LogTrace("L1GtTriggerMaskTechTrigConfigOnlineProd") << (*iter) << std::endl;
0054     }
0055   }
0056 
0057   l1t::OMDSReader::QueryResults results = m_omdsReader.basicQuery(
0058       columns, gtSchema, "GT_PARTITION_FINOR_TT", "GT_PARTITION_FINOR_TT.ID", m_omdsReader.singleAttribute(objectKey));
0059 
0060   // check if query was successful
0061   if (results.queryFailed()) {
0062     edm::LogError("L1-O2O") << "Problem with L1GtTriggerMaskTechTrigRcd key:" << objectKey;
0063     return pL1GtTriggerMask;
0064   }
0065 
0066   // mask for other partitions than m_partitionNumber set to 1 (algorithm masked)
0067   int maskSize = columns.size() - 1;  // table ID is also in columns
0068   std::vector<bool> trigMaskBool(maskSize, false);
0069   std::vector<unsigned int> trigMask(maskSize, 0);
0070 
0071   for (int i = 0; i < maskSize; i++) {
0072     bool tMask = trigMaskBool[i];
0073     results.fillVariable(columns[i + 1], tMask);
0074     trigMask[i] = 0xFF & (~(static_cast<unsigned int>(tMask) << m_partitionNumber));
0075   }
0076 
0077   // fill the record
0078   pL1GtTriggerMask->setGtTriggerMask(trigMask);
0079 
0080   if (edm::isDebugEnabled()) {
0081     std::ostringstream myCoutStream;
0082     pL1GtTriggerMask->print(myCoutStream);
0083     LogTrace("L1GtTriggerMaskTechTrigConfigOnlineProd")
0084         << "\nThe following L1GtTriggerMaskTechTrigRcd record was read from OMDS: \n"
0085         << myCoutStream.str() << "\n"
0086         << std::endl;
0087   }
0088 
0089   return pL1GtTriggerMask;
0090 }
0091 
0092 DEFINE_FWK_EVENTSETUP_MODULE(L1GtTriggerMaskTechTrigConfigOnlineProd);