How to add a set of numbers to each event in a CMSSW root file

Complete: 5

Solution provided by Luca Lista.

1) write your own producer module, e.g. XSectionProducer.h in the package you are working:

#include "FWCore/Framework/interface/EDProducer.h"
#include "FWCore/Framework/interface/Event.h"

class XSectionProducer : public edm::EDProducer {
public:
  explicit XSectionProducer(edm::ParameterSet const& p) :
    xsection_(p.getParameter("xsection")),
    efficiency_(p.getParameter("efficiency")) {
    produces( "xsection" ).setBranchAlias( "xsection" );
    produces( "efficiency" ).setBranchAlias( "efficiency" );

  }
  virtual ~XSectionProducer() { }
  virtual void produce( edm::Event& e, const edm::EventSetup& ) {
    std::auto_ptr
      xsection(new double(xsection_)),
      efficiency(new double(efficiency_));
    e.put(xsection, "xsection" );
    e.put(efficiency, "efficiency" );
  }
private:
  double xsection_, efficiency_;
};

2) add SealModule.cc to your package with declarations of all producers of the package, for example in the case of RecoBTag where there's already another producer (TrackCounting):

#include "PluginManager/ModuleDef.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "RecoBTag/TrackCounting/interface/TrackCounting.h"
#include "RecoBTag/TrackCounting/interface/XSectionProducer.h"

//define this as a plug-in
DEFINE_SEAL_MODULE();
DEFINE_ANOTHER_FWK_MODULE( XSectionProducer );
DEFINE_ANOTHER_FWK_MODULE( TrackCounting );

3) remove the module definition from the already existing producers, in this case from RecoBTag/TrackCounting/src/TrackCounting.cc

4) compile

5) add this module to the configuration file

  module mymodule = XSectionProducer {
    double xsection = 2.2
    double efficiency = 0.9
}
and add mymodule to the path.

6) Note that the aliases which are set in the producer class allow you to plot the recorded items directly by their names (in this example xsection and efficiency).

Alternatively, without writing a producer and compiling, one can add a single number (per each event) by adding

  module crossSection = DoubleProducer {
    double dvalue = 3.1415
}
and adding crossSection to the path.


KatiLassilaPerini - 25 Jul 2006: Created page

Responsible: KatiLassilaPerini

Edit | Attach | Watch | Print version | History: r5 < r4 < r3 < r2 < r1 | Backlinks | Raw View | WYSIWYG | More topic actions
Topic revision: r5 - 2007-10-02 - JennyWilliams



 
    • Cern Search Icon Cern Search
    • TWiki Search Icon TWiki Search
    • Google Search Icon Google Search

    CMSPublic All webs login

This site is powered by the TWiki collaboration platform Powered by PerlCopyright & 2008-2019 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding TWiki? Send feedback