CMS 3D CMS Logo

Public Member Functions | Static Public Member Functions | Private Attributes

edm::EventContentAnalyzer Class Reference

Inheritance diagram for edm::EventContentAnalyzer:
edm::EDAnalyzer

List of all members.

Public Member Functions

virtual void analyze (Event const &, EventSetup const &)
virtual void endJob ()
 EventContentAnalyzer (ParameterSet const &)
 ~EventContentAnalyzer ()

Static Public Member Functions

static void fillDescriptions (ConfigurationDescriptions &descriptions)

Private Attributes

std::map< std::string, int > cumulates_
int evno_
bool getData_
std::vector< std::string > getModuleLabels_
std::string indentation_
bool listContent_
std::vector< std::string > moduleLabels_
bool verbose_
std::string verboseIndentation_

Detailed Description

Definition at line 263 of file EventContentAnalyzer.cc.


Constructor & Destructor Documentation

edm::EventContentAnalyzer::EventContentAnalyzer ( ParameterSet const &  iConfig) [explicit]

Definition at line 290 of file EventContentAnalyzer.cc.

References moduleLabels_, and edm::sort_all().

                                                                        :
    indentation_(iConfig.getUntrackedParameter("indentation", std::string("++"))),
    verboseIndentation_(iConfig.getUntrackedParameter("verboseIndentation", std::string("  "))),
    moduleLabels_(iConfig.getUntrackedParameter("verboseForModuleLabels", std::vector<std::string>())),
    verbose_(iConfig.getUntrackedParameter("verbose", false) || moduleLabels_.size()>0),
    getModuleLabels_(iConfig.getUntrackedParameter("getDataForModuleLabels", std::vector<std::string>())),
    getData_(iConfig.getUntrackedParameter("getData", false) || getModuleLabels_.size()>0),
    evno_(1),
    listContent_(iConfig.getUntrackedParameter("listContent",true)){
     //now do what ever initialization is needed
     sort_all(moduleLabels_);
  }
edm::EventContentAnalyzer::~EventContentAnalyzer ( )

Definition at line 303 of file EventContentAnalyzer.cc.

                                              {

     // do anything here that needs to be done at destruction time
     // (e.g. close files, deallocate resources etc.)

  }

Member Function Documentation

void edm::EventContentAnalyzer::analyze ( Event const &  iEvent,
EventSetup const &  iSetup 
) [virtual]

Implements edm::EDAnalyzer.

Definition at line 316 of file EventContentAnalyzer.cc.

References edm::binary_search_all(), className(), cumulates_, evno_, edm::friendlyname::friendlyName(), edm::Event::getAllProvenance(), edm::Event::getByLabel(), getData_, getModuleLabels_, patZpeak::handle, indentation_, combine::key, listContent_, moduleLabels_, verbose_, and verboseIndentation_.

                                                                             {
     typedef std::vector<Provenance const*> Provenances;
     Provenances provenances;

     iEvent.getAllProvenance(provenances);

     if(listContent_) {
       LogAbsolute("EventContent") << "\n" << indentation_ << "Event " << std::setw(5) << evno_ << " contains "
                                   << provenances.size() << " product" << (provenances.size() == 1 ? "" : "s")
                                   << " with friendlyClassName, moduleLabel, productInstanceName and processName:"
                                   << std::endl;
     }

     std::string startIndent = indentation_+verboseIndentation_;
     for(Provenances::iterator itProv = provenances.begin(), itProvEnd = provenances.end();
                               itProv != itProvEnd;
                             ++itProv) {
         std::string const& className = (*itProv)->className();

         std::string const& friendlyName = (*itProv)->friendlyClassName();
         //if(friendlyName.empty())  friendlyName = std::string("||");

         std::string const& modLabel = (*itProv)->moduleLabel();
         //if(modLabel.empty()) modLabel = std::string("||");

         std::string const& instanceName = (*itProv)->productInstanceName();
         //if(instanceName.empty()) instanceName = std::string("||");

         std::string const& processName = (*itProv)->processName();

         bool doVerbose = verbose_ && (moduleLabels_.empty() ||
                                       binary_search_all(moduleLabels_, modLabel));

         if(listContent_ || doVerbose ) {
           LogAbsolute("EventContent") << indentation_ << friendlyName
                                       << " \"" << modLabel
                                       << "\" \"" << instanceName << "\" \""
                                       << processName << "\""
                                       << " (productId = " << (*itProv)->productID() << ")"
                                       << std::endl;
         }

         std::string key = friendlyName
         + std::string(" + \"") + modLabel
         + std::string("\" + \"") + instanceName + "\" \"" + processName + "\"";
         ++cumulates_[key];

         if(doVerbose) {

           //indent one level before starting to print
           printObject(iEvent,
                       className,
                       modLabel,
                       instanceName,
                       processName,
                       startIndent,
                       verboseIndentation_);
             continue;

         }
         if(getData_) {
           if(getModuleLabels_.empty() ||
             binary_search_all(getModuleLabels_, modLabel)) {
             try {
               GenericHandle handle(className);
             } catch(edm::Exception const&) {
               LogAbsolute("EventContent") << startIndent << " \"" << className << "\"" << " is an unknown type" << std::endl;
               return;
             }
             GenericHandle handle(className);
             iEvent.getByLabel(InputTag(modLabel,
                                        instanceName,
                                        processName),
                                        handle);
           }
         }
     }
     //std::cout <<"Mine"<<std::endl;
     ++evno_;
  }
void edm::EventContentAnalyzer::endJob ( void  ) [virtual]

Reimplemented from edm::EDAnalyzer.

Definition at line 399 of file EventContentAnalyzer.cc.

References cumulates_.

                               {
     typedef std::map<std::string, int> nameMap;

     LogAbsolute("EventContent") << "\nSummary for key being the concatenation of friendlyClassName, moduleLabel, productInstanceName and processName" << std::endl;
     for(nameMap::const_iterator it = cumulates_.begin(), itEnd = cumulates_.end();
                                 it != itEnd;
                                 ++it) {
        LogAbsolute("EventContent") << std::setw(6) << it->second << " occurrences of key " << it->first << std::endl;
     }

  // Test boost::lexical_cast  We don't need this right now so comment it out.
  // int k = 137;
  // std::string ktext = boost::lexical_cast<std::string>(k);
  // std::cout << "\nInteger " << k << " expressed as a string is |" << ktext << "|" << std::endl;
  }
void edm::EventContentAnalyzer::fillDescriptions ( ConfigurationDescriptions descriptions) [static]

Reimplemented from edm::EDAnalyzer.

Definition at line 416 of file EventContentAnalyzer.cc.

References edm::ConfigurationDescriptions::add(), edm::ParameterSetDescription::addOptionalUntracked(), runTheMatrix::np, edm::ParameterDescriptionNode::setComment(), and edm::ConfigurationDescriptions::setComment().

                                                                                 {

     descriptions.setComment("This plugin will print a list of all products in the event "
                             "provenance.  It also has options to print and/or get each product.");

     ParameterSetDescription desc;

     ParameterDescriptionNode *np;

     std::string defaultString("++");
     np = desc.addOptionalUntracked<std::string>("indentation", defaultString);
     np->setComment("This string is printed at the beginning of every line printed during event processing.");

     np = desc.addOptionalUntracked<bool>("verbose", false);
     np->setComment("If true, the contents of products are printed using Reflex.");

     defaultString = "  ";
     np = desc.addOptionalUntracked<std::string>("verboseIndentation", defaultString);
     np->setComment("This string is used to further indent lines when printing the contents of products in verbose mode.");

     std::vector<std::string> defaultVString;

     np = desc.addOptionalUntracked<std::vector<std::string> >("verboseForModuleLabels", defaultVString);
     np->setComment("If this vector is not empty, then only products with module labels on this list are printed using Reflex.");

     np = desc.addOptionalUntracked<bool>("getData", false);
     np->setComment("If true the products will be retrieved using getByLabel.");

     np = desc.addOptionalUntracked<std::vector<std::string> >("getDataForModuleLabels", defaultVString);
     np->setComment("If this vector is not empty, then only products with module labels on this list are retrieved by getByLabel.");

     np = desc.addOptionalUntracked<bool>("listContent", true);
     np->setComment("If true then print a list of all the event content.");


     descriptions.add("printContent", desc);
  }

Member Data Documentation

std::map<std::string, int> edm::EventContentAnalyzer::cumulates_ [private]

Definition at line 283 of file EventContentAnalyzer.cc.

Referenced by analyze(), and endJob().

Definition at line 282 of file EventContentAnalyzer.cc.

Referenced by analyze().

Definition at line 281 of file EventContentAnalyzer.cc.

Referenced by analyze().

std::vector<std::string> edm::EventContentAnalyzer::getModuleLabels_ [private]

Definition at line 280 of file EventContentAnalyzer.cc.

Referenced by analyze().

Definition at line 276 of file EventContentAnalyzer.cc.

Referenced by analyze().

Definition at line 284 of file EventContentAnalyzer.cc.

Referenced by analyze().

std::vector<std::string> edm::EventContentAnalyzer::moduleLabels_ [private]

Definition at line 278 of file EventContentAnalyzer.cc.

Referenced by analyze(), and EventContentAnalyzer().

Definition at line 279 of file EventContentAnalyzer.cc.

Referenced by analyze().

Definition at line 277 of file EventContentAnalyzer.cc.

Referenced by analyze().