1 | /* ======================================================================== *\
|
---|
2 | !
|
---|
3 | ! *
|
---|
4 | ! * This file is part of MARS, the MAGIC Analysis and Reconstruction
|
---|
5 | ! * Software. It is distributed to you in the hope that it can be a useful
|
---|
6 | ! * and timesaving tool in analysing Data of imaging Cerenkov telescopes.
|
---|
7 | ! * It is distributed WITHOUT ANY WARRANTY.
|
---|
8 | ! *
|
---|
9 | ! * Permission to use, copy, modify and distribute this software and its
|
---|
10 | ! * documentation for any purpose is hereby granted without fee,
|
---|
11 | ! * provided that the above copyright notice appear in all copies and
|
---|
12 | ! * that both that copyright notice and this permission notice appear
|
---|
13 | ! * in supporting documentation. It is provided "as is" without express
|
---|
14 | ! * or implied warranty.
|
---|
15 | ! *
|
---|
16 | !
|
---|
17 | !
|
---|
18 | ! Author(s): Antonio Stamerra 1/2003 <mailto:antono.stamerra@pi.infn.it>
|
---|
19 | ! Author(s): Marcos Lopez 1/2003 <mailto:marcos@gae.ucm.es>
|
---|
20 | !
|
---|
21 | ! Copyright: MAGIC Software Development, 2000-2003
|
---|
22 | !
|
---|
23 | !
|
---|
24 | \* ======================================================================== */
|
---|
25 |
|
---|
26 |
|
---|
27 | /////////////////////////////////////////////////////////////////////////////
|
---|
28 | // //
|
---|
29 | // MMcTriggerLvl2 //
|
---|
30 | // Storage container for the 2nd level trigger selection parameters //
|
---|
31 | // as part of the 2nd level trigger simulation //
|
---|
32 | // //
|
---|
33 | // input parameter: //
|
---|
34 | // fCompactNN number of next neighboors that define a compact pixel //
|
---|
35 | // //
|
---|
36 | // //
|
---|
37 | // Basic L2T Selection Parameters: //
|
---|
38 | // //
|
---|
39 | // fLutPseudoSize number of compact pixels in one LUT //
|
---|
40 | // fPseudoSize Multiplicity of the bigger cluster //
|
---|
41 | // fSizeBiggerCell higher number of fired pixel in cell //
|
---|
42 | // //
|
---|
43 | /////////////////////////////////////////////////////////////////////////////
|
---|
44 |
|
---|
45 | #include "MMcTriggerLvl2.h"
|
---|
46 |
|
---|
47 | #include "MGeomCam.h"
|
---|
48 | #include "MGeomPix.h"
|
---|
49 | #include "MGeomCamMagic.h"
|
---|
50 | #include "MCamDisplay.h"
|
---|
51 |
|
---|
52 | #include "MMcTrig.hxx"
|
---|
53 |
|
---|
54 | #include "MLog.h"
|
---|
55 |
|
---|
56 | #include <TCanvas.h>
|
---|
57 |
|
---|
58 |
|
---|
59 | ClassImp(MMcTriggerLvl2)
|
---|
60 |
|
---|
61 | // ---------------------------
|
---|
62 | // Initialization of static const data members pixel_in_cell and pixel_in_lut
|
---|
63 |
|
---|
64 | //
|
---|
65 | // Correspondence TABLE between pixel numbering in the trigger cells and
|
---|
66 | // the standard spiral counting
|
---|
67 | // (Note: Pixels start to count from 1 instead of 0)
|
---|
68 | //
|
---|
69 | const Int_t MMcTriggerLvl2::gsPixelsInCell[36][19] = {
|
---|
70 | {26, 91, 66, 71, 76, 81, 86, 269, 224, 233, 242, 251, 260, 391, 336, 347, 358, 369, 380},
|
---|
71 | {25, 61, 41, 45, 49, 53, 57, 215, 175, 183, 191, 199, 207, 325, 275, 285, 295, 305, 315},
|
---|
72 | {24, 37, 22, 25, 28, 31, 34, 167, 132, 139, 146, 153, 160, 265, 220, 229, 238, 247, 256},
|
---|
73 | {23, 19, 9, 11, 13, 15, 17, 125, 95, 101, 107, 113, 119, 211, 171, 179, 187, 195, 203},
|
---|
74 | {27, 62, 67, 72, 77, 82, 87, 270, 225, 234, 243, 252, 261, 392, 337, 348, 359, 370, 381},
|
---|
75 | {12, 38, 42, 46, 50, 54, 58, 216, 176, 184, 192, 200, 208, 326, 276, 286, 296, 306, 316},
|
---|
76 | {11, 20, 23, 26, 29, 32, 35, 168, 133, 140, 147, 154, 161, 266, 221, 230, 239, 248, 257},
|
---|
77 | {10, 8, 10, 12, 14, 16, 18, 126, 96, 102, 108, 114, 120, 212, 172, 180, 188, 196, 204},
|
---|
78 | {22, 2, 3, 4, 5, 6, 7, 90, 65, 70, 75, 80, 85, 164, 129, 136, 143, 150, 157},
|
---|
79 | {28, 93, 99, 105, 111, 117, 123, 271, 226, 235, 244, 253, 262, 393, 338, 349, 360, 371, 382},
|
---|
80 | {13, 63, 68, 73, 78, 83, 88, 217, 177, 185, 193, 201, 209, 327, 277, 287, 297, 307, 317},
|
---|
81 | { 4, 39, 43, 47, 51, 55, 59, 169, 134, 141, 148, 155, 162, 267, 222, 231, 240, 249, 258},
|
---|
82 | { 3, 21, 24, 27, 30, 33, 36, 127, 97, 103, 109, 115, 121, 213, 173, 181, 189, 197, 205},
|
---|
83 | { 9, 9, 11, 13, 15, 17, 19, 91, 66, 71, 76, 81, 86, 165, 130, 137, 144, 151, 158},
|
---|
84 | {21, 3, 4, 5, 6, 7, 2, 61, 41, 45, 49, 53, 57, 123, 93, 99, 105, 111, 117},
|
---|
85 | {29, 130, 137, 144, 151, 158, 165, 218, 227, 236, 245, 254, 263, 394, 339, 350, 361, 372, 383},
|
---|
86 | {14, 94, 100, 106, 112, 118, 124, 170, 178, 186, 194, 202, 210, 328, 278, 288, 298, 308, 318},
|
---|
87 | { 5, 64, 69, 74, 79, 84, 89, 128, 135, 142, 149, 156, 163, 268, 223, 232, 241, 250, 259},
|
---|
88 | { 1, 40, 44, 48, 52, 56, 60, 92, 98, 104, 110, 116, 122, 214, 174, 182, 190, 198, 206},
|
---|
89 | { 2, 22, 25, 28, 31, 34, 37, 62, 67, 72, 77, 82, 87, 166, 131, 138, 145, 152, 159},
|
---|
90 | { 8, 10, 12, 14, 16, 18, 8, 38, 42, 46, 50, 54, 58, 124, 94, 100, 106, 112, 118},
|
---|
91 | {20, 11, 13, 15, 17, 19, 9, 20, 23, 26, 29, 32, 35, 88, 63, 68, 73, 78, 83},
|
---|
92 | {30, 131, 138, 145, 152, 159, 166, 219, 228, 237, 246, 255, 264, 329, 279, 289, 299, 309, 319},
|
---|
93 | {15, 95, 101, 107, 113, 119, 125, 171, 179, 187, 195, 203, 211, 269, 224, 233, 242, 251, 260},
|
---|
94 | { 6, 65, 70, 75, 80, 85, 90, 129, 136, 143, 150, 157, 164, 215, 175, 183, 191, 199, 207},
|
---|
95 | { 7, 41, 45, 49, 53, 57, 61, 93, 99, 105, 111, 117, 123, 167, 132, 139, 146, 153, 160},
|
---|
96 | {19, 23, 26, 29, 32, 35, 20, 63, 68, 73, 78, 83, 88, 125, 95, 101, 107, 113, 119},
|
---|
97 | {37, 24, 27, 30, 33, 36, 21, 39, 43, 47, 51, 55, 59, 89, 64, 69, 74, 79, 84},
|
---|
98 | {31, 132, 139, 146, 153, 160, 167, 220, 229, 238, 247, 256, 265, 270, 225, 234, 243, 252, 261},
|
---|
99 | {16, 96, 102, 108, 114, 120, 126, 172, 180, 188, 196, 204, 212, 216, 176, 184, 192, 200, 208},
|
---|
100 | {17, 66, 71, 76, 81, 86, 91, 130, 137, 144, 151, 158, 165, 168, 133, 140, 147, 154, 161},
|
---|
101 | {18, 42, 46, 50, 54, 58, 38, 94, 100, 106, 112, 118, 124, 126, 96, 102, 108, 114, 120},
|
---|
102 | {36, 43, 47, 51, 55, 59, 39, 64, 69, 74, 79, 84, 89, 90, 65, 70, 75, 80, 85},
|
---|
103 | {32, 133, 140, 147, 154, 161, 168, 221, 230, 239, 248, 257, 266, 217, 177, 185, 193, 201, 209},
|
---|
104 | {33, 97, 103, 109, 115, 121, 127, 173, 181, 189, 197, 205, 213, 169, 134, 141, 148, 155, 162},
|
---|
105 | {35, 68, 73, 78, 83, 88, 63, 95, 101, 107, 113, 119, 125, 91, 66, 71, 76, 81, 86}
|
---|
106 | };
|
---|
107 |
|
---|
108 | //
|
---|
109 | // corrispondence between pixels in cell and lut (pix numbering starts from 1)
|
---|
110 | //
|
---|
111 | const Int_t MMcTriggerLvl2::gsPixelsInLut[3][12] = {
|
---|
112 | { 1, 2, 3, 4, 6, 7, 8, 9, 12, 13, 14, 15},
|
---|
113 | {34, 29, 23, 16, 30, 24, 17, 10, 25, 18, 11, 5},
|
---|
114 | {35, 31, 26, 20, 19, 32, 27, 21, 36, 33, 28, 22},
|
---|
115 | };
|
---|
116 |
|
---|
117 |
|
---|
118 | // --------------------------------------------------------------------------
|
---|
119 | //
|
---|
120 | // Default constructor
|
---|
121 | //
|
---|
122 | MMcTriggerLvl2::MMcTriggerLvl2(const char *name, const char *title)
|
---|
123 | {
|
---|
124 | fName = name ? name : ClassName();
|
---|
125 | fTitle = title;
|
---|
126 |
|
---|
127 | *fLog << "created MMcTriggerLvl2" << endl;
|
---|
128 |
|
---|
129 | //
|
---|
130 | // Initialization of the fPixels array to zero
|
---|
131 | //
|
---|
132 | memset (fPixels,0,36*19*sizeof(Int_t));
|
---|
133 | memset (fFiredPixel,0,397*sizeof(Int_t));
|
---|
134 |
|
---|
135 | // create a new camera
|
---|
136 | SetNewCamera(new MGeomCamMagic);
|
---|
137 | }
|
---|
138 |
|
---|
139 | // --------------------------------------------------------------------------
|
---|
140 | //
|
---|
141 | // Destructor
|
---|
142 | //
|
---|
143 | MMcTriggerLvl2::~MMcTriggerLvl2()
|
---|
144 | {
|
---|
145 | delete fCam;
|
---|
146 | delete fGeomCam;
|
---|
147 | }
|
---|
148 |
|
---|
149 | // --------------------------------------------------------------------------
|
---|
150 | //
|
---|
151 | // Print functions for debugging and testing
|
---|
152 | //
|
---|
153 | // Options available:
|
---|
154 | //
|
---|
155 | // "cell":
|
---|
156 | // Print out the pixel number of a given trigger cell
|
---|
157 | //
|
---|
158 | // "status":
|
---|
159 | // Print a table with the status (pixel is fired or not after Lvl1) for
|
---|
160 | // all the pixels in all the trigger cells
|
---|
161 | //
|
---|
162 | // no option:
|
---|
163 | // Print the value of the selection parameters
|
---|
164 | //
|
---|
165 | //
|
---|
166 | void MMcTriggerLvl2::Print(Option_t *opt) const
|
---|
167 | {
|
---|
168 | TString str(opt);
|
---|
169 |
|
---|
170 | if (str.Contains("status", TString::kIgnoreCase))
|
---|
171 | {
|
---|
172 | *fLog << " Status of cells 1-9" <<endl;
|
---|
173 | for(int i=0; i<36; i++)
|
---|
174 | {
|
---|
175 | for(int j=0; j<9; j++)
|
---|
176 | {
|
---|
177 | // *fLog.width(3);
|
---|
178 | *fLog <<gsPixelsInCell[i][j]-1 << ":" << fPixels[i][j] << "\t ";
|
---|
179 | }
|
---|
180 | *fLog << endl;
|
---|
181 | }
|
---|
182 | }
|
---|
183 | else if (str.Contains("cell", TString::kIgnoreCase))
|
---|
184 | {
|
---|
185 | *fLog << " Pixel numbering in cells 1-9" <<endl;
|
---|
186 | for (int i=0;i<36;i++)
|
---|
187 | {
|
---|
188 | for(int j=0; j<9; j++)
|
---|
189 | {
|
---|
190 | *fLog << gsPixelsInCell[i][j]-1 << "\t";
|
---|
191 | }
|
---|
192 | *fLog << endl;
|
---|
193 | }
|
---|
194 | }
|
---|
195 | else
|
---|
196 | {
|
---|
197 | *fLog << " L2T selection parameters:" << endl;
|
---|
198 | *fLog << " - LutPseudoSize = " << fLutPseudoSize << endl;
|
---|
199 | *fLog << " - PseudoSize = " << fPseudoSize << endl;
|
---|
200 | *fLog << " - BiggerCellSize = " << fSizeBiggerCell << endl;
|
---|
201 | }
|
---|
202 |
|
---|
203 | }
|
---|
204 |
|
---|
205 | // --------------------------------------------------------------------------
|
---|
206 | //
|
---|
207 | // Take the information supplied by the Lvl1 (it reads from the object MMcTrig
|
---|
208 | // the status of all pixels after Lvl1) and pass it to the Lvl2 (fill the
|
---|
209 | // array fPixels)
|
---|
210 | //
|
---|
211 | //
|
---|
212 | void MMcTriggerLvl2::SetLv1(MMcTrig *trig)
|
---|
213 | {
|
---|
214 | if (!trig)
|
---|
215 | return;
|
---|
216 |
|
---|
217 | fMcTrig = trig;
|
---|
218 |
|
---|
219 | //fMcTrig->PrintPixelsFirstLevel();
|
---|
220 |
|
---|
221 | for(int i=0; i<36; i++)
|
---|
222 | {
|
---|
223 | for(int j=0; j<19; j++)
|
---|
224 | {
|
---|
225 | int pixel = gsPixelsInCell[i][j]-1;
|
---|
226 | fPixels[i][j] = (fMcTrig->IsPixelFired(pixel,0)) ? 1 : 0;
|
---|
227 | fFiredPixel[pixel]=(fMcTrig->IsPixelFired(pixel,0)) ? 1 : 0;
|
---|
228 | }
|
---|
229 | }
|
---|
230 | }
|
---|
231 |
|
---|
232 |
|
---|
233 | // --------------------------------------------------------------------------
|
---|
234 | //
|
---|
235 | // Set the trigger status ( pixel fired(=1) or not(=0) ) manually for a given
|
---|
236 | // pixel of a given cell
|
---|
237 | //
|
---|
238 | //
|
---|
239 | void MMcTriggerLvl2::SetPixelFired(Int_t pixel, Int_t fired)
|
---|
240 | {
|
---|
241 | for(int i=0; i<36; i++)
|
---|
242 | {
|
---|
243 | for(int j=0; j<19; j++)
|
---|
244 | {
|
---|
245 | if(gsPixelsInCell[i][j]-1==pixel) fPixels[i][j]=fired;
|
---|
246 | }
|
---|
247 | }
|
---|
248 |
|
---|
249 | }
|
---|
250 |
|
---|
251 | // --------------------------------------------------------------------------
|
---|
252 | //
|
---|
253 | // Calculate the Level 2 Trigger (L2T) parameters. They can be used
|
---|
254 | // to select the events that have passed the L2T selection rule.
|
---|
255 | //
|
---|
256 | //
|
---|
257 | void MMcTriggerLvl2::Calc()
|
---|
258 | {
|
---|
259 |
|
---|
260 | // Find the Lut and cell with the higher LutPseudoSize.
|
---|
261 | int lutcell = CalcBiggerLutPseudoSize();
|
---|
262 | int maxcell = lutcell/10;
|
---|
263 | int maxlut = lutcell-maxcell*10;
|
---|
264 | fLutPseudoSize = GetLutCompactPixel(maxcell,maxlut);
|
---|
265 |
|
---|
266 | CalcPseudoSize();
|
---|
267 |
|
---|
268 | fSizeBiggerCell = GetCellNumberFired(CalcBiggerFiredCell());
|
---|
269 |
|
---|
270 | }
|
---|
271 |
|
---|
272 |
|
---|
273 | // --------------------------------------------------------------------------
|
---|
274 | //
|
---|
275 | // Display the MAGIC Camera a draw the pixels corresponding to a given cell
|
---|
276 | // (preliminary) <to be fixed>
|
---|
277 | //
|
---|
278 | void MMcTriggerLvl2::DrawCell(Int_t cell)
|
---|
279 | {
|
---|
280 |
|
---|
281 | if(cell>18) return;
|
---|
282 |
|
---|
283 | //
|
---|
284 | // Use MCamDisplay class variable for avoiding to create a MCamDisplay each
|
---|
285 | // time this function is called. Also, now all the hexagons are drawn in
|
---|
286 | // the same camera pad
|
---|
287 | //
|
---|
288 | if (!fGeomCam)
|
---|
289 | fGeomCam = new MGeomCamMagic;
|
---|
290 | if (!fCam)
|
---|
291 | {
|
---|
292 | fCam = new MCamDisplay(fGeomCam);
|
---|
293 | fCam->Draw();
|
---|
294 | fCam->DrawPixelNumbers();
|
---|
295 | }
|
---|
296 |
|
---|
297 | //fCam->Draw();
|
---|
298 | fCam->Reset();
|
---|
299 |
|
---|
300 | int color=0;
|
---|
301 |
|
---|
302 | for(int i=0; i<36; i++)
|
---|
303 | {
|
---|
304 | color = (fPixels[i][cell]) ? 5 : 3;
|
---|
305 | fCam->SetPix( gsPixelsInCell[i][cell]-1, color, 1, 5 );
|
---|
306 | }
|
---|
307 |
|
---|
308 | //
|
---|
309 | // Update the display (paint the camera with the new colors)
|
---|
310 | //
|
---|
311 | gPad->Modified();
|
---|
312 | gPad->Update();
|
---|
313 | }
|
---|
314 |
|
---|
315 |
|
---|
316 |
|
---|
317 | // --------------------------------------------------------------------------
|
---|
318 | //
|
---|
319 | // Display the MAGIC camera and draw all the pixel fired after Lvl1
|
---|
320 | // (preliminary) <to be fixed>
|
---|
321 | //
|
---|
322 | //
|
---|
323 | void MMcTriggerLvl2::DrawLv1()
|
---|
324 | {
|
---|
325 | //
|
---|
326 | // Use MCamDisplay class variable for avoiding to create a MCamDisplay each
|
---|
327 | // time this function is called. Also, now all the hexagons are drawn in
|
---|
328 | // the same camera pad
|
---|
329 | //
|
---|
330 | // !FixMe! Delete this method when the trigger display is available!
|
---|
331 | //
|
---|
332 | if (!fGeomCam)
|
---|
333 | fGeomCam = new MGeomCamMagic;
|
---|
334 | if (!fCam)
|
---|
335 | {
|
---|
336 | fCam = new MCamDisplay(fGeomCam);
|
---|
337 | fCam->Draw();
|
---|
338 | fCam->DrawPixelNumbers();
|
---|
339 | }
|
---|
340 |
|
---|
341 | //
|
---|
342 | // Set the array of colors for each pixel (that will be painted after
|
---|
343 | // updating the dispaly)
|
---|
344 | //
|
---|
345 | int color=0;
|
---|
346 |
|
---|
347 | for(int i=0; i<577; i++)
|
---|
348 | {
|
---|
349 | color = (fMcTrig->IsPixelFired(i,0)) ? 1 : 2;
|
---|
350 | fCam->SetPix( i, color, 1, 5 );
|
---|
351 | }
|
---|
352 |
|
---|
353 | //
|
---|
354 | // Update the display (paint the camera with the new colors)
|
---|
355 | //
|
---|
356 | gPad->Modified();
|
---|
357 | gPad->Update();
|
---|
358 |
|
---|
359 | }
|
---|
360 |
|
---|
361 | // --------------------------------------------------------------------------
|
---|
362 | //
|
---|
363 | // For a given cell, just count how many pixels have been fired after Lvl1
|
---|
364 | //
|
---|
365 | Int_t MMcTriggerLvl2::GetCellNumberFired(int cell)
|
---|
366 | {
|
---|
367 | int size=0;
|
---|
368 |
|
---|
369 | for(int i=0; i<36; i++)
|
---|
370 | {
|
---|
371 | size += fPixels[i][cell];
|
---|
372 | }
|
---|
373 |
|
---|
374 | return size;
|
---|
375 |
|
---|
376 | }
|
---|
377 |
|
---|
378 |
|
---|
379 | // --------------------------------------------------------------------------
|
---|
380 | //
|
---|
381 | // Find the cell which the bigger number of fired pixels
|
---|
382 | //
|
---|
383 | //
|
---|
384 | Int_t MMcTriggerLvl2::CalcBiggerFiredCell()
|
---|
385 | {
|
---|
386 | int size=-1;
|
---|
387 | int cell=-1;
|
---|
388 |
|
---|
389 | for(int j=0; j<19; j++)
|
---|
390 | {
|
---|
391 | if (GetCellNumberFired(j) > size)
|
---|
392 | {
|
---|
393 | size = GetCellNumberFired(j);
|
---|
394 | cell = j;
|
---|
395 | }
|
---|
396 | }
|
---|
397 |
|
---|
398 | // *fLog << "size " <<size <<" in cell " << cell << endl;
|
---|
399 |
|
---|
400 | return cell;
|
---|
401 |
|
---|
402 | }
|
---|
403 |
|
---|
404 | // --------------------------------------------------------------------------
|
---|
405 | //
|
---|
406 | // Calculate the higher LutPseudoSize of one event defined as the higher number
|
---|
407 | // of compact pixel in the LUTs of the trigger cells.
|
---|
408 | // neighpix is the number of Next-Neighbors which defines the compact pixel
|
---|
409 | // topology (it can be 2-NN or 3-NN)
|
---|
410 | //
|
---|
411 | // It returns the cell and the LUT with the bigger LutPseudoSize, coded
|
---|
412 | // accordingly to: cell*10 + LUT
|
---|
413 | //
|
---|
414 | Int_t MMcTriggerLvl2::CalcBiggerLutPseudoSize()
|
---|
415 | {
|
---|
416 | int size=0;
|
---|
417 | int cell=-1;
|
---|
418 | int lut=-1;
|
---|
419 |
|
---|
420 | for(int j=0; j<19; j++)
|
---|
421 | {
|
---|
422 | for(int i=0; i<3; i++)
|
---|
423 | {
|
---|
424 | if (GetLutCompactPixel(j,i) >= size)
|
---|
425 | {
|
---|
426 | size = GetLutCompactPixel(j,i);
|
---|
427 | cell = j;
|
---|
428 | lut = i;
|
---|
429 | }
|
---|
430 | }
|
---|
431 | }
|
---|
432 |
|
---|
433 | // *fLog <<"Max cell: " << cell+1 << " Max Lut: " << lut+1 << " PseudoSize: " << size <<endl;
|
---|
434 |
|
---|
435 | return cell*10+lut;
|
---|
436 | }
|
---|
437 |
|
---|
438 |
|
---|
439 | // --------------------------------------------------------------------------
|
---|
440 | //
|
---|
441 | // Identify compact pixels in one LUT and calculate the LutPseudoSize
|
---|
442 | // (=number of compact pixels in one LUT)
|
---|
443 | // neighpix is the number of Next-Neighbors which defines the compact pixel
|
---|
444 | // topology.
|
---|
445 | // Up to now only 2NN or 3NN are considered
|
---|
446 | // <!if changed: change check made by Preprocess in MMcTriggerLvl2Calc>
|
---|
447 | //
|
---|
448 | // Returns:
|
---|
449 | // -1 wrong neighpix
|
---|
450 | // -2 wrong cell (<1 or >19)
|
---|
451 | // -3 wrong lut (<1 or >3)
|
---|
452 | // else:
|
---|
453 | // the number of compact pixels in one LUT.
|
---|
454 | //
|
---|
455 | Int_t MMcTriggerLvl2::GetLutCompactPixel(int cell, int lut)
|
---|
456 | {
|
---|
457 | int size=0;
|
---|
458 | int lutpix, a[12];
|
---|
459 | int neighpix= (*this).fCompactNN;
|
---|
460 |
|
---|
461 | // check on input variables
|
---|
462 |
|
---|
463 | if (neighpix >3 || neighpix < 2)
|
---|
464 | return(-1);
|
---|
465 |
|
---|
466 | if (cell<0 || cell>18)
|
---|
467 | return(-2);
|
---|
468 |
|
---|
469 | if (lut<0 || lut>2)
|
---|
470 | return(-3);
|
---|
471 |
|
---|
472 |
|
---|
473 | // LUT 1 and 2 are similar; LUT 3 differs
|
---|
474 |
|
---|
475 | for(int j=0; j<12; j++)
|
---|
476 | {
|
---|
477 | lutpix = gsPixelsInLut[lut][j]-1;
|
---|
478 | // *fLog << "j=" <<j<<" lutpix="<<lutpix<<" Cell="<<cell<<endl;
|
---|
479 | a[j] = fPixels[lutpix][cell];
|
---|
480 | }
|
---|
481 |
|
---|
482 | //
|
---|
483 | // Look for compact pixels 2NN
|
---|
484 | //
|
---|
485 | if (neighpix==2)
|
---|
486 | {
|
---|
487 | // case Lut 1 and 2
|
---|
488 | if (lut == 0 || lut == 1)
|
---|
489 | {
|
---|
490 | if (a[0] && a[1] && a[4])
|
---|
491 | size ++;
|
---|
492 | if (a[1] && ((a[0] && a[4]) ||
|
---|
493 | (a[4] && a[5]) ||
|
---|
494 | (a[5] && a[2]) ))
|
---|
495 | size ++;
|
---|
496 | if (a[2] && ((a[1] && a[5]) ||
|
---|
497 | (a[5] && a[6]) ||
|
---|
498 | (a[6] && a[3]) ))
|
---|
499 | size ++;
|
---|
500 | if (a[3] && ((a[2] && a[6]) ||
|
---|
501 | (a[6] && a[7]) ))
|
---|
502 | size ++;
|
---|
503 | if (a[4] && ((a[0] && a[1]) ||
|
---|
504 | (a[1] && a[5]) ||
|
---|
505 | (a[5] && a[8]) ))
|
---|
506 | size ++;
|
---|
507 | if (a[5] && ((a[1] && a[2]) ||
|
---|
508 | (a[2] && a[6]) ||
|
---|
509 | (a[6] && a[9]) ||
|
---|
510 | (a[9] && a[8]) ||
|
---|
511 | (a[8] && a[4]) ||
|
---|
512 | (a[4] && a[1]) ))
|
---|
513 | size ++;
|
---|
514 | if (a[6] && ((a[2] && a[3]) ||
|
---|
515 | (a[3] && a[7]) ||
|
---|
516 | (a[7] && a[10]) ||
|
---|
517 | (a[10] && a[9]) ||
|
---|
518 | (a[9] && a[5]) ||
|
---|
519 | (a[5] && a[2]) ))
|
---|
520 | size ++;
|
---|
521 | if (a[7] && ((a[3] && a[6]) ||
|
---|
522 | (a[6] && a[10]) ||
|
---|
523 | (a[10] && a[11]) ))
|
---|
524 | size ++;
|
---|
525 | if (a[8] && ((a[4] && a[5]) ||
|
---|
526 | (a[5] && a[9]) ))
|
---|
527 | size ++;
|
---|
528 | if (a[9] && ((a[8] && a[5]) ||
|
---|
529 | (a[5] && a[6]) ||
|
---|
530 | (a[6] && a[10]) ))
|
---|
531 | size ++;
|
---|
532 | if (a[10] && ((a[9] && a[6]) ||
|
---|
533 | (a[6] && a[7]) ||
|
---|
534 | (a[7] && a[11]) ))
|
---|
535 | size ++;
|
---|
536 | if (a[11] && a[7] && a[10])
|
---|
537 | size ++;
|
---|
538 | }
|
---|
539 |
|
---|
540 | // case Lut 3
|
---|
541 | if (lut==2)
|
---|
542 | {
|
---|
543 | if (a[0] && a[1] && a[5])
|
---|
544 | size ++;
|
---|
545 | if (a[1] && ((a[0] && a[5]) ||
|
---|
546 | (a[5] && a[2]) ))
|
---|
547 | size ++;
|
---|
548 | if (a[2] && ((a[1] && a[5]) ||
|
---|
549 | (a[5] && a[6]) ||
|
---|
550 | (a[3] && a[4]) ||
|
---|
551 | (a[6] && a[3]) ))
|
---|
552 | size ++;
|
---|
553 | if (a[3] && ((a[2] && a[6]) ||
|
---|
554 | (a[6] && a[7]) ||
|
---|
555 | (a[2] && a[4]) ))
|
---|
556 | size ++;
|
---|
557 | if (a[4] && ((a[2] && a[3]) ))
|
---|
558 | size ++;
|
---|
559 | if (a[5] && ((a[1] && a[2]) ||
|
---|
560 | (a[2] && a[6]) ||
|
---|
561 | (a[6] && a[9]) ||
|
---|
562 | (a[9] && a[8]) ))
|
---|
563 | size ++;
|
---|
564 | if (a[6] && ((a[2] && a[3]) ||
|
---|
565 | (a[3] && a[7]) ||
|
---|
566 | (a[7] && a[10]) ||
|
---|
567 | (a[10] && a[9]) ||
|
---|
568 | (a[9] && a[5]) ||
|
---|
569 | (a[5] && a[2]) ))
|
---|
570 | size ++;
|
---|
571 | if (a[7] && ((a[3] && a[6]) ||
|
---|
572 | (a[6] && a[10]) ||
|
---|
573 | (a[10] && a[11]) ))
|
---|
574 | size ++;
|
---|
575 | if (a[8] && a[5] && a[9])
|
---|
576 | size ++;
|
---|
577 | if (a[9] && ((a[8] && a[5]) ||
|
---|
578 | (a[5] && a[6]) ||
|
---|
579 | (a[6] && a[10]) ))
|
---|
580 | size ++;
|
---|
581 | if (a[10] && ((a[9] && a[6]) ||
|
---|
582 | (a[6] && a[7]) ||
|
---|
583 | (a[7] && a[11]) ))
|
---|
584 | size ++;
|
---|
585 | if (a[11] && a[7] && a[10])
|
---|
586 | size ++;
|
---|
587 | }
|
---|
588 | }
|
---|
589 |
|
---|
590 | //
|
---|
591 | // Look for compact pixels 3NN
|
---|
592 | //
|
---|
593 | if (neighpix==3)
|
---|
594 | {
|
---|
595 | // case Lut 1 and 2
|
---|
596 | if (lut == 0 || lut == 1)
|
---|
597 | {
|
---|
598 | if (a[0] && a[1] && a[4] && a[5]) // pix 0 is compact if there is a 4NN
|
---|
599 | size ++;
|
---|
600 | if (a[1] && ((a[0] && a[4] && a[5]) ||
|
---|
601 | (a[2] && a[4] && a[5]) ))
|
---|
602 | size ++;
|
---|
603 | if (a[2] && ((a[1] && a[5] && a[6]) ||
|
---|
604 | (a[5] && a[6] && a[3]) ))
|
---|
605 | size ++;
|
---|
606 | if (a[3] && (a[2] && a[6] && a[7] ))
|
---|
607 | size ++;
|
---|
608 | if (a[4] && ((a[0] && a[1] && a[5]) ||
|
---|
609 | (a[1] && a[5] && a[8]) ))
|
---|
610 | size ++;
|
---|
611 | if (a[5] && ((a[1] && a[2] && a[6]) ||
|
---|
612 | (a[2] && a[6] && a[9]) ||
|
---|
613 | (a[6] && a[9] && a[8]) ||
|
---|
614 | (a[9] && a[8] && a[4]) ||
|
---|
615 | (a[8] && a[4] && a[1]) ||
|
---|
616 | (a[4] && a[1] && a[2]) ))
|
---|
617 | size ++;
|
---|
618 | if (a[6] && ((a[2] && a[3] && a[7]) ||
|
---|
619 | (a[3] && a[7] && a[10]) ||
|
---|
620 | (a[7] && a[10] && a[9]) ||
|
---|
621 | (a[10] && a[9] && a[5]) ||
|
---|
622 | (a[9] && a[5] && a[2]) ||
|
---|
623 | (a[5] && a[2] && a[3]) ))
|
---|
624 | size ++;
|
---|
625 | if (a[7] && ((a[3] && a[6] && a[10]) ||
|
---|
626 | (a[6] && a[10] && a[11]) ))
|
---|
627 | size ++;
|
---|
628 | if (a[8] && (a[4] && a[5] && a[9] ))
|
---|
629 | size ++;
|
---|
630 | if (a[9] && ((a[8] && a[5] && a[6]) ||
|
---|
631 | (a[5] && a[6] && a[10]) ))
|
---|
632 | size ++;
|
---|
633 | if (a[10] && ((a[9] && a[6] && a[7]) ||
|
---|
634 | (a[6] && a[7] && a[11]) ))
|
---|
635 | size ++;
|
---|
636 | if (a[11] && a[7] && a[10] && a[6]) //pix 0 is compact if there is a 4NN
|
---|
637 | size ++;
|
---|
638 | }
|
---|
639 |
|
---|
640 | // case Lut 3
|
---|
641 | if (lut==2)
|
---|
642 | {
|
---|
643 | if (a[0] && a[1] && a[5] && a[8]) // pix 0 is compact if there is a 4NN
|
---|
644 | size ++;
|
---|
645 | if (a[1] && (a[0] && a[5] && a[2])) //pix 0 is compact if there is a 4NN
|
---|
646 | size ++;
|
---|
647 | if (a[2] && ((a[1] && a[5] && a[6]) ||
|
---|
648 | (a[3] && a[5] && a[6]) ||
|
---|
649 | (a[6] && a[3] && a[4]) ))
|
---|
650 | size ++;
|
---|
651 | if (a[3] && ((a[2] && a[4] && a[6]) ||
|
---|
652 | (a[2] && a[6] && a[7]) ))
|
---|
653 | size ++;
|
---|
654 | if (a[4] && (a[2] && a[3] && a[6] ))
|
---|
655 | size ++;
|
---|
656 | if (a[5] && ((a[1] && a[2] && a[6]) ||
|
---|
657 | (a[2] && a[6] && a[9]) ||
|
---|
658 | (a[6] && a[9] && a[8]) ))
|
---|
659 | size ++;
|
---|
660 | if (a[6] && ((a[2] && a[3] && a[7]) ||
|
---|
661 | (a[3] && a[7] && a[10]) ||
|
---|
662 | (a[7] && a[10] && a[9]) ||
|
---|
663 | (a[10] && a[9] && a[5]) ||
|
---|
664 | (a[9] && a[5] && a[2]) ||
|
---|
665 | (a[5] && a[2] && a[3]) ))
|
---|
666 | size ++;
|
---|
667 | if (a[7] && ((a[3] && a[6] && a[10]) ||
|
---|
668 | (a[6] && a[10] && a[11]) ))
|
---|
669 | size ++;
|
---|
670 | if (a[8] && a[5] && a[9] && a[6]) //pix 0 is compact if there is a 4NN
|
---|
671 | size ++;
|
---|
672 | if (a[9] && ((a[8] && a[5] && a[6]) ||
|
---|
673 | (a[5] && a[6] && a[10]) ))
|
---|
674 | size ++;
|
---|
675 | if (a[10] && ((a[9] && a[6] && a[7]) ||
|
---|
676 | (a[6] && a[7] && a[11]) ))
|
---|
677 | size ++;
|
---|
678 | if (a[11] && a[7] && a[10] && a[6]) //pix 0 is compact if there is a 4NN
|
---|
679 | size ++;
|
---|
680 | }
|
---|
681 | }
|
---|
682 |
|
---|
683 |
|
---|
684 | if(size<0 ||size>12)
|
---|
685 | *fLog << "*" << size <<"-";
|
---|
686 |
|
---|
687 | return size;
|
---|
688 | }
|
---|
689 |
|
---|
690 |
|
---|
691 | // --------------------------------------------------------------------------
|
---|
692 | //
|
---|
693 | // Look for clusters and calculate the PseudoSize of one event,
|
---|
694 | // defined as the multiplicity of the bigger cluster.
|
---|
695 | //
|
---|
696 | //
|
---|
697 | //
|
---|
698 | void MMcTriggerLvl2::CalcPseudoSize()
|
---|
699 | {
|
---|
700 | // Fill the fCompactPixel array with the compact pixels
|
---|
701 | CalcCompactPixels(fGeomCam);
|
---|
702 |
|
---|
703 | // seek the LUT with higher number of compact pixels
|
---|
704 | //
|
---|
705 | int cellut = CalcBiggerLutPseudoSize();
|
---|
706 | int maxcell = cellut/10;
|
---|
707 | int maxlut = cellut - maxcell*10;
|
---|
708 | int startpix;
|
---|
709 |
|
---|
710 | //
|
---|
711 | // seek a starting pixel in the lut for the iteration
|
---|
712 | //
|
---|
713 | int check=1;
|
---|
714 | for (int pixlut=0;pixlut<12;pixlut++)
|
---|
715 | {
|
---|
716 | int pixcell =gsPixelsInLut[maxlut][pixlut];
|
---|
717 | startpix = gsPixelsInCell[pixcell][maxcell]-1;
|
---|
718 | *fLog << "pix, compact:" << startpix << "@"<<fCompactPixel[startpix];
|
---|
719 | if (fCompactPixel[startpix]) // a starting pixel was found
|
---|
720 | break;
|
---|
721 | check++;
|
---|
722 | }
|
---|
723 |
|
---|
724 | // A LUT contains 12 pixels
|
---|
725 | if (check >= 12)
|
---|
726 | {
|
---|
727 | *fLog <<"Error: a starting pixels was not found!"<<endl;
|
---|
728 | return;
|
---|
729 | }
|
---|
730 | //
|
---|
731 | // Bulding cluster
|
---|
732 | //
|
---|
733 | Int_t cluster[397];
|
---|
734 | int pnt=0;
|
---|
735 | int pnt2=0; //pointer in the array fCluster_pix, needed for filling
|
---|
736 |
|
---|
737 | memset (cluster,0,397*sizeof(Int_t));
|
---|
738 | memset (fCluster_pix,-1,397*sizeof(Int_t));
|
---|
739 |
|
---|
740 | cluster[startpix]=1;
|
---|
741 | fCluster_pix[0]=startpix; //the starting pix is the first in cluster
|
---|
742 |
|
---|
743 | // Look at neighbour pixs if they are compact (iterative search)
|
---|
744 | // until the array (fCluster_pix) has no more compact pixels.
|
---|
745 | // pnt points to the pixel in the array fCluster_pix whose neighbors are
|
---|
746 | // under study; pnt2 points to the last element of this array.
|
---|
747 | //
|
---|
748 | while (fCluster_pix[pnt] != -1)
|
---|
749 | {
|
---|
750 | const MGeomPix &pix=(*fGeomCam)[fCluster_pix[pnt]];
|
---|
751 |
|
---|
752 | for (int i=0;i<pix.GetNumNeighbors();i++)
|
---|
753 | {
|
---|
754 | int pix_neigh = pix.GetNeighbor(i);
|
---|
755 | // check if pixel is fired and doesn't belong to cluster
|
---|
756 | if (fFiredPixel[pix_neigh] && !cluster[pix_neigh])
|
---|
757 | {
|
---|
758 | cluster[pix_neigh] = 1;
|
---|
759 | fCluster_pix[++pnt2] = pix_neigh;
|
---|
760 | }
|
---|
761 | }
|
---|
762 | pnt++;
|
---|
763 | }
|
---|
764 |
|
---|
765 | fPseudoSize = pnt;
|
---|
766 |
|
---|
767 | // *fLog << "ClusterID:" <<(*clust).GetClusterId() << " Mult:" << (*clust).GetMultiplicity()<<endl;
|
---|
768 |
|
---|
769 | *fLog <<"PSize: "<< fPseudoSize << " in cell:" << maxcell << " lut:" <<maxlut <<endl;
|
---|
770 |
|
---|
771 | return;
|
---|
772 | }
|
---|
773 |
|
---|
774 | // --------------------------------------------------------------------------
|
---|
775 | //
|
---|
776 | // Fill the fCompactPixels array with the pixels which are compact
|
---|
777 | //
|
---|
778 | // neighpix is the number of Next-Neighbors which defines the compact pixel
|
---|
779 | // topology (it can be 2-NN or 3-NN)
|
---|
780 | //
|
---|
781 | // Note: it is a *global* method; it looks in the all camera as a whole
|
---|
782 | //
|
---|
783 | //
|
---|
784 | void MMcTriggerLvl2::CalcCompactPixels(MGeomCam *geom)
|
---|
785 | {
|
---|
786 | memset (fCompactPixel,0,397*sizeof(Int_t));
|
---|
787 |
|
---|
788 | for(UInt_t pixid=0;pixid<397;pixid++)
|
---|
789 | {
|
---|
790 | // Look if the pixel is fired, otherwise continue
|
---|
791 | if (!fFiredPixel[pixid])
|
---|
792 | continue;
|
---|
793 |
|
---|
794 | const MGeomPix &pix=(*geom)[pixid];
|
---|
795 |
|
---|
796 | // Look for compact pixels.
|
---|
797 | // A compact pixel must have at least fCompactNN adjacent neighbors
|
---|
798 | // It checks the 6 different configurations of neighbors pixels
|
---|
799 | for (int i=0;i<pix.GetNumNeighbors();i++)
|
---|
800 | {
|
---|
801 | int j=0;
|
---|
802 | while (fFiredPixel[pix.GetNeighbor(i+j)]==1 && j < fCompactNN)
|
---|
803 | j++;
|
---|
804 | if (j!=fCompactNN) continue; // configuration doesn't satisfy compact condition
|
---|
805 |
|
---|
806 | fCompactPixel[pixid]=1; // pixel is compact
|
---|
807 |
|
---|
808 | *fLog << ","<<pixid;
|
---|
809 |
|
---|
810 | break;
|
---|
811 | }
|
---|
812 | }
|
---|
813 | }
|
---|
814 |
|
---|
815 |
|
---|
816 |
|
---|