CMS 3D CMS Logo

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