Skip to content

Commit

Permalink
Added xangle and beta* filter.
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-kaspar committed Aug 17, 2020
1 parent 37a05c6 commit 4a2d1cd
Show file tree
Hide file tree
Showing 3 changed files with 131 additions and 0 deletions.
4 changes: 4 additions & 0 deletions CondTools/RunInfo/plugins/BuildFile.xml
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,7 @@
<library file="RunInfoTestESProducer.cc" name="CondToolsRunInfoTestESProducer">
<flags EDM_PLUGIN="1"/>
</library>

<library file="XangleBetaStarFilter.cc">
<flags EDM_PLUGIN="1"/>
</library>
78 changes: 78 additions & 0 deletions CondTools/RunInfo/plugins/XangleBetaStarFilter.cc
Original file line number Diff line number Diff line change
@@ -0,0 +1,78 @@
/****************************************************************************
* Authors:
* Jan Kašpar
****************************************************************************/

#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Utilities/interface/Exception.h"
#include "FWCore/Framework/interface/EDFilter.h"
#include "FWCore/Framework/interface/Event.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Framework/interface/EventSetup.h"

#include "CondFormats/RunInfo/interface/LHCInfo.h"
#include "CondFormats/DataRecord/interface/LHCInfoRcd.h"

//----------------------------------------------------------------------------------------------------

class XangleBetaStarFilter : public edm::EDFilter
{
public:
explicit XangleBetaStarFilter(const edm::ParameterSet&);

static void fillDescriptions(edm::ConfigurationDescriptions &descriptions);

private:
edm::ESGetToken<LHCInfo, LHCInfoRcd> lhcInfoToken_;

double xangle_min_;
double xangle_max_;

double beta_star_min_;
double beta_star_max_;

virtual bool filter(edm::Event &, const edm::EventSetup &) override;
};

//----------------------------------------------------------------------------------------------------

XangleBetaStarFilter::XangleBetaStarFilter(const edm::ParameterSet& iConfig) :
lhcInfoToken_(esConsumes<LHCInfo, LHCInfoRcd>(edm::ESInputTag{"", iConfig.getParameter<std::string>("lhcInfoLabel")})),

xangle_min_(iConfig.getParameter<double>("xangle_min")),
xangle_max_(iConfig.getParameter<double>("xangle_max")),
beta_star_min_(iConfig.getParameter<double>("beta_star_min")),
beta_star_max_(iConfig.getParameter<double>("beta_star_max"))
{
}

//----------------------------------------------------------------------------------------------------

void XangleBetaStarFilter::fillDescriptions(edm::ConfigurationDescriptions &descriptions) {
edm::ParameterSetDescription desc;

desc.add<std::string>("lhcInfoLabel", "")->setComment("label of the LHCInfo record");

desc.add<double>("xangle_min", 0.);
desc.add<double>("xangle_max", 1000.);

desc.add<double>("beta_star_min", 0.);
desc.add<double>("beta_star_max", 1000.);

descriptions.add("xangleBetaStarFilter", desc);
}

//----------------------------------------------------------------------------------------------------

bool XangleBetaStarFilter::filter(edm::Event& /*iEvent*/, const edm::EventSetup& iSetup)
{
const auto &lhcInfo = iSetup.getData(lhcInfoToken_);

return (xangle_min_ <= lhcInfo.crossingAngle() && lhcInfo.crossingAngle() < xangle_max_)
&& (beta_star_min_ <= lhcInfo.betaStar() && lhcInfo.betaStar() < beta_star_max_);
}

//----------------------------------------------------------------------------------------------------

DEFINE_FWK_MODULE(XangleBetaStarFilter);
49 changes: 49 additions & 0 deletions CondTools/RunInfo/test/xangleBetaStarFilter_test_cfg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,49 @@
import FWCore.ParameterSet.Config as cms

process = cms.Process("TEST")

# define global tag
process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_cff')
from Configuration.AlCa.GlobalTag import GlobalTag
process.GlobalTag = GlobalTag(process.GlobalTag, '106X_dataRun2_v28', '')

# minimum of logs
process.MessageLogger = cms.Service("MessageLogger",
statistics = cms.untracked.vstring(),
destinations = cms.untracked.vstring('cout'),
cout = cms.untracked.PSet(
threshold = cms.untracked.string('WARNING')
)
)

# data source
process.source = cms.Source("PoolSource",
fileNames = cms.untracked.vstring("/store/data/Run2018D/EGamma/MINIAOD/12Nov2019_UL2018-v4/280000/FF9D0498-30CA-7241-A85C-6F4F272A7A16.root")
)

#process.maxEvents = cms.untracked.PSet(
# input = cms.untracked.int32(1000)
#)

# filter
process.load("CondTools.RunInfo.xangleBetaStarFilter_cfi")
process.xangleBetaStarFilter.xangle_min = 150
process.xangleBetaStarFilter.xangle_max = 170

# plotters
process.plotterBefore = cms.EDAnalyzer("CTPPSLHCInfoPlotter",
lhcInfoLabel = cms.string(""),
outputFile = cms.string("output_before_filter.root")
)

process.plotterAfter = cms.EDAnalyzer("CTPPSLHCInfoPlotter",
lhcInfoLabel = cms.string(""),
outputFile = cms.string("output_after_filter.root")
)

# path
process.p = cms.Path(
process.plotterBefore
* process.xangleBetaStarFilter
* process.plotterAfter
)

0 comments on commit 4a2d1cd

Please sign in to comment.