CMS 3D CMS Logo

OMTFResult.cc
Go to the documentation of this file.
1 #include <iostream>
2 #include <ostream>
3 #include <cmath>
4 
7 
10 void OMTFResult::configure(const OMTFConfiguration * omtfConfig) {
11 
12  myOmtfConfig = omtfConfig;
13 
14  clear();
15 
16 }
19 
20 void OMTFResult::setRefPhiRHits(unsigned int iRefLayer, int iRefPhiRHit){
21  refPhiRHit1D[iRefLayer] = iRefPhiRHit;
22 }
25 
26 void OMTFResult::addResult(unsigned int iRefLayer,
27  unsigned int iLayer,
28  unsigned int val,
29  int iRefPhi,
30  int iRefEta){
31 
32  refPhi1D[iRefLayer] = iRefPhi;
33  refEta1D[iRefLayer] = iRefEta;
34  results[iLayer][iRefLayer] = val;
35 
36 }
40 
41  results1D.assign(myOmtfConfig->nRefLayers(),0);
42  hits1D.assign(myOmtfConfig->nRefLayers(),0);
44  refPhi1D.assign(myOmtfConfig->nRefLayers(),1024);
45  refEta1D.assign(myOmtfConfig->nRefLayers(),1024);
46  hitsBits.assign(myOmtfConfig->nRefLayers(),0);
47  refPhiRHit1D.assign(myOmtfConfig->nRefLayers(),1024);
48 }
52 
53  for(unsigned int iLogicLayer=0;iLogicLayer<results.size();++iLogicLayer){
54  unsigned int connectedLayer = myOmtfConfig->getLogicToLogic().at(iLogicLayer);
55  for(unsigned int iRefLayer=0;iRefLayer<results[iLogicLayer].size();++iRefLayer){
57  unsigned int val = results[connectedLayer][iRefLayer]>0 ? results[iLogicLayer][iRefLayer]: 0;
58  results1D[iRefLayer]+=val;
59  hitsBits[iRefLayer]+=(val>0)*std::pow(2,iLogicLayer);
60 
61  if (myOmtfConfig->fwVersion() <= 4) {
63  if(!myOmtfConfig->getBendingLayers().count(iLogicLayer)) hits1D[iRefLayer]+=(val>0);
64  } else {
65  hits1D[iRefLayer]+=(val>0);
66  }
67 
68  }
69  }
70 }
73 bool OMTFResult::empty() const{
74 
75  unsigned int nHits = 0;
76  for(unsigned int iRefLayer=0;iRefLayer<myOmtfConfig->nRefLayers();++iRefLayer){
77  nHits+=hits1D[iRefLayer];
78  }
79  return (nHits==0);
80 }
83 std::ostream & operator << (std::ostream &out, const OMTFResult & aResult){
84 
85  for(unsigned int iLogicLayer=0;iLogicLayer<aResult.results.size();++iLogicLayer){
86  out<<"Logic layer: "<<iLogicLayer<<" results: ";
87  for(unsigned int iRefLayer=0;iRefLayer<aResult.results[iLogicLayer].size();++iRefLayer){
88  out<<aResult.results[iLogicLayer][iRefLayer]<<"\t";
89  }
90  out<<std::endl;
91  }
92 
93  out<<" Sum over layers: ";
94  for(unsigned int iRefLayer=0;iRefLayer<aResult.results1D.size();++iRefLayer){
95  out<<aResult.results1D[iRefLayer]<<"\t";
96  }
97 
98  out<<std::endl;
99 
100  out<<" Number of hits: ";
101  for(unsigned int iRefLayer=0;iRefLayer<aResult.hits1D.size();++iRefLayer){
102  out<<aResult.hits1D[iRefLayer]<<"\t";
103  }
104 
105  return out;
106 }
const std::set< int > & getBendingLayers() const
unsigned int nRefLayers() const
unsigned int fwVersion() const
const OMTFConfiguration * myOmtfConfig
Definition: OMTFResult.h:74
bool empty() const
Definition: OMTFResult.cc:73
unsigned int nLayers() const
vector2D results
Definition: OMTFResult.h:54
vector1D results1D
Sum of pdf weights for each reference layer.
Definition: OMTFResult.h:63
vector1D refPhiRHit1D
Reference phi for each reference layer - the input value.
Definition: OMTFResult.h:72
void configure(const OMTFConfiguration *omtfConfig)
Definition: OMTFResult.cc:10
const std::map< int, int > & getLogicToLogic() const
void setRefPhiRHits(unsigned int iRefLayer, int iRefPhiRHit)
Definition: OMTFResult.cc:20
vector1D refPhi1D
Reference phi for each reference layer.
Definition: OMTFResult.h:57
void finalise()
Definition: OMTFResult.cc:51
vector1D hits1D
Number of hits for each reference layer.
Definition: OMTFResult.h:66
void addResult(unsigned int iRefLayer, unsigned int iLayer, unsigned int val, int iRefPhi, int iRefEta)
Definition: OMTFResult.cc:26
friend std::ostream & operator<<(std::ostream &out, const OMTFResult &aResult)
Definition: OMTFResult.cc:83
vector1D refEta1D
Reference phi for each reference layer.
Definition: OMTFResult.h:60
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
void clear()
Definition: OMTFResult.cc:39
vector1D hitsBits
Words representing nimber of hit layers for each reference layer.
Definition: OMTFResult.h:69