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  // check if a preferred input tag was already found and compare it with the actual tag
88  // if the instance or the process names are different, one has incompatible tags - set
89  // the tag to empty input tag and indicate that multiple preferred input tags are found
90  // so it is not possibly to choose safely an input tag
91 
92  if ((m_l1GtRecordInputTag.label() == branchDescription.moduleLabel())
94  != branchDescription.productInstanceName())
96  != branchDescription.processName()))) {
97 
98  LogDebug("L1GtUtils")
99  << "\nWARNING: Found multiple preferred input tags for L1GlobalTriggerRecord product, "
100  << "\nwith different instaces or processes."
101  << "\nInput tag already found: "
102  << (m_l1GtRecordInputTag) << "\nActual tag: " << (tag)
103  << "\nInput tag set to empty tag." << std::endl;
104 
107  }
108  } else {
109  // no preferred input tag found yet, check now with the actual tag
110  for (std::vector<edm::InputTag>::const_iterator itPrefTag =
111  preferredL1GtRecordInputTag.begin(), itPrefTagEnd =
112  preferredL1GtRecordInputTag.end();
113  itPrefTag != itPrefTagEnd; ++itPrefTag) {
114 
115  if (branchDescription.moduleLabel() == itPrefTag->label()) {
119  m_foundPreferredRecord = true;
120  m_inputTagsL1GtRecord.push_back(tag);
121 
122  LogDebug("L1GtUtils")
123  << "\nWARNING: Input tag for L1GlobalTriggerRecord product set to preferred input tag"
124  << (tag) << std::endl;
125  break;
126  }
127  }
128  }
129 
130  if (!m_foundPreferredRecord) {
131 
132  // check if other input tag was found - if true, there are multiple input tags in the event,
133  // none in the preferred input tags, so it is not possibly to choose safely an input tag
134 
135  if (m_inputTagsL1GtRecord.size() > 1) {
136 
137  LogDebug("L1GtUtils")
138  << "\nWARNING: Found multiple input tags for L1GlobalTriggerRecord product."
139  << "\nNone is in the preferred input tags - no safe choice."
140  << "\nInput tag already found: "
141  << (m_l1GtRecordInputTag) << "\nActual tag: " << (tag)
142  << "\nInput tag set to empty tag." << std::endl;
145 
146  } else {
148 
150  m_inputTagsL1GtRecord.push_back(tag);
153 
154  LogDebug("L1GtUtils")
155  << "\nWARNING: No preferred input tag found for L1GlobalTriggerReadoutRecord product."
156  << "\nInput tag set to " << (tag) << std::endl;
157  }
158  }
159  }
160  }
161 
162 
163  // L1GlobalTriggerReadoutRecord
164 
166  && (branchDescription.unwrappedTypeID()
168  && (branchDescription.branchType() == edm::InEvent)) {
169 
170  edm::InputTag tag { branchDescription.moduleLabel(),
171  branchDescription.productInstanceName(),
172  branchDescription.processName() };
173 
175 
176  // check if a preferred input tag was already found and compare it with the actual tag
177  // if the instance or the process names are different, one has incompatible tags - set
178  // the tag to empty input tag and indicate that multiple preferred input tags are found
179  // so it is not possibly to choose safely an input tag
180 
182  == branchDescription.moduleLabel())
184  != branchDescription.productInstanceName())
186  != branchDescription.processName()))) {
187 
188  LogDebug("L1GtUtils")
189  << "\nWARNING: Found multiple preferred input tags for L1GlobalTriggerReadoutRecord product, "
190  << "\nwith different instaces or processes."
191  << "\nInput tag already found: "
192  << (m_l1GtReadoutRecordInputTag) << "\nActual tag: "
193  << (tag) << "\nInput tag set to empty tag."
194  << std::endl;
195 
198  }
199  } else {
200  // no preferred input tag found yet, check now with the actual tag
201 
202  for (std::vector<edm::InputTag>::const_iterator itPrefTag =
203  preferredL1GtReadoutRecordInputTag.begin(), itPrefTagEnd =
204  preferredL1GtReadoutRecordInputTag.end();
205  itPrefTag != itPrefTagEnd; ++itPrefTag) {
206 
207  if (branchDescription.moduleLabel() == itPrefTag->label()) {
213 
214  LogDebug("L1GtUtils")
215  << "\nWARNING: Input tag for L1GlobalTriggerReadoutRecord product set to preferred input tag"
216  << (tag) << std::endl;
217  break;
218  }
219  }
220  }
221 
223 
224  // check if other input tag was found - if true, there are multiple input tags in the event,
225  // none in the preferred input tags, so it is not possibly to choose safely an input tag
226 
227  if (m_inputTagsL1GtReadoutRecord.size() > 1) {
228 
229  LogDebug("L1GtUtils")
230  << "\nWARNING: Found multiple input tags for L1GlobalTriggerReadoutRecord product."
231  << "\nNone is in the preferred input tags - no safe choice."
232  << "\nInput tag already found: "
233  << (m_l1GtReadoutRecordInputTag) << "\nActual tag: "
234  << (tag) << "\nInput tag set to empty tag."
235  << std::endl;
238 
239  } else {
241 
246 
247  LogDebug("L1GtUtils")
248  << "\nWARNING: No preferred input tag found for L1GlobalTriggerReadoutRecord product."
249  << "\nInput tag set to " << (tag) << std::endl;
250  }
251  }
252  }
253  }
254 
255 
256 
257 
258  // L1GtTriggerMenuLite
259 
261  && (branchDescription.unwrappedTypeID()
262  == edm::TypeID(typeid(L1GtTriggerMenuLite)))
263  && (branchDescription.branchType() == edm::InEvent)) {
264 
265  edm::InputTag tag { branchDescription.moduleLabel(),
266  branchDescription.productInstanceName(),
267  branchDescription.processName() };
268 
270 
271  // check if a preferred input tag was already found and compare it with the actual tag
272  // if the instance or the process names are different, one has incompatible tags - set
273  // the tag to empty input tag and indicate that multiple preferred input tags are found
274  // so it is not possibly to choose safely an input tag
275 
277  == branchDescription.moduleLabel())
279  != branchDescription.productInstanceName())
281  != branchDescription.processName()))) {
282 
283  LogDebug("L1GtUtils")
284  << "\nWARNING: Found multiple preferred input tags for L1GtTriggerMenuLite product, "
285  << "\nwith different instaces or processes."
286  << "\nInput tag already found: "
287  << (m_l1GtTriggerMenuLiteInputTag) << "\nActual tag: " << (tag)
288  << "\nInput tag set to empty tag." << std::endl;
289 
292  }
293  } else {
294  // no preferred input tag found yet, check now with the actual tag
295 
296  for (std::vector<edm::InputTag>::const_iterator itPrefTag =
297  preferredL1GtTriggerMenuLiteInputTag.begin(), itPrefTagEnd =
298  preferredL1GtTriggerMenuLiteInputTag.end();
299  itPrefTag != itPrefTagEnd; ++itPrefTag) {
300 
301  if (branchDescription.moduleLabel() == itPrefTag->label()) {
306  m_inputTagsL1GtMenuLite.push_back(tag);
307 
308  LogDebug("L1GtUtils")
309  << "\nWARNING: Input tag for L1GtTriggerMenuLite product set to preferred input tag"
310  << (tag) << std::endl;
311  break;
312  }
313  }
314  }
315 
317 
318  // check if other input tag was found - if true, there are multiple input tags in the event,
319  // none in the preferred input tags, so it is not possibly to choose safely an input tag
320 
321  if (m_inputTagsL1GtMenuLite.size() > 1) {
322 
323  LogDebug("L1GtUtils")
324  << "\nWARNING: Found multiple input tags for L1GtTriggerMenuLite product."
325  << "\nNone is in the preferred input tags - no safe choice."
326  << "\nInput tag already found: "
327  << (m_l1GtTriggerMenuLiteInputTag) << "\nActual tag: " << (tag)
328  << "\nInput tag set to empty tag." << std::endl;
331 
332  } else {
334 
336  m_inputTagsL1GtMenuLite.push_back(tag);
339 
340  LogDebug("L1GtUtils")
341  << "\nWARNING: No preferred input tag found for L1GtTriggerMenuLite product."
342  << "\nInput tag set to " << (tag) << std::endl;
343  }
344  }
345  }
346  }
347 }
#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
def move
Definition: eostools.py:510
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:73
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)