CMS 3D CMS Logo

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