CMS 3D CMS Logo

Public Types | Public Member Functions | Private Attributes

BeamSpotOnlineProducer Class Reference

#include <BeamSpotOnlineProducer.h>

Inheritance diagram for BeamSpotOnlineProducer:
edm::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

List of all members.

Public Types

typedef std::vector
< edm::ParameterSet
Parameters

Public Member Functions

 BeamSpotOnlineProducer (const edm::ParameterSet &iConf)
 constructor
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)
 produce a beam spot class
 ~BeamSpotOnlineProducer ()
 destructor

Private Attributes

bool changeFrame_
edm::InputTag scalertag_
edm::InputTag thel1GtEvmReadoutRecordTag
double theMaxR2
double theMaxZ
double theSetSigmaZ

Detailed Description

_________________________________________________________________ class: BeamSpotOnlineProducer.h package: RecoVertex/BeamSpotProducer

author: Francisco Yumiceva, Fermilab (yumiceva@fnal.gov)

version

Id:
BeamSpotOnlineProducer.h,v 1.7 2010/09/10 12:13:16 vlimant Exp

________________________________________________________________

Definition at line 22 of file BeamSpotOnlineProducer.h.


Member Typedef Documentation

Definition at line 25 of file BeamSpotOnlineProducer.h.


Constructor & Destructor Documentation

BeamSpotOnlineProducer::BeamSpotOnlineProducer ( const edm::ParameterSet iConf) [explicit]

constructor

Definition at line 19 of file BeamSpotOnlineProducer.cc.

References edm::ParameterSet::getParameter().

{
  
  scalertag_ = iconf.getParameter<InputTag>("src");

  changeFrame_ = iconf.getParameter<bool>("changeToCMSCoordinates");

  theMaxR2 = iconf.getParameter<double>("maxRadius");
  theMaxR2*=theMaxR2;
  theMaxZ = iconf.getParameter<double>("maxZ");

  theSetSigmaZ = iconf.getParameter<double>("setSigmaZ");
  
  thel1GtEvmReadoutRecordTag = iconf.getParameter<InputTag>("gtEvmLabel");
  
  produces<reco::BeamSpot>();

} 
BeamSpotOnlineProducer::~BeamSpotOnlineProducer ( )

destructor

Definition at line 38 of file BeamSpotOnlineProducer.cc.

{}

Member Function Documentation

void BeamSpotOnlineProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
) [virtual]

produce a beam spot class

Implements edm::EDProducer.

Definition at line 41 of file BeamSpotOnlineProducer.cc.

References align::BeamSpot, BeamSpotOnline::dxdz(), BeamSpotOnline::dydz(), BeamSpotOnline::err_sigma_z(), BeamSpotOnline::err_x(), BeamSpotOnline::err_y(), BeamSpotOnline::err_z(), f, edm::EventSetup::get(), BeamSpotObjects::GetBeamWidthX(), BeamSpotObjects::GetBeamWidthY(), BeamSpotObjects::GetBetaStar(), edm::Event::getByLabel(), BeamSpotObjects::GetCovariance(), BeamSpotObjects::Getdxdz(), BeamSpotObjects::Getdydz(), BeamSpotObjects::GetEmittanceX(), BeamSpotObjects::GetEmittanceY(), BeamSpotObjects::GetSigmaZ(), BeamSpotObjects::GetX(), BeamSpotObjects::GetY(), BeamSpotObjects::GetZ(), i, j, reco::BeamSpot::LHC, makeMuonMisalignmentScenario::matrix, edm::ESHandle< T >::product(), edm::Event::put(), diffTwoXMLs::r2, query::result, reco::BeamSpot::setBeamWidthY(), reco::BeamSpot::setbetaStar(), reco::BeamSpot::setEmittanceX(), reco::BeamSpot::setEmittanceY(), reco::BeamSpot::setType(), BeamSpotOnline::sigma_z(), reco::BeamSpot::Tracker, BeamSpotOnline::width_x(), BeamSpotOnline::width_y(), BeamSpotOnline::x(), BeamSpotOnline::y(), and BeamSpotOnline::z().

{
  //shout MODE only in stable beam
  bool shoutMODE=false;
  edm::Handle<L1GlobalTriggerEvmReadoutRecord> gtEvmReadoutRecord;
  if (iEvent.getByLabel(thel1GtEvmReadoutRecordTag, gtEvmReadoutRecord)){
    const boost::uint16_t beamModeValue = (gtEvmReadoutRecord->gtfeWord()).beamMode();
    if (beamModeValue == 11) shoutMODE=true;
  }
  else{
    shoutMODE=true;
  }

  // get scalar collection
  Handle<BeamSpotOnlineCollection> handleScaler;
  iEvent.getByLabel( scalertag_, handleScaler);

  // beam spot scalar object
  BeamSpotOnline spotOnline;

  // product is a reco::BeamSpot object
  std::auto_ptr<reco::BeamSpot> result(new reco::BeamSpot);
  
  reco::BeamSpot aSpot;

  bool fallBackToDB=false;
  if (handleScaler->size()!=0){
    // get one element
    spotOnline = * ( handleScaler->begin() );
    
    // in case we need to switch to LHC reference frame
    // ignore for the moment rotations, and translations
    double f = 1.;
    if (changeFrame_) f = -1.;
    
    reco::BeamSpot::Point apoint( f* spotOnline.x(), spotOnline.y(), f* spotOnline.z() );
    
    reco::BeamSpot::CovarianceMatrix matrix;
    matrix(0,0) = spotOnline.err_x()*spotOnline.err_x();
    matrix(1,1) = spotOnline.err_y()*spotOnline.err_y();
    matrix(2,2) = spotOnline.err_z()*spotOnline.err_z();
    matrix(3,3) = spotOnline.err_sigma_z()*spotOnline.err_sigma_z();
    
    double sigmaZ = spotOnline.sigma_z();
    if (theSetSigmaZ>0)
      sigmaZ = theSetSigmaZ;
    
    aSpot = reco::BeamSpot( apoint,
                            sigmaZ,
                          spotOnline.dxdz(),
                            f* spotOnline.dydz(),
                            spotOnline.width_x(),
                            matrix);
    
    aSpot.setBeamWidthY( spotOnline.width_y() );
    aSpot.setEmittanceX( 0. );
    aSpot.setEmittanceY( 0. );
    aSpot.setbetaStar( 0.) ;
    aSpot.setType( reco::BeamSpot::LHC ); // flag value from scalars
    
    // check if we have a valid beam spot fit result from online DQM
    if ( spotOnline.x() == 0 &&
         spotOnline.y() == 0 &&
         spotOnline.z() == 0 &&
         spotOnline.width_x() == 0 &&
         spotOnline.width_y() == 0 ) 
      {
        if (shoutMODE){
          edm::LogWarning("BeamSpotFromDB") 
          << "Online Beam Spot producer falls back to DB value because the scaler values are zero ";
        }
        fallBackToDB=true;
      }
    double r2=spotOnline.x()*spotOnline.x() + spotOnline.y()*spotOnline.y();
    if (fabs(spotOnline.z())>=theMaxZ || r2>=theMaxR2){
      if (shoutMODE){
        edm::LogError("BeamSpotFromDB") 
          << "Online Beam Spot producer falls back to DB value because the scaler values are too big to be true :"
          <<spotOnline.x()<<" "<<spotOnline.y()<<" "<<spotOnline.z();
      }
      fallBackToDB=true;
    }
  }
  else{
    //empty online beamspot collection: FED data was empty
    //the error should probably have been send at unpacker level
    fallBackToDB=true;
  }
      
  if (fallBackToDB){

    edm::ESHandle< BeamSpotObjects > beamhandle;
    iSetup.get<BeamSpotObjectsRcd>().get(beamhandle);
    const BeamSpotObjects *spotDB = beamhandle.product();

    // translate from BeamSpotObjects to reco::BeamSpot
    reco::BeamSpot::Point apoint( spotDB->GetX(), spotDB->GetY(), spotDB->GetZ() );
  
    reco::BeamSpot::CovarianceMatrix matrix;
    for ( int i=0; i<7; ++i ) {
      for ( int j=0; j<7; ++j ) {
        matrix(i,j) = spotDB->GetCovariance(i,j);
      }
    }
  
    // this assume beam width same in x and y
    aSpot = reco::BeamSpot( apoint,
                            spotDB->GetSigmaZ(),
                            spotDB->Getdxdz(),
                            spotDB->Getdydz(),
                            spotDB->GetBeamWidthX(),
                            matrix );
    aSpot.setBeamWidthY( spotDB->GetBeamWidthY() );
    aSpot.setEmittanceX( spotDB->GetEmittanceX() );
    aSpot.setEmittanceY( spotDB->GetEmittanceY() );
    aSpot.setbetaStar( spotDB->GetBetaStar() );
    aSpot.setType( reco::BeamSpot::Tracker );

  }
  
  *result = aSpot;

  iEvent.put(result);

}

Member Data Documentation

Definition at line 38 of file BeamSpotOnlineProducer.h.

Definition at line 37 of file BeamSpotOnlineProducer.h.

Definition at line 40 of file BeamSpotOnlineProducer.h.

Definition at line 39 of file BeamSpotOnlineProducer.h.

Definition at line 39 of file BeamSpotOnlineProducer.h.

Definition at line 39 of file BeamSpotOnlineProducer.h.