Skip to content

Commit

Permalink
Merge pull request cms-sw#622 from emanueledimarco/ecalcorr_76X
Browse files Browse the repository at this point in the history
Updating ECAL scale and resolution corrections, and propagating to Heppy Electrons and Photons
  • Loading branch information
gpetruc committed Mar 7, 2016
2 parents a2a57fd + 63109b2 commit c8c1d15
Show file tree
Hide file tree
Showing 164 changed files with 5,544 additions and 1,424 deletions.
5 changes: 3 additions & 2 deletions Alignment/APEEstimation/test/SkimProducer/cmsRemove.sh
@@ -1,5 +1,6 @@
#!/bin/sh

eos="/afs/cern.ch/project/eos/installation/cms/bin/eos.select"

#directory="/store/caf/user/hauk/data/mu/Run2010B_Dec22ReReco/"
directory="/store/caf/user/ajkumar/ApeSkim/zmumu50/"
Expand Down Expand Up @@ -39,10 +40,10 @@ while [ $counter -le 1000 ]
do
fullname="${filebase}${counter}${filesuffix}"

cmsLs ${fullname}
$eos ls ${fullname}
if [ $? -eq 0 ] ; then
echo "Delete file: ${counter}";
cmsRm ${fullname}
$eos rm ${fullname}
else
echo "Last file reached: ${counter}"; exit 0;
fi
Expand Down
20 changes: 11 additions & 9 deletions Alignment/APEEstimation/test/SkimProducer/cmsRename.sh
@@ -1,5 +1,7 @@
#!/bin/sh

eos="/afs/cern.ch/project/eos/installation/cms/bin/eos.select"

if [ ! $# == 1 ]; then
echo "Usage: $0 sample"
exit 1
Expand Down Expand Up @@ -36,12 +38,12 @@ declare -i counter=1
inputFilename="${filebase}${filesuffix}"
outputFilename="${filebase}${counter}${filesuffix}"

cmsStageIn $inputFilename $tempFile
xrdcp root://eoscms//eos/cms${inputFilename} $tempFile

if [ ! -f $tempFile ] ; then echo "Last file reached: 0"; exit 0; fi
cmsStageOut $tempFile $outputFilename
xrdcp $tempFile root://eoscms//eos/cms${outputFilename}
if [ $? -eq 0 ] ; then
cmsRm ${filebase}${filesuffix}
$eos rm ${filebase}${filesuffix}
fi
rm $tempFile

Expand All @@ -53,11 +55,11 @@ do
inputFilename="${filebase}00${counter}${filesuffix}"
outputFilename="${filebase}${counterIncrement}${filesuffix}"

cmsStageIn $inputFilename $tempFile
xrdcp root://eoscms//eos/cms${inputFilename} $tempFile
if [ ! -f $tempFile ] ; then echo "Last file reached: ${counter}"; exit 0; fi
cmsStageOut $tempFile $outputFilename
xrdcp $tempFile root://eoscms//eos/cms${outputFilename}
if [ $? -eq 0 ] ; then
cmsRm $inputFilename
$eos rm $inputFilename
fi
rm $tempFile

Expand All @@ -75,11 +77,11 @@ do
inputFilename="${filebase}0${counterTen}${filesuffix}"
outputFilename="${filebase}${counterTenIncrement}${filesuffix}"

cmsStageIn $inputFilename $tempFile
xrdcp root://eoscms//eos/cms${inputFilename} $tempFile
if [ ! -f $tempFile ] ; then echo "Last file reached: ${counterTen}"; exit 0; fi
cmsStageOut $tempFile $outputFilename
xrdcp $tempFile root://eoscms//eos/cms${outputFilename}
if [ $? -eq 0 ] ; then
cmsRm $inputFilename
$eos rm $inputFilename
fi
rm $tempFile

Expand Down
2 changes: 1 addition & 1 deletion Alignment/APEEstimation/test/batch/cp.bash
Expand Up @@ -45,7 +45,7 @@ ls -l

for file in *.root;
do
cmsStageOut $file ${directory}${file}
xrdcp $file root://eoscms//eos/cms${directory}${file}
done


Expand Down
2 changes: 1 addition & 1 deletion Alignment/APEEstimation/test/batch/skimProducer.bash
Expand Up @@ -47,7 +47,7 @@ ls -l

for file in *.root;
do
cmsStageOut $file ${directory}${file}
xrdcp $file root://eoscms//eos/cms${directory}${file}
done


Expand Down
Expand Up @@ -15,7 +15,7 @@ source /afs/cern.ch/cms/caf/setup.csh
cd -


cmsStageIn _THE_INPUTBASE__THE_NUMBER_.root reco.root
xrdcp _THE_INPUTBASE__THE_NUMBER_.root reco.root


cmsRun $CMSSW_BASE/src/Alignment/APEEstimation/test/cfgTemplate/apeEstimator_cfg.py_THE_COMMANDS_
Expand Down
Expand Up @@ -24,7 +24,7 @@ BATCH_OUTPUTBASE1="${CMSSW_BASE}/src/Alignment/APEEstimation/test/batch/workingA
BATCH_OUTPUTSUFFIX=".tcsh"

helpFile1="help1.txt"
cat $BATCH_TEMPLATEFILE |sed "s/_THE_INPUTBASE_/${inputBase}/g" > $helpFile1
cat $BATCH_TEMPLATEFILE |sed "s/_THE_INPUTBASE_/root:\/\/eoscms\/\/eos\/cms\/${inputBase}/g" > $helpFile1



Expand Down
158 changes: 158 additions & 0 deletions Alignment/CommonAlignment/plugins/APVModeFilter.cc
@@ -0,0 +1,158 @@
// -*- C++ -*-
//
// Package: Alignment/CommonAlignment
// Class: APVModeFilter
//
/**\class APVModeFilter APVModeFilter.cc Alignment/CommonAlignment/plugins/APVModeFilter.cc
Description: Plugin to filter events based on the APV mode
Implementation:
The filter checks the bit configuration used for a given run and selects
only events according to the configured APV mode.
General reference:
https://twiki.cern.ch/twiki/bin/view/CMS/SiStripConditionObjects#SiStripLatency
Document describing the bit configuration (section 5.5):
https://cds.cern.ch/record/1069892/files/cer-002725643.pdf
Summary given here:
https://hypernews.cern.ch/HyperNews/CMS/get/recoTracking/1590/1/1/1.html
bit 1: 0 = 3-sample, 1 = 1-sample
bit 3: 0 = deconvolution, 1 = peak
if both bits are zero: deco
if both bits are one: peak
if 1 is zero and bit 3 is one: multi (not used in actual data taking)
*/
//
// Original Author: Gregor Mittag
// Created: Thu, 03 Dec 2015 16:51:33 GMT
//
//


// system include files
#include <bitset>
#include <array>

// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "FWCore/Utilities/interface/Exception.h"
#include "CondFormats/SiStripObjects/interface/SiStripLatency.h"
#include "CondFormats/DataRecord/interface/SiStripCondDataRecords.h"

//
// class declaration
//

class APVModeFilter : public edm::stream::EDFilter<> {
public:
explicit APVModeFilter(const edm::ParameterSet&);
~APVModeFilter() = default;

static void fillDescriptions(edm::ConfigurationDescriptions&);

private:
virtual bool filter(edm::Event&, const edm::EventSetup&) override;
virtual void beginRun(const edm::Run&, const edm::EventSetup&) override;

using BitMask = std::bitset<16>; /// APV mode is encoded in uin16_t

/// converts configuration parameter into type used for APV mode filtering
BitMask convertMode(const std::string& mode) const;

/// converts latency record content into type used for APV mode filtering
BitMask convertMode(const uint16_t& mode) const;


// ----------member data ---------------------------

/// bits of interest for the APV mode
static constexpr std::array<size_t, 2> bits_ = {{1, 3}};
static constexpr BitMask deco_ = BitMask(0); /// deco mode bit mask (0000)
static constexpr BitMask peak_ = BitMask(10); /// peak mode bit mask (1010)
static constexpr BitMask multi_ = BitMask(8); /// multi mode bit mask (1000)

const BitMask mode_; /// APV mode that is filtered
BitMask modeCurrentRun_; /// APV mode of the current run
};


//
// static data member definitions
//
constexpr std::array<size_t, 2> APVModeFilter::bits_;
constexpr APVModeFilter::BitMask APVModeFilter::deco_;
constexpr APVModeFilter::BitMask APVModeFilter::peak_;
constexpr APVModeFilter::BitMask APVModeFilter::multi_;


//
// constructors and destructor
//
APVModeFilter::APVModeFilter(const edm::ParameterSet& iConfig) :
mode_(convertMode(iConfig.getUntrackedParameter<std::string>("apvMode"))) {
}


//
// member functions
//

// ------------ method called on each new Event ------------
bool
APVModeFilter::filter(edm::Event&, const edm::EventSetup&) {
return mode_ == modeCurrentRun_;
}

// ------------ method called when starting to processes a run ------------
void
APVModeFilter::beginRun(const edm::Run&, const edm::EventSetup& iSetup) {
edm::ESHandle<SiStripLatency> siStripLatency;
iSetup.get<SiStripLatencyRcd>().get(siStripLatency);
auto product = siStripLatency.product();
modeCurrentRun_ = convertMode(product->singleMode());
}

APVModeFilter::BitMask
APVModeFilter::convertMode(const std::string& mode) const {
if (mode == "deco") {
return deco_;
} else if (mode == "peak") {
return peak_;
} else if (mode == "multi") {
return multi_;
} else {
throw cms::Exception("BadConfig")
<< "Your choice for the APV mode ('" << mode
<< "') is invalid.\nValid APV modes: deco, peak, multi" << std::endl;
}
}

APVModeFilter::BitMask
APVModeFilter::convertMode(const uint16_t& mode) const {
BitMask input(mode);
BitMask result;
for (const auto& bit: bits_) result.set(bit, input[bit]);
return result;
}

// ------------ method fills 'descriptions' with the allowed parameters for the module ------------
void
APVModeFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.setComment("Filters events with the APV mode 'apvMode' (deco/peak/multi).");
desc.addUntracked<std::string>("apvMode", "deco");
descriptions.add("apvModeFilter", desc);
}

//define this as a plug-in
DEFINE_FWK_MODULE(APVModeFilter);
7 changes: 7 additions & 0 deletions Alignment/CommonAlignment/plugins/BuildFile.xml
@@ -0,0 +1,7 @@
<use name="FWCore/Framework"/>
<use name="FWCore/PluginManager"/>
<use name="FWCore/ParameterSet"/>
<use name="CondFormats/DataRecord"/>
<use name="CondFormats/RunInfo"/>
<use name="CondFormats/SiStripObjects"/>
<flags EDM_PLUGIN="1"/>
122 changes: 122 additions & 0 deletions Alignment/CommonAlignment/plugins/MagneticFieldFilter.cc
@@ -0,0 +1,122 @@
// -*- C++ -*-
//
// Package: Alignment/CommonAlignment
// Class: MagneticFieldFilter
//
/**\class MagneticFieldFilter MagneticFieldFilter.cc Alignment/CommonAlignment/plugins/MagneticFieldFilter.cc
Description: Plugin to filter events based on the magnetic field value
Implementation:
Takes the magnet current from the RunInfoRcd and translates it into a
magnetic field value using the parameterization given here:
https://hypernews.cern.ch/HyperNews/CMS/get/magnetic-field/63/1/1/1.html
Agrees within an accuracy of ~20 mT with results of:
https://cmswbm.web.cern.ch/cmswbm/cmsdb/servlet/RunSummary
*/
//
// Original Author: Gregor Mittag
// Created: Wed, 25 Nov 2015 12:59:02 GMT
//
//


// user include files
#include "FWCore/Framework/interface/Frameworkfwd.h"
#include "FWCore/Framework/interface/MakerMacros.h"
#include "FWCore/Framework/interface/EventSetup.h"
#include "FWCore/Framework/interface/ESHandle.h"
#include "FWCore/ParameterSet/interface/ParameterSet.h"
#include "CondFormats/RunInfo/interface/RunInfo.h"
#include "CondFormats/DataRecord/interface/RunSummaryRcd.h"

//
// class declaration
//

class MagneticFieldFilter : public edm::stream::EDFilter<> {
public:
explicit MagneticFieldFilter(const edm::ParameterSet&);
~MagneticFieldFilter() = default;

static void fillDescriptions(edm::ConfigurationDescriptions&);

private:
virtual bool filter(edm::Event&, const edm::EventSetup&) override;
virtual void beginRun(const edm::Run&, const edm::EventSetup&) override;

/// convert Ampere (A) to Tesla (T)
float currentToField(const float& current) const;

// ----------member data ---------------------------
/// see: https://hypernews.cern.ch/HyperNews/CMS/get/magnetic-field/63/1/1/1.html
static constexpr float linearCoeffCurrentToField_ = 2.084287e-04;
/// see: https://hypernews.cern.ch/HyperNews/CMS/get/magnetic-field/63/1/1/1.html
static constexpr float constantTermCurrentToField_ = 1.704418e-02;

const int magneticField_; /// magnetic field that is filtered
int magneticFieldCurrentRun_; /// magnetic field estimate of the current run
};

//
// static data member definitions
//
constexpr float MagneticFieldFilter::linearCoeffCurrentToField_;
constexpr float MagneticFieldFilter::constantTermCurrentToField_;


//
// constructor
//
MagneticFieldFilter::MagneticFieldFilter(const edm::ParameterSet& iConfig) :
magneticField_(iConfig.getUntrackedParameter<int>("magneticField")),
magneticFieldCurrentRun_(-10000) {
}


//
// member functions
//

// ------------ method called on each new Event ------------
bool
MagneticFieldFilter::filter(edm::Event&, const edm::EventSetup&) {
return magneticField_ == magneticFieldCurrentRun_;
}

// ------------ method called when starting to processes a run ------------

void
MagneticFieldFilter::beginRun(const edm::Run&, const edm::EventSetup& iSetup) {
edm::ESHandle<RunInfo> sum;
iSetup.get<RunInfoRcd>().get(sum);
auto summary = sum.product();
// convert from Tesla to kGauss (multiply with 10) and
// round off to whole kGauss (add 0.5 and cast to int) as is done in
// 'MagneticField::computeNominalValue()':
magneticFieldCurrentRun_ =
static_cast<int>(currentToField(summary->m_avg_current)*10.0 + 0.5);
}


float
MagneticFieldFilter::currentToField(const float& current) const {
return linearCoeffCurrentToField_ * current + constantTermCurrentToField_;
}


// ------------ method fills 'descriptions' with the allowed parameters for the module ------------
void
MagneticFieldFilter::fillDescriptions(edm::ConfigurationDescriptions& descriptions) {
edm::ParameterSetDescription desc;
desc.setComment("Filters events with a magnetic field of 'magneticField'.");
desc.addUntracked<int>("magneticField", 38)
->setComment("In units of kGauss (= 0.1 Tesla).");
descriptions.add("magneticFieldFilter", desc);
}

//define this as a plug-in
DEFINE_FWK_MODULE(MagneticFieldFilter);

0 comments on commit c8c1d15

Please sign in to comment.