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

add LumiCorrections records and definitions; adding LumiInfo.h members/methods #20651

Merged
merged 9 commits into from Oct 17, 2017
5 changes: 3 additions & 2 deletions CondCore/LuminosityPlugins/src/plugin.cc
@@ -1,9 +1,10 @@
#include "CondCore/ESSources/interface/registration_macros.h"
#include "CondFormats/Luminosity/interface/LumiSectionData.h"
#include "CondFormats/DataRecord/interface/LumiSectionDataRcd.h"
#include "CondFormats/Luminosity/interface/LumiCorrections.h"
#include "CondFormats/DataRecord/interface/LumiCorrectionsRcd.h"


REGISTER_PLUGIN(LumiSectionDataRcd, lumi::LumiSectionData);


REGISTER_PLUGIN(LumiCorrectionsRcd, LumiCorrections);

25 changes: 25 additions & 0 deletions CondFormats/DataRecord/interface/LumiCorrectionsRcd.h
@@ -0,0 +1,25 @@
#ifndef DataRecord_LumiCorrectionsRcd_h
#define DataRecord_LumiCorrectionsRcd_h
// -*- C++ -*-
//
// Package: CondFormats/DataRecord
// Class : LumiCorrectionsRcd
//
/**\class LumiCorrectionsRcd LumiCorrectionsRcd.h CondFormats/DataRecord/interface/LumiCorrectionsRcd.h

Description: [one line class summary]

Usage:
<usage>

*/
//
// Author: Sam Higginbotham
// Created: Fri, 21 Jul 2017 18:15:12 GMT
//

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

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

#endif
15 changes: 15 additions & 0 deletions CondFormats/DataRecord/src/LumiCorrectionsRcd.cc
@@ -0,0 +1,15 @@
// -*- C++ -*-
//
// Package: CondFormats/DataRecord
// Class : LumiCorrectionsRcd
//
// Implementation:
// [Notes on implementation]
//
// Author: Sam Higginbotham
// Created: Fri, 21 Jul 2017 18:15:12 GMT

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

EVENTSETUP_RECORD_REG(LumiCorrectionsRcd);
44 changes: 44 additions & 0 deletions CondFormats/Luminosity/interface/LumiCorrections.h
@@ -0,0 +1,44 @@
#ifndef CondFormats_Luminosity_LumiCorrections_h
#define CondFormats_Luminosity_LumiCorrections_h

/**
* \class LumiCorrections
*
* \author Sam Higginbotham, Chris Palmer
*
* This class should contain scale factors for correcting
* out-of-time pile-up per bunch crossing on rates intended
* for luminosity estimates. There is the option of saving
* the total scale factor on the total luminosity in
* m_overallCorrection as well.
*/


#include <sstream>
#include <cstring>
#include <vector>
#include <boost/serialization/vector.hpp>
#include "CondFormats/Serialization/interface/Serializable.h"

class LumiCorrections {
public:
void setOverallCorrection(float overallCorrection){m_overallCorrection=overallCorrection;}
void setType1Fraction(float type1frac){m_type1Fraction=type1frac;}
void setType1Residual(float type1res){m_type1Residual=type1res;}
void setType2Residual(float type2res){m_type2Residual=type2res;}
void setCorrectionsBX(std::vector<float>& correctBX){m_correctionsBX.assign(correctBX.begin(),correctBX.end());}
float getOverallCorrection(){return m_overallCorrection;}
float getCorrectionAtBX(float bx){return m_correctionsBX[bx];}
float getType1Fraction(){return m_type1Fraction;}
float getType1Residual(){return m_type1Residual;}
float getType2Residual(){return m_type2Residual;}
const std::vector<float>& getCorrectionsBX() const{return m_correctionsBX;}
private:
float m_overallCorrection;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

from the class its hard to know if one should include the overall correction together with the bx by bx correction. Please add a bit of documentation on the various meanings. It also might be useful to have an accessor to the ith bx and its length.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I added some comments at the top. There are use cases for only using the total correction with some luminometers and so we need it available here.

float m_type1Fraction;
float m_type1Residual;
float m_type2Residual;
std::vector<float> m_correctionsBX;
COND_SERIALIZABLE;
};
#endif
6 changes: 6 additions & 0 deletions CondFormats/Luminosity/src/T_EventSetup_LumiCorrections.cc
@@ -0,0 +1,6 @@
// T_EventSetup_LumiCorrections.cc

#include "CondFormats/Luminosity/interface/LumiCorrections.h"
#include "FWCore/Utilities/interface/typelookup.h"

TYPELOOKUP_DATA_REG(LumiCorrections);
1 change: 1 addition & 0 deletions CondFormats/Luminosity/src/classes_def.xml
Expand Up @@ -6,4 +6,5 @@
<class name="std::vector< lumi::HLTInfo >"/>
<class name="std::vector< lumi::TriggerInfo >"/>
<class name="std::vector< lumi::BunchCrossingInfo >"/>
<class name="LumiCorrections" class_version="0"/>
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

i don't follow the need for (or lack of) class_versions here. @ggovi - is this needed?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't know about this one. @samhiggie made this line. Where did you get it from?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hi, I copied the instructions almost exactly from this twiki example to register an object to the DB. https://twiki.cern.ch/twiki/bin/view/CMSPublic/SWGuideCondObjectsTutorial#The_object_class
They have this format in the classes_def.xml... maybe it's not needed and this is an old format. I don't really know.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

indeed, I don't know either - i asked @ggovi to provide instructions...

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

By the way: I also noticed it, but I did not comment because I realized that all classes in the CondFormats are have class_version="0", see
https://cmssdt.cern.ch/lxr/search?%21v=CMSSW_9_4_X_2017-10-15-2300&_filestring=CondFormats&_string=class_version&_casesensitive=1

Good to try to understand if it does correspond to a kind of (justified) rule.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It looks like a lot of people were following the twiki. :) IMO this may be superfluous but shouldn't harm anything. Merging this PR shouldn't be held up by understanding this issue which is really unrelated (and ignored up to now in other places). It just looks like the twiki should be updated by someone ( @ggovi ?).

I don't mind changing this, but the approval of this PR shouldn't linger for days because of this.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

the class version is no longer needed for the persistency since ORA disappeared ( cmssw_7_2_X )

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

thanks @ggovi - maybe your documentation and existing class_versions can get cleaned up in a followup PR.

</lcgdict>
1 change: 1 addition & 0 deletions CondFormats/Luminosity/src/headers.h
@@ -1 +1,2 @@
#include "CondFormats/Luminosity/interface/LumiSectionData.h"
#include "CondFormats/Luminosity/interface/LumiCorrections.h"
3 changes: 3 additions & 0 deletions CondFormats/Luminosity/test/BuildFile.xml
@@ -1,3 +1,6 @@
<bin file="testSerializationLuminosity.cpp">
<use name="CondFormats/Luminosity"/>
</bin>
<bin file="testSerializationLumiCorrections.cpp">
<use name="CondFormats/Luminosity"/>
</bin>
@@ -0,0 +1,7 @@
#include "CondFormats/Serialization/interface/Test.h"
#include "CondFormats/Luminosity/interface/LumiCorrections.h"

int main()
{
testSerialization<LumiCorrections>();
}
192 changes: 146 additions & 46 deletions DataFormats/Luminosity/interface/LumiInfo.h
@@ -1,8 +1,8 @@
#ifndef DataFormats_Luminosity_LumiInfo_h
#define DataFormats_Luminosity_LumiInfo_h

/** \class LumiInfo
*
/**
* \class LumiInfo
*
* LumiInfo has been created by merging the content of
* the old LumiSummary and LumiDetails classes to streamline
Expand All @@ -15,70 +15,170 @@
* Zhen Xie
* Paul Lujan
* \version 1st Version June 7 2007, merged September 10 2014
* \version October 2017 by Chris Palmer and Sam Higginbotham for PCC projects
*
*
************************************************************/
*/

#include <vector>
#include <iosfwd>
#include <string>
#include "DataFormats/Luminosity/interface/LumiConstants.h"

class LumiInfo {
public:
/// default constructor
LumiInfo():
deadtimeFraction_(0)
{
instLumiByBX_.assign(LumiConstants::numBX, 0.0);
}
public:
/**
* default constructor
*/
LumiInfo():
deadtimeFraction_(0)
{
instLumiByBX_.assign(LumiConstants::numBX, 0.0);
instLumiStatErrByBX_.assign(LumiConstants::numBX, 0.0);
totalInstLuminosity_=0;
totalInstLumiStatErr_=0;
}

/// constructor with fill
LumiInfo(float deadtimeFraction,
const std::vector<float>& instLumiByBX):
deadtimeFraction_(deadtimeFraction)
{
instLumiByBX_.assign(instLumiByBX.begin(), instLumiByBX.end());
}

/// destructor
~LumiInfo(){}
/**
* constructor with fill; if total algo is the same as summing
*/
LumiInfo(float deadtimeFraction, const std::vector<float>& instLumiByBX):
deadtimeFraction_(deadtimeFraction),
instLumiByBX_(instLumiByBX)
{
instLumiStatErrByBX_.assign(LumiConstants::numBX, 0.0);
setTotalInstToBXSum() ;
totalInstLumiStatErr_=0;
}

// Instantaneous luminosity (in Hz/ub)
float instLuminosity() const;
/**
* constructor with fill; if total algo DIFFERS from summing
*/
LumiInfo(float deadtimeFraction, const std::vector<float>& instLumiByBX, float totalInstLumi):
deadtimeFraction_(deadtimeFraction),
totalInstLuminosity_(totalInstLumi),
instLumiByBX_(instLumiByBX)
{
instLumiStatErrByBX_.assign(LumiConstants::numBX, 0.0);
totalInstLumiStatErr_=0;
}

// Integrated (delivered) luminosity (in ub^-1)
float integLuminosity() const;
/**
* constructor with fill; if total algo DIFFERS from summing and adding including stats
*/
LumiInfo(float deadtimeFraction, const std::vector<float>& instLumiByBX, float totalInstLumi,
const std::vector<float>& instLumiErrByBX, float totalInstLumiErr):
deadtimeFraction_(deadtimeFraction),
totalInstLuminosity_(totalInstLumi),
totalInstLumiStatErr_(totalInstLumiErr),
instLumiByBX_(instLumiByBX),
instLumiStatErrByBX_(instLumiErrByBX)
{
}

// Recorded (integrated) luminosity (in ub^-1)
// (==integLuminosity * (1-deadtimeFraction))
float recordedLuminosity() const;
/**
* destructor
*/
~LumiInfo(){}

// Deadtime/livetime fraction
float deadFraction() const { return deadtimeFraction_; }
float liveFraction() const { return 1-deadtimeFraction_; }
//
// all getters
//

// lumi section length in seconds = numorbits*3564*25e-09
float lumiSectionLength() const;
/**
* Returns total instantanious luminosity in hz/uB
*/
float getTotalInstLumi() const{return totalInstLuminosity_;}
/**
* Returns statistical error on total instantanious luminosity in hz/uB
*/
float getTotalInstStatError() const{return totalInstLumiStatErr_;}
/**
* Returns instantaneous luminosity of all bunches
*/
const std::vector<float>& getInstLumiAllBX() const { return instLumiByBX_; }
/**
* Returns statistical error of instantaneous luminosity for all bunches
*/
const std::vector<float>& getErrorLumiAllBX() const { return instLumiStatErrByBX_; }
/**
* Returns instantaneous luminosity of one bunch
*/
float getInstLumiBX(int bx) const { return instLumiByBX_.at(bx); }
/**
* Deadtime fraction
*/
float getDeadFraction() const { return deadtimeFraction_; }
/**
* Livetime fraction (1-deadtime frac)
*/
float getLiveFraction() const { return 1-deadtimeFraction_; }


//
// all setters
//

// Inst lumi by bunch
float getInstLumiBX(int bx) const { return instLumiByBX_.at(bx); }
const std::vector<float>& getInstLumiAllBX() const { return instLumiByBX_; }
/**
* Set the deadtime fraction
*/
void setDeadFraction(float deadtimeFraction) { deadtimeFraction_ = deadtimeFraction; }
/**
* Set total instantanious luminosity in hz/uB
*/
void setTotalInstLumi(float totalLumi){ totalInstLuminosity_=totalLumi;}
/**
* Set statistical error on total instantanious luminosity in hz/uB
*/
void setTotalInstStatError(float statError){ totalInstLumiStatErr_=statError;}
/**
* Set statistical error of instantaneous luminosity for all bunches
*/
void setInstLumiAllBX(std::vector<float>& instLumiByBX);
/**
* Set statistical error of instantaneous luminosity for all bunches
*/
void setErrorLumiAllBX(std::vector<float>& errLumiByBX);

bool isProductEqual(LumiInfo const& next) const;

/**
* Resets totalInstLuminosity_ to be the sum of instantaneous
* luminosity
*/
void setTotalInstToBXSum() ;

//
//setters
//

void setDeadFraction(float deadtimeFraction) { deadtimeFraction_ = deadtimeFraction; }
// fill inst lumi
void fill(const std::vector<float>& instLumiByBX);
// synonym for above
void fillInstLumi(const std::vector<float>& instLumiByBX);
/**
* Returns the sum of the instantaneous luminosity in Hz/uB,
* which not always the same as totalInstLuminosity_.
*/
float instLuminosityBXSum() const;
/**
* Integrated (delivered) luminosity (in ub^-1)
*/
float integLuminosity() const;
/**
* Recorded (integrated) luminosity (in ub^-1)
* (==integLuminosity * (1-deadtimeFraction))
*/
float recordedLuminosity() const;
/**
* lumi section length in seconds = numorbits*3564*25e-09
*/
float lumiSectionLength() const;
/**
* This method checks if all the essential values of this LumiInfo are
* the same as the ones in the LumiInfo given as an argument.
*/
bool isProductEqual(LumiInfo const& next) const;

private:
float deadtimeFraction_;
std::vector<float> instLumiByBX_;
private:
float deadtimeFraction_;
float totalInstLuminosity_;
float totalInstLumiStatErr_;
std::vector<float> instLumiByBX_;
std::vector<float> instLumiStatErrByBX_;
};

std::ostream& operator<<(std::ostream& s, const LumiInfo& lumiInfo);
Expand Down
7 changes: 6 additions & 1 deletion DataFormats/Luminosity/interface/PixelClusterCounts.h
Expand Up @@ -41,7 +41,12 @@ class PixelClusterCounts {
std::vector<int> const & readCounts() const {
return(m_counts);
}

std::vector<int> const & readEvents() const {
return(m_events);
}
std::vector<int> const & readModID() const {
return(m_ModID);
}

private:
std::vector<int> m_counts;
Expand Down