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::EDProducer edm::ProducerBase edm::EDConsumerBase edm::ProductRegistryHelper

Public Types

typedef std::vector
< edm::ParameterSet
Parameters
 
- Public Types inherited from edm::EDProducer
typedef EDProducer ModuleType
 
- Public Types inherited from edm::ProducerBase
typedef
ProductRegistryHelper::TypeLabelList 
TypeLabelList
 

Public Member Functions

 BeamSpotOnlineProducer (const edm::ParameterSet &iConf)
 constructor More...
 
virtual void produce (edm::Event &iEvent, const edm::EventSetup &iSetup)
 produce a beam spot class More...
 
 ~BeamSpotOnlineProducer ()
 destructor More...
 
- Public Member Functions inherited from edm::EDProducer
 EDProducer ()
 
ModuleDescription const & moduleDescription () const
 
virtual ~EDProducer ()
 
- Public Member Functions inherited from edm::ProducerBase
 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
 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
 
bool registeredToConsume (ProductHolderIndex, bool, BranchType) const
 
bool registeredToConsumeMany (TypeID const &, BranchType) const
 
void updateLookup (BranchType iBranchType, ProductHolderIndexHelper const &)
 
virtual ~EDConsumerBase ()
 

Private Attributes

bool changeFrame_
 
edm::EDGetTokenT
< L1GlobalTriggerEvmReadoutRecord
l1GtEvmReadoutRecordToken_
 
edm::EDGetTokenT
< BeamSpotOnlineCollection
scalerToken_
 
double theMaxR2
 
double theMaxZ
 
double theSetSigmaZ
 

Additional Inherited Members

- Static Public Member Functions inherited from edm::EDProducer
static const std::string & baseType ()
 
static void fillDescriptions (ConfigurationDescriptions &descriptions)
 
static void prevalidate (ConfigurationDescriptions &descriptions)
 
- Protected Member Functions inherited from edm::ProducerBase
void callWhenNewProductsRegistered (std::function< void(BranchDescription const &)> const &func)
 
- 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().

18 {
19 
20  scalerToken_ = consumes<BeamSpotOnlineCollection>(
21  iconf.getParameter<InputTag>("src"));
22 
23  changeFrame_ = iconf.getParameter<bool>("changeToCMSCoordinates");
24 
25  theMaxR2 = iconf.getParameter<double>("maxRadius");
27  theMaxZ = iconf.getParameter<double>("maxZ");
28 
29  theSetSigmaZ = iconf.getParameter<double>("setSigmaZ");
30 
31  l1GtEvmReadoutRecordToken_ = consumes<L1GlobalTriggerEvmReadoutRecord>(
32  iconf.getParameter<InputTag>("gtEvmLabel"));
33 
34  produces<reco::BeamSpot>();
35 
36 }
edm::EDGetTokenT< L1GlobalTriggerEvmReadoutRecord > l1GtEvmReadoutRecordToken_
edm::EDGetTokenT< BeamSpotOnlineCollection > scalerToken_
BeamSpotOnlineProducer::~BeamSpotOnlineProducer ( )

destructor

Definition at line 38 of file BeamSpotOnlineProducer.cc.

38 {}

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::getByToken(), 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< class >::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().

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

bool BeamSpotOnlineProducer::changeFrame_
private

Definition at line 39 of file BeamSpotOnlineProducer.h.

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

Definition at line 42 of file BeamSpotOnlineProducer.h.

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

Definition at line 41 of file BeamSpotOnlineProducer.h.

double BeamSpotOnlineProducer::theMaxR2
private

Definition at line 40 of file BeamSpotOnlineProducer.h.

double BeamSpotOnlineProducer::theMaxZ
private

Definition at line 40 of file BeamSpotOnlineProducer.h.

double BeamSpotOnlineProducer::theSetSigmaZ
private

Definition at line 40 of file BeamSpotOnlineProducer.h.