CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
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);
61  if(!myOmtfConfig->getBendingLayers().count(iLogicLayer)) hits1D[iRefLayer]+=(val>0);
62  }
63  }
64 }
67 bool OMTFResult::empty() const{
68 
69  unsigned int nHits = 0;
70  for(unsigned int iRefLayer=0;iRefLayer<myOmtfConfig->nRefLayers();++iRefLayer){
71  nHits+=hits1D[iRefLayer];
72  }
73  return (nHits==0);
74 }
77 std::ostream & operator << (std::ostream &out, const OMTFResult & aResult){
78 
79  for(unsigned int iLogicLayer=0;iLogicLayer<aResult.results.size();++iLogicLayer){
80  out<<"Logic layer: "<<iLogicLayer<<" results: ";
81  for(unsigned int iRefLayer=0;iRefLayer<aResult.results[iLogicLayer].size();++iRefLayer){
82  out<<aResult.results[iLogicLayer][iRefLayer]<<"\t";
83  }
84  out<<std::endl;
85  }
86 
87  out<<" Sum over layers: ";
88  for(unsigned int iRefLayer=0;iRefLayer<aResult.results1D.size();++iRefLayer){
89  out<<aResult.results1D[iRefLayer]<<"\t";
90  }
91 
92  out<<std::endl;
93 
94  out<<" Number of hits: ";
95  for(unsigned int iRefLayer=0;iRefLayer<aResult.hits1D.size();++iRefLayer){
96  out<<aResult.hits1D[iRefLayer]<<"\t";
97  }
98 
99  return out;
100 }
const std::set< int > & getBendingLayers() const
unsigned int nRefLayers() const
const OMTFConfiguration * myOmtfConfig
Definition: OMTFResult.h:74
bool empty() const
Definition: OMTFResult.cc:67
unsigned int nLayers() const
vector2D results
Definition: OMTFResult.h:54
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:188
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
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