CMS 3D CMS Logo

L1GtUtilsHelper.cc
Go to the documentation of this file.
6 
8 
10  : m_consumesCollector(iC),
11  m_l1GtRecordInputTag(pset.getParameter<edm::InputTag>("l1GtRecordInputTag")),
12  m_l1GtReadoutRecordInputTag(pset.getParameter<edm::InputTag>("l1GtReadoutRecordInputTag")),
13  m_l1GtTriggerMenuLiteInputTag(pset.getParameter<edm::InputTag>("l1GtTriggerMenuLiteInputTag")),
14  m_findRecord(false),
15  m_findReadoutRecord(false),
16  m_findMenuLite(false),
17  m_foundPreferredRecord(false),
18  m_foundPreferredReadoutRecord(false),
19  m_foundPreferredMenuLite(false) {
24  }
25 }
26 
28  desc.add<edm::InputTag>("l1GtRecordInputTag", edm::InputTag());
29  desc.add<edm::InputTag>("l1GtReadoutRecordInputTag", edm::InputTag());
30  desc.add<edm::InputTag>("l1GtTriggerMenuLiteInputTag", edm::InputTag());
31 }
32 
33 void L1GtUtilsHelper::operator()(edm::BranchDescription const& branchDescription) {
34  // This is only used if required InputTags were not specified already.
35  // This is called early in the process, once for each product in the ProductRegistry.
36  // The callback is registered when callWhenNewProductsRegistered is called.
37  // It finds products by type and sets the token so that it can be used
38  // later when getting the product.
39 
40  // The code will look for the corresponding product in ProductRegistry.
41  // If the product is found, it checks the product label in
42  // a vector of preferred input tags (hardwired now to "gtDigis" and
43  // "hltGtDigis"). The first input tag from the vector of preferred input tags, with the
44  // same label as the input tag found from provenance, is kept as input tag, if there are no
45  // multiple products with the same label.
46 
47  // If multiple products are found and no one has a label in the vector of preferred input tags,
48  // or if multiple products are found with the label in the vector of preferred input tags
49  // (with different instance or process) the input tag is set to empty input tag, and L1GtUtil
50  // will produce an error, as it is not possible to safely choose a product. In this case, one must
51  // provide explicitly the correct input tag via configuration or in the constructor.
52 
53  // TODO decide if the preferred input tags must be given as input parameters
54  // or stay hardwired
55 
56  std::vector<edm::InputTag> preferredL1GtRecordInputTag = {edm::InputTag("gtDigis"), edm::InputTag("hltGtDigis")};
57 
58  std::vector<edm::InputTag> preferredL1GtReadoutRecordInputTag = {edm::InputTag("gtDigis"),
59  edm::InputTag("hltGtDigis")};
60 
61  std::vector<edm::InputTag> preferredL1GtTriggerMenuLiteInputTag = {edm::InputTag("gtDigis"),
62  edm::InputTag("hltGtDigis")};
63 
64  // L1GlobalTriggerRecord
65 
67  (branchDescription.unwrappedTypeID() == edm::TypeID(typeid(L1GlobalTriggerRecord))) &&
68  (branchDescription.branchType() == edm::InEvent)) {
70  branchDescription.moduleLabel(), branchDescription.productInstanceName(), branchDescription.processName()};
71 
73  // check if a preferred input tag was already found and compare it with the actual tag
74  // if the instance or the process names are different, one has incompatible tags - set
75  // the tag to empty input tag and indicate that multiple preferred input tags are found
76  // so it is not possibly to choose safely an input tag
77 
78  if ((m_l1GtRecordInputTag.label() == branchDescription.moduleLabel()) &&
79  ((m_l1GtRecordInputTag.instance() != branchDescription.productInstanceName()) ||
80  (m_l1GtRecordInputTag.process() != branchDescription.processName()))) {
81  LogDebug("L1GtUtils") << "\nWARNING: Found multiple preferred input tags for L1GlobalTriggerRecord product, "
82  << "\nwith different instaces or processes."
83  << "\nInput tag already found: " << (m_l1GtRecordInputTag) << "\nActual tag: " << (tag)
84  << "\nInput tag set to empty tag." << std::endl;
85 
88  }
89  } else {
90  // no preferred input tag found yet, check now with the actual tag
91  for (std::vector<edm::InputTag>::const_iterator itPrefTag = preferredL1GtRecordInputTag.begin(),
92  itPrefTagEnd = preferredL1GtRecordInputTag.end();
93  itPrefTag != itPrefTagEnd;
94  ++itPrefTag) {
95  if (branchDescription.moduleLabel() == itPrefTag->label()) {
99  m_inputTagsL1GtRecord.push_back(tag);
100 
101  LogDebug("L1GtUtils") << "\nWARNING: Input tag for L1GlobalTriggerRecord product set to preferred input tag"
102  << (tag) << std::endl;
103  break;
104  }
105  }
106  }
107 
108  if (!m_foundPreferredRecord) {
109  // check if other input tag was found - if true, there are multiple input tags in the event,
110  // none in the preferred input tags, so it is not possibly to choose safely an input tag
111 
112  if (m_inputTagsL1GtRecord.size() > 1) {
113  LogDebug("L1GtUtils") << "\nWARNING: Found multiple input tags for L1GlobalTriggerRecord product."
114  << "\nNone is in the preferred input tags - no safe choice."
115  << "\nInput tag already found: " << (m_l1GtRecordInputTag) << "\nActual tag: " << (tag)
116  << "\nInput tag set to empty tag." << std::endl;
119 
120  } else {
123  m_inputTagsL1GtRecord.push_back(tag);
125 
126  LogDebug("L1GtUtils") << "\nWARNING: No preferred input tag found for L1GlobalTriggerReadoutRecord product."
127  << "\nInput tag set to " << (tag) << std::endl;
128  }
129  }
130  }
131  }
132 
133  // L1GlobalTriggerReadoutRecord
134 
136  (branchDescription.unwrappedTypeID() == edm::TypeID(typeid(L1GlobalTriggerReadoutRecord))) &&
137  (branchDescription.branchType() == edm::InEvent)) {
139  branchDescription.moduleLabel(), branchDescription.productInstanceName(), branchDescription.processName()};
140 
142  // check if a preferred input tag was already found and compare it with the actual tag
143  // if the instance or the process names are different, one has incompatible tags - set
144  // the tag to empty input tag and indicate that multiple preferred input tags are found
145  // so it is not possibly to choose safely an input tag
146 
147  if ((m_l1GtReadoutRecordInputTag.label() == branchDescription.moduleLabel()) &&
148  ((m_l1GtReadoutRecordInputTag.instance() != branchDescription.productInstanceName()) ||
149  (m_l1GtReadoutRecordInputTag.process() != branchDescription.processName()))) {
150  LogDebug("L1GtUtils")
151  << "\nWARNING: Found multiple preferred input tags for L1GlobalTriggerReadoutRecord product, "
152  << "\nwith different instaces or processes."
153  << "\nInput tag already found: " << (m_l1GtReadoutRecordInputTag) << "\nActual tag: " << (tag)
154  << "\nInput tag set to empty tag." << std::endl;
155 
158  }
159  } else {
160  // no preferred input tag found yet, check now with the actual tag
161 
162  for (std::vector<edm::InputTag>::const_iterator itPrefTag = preferredL1GtReadoutRecordInputTag.begin(),
163  itPrefTagEnd = preferredL1GtReadoutRecordInputTag.end();
164  itPrefTag != itPrefTagEnd;
165  ++itPrefTag) {
166  if (branchDescription.moduleLabel() == itPrefTag->label()) {
171 
172  LogDebug("L1GtUtils")
173  << "\nWARNING: Input tag for L1GlobalTriggerReadoutRecord product set to preferred input tag" << (tag)
174  << std::endl;
175  break;
176  }
177  }
178  }
179 
181  // check if other input tag was found - if true, there are multiple input tags in the event,
182  // none in the preferred input tags, so it is not possibly to choose safely an input tag
183 
184  if (m_inputTagsL1GtReadoutRecord.size() > 1) {
185  LogDebug("L1GtUtils") << "\nWARNING: Found multiple input tags for L1GlobalTriggerReadoutRecord product."
186  << "\nNone is in the preferred input tags - no safe choice."
187  << "\nInput tag already found: " << (m_l1GtReadoutRecordInputTag)
188  << "\nActual tag: " << (tag) << "\nInput tag set to empty tag." << std::endl;
191 
192  } else {
197 
198  LogDebug("L1GtUtils") << "\nWARNING: No preferred input tag found for L1GlobalTriggerReadoutRecord product."
199  << "\nInput tag set to " << (tag) << std::endl;
200  }
201  }
202  }
203  }
204 
205  // L1GtTriggerMenuLite
206 
208  (branchDescription.unwrappedTypeID() == edm::TypeID(typeid(L1GtTriggerMenuLite))) &&
209  (branchDescription.branchType() == edm::InEvent)) {
211  branchDescription.moduleLabel(), branchDescription.productInstanceName(), branchDescription.processName()};
212 
214  // check if a preferred input tag was already found and compare it with the actual tag
215  // if the instance or the process names are different, one has incompatible tags - set
216  // the tag to empty input tag and indicate that multiple preferred input tags are found
217  // so it is not possibly to choose safely an input tag
218 
219  if ((m_l1GtTriggerMenuLiteInputTag.label() == branchDescription.moduleLabel()) &&
220  ((m_l1GtTriggerMenuLiteInputTag.instance() != branchDescription.productInstanceName()) ||
221  (m_l1GtTriggerMenuLiteInputTag.process() != branchDescription.processName()))) {
222  LogDebug("L1GtUtils") << "\nWARNING: Found multiple preferred input tags for L1GtTriggerMenuLite product, "
223  << "\nwith different instaces or processes."
224  << "\nInput tag already found: " << (m_l1GtTriggerMenuLiteInputTag)
225  << "\nActual tag: " << (tag) << "\nInput tag set to empty tag." << std::endl;
226 
229  }
230  } else {
231  // no preferred input tag found yet, check now with the actual tag
232 
233  for (std::vector<edm::InputTag>::const_iterator itPrefTag = preferredL1GtTriggerMenuLiteInputTag.begin(),
234  itPrefTagEnd = preferredL1GtTriggerMenuLiteInputTag.end();
235  itPrefTag != itPrefTagEnd;
236  ++itPrefTag) {
237  if (branchDescription.moduleLabel() == itPrefTag->label()) {
241  m_inputTagsL1GtMenuLite.push_back(tag);
242 
243  LogDebug("L1GtUtils") << "\nWARNING: Input tag for L1GtTriggerMenuLite product set to preferred input tag"
244  << (tag) << std::endl;
245  break;
246  }
247  }
248  }
249 
251  // check if other input tag was found - if true, there are multiple input tags in the event,
252  // none in the preferred input tags, so it is not possibly to choose safely an input tag
253 
254  if (m_inputTagsL1GtMenuLite.size() > 1) {
255  LogDebug("L1GtUtils") << "\nWARNING: Found multiple input tags for L1GtTriggerMenuLite product."
256  << "\nNone is in the preferred input tags - no safe choice."
257  << "\nInput tag already found: " << (m_l1GtTriggerMenuLiteInputTag)
258  << "\nActual tag: " << (tag) << "\nInput tag set to empty tag." << std::endl;
261 
262  } else {
265  m_inputTagsL1GtMenuLite.push_back(tag);
267 
268  LogDebug("L1GtUtils") << "\nWARNING: No preferred input tag found for L1GtTriggerMenuLite product."
269  << "\nInput tag set to " << (tag) << std::endl;
270  }
271  }
272  }
273  }
274 }
edm::BranchDescription::productInstanceName
std::string const & productInstanceName() const
Definition: BranchDescription.h:81
L1GtUtilsHelper::L1GtUtilsHelper
L1GtUtilsHelper(edm::ParameterSet const &pset, edm::ConsumesCollector &iC, bool useL1GtTriggerMenuLite)
Definition: L1GtUtilsHelper.cc:9
MessageLogger.h
funct::false
false
Definition: Factorize.h:29
BranchType.h
edm::InputTag::instance
std::string const & instance() const
Definition: InputTag.h:37
edm
HLT enums.
Definition: AlignableModifier.h:19
HLT_FULL_cff.InputTag
InputTag
Definition: HLT_FULL_cff.py:89287
edm::ParameterSetDescription
Definition: ParameterSetDescription.h:52
edm::EDGetTokenT::isUninitialized
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:99
TypeID.h
edm::InputTag::process
std::string const & process() const
Definition: InputTag.h:40
L1GtUtilsHelper::m_foundMultipleL1GtReadoutRecord
bool m_foundMultipleL1GtReadoutRecord
Definition: L1GtUtilsHelper.h:103
edm::InRun
Definition: BranchType.h:11
L1GlobalTriggerReadoutRecord
Definition: L1GlobalTriggerReadoutRecord.h:46
L1GtUtilsHelper::m_l1GtTriggerMenuLiteInputTag
edm::InputTag m_l1GtTriggerMenuLiteInputTag
Definition: L1GtUtilsHelper.h:88
L1GtUtilsHelper::m_inputTagsL1GtMenuLite
std::vector< edm::InputTag > m_inputTagsL1GtMenuLite
Definition: L1GtUtilsHelper.h:109
edm::InputTag::label
std::string const & label() const
Definition: InputTag.h:36
L1GtUtilsHelper::m_foundMultipleL1GtMenuLite
bool m_foundMultipleL1GtMenuLite
Definition: L1GtUtilsHelper.h:104
L1GtUtilsHelper::m_inputTagsL1GtReadoutRecord
std::vector< edm::InputTag > m_inputTagsL1GtReadoutRecord
Definition: L1GtUtilsHelper.h:108
edm::BranchDescription::processName
std::string const & processName() const
Definition: BranchDescription.h:73
GlobalPosition_Frontier_DevDB_cff.tag
tag
Definition: GlobalPosition_Frontier_DevDB_cff.py:11
L1GtUtilsHelper::m_foundMultipleL1GtRecord
bool m_foundMultipleL1GtRecord
Definition: L1GtUtilsHelper.h:102
L1GtUtilsHelper::m_inputTagsL1GtRecord
std::vector< edm::InputTag > m_inputTagsL1GtRecord
Definition: L1GtUtilsHelper.h:107
edm::BranchDescription::unwrappedTypeID
TypeID unwrappedTypeID() const
Definition: BranchDescription.h:97
edm::ConsumesCollector::consumes
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
Definition: ConsumesCollector.h:55
L1GtUtilsHelper.h
edm::InEvent
Definition: BranchType.h:11
L1GtUtilsHelper::m_l1GtReadoutRecordToken
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_l1GtReadoutRecordToken
Definition: L1GtUtilsHelper.h:91
ParameterSetDescription.h
useL1GtTriggerMenuLite
static const bool useL1GtTriggerMenuLite(true)
BranchDescription.h
LogDebug
#define LogDebug(id)
Definition: MessageLogger.h:223
edm::ParameterSet
Definition: ParameterSet.h:47
L1GtUtilsHelper::m_findMenuLite
bool m_findMenuLite
Definition: L1GtUtilsHelper.h:96
L1GtUtilsHelper::m_foundPreferredReadoutRecord
bool m_foundPreferredReadoutRecord
Definition: L1GtUtilsHelper.h:99
L1GtUtilsHelper::operator()
void operator()(edm::BranchDescription const &branchDescription)
Definition: L1GtUtilsHelper.cc:33
L1GtUtilsHelper::fillDescription
static void fillDescription(edm::ParameterSetDescription &desc)
Definition: L1GtUtilsHelper.cc:27
L1GtUtilsHelper::m_l1GtReadoutRecordInputTag
edm::InputTag m_l1GtReadoutRecordInputTag
Definition: L1GtUtilsHelper.h:87
edm::BranchDescription::branchType
BranchType const & branchType() const
Definition: BranchDescription.h:121
L1GtUtilsHelper::m_findRecord
bool m_findRecord
Definition: L1GtUtilsHelper.h:94
L1GtTriggerMenuLite
Definition: L1GtTriggerMenuLite.h:39
L1GtUtilsHelper::m_l1GtTriggerMenuLiteToken
edm::EDGetTokenT< L1GtTriggerMenuLite > m_l1GtTriggerMenuLiteToken
Definition: L1GtUtilsHelper.h:92
submitPVResolutionJobs.desc
string desc
Definition: submitPVResolutionJobs.py:251
edm::TypeID
Definition: TypeID.h:22
L1GtUtilsHelper::m_foundPreferredMenuLite
bool m_foundPreferredMenuLite
Definition: L1GtUtilsHelper.h:100
edm::BranchDescription::moduleLabel
std::string const & moduleLabel() const
Definition: BranchDescription.h:72
L1GtUtilsHelper::m_findReadoutRecord
bool m_findReadoutRecord
Definition: L1GtUtilsHelper.h:95
edm::BranchDescription
Definition: BranchDescription.h:32
L1GtUtilsHelper::m_l1GtRecordToken
edm::EDGetTokenT< L1GlobalTriggerRecord > m_l1GtRecordToken
Definition: L1GtUtilsHelper.h:90
L1GtUtilsHelper::m_consumesCollector
edm::ConsumesCollector m_consumesCollector
Definition: L1GtUtilsHelper.h:84
L1GlobalTriggerRecord
Definition: L1GlobalTriggerRecord.h:33
L1GtUtilsHelper::m_foundPreferredRecord
bool m_foundPreferredRecord
Definition: L1GtUtilsHelper.h:98
edm::InputTag
Definition: InputTag.h:15
edm::ConsumesCollector
Definition: ConsumesCollector.h:45
L1GtUtilsHelper::m_l1GtRecordInputTag
edm::InputTag m_l1GtRecordInputTag
Definition: L1GtUtilsHelper.h:86
muonDTDigis_cfi.pset
pset
Definition: muonDTDigis_cfi.py:27