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 
11 
12  clear();
13 
14 }
17 
18 void OMTFResult::setRefPhiRHits(unsigned int iRefLayer, int iRefPhiRHit){
19  refPhiRHit1D[iRefLayer] = iRefPhiRHit;
20 }
23 
24 void OMTFResult::addResult(unsigned int iRefLayer,
25  unsigned int iLayer,
26  unsigned int val,
27  int iRefPhi,
28  int iRefEta){
29 
30  refPhi1D[iRefLayer] = iRefPhi;
31  refEta1D[iRefLayer] = iRefEta;
32  results[iLayer][iRefLayer] = val;
33 
34 }
38 
39  results1D.assign(OMTFConfiguration::instance()->nRefLayers,0);
40  hits1D.assign(OMTFConfiguration::instance()->nRefLayers,0);
42  refPhi1D.assign(OMTFConfiguration::instance()->nRefLayers,1024);
43  refEta1D.assign(OMTFConfiguration::instance()->nRefLayers,1024);
44  hitsBits.assign(OMTFConfiguration::instance()->nRefLayers,0);
45  refPhiRHit1D.assign(OMTFConfiguration::instance()->nRefLayers,1024);
46 }
50 
51  for(unsigned int iLogicLayer=0;iLogicLayer<results.size();++iLogicLayer){
52 
53  //unsigned int connectedLayer = OMTFConfiguration::instance()->logicToLogic[iLogicLayer];
54  auto iter = OMTFConfiguration::instance()->logicToLogic.find(iLogicLayer);
55  unsigned int connectedLayer = iter->second;
56 
57  for(unsigned int iRefLayer=0;iRefLayer<results[iLogicLayer].size();++iRefLayer){
59  unsigned int val = results[connectedLayer][iRefLayer]>0 ? results[iLogicLayer][iRefLayer]: 0;
60  results1D[iRefLayer]+=val;
61  hitsBits[iRefLayer]+=(val>0)*std::pow(2,iLogicLayer);
63  if(!OMTFConfiguration::instance()->bendingLayers.count(iLogicLayer)) hits1D[iRefLayer]+=(val>0);
64  }
65  }
66 }
69 bool OMTFResult::empty() const{
70 
71  unsigned int nHits = 0;
72 
73  for(unsigned int iRefLayer=0;iRefLayer<OMTFConfiguration::instance()->nRefLayers;++iRefLayer){
74  nHits+=hits1D[iRefLayer];
75  }
76  return (nHits==0);
77 }
80 std::ostream & operator << (std::ostream &out, const OMTFResult & aResult){
81 
82  for(unsigned int iLogicLayer=0;iLogicLayer<aResult.results.size();++iLogicLayer){
83  out<<"Logic layer: "<<iLogicLayer<<" results: ";
84  for(unsigned int iRefLayer=0;iRefLayer<aResult.results[iLogicLayer].size();++iRefLayer){
85  out<<aResult.results[iLogicLayer][iRefLayer]<<"\t";
86  }
87  out<<std::endl;
88  }
89 
90  out<<" Sum over layers: ";
91  for(unsigned int iRefLayer=0;iRefLayer<aResult.results1D.size();++iRefLayer){
92  out<<aResult.results1D[iRefLayer]<<"\t";
93  }
94 
95  out<<std::endl;
96 
97  out<<" Number of hits: ";
98  for(unsigned int iRefLayer=0;iRefLayer<aResult.hits1D.size();++iRefLayer){
99  out<<aResult.hits1D[iRefLayer]<<"\t";
100  }
101 
102  return out;
103 }
std::map< int, int > logicToLogic
bool empty() const
Definition: OMTFResult.cc:69
vector2D results
Definition: OMTFResult.h:50
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:187
vector1D results1D
Sum of pdf weights for each reference layer.
Definition: OMTFResult.h:59
vector1D refPhiRHit1D
Reference phi for each reference layer - the input value.
Definition: OMTFResult.h:68
void setRefPhiRHits(unsigned int iRefLayer, int iRefPhiRHit)
Definition: OMTFResult.cc:18
vector1D refPhi1D
Reference phi for each reference layer.
Definition: OMTFResult.h:53
unsigned int nRefLayers
void finalise()
Definition: OMTFResult.cc:49
std::set< int > bendingLayers
vector1D hits1D
Number of hits for each reference layer.
Definition: OMTFResult.h:62
void addResult(unsigned int iRefLayer, unsigned int iLayer, unsigned int val, int iRefPhi, int iRefEta)
Definition: OMTFResult.cc:24
vector1D refEta1D
Reference phi for each reference layer.
Definition: OMTFResult.h:56
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
static const OMTFConfiguration * instance()
void clear()
Definition: OMTFResult.cc:37
vector1D hitsBits
Words representing nimber of hit layers for each reference layer.
Definition: OMTFResult.h:65