31 std::pair<TypeInBranchType, ConstBranchDescription const*>
const& iRHS)
const {
32 if(iLHS.first < iRHS.first) {
35 if(iRHS.first < iLHS.first) {
39 int c = iLHS.second->moduleLabel().compare(iRHS.second->moduleLabel());
46 c = iLHS.second->productInstanceName().compare(iRHS.second->productInstanceName());
54 return iLHS.second->processName() < iRHS.second->processName();
62 productLookupIndexList_(),
64 processNameOrderingForBranchType_(static_cast<unsigned int>(
NumBranchTypes), std::vector<std::string>()),
79 for (
unsigned int i = 0; i < static_cast<unsigned int>(
NumBranchTypes); ++
i) {
102 struct CompareModuleLabelAndProductInstanceName {
103 typedef std::pair<std::string const*, std::string const*> StringPtrPair;
104 bool operator()(StringPtrPair
const& iLHS, StringPtrPair
const& iRHS)
const {
105 int c = iLHS.first->compare(*iRHS.first);
106 if (c < 0)
return true;
107 if (c > 0)
return false;
108 return(*iLHS.second < *iRHS.second);
111 int c = iLHS.branchDescription()->moduleLabel().compare(*iRHS.first);
112 if (c < 0)
return true;
113 if (c > 0)
return false;
114 return(iLHS.branchDescription()->productInstanceName() < *iRHS.second);
117 int c = iLHS.first->compare(iRHS.branchDescription()->moduleLabel());
118 if (c < 0)
return true;
119 if (c > 0)
return false;
120 return(*iLHS.second < iRHS.branchDescription()->productInstanceName());
123 int c = iLHS.branchDescription()->moduleLabel().compare(iRHS.branchDescription()->moduleLabel());
124 if (c < 0)
return true;
125 if (c > 0)
return false;
126 return(iLHS.branchDescription()->productInstanceName() < iRHS.branchDescription()->productInstanceName());
130 struct BranchTypeOnlyCompare {
131 bool operator()(std::pair<TypeInBranchType, BranchDescriptionIndex>
const& iLHS, std::pair<TypeInBranchType, BranchDescriptionIndex>
const& iRHS)
const {
132 return iLHS.first.branchType() < iRHS.first.branchType();
136 struct CompareProcessList {
137 std::vector<std::string>
const* list_;
139 CompareProcessList(std::vector<std::string>
const* iList) : list_(iList) {}
142 std::string
const& lhs = iLHS.branchDescription()->processName();
143 std::string
const& rhs = iRHS.branchDescription()->processName();
144 if(lhs == rhs) {
return false;}
146 for(std::vector<std::string>::const_reverse_iterator it = list_->rbegin(), itEnd = list_->rend();
149 if(*it == lhs) {
return true;}
150 if(*it == rhs) {
return false;}
160 TransientProductLookupMap::ProductLookupIndexList::iterator iEnd,
161 std::vector<std::string>
const& iNameOrder) {
163 std::vector<std::string>::const_reverse_iterator itNO = iNameOrder.rbegin();
164 unsigned int index = 0;
165 for(; iIt != iEnd; ++iIt) {
167 itNO = iNameOrder.rbegin();
170 while(*itNO != iIt->branchDescription()->processName()) {
172 assert(itNO != iNameOrder.rend());
175 iIt->setProcessIndex(index);
183 if(iHistory.
id() == historyID) {
188 if(iHistory.
empty()) {
190 historyID = iHistory.
id();
201 std::vector<std::string>::iterator it = processNameOrdering.begin();
202 std::vector<std::string>::iterator itEnd = processNameOrdering.end();
207 std::vector<std::string>::iterator itStart = it;
208 bool mustReorder =
false;
209 while(it != itEnd && itH != itHEnd) {
210 if(*it == itH->processName()) {
214 for(std::vector<std::string>::iterator itOld = itStart; itOld != it; ++itOld) {
215 if(*itOld == itH->processName()) {
226 if(!mustReorder && it != itEnd && *it == iNewProcessName) {
238 historyID = iHistory.
id();
239 std::vector<std::string>
temp(processNameOrdering.size(), std::string());
243 std::vector<std::string>::reverse_iterator itR =
temp.rbegin();
244 std::vector<std::string>::reverse_iterator itREnd =
temp.rend();
248 if(processNameOrdering.end() !=
std::find(processNameOrdering.begin(), processNameOrdering.end(), iNewProcessName)) {
249 *itR = iNewProcessName;
251 if (iNewProcessName == itRH->processName()) {
255 for(; itRH != itRHEnd; ++itRH) {
256 if(processNameOrdering.end() !=
std::find(processNameOrdering.begin(), processNameOrdering.end(), itRH->processName())) {
258 *itR = itRH->processName();
266 std::vector<std::string>::iterator itOld = processNameOrdering.begin();
268 std::vector<std::string>::iterator itStart =
temp.begin()+(itREnd - itR);
269 while(it != itStart) {
270 assert(itOld != processNameOrdering.end());
279 processNameOrdering.swap(
temp);
283 std::pair<TypeInBranchTypeLookup::iterator, TypeInBranchTypeLookup::iterator> branchRange =
286 if(branchRange.first == branchRange.second) {
296 while(itIndex != itIndexEnd) {
297 itIndex->setIsFirst(
false);
298 ProductLookupIndexList::iterator itNext = itIndex;
299 while(itNext != itIndexEnd && !itNext->isFirst()) {
302 std::sort(itIndex, itNext, CompareProcessList(&processNameOrdering));
303 itIndex->setIsFirst(
true);
325 std::set<std::string, std::greater<std::string> > processNames;
329 static std::string
const kEmpty;
330 std::string
const* lastSeenModule = &kEmpty;
331 std::string
const* lastSeenProductInstance = &kEmpty;
332 for(FillFromMap::const_iterator it = iMap.begin(), itEnd = iMap.end();
335 bool isFirst = ((lastSeen < it->first.first) || (it->first.first < lastSeen));
337 lastSeen = it->first.first;
341 isFirst = (*lastSeenModule != it->first.second->moduleLabel() ||
342 *lastSeenProductInstance != it->first.second->productInstanceName());
350 lastSeenModule = &(it->first.second->moduleLabel());
351 lastSeenProductInstance = &(it->first.second->productInstanceName());
353 processNames.insert(it->first.second->processName());
362 for(;itPH != itPHEnd; ++itPH, ++itPN) {
364 itPN->assign(processNames.begin(), processNames.end());
375 struct CompareFirst {
378 return iLHS.first < iRHS.first;
383 std::pair<TransientProductLookupMap::const_iterator, TransientProductLookupMap::const_iterator>
385 TypeInBranchTypeLookup::const_iterator itFind = std::lower_bound(
branchLookup_.begin(),
397 return std::make_pair(itStart, itEnd);
400 std::pair<TransientProductLookupMap::const_iterator, TransientProductLookupMap::const_iterator>
403 std::string
const& productInstanceName)
const {
404 std::pair<const_iterator, const_iterator> itPair = this->
equal_range(iKey);
406 if (itPair.first == itPair.second) {
411 itPair.first = std::lower_bound(itPair.first, itPair.second, std::make_pair(&moduleLabel, &productInstanceName), CompareModuleLabelAndProductInstanceName());
413 if (!(itPair.first < itPair.second) ||
414 itPair.first->branchDescription()->moduleLabel() != moduleLabel ||
415 itPair.first->branchDescription()->productInstanceName() != productInstanceName) {
416 itPair.second = itPair.first;
const_reverse_iterator rbegin() const
collection_type::const_iterator const_iterator
const_iterator begin() const
TypeInBranchTypeLookup branchLookup_
collection_type::const_reverse_iterator const_reverse_iterator
void reorderIfNecessary(BranchType, ProcessHistory const &, std::string const &iNewProcessName)
reorders the ProductLookupIndexes for the BranchType based on the processing ordering ...
ProductLookupIndexList productLookupIndexList_
Container::value_type value_type
void find(edm::Handle< EcalRecHitCollection > &hits, DetId thisDet, std::vector< EcalRecHitCollection::const_iterator > &hit, bool debug=false)
ProductLookupIndexList::const_iterator const_iterator
const_reverse_iterator rend() const
std::vector< ProcessHistoryID > historyIDsForBranchType_
void fillFrom(FillFromMap const &)
std::vector< std::vector< std::string > > processNameOrderingForBranchType_
Hash< ProcessHistoryType > ProcessHistoryID
static void fillInProcessIndexes(TransientProductLookupMap::ProductLookupIndexList::iterator iIt, TransientProductLookupMap::ProductLookupIndexList::iterator iEnd, std::vector< std::string > const &iNameOrder)
bool operator()(std::pair< TypeInBranchType, ConstBranchDescription const * > const &iLHS, std::pair< TypeInBranchType, ConstBranchDescription const * > const &iRHS) const
std::pair< const_iterator, const_iterator > equal_range(TypeInBranchType const &) const
returns a pair of iterators that define the range for items matching the TypeInBranchType ...
TransientProductLookupMap()
const_iterator end() const
ProcessHistoryID id() const
std::map< std::pair< TypeInBranchType, ConstBranchDescription const * >, ProductTransientIndex, CompareTypeInBranchTypeConstBranchDescription > FillFromMap
unsigned int BranchDescriptionIndex
const std::string * moduleLabel() const