Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

New BeamSpot Object and Records #29662

Merged
merged 9 commits into from
May 20, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions CondCore/BeamSpotPlugins/src/plugin.cc
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
#include "CondCore/ESSources/interface/registration_macros.h"
#include "CondFormats/DataRecord/interface/BeamSpotObjectsRcd.h"
#include "CondFormats/DataRecord/interface/SimBeamSpotObjectsRcd.h"
#include "CondFormats/DataRecord/interface/BeamSpotOnlineHLTObjectsRcd.h"
#include "CondFormats/DataRecord/interface/BeamSpotOnlineLegacyObjectsRcd.h"
#include "CondFormats/BeamSpotObjects/interface/BeamSpotObjects.h"
#include "CondFormats/BeamSpotObjects/interface/SimBeamSpotObjects.h"
#include "CondFormats/BeamSpotObjects/interface/BeamSpotOnlineObjects.h"

REGISTER_PLUGIN(BeamSpotObjectsRcd, BeamSpotObjects);
REGISTER_PLUGIN(SimBeamSpotObjectsRcd, SimBeamSpotObjects);
REGISTER_PLUGIN(BeamSpotOnlineHLTObjectsRcd, BeamSpotOnlineObjects);
REGISTER_PLUGIN(BeamSpotOnlineLegacyObjectsRcd, BeamSpotOnlineObjects);
1 change: 1 addition & 0 deletions CondCore/Utilities/plugins/Module_2XML.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ PAYLOAD_2XML_MODULE(pluginUtilities_payload2xml) {
PAYLOAD_2XML_CLASS(AlignmentSurfaceDeformations);
PAYLOAD_2XML_CLASS(Alignments);
PAYLOAD_2XML_CLASS(BeamSpotObjects);
PAYLOAD_2XML_CLASS(BeamSpotOnlineObjects);
PAYLOAD_2XML_CLASS(CSCBadChambers);
PAYLOAD_2XML_CLASS(CSCBadStrips);
PAYLOAD_2XML_CLASS(CSCBadWires);
Expand Down
1 change: 1 addition & 0 deletions CondCore/Utilities/src/CondDBFetch.cc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ namespace cond {
FETCH_PAYLOAD_CASE(Alignments)
FETCH_PAYLOAD_CASE(AlignPCLThresholds)
FETCH_PAYLOAD_CASE(BeamSpotObjects)
FETCH_PAYLOAD_CASE(BeamSpotOnlineObjects)
FETCH_PAYLOAD_CASE(CSCBadChambers)
FETCH_PAYLOAD_CASE(CSCBadStrips)
FETCH_PAYLOAD_CASE(CSCBadWires)
Expand Down
1 change: 1 addition & 0 deletions CondCore/Utilities/src/CondDBImport.cc
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ namespace cond {
IMPORT_PAYLOAD_CASE(Alignments)
IMPORT_PAYLOAD_CASE(AlignPCLThresholds)
IMPORT_PAYLOAD_CASE(BeamSpotObjects)
IMPORT_PAYLOAD_CASE(BeamSpotOnlineObjects)
IMPORT_PAYLOAD_CASE(CSCBadChambers)
IMPORT_PAYLOAD_CASE(CSCBadStrips)
IMPORT_PAYLOAD_CASE(CSCBadWires)
Expand Down
1 change: 1 addition & 0 deletions CondCore/Utilities/src/CondFormats.h
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
#include "CondFormats/Alignment/interface/AlignmentSurfaceDeformations.h"
#include "CondFormats/Alignment/interface/Alignments.h"
#include "CondFormats/BeamSpotObjects/interface/BeamSpotObjects.h"
#include "CondFormats/BeamSpotObjects/interface/BeamSpotOnlineObjects.h"
#include "CondFormats/CastorObjects/interface/CastorElectronicsMap.h"
#include "CondFormats/CastorObjects/interface/CastorSaturationCorrs.h"
#include "CondFormats/HIObjects/interface/CentralityTable.h"
Expand Down
2 changes: 1 addition & 1 deletion CondFormats/BeamSpotObjects/interface/BeamSpotObjects.h
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ class BeamSpotObjects {
/// print beam spot parameters
void print(std::stringstream& ss) const;

private:
protected:
double position_[3];
double sigmaZ_;
double beamwidthX_;
Expand Down
97 changes: 97 additions & 0 deletions CondFormats/BeamSpotObjects/interface/BeamSpotOnlineObjects.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
#ifndef BEAMSPOTONLINEOBJECTS_H
#define BEAMSPOTONLINEOBJECTS_H
/** \class BeamSpotOnlineObjects
*
* Class inheriting from BeamSpotObjects.
* New members of the class:
* - lastAnalyzedLumi : last lumisection analyzed
* - lastAnalyzedRun : run of the last analyzed lumisection
* - lastAnalyzedFill : fill of the last analyzed lumisection
*
* \author Francisco Brivio, Milano-Bicocca (francesco.brivio@cern.ch)
*
*/

#include "CondFormats/Serialization/interface/Serializable.h"
#include "CondFormats/Common/interface/Time.h"
#include "CondFormats/BeamSpotObjects/interface/BeamSpotObjects.h"

#include <cmath>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>

class BeamSpotOnlineObjects : public BeamSpotObjects {
public:
/// default constructor
BeamSpotOnlineObjects() {
lastAnalyzedLumi_ = 0;
lastAnalyzedRun_ = 0;
lastAnalyzedFill_ = 0;
intParams_.resize(ISIZE, std::vector<int>(1, 0));
timeParams_.resize(TSIZE, std::vector<unsigned long long>(1, 0ULL));
}

~BeamSpotOnlineObjects() override {}

/// Enums
enum IntParamIndex { NUM_TRACKS = 0, NUM_PVS = 1, ISIZE = 2 };
enum TimeParamIndex { CREATE_TIME = 0, TSIZE = 1 };

/// Setters Methods
// set lastAnalyzedLumi_, last analyzed lumisection
void SetLastAnalyzedLumi(int val) { lastAnalyzedLumi_ = val; }

// set lastAnalyzedRun_, run of the last analyzed lumisection
void SetLastAnalyzedRun(int val) { lastAnalyzedRun_ = val; }

// set lastAnalyzedFill_, fill of the last analyzed lumisection
void SetLastAnalyzedFill(int val) { lastAnalyzedFill_ = val; }

// set number of tracks used in the BeamSpot fit
void SetNumTracks(int val);

// set number of Primary Vertices used in the BeamSpot fit
void SetNumPVs(int val);

// set creation time of the payload
void SetCreationTime(cond::Time_t val);

/// Getters Methods
// get lastAnalyzedLumi_, last analyzed lumisection
int GetLastAnalyzedLumi() const { return lastAnalyzedLumi_; }

// get lastAnalyzedRun_, run of the last analyzed lumisection
int GetLastAnalyzedRun() const { return lastAnalyzedRun_; }

// get lastAnalyzedFill_, fill of the last analyzed lumisection
int GetLastAnalyzedFill() const { return lastAnalyzedFill_; }

// get number of tracks used in the BeamSpot fit
int GetNumTracks() const;

// get number of Primary Vertices used in the BeamSpot fit
int GetNumPVs() const;

// get creation time of the payload
cond::Time_t GetCreationTime() const;

/// Print BeamSpotOnline parameters
void print(std::stringstream& ss) const;

private:
int lastAnalyzedLumi_;
int lastAnalyzedRun_;
int lastAnalyzedFill_;
std::vector<std::vector<int> > intParams_;
std::vector<std::vector<float> > floatParams_;
std::vector<std::vector<std::string> > stringParams_;
std::vector<std::vector<unsigned long long> > timeParams_;

COND_SERIALIZABLE;
};

std::ostream& operator<<(std::ostream&, BeamSpotOnlineObjects beam);

#endif
96 changes: 96 additions & 0 deletions CondFormats/BeamSpotObjects/src/BeamSpotOnlineObjects.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
#include "CondFormats/BeamSpotObjects/interface/BeamSpotOnlineObjects.h"

#include <iostream>

namespace BeamSpotOnlineObjectsImpl {
template <typename T>
const T& getParams(const std::vector<T>& params, size_t index) {
if (index >= params.size())
throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range.");
return params[index];
}

template <typename T>
T& accessParams(std::vector<T>& params, size_t index) {
if (index >= params.size())
throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range.");
return params[index];
}

template <typename T>
const T& getOneParam(const std::vector<std::vector<T> >& params, size_t index) {
if (index >= params.size())
throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range.");
const std::vector<T>& inner = params[index];
if (inner.empty())
throw std::out_of_range("Parameter with index " + std::to_string(index) + " type=" + typeid(T).name() +
" has no value stored.");
return inner[0];
}

template <typename T>
void setOneParam(std::vector<std::vector<T> >& params, size_t index, const T& value) {
if (index >= params.size())
throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range.");
params[index] = std::vector<T>(1, value);
}

template <typename T>
void setParams(std::vector<T>& params, size_t index, const T& value) {
if (index >= params.size())
throw std::out_of_range("Parameter with index " + std::to_string(index) + " is out of range.");
params[index] = value;
}

} //namespace BeamSpotOnlineObjectsImpl

// getters
int BeamSpotOnlineObjects::GetNumTracks() const {
return BeamSpotOnlineObjectsImpl::getOneParam(intParams_, NUM_TRACKS);
}

int BeamSpotOnlineObjects::GetNumPVs() const { return BeamSpotOnlineObjectsImpl::getOneParam(intParams_, NUM_PVS); }

cond::Time_t BeamSpotOnlineObjects::GetCreationTime() const {
return BeamSpotOnlineObjectsImpl::getOneParam(timeParams_, CREATE_TIME);
}

// setters
void BeamSpotOnlineObjects::SetNumTracks(int nTracks) {
BeamSpotOnlineObjectsImpl::setOneParam(intParams_, NUM_TRACKS, nTracks);
}

void BeamSpotOnlineObjects::SetNumPVs(int nPVs) { BeamSpotOnlineObjectsImpl::setOneParam(intParams_, NUM_PVS, nPVs); }

void BeamSpotOnlineObjects::SetCreationTime(cond::Time_t createTime) {
BeamSpotOnlineObjectsImpl::setOneParam(timeParams_, CREATE_TIME, createTime);
}

// printers
void BeamSpotOnlineObjects::print(std::stringstream& ss) const {
ss << "-----------------------------------------------------\n"
<< " BeamSpotOnline Data\n\n"
<< " Beam type = " << GetBeamType() << "\n"
<< " X0 = " << GetX() << " +/- " << GetXError() << " [cm]\n"
<< " Y0 = " << GetY() << " +/- " << GetYError() << " [cm]\n"
<< " Z0 = " << GetZ() << " +/- " << GetZError() << " [cm]\n"
<< " Sigma Z0 = " << GetSigmaZ() << " +/- " << GetSigmaZError() << " [cm]\n"
<< " dxdz = " << Getdxdz() << " +/- " << GetdxdzError() << " [radians]\n"
<< " dydz = " << Getdydz() << " +/- " << GetdydzError() << " [radians]\n"
<< " Beam Width X = " << GetBeamWidthX() << " +/- " << GetBeamWidthXError() << " [cm]\n"
<< " Beam Width Y = " << GetBeamWidthY() << " +/- " << GetBeamWidthYError() << " [cm]\n"
<< " Emittance X = " << GetEmittanceX() << " [cm]\n"
<< " Emittance Y = " << GetEmittanceY() << " [cm]\n"
<< " Beta star = " << GetBetaStar() << " [cm]\n"
<< " Last Lumi = " << GetLastAnalyzedLumi() << "\n"
<< " Last Run = " << GetLastAnalyzedRun() << "\n"
<< " Last Fill = " << GetLastAnalyzedFill() << "\n"
<< "-----------------------------------------------------\n\n";
}

std::ostream& operator<<(std::ostream& os, BeamSpotOnlineObjects beam) {
std::stringstream ss;
beam.print(ss);
os << ss.str();
return os;
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
#include "CondFormats/BeamSpotObjects/interface/BeamSpotOnlineObjects.h"
#include "FWCore/Utilities/interface/typelookup.h"
TYPELOOKUP_DATA_REG(BeamSpotOnlineObjects);
1 change: 1 addition & 0 deletions CondFormats/BeamSpotObjects/src/classes_def.xml
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
<lcgdict>
<class name="BeamSpotObjects"/>
<class name="SimBeamSpotObjects"/>
<class name="BeamSpotOnlineObjects"/>
</lcgdict>
1 change: 1 addition & 0 deletions CondFormats/BeamSpotObjects/src/headers.h
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
#include "CondFormats/BeamSpotObjects/interface/BeamSpotObjects.h"
#include "CondFormats/BeamSpotObjects/interface/SimBeamSpotObjects.h"
#include "CondFormats/BeamSpotObjects/interface/BeamSpotOnlineObjects.h"
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
int main() {
testSerialization<BeamSpotObjects>();
testSerialization<SimBeamSpotObjects>();
testSerialization<BeamSpotOnlineObjects>();

return 0;
}
27 changes: 27 additions & 0 deletions CondFormats/DataRecord/interface/BeamSpotOnlineHLTObjectsRcd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef DataRecord_BeamSpotOnlineHLTObjectsRcd_h
#define DataRecord_BeamSpotOnlineHLTObjectsRcd_h
// -*- C++ -*-
//
// Package: DataRecord
// Class : BeamSpotOnlineHLTObjectsRcd
//
/**\class BeamSpotOnlineHLTObjectsRcd BeamSpotOnlineHLTObjectsRcd.h CondFormats/DataRecord/interface/BeamSpotOnlineHLTObjectsRcd.h

Description: <one line class summary>

Usage:
<usage>

*/
//
// Author:
// Created: Tue Mar 6 19:34:33 CST 2007
// $Id$
//

#include "FWCore/Framework/interface/EventSetupRecordImplementation.h"

class BeamSpotOnlineHLTObjectsRcd
: public edm::eventsetup::EventSetupRecordImplementation<BeamSpotOnlineHLTObjectsRcd> {};

#endif
27 changes: 27 additions & 0 deletions CondFormats/DataRecord/interface/BeamSpotOnlineLegacyObjectsRcd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
#ifndef DataRecord_BeamSpotOnlineLegacyObjectsRcd_h
#define DataRecord_BeamSpotOnlineLegacyObjectsRcd_h
// -*- C++ -*-
//
// Package: DataRecord
// Class : BeamSpotOnlineLegacyObjectsRcd
//
/**\class BeamSpotOnlineLegacyObjectsRcd BeamSpotOnlineLegacyObjectsRcd.h CondFormats/DataRecord/interface/BeamSpotOnlineLegacyObjectsRcd.h

Description: <one line class summary>

Usage:
<usage>

*/
//
// Author:
// Created: Tue Mar 6 19:34:33 CST 2007
// $Id$
//

#include "FWCore/Framework/interface/EventSetupRecordImplementation.h"

class BeamSpotOnlineLegacyObjectsRcd
: public edm::eventsetup::EventSetupRecordImplementation<BeamSpotOnlineLegacyObjectsRcd> {};

#endif
31 changes: 31 additions & 0 deletions CondFormats/DataRecord/interface/BeamSpotTransientObjectsRcd.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
#ifndef DataRecord_BeamSpotTransientObjectsRcd_h
#define DataRecord_BeamSpotTransientObjectsRcd_h
// -*- C++ -*-
//
// Package: DataRecord
// Class : BeamSpotTransientObjectsRcd
//
/**\class BeamSpotTransientObjectsRcd BeamSpotTransientObjectsRcd.h CondFormats/DataRecord/interface/BeamSpotTransientObjectsRcd.h

Description: <one line class summary>

Usage:
<usage>

*/
//
// Author:
// Created: Tue Mar 6 19:34:33 CST 2007
// $Id$
//
#include "boost/mpl/vector.hpp"
#include "FWCore/Framework/interface/DependentRecordImplementation.h"
#include "CondFormats/DataRecord/interface/BeamSpotOnlineHLTObjectsRcd.h"
#include "CondFormats/DataRecord/interface/BeamSpotOnlineLegacyObjectsRcd.h"

class BeamSpotTransientObjectsRcd
: public edm::eventsetup::DependentRecordImplementation<
BeamSpotTransientObjectsRcd,
boost::mpl::vector<BeamSpotOnlineHLTObjectsRcd, BeamSpotOnlineLegacyObjectsRcd> > {};

#endif
16 changes: 16 additions & 0 deletions CondFormats/DataRecord/src/BeamSpotOnlineHLTObjectsRcd.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
// -*- C++ -*-
//
// Package: DataRecord
// Class : BeamSpotOnlineHLTObjectsRcd
//
// Implementation:
// <Notes on implementation>
//
// Author:
// Created: Tue Mar 6 19:34:33 CST 2007
// $Id$

#include "CondFormats/DataRecord/interface/BeamSpotOnlineHLTObjectsRcd.h"
#include "FWCore/Framework/interface/eventsetuprecord_registration_macro.h"

EVENTSETUP_RECORD_REG(BeamSpotOnlineHLTObjectsRcd);
Loading