CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Attributes
BeamSpotOnlineProducer Class Reference

#include <BeamSpotOnlineProducer.h>

Inheritance diagram for BeamSpotOnlineProducer:
edm::stream::EDProducer<> edm::stream::EDProducerBase edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Types

typedef std::vector
< edm::ParameterSet
Parameters
 
- Public Types inherited from edm::stream::EDProducer<>
typedef CacheContexts< T...> CacheTypes
 
typedef CacheTypes::GlobalCache GlobalCache
 
typedef AbilityChecker< T...> HasAbility
 
typedef
CacheTypes::LuminosityBlockCache 
LuminosityBlockCache
 
typedef
LuminosityBlockContextT
< LuminosityBlockCache,
RunCache, GlobalCache
LuminosityBlockContext
 
typedef
CacheTypes::LuminosityBlockSummaryCache 
LuminosityBlockSummaryCache
 
typedef CacheTypes::RunCache RunCache
 
typedef RunContextT< RunCache,
GlobalCache
RunContext
 
typedef CacheTypes::RunSummaryCache RunSummaryCache
 
- Public Types inherited from edm::stream::EDProducerBase
typedef EDProducerAdaptorBase ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 
- Public Types inherited from edm::EDConsumerBase
typedef ProductLabels Labels
 

Public Member Functions

 BeamSpotOnlineProducer (const edm::ParameterSet &iConf)
 constructor More...
 
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup) override
 produce a beam spot class More...
 
 ~BeamSpotOnlineProducer ()
 destructor More...
 
- Public Member Functions inherited from edm::stream::EDProducer<>
 EDProducer ()=default
 
- Public Member Functions inherited from edm::stream::EDProducerBase
 EDProducerBase ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducerBase ()
 
- Public Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
 ProducerBase ()
 
void registerProducts (ProducerBase *, ProductRegistry *, ModuleDescription const &)
 
std::function< void(BranchDescription
const &)> 
registrationCallback () const
 used by the fwk to register list of products More...
 
virtual ~ProducerBase ()
 
- Public Member Functions inherited from edm::EDConsumerBase
std::vector< ConsumesInfoconsumesInfo () const
 
 EDConsumerBase ()
 
ProductHolderIndexAndSkipBit indexFrom (EDGetToken, BranchType, TypeID const &) const
 
void itemsMayGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
void itemsToGet (BranchType, std::vector< ProductHolderIndexAndSkipBit > &) const
 
std::vector
< ProductHolderIndexAndSkipBit >
const & 
itemsToGetFromEvent () const
 
void labelsForToken (EDGetToken iToken, Labels &oLabels) const
 
void modulesDependentUpon (const std::string &iProcessName, std::vector< const char * > &oModuleLabels) const
 
void modulesWhoseProductsAreConsumed (std::vector< ModuleDescription const * > &modules, ProductRegistry const &preg, std::map< std::string, ModuleDescription const * > const &labelsToDesc, std::string const &processName) const
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

const bool changeFrame_
 
const edm::EDGetTokenT
< L1GlobalTriggerEvmReadoutRecord
l1GtEvmReadoutRecordToken_
 
const edm::EDGetTokenT
< BeamSpotOnlineCollection
scalerToken_
 
const unsigned int theBeamShoutMode
 
double theMaxR2
 
const double theMaxZ
 
const double theSetSigmaZ
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::stream::EDProducerBase
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::EDConsumerBase
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > consumes (edm::InputTag const &tag)
 
EDGetToken consumes (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken consumes (TypeToGet const &id, edm::InputTag const &tag)
 
ConsumesCollector consumesCollector ()
 Use a ConsumesCollector to gather consumes information from helper functions. More...
 
template<typename ProductType , BranchType B = InEvent>
void consumesMany ()
 
void consumesMany (const TypeToGet &id)
 
template<BranchType B>
void consumesMany (const TypeToGet &id)
 
template<typename ProductType , BranchType B = InEvent>
EDGetTokenT< ProductType > mayConsume (edm::InputTag const &tag)
 
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 
template<BranchType B>
EDGetToken mayConsume (const TypeToGet &id, edm::InputTag const &tag)
 

Detailed Description


class: BeamSpotOnlineProducer.h package: RecoVertex/BeamSpotProducer

author: Francisco Yumiceva, Fermilab (yumic.nosp@m.eva@.nosp@m.fnal..nosp@m.gov)


Definition at line 24 of file BeamSpotOnlineProducer.h.

Member Typedef Documentation

Definition at line 27 of file BeamSpotOnlineProducer.h.

Constructor & Destructor Documentation

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

constructor

Definition at line 17 of file BeamSpotOnlineProducer.cc.

References edm::ParameterSet::getParameter(), and theMaxR2.

18  : changeFrame_ ( iconf.getParameter<bool> ("changeToCMSCoordinates") )
19  , theMaxZ ( iconf.getParameter<double>("maxZ") )
20  , theSetSigmaZ ( iconf.getParameter<double>("setSigmaZ") )
21  , scalerToken_ ( consumes<BeamSpotOnlineCollection> ( iconf.getParameter<InputTag>("src") ) )
22  , l1GtEvmReadoutRecordToken_ ( consumes<L1GlobalTriggerEvmReadoutRecord>( iconf.getParameter<InputTag>("gtEvmLabel")) )
23  , theBeamShoutMode ( iconf.getUntrackedParameter<unsigned int> ("beamMode",11) )
24 {
25 
26  theMaxR2 = iconf.getParameter<double>("maxRadius");
28 
29  produces<reco::BeamSpot>();
30 
31 }
const edm::EDGetTokenT< L1GlobalTriggerEvmReadoutRecord > l1GtEvmReadoutRecordToken_
const edm::EDGetTokenT< BeamSpotOnlineCollection > scalerToken_
const unsigned int theBeamShoutMode
BeamSpotOnlineProducer::~BeamSpotOnlineProducer ( )

destructor

Definition at line 33 of file BeamSpotOnlineProducer.cc.

33 {}

Member Function Documentation

void BeamSpotOnlineProducer::produce ( edm::Event iEvent,
const edm::EventSetup iSetup 
)
overridevirtual

produce a beam spot class

Implements edm::stream::EDProducerBase.

Definition at line 36 of file BeamSpotOnlineProducer.cc.

References align::BeamSpot, changeFrame_, 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::getByToken(), BeamSpotObjects::GetCovariance(), BeamSpotObjects::Getdxdz(), BeamSpotObjects::Getdydz(), BeamSpotObjects::GetEmittanceX(), BeamSpotObjects::GetEmittanceY(), BeamSpotObjects::GetSigmaZ(), BeamSpotObjects::GetX(), BeamSpotObjects::GetY(), BeamSpotObjects::GetZ(), i, j, l1GtEvmReadoutRecordToken_, reco::BeamSpot::LHC, makeMuonMisalignmentScenario::matrix, edm::ESHandle< class >::product(), edm::Event::put(), diffTwoXMLs::r2, query::result, scalerToken_, reco::BeamSpot::setBeamWidthY(), reco::BeamSpot::setbetaStar(), reco::BeamSpot::setEmittanceX(), reco::BeamSpot::setEmittanceY(), reco::BeamSpot::setType(), BeamSpotOnline::sigma_z(), theBeamShoutMode, theMaxR2, theMaxZ, theSetSigmaZ, reco::BeamSpot::Tracker, BeamSpotOnline::width_x(), BeamSpotOnline::width_y(), BeamSpotOnline::x(), BeamSpotOnline::y(), and BeamSpotOnline::z().

37 {
38  //shout MODE only in stable beam
39  bool shoutMODE=false;
41  if (iEvent.getByToken(l1GtEvmReadoutRecordToken_, gtEvmReadoutRecord)){
42  if (gtEvmReadoutRecord->gtfeWord().beamMode() == theBeamShoutMode) shoutMODE=true;
43  }
44  else{
45  shoutMODE=true;
46  }
47 
48  // get scalar collection
50  iEvent.getByToken( scalerToken_, handleScaler);
51 
52  // beam spot scalar object
53  BeamSpotOnline spotOnline;
54 
55  // product is a reco::BeamSpot object
56  std::auto_ptr<reco::BeamSpot> result(new reco::BeamSpot);
57 
58  reco::BeamSpot aSpot;
59 
60  bool fallBackToDB=false;
61  if (handleScaler->size()!=0){
62  // get one element
63  spotOnline = * ( handleScaler->begin() );
64 
65  // in case we need to switch to LHC reference frame
66  // ignore for the moment rotations, and translations
67  double f = 1.;
68  if (changeFrame_) f = -1.;
69 
70  reco::BeamSpot::Point apoint( f* spotOnline.x(), spotOnline.y(), f* spotOnline.z() );
71 
73  matrix(0,0) = spotOnline.err_x()*spotOnline.err_x();
74  matrix(1,1) = spotOnline.err_y()*spotOnline.err_y();
75  matrix(2,2) = spotOnline.err_z()*spotOnline.err_z();
76  matrix(3,3) = spotOnline.err_sigma_z()*spotOnline.err_sigma_z();
77 
78  double sigmaZ = spotOnline.sigma_z();
79  if (theSetSigmaZ>0)
80  sigmaZ = theSetSigmaZ;
81 
82  aSpot = reco::BeamSpot( apoint,
83  sigmaZ,
84  spotOnline.dxdz(),
85  f* spotOnline.dydz(),
86  spotOnline.width_x(),
87  matrix);
88 
89  aSpot.setBeamWidthY( spotOnline.width_y() );
90  aSpot.setEmittanceX( 0. );
91  aSpot.setEmittanceY( 0. );
92  aSpot.setbetaStar( 0.) ;
93  aSpot.setType( reco::BeamSpot::LHC ); // flag value from scalars
94 
95  // check if we have a valid beam spot fit result from online DQM
96  if ( spotOnline.x() == 0 &&
97  spotOnline.y() == 0 &&
98  spotOnline.z() == 0 &&
99  spotOnline.width_x() == 0 &&
100  spotOnline.width_y() == 0 )
101  {
102  if (shoutMODE){
103  edm::LogWarning("BeamSpotFromDB")
104  << "Online Beam Spot producer falls back to DB value because the scaler values are zero ";
105  }
106  fallBackToDB=true;
107  }
108  double r2=spotOnline.x()*spotOnline.x() + spotOnline.y()*spotOnline.y();
109  if (fabs(spotOnline.z())>=theMaxZ || r2>=theMaxR2){
110  if (shoutMODE){
111  edm::LogError("BeamSpotFromDB")
112  << "Online Beam Spot producer falls back to DB value because the scaler values are too big to be true :"
113  <<spotOnline.x()<<" "<<spotOnline.y()<<" "<<spotOnline.z();
114  }
115  fallBackToDB=true;
116  }
117  }
118  else{
119  //empty online beamspot collection: FED data was empty
120  //the error should probably have been send at unpacker level
121  fallBackToDB=true;
122  }
123 
124  if (fallBackToDB){
125 
127  iSetup.get<BeamSpotObjectsRcd>().get(beamhandle);
128  const BeamSpotObjects *spotDB = beamhandle.product();
129 
130  // translate from BeamSpotObjects to reco::BeamSpot
131  reco::BeamSpot::Point apoint( spotDB->GetX(), spotDB->GetY(), spotDB->GetZ() );
132 
134  for ( int i=0; i<7; ++i ) {
135  for ( int j=0; j<7; ++j ) {
136  matrix(i,j) = spotDB->GetCovariance(i,j);
137  }
138  }
139 
140  // this assume beam width same in x and y
141  aSpot = reco::BeamSpot( apoint,
142  spotDB->GetSigmaZ(),
143  spotDB->Getdxdz(),
144  spotDB->Getdydz(),
145  spotDB->GetBeamWidthX(),
146  matrix );
147  aSpot.setBeamWidthY( spotDB->GetBeamWidthY() );
148  aSpot.setEmittanceX( spotDB->GetEmittanceX() );
149  aSpot.setEmittanceY( spotDB->GetEmittanceY() );
150  aSpot.setbetaStar( spotDB->GetBetaStar() );
152 
153  }
154 
155  *result = aSpot;
156 
157  iEvent.put(result);
158 
159 }
double Getdydz() const
get dydz slope, crossing angle in YZ
math::Error< dimension >::type CovarianceMatrix
Definition: BeamSpot.h:31
int i
Definition: DBlmapReader.cc:9
float err_y() const
float dxdz() const
double GetY() const
get Y beam position
void setbetaStar(double v)
Definition: BeamSpot.h:145
const edm::EDGetTokenT< L1GlobalTriggerEvmReadoutRecord > l1GtEvmReadoutRecordToken_
bool getByToken(EDGetToken token, Handle< PROD > &result) const
Definition: Event.h:464
float err_x() const
float dydz() const
float sigma_z() const
const edm::EDGetTokenT< BeamSpotOnlineCollection > scalerToken_
float y() const
float x() const
double GetSigmaZ() const
get sigma Z, RMS bunch length
double GetBeamWidthX() const
get average transverse beam width
math::XYZPoint Point
point in the space
Definition: BeamSpot.h:29
float z() const
float width_y() const
double GetBeamWidthY() const
get average transverse beam width
double GetEmittanceX() const
get emittance
void setType(BeamType type)
set beam type
Definition: BeamSpot.h:131
void setBeamWidthY(double v)
Definition: BeamSpot.h:109
void setEmittanceY(double v)
Definition: BeamSpot.h:144
OrphanHandle< PROD > put(std::auto_ptr< PROD > product)
Put a new product.
Definition: Event.h:120
tuple result
Definition: query.py:137
int j
Definition: DBlmapReader.cc:9
double GetZ() const
get Z beam position
double f[11][100]
const unsigned int theBeamShoutMode
double Getdxdz() const
get dxdz slope, crossing angle in XZ
float err_z() const
double GetX() const
get X beam position
const T & get() const
Definition: EventSetup.h:56
T const * product() const
Definition: ESHandle.h:86
double GetBetaStar() const
get beta star
double GetCovariance(int i, int j) const
get i,j element of the full covariance matrix 7x7
float width_x() const
double GetEmittanceY() const
get emittance
float err_sigma_z() const
void setEmittanceX(double v)
Definition: BeamSpot.h:143

Member Data Documentation

const bool BeamSpotOnlineProducer::changeFrame_
private

Definition at line 39 of file BeamSpotOnlineProducer.h.

Referenced by produce().

const edm::EDGetTokenT<L1GlobalTriggerEvmReadoutRecord> BeamSpotOnlineProducer::l1GtEvmReadoutRecordToken_
private

Definition at line 43 of file BeamSpotOnlineProducer.h.

Referenced by produce().

const edm::EDGetTokenT<BeamSpotOnlineCollection> BeamSpotOnlineProducer::scalerToken_
private

Definition at line 42 of file BeamSpotOnlineProducer.h.

Referenced by produce().

const unsigned int BeamSpotOnlineProducer::theBeamShoutMode
private

Definition at line 45 of file BeamSpotOnlineProducer.h.

Referenced by produce().

double BeamSpotOnlineProducer::theMaxR2
private

Definition at line 41 of file BeamSpotOnlineProducer.h.

Referenced by BeamSpotOnlineProducer(), and produce().

const double BeamSpotOnlineProducer::theMaxZ
private

Definition at line 40 of file BeamSpotOnlineProducer.h.

Referenced by produce().

const double BeamSpotOnlineProducer::theSetSigmaZ
private

Definition at line 40 of file BeamSpotOnlineProducer.h.

Referenced by produce().