test
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, const OMTFConfiguration *omtfConfig)
 
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 (unsigned int nPdfAddrBits)
 
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
 
const OMTFConfigurationmyOmtfConfig
 
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 44 of file GoldenPattern.h.

Member Typedef Documentation

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

Definition at line 51 of file GoldenPattern.h.

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

Definition at line 48 of file GoldenPattern.h.

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

Definition at line 49 of file GoldenPattern.h.

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

Definition at line 50 of file GoldenPattern.h.

Constructor & Destructor Documentation

GoldenPattern::GoldenPattern ( const Key aKey,
const OMTFConfiguration omtfConfig 
)
inline

Definition at line 56 of file GoldenPattern.h.

56 : theKey(aKey), myOmtfConfig(omtfConfig){}
const OMTFConfiguration * myOmtfConfig
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 50 of file GoldenPattern.cc.

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

53  {
54 
55  int nHitsInLayer = 0;
56  int phiDist = exp2(myOmtfConfig->nPdfAddrBits());
57  for(auto itHit: layerHits){
58  if(itHit>=(int)myOmtfConfig->nPhiBins()) continue;
59  if(abs(itHit-phiRefHit)<phiDist) phiDist = itHit-phiRefHit;
60  ++nHitsInLayer;
61  }
63  if(nHitsInLayer>1 || nHitsInLayer==0) return;
64 
66  if(phiDist>=(int)myOmtfConfig->nPhiBins()/2) phiDist-=(int)myOmtfConfig->nPhiBins();
67  if(phiDist<=-(int)myOmtfConfig->nPhiBins()/2) phiDist+=(int)myOmtfConfig->nPhiBins();
68 
70  int phiDistShift=phiDist+exp2(myOmtfConfig->nPdfAddrBits()-1);
71 
75  if(phiDistShift<0 ||
76  phiDistShift>exp2(myOmtfConfig->nPdfAddrBits())-1){
77  return;
78  }
79 
80  if((int)iLayer==myOmtfConfig->getRefToLogicNumber()[iRefLayer]) ++meanDistPhiCounts[iLayer][iRefLayer];
81  ++pdfAllRef[iLayer][iRefLayer][phiDistShift];
82 }
vector2D meanDistPhiCounts
unsigned int nPhiBins() const
const OMTFConfiguration * myOmtfConfig
unsigned int nPdfAddrBits() const
vector3D pdfAllRef
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
const std::vector< int > & getRefToLogicNumber() const
const vector2D& GoldenPattern::getMeanDistPhi ( ) const
inline

Definition at line 62 of file GoldenPattern.h.

References meanDistPhi.

Referenced by OMTFProcessor::averagePatterns().

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

Definition at line 64 of file GoldenPattern.h.

References pdfAllRef.

Referenced by OMTFProcessor::shiftGP().

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

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

Definition at line 213 of file GoldenPattern.cc.

References meanDistPhi, and meanDistPhiCounts.

213  {
214 
215  for (unsigned int iRefLayer=0;iRefLayer<meanDistPhi[0].size();++iRefLayer){
216  for (unsigned int iLayer=0;iLayer<meanDistPhi.size();++iLayer){
217  if(meanDistPhiCounts.size() && meanDistPhiCounts[iLayer][iRefLayer]) return true;
218  }
219  }
220  return false;
221 }
vector2D meanDistPhiCounts
vector2D meanDistPhi
Key GoldenPattern::key ( ) const
inline

Definition at line 58 of file GoldenPattern.h.

References theKey.

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

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

Definition at line 68 of file GoldenPattern.h.

References meanDistPhi.

Referenced by XMLConfigWriter::writeGPData().

68 { return meanDistPhi[iLayer][iRefLayer];}
vector2D meanDistPhi
void GoldenPattern::normalise ( unsigned int  nPdfAddrBits)

Normalise event counts in mean dist phi, and pdf vectors to get the real values of meand dist phi and probability. The pdf width is passed to this method, since the width stored in configuration is extended during the pattern making phase.

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 149 of file GoldenPattern.cc.

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

149  {
150 
151  for (unsigned int iRefLayer=0;iRefLayer<pdfAllRef[0].size();++iRefLayer){
152  for (unsigned int iLayer=0;iLayer<pdfAllRef.size();++iLayer){
153  for (unsigned int iPdf=0;iPdf<pdfAllRef[iLayer][iRefLayer].size();++iPdf){
154  float pVal = log((float)pdfAllRef[iLayer][iRefLayer][iPdf]/meanDistPhiCounts[myOmtfConfig->getRefToLogicNumber()[iRefLayer]][iRefLayer]);
155  if(pVal<log(myOmtfConfig->minPdfVal())) continue;
156  meanDistPhi[iLayer][iRefLayer]+=(iPdf - exp2(myOmtfConfig->nPdfAddrBits()-1))*pdfAllRef[iLayer][iRefLayer][iPdf];
157  if((int)iLayer!=myOmtfConfig->getRefToLogicNumber()[iRefLayer]) meanDistPhiCounts[iLayer][iRefLayer]+=pdfAllRef[iLayer][iRefLayer][iPdf];
158  }
159  }
160  }
161 
163  for (unsigned int iRefLayer=0;iRefLayer<meanDistPhi[0].size();++iRefLayer){
164  for (unsigned int iLayer=0;iLayer<meanDistPhi.size();++iLayer){
165  if(meanDistPhiCounts.size() && meanDistPhiCounts[iLayer][iRefLayer]){
166  if(meanDistPhiCounts[iLayer][iRefLayer]<1000) meanDistPhi[iLayer][iRefLayer] = 0;
167  else meanDistPhi[iLayer][iRefLayer] = rint((float)meanDistPhi[iLayer][iRefLayer]/meanDistPhiCounts[iLayer][iRefLayer]);
168  }
169  }
170  }
171  const float minPlog = log(myOmtfConfig->minPdfVal());
172  const unsigned int nPdfValBits = myOmtfConfig->nPdfValBits();
174  float pVal;
175  int digitisedVal, truncatedValue;
176  for (unsigned int iRefLayer=0;iRefLayer<pdfAllRef[0].size();++iRefLayer){
177  for (unsigned int iLayer=0;iLayer<pdfAllRef.size();++iLayer){
178  for (unsigned int iPdf=0;iPdf<pdfAllRef[iLayer][iRefLayer].size();++iPdf){
179  if(!meanDistPhiCounts[myOmtfConfig->getRefToLogicNumber()[iRefLayer]][iRefLayer] ||
180  !pdfAllRef[iLayer][iRefLayer][iPdf]) continue;
181  pVal = log((float)pdfAllRef[iLayer][iRefLayer][iPdf]/meanDistPhiCounts[myOmtfConfig->getRefToLogicNumber()[iRefLayer]][iRefLayer]);
183  if((pVal<minPlog || meanDistPhiCounts[iLayer][iRefLayer]<1000)){
184  pdfAllRef[iLayer][iRefLayer][iPdf] = 0;
185  continue;
186  }
190  digitisedVal = rint((std::pow(2,nPdfValBits)-1) - (pVal/minPlog)*(std::pow(2,nPdfValBits)-1));
192  truncatedValue = 0 | (digitisedVal & ((int)pow(2,nPdfValBits)-1));
193  pdfAllRef[iLayer][iRefLayer][iPdf] = truncatedValue;
194  }
195  }
196  }
197 
198  vector3D pdfAllRefTmp = pdfAllRef;
199  for (unsigned int iRefLayer=0;iRefLayer<pdfAllRef[0].size();++iRefLayer){
200  for (unsigned int iLayer=0;iLayer<pdfAllRef.size();++iLayer){
201  for (unsigned int iPdf=0;iPdf<pdfAllRef[iLayer][iRefLayer].size();++iPdf){
202  pdfAllRef[iLayer][iRefLayer][iPdf] = 0;
204  int index = iPdf - exp2(myOmtfConfig->nPdfAddrBits()-1) - meanDistPhi[iLayer][iRefLayer] + exp2(nPdfAddrBits-1);
205  if(index<0 || index>exp2(nPdfAddrBits)-1) continue;
206  pdfAllRef[iLayer][iRefLayer][index] = pdfAllRefTmp[iLayer][iRefLayer][iPdf];
207  }
208  }
209  }
210 }
vector2D meanDistPhiCounts
const OMTFConfiguration * myOmtfConfig
vector2D meanDistPhi
std::vector< vector2D > vector3D
Definition: GoldenPattern.h:50
unsigned int nPdfAddrBits() const
vector3D pdfAllRef
float minPdfVal() const
const std::vector< int > & getRefToLogicNumber() const
unsigned int nPdfValBits() const
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
int GoldenPattern::pdfValue ( unsigned int  iLayer,
unsigned int  iRefLayer,
unsigned int  iBin 
) const
inline

Definition at line 70 of file GoldenPattern.h.

References pdfAllRef.

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

70 {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

Check if phiDist is within pdf range -63 +63

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

Definition at line 13 of file GoldenPattern.cc.

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

16  {
17 
19 
20  int phiMean = meanDistPhi[iLayer][iRefLayer];
21  int phiDist = exp2(myOmtfConfig->nPdfAddrBits());
24  for(auto itHit: layerHits){
25  if(itHit>=(int)myOmtfConfig->nPhiBins()) continue;
26  if(abs(itHit-phiMean-phiRefHit)<abs(phiDist)) phiDist = itHit-phiMean-phiRefHit;
27  }
28 
30  if(abs(phiDist)>(exp2(myOmtfConfig->nPdfAddrBits()-1) -1)) return aResult;
31 
33  phiDist+=exp2(myOmtfConfig->nPdfAddrBits()-1);
34 
35  int pdfVal = pdfAllRef[iLayer][iRefLayer][phiDist];
36 
37  return GoldenPattern::layerResult(pdfVal,pdfVal>0);
38 }
unsigned int nPhiBins() const
const OMTFConfiguration * myOmtfConfig
vector2D meanDistPhi
unsigned int nPdfAddrBits() const
vector3D pdfAllRef
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
std::pair< int, bool > layerResult
Definition: GoldenPattern.h:51
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 41 of file GoldenPattern.cc.

References meanDistPhi.

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

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

Definition at line 132 of file GoldenPattern.cc.

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

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

132  {
133 
135  GoldenPattern::vector2D meanDistPhi2D(myOmtfConfig->nLayers());
136  meanDistPhi2D.assign(myOmtfConfig->nLayers(), meanDistPhi1D);
137  meanDistPhi = meanDistPhi2D;
138  meanDistPhiCounts = meanDistPhi2D;
139 
143 
144  pdf2D.assign(myOmtfConfig->nRefLayers(),pdf1D);
145  pdfAllRef.assign(myOmtfConfig->nLayers(),pdf2D);
146 }
unsigned int nRefLayers() const
vector2D meanDistPhiCounts
std::vector< int > vector1D
Definition: GoldenPattern.h:48
unsigned int nLayers() const
const OMTFConfiguration * myOmtfConfig
vector2D meanDistPhi
std::vector< vector1D > vector2D
Definition: GoldenPattern.h:49
std::vector< vector2D > vector3D
Definition: GoldenPattern.h:50
unsigned int nPdfAddrBits() const
vector3D pdfAllRef
void GoldenPattern::setMeanDistPhi ( const vector2D aMeanDistPhi)
inline

Definition at line 60 of file GoldenPattern.h.

References meanDistPhi.

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

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

Definition at line 66 of file GoldenPattern.h.

References pdfAllRef.

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

66 { pdfAllRef = aPdf; }
vector3D pdfAllRef

Friends And Related Function Documentation

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

Definition at line 85 of file GoldenPattern.cc.

85  {
86 
87  out <<"GoldenPattern "<< aPattern.theKey <<std::endl;
88  out <<"Number of reference layers: "<<aPattern.meanDistPhi[0].size()
89  <<", number of measurement layers: "<<aPattern.pdfAllRef.size()
90  <<std::endl;
91 
92  if(!aPattern.meanDistPhi.size()) return out;
93  if(!aPattern.pdfAllRef.size()) return out;
94 
95  out<<"Mean dist phi per layer:"<<std::endl;
96  for (unsigned int iRefLayer=0;iRefLayer<aPattern.meanDistPhi[0].size();++iRefLayer){
97  out<<"Ref layer: "<<iRefLayer<<" (";
98  for (unsigned int iLayer=0;iLayer<aPattern.meanDistPhi.size();++iLayer){
99  out<<std::setw(3)<<aPattern.meanDistPhi[iLayer][iRefLayer]<<"\t";
100  }
101  out<<")"<<std::endl;
102  }
103 
104  if(aPattern.meanDistPhiCounts.size()){
105  out<<"Counts number per layer:"<<std::endl;
106  for (unsigned int iRefLayer=0;iRefLayer<aPattern.meanDistPhi[0].size();++iRefLayer){
107  out<<"Ref layer: "<<iRefLayer<<" (";
108  for (unsigned int iLayer=0;iLayer<aPattern.meanDistPhi.size();++iLayer){
109  out<<aPattern.meanDistPhiCounts[iLayer][iRefLayer]<<"\t";
110  }
111  out<<")"<<std::endl;
112  }
113  }
114 
115  unsigned int nPdfAddrBits = 7;
116  out<<"PDF per layer:"<<std::endl;
117  for (unsigned int iRefLayer=0;iRefLayer<aPattern.pdfAllRef[0].size();++iRefLayer){
118  out<<"Ref layer: "<<iRefLayer;
119  for (unsigned int iLayer=0;iLayer<aPattern.pdfAllRef.size();++iLayer){
120  out<<", measurement layer: "<<iLayer<<std::endl;
121  for (unsigned int iPdf=0;iPdf<exp2(nPdfAddrBits);++iPdf){
122  out<<std::setw(2)<<aPattern.pdfAllRef[iLayer][iRefLayer][iPdf]<<" ";
123  }
124  out<<std::endl;
125  }
126  }
127 
128  return out;
129 }
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 118 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 122 of file GoldenPattern.h.

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

const OMTFConfiguration* GoldenPattern::myOmtfConfig
private

Definition at line 124 of file GoldenPattern.h.

Referenced by addCount(), normalise(), process1Layer1RefLayer(), 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 113 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 107 of file GoldenPattern.h.

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