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];
}
53 changes: 26 additions & 27 deletions L1Trigger/L1TMuonOverlap/src/OMTFConfigMaker.cc
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
#include <iostream>

#include "L1Trigger/L1TMuonOverlap/interface/OMTFConfigMaker.h"
#include "L1Trigger/L1TMuonOverlap/interface/OMTFConfiguration.h"
#include "L1Trigger/L1TMuonOverlap/interface/GoldenPattern.h"
#include "L1Trigger/L1TMuonOverlap/interface/XMLConfigReader.h"
#include "L1Trigger/L1TMuonOverlap/interface/OMTFinput.h"
@@ -11,13 +10,13 @@

///////////////////////////////////////////////
///////////////////////////////////////////////
OMTFConfigMaker::OMTFConfigMaker(const edm::ParameterSet & theConfig){
OMTFConfigMaker::OMTFConfigMaker(const edm::ParameterSet & theConfig, OMTFConfiguration * omtf_config) : m_omtf_config(omtf_config) {

std::vector<int> refPhi1D(omtf_config_->nLogicRegions,2*omtf_config_->nPhiBins);
minRefPhi2D.assign(omtf_config_->nRefLayers,refPhi1D);
std::vector<int> refPhi1D(OMTFConfiguration::instance()->nLogicRegions,2*OMTFConfiguration::instance()->nPhiBins);
minRefPhi2D.assign(OMTFConfiguration::instance()->nRefLayers,refPhi1D);

refPhi1D = std::vector<int>(omtf_config_->nLogicRegions,-2*omtf_config_->nPhiBins);
maxRefPhi2D.assign(omtf_config_->nRefLayers,refPhi1D);
refPhi1D = std::vector<int>(OMTFConfiguration::instance()->nLogicRegions,-2*OMTFConfiguration::instance()->nPhiBins);
maxRefPhi2D.assign(OMTFConfiguration::instance()->nRefLayers,refPhi1D);

}
///////////////////////////////////////////////
@@ -35,13 +34,13 @@ void OMTFConfigMaker::fillPhiMaps(unsigned int iProcessor,
const OMTFinput & aInput){

////Find starting and ending iPhi of each input used for reference hits.
for(unsigned int iRefLayer=0;iRefLayer<omtf_config_->nRefLayers;++iRefLayer){
const OMTFinput::vector1D & refLayerHits = aInput.getLayerData(omtf_config_->refToLogicNumber[iRefLayer]);
for(unsigned int iRefLayer=0;iRefLayer<OMTFConfiguration::instance()->nRefLayers;++iRefLayer){
const OMTFinput::vector1D & refLayerHits = aInput.getLayerData(OMTFConfiguration::instance()->refToLogicNumber[iRefLayer]);
if(!refLayerHits.size()) continue;
for(unsigned int iInput=0;iInput<omtf_config_->nInputs;++iInput){
for(unsigned int iInput=0;iInput<OMTFConfiguration::instance()->nInputs;++iInput){
int phiRef = refLayerHits[iInput];
unsigned int iRegion = omtf_config_->getRegionNumberFromMap(iInput,iRefLayer,phiRef);
if(phiRef>=(int)omtf_config_->nPhiBins) continue;
unsigned int iRegion = OMTFConfiguration::instance()->getRegionNumberFromMap(iInput,iRefLayer,phiRef);
if(phiRef>=(int)OMTFConfiguration::instance()->nPhiBins) continue;
if(phiRef<minRefPhi2D[iRefLayer][iRegion]) minRefPhi2D[iRefLayer][iRegion] = phiRef;
if(phiRef>maxRefPhi2D[iRefLayer][iRegion]) maxRefPhi2D[iRefLayer][iRegion] = phiRef;
}
@@ -52,17 +51,17 @@ void OMTFConfigMaker::fillPhiMaps(unsigned int iProcessor,
void OMTFConfigMaker::printPhiMap(std::ostream & out){

out<<"min Phi in each logicRegion (X) in each ref Layer (Y): "<<std::endl;
for(unsigned int iRefLayer=0;iRefLayer<omtf_config_->nRefLayers;++iRefLayer){
for(unsigned int iLogicRegion=0;iLogicRegion<omtf_config_->nLogicRegions;++iLogicRegion){
for(unsigned int iRefLayer=0;iRefLayer<OMTFConfiguration::instance()->nRefLayers;++iRefLayer){
for(unsigned int iLogicRegion=0;iLogicRegion<OMTFConfiguration::instance()->nLogicRegions;++iLogicRegion){
out<<" "<<minRefPhi2D[iRefLayer][iLogicRegion]<<"\t";
}
out<<std::endl;
}
out<<std::endl;

out<<"max Phi in each logicRegion (X) in each ref Layer (Y): "<<std::endl;
for(unsigned int iRefLayer=0;iRefLayer<omtf_config_->nRefLayers;++iRefLayer){
for(unsigned int iLogicRegion=0;iLogicRegion<omtf_config_->nLogicRegions;++iLogicRegion){
for(unsigned int iRefLayer=0;iRefLayer<OMTFConfiguration::instance()->nRefLayers;++iRefLayer){
for(unsigned int iLogicRegion=0;iLogicRegion<OMTFConfiguration::instance()->nLogicRegions;++iLogicRegion){
out<<" "<<maxRefPhi2D[iRefLayer][iLogicRegion]<<"\t";
}
out<<std::endl;
@@ -77,14 +76,14 @@ void OMTFConfigMaker::makeConnetionsMap(unsigned int iProcessor,

fillPhiMaps(iProcessor,aInput);

for(unsigned int iRefLayer=0;iRefLayer<omtf_config_->nRefLayers;++iRefLayer){
const OMTFinput::vector1D & refLayerHits = aInput.getLayerData(omtf_config_->refToLogicNumber[iRefLayer]);
for(unsigned int iRefLayer=0;iRefLayer<OMTFConfiguration::instance()->nRefLayers;++iRefLayer){
const OMTFinput::vector1D & refLayerHits = aInput.getLayerData(OMTFConfiguration::instance()->refToLogicNumber[iRefLayer]);
if(!refLayerHits.size()) continue;
//////////////////////
for(unsigned int iInput=0;iInput<refLayerHits.size();++iInput){
int phiRef = refLayerHits[iInput];
unsigned int iRegion = omtf_config_->getRegionNumberFromMap(iInput,iRefLayer,phiRef);
if(iRegion>=omtf_config_->nLogicRegions) continue;
unsigned int iRegion = OMTFConfiguration::instance()->getRegionNumberFromMap(iInput,iRefLayer,phiRef);
if(iRegion>=OMTFConfiguration::instance()->nLogicRegions) continue;
fillInputRange(iProcessor,iRegion,aInput);
fillInputRange(iProcessor,iRegion,iRefLayer,iInput);
///Always use two hits from a single chamber.
@@ -100,11 +99,11 @@ void OMTFConfigMaker::fillInputRange(unsigned int iProcessor,
unsigned int iRegion,
const OMTFinput & aInput){

for(unsigned int iLogicLayer=0;iLogicLayer<omtf_config_->nLayers;++iLogicLayer){
for(unsigned int iLogicLayer=0;iLogicLayer<OMTFConfiguration::instance()->nLayers;++iLogicLayer){

for(unsigned int iInput=0;iInput<14;++iInput){
bool isHit = aInput.getLayerData(iLogicLayer)[iInput]<(int)omtf_config_->nPhiBins;
omtf_config_->measurements4D[iProcessor][iRegion][iLogicLayer][iInput]+=isHit;
bool isHit = aInput.getLayerData(iLogicLayer)[iInput]<(int)OMTFConfiguration::instance()->nPhiBins;
m_omtf_config->measurements4D[iProcessor][iRegion][iLogicLayer][iInput]+=isHit;
}
}
}
@@ -115,7 +114,7 @@ void OMTFConfigMaker::fillInputRange(unsigned int iProcessor,
unsigned int iRefLayer,
unsigned int iInput){

++omtf_config_->measurements4Dref[iProcessor][iRegion][iRefLayer][iInput];
++m_omtf_config->measurements4Dref[iProcessor][iRegion][iRefLayer][iInput];

}
///////////////////////////////////////////////
@@ -129,19 +128,19 @@ void OMTFConfigMaker::printConnections(std::ostream & out,
<<std::endl;

out<<"Ref hits"<<std::endl;
for(unsigned int iLogicLayer=0;iLogicLayer<omtf_config_->nLayers;++iLogicLayer){
for(unsigned int iLogicLayer=0;iLogicLayer<OMTFConfiguration::instance()->nLayers;++iLogicLayer){
out<<"Logic layer: "<<iLogicLayer<<" Hits: ";
for(unsigned int iInput=0;iInput<14;++iInput){
out<<omtf_config_->measurements4Dref[iProcessor][iRegion][iLogicLayer][iInput]<<"\t";
out<<OMTFConfiguration::instance()->measurements4Dref[iProcessor][iRegion][iLogicLayer][iInput]<<"\t";
}
out<<std::endl;
}
/*
out<<"Measurement hits"<<std::endl;
for(unsigned int iLogicLayer=0;iLogicLayer<omtf_config_->nLayers;++iLogicLayer){
for(unsigned int iLogicLayer=0;iLogicLayer<OMTFConfiguration::instance()->nLayers;++iLogicLayer){
out<<"Logic layer: "<<iLogicLayer<<" Hits: ";
for(unsigned int iInput=0;iInput<14;++iInput){
out<<omtf_config_->measurements4D[iProcessor][iRegion][iLogicLayer][iInput]<<"\t";
out<<OMTFConfiguration::instance()->measurements4D[iProcessor][iRegion][iLogicLayer][iInput]<<"\t";
}
out<<std::endl;
}
14 changes: 7 additions & 7 deletions L1Trigger/L1TMuonOverlap/src/OMTFConfiguration.cc
Original file line number Diff line number Diff line change
@@ -14,7 +14,7 @@
#include "L1Trigger/L1TMuonOverlap/interface/OMTFConfiguration.h"
#include "L1Trigger/L1TMuonOverlap/interface/XMLConfigReader.h"

OMTFConfiguration * omtf_config_ = NULL;
OMTFConfiguration * OMTFConfiguration::latest_instance_ = NULL;

///////////////////////////////////////////////
///////////////////////////////////////////////
@@ -50,13 +50,13 @@ std::ostream & operator << (std::ostream &out, const RefHitDef & aRefHitDef){
///////////////////////////////////////////////
///////////////////////////////////////////////
OMTFConfiguration::OMTFConfiguration(const edm::ParameterSet & theConfig){
omtf_config_ = this;
latest_instance_ = this;

if(theConfig.getParameter<bool>("configFromXML")){
if (!theConfig.exists("configXMLFile") ) return;
std::string fName = theConfig.getParameter<edm::FileInPath>("configXMLFile").fullPath();

XMLConfigReader myReader;
XMLConfigReader myReader(this);
myReader.setConfigFile(fName);
configure(&myReader);
}
@@ -234,7 +234,7 @@ std::ostream & operator << (std::ostream &out, const OMTFConfiguration & aConfig
///////////////////////////////////////////////
bool OMTFConfiguration::isInRegionRange(int iPhiStart,
unsigned int coneSize,
int iPhi){
int iPhi) const {

if(iPhi<0) iPhi+=nPhiBins;
if(iPhiStart<0) iPhiStart+=nPhiBins;
@@ -254,7 +254,7 @@ bool OMTFConfiguration::isInRegionRange(int iPhiStart,
///////////////////////////////////////////////
unsigned int OMTFConfiguration::getRegionNumberFromMap(unsigned int iInput,
unsigned int iRefLayer,
int iPhi){
int iPhi) const {

for(unsigned int iRegion=0;iRegion<nLogicRegions;++iRegion){
if(iPhi>=regionPhisVsRefLayerVsInput[iInput][iRefLayer][iRegion].first &&
@@ -266,15 +266,15 @@ unsigned int OMTFConfiguration::getRegionNumberFromMap(unsigned int iInput,
}
///////////////////////////////////////////////
///////////////////////////////////////////////
int OMTFConfiguration::globalPhiStart(unsigned int iProcessor){
int OMTFConfiguration::globalPhiStart(unsigned int iProcessor) const {

return *std::min_element(processorPhiVsRefLayer[iProcessor].begin(),
processorPhiVsRefLayer[iProcessor].end());

}
///////////////////////////////////////////////
///////////////////////////////////////////////
uint32_t OMTFConfiguration::getLayerNumber(uint32_t rawId){
uint32_t OMTFConfiguration::getLayerNumber(uint32_t rawId) const {

uint32_t aLayer = 0;

83 changes: 41 additions & 42 deletions L1Trigger/L1TMuonOverlap/src/OMTFProcessor.cc
Original file line number Diff line number Diff line change
@@ -10,7 +10,6 @@
#include "CondFormats/L1TObjects/interface/L1TMuonOverlapParams.h"

#include "L1Trigger/L1TMuonOverlap/interface/OMTFProcessor.h"
#include "L1Trigger/L1TMuonOverlap/interface/OMTFConfiguration.h"
#include "L1Trigger/L1TMuonOverlap/interface/GoldenPattern.h"
#include "L1Trigger/L1TMuonOverlap/interface/XMLConfigReader.h"
#include "L1Trigger/L1TMuonOverlap/interface/OMTFinput.h"
@@ -21,7 +20,7 @@
#include "SimDataFormats/Track/interface/SimTrack.h"
///////////////////////////////////////////////
///////////////////////////////////////////////
OMTFProcessor::OMTFProcessor(const edm::ParameterSet & theConfig){
OMTFProcessor::OMTFProcessor(const edm::ParameterSet & theConfig, OMTFConfiguration * omtf_config) : m_omtf_config(omtf_config) {

if(theConfig.getParameter<bool>("configFromXML")){
if ( !theConfig.exists("patternsXMLFiles") ) return;
@@ -30,7 +29,7 @@ OMTFProcessor::OMTFProcessor(const edm::ParameterSet & theConfig){
fileNames.push_back(it.getParameter<edm::FileInPath>("patternsXMLFile").fullPath());
}
resetConfiguration();
XMLConfigReader myReader;
XMLConfigReader myReader(m_omtf_config);
for(auto it: fileNames){
myReader.setPatternsFile(it);
configure(&myReader);
@@ -57,7 +56,7 @@ bool OMTFProcessor::configure(XMLConfigReader *aReader){

resetConfiguration();

myResults.assign(omtf_config_->nTestRefHits,OMTFProcessor::resultsMap());
myResults.assign(OMTFConfiguration::instance()->nTestRefHits,OMTFProcessor::resultsMap());

const std::vector<GoldenPattern *> & aGPs = aReader->readPatterns();
for(auto it: aGPs){
@@ -72,41 +71,41 @@ bool OMTFProcessor::configure(const L1TMuonOverlapParams* omtfParams){

resetConfiguration();

myResults.assign(omtf_config_->nTestRefHits,OMTFProcessor::resultsMap());
myResults.assign(OMTFConfiguration::instance()->nTestRefHits,OMTFProcessor::resultsMap());

const l1t::LUT* chargeLUT = omtfParams->chargeLUT();
const l1t::LUT* etaLUT = omtfParams->etaLUT();
const l1t::LUT* ptLUT = omtfParams->ptLUT();
const l1t::LUT* pdfLUT = omtfParams->pdfLUT();
const l1t::LUT* meanDistPhiLUT = omtfParams->meanDistPhiLUT();

unsigned int nGPs = omtf_config_->nGoldenPatterns;
unsigned int nGPs = OMTFConfiguration::instance()->nGoldenPatterns;
unsigned int address = 0;
unsigned int iEta, iPt, iCharge;
for(unsigned int iGP=0;iGP<nGPs;++iGP){
address = iGP;
iEta = etaLUT->data(address);
iCharge = chargeLUT->data(address)==0? -1:1;
iPt = ptLUT->data(address);
GoldenPattern::vector2D meanDistPhi2D(omtf_config_->nLayers);
GoldenPattern::vector1D pdf1D(exp2(omtf_config_->nPdfAddrBits));
GoldenPattern::vector3D pdf3D(omtf_config_->nLayers);
GoldenPattern::vector2D pdf2D(omtf_config_->nRefLayers);
GoldenPattern::vector2D meanDistPhi2D(OMTFConfiguration::instance()->nLayers);
GoldenPattern::vector1D pdf1D(exp2(OMTFConfiguration::instance()->nPdfAddrBits));
GoldenPattern::vector3D pdf3D(OMTFConfiguration::instance()->nLayers);
GoldenPattern::vector2D pdf2D(OMTFConfiguration::instance()->nRefLayers);
///Mean dist phi data
for(unsigned int iLayer=0;iLayer<omtf_config_->nLayers;++iLayer){
GoldenPattern::vector1D meanDistPhi1D(omtf_config_->nRefLayers);
for(unsigned int iRefLayer=0;iRefLayer<omtf_config_->nRefLayers;++iRefLayer){
address = iRefLayer + iLayer*omtf_config_->nRefLayers + iGP*(omtf_config_->nRefLayers*omtf_config_->nLayers);
for(unsigned int iLayer=0;iLayer<OMTFConfiguration::instance()->nLayers;++iLayer){
GoldenPattern::vector1D meanDistPhi1D(OMTFConfiguration::instance()->nRefLayers);
for(unsigned int iRefLayer=0;iRefLayer<OMTFConfiguration::instance()->nRefLayers;++iRefLayer){
address = iRefLayer + iLayer*OMTFConfiguration::instance()->nRefLayers + iGP*(OMTFConfiguration::instance()->nRefLayers*OMTFConfiguration::instance()->nLayers);
meanDistPhi1D[iRefLayer] = meanDistPhiLUT->data(address) - (1<<(meanDistPhiLUT->nrBitsData() -1));
}
meanDistPhi2D[iLayer] = meanDistPhi1D;
///Pdf data
for(unsigned int iRefLayer=0;iRefLayer<omtf_config_->nRefLayers;++iRefLayer){
pdf1D.assign(1<<omtf_config_->nPdfAddrBits,0);
for(unsigned int iPdf=0;iPdf<(unsigned int)(1<<omtf_config_->nPdfAddrBits);++iPdf){
address = iPdf + iRefLayer*(1<<omtf_config_->nPdfAddrBits) +
iLayer*omtf_config_->nRefLayers*(1<<omtf_config_->nPdfAddrBits) +
iGP*omtf_config_->nLayers*omtf_config_->nRefLayers*(1<<omtf_config_->nPdfAddrBits);
for(unsigned int iRefLayer=0;iRefLayer<OMTFConfiguration::instance()->nRefLayers;++iRefLayer){
pdf1D.assign(1<<OMTFConfiguration::instance()->nPdfAddrBits,0);
for(unsigned int iPdf=0;iPdf<(unsigned int)(1<<OMTFConfiguration::instance()->nPdfAddrBits);++iPdf){
address = iPdf + iRefLayer*(1<<OMTFConfiguration::instance()->nPdfAddrBits) +
iLayer*OMTFConfiguration::instance()->nRefLayers*(1<<OMTFConfiguration::instance()->nPdfAddrBits) +
iGP*OMTFConfiguration::instance()->nLayers*OMTFConfiguration::instance()->nRefLayers*(1<<OMTFConfiguration::instance()->nPdfAddrBits);
pdf1D[iPdf] = pdfLUT->data(address);
}
pdf2D[iRefLayer] = pdf1D;
@@ -182,8 +181,8 @@ void OMTFProcessor::averagePatterns(int charge){
GoldenPattern::vector2D meanDistPhi3 = aGP3->getMeanDistPhi();
GoldenPattern::vector2D meanDistPhi4 = aGP4->getMeanDistPhi();

for(unsigned int iLayer=0;iLayer<omtf_config_->nLayers;++iLayer){
for(unsigned int iRefLayer=0;iRefLayer<omtf_config_->nRefLayers;++iRefLayer){
for(unsigned int iLayer=0;iLayer<OMTFConfiguration::instance()->nLayers;++iLayer){
for(unsigned int iRefLayer=0;iRefLayer<OMTFConfiguration::instance()->nRefLayers;++iRefLayer){
meanDistPhi[iLayer][iRefLayer]+=meanDistPhi2[iLayer][iRefLayer];
meanDistPhi[iLayer][iRefLayer]+=meanDistPhi3[iLayer][iRefLayer];
meanDistPhi[iLayer][iRefLayer]+=meanDistPhi4[iLayer][iRefLayer];
@@ -214,13 +213,13 @@ void OMTFProcessor::shiftGP(GoldenPattern *aGP,

///Shift pdfs by differecne between original menaDistPhi, and
///the averaged value
unsigned int nPdfBins = exp2(omtf_config_->nPdfAddrBits);
unsigned int nPdfBins = exp2(OMTFConfiguration::instance()->nPdfAddrBits);

GoldenPattern::vector3D pdfAllRef = aGP->getPdf();

int indexShift = 0;
for(unsigned int iLayer=0;iLayer<omtf_config_->nLayers;++iLayer){
for(unsigned int iRefLayer=0;iRefLayer<omtf_config_->nRefLayers;++iRefLayer){
for(unsigned int iLayer=0;iLayer<OMTFConfiguration::instance()->nLayers;++iLayer){
for(unsigned int iRefLayer=0;iRefLayer<OMTFConfiguration::instance()->nRefLayers;++iRefLayer){
indexShift = meanDistPhiOld[iLayer][iRefLayer] - meanDistPhiNew[iLayer][iRefLayer];
for(unsigned int iPdfBin=0;iPdfBin<nPdfBins;++iPdfBin) pdfAllRef[iLayer][iRefLayer][iPdfBin] = 0;
for(unsigned int iPdfBin=0;iPdfBin<nPdfBins;++iPdfBin){
@@ -246,22 +245,22 @@ const std::vector<OMTFProcessor::resultsMap> & OMTFProcessor::processInput(unsig
std::bitset<128> refHitsBits = aInput.getRefHits(iProcessor);
if(refHitsBits.none()) return myResults;

for(unsigned int iLayer=0;iLayer<omtf_config_->nLayers;++iLayer){
for(unsigned int iLayer=0;iLayer<OMTFConfiguration::instance()->nLayers;++iLayer){
const OMTFinput::vector1D & layerHits = aInput.getLayerData(iLayer);
if(!layerHits.size()) continue;
///Number of reference hits to be checked.
///Value read from XML configuration
unsigned int nTestedRefHits = omtf_config_->nTestRefHits;
for(unsigned int iRefHit=0;iRefHit<omtf_config_->nRefHits;++iRefHit){
unsigned int nTestedRefHits = OMTFConfiguration::instance()->nTestRefHits;
for(unsigned int iRefHit=0;iRefHit<OMTFConfiguration::instance()->nRefHits;++iRefHit){
if(!refHitsBits[iRefHit]) continue;
if(nTestedRefHits--==0) break;
const RefHitDef & aRefHitDef = omtf_config_->refHitsDefs[iProcessor][iRefHit];
const RefHitDef & aRefHitDef = OMTFConfiguration::instance()->refHitsDefs[iProcessor][iRefHit];

int phiRef = aInput.getLayerData(omtf_config_->refToLogicNumber[aRefHitDef.iRefLayer])[aRefHitDef.iInput];
int etaRef = aInput.getLayerData(omtf_config_->refToLogicNumber[aRefHitDef.iRefLayer],true)[aRefHitDef.iInput];
int phiRef = aInput.getLayerData(OMTFConfiguration::instance()->refToLogicNumber[aRefHitDef.iRefLayer])[aRefHitDef.iInput];
int etaRef = aInput.getLayerData(OMTFConfiguration::instance()->refToLogicNumber[aRefHitDef.iRefLayer],true)[aRefHitDef.iInput];
unsigned int iRegion = aRefHitDef.iRegion;

if(omtf_config_->bendingLayers.count(iLayer)) phiRef = 0;
if(OMTFConfiguration::instance()->bendingLayers.count(iLayer)) phiRef = 0;
const OMTFinput::vector1D restrictedLayerHits = restrictInput(iProcessor, iRegion, iLayer,layerHits);
for(auto itGP: theGPs){
GoldenPattern::layerResult aLayerResult = itGP.second->process1Layer1RefLayer(aRefHitDef.iRefLayer,iLayer,
@@ -272,8 +271,8 @@ const std::vector<OMTFProcessor::resultsMap> & OMTFProcessor::processInput(unsig
// std::cout << itGP.second->pdfValue(1,0,0) << std::endl;

int phiRefSt2 = itGP.second->propagateRefPhi(phiRef, etaRef, aRefHitDef.iRefLayer);
myResults[omtf_config_->nTestRefHits-nTestedRefHits-1][itGP.second->key()].setRefPhiRHits(aRefHitDef.iRefLayer, phiRef);
myResults[omtf_config_->nTestRefHits-nTestedRefHits-1][itGP.second->key()].addResult(aRefHitDef.iRefLayer,iLayer,
myResults[OMTFConfiguration::instance()->nTestRefHits-nTestedRefHits-1][itGP.second->key()].setRefPhiRHits(aRefHitDef.iRefLayer, phiRef);
myResults[OMTFConfiguration::instance()->nTestRefHits-nTestedRefHits-1][itGP.second->key()].addResult(aRefHitDef.iRefLayer,iLayer,
aLayerResult.first,
phiRefSt2,etaRef);
}
@@ -300,11 +299,11 @@ OMTFinput::vector1D OMTFProcessor::restrictInput(unsigned int iProcessor,

OMTFinput::vector1D myHits = layerHits;

unsigned int iStart = omtf_config_->connections[iProcessor][iRegion][iLayer].first;
unsigned int iEnd = iStart + omtf_config_->connections[iProcessor][iRegion][iLayer].second -1;
unsigned int iStart = OMTFConfiguration::instance()->connections[iProcessor][iRegion][iLayer].first;
unsigned int iEnd = iStart + OMTFConfiguration::instance()->connections[iProcessor][iRegion][iLayer].second -1;

for(unsigned int iInput=0;iInput<14;++iInput){
if(iInput<iStart || iInput>iEnd) myHits[iInput] = omtf_config_->nPhiBins;
if(iInput<iStart || iInput>iEnd) myHits[iInput] = OMTFConfiguration::instance()->nPhiBins;
}

return myHits;
@@ -334,17 +333,17 @@ void OMTFProcessor::fillCounts(unsigned int iProcessor,
myStr<<aInput<<std::endl;
edm::LogInfo("OMTF processor")<<myStr.str();

for(unsigned int iLayer=0;iLayer<omtf_config_->nLayers;++iLayer){
for(unsigned int iLayer=0;iLayer<OMTFConfiguration::instance()->nLayers;++iLayer){
const OMTFinput::vector1D & layerHits = aInput.getLayerData(iLayer);
if(!layerHits.size()) continue;
///Number of reference hits to be checked.
///Value read from XML configuration
for(unsigned int iRefHit=0;iRefHit<omtf_config_->nRefHits;++iRefHit){
for(unsigned int iRefHit=0;iRefHit<OMTFConfiguration::instance()->nRefHits;++iRefHit){
if(!refHitsBits[iRefHit]) continue;
const RefHitDef & aRefHitDef = omtf_config_->refHitsDefs[iProcessor][iRefHit];
int phiRef = aInput.getLayerData(omtf_config_->refToLogicNumber[aRefHitDef.iRefLayer])[aRefHitDef.iInput];
const RefHitDef & aRefHitDef = OMTFConfiguration::instance()->refHitsDefs[iProcessor][iRefHit];
int phiRef = aInput.getLayerData(OMTFConfiguration::instance()->refToLogicNumber[aRefHitDef.iRefLayer])[aRefHitDef.iInput];
unsigned int iRegion = aRefHitDef.iRegion;
if(omtf_config_->bendingLayers.count(iLayer)) phiRef = 0;
if(OMTFConfiguration::instance()->bendingLayers.count(iLayer)) phiRef = 0;
const OMTFinput::vector1D restrictedLayerHits = restrictInput(iProcessor, iRegion, iLayer,layerHits);
for(auto itGP: theGPs){
if(itGP.first.theCharge!=theCharge) continue;
10 changes: 5 additions & 5 deletions L1Trigger/L1TMuonOverlap/src/OMTFReconstruction.cc
Original file line number Diff line number Diff line change
@@ -53,7 +53,7 @@ void OMTFReconstruction::beginJob() {

if(m_Config.exists("omtf")){
m_OMTFConfig = new OMTFConfiguration(m_Config.getParameter<edm::ParameterSet>("omtf"));
m_OMTF = new OMTFProcessor(m_Config.getParameter<edm::ParameterSet>("omtf"));
m_OMTF = new OMTFProcessor(m_Config.getParameter<edm::ParameterSet>("omtf"), m_OMTFConfig);
}
}

@@ -103,10 +103,10 @@ std::auto_ptr<l1t::RegionalMuonCandBxCollection > OMTFReconstruction::reconstruc
std::auto_ptr<l1t::RegionalMuonCandBxCollection > candidates(new l1t::RegionalMuonCandBxCollection);

///The order is important: first put omtf_pos candidates, then omtf_neg.
for(unsigned int iProcessor=0; iProcessor<omtf_config_->nProcessors; ++iProcessor)
for(unsigned int iProcessor=0; iProcessor<OMTFConfiguration::instance()->nProcessors; ++iProcessor)
getProcessorCandidates(iProcessor, l1t::tftype::omtf_pos, bx, *candidates);

for(unsigned int iProcessor=0; iProcessor<omtf_config_->nProcessors; ++iProcessor)
for(unsigned int iProcessor=0; iProcessor<OMTFConfiguration::instance()->nProcessors; ++iProcessor)
getProcessorCandidates(iProcessor, l1t::tftype::omtf_neg, bx, *candidates);

return candidates;
@@ -156,7 +156,7 @@ void OMTFReconstruction::writeResultToXML(unsigned int iProcessor, const OMTFinp
//Write data to XML file
if(dumpResultToXML){
xercesc::DOMElement * aProcElement = m_Writer->writeEventData(aTopElement,iProcessor,input);
for(unsigned int iRefHit=0;iRefHit<omtf_config_->nTestRefHits;++iRefHit){
for(unsigned int iRefHit=0;iRefHit<OMTFConfiguration::instance()->nTestRefHits;++iRefHit){
///Dump only regions, where a candidate was found
AlgoMuon myCand = m_Sorter.sortRefHitResults(results[iRefHit],0);//charge=0 means ignore charge
if(myCand.getPt()) {
@@ -168,4 +168,4 @@ void OMTFReconstruction::writeResultToXML(unsigned int iProcessor, const OMTFinp
}
}
}
}
}
24 changes: 14 additions & 10 deletions L1Trigger/L1TMuonOverlap/src/OMTFResult.cc
Original file line number Diff line number Diff line change
@@ -36,27 +36,31 @@ void OMTFResult::addResult(unsigned int iRefLayer,
////////////////////////////////////////////
void OMTFResult::clear(){

results1D.assign(omtf_config_->nRefLayers,0);
hits1D.assign(omtf_config_->nRefLayers,0);
results.assign(omtf_config_->nLayers,results1D);
refPhi1D.assign(omtf_config_->nRefLayers,1024);
refEta1D.assign(omtf_config_->nRefLayers,1024);
hitsBits.assign(omtf_config_->nRefLayers,0);
refPhiRHit1D.assign(omtf_config_->nRefLayers,1024);
results1D.assign(OMTFConfiguration::instance()->nRefLayers,0);
hits1D.assign(OMTFConfiguration::instance()->nRefLayers,0);
results.assign(OMTFConfiguration::instance()->nLayers,results1D);
refPhi1D.assign(OMTFConfiguration::instance()->nRefLayers,1024);
refEta1D.assign(OMTFConfiguration::instance()->nRefLayers,1024);
hitsBits.assign(OMTFConfiguration::instance()->nRefLayers,0);
refPhiRHit1D.assign(OMTFConfiguration::instance()->nRefLayers,1024);
}
////////////////////////////////////////////
////////////////////////////////////////////
void OMTFResult::finalise(){

for(unsigned int iLogicLayer=0;iLogicLayer<results.size();++iLogicLayer){
unsigned int connectedLayer = omtf_config_->logicToLogic[iLogicLayer];

//unsigned int connectedLayer = OMTFConfiguration::instance()->logicToLogic[iLogicLayer];
auto iter = OMTFConfiguration::instance()->logicToLogic.find(iLogicLayer);
unsigned int connectedLayer = iter->second;

for(unsigned int iRefLayer=0;iRefLayer<results[iLogicLayer].size();++iRefLayer){
///If connected layer (POS or BEND) has not been fired, ignore this layer also
unsigned int val = results[connectedLayer][iRefLayer]>0 ? results[iLogicLayer][iRefLayer]: 0;
results1D[iRefLayer]+=val;
hitsBits[iRefLayer]+=(val>0)*std::pow(2,iLogicLayer);
///Do not count bending layers in hit count
if(!omtf_config_->bendingLayers.count(iLogicLayer)) hits1D[iRefLayer]+=(val>0);
if(!OMTFConfiguration::instance()->bendingLayers.count(iLogicLayer)) hits1D[iRefLayer]+=(val>0);
}
}
}
@@ -66,7 +70,7 @@ bool OMTFResult::empty() const{

unsigned int nHits = 0;

for(unsigned int iRefLayer=0;iRefLayer<omtf_config_->nRefLayers;++iRefLayer){
for(unsigned int iRefLayer=0;iRefLayer<OMTFConfiguration::instance()->nRefLayers;++iRefLayer){
nHits+=hits1D[iRefLayer];
}
return (nHits==0);
4 changes: 2 additions & 2 deletions L1Trigger/L1TMuonOverlap/src/OMTFSorter.cc
Original file line number Diff line number Diff line change
@@ -171,7 +171,7 @@ void OMTFSorter::sortRefHitResults(const std::vector<OMTFProcessor::resultsMap>
// 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->phi - it2->phi)<5/360.0*omtf_config_->nPhiBins){
// if(std::abs(it1->phi - it2->phi)<5/360.0*OMTFConfiguration::instance()->nPhiBins){
// isGhost=true;
// break;
// }
@@ -253,7 +253,7 @@ void OMTFSorter::sortProcessorAndFillCandidates(unsigned int iProcessor, l1t::tf
candidate.setHwEta(myCand.getEta());

float phiValue = myCand.getPhi();
if(phiValue>=(int)omtf_config_->nPhiBins) phiValue-=omtf_config_->nPhiBins;
if(phiValue>=(int)OMTFConfiguration::instance()->nPhiBins) phiValue-=OMTFConfiguration::instance()->nPhiBins;
///conversion factor from OMTF to uGMT scale: 5400/576
phiValue/=9.375;
candidate.setHwPhi(phiValue);
38 changes: 19 additions & 19 deletions L1Trigger/L1TMuonOverlap/src/OMTFinput.cc
Original file line number Diff line number Diff line change
@@ -28,10 +28,10 @@ std::bitset<128> OMTFinput::getRefHits(unsigned int iProcessor) const{
std::bitset<128> refHits;

unsigned int iRefHit = 0;
for(auto iRefHitDef:omtf_config_->refHitsDefs[iProcessor]){
int iPhi = getLayerData(omtf_config_->refToLogicNumber[iRefHitDef.iRefLayer])[iRefHitDef.iInput];
int iEta = getLayerData(omtf_config_->refToLogicNumber[iRefHitDef.iRefLayer],true)[iRefHitDef.iInput];
if(iPhi<(int)omtf_config_->nPhiBins){
for(auto iRefHitDef:OMTFConfiguration::instance()->refHitsDefs[iProcessor]){
int iPhi = getLayerData(OMTFConfiguration::instance()->refToLogicNumber[iRefHitDef.iRefLayer])[iRefHitDef.iInput];
int iEta = getLayerData(OMTFConfiguration::instance()->refToLogicNumber[iRefHitDef.iRefLayer],true)[iRefHitDef.iInput];
if(iPhi<(int)OMTFConfiguration::instance()->nPhiBins){
refHits.set(iRefHit, iRefHitDef.fitsRange(iPhi));
refHitsEta[iRefHit] = iEta;
}
@@ -46,12 +46,12 @@ bool OMTFinput::addLayerHit(unsigned int iLayer,
unsigned int iInput,
int iPhi, int iEta){

assert(iLayer<omtf_config_->nLayers);
assert(iLayer<OMTFConfiguration::instance()->nLayers);
assert(iInput<14);

if(iPhi>=(int)omtf_config_->nPhiBins) return true;
if(iPhi>=(int)OMTFConfiguration::instance()->nPhiBins) return true;

if(measurementsPhi[iLayer][iInput]!=(int)omtf_config_->nPhiBins) ++iInput;
if(measurementsPhi[iLayer][iInput]!=(int)OMTFConfiguration::instance()->nPhiBins) ++iInput;

if(iInput>13) return false;

@@ -74,7 +74,7 @@ void OMTFinput::readData(XMLConfigReader *aReader,
///////////////////////////////////////////////////
void OMTFinput::mergeData(const OMTFinput *aInput){

for(unsigned int iLayer=0;iLayer<omtf_config_->nLayers;++iLayer){
for(unsigned int iLayer=0;iLayer<OMTFConfiguration::instance()->nLayers;++iLayer){
const OMTFinput::vector1D & aPhiVec = aInput->getLayerData(iLayer,false);
const OMTFinput::vector1D & aEtaVec = aInput->getLayerData(iLayer,true);
if(!aPhiVec.size()) continue;
@@ -84,7 +84,7 @@ void OMTFinput::mergeData(const OMTFinput *aInput){
for(unsigned int iInput=0;iInput<14;++iInput){

//if(aPhiVec[iInput]==layerData[iInput] &&
// aPhiVec[iInput]!=(int)omtf_config_->nPhiBins) std::cout<<"Same HIT!"<<std::endl;
// aPhiVec[iInput]!=(int)OMTFConfiguration::instance()->nPhiBins) std::cout<<"Same HIT!"<<std::endl;

addLayerHit(iLayer,iInput,aPhiVec[iInput],aEtaVec[iInput]);
}
@@ -94,30 +94,30 @@ void OMTFinput::mergeData(const OMTFinput *aInput){
///////////////////////////////////////////////////
void OMTFinput::clear(){

vector1D aLayer1D(14,omtf_config_->nPhiBins);
measurementsPhi.assign(omtf_config_->nLayers,aLayer1D);
measurementsEta.assign(omtf_config_->nLayers,aLayer1D);
refHitsEta.assign(128,omtf_config_->nPhiBins);
vector1D aLayer1D(14,OMTFConfiguration::instance()->nPhiBins);
measurementsPhi.assign(OMTFConfiguration::instance()->nLayers,aLayer1D);
measurementsEta.assign(OMTFConfiguration::instance()->nLayers,aLayer1D);
refHitsEta.assign(128,OMTFConfiguration::instance()->nPhiBins);

}
///////////////////////////////////////////////////
///////////////////////////////////////////////////
void OMTFinput::shiftMyPhi(int phiShift){


int lowScaleEnd = std::pow(2,omtf_config_->nPhiBits-1);
int lowScaleEnd = std::pow(2,OMTFConfiguration::instance()->nPhiBits-1);
int highScaleEnd = lowScaleEnd-1;

for(unsigned int iLogicLayer=0;iLogicLayer<measurementsPhi.size();++iLogicLayer){
for(unsigned int iHit=0;iHit<measurementsPhi[iLogicLayer].size();++iHit){
if(!omtf_config_->bendingLayers.count(iLogicLayer) &&
measurementsPhi[iLogicLayer][iHit]<(int)omtf_config_->nPhiBins){
if(measurementsPhi[iLogicLayer][iHit]<0) measurementsPhi[iLogicLayer][iHit]+=omtf_config_->nPhiBins;
if(!OMTFConfiguration::instance()->bendingLayers.count(iLogicLayer) &&
measurementsPhi[iLogicLayer][iHit]<(int)OMTFConfiguration::instance()->nPhiBins){
if(measurementsPhi[iLogicLayer][iHit]<0) measurementsPhi[iLogicLayer][iHit]+=OMTFConfiguration::instance()->nPhiBins;
measurementsPhi[iLogicLayer][iHit]-=phiShift;
if(measurementsPhi[iLogicLayer][iHit]<0) measurementsPhi[iLogicLayer][iHit]+=omtf_config_->nPhiBins;
if(measurementsPhi[iLogicLayer][iHit]<0) measurementsPhi[iLogicLayer][iHit]+=OMTFConfiguration::instance()->nPhiBins;
measurementsPhi[iLogicLayer][iHit]+=-lowScaleEnd;
if(measurementsPhi[iLogicLayer][iHit]<-lowScaleEnd ||
measurementsPhi[iLogicLayer][iHit]>highScaleEnd) measurementsPhi[iLogicLayer][iHit] = (int)omtf_config_->nPhiBins;
measurementsPhi[iLogicLayer][iHit]>highScaleEnd) measurementsPhi[iLogicLayer][iHit] = (int)OMTFConfiguration::instance()->nPhiBins;
}
}
}
50 changes: 30 additions & 20 deletions L1Trigger/L1TMuonOverlap/src/OMTFinputMaker.cc
Original file line number Diff line number Diff line change
@@ -34,8 +34,8 @@ bool OMTFinputMaker::acceptDigi(uint32_t rawId,
unsigned int iProcessor,
l1t::tftype type){

unsigned int aMin = omtf_config_->barrelMin[iProcessor];
unsigned int aMax = omtf_config_->barrelMax[iProcessor];
unsigned int aMin = OMTFConfiguration::instance()->barrelMin[iProcessor];
unsigned int aMax = OMTFConfiguration::instance()->barrelMax[iProcessor];
unsigned int aSector = 99;

///Clean up digis. Remove unconnected detectors
@@ -81,8 +81,8 @@ bool OMTFinputMaker::acceptDigi(uint32_t rawId,
if(aId.region()==0) aSector = aId.sector();
if(aId.region()!=0){
aSector = (aId.sector()-1)*6+aId.subsector();
aMin = omtf_config_->endcap10DegMin[iProcessor];
aMax = omtf_config_->endcap10DegMax[iProcessor];
aMin = OMTFConfiguration::instance()->endcap10DegMin[iProcessor];
aMax = OMTFConfiguration::instance()->endcap10DegMax[iProcessor];
}

break;
@@ -114,13 +114,13 @@ bool OMTFinputMaker::acceptDigi(uint32_t rawId,

aSector = csc.chamber();

aMin = omtf_config_->endcap10DegMin[iProcessor];
aMax = omtf_config_->endcap10DegMax[iProcessor];
aMin = OMTFConfiguration::instance()->endcap10DegMin[iProcessor];
aMax = OMTFConfiguration::instance()->endcap10DegMax[iProcessor];

if( (type==l1t::tftype::emtf_pos || type==l1t::tftype::emtf_neg) &&
csc.station()>1 && csc.ring()==1){
aMin = omtf_config_->endcap20DegMin[iProcessor];
aMax = omtf_config_->endcap20DegMax[iProcessor];
aMin = OMTFConfiguration::instance()->endcap20DegMin[iProcessor];
aMax = OMTFConfiguration::instance()->endcap20DegMax[iProcessor];
}
break;
}
@@ -139,7 +139,7 @@ unsigned int OMTFinputMaker::getInputNumber(unsigned int rawId,

unsigned int iInput = 99;
unsigned int aSector = 99;
int aMin = omtf_config_->barrelMin[iProcessor];
int aMin = OMTFConfiguration::instance()->barrelMin[iProcessor];
int iRoll = 1;
int nInputsPerSector = 2;

@@ -169,7 +169,7 @@ unsigned int OMTFinputMaker::getInputNumber(unsigned int rawId,
}
if(rpc.region()!=0){
aSector = (rpc.sector()-1)*6+rpc.subsector();
aMin = omtf_config_->endcap10DegMin[iProcessor];
aMin = OMTFConfiguration::instance()->endcap10DegMin[iProcessor];
///on the 0-2pi border we need to add 4 10 deg sectors
///to get the correct index
if(iProcessor==5 && aSector<5) aMin = -4;
@@ -187,7 +187,7 @@ unsigned int OMTFinputMaker::getInputNumber(unsigned int rawId,
case MuonSubdetId::CSC: {
CSCDetId csc(rawId);
aSector = csc.chamber();
aMin = omtf_config_->endcap10DegMin[iProcessor];
aMin = OMTFConfiguration::instance()->endcap10DegMin[iProcessor];
///on the 0-2pi border we need to add 4 10deg sectors
///to get the correct index
if(iProcessor==5 && aSector<5) aMin = -4;
@@ -196,7 +196,7 @@ unsigned int OMTFinputMaker::getInputNumber(unsigned int rawId,
///to get the correct index
if( (type==l1t::tftype::emtf_pos || type==l1t::tftype::emtf_neg) &&
csc.station()>1 && csc.ring()==1){
aMin = omtf_config_->endcap20DegMin[iProcessor];
aMin = OMTFConfiguration::instance()->endcap20DegMin[iProcessor];
if(iProcessor==5 && aSector<3) aMin = -2;
}
break;
@@ -235,10 +235,13 @@ OMTFinput OMTFinputMaker::processDT(const L1MuDTChambPhContainer *dtPhDigis,
// FIXME (MK): at least Ts2Tag selection is not correct! Check it
if (digiIt.bxNum()!= 0 || digiIt.BxCnt()!= 0 || digiIt.Ts2Tag()!= 0 || digiIt.code()<4) continue;

unsigned int hwNumber = omtf_config_->getLayerNumber(detid.rawId());
if(omtf_config_->hwToLogicLayer.find(hwNumber)==omtf_config_->hwToLogicLayer.end()) continue;
unsigned int hwNumber = OMTFConfiguration::instance()->getLayerNumber(detid.rawId());
if(OMTFConfiguration::instance()->hwToLogicLayer.find(hwNumber)==OMTFConfiguration::instance()->hwToLogicLayer.end()) continue;

unsigned int iLayer = omtf_config_->hwToLogicLayer[hwNumber];
//unsigned int iLayer = OMTFConfiguration::instance()->hwToLogicLayer[hwNumber];
auto iter = OMTFConfiguration::instance()->hwToLogicLayer.find(hwNumber);
unsigned int iLayer = iter->second;

int iPhi = myAngleConverter.getProcessorPhi(iProcessor, type, digiIt);
int iEta = myAngleConverter.getGlobalEta(detid.rawId(), digiIt, dtThDigis);
unsigned int iInput= getInputNumber(detid.rawId(), iProcessor, type);
@@ -273,10 +276,14 @@ OMTFinput OMTFinputMaker::processCSC(const CSCCorrelatedLCTDigiCollection *cscDi
///CSC central BX is 6 for some reason.
if (abs(digi->getBX()- 6)>0) continue;

unsigned int hwNumber = omtf_config_->getLayerNumber(rawid);
if(omtf_config_->hwToLogicLayer.find(hwNumber)==omtf_config_->hwToLogicLayer.end()) continue;
unsigned int hwNumber = OMTFConfiguration::instance()->getLayerNumber(rawid);
if(OMTFConfiguration::instance()->hwToLogicLayer.find(hwNumber)==OMTFConfiguration::instance()->hwToLogicLayer.end()) continue;


//unsigned int iLayer = OMTFConfiguration::instance()->hwToLogicLayer[hwNumber];
auto iter = OMTFConfiguration::instance()->hwToLogicLayer.find(hwNumber);
unsigned int iLayer = iter->second;

unsigned int iLayer = omtf_config_->hwToLogicLayer[hwNumber];
int iPhi = myAngleConverter.getProcessorPhi(iProcessor, type, CSCDetId(rawid), *digi);
int iEta = myAngleConverter.getGlobalEta(rawid, *digi);
///Accept CSC digis only up to eta=1.26.
@@ -326,8 +333,11 @@ OMTFinput OMTFinputMaker::processRPC(const RPCDigiCollection *rpcDigis,
int iPhiHalfStrip2 = myAngleConverter.getProcessorPhi(iProcessor, type, roll, cluster.second);
int iPhi = (iPhiHalfStrip1+iPhiHalfStrip2)/2;
int iEta = myAngleConverter.getGlobalEta(rawid, cluster.first);
unsigned int hwNumber = omtf_config_->getLayerNumber(rawid);
unsigned int iLayer = omtf_config_->hwToLogicLayer[hwNumber];
unsigned int hwNumber = OMTFConfiguration::instance()->getLayerNumber(rawid);
//unsigned int iLayer = OMTFConfiguration::instance()->hwToLogicLayer[hwNumber];
auto iter = OMTFConfiguration::instance()->hwToLogicLayer.find(hwNumber);
unsigned int iLayer = iter->second;

unsigned int iInput= getInputNumber(rawid, iProcessor, type);
result.addLayerHit(iLayer,iInput,iPhi,iEta);

141 changes: 70 additions & 71 deletions L1Trigger/L1TMuonOverlap/src/XMLConfigReader.cc

Large diffs are not rendered by default.

54 changes: 27 additions & 27 deletions L1Trigger/L1TMuonOverlap/src/XMLConfigWriter.cc
Original file line number Diff line number Diff line change
@@ -66,7 +66,7 @@ void XMLConfigWriter::initialiseXMLDocument(const std::string & docName){
theDoc = domImpl->createDocument(0,_toDOMS(docName.c_str()), 0);
theTopElement = theDoc->getDocumentElement();

unsigned int version = omtf_config_->fwVersion;
unsigned int version = OMTFConfiguration::instance()->fwVersion;
unsigned int mask32bits = pow(2,32)-1;

version &=mask32bits;
@@ -148,7 +148,7 @@ xercesc::DOMElement * XMLConfigWriter::writeEventData(xercesc::DOMElement *aTopE
aProcessor->setAttribute(_toDOMS("iProcessor"), _toDOMS(stringStr.str()));

xercesc::DOMElement *aLayer, *aHit;
for(unsigned int iLayer=0;iLayer<omtf_config_->nLayers;++iLayer){
for(unsigned int iLayer=0;iLayer<OMTFConfiguration::instance()->nLayers;++iLayer){
const OMTFinput::vector1D & layerDataPhi = aInput.getLayerData(iLayer);
const OMTFinput::vector1D & layerDataEta = aInput.getLayerData(iLayer,true);

@@ -167,7 +167,7 @@ xercesc::DOMElement * XMLConfigWriter::writeEventData(xercesc::DOMElement *aTopE
stringStr.str("");
stringStr<<layerDataEta[iHit];
aHit->setAttribute(_toDOMS("iEta"), _toDOMS(stringStr.str()));
if(layerDataPhi[iHit]>=(int)omtf_config_->nPhiBins) continue;
if(layerDataPhi[iHit]>=(int)OMTFConfiguration::instance()->nPhiBins) continue;
aLayer->appendChild(aHit);
}
if(aLayer->getChildNodes()->getLength()) aProcessor->appendChild(aLayer);
@@ -244,7 +244,7 @@ void XMLConfigWriter::writeResultsData(xercesc::DOMElement *aTopElement,
aGP->setAttribute(_toDOMS("iCharge"), _toDOMS(stringStr.str()));
/////////////////
///Write results details for this GP
for(unsigned int iRefLayer=0;iRefLayer<omtf_config_->nRefLayers;++iRefLayer){
for(unsigned int iRefLayer=0;iRefLayer<OMTFConfiguration::instance()->nRefLayers;++iRefLayer){
xercesc::DOMElement* aRefLayer = theDoc->createElement(_toDOMS("Result"));
stringStr.str("");
stringStr<<iRefLayer;
@@ -253,9 +253,9 @@ void XMLConfigWriter::writeResultsData(xercesc::DOMElement *aTopElement,
stringStr<<iRegion;
aRefLayer->setAttribute(_toDOMS("iRegion"), _toDOMS(stringStr.str()));
stringStr.str("");
stringStr<<omtf_config_->refToLogicNumber[iRefLayer];
stringStr<<OMTFConfiguration::instance()->refToLogicNumber[iRefLayer];
aRefLayer->setAttribute(_toDOMS("iLogicLayer"), _toDOMS(stringStr.str()));
for(unsigned int iLogicLayer=0;iLogicLayer<omtf_config_->nLayers;++iLogicLayer){
for(unsigned int iLogicLayer=0;iLogicLayer<OMTFConfiguration::instance()->nLayers;++iLogicLayer){
xercesc::DOMElement* aLayer = theDoc->createElement(_toDOMS("Layer"));
stringStr.str("");
stringStr<<iLogicLayer;
@@ -291,7 +291,7 @@ void XMLConfigWriter::writeGPData(const GoldenPattern & aGP){
stringStr<<aGP.key().theCharge;
aGPElement->setAttribute(_toDOMS("iCharge"), _toDOMS(stringStr.str()));

for(unsigned int iLayer = 0;iLayer<omtf_config_->nLayers;++iLayer){
for(unsigned int iLayer = 0;iLayer<OMTFConfiguration::instance()->nLayers;++iLayer){
int nOfPhis = 0;
/////////////////////////////////////
aLayer = theDoc->createElement(_toDOMS("Layer"));
@@ -302,7 +302,7 @@ void XMLConfigWriter::writeGPData(const GoldenPattern & aGP){
stringStr.str("");
stringStr<<nOfPhis;
aLayer->setAttribute(_toDOMS("nOfPhis"), _toDOMS(stringStr.str()));
for(unsigned int iRefLayer=0;iRefLayer<omtf_config_->nRefLayers;++iRefLayer){
for(unsigned int iRefLayer=0;iRefLayer<OMTFConfiguration::instance()->nRefLayers;++iRefLayer){
aRefLayer = theDoc->createElement(_toDOMS("RefLayer"));
int meanDistPhi = aGP.meanDistPhiValue(iLayer,iRefLayer);
stringStr.str("");
@@ -322,8 +322,8 @@ void XMLConfigWriter::writeGPData(const GoldenPattern & aGP){
aRefLayer->setAttribute(_toDOMS("distMsbPhiShift"), _toDOMS(stringStr.str()));
aLayer->appendChild(aRefLayer);
}
for(unsigned int iRefLayer=0;iRefLayer<omtf_config_->nRefLayers;++iRefLayer){
for(unsigned int iPdf=0;iPdf<exp2(omtf_config_->nPdfAddrBits);++iPdf){
for(unsigned int iRefLayer=0;iRefLayer<OMTFConfiguration::instance()->nRefLayers;++iRefLayer){
for(unsigned int iPdf=0;iPdf<exp2(OMTFConfiguration::instance()->nPdfAddrBits);++iPdf){
aPdf = theDoc->createElement(_toDOMS("PDF"));
stringStr.str("");
stringStr<<aGP.pdfValue(iLayer,iRefLayer,iPdf);
@@ -375,7 +375,7 @@ void XMLConfigWriter::writeGPData(const GoldenPattern & aGP1,

aGPElement->setAttribute(_toDOMS("iCharge"), _toDOMS(stringStr.str()));

for(unsigned int iLayer = 0;iLayer<omtf_config_->nLayers;++iLayer){
for(unsigned int iLayer = 0;iLayer<OMTFConfiguration::instance()->nLayers;++iLayer){
int nOfPhis = 0;
/////////////////////////////////////
aLayer = theDoc->createElement(_toDOMS("Layer"));
@@ -386,7 +386,7 @@ void XMLConfigWriter::writeGPData(const GoldenPattern & aGP1,
stringStr.str("");
stringStr<<nOfPhis;
aLayer->setAttribute(_toDOMS("nOfPhis"), _toDOMS(stringStr.str()));
for(unsigned int iRefLayer=0;iRefLayer<omtf_config_->nRefLayers;++iRefLayer){
for(unsigned int iRefLayer=0;iRefLayer<OMTFConfiguration::instance()->nRefLayers;++iRefLayer){
aRefLayer = theDoc->createElement(_toDOMS("RefLayer"));
int meanDistPhi = aGP1.meanDistPhiValue(iLayer,iRefLayer);

@@ -413,8 +413,8 @@ void XMLConfigWriter::writeGPData(const GoldenPattern & aGP1,
aRefLayer->setAttribute(_toDOMS("distMsbPhiShift"), _toDOMS(stringStr.str()));
aLayer->appendChild(aRefLayer);
}
for(unsigned int iRefLayer=0;iRefLayer<omtf_config_->nRefLayers;++iRefLayer){
for(unsigned int iPdf=0;iPdf<exp2(omtf_config_->nPdfAddrBits);++iPdf){
for(unsigned int iRefLayer=0;iRefLayer<OMTFConfiguration::instance()->nRefLayers;++iRefLayer){
for(unsigned int iPdf=0;iPdf<exp2(OMTFConfiguration::instance()->nPdfAddrBits);++iPdf){
aPdf = theDoc->createElement(_toDOMS("PDF"));
stringStr.str("");
stringStr<<aGP1.pdfValue(iLayer,iRefLayer,iPdf);
@@ -446,29 +446,29 @@ void XMLConfigWriter::writeConnectionsData(const std::vector<std::vector <OMTFC
stringStr.str("");
stringStr<<iProcessor;
aProcessorElement->setAttribute(_toDOMS("iProcessor"), _toDOMS(stringStr.str()));
for(unsigned int iRefLayer=0;iRefLayer<omtf_config_->nRefLayers;++iRefLayer){
for(unsigned int iRefLayer=0;iRefLayer<OMTFConfiguration::instance()->nRefLayers;++iRefLayer){
xercesc::DOMElement* aRefLayerElement = theDoc->createElement(_toDOMS("RefLayer"));
stringStr.str("");
stringStr<<iRefLayer;
aRefLayerElement->setAttribute(_toDOMS("iRefLayer"), _toDOMS(stringStr.str()));
stringStr.str("");
stringStr<<omtf_config_->processorPhiVsRefLayer[iProcessor][iRefLayer];
stringStr<<OMTFConfiguration::instance()->processorPhiVsRefLayer[iProcessor][iRefLayer];
aRefLayerElement->setAttribute(_toDOMS("iGlobalPhiStart"), _toDOMS(stringStr.str()));
aProcessorElement->appendChild(aRefLayerElement);
}
unsigned int iRefHit = 0;

/////
///////
for(unsigned int iRefLayer=0;iRefLayer<omtf_config_->nRefLayers;++iRefLayer){
for(unsigned int iRefLayer=0;iRefLayer<OMTFConfiguration::instance()->nRefLayers;++iRefLayer){
for(unsigned int iRegion=0;iRegion<6;++iRegion){
unsigned int maxHitCount = 0;
for(unsigned int iInput=0;iInput<14;++iInput) {
if((int)maxHitCount<omtf_config_->measurements4Dref[iProcessor][iRegion][iRefLayer][iInput])
maxHitCount = omtf_config_->measurements4Dref[iProcessor][iRegion][iRefLayer][iInput];
if((int)maxHitCount<OMTFConfiguration::instance()->measurements4Dref[iProcessor][iRegion][iRefLayer][iInput])
maxHitCount = OMTFConfiguration::instance()->measurements4Dref[iProcessor][iRegion][iRefLayer][iInput];
}
for(unsigned int iInput=0;iInput<14;++iInput){
unsigned int hitCount = omtf_config_->measurements4Dref[iProcessor][iRegion][iRefLayer][iInput];
unsigned int hitCount = OMTFConfiguration::instance()->measurements4Dref[iProcessor][iRegion][iRefLayer][iInput];
if(hitCount<maxHitCount*0.1) continue;
xercesc::DOMElement* aRefHitElement = theDoc->createElement(_toDOMS("RefHit"));
stringStr.str("");
@@ -485,10 +485,10 @@ void XMLConfigWriter::writeConnectionsData(const std::vector<std::vector <OMTFC
stringStr.str("");
stringStr<<iInput;
aRefHitElement->setAttribute(_toDOMS("iInput"), _toDOMS(stringStr.str()));
unsigned int logicRegionSize = 10/360.0*omtf_config_->nPhiBins;
int lowScaleEnd = std::pow(2,omtf_config_->nPhiBits-1);
unsigned int logicRegionSize = 10/360.0*OMTFConfiguration::instance()->nPhiBins;
int lowScaleEnd = std::pow(2,OMTFConfiguration::instance()->nPhiBits-1);
///iPhiMin and iPhiMax are expressed in n bit scale -2**n, +2**2-1 used in each processor
int iPhiMin = omtf_config_->processorPhiVsRefLayer[iProcessor][iRefLayer]-omtf_config_->globalPhiStart(iProcessor)-lowScaleEnd;
int iPhiMin = OMTFConfiguration::instance()->processorPhiVsRefLayer[iProcessor][iRefLayer]-OMTFConfiguration::instance()->globalPhiStart(iProcessor)-lowScaleEnd;
int iPhiMax = iPhiMin+logicRegionSize-1;

iPhiMin+=iRegion*logicRegionSize;
@@ -501,10 +501,10 @@ void XMLConfigWriter::writeConnectionsData(const std::vector<std::vector <OMTFC
stringStr.str("");
stringStr<<iPhiMax;
aRefHitElement->setAttribute(_toDOMS("iPhiMax"), _toDOMS(stringStr.str()));
if(iRefHit<omtf_config_->nRefHits) aProcessorElement->appendChild(aRefHitElement);
if(iRefHit<OMTFConfiguration::instance()->nRefHits) aProcessorElement->appendChild(aRefHitElement);
++iRefHit;
}
for(;iRegion==5 && iRefLayer==7 && iRefHit<omtf_config_->nRefHits;++iRefHit){
for(;iRegion==5 && iRefLayer==7 && iRefHit<OMTFConfiguration::instance()->nRefHits;++iRefHit){
xercesc::DOMElement* aRefHitElement = theDoc->createElement(_toDOMS("RefHit"));
stringStr.str("");
stringStr<<iRefHit;
@@ -543,13 +543,13 @@ void XMLConfigWriter::writeConnectionsData(const std::vector<std::vector <OMTFC
stringStr<<iRegion;
aRegionElement->setAttribute(_toDOMS("iRegion"), _toDOMS(stringStr.str()));

for(unsigned int iLogicLayer=0;iLogicLayer<omtf_config_->nLayers;++iLogicLayer){
for(unsigned int iLogicLayer=0;iLogicLayer<OMTFConfiguration::instance()->nLayers;++iLogicLayer){
xercesc::DOMElement* aLayerElement = theDoc->createElement(_toDOMS("Layer"));
stringStr.str("");
stringStr<<iLogicLayer;
////////////////////////////////////////////////
aLayerElement->setAttribute(_toDOMS("iLayer"), _toDOMS(stringStr.str()));
const OMTFConfiguration::vector1D & myCounts = omtf_config_->measurements4D[iProcessor][iRegion][iLogicLayer];
const OMTFConfiguration::vector1D & myCounts = OMTFConfiguration::instance()->measurements4D[iProcessor][iRegion][iLogicLayer];
unsigned int maxInput = findMaxInput(myCounts);
unsigned int begin = 0, end = 0;
if((int)maxInput-2>=0) begin = maxInput-2;

0 comments on commit 2df598b

Please sign in to comment.