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 }
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
edm::InputTag m_l1GtReadoutRecordInputTag
std::string const & instance() const
Definition: InputTag.h:37
BranchType const & branchType() const
constexpr bool isUninitialized() const noexcept
Definition: EDGetToken.h:99
TypeID unwrappedTypeID() const
std::string const & processName() const
edm::EDGetTokenT< L1GtTriggerMenuLite > m_l1GtTriggerMenuLiteToken
std::string const & label() const
Definition: InputTag.h:36
std::vector< edm::InputTag > m_inputTagsL1GtReadoutRecord
edm::InputTag m_l1GtTriggerMenuLiteInputTag
edm::InputTag m_l1GtRecordInputTag
std::vector< edm::InputTag > m_inputTagsL1GtMenuLite
std::string const & productInstanceName() const
bool m_foundMultipleL1GtReadoutRecord
std::vector< edm::InputTag > m_inputTagsL1GtRecord
static void fillDescription(edm::ParameterSetDescription &desc)
bool m_foundMultipleL1GtRecord
edm::EDGetTokenT< L1GlobalTriggerRecord > m_l1GtRecordToken
bool m_foundMultipleL1GtMenuLite
edm::ConsumesCollector m_consumesCollector
bool m_foundPreferredReadoutRecord
static const bool useL1GtTriggerMenuLite(true)
HLT enums.
void operator()(edm::BranchDescription const &branchDescription)
std::string const & process() const
Definition: InputTag.h:40
edm::EDGetTokenT< L1GlobalTriggerReadoutRecord > m_l1GtReadoutRecordToken
std::string const & moduleLabel() const
L1GtUtilsHelper(edm::ParameterSet const &pset, edm::ConsumesCollector &iC, bool useL1GtTriggerMenuLite)
#define LogDebug(id)