CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
List of all members | Public Types | Public Member Functions | Private Attributes | Friends
GoldenPattern Class Reference

#include <GoldenPattern.h>

Public Types

typedef std::pair< int, bool > layerResult
 
typedef std::vector< int > vector1D
 
typedef std::vector< vector1Dvector2D
 
typedef std::vector< vector2Dvector3D
 

Public Member Functions

void addCount (unsigned int iRefLayer, unsigned int iLayer, const int refPhi, const OMTFinput::vector1D &layerHits)
 Add a single count to the relevant pdf bin in three dimensions. More...
 
const vector2DgetMeanDistPhi () const
 
const vector3DgetPdf () const
 
 GoldenPattern (const Key &aKey)
 
bool hasCounts ()
 Check if the GP has any counts in any of referecne layers;. More...
 
Key key () const
 
int meanDistPhiValue (unsigned int iLayer, unsigned int iRefLayer) const
 
void normalise ()
 
int pdfValue (unsigned int iLayer, unsigned int iRefLayer, unsigned int iBin) const
 
GoldenPattern::layerResult process1Layer1RefLayer (unsigned int iRefLayer, unsigned int iLayer, const int refPhi, const OMTFinput::vector1D &layerHits)
 
int propagateRefPhi (int phiRef, int etaRef, unsigned int iRefLayer)
 
void reset ()
 Reset contents of all data vectors, keeping the vectors size. More...
 
void setMeanDistPhi (const vector2D &aMeanDistPhi)
 
void setPdf (const vector3D &aPdf)
 

Private Attributes

vector2D meanDistPhi
 
vector2D meanDistPhiCounts
 
vector3D pdfAllRef
 
Key theKey
 Pattern kinematical identification (iEta,iPt,iCharge) More...
 

Friends

std::ostream & operator<< (std::ostream &out, const GoldenPattern &aPattern)
 

Detailed Description

Definition at line 45 of file GoldenPattern.h.

Member Typedef Documentation

typedef std::pair<int,bool> GoldenPattern::layerResult

Definition at line 52 of file GoldenPattern.h.

typedef std::vector<int> GoldenPattern::vector1D

Definition at line 49 of file GoldenPattern.h.

typedef std::vector<vector1D> GoldenPattern::vector2D

Definition at line 50 of file GoldenPattern.h.

typedef std::vector<vector2D> GoldenPattern::vector3D

Definition at line 51 of file GoldenPattern.h.

Constructor & Destructor Documentation

GoldenPattern::GoldenPattern ( const Key aKey)
inline

Definition at line 57 of file GoldenPattern.h.

57 : theKey(aKey){}
Key theKey
Pattern kinematical identification (iEta,iPt,iCharge)

Member Function Documentation

void GoldenPattern::addCount ( unsigned int  iRefLayer,
unsigned int  iLayer,
const int  refPhi,
const OMTFinput::vector1D layerHits 
)

Add a single count to the relevant pdf bin in three dimensions.

For making the patterns take events with a single hit in each layer

Shift phiDist so it is in +-Pi range

Shift phidist, so 0 is at the middle of the range

Check if phiDist is within pdf range in -64 +63 U2 code Find more elegant way to check this.

Definition at line 54 of file GoldenPattern.cc.

References funct::abs(), meanDistPhiCounts, OMTFConfiguration::nPdfAddrBits, OMTFConfiguration::nPhiBins, pdfAllRef, and OMTFConfiguration::refToLogicNumber.

57  {
58 
59  int nHitsInLayer = 0;
60  int phiDist = exp2(OMTFConfiguration::nPdfAddrBits);
61 
62  for(auto itHit: layerHits){
63  if(itHit>=(int)OMTFConfiguration::nPhiBins) continue;
64  if(abs(itHit-phiRefHit)<phiDist) phiDist = itHit-phiRefHit;
65  ++nHitsInLayer;
66  }
68  if(nHitsInLayer>1 || nHitsInLayer==0) return;
69 
71  if(phiDist>=(int)OMTFConfiguration::nPhiBins/2) phiDist-=(int)OMTFConfiguration::nPhiBins;
72  if(phiDist<=-(int)OMTFConfiguration::nPhiBins/2) phiDist+=(int)OMTFConfiguration::nPhiBins;
73 
75  int phiDistShift=phiDist+exp2(OMTFConfiguration::nPdfAddrBits-1);
76 
80  if(phiDistShift<0 ||
81  phiDistShift>exp2(OMTFConfiguration::nPdfAddrBits)-1){
82  return;
83  }
84  if((int)iLayer==OMTFConfiguration::refToLogicNumber[iRefLayer]) ++meanDistPhiCounts[iLayer][iRefLayer];
85  ++pdfAllRef[iLayer][iRefLayer][phiDistShift];
86 }
vector2D meanDistPhiCounts
static unsigned int nPdfAddrBits
vector3D pdfAllRef
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static unsigned int nPhiBins
static std::vector< int > refToLogicNumber
const vector2D& GoldenPattern::getMeanDistPhi ( ) const
inline

Definition at line 63 of file GoldenPattern.h.

References meanDistPhi.

Referenced by OMTFProcessor::averagePatterns().

63 {return meanDistPhi;}
vector2D meanDistPhi
const vector3D& GoldenPattern::getPdf ( ) const
inline

Definition at line 65 of file GoldenPattern.h.

References pdfAllRef.

Referenced by OMTFProcessor::shiftGP().

65 {return pdfAllRef;}
vector3D pdfAllRef
bool GoldenPattern::hasCounts ( )

Check if the GP has any counts in any of referecne layers;.

Definition at line 221 of file GoldenPattern.cc.

References meanDistPhi, and meanDistPhiCounts.

221  {
222 
223  for (unsigned int iRefLayer=0;iRefLayer<meanDistPhi[0].size();++iRefLayer){
224  for (unsigned int iLayer=0;iLayer<meanDistPhi.size();++iLayer){
225  if(meanDistPhiCounts.size() && meanDistPhiCounts[iLayer][iRefLayer]) return true;
226  }
227  }
228  return false;
229 }
vector2D meanDistPhiCounts
vector2D meanDistPhi
Key GoldenPattern::key ( ) const
inline

Definition at line 59 of file GoldenPattern.h.

References theKey.

Referenced by OMTFProcessor::addGP(), XMLConfigWriter::writeGPData(), and L1TMuonOverlapTrackProducer::writeMergedGPs().

59 {return theKey;}
Key theKey
Pattern kinematical identification (iEta,iPt,iCharge)
int GoldenPattern::meanDistPhiValue ( unsigned int  iLayer,
unsigned int  iRefLayer 
) const
inline

Definition at line 69 of file GoldenPattern.h.

References meanDistPhi.

Referenced by XMLConfigWriter::writeGPData().

69 { return meanDistPhi[iLayer][iRefLayer];}
vector2D meanDistPhi
void GoldenPattern::normalise ( )

Normalise event counts in mean dist phi, and pdf vectors to get the real values of meand dist phi and probability

Mean dist phi

Probabilities. Normalise and change from float to integer values

If there are only a few counts in given measurement layer, set pdf value to 0

Digitisation Values remapped 0->std::pow(2,nPdfValBits) minPlog->0

Make sure digitised value is saved using nBitsVal bits

Shift pdf index by meanDistPhi

Definition at line 153 of file GoldenPattern.cc.

References cmsHarvester::index, dqm-mbProfile::log, meanDistPhi, meanDistPhiCounts, OMTFConfiguration::minPdfVal, OMTFConfiguration::nPdfAddrBits, OMTFConfiguration::nPdfValBits, pdfAllRef, funct::pow(), and OMTFConfiguration::refToLogicNumber.

153  {
154 
155  for (unsigned int iRefLayer=0;iRefLayer<pdfAllRef[0].size();++iRefLayer){
156  for (unsigned int iLayer=0;iLayer<pdfAllRef.size();++iLayer){
157  for (unsigned int iPdf=0;iPdf<pdfAllRef[iLayer][iRefLayer].size();++iPdf){
158  float pVal = log((float)pdfAllRef[iLayer][iRefLayer][iPdf]/meanDistPhiCounts[OMTFConfiguration::refToLogicNumber[iRefLayer]][iRefLayer]);
159  if(pVal<log(OMTFConfiguration::minPdfVal)) continue;
160  meanDistPhi[iLayer][iRefLayer]+=(iPdf - exp2(OMTFConfiguration::nPdfAddrBits-1))*pdfAllRef[iLayer][iRefLayer][iPdf];
161  if((int)iLayer!=OMTFConfiguration::refToLogicNumber[iRefLayer]) meanDistPhiCounts[iLayer][iRefLayer]+=pdfAllRef[iLayer][iRefLayer][iPdf];
162  }
163  }
164  }
165 
167  for (unsigned int iRefLayer=0;iRefLayer<meanDistPhi[0].size();++iRefLayer){
168  for (unsigned int iLayer=0;iLayer<meanDistPhi.size();++iLayer){
169  if(meanDistPhiCounts.size() && meanDistPhiCounts[iLayer][iRefLayer]){
170  if (meanDistPhiCounts[iLayer][iRefLayer]<1000) meanDistPhi[iLayer][iRefLayer] = 0;
171  else meanDistPhi[iLayer][iRefLayer] = rint((float)meanDistPhi[iLayer][iRefLayer]/meanDistPhiCounts[iLayer][iRefLayer]);
172  }
173  }
174  }
175 
176  const float minPlog = log(OMTFConfiguration::minPdfVal);
177  const unsigned int nPdfValBits = OMTFConfiguration::nPdfValBits;
179  float pVal;
180  int digitisedVal, truncatedValue;
181  for (unsigned int iRefLayer=0;iRefLayer<pdfAllRef[0].size();++iRefLayer){
182  for (unsigned int iLayer=0;iLayer<pdfAllRef.size();++iLayer){
183  for (unsigned int iPdf=0;iPdf<pdfAllRef[iLayer][iRefLayer].size();++iPdf){
184  if(!meanDistPhiCounts[OMTFConfiguration::refToLogicNumber[iRefLayer]][iRefLayer] ||
185  !pdfAllRef[iLayer][iRefLayer][iPdf]) continue;
186  pVal = log((float)pdfAllRef[iLayer][iRefLayer][iPdf]/meanDistPhiCounts[OMTFConfiguration::refToLogicNumber[iRefLayer]][iRefLayer]);
188  if(pVal<minPlog || meanDistPhiCounts[iLayer][iRefLayer]<1000){
189  pdfAllRef[iLayer][iRefLayer][iPdf] = 0;
190  continue;
191  }
195  digitisedVal = rint((std::pow(2,nPdfValBits)-1) - (pVal/minPlog)*(std::pow(2,nPdfValBits)-1));
197  truncatedValue = 0 | (digitisedVal & ((int)pow(2,nPdfValBits)-1));
198  pdfAllRef[iLayer][iRefLayer][iPdf] = truncatedValue;
199  }
200  }
201  }
202 
203 
204  vector3D pdfAllRefTmp = pdfAllRef;
205 
206  const unsigned int nPdfAddrBits = 7;
207  for (unsigned int iRefLayer=0;iRefLayer<pdfAllRef[0].size();++iRefLayer){
208  for (unsigned int iLayer=0;iLayer<pdfAllRef.size();++iLayer){
209  for (unsigned int iPdf=0;iPdf<pdfAllRef[iLayer][iRefLayer].size();++iPdf){
210  pdfAllRef[iLayer][iRefLayer][iPdf] = 0;
212  int index = iPdf - exp2(OMTFConfiguration::nPdfAddrBits-1) - meanDistPhi[iLayer][iRefLayer] + exp2(nPdfAddrBits-1);
213  if(index<0 || index>exp2(nPdfAddrBits)-1) continue;
214  pdfAllRef[iLayer][iRefLayer][index] = pdfAllRefTmp[iLayer][iRefLayer][iPdf];
215  }
216  }
217  }
218 }
vector2D meanDistPhiCounts
static float minPdfVal
vector2D meanDistPhi
static unsigned int nPdfAddrBits
std::vector< vector2D > vector3D
Definition: GoldenPattern.h:51
vector3D pdfAllRef
static std::vector< int > refToLogicNumber
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
static unsigned int nPdfValBits
int GoldenPattern::pdfValue ( unsigned int  iLayer,
unsigned int  iRefLayer,
unsigned int  iBin 
) const
inline

Definition at line 71 of file GoldenPattern.h.

References pdfAllRef.

Referenced by OMTFProcessor::shiftGP(), and XMLConfigWriter::writeGPData().

71 {return pdfAllRef[iLayer][iRefLayer][iBin];}
vector3D pdfAllRef
GoldenPattern::layerResult GoldenPattern::process1Layer1RefLayer ( unsigned int  iRefLayer,
unsigned int  iLayer,
const int  refPhi,
const OMTFinput::vector1D layerHits 
)

Process single measurement layer with a single ref layer Method should be thread safe

Select hit closest to the mean of probability distribution in given layer

Shift phidist, so 0 is at the middle of the range

Check if phiDist is within pdf range in -64 +63 U2 code Find more elegant way to check this.

Definition at line 13 of file GoldenPattern.cc.

References funct::abs(), meanDistPhi, OMTFConfiguration::nPdfAddrBits, OMTFConfiguration::nPhiBins, and pdfAllRef.

16  {
17 
19 
20  int phiMean = meanDistPhi[iLayer][iRefLayer];
21  int phiDist = exp2(OMTFConfiguration::nPdfAddrBits);
24  for(auto itHit: layerHits){
25  if(itHit>=(int)OMTFConfiguration::nPhiBins) continue;
26  if(abs(itHit-phiMean-phiRefHit)<abs(phiDist)) phiDist = itHit-phiMean-phiRefHit;
27  }
28 
30  phiDist+=exp2(OMTFConfiguration::nPdfAddrBits-1);
31 
35  if(phiDist<0 ||
36  phiDist>exp2(OMTFConfiguration::nPdfAddrBits)-1){
37  return aResult;
38  }
39 
40  int pdfVal = pdfAllRef[iLayer][iRefLayer][phiDist];
41  return GoldenPattern::layerResult(pdfVal,pdfVal>0);
42 }
vector2D meanDistPhi
static unsigned int nPdfAddrBits
vector3D pdfAllRef
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
static unsigned int nPhiBins
std::pair< int, bool > layerResult
Definition: GoldenPattern.h:52
int GoldenPattern::propagateRefPhi ( int  phiRef,
int  etaRef,
unsigned int  iRefLayer 
)

Propagate phi from given reference layer to MB2 or ME2 ME2 is used if eta of reference hit is larger than 1.1 expressed in ingerer MicroGMT scale: 1.1/2.61*240 = 101

Definition at line 45 of file GoldenPattern.cc.

References meanDistPhi.

45  {
46 
47  unsigned int iLayer = 2; //MB2
48  //if(etaRef>101) iLayer = 7;//RE2
49  return phiRef + meanDistPhi[iLayer][iRefLayer];
50 
51 }
vector2D meanDistPhi
void GoldenPattern::reset ( void  )

Reset contents of all data vectors, keeping the vectors size.

Definition at line 135 of file GoldenPattern.cc.

References meanDistPhi, meanDistPhiCounts, OMTFConfiguration::nLayers, OMTFConfiguration::nPdfAddrBits, OMTFConfiguration::nRefLayers, and pdfAllRef.

Referenced by L1TMuonOverlapTrackProducer::endJob(), and L1TMuonOverlapTrackProducer::writeMergedGPs().

135  {
136 
139  meanDistPhi2D.assign(OMTFConfiguration::nLayers, meanDistPhi1D);
140  meanDistPhi = meanDistPhi2D;
141  meanDistPhiCounts = meanDistPhi2D;
142 
146 
147  pdf2D.assign(OMTFConfiguration::nRefLayers,pdf1D);
149 
150 }
static unsigned int nLayers
vector2D meanDistPhiCounts
std::vector< int > vector1D
Definition: GoldenPattern.h:49
vector2D meanDistPhi
static unsigned int nPdfAddrBits
std::vector< vector1D > vector2D
Definition: GoldenPattern.h:50
std::vector< vector2D > vector3D
Definition: GoldenPattern.h:51
vector3D pdfAllRef
static unsigned int nRefLayers
void GoldenPattern::setMeanDistPhi ( const vector2D aMeanDistPhi)
inline

Definition at line 61 of file GoldenPattern.h.

References meanDistPhi.

Referenced by OMTFProcessor::averagePatterns(), XMLConfigReader::buildGP(), and OMTFProcessor::configure().

61 { meanDistPhi = aMeanDistPhi; }
vector2D meanDistPhi
void GoldenPattern::setPdf ( const vector3D aPdf)
inline

Definition at line 67 of file GoldenPattern.h.

References pdfAllRef.

Referenced by XMLConfigReader::buildGP(), OMTFProcessor::configure(), and OMTFProcessor::shiftGP().

67 { pdfAllRef = aPdf; }
vector3D pdfAllRef

Friends And Related Function Documentation

std::ostream& operator<< ( std::ostream &  out,
const GoldenPattern aPattern 
)
friend

Definition at line 89 of file GoldenPattern.cc.

89  {
90 
91  out <<"GoldenPattern "<< aPattern.theKey <<std::endl;
92  out <<"Number of reference layers: "<<aPattern.meanDistPhi[0].size()
93  <<", number of measurement layers: "<<aPattern.pdfAllRef.size()
94  <<std::endl;
95 
96  if(!aPattern.meanDistPhi.size()) return out;
97  if(!aPattern.pdfAllRef.size()) return out;
98 
99  out<<"Mean dist phi per layer:"<<std::endl;
100  for (unsigned int iRefLayer=0;iRefLayer<aPattern.meanDistPhi[0].size();++iRefLayer){
101  out<<"Ref layer: "<<iRefLayer<<" (";
102  for (unsigned int iLayer=0;iLayer<aPattern.meanDistPhi.size();++iLayer){
103  out<<std::setw(3)<<aPattern.meanDistPhi[iLayer][iRefLayer]<<"\t";
104  }
105  out<<")"<<std::endl;
106  }
107 
108  if(aPattern.meanDistPhiCounts.size()){
109  out<<"Counts number per layer:"<<std::endl;
110  for (unsigned int iRefLayer=0;iRefLayer<aPattern.meanDistPhi[0].size();++iRefLayer){
111  out<<"Ref layer: "<<iRefLayer<<" (";
112  for (unsigned int iLayer=0;iLayer<aPattern.meanDistPhi.size();++iLayer){
113  out<<aPattern.meanDistPhiCounts[iLayer][iRefLayer]<<"\t";
114  }
115  out<<")"<<std::endl;
116  }
117  }
118 /*
119  out<<"PDF per layer:"<<std::endl;
120  for (unsigned int iRefLayer=0;iRefLayer<aPattern.pdfAllRef[0].size();++iRefLayer){
121  out<<"Ref layer: "<<iRefLayer;
122  for (unsigned int iLayer=0;iLayer<aPattern.pdfAllRef.size();++iLayer){
123  out<<", measurement layer: "<<iLayer<<std::endl;
124  for (unsigned int iPdf=0;iPdf<exp2(OMTFConfiguration::nPdfAddrBits);++iPdf){
125  out<<std::setw(2)<<aPattern.pdfAllRef[iLayer][iRefLayer][iPdf]<<" ";
126  }
127  out<<std::endl;
128  }
129  }
130 */
131  return out;
132 }
vector2D meanDistPhiCounts
vector2D meanDistPhi
Key theKey
Pattern kinematical identification (iEta,iPt,iCharge)
vector3D pdfAllRef

Member Data Documentation

vector2D GoldenPattern::meanDistPhi
private

Mean positions in each layer First index: measurement layer number Second index: refLayer number

Definition at line 117 of file GoldenPattern.h.

Referenced by getMeanDistPhi(), hasCounts(), meanDistPhiValue(), normalise(), operator<<(), process1Layer1RefLayer(), propagateRefPhi(), reset(), and setMeanDistPhi().

vector2D GoldenPattern::meanDistPhiCounts
private

Vector holding number of counts. Used for making the patterns

Definition at line 121 of file GoldenPattern.h.

Referenced by addCount(), hasCounts(), normalise(), operator<<(), and reset().

vector3D GoldenPattern::pdfAllRef
private

Distributions for all reference layers First index: measurement layer number Second index: refLayer number Third index: pdf bin number within layer

Definition at line 112 of file GoldenPattern.h.

Referenced by addCount(), getPdf(), normalise(), operator<<(), pdfValue(), process1Layer1RefLayer(), reset(), and setPdf().

Key GoldenPattern::theKey
private

Pattern kinematical identification (iEta,iPt,iCharge)

Definition at line 106 of file GoldenPattern.h.

Referenced by key(), and operator<<().