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  myOmtfConfig = omtfConfig;
12 
13  clear();
14 }
17 
18 void OMTFResult::setRefPhiRHits(unsigned int iRefLayer, int iRefPhiRHit) { refPhiRHit1D[iRefLayer] = iRefPhiRHit; }
21 
22 void OMTFResult::addResult(unsigned int iRefLayer, unsigned int iLayer, unsigned int val, int iRefPhi, int iRefEta) {
23  refPhi1D[iRefLayer] = iRefPhi;
24  refEta1D[iRefLayer] = iRefEta;
25  results[iLayer][iRefLayer] = val;
26 }
30  results1D.assign(myOmtfConfig->nRefLayers(), 0);
31  hits1D.assign(myOmtfConfig->nRefLayers(), 0);
33  refPhi1D.assign(myOmtfConfig->nRefLayers(), 1024);
34  refEta1D.assign(myOmtfConfig->nRefLayers(), 1024);
35  hitsBits.assign(myOmtfConfig->nRefLayers(), 0);
36  refPhiRHit1D.assign(myOmtfConfig->nRefLayers(), 1024);
37 }
41  for (unsigned int iLogicLayer = 0; iLogicLayer < results.size(); ++iLogicLayer) {
42  unsigned int connectedLayer = myOmtfConfig->getLogicToLogic().at(iLogicLayer);
43  for (unsigned int iRefLayer = 0; iRefLayer < results[iLogicLayer].size(); ++iRefLayer) {
45  unsigned int val = results[connectedLayer][iRefLayer] > 0 ? results[iLogicLayer][iRefLayer] : 0;
46  results1D[iRefLayer] += val;
47  hitsBits[iRefLayer] += (val > 0) * std::pow(2, iLogicLayer);
48 
49  if (myOmtfConfig->fwVersion() <= 4) {
51  if (!myOmtfConfig->getBendingLayers().count(iLogicLayer))
52  hits1D[iRefLayer] += (val > 0);
53  } else {
54  hits1D[iRefLayer] += (val > 0);
55  }
56  }
57  }
58 }
61 bool OMTFResult::empty() const {
62  unsigned int nHits = 0;
63  for (unsigned int iRefLayer = 0; iRefLayer < myOmtfConfig->nRefLayers(); ++iRefLayer) {
64  nHits += hits1D[iRefLayer];
65  }
66  return (nHits == 0);
67 }
70 std::ostream &operator<<(std::ostream &out, const OMTFResult &aResult) {
71  for (unsigned int iLogicLayer = 0; iLogicLayer < aResult.results.size(); ++iLogicLayer) {
72  out << "Logic layer: " << iLogicLayer << " results: ";
73  for (unsigned int iRefLayer = 0; iRefLayer < aResult.results[iLogicLayer].size(); ++iRefLayer) {
74  out << aResult.results[iLogicLayer][iRefLayer] << "\t";
75  }
76  out << std::endl;
77  }
78 
79  out << " Sum over layers: ";
80  for (unsigned int iRefLayer = 0; iRefLayer < aResult.results1D.size(); ++iRefLayer) {
81  out << aResult.results1D[iRefLayer] << "\t";
82  }
83 
84  out << std::endl;
85 
86  out << " Number of hits: ";
87  for (unsigned int iRefLayer = 0; iRefLayer < aResult.hits1D.size(); ++iRefLayer) {
88  out << aResult.hits1D[iRefLayer] << "\t";
89  }
90 
91  return out;
92 }
OMTFResult::setRefPhiRHits
void setRefPhiRHits(unsigned int iRefLayer, int iRefPhiRHit)
Definition: OMTFResult.cc:18
OMTFResult::configure
void configure(const OMTFConfiguration *omtfConfig)
Definition: OMTFResult.cc:10
OMTFResult::refPhi1D
vector1D refPhi1D
Reference phi for each reference layer.
Definition: OMTFResult.h:51
OMTFResult::hits1D
vector1D hits1D
Number of hits for each reference layer.
Definition: OMTFResult.h:60
OMTFResult::finalise
void finalise()
Definition: OMTFResult.cc:40
OMTFConfiguration
Definition: OMTFConfiguration.h:44
OMTFResult::addResult
void addResult(unsigned int iRefLayer, unsigned int iLayer, unsigned int val, int iRefPhi, int iRefEta)
Definition: OMTFResult.cc:22
OMTFConfiguration::fwVersion
unsigned int fwVersion() const
Definition: OMTFConfiguration.h:81
OMTFConfiguration.h
OMTFResult::refEta1D
vector1D refEta1D
Reference phi for each reference layer.
Definition: OMTFResult.h:54
OMTFResult::empty
bool empty() const
Definition: OMTFResult.cc:61
OMTFResult::clear
void clear()
Definition: OMTFResult.cc:29
OMTFResult.h
OMTFResult::hitsBits
vector1D hitsBits
Words representing nimber of hit layers for each reference layer.
Definition: OMTFResult.h:63
OMTFConfiguration::getLogicToLogic
const std::map< int, int > & getLogicToLogic() const
Definition: OMTFConfiguration.h:103
OMTFConfiguration::nLayers
unsigned int nLayers() const
Definition: OMTFConfiguration.h:87
operator<<
std::ostream & operator<<(std::ostream &out, const OMTFResult &aResult)
Definition: OMTFResult.cc:70
OMTFResult::myOmtfConfig
const OMTFConfiguration * myOmtfConfig
Definition: OMTFResult.h:68
OMTFResult::results1D
vector1D results1D
Sum of pdf weights for each reference layer.
Definition: OMTFResult.h:57
OMTFResult::results
vector2D results
Definition: OMTFResult.h:48
heppy_batch.val
val
Definition: heppy_batch.py:351
OMTFConfiguration::nRefLayers
unsigned int nRefLayers() const
Definition: OMTFConfiguration.h:89
OMTFConfiguration::getBendingLayers
const std::set< int > & getBendingLayers() const
Definition: OMTFConfiguration.h:104
MillePedeFileConverter_cfg.out
out
Definition: MillePedeFileConverter_cfg.py:31
funct::pow
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
OMTFResult
Definition: OMTFResult.h:9
OMTFResult::refPhiRHit1D
vector1D refPhiRHit1D
Reference phi for each reference layer - the input value.
Definition: OMTFResult.h:66