Skip to content

Commit

Permalink
Cherry-picked minimum set of changes to get PR #11253 to compile in 74X.
Browse files Browse the repository at this point in the history
  • Loading branch information
mulhearn committed Sep 23, 2015
1 parent eac8218 commit 875741b
Show file tree
Hide file tree
Showing 9 changed files with 193 additions and 19 deletions.
Expand Up @@ -6,6 +6,7 @@
//#include "CondFormats/L1TObjects/interface/CaloParams.h"
#include "L1Trigger/L1TCalorimeter/interface/CaloParamsStage1.h"

#include "L1Trigger/L1TCalorimeter/interface/Stage1TauIsolationLUT.h"

// This is the implementation of the Stage1Layer2TauAlgorithm abstract base class.
// This class will be used to find sngle high pt tracks in heavy ion collisions.
Expand Down Expand Up @@ -39,7 +40,6 @@ namespace l1t {

CaloParamsStage1* const params_;


string findNESW(int ieta, int iphi, int neta, int nphi) const;

double JetIsolation(int et, int ieta, int iphi,
Expand All @@ -64,6 +64,7 @@ namespace l1t {
private:

CaloParamsStage1* const params_;
Stage1TauIsolationLUT* isoTauLut;


string findNESW(int ieta, int iphi, int neta, int nphi) const;
Expand Down
41 changes: 41 additions & 0 deletions L1Trigger/L1TCalorimeter/interface/Stage1TauIsolationLUT.h
@@ -0,0 +1,41 @@
// Stage1TauIsolationLUT.h
// Author: Leonard Apanasevich
//

#ifndef STAGE1TAUISOLATIONLUT_H
#define STAGE1TAUISOLATIONLUT_H

#define NBITS_JET_ET_LUT 8
#define NBITS_TAU_ET_LUT 8
#define NBITS_DATA 1 // number of bits in the payload
#define LUT_VERSION 1 // bump up the version number is any of the above is changed or if the relative tau iso algo is changed

#include <iostream>
#include <math.h>
#include "L1Trigger/L1TCalorimeter/interface/CaloParamsStage1.h"

namespace l1t {

class Stage1TauIsolationLUT{
public:
static const unsigned int nbitsJet; // number of bits used to store JET ET in LUT
static const unsigned int nbitsTau; // number of bits used to store TAU ET in LUT
static const unsigned int nbits_data; // number of bits in the payload
static const unsigned int lut_version;

Stage1TauIsolationLUT(CaloParamsStage1* params);
virtual ~Stage1TauIsolationLUT();

unsigned lutAddress(unsigned int, unsigned int) const;
int lutPayload(unsigned int) const;
private:

CaloParamsStage1* const params_;
//double tauMaxJetIsolationA;
//double tauMaxJetIsolationB;
//int tauMinPtJetIsolationB;

};

}
#endif
10 changes: 6 additions & 4 deletions L1Trigger/L1TCalorimeter/python/caloStage1Params_cfi.py
Expand Up @@ -13,7 +13,7 @@

# EG
caloStage1Params.egLsb = cms.double(1.)
caloStage1Params.egSeedThreshold = cms.double(1.)
caloStage1Params.egSeedThreshold = cms.double(0.)

caloStage1Params.egMinPtJetIsolation = cms.int32(25)
caloStage1Params.egMaxPtJetIsolation = cms.int32(63)
Expand All @@ -38,17 +38,19 @@
caloStage1Params.tauMaxJetIsolationB = cms.double(100.)
caloStage1Params.tauMaxJetIsolationA = cms.double(0.1)
caloStage1Params.tauIsoLUTFile = cms.FileInPath("L1Trigger/L1TCalorimeter/data/tauIsoLUT_stage1_isolA0.10_isolB100.00_ch_switchToIsoBPt192.00_j8t8.txt")
caloStage1Params.tauCalibrationLUTFile = cms.FileInPath("L1Trigger/L1TCalorimeter/data/tauCalibrationLUT_stage1.txt")
## caloStage1Params.tauCalibrationLUTFile = cms.FileInPath("L1Trigger/L1TCalorimeter/data/tauCalibrationLUT_stage1.txt")
caloStage1Params.tauCalibrationLUTFile = cms.FileInPath("L1Trigger/L1TCalorimeter/data/tauL1Calib_LUT.txt")
caloStage1Params.tauEtToHFRingEtLUTFile= cms.FileInPath("L1Trigger/L1TCalorimeter/data/tauHwEtToHFRingScale_LUT.txt")
caloStage1Params.isoTauEtaMin = cms.int32(5)
caloStage1Params.isoTauEtaMax = cms.int32(16)
# jets
caloStage1Params.jetLsb = cms.double(0.5)
caloStage1Params.jetSeedThreshold = cms.double(10.)
caloStage1Params.jetSeedThreshold = cms.double(5.)
caloStage1Params.jetNeighbourThreshold = cms.double(0.)
caloStage1Params.jetCalibrationType = cms.string("Stage1JEC")
caloStage1Params.jetCalibrationParams = jetSF_8TeV_data
caloStage1Params.jetCalibrationLUTFile = cms.FileInPath("L1Trigger/L1TCalorimeter/data/jetCalibrationLUT_stage1_prelim.txt")
## caloStage1Params.jetCalibrationLUTFile = cms.FileInPath("L1Trigger/L1TCalorimeter/data/jetCalibrationLUT_stage1_prelim.txt")
caloStage1Params.jetCalibrationLUTFile = cms.FileInPath("L1Trigger/L1TCalorimeter/data/jetCalibrationLUT_symmetric_0is0.txt")

# sums
caloStage1Params.etSumLsb = cms.double(0.5)
Expand Down
84 changes: 84 additions & 0 deletions L1Trigger/L1TCalorimeter/src/Stage1TauIsolationLUT.cc
@@ -0,0 +1,84 @@
// Stage1TauIsolationLUT.cc
// Author: Leonard Apanasevich
//

#include "L1Trigger/L1TCalorimeter/interface/Stage1TauIsolationLUT.h"
#include <vector>

using namespace l1t;

const unsigned int Stage1TauIsolationLUT::nbitsJet=NBITS_JET_ET_LUT;
const unsigned int Stage1TauIsolationLUT::nbitsTau=NBITS_TAU_ET_LUT;
const unsigned int Stage1TauIsolationLUT::nbits_data=NBITS_DATA;
const unsigned int Stage1TauIsolationLUT::lut_version=LUT_VERSION;

Stage1TauIsolationLUT::Stage1TauIsolationLUT(CaloParamsStage1* params): params_(params)
{};

unsigned Stage1TauIsolationLUT::lutAddress(unsigned int tauPt, unsigned int jetPt) const
{
const unsigned int maxJet = pow(2,nbitsJet)-1;
const unsigned int maxTau = pow(2,nbitsTau)-1;

// lut only defined for 8 bit Jet ET
if ( (nbitsJet != 8) || (nbitsTau != 8) ) return 0;

double jetLsb=params_->jetLsb();
if (abs(jetLsb-0.5) > 0.0001){
std::cout << "%Stage1TauIsolationLUT-E-Unexpected jetLsb " << jetLsb << " IsoTau calculation will be broken"<< std::endl;
return 0;
}

tauPt=tauPt>>1;
jetPt=jetPt>>1;

if (jetPt>maxJet) jetPt=maxJet;
if (tauPt>maxTau) tauPt=maxTau;

unsigned int address= (jetPt << nbitsTau) + tauPt;
return address;
}

int Stage1TauIsolationLUT::lutPayload(unsigned int address) const
{

const unsigned int maxJet = pow(2,nbitsJet)-1;
const unsigned int maxTau = pow(2,nbitsTau)-1;

const double tauMaxJetIsolationA = params_->tauMaxJetIsolationA();
const double tauMaxJetIsolationB = params_->tauMaxJetIsolationB();
const double tauMinPtJetIsolationB = params_->tauMinPtJetIsolationB();

unsigned int maxAddress = pow(2,nbitsJet+nbitsTau)-1;
if (address > maxAddress){ // check that address is right length
std::cout << "%Stage1TauIsolationLUT-E-Address: " << address
<< " exceeds maximum value allowed. Setting value to maximum (" << maxAddress << ")" << std::endl;
address = maxAddress;
}
// extract the jet and tau et from the address
int ijetet = address >> nbitsTau;
int itauet = address & 0xff;


double jet_pt = static_cast <float> (ijetet); // no need convert to physical eT, as right shift (>>1) operation
double tau_pt = static_cast <float> (itauet); // in lutAddress automatically converts to physical eT, assuming lsb=0.5

//std::cout << "ijetet: " << ijetet << "\titauet: " << itauet << std::endl;
//std::cout << "jetet: " << jet_pt << "\ttauet: " << tau_pt << std::endl;

int isol=0;
if (maxTau == itauet){
isol=1;
} else if (maxJet == ijetet){
isol=1;
} else {
double relativeJetIsolationTau = (jet_pt / tau_pt) -1;

double isolCut=tauMaxJetIsolationA;
if (tau_pt >= tauMinPtJetIsolationB)isolCut=tauMaxJetIsolationB;
if (relativeJetIsolationTau < isolCut) isol=1;
}
return isol;
}

Stage1TauIsolationLUT::~Stage1TauIsolationLUT(){};
Expand Up @@ -147,6 +147,8 @@ unsigned l1t::Stage1Layer2EGammaAlgorithmImpHW::isoLutIndex(unsigned int egPt,un
const unsigned int nbitsEG=6; // number of bits used for EG bins in LUT file (needed for left shift operation)
// const unsigned int nbitsJet=9; // not used but here for info number of bits used for Jet bins in LUT file

//jetPt &= 511; // Take only the LSB 9 bits to match firmware.
if(jetPt > 511) jetPt = 511;
unsigned int address= (jetPt << nbitsEG) + egPt;
// std::cout << address << "\t## " << egPt << " " << jetPt << std::endl;
return address;
Expand Down
Expand Up @@ -98,11 +98,6 @@ void l1t::Stage1Layer2EtSumAlgorithmImpHW::processEvent(const std::vector<l1t::C
int sumHT, MHT, iPhiHT;
std::tie(sumHT, MHT, iPhiHT) = doSumAndMET(regionHtVect, ETSumType::kHadronicSum);

//MHT is replaced with MHT/HT
uint16_t MHToHT=MHToverHT(MHT,sumHT);
//iPhiHt is replaced by the dPhi between two most energetic jets
iPhiHT = DiJetPhi(jets);

// Set quality (i.e. overflow) bits appropriately
int METqual = 0;
int MHTqual = 0;
Expand All @@ -117,6 +112,14 @@ void l1t::Stage1Layer2EtSumAlgorithmImpHW::processEvent(const std::vector<l1t::C
if(sumHT >= 0xfff)
HTTqual = 1;

MHT &= 127; // limit MHT to 7 bits as the firmware does, but only after checking for overflow.
//MHT is replaced with MHT/HT
uint16_t MHToHT=MHToverHT(MHT,sumHT);
// std::cout << "MHT HT MHT/HT" << std::endl;
// std::cout << MHT << " " << sumHT << " " << MHToHT << std::endl;
//iPhiHt is replaced by the dPhi between two most energetic jets
iPhiHT = DiJetPhi(jets);


const ROOT::Math::LorentzVector<ROOT::Math::PxPyPzE4D<double> > etLorentz(0,0,0,0);
l1t::EtSum etMiss(*&etLorentz,EtSum::EtSumType::kMissingEt,MET&0xfff,0,iPhiET,METqual);
Expand Down
Expand Up @@ -24,9 +24,13 @@ using namespace l1t;

Stage1Layer2TauAlgorithmImpHW::Stage1Layer2TauAlgorithmImpHW(CaloParamsStage1* params) : params_(params)
{

isoTauLut = new Stage1TauIsolationLUT(params_);
}

Stage1Layer2TauAlgorithmImpHW::~Stage1Layer2TauAlgorithmImpHW(){};
Stage1Layer2TauAlgorithmImpHW::~Stage1Layer2TauAlgorithmImpHW(){
delete isoTauLut;
};



Expand Down Expand Up @@ -128,11 +132,15 @@ void l1t::Stage1Layer2TauAlgorithmImpHW::processEvent(const std::vector<l1t::Cal
int jetEt=AssociatedJetPt(region->hwEta(), region->hwPhi(),unCorrJets);
if (jetEt>0){
unsigned int MAX_LUT_ADDRESS = params_->tauIsolationLUT()->maxSize()-1;
unsigned int lutAddress = isoLutIndex(tauEt,jetEt);
// unsigned int lutAddress = isoLutIndex(tauEt,jetEt);
unsigned lutAddress = isoTauLut->lutAddress(tauEt,jetEt);
if (tauEt >0){
if (lutAddress > MAX_LUT_ADDRESS) lutAddress = MAX_LUT_ADDRESS;
isoFlag= params_->tauIsolationLUT()->data(lutAddress);
isoFlag = params_->tauIsolationLUT()->data(lutAddress);
// isoFlag= isoTauLut->lutPayload(lutAddress);
// if (isoFlag != params_->tauIsolationLUT()->data(lutAddress)) std::cout << "XXX -- isoFlag: " << isoFlag << "\tisoFlag2: " << params_->tauIsolationLUT()->data(lutAddress) << std::endl;
}

}else{ // no associated jet
isoFlag=1;
}
Expand Down Expand Up @@ -314,6 +322,7 @@ unsigned l1t::Stage1Layer2TauAlgorithmImpHW::isoLutIndex(unsigned int tauPt,unsi
if (tauPt>maxTau) tauPt=maxTau;

unsigned int address= (jetPt << nbitsTau) + tauPt;

// std::cout << address << "\t## " << tauPt << " " << jetPt << std::endl;
return address;
}
4 changes: 4 additions & 0 deletions L1Trigger/L1TCalorimeter/src/legacyGtHelper.cc
Expand Up @@ -19,6 +19,10 @@ namespace l1t {
if(pt > ((1<<10) -1) )
pt = ((1<<10) -1);
unsigned int eta = itJet->hwEta();
if (eta>10){ // LUT is symmetric in eta. For eta>10 map to corresponding eta<10 bin
int offset=2*(eta-10)-1;
eta=eta-offset;
}
unsigned int lutAddress = (eta<<10)+pt;

unsigned int rank = params->jetCalibrationLUT()->data(lutAddress);
Expand Down
40 changes: 34 additions & 6 deletions L1Trigger/L1TCalorimeter/test/SimL1Emulator_Stage1.py
Expand Up @@ -4,21 +4,22 @@

process.load('Configuration.StandardSequences.Services_cff')
process.load('FWCore.MessageService.MessageLogger_cfi')
process.load('Configuration/StandardSequences/FrontierConditions_GlobalTag_cff')
## process.load('Configuration/StandardSequences/FrontierConditions_GlobalTag_cff')
process.load('Configuration.StandardSequences.FrontierConditions_GlobalTag_condDBv2_cff')
process.load('Configuration.EventContent.EventContent_cff')
process.load('Configuration.Geometry.GeometryIdeal_cff')

# Select the Message Logger output you would like to see:
process.load('FWCore.MessageService.MessageLogger_cfi')

process.maxEvents = cms.untracked.PSet(
input = cms.untracked.int32(100)
input = cms.untracked.int32(-200)
)

# Input source
process.source = cms.Source("PoolSource",
secondaryFileNames = cms.untracked.vstring(),
fileNames = cms.untracked.vstring("root://xrootd.unl.edu//store/mc/Fall13dr/Neutrino_Pt-2to20_gun/GEN-SIM-RAW/tsg_PU40bx25_POSTLS162_V2-v1/00005/02B79593-F47F-E311-8FF6-003048FFD796.root")
fileNames = cms.untracked.vstring("/store/relval/CMSSW_7_5_0_pre4/RelValTTbar_13/GEN-SIM-DIGI-RAW-HLTDEBUG/PU25ns_MCRUN2_75_V1-v1/00000/0CD12657-DAF7-E411-91F2-002618943910.root")
)


Expand All @@ -40,9 +41,10 @@
process.options = cms.untracked.PSet()

# Other statements
from Configuration.AlCa.GlobalTag import GlobalTag
process.GlobalTag.connect = cms.string('frontier://FrontierProd/CMS_COND_31X_GLOBALTAG')
process.GlobalTag.globaltag = cms.string('POSTLS162_V2::All')
## from Configuration.AlCa.GlobalTag import GlobalTag
## process.GlobalTag.connect = cms.string('frontier://FrontierProd/CMS_COND_31X_GLOBALTAG')
from Configuration.AlCa.GlobalTag_condDBv2 import GlobalTag
process.GlobalTag.globaltag = cms.string('MCRUN2_75_V1')

process.load('L1Trigger.L1TCalorimeter.L1TCaloStage1_PPFromRaw_cff')

Expand All @@ -54,6 +56,32 @@
process.simGtDigis.TechnicalTriggersInputTags = cms.VInputTag( )


### Get new RCT calibrations from CondDB until new GlobalTag is ready
### Goes with tauL1Calib_LUT.txt
### Need new GCT jet calibrations to go with it
#from CondCore.DBCommon.CondDBSetup_cfi import CondDBSetup
#process.rctSFDB = cms.ESSource("PoolDBESSource",
# CondDBSetup,
# connect = cms.string('frontier://FrontierProd/CMS_CONDITIONS'),
# DumpStat=cms.untracked.bool(True),
# toGet = cms.VPSet(
# cms.PSet(
# record = cms.string('L1RCTParametersRcd'),
# tag = cms.string('L1RCTParametersRcd_L1TDevelCollisions_ExtendedScaleFactorsV4')
# )
# )
#)
## process.prefer("caloParmsDB")
#process.es_prefer_rctSFDB = cms.ESPrefer( "PoolDBESSource", "rctSFDB" )

## load the CaloStage1 params
## process.GlobalTag.toGet = cms.VPSet(
## cms.PSet(record = cms.string("L1TCaloParamsRcd"),
## tag = cms.string("L1TCaloParams_CRAFT09_hlt"),
## connect = cms.string("sqlite:l1config.db")
## )
## )

process.p1 = cms.Path(
process.L1TCaloStage1_PPFromRaw
+process.simGtDigis
Expand Down

0 comments on commit 875741b

Please sign in to comment.