Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 13:27:23

0001 #include "Fireworks/FWInterface/src/FWFFMetadataManager.h"
0002 #include "Fireworks/FWInterface/src/FWFFMetadataUpdateRequest.h"
0003 #include "Fireworks/Core/interface/fwLog.h"
0004 #include "DataFormats/Provenance/interface/StableProvenance.h"
0005 #include "DataFormats/Provenance/interface/BranchDescription.h"
0006 #include "FWCore/Framework/interface/Event.h"
0007 #include "Fireworks/Core/interface/FWItemAccessorFactory.h"
0008 
0009 #include "TClass.h"
0010 FWFFMetadataManager::FWFFMetadataManager() : m_event(nullptr) {}
0011 
0012 bool FWFFMetadataManager::hasModuleLabel(std::string &iModuleLabel) {
0013   if (m_event) {
0014     std::vector<edm::StableProvenance const *> provenances;
0015     m_event->getAllStableProvenance(provenances);
0016 
0017     for (size_t pi = 0, pe = provenances.size(); pi != pe; ++pi) {
0018       edm::StableProvenance const *provenance = provenances[pi];
0019       if (provenance && (provenance->branchDescription().moduleLabel() == iModuleLabel))
0020         return true;
0021     }
0022   }
0023   return false;
0024 }
0025 
0026 bool FWFFMetadataManager::doUpdate(FWJobMetadataUpdateRequest *request) {
0027   // Clean up previous data.
0028   usableData().clear();
0029 
0030   assert(m_typeAndReps);
0031   FWFFMetadataUpdateRequest *fullRequest = dynamic_cast<FWFFMetadataUpdateRequest *>(request);
0032   if (!fullRequest)
0033     return false;
0034   const edm::Event &event = fullRequest->event();
0035   m_event = &event;
0036 
0037   typedef std::set<std::string> Purposes;
0038   Purposes purposes;
0039   std::vector<edm::StableProvenance const *> provenances;
0040 
0041   event.getAllStableProvenance(provenances);
0042 
0043   for (size_t pi = 0, pe = provenances.size(); pi != pe; ++pi) {
0044     edm::StableProvenance const *provenance = provenances[pi];
0045     if (!provenance)
0046       continue;
0047     Data d;
0048     const edm::BranchDescription &desc = provenance->branchDescription();
0049 
0050     const std::vector<FWRepresentationInfo> &infos = m_typeAndReps->representationsForType(desc.fullClassName());
0051 
0052     /*
0053       //std::cout <<"try to find match "<<itBranch->fullClassName()<<std::endl;
0054       //For each view we need to find the non-sub-part builder whose proximity is smallest and 
0055       // then register only that purpose
0056       //NOTE: for now, we will ignore the view and only look for the closest proximity
0057       unsigned int minProx = ~(0U);
0058       for (size_t ii = 0, ei = infos.size(); ii != ei; ++ii) {
0059          if (!infos[ii].representsSubPart() && minProx > infos[ii].proximity()) {
0060             minProx = infos[ii].proximity();
0061          }
0062       }
0063        */
0064 
0065     //the infos list can contain multiple items with the same purpose so we will just find
0066     // the unique ones
0067     purposes.clear();
0068     for (size_t ii = 0, ei = infos.size(); ii != ei; ++ii) {
0069       /* if(!infos[ii].representsSubPart() && minProx != infos[ii].proximity()) {
0070             continue;
0071          } */
0072       purposes.insert(infos[ii].purpose());
0073     }
0074 
0075     if (purposes.empty())
0076       purposes.insert("Table");
0077 
0078     for (Purposes::const_iterator itPurpose = purposes.begin(), itEnd = purposes.end(); itPurpose != itEnd;
0079          ++itPurpose) {
0080       // Determine whether or not the class can be iterated
0081       // either by using a TVirtualCollectionProxy (of the class
0082       // itself or on one of its members), or by using a
0083       // FWItemAccessor plugin.
0084       TClass *theClass = TClass::GetClass(desc.fullClassName().c_str());
0085 
0086       if (!theClass)
0087         continue;
0088 
0089       if (!theClass->GetTypeInfo())
0090         continue;
0091 
0092       // This is pretty much the same thing that happens
0093       if (!FWItemAccessorFactory::classAccessedAsCollection(theClass)) {
0094         fwLog(fwlog::kDebug) << theClass->GetName() << " will not be displayed in table." << std::endl;
0095         continue;
0096       }
0097       d.type_ = desc.fullClassName();
0098       d.purpose_ = *itPurpose;
0099       d.moduleLabel_ = desc.moduleLabel();
0100       d.productInstanceLabel_ = desc.productInstanceName();
0101       d.processName_ = desc.processName();
0102       usableData().push_back(d);
0103       fwLog(fwlog::kDebug) << "Add collection will display " << d.type_ << " " << d.moduleLabel_ << " "
0104                            << d.productInstanceLabel_ << " " << d.processName_ << std::endl;
0105     }
0106   }
0107   return true;
0108 }