Back to home page

Project CMSSW displayed by LXR

 
 

    


File indexing completed on 2024-04-06 12:29:41

0001 #ifndef SimDataFormats_GeneratorProducts_HepMCProduct_h
0002 #define SimDataFormats_GeneratorProducts_HepMCProduct_h
0003 
0004 /** \class HepMCProduct
0005  *
0006  *  \author Joanna Weng, Filip Moortgat
0007  */
0008 
0009 #include "DataFormats/Common/interface/Ref.h"
0010 #include <TMatrixD.h>
0011 #include <HepMC/GenEvent.h>
0012 #include <cstddef>
0013 
0014 namespace HepMC {
0015   class FourVector;
0016   class GenParticle;
0017   class GenVertex;
0018 }  // namespace HepMC
0019 
0020 namespace edm {
0021   class HepMCProduct {
0022   public:
0023     HepMCProduct() : evt_(nullptr), isVtxGenApplied_(false), isVtxBoostApplied_(false), isPBoostApplied_(false) {}
0024 
0025     explicit HepMCProduct(HepMC::GenEvent *evt);
0026     virtual ~HepMCProduct();
0027 
0028     void addHepMCData(HepMC::GenEvent *evt);
0029 
0030     void applyVtxGen(HepMC::FourVector const *vtxShift) { applyVtxGen(*vtxShift); }
0031     void applyVtxGen(HepMC::FourVector const &vtxShift);
0032 
0033     void boostToLab(TMatrixD const *lorentz, std::string const &type);
0034 
0035     const HepMC::GenEvent &getHepMCData() const;
0036 
0037     const HepMC::GenEvent *GetEvent() const { return evt_; }
0038 
0039     bool isVtxGenApplied() const { return isVtxGenApplied_; }
0040     bool isVtxBoostApplied() const { return isVtxBoostApplied_; }
0041     bool isPBoostApplied() const { return isPBoostApplied_; }
0042 
0043     HepMCProduct(HepMCProduct const &orig);
0044     HepMCProduct &operator=(HepMCProduct const &other);
0045     HepMCProduct(HepMCProduct &&orig);
0046     HepMCProduct &operator=(HepMCProduct &&other);
0047     void swap(HepMCProduct &other);
0048 
0049   private:
0050     HepMC::GenEvent *evt_;
0051 
0052     bool isVtxGenApplied_;
0053     bool isVtxBoostApplied_;
0054     bool isPBoostApplied_;
0055   };
0056 
0057   // This allows edm::Refs to work with HepMCProduct
0058   namespace refhelper {
0059     template <>
0060     struct FindTrait<edm::HepMCProduct, HepMC::GenParticle> {
0061       struct Find {
0062         using first_argument_type = edm::HepMCProduct const &;
0063         using second_argument_type = int;
0064         using result_type = HepMC::GenParticle const *;
0065 
0066         result_type operator()(first_argument_type iContainer, second_argument_type iBarCode) {
0067           return iContainer.getHepMCData().barcode_to_particle(iBarCode);
0068         }
0069       };
0070 
0071       typedef Find value;
0072     };
0073 
0074     template <>
0075     struct FindTrait<edm::HepMCProduct, HepMC::GenVertex> {
0076       struct Find {
0077         using first_argument_type = edm::HepMCProduct const &;
0078         using second_argument_type = int;
0079         using result_type = HepMC::GenVertex const *;
0080 
0081         result_type operator()(first_argument_type iContainer, second_argument_type iBarCode) {
0082           return iContainer.getHepMCData().barcode_to_vertex(iBarCode);
0083         }
0084       };
0085 
0086       typedef Find value;
0087     };
0088   }  // namespace refhelper
0089 }  // namespace edm
0090 
0091 #endif  // SimDataFormats_GeneratorProducts_HepMCProduct_h