CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Private Member Functions

edm::ProvenanceCheckerOutputModule Class Reference

Inheritance diagram for edm::ProvenanceCheckerOutputModule:
edm::OutputModule

List of all members.

Public Member Functions

 ProvenanceCheckerOutputModule (ParameterSet const &pset)
virtual ~ProvenanceCheckerOutputModule ()

Static Public Member Functions

static void fillDescriptions (ConfigurationDescriptions &descriptions)

Private Member Functions

virtual void write (EventPrincipal const &e)
virtual void writeLuminosityBlock (LuminosityBlockPrincipal const &)
virtual void writeRun (RunPrincipal const &)

Detailed Description

Definition at line 28 of file ProvenanceCheckerOutputModule.cc.


Constructor & Destructor Documentation

edm::ProvenanceCheckerOutputModule::ProvenanceCheckerOutputModule ( ParameterSet const &  pset) [explicit]

Definition at line 53 of file ProvenanceCheckerOutputModule.cc.

                                                                                        :
   OutputModule(pset)
   {
   }
edm::ProvenanceCheckerOutputModule::~ProvenanceCheckerOutputModule ( ) [virtual]

Definition at line 63 of file ProvenanceCheckerOutputModule.cc.

   {
   }

Member Function Documentation

void edm::ProvenanceCheckerOutputModule::fillDescriptions ( ConfigurationDescriptions descriptions) [static]

Reimplemented from edm::OutputModule.

Definition at line 220 of file ProvenanceCheckerOutputModule.cc.

References edm::ConfigurationDescriptions::add(), and edm::OutputModule::fillDescription().

                                                                                         {
    ParameterSetDescription desc;
    OutputModule::fillDescription(desc);
    descriptions.add("provenanceChecker", desc);
  }
void edm::ProvenanceCheckerOutputModule::write ( EventPrincipal const &  e) [private, virtual]

Implements edm::OutputModule.

Definition at line 104 of file ProvenanceCheckerOutputModule.cc.

References edm::Principal::begin(), edm::EventPrincipal::branchMapperPtr(), edm::Principal::end(), Exception, edm::Principal::getForOutput(), edm::ProductRegistry::productList(), and edm::Principal::productRegistry().

                                                               {
      //check ProductProvenance's parents to see if they are in the ProductProvenance list
      boost::shared_ptr<BranchMapper> mapperPtr = e.branchMapperPtr();

      std::map<BranchID, bool> seenParentInPrincipal;
      std::set<BranchID> missingFromMapper;
      std::set<BranchID> missingProductProvenance;

      std::map<BranchID, boost::shared_ptr<Group> > idToGroup;
      for(EventPrincipal::const_iterator it = e.begin(), itEnd = e.end();
          it != itEnd;
          ++it) {
         if(*it) {
            BranchID branchID = (*it)->branchDescription().branchID();
            idToGroup[branchID] = (*it);
            if((*it)->productUnavailable()) {
               //This call seems to have a side effect of filling the 'ProductProvenance' in the Group
               OutputHandle const oh = e.getForOutput(branchID, false);

               bool cannotFindProductProvenance=false;
               if(!(*it)->productProvenancePtr()) {
                  missingProductProvenance.insert(branchID);
                  cannotFindProductProvenance=true;
               }
               ProductProvenance const* pInfo = mapperPtr->branchIDToProvenance(branchID);
               if(!pInfo) {
                  missingFromMapper.insert(branchID);
                  continue;
               }
               if(cannotFindProductProvenance) {
                  continue;
               }
               markAncestors(*((*it)->productProvenancePtr()), *mapperPtr, seenParentInPrincipal, missingFromMapper);
            }
            seenParentInPrincipal[branchID] = true;
         }
      }

      //Determine what BranchIDs are in the product registry
      ProductRegistry const& reg = e.productRegistry();
      ProductRegistry::ProductList const prodList = reg.productList();
      std::set<BranchID> branchesInReg;
      for(ProductRegistry::ProductList::const_iterator it = prodList.begin(), itEnd = prodList.end();
          it != itEnd;
          ++it) {
         branchesInReg.insert(it->second.branchID());
      }

      std::set<BranchID> missingFromPrincipal;
      std::set<BranchID> missingFromReg;
      for(std::map<BranchID, bool>::iterator it = seenParentInPrincipal.begin(), itEnd = seenParentInPrincipal.end();
          it != itEnd;
          ++it) {
         if(!it->second) {
            missingFromPrincipal.insert(it->first);
         }
         if(branchesInReg.find(it->first) == branchesInReg.end()) {
            missingFromReg.insert(it->first);
         }
      }

      if(missingFromMapper.size()) {
         LogError("ProvenanceChecker") << "Missing the following BranchIDs from BranchMapper\n";
         for(std::set<BranchID>::iterator it = missingFromMapper.begin(), itEnd = missingFromMapper.end();
             it != itEnd;
             ++it) {
            LogProblem("ProvenanceChecker") << *it<<" "<<idToGroup[*it]->branchDescription();
         }
      }
      if(missingFromPrincipal.size()) {
         LogError("ProvenanceChecker") << "Missing the following BranchIDs from EventPrincipal\n";
         for(std::set<BranchID>::iterator it = missingFromPrincipal.begin(), itEnd = missingFromPrincipal.end();
             it != itEnd;
             ++it) {
            LogProblem("ProvenanceChecker") << *it;
         }
      }

      if(missingProductProvenance.size()) {
         LogError("ProvenanceChecker") << "The Groups for the following BranchIDs have no ProductProvenance\n";
         for(std::set<BranchID>::iterator it = missingProductProvenance.begin(), itEnd = missingProductProvenance.end();
             it != itEnd;
             ++it) {
            LogProblem("ProvenanceChecker") << *it<<" "<<idToGroup[*it]->branchDescription();
         }
      }

      if(missingFromReg.size()) {
         LogError("ProvenanceChecker") << "Missing the following BranchIDs from ProductRegistry\n";
         for(std::set<BranchID>::iterator it = missingFromReg.begin(), itEnd = missingFromReg.end();
             it != itEnd;
             ++it) {
            LogProblem("ProvenanceChecker") << *it;
         }
      }

      if(missingFromMapper.size() || missingFromPrincipal.size() || missingProductProvenance.size() || missingFromReg.size()) {
         throw cms::Exception("ProvenanceError")
         << (missingFromMapper.size() || missingFromPrincipal.size() ? "Having missing ancestors" : "")
         << (missingFromMapper.size() ? " from BranchMapper" : "")
         << (missingFromMapper.size() && missingFromPrincipal.size() ? " and" : "")
         << (missingFromPrincipal.size() ? " from EventPrincipal" : "")
         << (missingFromMapper.size() || missingFromPrincipal.size() ? ".\n" : "")
         << (missingProductProvenance.size() ? " Have missing ProductProvenance's from Group in EventPrincipal.\n" : "")
         << (missingFromReg.size() ? " Have missing info from ProductRegistry.\n" : "");
      }
   }
virtual void edm::ProvenanceCheckerOutputModule::writeLuminosityBlock ( LuminosityBlockPrincipal const &  ) [inline, private, virtual]

Implements edm::OutputModule.

Definition at line 37 of file ProvenanceCheckerOutputModule.cc.

{}
virtual void edm::ProvenanceCheckerOutputModule::writeRun ( RunPrincipal const &  ) [inline, private, virtual]

Implements edm::OutputModule.

Definition at line 38 of file ProvenanceCheckerOutputModule.cc.

{}