Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:22:19

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