CMS 3D CMS Logo

Public Member Functions | Private Attributes

edm::HepMCProduct Class Reference

#include <HepMCProduct.h>

List of all members.

Public Member Functions

void addHepMCData (HepMC::GenEvent *evt)
void applyVtxGen (HepMC::FourVector *vtxShift) const
void boostToLab (TMatrixD *lorentz, std::string type) const
const HepMC::GenEvent * GetEvent () const
const HepMC::GenEvent & getHepMCData () const
 HepMCProduct (HepMC::GenEvent *evt)
 HepMCProduct ()
 HepMCProduct (HepMCProduct const &orig)
bool isPBoostApplied () const
bool isVtxBoostApplied () const
bool isVtxGenApplied () const
HepMCProductoperator= (HepMCProduct const &other)
void swap (HepMCProduct &other)
virtual ~HepMCProduct ()

Private Attributes

HepMC::GenEvent * evt_
bool isPBoostApplied_
bool isVtxBoostApplied_
bool isVtxGenApplied_

Detailed Description

Definition at line 18 of file HepMCProduct.h.


Constructor & Destructor Documentation

edm::HepMCProduct::HepMCProduct ( ) [inline]

Definition at line 20 of file HepMCProduct.h.

                               :
                        evt_(0), isVtxGenApplied_(false),
                        isVtxBoostApplied_(false), isPBoostApplied_(false) {}
HepMCProduct::HepMCProduct ( HepMC::GenEvent *  evt) [explicit]

Definition at line 17 of file HepMCProduct.cc.

References gather_cfg::cout.

                                                {
    evt_ = evt;
    cout << "Contructing HepMCProduct" << endl;
    
    //note: this is not quite safe, because GenEvent does NOT
    //      know if vertex smearing applied or nor - only the
    //      HepMCProduct itself knows !
    // isVtxGenApplied_ = 0 ;  // ???
}
HepMCProduct::~HepMCProduct ( ) [virtual]

Definition at line 27 of file HepMCProduct.cc.

                           {

        delete evt_; evt_ = 0; isVtxGenApplied_ = false;
        isVtxBoostApplied_ = false;
        isPBoostApplied_ = false;
}
HepMCProduct::HepMCProduct ( HepMCProduct const &  orig)

Definition at line 153 of file HepMCProduct.cc.

References evt_, isPBoostApplied_, isVtxBoostApplied_, and isVtxGenApplied_.

                                                    :
  evt_(0) {
  
   if (other.evt_) evt_=new HepMC::GenEvent(*other.evt_);
   isVtxGenApplied_ = other.isVtxGenApplied_ ;
   isVtxBoostApplied_ = other.isVtxBoostApplied_;
   isPBoostApplied_ = other.isPBoostApplied_;
   //fTimeOffset = other.fTimeOffset;
}

Member Function Documentation

void HepMCProduct::addHepMCData ( HepMC::GenEvent *  evt)

Definition at line 35 of file HepMCProduct.cc.

                                                   {
  //  evt->print();
  // cout <<sizeof (evt)  <<"  " << sizeof ( HepMC::GenEvent)   << endl;
  evt_ = evt;
  
  // same story about vertex smearing - GenEvent won't know it...
  // in fact, would be better to implement CmsGenEvent...
  
}
void HepMCProduct::applyVtxGen ( HepMC::FourVector *  vtxShift) const

Definition at line 45 of file HepMCProduct.cc.

References lumiQTWidget::t, funct::true, x, detailsBasic3DVector::y, and z.

{
        //std::cout<< " applyVtxGen called " << isVtxGenApplied_ << endl;
        //fTimeOffset = 0;
        
   if ( isVtxGenApplied() ) return ;
      
   for ( HepMC::GenEvent::vertex_iterator vt=evt_->vertices_begin();
                                          vt!=evt_->vertices_end(); ++vt )
   {
            
      double x = (*vt)->position().x() + vtxShift->x() ;
      double y = (*vt)->position().y() + vtxShift->y() ;
      double z = (*vt)->position().z() + vtxShift->z() ;
      double t = (*vt)->position().t() + vtxShift->t() ;
      //std::cout << " vertex (x,y,z)= " << x <<" " << y << " " << z << std::endl;
      (*vt)->set_position( HepMC::FourVector(x,y,z,t) ) ;      
   }
      
   isVtxGenApplied_ = true ;
   
   return ;

} 
void HepMCProduct::boostToLab ( TMatrixD *  lorentz,
std::string  type 
) const

Definition at line 70 of file HepMCProduct.cc.

References gather_cfg::cout, p4, and funct::true.

                                                                       {

        //std::cout << "from boostToLab:" << std::endl;
        
  
  
        if ( lorentz == 0 ) {

                //std::cout << " lorentz = 0 " << std::endl;
                return;
        }

        //lorentz->Print();

  TMatrixD tmplorentz(*lorentz);
  //tmplorentz.Print();
  
        if ( type == "vertex") {

                if ( isVtxBoostApplied() ) {
                        //std::cout << " isVtxBoostApplied true " << std::endl;
                        return ;
                }
                
                for ( HepMC::GenEvent::vertex_iterator vt=evt_->vertices_begin();
                          vt!=evt_->vertices_end(); ++vt ) {

                        // change basis to lorentz boost definition: (t,x,z,y)
                        TMatrixD p4(4,1);
                        p4(0,0) = (*vt)->position().t();
                        p4(1,0) = (*vt)->position().x();
                        p4(2,0) = (*vt)->position().z();
                        p4(3,0) = (*vt)->position().y();

                        TMatrixD p4lab(4,1);
                        p4lab = tmplorentz * p4;
                        //std::cout << " vertex lorentz: " << p4lab(1,0) << " " << p4lab(3,0) << " " << p4lab(2,0) << std::endl;
                        (*vt)->set_position( HepMC::FourVector(p4lab(1,0),p4lab(3,0),p4lab(2,0), p4lab(0,0) ) ) ;      
                }
      
                isVtxBoostApplied_ = true ;
        }
        else if ( type == "momentum") {
                
                if ( isPBoostApplied() ) {
                        //std::cout << " isPBoostApplied true " << std::endl;
                        return ;
                }
                
                for ( HepMC::GenEvent::particle_iterator part=evt_->particles_begin();
                          part!=evt_->particles_end(); ++part ) {

                        // change basis to lorentz boost definition: (E,Px,Pz,Py)
                        TMatrixD p4(4,1);
                        p4(0,0) = (*part)->momentum().e();
                        p4(1,0) = (*part)->momentum().x();
                        p4(2,0) = (*part)->momentum().z();
                        p4(3,0) = (*part)->momentum().y();

                        TMatrixD p4lab(4,1);
                        p4lab = tmplorentz * p4;
                        //std::cout << " momentum lorentz: " << p4lab(1,0) << " " << p4lab(3,0) << " " << p4lab(2,0) << std::endl;
                        (*part)->set_momentum( HepMC::FourVector(p4lab(1,0),p4lab(3,0),p4lab(2,0),p4lab(0,0) ) ) ;      
                }
      
                isPBoostApplied_ = true ;
        }
        else {
                std::cout << " no type found for boostToLab(std::string), options are vertex or momentum" << std::endl;
        }
                
                 
        return ;
}
const HepMC::GenEvent* edm::HepMCProduct::GetEvent ( ) const [inline]
const HepMC::GenEvent & HepMCProduct::getHepMCData ( ) const

Definition at line 147 of file HepMCProduct.cc.

                                  {

  return  * evt_;
}
bool edm::HepMCProduct::isPBoostApplied ( ) const [inline]

Definition at line 39 of file HepMCProduct.h.

References isPBoostApplied_.

{ return isPBoostApplied_; }
bool edm::HepMCProduct::isVtxBoostApplied ( ) const [inline]

Definition at line 38 of file HepMCProduct.h.

References isVtxBoostApplied_.

{ return isVtxBoostApplied_; }
bool edm::HepMCProduct::isVtxGenApplied ( ) const [inline]

Definition at line 37 of file HepMCProduct.h.

References isVtxGenApplied_.

{ return isVtxGenApplied_; }
HepMCProduct & HepMCProduct::operator= ( HepMCProduct const &  other)

Definition at line 175 of file HepMCProduct.cc.

References swap(), and groupFilesInBlocks::temp.

                                                 {
  HepMCProduct temp(other);
  swap(temp);
  return *this;
} 
void HepMCProduct::swap ( HepMCProduct other)

Definition at line 165 of file HepMCProduct.cc.

References evt_, isPBoostApplied_, isVtxBoostApplied_, and isVtxGenApplied_.

Referenced by operator=().

                                      {
  std::swap(evt_, other.evt_);
  std::swap(isVtxGenApplied_, other.isVtxGenApplied_);
  std::swap(isVtxBoostApplied_, other.isVtxBoostApplied_);
  std::swap(isPBoostApplied_, other.isPBoostApplied_);
  //std::swap(fTimeOffset, other.fTimeOffset);
}

Member Data Documentation

HepMC::GenEvent* edm::HepMCProduct::evt_ [private]

Definition at line 46 of file HepMCProduct.h.

Referenced by GetEvent(), HepMCProduct(), and swap().

bool edm::HepMCProduct::isPBoostApplied_ [mutable, private]

Definition at line 50 of file HepMCProduct.h.

Referenced by HepMCProduct(), isPBoostApplied(), and swap().

bool edm::HepMCProduct::isVtxBoostApplied_ [mutable, private]

Definition at line 49 of file HepMCProduct.h.

Referenced by HepMCProduct(), isVtxBoostApplied(), and swap().

bool edm::HepMCProduct::isVtxGenApplied_ [mutable, private]

Definition at line 48 of file HepMCProduct.h.

Referenced by HepMCProduct(), isVtxGenApplied(), and swap().