Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:23:21

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/global/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::global::EDProducer<> {
0041 public:
0042   explicit EventShapeVarsProducer(const edm::ParameterSet&);
0043 
0044 private:
0045   edm::EDGetTokenT<edm::View<reco::Candidate>> srcToken_;
0046   double r_;
0047   unsigned fwmax_;
0048 
0049   void produce(edm::StreamID, edm::Event&, const edm::EventSetup&) const override;
0050 };
0051 
0052 EventShapeVarsProducer::EventShapeVarsProducer(const edm::ParameterSet& cfg) {
0053   srcToken_ = consumes<edm::View<reco::Candidate>>(cfg.getParameter<edm::InputTag>("src"));
0054   r_ = cfg.exists("r") ? cfg.getParameter<double>("r") : 2.;
0055   fwmax_ = cfg.exists("fwmax") ? cfg.getParameter<unsigned>("fwmax") : 0;
0056 
0057   produces<double>("thrust");
0058   //produces<double>("oblateness");
0059   produces<double>("isotropy");
0060   produces<double>("circularity");
0061   produces<double>("sphericity");
0062   produces<double>("aplanarity");
0063   produces<double>("C");
0064   produces<double>("D");
0065   if (fwmax_ > 0)
0066     produces<std::vector<double>>("FWmoments");
0067 }
0068 
0069 void put(edm::Event& evt, double value, const char* instanceName) {
0070   evt.put(std::make_unique<double>(value), instanceName);
0071 }
0072 
0073 void EventShapeVarsProducer::produce(edm::StreamID, edm::Event& evt, const edm::EventSetup&) const {
0074   edm::Handle<edm::View<reco::Candidate>> objects;
0075   evt.getByToken(srcToken_, objects);
0076 
0077   Thrust thrustAlgo(objects->begin(), objects->end());
0078   put(evt, thrustAlgo.thrust(), "thrust");
0079   //put(evt, thrustAlgo.oblateness(), "oblateness");
0080 
0081   EventShapeVariables eventShapeVarsAlgo(*objects);
0082   eventShapeVarsAlgo.set_r(r_);
0083   put(evt, eventShapeVarsAlgo.isotropy(), "isotropy");
0084   put(evt, eventShapeVarsAlgo.circularity(), "circularity");
0085   put(evt, eventShapeVarsAlgo.sphericity(), "sphericity");
0086   put(evt, eventShapeVarsAlgo.aplanarity(), "aplanarity");
0087   put(evt, eventShapeVarsAlgo.C(), "C");
0088   put(evt, eventShapeVarsAlgo.D(), "D");
0089   if (fwmax_ > 0) {
0090     eventShapeVarsAlgo.setFWmax(fwmax_);
0091     auto vfw = std::make_unique<std::vector<double>>(eventShapeVarsAlgo.getFWmoments());
0092     evt.put(std::move(vfw), "FWmoments");
0093   }
0094 }
0095 
0096 #include "FWCore/Framework/interface/MakerMacros.h"
0097 
0098 DEFINE_FWK_MODULE(EventShapeVarsProducer);