StRoot  1
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Groups Pages
CheckPattern.C
1 // This simple macro reads in the output made by "runBfcEpd.C", which tells
2 // what is the "level" of the ADC of each tile. We are using this to test
3 // mapping using PedAsPhys runs.
4 //
5 // If things are working, the file should match up with one of our Seven Patterns
6 
7 
8 int level[2][12][31]; // Vped level. 0,1, or 2
9 
10 void SetPattern(int patternNumber); // this just fills the array level[][][] with the numbers 0,1,2
11 
12 
13 void CheckPattern(char* txtFileName, int patternNumber=4)
14 {
15  SetPattern(patternNumber);
16  ifstream ifs;
17  // ifs.open(Form("%d/ExtractedLevels.txt",runNumber));
18  ifs.open(txtFileName);
19  int ew,pp,tt,ilev,adc;
20  int nerrors=0;
21  for (int i=0; i<744; i++){
22  ifs >> ew >> pp >> tt >> ilev >> adc;
23  int ewindex=(ew<0)?0:1;
24  if (ilev!=level[ewindex][pp-1][tt-1]){
25  cout << "MISMATCH!!! ew/pp/tt = " << ew << "/" << pp << "/" << tt << "\n";
26  nerrors++;
27  }
28  }
29  ifs.close();
30 
31  cout << "Matching file " << txtFileName << " with Pattern " << patternNumber << " yields " << nerrors << " errors\n";
32 
33 }
34 
35 
36 void SetPattern(int patternNumber){
37 
38  // we'll set it to -1 here. If anybody is still -1 at the end, then there is a problem
39  for (int ew=0; ew<2; ew++){
40  for (int pp=1; pp<13; pp++){
41  for (int tt=1; tt<32; tt++){
42  level[ew][pp-1][tt-1]=-1;
43  }
44  }
45  }
46 
47  switch (patternNumber){
48  case 1: // East at 1, West at 2
49  for (int pp=1; pp<13; pp++){
50  for (int tt=1; tt<32; tt++){
51  level[0][pp-1][tt-1] = 1;
52  level[1][pp-1][tt-1] = 2;
53  }
54  }
55  break;
56  case 2: // break each wheel into thirds
57  for (int ew=0; ew<2; ew++){
58  for (int pp=1; pp<13; pp++){
59  int lev;
60  if (pp<5) lev=0;
61  if ((pp>4)&&(pp<9)) lev=1;
62  if (pp>8) lev=2;
63  for (int tt=1; tt<32; tt++){
64  level[ew][pp-1][tt-1]=lev;
65  }
66  }
67  }
68  break;
69  case 3: // break each 1/3 wheel into three pieces
70  for (int ew=0; ew<2; ew++){
71  for (int pp=1; pp<13; pp++){
72  for (int tt=1; tt<32; tt++){
73  if ((pp==1)||(pp==5)||(pp==9)) level[ew][pp-1][tt-1]=0;
74  if ((pp==2)||(pp==6)||(pp==10)) level[ew][pp-1][tt-1]=1;
75  if ((pp==4)||(pp==8)||(pp==12)) level[ew][pp-1][tt-1]=2;
76  if ((pp==3)||(pp==7)||(pp==11)){
77  if (tt%2==1){ // odd
78  level[ew][pp-1][tt-1] = 1;
79  }
80  else { // even
81  level[ew][pp-1][tt-1] = 2;
82  }
83  }
84  }
85  }
86  }
87  break;
88  case 4: // localize potential swap to the SECTOR level
89  for (int ew=0; ew<2; ew++){
90  for (int pp=1; pp<13; pp++){
91  for (int tt=1; tt<32; tt+=2){ // NOTE increment by TWO -- we are looping over ODD tiles
92  if ((pp==1)||(pp==2)||(pp==5)||(pp==6)||(pp==9)||(pp==10)) level[ew][pp-1][tt-1] = 0;
93  if ((pp==4)||(pp==8)||(pp==12)) level[ew][pp-1][tt-1] = 1;
94  if ((pp==3)||(pp==7)||(pp==11)) level[ew][pp-1][tt-1] = 2;
95  }
96  for (int tt=2; tt<32; tt+=2){ // NOTE increment by TWO -- we are looping over EVEN tiles
97  if ((pp==3)||(pp==7)||(pp==11)) level[ew][pp-1][tt-1] = 0;
98  if ((pp==1)||(pp==2)||(pp==5)||(pp==6)||(pp==9)||(pp==10)) level[ew][pp-1][tt-1] = 1;
99  if ((pp==4)||(pp==8)||(pp==12)) level[ew][pp-1][tt-1] = 2;
100  }
101  }
102  }
103  break;
104  case 5: // low look within sectors
105  for (int ew=0; ew<2; ew++){
106  for (int pp=1; pp<13; pp++){
107  for (int tt=1; tt<12; tt+=2){
108  level[ew][pp-1][tt-1] = 0;
109  }
110  for (int tt=13; tt<22; tt+=2){
111  level[ew][pp-1][tt-1] = 1;
112  }
113  for (int tt=23; tt<32; tt+=2){
114  level[ew][pp-1][tt-1] = 2;
115  }
116 
117  for (int tt=2; tt<11; tt+=2){
118  level[ew][pp-1][tt-1] = 0;
119  }
120  for (int tt=12; tt<21; tt+=2){
121  level[ew][pp-1][tt-1] = 1;
122  }
123  for (int tt=22; tt<31; tt+=2){
124  level[ew][pp-1][tt-1] = 2;
125  }
126  }
127  }
128  break;
129  case 6: // breaking into pairs (and some singlets)
130  for (int ew=0; ew<2; ew++){
131  for (int pp=1; pp<13; pp++){
132  level[ew][pp-1][1-1] = 0;
133  level[ew][pp-1][2-1] = 0;
134  level[ew][pp-1][3-1] = 0;
135  level[ew][pp-1][4-1] = 0;
136  level[ew][pp-1][5-1] = 1;
137  level[ew][pp-1][6-1] = 1;
138  level[ew][pp-1][7-1] = 1;
139  level[ew][pp-1][8-1] = 1;
140  level[ew][pp-1][9-1] = 2;
141  level[ew][pp-1][10-1] =2 ;
142  level[ew][pp-1][11-1] = 2;
143  level[ew][pp-1][12-1] = 0;
144  level[ew][pp-1][13-1] = 0;
145  level[ew][pp-1][14-1] = 0;
146  level[ew][pp-1][15-1] = 0;
147  level[ew][pp-1][16-1] = 1;
148  level[ew][pp-1][17-1] = 1;
149  level[ew][pp-1][18-1] = 1;
150  level[ew][pp-1][19-1] = 1;
151  level[ew][pp-1][20-1] = 2;
152  level[ew][pp-1][21-1] = 2;
153  level[ew][pp-1][22-1] = 0;
154  level[ew][pp-1][23-1] = 0;
155  level[ew][pp-1][24-1] = 0;
156  level[ew][pp-1][25-1] = 0;
157  level[ew][pp-1][26-1] = 1;
158  level[ew][pp-1][27-1] = 1;
159  level[ew][pp-1][28-1] = 1;
160  level[ew][pp-1][29-1] = 1;
161  level[ew][pp-1][30-1] = 2;
162  level[ew][pp-1][31-1] = 2;
163  }
164  }
165  break;
166  case 7: // last disambiguity
167  for (int ew=0; ew<2; ew++){
168  for (int pp=1; pp<13; pp++){
169  level[ew][pp-1][1-1] = 0;
170  level[ew][pp-1][2-1] = 0;
171  level[ew][pp-1][3-1] = 1;
172  level[ew][pp-1][4-1] = 1;
173  level[ew][pp-1][5-1] = 0;
174  level[ew][pp-1][6-1] = 0;
175  level[ew][pp-1][7-1] = 1;
176  level[ew][pp-1][8-1] = 1;
177  level[ew][pp-1][9-1] = 0;
178  level[ew][pp-1][10-1] = 2;
179  level[ew][pp-1][11-1] = 1;
180  level[ew][pp-1][12-1] = 0;
181  level[ew][pp-1][13-1] = 0;
182  level[ew][pp-1][14-1] = 1;
183  level[ew][pp-1][15-1] = 1;
184  level[ew][pp-1][16-1] = 0;
185  level[ew][pp-1][17-1] = 0;
186  level[ew][pp-1][18-1] = 1;
187  level[ew][pp-1][19-1] = 1;
188  level[ew][pp-1][20-1] = 2;
189  level[ew][pp-1][21-1] = 2;
190  level[ew][pp-1][22-1] = 0;
191  level[ew][pp-1][23-1] = 0;
192  level[ew][pp-1][24-1] = 1;
193  level[ew][pp-1][25-1] = 1;
194  level[ew][pp-1][26-1] = 0;
195  level[ew][pp-1][27-1] = 0;
196  level[ew][pp-1][28-1] = 1;
197  level[ew][pp-1][29-1] = 1;
198  level[ew][pp-1][30-1] = 2;
199  level[ew][pp-1][31-1] = 2;
200  }
201  }
202  break;
203  default:
204  cout << "No! not allowed pattern!\n";
205  break;
206  }
207 
208  // now check whether everybody has been set
209  for (int ew=0; ew<2; ew++){
210  for (int pp=1; pp<13; pp++){
211  for (int tt=1; tt<32; tt++){
212  if (level[ew][pp-1][tt-1]<0)
213  cout << "Hey, no level set for EW=" << ew << " PP=" << pp << " TT=" << tt << endl;
214  }
215  }
216  }
217  return;
218 }
219