test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
OMTFinput.cc
Go to the documentation of this file.
1 #include <cassert>
2 #include <iostream>
3 #include <cmath>
4 
8 
12 
13  myOmtfConfig = omtfConfig;
14  clear();
15 
16 }
19 const OMTFinput::vector1D & OMTFinput::getLayerData(unsigned int iLayer, bool giveEta) const{
20  assert(iLayer<measurementsPhi.size());
21 
22  if(giveEta) return measurementsEta[iLayer];
23  return measurementsPhi[iLayer];
24 }
27 std::bitset<128> OMTFinput::getRefHits(unsigned int iProcessor) const{
28 
29  std::bitset<128> refHits;
30 
31  unsigned int iRefHit = 0;
32  for(auto iRefHitDef:myOmtfConfig->getRefHitsDefs()[iProcessor]){
33  int iPhi = getLayerData(myOmtfConfig->getRefToLogicNumber()[iRefHitDef.iRefLayer])[iRefHitDef.iInput];
34  int iEta = getLayerData(myOmtfConfig->getRefToLogicNumber()[iRefHitDef.iRefLayer],true)[iRefHitDef.iInput];
35  if(iPhi<(int)myOmtfConfig->nPhiBins()){
36  refHits.set(iRefHit, iRefHitDef.fitsRange(iPhi));
37  refHitsEta[iRefHit] = iEta;
38  }
39  iRefHit++;
40  }
41 
42  return refHits;
43 }
46 bool OMTFinput::addLayerHit(unsigned int iLayer,
47  unsigned int iInput,
48  int iPhi, int iEta){
49 
50  bool overwrite = false;
51  assert(iLayer<myOmtfConfig->nLayers());
52  assert(iInput<14);
53 
54  if(iPhi>=(int)myOmtfConfig->nPhiBins()) return true;
55 // unsigned int origInput = iInput;
56 
57  if(measurementsPhi[iLayer][iInput]!=(int)myOmtfConfig->nPhiBins()) ++iInput;
58  if(measurementsPhi[iLayer][iInput]!=(int)myOmtfConfig->nPhiBins()) overwrite = true;
59 
60 // std::cout <<" addLayerHit :"<<iLayer<<" input orig :"<<inputorig<<" now: "<< iInput <<" phi: "<<iPhi<< std::endl;
61 
62  if(iInput>13) return false;
63 
64  measurementsPhi[iLayer][iInput] = iPhi;
65  measurementsEta[iLayer][iInput] = iEta;
66 
67 // return (origInput==iInput);
68  return (!overwrite);
69 }
73  unsigned int iEvent,
74  unsigned int iProcessor){
75 
76  measurementsPhi = aReader->readEvent(iEvent, iProcessor);
77  measurementsEta = aReader->readEvent(iEvent, iProcessor, true);
78 
79 }
82 void OMTFinput::mergeData(const OMTFinput *aInput){
83 
84  for(unsigned int iLayer=0;iLayer<myOmtfConfig->nLayers();++iLayer){
85  const OMTFinput::vector1D & aPhiVec = aInput->getLayerData(iLayer,false);
86  const OMTFinput::vector1D & aEtaVec = aInput->getLayerData(iLayer,true);
87  if(!aPhiVec.size()) continue;
88 
89  OMTFinput::vector1D layerData = getLayerData(iLayer, false);
90  for(unsigned int iInput=0;iInput<14;++iInput){
91  addLayerHit(iLayer,iInput,aPhiVec[iInput],aEtaVec[iInput]);
92  }
93  }
94 }
98 
99  vector1D aLayer1D(14,myOmtfConfig->nPhiBins());
100  measurementsPhi.assign(myOmtfConfig->nLayers(),aLayer1D);
101  measurementsEta.assign(myOmtfConfig->nLayers(),aLayer1D);
102  refHitsEta.assign(128,myOmtfConfig->nPhiBins());
103 
104 }
107 void OMTFinput::shiftMyPhi(int phiShift){
108 
109  int lowScaleEnd = std::pow(2,myOmtfConfig->nPhiBits()-1);
110  int highScaleEnd = lowScaleEnd-1;
111 
112 for(unsigned int iLogicLayer=0;iLogicLayer<measurementsPhi.size();++iLogicLayer){
113  for(unsigned int iHit=0;iHit<measurementsPhi[iLogicLayer].size();++iHit){
114  if(!myOmtfConfig->getBendingLayers().count(iLogicLayer) &&
115  measurementsPhi[iLogicLayer][iHit]<(int)myOmtfConfig->nPhiBins()){
116  if(measurementsPhi[iLogicLayer][iHit]<0) measurementsPhi[iLogicLayer][iHit]+=myOmtfConfig->nPhiBins();
117  measurementsPhi[iLogicLayer][iHit]-=phiShift;
118  if(measurementsPhi[iLogicLayer][iHit]<0) measurementsPhi[iLogicLayer][iHit]+=myOmtfConfig->nPhiBins();
119  measurementsPhi[iLogicLayer][iHit]+=-lowScaleEnd;
120  if(measurementsPhi[iLogicLayer][iHit]<-lowScaleEnd ||
121  measurementsPhi[iLogicLayer][iHit]>highScaleEnd) measurementsPhi[iLogicLayer][iHit] = (int)myOmtfConfig->nPhiBins();
122  }
123  }
124  }
125 }
128 std::ostream & operator << (std::ostream &out, const OMTFinput & aInput){
129 
130 for(unsigned int iLogicLayer=0;iLogicLayer<aInput.measurementsPhi.size();++iLogicLayer){
131  out<<"Logic layer: "<<iLogicLayer<<" Hits: ";
132  for(unsigned int iHit=0;iHit<aInput.measurementsPhi[iLogicLayer].size();++iHit){
133  out<<aInput.measurementsPhi[iLogicLayer][iHit]<<"\t";
134  }
135  out<<std::endl;
136  }
137  return out;
138 }
const std::set< int > & getBendingLayers() const
void clear()
Reset vectors with data.
Definition: OMTFinput.cc:97
vector2D measurementsEta
Definition: OMTFinput.h:59
void mergeData(const OMTFinput *aInput)
Definition: OMTFinput.cc:82
const OMTFConfiguration * myOmtfConfig
Definition: OMTFinput.h:64
void shiftMyPhi(int phiShift)
Apply shift to all data.
Definition: OMTFinput.cc:107
assert(m_qm.get())
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)
std::ostream & operator<<(std::ostream &out, const ALILine &li)
Definition: ALILine.cc:188
std::vector< int > vector1D
Definition: OMTFinput.h:15
const OMTFinput::vector1D & getLayerData(unsigned int iLayer, bool giveEta=false) const
Definition: OMTFinput.cc:19
vector1D refHitsEta
RefHitsEta.
Definition: OMTFinput.h:62
unsigned int nPhiBits() const
int iEvent
Definition: GenABIO.cc:230
const std::vector< std::vector< RefHitDef > > & getRefHitsDefs() const
OMTFinput(const OMTFConfiguration *)
Definition: OMTFinput.cc:11
std::bitset< 128 > getRefHits(unsigned int iProcessor) const
Definition: OMTFinput.cc:27
const std::vector< int > & getRefToLogicNumber() const
bool addLayerHit(unsigned int iLayer, unsigned int iInput, int iPhi, int iEta)
Definition: OMTFinput.cc:46
void readData(XMLConfigReader *aReader, unsigned int iEvent=0, unsigned int iProcessor=0)
Read data from a XML file.
Definition: OMTFinput.cc:72
Power< A, B >::type pow(const A &a, const B &b)
Definition: Power.h:40
vector2D measurementsPhi
Definition: OMTFinput.h:54