test
CMS 3D CMS Logo

 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
PatternRecognition.cc
Go to the documentation of this file.
1 
9 
10 //hardcoded pattern definitions
11 #define PATTERN_SIZE 9
12 const PhiMemoryImage pattern1 (0x8000,0,0,0x8000,0,0,0x8000,0,0,0x8000,0,0);
13 const PhiMemoryImage pattern2 (0x10000,0,0,0x8000,0,0,0xc000,0,0,0xc000,0,0);
14 const PhiMemoryImage pattern3 (0x4000,0,0,0x8000,0,0,0x18000,0,0,0x18000,0,0);
15 const PhiMemoryImage pattern4 (0x60000,0,0,0x8000,0,0,0xe000,0,0,0xe000,0,0);
16 const PhiMemoryImage pattern5 (0x3000,0,0,0x8000,0,0,0x78000,0,0,0x78000,0,0);
17 const PhiMemoryImage pattern6 (0x780000,0,0,0x8000,0,0,0xff00,0,0,0xff00,0,0);
18 const PhiMemoryImage pattern7 (0xf00,0,0,0x8000,0,0,0x7f8000,0,0,0x7f8000,0,0);
19 const PhiMemoryImage pattern8 (0x7f800000,0,0,0x8000,0,0,0xff00,0,0,0xff00,0,0);//
20 const PhiMemoryImage pattern9 (0xff,0,0,0x8000,0,0,0x7f8000,0,0,0x7f8000,0,0);
22 
23 
25 
27  //bool verbose = false;
28  std::vector<int> tmp (192, 0);//was 128
29  std::vector<std::vector<int>> lya (4, tmp), stra (4, tmp), ranka_t (4, tmp), ranka (4, tmp);
30  std::vector<PhiMemoryImage> Merged = Eout.zone;
32 
33 
34  for(int zone=0;zone<4;zone++){
35 
36 
37 
38  for(int b=0;b<192;b++){//loop over stips of detector zones//was 128 now 192 to accomodate
39  //larger phi scale used in neighboring sectors algorithm
40  int ly[PATTERN_SIZE] = {0}, srt[PATTERN_SIZE] = {0}, qu[PATTERN_SIZE] = {0};
42  for (int i=0; i<PATTERN_SIZE; i++) patt[i] = patterns[i];
43  for(int y=0;y != PATTERN_SIZE;y++){//loop over patterns
44 
45  bool zona[12] = {false}; //Clear out station presence
46 
47  if((b-15) < 63){
48  patt[y].BitShift(b-15);
49  }
50  else if((b-15) < 127){
51  patt[y].BitShift(63);patt[y].BitShift(b-78);
52  }
53  else{
54  patt[y].BitShift(63);patt[y].BitShift(63);patt[y].BitShift(b-141);
55  }
56 
57 
58  for(int yy=0;yy != 12;yy++){//loop over 8 long integers of each pattern
59 
60  zona[yy] = patt[y][yy] & Merged[zone][yy];
61  }
62 
63 
64 
65  if(zona[0] || zona[1] || zona[2]){ly[y] += 4;}//if station 1 is present
66  if(zona[3] || zona[4] || zona[5]){ly[y] += 2;}//if station 2 is present
67  if(zona[6] || zona[7] || zona[8] || zona[9] || zona[10] || zona[11]){ly[y] += 1;}//if station 3 or 4 is present
68  srt[y] = y/2;//straightness code::pattern specific
69 
70  if( (ly[y] != 0) && (ly[y] != 1) && (ly[y] != 2) && (ly[y] != 4) ){//Removes single and ME34 hit combinations//
71 
72 
73  //creates quality code by interleving straightness and layer bit words///
74  if((srt[y] & 1) != 0){qu[y] += 2;}
75  if((srt[y] & 2) != 0){qu[y] += 8;}
76  if((srt[y] & 4) != 0){qu[y] += 32;}
77  if((ly[y] & 1) != 0){qu[y] += 1;}
78  if((ly[y] & 2) != 0){qu[y] += 4;}
79  if((ly[y] & 4) != 0){qu[y] += 16;}
81 
82  }
83 
84  }//pattern loop
85 
86  for(int a=0;a<PATTERN_SIZE;a++)
87  {
88  if(qu[a] > ranka_t[zone][b]){//take highest quality from all patterns at given key strip
89 
90  ranka_t[zone][b] = qu[a];
91  lya[zone][b] = ly[a];
92  stra[zone][b] = srt[a];
93  }
94  }//pattern loop to assign quality
95 
96 
97 
98 
99 
100  }//strip loop
101  }//zone loop
102 
103 
107 
108 
109  for(int zone=0;zone<4;zone++){
110 
111  for(int k=0;k<192;k++){//was 128
112 
113  int qr = 0, ql = 0, qc = ranka_t[zone][k];
114 
115  //if(qc && verbose)
116  // std::cout<<"\n"<<k<<":qc = "<<qc<<" straight: "<<stra[zone][k]<<" lya: "<<lya[zone][k]<<std::endl;
117 
118  if(k>0){qr=ranka_t[zone][k-1];}
119  if(k<191){ql=ranka_t[zone][k+1];}//was 127
120 
121  if((qc <= ql) || (qc < qr)){qc = 0;}
122 
123  ranka[zone][k] = qc;
124  }
125  }
126 
127 
128  QualityOutput qout;
129  qout.rank = ranka;
130  qout.layer = lya;
131  qout.straightness = stra;
132 
134  output.detected = qout;
135  output.hits = Eout.convertedhits;
136 
137 
138  return output;
139 
140  }
141 
142 
143  std::vector<PatternOutput> Patterns(std::vector<ZonesOutput> Zones){
144 
146  std::vector<PatternOutput> output (3,tmp);
147 
148  for(int i=0;i<3;i++)
149  output[i] = DetectPatterns(Zones[i]);
150 
151 
152  return output;
153 
154  }
155 
156 
158 
159 
163  for(int zz=0;zz<4;zz++){
164  for(int z = 0;z<192;z++){//was 128
165 
166  if((out.rank)[zz][z] && ((out.layer)[zz][z] || (out.straightness)[zz][z])){std::cout<<"Found Pattern Zone: "<<zz<<"::new "<<(z+1)<<": "<<(out.layer)[zz][z]<<", "<<(out.straightness)[zz][z]<<", "<<(out.rank)[zz][z]<<" ";std::cout<<"\n\n";}//changing zones to Merged
167 
168  }
169  }
170  }
int i
Definition: DBlmapReader.cc:9
void PrintQuality(QualityOutput out)
const PhiMemoryImage pattern8(0x7f800000, 0, 0, 0x8000, 0, 0, 0xff00, 0, 0, 0xff00, 0, 0)
const PhiMemoryImage pattern5(0x3000, 0, 0, 0x8000, 0, 0, 0x78000, 0, 0, 0x78000, 0, 0)
PatternOutput DetectPatterns(ZonesOutput Eout)
float float float z
const PhiMemoryImage pattern2(0x10000, 0, 0, 0x8000, 0, 0, 0xc000, 0, 0, 0xc000, 0, 0)
const PhiMemoryImage pattern9(0xff, 0, 0, 0x8000, 0, 0, 0x7f8000, 0, 0, 0x7f8000, 0, 0)
std::vector< PatternOutput > Patterns(std::vector< ZonesOutput > Zones)
const PhiMemoryImage patterns[9]
const PhiMemoryImage pattern3(0x4000, 0, 0, 0x8000, 0, 0, 0x18000, 0, 0, 0x18000, 0, 0)
std::vector< PhiMemoryImage > zone
std::vector< ConvertedHit > convertedhits
#define PATTERN_SIZE
void BitShift(int nBits)
const PhiMemoryImage pattern1(0x8000, 0, 0, 0x8000, 0, 0, 0x8000, 0, 0, 0x8000, 0, 0)
double b
Definition: hdecay.h:120
const PhiMemoryImage pattern6(0x780000, 0, 0, 0x8000, 0, 0, 0xff00, 0, 0, 0xff00, 0, 0)
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
double a
Definition: hdecay.h:121
const PhiMemoryImage pattern7(0xf00, 0, 0, 0x8000, 0, 0, 0x7f8000, 0, 0, 0x7f8000, 0, 0)
tuple cout
Definition: gather_cfg.py:145
std::vector< ZonesOutput > Zones(std::vector< std::vector< ConvertedHit >> Hits)
Definition: ZoneCreation.h:39
QualityOutput detected
std::vector< ConvertedHit > hits
const PhiMemoryImage pattern4(0x60000, 0, 0, 0x8000, 0, 0, 0xe000, 0, 0, 0xe000, 0, 0)
float patt[4][130000]
Definition: HijingWrapper.h:38