CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1GtUtilsHelper.cc
Go to the documentation of this file.
6 
8 
9 
13  m_consumesCollector(std::move(iC)),
14  m_l1GtRecordInputTag(pset.getParameter<edm::InputTag>("l1GtRecordInputTag")),
15  m_l1GtReadoutRecordInputTag(pset.getParameter<edm::InputTag>("l1GtReadoutRecordInputTag")),
16  m_l1GtTriggerMenuLiteInputTag(pset.getParameter<edm::InputTag>("l1GtTriggerMenuLiteInputTag")),
17  m_findRecord(false),
18  m_findReadoutRecord(false),
19  m_findMenuLite(false),
20  m_foundPreferredRecord(false),
21  m_foundPreferredReadoutRecord(false),
22  m_foundPreferredMenuLite(false) {
23 
28  if (useL1GtTriggerMenuLite) {
32  }
33 }
34 
36  desc.add<edm::InputTag>("l1GtRecordInputTag", edm::InputTag());
37  desc.add<edm::InputTag>("l1GtReadoutRecordInputTag", edm::InputTag());
38  desc.add<edm::InputTag>("l1GtTriggerMenuLiteInputTag", edm::InputTag());
39 }
40 
42  edm::BranchDescription const& branchDescription) {
43 
44  // This is only used if required InputTags were not specified already.
45  // This is called early in the process, once for each product in the ProductRegistry.
46  // The callback is registered when callWhenNewProductsRegistered is called.
47  // It finds products by type and sets the token so that it can be used
48  // later when getting the product.
49 
50  // The code will look for the corresponding product in ProductRegistry.
51  // If the product is found, it checks the product label in
52  // a vector of preferred input tags (hardwired now to "gtDigis" and
53  // "hltGtDigis"). The first input tag from the vector of preferred input tags, with the
54  // same label as the input tag found from provenance, is kept as input tag, if there are no
55  // multiple products with the same label.
56 
57  // If multiple products are found and no one has a label in the vector of preferred input tags,
58  // or if multiple products are found with the label in the vector of preferred input tags
59  // (with different instance or process) the input tag is set to empty input tag, and L1GtUtil
60  // will produce an error, as it is not possible to safely choose a product. In this case, one must
61  // provide explicitly the correct input tag via configuration or in the constructor.
62 
63  // TODO decide if the preferred input tags must be given as input parameters
64  // or stay hardwired
65 
66  std::vector<edm::InputTag> preferredL1GtRecordInputTag = { edm::InputTag(
67  "gtDigis"), edm::InputTag("hltGtDigis") };
68 
69  std::vector<edm::InputTag> preferredL1GtReadoutRecordInputTag = {
70  edm::InputTag("gtDigis"), edm::InputTag("hltGtDigis") };
71 
72  std::vector<edm::InputTag> preferredL1GtTriggerMenuLiteInputTag = {
73  edm::InputTag("gtDigis"), edm::InputTag("hltGtDigis") };
74 
75  // L1GlobalTriggerRecord
76 
78  && (branchDescription.unwrappedTypeID()
80  && (branchDescription.branchType() == edm::InEvent)) {
81 
82  edm::InputTag tag { branchDescription.moduleLabel(),
83  branchDescription.productInstanceName(),
84  branchDescription.processName() };
85 
87 
88  // check if a preferred input tag was already found and compare it with the actual tag
89  // if the instance or the process names are different, one has incompatible tags - set
90  // the tag to empty input tag and indicate that multiple preferred input tags are found
91  // so it is not possibly to choose safely an input tag
92 
93  if ((m_l1GtRecordInputTag.label() == branchDescription.moduleLabel())
95  != branchDescription.productInstanceName())
97  != branchDescription.processName()))) {
98 
99  LogDebug("L1GtUtils")
100  << "\nWARNING: Found multiple preferred input tags for L1GlobalTriggerRecord product, "
101  << "\nwith different instaces or processes."
102  << "\nInput tag already found: "
103  << (m_l1GtRecordInputTag) << "\nActual tag: " << (tag)
104  << "\nInput tag set to empty tag." << std::endl;
105 
108  }
109  } else {
110  // no preferred input tag found yet, check now with the actual tag
111 
112  for (std::vector<edm::InputTag>::const_iterator itPrefTag =
113  preferredL1GtRecordInputTag.begin(), itPrefTagEnd =
114  preferredL1GtRecordInputTag.end();
115  itPrefTag != itPrefTagEnd; ++itPrefTag) {
116 
117  if (branchDescription.moduleLabel() == itPrefTag->label()) {
121  m_foundPreferredRecord = true;
122  m_inputTagsL1GtRecord.push_back(tag);
123 
124  LogDebug("L1GtUtils")
125  << "\nWARNING: Input tag for L1GlobalTriggerRecord product set to preferred input tag"
126  << (tag) << std::endl;
127  break;
128  }
129  }
130  }
131 
132  if (!m_foundPreferredRecord) {
133 
134  // check if other input tag was found - if true, there are multiple input tags in the event,
135  // none in the preferred input tags, so it is not possibly to choose safely an input tag
136 
137  if (m_inputTagsL1GtRecord.size() > 1) {
138 
139  LogDebug("L1GtUtils")
140  << "\nWARNING: Found multiple input tags for L1GlobalTriggerRecord product."
141  << "\nNone is in the preferred input tags - no safe choice."
142  << "\nInput tag already found: "
143  << (m_l1GtRecordInputTag) << "\nActual tag: " << (tag)
144  << "\nInput tag set to empty tag." << std::endl;
147 
148  } else {
150 
152  m_inputTagsL1GtRecord.push_back(tag);
155 
156  LogDebug("L1GtUtils")
157  << "\nWARNING: No preferred input tag found for L1GlobalTriggerReadoutRecord product."
158  << "\nInput tag set to " << (tag) << std::endl;
159  }
160  }
161  }
162  }
163 
164 
165  // L1GlobalTriggerReadoutRecord
166 
168  && (branchDescription.unwrappedTypeID()
170  && (branchDescription.branchType() == edm::InEvent)) {
171 
172  edm::InputTag tag { branchDescription.moduleLabel(),
173  branchDescription.productInstanceName(),
174  branchDescription.processName() };
175 
177 
178  // check if a preferred input tag was already found and compare it with the actual tag
179  // if the instance or the process names are different, one has incompatible tags - set
180  // the tag to empty input tag and indicate that multiple preferred input tags are found
181  // so it is not possibly to choose safely an input tag
182 
184  == branchDescription.moduleLabel())
186  != branchDescription.productInstanceName())
188  != branchDescription.processName()))) {
189 
190  LogDebug("L1GtUtils")
191  << "\nWARNING: Found multiple preferred input tags for L1GlobalTriggerReadoutRecord product, "
192  << "\nwith different instaces or processes."
193  << "\nInput tag already found: "
194  << (m_l1GtReadoutRecordInputTag) << "\nActual tag: "
195  << (tag) << "\nInput tag set to empty tag."
196  << std::endl;
197 
200  }
201  } else {
202  // no preferred input tag found yet, check now with the actual tag
203 
204  for (std::vector<edm::InputTag>::const_iterator itPrefTag =
205  preferredL1GtReadoutRecordInputTag.begin(), itPrefTagEnd =
206  preferredL1GtReadoutRecordInputTag.end();
207  itPrefTag != itPrefTagEnd; ++itPrefTag) {
208 
209  if (branchDescription.moduleLabel() == itPrefTag->label()) {
215 
216  LogDebug("L1GtUtils")
217  << "\nWARNING: Input tag for L1GlobalTriggerReadoutRecord product set to preferred input tag"
218  << (tag) << std::endl;
219  break;
220  }
221  }
222  }
223 
225 
226  // check if other input tag was found - if true, there are multiple input tags in the event,
227  // none in the preferred input tags, so it is not possibly to choose safely an input tag
228 
229  if (m_inputTagsL1GtReadoutRecord.size() > 1) {
230 
231  LogDebug("L1GtUtils")
232  << "\nWARNING: Found multiple input tags for L1GlobalTriggerReadoutRecord product."
233  << "\nNone is in the preferred input tags - no safe choice."
234  << "\nInput tag already found: "
235  << (m_l1GtReadoutRecordInputTag) << "\nActual tag: "
236  << (tag) << "\nInput tag set to empty tag."
237  << std::endl;
240 
241  } else {
243 
248 
249  LogDebug("L1GtUtils")
250  << "\nWARNING: No preferred input tag found for L1GlobalTriggerReadoutRecord product."
251  << "\nInput tag set to " << (tag) << std::endl;
252  }
253  }
254  }
255  }
256 
257 
258 
259 
260  // L1GtTriggerMenuLite
261 
263  && (branchDescription.unwrappedTypeID()
264  == edm::TypeID(typeid(L1GtTriggerMenuLite)))
265  && (branchDescription.branchType() == edm::InEvent)) {
266 
267  edm::InputTag tag { branchDescription.moduleLabel(),
268  branchDescription.productInstanceName(),
269  branchDescription.processName() };
270 
272 
273  // check if a preferred input tag was already found and compare it with the actual tag
274  // if the instance or the process names are different, one has incompatible tags - set
275  // the tag to empty input tag and indicate that multiple preferred input tags are found
276  // so it is not possibly to choose safely an input tag
277 
279  == branchDescription.moduleLabel())
281  != branchDescription.productInstanceName())
283  != branchDescription.processName()))) {
284 
285  LogDebug("L1GtUtils")
286  << "\nWARNING: Found multiple preferred input tags for L1GtTriggerMenuLite product, "
287  << "\nwith different instaces or processes."
288  << "\nInput tag already found: "
289  << (m_l1GtTriggerMenuLiteInputTag) << "\nActual tag: " << (tag)
290  << "\nInput tag set to empty tag." << std::endl;
291 
294  }
295  } else {
296  // no preferred input tag found yet, check now with the actual tag
297 
298  for (std::vector<edm::InputTag>::const_iterator itPrefTag =
299  preferredL1GtTriggerMenuLiteInputTag.begin(), itPrefTagEnd =
300  preferredL1GtTriggerMenuLiteInputTag.end();
301  itPrefTag != itPrefTagEnd; ++itPrefTag) {
302 
303  if (branchDescription.moduleLabel() == itPrefTag->label()) {
308  m_inputTagsL1GtMenuLite.push_back(tag);
309 
310  LogDebug("L1GtUtils")
311  << "\nWARNING: Input tag for L1GtTriggerMenuLite product set to preferred input tag"
312  << (tag) << std::endl;
313  break;
314  }
315  }
316  }
317 
319 
320  // check if other input tag was found - if true, there are multiple input tags in the event,
321  // none in the preferred input tags, so it is not possibly to choose safely an input tag
322 
323  if (m_inputTagsL1GtMenuLite.size() > 1) {
324 
325  LogDebug("L1GtUtils")
326  << "\nWARNING: Found multiple input tags for L1GtTriggerMenuLite product."
327  << "\nNone is in the preferred input tags - no safe choice."
328  << "\nInput tag already found: "
329  << (m_l1GtTriggerMenuLiteInputTag) << "\nActual tag: " << (tag)
330  << "\nInput tag set to empty tag." << std::endl;
333 
334  } else {
336 
338  m_inputTagsL1GtMenuLite.push_back(tag);
341 
342  LogDebug("L1GtUtils")
343  << "\nWARNING: No preferred input tag found for L1GtTriggerMenuLite product."
344  << "\nInput tag set to " << (tag) << std::endl;
345  }
346  }
347  }
348  }
349 }
#define LogDebug(id)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
BranchType const & branchType() const
edm::InputTag m_l1GtReadoutRecordInputTag
std::string const & processName() const
edm::EDGetTokenT< L1GtTriggerMenuLite > m_l1GtTriggerMenuLiteToken
std::vector< edm::InputTag > m_inputTagsL1GtReadoutRecord
edm::InputTag m_l1GtTriggerMenuLiteInputTag
edm::InputTag m_l1GtRecordInputTag
std::vector< edm::InputTag > m_inputTagsL1GtMenuLite
std::string const & moduleLabel() const
std::string const & productInstanceName() const
bool m_foundMultipleL1GtReadoutRecord
TypeID unwrappedTypeID() const
std::vector< edm::InputTag > m_inputTagsL1GtRecord
static void fillDescription(edm::ParameterSetDescription &desc)
bool m_foundMultipleL1GtRecord
edm::EDGetTokenT< L1GlobalTriggerRecord > m_l1GtRecordToken
bool m_foundMultipleL1GtMenuLite
ParameterDescriptionBase * add(U const &iLabel, T const &value)
edm::ConsumesCollector m_consumesCollector
bool m_foundPreferredReadoutRecord
static const bool useL1GtTriggerMenuLite(true)
std::string const & label() const
Definition: InputTag.h:43
std::string const & process() const
Definition: InputTag.h:47
bool isUninitialized() const
Definition: EDGetToken.h:71
void operator()(edm::BranchDescription const &branchDescription)
volatile std::atomic< bool > shutdown_flag false
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_l1GtReadoutRecordToken
std::string const & instance() const
Definition: InputTag.h:44
L1GtUtilsHelper(edm::ParameterSet const &pset, edm::ConsumesCollector &iC, bool useL1GtTriggerMenuLite)