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(), OMTFConfiguration::instance(), meanDistPhiCounts, ecaldqm::binning::nPhiBins, OMTFConfiguration::nPhiBins, and pdfAllRef.

57  {
58 
59  int nHitsInLayer = 0;
60  int phiDist = exp2(OMTFConfiguration::instance()->nPdfAddrBits);
61 
62  for(auto itHit: layerHits){
63  if(itHit>=(int)OMTFConfiguration::instance()->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::instance()->nPhiBins/2) phiDist-=(int)OMTFConfiguration::instance()->nPhiBins;
72  if(phiDist<=-(int)OMTFConfiguration::instance()->nPhiBins/2) phiDist+=(int)OMTFConfiguration::instance()->nPhiBins;
73 
75  int phiDistShift=phiDist+exp2(OMTFConfiguration::instance()->nPdfAddrBits-1);
76 
80  if(phiDistShift<0 ||
81  phiDistShift>exp2(OMTFConfiguration::instance()->nPdfAddrBits)-1){
82  return;
83  }
84 
85  if((int)iLayer==OMTFConfiguration::instance()->refToLogicNumber[iRefLayer]) ++meanDistPhiCounts[iLayer][iRefLayer];
86  ++pdfAllRef[iLayer][iRefLayer][phiDistShift];
87 }
vector2D meanDistPhiCounts
vector3D pdfAllRef
Abs< T >::type abs(const T &t)
Definition: Abs.h:22
unsigned int nPhiBins
static const OMTFConfiguration * instance()
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 222 of file GoldenPattern.cc.

References meanDistPhi, and meanDistPhiCounts.

222  {
223 
224  for (unsigned int iRefLayer=0;iRefLayer<meanDistPhi[0].size();++iRefLayer){
225  for (unsigned int iLayer=0;iLayer<meanDistPhi.size();++iLayer){
226  if(meanDistPhiCounts.size() && meanDistPhiCounts[iLayer][iRefLayer]) return true;
227  }
228  }
229  return false;
230 }
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 OMTFPatternMaker::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 154 of file GoldenPattern.cc.

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

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

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

References OMTFConfiguration::instance(), meanDistPhi, meanDistPhiCounts, and pdfAllRef.

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

136  {
137 
138  GoldenPattern::vector1D meanDistPhi1D(OMTFConfiguration::instance()->nRefLayers);
139  GoldenPattern::vector2D meanDistPhi2D(OMTFConfiguration::instance()->nLayers);
140  meanDistPhi2D.assign(OMTFConfiguration::instance()->nLayers, meanDistPhi1D);
141  meanDistPhi = meanDistPhi2D;
142  meanDistPhiCounts = meanDistPhi2D;
143 
144  GoldenPattern::vector1D pdf1D(exp2(OMTFConfiguration::instance()->nPdfAddrBits));
147 
148  pdf2D.assign(OMTFConfiguration::instance()->nRefLayers,pdf1D);
149  pdfAllRef.assign(OMTFConfiguration::instance()->nLayers,pdf2D);
150 
151 }
vector2D meanDistPhiCounts
std::vector< int > vector1D
Definition: GoldenPattern.h:49
vector2D meanDistPhi
std::vector< vector1D > vector2D
Definition: GoldenPattern.h:50
std::vector< vector2D > vector3D
Definition: GoldenPattern.h:51
vector3D pdfAllRef
static const OMTFConfiguration * instance()
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 90 of file GoldenPattern.cc.

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