File indexing completed on 2021-02-14 14:22:58
0001 #include "L1Trigger/L1TGlobal/interface/L1TGlobalUtilHelper.h"
0002 #include "DataFormats/Provenance/interface/BranchDescription.h"
0003 #include "FWCore/ParameterSet/interface/ParameterSetDescription.h"
0004 #include "FWCore/Utilities/interface/BranchType.h"
0005 #include "FWCore/Utilities/interface/TypeID.h"
0006
0007 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0008
0009 l1t::L1TGlobalUtilHelper::L1TGlobalUtilHelper(edm::ParameterSet const& pset, edm::ConsumesCollector& iC)
0010 : m_consumesCollector(iC),
0011 m_l1tAlgBlkInputTag(pset.getParameter<edm::InputTag>("l1tAlgBlkInputTag")),
0012 m_l1tExtBlkInputTag(pset.getParameter<edm::InputTag>("l1tExtBlkInputTag")),
0013 m_findL1TAlgBlk(false),
0014 m_findL1TExtBlk(false),
0015 m_readPrescalesFromFile(pset.getParameter<bool>("ReadPrescalesFromFile")),
0016 m_foundPreferredL1TAlgBlk(false),
0017 m_foundPreferredL1TExtBlk(false) {
0018 m_l1tAlgBlkToken = iC.consumes<GlobalAlgBlkBxCollection>(m_l1tAlgBlkInputTag);
0019 m_l1tExtBlkToken = iC.consumes<GlobalExtBlkBxCollection>(m_l1tExtBlkInputTag);
0020 }
0021
0022 void l1t::L1TGlobalUtilHelper::fillDescription(edm::ParameterSetDescription& desc) {
0023 desc.add<edm::InputTag>("l1tAlgBlkInputTag", edm::InputTag());
0024 desc.add<edm::InputTag>("l1tExtBlkInputTag", edm::InputTag());
0025 desc.add<bool>("ReadPrescalesFromFile", false);
0026 }
0027
0028 void l1t::L1TGlobalUtilHelper::operator()(edm::BranchDescription const& branchDescription) {
0029
0030
0031
0032
0033
0034
0035
0036
0037
0038
0039
0040
0041
0042
0043
0044
0045
0046
0047
0048
0049
0050
0051 if (branchDescription.dropped()) {
0052 return;
0053 }
0054
0055 std::vector<edm::InputTag> preferredL1TAlgBlkInputTag = {edm::InputTag("gtStage2Digis"),
0056 edm::InputTag("hltGtStage2Digis")};
0057
0058 std::vector<edm::InputTag> preferredL1TExtBlkInputTag = {edm::InputTag("gtStage2Digis"),
0059 edm::InputTag("hltGtStage2Digis")};
0060
0061
0062
0063 if (m_findL1TAlgBlk && (!m_foundMultipleL1TAlgBlk) &&
0064 (branchDescription.unwrappedTypeID() == edm::TypeID(typeid(GlobalAlgBlkBxCollection))) &&
0065 (branchDescription.branchType() == edm::InEvent)) {
0066 edm::InputTag tag{
0067 branchDescription.moduleLabel(), branchDescription.productInstanceName(), branchDescription.processName()};
0068
0069 if (m_foundPreferredL1TAlgBlk) {
0070
0071
0072
0073
0074
0075 if ((m_l1tAlgBlkInputTag.label() == branchDescription.moduleLabel()) &&
0076 ((m_l1tAlgBlkInputTag.instance() != branchDescription.productInstanceName()) ||
0077 (m_l1tAlgBlkInputTag.process() != branchDescription.processName()))) {
0078 LogDebug("L1TGlobalUtil") << "\nWARNING: Found multiple preferred input tags for GlobalAlgBlkBxCollection, "
0079 << "\nwith different instaces or processes."
0080 << "\nInput tag already found: " << (m_l1tAlgBlkInputTag) << "\nActual tag: " << (tag)
0081 << "\nInput tag set to empty tag." << std::endl;
0082
0083 m_foundMultipleL1TAlgBlk = true;
0084 m_l1tAlgBlkInputTag = edm::InputTag();
0085 }
0086 } else {
0087
0088 for (std::vector<edm::InputTag>::const_iterator itPrefTag = preferredL1TAlgBlkInputTag.begin(),
0089 itPrefTagEnd = preferredL1TAlgBlkInputTag.end();
0090 itPrefTag != itPrefTagEnd;
0091 ++itPrefTag) {
0092 if (branchDescription.moduleLabel() == itPrefTag->label()) {
0093 m_l1tAlgBlkInputTag = tag;
0094 m_l1tAlgBlkToken = m_consumesCollector.consumes<GlobalAlgBlkBxCollection>(tag);
0095 m_foundPreferredL1TAlgBlk = true;
0096 m_inputTagsL1TAlgBlk.push_back(tag);
0097
0098 LogDebug("L1TGlobalUtil")
0099 << "\nWARNING: Input tag for GlobalAlgBlkBxCollection product set to preferred input tag" << (tag)
0100 << std::endl;
0101 break;
0102 }
0103 }
0104 }
0105
0106 if (!m_foundPreferredL1TAlgBlk) {
0107
0108
0109
0110 if (m_inputTagsL1TAlgBlk.size() > 1) {
0111 LogDebug("L1TGlobalUtil") << "\nWARNING: Found multiple input tags for GlobalAlgBlkBxCollection product."
0112 << "\nNone is in the preferred input tags - no safe choice."
0113 << "\nInput tag already found: " << (m_l1tAlgBlkInputTag) << "\nActual tag: " << (tag)
0114 << "\nInput tag set to empty tag." << std::endl;
0115 m_l1tAlgBlkInputTag = edm::InputTag();
0116 m_foundMultipleL1TAlgBlk = true;
0117
0118 } else {
0119 if (m_l1tAlgBlkToken.isUninitialized()) {
0120 m_l1tAlgBlkInputTag = tag;
0121 m_inputTagsL1TAlgBlk.push_back(tag);
0122 m_l1tAlgBlkToken = m_consumesCollector.consumes<GlobalAlgBlkBxCollection>(tag);
0123
0124 LogDebug("L1TGlobalUtil") << "\nWARNING: No preferred input tag found for GlobalAlgBlkBxCollection."
0125 << "\nInput tag set to " << (tag) << std::endl;
0126 }
0127 }
0128 }
0129 }
0130
0131
0132
0133 if (m_findL1TExtBlk && (!m_foundMultipleL1TExtBlk) &&
0134 (branchDescription.unwrappedTypeID() == edm::TypeID(typeid(GlobalExtBlkBxCollection))) &&
0135 (branchDescription.branchType() == edm::InEvent)) {
0136 edm::InputTag tag{
0137 branchDescription.moduleLabel(), branchDescription.productInstanceName(), branchDescription.processName()};
0138
0139 if (m_foundPreferredL1TExtBlk) {
0140
0141
0142
0143
0144
0145 if ((m_l1tExtBlkInputTag.label() == branchDescription.moduleLabel()) &&
0146 ((m_l1tExtBlkInputTag.instance() != branchDescription.productInstanceName()) ||
0147 (m_l1tExtBlkInputTag.process() != branchDescription.processName()))) {
0148 LogDebug("L1TGlobalUtil") << "\nWARNING: Found multiple preferred input tags for GlobalExtBlkBxCollection, "
0149 << "\nwith different instaces or processes."
0150 << "\nInput tag already found: " << (m_l1tExtBlkInputTag) << "\nActual tag: " << (tag)
0151 << "\nInput tag set to empty tag." << std::endl;
0152
0153 m_foundMultipleL1TExtBlk = true;
0154 m_l1tExtBlkInputTag = edm::InputTag();
0155 }
0156 } else {
0157
0158
0159 for (std::vector<edm::InputTag>::const_iterator itPrefTag = preferredL1TExtBlkInputTag.begin(),
0160 itPrefTagEnd = preferredL1TExtBlkInputTag.end();
0161 itPrefTag != itPrefTagEnd;
0162 ++itPrefTag) {
0163 if (branchDescription.moduleLabel() == itPrefTag->label()) {
0164 m_l1tExtBlkInputTag = tag;
0165 m_l1tExtBlkToken = m_consumesCollector.consumes<GlobalExtBlkBxCollection>(tag);
0166 m_foundPreferredL1TExtBlk = true;
0167 m_inputTagsL1TExtBlk.push_back(tag);
0168
0169 LogDebug("L1TGlobalUtil")
0170 << "\nWARNING: Input tag for GlobalExtBlkBxCollection product set to preferred input tag" << (tag)
0171 << std::endl;
0172 break;
0173 }
0174 }
0175 }
0176
0177 if (!m_foundPreferredL1TExtBlk) {
0178
0179
0180
0181 if (m_inputTagsL1TExtBlk.size() > 1) {
0182 LogDebug("L1TGlobalUtil") << "\nWARNING: Found multiple input tags for GlobalExtBlkBxCollection."
0183 << "\nNone is in the preferred input tags - no safe choice."
0184 << "\nInput tag already found: " << (m_l1tExtBlkInputTag) << "\nActual tag: " << (tag)
0185 << "\nInput tag set to empty tag." << std::endl;
0186 m_l1tExtBlkInputTag = edm::InputTag();
0187 m_foundMultipleL1TExtBlk = true;
0188
0189 } else {
0190 if (m_l1tExtBlkToken.isUninitialized()) {
0191 m_l1tExtBlkInputTag = tag;
0192 m_inputTagsL1TExtBlk.push_back(tag);
0193 m_l1tExtBlkToken = m_consumesCollector.consumes<GlobalExtBlkBxCollection>(tag);
0194
0195 LogDebug("L1TGlobalUtil") << "\nWARNING: No preferred input tag found for GlobalExtBlkBxCollection product."
0196 << "\nInput tag set to " << (tag) << std::endl;
0197 }
0198 }
0199 }
0200 }
0201 }