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  if (branchDescription.dropped()) { return; }
56 
57  std::vector<edm::InputTag> preferredL1TAlgBlkInputTag = {
58  edm::InputTag("gtStage2Digis"), edm::InputTag("hltGtStage2Digis") };
59 
60  std::vector<edm::InputTag> preferredL1TExtBlkInputTag = {
61  edm::InputTag("gtStage2Digis"), edm::InputTag("hltGtStage2Digis") };
62 
63 
64  // GlobalAlgBlkBxCollection
65 
67  && (branchDescription.unwrappedTypeID()
69  && (branchDescription.branchType() == edm::InEvent)) {
70 
71  edm::InputTag tag { branchDescription.moduleLabel(),
72  branchDescription.productInstanceName(),
73  branchDescription.processName() };
74 
76  // check if a preferred input tag was already found and compare it with the actual tag
77  // if the instance or the process names are different, one has incompatible tags - set
78  // the tag to empty input tag and indicate that multiple preferred input tags are found
79  // so it is not possibly to choose safely an input tag
80 
81  if ((m_l1tAlgBlkInputTag.label() == branchDescription.moduleLabel())
83  != branchDescription.productInstanceName())
85  != branchDescription.processName()))) {
86 
87  LogDebug("L1TGlobalUtil")
88  << "\nWARNING: Found multiple preferred input tags for GlobalAlgBlkBxCollection, "
89  << "\nwith different instaces or processes."
90  << "\nInput tag already found: "
91  << (m_l1tAlgBlkInputTag) << "\nActual tag: " << (tag)
92  << "\nInput tag set to empty tag." << std::endl;
93 
96  }
97  } else {
98  // no preferred input tag found yet, check now with the actual tag
99  for (std::vector<edm::InputTag>::const_iterator itPrefTag =
100  preferredL1TAlgBlkInputTag.begin(), itPrefTagEnd =
101  preferredL1TAlgBlkInputTag.end();
102  itPrefTag != itPrefTagEnd; ++itPrefTag) {
103 
104  if (branchDescription.moduleLabel() == itPrefTag->label()) {
108  m_inputTagsL1TAlgBlk.push_back(tag);
109 
110  LogDebug("L1TGlobalUtil")
111  << "\nWARNING: Input tag for GlobalAlgBlkBxCollection product set to preferred input tag"
112  << (tag) << std::endl;
113  break;
114  }
115  }
116  }
117 
119 
120  // check if other input tag was found - if true, there are multiple input tags in the event,
121  // none in the preferred input tags, so it is not possibly to choose safely an input tag
122 
123  if (m_inputTagsL1TAlgBlk.size() > 1) {
124 
125  LogDebug("L1TGlobalUtil")
126  << "\nWARNING: Found multiple input tags for GlobalAlgBlkBxCollection product."
127  << "\nNone is in the preferred input tags - no safe choice."
128  << "\nInput tag already found: "
129  << (m_l1tAlgBlkInputTag) << "\nActual tag: " << (tag)
130  << "\nInput tag set to empty tag." << std::endl;
133 
134  } else {
135  if (m_l1tAlgBlkToken.isUninitialized()) {
136 
138  m_inputTagsL1TAlgBlk.push_back(tag);
140 
141  LogDebug("L1TGlobalUtil")
142  << "\nWARNING: No preferred input tag found for GlobalAlgBlkBxCollection."
143  << "\nInput tag set to " << (tag) << std::endl;
144  }
145  }
146  }
147  }
148 
149  // GlobalExtBlkBxCollection
150 
152  && (branchDescription.unwrappedTypeID()
154  && (branchDescription.branchType() == edm::InEvent)) {
155 
156  edm::InputTag tag { branchDescription.moduleLabel(),
157  branchDescription.productInstanceName(),
158  branchDescription.processName() };
159 
161 
162  // check if a preferred input tag was already found and compare it with the actual tag
163  // if the instance or the process names are different, one has incompatible tags - set
164  // the tag to empty input tag and indicate that multiple preferred input tags are found
165  // so it is not possibly to choose safely an input tag
166 
168  == branchDescription.moduleLabel())
170  != branchDescription.productInstanceName())
172  != branchDescription.processName()))) {
173 
174  LogDebug("L1TGlobalUtil")
175  << "\nWARNING: Found multiple preferred input tags for GlobalExtBlkBxCollection, "
176  << "\nwith different instaces or processes."
177  << "\nInput tag already found: "
178  << (m_l1tExtBlkInputTag) << "\nActual tag: "
179  << (tag) << "\nInput tag set to empty tag."
180  << std::endl;
181 
184  }
185  } else {
186  // no preferred input tag found yet, check now with the actual tag
187 
188  for (std::vector<edm::InputTag>::const_iterator itPrefTag =
189  preferredL1TExtBlkInputTag.begin(), itPrefTagEnd =
190  preferredL1TExtBlkInputTag.end();
191  itPrefTag != itPrefTagEnd; ++itPrefTag) {
192 
193  if (branchDescription.moduleLabel() == itPrefTag->label()) {
197  m_inputTagsL1TExtBlk.push_back(tag);
198 
199  LogDebug("L1TGlobalUtil")
200  << "\nWARNING: Input tag for GlobalExtBlkBxCollection product set to preferred input tag"
201  << (tag) << std::endl;
202  break;
203  }
204  }
205  }
206 
208 
209  // check if other input tag was found - if true, there are multiple input tags in the event,
210  // none in the preferred input tags, so it is not possibly to choose safely an input tag
211 
212  if (m_inputTagsL1TExtBlk.size() > 1) {
213 
214  LogDebug("L1TGlobalUtil")
215  << "\nWARNING: Found multiple input tags for GlobalExtBlkBxCollection."
216  << "\nNone is in the preferred input tags - no safe choice."
217  << "\nInput tag already found: "
218  << (m_l1tExtBlkInputTag) << "\nActual tag: "
219  << (tag) << "\nInput tag set to empty tag."
220  << std::endl;
223 
224  } else {
225  if (m_l1tExtBlkToken.isUninitialized()) {
226 
228  m_inputTagsL1TExtBlk.push_back(tag);
230 
231  LogDebug("L1TGlobalUtil")
232  << "\nWARNING: No preferred input tag found for GlobalExtBlkBxCollection product."
233  << "\nInput tag set to " << (tag) << std::endl;
234  }
235  }
236  }
237  }
238 }
#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