Skip to content

Commit

Permalink
Showing 20 changed files with 305 additions and 290 deletions.
2 changes: 1 addition & 1 deletion L1Trigger/L1TMuonOverlap/interface/AngleConverter.h
Original file line number Diff line number Diff line change
@@ -33,7 +33,7 @@ class RPCDetId;
void checkAndUpdateGeometry(const edm::EventSetup&);

/// get phi of DT,CSC and RPC azimutal angle digi in processor scale, used by OMTF algorithm.
/// in case of wrong phi returns omtf_config_->nPhiBins
/// in case of wrong phi returns OMTFConfiguration::instance()->nPhiBins
int getProcessorPhi(unsigned int iProcessor, l1t::tftype part, const L1MuDTChambPhDigi &digi) const;
int getProcessorPhi(unsigned int iProcessor, l1t::tftype part, const CSCDetId & csc, const CSCCorrelatedLCTDigi &digi) const;
int getProcessorPhi(unsigned int iProcessor, l1t::tftype part, const RPCDetId & rollId, const unsigned int &digi) const;
6 changes: 4 additions & 2 deletions L1Trigger/L1TMuonOverlap/interface/OMTFConfigMaker.h
Original file line number Diff line number Diff line change
@@ -5,6 +5,7 @@

#include "L1Trigger/L1TMuonOverlap/interface/GoldenPattern.h"
#include "L1Trigger/L1TMuonOverlap/interface/OMTFResult.h"
#include "L1Trigger/L1TMuonOverlap/interface/OMTFConfiguration.h"

class XMLConfigReader;
class OMTFinput;
@@ -17,7 +18,7 @@ class OMTFConfigMaker{

public:

OMTFConfigMaker(const edm::ParameterSet & cfg);
OMTFConfigMaker(const edm::ParameterSet & cfg, OMTFConfiguration * omtf_config);

~OMTFConfigMaker();

@@ -66,7 +67,8 @@ class OMTFConfigMaker{
///Second index: logic region number
std::vector<std::vector<int> > minRefPhi2D;
std::vector<std::vector<int> > maxRefPhi2D;


OMTFConfiguration * m_omtf_config;
};


16 changes: 7 additions & 9 deletions L1Trigger/L1TMuonOverlap/interface/OMTFConfiguration.h
Original file line number Diff line number Diff line change
@@ -47,15 +47,12 @@ class RefHitDef{

};

// temp hack for migration from static:
class OMTFConfiguration;
extern OMTFConfiguration * omtf_config_;

class OMTFConfiguration{

public:

// also part of temp hack above
static const OMTFConfiguration * instance(){ return latest_instance_; }

OMTFConfiguration(const edm::ParameterSet & cfg);

void configure(XMLConfigReader *aReader);
@@ -139,26 +136,27 @@ class OMTFConfiguration{
///ranges are taken from DB.
unsigned int getRegionNumberFromMap(unsigned int iInput,
unsigned int iRefLayer,
int iPhi);
int iPhi) const;

///Check if given referecne hit is
///in phi range for some logic cone.
///Care is needed arounf +Pi and +2Pi points
bool isInRegionRange(int iPhiStart,
unsigned int coneSize,
int iPhi);
int iPhi) const;


///Return global phi for beggining of given processor
///Uses minim phi over all reference layers.
int globalPhiStart(unsigned int iProcessor);
int globalPhiStart(unsigned int iProcessor) const;

///Return layer number encoding subsystem, and
///station number in a simple formula:
/// aLayer+100*detId.subdetId()
///where aLayer is a layer number counting from vertex
uint32_t getLayerNumber(uint32_t rawId);
uint32_t getLayerNumber(uint32_t rawId) const;

static OMTFConfiguration * latest_instance_;
};


6 changes: 4 additions & 2 deletions L1Trigger/L1TMuonOverlap/interface/OMTFProcessor.h
Original file line number Diff line number Diff line change
@@ -5,9 +5,10 @@

#include "L1Trigger/L1TMuonOverlap/interface/GoldenPattern.h"
#include "L1Trigger/L1TMuonOverlap/interface/OMTFResult.h"
#include "L1Trigger/L1TMuonOverlap/interface/OMTFConfiguration.h"


class L1TMuonOverlapParams;
class OMTFConfiguration;
class XMLConfigReader;
class OMTFinput;

@@ -23,7 +24,7 @@ class OMTFProcessor{

typedef std::map<Key,OMTFResult> resultsMap;

OMTFProcessor(const edm::ParameterSet & cfg);
OMTFProcessor(const edm::ParameterSet & cfg, OMTFConfiguration * omtf_config);

~OMTFProcessor();

@@ -96,6 +97,7 @@ class OMTFProcessor{
///Reference hit number is isued as a vector index.
std::vector<OMTFProcessor::resultsMap> myResults;

OMTFConfiguration * m_omtf_config;
};


4 changes: 3 additions & 1 deletion L1Trigger/L1TMuonOverlap/interface/XMLConfigReader.h
Original file line number Diff line number Diff line change
@@ -9,6 +9,7 @@
#include "xercesc/dom/DOM.hpp"

#include "CondFormats/L1TObjects/interface/LUT.h"
#include "L1Trigger/L1TMuonOverlap/interface/OMTFConfiguration.h"

class GoldenPattern;
class OMTFConfiguration;
@@ -26,7 +27,7 @@ class XMLConfigReader{

public:

XMLConfigReader();
XMLConfigReader(OMTFConfiguration * omtf_config);

void readConfig(const std::string fName);

@@ -63,6 +64,7 @@ class XMLConfigReader{
///Cache with GPs read.
std::vector<GoldenPattern*> aGPs;

OMTFConfiguration * m_omtf_config;
};


Original file line number Diff line number Diff line change
@@ -29,14 +29,14 @@ L1TMuonOverlapParamsESProducer::L1TMuonOverlapParamsESProducer(const edm::Parame
fileNames.push_back(it.getParameter<edm::FileInPath>("patternsXMLFile").fullPath());
}


XMLConfigReader myReader;
myOMTFConfig = new OMTFConfiguration(theConfig);
XMLConfigReader myReader(myOMTFConfig);

myReader.setConfigFile(fName);
readConnectionsXML(&myReader);

///Have to fill OMTFConfiguration data to be able to read the Golden Patterns file, as there are
///some consistency checks during XML parsing.
myOMTFConfig = new OMTFConfiguration(theConfig);
myOMTFConfig->configure(&m_params);

for(auto it: fileNames){
12 changes: 6 additions & 6 deletions L1Trigger/L1TMuonOverlap/plugins/OMTFPatternMaker.cc
Original file line number Diff line number Diff line change
@@ -76,7 +76,7 @@ void OMTFPatternMaker::beginRun(edm::Run const& run, edm::EventSetup const& iSet

///For making the patterns use extended pdf width in phi
////Ugly hack to modify configuration parameters at runtime.
omtf_config_->nPdfAddrBits = 14;
myOMTFConfig->nPdfAddrBits = 14;

///Clear existing GoldenPatterns
const std::map<Key,GoldenPattern*> & theGPs = myOMTF->getPatterns();
@@ -89,8 +89,8 @@ void OMTFPatternMaker::beginJob(){

if(theConfig.exists("omtf")){
myOMTFConfig = new OMTFConfiguration(theConfig.getParameter<edm::ParameterSet>("omtf"));
myOMTFConfigMaker = new OMTFConfigMaker(theConfig.getParameter<edm::ParameterSet>("omtf"));
myOMTF = new OMTFProcessor(theConfig.getParameter<edm::ParameterSet>("omtf"));
myOMTFConfigMaker = new OMTFConfigMaker(theConfig.getParameter<edm::ParameterSet>("omtf"), myOMTFConfig);
myOMTF = new OMTFProcessor(theConfig.getParameter<edm::ParameterSet>("omtf"), myOMTFConfig);
}
}
/////////////////////////////////////////////////////
@@ -106,8 +106,8 @@ void OMTFPatternMaker::endJob(){
itGP.second->normalise();
}

////Ugly hack to modify configuration parameters at runtime.
omtf_config_->nPdfAddrBits = 7;
////Ugly hack to modify configuration parameters at runtime.
myOMTFConfig->nPdfAddrBits = 7;
for(auto itGP: myGPmap){
////
unsigned int iPt = theConfig.getParameter<int>("ptCode")+1;
@@ -135,7 +135,7 @@ void OMTFPatternMaker::endJob(){
myOMTFConfigMaker->printConnections(std::cout,iProcessor,3);
myOMTFConfigMaker->printConnections(std::cout,iProcessor,4);
myOMTFConfigMaker->printConnections(std::cout,iProcessor,5);
myWriter->writeConnectionsData(omtf_config_->measurements4D);
myWriter->writeConnectionsData(OMTFConfiguration::instance()->measurements4D);
myWriter->finaliseXMLDocument(fName);
}

12 changes: 6 additions & 6 deletions L1Trigger/L1TMuonOverlap/src/AngleConverter.cc
Original file line number Diff line number Diff line change
@@ -42,8 +42,8 @@ void AngleConverter::checkAndUpdateGeometry(const edm::EventSetup& es) {
int AngleConverter::getProcessorPhi(unsigned int iProcessor, l1t::tftype part, const L1MuDTChambPhDigi &digi) const
{

double hsPhiPitch = 2*M_PI/omtf_config_->nPhiBins; // width of phi Pitch, related to halfStrip at CSC station 2
const int dummy = omtf_config_->nPhiBins;
double hsPhiPitch = 2*M_PI/OMTFConfiguration::instance()->nPhiBins; // width of phi Pitch, related to halfStrip at CSC station 2
const int dummy = OMTFConfiguration::instance()->nPhiBins;

int processor= iProcessor+1; // FIXME: get from OMTF name when available
int posneg = (part==l1t::tftype::omtf_pos) ? 1 : -1; // FIXME: get from OMTF name
@@ -76,8 +76,8 @@ int AngleConverter::getProcessorPhi(unsigned int iProcessor, l1t::tftype part, c
int AngleConverter::getProcessorPhi(unsigned int iProcessor, l1t::tftype part, const CSCDetId & csc, const CSCCorrelatedLCTDigi &digi) const
{

const double hsPhiPitch = 2*M_PI/omtf_config_->nPhiBins; //
const int dummy = omtf_config_->nPhiBins;
const double hsPhiPitch = 2*M_PI/OMTFConfiguration::instance()->nPhiBins; //
const int dummy = OMTFConfiguration::instance()->nPhiBins;

int processor= iProcessor+1; // FIXME: get from OMTF name when available
int posneg = (part==l1t::tftype::omtf_pos) ? 1 : -1; // FIXME: get from OMTF name
@@ -127,8 +127,8 @@ int AngleConverter::getProcessorPhi(unsigned int iProcessor, l1t::tftype part, c
///////////////////////////////////////
int AngleConverter::getProcessorPhi(unsigned int iProcessor, l1t::tftype part, const RPCDetId & rollId, const unsigned int &digi) const
{
const double hsPhiPitch = 2*M_PI/omtf_config_->nPhiBins; //
const int dummy = omtf_config_->nPhiBins;
const double hsPhiPitch = 2*M_PI/OMTFConfiguration::instance()->nPhiBins; //
const int dummy = OMTFConfiguration::instance()->nPhiBins;

int processor = iProcessor+1;
const RPCRoll* roll = _georpc->roll(rollId);
2 changes: 1 addition & 1 deletion L1Trigger/L1TMuonOverlap/src/GhostBuster.cc
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ void OMTFGhostBuster::select(std::vector<AlgoMuon> & refHitCands, int charge){
it2 != refHitCleanCands.end(); ++it2){
//do not accept candidates with similar phi (any charge combination)
//veto window 5deg(=half of logic cone)=5/360*5760=80"logic strips"
if(std::abs(it1->getPhi() - it2->getPhi())<5/360.0*omtf_config_->nPhiBins){
if(std::abs(it1->getPhi() - it2->getPhi())<5/360.0*OMTFConfiguration::instance()->nPhiBins){
isGhost=true;
break;
}
58 changes: 29 additions & 29 deletions L1Trigger/L1TMuonOverlap/src/GoldenPattern.cc
Original file line number Diff line number Diff line change
@@ -18,22 +18,22 @@ GoldenPattern::layerResult GoldenPattern::process1Layer1RefLayer(unsigned int iR
GoldenPattern::layerResult aResult;

int phiMean = meanDistPhi[iLayer][iRefLayer];
int phiDist = exp2(omtf_config_->nPdfAddrBits);
int phiDist = exp2(OMTFConfiguration::instance()->nPdfAddrBits);
///Select hit closest to the mean of probability
///distribution in given layer
for(auto itHit: layerHits){
if(itHit>=(int)omtf_config_->nPhiBins) continue;
if(itHit>=(int)OMTFConfiguration::instance()->nPhiBins) continue;
if(abs(itHit-phiMean-phiRefHit)<abs(phiDist)) phiDist = itHit-phiMean-phiRefHit;
}

///Shift phidist, so 0 is at the middle of the range
phiDist+=exp2(omtf_config_->nPdfAddrBits-1);
phiDist+=exp2(OMTFConfiguration::instance()->nPdfAddrBits-1);

///Check if phiDist is within pdf range
///in -64 +63 U2 code
///Find more elegant way to check this.
if(phiDist<0 ||
phiDist>exp2(omtf_config_->nPdfAddrBits)-1){
phiDist>exp2(OMTFConfiguration::instance()->nPdfAddrBits)-1){
return aResult;
}

@@ -57,32 +57,32 @@ void GoldenPattern::addCount(unsigned int iRefLayer,
const OMTFinput::vector1D & layerHits){

int nHitsInLayer = 0;
int phiDist = exp2(omtf_config_->nPdfAddrBits);
int phiDist = exp2(OMTFConfiguration::instance()->nPdfAddrBits);

for(auto itHit: layerHits){
if(itHit>=(int)omtf_config_->nPhiBins) continue;
if(itHit>=(int)OMTFConfiguration::instance()->nPhiBins) continue;
if(abs(itHit-phiRefHit)<phiDist) phiDist = itHit-phiRefHit;
++nHitsInLayer;
}
///For making the patterns take events with a single hit in each layer
if(nHitsInLayer>1 || nHitsInLayer==0) return;

///Shift phiDist so it is in +-Pi range
if(phiDist>=(int)omtf_config_->nPhiBins/2) phiDist-=(int)omtf_config_->nPhiBins;
if(phiDist<=-(int)omtf_config_->nPhiBins/2) phiDist+=(int)omtf_config_->nPhiBins;
if(phiDist>=(int)OMTFConfiguration::instance()->nPhiBins/2) phiDist-=(int)OMTFConfiguration::instance()->nPhiBins;
if(phiDist<=-(int)OMTFConfiguration::instance()->nPhiBins/2) phiDist+=(int)OMTFConfiguration::instance()->nPhiBins;

///Shift phidist, so 0 is at the middle of the range
int phiDistShift=phiDist+exp2(omtf_config_->nPdfAddrBits-1);
int phiDistShift=phiDist+exp2(OMTFConfiguration::instance()->nPdfAddrBits-1);

///Check if phiDist is within pdf range
///in -64 +63 U2 code
///Find more elegant way to check this.
if(phiDistShift<0 ||
phiDistShift>exp2(omtf_config_->nPdfAddrBits)-1){
phiDistShift>exp2(OMTFConfiguration::instance()->nPdfAddrBits)-1){
return;
}

if((int)iLayer==omtf_config_->refToLogicNumber[iRefLayer]) ++meanDistPhiCounts[iLayer][iRefLayer];
if((int)iLayer==OMTFConfiguration::instance()->refToLogicNumber[iRefLayer]) ++meanDistPhiCounts[iLayer][iRefLayer];
++pdfAllRef[iLayer][iRefLayer][phiDistShift];
}
////////////////////////////////////////////////////
@@ -122,7 +122,7 @@ std::ostream & operator << (std::ostream &out, const GoldenPattern & aPattern){
out<<"Ref layer: "<<iRefLayer;
for (unsigned int iLayer=0;iLayer<aPattern.pdfAllRef.size();++iLayer){
out<<", measurement layer: "<<iLayer<<std::endl;
for (unsigned int iPdf=0;iPdf<exp2(omtf_config_->nPdfAddrBits);++iPdf){
for (unsigned int iPdf=0;iPdf<exp2(OMTFConfiguration::instance()->nPdfAddrBits);++iPdf){
out<<std::setw(2)<<aPattern.pdfAllRef[iLayer][iRefLayer][iPdf]<<" ";
}
out<<std::endl;
@@ -135,18 +135,18 @@ std::ostream & operator << (std::ostream &out, const GoldenPattern & aPattern){
////////////////////////////////////////////////////
void GoldenPattern::reset(){

GoldenPattern::vector1D meanDistPhi1D(omtf_config_->nRefLayers);
GoldenPattern::vector2D meanDistPhi2D(omtf_config_->nLayers);
meanDistPhi2D.assign(omtf_config_->nLayers, meanDistPhi1D);
GoldenPattern::vector1D meanDistPhi1D(OMTFConfiguration::instance()->nRefLayers);
GoldenPattern::vector2D meanDistPhi2D(OMTFConfiguration::instance()->nLayers);
meanDistPhi2D.assign(OMTFConfiguration::instance()->nLayers, meanDistPhi1D);
meanDistPhi = meanDistPhi2D;
meanDistPhiCounts = meanDistPhi2D;

GoldenPattern::vector1D pdf1D(exp2(omtf_config_->nPdfAddrBits));
GoldenPattern::vector2D pdf2D(omtf_config_->nRefLayers);
GoldenPattern::vector3D pdf3D(omtf_config_->nLayers);
GoldenPattern::vector1D pdf1D(exp2(OMTFConfiguration::instance()->nPdfAddrBits));
GoldenPattern::vector2D pdf2D(OMTFConfiguration::instance()->nRefLayers);
GoldenPattern::vector3D pdf3D(OMTFConfiguration::instance()->nLayers);

pdf2D.assign(omtf_config_->nRefLayers,pdf1D);
pdfAllRef.assign(omtf_config_->nLayers,pdf2D);
pdf2D.assign(OMTFConfiguration::instance()->nRefLayers,pdf1D);
pdfAllRef.assign(OMTFConfiguration::instance()->nLayers,pdf2D);

}
////////////////////////////////////////////////////
@@ -156,10 +156,10 @@ void GoldenPattern::normalise(){
for (unsigned int iRefLayer=0;iRefLayer<pdfAllRef[0].size();++iRefLayer){
for (unsigned int iLayer=0;iLayer<pdfAllRef.size();++iLayer){
for (unsigned int iPdf=0;iPdf<pdfAllRef[iLayer][iRefLayer].size();++iPdf){
float pVal = log((float)pdfAllRef[iLayer][iRefLayer][iPdf]/meanDistPhiCounts[omtf_config_->refToLogicNumber[iRefLayer]][iRefLayer]);
if(pVal<log(omtf_config_->minPdfVal)) continue;
meanDistPhi[iLayer][iRefLayer]+=(iPdf - exp2(omtf_config_->nPdfAddrBits-1))*pdfAllRef[iLayer][iRefLayer][iPdf];
if((int)iLayer!=omtf_config_->refToLogicNumber[iRefLayer]) meanDistPhiCounts[iLayer][iRefLayer]+=pdfAllRef[iLayer][iRefLayer][iPdf];
float pVal = log((float)pdfAllRef[iLayer][iRefLayer][iPdf]/meanDistPhiCounts[OMTFConfiguration::instance()->refToLogicNumber[iRefLayer]][iRefLayer]);
if(pVal<log(OMTFConfiguration::instance()->minPdfVal)) continue;
meanDistPhi[iLayer][iRefLayer]+=(iPdf - exp2(OMTFConfiguration::instance()->nPdfAddrBits-1))*pdfAllRef[iLayer][iRefLayer][iPdf];
if((int)iLayer!=OMTFConfiguration::instance()->refToLogicNumber[iRefLayer]) meanDistPhiCounts[iLayer][iRefLayer]+=pdfAllRef[iLayer][iRefLayer][iPdf];
}
}
}
@@ -174,17 +174,17 @@ void GoldenPattern::normalise(){
}
}

const float minPlog = log(omtf_config_->minPdfVal);
const unsigned int nPdfValBits = omtf_config_->nPdfValBits;
const float minPlog = log(OMTFConfiguration::instance()->minPdfVal);
const unsigned int nPdfValBits = OMTFConfiguration::instance()->nPdfValBits;
///Probabilities. Normalise and change from float to integer values
float pVal;
int digitisedVal, truncatedValue;
for (unsigned int iRefLayer=0;iRefLayer<pdfAllRef[0].size();++iRefLayer){
for (unsigned int iLayer=0;iLayer<pdfAllRef.size();++iLayer){
for (unsigned int iPdf=0;iPdf<pdfAllRef[iLayer][iRefLayer].size();++iPdf){
if(!meanDistPhiCounts[omtf_config_->refToLogicNumber[iRefLayer]][iRefLayer] ||
if(!meanDistPhiCounts[OMTFConfiguration::instance()->refToLogicNumber[iRefLayer]][iRefLayer] ||
!pdfAllRef[iLayer][iRefLayer][iPdf]) continue;
pVal = log((float)pdfAllRef[iLayer][iRefLayer][iPdf]/meanDistPhiCounts[omtf_config_->refToLogicNumber[iRefLayer]][iRefLayer]);
pVal = log((float)pdfAllRef[iLayer][iRefLayer][iPdf]/meanDistPhiCounts[OMTFConfiguration::instance()->refToLogicNumber[iRefLayer]][iRefLayer]);
///If there are only a few counts in given measurement layer, set pdf value to 0
if(pVal<minPlog || meanDistPhiCounts[iLayer][iRefLayer]<1000){
pdfAllRef[iLayer][iRefLayer][iPdf] = 0;
@@ -210,7 +210,7 @@ void GoldenPattern::normalise(){
for (unsigned int iPdf=0;iPdf<pdfAllRef[iLayer][iRefLayer].size();++iPdf){
pdfAllRef[iLayer][iRefLayer][iPdf] = 0;
///Shift pdf index by meanDistPhi
int index = iPdf - exp2(omtf_config_->nPdfAddrBits-1) - meanDistPhi[iLayer][iRefLayer] + exp2(nPdfAddrBits-1);
int index = iPdf - exp2(OMTFConfiguration::instance()->nPdfAddrBits-1) - meanDistPhi[iLayer][iRefLayer] + exp2(nPdfAddrBits-1);
if(index<0 || index>exp2(nPdfAddrBits)-1) continue;
pdfAllRef[iLayer][iRefLayer][index] = pdfAllRefTmp[iLayer][iRefLayer][iPdf];
}
Loading

0 comments on commit 2df598b

Please sign in to comment.