Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2021-07-28 03:10:09

0001 /** \class EventShapeVarsProducer
0002  *
0003  * Produce set of event shape variables.
0004  * The values of different event shape variables are stored as doubles in the event.
0005  * They can be retrieved with InputTags like "moduleName::instanceName", where moduleName corresponds to
0006  * "eventShapeVarsProducer" per default and instance name specifies an individual event shape variable
0007  * which you wish to retrieve from the event:
0008  *
0009  *  - thrust
0010  *  - oblateness
0011  *  - isotropy
0012  *  - circularity
0013  *  - sphericity
0014  *  - aplanarity
0015  *  - C
0016  *  - D
0017  *  - Fox-Wolfram moments
0018  *
0019  *  See https://arxiv.org/pdf/hep-ph/0603175v2.pdf#page=524
0020  *  for an explanation of sphericity, aplanarity, the quantities C and D, thrust, oblateness, Fox-Wolfram moments.
0021  *
0022  * \author Christian Veelken, UC Davis
0023  *
0024  *
0025  *
0026  */
0027 
0028 #include "FWCore/Framework/interface/EDProducer.h"
0029 #include "FWCore/Framework/interface/Event.h"
0030 #include "FWCore/Framework/interface/EventSetup.h"
0031 #include "FWCore/MessageLogger/interface/MessageLogger.h"
0032 #include "FWCore/ParameterSet/interface/ParameterSet.h"
0033 #include "FWCore/Utilities/interface/InputTag.h"
0034 #include "PhysicsTools/CandUtils/interface/EventShapeVariables.h"
0035 #include "PhysicsTools/CandUtils/interface/Thrust.h"
0036 
0037 #include <memory>
0038 #include <vector>
0039 
0040 class EventShapeVarsProducer : public edm::EDProducer {
0041 public:
0042   explicit EventShapeVarsProducer(const edm::ParameterSet&);
0043   ~EventShapeVarsProducer() override {}
0044 
0045 private:
0046   edm::EDGetTokenT<edm::View<reco::Candidate>> srcToken_;
0047   double r_;
0048   unsigned fwmax_;
0049 
0050   void beginJob() override {}
0051   void produce(edm::Event&, const edm::EventSetup&) override;
0052   void endJob() override {}
0053 };
0054 
0055 EventShapeVarsProducer::EventShapeVarsProducer(const edm::ParameterSet& cfg) {
0056   srcToken_ = consumes<edm::View<reco::Candidate>>(cfg.getParameter<edm::InputTag>("src"));
0057   r_ = cfg.exists("r") ? cfg.getParameter<double>("r") : 2.;
0058   fwmax_ = cfg.exists("fwmax") ? cfg.getParameter<unsigned>("fwmax") : 0;
0059 
0060   produces<double>("thrust");
0061   //produces<double>("oblateness");
0062   produces<double>("isotropy");
0063   produces<double>("circularity");
0064   produces<double>("sphericity");
0065   produces<double>("aplanarity");
0066   produces<double>("C");
0067   produces<double>("D");
0068   if (fwmax_ > 0)
0069     produces<std::vector<double>>("FWmoments");
0070 }
0071 
0072 void put(edm::Event& evt, double value, const char* instanceName) {
0073   evt.put(std::make_unique<double>(value), instanceName);
0074 }
0075 
0076 void EventShapeVarsProducer::produce(edm::Event& evt, const edm::EventSetup&) {
0077   edm::Handle<edm::View<reco::Candidate>> objects;
0078   evt.getByToken(srcToken_, objects);
0079 
0080   Thrust thrustAlgo(objects->begin(), objects->end());
0081   put(evt, thrustAlgo.thrust(), "thrust");
0082   //put(evt, thrustAlgo.oblateness(), "oblateness");
0083 
0084   EventShapeVariables eventShapeVarsAlgo(*objects);
0085   eventShapeVarsAlgo.set_r(r_);
0086   put(evt, eventShapeVarsAlgo.isotropy(), "isotropy");
0087   put(evt, eventShapeVarsAlgo.circularity(), "circularity");
0088   put(evt, eventShapeVarsAlgo.sphericity(), "sphericity");
0089   put(evt, eventShapeVarsAlgo.aplanarity(), "aplanarity");
0090   put(evt, eventShapeVarsAlgo.C(), "C");
0091   put(evt, eventShapeVarsAlgo.D(), "D");
0092   if (fwmax_ > 0) {
0093     eventShapeVarsAlgo.setFWmax(fwmax_);
0094     auto vfw = std::make_unique<std::vector<double>>(eventShapeVarsAlgo.getFWmoments());
0095     evt.put(std::move(vfw), "FWmoments");
0096   }
0097 }
0098 
0099 #include "FWCore/Framework/interface/MakerMacros.h"
0100 
0101 DEFINE_FWK_MODULE(EventShapeVarsProducer);