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 ()
 
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 46 of file GoldenPattern.h.

Member Typedef Documentation

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

Definition at line 53 of file GoldenPattern.h.

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

Definition at line 50 of file GoldenPattern.h.

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

Definition at line 51 of file GoldenPattern.h.

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

Definition at line 52 of file GoldenPattern.h.

Constructor & Destructor Documentation

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

Definition at line 58 of file GoldenPattern.h.

58 : 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 53 of file GoldenPattern.cc.

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

56  {
57 
58  int nHitsInLayer = 0;
59  int phiDist = exp2(myOmtfConfig->nPdfAddrBits());
60  for(auto itHit: layerHits){
61  if(itHit>=(int)myOmtfConfig->nPhiBins()) continue;
62  if(abs(itHit-phiRefHit)<phiDist) phiDist = itHit-phiRefHit;
63  ++nHitsInLayer;
64  }
66  if(nHitsInLayer>1 || nHitsInLayer==0) return;
67 
69  if(phiDist>=(int)myOmtfConfig->nPhiBins()/2) phiDist-=(int)myOmtfConfig->nPhiBins();
70  if(phiDist<=-(int)myOmtfConfig->nPhiBins()/2) phiDist+=(int)myOmtfConfig->nPhiBins();
71 
73  int phiDistShift=phiDist+exp2(myOmtfConfig->nPdfAddrBits()-1);
74 
78  if(phiDistShift<0 ||
79  phiDistShift>exp2(myOmtfConfig->nPdfAddrBits())-1){
80  return;
81  }
82 
83  if((int)iLayer==myOmtfConfig->getRefToLogicNumber()[iRefLayer]) ++meanDistPhiCounts[iLayer][iRefLayer];
84  ++pdfAllRef[iLayer][iRefLayer][phiDistShift];
85 }
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 64 of file GoldenPattern.h.

References meanDistPhi.

Referenced by OMTFProcessor::averagePatterns().

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

Definition at line 66 of file GoldenPattern.h.

References pdfAllRef.

Referenced by OMTFProcessor::shiftGP().

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

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

Definition at line 218 of file GoldenPattern.cc.

References meanDistPhi, and meanDistPhiCounts.

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

Definition at line 60 of file GoldenPattern.h.

References theKey.

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

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

Definition at line 70 of file GoldenPattern.h.

References meanDistPhi.

Referenced by XMLConfigWriter::writeGPData().

70 { 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 151 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().

151  {
152 
153  for (unsigned int iRefLayer=0;iRefLayer<pdfAllRef[0].size();++iRefLayer){
154  for (unsigned int iLayer=0;iLayer<pdfAllRef.size();++iLayer){
155  for (unsigned int iPdf=0;iPdf<pdfAllRef[iLayer][iRefLayer].size();++iPdf){
156  float pVal = log((float)pdfAllRef[iLayer][iRefLayer][iPdf]/meanDistPhiCounts[myOmtfConfig->getRefToLogicNumber()[iRefLayer]][iRefLayer]);
157  if(pVal<log(myOmtfConfig->minPdfVal())) continue;
158  meanDistPhi[iLayer][iRefLayer]+=(iPdf - exp2(myOmtfConfig->nPdfAddrBits()-1))*pdfAllRef[iLayer][iRefLayer][iPdf];
159  if((int)iLayer!=myOmtfConfig->getRefToLogicNumber()[iRefLayer]) meanDistPhiCounts[iLayer][iRefLayer]+=pdfAllRef[iLayer][iRefLayer][iPdf];
160  }
161  }
162  }
163 
165  for (unsigned int iRefLayer=0;iRefLayer<meanDistPhi[0].size();++iRefLayer){
166  for (unsigned int iLayer=0;iLayer<meanDistPhi.size();++iLayer){
167  if(meanDistPhiCounts.size() && meanDistPhiCounts[iLayer][iRefLayer]){
168  if(meanDistPhiCounts[iLayer][iRefLayer]<1000) meanDistPhi[iLayer][iRefLayer] = 0;
169  else meanDistPhi[iLayer][iRefLayer] = rint((float)meanDistPhi[iLayer][iRefLayer]/meanDistPhiCounts[iLayer][iRefLayer]);
170  }
171  }
172  }
173  const float minPlog = log(myOmtfConfig->minPdfVal());
174  const unsigned int nPdfValBits = myOmtfConfig->nPdfValBits();
176  float pVal;
177  int digitisedVal, truncatedValue;
178  for (unsigned int iRefLayer=0;iRefLayer<pdfAllRef[0].size();++iRefLayer){
179  for (unsigned int iLayer=0;iLayer<pdfAllRef.size();++iLayer){
180  for (unsigned int iPdf=0;iPdf<pdfAllRef[iLayer][iRefLayer].size();++iPdf){
181  if(!meanDistPhiCounts[myOmtfConfig->getRefToLogicNumber()[iRefLayer]][iRefLayer] ||
182  !pdfAllRef[iLayer][iRefLayer][iPdf]) continue;
183  pVal = log((float)pdfAllRef[iLayer][iRefLayer][iPdf]/meanDistPhiCounts[myOmtfConfig->getRefToLogicNumber()[iRefLayer]][iRefLayer]);
185  if(pVal<minPlog || meanDistPhiCounts[iLayer][iRefLayer]<1000){
186  pdfAllRef[iLayer][iRefLayer][iPdf] = 0;
187  continue;
188  }
192  digitisedVal = rint((std::pow(2,nPdfValBits)-1) - (pVal/minPlog)*(std::pow(2,nPdfValBits)-1));
194  truncatedValue = 0 | (digitisedVal & ((int)pow(2,nPdfValBits)-1));
195  pdfAllRef[iLayer][iRefLayer][iPdf] = truncatedValue;
196  }
197  }
198  }
199 
200 
201  vector3D pdfAllRefTmp = pdfAllRef;
202 
203  const unsigned int nPdfAddrBits = 7;
204  for (unsigned int iRefLayer=0;iRefLayer<pdfAllRef[0].size();++iRefLayer){
205  for (unsigned int iLayer=0;iLayer<pdfAllRef.size();++iLayer){
206  for (unsigned int iPdf=0;iPdf<pdfAllRef[iLayer][iRefLayer].size();++iPdf){
207  pdfAllRef[iLayer][iRefLayer][iPdf] = 0;
209  int index = iPdf - exp2(myOmtfConfig->nPdfAddrBits()-1) - meanDistPhi[iLayer][iRefLayer] + exp2(nPdfAddrBits-1);
210  if(index<0 || index>exp2(nPdfAddrBits)-1) continue;
211  pdfAllRef[iLayer][iRefLayer][index] = pdfAllRefTmp[iLayer][iRefLayer][iPdf];
212  }
213  }
214  }
215 }
vector2D meanDistPhiCounts
const OMTFConfiguration * myOmtfConfig
vector2D meanDistPhi
std::vector< vector2D > vector3D
Definition: GoldenPattern.h:52
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 72 of file GoldenPattern.h.

References pdfAllRef.

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

72 {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, 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  phiDist+=exp2(myOmtfConfig->nPdfAddrBits()-1);
34  if(phiDist<0 ||
35  phiDist>exp2(myOmtfConfig->nPdfAddrBits())-1){
36  return aResult;
37  }
38 
39  int pdfVal = pdfAllRef[iLayer][iRefLayer][phiDist];
40  return GoldenPattern::layerResult(pdfVal,pdfVal>0);
41 }
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:53
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 44 of file GoldenPattern.cc.

References meanDistPhi.

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

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

Definition at line 134 of file GoldenPattern.cc.

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

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

134  {
135 
137  GoldenPattern::vector2D meanDistPhi2D(myOmtfConfig->nLayers());
138  meanDistPhi2D.assign(myOmtfConfig->nLayers(), meanDistPhi1D);
139  meanDistPhi = meanDistPhi2D;
140  meanDistPhiCounts = meanDistPhi2D;
141 
145 
146  pdf2D.assign(myOmtfConfig->nRefLayers(),pdf1D);
147  pdfAllRef.assign(myOmtfConfig->nLayers(),pdf2D);
148 }
unsigned int nRefLayers() const
vector2D meanDistPhiCounts
std::vector< int > vector1D
Definition: GoldenPattern.h:50
unsigned int nLayers() const
const OMTFConfiguration * myOmtfConfig
vector2D meanDistPhi
std::vector< vector1D > vector2D
Definition: GoldenPattern.h:51
std::vector< vector2D > vector3D
Definition: GoldenPattern.h:52
unsigned int nPdfAddrBits() const
vector3D pdfAllRef
void GoldenPattern::setMeanDistPhi ( const vector2D aMeanDistPhi)
inline

Definition at line 62 of file GoldenPattern.h.

References meanDistPhi.

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

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

Definition at line 68 of file GoldenPattern.h.

References pdfAllRef.

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

68 { pdfAllRef = aPdf; }
vector3D pdfAllRef

Friends And Related Function Documentation

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

Definition at line 88 of file GoldenPattern.cc.

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