CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
OMTFinput.cc
Go to the documentation of this file.
1 #include <cassert>
2 #include <iostream>
3 #include <cmath>
4 
8 
13  clear();
14 }
17 const OMTFinput::vector1D &OMTFinput::getLayerData(unsigned int iLayer, bool giveEta) const {
18  assert(iLayer < measurementsPhi.size());
19 
20  if (giveEta)
21  return measurementsEta[iLayer];
22  return measurementsPhi[iLayer];
23 }
26 std::bitset<128> OMTFinput::getRefHits(unsigned int iProcessor) const {
27  std::bitset<128> refHits;
28 
29  unsigned int iRefHit = 0;
30  for (auto iRefHitDef : myOmtfConfig->getRefHitsDefs()[iProcessor]) {
31  int iPhi = getLayerData(myOmtfConfig->getRefToLogicNumber()[iRefHitDef.iRefLayer])[iRefHitDef.iInput];
32  int iEta = getLayerData(myOmtfConfig->getRefToLogicNumber()[iRefHitDef.iRefLayer], true)[iRefHitDef.iInput];
33  if (iPhi < (int)myOmtfConfig->nPhiBins()) {
34  refHits.set(iRefHit, iRefHitDef.fitsRange(iPhi));
35  refHitsEta[iRefHit] = iEta;
36  }
37  iRefHit++;
38  }
39 
40  return refHits;
41 }
44 bool OMTFinput::addLayerHit(unsigned int iLayer, unsigned int iInput, int iPhi, int iEta, bool allowOverwrite) {
45  bool overwrite = false;
46  assert(iLayer < myOmtfConfig->nLayers());
47  assert(iInput < 14);
48 
49  if (iPhi >= (int)myOmtfConfig->nPhiBins())
50  return true;
51 
52  if (allowOverwrite && measurementsPhi[iLayer][iInput] == iPhi && measurementsEta[iLayer][iInput] == iEta)
53  return true;
54 
55  if (measurementsPhi[iLayer][iInput] != (int)myOmtfConfig->nPhiBins())
56  ++iInput;
57  if (measurementsPhi[iLayer][iInput] != (int)myOmtfConfig->nPhiBins())
58  overwrite = true;
59 
60  if (iInput > 13)
61  return true;
62 
63  measurementsPhi[iLayer][iInput] = iPhi;
64  measurementsEta[iLayer][iInput] = iEta;
65 
66  return overwrite;
67 }
70 void OMTFinput::readData(XMLConfigReader *aReader, unsigned int iEvent, unsigned int iProcessor) {
71  measurementsPhi = aReader->readEvent(iEvent, iProcessor);
72  measurementsEta = aReader->readEvent(iEvent, iProcessor, true);
73 }
76 void OMTFinput::mergeData(const OMTFinput *aInput) {
77  for (unsigned int iLayer = 0; iLayer < myOmtfConfig->nLayers(); ++iLayer) {
78  const OMTFinput::vector1D &aPhiVec = aInput->getLayerData(iLayer, false);
79  const OMTFinput::vector1D &aEtaVec = aInput->getLayerData(iLayer, true);
80  if (aPhiVec.empty())
81  continue;
82 
83  OMTFinput::vector1D layerData = getLayerData(iLayer, false);
84  for (unsigned int iInput = 0; iInput < 14; ++iInput) {
85  addLayerHit(iLayer, iInput, aPhiVec[iInput], aEtaVec[iInput]);
86  }
87  }
88 }
92  vector1D aLayer1D(14, myOmtfConfig->nPhiBins());
93  measurementsPhi.assign(myOmtfConfig->nLayers(), aLayer1D);
94  measurementsEta.assign(myOmtfConfig->nLayers(), aLayer1D);
95  refHitsEta.assign(128, myOmtfConfig->nPhiBins());
96 }
99 void OMTFinput::shiftMyPhi(int phiShift) {
100  int lowScaleEnd = std::pow(2, myOmtfConfig->nPhiBits() - 1);
101  int highScaleEnd = lowScaleEnd - 1;
102 
103  for (unsigned int iLogicLayer = 0; iLogicLayer < measurementsPhi.size(); ++iLogicLayer) {
104  for (unsigned int iHit = 0; iHit < measurementsPhi[iLogicLayer].size(); ++iHit) {
105  if (!myOmtfConfig->getBendingLayers().count(iLogicLayer) &&
106  measurementsPhi[iLogicLayer][iHit] < (int)myOmtfConfig->nPhiBins()) {
107  if (measurementsPhi[iLogicLayer][iHit] < 0)
108  measurementsPhi[iLogicLayer][iHit] += myOmtfConfig->nPhiBins();
109  measurementsPhi[iLogicLayer][iHit] -= phiShift;
110  if (measurementsPhi[iLogicLayer][iHit] < 0)
111  measurementsPhi[iLogicLayer][iHit] += myOmtfConfig->nPhiBins();
112  measurementsPhi[iLogicLayer][iHit] += -lowScaleEnd;
113  if (measurementsPhi[iLogicLayer][iHit] < -lowScaleEnd || measurementsPhi[iLogicLayer][iHit] > highScaleEnd)
114  measurementsPhi[iLogicLayer][iHit] = (int)myOmtfConfig->nPhiBins();
115  }
116  }
117  }
118 }
121 std::ostream &operator<<(std::ostream &out, const OMTFinput &aInput) {
122  for (unsigned int iLogicLayer = 0; iLogicLayer < aInput.measurementsPhi.size(); ++iLogicLayer) {
123  out << "Logic layer: " << iLogicLayer << " Hits: ";
124  for (unsigned int iHit = 0; iHit < aInput.measurementsPhi[iLogicLayer].size(); ++iHit) {
125  out << aInput.measurementsPhi[iLogicLayer][iHit] << "\t";
126  }
127  out << std::endl;
128  }
129  return out;
130 }
const std::set< int > & getBendingLayers() const
bool addLayerHit(unsigned int iLayer, unsigned int iInput, int iPhi, int iEta, bool allowOverwrite=true)
Definition: OMTFinput.cc:44
void clear()
Reset vectors with data.
Definition: OMTFinput.cc:91
vector2D measurementsEta
Definition: OMTFinput.h:55
void mergeData(const OMTFinput *aInput)
Definition: OMTFinput.cc:76
void shiftMyPhi(int phiShift)
Apply shift to all data.
Definition: OMTFinput.cc:99
unsigned int nLayers() const
unsigned int nPhiBins() const
std::vector< std::vector< int > > readEvent(unsigned int iEvent=0, unsigned int iProcessor=0, bool readEta=false)
omtfConfig(omtfConfig)
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:167
std::vector< int > vector1D
Definition: OMTFinput.h:13
assert(be >=bs)
const OMTFinput::vector1D & getLayerData(unsigned int iLayer, bool giveEta=false) const
Definition: OMTFinput.cc:17
vector1D refHitsEta
RefHitsEta.
Definition: OMTFinput.h:58
constexpr int nLayers
Definition: Config.h:73
unsigned int nPhiBits() const
int iEvent
Definition: GenABIO.cc:224
const std::vector< std::vector< RefHitDef > > & getRefHitsDefs() const
if(conf_.getParameter< bool >("UseStripCablingDB"))
OMTFinput(const OMTFConfiguration *)
Definition: OMTFinput.cc:11
std::bitset< 128 > getRefHits(unsigned int iProcessor) const
Definition: OMTFinput.cc:26
const std::vector< int > & getRefToLogicNumber() const
const OMTFConfiguration * myOmtfConfig
Definition: OMTFinput.h:60
void readData(XMLConfigReader *aReader, unsigned int iEvent=0, unsigned int iProcessor=0)
Read data from a XML file.
Definition: OMTFinput.cc:70
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:29
vector2D measurementsPhi
Definition: OMTFinput.h:50