Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-02-14 14:21:21

0001 
0002 #include <iostream>
0003 
0004 #include "IOPool/Streamer/test/StreamThingAnalyzer.h"
0005 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0006 
0007 #include "FWCore/Framework/interface/Event.h"
0008 #include "FWCore/Framework/interface/ModuleLabelMatch.h"
0009 #include "DataFormats/Common/interface/Handle.h"
0010 #include "FWCore/Framework/interface/MakerMacros.h"
0011 // #include "FWCore/MessageLogger/interface/MessageLogger.h"
0012 
0013 #include <iostream>
0014 #include <algorithm>
0015 #include <numeric>
0016 #include <iterator>
0017 
0018 using namespace edmtestprod;
0019 
0020 namespace edmtest_thing {
0021   StreamThingAnalyzer::StreamThingAnalyzer(edm::ParameterSet const& ps)
0022       : name_(ps.getParameter<std::string>("product_to_get")),
0023         total_(),
0024         out_("gennums.txt"),
0025         cnt_(),
0026         getterUsingLabel_(edm::ModuleLabelMatch(name_), this) {
0027     callWhenNewProductsRegistered(getterUsingLabel_);
0028     if (!out_) {
0029       std::cerr << "cannot open file gennums.txt" << std::endl;
0030       abort();
0031     }
0032     out_ << "event instance value" << std::endl;
0033 
0034     //LogDebug("StreamThing") << "ctor completing"; // << std::endl;
0035     //edm::LogInfo("stuff") << "again, ctor completing";
0036   }
0037 
0038   StreamThingAnalyzer::~StreamThingAnalyzer() { std::cout << "\nSTREAMTHING_CHECKSUM " << total_ << "\n" << std::endl; }
0039 
0040   void StreamThingAnalyzer::analyze(edm::Event const& e, edm::EventSetup const&) {
0041     typedef std::vector<edm::Handle<WriteThis> > ProdList;
0042     ProdList prod;
0043     getterUsingLabel_.fillHandles(e, prod);
0044     ProdList::iterator i(prod.begin()), end(prod.end());
0045     for (; i != end; ++i)
0046       total_ = accumulate((*i)->data_.begin(), (*i)->data_.end(), total_);
0047       //std::cout << tot << std::endl;
0048 
0049 #if 0
0050     for(i = prod.begin();i != end; ++i) {
0051       std::vector<int>::const_iterator ii((*i)->data_.begin()),
0052          ib((*i)->data_.end());
0053       for(; ii != ib; ++ii) {
0054              out_ << cnt_ << " " << i->id() << " " << *ii << "\n" ;
0055       }
0056     }
0057 #endif
0058 
0059     ++cnt_;
0060   }
0061 }  // namespace edmtest_thing
0062 
0063 using edmtest_thing::StreamThingAnalyzer;
0064 DEFINE_FWK_MODULE(StreamThingAnalyzer);