TauSpinnerCMS

Macros

Line Code
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87
// -*- C++ -*-
//
// Package: TauSpinnerInterface
// Class: TauSpinnerCMS
//
/**\class TauSpinnerCMS TauSpinnerCMS.cc

 */
//
// Original Author: Ian Nugent
// Created: Fri Feb 15 2013

#ifndef TauSpinnerCMS_h
#define TauSpinnerCMS_h

#include <iostream>

#include "SimDataFormats/GeneratorProducts/interface/HepMCProduct.h"

// essentials !!!
#include "FWCore/Framework/interface/Event.h"
#include "DataFormats/Common/interface/Handle.h"
#include "FWCore/Framework/interface/MakerMacros.h"

#include "FWCore/ServiceRegistry/interface/Service.h"
#include "CommonTools/UtilAlgos/interface/TFileService.h"
#include "TH1.h"

#include "FWCore/AbstractServices/interface/RandomNumberGenerator.h"
#include "FWCore/Concurrency/interface/SharedResourceNames.h"
#include "FWCore/Framework/interface/one/EDProducer.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/FileBlock.h"
#include "FWCore/Framework/interface/LuminosityBlock.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/Run.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/ServiceRegistry/interface/RandomEngineSentry.h"
#include "FWCore/Utilities/interface/EDMException.h"

#include "DataFormats/HepMCCandidate/interface/GenParticle.h"
#include "DataFormats/HepMCCandidate/interface/GenParticleFwd.h"
#include "TauSpinner/SimpleParticle.h"

class TauSpinnerCMS : public edm::one::EDProducer<edm::one::SharedResources> {
public:
  explicit TauSpinnerCMS(const edm::ParameterSet &);
  ~TauSpinnerCMS() override {}  // no need to delete ROOT stuff

  void produce(edm::Event &, const edm::EventSetup &) final;
  void beginJob() final;
  void endJob() final;
  static double flat();
  void setRandomEngine(CLHEP::HepRandomEngine *v) { fRandomEngine = v; }
  virtual void initialize();

private:
  bool isReco_;
  bool isTauolaConfigured_;
  bool isLHPDFConfigured_;
  std::string LHAPDFname_;
  double CMSEnergy_;
  edm::InputTag gensrc_;
  int MotherPDGID_, Ipol_, nonSM2_, nonSMN_;
  static bool isTauSpinnerConfigure;

  // Additional funtionms for Reco (not provided by Tauola/TauSpinner authors)
  int readParticlesfromReco(edm::Event &e,
                            TauSpinner::SimpleParticle &X,
                            TauSpinner::SimpleParticle &tau,
                            TauSpinner::SimpleParticle &tau2,
                            std::vector<TauSpinner::SimpleParticle> &tau_daughters,
                            std::vector<TauSpinner::SimpleParticle> &tau2_daughters);
  void GetLastSelf(const reco::GenParticle *Particle);
  void GetRecoDaughters(const reco::GenParticle *Particle,
                        std::vector<TauSpinner::SimpleParticle> &daughters,
                        int parentpdgid);
  bool isFirst(const reco::GenParticle *Particle);
  double roundOff_;

  static CLHEP::HepRandomEngine *fRandomEngine;
  edm::EDGetTokenT<edm::HepMCProduct> hepmcCollectionToken_;
  edm::EDGetTokenT<reco::GenParticleCollection> GenParticleCollectionToken_;
  static bool fInitialized;
};
#endif