Back to home page

Project CMSSW displayed by LXR

 
 

    


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

0001 /**
0002  * \class L1GtTriggerMenuXmlProducer
0003  *
0004  *
0005  * Description: ESProducer for the L1 Trigger Menu from an XML file .
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/L1GtTriggerMenuXmlProducer.h"
0017 
0018 // system include files
0019 #include <memory>
0020 
0021 // user include files
0022 //   base class
0023 #include "FWCore/Framework/interface/ESProducer.h"
0024 
0025 #include "FWCore/Framework/interface/ModuleFactory.h"
0026 #include "FWCore/Framework/interface/ESHandle.h"
0027 
0028 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0029 #include "FWCore/MessageLogger/interface/MessageDrop.h"
0030 
0031 #include "CondFormats/L1TObjects/interface/L1GtTriggerMenu.h"
0032 #include "CondFormats/DataRecord/interface/L1GtTriggerMenuRcd.h"
0033 
0034 #include "CondFormats/L1TObjects/interface/L1GtStableParameters.h"
0035 #include "CondFormats/DataRecord/interface/L1GtStableParametersRcd.h"
0036 
0037 #include "L1TriggerConfig/L1GtConfigProducers/interface/L1GtTriggerMenuXmlParser.h"
0038 
0039 // forward declarations
0040 
0041 // constructor(s)
0042 L1GtTriggerMenuXmlProducer::L1GtTriggerMenuXmlProducer(const edm::ParameterSet& parSet) {
0043   // tell the framework what data is being produced
0044   m_getToken = setWhatProduced(this, &L1GtTriggerMenuXmlProducer::produceGtTriggerMenu).consumes();
0045 
0046   // now do what ever other initialization is needed
0047 
0048   // directory in /data/Luminosity for the trigger menu
0049   std::string menuDir = parSet.getParameter<std::string>("TriggerMenuLuminosity");
0050 
0051   // def.xml file
0052   std::string defXmlFileName = parSet.getParameter<std::string>("DefXmlFile");
0053 
0054   edm::FileInPath f1("L1TriggerConfig/L1GtConfigProducers/data/Luminosity/" + menuDir + "/" + defXmlFileName);
0055 
0056   m_defXmlFile = f1.fullPath();
0057 
0058   // vme.xml file
0059   std::string vmeXmlFileName = parSet.getParameter<std::string>("VmeXmlFile");
0060 
0061   if (!vmeXmlFileName.empty()) {
0062     edm::FileInPath f2("L1TriggerConfig/L1GtConfigProducers/data/Luminosity/" + menuDir + "/" + vmeXmlFileName);
0063 
0064     m_vmeXmlFile = f2.fullPath();
0065   }
0066 
0067   edm::LogInfo("L1GtConfigProducers") << "\n\nL1 Trigger Menu: "
0068                                       << "\n\n  def.xml file: \n    " << m_defXmlFile << "\n\n  vme.xml file: \n    "
0069                                       << m_vmeXmlFile << "\n\n"
0070                                       << std::endl;
0071 }
0072 
0073 // destructor
0074 L1GtTriggerMenuXmlProducer::~L1GtTriggerMenuXmlProducer() {
0075   // empty
0076 }
0077 
0078 // member functions
0079 
0080 // method called to produce the data
0081 std::unique_ptr<L1GtTriggerMenu> L1GtTriggerMenuXmlProducer::produceGtTriggerMenu(
0082     const L1GtTriggerMenuRcd& l1MenuRecord) {
0083   // get the parameters needed from other records
0084   edm::ESHandle<L1GtStableParameters> stableParameters = l1MenuRecord.getHandle(m_getToken);
0085 
0086   unsigned int numberConditionChips = stableParameters->gtNumberConditionChips();
0087   unsigned int pinsOnConditionChip = stableParameters->gtPinsOnConditionChip();
0088   std::vector<int> orderConditionChip = stableParameters->gtOrderConditionChip();
0089   unsigned int numberPhysTriggers = stableParameters->gtNumberPhysTriggers();
0090   unsigned int numberTechTriggers = stableParameters->gtNumberTechnicalTriggers();
0091   unsigned int numberL1JetCounts = stableParameters->gtNumberL1JetCounts();
0092 
0093   L1GtTriggerMenuXmlParser gtXmlParser = L1GtTriggerMenuXmlParser();
0094 
0095   gtXmlParser.setGtNumberConditionChips(numberConditionChips);
0096   gtXmlParser.setGtPinsOnConditionChip(pinsOnConditionChip);
0097   gtXmlParser.setGtOrderConditionChip(orderConditionChip);
0098   gtXmlParser.setGtNumberPhysTriggers(numberPhysTriggers);
0099   gtXmlParser.setGtNumberTechTriggers(numberTechTriggers);
0100   gtXmlParser.setGtNumberL1JetCounts(numberL1JetCounts);
0101 
0102   gtXmlParser.parseXmlFile(m_defXmlFile, m_vmeXmlFile);
0103 
0104   // transfer the condition map and algorithm map from parser to L1GtTriggerMenu
0105 
0106   auto pL1GtTriggerMenu = std::make_unique<L1GtTriggerMenu>(gtXmlParser.gtTriggerMenuName(),
0107                                                             numberConditionChips,
0108                                                             gtXmlParser.vecMuonTemplate(),
0109                                                             gtXmlParser.vecCaloTemplate(),
0110                                                             gtXmlParser.vecEnergySumTemplate(),
0111                                                             gtXmlParser.vecJetCountsTemplate(),
0112                                                             gtXmlParser.vecCastorTemplate(),
0113                                                             gtXmlParser.vecHfBitCountsTemplate(),
0114                                                             gtXmlParser.vecHfRingEtSumsTemplate(),
0115                                                             gtXmlParser.vecBptxTemplate(),
0116                                                             gtXmlParser.vecExternalTemplate(),
0117                                                             gtXmlParser.vecCorrelationTemplate(),
0118                                                             gtXmlParser.corMuonTemplate(),
0119                                                             gtXmlParser.corCaloTemplate(),
0120                                                             gtXmlParser.corEnergySumTemplate());
0121 
0122   pL1GtTriggerMenu->setGtTriggerMenuInterface(gtXmlParser.gtTriggerMenuInterface());
0123   pL1GtTriggerMenu->setGtTriggerMenuImplementation(gtXmlParser.gtTriggerMenuImplementation());
0124   pL1GtTriggerMenu->setGtScaleDbKey(gtXmlParser.gtScaleDbKey());
0125 
0126   pL1GtTriggerMenu->setGtAlgorithmMap(gtXmlParser.gtAlgorithmMap());
0127   pL1GtTriggerMenu->setGtAlgorithmAliasMap(gtXmlParser.gtAlgorithmAliasMap());
0128   pL1GtTriggerMenu->setGtTechnicalTriggerMap(gtXmlParser.gtTechnicalTriggerMap());
0129 
0130   //LogDebug("L1GtConfigProducers")
0131   //<< "\n\nReturning L1 Trigger Menu!"
0132   //<< "\n\n"
0133   //<< std::endl;
0134 
0135   return pL1GtTriggerMenu;
0136 }