CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
L1TGlobalUtilHelper.cc
Go to the documentation of this file.
6 
8 
9 
11  m_consumesCollector(std::move(iC)),
12  m_l1tAlgBlkInputTag(pset.getParameter<edm::InputTag>("l1tAlgBlkInputTag")),
13  m_l1tExtBlkInputTag(pset.getParameter<edm::InputTag>("l1tExtBlkInputTag")),
14  m_findL1TAlgBlk(false),
15  m_findL1TExtBlk(false),
16  m_foundPreferredL1TAlgBlk(false),
17  m_foundPreferredL1TExtBlk(false) {
18 
21 
22 }
23 
25  desc.add<edm::InputTag>("l1tAlgBlkInputTag", edm::InputTag());
26  desc.add<edm::InputTag>("l1tExtBlkInputTag", edm::InputTag());
27 }
28 
30 
31  // This is only used if required InputTags were not specified already.
32  // This is called early in the process, once for each product in the ProductRegistry.
33  // The callback is registered when callWhenNewProductsRegistered is called.
34  // It finds products by type and sets the token so that it can be used
35  // later when getting the product.
36 
37  // The code will look for the corresponding product in ProductRegistry.
38  // If the product is found, it checks the product label in
39  // a vector of preferred input tags (hardwired now to "gtDigis" and
40  // "hltGtDigis"). The first input tag from the vector of preferred input tags, with the
41  // same label as the input tag found from provenance, is kept as input tag, if there are no
42  // multiple products with the same label.
43 
44  // If multiple products are found and no one has a label in the vector of preferred input tags,
45  // or if multiple products are found with the label in the vector of preferred input tags
46  // (with different instance or process) the input tag is set to empty input tag, and L1GtUtil
47  // will produce an error, as it is not possible to safely choose a product. In this case, one must
48  // provide explicitly the correct input tag via configuration or in the constructor.
49 
50  // TODO decide if the preferred input tags must be given as input parameters
51  // or stay hardwired
52 
53  std::vector<edm::InputTag> preferredL1TAlgBlkInputTag = {
54  edm::InputTag("gtStage2Digis"), edm::InputTag("hltGtStage2Digis") };
55 
56  std::vector<edm::InputTag> preferredL1TExtBlkInputTag = {
57  edm::InputTag("gtStage2Digis"), edm::InputTag("hltGtStage2Digis") };
58 
59 
60  // GlobalAlgBlkBxCollection
61 
62  if (m_findL1TAlgBlk && (!m_foundMultipleL1TAlgBlk)
63  && (branchDescription.unwrappedTypeID()
65  && (branchDescription.branchType() == edm::InEvent)) {
66 
67  edm::InputTag tag { branchDescription.moduleLabel(),
68  branchDescription.productInstanceName(),
69  branchDescription.processName() };
70 
71  if (m_foundPreferredL1TAlgBlk) {
72  // check if a preferred input tag was already found and compare it with the actual tag
73  // if the instance or the process names are different, one has incompatible tags - set
74  // the tag to empty input tag and indicate that multiple preferred input tags are found
75  // so it is not possibly to choose safely an input tag
76 
77  if ((m_l1tAlgBlkInputTag.label() == branchDescription.moduleLabel())
78  && ((m_l1tAlgBlkInputTag.instance()
79  != branchDescription.productInstanceName())
80  || (m_l1tAlgBlkInputTag.process()
81  != branchDescription.processName()))) {
82 
83  LogDebug("L1TGlobalUtil")
84  << "\nWARNING: Found multiple preferred input tags for GlobalAlgBlkBxCollection, "
85  << "\nwith different instaces or processes."
86  << "\nInput tag already found: "
87  << (m_l1tAlgBlkInputTag) << "\nActual tag: " << (tag)
88  << "\nInput tag set to empty tag." << std::endl;
89 
90  m_foundMultipleL1TAlgBlk = true;
91  m_l1tAlgBlkInputTag = edm::InputTag();
92  }
93  } else {
94  // no preferred input tag found yet, check now with the actual tag
95  for (std::vector<edm::InputTag>::const_iterator itPrefTag =
96  preferredL1TAlgBlkInputTag.begin(), itPrefTagEnd =
97  preferredL1TAlgBlkInputTag.end();
98  itPrefTag != itPrefTagEnd; ++itPrefTag) {
99 
100  if (branchDescription.moduleLabel() == itPrefTag->label()) {
101  m_l1tAlgBlkInputTag = tag;
102  m_l1tAlgBlkToken = m_consumesCollector.consumes<GlobalAlgBlkBxCollection>(tag);
103  m_foundPreferredL1TAlgBlk = true;
104  m_inputTagsL1TAlgBlk.push_back(tag);
105 
106  LogDebug("L1TGlobalUtil")
107  << "\nWARNING: Input tag for GlobalAlgBlkBxCollection product set to preferred input tag"
108  << (tag) << std::endl;
109  break;
110  }
111  }
112  }
113 
114  if (!m_foundPreferredL1TAlgBlk) {
115 
116  // check if other input tag was found - if true, there are multiple input tags in the event,
117  // none in the preferred input tags, so it is not possibly to choose safely an input tag
118 
119  if (m_inputTagsL1TAlgBlk.size() > 1) {
120 
121  LogDebug("L1TGlobalUtil")
122  << "\nWARNING: Found multiple input tags for GlobalAlgBlkBxCollection product."
123  << "\nNone is in the preferred input tags - no safe choice."
124  << "\nInput tag already found: "
125  << (m_l1tAlgBlkInputTag) << "\nActual tag: " << (tag)
126  << "\nInput tag set to empty tag." << std::endl;
127  m_l1tAlgBlkInputTag = edm::InputTag();
128  m_foundMultipleL1TAlgBlk = true;
129 
130  } else {
131  if (m_l1tAlgBlkToken.isUninitialized()) {
132 
133  m_l1tAlgBlkInputTag = tag;
134  m_inputTagsL1TAlgBlk.push_back(tag);
135  m_l1tAlgBlkToken = m_consumesCollector.consumes<GlobalAlgBlkBxCollection>(tag);
136 
137  LogDebug("L1TGlobalUtil")
138  << "\nWARNING: No preferred input tag found for GlobalAlgBlkBxCollection."
139  << "\nInput tag set to " << (tag) << std::endl;
140  }
141  }
142  }
143  }
144 
145  // GlobalExtBlkBxCollection
146 
147  if (m_findL1TExtBlk && (!m_foundMultipleL1TExtBlk)
148  && (branchDescription.unwrappedTypeID()
150  && (branchDescription.branchType() == edm::InEvent)) {
151 
152  edm::InputTag tag { branchDescription.moduleLabel(),
153  branchDescription.productInstanceName(),
154  branchDescription.processName() };
155 
156  if (m_foundPreferredL1TExtBlk) {
157 
158  // check if a preferred input tag was already found and compare it with the actual tag
159  // if the instance or the process names are different, one has incompatible tags - set
160  // the tag to empty input tag and indicate that multiple preferred input tags are found
161  // so it is not possibly to choose safely an input tag
162 
163  if ((m_l1tExtBlkInputTag.label()
164  == branchDescription.moduleLabel())
165  && ((m_l1tExtBlkInputTag.instance()
166  != branchDescription.productInstanceName())
167  || (m_l1tExtBlkInputTag.process()
168  != branchDescription.processName()))) {
169 
170  LogDebug("L1TGlobalUtil")
171  << "\nWARNING: Found multiple preferred input tags for GlobalExtBlkBxCollection, "
172  << "\nwith different instaces or processes."
173  << "\nInput tag already found: "
174  << (m_l1tExtBlkInputTag) << "\nActual tag: "
175  << (tag) << "\nInput tag set to empty tag."
176  << std::endl;
177 
178  m_foundMultipleL1TExtBlk = true;
179  m_l1tExtBlkInputTag = edm::InputTag();
180  }
181  } else {
182  // no preferred input tag found yet, check now with the actual tag
183 
184  for (std::vector<edm::InputTag>::const_iterator itPrefTag =
185  preferredL1TExtBlkInputTag.begin(), itPrefTagEnd =
186  preferredL1TExtBlkInputTag.end();
187  itPrefTag != itPrefTagEnd; ++itPrefTag) {
188 
189  if (branchDescription.moduleLabel() == itPrefTag->label()) {
190  m_l1tExtBlkInputTag = tag;
191  m_l1tExtBlkToken = m_consumesCollector.consumes<GlobalExtBlkBxCollection>(tag);
192  m_foundPreferredL1TExtBlk = true;
193  m_inputTagsL1TExtBlk.push_back(tag);
194 
195  LogDebug("L1TGlobalUtil")
196  << "\nWARNING: Input tag for GlobalExtBlkBxCollection product set to preferred input tag"
197  << (tag) << std::endl;
198  break;
199  }
200  }
201  }
202 
203  if (!m_foundPreferredL1TExtBlk) {
204 
205  // check if other input tag was found - if true, there are multiple input tags in the event,
206  // none in the preferred input tags, so it is not possibly to choose safely an input tag
207 
208  if (m_inputTagsL1TExtBlk.size() > 1) {
209 
210  LogDebug("L1TGlobalUtil")
211  << "\nWARNING: Found multiple input tags for GlobalExtBlkBxCollection."
212  << "\nNone is in the preferred input tags - no safe choice."
213  << "\nInput tag already found: "
214  << (m_l1tExtBlkInputTag) << "\nActual tag: "
215  << (tag) << "\nInput tag set to empty tag."
216  << std::endl;
217  m_l1tExtBlkInputTag = edm::InputTag();
218  m_foundMultipleL1TExtBlk = true;
219 
220  } else {
221  if (m_l1tExtBlkToken.isUninitialized()) {
222 
223  m_l1tExtBlkInputTag = tag;
224  m_inputTagsL1TExtBlk.push_back(tag);
225  m_l1tExtBlkToken = m_consumesCollector.consumes<GlobalExtBlkBxCollection>(tag);
226 
227  LogDebug("L1TGlobalUtil")
228  << "\nWARNING: No preferred input tag found for GlobalExtBlkBxCollection product."
229  << "\nInput tag set to " << (tag) << std::endl;
230  }
231  }
232  }
233  }
234 }
#define LogDebug(id)
EDGetTokenT< ProductType > consumes(edm::InputTag const &tag)
BranchType const & branchType() const
std::string const & processName() const
L1TGlobalUtilHelper(edm::ParameterSet const &pset, edm::ConsumesCollector &iC)
edm::EDGetTokenT< GlobalExtBlkBxCollection > m_l1tExtBlkToken
std::string const & moduleLabel() const
std::string const & productInstanceName() const
def move
Definition: eostools.py:510
TypeID unwrappedTypeID() const
static void fillDescription(edm::ParameterSetDescription &desc)
ParameterDescriptionBase * add(U const &iLabel, T const &value)
edm::EDGetTokenT< GlobalAlgBlkBxCollection > m_l1tAlgBlkToken
void operator()(edm::BranchDescription const &branchDescription)
volatile std::atomic< bool > shutdown_flag false
void push_back(int bx, T object)