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 PhiMemoryImage pattern1 (0x8000,0,0x8000,0,0x8000,0,0x8000,0);
13 PhiMemoryImage pattern2 (0x10000,0,0x8000,0,0xc000,0,0xc000,0);
14 PhiMemoryImage pattern3 (0x4000,0,0x8000,0,0x18000,0,0x18000,0);
15 PhiMemoryImage pattern4 (0x60000,0,0x8000,0,0xe000,0,0xe000,0);
16 PhiMemoryImage pattern5 (0x3000,0,0x8000,0,0x78000,0,0x78000,0);
17 PhiMemoryImage pattern6 (0x780000,0,0x8000,0,0xff00,0,0xff00,0);
18 PhiMemoryImage pattern7 (0xf00,0,0x8000,0,0x7f8000,0,0x7f8000,0);
19 PhiMemoryImage pattern8 (0x7f800000,0,0x8000,0,0xff00,0,0xff00,0);//
20 PhiMemoryImage pattern9 (0xff,0,0x8000,0,0x7f8000,0,0x7f8000,0);
22 
23 
25 
27  //bool verbose = false;
28  std::vector<int> tmp (128, 0);
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<128;b++){//loop over stips of detector zones
39 
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[8] = {false}; //Clear out station presence
46 
47  if((b-15) < 63){
48  patt[y].BitShift(b-15);
49  }
50  else{
51  patt[y].BitShift(63);patt[y].BitShift(b-78);
52  }
53 
54 
55  for(int yy=0;yy != 8;yy++){//loop over 8 long integers of each pattern
56 
57  zona[yy] = patt[y][yy] & Merged[zone][yy];
58  }
59 
60 
61 
62  if(zona[0] || zona[1]){ly[y] += 4;}//if station 1 is present
63  if(zona[2] || zona[3]){ly[y] += 2;}//if station 2 is present
64  if(zona[4] || zona[5] || zona[6] || zona[7]){ly[y] += 1;}//if station 3 or 4 is present
65  srt[y] = y/2;//straightness code::pattern specific
66 
67  if( (ly[y] != 0) && (ly[y] != 1) && (ly[y] != 2) && (ly[y] != 4) ){//Removes single and ME34 hit combinations//
68 
69 
70  //creates quality code by interleving straightness and layer bit words///
71  if((srt[y] & 1) != 0){qu[y] += 2;}
72  if((srt[y] & 2) != 0){qu[y] += 8;}
73  if((srt[y] & 4) != 0){qu[y] += 32;}
74  if((ly[y] & 1) != 0){qu[y] += 1;}
75  if((ly[y] & 2) != 0){qu[y] += 4;}
76  if((ly[y] & 4) != 0){qu[y] += 16;}
78 
79  }
80 
81  }//pattern loop
82 
83  for(int a=0;a<PATTERN_SIZE;a++)
84  {
85  if(qu[a] > ranka_t[zone][b]){//take highest quality from all patterns at given key strip
86 
87  ranka_t[zone][b] = qu[a];
88  lya[zone][b] = ly[a];
89  stra[zone][b] = srt[a];
90  }
91  }//pattern loop to assign quality
92 
93 
94 
95 
96 
97  }//strip loop
98  }//zone loop
99 
100 
104 
105 
106  for(int zone=0;zone<4;zone++){
107 
108  for(int k=0;k<128;k++){
109 
110  int qr = ranka_t[zone][k-1], ql = ranka_t[zone][k+1], qc = ranka_t[zone][k];
111 
112  //if(qc && verbose)
113  // std::cout<<"\n"<<k<<":qc = "<<qc<<" straight: "<<stra[zone][k]<<" lya: "<<lya[zone][k]<<std::endl;
114 
115  if(k==0){qr=0;}
116  if(k==127){ql=0;}
117 
118  if((qc <= ql) || (qc < qr)){qc = 0;}
119 
120  ranka[zone][k] = qc;
121  }
122  }
123 
124 
125 
126 
127  QualityOutput qout;
128  qout.rank = ranka;
129  qout.layer = lya;
130  qout.straightness = stra;
131 
133  output.detected = qout;
134  output.hits = Eout.convertedhits;
135 
136 
137  return output;
138 
139  }
140 
141 
142  std::vector<PatternOutput> Patterns(std::vector<ZonesOutput> Zones){
143 
145  std::vector<PatternOutput> output (3,tmp);
146 
147  for(int i=0;i<3;i++)
148  output[i] = DetectPatterns(Zones[i]);
149 
150 
151  return output;
152 
153  }
154 
155 
157 
158 
162  for(int zz=0;zz<4;zz++){
163  for(int z = 0;z<128;z++){
164 
165  //if((out.rank)[zz][z]){std::cout<<"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
166 
167  }
168  }
169  }
int i
Definition: DBlmapReader.cc:9
void PrintQuality(QualityOutput out)
PhiMemoryImage patterns[9]
PhiMemoryImage pattern2(0x10000, 0, 0x8000, 0, 0xc000, 0, 0xc000, 0)
PatternOutput DetectPatterns(ZonesOutput Eout)
float float float z
PhiMemoryImage pattern5(0x3000, 0, 0x8000, 0, 0x78000, 0, 0x78000, 0)
std::vector< PatternOutput > Patterns(std::vector< ZonesOutput > Zones)
std::vector< PhiMemoryImage > zone
PhiMemoryImage pattern4(0x60000, 0, 0x8000, 0, 0xe000, 0, 0xe000, 0)
std::vector< ConvertedHit > convertedhits
#define PATTERN_SIZE
PhiMemoryImage pattern7(0xf00, 0, 0x8000, 0, 0x7f8000, 0, 0x7f8000, 0)
PhiMemoryImage pattern8(0x7f800000, 0, 0x8000, 0, 0xff00, 0, 0xff00, 0)
void BitShift(int nBits)
PhiMemoryImage pattern6(0x780000, 0, 0x8000, 0, 0xff00, 0, 0xff00, 0)
double b
Definition: hdecay.h:120
std::vector< std::vector< double > > tmp
Definition: MVATrainer.cc:100
PhiMemoryImage pattern3(0x4000, 0, 0x8000, 0, 0x18000, 0, 0x18000, 0)
double a
Definition: hdecay.h:121
PhiMemoryImage pattern1(0x8000, 0, 0x8000, 0, 0x8000, 0, 0x8000, 0)
PhiMemoryImage pattern9(0xff, 0, 0x8000, 0, 0x7f8000, 0, 0x7f8000, 0)
std::vector< ZonesOutput > Zones(std::vector< std::vector< ConvertedHit >> Hits)
Definition: ZoneCreation.h:42
QualityOutput detected
std::vector< ConvertedHit > hits
float patt[4][130000]
Definition: HijingWrapper.h:38